diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 749ab62c5..000000000 --- a/.drone.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -kind: pipeline -type: docker -name: EQEmulator Server Linux CI - -# Limits how many of these builds can run on the drone runner at a time, this isn't about cores -concurrency: - limit: 1 - -steps: - - name: server-build - # Source build script https://github.com/Akkadius/akk-stack/blob/master/containers/eqemu-server/Dockerfile#L20 - image: akkadius/eqemu-server:latest - commands: - - sudo chown eqemu:eqemu /drone/src/ * -R - - git submodule init && git submodule update && mkdir -p build && cd build && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_BOTS=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' .. && make -j$((`nproc`-4)) \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a955aa60c..1c6e5c871 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ { "label": "make", "type": "shell", - "command": "cd bin && make", + "command": "cd build && make", "group": { "kind": "build", "isDefault": true @@ -18,7 +18,7 @@ { "label": "make clean", "type": "shell", - "command": "cd bin && make clean", + "command": "cd build && make clean", "group": { "kind": "build", "isDefault": true @@ -30,7 +30,7 @@ { "label": "cmake", "type": "shell", - "command": "mkdir -p bin && cd bin && rm CMakeCache.txt && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' ..", + "command": "mkdir -p build && cd build && rm CMakeCache.txt && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' ..", "group": { "kind": "build", "isDefault": true @@ -52,7 +52,7 @@ { "label": "download maps", "type": "shell", - "command": "mkdir -p bin && cd bin && wget https://codeload.github.com/Akkadius/EQEmuMaps/zip/master -O maps.zip && unzip -o maps.zip && rm ./maps -rf && mv EQEmuMaps-master maps && rm maps.zip", + "command": "mkdir -p build/bin && cd build/bin && wget https://codeload.github.com/Akkadius/EQEmuMaps/zip/master -O maps.zip && unzip -o maps.zip && rm ./maps -rf && mv EQEmuMaps-master maps && rm maps.zip", "group": { "kind": "build", "isDefault": true @@ -64,7 +64,7 @@ { "label": "download quests", "type": "shell", - "command": "mkdir -p bin && cd bin && cd server && git -C ./quests pull 2> /dev/null || git clone https://github.com/ProjectEQ/projecteqquests.git quests", + "command": "mkdir -p build/bin && cd build/bin && cd server && git -C ./quests pull 2> /dev/null || git clone https://github.com/ProjectEQ/projecteqquests.git quests", "group": { "kind": "build", "isDefault": true @@ -76,7 +76,7 @@ { "label": "download eqemu_config", "type": "shell", - "command": "mkdir -p bin && cd bin && wget --no-check-certificate https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/eqemu_config_docker.json -O eqemu_config.json", + "command": "mkdir -p build/bin && cd build/bin && wget --no-check-certificate https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/eqemu_config_docker.json -O eqemu_config.json", "group": { "kind": "build", "isDefault": true @@ -88,7 +88,7 @@ { "label": "rebuild database (mariadb must be started)", "type": "shell", - "command": "mkdir -p bin && cd bin && docker run -i --rm --privileged -v ${HOST_PROJECT_PATH}/bin:/src --network=eqemu -it eqemu/server:0.0.3 bash -c './eqemu_server.pl source_peq_db && ./eqemu_server.pl check_db_updates && ./eqemu_server.pl linux_login_server_setup'", + "command": "mkdir -p build/bin && cd build/bin && docker run -i --rm --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --network=eqemu -it eqemu/server:0.0.3 bash -c './eqemu_server.pl source_peq_db && ./eqemu_server.pl check_db_updates && ./eqemu_server.pl linux_login_server_setup'", "group": { "kind": "build", "isDefault": true @@ -100,7 +100,7 @@ { "label": "zone 7000", "type": "shell", - "command": "docker stop zone7000 | true && docker network create eqemu | true && docker run -i --rm --name zone7000 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu -p 7000:7000/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7000:7000", + "command": "docker stop zone7000 | true && docker network create eqemu | true && docker run -i --rm --name zone7000 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu -p 7000:7000/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7000:7000", "group": { "kind": "test", "isDefault": true @@ -109,7 +109,7 @@ { "label": "zone 7001", "type": "shell", - "command": "docker stop zone7001 | true && docker network create eqemu | true && docker run -i --rm --name zone7001 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu -p 7001:7001/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7001:7001", + "command": "docker stop zone7001 | true && docker network create eqemu | true && docker run -i --rm --name zone7001 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu -p 7001:7001/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7001:7001", "group": { "kind": "test", "isDefault": true @@ -118,7 +118,7 @@ { "label": "loginserver", "type": "shell", - "command": "docker stop loginserver | true && docker network create eqemu | true && docker run -i --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu --name loginserver -p 5999:5999/udp -p 5998:5998/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./loginserver", + "command": "docker stop loginserver | true && docker network create eqemu | true && docker run -i --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu --name loginserver -p 5999:5999/udp -p 5998:5998/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./loginserver", "group": { "kind": "test", "isDefault": true @@ -127,7 +127,7 @@ { "label": "shared_memory, world", "type": "shell", - "command": "docker stop sharedmemory | true && docker stop world | true && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --network=eqemu --name sharedmemory eqemu/server:0.0.3 ./shared_memory && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name world -p 9000:9000 -p 9000:9000/udp -p 9001:9001 -p 9080:9080 eqemu/server:0.0.3 gdb -ex run ./world", + "command": "docker stop sharedmemory | true && docker stop world | true && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --network=eqemu --name sharedmemory eqemu/server:0.0.3 ./shared_memory && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name world -p 9000:9000 -p 9000:9000/udp -p 9001:9001 -p 9080:9080 eqemu/server:0.0.3 gdb -ex run ./world", "group": { "kind": "test", "isDefault": true @@ -136,7 +136,7 @@ { "label": "queryserv", "type": "shell", - "command": "docker stop queryserv | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name queryserv eqemu/server:0.0.3 gdb -ex run ./queryserv", + "command": "docker stop queryserv | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name queryserv eqemu/server:0.0.3 gdb -ex run ./queryserv", "group": { "kind": "test", "isDefault": true @@ -145,16 +145,7 @@ { "label": "mariadb", "type": "shell", - "command": "docker stop mariadb | true && cd bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin/db:/bitnami/mariadb -p 3306:3306 -e MARIADB_DATABASE=peq -e MARIADB_USER=eqemu -e MARIADB_PASSWORD=eqemupass -e ALLOW_EMPTY_PASSWORD=yes --name mariadb --network=eqemu bitnami/mariadb:latest", - "group": { - "kind": "test", - "isDefault": true - } - }, - { - "label": "ucs", - "type": "shell", - "command": "docker stop ucs | true && cd bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src -p 7778:7778 --name ucs --network=eqemu eqemu/server:0.0.3 gdb -ex run ./ucs", + "command": "docker stop mariadb | true && cd build/bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin/db:/bitnami/mariadb -p 3306:3306 -e MARIADB_DATABASE=peq -e MARIADB_USER=eqemu -e MARIADB_PASSWORD=eqemupass -e ALLOW_EMPTY_PASSWORD=yes --name mariadb --network=eqemu bitnami/mariadb:latest", "group": { "kind": "test", "isDefault": true diff --git a/CMakeLists.txt b/CMakeLists.txt index 526d68099..24816a323 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) -SET(CMAKE_CXX_STANDARD 14) +SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_CXX_EXTENSIONS OFF) @@ -55,7 +55,6 @@ FIND_PACKAGE(MariaDB) FIND_PACKAGE(ZLIB) FIND_PACKAGE(OpenSSL) FIND_PACKAGE(Lua51) -FIND_PACKAGE(LuaJit) FIND_PACKAGE(PerlLibs) FIND_PACKAGE(Sodium) FIND_PACKAGE(mbedTLS) @@ -88,12 +87,6 @@ ELSE() MESSAGE(STATUS "* Lua: MISSING *") ENDIF() -IF(LuaJit_FOUND) - MESSAGE(STATUS "* LuaJIT: FOUND *") -ELSE() - MESSAGE(STATUS "* LuaJIT: MISSING *") -ENDIF() - IF(PerlLibs_FOUND) MESSAGE(STATUS "* Perl: FOUND *") ELSE() @@ -129,7 +122,6 @@ OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON) OPTION(EQEMU_BUILD_HC "Build the headless client." OFF) OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF) OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON) -OPTION(EQEMU_PREFER_LUA "Build with normal Lua even if LuaJIT is found." OFF) IF(EQEMU_COMMANDS_LOGGING) ADD_DEFINITIONS(-DCOMMANDS_LOGGING) @@ -220,12 +212,7 @@ ELSE() SET(SODIUM_LIBRARY_ENABLED OFF) ENDIF() -IF(LUAJIT_FOUND AND NOT (EQEMU_PREFER_LUA AND Lua51_FOUND)) - SET(LUA_LIBRARY_TYPE " LuaJIT") - SET(LUA_LIBRARY_ENABLED ON) - SET(LUA_LIBRARY_LIBS ${LUAJIT_LIBRARY} luabind) - SET(LUA_LIBRARY_INCLUDE ${LUAJIT_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind") -ELSEIF(Lua51_FOUND ) +IF(Lua51_FOUND) SET(LUA_LIBRARY_TYPE " Lua 5.1") SET(LUA_LIBRARY_ENABLED ON) SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind) @@ -252,7 +239,6 @@ IF(ZLIB_FOUND) SET(ZLIB_LIBRARY_TYPE "zlib-ng") SET(ZLIB_LIBRARY_LIBS "zlibstatic") SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng") - INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng") ELSE() SET(ZLIB_LIBRARY_TYPE " zlib") SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY}) @@ -313,7 +299,7 @@ IF(LUA_LIBRARY_ENABLED) IF(EQEMU_BUILD_LUA) ADD_DEFINITIONS(-DLUA_EQEMU) - SET(ZONE_LIBS ${LUA_LIBRARY_LIBS}) + SET(SERVER_LIBS ${SERVER_LIBS} ${LUA_LIBRARY_LIBS}) INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}") OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON) @@ -348,8 +334,6 @@ IF(UNIX) ENDIF() ENDIF() -SET(ZONE_LIBS ${ZONE_LIBS} ${SERVER_LIBS}) - IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED) MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.") ENDIF() diff --git a/README.md b/README.md index fea2c23a4..e999b7050 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,3 @@ forum, although pull requests will be much quicker and easier on all parties. - diff --git a/appveyor-bots.yml b/appveyor-bots.yml index 540d9b3df..9edb00593 100644 --- a/appveyor-bots.yml +++ b/appveyor-bots.yml @@ -16,6 +16,6 @@ build: verbosity: minimal after_build: - cmd: >- - 7z a build_x64-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb C:\projects\eqemu\build\libs\zlibng\RelWithDebInfo\*.dll + 7z a build_x64-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb - appveyor PushArtifact build_x64-bots.zip + appveyor PushArtifact build_x64-bots.zip \ No newline at end of file diff --git a/appveyor-no-bots.yml b/appveyor-no-bots.yml index 0b0f5b8a2..7aea00332 100644 --- a/appveyor-no-bots.yml +++ b/appveyor-no-bots.yml @@ -16,6 +16,6 @@ build: verbosity: minimal after_build: - cmd: >- - 7z a build_x64-no-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb C:\projects\eqemu\build\libs\zlibng\RelWithDebInfo\*.dll + 7z a build_x64-no-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb - appveyor PushArtifact build_x64-no-bots.zip + appveyor PushArtifact build_x64-no-bots.zip \ No newline at end of file diff --git a/cmake/FindLua51.cmake b/cmake/FindLua51.cmake index 0aab2bb82..47fa0aaae 100644 --- a/cmake/FindLua51.cmake +++ b/cmake/FindLua51.cmake @@ -38,7 +38,7 @@ locations other than lua/ find_path(LUA_INCLUDE_DIR lua.h HINTS ENV LUA_DIR - PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include + PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include/luajit include PATHS ~/Library/Frameworks /Library/Frameworks @@ -49,7 +49,7 @@ find_path(LUA_INCLUDE_DIR lua.h ) find_library(LUA_LIBRARY - NAMES lua51 lua5.1 lua-5.1 lua + NAMES lua51 lua5.1 lua-5.1 lua luajit HINTS ENV LUA_DIR PATH_SUFFIXES lib diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake deleted file mode 100644 index a7376dee1..000000000 --- a/cmake/FindLuaJit.cmake +++ /dev/null @@ -1,91 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. -# Modified from the FindLua51 that comes with CMake - -#[=======================================================================[.rst: -FindLuaJit ---------- - - - -Locate LuaJit library This module defines - -:: - - LUAJIT_FOUND, if false, do not try to link to Lua - LUAJIT_LIBRARIES - LUAJIT_INCLUDE_DIR, where to find lua.h - LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8) - - - -Note that the expected include convention is - -:: - - #include "lua.h" - -and not - -:: - - #include - -This is because, the lua location is not standardized and may exist in -locations other than lua/ -#]=======================================================================] - -find_path(LUAJIT_INCLUDE_DIR lua.h - HINTS - ENV LUA_DIR - PATH_SUFFIXES include/luajit include/luajit-2.0 include/luajit-2.1 include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -) - -find_library(LUAJIT_LIBRARY - NAMES luajit51 luajit5.1 luajit-5.1 luajit lua51 - HINTS - ENV LUA_DIR - PATH_SUFFIXES lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw - /opt/local - /opt/csw - /opt -) - -if(LUAJIT_LIBRARY) - # include the math library for Unix - if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU) - find_library(LUAJIT_MATH_LIBRARY m) - set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY};${LUAJIT_MATH_LIBRARY}" CACHE STRING "Lua Libraries") - # For Windows and Mac, don't need to explicitly include the math library - else() - set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}" CACHE STRING "Lua Libraries") - endif() -endif() - -if(LUAJIT_INCLUDE_DIR AND EXISTS "${LUAJIT_INCLUDE_DIR}/lua.h") - file(STRINGS "${LUAJIT_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"") - - string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${lua_version_str}") - unset(lua_version_str) -endif() - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if -# all listed variables are TRUE -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit - REQUIRED_VARS LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR - VERSION_VAR LUAJIT_VERSION_STRING) - -mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY) - diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 08db08585..702f2c867 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -16,7 +16,6 @@ SET(common_sources database_instances.cpp dbcore.cpp deity.cpp - dynamic_zone_base.cpp emu_constants.cpp emu_limits.cpp emu_opcodes.cpp @@ -32,8 +31,6 @@ SET(common_sources eq_stream_proxy.cpp eqtime.cpp event_sub.cpp - expedition_base.cpp - expedition_lockout_timer.cpp extprofile.cpp faction.cpp file_util.cpp @@ -70,7 +67,6 @@ SET(common_sources rulesys.cpp say_link.cpp serialize_buffer.cpp - server_event_scheduler.cpp serverinfo.cpp shareddb.cpp skills.cpp @@ -152,7 +148,6 @@ SET(repositories repositories/base/base_character_currency_repository.h repositories/base/base_character_data_repository.h repositories/base/base_character_disciplines_repository.h - repositories/base/base_character_expedition_lockouts_repository.h repositories/base/base_character_inspect_messages_repository.h repositories/base/base_character_item_recast_repository.h repositories/base/base_character_languages_repository.h @@ -171,16 +166,11 @@ SET(repositories repositories/base/base_char_recipe_list_repository.h repositories/base/base_completed_tasks_repository.h repositories/base/base_content_flags_repository.h - repositories/base/base_damageshieldtypes_repository.h repositories/base/base_data_buckets_repository.h repositories/base/base_db_str_repository.h repositories/base/base_discovered_items_repository.h repositories/base/base_doors_repository.h - repositories/base/base_dynamic_zones_repository.h repositories/base/base_eventlog_repository.h - repositories/base/base_expeditions_repository.h - repositories/base/base_expedition_lockouts_repository.h - repositories/base/base_expedition_members_repository.h repositories/base/base_faction_base_data_repository.h repositories/base/base_faction_list_repository.h repositories/base/base_faction_list_mod_repository.h @@ -254,7 +244,6 @@ SET(repositories repositories/base/base_rule_sets_repository.h repositories/base/base_rule_values_repository.h repositories/base/base_saylink_repository.h - repositories/base/base_server_scheduled_events_repository.h repositories/base/base_skill_caps_repository.h repositories/base/base_spawn2_repository.h repositories/base/base_spawnentry_repository.h @@ -278,6 +267,7 @@ SET(repositories repositories/base/base_traps_repository.h repositories/base/base_tributes_repository.h repositories/base/base_tribute_levels_repository.h + repositories/base/base_variables_repository.h repositories/base/base_veteran_reward_templates_repository.h repositories/base/base_zone_repository.h repositories/base/base_zone_points_repository.h @@ -316,7 +306,6 @@ SET(repositories repositories/character_currency_repository.h repositories/character_data_repository.h repositories/character_disciplines_repository.h - repositories/character_expedition_lockouts_repository.h repositories/character_inspect_messages_repository.h repositories/character_item_recast_repository.h repositories/character_languages_repository.h @@ -335,16 +324,11 @@ SET(repositories repositories/char_recipe_list_repository.h repositories/completed_tasks_repository.h repositories/content_flags_repository.h - repositories/damageshieldtypes_repository.h repositories/data_buckets_repository.h repositories/db_str_repository.h repositories/discovered_items_repository.h repositories/doors_repository.h - repositories/dynamic_zones_repository.h repositories/eventlog_repository.h - repositories/expeditions_repository.h - repositories/expedition_lockouts_repository.h - repositories/expedition_members_repository.h repositories/faction_base_data_repository.h repositories/faction_list_repository.h repositories/faction_list_mod_repository.h @@ -418,7 +402,6 @@ SET(repositories repositories/rule_sets_repository.h repositories/rule_values_repository.h repositories/saylink_repository.h - repositories/server_scheduled_events_repository.h repositories/skill_caps_repository.h repositories/spawn2_repository.h repositories/spawnentry_repository.h @@ -442,6 +425,7 @@ SET(repositories repositories/traps_repository.h repositories/tributes_repository.h repositories/tribute_levels_repository.h + repositories/variables_repository.h repositories/veteran_reward_templates_repository.h repositories/zone_repository.h repositories/zone_points_repository.h @@ -465,14 +449,12 @@ SET(common_headers cli/argh.h cli/eqemu_command_handler.h cli/terminal_color.hpp - cron/croncpp.h database/database_dump_service.h data_verification.h database.h database_schema.h dbcore.h deity.h - dynamic_zone_base.h emu_constants.h emu_limits.h emu_opcodes.h @@ -496,8 +478,6 @@ SET(common_headers eqtime.h errmsg.h event_sub.h - expedition_base.h - expedition_lockout_timer.h extprofile.h faction.h file_util.h @@ -549,7 +529,6 @@ SET(common_headers say_link.h seperator.h serialize_buffer.h - server_event_scheduler.h serverinfo.h servertalk.h shareddb.h diff --git a/common/classes.cpp b/common/classes.cpp index b9445443f..3aaeeded3 100644 --- a/common/classes.cpp +++ b/common/classes.cpp @@ -378,8 +378,6 @@ const char *GetClassIDName(uint8 class_id, uint8 level) return "Berserker Guildmaster"; case MERCHANT: return "Merchant"; - case DISCORD_MERCHANT: - return "Discord Merchant"; case ADVENTURERECRUITER: return "Adventure Recruiter"; case ADVENTUREMERCHANT: @@ -390,18 +388,6 @@ const char *GetClassIDName(uint8 class_id, uint8 level) return "Tribute Master"; case GUILD_TRIBUTE_MASTER: return "Guild Tribute Master"; - case GUILD_BANKER: - return "Guild Banker"; - case NORRATHS_KEEPERS_MERCHANT: - return "Radiant Crystal Merchant"; - case DARK_REIGN_MERCHANT: - return "Ebon Crystal Merchant"; - case FELLOWSHIP_MASTER: - return "Fellowship Master"; - case ALT_CURRENCY_MERCHANT: - return "Alternate Currency Merchant"; - case MERCERNARY_MASTER: - return "Mercenary Liaison"; default: return "Unknown"; } diff --git a/common/classes.h b/common/classes.h index a35014d94..f63758937 100644 --- a/common/classes.h +++ b/common/classes.h @@ -61,7 +61,6 @@ #define CORPSE_CLASS 62 // only seen on Danvi's Corpse in Akheva so far.. #define TRIBUTE_MASTER 63 #define GUILD_TRIBUTE_MASTER 64 // not sure -#define GUILD_BANKER 66 #define NORRATHS_KEEPERS_MERCHANT 67 #define DARK_REIGN_MERCHANT 68 #define FELLOWSHIP_MASTER 69 diff --git a/common/content/world_content_service.cpp b/common/content/world_content_service.cpp index feb0f5b76..949ebcc0d 100644 --- a/common/content/world_content_service.cpp +++ b/common/content/world_content_service.cpp @@ -22,7 +22,6 @@ #include "../database.h" #include "../rulesys.h" #include "../eqemu_logsys.h" -#include "../repositories/content_flags_repository.h" WorldContentService::WorldContentService() @@ -100,21 +99,3 @@ bool WorldContentService::IsContentFlagEnabled(const std::string& content_flag) return false; } - -void WorldContentService::ReloadContentFlags(Database &db) -{ - std::vector set_content_flags; - auto content_flags = ContentFlagsRepository::GetWhere(db, "enabled = 1"); - - set_content_flags.reserve(content_flags.size()); - for (auto &flags: content_flags) { - set_content_flags.push_back(flags.flag_name); - } - - LogInfo( - "Enabled content flags [{}]", - implode(", ", set_content_flags) - ); - - SetContentFlags(set_content_flags); -} diff --git a/common/content/world_content_service.h b/common/content/world_content_service.h index 47220b349..662ec20cc 100644 --- a/common/content/world_content_service.h +++ b/common/content/world_content_service.h @@ -24,8 +24,6 @@ #include #include -class Database; - namespace Expansion { static const int EXPANSION_ALL = -1; static const int EXPANSION_FILTER_MAX = 99; @@ -104,33 +102,33 @@ public: int GetCurrentExpansion() const; void SetCurrentExpansion(int current_expansion); - bool IsClassicEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Classic || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheRuinsOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheRuinsOfKunark || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheScarsOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheScarsOfVelious || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheShadowsOfLuclinEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheShadowsOfLuclin || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsThePlanesOfPowerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ThePlanesOfPower || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheLegacyOfYkeshaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheLegacyOfYkesha || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsLostDungeonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::LostDungeonsOfNorrath || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsGatesOfDiscordEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::GatesOfDiscord || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsOmensOfWarEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::OmensOfWar || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsDragonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DragonsOfNorrath || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsDepthsOfDarkhollowEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DepthsOfDarkhollow || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsProphecyOfRoEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ProphecyOfRo || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheSerpentsSpineEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheSerpentsSpine || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheBuriedSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBuriedSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsSecretsOfFaydwerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SecretsOfFaydwer || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsSeedsOfDestructionEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SeedsOfDestruction || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsUnderfootEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Underfoot || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsHouseOfThuleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::HouseOfThule || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsVeilOfAlarisEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::VeilOfAlaris || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsRainOfFearEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RainOfFear || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsCallOfTheForsakenEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::CallOfTheForsaken || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheDarkendSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheDarkendSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheBrokenMirrorEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBrokenMirror || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsEmpiresOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::EmpiresOfKunark || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsRingOfScaleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RingOfScale || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTheBurningLandsEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBurningLands || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } - bool IsTormentOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TormentOfVelious || GetCurrentExpansion() == Expansion::EXPANSION_ALL; } + bool IsClassicEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Classic; } + bool IsTheRuinsOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheRuinsOfKunark; } + bool IsTheScarsOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheScarsOfVelious; } + bool IsTheShadowsOfLuclinEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheShadowsOfLuclin; } + bool IsThePlanesOfPowerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ThePlanesOfPower; } + bool IsTheLegacyOfYkeshaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheLegacyOfYkesha; } + bool IsLostDungeonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::LostDungeonsOfNorrath; } + bool IsGatesOfDiscordEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::GatesOfDiscord; } + bool IsOmensOfWarEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::OmensOfWar; } + bool IsDragonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DragonsOfNorrath; } + bool IsDepthsOfDarkhollowEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DepthsOfDarkhollow; } + bool IsProphecyOfRoEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ProphecyOfRo; } + bool IsTheSerpentsSpineEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheSerpentsSpine; } + bool IsTheBuriedSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBuriedSea; } + bool IsSecretsOfFaydwerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SecretsOfFaydwer; } + bool IsSeedsOfDestructionEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SeedsOfDestruction; } + bool IsUnderfootEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Underfoot; } + bool IsHouseOfThuleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::HouseOfThule; } + bool IsVeilOfAlarisEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::VeilOfAlaris; } + bool IsRainOfFearEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RainOfFear; } + bool IsCallOfTheForsakenEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::CallOfTheForsaken; } + bool IsTheDarkendSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheDarkendSea; } + bool IsTheBrokenMirrorEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBrokenMirror; } + bool IsEmpiresOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::EmpiresOfKunark; } + bool IsRingOfScaleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RingOfScale; } + bool IsTheBurningLandsEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBurningLands; } + bool IsTormentOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TormentOfVelious; } bool IsCurrentExpansionClassic() { return current_expansion == Expansion::ExpansionNumber::Classic; } bool IsCurrentExpansionTheRuinsOfKunark() { return current_expansion == Expansion::ExpansionNumber::TheRuinsOfKunark; } @@ -167,7 +165,6 @@ public: const std::vector &GetContentFlags() const; bool IsContentFlagEnabled(const std::string& content_flag); void SetContentFlags(std::vector content_flags); - void ReloadContentFlags(Database &db); void SetExpansionContext(); }; diff --git a/common/cron/croncpp.h b/common/cron/croncpp.h deleted file mode 100644 index 5a22a7f72..000000000 --- a/common/cron/croncpp.h +++ /dev/null @@ -1,876 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#if __cplusplus > 201402L -#include -#define CRONCPP_IS_CPP17 -#endif - -namespace cron -{ -#ifdef CRONCPP_IS_CPP17 - #define HAS_STRING_VIEW - #define STRING_VIEW std::string_view - #define STRING_VIEW_NPOS std::string_view::npos - #define CONSTEXPTR constexpr -#else -#define STRING_VIEW std::string const & -#define STRING_VIEW_NPOS std::string::npos -#define CONSTEXPTR -#endif - - using cron_int = uint8_t; - - constexpr std::time_t INVALID_TIME = static_cast(-1); - - constexpr size_t INVALID_CRON_INDEX = static_cast(-1); - - class cronexpr; - - namespace detail - { - enum class cron_field - { - second, - minute, - hour_of_day, - day_of_week, - day_of_month, - month, - year - }; - - template - static bool find_next(cronexpr const & cex, - std::tm& date, - size_t const dot); - } - - struct bad_cronexpr : public std::runtime_error - { - public: - explicit bad_cronexpr(STRING_VIEW message) : - std::runtime_error(message.data()) - {} - }; - - - struct cron_standard_traits - { - static const cron_int CRON_MIN_SECONDS = 0; - static const cron_int CRON_MAX_SECONDS = 59; - - static const cron_int CRON_MIN_MINUTES = 0; - static const cron_int CRON_MAX_MINUTES = 59; - - static const cron_int CRON_MIN_HOURS = 0; - static const cron_int CRON_MAX_HOURS = 23; - - static const cron_int CRON_MIN_DAYS_OF_WEEK = 0; - static const cron_int CRON_MAX_DAYS_OF_WEEK = 6; - - static const cron_int CRON_MIN_DAYS_OF_MONTH = 1; - static const cron_int CRON_MAX_DAYS_OF_MONTH = 31; - - static const cron_int CRON_MIN_MONTHS = 1; - static const cron_int CRON_MAX_MONTHS = 12; - - static const cron_int CRON_MAX_YEARS_DIFF = 4; - -#ifdef CRONCPP_IS_CPP17 - static const inline std::vector DAYS = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - static const inline std::vector MONTHS = { "NIL", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; -#else - static std::vector& DAYS() - { - static std::vector days = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - return days; - } - - static std::vector& MONTHS() - { - static std::vector months = { "NIL", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; - return months; - } -#endif - }; - - struct cron_oracle_traits - { - static const cron_int CRON_MIN_SECONDS = 0; - static const cron_int CRON_MAX_SECONDS = 59; - - static const cron_int CRON_MIN_MINUTES = 0; - static const cron_int CRON_MAX_MINUTES = 59; - - static const cron_int CRON_MIN_HOURS = 0; - static const cron_int CRON_MAX_HOURS = 23; - - static const cron_int CRON_MIN_DAYS_OF_WEEK = 1; - static const cron_int CRON_MAX_DAYS_OF_WEEK = 7; - - static const cron_int CRON_MIN_DAYS_OF_MONTH = 1; - static const cron_int CRON_MAX_DAYS_OF_MONTH = 31; - - static const cron_int CRON_MIN_MONTHS = 0; - static const cron_int CRON_MAX_MONTHS = 11; - - static const cron_int CRON_MAX_YEARS_DIFF = 4; - -#ifdef CRONCPP_IS_CPP17 - static const inline std::vector DAYS = { "NIL", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - static const inline std::vector MONTHS = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; -#else - - static std::vector& DAYS() - { - static std::vector days = { "NIL", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - return days; - } - - static std::vector& MONTHS() - { - static std::vector months = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; - return months; - } -#endif - }; - - struct cron_quartz_traits - { - static const cron_int CRON_MIN_SECONDS = 0; - static const cron_int CRON_MAX_SECONDS = 59; - - static const cron_int CRON_MIN_MINUTES = 0; - static const cron_int CRON_MAX_MINUTES = 59; - - static const cron_int CRON_MIN_HOURS = 0; - static const cron_int CRON_MAX_HOURS = 23; - - static const cron_int CRON_MIN_DAYS_OF_WEEK = 1; - static const cron_int CRON_MAX_DAYS_OF_WEEK = 7; - - static const cron_int CRON_MIN_DAYS_OF_MONTH = 1; - static const cron_int CRON_MAX_DAYS_OF_MONTH = 31; - - static const cron_int CRON_MIN_MONTHS = 1; - static const cron_int CRON_MAX_MONTHS = 12; - - static const cron_int CRON_MAX_YEARS_DIFF = 4; - -#ifdef CRONCPP_IS_CPP17 - static const inline std::vector DAYS = { "NIL", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - static const inline std::vector MONTHS = { "NIL", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; -#else - static std::vector& DAYS() - { - static std::vector days = { "NIL", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - return days; - } - - static std::vector& MONTHS() - { - static std::vector months = { "NIL", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; - return months; - } -#endif - }; - - class cronexpr; - - template - static cronexpr make_cron(STRING_VIEW expr); - - class cronexpr - { - std::bitset<60> seconds; - std::bitset<60> minutes; - std::bitset<24> hours; - std::bitset<7> days_of_week; - std::bitset<31> days_of_month; - std::bitset<12> months; - - friend bool operator==(cronexpr const & e1, cronexpr const & e2); - friend bool operator!=(cronexpr const & e1, cronexpr const & e2); - - template - friend bool detail::find_next(cronexpr const & cex, - std::tm& date, - size_t const dot); - - friend std::string to_string(cronexpr const & cex); - - template - friend cronexpr make_cron(STRING_VIEW expr); - }; - - inline bool operator==(cronexpr const & e1, cronexpr const & e2) - { - return - e1.seconds == e2.seconds && - e1.minutes == e2.minutes && - e1.hours == e2.hours && - e1.days_of_week == e2.days_of_week && - e1.days_of_month == e2.days_of_month && - e1.months == e2.months; - } - - inline bool operator!=(cronexpr const & e1, cronexpr const & e2) - { - return !(e1 == e2); - } - - inline std::string to_string(cronexpr const & cex) - { - return - cex.seconds.to_string() + " " + - cex.minutes.to_string() + " " + - cex.hours.to_string() + " " + - cex.days_of_month.to_string() + " " + - cex.months.to_string() + " " + - cex.days_of_week.to_string(); - } - - namespace utils - { - inline std::time_t tm_to_time(std::tm& date) - { - return std::mktime(&date); - } - - inline std::tm* time_to_tm(std::time_t const * date, std::tm* const out) - { -#ifdef _WIN32 - errno_t err = localtime_s(out, date); - return 0 == err ? out : nullptr; -#else - return localtime_r(date, out); -#endif - } - - inline std::tm to_tm(STRING_VIEW time) - { - std::istringstream str(time.data()); - str.imbue(std::locale(setlocale(LC_ALL, nullptr))); - - std::tm result; - str >> std::get_time(&result, "%Y-%m-%d %H:%M:%S"); - if (str.fail()) throw std::runtime_error("Parsing date failed!"); - - result.tm_isdst = -1; // DST info not available - - return result; - } - - inline std::string to_string(std::tm const & tm) - { - std::ostringstream str; - str.imbue(std::locale(setlocale(LC_ALL, nullptr))); - str << std::put_time(&tm, "%Y-%m-%d %H:%M:%S"); - if (str.fail()) throw std::runtime_error("Writing date failed!"); - - return str.str(); - } - - inline std::string to_upper(std::string text) - { - std::transform(std::begin(text), std::end(text), - std::begin(text), static_cast(std::toupper)); - - return text; - } - - static std::vector split(STRING_VIEW text, char const delimiter) - { - std::vector tokens; - std::string token; - std::istringstream tokenStream(text.data()); - while (std::getline(tokenStream, token, delimiter)) - { - tokens.push_back(token); - } - return tokens; - } - - CONSTEXPTR inline bool contains(STRING_VIEW text, char const ch) noexcept - { - return STRING_VIEW_NPOS != text.find_first_of(ch); - } - } - - namespace detail - { - - inline cron_int to_cron_int(STRING_VIEW text) - { - try - { - return static_cast(std::stoul(text.data())); - } - catch (std::exception const & ex) - { - throw bad_cronexpr(ex.what()); - } - } - - static std::string replace_ordinals( - std::string text, - std::vector const & replacement) - { - for (size_t i = 0; i < replacement.size(); ++i) - { - auto pos = text.find(replacement[i]); - if (std::string::npos != pos) - text.replace(pos, 3 ,std::to_string(i)); - } - - return text; - } - - static std::pair make_range( - STRING_VIEW field, - cron_int const minval, - cron_int const maxval) - { - cron_int first = 0; - cron_int last = 0; - if (field.size() == 1 && field[0] == '*') - { - first = minval; - last = maxval; - } - else if (!utils::contains(field, '-')) - { - first = to_cron_int(field); - last = first; - } - else - { - auto parts = utils::split(field, '-'); - if (parts.size() != 2) - throw bad_cronexpr("Specified range requires two fields"); - - first = to_cron_int(parts[0]); - last = to_cron_int(parts[1]); - } - - if (first > maxval || last > maxval) - { - throw bad_cronexpr("Specified range exceeds maximum"); - } - if (first < minval || last < minval) - { - throw bad_cronexpr("Specified range is less than minimum"); - } - if (first > last) - { - throw bad_cronexpr("Specified range start exceeds range end"); - } - - return { first, last }; - } - - template - static void set_cron_field( - STRING_VIEW value, - std::bitset& target, - cron_int const minval, - cron_int const maxval) - { - if(value.length() > 0 && value[value.length()-1] == ',') - throw bad_cronexpr("Value cannot end with comma"); - - auto fields = utils::split(value, ','); - if (fields.empty()) - throw bad_cronexpr("Expression parsing error"); - - for (auto const & field : fields) - { - if (!utils::contains(field, '/')) - { -#ifdef CRONCPP_IS_CPP17 - auto[first, last] = detail::make_range(field, minval, maxval); -#else - auto range = detail::make_range(field, minval, maxval); - auto first = range.first; - auto last = range.second; -#endif - for (cron_int i = first - minval; i <= last - minval; ++i) - { - target.set(i); - } - } - else - { - auto parts = utils::split(field, '/'); - if (parts.size() != 2) - throw bad_cronexpr("Incrementer must have two fields"); - -#ifdef CRONCPP_IS_CPP17 - auto[first, last] = detail::make_range(parts[0], minval, maxval); -#else - auto range = detail::make_range(parts[0], minval, maxval); - auto first = range.first; - auto last = range.second; -#endif - - if (!utils::contains(parts[0], '-')) - { - last = maxval; - } - - auto delta = detail::to_cron_int(parts[1]); - if(delta <= 0) - throw bad_cronexpr("Incrementer must be a positive value"); - - for (cron_int i = first - minval; i <= last - minval; i += delta) - { - target.set(i); - } - } - } - } - - template - static void set_cron_days_of_week( - std::string value, - std::bitset<7>& target) - { - auto days = utils::to_upper(value); - auto days_replaced = detail::replace_ordinals( - days, -#ifdef CRONCPP_IS_CPP17 - Traits::DAYS -#else - Traits::DAYS() -#endif - ); - - if (days_replaced.size() == 1 && days_replaced[0] == '?') - days_replaced[0] = '*'; - - set_cron_field( - days_replaced, - target, - Traits::CRON_MIN_DAYS_OF_WEEK, - Traits::CRON_MAX_DAYS_OF_WEEK); - } - - template - static void set_cron_days_of_month( - std::string value, - std::bitset<31>& target) - { - if (value.size() == 1 && value[0] == '?') - value[0] = '*'; - - set_cron_field( - value, - target, - Traits::CRON_MIN_DAYS_OF_MONTH, - Traits::CRON_MAX_DAYS_OF_MONTH); - } - - template - static void set_cron_month( - std::string value, - std::bitset<12>& target) - { - auto month = utils::to_upper(value); - auto month_replaced = replace_ordinals( - month, -#ifdef CRONCPP_IS_CPP17 - Traits::MONTHS -#else - Traits::MONTHS() -#endif - ); - - set_cron_field( - month_replaced, - target, - Traits::CRON_MIN_MONTHS, - Traits::CRON_MAX_MONTHS); - } - - template - inline size_t next_set_bit( - std::bitset const & target, - size_t /*minimum*/, - size_t /*maximum*/, - size_t offset) - { - for (auto i = offset; i < N; ++i) - { - if (target.test(i)) return i; - } - - return INVALID_CRON_INDEX; - } - - inline void add_to_field( - std::tm& date, - cron_field const field, - int const val) - { - switch (field) - { - case cron_field::second: - date.tm_sec += val; - break; - case cron_field::minute: - date.tm_min += val; - break; - case cron_field::hour_of_day: - date.tm_hour += val; - break; - case cron_field::day_of_week: - case cron_field::day_of_month: - date.tm_mday += val; - break; - case cron_field::month: - date.tm_mon += val; - break; - case cron_field::year: - date.tm_year += val; - break; - } - - if (INVALID_TIME == utils::tm_to_time(date)) - throw bad_cronexpr("Invalid time expression"); - } - - inline void set_field( - std::tm& date, - cron_field const field, - int const val) - { - switch (field) - { - case cron_field::second: - date.tm_sec = val; - break; - case cron_field::minute: - date.tm_min = val; - break; - case cron_field::hour_of_day: - date.tm_hour = val; - break; - case cron_field::day_of_week: - date.tm_wday = val; - break; - case cron_field::day_of_month: - date.tm_mday = val; - break; - case cron_field::month: - date.tm_mon = val; - break; - case cron_field::year: - date.tm_year = val; - break; - } - - if (INVALID_TIME == utils::tm_to_time(date)) - throw bad_cronexpr("Invalid time expression"); - } - - inline void reset_field( - std::tm& date, - cron_field const field) - { - switch (field) - { - case cron_field::second: - date.tm_sec = 0; - break; - case cron_field::minute: - date.tm_min = 0; - break; - case cron_field::hour_of_day: - date.tm_hour = 0; - break; - case cron_field::day_of_week: - date.tm_wday = 0; - break; - case cron_field::day_of_month: - date.tm_mday = 1; - break; - case cron_field::month: - date.tm_mon = 0; - break; - case cron_field::year: - date.tm_year = 0; - break; - } - - if (INVALID_TIME == utils::tm_to_time(date)) - throw bad_cronexpr("Invalid time expression"); - } - - inline void reset_all_fields( - std::tm& date, - std::bitset<7> const & marked_fields) - { - for (size_t i = 0; i < marked_fields.size(); ++i) - { - if (marked_fields.test(i)) - reset_field(date, static_cast(i)); - } - } - - inline void mark_field( - std::bitset<7> & orders, - cron_field const field) - { - if (!orders.test(static_cast(field))) - orders.set(static_cast(field)); - } - - template - static size_t find_next( - std::bitset const & target, - std::tm& date, - unsigned int const minimum, - unsigned int const maximum, - unsigned int const value, - cron_field const field, - cron_field const next_field, - std::bitset<7> const & marked_fields) - { - auto next_value = next_set_bit(target, minimum, maximum, value); - if (INVALID_CRON_INDEX == next_value) - { - add_to_field(date, next_field, 1); - reset_field(date, field); - next_value = next_set_bit(target, minimum, maximum, 0); - } - - if (INVALID_CRON_INDEX == next_value || next_value != value) - { - set_field(date, field, static_cast(next_value)); - reset_all_fields(date, marked_fields); - } - - return next_value; - } - - template - static size_t find_next_day( - std::tm& date, - std::bitset<31> const & days_of_month, - size_t day_of_month, - std::bitset<7> const & days_of_week, - size_t day_of_week, - std::bitset<7> const & marked_fields) - { - unsigned int count = 0; - unsigned int maximum = 366; - while ( - (!days_of_month.test(day_of_month - Traits::CRON_MIN_DAYS_OF_MONTH) || - !days_of_week.test(day_of_week - Traits::CRON_MIN_DAYS_OF_WEEK)) - && count++ < maximum) - { - add_to_field(date, cron_field::day_of_month, 1); - - day_of_month = date.tm_mday; - day_of_week = date.tm_wday; - - reset_all_fields(date, marked_fields); - } - - return day_of_month; - } - - template - static bool find_next(cronexpr const & cex, - std::tm& date, - size_t const dot) - { - bool res = true; - - std::bitset<7> marked_fields{ 0 }; - std::bitset<7> empty_list{ 0 }; - - unsigned int second = date.tm_sec; - auto updated_second = find_next( - cex.seconds, - date, - Traits::CRON_MIN_SECONDS, - Traits::CRON_MAX_SECONDS, - second, - cron_field::second, - cron_field::minute, - empty_list); - - if (second == updated_second) - { - mark_field(marked_fields, cron_field::second); - } - - unsigned int minute = date.tm_min; - auto update_minute = find_next( - cex.minutes, - date, - Traits::CRON_MIN_MINUTES, - Traits::CRON_MAX_MINUTES, - minute, - cron_field::minute, - cron_field::hour_of_day, - marked_fields); - if (minute == update_minute) - { - mark_field(marked_fields, cron_field::minute); - } - else - { - res = find_next(cex, date, dot); - if (!res) return res; - } - - unsigned int hour = date.tm_hour; - auto updated_hour = find_next( - cex.hours, - date, - Traits::CRON_MIN_HOURS, - Traits::CRON_MAX_HOURS, - hour, - cron_field::hour_of_day, - cron_field::day_of_week, - marked_fields); - if (hour == updated_hour) - { - mark_field(marked_fields, cron_field::hour_of_day); - } - else - { - res = find_next(cex, date, dot); - if (!res) return res; - } - - unsigned int day_of_week = date.tm_wday; - unsigned int day_of_month = date.tm_mday; - auto updated_day_of_month = find_next_day( - date, - cex.days_of_month, - day_of_month, - cex.days_of_week, - day_of_week, - marked_fields); - if (day_of_month == updated_day_of_month) - { - mark_field(marked_fields, cron_field::day_of_month); - } - else - { - res = find_next(cex, date, dot); - if (!res) return res; - } - - unsigned int month = date.tm_mon; - auto updated_month = find_next( - cex.months, - date, - Traits::CRON_MIN_MONTHS, - Traits::CRON_MAX_MONTHS, - month, - cron_field::month, - cron_field::year, - marked_fields); - if (month != updated_month) - { - if (date.tm_year - dot > Traits::CRON_MAX_YEARS_DIFF) - return false; - - res = find_next(cex, date, dot); - if (!res) return res; - } - - return res; - } - } - - template - static cronexpr make_cron(STRING_VIEW expr) - { - cronexpr cex; - - if (expr.empty()) - throw bad_cronexpr("Invalid empty cron expression"); - - auto fields = utils::split(expr, ' '); - fields.erase( - std::remove_if(std::begin(fields), std::end(fields), - [](STRING_VIEW s) {return s.empty(); }), - std::end(fields)); - if (fields.size() != 6) - throw bad_cronexpr("cron expression must have six fields"); - - detail::set_cron_field(fields[0], cex.seconds, Traits::CRON_MIN_SECONDS, Traits::CRON_MAX_SECONDS); - detail::set_cron_field(fields[1], cex.minutes, Traits::CRON_MIN_MINUTES, Traits::CRON_MAX_MINUTES); - detail::set_cron_field(fields[2], cex.hours, Traits::CRON_MIN_HOURS, Traits::CRON_MAX_HOURS); - - detail::set_cron_days_of_week(fields[5], cex.days_of_week); - - detail::set_cron_days_of_month(fields[3], cex.days_of_month); - - detail::set_cron_month(fields[4], cex.months); - - return cex; - } - - template - static std::tm cron_next(cronexpr const & cex, std::tm date) - { - time_t original = utils::tm_to_time(date); - if (INVALID_TIME == original) return {}; - - if (!detail::find_next(cex, date, date.tm_year)) - return {}; - - time_t calculated = utils::tm_to_time(date); - if (INVALID_TIME == calculated) return {}; - - if (calculated == original) - { - add_to_field(date, detail::cron_field::second, 1); - if (!detail::find_next(cex, date, date.tm_year)) - return {}; - } - - return date; - } - - template - static std::time_t cron_next(cronexpr const & cex, std::time_t const & date) - { - std::tm val; - std::tm* dt = utils::time_to_tm(&date, &val); - if (dt == nullptr) return INVALID_TIME; - - time_t original = utils::tm_to_time(*dt); - if (INVALID_TIME == original) return INVALID_TIME; - - if(!detail::find_next(cex, *dt, dt->tm_year)) - return INVALID_TIME; - - time_t calculated = utils::tm_to_time(*dt); - if (INVALID_TIME == calculated) return calculated; - - if (calculated == original) - { - add_to_field(*dt, detail::cron_field::second, 1); - if(!detail::find_next(cex, *dt, dt->tm_year)) - return INVALID_TIME; - } - - return utils::tm_to_time(*dt); - } -} diff --git a/common/database.cpp b/common/database.cpp index 385f07c18..01520d5a3 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -703,11 +703,11 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe "(%u, %u, %u, %f, %f, %f, %f, %i), " "(%u, %u, %u, %f, %f, %f, %f, %i), " "(%u, %u, %u, %f, %f, %f, %f, %i)", - character_id, pp->binds[0].zone_id, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading, 0, - character_id, pp->binds[1].zone_id, 0, pp->binds[1].x, pp->binds[1].y, pp->binds[1].z, pp->binds[1].heading, 1, - character_id, pp->binds[2].zone_id, 0, pp->binds[2].x, pp->binds[2].y, pp->binds[2].z, pp->binds[2].heading, 2, - character_id, pp->binds[3].zone_id, 0, pp->binds[3].x, pp->binds[3].y, pp->binds[3].z, pp->binds[3].heading, 3, - character_id, pp->binds[4].zone_id, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading, 4 + character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading, 0, + character_id, pp->binds[1].zoneId, 0, pp->binds[1].x, pp->binds[1].y, pp->binds[1].z, pp->binds[1].heading, 1, + character_id, pp->binds[2].zoneId, 0, pp->binds[2].x, pp->binds[2].y, pp->binds[2].z, pp->binds[2].heading, 2, + character_id, pp->binds[3].zoneId, 0, pp->binds[3].x, pp->binds[3].y, pp->binds[3].z, pp->binds[3].heading, 3, + character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading, 4 ); results = QueryDatabase(query); /* HoTT Ability */ @@ -870,40 +870,36 @@ void Database::GetCharName(uint32 char_id, char* name) { } } -std::string Database::GetCharNameByID(uint32 char_id) { +const char* Database::GetCharNameByID(uint32 char_id) { std::string query = fmt::format("SELECT `name` FROM `character_data` WHERE id = {}", char_id); auto results = QueryDatabase(query); - std::string res; if (!results.Success()) { - return res; + return ""; } if (results.RowCount() == 0) { - return res; + return ""; } auto row = results.begin(); - res = row[0]; - return res; + return row[0]; } -std::string Database::GetNPCNameByID(uint32 npc_id) { +const char* Database::GetNPCNameByID(uint32 npc_id) { std::string query = fmt::format("SELECT `name` FROM `npc_types` WHERE id = {}", npc_id); auto results = QueryDatabase(query); - std::string res; if (!results.Success()) { - return res; + return ""; } if (results.RowCount() == 0) { - return res; + return ""; } auto row = results.begin(); - res = row[0]; - return res; + return row[0]; } bool Database::LoadVariables() { @@ -975,24 +971,10 @@ bool Database::SetVariable(const std::string varname, const std::string &varvalu } // Get zone starting points from DB -bool Database::GetSafePoints(const char* zone_short_name, uint32 instance_version, float* safe_x, float* safe_y, float* safe_z, float* safe_heading, int16* min_status, uint8* min_level, char *flag_needed) { +bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) { - if (zone_short_name == nullptr) - return false; - - std::string query = fmt::format( - SQL( - SELECT - `safe_x`, `safe_y`, `safe_z`, `safe_heading`, `min_status`, `min_level`, `flag_needed` - FROM - zone - WHERE - `short_name` = '{}' - AND - (`version` = {} OR `version` = 0) - ORDER BY `version` DESC - ), zone_short_name, instance_version - ); + std::string query = StringFormat("SELECT safe_x, safe_y, safe_z, min_status, min_level, flag_needed FROM zone " + " WHERE short_name='%s' AND (version=%i OR version=0) ORDER BY version DESC", short_name, version); auto results = QueryDatabase(query); if (!results.Success()) @@ -1005,24 +987,16 @@ bool Database::GetSafePoints(const char* zone_short_name, uint32 instance_versio if (safe_x != nullptr) *safe_x = atof(row[0]); - if (safe_y != nullptr) *safe_y = atof(row[1]); - if (safe_z != nullptr) *safe_z = atof(row[2]); - - if (safe_heading != nullptr) - *safe_heading = atof(row[3]); - - if (min_status != nullptr) - *min_status = atoi(row[4]); - - if (min_level != nullptr) - *min_level = atoi(row[5]); - + if (minstatus != nullptr) + *minstatus = atoi(row[3]); + if (minlevel != nullptr) + *minlevel = atoi(row[4]); if (flag_needed != nullptr) - strcpy(flag_needed, row[6]); + strcpy(flag_needed, row[5]); return true; } @@ -1382,20 +1356,6 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character return results.RowsAffected() != 0; } -bool Database::SetMQDetectionFlag(const char* accountname, const char* charactername, const std::string &hacked, const char* zone) { - //Utilize the "hacker" table, but also give zone information. - auto query = fmt::format("INSERT INTO hackers(account, name, hacked, zone) values('{}', '{}', '{}', '{}')", - accountname, charactername, hacked, zone); - auto results = QueryDatabase(query); - - if (!results.Success()) - { - return false; - } - - return results.RowsAffected() != 0; -} - uint8 Database::GetRaceSkill(uint8 skillid, uint8 in_race) { uint16 race_cap = 0; diff --git a/common/database.h b/common/database.h index f6d93d5aa..74566f4fd 100644 --- a/common/database.h +++ b/common/database.h @@ -45,6 +45,24 @@ namespace EQ class InventoryProfile; } +struct EventLogDetails_Struct { + uint32 id; + char accountname[64]; + uint32 account_id; + int16 status; + char charactername[64]; + char targetname[64]; + char timestamp[64]; + char descriptiontype[64]; + char details[128]; +}; + +struct CharacterEventLog_Struct { + uint32 count; + uint8 eventid; + EventLogDetails_Struct eld[255]; +}; + struct npcDecayTimes_Struct { uint16 minlvl; uint16 maxlvl; @@ -110,7 +128,6 @@ public: bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct *pp); bool SetHackerFlag(const char *accountname, const char *charactername, const char *hacked); bool SetMQDetectionFlag(const char *accountname, const char *charactername, const char *hacked, const char *zone); - bool SetMQDetectionFlag(const char *accountname, const char *charactername, const std::string &hacked, const char *zone); bool UpdateName(const char *oldname, const char *newname); bool CopyCharacter( std::string source_character_name, @@ -138,8 +155,8 @@ public: void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0); void GetCharName(uint32 char_id, char* name); - std::string GetCharNameByID(uint32 char_id); - std::string GetNPCNameByID(uint32 npc_id); + const char *GetCharNameByID(uint32 char_id); + const char *GetNPCNameByID(uint32 npc_id); void LoginIP(uint32 AccountID, const char* LoginIP); /* Instancing */ @@ -242,7 +259,7 @@ public: /* General Queries */ - bool GetSafePoints(const char* zone_short_name, uint32 instance_version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, float* safe_heading = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr); + bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr); bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0); bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0); bool LoadPTimers(uint32 charid, PTimerList &into); diff --git a/common/database/database_dump_service.cpp b/common/database/database_dump_service.cpp index 7efd80f83..df083901d 100644 --- a/common/database/database_dump_service.cpp +++ b/common/database/database_dump_service.cpp @@ -300,7 +300,8 @@ void DatabaseDumpService::Dump() config->DatabaseUsername ); - std::string options = "--allow-keywords --extended-insert --max-allowed-packet=1G --net-buffer-length=32704"; + std::string options = "--allow-keywords --extended-insert"; + if (IsDumpWithNoData()) { options += " --no-data"; } diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index 561e1679b..d49651f4d 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -48,7 +48,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA namespace Convert { struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1320,18 +1320,18 @@ bool Database::CheckDatabaseConvertPPDeblob(){ if (rquery != ""){ results = QueryDatabase(rquery); } /* Run Bind Home Convert */ - if (pp->binds[4].zone_id < 999 && !_ISNAN_(pp->binds[4].x) && !_ISNAN_(pp->binds[4].y) && !_ISNAN_(pp->binds[4].z) && !_ISNAN_(pp->binds[4].heading)) { + if (pp->binds[4].zoneId < 999 && !_ISNAN_(pp->binds[4].x) && !_ISNAN_(pp->binds[4].y) && !_ISNAN_(pp->binds[4].z) && !_ISNAN_(pp->binds[4].heading)) { rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" " VALUES (%u, %u, %u, %f, %f, %f, %f, 1)", - character_id, pp->binds[4].zone_id, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading); + character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading); if (rquery != ""){ results = QueryDatabase(rquery); } } /* Run Bind Convert */ - if (pp->binds[0].zone_id < 999 && !_ISNAN_(pp->binds[0].x) && !_ISNAN_(pp->binds[0].y) && !_ISNAN_(pp->binds[0].z) && !_ISNAN_(pp->binds[0].heading)) { + if (pp->binds[0].zoneId < 999 && !_ISNAN_(pp->binds[0].x) && !_ISNAN_(pp->binds[0].y) && !_ISNAN_(pp->binds[0].z) && !_ISNAN_(pp->binds[0].heading)) { rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" " VALUES (%u, %u, %u, %f, %f, %f, %f, 0)", - character_id, pp->binds[0].zone_id, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading); + character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading); if (rquery != ""){ results = QueryDatabase(rquery); } } /* Run Language Convert */ diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 0c4be4bd6..372c6751f 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -493,9 +493,6 @@ void Database::DeleteInstance(uint16 instance_id) query = StringFormat("DELETE FROM spawn_condition_values WHERE instance_id=%u", instance_id); QueryDatabase(query); - query = fmt::format("DELETE FROM dynamic_zones WHERE instance_id={}", instance_id); - QueryDatabase(query); - BuryCorpsesInInstance(instance_id); } @@ -507,7 +504,7 @@ void Database::FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 char char ln[128]; memset(ln, 0, 128); - GetGroupLeadershipInfo(gid, ln); + strcpy(ln, GetGroupLeadershipInfo(gid, ln)); uint32 l_charid = GetCharacterID((const char*)ln); uint16 l_id = GetInstanceID(zone, l_charid, version); @@ -585,7 +582,8 @@ void Database::PurgeExpiredInstances() QueryDatabase(fmt::format("DELETE FROM respawn_times WHERE instance_id IN ({})", imploded_instance_ids)); QueryDatabase(fmt::format("DELETE FROM spawn_condition_values WHERE instance_id IN ({})", imploded_instance_ids)); QueryDatabase(fmt::format("UPDATE character_corpses SET is_buried = 1, instance_id = 0 WHERE instance_id IN ({})", imploded_instance_ids)); - QueryDatabase(fmt::format("DELETE FROM dynamic_zones WHERE instance_id IN ({})", imploded_instance_ids)); + + } void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration) diff --git a/common/database_schema.h b/common/database_schema.h index 8d8e81441..0b6536d96 100644 --- a/common/database_schema.h +++ b/common/database_schema.h @@ -50,8 +50,6 @@ namespace DatabaseSchema { {"character_data", "id"}, {"character_disciplines", "id"}, {"character_enabledtasks", "charid"}, - {"character_expedition_lockouts", "character_id"}, - {"character_exp_modifiers", "character_id"}, {"character_inspect_messages", "id"}, {"character_item_recast", "id"}, {"character_languages", "id"}, @@ -116,8 +114,6 @@ namespace DatabaseSchema { "character_data", "character_disciplines", "character_enabledtasks", - "character_expedition_lockouts", - "character_exp_modifiers", "character_inspect_messages", "character_item_recast", "character_languages", @@ -309,11 +305,7 @@ namespace DatabaseSchema { "banned_ips", "bug_reports", "bugs", - "dynamic_zones", "eventlog", - "expedition_lockouts", - "expedition_members", - "expeditions", "gm_ips", "group_id", "group_leaders", @@ -330,7 +322,7 @@ namespace DatabaseSchema { "reports", "respawn_times", "saylink", - "server_scheduled_events", + }; } diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 7f1f52363..dae05b14b 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -223,10 +223,10 @@ bool DBcore::Open( ) { LockMutex lock(&MDatabase); - safe_delete_array(pHost); - safe_delete_array(pUser); - safe_delete_array(pPassword); - safe_delete_array(pDatabase); + safe_delete(pHost); + safe_delete(pUser); + safe_delete(pPassword); + safe_delete(pDatabase); pHost = strcpy(new char[strlen(iHost) + 1], iHost); pUser = strcpy(new char[strlen(iUser) + 1], iUser); pPassword = strcpy(new char[strlen(iPassword) + 1], iPassword); diff --git a/common/dynamic_zone_base.cpp b/common/dynamic_zone_base.cpp deleted file mode 100644 index 8e29722d3..000000000 --- a/common/dynamic_zone_base.cpp +++ /dev/null @@ -1,289 +0,0 @@ -#include "dynamic_zone_base.h" -#include "database.h" -#include "eqemu_logsys.h" -#include "repositories/instance_list_repository.h" -#include "repositories/instance_list_player_repository.h" -#include "servertalk.h" - -DynamicZoneBase::DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& entry) -{ - LoadRepositoryResult(std::move(entry)); -} - -uint32_t DynamicZoneBase::Create() -{ - if (m_id != 0) - { - return m_id; - } - - if (GetInstanceID() == 0) - { - CreateInstance(); - } - - m_id = SaveToDatabase(); - - return m_id; -} - -uint32_t DynamicZoneBase::CreateInstance() -{ - if (m_instance_id) - { - LogDynamicZones("CreateInstance failed, instance id [{}] already created", m_instance_id); - return 0; - } - - if (!m_zone_id) - { - LogDynamicZones("CreateInstance failed, invalid zone id [{}]", m_zone_id); - return 0; - } - - uint16_t unused_instance_id = 0; - if (!GetDatabase().GetUnusedInstanceID(unused_instance_id)) // todo: doesn't this race with insert? - { - LogDynamicZones("Failed to find unused instance id"); - return 0; - } - - m_start_time = std::chrono::system_clock::now(); - m_expire_time = m_start_time + m_duration; - - auto insert_instance = InstanceListRepository::NewEntity(); - insert_instance.id = unused_instance_id; - insert_instance.zone = m_zone_id; - insert_instance.version = m_zone_version; - insert_instance.start_time = static_cast(std::chrono::system_clock::to_time_t(m_start_time)); - insert_instance.duration = static_cast(m_duration.count()); - insert_instance.never_expires = m_never_expires; - - auto instance = InstanceListRepository::InsertOne(GetDatabase(), insert_instance); - if (instance.id == 0) - { - LogDynamicZones("Failed to create instance [{}] for zone [{}]", unused_instance_id, m_zone_id); - return 0; - } - - m_instance_id = instance.id; - - return m_instance_id; -} - -void DynamicZoneBase::LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry) -{ - m_id = dz_entry.id; - m_instance_id = dz_entry.instance_id; - m_type = static_cast(dz_entry.type); - m_compass.zone_id = dz_entry.compass_zone_id; - m_compass.x = dz_entry.compass_x; - m_compass.y = dz_entry.compass_y; - m_compass.z = dz_entry.compass_z; - m_safereturn.zone_id = dz_entry.safe_return_zone_id; - m_safereturn.x = dz_entry.safe_return_x; - m_safereturn.y = dz_entry.safe_return_y; - m_safereturn.z = dz_entry.safe_return_z; - m_safereturn.heading = dz_entry.safe_return_heading; - m_zonein.x = dz_entry.zone_in_x; - m_zonein.y = dz_entry.zone_in_y; - m_zonein.z = dz_entry.zone_in_z; - m_zonein.heading = dz_entry.zone_in_heading; - m_has_zonein = (dz_entry.has_zone_in != 0); - // instance_list portion - m_zone_id = dz_entry.zone; - m_zone_version = dz_entry.version; - m_start_time = std::chrono::system_clock::from_time_t(dz_entry.start_time); - m_duration = std::chrono::seconds(dz_entry.duration); - m_never_expires = (dz_entry.never_expires != 0); - m_expire_time = m_start_time + m_duration; -} - -uint32_t DynamicZoneBase::SaveToDatabase() -{ - LogDynamicZonesDetail("Saving dz instance [{}] to database", m_instance_id); - - if (m_instance_id != 0) - { - auto insert_dz = DynamicZonesRepository::NewEntity(); - insert_dz.instance_id = m_instance_id, - insert_dz.type = static_cast(m_type); - insert_dz.compass_zone_id = m_compass.zone_id; - insert_dz.compass_x = m_compass.x; - insert_dz.compass_y = m_compass.y; - insert_dz.compass_z = m_compass.z; - insert_dz.safe_return_zone_id = m_safereturn.zone_id; - insert_dz.safe_return_x = m_safereturn.x; - insert_dz.safe_return_y = m_safereturn.y; - insert_dz.safe_return_z = m_safereturn.z; - insert_dz.safe_return_heading = m_safereturn.heading; - insert_dz.zone_in_x = m_zonein.x; - insert_dz.zone_in_y = m_zonein.y; - insert_dz.zone_in_z = m_zonein.z; - insert_dz.zone_in_heading = m_zonein.heading; - insert_dz.has_zone_in = m_has_zonein; - - auto inserted_dz = DynamicZonesRepository::InsertOne(GetDatabase(), insert_dz); - return inserted_dz.id; - } - return 0; -} - -void DynamicZoneBase::AddCharacter(uint32_t character_id) -{ - GetDatabase().AddClientToInstance(m_instance_id, character_id); - SendInstanceAddRemoveCharacter(character_id, false); // stops client kick timer -} - -void DynamicZoneBase::RemoveCharacter(uint32_t character_id) -{ - GetDatabase().RemoveClientFromInstance(m_instance_id, character_id); - SendInstanceAddRemoveCharacter(character_id, true); // start client kick timer -} - -void DynamicZoneBase::RemoveAllCharacters(bool enable_removal_timers) -{ - if (GetInstanceID() == 0) - { - return; - } - - if (enable_removal_timers) - { - SendInstanceRemoveAllCharacters(); - } - - GetDatabase().RemoveClientsFromInstance(GetInstanceID()); -} - -void DynamicZoneBase::SaveInstanceMembersToDatabase(const std::vector& character_ids) -{ - LogDynamicZonesDetail("Saving [{}] members for instance [{}]", character_ids.size(), m_instance_id); - - std::vector insert_players; - - for (const auto& character_id : character_ids) - { - InstanceListPlayerRepository::InstanceListPlayer entry{}; - entry.id = static_cast(m_instance_id); - entry.charid = static_cast(character_id); - insert_players.emplace_back(entry); - } - - InstanceListPlayerRepository::InsertMany(GetDatabase(), insert_players); -} - -void DynamicZoneBase::SetCompass(const DynamicZoneLocation& location, bool update_db) -{ - ProcessCompassChange(location); - - if (update_db) - { - LogDynamicZonesDetail("Saving [{}] compass zone: [{}] xyz: ([{}], [{}], [{}])", - m_id, m_compass.zone_id, m_compass.x, m_compass.y, m_compass.z); - - DynamicZonesRepository::UpdateCompass(GetDatabase(), - m_id, m_compass.zone_id, m_compass.x, m_compass.y, m_compass.z); - - SendGlobalLocationChange(ServerOP_DzSetCompass, location); - } -} - -void DynamicZoneBase::SetCompass(uint32_t zone_id, float x, float y, float z, bool update_db) -{ - SetCompass({ zone_id, x, y, z, 0.0f }, update_db); -} - -void DynamicZoneBase::SetSafeReturn(const DynamicZoneLocation& location, bool update_db) -{ - m_safereturn = location; - - if (update_db) - { - LogDynamicZonesDetail("Saving [{}] safereturn zone: [{}] xyzh: ([{}], [{}], [{}], [{}])", - m_id, m_safereturn.zone_id, m_safereturn.x, m_safereturn.y, m_safereturn.z, m_safereturn.heading); - - DynamicZonesRepository::UpdateSafeReturn(GetDatabase(), m_id, m_safereturn.zone_id, - m_safereturn.x, m_safereturn.y, m_safereturn.z, m_safereturn.heading); - - SendGlobalLocationChange(ServerOP_DzSetSafeReturn, location); - } -} - -void DynamicZoneBase::SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db) -{ - SetSafeReturn({ zone_id, x, y, z, heading }, update_db); -} - -void DynamicZoneBase::SetZoneInLocation(const DynamicZoneLocation& location, bool update_db) -{ - m_zonein = location; - m_has_zonein = true; - - if (update_db) - { - LogDynamicZonesDetail("Saving [{}] zonein zone: [{}] xyzh: ([{}], [{}], [{}], [{}])", - m_id, m_zone_id, m_zonein.x, m_zonein.y, m_zonein.z, m_zonein.heading); - - DynamicZonesRepository::UpdateZoneIn(GetDatabase(), m_id, m_zone_id, - m_zonein.x, m_zonein.y, m_zonein.z, m_zonein.heading, m_has_zonein); - - SendGlobalLocationChange(ServerOP_DzSetZoneIn, location); - } -} - -void DynamicZoneBase::SetZoneInLocation(float x, float y, float z, float heading, bool update_db) -{ - SetZoneInLocation({ 0, x, y, z, heading }, update_db); -} - -uint32_t DynamicZoneBase::GetSecondsRemaining() const -{ - auto remaining = std::chrono::duration_cast(GetDurationRemaining()).count(); - return std::max(0, static_cast(remaining)); -} - -std::unique_ptr DynamicZoneBase::CreateServerAddRemoveCharacterPacket( - uint32_t character_id, bool removed) -{ - constexpr uint32_t pack_size = sizeof(ServerDzCharacter_Struct); - auto pack = std::make_unique(ServerOP_DzAddRemoveCharacter, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->zone_id = GetZoneID(); - buf->instance_id = GetInstanceID(); - buf->remove = removed; - buf->character_id = character_id; - - return pack; -} - -std::unique_ptr DynamicZoneBase::CreateServerRemoveAllCharactersPacket() -{ - constexpr uint32_t pack_size = sizeof(ServerDzCharacter_Struct); - auto pack = std::make_unique(ServerOP_DzRemoveAllCharacters, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->zone_id = GetZoneID(); - buf->instance_id = GetInstanceID(); - buf->remove = true; - buf->character_id = 0; - - return pack; -} - -std::unique_ptr DynamicZoneBase::CreateServerDzLocationPacket( - uint16_t server_opcode, const DynamicZoneLocation& location) -{ - constexpr uint32_t pack_size = sizeof(ServerDzLocation_Struct); - auto pack = std::make_unique(server_opcode, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->dz_id = GetID(); - buf->sender_zone_id = GetCurrentZoneID(); - buf->sender_instance_id = GetCurrentInstanceID(); - buf->zone_id = location.zone_id; - buf->x = location.x; - buf->y = location.y; - buf->z = location.z; - buf->heading = location.heading; - - return pack; -} diff --git a/common/dynamic_zone_base.h b/common/dynamic_zone_base.h deleted file mode 100644 index 5a84fa8fa..000000000 --- a/common/dynamic_zone_base.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef COMMON_DYNAMIC_ZONE_BASE_H -#define COMMON_DYNAMIC_ZONE_BASE_H - -#include "eq_constants.h" -#include "repositories/dynamic_zones_repository.h" -#include -#include -#include -#include -#include -#include - -class Database; -class ServerPacket; - -struct DynamicZoneMember -{ - uint32_t id = 0; - std::string name; - DynamicZoneMemberStatus status = DynamicZoneMemberStatus::Online; - - DynamicZoneMember() = default; - DynamicZoneMember(uint32_t id, std::string name_) - : id(id), name{std::move(name_)} {} - DynamicZoneMember(uint32_t id, std::string name_, DynamicZoneMemberStatus status_) - : id(id), name{std::move(name_)}, status(status_) {} - - bool IsOnline() const { return status == DynamicZoneMemberStatus::Online || - status == DynamicZoneMemberStatus::InDynamicZone; } - bool IsValid() const { return id != 0 && !name.empty(); } -}; - -struct DynamicZoneLocation -{ - uint32_t zone_id = 0; - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - float heading = 0.0f; - - DynamicZoneLocation() = default; - DynamicZoneLocation(uint32_t zone_id_, float x_, float y_, float z_, float heading_) - : zone_id(zone_id_), x(x_), y(y_), z(z_), heading(heading_) {} -}; - -class DynamicZoneBase -{ -public: - virtual ~DynamicZoneBase() = default; - DynamicZoneBase(const DynamicZoneBase&) = default; - DynamicZoneBase(DynamicZoneBase&&) = default; - DynamicZoneBase& operator=(const DynamicZoneBase&) = default; - DynamicZoneBase& operator=(DynamicZoneBase&&) = default; - DynamicZoneBase() = default; - DynamicZoneBase(uint32_t dz_id) : m_id(dz_id) {} - DynamicZoneBase(DynamicZoneType type) : m_type(type) {} - DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& entry); - - virtual void SetSecondsRemaining(uint32_t seconds_remaining) = 0; - - uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); } - uint32_t GetID() const { return m_id; } - uint16_t GetInstanceID() const { return static_cast(m_instance_id); } - uint32_t GetMaxPlayers() const { return m_max_players; } - uint32_t GetMinPlayers() const { return m_min_players; } - uint32_t GetSecondsRemaining() const; - uint16_t GetZoneID() const { return static_cast(m_zone_id); } - uint32_t GetZoneIndex() const { return (m_instance_id << 16) | (m_zone_id & 0xffff); } - uint32_t GetZoneVersion() const { return m_zone_version; } - DynamicZoneType GetType() const { return m_type; } - const std::string& GetLeaderName() const { return m_leader_name; } - const std::string& GetName() const { return m_name; } - const DynamicZoneLocation& GetCompassLocation() const { return m_compass; } - const DynamicZoneLocation& GetSafeReturnLocation() const { return m_safereturn; } - const DynamicZoneLocation& GetZoneInLocation() const { return m_zonein; } - std::chrono::system_clock::duration GetDurationRemaining() const { return m_expire_time - std::chrono::system_clock::now(); } - - void AddCharacter(uint32_t character_id); - uint32_t Create(); - bool HasZoneInLocation() const { return m_has_zonein; } - bool IsExpired() const { return m_expire_time < std::chrono::system_clock::now(); } - bool IsInstanceID(uint32_t instance_id) const { return (m_instance_id != 0 && m_instance_id == instance_id); } - bool IsValid() const { return m_instance_id != 0; } - bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; } - void RemoveAllCharacters(bool enable_removal_timers = true); - void RemoveCharacter(uint32_t character_id); - void SaveInstanceMembersToDatabase(const std::vector& character_ids); - void SetCompass(const DynamicZoneLocation& location, bool update_db = false); - void SetCompass(uint32_t zone_id, float x, float y, float z, bool update_db = false); - void SetLeaderName(const std::string& leader_name) { m_leader_name = leader_name; } - void SetMaxPlayers(uint32_t max_players) { m_max_players = max_players; } - void SetMinPlayers(uint32_t min_players) { m_min_players = min_players; } - void SetName(const std::string& name) { m_name = name; } - void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false); - void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db = false); - void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false); - void SetZoneInLocation(float x, float y, float z, float heading, bool update_db = false); - -protected: - virtual uint16_t GetCurrentInstanceID() { return 0; } - virtual uint16_t GetCurrentZoneID() { return 0; } - virtual Database& GetDatabase() = 0; - virtual void ProcessCompassChange(const DynamicZoneLocation& location) { m_compass = location; } - virtual void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) = 0; - virtual void SendInstanceRemoveAllCharacters() = 0; - virtual void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) = 0; - - uint32_t CreateInstance(); - void LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry); - uint32_t SaveToDatabase(); - - std::unique_ptr CreateServerAddRemoveCharacterPacket(uint32_t character_id, bool removed); - std::unique_ptr CreateServerRemoveAllCharactersPacket(); - std::unique_ptr CreateServerDzLocationPacket(uint16_t server_opcode, const DynamicZoneLocation& location); - - uint32_t m_id = 0; - uint32_t m_zone_id = 0; - uint32_t m_instance_id = 0; - uint32_t m_zone_version = 0; - uint32_t m_min_players = 0; - uint32_t m_max_players = 0; - bool m_never_expires = false; - bool m_has_zonein = false; - std::string m_name; - std::string m_leader_name; - DynamicZoneType m_type{ DynamicZoneType::None }; - DynamicZoneLocation m_compass; - DynamicZoneLocation m_safereturn; - DynamicZoneLocation m_zonein; - std::chrono::seconds m_duration; - std::chrono::time_point m_start_time; - std::chrono::time_point m_expire_time; -}; - -#endif diff --git a/common/emu_oplist.h b/common/emu_oplist.h index 46fd564e6..5078cca68 100644 --- a/common/emu_oplist.h +++ b/common/emu_oplist.h @@ -136,22 +136,20 @@ N(OP_Dye), N(OP_DynamicWall), N(OP_DzAddPlayer), N(OP_DzChooseZone), -N(OP_DzChooseZoneReply), N(OP_DzCompass), N(OP_DzExpeditionEndsWarning), N(OP_DzExpeditionInfo), -N(OP_DzExpeditionInvite), -N(OP_DzExpeditionInviteResponse), -N(OP_DzExpeditionLockoutTimers), +N(OP_DzExpeditionList), +N(OP_DzJoinExpeditionConfirm), +N(OP_DzJoinExpeditionReply), +N(OP_DzLeaderStatus), N(OP_DzListTimers), N(OP_DzMakeLeader), N(OP_DzMemberList), -N(OP_DzMemberListName), -N(OP_DzMemberListStatus), +N(OP_DzMemberStatus), N(OP_DzPlayerList), N(OP_DzQuit), N(OP_DzRemovePlayer), -N(OP_DzSetLeaderName), N(OP_DzSwapPlayer), N(OP_Emote), N(OP_EndLootRequest), @@ -273,7 +271,6 @@ N(OP_ItemVerifyRequest), N(OP_ItemViewUnknown), N(OP_Jump), N(OP_KeyRing), -N(OP_KickPlayers), N(OP_KnowledgeBase), N(OP_LDoNButton), N(OP_LDoNDisarmTraps), diff --git a/common/eq_constants.h b/common/eq_constants.h index a585bdd87..1a0c517bd 100644 --- a/common/eq_constants.h +++ b/common/eq_constants.h @@ -464,23 +464,4 @@ namespace ZoneBlockedSpellTypes { const uint8 Region = 2; }; -enum class DynamicZoneType -{ - None = 0, - Expedition, - Tutorial, - Task, - Mission, // Shared Task - Quest -}; - -enum class DynamicZoneMemberStatus : uint8_t -{ - Unknown = 0, - Online, - Offline, - InDynamicZone, - LinkDead -}; - #endif /*COMMON_EQ_CONSTANTS_H*/ diff --git a/common/eq_limits.cpp b/common/eq_limits.cpp index 188c8f888..72c82f450 100644 --- a/common/eq_limits.cpp +++ b/common/eq_limits.cpp @@ -794,7 +794,7 @@ void EQ::inventory::InitializeDynamicLookups() { continue; // direct manipulation of lookup indices is safe so long as (int)ClientVersion:: == (int)MobVersion:: - inventory_dynamic_nongm_lookup_entries[iter] = std::make_unique(inventory_static_lookup_entries[iter]); + inventory_dynamic_nongm_lookup_entries[iter] = std::unique_ptr(new LookupEntry(inventory_static_lookup_entries[iter])); // clamp affected fields to the lowest standard inventory_dynamic_nongm_lookup_entries[iter]->InventoryTypeSize.Bank = Titanium::invtype::BANK_SIZE; // bank size @@ -864,7 +864,7 @@ void EQ::inventory::InitializeDynamicLookups() { } // direct manipulation of lookup indices is safe so long as (int)ClientVersion:: == (int)MobVersion:: - inventory_dynamic_gm_lookup_entries[iter] = std::make_unique(inventory_static_lookup_entries[iter]); + inventory_dynamic_gm_lookup_entries[iter] = std::unique_ptr(new LookupEntry(inventory_static_lookup_entries[iter])); inventory_dynamic_gm_lookup_entries[iter]->PossessionsBitmask = 0; // we'll fix later inventory_dynamic_gm_lookup_entries[iter]->CorpseBitmask = 0; // we'll fix later diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index f5d47546e..d6e8b0c97 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -375,16 +375,13 @@ struct NewZone_Struct { /*0686*/ uint16 zone_instance; /*0688*/ uint32 unknown688; /*0692*/ uint8 unknown692[8]; -// Titanium doesn't have a translator, but we can still safely add stuff under here without issues since client memcpy's only what it knows -// Just wastes some bandwidth sending to tit clients /shrug /*0700*/ float fog_density; /*0704*/ uint32 SuspendBuffs; /*0708*/ uint32 FastRegenHP; /*0712*/ uint32 FastRegenMana; /*0716*/ uint32 FastRegenEndurance; /*0720*/ uint32 NPCAggroMaxDist; -/*0724*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, if this value is 0, it prevents you from running off edges that would end up underworld -/*0728*/ +/*0724*/ }; /* @@ -829,7 +826,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1772,7 +1769,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -3247,7 +3244,7 @@ struct TraderClick_Struct{ }; struct FormattedMessage_Struct{ - uint32 unknown0; // 1 means from world server + uint32 unknown0; uint32 string_id; uint32 type; char message[0]; @@ -3255,7 +3252,7 @@ struct FormattedMessage_Struct{ struct SimpleMessage_Struct{ uint32 string_id; uint32 color; - uint32 unknown8; // 1 means from world server + uint32 unknown8; }; struct GuildMemberUpdate_Struct { @@ -4835,99 +4832,17 @@ struct BuffIcon_Struct BuffIconEntry_Struct entries[0]; }; -struct ExpeditionInvite_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint32 client_id; // unique character id -/*004*/ uint32 unknown004; // added after titanium -/*008*/ char inviter_name[64]; -/*072*/ char expedition_name[128]; -/*200*/ uint8 swapping; // 0: adding 1: swapping -/*201*/ char swap_name[64]; // if swapping, swap name being removed -/*265*/ uint8 padding[3]; -/*268*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*270*/ uint16 dz_instance_id; +/*000*/ uint32 max_players; +/*004*/ char expedition_name[128]; +/*132*/ char leader_name[64]; }; -struct ExpeditionInviteResponse_Struct +struct ExpeditionJoinPrompt_Struct { -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; // added after titanium -/*008*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*010*/ uint16 dz_instance_id; -/*012*/ uint8 accepted; // 0: declined 1: accepted -/*013*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*014*/ char swap_name[64]; // swap name sent in invite -/*078*/ uint8 unknown078; // padding garbage? -/*079*/ uint8 unknown079; // padding garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; // added after titanium -/*008*/ uint32 assigned; // padded bool, 0: clear info, 1: fill window info -/*012*/ uint32 max_players; -/*016*/ char dz_name[128]; -/*144*/ char leader_name[64]; -//*208*/ uint32 dz_type; // only in newer clients, if not 1 (expedition type) window does not auto show when dz info assigned -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[64]; // variable length, null terminated, max 0x40 (64) -/*064*/ uint8 online_status; // 0: unknown, 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*012*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[128]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[256]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char add_player_name[64]; // swap to (player must confirm) -/*072*/ char rem_player_name[64]; // swap from +/*000*/ char player_name[64]; +/*064*/ char expedition_name[64]; }; struct ExpeditionExpireWarning @@ -4935,67 +4850,48 @@ struct ExpeditionExpireWarning /*008*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionCompassEntry_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) -/*008*/ uint32 unknown008; -/*012*/ float y; -/*016*/ float x; -/*020*/ float z; +/*000*/ uint32 enabled; //guess +/*004*/ float y; +/*008*/ float x; +/*012*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; /*000*/ uint32 count; -/*004*/ DynamicZoneCompassEntry_Struct entries[0]; +/*004*/ ExpeditionCompassEntry_Struct entries[0]; }; -struct DynamicZoneChooseZoneEntry_Struct +struct ExpeditionMemberEntry_Struct { -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // seen 28 00 00 00 (40), sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[128]; // variable length, null terminated -/*144*/ char leader_name[64]; // variable length, null terminated + char name[64]; + char status; }; -struct DynamicZoneChooseZone_Struct +struct ExpeditionMemberList_Struct { -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; +/*000*/ uint32 count; +/*004*/ ExpeditionMemberEntry_Struct entries[0]; }; -struct DynamicZoneChooseZoneReply_Struct +struct ExpeditionLockoutEntry_Struct { -/*000*/ uint32 unknown000; // ff ff ff ff -/*004*/ uint32 unknown004; // seen 69 00 00 00 -/*008*/ uint32 unknown008; // ff ff ff ff -/*012*/ uint32 unknown_id1; // from choose zone entry message -/*016*/ uint16 dz_zone_id; // dz_id pair -/*018*/ uint16 dz_instance_id; -/*020*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*024*/ uint32 unknown_id2; // from choose zone entry message -/*028*/ uint32 unknown028; // 00 00 00 00 -/*032*/ uint32 unknown032; // always same as unknown044 -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; // always same as unknown032 -/*048*/ uint32 unknown048; // seen 01 00 00 00 and 02 00 00 00 +/*000*/ uint32 time_left; +/*004*/ char expedition[128]; +/*132*/ char expedition_event[128]; }; -struct KickPlayers_Struct +struct ExpeditionLockoutList_Struct { -/*000*/ char char_name[64]; -/*064*/ uint32 unknown064; // always 0 -/*068*/ uint8 kick_expedition; // true if /kickplayers exp -/*069*/ uint8 kick_task; // true if /kickplayers task -/*070*/ uint8 padding[2]; +/*000*/ uint32 count; +/*004*/ ExpeditionLockoutEntry_Struct entries[0]; +}; + +struct ExpeditionLeaderSet_Struct +{ +/*000*/ char leader_name[64]; }; struct CorpseDrag_Struct diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index ad43ee61d..368d8fbec 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -127,7 +127,6 @@ void EQEmuLogSys::LoadLogSettingsDefaults() log_settings[Logs::HotReload].log_to_gmsay = static_cast(Logs::General); log_settings[Logs::HotReload].log_to_console = static_cast(Logs::General); log_settings[Logs::Loot].log_to_gmsay = static_cast(Logs::General); - log_settings[Logs::Scheduler].log_to_console = static_cast(Logs::General); /** * RFC 5424 @@ -207,7 +206,11 @@ std::string EQEmuLogSys::FormatOutMessageString( const std::string &in_message ) { - std::string return_string = "[" + GetPlatformName() + "] "; + std::string return_string; + + if (IsRfc5424LogCategory(log_category)) { + return_string = "[" + GetPlatformName() + "] "; + } return return_string + "[" + Logs::LogCategoryName[log_category] + "] " + in_message; } diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index 0b33b55a3..80cf9851f 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -118,9 +118,6 @@ namespace Logs { Merchants, ZonePoints, Loot, - Expeditions, - DynamicZones, - Scheduler, MaxCategoryID /* Don't Remove this */ }; @@ -197,10 +194,7 @@ namespace Logs { "HotReload", "Merchants", "ZonePoints", - "Loot", - "Expeditions", - "DynamicZones", - "Scheduler", + "Loot" }; } diff --git a/common/eqemu_logsys_log_aliases.h b/common/eqemu_logsys_log_aliases.h index ddd27335f..514f37e21 100644 --- a/common/eqemu_logsys_log_aliases.h +++ b/common/eqemu_logsys_log_aliases.h @@ -161,16 +161,6 @@ OutF(LogSys, Logs::Detail, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) -#define LogGroup(message, ...) do {\ - if (LogSys.log_settings[Logs::Group].is_category_enabled == 1)\ - OutF(LogSys, Logs::General, Logs::Group, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogGroupDetail(message, ...) do {\ - if (LogSys.log_settings[Logs::Group].is_category_enabled == 1)\ - OutF(LogSys, Logs::Detail, Logs::Group, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - #define LogGuilds(message, ...) do {\ if (LogSys.log_settings[Logs::Guilds].is_category_enabled == 1)\ OutF(LogSys, Logs::General, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ @@ -611,41 +601,6 @@ OutF(LogSys, Logs::Detail, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) -#define LogExpeditions(message, ...) do {\ - if (LogSys.log_settings[Logs::Expeditions].is_category_enabled == 1)\ - OutF(LogSys, Logs::General, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogExpeditionsModerate(message, ...) do {\ - if (LogSys.log_settings[Logs::Expeditions].is_category_enabled == 1)\ - OutF(LogSys, Logs::Moderate, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogExpeditionsDetail(message, ...) do {\ - if (LogSys.log_settings[Logs::Expeditions].is_category_enabled == 1)\ - OutF(LogSys, Logs::Detail, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogDynamicZones(message, ...) do {\ - if (LogSys.log_settings[Logs::DynamicZones].is_category_enabled == 1)\ - OutF(LogSys, Logs::General, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogDynamicZonesDetail(message, ...) do {\ - if (LogSys.log_settings[Logs::DynamicZones].is_category_enabled == 1)\ - OutF(LogSys, Logs::Detail, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogScheduler(message, ...) do {\ - if (LogSys.log_settings[Logs::Scheduler].is_category_enabled == 1)\ - OutF(LogSys, Logs::General, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogSchedulerDetail(message, ...) do {\ - if (LogSys.log_settings[Logs::Scheduler].is_category_enabled == 1)\ - OutF(LogSys, Logs::Detail, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - #define Log(debug_level, log_category, message, ...) do {\ if (LogSys.log_settings[log_category].is_category_enabled == 1)\ LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ @@ -739,12 +694,6 @@ #define LogDoorsDetail(message, ...) do {\ } while (0) -#define LogGroup(message, ...) do {\ -} while (0) - -#define LogGroupDetail(message, ...) do {\ -} while (0) - #define LogGuilds(message, ...) do {\ } while (0) @@ -1003,21 +952,6 @@ #define LogZonePointsDetail(message, ...) do {\ } while (0) -#define LogExpeditions(message, ...) do {\ -} while (0) - -#define LogExpeditionsModerate(message, ...) do {\ -} while (0) - -#define LogExpeditionsDetail(message, ...) do {\ -} while (0) - -#define LogDynamicZones(message, ...) do {\ -} while (0) - -#define LogDynamicZonesDetail(message, ...) do {\ -} while (0) - #define Log(debug_level, log_category, message, ...) do {\ } while (0) diff --git a/common/event/timer.h b/common/event/timer.h index 73ac7af35..e71459630 100644 --- a/common/event/timer.h +++ b/common/event/timer.h @@ -51,7 +51,7 @@ namespace EQ { void Stop() { if (m_timer) { uv_close((uv_handle_t*)m_timer, [](uv_handle_t* handle) { - delete (uv_timer_t *)handle; + delete handle; }); m_timer = nullptr; } diff --git a/common/expedition_base.cpp b/common/expedition_base.cpp deleted file mode 100644 index a5f890204..000000000 --- a/common/expedition_base.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "expedition_base.h" -#include "repositories/expeditions_repository.h" -#include "rulesys.h" - -ExpeditionBase::ExpeditionBase(uint32_t id, const std::string& uuid, - const std::string& expedition_name, const DynamicZoneMember& leader -) : - m_id(id), - m_uuid(uuid), - m_expedition_name(expedition_name), - m_leader(leader) -{ -} - -void ExpeditionBase::LoadRepositoryResult(ExpeditionsRepository::ExpeditionWithLeader&& entry) -{ - m_id = entry.id; - m_uuid = std::move(entry.uuid); - m_expedition_name = std::move(entry.expedition_name); - m_add_replay_on_join = entry.add_replay_on_join; - m_is_locked = entry.is_locked; - m_leader.id = entry.leader_id; - m_leader.name = std::move(entry.leader_name); -} - -void ExpeditionBase::AddMemberFromRepositoryResult( - ExpeditionMembersRepository::MemberWithName&& entry) -{ - auto status = DynamicZoneMemberStatus::Unknown; - AddInternalMember({ entry.character_id, std::move(entry.character_name), status }); -} - -void ExpeditionBase::AddInternalMember(const DynamicZoneMember& member) -{ - if (!HasMember(member.id)) - { - m_members.emplace_back(member); - } -} - -void ExpeditionBase::RemoveInternalMember(uint32_t character_id) -{ - m_members.erase(std::remove_if(m_members.begin(), m_members.end(), - [&](const DynamicZoneMember& member) { return member.id == character_id; } - ), m_members.end()); -} - - -bool ExpeditionBase::HasMember(uint32_t character_id) -{ - return std::any_of(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { - return member.id == character_id; - }); -} - -bool ExpeditionBase::HasMember(const std::string& character_name) -{ - return std::any_of(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { - return (strcasecmp(member.name.c_str(), character_name.c_str()) == 0); - }); -} - -DynamicZoneMember ExpeditionBase::GetMemberData(uint32_t character_id) -{ - auto it = std::find_if(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { - return member.id == character_id; - }); - - DynamicZoneMember member_data; - if (it != m_members.end()) - { - member_data = *it; - } - return member_data; -} - -DynamicZoneMember ExpeditionBase::GetMemberData(const std::string& character_name) -{ - auto it = std::find_if(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { - return (strcasecmp(member.name.c_str(), character_name.c_str()) == 0); - }); - - DynamicZoneMember member_data; - if (it != m_members.end()) - { - member_data = *it; - } - return member_data; -} - -bool ExpeditionBase::SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status) -{ - if (status == DynamicZoneMemberStatus::InDynamicZone && !RuleB(Expedition, EnableInDynamicZoneStatus)) - { - status = DynamicZoneMemberStatus::Online; - } - - if (character_id == m_leader.id) - { - m_leader.status = status; - } - - auto it = std::find_if(m_members.begin(), m_members.end(), - [&](const DynamicZoneMember& member) { return member.id == character_id; }); - - if (it != m_members.end() && it->status != status) - { - it->status = status; - return true; - } - - return false; -} diff --git a/common/expedition_base.h b/common/expedition_base.h deleted file mode 100644 index e93c707b5..000000000 --- a/common/expedition_base.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef COMMON_EXPEDITION_BASE_H -#define COMMON_EXPEDITION_BASE_H - -#include "dynamic_zone_base.h" -#include "repositories/expeditions_repository.h" -#include "repositories/expedition_members_repository.h" -#include -#include -#include - -class ExpeditionBase -{ -public: - virtual ~ExpeditionBase() = default; - ExpeditionBase(const ExpeditionBase&) = default; - ExpeditionBase(ExpeditionBase&&) = default; - ExpeditionBase& operator=(const ExpeditionBase&) = default; - ExpeditionBase& operator=(ExpeditionBase&&) = default; - - uint32_t GetID() const { return m_id; } - uint32_t GetLeaderID() const { return m_leader.id; } - uint32_t GetMemberCount() const { return static_cast(m_members.size()); } - const std::string& GetName() const { return m_expedition_name; } - const std::string& GetLeaderName() const { return m_leader.name; } - const std::string& GetUUID() const { return m_uuid; } - const std::vector& GetMembers() const { return m_members; } - - void AddInternalMember(const DynamicZoneMember& member); - void ClearInternalMembers() { m_members.clear(); } - bool HasMember(const std::string& character_name); - bool HasMember(uint32_t character_id); - bool IsEmpty() const { return m_members.empty(); } - void RemoveInternalMember(uint32_t character_id); - bool SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status); - - void LoadRepositoryResult(ExpeditionsRepository::ExpeditionWithLeader&& entry); - void AddMemberFromRepositoryResult(ExpeditionMembersRepository::MemberWithName&& entry); - -protected: - ExpeditionBase() = default; - ExpeditionBase(uint32_t id, const std::string& uuid, const std::string& expedition_name, - const DynamicZoneMember& leader); - - DynamicZoneMember GetMemberData(uint32_t character_id); - DynamicZoneMember GetMemberData(const std::string& character_name); - - uint32_t m_id = 0; - bool m_is_locked = false; - bool m_add_replay_on_join = true; - std::string m_uuid; - std::string m_expedition_name; - DynamicZoneMember m_leader; - std::vector m_members; -}; - -#endif diff --git a/common/expedition_lockout_timer.cpp b/common/expedition_lockout_timer.cpp deleted file mode 100644 index dc4cb97c6..000000000 --- a/common/expedition_lockout_timer.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition_lockout_timer.h" -#include "../common/string_util.h" -#include "../common/rulesys.h" -#include "../common/util/uuid.h" -#include - -const char* const DZ_REPLAY_TIMER_NAME = "Replay Timer"; // see December 14, 2016 patch notes - -ExpeditionLockoutTimer::ExpeditionLockoutTimer( - std::string expedition_uuid, std::string expedition_name, - std::string event_name, uint64_t expire_time, uint32_t duration -) : - m_expedition_uuid{std::move(expedition_uuid)}, - m_expedition_name{std::move(expedition_name)}, - m_event_name{std::move(event_name)}, - m_expire_time(std::chrono::system_clock::from_time_t(expire_time)), - m_duration(duration) -{ - if (m_event_name == DZ_REPLAY_TIMER_NAME) - { - m_is_replay_timer = true; - } -} - -ExpeditionLockoutTimer ExpeditionLockoutTimer::CreateLockout( - const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid) -{ - seconds = static_cast(seconds * RuleR(Expedition, LockoutDurationMultiplier)); - - if (uuid.empty()) - { - uuid = EQ::Util::UUID::Generate().ToString(); - } - - ExpeditionLockoutTimer lockout{uuid, expedition_name, event_name, 0, seconds}; - lockout.Reset(); // sets expire time - return lockout; -} - -uint32_t ExpeditionLockoutTimer::GetSecondsRemaining() const -{ - auto now = std::chrono::system_clock::now(); - if (m_expire_time > now) - { - auto remaining = m_expire_time - now; - return static_cast(std::chrono::duration_cast(remaining).count()); - } - return 0; -} - -ExpeditionLockoutTimer::DaysHoursMinutes ExpeditionLockoutTimer::GetDaysHoursMinutesRemaining() const -{ - auto seconds = GetSecondsRemaining(); - return ExpeditionLockoutTimer::DaysHoursMinutes{ - fmt::format_int(seconds / 86400).str(), // days - fmt::format_int((seconds / 3600) % 24).str(), // hours - fmt::format_int((seconds / 60) % 60).str() // minutes - }; -} - -bool ExpeditionLockoutTimer::IsSameLockout(const ExpeditionLockoutTimer& compare_lockout) const -{ - return compare_lockout.IsSameLockout(GetExpeditionName(), GetEventName()); -} - -bool ExpeditionLockoutTimer::IsSameLockout( - const std::string& expedition_name, const std::string& event_name) const -{ - return GetExpeditionName() == expedition_name && GetEventName() == event_name; -} - -void ExpeditionLockoutTimer::AddLockoutTime(int seconds) -{ - seconds = static_cast(seconds * RuleR(Expedition, LockoutDurationMultiplier)); - - auto new_duration = std::max(0, static_cast(m_duration.count()) + seconds); - - auto start_time = m_expire_time - m_duration; - m_duration = std::chrono::seconds(new_duration); - m_expire_time = start_time + m_duration; -} diff --git a/common/expedition_lockout_timer.h b/common/expedition_lockout_timer.h deleted file mode 100644 index 8cbf3da54..000000000 --- a/common/expedition_lockout_timer.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EXPEDITION_LOCKOUT_TIMER_H -#define EXPEDITION_LOCKOUT_TIMER_H - -#include -#include - -extern const char* const DZ_REPLAY_TIMER_NAME; - -class ExpeditionLockoutTimer -{ -public: - ExpeditionLockoutTimer() = default; - ExpeditionLockoutTimer( - std::string expedition_uuid, std::string expedition_name, - std::string event_name, uint64_t expire_time, uint32_t duration); - - static ExpeditionLockoutTimer CreateLockout( - const std::string& expedition_name, const std::string& event_name, - uint32_t seconds, std::string uuid = {}); - - struct DaysHoursMinutes - { - std::string days; - std::string hours; - std::string mins; - }; - - void AddLockoutTime(int seconds); - uint32_t GetDuration() const { return static_cast(m_duration.count()); } - uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); } - uint64_t GetStartTime() const { return std::chrono::system_clock::to_time_t(m_expire_time - m_duration); } - uint32_t GetSecondsRemaining() const; - DaysHoursMinutes GetDaysHoursMinutesRemaining() const; - const std::string& GetExpeditionName() const { return m_expedition_name; } - const std::string& GetExpeditionUUID() const { return m_expedition_uuid; } - const std::string& GetEventName() const { return m_event_name; } - bool IsExpired() const { return GetSecondsRemaining() == 0; } - bool IsFromExpedition(const std::string& uuid) const { return uuid == m_expedition_uuid; } - bool IsReplayTimer() const { return m_is_replay_timer; } - bool IsSameLockout(const ExpeditionLockoutTimer& compare_lockout) const; - bool IsSameLockout(const std::string& expedition_name, const std::string& event_name) const; - void Reset() { m_expire_time = std::chrono::system_clock::now() + m_duration; } - void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); } - void SetExpireTime(uint64_t expire_time) { m_expire_time = std::chrono::system_clock::from_time_t(expire_time); } - void SetUUID(const std::string& uuid) { m_expedition_uuid = uuid; } - -private: - bool m_is_replay_timer = false; - std::string m_expedition_uuid; // expedition received in - std::string m_expedition_name; - std::string m_event_name; - std::chrono::seconds m_duration; - std::chrono::time_point m_expire_time; -}; - -#endif diff --git a/common/net/console_server.cpp b/common/net/console_server.cpp index 31b597bfb..ab420bd42 100644 --- a/common/net/console_server.cpp +++ b/common/net/console_server.cpp @@ -4,7 +4,7 @@ EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port) { - m_server = std::make_unique(); + m_server.reset(new EQ::Net::TCPServer()); m_server->Listen(addr, port, false, [this](std::shared_ptr connection) { ConsoleServerConnection *c = new ConsoleServerConnection(this, connection); m_connections.insert(std::make_pair(c->GetUUID(), std::unique_ptr(c))); diff --git a/common/net/servertalk_client_connection.cpp b/common/net/servertalk_client_connection.cpp index 88cfc021a..0a5dceac6 100644 --- a/common/net/servertalk_client_connection.cpp +++ b/common/net/servertalk_client_connection.cpp @@ -3,7 +3,7 @@ #include "../eqemu_logsys.h" EQ::Net::ServertalkClient::ServertalkClient(const std::string &addr, int port, bool ipv6, const std::string &identifier, const std::string &credentials) - : m_timer(std::make_unique(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this))) + : m_timer(std::unique_ptr(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this)))) { m_port = port; m_ipv6 = ipv6; diff --git a/common/net/servertalk_legacy_client_connection.cpp b/common/net/servertalk_legacy_client_connection.cpp index 8be329e65..3cbe1c85a 100644 --- a/common/net/servertalk_legacy_client_connection.cpp +++ b/common/net/servertalk_legacy_client_connection.cpp @@ -3,7 +3,7 @@ #include "../eqemu_logsys.h" EQ::Net::ServertalkLegacyClient::ServertalkLegacyClient(const std::string &addr, int port, bool ipv6) - : m_timer(std::make_unique(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this))) + : m_timer(std::unique_ptr(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this)))) { m_port = port; m_ipv6 = ipv6; diff --git a/common/net/servertalk_server.cpp b/common/net/servertalk_server.cpp index 297d4cd31..fcbea917c 100644 --- a/common/net/servertalk_server.cpp +++ b/common/net/servertalk_server.cpp @@ -13,7 +13,7 @@ void EQ::Net::ServertalkServer::Listen(const ServertalkServerOptions& opts) m_encrypted = opts.encrypted; m_credentials = opts.credentials; m_allow_downgrade = opts.allow_downgrade; - m_server = std::make_unique(); + m_server.reset(new EQ::Net::TCPServer()); m_server->Listen(opts.port, opts.ipv6, [this](std::shared_ptr connection) { m_unident_connections.push_back(std::make_shared(connection, this, m_encrypted, m_allow_downgrade)); }); diff --git a/common/net/tcp_connection.cpp b/common/net/tcp_connection.cpp index 372442c7d..695ac7643 100644 --- a/common/net/tcp_connection.cpp +++ b/common/net/tcp_connection.cpp @@ -2,7 +2,7 @@ #include "../event/event_loop.h" void on_close_handle(uv_handle_t* handle) { - delete (uv_tcp_t *)handle; + delete handle; } EQ::Net::TCPConnection::TCPConnection(uv_tcp_t *socket) @@ -115,7 +115,7 @@ void EQ::Net::TCPConnection::Disconnect() connection->m_on_disconnect_cb(connection); } - delete (uv_tcp_t *)handle; + delete handle; }); m_socket = nullptr; } diff --git a/common/net/tcp_server.cpp b/common/net/tcp_server.cpp index 777c92be5..ed68d54dc 100644 --- a/common/net/tcp_server.cpp +++ b/common/net/tcp_server.cpp @@ -2,7 +2,7 @@ #include "../event/event_loop.h" void on_close_tcp_server_handle(uv_handle_t* handle) { - delete (uv_tcp_t *)handle; + delete handle; } EQ::Net::TCPServer::TCPServer() diff --git a/common/net/websocket_server.cpp b/common/net/websocket_server.cpp index dda1a4a96..b46fc7953 100644 --- a/common/net/websocket_server.cpp +++ b/common/net/websocket_server.cpp @@ -34,8 +34,8 @@ struct EQ::Net::WebsocketServer::Impl EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port) { - _impl = std::make_unique(); - _impl->server = std::make_unique(); + _impl.reset(new Impl()); + _impl->server.reset(new EQ::Net::TCPServer()); _impl->server->Listen(addr, port, false, [this](std::shared_ptr connection) { auto wsc = _impl->ws_server.get_connection(); WebsocketServerConnection *c = new WebsocketServerConnection(this, connection, wsc); @@ -53,7 +53,7 @@ EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port) return websocketpp::lib::error_code(); }); - _impl->ping_timer = std::make_unique(5000, true, [this](EQ::Timer *t) { + _impl->ping_timer.reset(new EQ::Timer(5000, true, [this](EQ::Timer *t) { auto iter = _impl->connections.begin(); while (iter != _impl->connections.end()) { @@ -67,7 +67,7 @@ EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port) iter++; } - }); + })); _impl->methods.insert(std::make_pair("login", MethodHandlerEntry(std::bind(&WebsocketServer::Login, this, std::placeholders::_1, std::placeholders::_2), 0))); _impl->methods.insert(std::make_pair("subscribe", MethodHandlerEntry(std::bind(&WebsocketServer::Subscribe, this, std::placeholders::_1, std::placeholders::_2), 0))); diff --git a/common/net/websocket_server_connection.cpp b/common/net/websocket_server_connection.cpp index 3c1271518..50b117062 100644 --- a/common/net/websocket_server_connection.cpp +++ b/common/net/websocket_server_connection.cpp @@ -20,7 +20,7 @@ EQ::Net::WebsocketServerConnection::WebsocketServerConnection(WebsocketServer *p std::shared_ptr connection, std::shared_ptr ws_connection) { - _impl = std::make_unique(); + _impl.reset(new Impl()); _impl->parent = parent; _impl->connection = connection; _impl->id = EQ::Util::UUID::Generate().ToString(); diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 38b109677..c9e80a0f1 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -710,48 +710,15 @@ namespace RoF FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); - OUT(client_id); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -772,108 +739,112 @@ namespace RoF ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->unknown004 = 785316192; + eq->unknown008 = 435601; + strncpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); + strncpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strncpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); + strncpy(eq->player_name, emu->player_name, sizeof(eq->player_name)); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1856,7 +1827,6 @@ namespace RoF OUT(FastRegenHP); OUT(FastRegenMana); OUT(FastRegenEndurance); - OUT(underworld_teleport_index); eq->FogDensity = emu->fog_density; @@ -1968,7 +1938,7 @@ namespace RoF for (int r = 0; r < 5; r++) { - outapp->WriteUInt32(emu->binds[r].zone_id); + outapp->WriteUInt32(emu->binds[r].zoneId); outapp->WriteFloat(emu->binds[r].x); outapp->WriteFloat(emu->binds[r].y); outapp->WriteFloat(emu->binds[r].z); @@ -4417,84 +4387,6 @@ namespace RoF FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - IN(unknown000); - IN(unknown004); - IN(unknown008); - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - IN(unknown028); - IN(unknown032); - IN(unknown036); - IN(unknown040); - IN(unknown044); - IN(unknown048); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 55fbfe2c8..1b3827984 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -759,48 +759,15 @@ namespace RoF2 FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); - OUT(client_id); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -821,108 +788,112 @@ namespace RoF2 ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->unknown004 = 785316192; + eq->unknown008 = 435601; + strncpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); + strncpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strncpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); + strncpy(eq->player_name, emu->player_name, sizeof(eq->player_name)); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1905,7 +1876,6 @@ namespace RoF2 OUT(FastRegenHP); OUT(FastRegenMana); OUT(FastRegenEndurance); - OUT(underworld_teleport_index); eq->FogDensity = emu->fog_density; @@ -2025,7 +1995,7 @@ namespace RoF2 for (int r = 0; r < 5; r++) { - outapp->WriteUInt32(emu->binds[r].zone_id); + outapp->WriteUInt32(emu->binds[r].zoneId); outapp->WriteFloat(emu->binds[r].x); outapp->WriteFloat(emu->binds[r].y); outapp->WriteFloat(emu->binds[r].z); @@ -4614,84 +4584,6 @@ namespace RoF2 FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - IN(unknown000); - IN(unknown004); - IN(unknown008); - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - IN(unknown028); - IN(unknown032); - IN(unknown036); - IN(unknown040); - IN(unknown044); - IN(unknown048); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/rof2_ops.h b/common/patches/rof2_ops.h index 22b6e6662..32798fef5 100644 --- a/common/patches/rof2_ops.h +++ b/common/patches/rof2_ops.h @@ -58,16 +58,13 @@ E(OP_DeleteCharge) E(OP_DeleteItem) E(OP_DeleteSpawn) E(OP_DisciplineUpdate) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_ExpansionInfo) E(OP_FormattedMessage) @@ -162,12 +159,6 @@ D(OP_ConsiderCorpse) D(OP_Consume) D(OP_Damage) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_EnvDamage) D(OP_FaceChange) diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index a37e25d61..67947d57f 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -628,7 +628,7 @@ struct NewZone_Struct { /*0856*/ uint32 scriptNPCReceivedanItem; /*0860*/ uint32 bCheck; // padded bool /*0864*/ uint32 scriptIDSomething; - /*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions + /*0868*/ uint32 scriptIDSomething2; /*0872*/ uint32 scriptIDSomething3; /*0876*/ uint32 SuspendBuffs; // padded bool /*0880*/ uint32 LavaDamage; // LavaDamage value @@ -1053,7 +1053,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -2084,7 +2084,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -4882,169 +4882,52 @@ struct VeteranClaim /*076*/ uint32 action; }; -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; // unique character id -/*004*/ uint32 unknown004; -/*008*/ char inviter_name[64]; -/*072*/ char expedition_name[128]; -/*200*/ uint8 swapping; // 0: adding 1: swapping -/*201*/ char swap_name[64]; // if swapping, swap name being removed -/*265*/ uint8 padding[3]; -/*268*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*270*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct +struct ExpeditionEntryHeader_Struct { /*000*/ uint32 unknown000; +/*000*/ uint32 number_of_entries; +}; + +struct ExpeditionJoinPrompt_Struct +{ +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; -/*008*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*010*/ uint16 dz_instance_id; -/*012*/ uint8 accepted; // 0: declined 1: accepted -/*013*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*014*/ char swap_name[64]; // swap name sent in invite -/*078*/ uint8 unknown078; // padding garbage? -/*079*/ uint8 unknown079; // padding garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 assigned; // padded bool, 0: clear info, 1: fill window info -/*012*/ uint32 max_players; -/*016*/ char dz_name[128]; -/*144*/ char leader_name[64]; -//*208*/ uint32 dz_type; // only in newer clients, if not 1 (expedition type) window does not auto show when dz info assigned -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; // number of players in window -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*012*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char add_player_name[64]; // swap to (player must confirm) -/*072*/ char rem_player_name[64]; // swap from +/*008*/ char player_name[64]; +/*072*/ char expedition_name[64]; }; struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; /*008*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) +/*000*/ uint32 clientid; +/*004*/ uint32 unknown004; /*008*/ uint32 unknown008; +/*012*/ uint32 max_players; +/*016*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; -}; - -struct DynamicZoneChooseZoneEntry_Struct -{ -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // seen 28 00 00 00 (40), sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; // ff ff ff ff -/*004*/ uint32 unknown004; // seen 69 00 00 00 -/*008*/ uint32 unknown008; // ff ff ff ff -/*012*/ uint32 unknown_id1; // from choose zone entry message -/*016*/ uint16 dz_zone_id; // dz_id pair -/*018*/ uint16 dz_instance_id; -/*020*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*024*/ uint32 unknown_id2; // from choose zone entry message -/*028*/ uint32 unknown028; // 00 00 00 00 -/*032*/ uint32 unknown032; // always same as unknown044 -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; // always same as unknown032 -/*048*/ uint32 unknown048; // seen 01 00 00 00 and 02 00 00 00 -}; - -struct KickPlayers_Struct -{ -/*000*/ char char_name[64]; -/*064*/ uint32 unknown064; // always 0 -/*068*/ uint8 kick_expedition; // true if /kickplayers exp -/*069*/ uint8 kick_task; // true if /kickplayers task -/*070*/ uint8 padding[2]; +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; struct MaxCharacters_Struct diff --git a/common/patches/rof_ops.h b/common/patches/rof_ops.h index f06834d21..11fd83f51 100644 --- a/common/patches/rof_ops.h +++ b/common/patches/rof_ops.h @@ -44,16 +44,13 @@ E(OP_DeleteCharge) E(OP_DeleteItem) E(OP_DeleteSpawn) E(OP_DisciplineUpdate) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_ExpansionInfo) E(OP_FormattedMessage) @@ -148,12 +145,6 @@ D(OP_ConsiderCorpse) D(OP_Consume) D(OP_Damage) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_EnvDamage) D(OP_FaceChange) diff --git a/common/patches/rof_structs.h b/common/patches/rof_structs.h index a8297b2ea..76324d59b 100644 --- a/common/patches/rof_structs.h +++ b/common/patches/rof_structs.h @@ -575,11 +575,7 @@ struct NewZone_Struct { /*0848*/ int32 unknown848; /*0852*/ uint16 zone_id; /*0854*/ uint16 zone_instance; -/*0856*/ uint32 scriptNPCReceivedanItem; -/*0860*/ uint32 bCheck; // padded bool -/*0864*/ uint32 scriptIDSomething; -/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions -/*0872*/ uint32 scriptIDSomething3; +/*0856*/ char unknown856[20]; /*0876*/ uint32 SuspendBuffs; /*0880*/ uint32 unknown880; // Seen 50 /*0884*/ uint32 unknown884; // Seen 10 @@ -998,7 +994,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -2062,7 +2058,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -4815,159 +4811,52 @@ struct VeteranClaim /*076*/ uint32 action; }; -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; // unique character id -/*004*/ uint32 unknown004; -/*008*/ char inviter_name[64]; -/*072*/ char expedition_name[128]; -/*200*/ uint8 swapping; // 0: adding 1: swapping -/*201*/ char swap_name[64]; // if swapping, swap name being removed -/*265*/ uint8 padding[3]; -/*268*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*270*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct +struct ExpeditionEntryHeader_Struct { /*000*/ uint32 unknown000; +/*000*/ uint32 number_of_entries; +}; + +struct ExpeditionJoinPrompt_Struct +{ +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; -/*008*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*010*/ uint16 dz_instance_id; -/*012*/ uint8 accepted; // 0: declined 1: accepted -/*013*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*014*/ char swap_name[64]; // swap name sent in invite -/*078*/ uint8 unknown078; // padding garbage? -/*079*/ uint8 unknown079; // padding garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 assigned; // padded bool -/*012*/ uint32 max_players; -/*016*/ char dz_name[128]; -/*144*/ char leader_name[64]; -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; // number of players in window -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*012*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char add_player_name[64]; // swap to (player must confirm) -/*072*/ char rem_player_name[64]; // swap from +/*008*/ char player_name[64]; +/*072*/ char expedition_name[64]; }; struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; /*008*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) +/*000*/ uint32 clientid; +/*004*/ uint32 unknown004; /*008*/ uint32 unknown008; +/*012*/ uint32 max_players; +/*016*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; -}; - -struct DynamicZoneChooseZoneEntry_Struct -{ -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; // ff ff ff ff -/*004*/ uint32 unknown004; // seen 69 00 00 00 -/*008*/ uint32 unknown008; // ff ff ff ff -/*012*/ uint32 unknown_id1; // from choose zone entry message -/*016*/ uint16 dz_zone_id; // dz_id pair -/*018*/ uint16 dz_instance_id; -/*020*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*024*/ uint32 unknown_id2; // from choose zone entry message -/*028*/ uint32 unknown028; // 00 00 00 00 -/*032*/ uint32 unknown032; // always same as unknown044 -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; // always same as unknown032 -/*048*/ uint32 unknown048; // seen 01 00 00 00 and 02 00 00 00 +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; struct MaxCharacters_Struct diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 404190d09..6e3f274e7 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -483,48 +483,15 @@ namespace SoD FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); - OUT(client_id); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -545,109 +512,112 @@ namespace SoD ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->unknown004 = 785316192; + eq->unknown008 = 435601; + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->leader_name, emu->leader_name); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->player_name, emu->player_name); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1383,7 +1353,6 @@ namespace SoD OUT(FastRegenHP); OUT(FastRegenMana); OUT(FastRegenEndurance); - OUT(underworld_teleport_index); /*fill in some unknowns with observed values, hopefully it will help */ eq->unknown800 = -1; @@ -1475,7 +1444,7 @@ namespace SoD eq->level1 = emu->level; // OUT(unknown00022[2]); for (r = 0; r < 5; r++) { - OUT(binds[r].zone_id); + OUT(binds[r].zoneId); OUT(binds[r].x); OUT(binds[r].y); OUT(binds[r].z); @@ -3004,84 +2973,6 @@ namespace SoD FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - IN(unknown000); - IN(unknown004); - IN(unknown008); - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - IN(unknown028); - IN(unknown032); - IN(unknown036); - IN(unknown040); - IN(unknown044); - IN(unknown048); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/sod_ops.h b/common/patches/sod_ops.h index 5216a77ce..6909e1f28 100644 --- a/common/patches/sod_ops.h +++ b/common/patches/sod_ops.h @@ -35,16 +35,13 @@ E(OP_Consider) E(OP_Damage) E(OP_DeleteCharge) E(OP_DeleteItem) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_ExpansionInfo) E(OP_FormattedMessage) @@ -114,12 +111,6 @@ D(OP_Consider) D(OP_ConsiderCorpse) D(OP_Consume) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_FaceChange) D(OP_FindPersonRequest) diff --git a/common/patches/sod_structs.h b/common/patches/sod_structs.h index 70866db8f..2a8b0cec8 100644 --- a/common/patches/sod_structs.h +++ b/common/patches/sod_structs.h @@ -444,11 +444,7 @@ struct NewZone_Struct { /*0848*/ int32 unknown848; /*0852*/ uint16 zone_id; /*0854*/ uint16 zone_instance; -/*0856*/ uint32 scriptNPCReceivedanItem; -/*0860*/ uint32 bCheck; // padded bool -/*0864*/ uint32 scriptIDSomething; -/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions -/*0872*/ uint32 scriptIDSomething3; +/*0856*/ char unknown856[20]; /*0876*/ uint32 SuspendBuffs; /*0880*/ uint32 unknown880; //seen 50 /*0884*/ uint32 unknown884; //seen 10 @@ -803,7 +799,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1714,7 +1710,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -4169,160 +4165,52 @@ struct VeteranReward /*012*/ VeteranRewardItem items[8]; }; - -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; // unique character id -/*004*/ uint32 unknown004; -/*008*/ char inviter_name[64]; -/*072*/ char expedition_name[128]; -/*200*/ uint8 swapping; // 0: adding 1: swapping -/*201*/ char swap_name[64]; // if swapping, swap name being removed -/*265*/ uint8 padding[3]; -/*268*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*270*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct +struct ExpeditionEntryHeader_Struct { /*000*/ uint32 unknown000; +/*000*/ uint32 number_of_entries; +}; + +struct ExpeditionJoinPrompt_Struct +{ +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; -/*008*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*010*/ uint16 dz_instance_id; -/*012*/ uint8 accepted; // 0: declined 1: accepted -/*013*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*014*/ char swap_name[64]; // swap name sent in invite -/*078*/ uint8 unknown078; // padding garbage? -/*079*/ uint8 unknown079; // padding garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 assigned; // padded bool -/*012*/ uint32 max_players; -/*016*/ char dz_name[128]; -/*144*/ char leader_name[64]; -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; // number of players in window -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*012*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char add_player_name[64]; // swap to (player must confirm) -/*072*/ char rem_player_name[64]; // swap from +/*008*/ char player_name[64]; +/*072*/ char expedition_name[64]; }; struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; /*008*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) +/*000*/ uint32 clientid; +/*004*/ uint32 unknown004; /*008*/ uint32 unknown008; +/*012*/ uint32 max_players; +/*016*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; -}; - -struct DynamicZoneChooseZoneEntry_Struct -{ -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; // ff ff ff ff -/*004*/ uint32 unknown004; // seen 69 00 00 00 -/*008*/ uint32 unknown008; // ff ff ff ff -/*012*/ uint32 unknown_id1; // from choose zone entry message -/*016*/ uint16 dz_zone_id; // dz_id pair -/*018*/ uint16 dz_instance_id; -/*020*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*024*/ uint32 unknown_id2; // from choose zone entry message -/*028*/ uint32 unknown028; // 00 00 00 00 -/*032*/ uint32 unknown032; // always same as unknown044 -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; // always same as unknown032 -/*048*/ uint32 unknown048; // seen 01 00 00 00 and 02 00 00 00 +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; struct AltCurrencySelectItem_Struct { diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 07758bba6..94e94f946 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -471,48 +471,14 @@ namespace SoF FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); - - OUT(client_id); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -533,108 +499,111 @@ namespace SoF ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->enabled_max = 1; + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->leader_name, emu->leader_name); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - for (uint32 i = 0; i < emu->count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (int i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->player_name, emu->player_name); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + //ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1061,7 +1030,6 @@ namespace SoF OUT(FastRegenHP); OUT(FastRegenMana); OUT(FastRegenEndurance); - OUT(underworld_teleport_index); /*fill in some unknowns with observed values, hopefully it will help */ eq->unknown796 = -1; @@ -1140,7 +1108,7 @@ namespace SoF eq->level1 = emu->level; // OUT(unknown00022[2]); for (r = 0; r < 5; r++) { - OUT(binds[r].zone_id); + OUT(binds[r].zoneId); OUT(binds[r].x); OUT(binds[r].y); OUT(binds[r].z); @@ -2466,83 +2434,6 @@ namespace SoF FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - emu->unknown000 = eq->unknown000; - emu->unknown008 = eq->unknown004; - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - emu->unknown028 = eq->unknown024; - emu->unknown032 = eq->unknown028; - emu->unknown036 = eq->unknown032; - emu->unknown040 = eq->unknown036; - emu->unknown044 = eq->unknown040; - emu->unknown048 = eq->unknown044; - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/sof_ops.h b/common/patches/sof_ops.h index 653bb5979..0ff2cfd2f 100644 --- a/common/patches/sof_ops.h +++ b/common/patches/sof_ops.h @@ -36,16 +36,13 @@ E(OP_Damage) E(OP_DeleteCharge) E(OP_DeleteItem) E(OP_DeleteSpawn) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_ExpansionInfo) E(OP_FormattedMessage) @@ -106,12 +103,6 @@ D(OP_Consider) D(OP_ConsiderCorpse) D(OP_Consume) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_FaceChange) D(OP_FindPersonRequest) diff --git a/common/patches/sof_structs.h b/common/patches/sof_structs.h index 97b200a91..c76ef0b96 100644 --- a/common/patches/sof_structs.h +++ b/common/patches/sof_structs.h @@ -448,11 +448,7 @@ struct NewZone_Struct { /*0844*/ int32 unknown844; /*0848*/ uint16 zone_id; /*0850*/ uint16 zone_instance; -/*0852*/ uint32 scriptNPCReceivedanItem; -/*0856*/ uint32 bCheck; // padded bool -/*0860*/ uint32 scriptIDSomething; -/*0864*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions -/*0868*/ uint32 scriptIDSomething3; +/*0852*/ char unknown852[20]; /*0872*/ uint32 SuspendBuffs; /*0876*/ uint32 unknown876; //seen 50 /*0880*/ uint32 unknown880; //seen 10 @@ -804,7 +800,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1742,7 +1738,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -4088,150 +4084,43 @@ struct VeteranReward /*012*/ VeteranRewardItem items[8]; }; -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; -/*004*/ char inviter_name[64]; -/*068*/ char expedition_name[128]; -/*196*/ uint8 swapping; // 0: adding 1: swapping -/*197*/ char swap_name[64]; // if swapping, swap name being removed -/*261*/ uint8 padding[3]; -/*264*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*268*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*006*/ uint16 dz_instance_id; -/*008*/ uint8 accepted; // 0: declined 1: accepted -/*009*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*010*/ char swap_name[64]; // swap name sent in invite -/*074*/ uint8 unknown078; // padding/garbage? -/*075*/ uint8 unknown079; // padding/garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 assigned; // padded bool -/*008*/ uint32 max_players; -/*012*/ char dz_name[128]; -/*140*/ char leader_name[64]; -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*008*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ char add_player_name[64]; // swap to (player must confirm) -/*068*/ char rem_player_name[64]; // swap from -}; - struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 unknown000; /*004*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) -/*008*/ uint32 unknown008; +/*000*/ uint32 clientid; +/*004*/ uint32 enabled_max; +/*008*/ uint32 max_players; +/*012*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; -struct DynamicZoneChooseZoneEntry_Struct +struct ExpeditionJoinPrompt_Struct { -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ uint32 unknown_id1; -/*012*/ uint16 dz_zone_id; -/*014*/ uint16 dz_instance_id; -/*016*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*020*/ uint32 unknown_id2; -/*024*/ uint32 unknown024; -/*028*/ uint32 unknown028; // always same as unknown040 -/*032*/ uint32 unknown032; -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; // always same as unknown028 -/*044*/ uint32 unknown044; +/*000*/ uint32 clientid; +/*004*/ char player_name[64]; +/*068*/ char expedition_name[64]; }; struct AltCurrencySelectItem_Struct { diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index bb35d9f87..505bca10c 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -414,48 +414,15 @@ namespace Titanium FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); - OUT(client_id); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -476,108 +443,111 @@ namespace Titanium ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->enabled_max = 1; + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->leader_name, emu->leader_name); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->player_name, emu->player_name); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + //ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1022,7 +992,7 @@ namespace Titanium eq->level1 = emu->level; // OUT(unknown00022[2]); for (r = 0; r < 5; r++) { - OUT(binds[r].zone_id); + OUT(binds[r].zoneId); OUT(binds[r].x); OUT(binds[r].y); OUT(binds[r].z); @@ -1973,83 +1943,6 @@ namespace Titanium FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - emu->unknown000 = eq->unknown000; - emu->unknown008 = eq->unknown004; - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - emu->unknown028 = eq->unknown024; - emu->unknown032 = eq->unknown028; - emu->unknown036 = eq->unknown032; - emu->unknown040 = eq->unknown036; - emu->unknown044 = eq->unknown040; - emu->unknown048 = eq->unknown044; - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/titanium_ops.h b/common/patches/titanium_ops.h index 961c850fe..d3c8c1dde 100644 --- a/common/patches/titanium_ops.h +++ b/common/patches/titanium_ops.h @@ -32,16 +32,13 @@ E(OP_Damage) E(OP_DeleteCharge) E(OP_DeleteItem) E(OP_DeleteSpawn) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_FormattedMessage) E(OP_GroundSpawn) @@ -89,12 +86,6 @@ D(OP_CharacterCreate) D(OP_ClientUpdate) D(OP_Consume) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_FaceChange) D(OP_InspectAnswer) diff --git a/common/patches/titanium_structs.h b/common/patches/titanium_structs.h index 2846288bc..f620089d6 100644 --- a/common/patches/titanium_structs.h +++ b/common/patches/titanium_structs.h @@ -738,7 +738,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1509,7 +1509,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -3299,150 +3299,43 @@ struct VeteranReward /*004*/ VeteranRewardItem item; }; -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; -/*004*/ char inviter_name[64]; -/*068*/ char expedition_name[128]; -/*196*/ uint8 swapping; // 0: adding 1: swapping -/*197*/ char swap_name[64]; // if swapping, swap name being removed -/*261*/ uint8 padding[3]; -/*264*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*268*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*006*/ uint16 dz_instance_id; -/*008*/ uint8 accepted; // 0: declined 1: accepted -/*009*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*010*/ char swap_name[64]; // swap name sent in invite -/*074*/ uint8 unknown078; // padding/garbage? -/*075*/ uint8 unknown079; // padding/garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 assigned; // padded bool -/*008*/ uint32 max_players; -/*012*/ char dz_name[128]; -/*140*/ char leader_name[64]; -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*008*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ char add_player_name[64]; // swap to (player must confirm) -/*068*/ char rem_player_name[64]; // swap from -}; - struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 unknown000; /*004*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) -/*008*/ uint32 unknown008; +/*000*/ uint32 clientid; +/*004*/ uint32 enabled_max; +/*008*/ uint32 max_players; +/*012*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; -struct DynamicZoneChooseZoneEntry_Struct +struct ExpeditionJoinPrompt_Struct { -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ uint32 unknown_id1; -/*012*/ uint16 dz_zone_id; -/*014*/ uint16 dz_instance_id; -/*016*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*020*/ uint32 unknown_id2; -/*024*/ uint32 unknown024; -/*028*/ uint32 unknown028; // always same as unknown040 -/*032*/ uint32 unknown032; -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; // always same as unknown028 -/*044*/ uint32 unknown044; +/*000*/ uint32 clientid; +/*004*/ char player_name[64]; +/*068*/ char expedition_name[64]; }; struct LFGuild_SearchPlayer_Struct diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index c23415737..49c13833d 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -613,48 +613,14 @@ namespace UF FINISH_ENCODE(); } - ENCODE(OP_DzChooseZone) - { - SETUP_VAR_ENCODE(DynamicZoneChooseZone_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); - - for (uint32 i = 0; i < emu->count; ++i) - { - buf.WriteUInt16(emu->choices[i].dz_zone_id); - buf.WriteUInt16(emu->choices[i].dz_instance_id); - buf.WriteUInt32(emu->choices[i].unknown_id1); - buf.WriteUInt32(emu->choices[i].dz_type); - buf.WriteUInt32(emu->choices[i].unknown_id2); - buf.WriteString(emu->choices[i].description); - buf.WriteString(emu->choices[i].leader_name); - } - - __packet->size = buf.size(); - __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); - - FINISH_ENCODE(); - } - ENCODE(OP_DzCompass) { - SETUP_VAR_ENCODE(DynamicZoneCompass_Struct); - ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct, - sizeof(structs::DynamicZoneCompass_Struct) + - sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count - ); - - OUT(client_id); + SETUP_VAR_ENCODE(ExpeditionCompass_Struct); + ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); OUT(count); for (uint32 i = 0; i < emu->count; ++i) { - OUT(entries[i].dz_zone_id); - OUT(entries[i].dz_instance_id); - OUT(entries[i].dz_type); OUT(entries[i].x); OUT(entries[i].y); OUT(entries[i].z); @@ -675,108 +641,112 @@ namespace UF ENCODE(OP_DzExpeditionInfo) { - ENCODE_LENGTH_EXACT(DynamicZoneInfo_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneInfo_Struct, structs::DynamicZoneInfo_Struct); + ENCODE_LENGTH_EXACT(ExpeditionInfo_Struct); + SETUP_DIRECT_ENCODE(ExpeditionInfo_Struct, structs::ExpeditionInfo_Struct); - OUT(client_id); - OUT(assigned); OUT(max_players); - strn0cpy(eq->dz_name, emu->dz_name, sizeof(eq->dz_name)); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + eq->unknown004 = 785316192; + eq->unknown008 = 435601; + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->leader_name, emu->leader_name); FINISH_ENCODE(); } - ENCODE(OP_DzExpeditionInvite) + ENCODE(OP_DzExpeditionList) { - ENCODE_LENGTH_EXACT(ExpeditionInvite_Struct); - SETUP_DIRECT_ENCODE(ExpeditionInvite_Struct, structs::ExpeditionInvite_Struct); + SETUP_VAR_ENCODE(ExpeditionLockoutList_Struct); - OUT(client_id); - strn0cpy(eq->inviter_name, emu->inviter_name, sizeof(eq->inviter_name)); - strn0cpy(eq->expedition_name, emu->expedition_name, sizeof(eq->expedition_name)); - OUT(swapping); - strn0cpy(eq->swap_name, emu->swap_name, sizeof(eq->swap_name)); - OUT(dz_zone_id); - OUT(dz_instance_id); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzExpeditionLockoutTimers) - { - SETUP_VAR_ENCODE(ExpeditionLockoutTimers_Struct); - - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->count); + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->timers[i].expedition_name); - buf.WriteUInt32(emu->timers[i].seconds_remaining); - buf.WriteInt32(emu->timers[i].event_type); - buf.WriteString(emu->timers[i].event_name); + ss.write(emu->entries[i].expedition, strlen(emu->entries[i].expedition)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].time_left, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->entries[i].expedition_event, strlen(emu->entries[i].expedition_event)); + ss.write((const char*)&null_term, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzSetLeaderName) + ENCODE(OP_DzJoinExpeditionConfirm) { - ENCODE_LENGTH_EXACT(DynamicZoneLeaderName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneLeaderName_Struct, structs::DynamicZoneLeaderName_Struct); + ENCODE_LENGTH_EXACT(ExpeditionJoinPrompt_Struct); + SETUP_DIRECT_ENCODE(ExpeditionJoinPrompt_Struct, structs::ExpeditionJoinPrompt_Struct); - OUT(client_id); - strn0cpy(eq->leader_name, emu->leader_name, sizeof(eq->leader_name)); + strcpy(eq->expedition_name, emu->expedition_name); + strcpy(eq->player_name, emu->player_name); + + FINISH_ENCODE(); + } + + ENCODE(OP_DzLeaderStatus) + { + SETUP_VAR_ENCODE(ExpeditionLeaderSet_Struct); + + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + uint32 client_id = 0; + uint8 null_term = 0; + + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write(emu->leader_name, strlen(emu->leader_name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//0xffffffff + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&client_id, sizeof(uint32));//1 + ss.write((const char*)&client_id, sizeof(uint32)); + + __packet->size = ss.str().length(); + __packet->pBuffer = new unsigned char[__packet->size]; + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } ENCODE(OP_DzMemberList) { - SETUP_VAR_ENCODE(DynamicZoneMemberList_Struct); + SETUP_VAR_ENCODE(ExpeditionMemberList_Struct); - SerializeBuffer buf; - buf.WriteUInt32(emu->client_id); - buf.WriteUInt32(emu->member_count); - for (uint32 i = 0; i < emu->member_count; ++i) + std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary); + + uint32 client_id = 0; + uint8 null_term = 0; + ss.write((const char*)&client_id, sizeof(uint32)); + ss.write((const char*)&emu->count, sizeof(uint32)); + for (uint32 i = 0; i < emu->count; ++i) { - buf.WriteString(emu->members[i].name); - buf.WriteUInt8(emu->members[i].online_status); + ss.write(emu->entries[i].name, strlen(emu->entries[i].name)); + ss.write((const char*)&null_term, sizeof(char)); + ss.write((const char*)&emu->entries[i].status, sizeof(char)); } - __packet->size = buf.size(); + __packet->size = ss.str().length(); __packet->pBuffer = new unsigned char[__packet->size]; - memcpy(__packet->pBuffer, buf.buffer(), __packet->size); + memcpy(__packet->pBuffer, ss.str().c_str(), __packet->size); FINISH_ENCODE(); } - ENCODE(OP_DzMemberListName) - { - ENCODE_LENGTH_EXACT(DynamicZoneMemberListName_Struct); - SETUP_DIRECT_ENCODE(DynamicZoneMemberListName_Struct, structs::DynamicZoneMemberListName_Struct); - - OUT(client_id); - OUT(add_name); - strn0cpy(eq->name, emu->name, sizeof(eq->name)); - - FINISH_ENCODE(); - } - - ENCODE(OP_DzMemberListStatus) - { - auto emu = reinterpret_cast((*p)->pBuffer); - if (emu->member_count == 1) - { - ENCODE_FORWARD(OP_DzMemberList); - } - } - ENCODE(OP_Emote) { EQApplicationPacket *in = *p; @@ -1607,7 +1577,6 @@ namespace UF OUT(FastRegenHP); OUT(FastRegenMana); OUT(FastRegenEndurance); - OUT(underworld_teleport_index); eq->FogDensity = emu->fog_density; @@ -1705,7 +1674,7 @@ namespace UF eq->level1 = emu->level; // OUT(unknown00022[2]); for (r = 0; r < 5; r++) { - OUT(binds[r].zone_id); + OUT(binds[r].zoneId); OUT(binds[r].x); OUT(binds[r].y); OUT(binds[r].z); @@ -3345,84 +3314,6 @@ namespace UF FINISH_DIRECT_DECODE(); } - DECODE(OP_DzAddPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzChooseZoneReply) - { - DECODE_LENGTH_EXACT(structs::DynamicZoneChooseZoneReply_Struct); - SETUP_DIRECT_DECODE(DynamicZoneChooseZoneReply_Struct, structs::DynamicZoneChooseZoneReply_Struct); - - IN(unknown000); - IN(unknown004); - IN(unknown008); - IN(unknown_id1); - IN(dz_zone_id); - IN(dz_instance_id); - IN(dz_type); - IN(unknown_id2); - IN(unknown028); - IN(unknown032); - IN(unknown036); - IN(unknown040); - IN(unknown044); - IN(unknown048); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzExpeditionInviteResponse) - { - DECODE_LENGTH_EXACT(structs::ExpeditionInviteResponse_Struct); - SETUP_DIRECT_DECODE(ExpeditionInviteResponse_Struct, structs::ExpeditionInviteResponse_Struct); - - IN(dz_zone_id); - IN(dz_instance_id); - IN(accepted); - IN(swapping); - strn0cpy(emu->swap_name, eq->swap_name, sizeof(emu->swap_name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzMakeLeader) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzRemovePlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommand_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommand_Struct, structs::ExpeditionCommand_Struct); - - strn0cpy(emu->name, eq->name, sizeof(emu->name)); - - FINISH_DIRECT_DECODE(); - } - - DECODE(OP_DzSwapPlayer) - { - DECODE_LENGTH_EXACT(structs::ExpeditionCommandSwap_Struct); - SETUP_DIRECT_DECODE(ExpeditionCommandSwap_Struct, structs::ExpeditionCommandSwap_Struct); - - strn0cpy(emu->add_player_name, eq->add_player_name, sizeof(emu->add_player_name)); - strn0cpy(emu->rem_player_name, eq->rem_player_name, sizeof(emu->rem_player_name)); - - FINISH_DIRECT_DECODE(); - } - DECODE(OP_Emote) { unsigned char *__eq_buffer = __packet->pBuffer; diff --git a/common/patches/uf_ops.h b/common/patches/uf_ops.h index 76b7e014b..9d7742cf0 100644 --- a/common/patches/uf_ops.h +++ b/common/patches/uf_ops.h @@ -38,16 +38,13 @@ E(OP_Damage) E(OP_DeleteCharge) E(OP_DeleteItem) E(OP_DisciplineUpdate) -E(OP_DzChooseZone) E(OP_DzCompass) E(OP_DzExpeditionEndsWarning) E(OP_DzExpeditionInfo) -E(OP_DzExpeditionInvite) -E(OP_DzExpeditionLockoutTimers) +E(OP_DzExpeditionList) +E(OP_DzJoinExpeditionConfirm) +E(OP_DzLeaderStatus) E(OP_DzMemberList) -E(OP_DzMemberListName) -E(OP_DzMemberListStatus) -E(OP_DzSetLeaderName) E(OP_Emote) E(OP_ExpansionInfo) E(OP_FormattedMessage) @@ -123,12 +120,6 @@ D(OP_ConsiderCorpse) D(OP_Consume) D(OP_Damage) D(OP_DeleteItem) -D(OP_DzAddPlayer) -D(OP_DzChooseZoneReply) -D(OP_DzExpeditionInviteResponse) -D(OP_DzMakeLeader) -D(OP_DzRemovePlayer) -D(OP_DzSwapPlayer) D(OP_Emote) D(OP_EnvDamage) D(OP_FaceChange) diff --git a/common/patches/uf_structs.h b/common/patches/uf_structs.h index 6c1b4a4ed..a87ab7a07 100644 --- a/common/patches/uf_structs.h +++ b/common/patches/uf_structs.h @@ -444,11 +444,7 @@ struct NewZone_Struct { /*0848*/ int32 unknown848; /*0852*/ uint16 zone_id; /*0854*/ uint16 zone_instance; -/*0856*/ uint32 scriptNPCReceivedanItem; -/*0860*/ uint32 bCheck; // padded bool -/*0864*/ uint32 scriptIDSomething; -/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions -/*0872*/ uint32 scriptIDSomething3; +/*0856*/ char unknown856[20]; /*0876*/ uint32 SuspendBuffs; /*0880*/ uint32 unknown880; //seen 50 /*0884*/ uint32 unknown884; //seen 10 @@ -833,7 +829,7 @@ struct LeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1755,7 +1751,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ uint32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ int8 success; // =0 client->server, =1 server->client, -X=specific error @@ -4250,160 +4246,52 @@ struct VeteranReward /*012*/ VeteranRewardItem items[8]; }; - -struct ExpeditionInvite_Struct -{ -/*000*/ uint32 client_id; // unique character id -/*004*/ uint32 unknown004; -/*008*/ char inviter_name[64]; -/*072*/ char expedition_name[128]; -/*200*/ uint8 swapping; // 0: adding 1: swapping -/*201*/ char swap_name[64]; // if swapping, swap name being removed -/*265*/ uint8 padding[3]; -/*268*/ uint16 dz_zone_id; // dz_id zone/instance pair, sent back in reply -/*270*/ uint16 dz_instance_id; -}; - -struct ExpeditionInviteResponse_Struct +struct ExpeditionEntryHeader_Struct { /*000*/ uint32 unknown000; +/*000*/ uint32 number_of_entries; +}; + +struct ExpeditionJoinPrompt_Struct +{ +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; -/*008*/ uint16 dz_zone_id; // dz_id pair sent in invite -/*010*/ uint16 dz_instance_id; -/*012*/ uint8 accepted; // 0: declined 1: accepted -/*013*/ uint8 swapping; // 0: adding 1: swapping (sent in invite) -/*014*/ char swap_name[64]; // swap name sent in invite -/*078*/ uint8 unknown078; // padding garbage? -/*079*/ uint8 unknown079; // padding garbage? -}; - -struct DynamicZoneInfo_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 assigned; // padded bool -/*012*/ uint32 max_players; -/*016*/ char dz_name[128]; -/*144*/ char leader_name[64]; -}; - -struct DynamicZoneMemberEntry_Struct -{ -/*000*/ char name[1]; // variable length, null terminated, max 0x40 (64) -/*000*/ uint8 online_status; // 0: unknown 1: Online, 2: Offline, 3: In Dynamic Zone, 4: Link Dead -}; - -struct DynamicZoneMemberList_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 member_count; // number of players in window -/*008*/ DynamicZoneMemberEntry_Struct members[0]; // variable length -}; - -struct DynamicZoneMemberListName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ uint32 add_name; // padded bool, 0: remove name, 1: add name with unknown status -/*012*/ char name[64]; -}; - -struct ExpeditionLockoutTimerEntry_Struct -{ -/*000*/ char expedition_name[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ uint32 seconds_remaining; -/*000*/ int32 event_type; // seen -1 (0xffffffff) for replay timers and 1 for event timers -/*000*/ char event_name[1]; // variable length, null terminated, max 0x100 (256) -}; - -struct ExpeditionLockoutTimers_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ ExpeditionLockoutTimerEntry_Struct timers[0]; -}; - -struct DynamicZoneLeaderName_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 unknown004; -/*008*/ char leader_name[64]; -}; - -struct ExpeditionCommand_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char name[64]; -}; - -struct ExpeditionCommandSwap_Struct -{ -/*000*/ uint32 unknown000; -/*004*/ uint32 unknown004; -/*008*/ char add_player_name[64]; // swap to (player must confirm) -/*072*/ char rem_player_name[64]; // swap from +/*008*/ char player_name[64]; +/*072*/ char expedition_name[64]; }; struct ExpeditionExpireWarning { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 unknown004; /*008*/ uint32 minutes_remaining; }; -struct DynamicZoneCompassEntry_Struct +struct ExpeditionInfo_Struct { -/*000*/ uint16 dz_zone_id; // target dz id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green) +/*000*/ uint32 clientid; +/*004*/ uint32 unknown004; /*008*/ uint32 unknown008; +/*012*/ uint32 max_players; +/*016*/ char expedition_name[128]; +/*142*/ char leader_name[64]; +}; + +struct ExpeditionCompassEntry_Struct +{ +/*000*/ float unknown000; //seen *((uint32*)) = 1584791871 +/*004*/ uint32 enabled; //guess +/*008*/ uint32 unknown008; //seen 1019 /*012*/ float y; /*016*/ float x; /*020*/ float z; }; -struct DynamicZoneCompass_Struct +struct ExpeditionCompass_Struct { -/*000*/ uint32 client_id; +/*000*/ uint32 clientid; /*004*/ uint32 count; -/*008*/ DynamicZoneCompassEntry_Struct entries[0]; -}; - -struct DynamicZoneChooseZoneEntry_Struct -{ -/*000*/ uint16 dz_zone_id; // dz_id pair -/*002*/ uint16 dz_instance_id; -/*004*/ uint32 unknown_id1; // sent back in reply -/*008*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -- sent back in reply -/*012*/ uint32 unknown_id2; // possibly an id based on dz type, for expeditions this was same as dz_id (zone|instance) but task dz was different -/*016*/ char description[1]; // variable length, null terminated, max 0x80 (128) -/*000*/ char leader_name[1]; // variable length, null terminated, max 0x40 (64) -}; - -struct DynamicZoneChooseZone_Struct -{ -/*000*/ uint32 client_id; -/*004*/ uint32 count; -/*008*/ DynamicZoneChooseZoneEntry_Struct choices[0]; -}; - -struct DynamicZoneChooseZoneReply_Struct -{ -/*000*/ uint32 unknown000; // ff ff ff ff -/*004*/ uint32 unknown004; // seen 69 00 00 00 -/*008*/ uint32 unknown008; // ff ff ff ff -/*012*/ uint32 unknown_id1; // from choose zone entry message -/*016*/ uint16 dz_zone_id; // dz_id pair -/*018*/ uint16 dz_instance_id; -/*020*/ uint32 dz_type; // 1: Expedition, 2: Tutorial, 3: Task, 4: Mission, 5: Quest -/*024*/ uint32 unknown_id2; // from choose zone entry message -/*028*/ uint32 unknown028; // 00 00 00 00 -/*032*/ uint32 unknown032; // always same as unknown044 -/*036*/ uint32 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; // always same as unknown032 -/*048*/ uint32 unknown048; // seen 01 00 00 00 and 02 00 00 00 +/*008*/ ExpeditionCompassEntry_Struct entries[0]; }; struct AltCurrencySelectItem_Struct { diff --git a/common/platform.cpp b/common/platform.cpp index e5481c339..b67267155 100644 --- a/common/platform.cpp +++ b/common/platform.cpp @@ -46,15 +46,15 @@ std::string GetPlatformName() { switch (GetExecutablePlatformInt()) { case EQEmuExePlatform::ExePlatformWorld: - return "World"; + return "WorldServer"; case EQEmuExePlatform::ExePlatformQueryServ: - return "QS"; + return "QueryServer"; case EQEmuExePlatform::ExePlatformZone: - return "Zone"; + return "ZoneServer"; case EQEmuExePlatform::ExePlatformUCS: return "UCS"; case EQEmuExePlatform::ExePlatformLogin: - return "Login"; + return "LoginServer"; case EQEmuExePlatform::ExePlatformSocket_Server: return "SocketServer"; case EQEmuExePlatform::ExePlatformSharedMemory: @@ -70,4 +70,4 @@ std::string GetPlatformName() default: return ""; } -} +} \ No newline at end of file diff --git a/common/repositories/base/base_aa_ability_repository.h b/common/repositories/base/base_aa_ability_repository.h index fbf16f0ba..49f83e61d 100644 --- a/common/repositories/base/base_aa_ability_repository.h +++ b/common/repositories/base/base_aa_ability_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_AA_ABILITY_REPOSITORY_H @@ -64,6 +81,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("aa_ability"); @@ -83,7 +115,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -124,11 +156,10 @@ public: } static AaAbility FindOne( - Database& db, int aa_ability_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -162,11 +193,10 @@ public: } static int DeleteOne( - Database& db, int aa_ability_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -179,7 +209,6 @@ public: } static int UpdateOne( - Database& db, AaAbility aa_ability_entry ) { @@ -202,7 +231,7 @@ public: update_values.push_back(columns[12] + " = " + std::to_string(aa_ability_entry.enabled)); update_values.push_back(columns[13] + " = " + std::to_string(aa_ability_entry.reset_on_death)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -216,7 +245,6 @@ public: } static AaAbility InsertOne( - Database& db, AaAbility aa_ability_entry ) { @@ -237,7 +265,7 @@ public: insert_values.push_back(std::to_string(aa_ability_entry.enabled)); insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -256,7 +284,6 @@ public: } static int InsertMany( - Database& db, std::vector aa_ability_entries ) { @@ -285,7 +312,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -296,11 +323,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -333,11 +360,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -371,9 +398,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -384,9 +411,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_aa_rank_effects_repository.h b/common/repositories/base/base_aa_rank_effects_repository.h index fa0eebcd1..0d31f8688 100644 --- a/common/repositories/base/base_aa_rank_effects_repository.h +++ b/common/repositories/base/base_aa_rank_effects_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("aa_rank_effects"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static AaRankEffects FindOne( - Database& db, int aa_rank_effects_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int aa_rank_effects_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, AaRankEffects aa_rank_effects_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(aa_rank_effects_entry.base1)); update_values.push_back(columns[4] + " = " + std::to_string(aa_rank_effects_entry.base2)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static AaRankEffects InsertOne( - Database& db, AaRankEffects aa_rank_effects_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(aa_rank_effects_entry.base1)); insert_values.push_back(std::to_string(aa_rank_effects_entry.base2)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector aa_rank_effects_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_aa_rank_prereqs_repository.h b/common/repositories/base/base_aa_rank_prereqs_repository.h index 04b1a0a38..5432b5a19 100644 --- a/common/repositories/base/base_aa_rank_prereqs_repository.h +++ b/common/repositories/base/base_aa_rank_prereqs_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("aa_rank_prereqs"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static AaRankPrereqs FindOne( - Database& db, int aa_rank_prereqs_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int aa_rank_prereqs_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, AaRankPrereqs aa_rank_prereqs_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_prereqs_entry.aa_id)); update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_prereqs_entry.points)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static AaRankPrereqs InsertOne( - Database& db, AaRankPrereqs aa_rank_prereqs_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id)); insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector aa_rank_prereqs_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_aa_ranks_repository.h b/common/repositories/base/base_aa_ranks_repository.h index 8145e3e96..dca90f694 100644 --- a/common/repositories/base/base_aa_ranks_repository.h +++ b/common/repositories/base/base_aa_ranks_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_AA_RANKS_REPOSITORY_H @@ -62,6 +79,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("aa_ranks"); @@ -81,7 +113,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -121,11 +153,10 @@ public: } static AaRanks FindOne( - Database& db, int aa_ranks_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -158,11 +189,10 @@ public: } static int DeleteOne( - Database& db, int aa_ranks_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -175,7 +205,6 @@ public: } static int UpdateOne( - Database& db, AaRanks aa_ranks_entry ) { @@ -197,7 +226,7 @@ public: update_values.push_back(columns[11] + " = " + std::to_string(aa_ranks_entry.prev_id)); update_values.push_back(columns[12] + " = " + std::to_string(aa_ranks_entry.next_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -211,7 +240,6 @@ public: } static AaRanks InsertOne( - Database& db, AaRanks aa_ranks_entry ) { @@ -231,7 +259,7 @@ public: insert_values.push_back(std::to_string(aa_ranks_entry.prev_id)); insert_values.push_back(std::to_string(aa_ranks_entry.next_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -250,7 +278,6 @@ public: } static int InsertMany( - Database& db, std::vector aa_ranks_entries ) { @@ -278,7 +305,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -289,11 +316,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -325,11 +352,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -362,9 +389,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -375,9 +402,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_account_flags_repository.h b/common/repositories/base/base_account_flags_repository.h index af9c9b223..5d67e14ec 100644 --- a/common/repositories/base/base_account_flags_repository.h +++ b/common/repositories/base/base_account_flags_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("account_flags"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static AccountFlags FindOne( - Database& db, int account_flags_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int account_flags_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, AccountFlags account_flags_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(account_flags_entry.p_flag) + "'"); update_values.push_back(columns[2] + " = '" + EscapeString(account_flags_entry.p_value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static AccountFlags InsertOne( - Database& db, AccountFlags account_flags_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back("'" + EscapeString(account_flags_entry.p_flag) + "'"); insert_values.push_back("'" + EscapeString(account_flags_entry.p_value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector account_flags_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_account_ip_repository.h b/common/repositories/base/base_account_ip_repository.h index 1384c4ef2..127c8c80e 100644 --- a/common/repositories/base/base_account_ip_repository.h +++ b/common/repositories/base/base_account_ip_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("account_ip"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static AccountIp FindOne( - Database& db, int account_ip_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int account_ip_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, AccountIp account_ip_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(account_ip_entry.count)); update_values.push_back(columns[3] + " = '" + EscapeString(account_ip_entry.lastused) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static AccountIp InsertOne( - Database& db, AccountIp account_ip_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(account_ip_entry.count)); insert_values.push_back("'" + EscapeString(account_ip_entry.lastused) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector account_ip_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_account_repository.h b/common/repositories/base/base_account_repository.h index 6283caf13..e2f0b5ec2 100644 --- a/common/repositories/base/base_account_repository.h +++ b/common/repositories/base/base_account_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ACCOUNT_REPOSITORY_H @@ -74,6 +91,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("account"); @@ -93,7 +125,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -139,11 +171,10 @@ public: } static Account FindOne( - Database& db, int account_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -182,11 +213,10 @@ public: } static int DeleteOne( - Database& db, int account_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -199,7 +229,6 @@ public: } static int UpdateOne( - Database& db, Account account_entry ) { @@ -226,7 +255,7 @@ public: update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'"); update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -240,13 +269,11 @@ public: } static Account InsertOne( - Database& db, Account account_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(account_entry.id)); insert_values.push_back("'" + EscapeString(account_entry.name) + "'"); insert_values.push_back("'" + EscapeString(account_entry.charname) + "'"); insert_values.push_back(std::to_string(account_entry.sharedplat)); @@ -266,7 +293,7 @@ public: insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'"); insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -285,7 +312,6 @@ public: } static int InsertMany( - Database& db, std::vector account_entries ) { @@ -294,7 +320,6 @@ public: for (auto &account_entry: account_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(account_entry.id)); insert_values.push_back("'" + EscapeString(account_entry.name) + "'"); insert_values.push_back("'" + EscapeString(account_entry.charname) + "'"); insert_values.push_back(std::to_string(account_entry.sharedplat)); @@ -319,7 +344,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -330,11 +355,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -372,11 +397,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -415,9 +440,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -428,9 +453,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_account_rewards_repository.h b/common/repositories/base/base_account_rewards_repository.h index ee6213e16..c7faa48e6 100644 --- a/common/repositories/base/base_account_rewards_repository.h +++ b/common/repositories/base/base_account_rewards_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("account_rewards"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static AccountRewards FindOne( - Database& db, int account_rewards_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int account_rewards_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, AccountRewards account_rewards_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(account_rewards_entry.reward_id)); update_values.push_back(columns[2] + " = " + std::to_string(account_rewards_entry.amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static AccountRewards InsertOne( - Database& db, AccountRewards account_rewards_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(account_rewards_entry.reward_id)); insert_values.push_back(std::to_string(account_rewards_entry.amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector account_rewards_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_details_repository.h b/common/repositories/base/base_adventure_details_repository.h index 656ba8908..5ce8b68ef 100644 --- a/common/repositories/base/base_adventure_details_repository.h +++ b/common/repositories/base/base_adventure_details_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_details"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static AdventureDetails FindOne( - Database& db, int adventure_details_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int adventure_details_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, AdventureDetails adventure_details_entry ) { @@ -176,7 +205,7 @@ public: update_values.push_back(columns[7] + " = " + std::to_string(adventure_details_entry.time_zoned)); update_values.push_back(columns[8] + " = " + std::to_string(adventure_details_entry.time_completed)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -190,13 +219,11 @@ public: } static AdventureDetails InsertOne( - Database& db, AdventureDetails adventure_details_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(adventure_details_entry.id)); insert_values.push_back(std::to_string(adventure_details_entry.adventure_id)); insert_values.push_back(std::to_string(adventure_details_entry.instance_id)); insert_values.push_back(std::to_string(adventure_details_entry.count)); @@ -206,7 +233,7 @@ public: insert_values.push_back(std::to_string(adventure_details_entry.time_zoned)); insert_values.push_back(std::to_string(adventure_details_entry.time_completed)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -225,7 +252,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_details_entries ) { @@ -234,7 +260,6 @@ public: for (auto &adventure_details_entry: adventure_details_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(adventure_details_entry.id)); insert_values.push_back(std::to_string(adventure_details_entry.adventure_id)); insert_values.push_back(std::to_string(adventure_details_entry.instance_id)); insert_values.push_back(std::to_string(adventure_details_entry.count)); @@ -249,7 +274,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -260,11 +285,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -292,11 +317,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -325,9 +350,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -338,9 +363,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_members_repository.h b/common/repositories/base/base_adventure_members_repository.h index 4cdc357fd..6994df694 100644 --- a/common/repositories/base/base_adventure_members_repository.h +++ b/common/repositories/base/base_adventure_members_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_members"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static AdventureMembers FindOne( - Database& db, int adventure_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int adventure_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, AdventureMembers adventure_members_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(adventure_members_entry.charid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static AdventureMembers InsertOne( - Database& db, AdventureMembers adventure_members_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(adventure_members_entry.id)); insert_values.push_back(std::to_string(adventure_members_entry.charid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_members_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_stats_repository.h b/common/repositories/base/base_adventure_stats_repository.h index b1634c080..b1f622c7e 100644 --- a/common/repositories/base/base_adventure_stats_repository.h +++ b/common/repositories/base/base_adventure_stats_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H @@ -58,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_stats"); @@ -77,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -115,11 +147,10 @@ public: } static AdventureStats FindOne( - Database& db, int adventure_stats_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -150,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int adventure_stats_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +197,6 @@ public: } static int UpdateOne( - Database& db, AdventureStats adventure_stats_entry ) { @@ -187,7 +216,7 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(adventure_stats_entry.ruj_losses)); update_values.push_back(columns[10] + " = " + std::to_string(adventure_stats_entry.tak_losses)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +230,6 @@ public: } static AdventureStats InsertOne( - Database& db, AdventureStats adventure_stats_entry ) { @@ -219,7 +247,7 @@ public: insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses)); insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_stats_entries ) { @@ -264,7 +291,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -309,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -344,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_template_entry_flavor_repository.h b/common/repositories/base/base_adventure_template_entry_flavor_repository.h index 8b4bfa7b6..684a5a91b 100644 --- a/common/repositories/base/base_adventure_template_entry_flavor_repository.h +++ b/common/repositories/base/base_adventure_template_entry_flavor_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_template_entry_flavor"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static AdventureTemplateEntryFlavor FindOne( - Database& db, int adventure_template_entry_flavor_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int adventure_template_entry_flavor_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_flavor_entry.id)); update_values.push_back(columns[1] + " = '" + EscapeString(adventure_template_entry_flavor_entry.text) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static AdventureTemplateEntryFlavor InsertOne( - Database& db, AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id)); insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_template_entry_flavor_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_template_entry_repository.h b/common/repositories/base/base_adventure_template_entry_repository.h index 5e4b9ca7c..3f97c85e6 100644 --- a/common/repositories/base/base_adventure_template_entry_repository.h +++ b/common/repositories/base/base_adventure_template_entry_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_template_entry"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static AdventureTemplateEntry FindOne( - Database& db, int adventure_template_entry_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int adventure_template_entry_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, AdventureTemplateEntry adventure_template_entry_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(adventure_template_entry_entry.template_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static AdventureTemplateEntry InsertOne( - Database& db, AdventureTemplateEntry adventure_template_entry_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(adventure_template_entry_entry.id)); insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_template_entry_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_adventure_template_repository.h b/common/repositories/base/base_adventure_template_repository.h index 076b8abc5..0f15813da 100644 --- a/common/repositories/base/base_adventure_template_repository.h +++ b/common/repositories/base/base_adventure_template_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H @@ -102,6 +119,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("adventure_template"); @@ -121,7 +153,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -181,11 +213,10 @@ public: } static AdventureTemplate FindOne( - Database& db, int adventure_template_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -238,11 +269,10 @@ public: } static int DeleteOne( - Database& db, int adventure_template_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -255,7 +285,6 @@ public: } static int UpdateOne( - Database& db, AdventureTemplate adventure_template_entry ) { @@ -297,7 +326,7 @@ public: update_values.push_back(columns[31] + " = " + std::to_string(adventure_template_entry.graveyard_z)); update_values.push_back(columns[32] + " = " + std::to_string(adventure_template_entry.graveyard_radius)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -311,7 +340,6 @@ public: } static AdventureTemplate InsertOne( - Database& db, AdventureTemplate adventure_template_entry ) { @@ -351,7 +379,7 @@ public: insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z)); insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -370,7 +398,6 @@ public: } static int InsertMany( - Database& db, std::vector adventure_template_entries ) { @@ -418,7 +445,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -429,11 +456,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -485,11 +512,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -542,9 +569,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -555,9 +582,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_alternate_currency_repository.h b/common/repositories/base/base_alternate_currency_repository.h index 832da0f84..a6ad62517 100644 --- a/common/repositories/base/base_alternate_currency_repository.h +++ b/common/repositories/base/base_alternate_currency_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("alternate_currency"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static AlternateCurrency FindOne( - Database& db, int alternate_currency_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int alternate_currency_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, AlternateCurrency alternate_currency_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(alternate_currency_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(alternate_currency_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static AlternateCurrency InsertOne( - Database& db, AlternateCurrency alternate_currency_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(alternate_currency_entry.id)); insert_values.push_back(std::to_string(alternate_currency_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector alternate_currency_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_auras_repository.h b/common/repositories/base/base_auras_repository.h index e884fc50b..8849528b4 100644 --- a/common/repositories/base/base_auras_repository.h +++ b/common/repositories/base/base_auras_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_AURAS_REPOSITORY_H @@ -58,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("auras"); @@ -77,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -115,11 +147,10 @@ public: } static Auras FindOne( - Database& db, int auras_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -150,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int auras_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +197,6 @@ public: } static int UpdateOne( - Database& db, Auras auras_entry ) { @@ -187,7 +216,7 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(auras_entry.icon)); update_values.push_back(columns[10] + " = " + std::to_string(auras_entry.cast_time)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +230,6 @@ public: } static Auras InsertOne( - Database& db, Auras auras_entry ) { @@ -219,7 +247,7 @@ public: insert_values.push_back(std::to_string(auras_entry.icon)); insert_values.push_back(std::to_string(auras_entry.cast_time)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector auras_entries ) { @@ -264,7 +291,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -309,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -344,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_base_data_repository.h b/common/repositories/base/base_base_data_repository.h index 3574f254a..f42ff6842 100644 --- a/common/repositories/base/base_base_data_repository.h +++ b/common/repositories/base/base_base_data_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_BASE_DATA_REPOSITORY_H @@ -56,6 +73,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("base_data"); @@ -75,7 +107,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -112,11 +144,10 @@ public: } static BaseData FindOne( - Database& db, int base_data_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -146,11 +177,10 @@ public: } static int DeleteOne( - Database& db, int base_data_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -163,7 +193,6 @@ public: } static int UpdateOne( - Database& db, BaseData base_data_entry ) { @@ -182,7 +211,7 @@ public: update_values.push_back(columns[8] + " = " + std::to_string(base_data_entry.mana_fac)); update_values.push_back(columns[9] + " = " + std::to_string(base_data_entry.end_fac)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -196,7 +225,6 @@ public: } static BaseData InsertOne( - Database& db, BaseData base_data_entry ) { @@ -213,7 +241,7 @@ public: insert_values.push_back(std::to_string(base_data_entry.mana_fac)); insert_values.push_back(std::to_string(base_data_entry.end_fac)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -232,7 +260,6 @@ public: } static int InsertMany( - Database& db, std::vector base_data_entries ) { @@ -257,7 +284,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -268,11 +295,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -301,11 +328,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -335,9 +362,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -348,9 +375,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_blocked_spells_repository.h b/common/repositories/base/base_blocked_spells_repository.h index d17524a2c..50e6a682e 100644 --- a/common/repositories/base/base_blocked_spells_repository.h +++ b/common/repositories/base/base_blocked_spells_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H @@ -60,6 +77,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("blocked_spells"); @@ -79,7 +111,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -118,11 +150,10 @@ public: } static BlockedSpells FindOne( - Database& db, int blocked_spells_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -154,11 +185,10 @@ public: } static int DeleteOne( - Database& db, int blocked_spells_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -171,7 +201,6 @@ public: } static int UpdateOne( - Database& db, BlockedSpells blocked_spells_entry ) { @@ -191,7 +220,7 @@ public: update_values.push_back(columns[10] + " = '" + EscapeString(blocked_spells_entry.message) + "'"); update_values.push_back(columns[11] + " = '" + EscapeString(blocked_spells_entry.description) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -205,13 +234,11 @@ public: } static BlockedSpells InsertOne( - Database& db, BlockedSpells blocked_spells_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(blocked_spells_entry.id)); insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); insert_values.push_back(std::to_string(blocked_spells_entry.type)); insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); @@ -224,7 +251,7 @@ public: insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'"); insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -243,7 +270,6 @@ public: } static int InsertMany( - Database& db, std::vector blocked_spells_entries ) { @@ -252,7 +278,6 @@ public: for (auto &blocked_spells_entry: blocked_spells_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(blocked_spells_entry.id)); insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); insert_values.push_back(std::to_string(blocked_spells_entry.type)); insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); @@ -270,7 +295,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -281,11 +306,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -316,11 +341,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -352,9 +377,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -365,9 +390,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_bug_reports_repository.h b/common/repositories/base/base_bug_reports_repository.h index ecd1335ef..c70d897f2 100644 --- a/common/repositories/base/base_bug_reports_repository.h +++ b/common/repositories/base/base_bug_reports_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_BUG_REPORTS_REPOSITORY_H @@ -100,6 +117,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("bug_reports"); @@ -119,7 +151,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -178,11 +210,10 @@ public: } static BugReports FindOne( - Database& db, int bug_reports_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -234,11 +265,10 @@ public: } static int DeleteOne( - Database& db, int bug_reports_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -251,7 +281,6 @@ public: } static int UpdateOne( - Database& db, BugReports bug_reports_entry ) { @@ -291,7 +320,7 @@ public: update_values.push_back(columns[30] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'"); update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -305,13 +334,11 @@ public: } static BugReports InsertOne( - Database& db, BugReports bug_reports_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(bug_reports_entry.id)); insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'"); insert_values.push_back(std::to_string(bug_reports_entry.client_version_id)); insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'"); @@ -344,7 +371,7 @@ public: insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -363,7 +390,6 @@ public: } static int InsertMany( - Database& db, std::vector bug_reports_entries ) { @@ -372,7 +398,6 @@ public: for (auto &bug_reports_entry: bug_reports_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(bug_reports_entry.id)); insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'"); insert_values.push_back(std::to_string(bug_reports_entry.client_version_id)); insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'"); @@ -410,7 +435,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -421,11 +446,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -476,11 +501,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -532,9 +557,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -545,9 +570,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_bugs_repository.h b/common/repositories/base/base_bugs_repository.h index 9ac9b9330..4bcab8c66 100644 --- a/common/repositories/base/base_bugs_repository.h +++ b/common/repositories/base/base_bugs_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_BUGS_REPOSITORY_H @@ -62,6 +79,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("bugs"); @@ -81,7 +113,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -121,11 +153,10 @@ public: } static Bugs FindOne( - Database& db, int bugs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -158,11 +189,10 @@ public: } static int DeleteOne( - Database& db, int bugs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -175,7 +205,6 @@ public: } static int UpdateOne( - Database& db, Bugs bugs_entry ) { @@ -196,7 +225,7 @@ public: update_values.push_back(columns[11] + " = '" + EscapeString(bugs_entry.date) + "'"); update_values.push_back(columns[12] + " = " + std::to_string(bugs_entry.status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -210,13 +239,11 @@ public: } static Bugs InsertOne( - Database& db, Bugs bugs_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(bugs_entry.id)); insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'"); @@ -230,7 +257,7 @@ public: insert_values.push_back("'" + EscapeString(bugs_entry.date) + "'"); insert_values.push_back(std::to_string(bugs_entry.status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -249,7 +276,6 @@ public: } static int InsertMany( - Database& db, std::vector bugs_entries ) { @@ -258,7 +284,6 @@ public: for (auto &bugs_entry: bugs_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(bugs_entry.id)); insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'"); @@ -277,7 +302,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -288,11 +313,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -324,11 +349,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -361,9 +386,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -374,9 +399,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_buyer_repository.h b/common/repositories/base/base_buyer_repository.h index 1b1cb9800..e4b41575d 100644 --- a/common/repositories/base/base_buyer_repository.h +++ b/common/repositories/base/base_buyer_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_BUYER_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("buyer"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static Buyer FindOne( - Database& db, int buyer_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int buyer_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, Buyer buyer_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(buyer_entry.quantity)); update_values.push_back(columns[5] + " = " + std::to_string(buyer_entry.price)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static Buyer InsertOne( - Database& db, Buyer buyer_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back(std::to_string(buyer_entry.quantity)); insert_values.push_back(std::to_string(buyer_entry.price)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector buyer_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_char_create_combinations_repository.h b/common/repositories/base/base_char_create_combinations_repository.h index ed806d6bd..cf103ec8a 100644 --- a/common/repositories/base/base_char_create_combinations_repository.h +++ b/common/repositories/base/base_char_create_combinations_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H @@ -18,12 +35,15 @@ class BaseCharCreateCombinationsRepository { public: struct CharCreateCombinations { - int allocation_id; - int race; - int class; - int deity; - int start_zone; - int expansions_req; + int allocation_id; + int race; + int class; + int deity; + int start_zone; + int expansions_req; + int min_expansion; + int max_expansion; + std::string content_flags; }; static std::string PrimaryKey() @@ -40,6 +60,9 @@ public: "deity", "start_zone", "expansions_req", + "min_expansion", + "max_expansion", + "content_flags", }; } @@ -48,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("char_create_combinations"); @@ -67,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -81,6 +119,9 @@ public: entry.deity = 0; entry.start_zone = 0; entry.expansions_req = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -100,11 +141,10 @@ public: } static CharCreateCombinations FindOne( - Database& db, int char_create_combinations_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,6 +162,9 @@ public: entry.deity = atoi(row[3]); entry.start_zone = atoi(row[4]); entry.expansions_req = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; return entry; } @@ -130,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int char_create_combinations_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +189,6 @@ public: } static int UpdateOne( - Database& db, CharCreateCombinations char_create_combinations_entry ) { @@ -161,8 +202,11 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(char_create_combinations_entry.deity)); update_values.push_back(columns[4] + " = " + std::to_string(char_create_combinations_entry.start_zone)); update_values.push_back(columns[5] + " = " + std::to_string(char_create_combinations_entry.expansions_req)); + update_values.push_back(columns[6] + " = " + std::to_string(char_create_combinations_entry.min_expansion)); + update_values.push_back(columns[7] + " = " + std::to_string(char_create_combinations_entry.max_expansion)); + update_values.push_back(columns[8] + " = '" + EscapeString(char_create_combinations_entry.content_flags) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +220,6 @@ public: } static CharCreateCombinations InsertOne( - Database& db, CharCreateCombinations char_create_combinations_entry ) { @@ -188,8 +231,11 @@ public: insert_values.push_back(std::to_string(char_create_combinations_entry.deity)); insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone)); insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req)); + insert_values.push_back(std::to_string(char_create_combinations_entry.min_expansion)); + insert_values.push_back(std::to_string(char_create_combinations_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(char_create_combinations_entry.content_flags) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector char_create_combinations_entries ) { @@ -223,13 +268,16 @@ public: insert_values.push_back(std::to_string(char_create_combinations_entry.deity)); insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone)); insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req)); + insert_values.push_back(std::to_string(char_create_combinations_entry.min_expansion)); + insert_values.push_back(std::to_string(char_create_combinations_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(char_create_combinations_entry.content_flags) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -262,6 +310,9 @@ public: entry.deity = atoi(row[3]); entry.start_zone = atoi(row[4]); entry.expansions_req = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; all_entries.push_back(entry); } @@ -269,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -292,6 +343,9 @@ public: entry.deity = atoi(row[3]); entry.start_zone = atoi(row[4]); entry.expansions_req = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; all_entries.push_back(entry); } @@ -299,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_char_create_point_allocations_repository.h b/common/repositories/base/base_char_create_point_allocations_repository.h index 7b3f4a2d6..34b4efefa 100644 --- a/common/repositories/base/base_char_create_point_allocations_repository.h +++ b/common/repositories/base/base_char_create_point_allocations_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H @@ -66,6 +83,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("char_create_point_allocations"); @@ -85,7 +117,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -127,11 +159,10 @@ public: } static CharCreatePointAllocations FindOne( - Database& db, int char_create_point_allocations_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -166,11 +197,10 @@ public: } static int DeleteOne( - Database& db, int char_create_point_allocations_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -183,7 +213,6 @@ public: } static int UpdateOne( - Database& db, CharCreatePointAllocations char_create_point_allocations_entry ) { @@ -207,7 +236,7 @@ public: update_values.push_back(columns[13] + " = " + std::to_string(char_create_point_allocations_entry.alloc_wis)); update_values.push_back(columns[14] + " = " + std::to_string(char_create_point_allocations_entry.alloc_cha)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -221,7 +250,6 @@ public: } static CharCreatePointAllocations InsertOne( - Database& db, CharCreatePointAllocations char_create_point_allocations_entry ) { @@ -243,7 +271,7 @@ public: insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis)); insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -262,7 +290,6 @@ public: } static int InsertMany( - Database& db, std::vector char_create_point_allocations_entries ) { @@ -292,7 +319,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -303,11 +330,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -341,11 +368,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -380,9 +407,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -393,9 +420,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_char_recipe_list_repository.h b/common/repositories/base/base_char_recipe_list_repository.h index cb3e33707..ab737e6a1 100644 --- a/common/repositories/base/base_char_recipe_list_repository.h +++ b/common/repositories/base/base_char_recipe_list_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("char_recipe_list"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharRecipeList FindOne( - Database& db, int char_recipe_list_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int char_recipe_list_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharRecipeList char_recipe_list_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(char_recipe_list_entry.recipe_id)); update_values.push_back(columns[2] + " = " + std::to_string(char_recipe_list_entry.madecount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharRecipeList InsertOne( - Database& db, CharRecipeList char_recipe_list_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id)); insert_values.push_back(std::to_string(char_recipe_list_entry.madecount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector char_recipe_list_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_activities_repository.h b/common/repositories/base/base_character_activities_repository.h index 9c4a7b144..4abc5e7dd 100644 --- a/common/repositories/base/base_character_activities_repository.h +++ b/common/repositories/base/base_character_activities_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_activities"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static CharacterActivities FindOne( - Database& db, int character_activities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int character_activities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, CharacterActivities character_activities_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(character_activities_entry.donecount)); update_values.push_back(columns[4] + " = " + std::to_string(character_activities_entry.completed)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static CharacterActivities InsertOne( - Database& db, CharacterActivities character_activities_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(character_activities_entry.donecount)); insert_values.push_back(std::to_string(character_activities_entry.completed)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector character_activities_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_alt_currency_repository.h b/common/repositories/base/base_character_alt_currency_repository.h index 9e2ebc695..645143ee2 100644 --- a/common/repositories/base/base_character_alt_currency_repository.h +++ b/common/repositories/base/base_character_alt_currency_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_alt_currency"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterAltCurrency FindOne( - Database& db, int character_alt_currency_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_alt_currency_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterAltCurrency character_alt_currency_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_alt_currency_entry.currency_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_alt_currency_entry.amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterAltCurrency InsertOne( - Database& db, CharacterAltCurrency character_alt_currency_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id)); insert_values.push_back(std::to_string(character_alt_currency_entry.amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_alt_currency_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_alternate_abilities_repository.h b/common/repositories/base/base_character_alternate_abilities_repository.h index de4ef1cb4..c578b99a4 100644 --- a/common/repositories/base/base_character_alternate_abilities_repository.h +++ b/common/repositories/base/base_character_alternate_abilities_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_alternate_abilities"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static CharacterAlternateAbilities FindOne( - Database& db, int character_alternate_abilities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int character_alternate_abilities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, CharacterAlternateAbilities character_alternate_abilities_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(character_alternate_abilities_entry.aa_value)); update_values.push_back(columns[3] + " = " + std::to_string(character_alternate_abilities_entry.charges)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static CharacterAlternateAbilities InsertOne( - Database& db, CharacterAlternateAbilities character_alternate_abilities_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value)); insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector character_alternate_abilities_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_auras_repository.h b/common/repositories/base/base_character_auras_repository.h index 8ac89e458..9959fa2a4 100644 --- a/common/repositories/base/base_character_auras_repository.h +++ b/common/repositories/base/base_character_auras_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_auras"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterAuras FindOne( - Database& db, int character_auras_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_auras_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterAuras character_auras_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_auras_entry.slot)); update_values.push_back(columns[2] + " = " + std::to_string(character_auras_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterAuras InsertOne( - Database& db, CharacterAuras character_auras_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_auras_entry.slot)); insert_values.push_back(std::to_string(character_auras_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_auras_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_bandolier_repository.h b/common/repositories/base/base_character_bandolier_repository.h index a208ac9da..62f0924b4 100644 --- a/common/repositories/base/base_character_bandolier_repository.h +++ b/common/repositories/base/base_character_bandolier_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_bandolier"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static CharacterBandolier FindOne( - Database& db, int character_bandolier_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int character_bandolier_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, CharacterBandolier character_bandolier_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(character_bandolier_entry.icon)); update_values.push_back(columns[5] + " = '" + EscapeString(character_bandolier_entry.bandolier_name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static CharacterBandolier InsertOne( - Database& db, CharacterBandolier character_bandolier_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back(std::to_string(character_bandolier_entry.icon)); insert_values.push_back("'" + EscapeString(character_bandolier_entry.bandolier_name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector character_bandolier_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_bind_repository.h b/common/repositories/base/base_character_bind_repository.h index 6ae2aee1d..911545a6f 100644 --- a/common/repositories/base/base_character_bind_repository.h +++ b/common/repositories/base/base_character_bind_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_bind"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static CharacterBind FindOne( - Database& db, int character_bind_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int character_bind_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, CharacterBind character_bind_entry ) { @@ -171,7 +200,7 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z)); update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -185,13 +214,11 @@ public: } static CharacterBind InsertOne( - Database& db, CharacterBind character_bind_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_bind_entry.id)); insert_values.push_back(std::to_string(character_bind_entry.slot)); insert_values.push_back(std::to_string(character_bind_entry.zone_id)); insert_values.push_back(std::to_string(character_bind_entry.instance_id)); @@ -200,7 +227,7 @@ public: insert_values.push_back(std::to_string(character_bind_entry.z)); insert_values.push_back(std::to_string(character_bind_entry.heading)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -219,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector character_bind_entries ) { @@ -228,7 +254,6 @@ public: for (auto &character_bind_entry: character_bind_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_bind_entry.id)); insert_values.push_back(std::to_string(character_bind_entry.slot)); insert_values.push_back(std::to_string(character_bind_entry.zone_id)); insert_values.push_back(std::to_string(character_bind_entry.instance_id)); @@ -242,7 +267,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -284,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -316,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -329,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_buffs_repository.h b/common/repositories/base/base_character_buffs_repository.h index 6e577e154..ac54813ae 100644 --- a/common/repositories/base/base_character_buffs_repository.h +++ b/common/repositories/base/base_character_buffs_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H @@ -70,6 +87,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_buffs"); @@ -89,7 +121,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -133,11 +165,10 @@ public: } static CharacterBuffs FindOne( - Database& db, int character_buffs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -174,11 +205,10 @@ public: } static int DeleteOne( - Database& db, int character_buffs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -191,7 +221,6 @@ public: } static int UpdateOne( - Database& db, CharacterBuffs character_buffs_entry ) { @@ -217,7 +246,7 @@ public: update_values.push_back(columns[15] + " = " + std::to_string(character_buffs_entry.ExtraDIChance)); update_values.push_back(columns[16] + " = " + std::to_string(character_buffs_entry.instrument_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -231,7 +260,6 @@ public: } static CharacterBuffs InsertOne( - Database& db, CharacterBuffs character_buffs_entry ) { @@ -255,7 +283,7 @@ public: insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance)); insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -274,7 +302,6 @@ public: } static int InsertMany( - Database& db, std::vector character_buffs_entries ) { @@ -306,7 +333,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -317,11 +344,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -357,11 +384,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -398,9 +425,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -411,9 +438,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_corpse_items_repository.h b/common/repositories/base/base_character_corpse_items_repository.h index a1d50d125..a41cac39d 100644 --- a/common/repositories/base/base_character_corpse_items_repository.h +++ b/common/repositories/base/base_character_corpse_items_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H @@ -58,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_corpse_items"); @@ -77,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -115,11 +147,10 @@ public: } static CharacterCorpseItems FindOne( - Database& db, int character_corpse_items_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -150,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int character_corpse_items_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +197,6 @@ public: } static int UpdateOne( - Database& db, CharacterCorpseItems character_corpse_items_entry ) { @@ -187,7 +216,7 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(character_corpse_items_entry.aug_6)); update_values.push_back(columns[10] + " = " + std::to_string(character_corpse_items_entry.attuned)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +230,6 @@ public: } static CharacterCorpseItems InsertOne( - Database& db, CharacterCorpseItems character_corpse_items_entry ) { @@ -219,7 +247,7 @@ public: insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6)); insert_values.push_back(std::to_string(character_corpse_items_entry.attuned)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector character_corpse_items_entries ) { @@ -264,7 +291,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -309,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -344,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_corpses_repository.h b/common/repositories/base/base_character_corpses_repository.h index bb7df4e0d..db64a58fa 100644 --- a/common/repositories/base/base_character_corpses_repository.h +++ b/common/repositories/base/base_character_corpses_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H @@ -130,6 +147,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_corpses"); @@ -149,7 +181,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -223,11 +255,10 @@ public: } static CharacterCorpses FindOne( - Database& db, int character_corpses_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -294,11 +325,10 @@ public: } static int DeleteOne( - Database& db, int character_corpses_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -311,7 +341,6 @@ public: } static int UpdateOne( - Database& db, CharacterCorpses character_corpses_entry ) { @@ -366,7 +395,7 @@ public: update_values.push_back(columns[45] + " = " + std::to_string(character_corpses_entry.wc_8)); update_values.push_back(columns[46] + " = " + std::to_string(character_corpses_entry.wc_9)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -380,13 +409,11 @@ public: } static CharacterCorpses InsertOne( - Database& db, CharacterCorpses character_corpses_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_corpses_entry.id)); insert_values.push_back(std::to_string(character_corpses_entry.charid)); insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); @@ -434,7 +461,7 @@ public: insert_values.push_back(std::to_string(character_corpses_entry.wc_8)); insert_values.push_back(std::to_string(character_corpses_entry.wc_9)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -453,7 +480,6 @@ public: } static int InsertMany( - Database& db, std::vector character_corpses_entries ) { @@ -462,7 +488,6 @@ public: for (auto &character_corpses_entry: character_corpses_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_corpses_entry.id)); insert_values.push_back(std::to_string(character_corpses_entry.charid)); insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); @@ -515,7 +540,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -526,11 +551,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -596,11 +621,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -667,9 +692,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -680,9 +705,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_currency_repository.h b/common/repositories/base/base_character_currency_repository.h index 17134a15d..93c78c0f5 100644 --- a/common/repositories/base/base_character_currency_repository.h +++ b/common/repositories/base/base_character_currency_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H @@ -70,6 +87,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_currency"); @@ -89,7 +121,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -133,11 +165,10 @@ public: } static CharacterCurrency FindOne( - Database& db, int character_currency_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -174,11 +205,10 @@ public: } static int DeleteOne( - Database& db, int character_currency_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -191,7 +221,6 @@ public: } static int UpdateOne( - Database& db, CharacterCurrency character_currency_entry ) { @@ -217,7 +246,7 @@ public: update_values.push_back(columns[15] + " = " + std::to_string(character_currency_entry.ebon_crystals)); update_values.push_back(columns[16] + " = " + std::to_string(character_currency_entry.career_ebon_crystals)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -231,7 +260,6 @@ public: } static CharacterCurrency InsertOne( - Database& db, CharacterCurrency character_currency_entry ) { @@ -255,7 +283,7 @@ public: insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals)); insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -274,7 +302,6 @@ public: } static int InsertMany( - Database& db, std::vector character_currency_entries ) { @@ -306,7 +333,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -317,11 +344,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -357,11 +384,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -398,9 +425,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -411,9 +438,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_data_repository.h b/common/repositories/base/base_character_data_repository.h index 623a5a875..e6c59579a 100644 --- a/common/repositories/base/base_character_data_repository.h +++ b/common/repositories/base/base_character_data_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_DATA_REPOSITORY_H @@ -240,6 +257,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_data"); @@ -259,7 +291,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -388,11 +420,10 @@ public: } static CharacterData FindOne( - Database& db, int character_data_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -514,11 +545,10 @@ public: } static int DeleteOne( - Database& db, int character_data_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -531,7 +561,6 @@ public: } static int UpdateOne( - Database& db, CharacterData character_data_entry ) { @@ -641,7 +670,7 @@ public: update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot)); update_values.push_back(columns[101] + " = '" + EscapeString(character_data_entry.deleted_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -655,13 +684,11 @@ public: } static CharacterData InsertOne( - Database& db, CharacterData character_data_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_data_entry.id)); insert_values.push_back(std::to_string(character_data_entry.account_id)); insert_values.push_back("'" + EscapeString(character_data_entry.name) + "'"); insert_values.push_back("'" + EscapeString(character_data_entry.last_name) + "'"); @@ -764,7 +791,7 @@ public: insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -783,7 +810,6 @@ public: } static int InsertMany( - Database& db, std::vector character_data_entries ) { @@ -792,7 +818,6 @@ public: for (auto &character_data_entry: character_data_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_data_entry.id)); insert_values.push_back(std::to_string(character_data_entry.account_id)); insert_values.push_back("'" + EscapeString(character_data_entry.name) + "'"); insert_values.push_back("'" + EscapeString(character_data_entry.last_name) + "'"); @@ -900,7 +925,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -911,11 +936,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -1036,11 +1061,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -1162,9 +1187,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -1175,9 +1200,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_disciplines_repository.h b/common/repositories/base/base_character_disciplines_repository.h index 941e36056..4401667d8 100644 --- a/common/repositories/base/base_character_disciplines_repository.h +++ b/common/repositories/base/base_character_disciplines_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_disciplines"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterDisciplines FindOne( - Database& db, int character_disciplines_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_disciplines_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterDisciplines character_disciplines_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_disciplines_entry.slot_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_disciplines_entry.disc_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterDisciplines InsertOne( - Database& db, CharacterDisciplines character_disciplines_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_disciplines_entry.slot_id)); insert_values.push_back(std::to_string(character_disciplines_entry.disc_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_disciplines_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_expedition_lockouts_repository.h b/common/repositories/base/base_character_expedition_lockouts_repository.h deleted file mode 100644 index d50dd1f9e..000000000 --- a/common/repositories/base/base_character_expedition_lockouts_repository.h +++ /dev/null @@ -1,337 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H -#define EQEMU_BASE_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseCharacterExpeditionLockoutsRepository { -public: - struct CharacterExpeditionLockouts { - int id; - int character_id; - std::string expedition_name; - std::string event_name; - std::string expire_time; - int duration; - std::string from_expedition_uuid; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "character_id", - "expedition_name", - "event_name", - "expire_time", - "duration", - "from_expedition_uuid", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("character_expedition_lockouts"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static CharacterExpeditionLockouts NewEntity() - { - CharacterExpeditionLockouts entry{}; - - entry.id = 0; - entry.character_id = 0; - entry.expedition_name = ""; - entry.event_name = ""; - entry.expire_time = ""; - entry.duration = 0; - entry.from_expedition_uuid = ""; - - return entry; - } - - static CharacterExpeditionLockouts GetCharacterExpeditionLockoutsEntry( - const std::vector &character_expedition_lockoutss, - int character_expedition_lockouts_id - ) - { - for (auto &character_expedition_lockouts : character_expedition_lockoutss) { - if (character_expedition_lockouts.id == character_expedition_lockouts_id) { - return character_expedition_lockouts; - } - } - - return NewEntity(); - } - - static CharacterExpeditionLockouts FindOne( - Database& db, - int character_expedition_lockouts_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - character_expedition_lockouts_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - CharacterExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int character_expedition_lockouts_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - character_expedition_lockouts_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - CharacterExpeditionLockouts character_expedition_lockouts_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id)); - update_values.push_back(columns[2] + " = '" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration)); - update_values.push_back(columns[6] + " = '" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - character_expedition_lockouts_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static CharacterExpeditionLockouts InsertOne( - Database& db, - CharacterExpeditionLockouts character_expedition_lockouts_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - character_expedition_lockouts_entry.id = results.LastInsertedID(); - return character_expedition_lockouts_entry; - } - - character_expedition_lockouts_entry = NewEntity(); - - return character_expedition_lockouts_entry; - } - - static int InsertMany( - Database& db, - std::vector character_expedition_lockouts_entries - ) - { - std::vector insert_chunks; - - for (auto &character_expedition_lockouts_entry: character_expedition_lockouts_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_character_inspect_messages_repository.h b/common/repositories/base/base_character_inspect_messages_repository.h index 0a8cbc3e6..d85cde5d4 100644 --- a/common/repositories/base/base_character_inspect_messages_repository.h +++ b/common/repositories/base/base_character_inspect_messages_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_inspect_messages"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static CharacterInspectMessages FindOne( - Database& db, int character_inspect_messages_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int character_inspect_messages_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, CharacterInspectMessages character_inspect_messages_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(character_inspect_messages_entry.id)); update_values.push_back(columns[1] + " = '" + EscapeString(character_inspect_messages_entry.inspect_message) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static CharacterInspectMessages InsertOne( - Database& db, CharacterInspectMessages character_inspect_messages_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(character_inspect_messages_entry.id)); insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector character_inspect_messages_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_item_recast_repository.h b/common/repositories/base/base_character_item_recast_repository.h index 433d0f0f0..1f4438ed1 100644 --- a/common/repositories/base/base_character_item_recast_repository.h +++ b/common/repositories/base/base_character_item_recast_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_item_recast"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterItemRecast FindOne( - Database& db, int character_item_recast_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_item_recast_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterItemRecast character_item_recast_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_item_recast_entry.recast_type)); update_values.push_back(columns[2] + " = " + std::to_string(character_item_recast_entry.timestamp)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterItemRecast InsertOne( - Database& db, CharacterItemRecast character_item_recast_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_item_recast_entry.recast_type)); insert_values.push_back(std::to_string(character_item_recast_entry.timestamp)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_item_recast_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_languages_repository.h b/common/repositories/base/base_character_languages_repository.h index 64217e8d7..bbbd4011a 100644 --- a/common/repositories/base/base_character_languages_repository.h +++ b/common/repositories/base/base_character_languages_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_languages"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterLanguages FindOne( - Database& db, int character_languages_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_languages_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterLanguages character_languages_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_languages_entry.lang_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_languages_entry.value)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static CharacterLanguages InsertOne( - Database& db, CharacterLanguages character_languages_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_languages_entry.id)); insert_values.push_back(std::to_string(character_languages_entry.lang_id)); insert_values.push_back(std::to_string(character_languages_entry.value)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector character_languages_entries ) { @@ -198,7 +224,6 @@ public: for (auto &character_languages_entry: character_languages_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_languages_entry.id)); insert_values.push_back(std::to_string(character_languages_entry.lang_id)); insert_values.push_back(std::to_string(character_languages_entry.value)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_leadership_abilities_repository.h b/common/repositories/base/base_character_leadership_abilities_repository.h index ac872d88b..17f57bf85 100644 --- a/common/repositories/base/base_character_leadership_abilities_repository.h +++ b/common/repositories/base/base_character_leadership_abilities_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_leadership_abilities"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterLeadershipAbilities FindOne( - Database& db, int character_leadership_abilities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_leadership_abilities_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterLeadershipAbilities character_leadership_abilities_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_leadership_abilities_entry.slot)); update_values.push_back(columns[2] + " = " + std::to_string(character_leadership_abilities_entry.rank)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterLeadershipAbilities InsertOne( - Database& db, CharacterLeadershipAbilities character_leadership_abilities_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot)); insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_leadership_abilities_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_material_repository.h b/common/repositories/base/base_character_material_repository.h index 1b434cf2c..a7215027f 100644 --- a/common/repositories/base/base_character_material_repository.h +++ b/common/repositories/base/base_character_material_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H @@ -50,6 +67,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_material"); @@ -69,7 +101,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -103,11 +135,10 @@ public: } static CharacterMaterial FindOne( - Database& db, int character_material_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -134,11 +165,10 @@ public: } static int DeleteOne( - Database& db, int character_material_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -151,7 +181,6 @@ public: } static int UpdateOne( - Database& db, CharacterMaterial character_material_entry ) { @@ -166,7 +195,7 @@ public: update_values.push_back(columns[5] + " = " + std::to_string(character_material_entry.use_tint)); update_values.push_back(columns[6] + " = " + std::to_string(character_material_entry.color)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -180,13 +209,11 @@ public: } static CharacterMaterial InsertOne( - Database& db, CharacterMaterial character_material_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_material_entry.id)); insert_values.push_back(std::to_string(character_material_entry.slot)); insert_values.push_back(std::to_string(character_material_entry.blue)); insert_values.push_back(std::to_string(character_material_entry.green)); @@ -194,7 +221,7 @@ public: insert_values.push_back(std::to_string(character_material_entry.use_tint)); insert_values.push_back(std::to_string(character_material_entry.color)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -213,7 +240,6 @@ public: } static int InsertMany( - Database& db, std::vector character_material_entries ) { @@ -222,7 +248,6 @@ public: for (auto &character_material_entry: character_material_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_material_entry.id)); insert_values.push_back(std::to_string(character_material_entry.slot)); insert_values.push_back(std::to_string(character_material_entry.blue)); insert_values.push_back(std::to_string(character_material_entry.green)); @@ -235,7 +260,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -246,11 +271,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -276,11 +301,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -307,9 +332,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -320,9 +345,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_memmed_spells_repository.h b/common/repositories/base/base_character_memmed_spells_repository.h index b47750533..e4672c756 100644 --- a/common/repositories/base/base_character_memmed_spells_repository.h +++ b/common/repositories/base/base_character_memmed_spells_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_memmed_spells"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterMemmedSpells FindOne( - Database& db, int character_memmed_spells_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_memmed_spells_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterMemmedSpells character_memmed_spells_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_memmed_spells_entry.slot_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_memmed_spells_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static CharacterMemmedSpells InsertOne( - Database& db, CharacterMemmedSpells character_memmed_spells_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id)); insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector character_memmed_spells_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_pet_buffs_repository.h b/common/repositories/base/base_character_pet_buffs_repository.h index 3dc6eb689..5cc56ddeb 100644 --- a/common/repositories/base/base_character_pet_buffs_repository.h +++ b/common/repositories/base/base_character_pet_buffs_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H @@ -58,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_pet_buffs"); @@ -77,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -115,11 +147,10 @@ public: } static CharacterPetBuffs FindOne( - Database& db, int character_pet_buffs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -150,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int character_pet_buffs_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +197,6 @@ public: } static int UpdateOne( - Database& db, CharacterPetBuffs character_pet_buffs_entry ) { @@ -187,7 +216,7 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(character_pet_buffs_entry.rune)); update_values.push_back(columns[10] + " = " + std::to_string(character_pet_buffs_entry.instrument_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +230,6 @@ public: } static CharacterPetBuffs InsertOne( - Database& db, CharacterPetBuffs character_pet_buffs_entry ) { @@ -219,7 +247,7 @@ public: insert_values.push_back(std::to_string(character_pet_buffs_entry.rune)); insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector character_pet_buffs_entries ) { @@ -264,7 +291,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -309,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -344,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_pet_info_repository.h b/common/repositories/base/base_character_pet_info_repository.h index 91f65d216..b4d795745 100644 --- a/common/repositories/base/base_character_pet_info_repository.h +++ b/common/repositories/base/base_character_pet_info_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H @@ -26,7 +43,6 @@ public: int hp; int mana; float size; - int taunting; }; static std::string PrimaryKey() @@ -45,7 +61,6 @@ public: "hp", "mana", "size", - "taunting", }; } @@ -54,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_pet_info"); @@ -73,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -89,7 +119,6 @@ public: entry.hp = 0; entry.mana = 0; entry.size = 0; - entry.taunting = 1; return entry; } @@ -109,11 +138,10 @@ public: } static CharacterPetInfo FindOne( - Database& db, int character_pet_info_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -133,7 +161,6 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); return entry; } @@ -142,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int character_pet_info_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +185,6 @@ public: } static int UpdateOne( - Database& db, CharacterPetInfo character_pet_info_entry ) { @@ -175,9 +200,8 @@ public: update_values.push_back(columns[5] + " = " + std::to_string(character_pet_info_entry.hp)); update_values.push_back(columns[6] + " = " + std::to_string(character_pet_info_entry.mana)); update_values.push_back(columns[7] + " = " + std::to_string(character_pet_info_entry.size)); - update_values.push_back(columns[8] + " = " + std::to_string(character_pet_info_entry.taunting)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +215,6 @@ public: } static CharacterPetInfo InsertOne( - Database& db, CharacterPetInfo character_pet_info_entry ) { @@ -205,9 +228,8 @@ public: insert_values.push_back(std::to_string(character_pet_info_entry.hp)); insert_values.push_back(std::to_string(character_pet_info_entry.mana)); insert_values.push_back(std::to_string(character_pet_info_entry.size)); - insert_values.push_back(std::to_string(character_pet_info_entry.taunting)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +248,6 @@ public: } static int InsertMany( - Database& db, std::vector character_pet_info_entries ) { @@ -243,14 +264,13 @@ public: insert_values.push_back(std::to_string(character_pet_info_entry.hp)); insert_values.push_back(std::to_string(character_pet_info_entry.mana)); insert_values.push_back(std::to_string(character_pet_info_entry.size)); - insert_values.push_back(std::to_string(character_pet_info_entry.taunting)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +281,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -285,7 +305,6 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); all_entries.push_back(entry); } @@ -293,11 +312,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -318,7 +337,6 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); all_entries.push_back(entry); } @@ -326,9 +344,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +357,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_pet_inventory_repository.h b/common/repositories/base/base_character_pet_inventory_repository.h index 4e7e26456..f55afb693 100644 --- a/common/repositories/base/base_character_pet_inventory_repository.h +++ b/common/repositories/base/base_character_pet_inventory_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_pet_inventory"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static CharacterPetInventory FindOne( - Database& db, int character_pet_inventory_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int character_pet_inventory_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, CharacterPetInventory character_pet_inventory_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(character_pet_inventory_entry.slot)); update_values.push_back(columns[3] + " = " + std::to_string(character_pet_inventory_entry.item_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static CharacterPetInventory InsertOne( - Database& db, CharacterPetInventory character_pet_inventory_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(character_pet_inventory_entry.slot)); insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector character_pet_inventory_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_potionbelt_repository.h b/common/repositories/base/base_character_potionbelt_repository.h index 16d1cbfcd..7fb753d55 100644 --- a/common/repositories/base/base_character_potionbelt_repository.h +++ b/common/repositories/base/base_character_potionbelt_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_potionbelt"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static CharacterPotionbelt FindOne( - Database& db, int character_potionbelt_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int character_potionbelt_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, CharacterPotionbelt character_potionbelt_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(character_potionbelt_entry.item_id)); update_values.push_back(columns[3] + " = " + std::to_string(character_potionbelt_entry.icon)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static CharacterPotionbelt InsertOne( - Database& db, CharacterPotionbelt character_potionbelt_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(character_potionbelt_entry.item_id)); insert_values.push_back(std::to_string(character_potionbelt_entry.icon)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector character_potionbelt_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_skills_repository.h b/common/repositories/base/base_character_skills_repository.h index d654fd448..c43622287 100644 --- a/common/repositories/base/base_character_skills_repository.h +++ b/common/repositories/base/base_character_skills_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_skills"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterSkills FindOne( - Database& db, int character_skills_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_skills_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterSkills character_skills_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_skills_entry.skill_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_skills_entry.value)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static CharacterSkills InsertOne( - Database& db, CharacterSkills character_skills_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_skills_entry.id)); insert_values.push_back(std::to_string(character_skills_entry.skill_id)); insert_values.push_back(std::to_string(character_skills_entry.value)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector character_skills_entries ) { @@ -198,7 +224,6 @@ public: for (auto &character_skills_entry: character_skills_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_skills_entry.id)); insert_values.push_back(std::to_string(character_skills_entry.skill_id)); insert_values.push_back(std::to_string(character_skills_entry.value)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_spells_repository.h b/common/repositories/base/base_character_spells_repository.h index eb34b0d43..e5a6ab1d9 100644 --- a/common/repositories/base/base_character_spells_repository.h +++ b/common/repositories/base/base_character_spells_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_spells"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static CharacterSpells FindOne( - Database& db, int character_spells_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int character_spells_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, CharacterSpells character_spells_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_spells_entry.slot_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_spells_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static CharacterSpells InsertOne( - Database& db, CharacterSpells character_spells_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(character_spells_entry.id)); insert_values.push_back(std::to_string(character_spells_entry.slot_id)); insert_values.push_back(std::to_string(character_spells_entry.spell_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector character_spells_entries ) { @@ -198,7 +224,6 @@ public: for (auto &character_spells_entry: character_spells_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(character_spells_entry.id)); insert_values.push_back(std::to_string(character_spells_entry.slot_id)); insert_values.push_back(std::to_string(character_spells_entry.spell_id)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_character_tasks_repository.h b/common/repositories/base/base_character_tasks_repository.h index 9d8371f34..00dea5af6 100644 --- a/common/repositories/base/base_character_tasks_repository.h +++ b/common/repositories/base/base_character_tasks_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("character_tasks"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static CharacterTasks FindOne( - Database& db, int character_tasks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int character_tasks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, CharacterTasks character_tasks_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(character_tasks_entry.type)); update_values.push_back(columns[4] + " = " + std::to_string(character_tasks_entry.acceptedtime)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static CharacterTasks InsertOne( - Database& db, CharacterTasks character_tasks_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(character_tasks_entry.type)); insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector character_tasks_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_completed_tasks_repository.h b/common/repositories/base/base_completed_tasks_repository.h index bee95bf79..7aa4bb65a 100644 --- a/common/repositories/base/base_completed_tasks_repository.h +++ b/common/repositories/base/base_completed_tasks_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("completed_tasks"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static CompletedTasks FindOne( - Database& db, int completed_tasks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int completed_tasks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, CompletedTasks completed_tasks_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(completed_tasks_entry.taskid)); update_values.push_back(columns[3] + " = " + std::to_string(completed_tasks_entry.activityid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static CompletedTasks InsertOne( - Database& db, CompletedTasks completed_tasks_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(completed_tasks_entry.taskid)); insert_values.push_back(std::to_string(completed_tasks_entry.activityid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector completed_tasks_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_content_flags_repository.h b/common/repositories/base/base_content_flags_repository.h index f59ad8663..34127d0e5 100644 --- a/common/repositories/base/base_content_flags_repository.h +++ b/common/repositories/base/base_content_flags_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_CONTENT_FLAGS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("content_flags"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static ContentFlags FindOne( - Database& db, int content_flags_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int content_flags_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, ContentFlags content_flags_entry ) { @@ -151,7 +180,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(content_flags_entry.enabled)); update_values.push_back(columns[3] + " = '" + EscapeString(content_flags_entry.notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -165,18 +194,16 @@ public: } static ContentFlags InsertOne( - Database& db, ContentFlags content_flags_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(content_flags_entry.id)); insert_values.push_back("'" + EscapeString(content_flags_entry.flag_name) + "'"); insert_values.push_back(std::to_string(content_flags_entry.enabled)); insert_values.push_back("'" + EscapeString(content_flags_entry.notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -195,7 +222,6 @@ public: } static int InsertMany( - Database& db, std::vector content_flags_entries ) { @@ -204,7 +230,6 @@ public: for (auto &content_flags_entry: content_flags_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(content_flags_entry.id)); insert_values.push_back("'" + EscapeString(content_flags_entry.flag_name) + "'"); insert_values.push_back(std::to_string(content_flags_entry.enabled)); insert_values.push_back("'" + EscapeString(content_flags_entry.notes) + "'"); @@ -214,7 +239,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -225,11 +250,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -252,11 +277,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -280,9 +305,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -293,9 +318,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_damageshieldtypes_repository.h b/common/repositories/base/base_damageshieldtypes_repository.h deleted file mode 100644 index b2c6be57e..000000000 --- a/common/repositories/base/base_damageshieldtypes_repository.h +++ /dev/null @@ -1,293 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_DAMAGESHIELDTYPES_REPOSITORY_H -#define EQEMU_BASE_DAMAGESHIELDTYPES_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseDamageshieldtypesRepository { -public: - struct Damageshieldtypes { - int spellid; - int type; - }; - - static std::string PrimaryKey() - { - return std::string("spellid"); - } - - static std::vector Columns() - { - return { - "spellid", - "type", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("damageshieldtypes"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static Damageshieldtypes NewEntity() - { - Damageshieldtypes entry{}; - - entry.spellid = 0; - entry.type = 0; - - return entry; - } - - static Damageshieldtypes GetDamageshieldtypesEntry( - const std::vector &damageshieldtypess, - int damageshieldtypes_id - ) - { - for (auto &damageshieldtypes : damageshieldtypess) { - if (damageshieldtypes.spellid == damageshieldtypes_id) { - return damageshieldtypes; - } - } - - return NewEntity(); - } - - static Damageshieldtypes FindOne( - Database& db, - int damageshieldtypes_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - damageshieldtypes_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - Damageshieldtypes entry{}; - - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int damageshieldtypes_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - damageshieldtypes_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - Damageshieldtypes damageshieldtypes_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[0] + " = " + std::to_string(damageshieldtypes_entry.spellid)); - update_values.push_back(columns[1] + " = " + std::to_string(damageshieldtypes_entry.type)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - damageshieldtypes_entry.spellid - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static Damageshieldtypes InsertOne( - Database& db, - Damageshieldtypes damageshieldtypes_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); - insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - damageshieldtypes_entry.spellid = results.LastInsertedID(); - return damageshieldtypes_entry; - } - - damageshieldtypes_entry = NewEntity(); - - return damageshieldtypes_entry; - } - - static int InsertMany( - Database& db, - std::vector damageshieldtypes_entries - ) - { - std::vector insert_chunks; - - for (auto &damageshieldtypes_entry: damageshieldtypes_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); - insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - Damageshieldtypes entry{}; - - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - Damageshieldtypes entry{}; - - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/base/base_data_buckets_repository.h b/common/repositories/base/base_data_buckets_repository.h index cef173a69..60608174c 100644 --- a/common/repositories/base/base_data_buckets_repository.h +++ b/common/repositories/base/base_data_buckets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("data_buckets"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static DataBuckets FindOne( - Database& db, int data_buckets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int data_buckets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, DataBuckets data_buckets_entry ) { @@ -151,7 +180,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(data_buckets_entry.value) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(data_buckets_entry.expires)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -165,18 +194,16 @@ public: } static DataBuckets InsertOne( - Database& db, DataBuckets data_buckets_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(data_buckets_entry.id)); insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'"); insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'"); insert_values.push_back(std::to_string(data_buckets_entry.expires)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -195,7 +222,6 @@ public: } static int InsertMany( - Database& db, std::vector data_buckets_entries ) { @@ -204,7 +230,6 @@ public: for (auto &data_buckets_entry: data_buckets_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(data_buckets_entry.id)); insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'"); insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'"); insert_values.push_back(std::to_string(data_buckets_entry.expires)); @@ -214,7 +239,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -225,11 +250,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -252,11 +277,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -280,9 +305,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -293,9 +318,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_db_str_repository.h b/common/repositories/base/base_db_str_repository.h index f9a827d95..c5dc031ac 100644 --- a/common/repositories/base/base_db_str_repository.h +++ b/common/repositories/base/base_db_str_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_DB_STR_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("db_str"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static DbStr FindOne( - Database& db, int db_str_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int db_str_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, DbStr db_str_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(db_str_entry.type)); update_values.push_back(columns[2] + " = '" + EscapeString(db_str_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static DbStr InsertOne( - Database& db, DbStr db_str_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(db_str_entry.type)); insert_values.push_back("'" + EscapeString(db_str_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector db_str_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_discovered_items_repository.h b/common/repositories/base/base_discovered_items_repository.h index 555566f9d..55ee1cc2e 100644 --- a/common/repositories/base/base_discovered_items_repository.h +++ b/common/repositories/base/base_discovered_items_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("discovered_items"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static DiscoveredItems FindOne( - Database& db, int discovered_items_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int discovered_items_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, DiscoveredItems discovered_items_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(discovered_items_entry.discovered_date)); update_values.push_back(columns[3] + " = " + std::to_string(discovered_items_entry.account_status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static DiscoveredItems InsertOne( - Database& db, DiscoveredItems discovered_items_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(discovered_items_entry.discovered_date)); insert_values.push_back(std::to_string(discovered_items_entry.account_status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector discovered_items_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_doors_repository.h b/common/repositories/base/base_doors_repository.h index 75d740742..3ca9dcd86 100644 --- a/common/repositories/base/base_doors_repository.h +++ b/common/repositories/base/base_doors_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_DOORS_REPOSITORY_H @@ -52,8 +69,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; - int is_instance_door; }; static std::string PrimaryKey() @@ -98,8 +113,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", - "is_instance_door", }; } @@ -108,6 +121,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("doors"); @@ -127,7 +155,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -135,42 +163,40 @@ public: { Doors entry{}; - entry.id = 0; - entry.doorid = 0; - entry.zone = ""; - entry.version = 0; - entry.name = ""; - entry.pos_y = 0; - entry.pos_x = 0; - entry.pos_z = 0; - entry.heading = 0; - entry.opentype = 0; - entry.guild = 0; - entry.lockpick = 0; - entry.keyitem = 0; - entry.nokeyring = 0; - entry.triggerdoor = 0; - entry.triggertype = 0; - entry.disable_timer = 0; - entry.doorisopen = 0; - entry.door_param = 0; - entry.dest_zone = "NONE"; - entry.dest_instance = 0; - entry.dest_x = 0; - entry.dest_y = 0; - entry.dest_z = 0; - entry.dest_heading = 0; - entry.invert_state = 0; - entry.incline = 0; - entry.size = 100; - entry.buffer = 0; - entry.client_version_mask = 4294967295; - entry.is_ldon_door = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; - entry.is_instance_door = 0; + entry.id = 0; + entry.doorid = 0; + entry.zone = ""; + entry.version = 0; + entry.name = ""; + entry.pos_y = 0; + entry.pos_x = 0; + entry.pos_z = 0; + entry.heading = 0; + entry.opentype = 0; + entry.guild = 0; + entry.lockpick = 0; + entry.keyitem = 0; + entry.nokeyring = 0; + entry.triggerdoor = 0; + entry.triggertype = 0; + entry.disable_timer = 0; + entry.doorisopen = 0; + entry.door_param = 0; + entry.dest_zone = "NONE"; + entry.dest_instance = 0; + entry.dest_x = 0; + entry.dest_y = 0; + entry.dest_z = 0; + entry.dest_heading = 0; + entry.invert_state = 0; + entry.incline = 0; + entry.size = 100; + entry.buffer = 0; + entry.client_version_mask = 4294967295; + entry.is_ldon_door = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -190,11 +216,10 @@ public: } static Doors FindOne( - Database& db, int doors_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -206,42 +231,40 @@ public: if (results.RowCount() == 1) { Doors entry{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.min_expansion = atoi(row[31]); - entry.max_expansion = atoi(row[32]); - entry.content_flags = row[33] ? row[33] : ""; - entry.content_flags_disabled = row[34] ? row[34] : ""; - entry.is_instance_door = atoi(row[35]); + entry.id = atoi(row[0]); + entry.doorid = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.name = row[4] ? row[4] : ""; + entry.pos_y = static_cast(atof(row[5])); + entry.pos_x = static_cast(atof(row[6])); + entry.pos_z = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.opentype = atoi(row[9]); + entry.guild = atoi(row[10]); + entry.lockpick = atoi(row[11]); + entry.keyitem = atoi(row[12]); + entry.nokeyring = atoi(row[13]); + entry.triggerdoor = atoi(row[14]); + entry.triggertype = atoi(row[15]); + entry.disable_timer = atoi(row[16]); + entry.doorisopen = atoi(row[17]); + entry.door_param = atoi(row[18]); + entry.dest_zone = row[19] ? row[19] : ""; + entry.dest_instance = atoi(row[20]); + entry.dest_x = static_cast(atof(row[21])); + entry.dest_y = static_cast(atof(row[22])); + entry.dest_z = static_cast(atof(row[23])); + entry.dest_heading = static_cast(atof(row[24])); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = static_cast(atof(row[28])); + entry.client_version_mask = atoi(row[29]); + entry.is_ldon_door = atoi(row[30]); + entry.min_expansion = atoi(row[31]); + entry.max_expansion = atoi(row[32]); + entry.content_flags = row[33] ? row[33] : ""; return entry; } @@ -250,11 +273,10 @@ public: } static int DeleteOne( - Database& db, int doors_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -267,7 +289,6 @@ public: } static int UpdateOne( - Database& db, Doors doors_entry ) { @@ -308,10 +329,8 @@ public: update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.min_expansion)); update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.max_expansion)); update_values.push_back(columns[33] + " = '" + EscapeString(doors_entry.content_flags) + "'"); - update_values.push_back(columns[34] + " = '" + EscapeString(doors_entry.content_flags_disabled) + "'"); - update_values.push_back(columns[35] + " = " + std::to_string(doors_entry.is_instance_door)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -325,13 +344,11 @@ public: } static Doors InsertOne( - Database& db, Doors doors_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(doors_entry.id)); insert_values.push_back(std::to_string(doors_entry.doorid)); insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'"); insert_values.push_back(std::to_string(doors_entry.version)); @@ -365,10 +382,8 @@ public: insert_values.push_back(std::to_string(doors_entry.min_expansion)); insert_values.push_back(std::to_string(doors_entry.max_expansion)); insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(doors_entry.is_instance_door)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -387,7 +402,6 @@ public: } static int InsertMany( - Database& db, std::vector doors_entries ) { @@ -396,7 +410,6 @@ public: for (auto &doors_entry: doors_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(doors_entry.id)); insert_values.push_back(std::to_string(doors_entry.doorid)); insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'"); insert_values.push_back(std::to_string(doors_entry.version)); @@ -430,15 +443,13 @@ public: insert_values.push_back(std::to_string(doors_entry.min_expansion)); insert_values.push_back(std::to_string(doors_entry.max_expansion)); insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(doors_entry.is_instance_door)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -449,11 +460,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -465,42 +476,40 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Doors entry{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.min_expansion = atoi(row[31]); - entry.max_expansion = atoi(row[32]); - entry.content_flags = row[33] ? row[33] : ""; - entry.content_flags_disabled = row[34] ? row[34] : ""; - entry.is_instance_door = atoi(row[35]); + entry.id = atoi(row[0]); + entry.doorid = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.name = row[4] ? row[4] : ""; + entry.pos_y = static_cast(atof(row[5])); + entry.pos_x = static_cast(atof(row[6])); + entry.pos_z = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.opentype = atoi(row[9]); + entry.guild = atoi(row[10]); + entry.lockpick = atoi(row[11]); + entry.keyitem = atoi(row[12]); + entry.nokeyring = atoi(row[13]); + entry.triggerdoor = atoi(row[14]); + entry.triggertype = atoi(row[15]); + entry.disable_timer = atoi(row[16]); + entry.doorisopen = atoi(row[17]); + entry.door_param = atoi(row[18]); + entry.dest_zone = row[19] ? row[19] : ""; + entry.dest_instance = atoi(row[20]); + entry.dest_x = static_cast(atof(row[21])); + entry.dest_y = static_cast(atof(row[22])); + entry.dest_z = static_cast(atof(row[23])); + entry.dest_heading = static_cast(atof(row[24])); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = static_cast(atof(row[28])); + entry.client_version_mask = atoi(row[29]); + entry.is_ldon_door = atoi(row[30]); + entry.min_expansion = atoi(row[31]); + entry.max_expansion = atoi(row[32]); + entry.content_flags = row[33] ? row[33] : ""; all_entries.push_back(entry); } @@ -508,11 +517,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -525,42 +534,40 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Doors entry{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.min_expansion = atoi(row[31]); - entry.max_expansion = atoi(row[32]); - entry.content_flags = row[33] ? row[33] : ""; - entry.content_flags_disabled = row[34] ? row[34] : ""; - entry.is_instance_door = atoi(row[35]); + entry.id = atoi(row[0]); + entry.doorid = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.name = row[4] ? row[4] : ""; + entry.pos_y = static_cast(atof(row[5])); + entry.pos_x = static_cast(atof(row[6])); + entry.pos_z = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.opentype = atoi(row[9]); + entry.guild = atoi(row[10]); + entry.lockpick = atoi(row[11]); + entry.keyitem = atoi(row[12]); + entry.nokeyring = atoi(row[13]); + entry.triggerdoor = atoi(row[14]); + entry.triggertype = atoi(row[15]); + entry.disable_timer = atoi(row[16]); + entry.doorisopen = atoi(row[17]); + entry.door_param = atoi(row[18]); + entry.dest_zone = row[19] ? row[19] : ""; + entry.dest_instance = atoi(row[20]); + entry.dest_x = static_cast(atof(row[21])); + entry.dest_y = static_cast(atof(row[22])); + entry.dest_z = static_cast(atof(row[23])); + entry.dest_heading = static_cast(atof(row[24])); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = static_cast(atof(row[28])); + entry.client_version_mask = atoi(row[29]); + entry.is_ldon_door = atoi(row[30]); + entry.min_expansion = atoi(row[31]); + entry.max_expansion = atoi(row[32]); + entry.content_flags = row[33] ? row[33] : ""; all_entries.push_back(entry); } @@ -568,9 +575,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -581,9 +588,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_dynamic_zones_repository.h b/common/repositories/base/base_dynamic_zones_repository.h deleted file mode 100644 index 13aabb07b..000000000 --- a/common/repositories/base/base_dynamic_zones_repository.h +++ /dev/null @@ -1,427 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_DYNAMIC_ZONES_REPOSITORY_H -#define EQEMU_BASE_DYNAMIC_ZONES_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseDynamicZonesRepository { -public: - struct DynamicZones { - int id; - int instance_id; - int type; - int compass_zone_id; - float compass_x; - float compass_y; - float compass_z; - int safe_return_zone_id; - float safe_return_x; - float safe_return_y; - float safe_return_z; - float safe_return_heading; - float zone_in_x; - float zone_in_y; - float zone_in_z; - float zone_in_heading; - int has_zone_in; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "instance_id", - "type", - "compass_zone_id", - "compass_x", - "compass_y", - "compass_z", - "safe_return_zone_id", - "safe_return_x", - "safe_return_y", - "safe_return_z", - "safe_return_heading", - "zone_in_x", - "zone_in_y", - "zone_in_z", - "zone_in_heading", - "has_zone_in", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("dynamic_zones"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static DynamicZones NewEntity() - { - DynamicZones entry{}; - - entry.id = 0; - entry.instance_id = 0; - entry.type = 0; - entry.compass_zone_id = 0; - entry.compass_x = 0; - entry.compass_y = 0; - entry.compass_z = 0; - entry.safe_return_zone_id = 0; - entry.safe_return_x = 0; - entry.safe_return_y = 0; - entry.safe_return_z = 0; - entry.safe_return_heading = 0; - entry.zone_in_x = 0; - entry.zone_in_y = 0; - entry.zone_in_z = 0; - entry.zone_in_heading = 0; - entry.has_zone_in = 0; - - return entry; - } - - static DynamicZones GetDynamicZonesEntry( - const std::vector &dynamic_zoness, - int dynamic_zones_id - ) - { - for (auto &dynamic_zones : dynamic_zoness) { - if (dynamic_zones.id == dynamic_zones_id) { - return dynamic_zones; - } - } - - return NewEntity(); - } - - static DynamicZones FindOne( - Database& db, - int dynamic_zones_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - dynamic_zones_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - DynamicZones entry{}; - - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.compass_zone_id = atoi(row[3]); - entry.compass_x = static_cast(atof(row[4])); - entry.compass_y = static_cast(atof(row[5])); - entry.compass_z = static_cast(atof(row[6])); - entry.safe_return_zone_id = atoi(row[7]); - entry.safe_return_x = static_cast(atof(row[8])); - entry.safe_return_y = static_cast(atof(row[9])); - entry.safe_return_z = static_cast(atof(row[10])); - entry.safe_return_heading = static_cast(atof(row[11])); - entry.zone_in_x = static_cast(atof(row[12])); - entry.zone_in_y = static_cast(atof(row[13])); - entry.zone_in_z = static_cast(atof(row[14])); - entry.zone_in_heading = static_cast(atof(row[15])); - entry.has_zone_in = atoi(row[16]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int dynamic_zones_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - dynamic_zones_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - DynamicZones dynamic_zones_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zones_entry.instance_id)); - update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zones_entry.type)); - update_values.push_back(columns[3] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id)); - update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zones_entry.compass_x)); - update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.compass_y)); - update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.compass_z)); - update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id)); - update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.safe_return_x)); - update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.safe_return_y)); - update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.safe_return_z)); - update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading)); - update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.zone_in_x)); - update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.zone_in_y)); - update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.zone_in_z)); - update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading)); - update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.has_zone_in)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - dynamic_zones_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static DynamicZones InsertOne( - Database& db, - DynamicZones dynamic_zones_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(dynamic_zones_entry.id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.type)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - dynamic_zones_entry.id = results.LastInsertedID(); - return dynamic_zones_entry; - } - - dynamic_zones_entry = NewEntity(); - - return dynamic_zones_entry; - } - - static int InsertMany( - Database& db, - std::vector dynamic_zones_entries - ) - { - std::vector insert_chunks; - - for (auto &dynamic_zones_entry: dynamic_zones_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(dynamic_zones_entry.id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.type)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZones entry{}; - - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.compass_zone_id = atoi(row[3]); - entry.compass_x = static_cast(atof(row[4])); - entry.compass_y = static_cast(atof(row[5])); - entry.compass_z = static_cast(atof(row[6])); - entry.safe_return_zone_id = atoi(row[7]); - entry.safe_return_x = static_cast(atof(row[8])); - entry.safe_return_y = static_cast(atof(row[9])); - entry.safe_return_z = static_cast(atof(row[10])); - entry.safe_return_heading = static_cast(atof(row[11])); - entry.zone_in_x = static_cast(atof(row[12])); - entry.zone_in_y = static_cast(atof(row[13])); - entry.zone_in_z = static_cast(atof(row[14])); - entry.zone_in_heading = static_cast(atof(row[15])); - entry.has_zone_in = atoi(row[16]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZones entry{}; - - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.compass_zone_id = atoi(row[3]); - entry.compass_x = static_cast(atof(row[4])); - entry.compass_y = static_cast(atof(row[5])); - entry.compass_z = static_cast(atof(row[6])); - entry.safe_return_zone_id = atoi(row[7]); - entry.safe_return_x = static_cast(atof(row[8])); - entry.safe_return_y = static_cast(atof(row[9])); - entry.safe_return_z = static_cast(atof(row[10])); - entry.safe_return_heading = static_cast(atof(row[11])); - entry.zone_in_x = static_cast(atof(row[12])); - entry.zone_in_y = static_cast(atof(row[13])); - entry.zone_in_z = static_cast(atof(row[14])); - entry.zone_in_heading = static_cast(atof(row[15])); - entry.has_zone_in = atoi(row[16]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_eventlog_repository.h b/common/repositories/base/base_eventlog_repository.h index 999fb455b..ce166886e 100644 --- a/common/repositories/base/base_eventlog_repository.h +++ b/common/repositories/base/base_eventlog_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_EVENTLOG_REPOSITORY_H @@ -56,6 +73,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("eventlog"); @@ -75,7 +107,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -112,11 +144,10 @@ public: } static Eventlog FindOne( - Database& db, int eventlog_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -146,11 +177,10 @@ public: } static int DeleteOne( - Database& db, int eventlog_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -163,7 +193,6 @@ public: } static int UpdateOne( - Database& db, Eventlog eventlog_entry ) { @@ -181,7 +210,7 @@ public: update_values.push_back(columns[8] + " = '" + EscapeString(eventlog_entry.description) + "'"); update_values.push_back(columns[9] + " = " + std::to_string(eventlog_entry.event_nid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -195,13 +224,11 @@ public: } static Eventlog InsertOne( - Database& db, Eventlog eventlog_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(eventlog_entry.id)); insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'"); insert_values.push_back(std::to_string(eventlog_entry.accountid)); insert_values.push_back(std::to_string(eventlog_entry.status)); @@ -212,7 +239,7 @@ public: insert_values.push_back("'" + EscapeString(eventlog_entry.description) + "'"); insert_values.push_back(std::to_string(eventlog_entry.event_nid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -231,7 +258,6 @@ public: } static int InsertMany( - Database& db, std::vector eventlog_entries ) { @@ -240,7 +266,6 @@ public: for (auto &eventlog_entry: eventlog_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(eventlog_entry.id)); insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'"); insert_values.push_back(std::to_string(eventlog_entry.accountid)); insert_values.push_back(std::to_string(eventlog_entry.status)); @@ -256,7 +281,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -267,11 +292,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -300,11 +325,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -334,9 +359,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -347,9 +372,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_expedition_lockouts_repository.h b/common/repositories/base/base_expedition_lockouts_repository.h deleted file mode 100644 index e9c5ceda2..000000000 --- a/common/repositories/base/base_expedition_lockouts_repository.h +++ /dev/null @@ -1,328 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_EXPEDITION_LOCKOUTS_REPOSITORY_H -#define EQEMU_BASE_EXPEDITION_LOCKOUTS_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseExpeditionLockoutsRepository { -public: - struct ExpeditionLockouts { - int id; - int expedition_id; - std::string event_name; - std::string expire_time; - int duration; - std::string from_expedition_uuid; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "expedition_id", - "event_name", - "expire_time", - "duration", - "from_expedition_uuid", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("expedition_lockouts"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static ExpeditionLockouts NewEntity() - { - ExpeditionLockouts entry{}; - - entry.id = 0; - entry.expedition_id = 0; - entry.event_name = ""; - entry.expire_time = ""; - entry.duration = 0; - entry.from_expedition_uuid = ""; - - return entry; - } - - static ExpeditionLockouts GetExpeditionLockoutsEntry( - const std::vector &expedition_lockoutss, - int expedition_lockouts_id - ) - { - for (auto &expedition_lockouts : expedition_lockoutss) { - if (expedition_lockouts.id == expedition_lockouts_id) { - return expedition_lockouts; - } - } - - return NewEntity(); - } - - static ExpeditionLockouts FindOne( - Database& db, - int expedition_lockouts_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - expedition_lockouts_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - ExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int expedition_lockouts_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - expedition_lockouts_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - ExpeditionLockouts expedition_lockouts_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id)); - update_values.push_back(columns[2] + " = '" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(expedition_lockouts_entry.duration)); - update_values.push_back(columns[5] + " = '" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - expedition_lockouts_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static ExpeditionLockouts InsertOne( - Database& db, - ExpeditionLockouts expedition_lockouts_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); - insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - expedition_lockouts_entry.id = results.LastInsertedID(); - return expedition_lockouts_entry; - } - - expedition_lockouts_entry = NewEntity(); - - return expedition_lockouts_entry; - } - - static int InsertMany( - Database& db, - std::vector expedition_lockouts_entries - ) - { - std::vector insert_chunks; - - for (auto &expedition_lockouts_entry: expedition_lockouts_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); - insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionLockouts entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_expedition_members_repository.h b/common/repositories/base/base_expedition_members_repository.h deleted file mode 100644 index dde0be588..000000000 --- a/common/repositories/base/base_expedition_members_repository.h +++ /dev/null @@ -1,310 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_EXPEDITION_MEMBERS_REPOSITORY_H -#define EQEMU_BASE_EXPEDITION_MEMBERS_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseExpeditionMembersRepository { -public: - struct ExpeditionMembers { - int id; - int expedition_id; - int character_id; - int is_current_member; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "expedition_id", - "character_id", - "is_current_member", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("expedition_members"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static ExpeditionMembers NewEntity() - { - ExpeditionMembers entry{}; - - entry.id = 0; - entry.expedition_id = 0; - entry.character_id = 0; - entry.is_current_member = 1; - - return entry; - } - - static ExpeditionMembers GetExpeditionMembersEntry( - const std::vector &expedition_memberss, - int expedition_members_id - ) - { - for (auto &expedition_members : expedition_memberss) { - if (expedition_members.id == expedition_members_id) { - return expedition_members; - } - } - - return NewEntity(); - } - - static ExpeditionMembers FindOne( - Database& db, - int expedition_members_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - expedition_members_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - ExpeditionMembers entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.character_id = atoi(row[2]); - entry.is_current_member = atoi(row[3]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int expedition_members_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - expedition_members_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - ExpeditionMembers expedition_members_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = " + std::to_string(expedition_members_entry.expedition_id)); - update_values.push_back(columns[2] + " = " + std::to_string(expedition_members_entry.character_id)); - update_values.push_back(columns[3] + " = " + std::to_string(expedition_members_entry.is_current_member)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - expedition_members_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static ExpeditionMembers InsertOne( - Database& db, - ExpeditionMembers expedition_members_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(expedition_members_entry.id)); - insert_values.push_back(std::to_string(expedition_members_entry.expedition_id)); - insert_values.push_back(std::to_string(expedition_members_entry.character_id)); - insert_values.push_back(std::to_string(expedition_members_entry.is_current_member)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - expedition_members_entry.id = results.LastInsertedID(); - return expedition_members_entry; - } - - expedition_members_entry = NewEntity(); - - return expedition_members_entry; - } - - static int InsertMany( - Database& db, - std::vector expedition_members_entries - ) - { - std::vector insert_chunks; - - for (auto &expedition_members_entry: expedition_members_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(expedition_members_entry.id)); - insert_values.push_back(std::to_string(expedition_members_entry.expedition_id)); - insert_values.push_back(std::to_string(expedition_members_entry.character_id)); - insert_values.push_back(std::to_string(expedition_members_entry.is_current_member)); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionMembers entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.character_id = atoi(row[2]); - entry.is_current_member = atoi(row[3]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionMembers entry{}; - - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.character_id = atoi(row[2]); - entry.is_current_member = atoi(row[3]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_EXPEDITION_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_expeditions_repository.h b/common/repositories/base/base_expeditions_repository.h deleted file mode 100644 index 8fea9a698..000000000 --- a/common/repositories/base/base_expeditions_repository.h +++ /dev/null @@ -1,355 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_EXPEDITIONS_REPOSITORY_H -#define EQEMU_BASE_EXPEDITIONS_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseExpeditionsRepository { -public: - struct Expeditions { - int id; - std::string uuid; - int dynamic_zone_id; - std::string expedition_name; - int leader_id; - int min_players; - int max_players; - int add_replay_on_join; - int is_locked; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "uuid", - "dynamic_zone_id", - "expedition_name", - "leader_id", - "min_players", - "max_players", - "add_replay_on_join", - "is_locked", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("expeditions"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static Expeditions NewEntity() - { - Expeditions entry{}; - - entry.id = 0; - entry.uuid = ""; - entry.dynamic_zone_id = 0; - entry.expedition_name = ""; - entry.leader_id = 0; - entry.min_players = 0; - entry.max_players = 0; - entry.add_replay_on_join = 1; - entry.is_locked = 0; - - return entry; - } - - static Expeditions GetExpeditionsEntry( - const std::vector &expeditionss, - int expeditions_id - ) - { - for (auto &expeditions : expeditionss) { - if (expeditions.id == expeditions_id) { - return expeditions; - } - } - - return NewEntity(); - } - - static Expeditions FindOne( - Database& db, - int expeditions_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - expeditions_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - Expeditions entry{}; - - entry.id = atoi(row[0]); - entry.uuid = row[1] ? row[1] : ""; - entry.dynamic_zone_id = atoi(row[2]); - entry.expedition_name = row[3] ? row[3] : ""; - entry.leader_id = atoi(row[4]); - entry.min_players = atoi(row[5]); - entry.max_players = atoi(row[6]); - entry.add_replay_on_join = atoi(row[7]); - entry.is_locked = atoi(row[8]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int expeditions_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - expeditions_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - Expeditions expeditions_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = '" + EscapeString(expeditions_entry.uuid) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.dynamic_zone_id)); - update_values.push_back(columns[3] + " = '" + EscapeString(expeditions_entry.expedition_name) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(expeditions_entry.leader_id)); - update_values.push_back(columns[5] + " = " + std::to_string(expeditions_entry.min_players)); - update_values.push_back(columns[6] + " = " + std::to_string(expeditions_entry.max_players)); - update_values.push_back(columns[7] + " = " + std::to_string(expeditions_entry.add_replay_on_join)); - update_values.push_back(columns[8] + " = " + std::to_string(expeditions_entry.is_locked)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - expeditions_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static Expeditions InsertOne( - Database& db, - Expeditions expeditions_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(expeditions_entry.id)); - insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'"); - insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); - insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'"); - insert_values.push_back(std::to_string(expeditions_entry.leader_id)); - insert_values.push_back(std::to_string(expeditions_entry.min_players)); - insert_values.push_back(std::to_string(expeditions_entry.max_players)); - insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); - insert_values.push_back(std::to_string(expeditions_entry.is_locked)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - expeditions_entry.id = results.LastInsertedID(); - return expeditions_entry; - } - - expeditions_entry = NewEntity(); - - return expeditions_entry; - } - - static int InsertMany( - Database& db, - std::vector expeditions_entries - ) - { - std::vector insert_chunks; - - for (auto &expeditions_entry: expeditions_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(expeditions_entry.id)); - insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'"); - insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); - insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'"); - insert_values.push_back(std::to_string(expeditions_entry.leader_id)); - insert_values.push_back(std::to_string(expeditions_entry.min_players)); - insert_values.push_back(std::to_string(expeditions_entry.max_players)); - insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); - insert_values.push_back(std::to_string(expeditions_entry.is_locked)); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - Expeditions entry{}; - - entry.id = atoi(row[0]); - entry.uuid = row[1] ? row[1] : ""; - entry.dynamic_zone_id = atoi(row[2]); - entry.expedition_name = row[3] ? row[3] : ""; - entry.leader_id = atoi(row[4]); - entry.min_players = atoi(row[5]); - entry.max_players = atoi(row[6]); - entry.add_replay_on_join = atoi(row[7]); - entry.is_locked = atoi(row[8]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - Expeditions entry{}; - - entry.id = atoi(row[0]); - entry.uuid = row[1] ? row[1] : ""; - entry.dynamic_zone_id = atoi(row[2]); - entry.expedition_name = row[3] ? row[3] : ""; - entry.leader_id = atoi(row[4]); - entry.min_players = atoi(row[5]); - entry.max_players = atoi(row[6]); - entry.add_replay_on_join = atoi(row[7]); - entry.is_locked = atoi(row[8]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_EXPEDITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_faction_base_data_repository.h b/common/repositories/base/base_faction_base_data_repository.h index c5bfc8c43..4860af5e5 100644 --- a/common/repositories/base/base_faction_base_data_repository.h +++ b/common/repositories/base/base_faction_base_data_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("faction_base_data"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static FactionBaseData FindOne( - Database& db, int faction_base_data_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int faction_base_data_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, FactionBaseData faction_base_data_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(faction_base_data_entry.unk_hero2)); update_values.push_back(columns[5] + " = " + std::to_string(faction_base_data_entry.unk_hero3)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static FactionBaseData InsertOne( - Database& db, FactionBaseData faction_base_data_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2)); insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector faction_base_data_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_faction_list_mod_repository.h b/common/repositories/base/base_faction_list_mod_repository.h index 673c6ac96..903cdf1e2 100644 --- a/common/repositories/base/base_faction_list_mod_repository.h +++ b/common/repositories/base/base_faction_list_mod_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("faction_list_mod"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static FactionListMod FindOne( - Database& db, int faction_list_mod_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int faction_list_mod_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, FactionListMod faction_list_mod_entry ) { @@ -151,7 +180,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(faction_list_mod_entry.mod)); update_values.push_back(columns[3] + " = '" + EscapeString(faction_list_mod_entry.mod_name) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -165,18 +194,16 @@ public: } static FactionListMod InsertOne( - Database& db, FactionListMod faction_list_mod_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(faction_list_mod_entry.id)); insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id)); insert_values.push_back(std::to_string(faction_list_mod_entry.mod)); insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -195,7 +222,6 @@ public: } static int InsertMany( - Database& db, std::vector faction_list_mod_entries ) { @@ -204,7 +230,6 @@ public: for (auto &faction_list_mod_entry: faction_list_mod_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(faction_list_mod_entry.id)); insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id)); insert_values.push_back(std::to_string(faction_list_mod_entry.mod)); insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'"); @@ -214,7 +239,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -225,11 +250,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -252,11 +277,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -280,9 +305,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -293,9 +318,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_faction_list_repository.h b/common/repositories/base/base_faction_list_repository.h index 32e20bb6c..d1fa6eabb 100644 --- a/common/repositories/base/base_faction_list_repository.h +++ b/common/repositories/base/base_faction_list_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FACTION_LIST_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("faction_list"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static FactionList FindOne( - Database& db, int faction_list_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int faction_list_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, FactionList faction_list_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(faction_list_entry.name) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(faction_list_entry.base)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static FactionList InsertOne( - Database& db, FactionList faction_list_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back("'" + EscapeString(faction_list_entry.name) + "'"); insert_values.push_back(std::to_string(faction_list_entry.base)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector faction_list_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_faction_values_repository.h b/common/repositories/base/base_faction_values_repository.h index 181779da3..1f32a8272 100644 --- a/common/repositories/base/base_faction_values_repository.h +++ b/common/repositories/base/base_faction_values_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FACTION_VALUES_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("faction_values"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static FactionValues FindOne( - Database& db, int faction_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int faction_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, FactionValues faction_values_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(faction_values_entry.current_value)); update_values.push_back(columns[3] + " = " + std::to_string(faction_values_entry.temp)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static FactionValues InsertOne( - Database& db, FactionValues faction_values_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(faction_values_entry.current_value)); insert_values.push_back(std::to_string(faction_values_entry.temp)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector faction_values_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_fishing_repository.h b/common/repositories/base/base_fishing_repository.h index 6ee2bf098..43f5a90c0 100644 --- a/common/repositories/base/base_fishing_repository.h +++ b/common/repositories/base/base_fishing_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FISHING_REPOSITORY_H @@ -28,7 +45,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -49,7 +65,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -58,6 +73,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("fishing"); @@ -77,7 +107,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -85,17 +115,16 @@ public: { Fishing entry{}; - entry.id = 0; - entry.zoneid = 0; - entry.Itemid = 0; - entry.skill_level = 0; - entry.chance = 0; - entry.npc_id = 0; - entry.npc_chance = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.zoneid = 0; + entry.Itemid = 0; + entry.skill_level = 0; + entry.chance = 0; + entry.npc_id = 0; + entry.npc_chance = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -115,11 +144,10 @@ public: } static Fishing FindOne( - Database& db, int fishing_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -131,17 +159,16 @@ public: if (results.RowCount() == 1) { Fishing entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.skill_level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.npc_id = atoi(row[5]); + entry.npc_chance = atoi(row[6]); + entry.min_expansion = atoi(row[7]); + entry.max_expansion = atoi(row[8]); + entry.content_flags = row[9] ? row[9] : ""; return entry; } @@ -150,11 +177,10 @@ public: } static int DeleteOne( - Database& db, int fishing_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +193,6 @@ public: } static int UpdateOne( - Database& db, Fishing fishing_entry ) { @@ -184,9 +209,8 @@ public: update_values.push_back(columns[7] + " = " + std::to_string(fishing_entry.min_expansion)); update_values.push_back(columns[8] + " = " + std::to_string(fishing_entry.max_expansion)); update_values.push_back(columns[9] + " = '" + EscapeString(fishing_entry.content_flags) + "'"); - update_values.push_back(columns[10] + " = '" + EscapeString(fishing_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -200,13 +224,11 @@ public: } static Fishing InsertOne( - Database& db, Fishing fishing_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(fishing_entry.id)); insert_values.push_back(std::to_string(fishing_entry.zoneid)); insert_values.push_back(std::to_string(fishing_entry.Itemid)); insert_values.push_back(std::to_string(fishing_entry.skill_level)); @@ -216,9 +238,8 @@ public: insert_values.push_back(std::to_string(fishing_entry.min_expansion)); insert_values.push_back(std::to_string(fishing_entry.max_expansion)); insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(fishing_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -237,7 +258,6 @@ public: } static int InsertMany( - Database& db, std::vector fishing_entries ) { @@ -246,7 +266,6 @@ public: for (auto &fishing_entry: fishing_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(fishing_entry.id)); insert_values.push_back(std::to_string(fishing_entry.zoneid)); insert_values.push_back(std::to_string(fishing_entry.Itemid)); insert_values.push_back(std::to_string(fishing_entry.skill_level)); @@ -256,14 +275,13 @@ public: insert_values.push_back(std::to_string(fishing_entry.min_expansion)); insert_values.push_back(std::to_string(fishing_entry.max_expansion)); insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(fishing_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -274,11 +292,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -290,17 +308,16 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Fishing entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.skill_level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.npc_id = atoi(row[5]); + entry.npc_chance = atoi(row[6]); + entry.min_expansion = atoi(row[7]); + entry.max_expansion = atoi(row[8]); + entry.content_flags = row[9] ? row[9] : ""; all_entries.push_back(entry); } @@ -308,11 +325,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -325,17 +342,16 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Fishing entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.skill_level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.npc_id = atoi(row[5]); + entry.npc_chance = atoi(row[6]); + entry.min_expansion = atoi(row[7]); + entry.max_expansion = atoi(row[8]); + entry.content_flags = row[9] ? row[9] : ""; all_entries.push_back(entry); } @@ -343,9 +359,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -356,9 +372,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_forage_repository.h b/common/repositories/base/base_forage_repository.h index 0aa684b1b..2f3690be4 100644 --- a/common/repositories/base/base_forage_repository.h +++ b/common/repositories/base/base_forage_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FORAGE_REPOSITORY_H @@ -26,7 +43,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -45,7 +61,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -54,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("forage"); @@ -73,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -81,15 +111,14 @@ public: { Forage entry{}; - entry.id = 0; - entry.zoneid = 0; - entry.Itemid = 0; - entry.level = 0; - entry.chance = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.zoneid = 0; + entry.Itemid = 0; + entry.level = 0; + entry.chance = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -109,11 +138,10 @@ public: } static Forage FindOne( - Database& db, int forage_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -125,15 +153,14 @@ public: if (results.RowCount() == 1) { Forage entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.min_expansion = atoi(row[5]); + entry.max_expansion = atoi(row[6]); + entry.content_flags = row[7] ? row[7] : ""; return entry; } @@ -142,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int forage_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +185,6 @@ public: } static int UpdateOne( - Database& db, Forage forage_entry ) { @@ -174,9 +199,8 @@ public: update_values.push_back(columns[5] + " = " + std::to_string(forage_entry.min_expansion)); update_values.push_back(columns[6] + " = " + std::to_string(forage_entry.max_expansion)); update_values.push_back(columns[7] + " = '" + EscapeString(forage_entry.content_flags) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(forage_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -190,13 +214,11 @@ public: } static Forage InsertOne( - Database& db, Forage forage_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(forage_entry.id)); insert_values.push_back(std::to_string(forage_entry.zoneid)); insert_values.push_back(std::to_string(forage_entry.Itemid)); insert_values.push_back(std::to_string(forage_entry.level)); @@ -204,9 +226,8 @@ public: insert_values.push_back(std::to_string(forage_entry.min_expansion)); insert_values.push_back(std::to_string(forage_entry.max_expansion)); insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(forage_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -225,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector forage_entries ) { @@ -234,7 +254,6 @@ public: for (auto &forage_entry: forage_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(forage_entry.id)); insert_values.push_back(std::to_string(forage_entry.zoneid)); insert_values.push_back(std::to_string(forage_entry.Itemid)); insert_values.push_back(std::to_string(forage_entry.level)); @@ -242,14 +261,13 @@ public: insert_values.push_back(std::to_string(forage_entry.min_expansion)); insert_values.push_back(std::to_string(forage_entry.max_expansion)); insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(forage_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -260,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -276,15 +294,14 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Forage entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.min_expansion = atoi(row[5]); + entry.max_expansion = atoi(row[6]); + entry.content_flags = row[7] ? row[7] : ""; all_entries.push_back(entry); } @@ -292,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -309,15 +326,14 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Forage entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.min_expansion = atoi(row[5]); + entry.max_expansion = atoi(row[6]); + entry.content_flags = row[7] ? row[7] : ""; all_entries.push_back(entry); } @@ -325,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -338,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_friends_repository.h b/common/repositories/base/base_friends_repository.h index 187994a85..9fb341b27 100644 --- a/common/repositories/base/base_friends_repository.h +++ b/common/repositories/base/base_friends_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_FRIENDS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("friends"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static Friends FindOne( - Database& db, int friends_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int friends_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, Friends friends_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(friends_entry.type)); update_values.push_back(columns[2] + " = '" + EscapeString(friends_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static Friends InsertOne( - Database& db, Friends friends_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(friends_entry.type)); insert_values.push_back("'" + EscapeString(friends_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector friends_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_global_loot_repository.h b/common/repositories/base/base_global_loot_repository.h index 98170acf5..0d86b6cdf 100644 --- a/common/repositories/base/base_global_loot_repository.h +++ b/common/repositories/base/base_global_loot_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H @@ -34,7 +51,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -61,7 +77,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -70,6 +85,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("global_loot"); @@ -89,7 +119,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,23 +127,22 @@ public: { GlobalLoot entry{}; - entry.id = 0; - entry.description = ""; - entry.loottable_id = 0; - entry.enabled = 1; - entry.min_level = 0; - entry.max_level = 0; - entry.rare = 0; - entry.raid = 0; - entry.race = ""; - entry.class = ""; - entry.bodytype = ""; - entry.zone = ""; - entry.hot_zone = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.description = ""; + entry.loottable_id = 0; + entry.enabled = 1; + entry.min_level = 0; + entry.max_level = 0; + entry.rare = 0; + entry.raid = 0; + entry.race = ""; + entry.class = ""; + entry.bodytype = ""; + entry.zone = ""; + entry.hot_zone = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -133,11 +162,10 @@ public: } static GlobalLoot FindOne( - Database& db, int global_loot_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -149,23 +177,22 @@ public: if (results.RowCount() == 1) { GlobalLoot entry{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + entry.id = atoi(row[0]); + entry.description = row[1] ? row[1] : ""; + entry.loottable_id = atoi(row[2]); + entry.enabled = atoi(row[3]); + entry.min_level = atoi(row[4]); + entry.max_level = atoi(row[5]); + entry.rare = atoi(row[6]); + entry.raid = atoi(row[7]); + entry.race = row[8] ? row[8] : ""; + entry.class = row[9] ? row[9] : ""; + entry.bodytype = row[10] ? row[10] : ""; + entry.zone = row[11] ? row[11] : ""; + entry.hot_zone = atoi(row[12]); + entry.min_expansion = atoi(row[13]); + entry.max_expansion = atoi(row[14]); + entry.content_flags = row[15] ? row[15] : ""; return entry; } @@ -174,11 +201,10 @@ public: } static int DeleteOne( - Database& db, int global_loot_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -191,7 +217,6 @@ public: } static int UpdateOne( - Database& db, GlobalLoot global_loot_entry ) { @@ -214,9 +239,8 @@ public: update_values.push_back(columns[13] + " = " + std::to_string(global_loot_entry.min_expansion)); update_values.push_back(columns[14] + " = " + std::to_string(global_loot_entry.max_expansion)); update_values.push_back(columns[15] + " = '" + EscapeString(global_loot_entry.content_flags) + "'"); - update_values.push_back(columns[16] + " = '" + EscapeString(global_loot_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -230,13 +254,11 @@ public: } static GlobalLoot InsertOne( - Database& db, GlobalLoot global_loot_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(global_loot_entry.id)); insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'"); insert_values.push_back(std::to_string(global_loot_entry.loottable_id)); insert_values.push_back(std::to_string(global_loot_entry.enabled)); @@ -252,9 +274,8 @@ public: insert_values.push_back(std::to_string(global_loot_entry.min_expansion)); insert_values.push_back(std::to_string(global_loot_entry.max_expansion)); insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -273,7 +294,6 @@ public: } static int InsertMany( - Database& db, std::vector global_loot_entries ) { @@ -282,7 +302,6 @@ public: for (auto &global_loot_entry: global_loot_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(global_loot_entry.id)); insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'"); insert_values.push_back(std::to_string(global_loot_entry.loottable_id)); insert_values.push_back(std::to_string(global_loot_entry.enabled)); @@ -298,14 +317,13 @@ public: insert_values.push_back(std::to_string(global_loot_entry.min_expansion)); insert_values.push_back(std::to_string(global_loot_entry.max_expansion)); insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -316,11 +334,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -332,23 +350,22 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GlobalLoot entry{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + entry.id = atoi(row[0]); + entry.description = row[1] ? row[1] : ""; + entry.loottable_id = atoi(row[2]); + entry.enabled = atoi(row[3]); + entry.min_level = atoi(row[4]); + entry.max_level = atoi(row[5]); + entry.rare = atoi(row[6]); + entry.raid = atoi(row[7]); + entry.race = row[8] ? row[8] : ""; + entry.class = row[9] ? row[9] : ""; + entry.bodytype = row[10] ? row[10] : ""; + entry.zone = row[11] ? row[11] : ""; + entry.hot_zone = atoi(row[12]); + entry.min_expansion = atoi(row[13]); + entry.max_expansion = atoi(row[14]); + entry.content_flags = row[15] ? row[15] : ""; all_entries.push_back(entry); } @@ -356,11 +373,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -373,23 +390,22 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GlobalLoot entry{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + entry.id = atoi(row[0]); + entry.description = row[1] ? row[1] : ""; + entry.loottable_id = atoi(row[2]); + entry.enabled = atoi(row[3]); + entry.min_level = atoi(row[4]); + entry.max_level = atoi(row[5]); + entry.rare = atoi(row[6]); + entry.raid = atoi(row[7]); + entry.race = row[8] ? row[8] : ""; + entry.class = row[9] ? row[9] : ""; + entry.bodytype = row[10] ? row[10] : ""; + entry.zone = row[11] ? row[11] : ""; + entry.hot_zone = atoi(row[12]); + entry.min_expansion = atoi(row[13]); + entry.max_expansion = atoi(row[14]); + entry.content_flags = row[15] ? row[15] : ""; all_entries.push_back(entry); } @@ -397,9 +413,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -410,9 +426,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_gm_ips_repository.h b/common/repositories/base/base_gm_ips_repository.h index 56027c7a2..c486fada1 100644 --- a/common/repositories/base/base_gm_ips_repository.h +++ b/common/repositories/base/base_gm_ips_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GM_IPS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("gm_ips"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static GmIps FindOne( - Database& db, int gm_ips_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int gm_ips_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, GmIps gm_ips_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(gm_ips_entry.account_id)); update_values.push_back(columns[2] + " = '" + EscapeString(gm_ips_entry.ip_address) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static GmIps InsertOne( - Database& db, GmIps gm_ips_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(gm_ips_entry.account_id)); insert_values.push_back("'" + EscapeString(gm_ips_entry.ip_address) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector gm_ips_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_goallists_repository.h b/common/repositories/base/base_goallists_repository.h index c736d9e01..b483c940e 100644 --- a/common/repositories/base/base_goallists_repository.h +++ b/common/repositories/base/base_goallists_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GOALLISTS_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("goallists"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static Goallists FindOne( - Database& db, int goallists_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int goallists_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, Goallists goallists_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(goallists_entry.listid)); update_values.push_back(columns[1] + " = " + std::to_string(goallists_entry.entry)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static Goallists InsertOne( - Database& db, Goallists goallists_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(goallists_entry.listid)); insert_values.push_back(std::to_string(goallists_entry.entry)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector goallists_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_graveyard_repository.h b/common/repositories/base/base_graveyard_repository.h index 500775a94..ca6aad86b 100644 --- a/common/repositories/base/base_graveyard_repository.h +++ b/common/repositories/base/base_graveyard_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GRAVEYARD_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("graveyard"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static Graveyard FindOne( - Database& db, int graveyard_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int graveyard_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, Graveyard graveyard_entry ) { @@ -161,7 +190,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(graveyard_entry.z)); update_values.push_back(columns[5] + " = " + std::to_string(graveyard_entry.heading)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -175,20 +204,18 @@ public: } static Graveyard InsertOne( - Database& db, Graveyard graveyard_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(graveyard_entry.id)); insert_values.push_back(std::to_string(graveyard_entry.zone_id)); insert_values.push_back(std::to_string(graveyard_entry.x)); insert_values.push_back(std::to_string(graveyard_entry.y)); insert_values.push_back(std::to_string(graveyard_entry.z)); insert_values.push_back(std::to_string(graveyard_entry.heading)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -207,7 +234,6 @@ public: } static int InsertMany( - Database& db, std::vector graveyard_entries ) { @@ -216,7 +242,6 @@ public: for (auto &graveyard_entry: graveyard_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(graveyard_entry.id)); insert_values.push_back(std::to_string(graveyard_entry.zone_id)); insert_values.push_back(std::to_string(graveyard_entry.x)); insert_values.push_back(std::to_string(graveyard_entry.y)); @@ -228,7 +253,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -239,11 +264,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -268,11 +293,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -298,9 +323,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -311,9 +336,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_ground_spawns_repository.h b/common/repositories/base/base_ground_spawns_repository.h index 6b2a0d5cc..7e21389fe 100644 --- a/common/repositories/base/base_ground_spawns_repository.h +++ b/common/repositories/base/base_ground_spawns_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GROUND_SPAWNS_REPOSITORY_H @@ -35,7 +52,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -63,7 +79,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -72,6 +87,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("ground_spawns"); @@ -91,7 +121,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -99,24 +129,23 @@ public: { GroundSpawns entry{}; - entry.id = 0; - entry.zoneid = 0; - entry.version = 0; - entry.max_x = 2000; - entry.max_y = 2000; - entry.max_z = 10000; - entry.min_x = -2000; - entry.min_y = -2000; - entry.heading = 0; - entry.name = ""; - entry.item = 0; - entry.max_allowed = 1; - entry.comment = ""; - entry.respawn_timer = 300; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.zoneid = 0; + entry.version = 0; + entry.max_x = 2000; + entry.max_y = 2000; + entry.max_z = 10000; + entry.min_x = -2000; + entry.min_y = -2000; + entry.heading = 0; + entry.name = ""; + entry.item = 0; + entry.max_allowed = 1; + entry.comment = ""; + entry.respawn_timer = 300; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -136,11 +165,10 @@ public: } static GroundSpawns FindOne( - Database& db, int ground_spawns_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -152,24 +180,23 @@ public: if (results.RowCount() == 1) { GroundSpawns entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = static_cast(atof(row[3])); + entry.max_y = static_cast(atof(row[4])); + entry.max_z = static_cast(atof(row[5])); + entry.min_x = static_cast(atof(row[6])); + entry.min_y = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; return entry; } @@ -178,11 +205,10 @@ public: } static int DeleteOne( - Database& db, int ground_spawns_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -195,7 +221,6 @@ public: } static int UpdateOne( - Database& db, GroundSpawns ground_spawns_entry ) { @@ -219,9 +244,8 @@ public: update_values.push_back(columns[14] + " = " + std::to_string(ground_spawns_entry.min_expansion)); update_values.push_back(columns[15] + " = " + std::to_string(ground_spawns_entry.max_expansion)); update_values.push_back(columns[16] + " = '" + EscapeString(ground_spawns_entry.content_flags) + "'"); - update_values.push_back(columns[17] + " = '" + EscapeString(ground_spawns_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -235,13 +259,11 @@ public: } static GroundSpawns InsertOne( - Database& db, GroundSpawns ground_spawns_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(ground_spawns_entry.id)); insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); insert_values.push_back(std::to_string(ground_spawns_entry.version)); insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); @@ -258,9 +280,8 @@ public: insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -279,7 +300,6 @@ public: } static int InsertMany( - Database& db, std::vector ground_spawns_entries ) { @@ -288,7 +308,6 @@ public: for (auto &ground_spawns_entry: ground_spawns_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(ground_spawns_entry.id)); insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); insert_values.push_back(std::to_string(ground_spawns_entry.version)); insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); @@ -305,14 +324,13 @@ public: insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -323,11 +341,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -339,24 +357,23 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GroundSpawns entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = static_cast(atof(row[3])); + entry.max_y = static_cast(atof(row[4])); + entry.max_z = static_cast(atof(row[5])); + entry.min_x = static_cast(atof(row[6])); + entry.min_y = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; all_entries.push_back(entry); } @@ -364,11 +381,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -381,24 +398,23 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GroundSpawns entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = static_cast(atof(row[3])); + entry.max_y = static_cast(atof(row[4])); + entry.max_z = static_cast(atof(row[5])); + entry.min_x = static_cast(atof(row[6])); + entry.min_y = static_cast(atof(row[7])); + entry.heading = static_cast(atof(row[8])); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; all_entries.push_back(entry); } @@ -406,9 +422,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -419,9 +435,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_group_id_repository.h b/common/repositories/base/base_group_id_repository.h index 8005f003e..c7d8303ef 100644 --- a/common/repositories/base/base_group_id_repository.h +++ b/common/repositories/base/base_group_id_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GROUP_ID_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("group_id"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static GroupId FindOne( - Database& db, int group_id_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int group_id_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, GroupId group_id_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(group_id_entry.name) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(group_id_entry.ismerc)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static GroupId InsertOne( - Database& db, GroupId group_id_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back("'" + EscapeString(group_id_entry.name) + "'"); insert_values.push_back(std::to_string(group_id_entry.ismerc)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector group_id_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_group_leaders_repository.h b/common/repositories/base/base_group_leaders_repository.h index 97e7028cd..e2551ade9 100644 --- a/common/repositories/base/base_group_leaders_repository.h +++ b/common/repositories/base/base_group_leaders_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GROUP_LEADERS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("group_leaders"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static GroupLeaders FindOne( - Database& db, int group_leaders_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int group_leaders_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, GroupLeaders group_leaders_entry ) { @@ -177,7 +206,7 @@ public: update_values.push_back(columns[7] + " = '" + EscapeString(group_leaders_entry.mentoree) + "'"); update_values.push_back(columns[8] + " = " + std::to_string(group_leaders_entry.mentor_percent)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +220,6 @@ public: } static GroupLeaders InsertOne( - Database& db, GroupLeaders group_leaders_entry ) { @@ -207,7 +235,7 @@ public: insert_values.push_back("'" + EscapeString(group_leaders_entry.mentoree) + "'"); insert_values.push_back(std::to_string(group_leaders_entry.mentor_percent)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector group_leaders_entries ) { @@ -250,7 +277,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_guild_members_repository.h b/common/repositories/base/base_guild_members_repository.h index 931d0bdf6..52eb6f51f 100644 --- a/common/repositories/base/base_guild_members_repository.h +++ b/common/repositories/base/base_guild_members_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("guild_members"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static GuildMembers FindOne( - Database& db, int guild_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int guild_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, GuildMembers guild_members_entry ) { @@ -177,7 +206,7 @@ public: update_values.push_back(columns[7] + " = '" + EscapeString(guild_members_entry.public_note) + "'"); update_values.push_back(columns[8] + " = " + std::to_string(guild_members_entry.alt)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +220,6 @@ public: } static GuildMembers InsertOne( - Database& db, GuildMembers guild_members_entry ) { @@ -207,7 +235,7 @@ public: insert_values.push_back("'" + EscapeString(guild_members_entry.public_note) + "'"); insert_values.push_back(std::to_string(guild_members_entry.alt)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector guild_members_entries ) { @@ -250,7 +277,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_guild_ranks_repository.h b/common/repositories/base/base_guild_ranks_repository.h index b608cfaa5..2235068ef 100644 --- a/common/repositories/base/base_guild_ranks_repository.h +++ b/common/repositories/base/base_guild_ranks_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GUILD_RANKS_REPOSITORY_H @@ -58,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("guild_ranks"); @@ -77,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -115,11 +147,10 @@ public: } static GuildRanks FindOne( - Database& db, int guild_ranks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -150,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int guild_ranks_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +197,6 @@ public: } static int UpdateOne( - Database& db, GuildRanks guild_ranks_entry ) { @@ -187,7 +216,7 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(guild_ranks_entry.can_motd)); update_values.push_back(columns[10] + " = " + std::to_string(guild_ranks_entry.can_warpeace)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +230,6 @@ public: } static GuildRanks InsertOne( - Database& db, GuildRanks guild_ranks_entry ) { @@ -219,7 +247,7 @@ public: insert_values.push_back(std::to_string(guild_ranks_entry.can_motd)); insert_values.push_back(std::to_string(guild_ranks_entry.can_warpeace)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector guild_ranks_entries ) { @@ -264,7 +291,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -309,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -344,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_guild_relations_repository.h b/common/repositories/base/base_guild_relations_repository.h index 2ddcd854f..2293bf578 100644 --- a/common/repositories/base/base_guild_relations_repository.h +++ b/common/repositories/base/base_guild_relations_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GUILD_RELATIONS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("guild_relations"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static GuildRelations FindOne( - Database& db, int guild_relations_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int guild_relations_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, GuildRelations guild_relations_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(guild_relations_entry.guild2)); update_values.push_back(columns[2] + " = " + std::to_string(guild_relations_entry.relation)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static GuildRelations InsertOne( - Database& db, GuildRelations guild_relations_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(guild_relations_entry.guild2)); insert_values.push_back(std::to_string(guild_relations_entry.relation)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector guild_relations_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_guilds_repository.h b/common/repositories/base/base_guilds_repository.h index e1cd14f14..9613aa9ef 100644 --- a/common/repositories/base/base_guilds_repository.h +++ b/common/repositories/base/base_guilds_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_GUILDS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("guilds"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static Guilds FindOne( - Database& db, int guilds_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int guilds_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, Guilds guilds_entry ) { @@ -176,7 +205,7 @@ public: update_values.push_back(columns[7] + " = '" + EscapeString(guilds_entry.channel) + "'"); update_values.push_back(columns[8] + " = '" + EscapeString(guilds_entry.url) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -190,13 +219,11 @@ public: } static Guilds InsertOne( - Database& db, Guilds guilds_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(guilds_entry.id)); insert_values.push_back("'" + EscapeString(guilds_entry.name) + "'"); insert_values.push_back(std::to_string(guilds_entry.leader)); insert_values.push_back(std::to_string(guilds_entry.minstatus)); @@ -206,7 +233,7 @@ public: insert_values.push_back("'" + EscapeString(guilds_entry.channel) + "'"); insert_values.push_back("'" + EscapeString(guilds_entry.url) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -225,7 +252,6 @@ public: } static int InsertMany( - Database& db, std::vector guilds_entries ) { @@ -234,7 +260,6 @@ public: for (auto &guilds_entry: guilds_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(guilds_entry.id)); insert_values.push_back("'" + EscapeString(guilds_entry.name) + "'"); insert_values.push_back(std::to_string(guilds_entry.leader)); insert_values.push_back(std::to_string(guilds_entry.minstatus)); @@ -249,7 +274,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -260,11 +285,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -292,11 +317,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -325,9 +350,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -338,9 +363,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_hackers_repository.h b/common/repositories/base/base_hackers_repository.h index 4a492deac..c580fdf10 100644 --- a/common/repositories/base/base_hackers_repository.h +++ b/common/repositories/base/base_hackers_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_HACKERS_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("hackers"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static Hackers FindOne( - Database& db, int hackers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int hackers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, Hackers hackers_entry ) { @@ -161,7 +190,7 @@ public: update_values.push_back(columns[4] + " = '" + EscapeString(hackers_entry.zone) + "'"); update_values.push_back(columns[5] + " = '" + EscapeString(hackers_entry.date) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -175,20 +204,18 @@ public: } static Hackers InsertOne( - Database& db, Hackers hackers_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(hackers_entry.id)); insert_values.push_back("'" + EscapeString(hackers_entry.account) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.name) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.hacked) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.zone) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.date) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -207,7 +234,6 @@ public: } static int InsertMany( - Database& db, std::vector hackers_entries ) { @@ -216,7 +242,6 @@ public: for (auto &hackers_entry: hackers_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(hackers_entry.id)); insert_values.push_back("'" + EscapeString(hackers_entry.account) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.name) + "'"); insert_values.push_back("'" + EscapeString(hackers_entry.hacked) + "'"); @@ -228,7 +253,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -239,11 +264,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -268,11 +293,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -298,9 +323,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -311,9 +336,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_instance_list_player_repository.h b/common/repositories/base/base_instance_list_player_repository.h index 4b8aed4ee..242655b58 100644 --- a/common/repositories/base/base_instance_list_player_repository.h +++ b/common/repositories/base/base_instance_list_player_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_INSTANCE_LIST_PLAYER_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("instance_list_player"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static InstanceListPlayer FindOne( - Database& db, int instance_list_player_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int instance_list_player_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, InstanceListPlayer instance_list_player_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(instance_list_player_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(instance_list_player_entry.charid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static InstanceListPlayer InsertOne( - Database& db, InstanceListPlayer instance_list_player_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(instance_list_player_entry.id)); insert_values.push_back(std::to_string(instance_list_player_entry.charid)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector instance_list_player_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_instance_list_repository.h b/common/repositories/base/base_instance_list_repository.h index 55b31703f..856ea85c7 100644 --- a/common/repositories/base/base_instance_list_repository.h +++ b/common/repositories/base/base_instance_list_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_INSTANCE_LIST_REPOSITORY_H @@ -50,6 +67,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("instance_list"); @@ -69,7 +101,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -103,11 +135,10 @@ public: } static InstanceList FindOne( - Database& db, int instance_list_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -134,11 +165,10 @@ public: } static int DeleteOne( - Database& db, int instance_list_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -151,7 +181,6 @@ public: } static int UpdateOne( - Database& db, InstanceList instance_list_entry ) { @@ -166,7 +195,7 @@ public: update_values.push_back(columns[5] + " = " + std::to_string(instance_list_entry.duration)); update_values.push_back(columns[6] + " = " + std::to_string(instance_list_entry.never_expires)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -180,13 +209,11 @@ public: } static InstanceList InsertOne( - Database& db, InstanceList instance_list_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(instance_list_entry.id)); insert_values.push_back(std::to_string(instance_list_entry.zone)); insert_values.push_back(std::to_string(instance_list_entry.version)); insert_values.push_back(std::to_string(instance_list_entry.is_global)); @@ -194,7 +221,7 @@ public: insert_values.push_back(std::to_string(instance_list_entry.duration)); insert_values.push_back(std::to_string(instance_list_entry.never_expires)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -213,7 +240,6 @@ public: } static int InsertMany( - Database& db, std::vector instance_list_entries ) { @@ -222,7 +248,6 @@ public: for (auto &instance_list_entry: instance_list_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(instance_list_entry.id)); insert_values.push_back(std::to_string(instance_list_entry.zone)); insert_values.push_back(std::to_string(instance_list_entry.version)); insert_values.push_back(std::to_string(instance_list_entry.is_global)); @@ -235,7 +260,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -246,11 +271,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -276,11 +301,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -307,9 +332,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -320,9 +345,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_inventory_repository.h b/common/repositories/base/base_inventory_repository.h index 62308ebdf..3ae9e72fb 100644 --- a/common/repositories/base/base_inventory_repository.h +++ b/common/repositories/base/base_inventory_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_INVENTORY_REPOSITORY_H @@ -68,6 +85,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("inventory"); @@ -87,7 +119,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -130,11 +162,10 @@ public: } static Inventory FindOne( - Database& db, int inventory_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -170,11 +201,10 @@ public: } static int DeleteOne( - Database& db, int inventory_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -187,7 +217,6 @@ public: } static int UpdateOne( - Database& db, Inventory inventory_entry ) { @@ -212,7 +241,7 @@ public: update_values.push_back(columns[14] + " = " + std::to_string(inventory_entry.ornamentidfile)); update_values.push_back(columns[15] + " = " + std::to_string(inventory_entry.ornament_hero_model)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -226,7 +255,6 @@ public: } static Inventory InsertOne( - Database& db, Inventory inventory_entry ) { @@ -249,7 +277,7 @@ public: insert_values.push_back(std::to_string(inventory_entry.ornamentidfile)); insert_values.push_back(std::to_string(inventory_entry.ornament_hero_model)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -268,7 +296,6 @@ public: } static int InsertMany( - Database& db, std::vector inventory_entries ) { @@ -299,7 +326,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -310,11 +337,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -349,11 +376,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -389,9 +416,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -402,9 +429,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_inventory_snapshots_repository.h b/common/repositories/base/base_inventory_snapshots_repository.h index 4d34062f3..d00caa2c9 100644 --- a/common/repositories/base/base_inventory_snapshots_repository.h +++ b/common/repositories/base/base_inventory_snapshots_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_INVENTORY_SNAPSHOTS_REPOSITORY_H @@ -70,6 +87,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("inventory_snapshots"); @@ -89,7 +121,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -133,11 +165,10 @@ public: } static InventorySnapshots FindOne( - Database& db, int inventory_snapshots_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -174,11 +205,10 @@ public: } static int DeleteOne( - Database& db, int inventory_snapshots_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -191,7 +221,6 @@ public: } static int UpdateOne( - Database& db, InventorySnapshots inventory_snapshots_entry ) { @@ -217,7 +246,7 @@ public: update_values.push_back(columns[15] + " = " + std::to_string(inventory_snapshots_entry.ornamentidfile)); update_values.push_back(columns[16] + " = " + std::to_string(inventory_snapshots_entry.ornament_hero_model)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -231,7 +260,6 @@ public: } static InventorySnapshots InsertOne( - Database& db, InventorySnapshots inventory_snapshots_entry ) { @@ -255,7 +283,7 @@ public: insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamentidfile)); insert_values.push_back(std::to_string(inventory_snapshots_entry.ornament_hero_model)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -274,7 +302,6 @@ public: } static int InsertMany( - Database& db, std::vector inventory_snapshots_entries ) { @@ -306,7 +333,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -317,11 +344,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -357,11 +384,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -398,9 +425,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -411,9 +438,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_ip_exemptions_repository.h b/common/repositories/base/base_ip_exemptions_repository.h index dadd49b8e..b4596e381 100644 --- a/common/repositories/base/base_ip_exemptions_repository.h +++ b/common/repositories/base/base_ip_exemptions_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_IP_EXEMPTIONS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("ip_exemptions"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static IpExemptions FindOne( - Database& db, int ip_exemptions_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int ip_exemptions_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, IpExemptions ip_exemptions_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(ip_exemptions_entry.exemption_amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static IpExemptions InsertOne( - Database& db, IpExemptions ip_exemptions_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_id)); insert_values.push_back("'" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector ip_exemptions_entries ) { @@ -198,7 +224,6 @@ public: for (auto &ip_exemptions_entry: ip_exemptions_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_id)); insert_values.push_back("'" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_item_tick_repository.h b/common/repositories/base/base_item_tick_repository.h index 77b0ec71e..deabd41b9 100644 --- a/common/repositories/base/base_item_tick_repository.h +++ b/common/repositories/base/base_item_tick_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ITEM_TICK_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("item_tick"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static ItemTick FindOne( - Database& db, int item_tick_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int item_tick_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, ItemTick item_tick_entry ) { @@ -161,7 +190,7 @@ public: update_values.push_back(columns[4] + " = '" + EscapeString(item_tick_entry.it_qglobal) + "'"); update_values.push_back(columns[5] + " = " + std::to_string(item_tick_entry.it_bagslot)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -175,7 +204,6 @@ public: } static ItemTick InsertOne( - Database& db, ItemTick item_tick_entry ) { @@ -184,11 +212,10 @@ public: insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); insert_values.push_back(std::to_string(item_tick_entry.it_chance)); insert_values.push_back(std::to_string(item_tick_entry.it_level)); - insert_values.push_back(std::to_string(item_tick_entry.it_id)); insert_values.push_back("'" + EscapeString(item_tick_entry.it_qglobal) + "'"); insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -207,7 +234,6 @@ public: } static int InsertMany( - Database& db, std::vector item_tick_entries ) { @@ -219,7 +245,6 @@ public: insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); insert_values.push_back(std::to_string(item_tick_entry.it_chance)); insert_values.push_back(std::to_string(item_tick_entry.it_level)); - insert_values.push_back(std::to_string(item_tick_entry.it_id)); insert_values.push_back("'" + EscapeString(item_tick_entry.it_qglobal) + "'"); insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); @@ -228,7 +253,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -239,11 +264,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -268,11 +293,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -298,9 +323,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -311,9 +336,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_items_repository.h b/common/repositories/base/base_items_repository.h index da124eca0..29884ec16 100644 --- a/common/repositories/base/base_items_repository.h +++ b/common/repositories/base/base_items_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ITEMS_REPOSITORY_H @@ -606,6 +623,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("items"); @@ -625,7 +657,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -937,11 +969,10 @@ public: } static Items FindOne( - Database& db, int items_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -1246,11 +1277,10 @@ public: } static int DeleteOne( - Database& db, int items_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -1263,7 +1293,6 @@ public: } static int UpdateOne( - Database& db, Items items_entry ) { @@ -1557,7 +1586,7 @@ public: update_values.push_back(columns[283] + " = " + std::to_string(items_entry.UNK241)); update_values.push_back(columns[284] + " = " + std::to_string(items_entry.epicitem)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -1571,7 +1600,6 @@ public: } static Items InsertOne( - Database& db, Items items_entry ) { @@ -1863,7 +1891,7 @@ public: insert_values.push_back(std::to_string(items_entry.UNK241)); insert_values.push_back(std::to_string(items_entry.epicitem)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -1882,7 +1910,6 @@ public: } static int InsertMany( - Database& db, std::vector items_entries ) { @@ -2182,7 +2209,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -2193,11 +2220,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -2501,11 +2528,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -2810,9 +2837,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -2823,9 +2850,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_ldon_trap_entries_repository.h b/common/repositories/base/base_ldon_trap_entries_repository.h index 05fc73bf5..103ecda10 100644 --- a/common/repositories/base/base_ldon_trap_entries_repository.h +++ b/common/repositories/base/base_ldon_trap_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LDON_TRAP_ENTRIES_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("ldon_trap_entries"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static LdonTrapEntries FindOne( - Database& db, int ldon_trap_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int ldon_trap_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, LdonTrapEntries ldon_trap_entries_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(ldon_trap_entries_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(ldon_trap_entries_entry.trap_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static LdonTrapEntries InsertOne( - Database& db, LdonTrapEntries ldon_trap_entries_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(ldon_trap_entries_entry.id)); insert_values.push_back(std::to_string(ldon_trap_entries_entry.trap_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector ldon_trap_entries_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_ldon_trap_templates_repository.h b/common/repositories/base/base_ldon_trap_templates_repository.h index 27def1890..2864117b2 100644 --- a/common/repositories/base/base_ldon_trap_templates_repository.h +++ b/common/repositories/base/base_ldon_trap_templates_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LDON_TRAP_TEMPLATES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("ldon_trap_templates"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static LdonTrapTemplates FindOne( - Database& db, int ldon_trap_templates_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int ldon_trap_templates_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, LdonTrapTemplates ldon_trap_templates_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(ldon_trap_templates_entry.skill)); update_values.push_back(columns[4] + " = " + std::to_string(ldon_trap_templates_entry.locked)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static LdonTrapTemplates InsertOne( - Database& db, LdonTrapTemplates ldon_trap_templates_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(ldon_trap_templates_entry.skill)); insert_values.push_back(std::to_string(ldon_trap_templates_entry.locked)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector ldon_trap_templates_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_level_exp_mods_repository.h b/common/repositories/base/base_level_exp_mods_repository.h index eaa4a5f4a..4a77e47dc 100644 --- a/common/repositories/base/base_level_exp_mods_repository.h +++ b/common/repositories/base/base_level_exp_mods_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LEVEL_EXP_MODS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("level_exp_mods"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static LevelExpMods FindOne( - Database& db, int level_exp_mods_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int level_exp_mods_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, LevelExpMods level_exp_mods_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(level_exp_mods_entry.exp_mod)); update_values.push_back(columns[2] + " = " + std::to_string(level_exp_mods_entry.aa_exp_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static LevelExpMods InsertOne( - Database& db, LevelExpMods level_exp_mods_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector level_exp_mods_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_lfguild_repository.h b/common/repositories/base/base_lfguild_repository.h index 10e2f0682..32dcd5fdf 100644 --- a/common/repositories/base/base_lfguild_repository.h +++ b/common/repositories/base/base_lfguild_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LFGUILD_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("lfguild"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static Lfguild FindOne( - Database& db, int lfguild_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int lfguild_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, Lfguild lfguild_entry ) { @@ -177,7 +206,7 @@ public: update_values.push_back(columns[7] + " = " + std::to_string(lfguild_entry.timezone)); update_values.push_back(columns[8] + " = " + std::to_string(lfguild_entry.timeposted)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +220,6 @@ public: } static Lfguild InsertOne( - Database& db, Lfguild lfguild_entry ) { @@ -207,7 +235,7 @@ public: insert_values.push_back(std::to_string(lfguild_entry.timezone)); insert_values.push_back(std::to_string(lfguild_entry.timeposted)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector lfguild_entries ) { @@ -250,7 +277,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_login_accounts_repository.h b/common/repositories/base/base_login_accounts_repository.h index 25dc167d1..d6f75cd74 100644 --- a/common/repositories/base/base_login_accounts_repository.h +++ b/common/repositories/base/base_login_accounts_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGIN_ACCOUNTS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("login_accounts"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static LoginAccounts FindOne( - Database& db, int login_accounts_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int login_accounts_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, LoginAccounts login_accounts_entry ) { @@ -177,7 +206,7 @@ public: update_values.push_back(columns[7] + " = '" + EscapeString(login_accounts_entry.created_at) + "'"); update_values.push_back(columns[8] + " = '" + EscapeString(login_accounts_entry.updated_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +220,6 @@ public: } static LoginAccounts InsertOne( - Database& db, LoginAccounts login_accounts_entry ) { @@ -207,7 +235,7 @@ public: insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'"); insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector login_accounts_entries ) { @@ -250,7 +277,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_login_api_tokens_repository.h b/common/repositories/base/base_login_api_tokens_repository.h index 88ed5c74a..fa2a1b96c 100644 --- a/common/repositories/base/base_login_api_tokens_repository.h +++ b/common/repositories/base/base_login_api_tokens_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGIN_API_TOKENS_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("login_api_tokens"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static LoginApiTokens FindOne( - Database& db, int login_api_tokens_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int login_api_tokens_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, LoginApiTokens login_api_tokens_entry ) { @@ -161,7 +190,7 @@ public: update_values.push_back(columns[4] + " = '" + EscapeString(login_api_tokens_entry.created_at) + "'"); update_values.push_back(columns[5] + " = '" + EscapeString(login_api_tokens_entry.updated_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -175,20 +204,18 @@ public: } static LoginApiTokens InsertOne( - Database& db, LoginApiTokens login_api_tokens_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(login_api_tokens_entry.id)); insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'"); insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -207,7 +234,6 @@ public: } static int InsertMany( - Database& db, std::vector login_api_tokens_entries ) { @@ -216,7 +242,6 @@ public: for (auto &login_api_tokens_entry: login_api_tokens_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(login_api_tokens_entry.id)); insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); @@ -228,7 +253,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -239,11 +264,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -268,11 +293,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -298,9 +323,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -311,9 +336,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_login_server_admins_repository.h b/common/repositories/base/base_login_server_admins_repository.h index 771eb014f..c0eeebee2 100644 --- a/common/repositories/base/base_login_server_admins_repository.h +++ b/common/repositories/base/base_login_server_admins_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGIN_SERVER_ADMINS_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("login_server_admins"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static LoginServerAdmins FindOne( - Database& db, int login_server_admins_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int login_server_admins_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, LoginServerAdmins login_server_admins_entry ) { @@ -171,7 +200,7 @@ public: update_values.push_back(columns[6] + " = '" + EscapeString(login_server_admins_entry.registration_date) + "'"); update_values.push_back(columns[7] + " = '" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -185,13 +214,11 @@ public: } static LoginServerAdmins InsertOne( - Database& db, LoginServerAdmins login_server_admins_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(login_server_admins_entry.id)); insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_password) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); @@ -200,7 +227,7 @@ public: insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -219,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector login_server_admins_entries ) { @@ -228,7 +254,6 @@ public: for (auto &login_server_admins_entry: login_server_admins_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(login_server_admins_entry.id)); insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_password) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); @@ -242,7 +267,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -284,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -316,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -329,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_login_server_list_types_repository.h b/common/repositories/base/base_login_server_list_types_repository.h index 16b47381c..c82355f5a 100644 --- a/common/repositories/base/base_login_server_list_types_repository.h +++ b/common/repositories/base/base_login_server_list_types_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("login_server_list_types"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static LoginServerListTypes FindOne( - Database& db, int login_server_list_types_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int login_server_list_types_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, LoginServerListTypes login_server_list_types_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(login_server_list_types_entry.id)); update_values.push_back(columns[1] + " = '" + EscapeString(login_server_list_types_entry.description) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static LoginServerListTypes InsertOne( - Database& db, LoginServerListTypes login_server_list_types_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(login_server_list_types_entry.id)); insert_values.push_back("'" + EscapeString(login_server_list_types_entry.description) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector login_server_list_types_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_login_world_servers_repository.h b/common/repositories/base/base_login_world_servers_repository.h index 96dc1f8ae..8c05bdf06 100644 --- a/common/repositories/base/base_login_world_servers_repository.h +++ b/common/repositories/base/base_login_world_servers_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGIN_WORLD_SERVERS_REPOSITORY_H @@ -56,6 +73,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("login_world_servers"); @@ -75,7 +107,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -112,11 +144,10 @@ public: } static LoginWorldServers FindOne( - Database& db, int login_world_servers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -146,11 +177,10 @@ public: } static int DeleteOne( - Database& db, int login_world_servers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -163,7 +193,6 @@ public: } static int UpdateOne( - Database& db, LoginWorldServers login_world_servers_entry ) { @@ -181,7 +210,7 @@ public: update_values.push_back(columns[8] + " = " + std::to_string(login_world_servers_entry.is_server_trusted)); update_values.push_back(columns[9] + " = '" + EscapeString(login_world_servers_entry.note) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -195,13 +224,11 @@ public: } static LoginWorldServers InsertOne( - Database& db, LoginWorldServers login_world_servers_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(login_world_servers_entry.id)); insert_values.push_back("'" + EscapeString(login_world_servers_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); @@ -212,7 +239,7 @@ public: insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); insert_values.push_back("'" + EscapeString(login_world_servers_entry.note) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -231,7 +258,6 @@ public: } static int InsertMany( - Database& db, std::vector login_world_servers_entries ) { @@ -240,7 +266,6 @@ public: for (auto &login_world_servers_entry: login_world_servers_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(login_world_servers_entry.id)); insert_values.push_back("'" + EscapeString(login_world_servers_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); @@ -256,7 +281,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -267,11 +292,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -300,11 +325,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -334,9 +359,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -347,9 +372,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_logsys_categories_repository.h b/common/repositories/base/base_logsys_categories_repository.h index 4077e32f7..a10744651 100644 --- a/common/repositories/base/base_logsys_categories_repository.h +++ b/common/repositories/base/base_logsys_categories_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOGSYS_CATEGORIES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("logsys_categories"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static LogsysCategories FindOne( - Database& db, int logsys_categories_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int logsys_categories_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, LogsysCategories logsys_categories_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(logsys_categories_entry.log_to_file)); update_values.push_back(columns[4] + " = " + std::to_string(logsys_categories_entry.log_to_gmsay)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static LogsysCategories InsertOne( - Database& db, LogsysCategories logsys_categories_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(logsys_categories_entry.log_to_file)); insert_values.push_back(std::to_string(logsys_categories_entry.log_to_gmsay)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector logsys_categories_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_lootdrop_entries_repository.h b/common/repositories/base/base_lootdrop_entries_repository.h index 524b00588..c513956e8 100644 --- a/common/repositories/base/base_lootdrop_entries_repository.h +++ b/common/repositories/base/base_lootdrop_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOOTDROP_ENTRIES_REPOSITORY_H @@ -24,11 +41,9 @@ public: int equip_item; float chance; float disabled_chance; - int trivial_min_level; - int trivial_max_level; + int minlevel; + int maxlevel; int multiplier; - int npc_min_level; - int npc_max_level; }; static std::string PrimaryKey() @@ -45,11 +60,9 @@ public: "equip_item", "chance", "disabled_chance", - "trivial_min_level", - "trivial_max_level", + "minlevel", + "maxlevel", "multiplier", - "npc_min_level", - "npc_max_level", }; } @@ -58,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("lootdrop_entries"); @@ -77,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -85,17 +113,15 @@ public: { LootdropEntries entry{}; - entry.lootdrop_id = 0; - entry.item_id = 0; - entry.item_charges = 1; - entry.equip_item = 0; - entry.chance = 1; - entry.disabled_chance = 0; - entry.trivial_min_level = 0; - entry.trivial_max_level = 0; - entry.multiplier = 1; - entry.npc_min_level = 0; - entry.npc_max_level = 0; + entry.lootdrop_id = 0; + entry.item_id = 0; + entry.item_charges = 1; + entry.equip_item = 0; + entry.chance = 1; + entry.disabled_chance = 0; + entry.minlevel = 0; + entry.maxlevel = 127; + entry.multiplier = 1; return entry; } @@ -115,11 +141,10 @@ public: } static LootdropEntries FindOne( - Database& db, int lootdrop_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -131,17 +156,15 @@ public: if (results.RowCount() == 1) { LootdropEntries entry{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = static_cast(atof(row[4])); + entry.disabled_chance = static_cast(atof(row[5])); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(row[8]); return entry; } @@ -150,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int lootdrop_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -167,7 +189,6 @@ public: } static int UpdateOne( - Database& db, LootdropEntries lootdrop_entries_entry ) { @@ -181,13 +202,11 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entries_entry.equip_item)); update_values.push_back(columns[4] + " = " + std::to_string(lootdrop_entries_entry.chance)); update_values.push_back(columns[5] + " = " + std::to_string(lootdrop_entries_entry.disabled_chance)); - update_values.push_back(columns[6] + " = " + std::to_string(lootdrop_entries_entry.trivial_min_level)); - update_values.push_back(columns[7] + " = " + std::to_string(lootdrop_entries_entry.trivial_max_level)); + update_values.push_back(columns[6] + " = " + std::to_string(lootdrop_entries_entry.minlevel)); + update_values.push_back(columns[7] + " = " + std::to_string(lootdrop_entries_entry.maxlevel)); update_values.push_back(columns[8] + " = " + std::to_string(lootdrop_entries_entry.multiplier)); - update_values.push_back(columns[9] + " = " + std::to_string(lootdrop_entries_entry.npc_min_level)); - update_values.push_back(columns[10] + " = " + std::to_string(lootdrop_entries_entry.npc_max_level)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -201,7 +220,6 @@ public: } static LootdropEntries InsertOne( - Database& db, LootdropEntries lootdrop_entries_entry ) { @@ -213,13 +231,11 @@ public: insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_max_level)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_max_level)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -238,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector lootdrop_entries_entries ) { @@ -253,18 +268,16 @@ public: insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_max_level)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_max_level)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -275,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -291,17 +304,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { LootdropEntries entry{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = static_cast(atof(row[4])); + entry.disabled_chance = static_cast(atof(row[5])); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(row[8]); all_entries.push_back(entry); } @@ -309,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,17 +337,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { LootdropEntries entry{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = static_cast(atof(row[4])); + entry.disabled_chance = static_cast(atof(row[5])); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(row[8]); all_entries.push_back(entry); } @@ -344,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -357,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_lootdrop_repository.h b/common/repositories/base/base_lootdrop_repository.h index abacd5f8b..081adb9bf 100644 --- a/common/repositories/base/base_lootdrop_repository.h +++ b/common/repositories/base/base_lootdrop_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOOTDROP_REPOSITORY_H @@ -23,7 +40,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -39,7 +55,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -48,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("lootdrop"); @@ -67,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -75,12 +105,11 @@ public: { Lootdrop entry{}; - entry.id = 0; - entry.name = ""; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.name = ""; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -100,11 +129,10 @@ public: } static Lootdrop FindOne( - Database& db, int lootdrop_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -116,12 +144,11 @@ public: if (results.RowCount() == 1) { Lootdrop entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? row[4] : ""; return entry; } @@ -130,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int lootdrop_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +173,6 @@ public: } static int UpdateOne( - Database& db, Lootdrop lootdrop_entry ) { @@ -159,9 +184,8 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entry.min_expansion)); update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entry.max_expansion)); update_values.push_back(columns[4] + " = '" + EscapeString(lootdrop_entry.content_flags) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(lootdrop_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -175,20 +199,17 @@ public: } static Lootdrop InsertOne( - Database& db, Lootdrop lootdrop_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(lootdrop_entry.id)); insert_values.push_back("'" + EscapeString(lootdrop_entry.name) + "'"); insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -207,7 +228,6 @@ public: } static int InsertMany( - Database& db, std::vector lootdrop_entries ) { @@ -216,19 +236,17 @@ public: for (auto &lootdrop_entry: lootdrop_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(lootdrop_entry.id)); insert_values.push_back("'" + EscapeString(lootdrop_entry.name) + "'"); insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -239,11 +257,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -255,12 +273,11 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Lootdrop entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? row[4] : ""; all_entries.push_back(entry); } @@ -268,11 +285,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -285,12 +302,11 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Lootdrop entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? row[4] : ""; all_entries.push_back(entry); } @@ -298,9 +314,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -311,9 +327,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_loottable_entries_repository.h b/common/repositories/base/base_loottable_entries_repository.h index e8143e7e3..f3baab03f 100644 --- a/common/repositories/base/base_loottable_entries_repository.h +++ b/common/repositories/base/base_loottable_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOOTTABLE_ENTRIES_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("loottable_entries"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static LoottableEntries FindOne( - Database& db, int loottable_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int loottable_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, LoottableEntries loottable_entries_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(loottable_entries_entry.mindrop)); update_values.push_back(columns[5] + " = " + std::to_string(loottable_entries_entry.probability)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static LoottableEntries InsertOne( - Database& db, LoottableEntries loottable_entries_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); insert_values.push_back(std::to_string(loottable_entries_entry.probability)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector loottable_entries_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_loottable_repository.h b/common/repositories/base/base_loottable_repository.h index 88ff30ec9..2fee78710 100644 --- a/common/repositories/base/base_loottable_repository.h +++ b/common/repositories/base/base_loottable_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_LOOTTABLE_REPOSITORY_H @@ -27,7 +44,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -47,7 +63,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -56,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("loottable"); @@ -75,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -83,16 +113,15 @@ public: { Loottable entry{}; - entry.id = 0; - entry.name = ""; - entry.mincash = 0; - entry.maxcash = 0; - entry.avgcoin = 0; - entry.done = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.name = ""; + entry.mincash = 0; + entry.maxcash = 0; + entry.avgcoin = 0; + entry.done = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -112,11 +141,10 @@ public: } static Loottable FindOne( - Database& db, int loottable_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -128,16 +156,15 @@ public: if (results.RowCount() == 1) { Loottable entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; return entry; } @@ -146,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int loottable_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -163,7 +189,6 @@ public: } static int UpdateOne( - Database& db, Loottable loottable_entry ) { @@ -179,9 +204,8 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(loottable_entry.min_expansion)); update_values.push_back(columns[7] + " = " + std::to_string(loottable_entry.max_expansion)); update_values.push_back(columns[8] + " = '" + EscapeString(loottable_entry.content_flags) + "'"); - update_values.push_back(columns[9] + " = '" + EscapeString(loottable_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -195,13 +219,11 @@ public: } static Loottable InsertOne( - Database& db, Loottable loottable_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(loottable_entry.id)); insert_values.push_back("'" + EscapeString(loottable_entry.name) + "'"); insert_values.push_back(std::to_string(loottable_entry.mincash)); insert_values.push_back(std::to_string(loottable_entry.maxcash)); @@ -210,9 +232,8 @@ public: insert_values.push_back(std::to_string(loottable_entry.min_expansion)); insert_values.push_back(std::to_string(loottable_entry.max_expansion)); insert_values.push_back("'" + EscapeString(loottable_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(loottable_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -231,7 +252,6 @@ public: } static int InsertMany( - Database& db, std::vector loottable_entries ) { @@ -240,7 +260,6 @@ public: for (auto &loottable_entry: loottable_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(loottable_entry.id)); insert_values.push_back("'" + EscapeString(loottable_entry.name) + "'"); insert_values.push_back(std::to_string(loottable_entry.mincash)); insert_values.push_back(std::to_string(loottable_entry.maxcash)); @@ -249,14 +268,13 @@ public: insert_values.push_back(std::to_string(loottable_entry.min_expansion)); insert_values.push_back(std::to_string(loottable_entry.max_expansion)); insert_values.push_back("'" + EscapeString(loottable_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(loottable_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -267,11 +285,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -283,16 +301,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Loottable entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; all_entries.push_back(entry); } @@ -300,11 +317,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -317,16 +334,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Loottable entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; all_entries.push_back(entry); } @@ -334,9 +350,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -347,9 +363,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_mail_repository.h b/common/repositories/base/base_mail_repository.h index 674881b64..efc14bab4 100644 --- a/common/repositories/base/base_mail_repository.h +++ b/common/repositories/base/base_mail_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_MAIL_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("mail"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static Mail FindOne( - Database& db, int mail_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int mail_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, Mail mail_entry ) { @@ -171,7 +200,7 @@ public: update_values.push_back(columns[6] + " = '" + EscapeString(mail_entry.to) + "'"); update_values.push_back(columns[7] + " = " + std::to_string(mail_entry.status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -185,13 +214,11 @@ public: } static Mail InsertOne( - Database& db, Mail mail_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(mail_entry.msgid)); insert_values.push_back(std::to_string(mail_entry.charid)); insert_values.push_back(std::to_string(mail_entry.timestamp)); insert_values.push_back("'" + EscapeString(mail_entry.from) + "'"); @@ -200,7 +227,7 @@ public: insert_values.push_back("'" + EscapeString(mail_entry.to) + "'"); insert_values.push_back(std::to_string(mail_entry.status)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -219,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector mail_entries ) { @@ -228,7 +254,6 @@ public: for (auto &mail_entry: mail_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(mail_entry.msgid)); insert_values.push_back(std::to_string(mail_entry.charid)); insert_values.push_back(std::to_string(mail_entry.timestamp)); insert_values.push_back("'" + EscapeString(mail_entry.from) + "'"); @@ -242,7 +267,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -284,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -316,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -329,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_merchantlist_repository.h b/common/repositories/base/base_merchantlist_repository.h index 437b419cd..0d72eaa5b 100644 --- a/common/repositories/base/base_merchantlist_repository.h +++ b/common/repositories/base/base_merchantlist_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_MERCHANTLIST_REPOSITORY_H @@ -29,7 +46,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -51,7 +67,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -60,6 +75,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("merchantlist"); @@ -79,7 +109,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -87,18 +117,17 @@ public: { Merchantlist entry{}; - entry.merchantid = 0; - entry.slot = 0; - entry.item = 0; - entry.faction_required = -100; - entry.level_required = 0; - entry.alt_currency_cost = 0; - entry.classes_required = 65535; - entry.probability = 100; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.merchantid = 0; + entry.slot = 0; + entry.item = 0; + entry.faction_required = -100; + entry.level_required = 0; + entry.alt_currency_cost = 0; + entry.classes_required = 65535; + entry.probability = 100; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -118,11 +147,10 @@ public: } static Merchantlist FindOne( - Database& db, int merchantlist_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -134,18 +162,17 @@ public: if (results.RowCount() == 1) { Merchantlist entry{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = row[10] ? row[10] : ""; return entry; } @@ -154,11 +181,10 @@ public: } static int DeleteOne( - Database& db, int merchantlist_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -171,7 +197,6 @@ public: } static int UpdateOne( - Database& db, Merchantlist merchantlist_entry ) { @@ -190,9 +215,8 @@ public: update_values.push_back(columns[8] + " = " + std::to_string(merchantlist_entry.min_expansion)); update_values.push_back(columns[9] + " = " + std::to_string(merchantlist_entry.max_expansion)); update_values.push_back(columns[10] + " = '" + EscapeString(merchantlist_entry.content_flags) + "'"); - update_values.push_back(columns[11] + " = '" + EscapeString(merchantlist_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -206,7 +230,6 @@ public: } static Merchantlist InsertOne( - Database& db, Merchantlist merchantlist_entry ) { @@ -223,9 +246,8 @@ public: insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -244,7 +266,6 @@ public: } static int InsertMany( - Database& db, std::vector merchantlist_entries ) { @@ -264,14 +285,13 @@ public: insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -282,11 +302,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -298,18 +318,17 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Merchantlist entry{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = row[10] ? row[10] : ""; all_entries.push_back(entry); } @@ -317,11 +336,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -334,18 +353,17 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Merchantlist entry{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = row[10] ? row[10] : ""; all_entries.push_back(entry); } @@ -353,9 +371,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -366,9 +384,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_merchantlist_temp_repository.h b/common/repositories/base/base_merchantlist_temp_repository.h index 1db32b796..23ce44ac5 100644 --- a/common/repositories/base/base_merchantlist_temp_repository.h +++ b/common/repositories/base/base_merchantlist_temp_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_MERCHANTLIST_TEMP_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("merchantlist_temp"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static MerchantlistTemp FindOne( - Database& db, int merchantlist_temp_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int merchantlist_temp_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, MerchantlistTemp merchantlist_temp_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(merchantlist_temp_entry.itemid)); update_values.push_back(columns[3] + " = " + std::to_string(merchantlist_temp_entry.charges)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static MerchantlistTemp InsertOne( - Database& db, MerchantlistTemp merchantlist_temp_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(merchantlist_temp_entry.itemid)); insert_values.push_back(std::to_string(merchantlist_temp_entry.charges)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector merchantlist_temp_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_name_filter_repository.h b/common/repositories/base/base_name_filter_repository.h index 5f9c19a8b..c94ff718c 100644 --- a/common/repositories/base/base_name_filter_repository.h +++ b/common/repositories/base/base_name_filter_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NAME_FILTER_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("name_filter"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static NameFilter FindOne( - Database& db, int name_filter_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int name_filter_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, NameFilter name_filter_entry ) { @@ -141,7 +170,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(name_filter_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -155,16 +184,14 @@ public: } static NameFilter InsertOne( - Database& db, NameFilter name_filter_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(name_filter_entry.id)); insert_values.push_back("'" + EscapeString(name_filter_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -183,7 +210,6 @@ public: } static int InsertMany( - Database& db, std::vector name_filter_entries ) { @@ -192,7 +218,6 @@ public: for (auto &name_filter_entry: name_filter_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(name_filter_entry.id)); insert_values.push_back("'" + EscapeString(name_filter_entry.name) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -200,7 +225,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -211,11 +236,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -236,11 +261,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -262,9 +287,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -275,9 +300,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_emotes_repository.h b/common/repositories/base/base_npc_emotes_repository.h index cc0503d16..286c89783 100644 --- a/common/repositories/base/base_npc_emotes_repository.h +++ b/common/repositories/base/base_npc_emotes_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_EMOTES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_emotes"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static NpcEmotes FindOne( - Database& db, int npc_emotes_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int npc_emotes_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, NpcEmotes npc_emotes_entry ) { @@ -156,7 +185,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(npc_emotes_entry.type)); update_values.push_back(columns[4] + " = '" + EscapeString(npc_emotes_entry.text) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -170,19 +199,17 @@ public: } static NpcEmotes InsertOne( - Database& db, NpcEmotes npc_emotes_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_emotes_entry.id)); insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); insert_values.push_back(std::to_string(npc_emotes_entry.event_)); insert_values.push_back(std::to_string(npc_emotes_entry.type)); insert_values.push_back("'" + EscapeString(npc_emotes_entry.text) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -201,7 +228,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_emotes_entries ) { @@ -210,7 +236,6 @@ public: for (auto &npc_emotes_entry: npc_emotes_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_emotes_entry.id)); insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); insert_values.push_back(std::to_string(npc_emotes_entry.event_)); insert_values.push_back(std::to_string(npc_emotes_entry.type)); @@ -221,7 +246,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -232,11 +257,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -260,11 +285,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -289,9 +314,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -302,9 +327,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_faction_entries_repository.h b/common/repositories/base/base_npc_faction_entries_repository.h index a25a9a258..396021a62 100644 --- a/common/repositories/base/base_npc_faction_entries_repository.h +++ b/common/repositories/base/base_npc_faction_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_FACTION_ENTRIES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_faction_entries"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static NpcFactionEntries FindOne( - Database& db, int npc_faction_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int npc_faction_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, NpcFactionEntries npc_faction_entries_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entries_entry.npc_value)); update_values.push_back(columns[4] + " = " + std::to_string(npc_faction_entries_entry.temp)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static NpcFactionEntries InsertOne( - Database& db, NpcFactionEntries npc_faction_entries_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_value)); insert_values.push_back(std::to_string(npc_faction_entries_entry.temp)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_faction_entries_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_faction_repository.h b/common/repositories/base/base_npc_faction_repository.h index 5cb58fafa..f20d4632f 100644 --- a/common/repositories/base/base_npc_faction_repository.h +++ b/common/repositories/base/base_npc_faction_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_FACTION_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_faction"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static NpcFaction FindOne( - Database& db, int npc_faction_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int npc_faction_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, NpcFaction npc_faction_entry ) { @@ -151,7 +180,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(npc_faction_entry.primaryfaction)); update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entry.ignore_primary_assist)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -165,18 +194,16 @@ public: } static NpcFaction InsertOne( - Database& db, NpcFaction npc_faction_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_faction_entry.id)); insert_values.push_back("'" + EscapeString(npc_faction_entry.name) + "'"); insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -195,7 +222,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_faction_entries ) { @@ -204,7 +230,6 @@ public: for (auto &npc_faction_entry: npc_faction_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_faction_entry.id)); insert_values.push_back("'" + EscapeString(npc_faction_entry.name) + "'"); insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); @@ -214,7 +239,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -225,11 +250,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -252,11 +277,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -280,9 +305,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -293,9 +318,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_scale_global_base_repository.h b/common/repositories/base/base_npc_scale_global_base_repository.h index e701c7686..4e36eb9e0 100644 --- a/common/repositories/base/base_npc_scale_global_base_repository.h +++ b/common/repositories/base/base_npc_scale_global_base_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H @@ -92,6 +109,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_scale_global_base"); @@ -111,7 +143,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -166,11 +198,10 @@ public: } static NpcScaleGlobalBase FindOne( - Database& db, int npc_scale_global_base_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -218,11 +249,10 @@ public: } static int DeleteOne( - Database& db, int npc_scale_global_base_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -235,7 +265,6 @@ public: } static int UpdateOne( - Database& db, NpcScaleGlobalBase npc_scale_global_base_entry ) { @@ -272,7 +301,7 @@ public: update_values.push_back(columns[26] + " = " + std::to_string(npc_scale_global_base_entry.heal_scale)); update_values.push_back(columns[27] + " = '" + EscapeString(npc_scale_global_base_entry.special_abilities) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -286,7 +315,6 @@ public: } static NpcScaleGlobalBase InsertOne( - Database& db, NpcScaleGlobalBase npc_scale_global_base_entry ) { @@ -321,7 +349,7 @@ public: insert_values.push_back(std::to_string(npc_scale_global_base_entry.heal_scale)); insert_values.push_back("'" + EscapeString(npc_scale_global_base_entry.special_abilities) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -340,7 +368,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_scale_global_base_entries ) { @@ -383,7 +410,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -394,11 +421,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -445,11 +472,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -497,9 +524,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -510,9 +537,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_spells_effects_entries_repository.h b/common/repositories/base/base_npc_spells_effects_entries_repository.h index 563176079..5117c4f36 100644 --- a/common/repositories/base/base_npc_spells_effects_entries_repository.h +++ b/common/repositories/base/base_npc_spells_effects_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_spells_effects_entries"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static NpcSpellsEffectsEntries FindOne( - Database& db, int npc_spells_effects_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int npc_spells_effects_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, NpcSpellsEffectsEntries npc_spells_effects_entries_entry ) { @@ -171,7 +200,7 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_effects_entries_entry.se_limit)); update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_effects_entries_entry.se_max)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -185,13 +214,11 @@ public: } static NpcSpellsEffectsEntries InsertOne( - Database& db, NpcSpellsEffectsEntries npc_spells_effects_entries_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); @@ -200,7 +227,7 @@ public: insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_limit)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_max)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -219,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_spells_effects_entries_entries ) { @@ -228,7 +254,6 @@ public: for (auto &npc_spells_effects_entries_entry: npc_spells_effects_entries_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); @@ -242,7 +267,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -284,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -316,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -329,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_spells_effects_repository.h b/common/repositories/base/base_npc_spells_effects_repository.h index a6b5e52bd..c5d098ec0 100644 --- a/common/repositories/base/base_npc_spells_effects_repository.h +++ b/common/repositories/base/base_npc_spells_effects_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_SPELLS_EFFECTS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_spells_effects"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static NpcSpellsEffects FindOne( - Database& db, int npc_spells_effects_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int npc_spells_effects_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, NpcSpellsEffects npc_spells_effects_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(npc_spells_effects_entry.name) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_effects_entry.parent_list)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static NpcSpellsEffects InsertOne( - Database& db, NpcSpellsEffects npc_spells_effects_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_effects_entry.id)); insert_values.push_back("'" + EscapeString(npc_spells_effects_entry.name) + "'"); insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_spells_effects_entries ) { @@ -198,7 +224,6 @@ public: for (auto &npc_spells_effects_entry: npc_spells_effects_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_effects_entry.id)); insert_values.push_back("'" + EscapeString(npc_spells_effects_entry.name) + "'"); insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_spells_entries_repository.h b/common/repositories/base/base_npc_spells_entries_repository.h index 97139ab2b..1ae15be21 100644 --- a/common/repositories/base/base_npc_spells_entries_repository.h +++ b/common/repositories/base/base_npc_spells_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_SPELLS_ENTRIES_REPOSITORY_H @@ -60,6 +77,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_spells_entries"); @@ -79,7 +111,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -118,11 +150,10 @@ public: } static NpcSpellsEntries FindOne( - Database& db, int npc_spells_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -154,11 +185,10 @@ public: } static int DeleteOne( - Database& db, int npc_spells_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -171,7 +201,6 @@ public: } static int UpdateOne( - Database& db, NpcSpellsEntries npc_spells_entries_entry ) { @@ -191,7 +220,7 @@ public: update_values.push_back(columns[10] + " = " + std::to_string(npc_spells_entries_entry.min_hp)); update_values.push_back(columns[11] + " = " + std::to_string(npc_spells_entries_entry.max_hp)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -205,13 +234,11 @@ public: } static NpcSpellsEntries InsertOne( - Database& db, NpcSpellsEntries npc_spells_entries_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_entries_entry.id)); insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); @@ -224,7 +251,7 @@ public: insert_values.push_back(std::to_string(npc_spells_entries_entry.min_hp)); insert_values.push_back(std::to_string(npc_spells_entries_entry.max_hp)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -243,7 +270,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_spells_entries_entries ) { @@ -252,7 +278,6 @@ public: for (auto &npc_spells_entries_entry: npc_spells_entries_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_entries_entry.id)); insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); @@ -270,7 +295,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -281,11 +306,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -316,11 +341,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -352,9 +377,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -365,9 +390,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_spells_repository.h b/common/repositories/base/base_npc_spells_repository.h index 448683064..444a3a3da 100644 --- a/common/repositories/base/base_npc_spells_repository.h +++ b/common/repositories/base/base_npc_spells_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_SPELLS_REPOSITORY_H @@ -78,6 +95,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_spells"); @@ -97,7 +129,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -145,11 +177,10 @@ public: } static NpcSpells FindOne( - Database& db, int npc_spells_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -190,11 +221,10 @@ public: } static int DeleteOne( - Database& db, int npc_spells_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -207,7 +237,6 @@ public: } static int UpdateOne( - Database& db, NpcSpells npc_spells_entry ) { @@ -236,7 +265,7 @@ public: update_values.push_back(columns[19] + " = " + std::to_string(npc_spells_entry.idle_no_sp_recast_max)); update_values.push_back(columns[20] + " = " + std::to_string(npc_spells_entry.idle_b_chance)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -250,13 +279,11 @@ public: } static NpcSpells InsertOne( - Database& db, NpcSpells npc_spells_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_entry.id)); insert_values.push_back("'" + EscapeString(npc_spells_entry.name) + "'"); insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); @@ -278,7 +305,7 @@ public: insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_max)); insert_values.push_back(std::to_string(npc_spells_entry.idle_b_chance)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -297,7 +324,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_spells_entries ) { @@ -306,7 +332,6 @@ public: for (auto &npc_spells_entry: npc_spells_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_spells_entry.id)); insert_values.push_back("'" + EscapeString(npc_spells_entry.name) + "'"); insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); @@ -333,7 +358,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -344,11 +369,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -388,11 +413,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -433,9 +458,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -446,9 +471,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_types_repository.h b/common/repositories/base/base_npc_types_repository.h index b127988fa..6ac6b5321 100644 --- a/common/repositories/base/base_npc_types_repository.h +++ b/common/repositories/base/base_npc_types_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_TYPES_REPOSITORY_H @@ -280,6 +297,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_types"); @@ -299,7 +331,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -448,11 +480,10 @@ public: } static NpcTypes FindOne( - Database& db, int npc_types_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -594,11 +625,10 @@ public: } static int DeleteOne( - Database& db, int npc_types_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -611,7 +641,6 @@ public: } static int UpdateOne( - Database& db, NpcTypes npc_types_entry ) { @@ -741,7 +770,7 @@ public: update_values.push_back(columns[120] + " = " + std::to_string(npc_types_entry.flymode)); update_values.push_back(columns[121] + " = " + std::to_string(npc_types_entry.always_aggro)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -755,13 +784,11 @@ public: } static NpcTypes InsertOne( - Database& db, NpcTypes npc_types_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_types_entry.id)); insert_values.push_back("'" + EscapeString(npc_types_entry.name) + "'"); insert_values.push_back("'" + EscapeString(npc_types_entry.lastname) + "'"); insert_values.push_back(std::to_string(npc_types_entry.level)); @@ -884,7 +911,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.flymode)); insert_values.push_back(std::to_string(npc_types_entry.always_aggro)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -903,7 +930,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_types_entries ) { @@ -912,7 +938,6 @@ public: for (auto &npc_types_entry: npc_types_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(npc_types_entry.id)); insert_values.push_back("'" + EscapeString(npc_types_entry.name) + "'"); insert_values.push_back("'" + EscapeString(npc_types_entry.lastname) + "'"); insert_values.push_back(std::to_string(npc_types_entry.level)); @@ -1040,7 +1065,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -1051,11 +1076,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -1196,11 +1221,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -1342,9 +1367,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -1355,9 +1380,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_npc_types_tint_repository.h b/common/repositories/base/base_npc_types_tint_repository.h index 3ba577f36..f451ee292 100644 --- a/common/repositories/base/base_npc_types_tint_repository.h +++ b/common/repositories/base/base_npc_types_tint_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_NPC_TYPES_TINT_REPOSITORY_H @@ -94,6 +111,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("npc_types_tint"); @@ -113,7 +145,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -169,11 +201,10 @@ public: } static NpcTypesTint FindOne( - Database& db, int npc_types_tint_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -222,11 +253,10 @@ public: } static int DeleteOne( - Database& db, int npc_types_tint_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -239,7 +269,6 @@ public: } static int UpdateOne( - Database& db, NpcTypesTint npc_types_tint_entry ) { @@ -277,7 +306,7 @@ public: update_values.push_back(columns[27] + " = " + std::to_string(npc_types_tint_entry.grn9x)); update_values.push_back(columns[28] + " = " + std::to_string(npc_types_tint_entry.blu9x)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -291,7 +320,6 @@ public: } static NpcTypesTint InsertOne( - Database& db, NpcTypesTint npc_types_tint_entry ) { @@ -327,7 +355,7 @@ public: insert_values.push_back(std::to_string(npc_types_tint_entry.grn9x)); insert_values.push_back(std::to_string(npc_types_tint_entry.blu9x)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -346,7 +374,6 @@ public: } static int InsertMany( - Database& db, std::vector npc_types_tint_entries ) { @@ -390,7 +417,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -401,11 +428,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -453,11 +480,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -506,9 +533,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -519,9 +546,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_object_contents_repository.h b/common/repositories/base/base_object_contents_repository.h index 576429ba0..c1b183cce 100644 --- a/common/repositories/base/base_object_contents_repository.h +++ b/common/repositories/base/base_object_contents_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_OBJECT_CONTENTS_REPOSITORY_H @@ -60,6 +77,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("object_contents"); @@ -79,7 +111,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -118,11 +150,10 @@ public: } static ObjectContents FindOne( - Database& db, int object_contents_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -154,11 +185,10 @@ public: } static int DeleteOne( - Database& db, int object_contents_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -171,7 +201,6 @@ public: } static int UpdateOne( - Database& db, ObjectContents object_contents_entry ) { @@ -192,7 +221,7 @@ public: update_values.push_back(columns[10] + " = " + std::to_string(object_contents_entry.augslot5)); update_values.push_back(columns[11] + " = " + std::to_string(object_contents_entry.augslot6)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -206,7 +235,6 @@ public: } static ObjectContents InsertOne( - Database& db, ObjectContents object_contents_entry ) { @@ -225,7 +253,7 @@ public: insert_values.push_back(std::to_string(object_contents_entry.augslot5)); insert_values.push_back(std::to_string(object_contents_entry.augslot6)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -244,7 +272,6 @@ public: } static int InsertMany( - Database& db, std::vector object_contents_entries ) { @@ -271,7 +298,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -282,11 +309,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -317,11 +344,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -353,9 +380,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -366,9 +393,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_object_repository.h b/common/repositories/base/base_object_repository.h index a572ed712..c44685202 100644 --- a/common/repositories/base/base_object_repository.h +++ b/common/repositories/base/base_object_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_OBJECT_REPOSITORY_H @@ -44,10 +61,6 @@ public: float tilt_x; float tilt_y; std::string display_name; - int min_expansion; - int max_expansion; - std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -84,10 +97,6 @@ public: "tilt_x", "tilt_y", "display_name", - "min_expansion", - "max_expansion", - "content_flags", - "content_flags_disabled", }; } @@ -96,6 +105,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("object"); @@ -115,7 +139,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -123,36 +147,32 @@ public: { Object entry{}; - entry.id = 0; - entry.zoneid = 0; - entry.version = 0; - entry.xpos = 0; - entry.ypos = 0; - entry.zpos = 0; - entry.heading = 0; - entry.itemid = 0; - entry.charges = 0; - entry.objectname = ""; - entry.type = 0; - entry.icon = 0; - entry.unknown08 = 0; - entry.unknown10 = 0; - entry.unknown20 = 0; - entry.unknown24 = 0; - entry.unknown60 = 0; - entry.unknown64 = 0; - entry.unknown68 = 0; - entry.unknown72 = 0; - entry.unknown76 = 0; - entry.unknown84 = 0; - entry.size = 100; - entry.tilt_x = 0; - entry.tilt_y = 0; - entry.display_name = ""; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.zoneid = 0; + entry.version = 0; + entry.xpos = 0; + entry.ypos = 0; + entry.zpos = 0; + entry.heading = 0; + entry.itemid = 0; + entry.charges = 0; + entry.objectname = ""; + entry.type = 0; + entry.icon = 0; + entry.unknown08 = 0; + entry.unknown10 = 0; + entry.unknown20 = 0; + entry.unknown24 = 0; + entry.unknown60 = 0; + entry.unknown64 = 0; + entry.unknown68 = 0; + entry.unknown72 = 0; + entry.unknown76 = 0; + entry.unknown84 = 0; + entry.size = 100; + entry.tilt_x = 0; + entry.tilt_y = 0; + entry.display_name = ""; return entry; } @@ -172,11 +192,10 @@ public: } static Object FindOne( - Database& db, int object_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -188,36 +207,32 @@ public: if (results.RowCount() == 1) { Object entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = static_cast(atof(row[3])); + entry.ypos = static_cast(atof(row[4])); + entry.zpos = static_cast(atof(row[5])); + entry.heading = static_cast(atof(row[6])); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = static_cast(atof(row[22])); + entry.tilt_x = static_cast(atof(row[23])); + entry.tilt_y = static_cast(atof(row[24])); + entry.display_name = row[25] ? row[25] : ""; return entry; } @@ -226,11 +241,10 @@ public: } static int DeleteOne( - Database& db, int object_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -243,7 +257,6 @@ public: } static int UpdateOne( - Database& db, Object object_entry ) { @@ -276,12 +289,8 @@ public: update_values.push_back(columns[23] + " = " + std::to_string(object_entry.tilt_x)); update_values.push_back(columns[24] + " = " + std::to_string(object_entry.tilt_y)); update_values.push_back(columns[25] + " = '" + EscapeString(object_entry.display_name) + "'"); - update_values.push_back(columns[26] + " = " + std::to_string(object_entry.min_expansion)); - update_values.push_back(columns[27] + " = " + std::to_string(object_entry.max_expansion)); - update_values.push_back(columns[28] + " = '" + EscapeString(object_entry.content_flags) + "'"); - update_values.push_back(columns[29] + " = '" + EscapeString(object_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -295,13 +304,11 @@ public: } static Object InsertOne( - Database& db, Object object_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(object_entry.id)); insert_values.push_back(std::to_string(object_entry.zoneid)); insert_values.push_back(std::to_string(object_entry.version)); insert_values.push_back(std::to_string(object_entry.xpos)); @@ -327,12 +334,8 @@ public: insert_values.push_back(std::to_string(object_entry.tilt_x)); insert_values.push_back(std::to_string(object_entry.tilt_y)); insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); - insert_values.push_back(std::to_string(object_entry.min_expansion)); - insert_values.push_back(std::to_string(object_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(object_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -351,7 +354,6 @@ public: } static int InsertMany( - Database& db, std::vector object_entries ) { @@ -360,7 +362,6 @@ public: for (auto &object_entry: object_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(object_entry.id)); insert_values.push_back(std::to_string(object_entry.zoneid)); insert_values.push_back(std::to_string(object_entry.version)); insert_values.push_back(std::to_string(object_entry.xpos)); @@ -386,17 +387,13 @@ public: insert_values.push_back(std::to_string(object_entry.tilt_x)); insert_values.push_back(std::to_string(object_entry.tilt_y)); insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); - insert_values.push_back(std::to_string(object_entry.min_expansion)); - insert_values.push_back(std::to_string(object_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(object_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -407,11 +404,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -423,36 +420,32 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Object entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = static_cast(atof(row[3])); + entry.ypos = static_cast(atof(row[4])); + entry.zpos = static_cast(atof(row[5])); + entry.heading = static_cast(atof(row[6])); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = static_cast(atof(row[22])); + entry.tilt_x = static_cast(atof(row[23])); + entry.tilt_y = static_cast(atof(row[24])); + entry.display_name = row[25] ? row[25] : ""; all_entries.push_back(entry); } @@ -460,11 +453,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -477,36 +470,32 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Object entry{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = static_cast(atof(row[3])); + entry.ypos = static_cast(atof(row[4])); + entry.zpos = static_cast(atof(row[5])); + entry.heading = static_cast(atof(row[6])); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = static_cast(atof(row[22])); + entry.tilt_x = static_cast(atof(row[23])); + entry.tilt_y = static_cast(atof(row[24])); + entry.display_name = row[25] ? row[25] : ""; all_entries.push_back(entry); } @@ -514,9 +503,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -527,9 +516,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_perl_event_export_settings_repository.h b/common/repositories/base/base_perl_event_export_settings_repository.h index d58084463..f2a73afc7 100644 --- a/common/repositories/base/base_perl_event_export_settings_repository.h +++ b/common/repositories/base/base_perl_event_export_settings_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H @@ -50,6 +67,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("perl_event_export_settings"); @@ -69,7 +101,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -103,11 +135,10 @@ public: } static PerlEventExportSettings FindOne( - Database& db, int perl_event_export_settings_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -134,11 +165,10 @@ public: } static int DeleteOne( - Database& db, int perl_event_export_settings_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -151,7 +181,6 @@ public: } static int UpdateOne( - Database& db, PerlEventExportSettings perl_event_export_settings_entry ) { @@ -167,7 +196,7 @@ public: update_values.push_back(columns[5] + " = " + std::to_string(perl_event_export_settings_entry.export_item)); update_values.push_back(columns[6] + " = " + std::to_string(perl_event_export_settings_entry.export_event)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -181,7 +210,6 @@ public: } static PerlEventExportSettings InsertOne( - Database& db, PerlEventExportSettings perl_event_export_settings_entry ) { @@ -195,7 +223,7 @@ public: insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_item)); insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_event)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -214,7 +242,6 @@ public: } static int InsertMany( - Database& db, std::vector perl_event_export_settings_entries ) { @@ -236,7 +263,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -247,11 +274,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -277,11 +304,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -308,9 +335,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -321,9 +348,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_petitions_repository.h b/common/repositories/base/base_petitions_repository.h index 30dd9feaa..033f7120e 100644 --- a/common/repositories/base/base_petitions_repository.h +++ b/common/repositories/base/base_petitions_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PETITIONS_REPOSITORY_H @@ -68,6 +85,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("petitions"); @@ -87,7 +119,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -130,11 +162,10 @@ public: } static Petitions FindOne( - Database& db, int petitions_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -170,11 +201,10 @@ public: } static int DeleteOne( - Database& db, int petitions_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -187,7 +217,6 @@ public: } static int UpdateOne( - Database& db, Petitions petitions_entry ) { @@ -211,7 +240,7 @@ public: update_values.push_back(columns[14] + " = " + std::to_string(petitions_entry.ischeckedout)); update_values.push_back(columns[15] + " = " + std::to_string(petitions_entry.senttime)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -225,13 +254,11 @@ public: } static Petitions InsertOne( - Database& db, Petitions petitions_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(petitions_entry.dib)); insert_values.push_back(std::to_string(petitions_entry.petid)); insert_values.push_back("'" + EscapeString(petitions_entry.charname) + "'"); insert_values.push_back("'" + EscapeString(petitions_entry.accountname) + "'"); @@ -248,7 +275,7 @@ public: insert_values.push_back(std::to_string(petitions_entry.ischeckedout)); insert_values.push_back(std::to_string(petitions_entry.senttime)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -267,7 +294,6 @@ public: } static int InsertMany( - Database& db, std::vector petitions_entries ) { @@ -276,7 +302,6 @@ public: for (auto &petitions_entry: petitions_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(petitions_entry.dib)); insert_values.push_back(std::to_string(petitions_entry.petid)); insert_values.push_back("'" + EscapeString(petitions_entry.charname) + "'"); insert_values.push_back("'" + EscapeString(petitions_entry.accountname) + "'"); @@ -298,7 +323,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -309,11 +334,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -348,11 +373,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -388,9 +413,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -401,9 +426,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_pets_equipmentset_entries_repository.h b/common/repositories/base/base_pets_equipmentset_entries_repository.h index ecd9b2643..aa97e6eab 100644 --- a/common/repositories/base/base_pets_equipmentset_entries_repository.h +++ b/common/repositories/base/base_pets_equipmentset_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("pets_equipmentset_entries"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static PetsEquipmentsetEntries FindOne( - Database& db, int pets_equipmentset_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int pets_equipmentset_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, PetsEquipmentsetEntries pets_equipmentset_entries_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(pets_equipmentset_entries_entry.slot)); update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entries_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static PetsEquipmentsetEntries InsertOne( - Database& db, PetsEquipmentsetEntries pets_equipmentset_entries_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.slot)); insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector pets_equipmentset_entries_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_pets_equipmentset_repository.h b/common/repositories/base/base_pets_equipmentset_repository.h index 0f27a879f..53c0e8740 100644 --- a/common/repositories/base/base_pets_equipmentset_repository.h +++ b/common/repositories/base/base_pets_equipmentset_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PETS_EQUIPMENTSET_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("pets_equipmentset"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static PetsEquipmentset FindOne( - Database& db, int pets_equipmentset_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int pets_equipmentset_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, PetsEquipmentset pets_equipmentset_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(pets_equipmentset_entry.setname) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entry.nested_set)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static PetsEquipmentset InsertOne( - Database& db, PetsEquipmentset pets_equipmentset_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back("'" + EscapeString(pets_equipmentset_entry.setname) + "'"); insert_values.push_back(std::to_string(pets_equipmentset_entry.nested_set)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector pets_equipmentset_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_pets_repository.h b/common/repositories/base/base_pets_repository.h index 75681e6c4..ef91281ce 100644 --- a/common/repositories/base/base_pets_repository.h +++ b/common/repositories/base/base_pets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PETS_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("pets"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static Pets FindOne( - Database& db, int pets_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int pets_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, Pets pets_entry ) { @@ -172,7 +201,7 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(pets_entry.monsterflag)); update_values.push_back(columns[7] + " = " + std::to_string(pets_entry.equipmentset)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -186,7 +215,6 @@ public: } static Pets InsertOne( - Database& db, Pets pets_entry ) { @@ -201,7 +229,7 @@ public: insert_values.push_back(std::to_string(pets_entry.monsterflag)); insert_values.push_back(std::to_string(pets_entry.equipmentset)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -220,7 +248,6 @@ public: } static int InsertMany( - Database& db, std::vector pets_entries ) { @@ -243,7 +270,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -254,11 +281,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -285,11 +312,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -317,9 +344,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -330,9 +357,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_player_titlesets_repository.h b/common/repositories/base/base_player_titlesets_repository.h index 12c800953..b5e51b70d 100644 --- a/common/repositories/base/base_player_titlesets_repository.h +++ b/common/repositories/base/base_player_titlesets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PLAYER_TITLESETS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("player_titlesets"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static PlayerTitlesets FindOne( - Database& db, int player_titlesets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int player_titlesets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, PlayerTitlesets player_titlesets_entry ) { @@ -146,7 +175,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(player_titlesets_entry.char_id)); update_values.push_back(columns[2] + " = " + std::to_string(player_titlesets_entry.title_set)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -160,17 +189,15 @@ public: } static PlayerTitlesets InsertOne( - Database& db, PlayerTitlesets player_titlesets_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(player_titlesets_entry.id)); insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -189,7 +216,6 @@ public: } static int InsertMany( - Database& db, std::vector player_titlesets_entries ) { @@ -198,7 +224,6 @@ public: for (auto &player_titlesets_entry: player_titlesets_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(player_titlesets_entry.id)); insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); @@ -207,7 +232,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -218,11 +243,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -244,11 +269,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -271,9 +296,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -284,9 +309,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_proximities_repository.h b/common/repositories/base/base_proximities_repository.h index 6b1f697b0..502a822dc 100644 --- a/common/repositories/base/base_proximities_repository.h +++ b/common/repositories/base/base_proximities_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_PROXIMITIES_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("proximities"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static Proximities FindOne( - Database& db, int proximities_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int proximities_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, Proximities proximities_entry ) { @@ -172,7 +201,7 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(proximities_entry.minz)); update_values.push_back(columns[7] + " = " + std::to_string(proximities_entry.maxz)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -186,7 +215,6 @@ public: } static Proximities InsertOne( - Database& db, Proximities proximities_entry ) { @@ -201,7 +229,7 @@ public: insert_values.push_back(std::to_string(proximities_entry.minz)); insert_values.push_back(std::to_string(proximities_entry.maxz)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -220,7 +248,6 @@ public: } static int InsertMany( - Database& db, std::vector proximities_entries ) { @@ -243,7 +270,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -254,11 +281,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -285,11 +312,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -317,9 +344,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -330,9 +357,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_quest_globals_repository.h b/common/repositories/base/base_quest_globals_repository.h index 0870938fd..9c16ea35f 100644 --- a/common/repositories/base/base_quest_globals_repository.h +++ b/common/repositories/base/base_quest_globals_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_QUEST_GLOBALS_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("quest_globals"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static QuestGlobals FindOne( - Database& db, int quest_globals_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int quest_globals_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, QuestGlobals quest_globals_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = '" + EscapeString(quest_globals_entry.value) + "'"); update_values.push_back(columns[5] + " = " + std::to_string(quest_globals_entry.expdate)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static QuestGlobals InsertOne( - Database& db, QuestGlobals quest_globals_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back("'" + EscapeString(quest_globals_entry.value) + "'"); insert_values.push_back(std::to_string(quest_globals_entry.expdate)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector quest_globals_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_raid_details_repository.h b/common/repositories/base/base_raid_details_repository.h index a0f717bc6..51b293ea4 100644 --- a/common/repositories/base/base_raid_details_repository.h +++ b/common/repositories/base/base_raid_details_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_RAID_DETAILS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("raid_details"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static RaidDetails FindOne( - Database& db, int raid_details_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int raid_details_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, RaidDetails raid_details_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(raid_details_entry.locked)); update_values.push_back(columns[3] + " = '" + EscapeString(raid_details_entry.motd) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static RaidDetails InsertOne( - Database& db, RaidDetails raid_details_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(raid_details_entry.locked)); insert_values.push_back("'" + EscapeString(raid_details_entry.motd) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector raid_details_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_raid_members_repository.h b/common/repositories/base/base_raid_members_repository.h index b4c9ef94f..2878ea884 100644 --- a/common/repositories/base/base_raid_members_repository.h +++ b/common/repositories/base/base_raid_members_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_RAID_MEMBERS_REPOSITORY_H @@ -54,6 +71,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("raid_members"); @@ -73,7 +105,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -109,11 +141,10 @@ public: } static RaidMembers FindOne( - Database& db, int raid_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -142,11 +173,10 @@ public: } static int DeleteOne( - Database& db, int raid_members_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -159,7 +189,6 @@ public: } static int UpdateOne( - Database& db, RaidMembers raid_members_entry ) { @@ -177,7 +206,7 @@ public: update_values.push_back(columns[7] + " = " + std::to_string(raid_members_entry.israidleader)); update_values.push_back(columns[8] + " = " + std::to_string(raid_members_entry.islooter)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -191,7 +220,6 @@ public: } static RaidMembers InsertOne( - Database& db, RaidMembers raid_members_entry ) { @@ -207,7 +235,7 @@ public: insert_values.push_back(std::to_string(raid_members_entry.israidleader)); insert_values.push_back(std::to_string(raid_members_entry.islooter)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +254,6 @@ public: } static int InsertMany( - Database& db, std::vector raid_members_entries ) { @@ -250,7 +277,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -261,11 +288,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,11 +320,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,9 +353,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -339,9 +366,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_reports_repository.h b/common/repositories/base/base_reports_repository.h index caebd4107..10471d7a7 100644 --- a/common/repositories/base/base_reports_repository.h +++ b/common/repositories/base/base_reports_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_REPORTS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("reports"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static Reports FindOne( - Database& db, int reports_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int reports_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, Reports reports_entry ) { @@ -151,7 +180,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(reports_entry.reported) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(reports_entry.reported_text) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -165,18 +194,16 @@ public: } static Reports InsertOne( - Database& db, Reports reports_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(reports_entry.id)); insert_values.push_back("'" + EscapeString(reports_entry.name) + "'"); insert_values.push_back("'" + EscapeString(reports_entry.reported) + "'"); insert_values.push_back("'" + EscapeString(reports_entry.reported_text) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -195,7 +222,6 @@ public: } static int InsertMany( - Database& db, std::vector reports_entries ) { @@ -204,7 +230,6 @@ public: for (auto &reports_entry: reports_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(reports_entry.id)); insert_values.push_back("'" + EscapeString(reports_entry.name) + "'"); insert_values.push_back("'" + EscapeString(reports_entry.reported) + "'"); insert_values.push_back("'" + EscapeString(reports_entry.reported_text) + "'"); @@ -214,7 +239,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -225,11 +250,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -252,11 +277,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -280,9 +305,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -293,9 +318,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_respawn_times_repository.h b/common/repositories/base/base_respawn_times_repository.h index df69f2be9..e95598529 100644 --- a/common/repositories/base/base_respawn_times_repository.h +++ b/common/repositories/base/base_respawn_times_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_RESPAWN_TIMES_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("respawn_times"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static RespawnTimes FindOne( - Database& db, int respawn_times_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int respawn_times_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, RespawnTimes respawn_times_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(respawn_times_entry.duration)); update_values.push_back(columns[3] + " = " + std::to_string(respawn_times_entry.instance_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static RespawnTimes InsertOne( - Database& db, RespawnTimes respawn_times_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(respawn_times_entry.duration)); insert_values.push_back(std::to_string(respawn_times_entry.instance_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector respawn_times_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_rule_sets_repository.h b/common/repositories/base/base_rule_sets_repository.h index 31dab96d9..0d0f48d43 100644 --- a/common/repositories/base/base_rule_sets_repository.h +++ b/common/repositories/base/base_rule_sets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_RULE_SETS_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("rule_sets"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static RuleSets FindOne( - Database& db, int rule_sets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int rule_sets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, RuleSets rule_sets_entry ) { @@ -141,7 +170,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(rule_sets_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -155,16 +184,14 @@ public: } static RuleSets InsertOne( - Database& db, RuleSets rule_sets_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(rule_sets_entry.ruleset_id)); insert_values.push_back("'" + EscapeString(rule_sets_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -183,7 +210,6 @@ public: } static int InsertMany( - Database& db, std::vector rule_sets_entries ) { @@ -192,7 +218,6 @@ public: for (auto &rule_sets_entry: rule_sets_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(rule_sets_entry.ruleset_id)); insert_values.push_back("'" + EscapeString(rule_sets_entry.name) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -200,7 +225,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -211,11 +236,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -236,11 +261,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -262,9 +287,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -275,9 +300,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_rule_values_repository.h b/common/repositories/base/base_rule_values_repository.h index 6bd6fe2d6..749b18a87 100644 --- a/common/repositories/base/base_rule_values_repository.h +++ b/common/repositories/base/base_rule_values_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_RULE_VALUES_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("rule_values"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static RuleValues FindOne( - Database& db, int rule_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int rule_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, RuleValues rule_values_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(rule_values_entry.rule_value) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(rule_values_entry.notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static RuleValues InsertOne( - Database& db, RuleValues rule_values_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back("'" + EscapeString(rule_values_entry.rule_value) + "'"); insert_values.push_back("'" + EscapeString(rule_values_entry.notes) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector rule_values_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_saylink_repository.h b/common/repositories/base/base_saylink_repository.h index e02b1954c..d58a02a9b 100644 --- a/common/repositories/base/base_saylink_repository.h +++ b/common/repositories/base/base_saylink_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SAYLINK_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("saylink"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static Saylink FindOne( - Database& db, int saylink_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int saylink_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, Saylink saylink_entry ) { @@ -141,7 +170,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(saylink_entry.phrase) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -155,16 +184,14 @@ public: } static Saylink InsertOne( - Database& db, Saylink saylink_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(saylink_entry.id)); insert_values.push_back("'" + EscapeString(saylink_entry.phrase) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -183,7 +210,6 @@ public: } static int InsertMany( - Database& db, std::vector saylink_entries ) { @@ -192,7 +218,6 @@ public: for (auto &saylink_entry: saylink_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(saylink_entry.id)); insert_values.push_back("'" + EscapeString(saylink_entry.phrase) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -200,7 +225,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -211,11 +236,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -236,11 +261,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -262,9 +287,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -275,9 +300,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_server_scheduled_events_repository.h b/common/repositories/base/base_server_scheduled_events_repository.h deleted file mode 100644 index 1cc319d6a..000000000 --- a/common/repositories/base/base_server_scheduled_events_repository.h +++ /dev/null @@ -1,427 +0,0 @@ -/** - * DO NOT MODIFY THIS FILE - * - * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_SERVER_SCHEDULED_EVENTS_REPOSITORY_H -#define EQEMU_BASE_SERVER_SCHEDULED_EVENTS_REPOSITORY_H - -#include "../../database.h" -#include "../../string_util.h" - -class BaseServerScheduledEventsRepository { -public: - struct ServerScheduledEvents { - int id; - std::string description; - std::string event_type; - std::string event_data; - int minute_start; - int hour_start; - int day_start; - int month_start; - int year_start; - int minute_end; - int hour_end; - int day_end; - int month_end; - int year_end; - std::string cron_expression; - std::string created_at; - std::string deleted_at; - }; - - static std::string PrimaryKey() - { - return std::string("id"); - } - - static std::vector Columns() - { - return { - "id", - "description", - "event_type", - "event_data", - "minute_start", - "hour_start", - "day_start", - "month_start", - "year_start", - "minute_end", - "hour_end", - "day_end", - "month_end", - "year_end", - "cron_expression", - "created_at", - "deleted_at", - }; - } - - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("server_scheduled_events"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static ServerScheduledEvents NewEntity() - { - ServerScheduledEvents entry{}; - - entry.id = 0; - entry.description = ""; - entry.event_type = ""; - entry.event_data = ""; - entry.minute_start = 0; - entry.hour_start = 0; - entry.day_start = 0; - entry.month_start = 0; - entry.year_start = 0; - entry.minute_end = 0; - entry.hour_end = 0; - entry.day_end = 0; - entry.month_end = 0; - entry.year_end = 0; - entry.cron_expression = ""; - entry.created_at = ""; - entry.deleted_at = ""; - - return entry; - } - - static ServerScheduledEvents GetServerScheduledEventsEntry( - const std::vector &server_scheduled_eventss, - int server_scheduled_events_id - ) - { - for (auto &server_scheduled_events : server_scheduled_eventss) { - if (server_scheduled_events.id == server_scheduled_events_id) { - return server_scheduled_events; - } - } - - return NewEntity(); - } - - static ServerScheduledEvents FindOne( - Database& db, - int server_scheduled_events_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - server_scheduled_events_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - ServerScheduledEvents entry{}; - - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int server_scheduled_events_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - server_scheduled_events_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - ServerScheduledEvents server_scheduled_events_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = '" + EscapeString(server_scheduled_events_entry.description) + "'"); - update_values.push_back(columns[2] + " = '" + EscapeString(server_scheduled_events_entry.event_type) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(server_scheduled_events_entry.event_data) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(server_scheduled_events_entry.minute_start)); - update_values.push_back(columns[5] + " = " + std::to_string(server_scheduled_events_entry.hour_start)); - update_values.push_back(columns[6] + " = " + std::to_string(server_scheduled_events_entry.day_start)); - update_values.push_back(columns[7] + " = " + std::to_string(server_scheduled_events_entry.month_start)); - update_values.push_back(columns[8] + " = " + std::to_string(server_scheduled_events_entry.year_start)); - update_values.push_back(columns[9] + " = " + std::to_string(server_scheduled_events_entry.minute_end)); - update_values.push_back(columns[10] + " = " + std::to_string(server_scheduled_events_entry.hour_end)); - update_values.push_back(columns[11] + " = " + std::to_string(server_scheduled_events_entry.day_end)); - update_values.push_back(columns[12] + " = " + std::to_string(server_scheduled_events_entry.month_end)); - update_values.push_back(columns[13] + " = " + std::to_string(server_scheduled_events_entry.year_end)); - update_values.push_back(columns[14] + " = '" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - update_values.push_back(columns[15] + " = '" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - update_values.push_back(columns[16] + " = '" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - server_scheduled_events_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static ServerScheduledEvents InsertOne( - Database& db, - ServerScheduledEvents server_scheduled_events_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(server_scheduled_events_entry.id)); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.description) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.event_type) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.event_data) + "'"); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - server_scheduled_events_entry.id = results.LastInsertedID(); - return server_scheduled_events_entry; - } - - server_scheduled_events_entry = NewEntity(); - - return server_scheduled_events_entry; - } - - static int InsertMany( - Database& db, - std::vector server_scheduled_events_entries - ) - { - std::vector insert_chunks; - - for (auto &server_scheduled_events_entry: server_scheduled_events_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(server_scheduled_events_entry.id)); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.description) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.event_type) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.event_data) + "'"); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ServerScheduledEvents entry{}; - - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, std::string where_filter) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {}", - BaseSelect(), - where_filter - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ServerScheduledEvents entry{}; - - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, std::string where_filter) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {}", - TableName(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int Truncate(Database& db) - { - auto results = db.QueryDatabase( - fmt::format( - "TRUNCATE TABLE {}", - TableName() - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - -}; - -#endif //EQEMU_BASE_SERVER_SCHEDULED_EVENTS_REPOSITORY_H diff --git a/common/repositories/base/base_skill_caps_repository.h b/common/repositories/base/base_skill_caps_repository.h index b17753782..561aaeef7 100644 --- a/common/repositories/base/base_skill_caps_repository.h +++ b/common/repositories/base/base_skill_caps_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SKILL_CAPS_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("skill_caps"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static SkillCaps FindOne( - Database& db, int skill_caps_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int skill_caps_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, SkillCaps skill_caps_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(skill_caps_entry.cap)); update_values.push_back(columns[4] + " = " + std::to_string(skill_caps_entry.class_)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static SkillCaps InsertOne( - Database& db, SkillCaps skill_caps_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(skill_caps_entry.cap)); insert_values.push_back(std::to_string(skill_caps_entry.class_)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector skill_caps_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawn2_repository.h b/common/repositories/base/base_spawn2_repository.h index 921c9262d..51e96a36b 100644 --- a/common/repositories/base/base_spawn2_repository.h +++ b/common/repositories/base/base_spawn2_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWN2_REPOSITORY_H @@ -33,10 +50,6 @@ public: int cond_value; int enabled; int animation; - int min_expansion; - int max_expansion; - std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -62,10 +75,6 @@ public: "cond_value", "enabled", "animation", - "min_expansion", - "max_expansion", - "content_flags", - "content_flags_disabled", }; } @@ -74,6 +83,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawn2"); @@ -93,7 +117,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -101,25 +125,21 @@ public: { Spawn2 entry{}; - entry.id = 0; - entry.spawngroupID = 0; - entry.zone = ""; - entry.version = 0; - entry.x = 0.000000; - entry.y = 0.000000; - entry.z = 0.000000; - entry.heading = 0.000000; - entry.respawntime = 0; - entry.variance = 0; - entry.pathgrid = 0; - entry._condition = 0; - entry.cond_value = 1; - entry.enabled = 1; - entry.animation = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.spawngroupID = 0; + entry.zone = ""; + entry.version = 0; + entry.x = 0.000000; + entry.y = 0.000000; + entry.z = 0.000000; + entry.heading = 0.000000; + entry.respawntime = 0; + entry.variance = 0; + entry.pathgrid = 0; + entry._condition = 0; + entry.cond_value = 1; + entry.enabled = 1; + entry.animation = 0; return entry; } @@ -139,11 +159,10 @@ public: } static Spawn2 FindOne( - Database& db, int spawn2_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -155,25 +174,21 @@ public: if (results.RowCount() == 1) { Spawn2 entry{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry._condition = atoi(row[11]); - entry.cond_value = atoi(row[12]); - entry.enabled = atoi(row[13]); - entry.animation = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = static_cast(atof(row[4])); + entry.y = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); return entry; } @@ -182,11 +197,10 @@ public: } static int DeleteOne( - Database& db, int spawn2_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -199,7 +213,6 @@ public: } static int UpdateOne( - Database& db, Spawn2 spawn2_entry ) { @@ -221,12 +234,8 @@ public: update_values.push_back(columns[12] + " = " + std::to_string(spawn2_entry.cond_value)); update_values.push_back(columns[13] + " = " + std::to_string(spawn2_entry.enabled)); update_values.push_back(columns[14] + " = " + std::to_string(spawn2_entry.animation)); - update_values.push_back(columns[15] + " = " + std::to_string(spawn2_entry.min_expansion)); - update_values.push_back(columns[16] + " = " + std::to_string(spawn2_entry.max_expansion)); - update_values.push_back(columns[17] + " = '" + EscapeString(spawn2_entry.content_flags) + "'"); - update_values.push_back(columns[18] + " = '" + EscapeString(spawn2_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -240,13 +249,11 @@ public: } static Spawn2 InsertOne( - Database& db, Spawn2 spawn2_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(spawn2_entry.id)); insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn2_entry.version)); @@ -261,12 +268,8 @@ public: insert_values.push_back(std::to_string(spawn2_entry.cond_value)); insert_values.push_back(std::to_string(spawn2_entry.enabled)); insert_values.push_back(std::to_string(spawn2_entry.animation)); - insert_values.push_back(std::to_string(spawn2_entry.min_expansion)); - insert_values.push_back(std::to_string(spawn2_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(spawn2_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -285,7 +288,6 @@ public: } static int InsertMany( - Database& db, std::vector spawn2_entries ) { @@ -294,7 +296,6 @@ public: for (auto &spawn2_entry: spawn2_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(spawn2_entry.id)); insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn2_entry.version)); @@ -309,17 +310,13 @@ public: insert_values.push_back(std::to_string(spawn2_entry.cond_value)); insert_values.push_back(std::to_string(spawn2_entry.enabled)); insert_values.push_back(std::to_string(spawn2_entry.animation)); - insert_values.push_back(std::to_string(spawn2_entry.min_expansion)); - insert_values.push_back(std::to_string(spawn2_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(spawn2_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -330,11 +327,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -346,25 +343,21 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Spawn2 entry{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry._condition = atoi(row[11]); - entry.cond_value = atoi(row[12]); - entry.enabled = atoi(row[13]); - entry.animation = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = static_cast(atof(row[4])); + entry.y = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); all_entries.push_back(entry); } @@ -372,11 +365,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -389,25 +382,21 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Spawn2 entry{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry._condition = atoi(row[11]); - entry.cond_value = atoi(row[12]); - entry.enabled = atoi(row[13]); - entry.animation = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = static_cast(atof(row[4])); + entry.y = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); all_entries.push_back(entry); } @@ -415,9 +404,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -428,9 +417,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawn_condition_values_repository.h b/common/repositories/base/base_spawn_condition_values_repository.h index c54eee597..fbcac8e70 100644 --- a/common/repositories/base/base_spawn_condition_values_repository.h +++ b/common/repositories/base/base_spawn_condition_values_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWN_CONDITION_VALUES_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawn_condition_values"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static SpawnConditionValues FindOne( - Database& db, int spawn_condition_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int spawn_condition_values_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, SpawnConditionValues spawn_condition_values_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(spawn_condition_values_entry.zone) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(spawn_condition_values_entry.instance_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static SpawnConditionValues InsertOne( - Database& db, SpawnConditionValues spawn_condition_values_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back("'" + EscapeString(spawn_condition_values_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn_condition_values_entry.instance_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector spawn_condition_values_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawn_conditions_repository.h b/common/repositories/base/base_spawn_conditions_repository.h index e0e7fa0ab..967e038fa 100644 --- a/common/repositories/base/base_spawn_conditions_repository.h +++ b/common/repositories/base/base_spawn_conditions_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWN_CONDITIONS_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawn_conditions"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static SpawnConditions FindOne( - Database& db, int spawn_conditions_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int spawn_conditions_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, SpawnConditions spawn_conditions_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(spawn_conditions_entry.onchange)); update_values.push_back(columns[4] + " = '" + EscapeString(spawn_conditions_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static SpawnConditions InsertOne( - Database& db, SpawnConditions spawn_conditions_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(spawn_conditions_entry.onchange)); insert_values.push_back("'" + EscapeString(spawn_conditions_entry.name) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector spawn_conditions_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawn_events_repository.h b/common/repositories/base/base_spawn_events_repository.h index da52bbb8a..aa871a7b9 100644 --- a/common/repositories/base/base_spawn_events_repository.h +++ b/common/repositories/base/base_spawn_events_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWN_EVENTS_REPOSITORY_H @@ -64,6 +81,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawn_events"); @@ -83,7 +115,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -124,11 +156,10 @@ public: } static SpawnEvents FindOne( - Database& db, int spawn_events_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -162,11 +193,10 @@ public: } static int DeleteOne( - Database& db, int spawn_events_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -179,7 +209,6 @@ public: } static int UpdateOne( - Database& db, SpawnEvents spawn_events_entry ) { @@ -201,7 +230,7 @@ public: update_values.push_back(columns[12] + " = " + std::to_string(spawn_events_entry.argument)); update_values.push_back(columns[13] + " = " + std::to_string(spawn_events_entry.strict)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -215,13 +244,11 @@ public: } static SpawnEvents InsertOne( - Database& db, SpawnEvents spawn_events_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(spawn_events_entry.id)); insert_values.push_back("'" + EscapeString(spawn_events_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); insert_values.push_back("'" + EscapeString(spawn_events_entry.name) + "'"); @@ -236,7 +263,7 @@ public: insert_values.push_back(std::to_string(spawn_events_entry.argument)); insert_values.push_back(std::to_string(spawn_events_entry.strict)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -255,7 +282,6 @@ public: } static int InsertMany( - Database& db, std::vector spawn_events_entries ) { @@ -264,7 +290,6 @@ public: for (auto &spawn_events_entry: spawn_events_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(spawn_events_entry.id)); insert_values.push_back("'" + EscapeString(spawn_events_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); insert_values.push_back("'" + EscapeString(spawn_events_entry.name) + "'"); @@ -284,7 +309,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -295,11 +320,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -332,11 +357,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -370,9 +395,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -383,9 +408,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawnentry_repository.h b/common/repositories/base/base_spawnentry_repository.h index 4a04bf7d6..66bdb4060 100644 --- a/common/repositories/base/base_spawnentry_repository.h +++ b/common/repositories/base/base_spawnentry_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWNENTRY_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawnentry"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static Spawnentry FindOne( - Database& db, int spawnentry_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int spawnentry_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, Spawnentry spawnentry_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(spawnentry_entry.chance)); update_values.push_back(columns[3] + " = " + std::to_string(spawnentry_entry.condition_value_filter)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static Spawnentry InsertOne( - Database& db, Spawnentry spawnentry_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(spawnentry_entry.chance)); insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector spawnentry_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spawngroup_repository.h b/common/repositories/base/base_spawngroup_repository.h index 0baba76aa..9e6e6bbf8 100644 --- a/common/repositories/base/base_spawngroup_repository.h +++ b/common/repositories/base/base_spawngroup_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPAWNGROUP_REPOSITORY_H @@ -62,6 +79,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spawngroup"); @@ -81,7 +113,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -121,11 +153,10 @@ public: } static Spawngroup FindOne( - Database& db, int spawngroup_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -158,11 +189,10 @@ public: } static int DeleteOne( - Database& db, int spawngroup_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -175,7 +205,6 @@ public: } static int UpdateOne( - Database& db, Spawngroup spawngroup_entry ) { @@ -196,7 +225,7 @@ public: update_values.push_back(columns[11] + " = " + std::to_string(spawngroup_entry.despawn_timer)); update_values.push_back(columns[12] + " = " + std::to_string(spawngroup_entry.wp_spawns)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -210,13 +239,11 @@ public: } static Spawngroup InsertOne( - Database& db, Spawngroup spawngroup_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(spawngroup_entry.id)); insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); insert_values.push_back(std::to_string(spawngroup_entry.dist)); @@ -230,7 +257,7 @@ public: insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer)); insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -249,7 +276,6 @@ public: } static int InsertMany( - Database& db, std::vector spawngroup_entries ) { @@ -258,7 +284,6 @@ public: for (auto &spawngroup_entry: spawngroup_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(spawngroup_entry.id)); insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); insert_values.push_back(std::to_string(spawngroup_entry.dist)); @@ -277,7 +302,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -288,11 +313,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -324,11 +349,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -361,9 +386,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -374,9 +399,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spell_buckets_repository.h b/common/repositories/base/base_spell_buckets_repository.h index 39ce3ff42..db038f510 100644 --- a/common/repositories/base/base_spell_buckets_repository.h +++ b/common/repositories/base/base_spell_buckets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPELL_BUCKETS_REPOSITORY_H @@ -42,6 +59,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spell_buckets"); @@ -61,7 +93,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -91,11 +123,10 @@ public: } static SpellBuckets FindOne( - Database& db, int spell_buckets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -118,11 +149,10 @@ public: } static int DeleteOne( - Database& db, int spell_buckets_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -135,7 +165,6 @@ public: } static int UpdateOne( - Database& db, SpellBuckets spell_buckets_entry ) { @@ -147,7 +176,7 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(spell_buckets_entry.key) + "'"); update_values.push_back(columns[2] + " = '" + EscapeString(spell_buckets_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -161,7 +190,6 @@ public: } static SpellBuckets InsertOne( - Database& db, SpellBuckets spell_buckets_entry ) { @@ -171,7 +199,7 @@ public: insert_values.push_back("'" + EscapeString(spell_buckets_entry.key) + "'"); insert_values.push_back("'" + EscapeString(spell_buckets_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -190,7 +218,6 @@ public: } static int InsertMany( - Database& db, std::vector spell_buckets_entries ) { @@ -208,7 +235,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -219,11 +246,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -245,11 +272,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -272,9 +299,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -285,9 +312,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spell_globals_repository.h b/common/repositories/base/base_spell_globals_repository.h index 40ce563ce..9a8c6dc81 100644 --- a/common/repositories/base/base_spell_globals_repository.h +++ b/common/repositories/base/base_spell_globals_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPELL_GLOBALS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spell_globals"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static SpellGlobals FindOne( - Database& db, int spell_globals_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int spell_globals_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, SpellGlobals spell_globals_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(spell_globals_entry.qglobal) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(spell_globals_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static SpellGlobals InsertOne( - Database& db, SpellGlobals spell_globals_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back("'" + EscapeString(spell_globals_entry.qglobal) + "'"); insert_values.push_back("'" + EscapeString(spell_globals_entry.value) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector spell_globals_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_spells_new_repository.h b/common/repositories/base/base_spells_new_repository.h index e59ce3b28..19220c09c 100644 --- a/common/repositories/base/base_spells_new_repository.h +++ b/common/repositories/base/base_spells_new_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_SPELLS_NEW_REPOSITORY_H @@ -510,6 +527,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("spells_new"); @@ -529,7 +561,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -793,11 +825,10 @@ public: } static SpellsNew FindOne( - Database& db, int spells_new_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -1054,11 +1085,10 @@ public: } static int DeleteOne( - Database& db, int spells_new_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -1071,7 +1101,6 @@ public: } static int UpdateOne( - Database& db, SpellsNew spells_new_entry ) { @@ -1317,7 +1346,7 @@ public: update_values.push_back(columns[235] + " = " + std::to_string(spells_new_entry.field235)); update_values.push_back(columns[236] + " = " + std::to_string(spells_new_entry.field236)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -1331,7 +1360,6 @@ public: } static SpellsNew InsertOne( - Database& db, SpellsNew spells_new_entry ) { @@ -1575,7 +1603,7 @@ public: insert_values.push_back(std::to_string(spells_new_entry.field235)); insert_values.push_back(std::to_string(spells_new_entry.field236)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -1594,7 +1622,6 @@ public: } static int InsertMany( - Database& db, std::vector spells_new_entries ) { @@ -1846,7 +1873,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -1857,11 +1884,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -2117,11 +2144,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -2378,9 +2405,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -2391,9 +2418,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_start_zones_repository.h b/common/repositories/base/base_start_zones_repository.h index 75a8595ca..60cfd072a 100644 --- a/common/repositories/base/base_start_zones_repository.h +++ b/common/repositories/base/base_start_zones_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_START_ZONES_REPOSITORY_H @@ -36,7 +53,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -65,7 +81,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -74,6 +89,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("start_zones"); @@ -93,7 +123,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -101,25 +131,24 @@ public: { StartZones entry{}; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; - entry.zone_id = 0; - entry.bind_id = 0; - entry.player_choice = 0; - entry.player_class = 0; - entry.player_deity = 0; - entry.player_race = 0; - entry.start_zone = 0; - entry.bind_x = 0; - entry.bind_y = 0; - entry.bind_z = 0; - entry.select_rank = 50; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.x = 0; + entry.y = 0; + entry.z = 0; + entry.heading = 0; + entry.zone_id = 0; + entry.bind_id = 0; + entry.player_choice = 0; + entry.player_class = 0; + entry.player_deity = 0; + entry.player_race = 0; + entry.start_zone = 0; + entry.bind_x = 0; + entry.bind_y = 0; + entry.bind_z = 0; + entry.select_rank = 50; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -139,11 +168,10 @@ public: } static StartZones FindOne( - Database& db, int start_zones_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -155,25 +183,24 @@ public: if (results.RowCount() == 1) { StartZones entry{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.x = static_cast(atof(row[0])); + entry.y = static_cast(atof(row[1])); + entry.z = static_cast(atof(row[2])); + entry.heading = static_cast(atof(row[3])); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = static_cast(atof(row[11])); + entry.bind_y = static_cast(atof(row[12])); + entry.bind_z = static_cast(atof(row[13])); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; return entry; } @@ -182,11 +209,10 @@ public: } static int DeleteOne( - Database& db, int start_zones_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -199,7 +225,6 @@ public: } static int UpdateOne( - Database& db, StartZones start_zones_entry ) { @@ -225,9 +250,8 @@ public: update_values.push_back(columns[15] + " = " + std::to_string(start_zones_entry.min_expansion)); update_values.push_back(columns[16] + " = " + std::to_string(start_zones_entry.max_expansion)); update_values.push_back(columns[17] + " = '" + EscapeString(start_zones_entry.content_flags) + "'"); - update_values.push_back(columns[18] + " = '" + EscapeString(start_zones_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -241,7 +265,6 @@ public: } static StartZones InsertOne( - Database& db, StartZones start_zones_entry ) { @@ -265,9 +288,8 @@ public: insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -286,7 +308,6 @@ public: } static int InsertMany( - Database& db, std::vector start_zones_entries ) { @@ -313,14 +334,13 @@ public: insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -331,11 +351,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -347,25 +367,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { StartZones entry{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.x = static_cast(atof(row[0])); + entry.y = static_cast(atof(row[1])); + entry.z = static_cast(atof(row[2])); + entry.heading = static_cast(atof(row[3])); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = static_cast(atof(row[11])); + entry.bind_y = static_cast(atof(row[12])); + entry.bind_z = static_cast(atof(row[13])); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; all_entries.push_back(entry); } @@ -373,11 +392,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -390,25 +409,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { StartZones entry{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + entry.x = static_cast(atof(row[0])); + entry.y = static_cast(atof(row[1])); + entry.z = static_cast(atof(row[2])); + entry.heading = static_cast(atof(row[3])); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = static_cast(atof(row[11])); + entry.bind_y = static_cast(atof(row[12])); + entry.bind_z = static_cast(atof(row[13])); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; all_entries.push_back(entry); } @@ -416,9 +434,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -429,9 +447,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_starting_items_repository.h b/common/repositories/base/base_starting_items_repository.h index edb2cafa9..5efab9ab4 100644 --- a/common/repositories/base/base_starting_items_repository.h +++ b/common/repositories/base/base_starting_items_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_STARTING_ITEMS_REPOSITORY_H @@ -30,7 +47,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -53,7 +69,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -62,6 +77,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("starting_items"); @@ -81,7 +111,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -89,19 +119,18 @@ public: { StartingItems entry{}; - entry.id = 0; - entry.race = 0; - entry.class = 0; - entry.deityid = 0; - entry.zoneid = 0; - entry.itemid = 0; - entry.item_charges = 1; - entry.gm = 0; - entry.slot = -1; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.race = 0; + entry.class = 0; + entry.deityid = 0; + entry.zoneid = 0; + entry.itemid = 0; + entry.item_charges = 1; + entry.gm = 0; + entry.slot = -1; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -121,11 +150,10 @@ public: } static StartingItems FindOne( - Database& db, int starting_items_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -137,19 +165,18 @@ public: if (results.RowCount() == 1) { StartingItems entry{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = row[11] ? row[11] : ""; return entry; } @@ -158,11 +185,10 @@ public: } static int DeleteOne( - Database& db, int starting_items_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -175,7 +201,6 @@ public: } static int UpdateOne( - Database& db, StartingItems starting_items_entry ) { @@ -194,9 +219,8 @@ public: update_values.push_back(columns[9] + " = " + std::to_string(starting_items_entry.min_expansion)); update_values.push_back(columns[10] + " = " + std::to_string(starting_items_entry.max_expansion)); update_values.push_back(columns[11] + " = '" + EscapeString(starting_items_entry.content_flags) + "'"); - update_values.push_back(columns[12] + " = '" + EscapeString(starting_items_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -210,13 +234,11 @@ public: } static StartingItems InsertOne( - Database& db, StartingItems starting_items_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(starting_items_entry.id)); insert_values.push_back(std::to_string(starting_items_entry.race)); insert_values.push_back(std::to_string(starting_items_entry.class)); insert_values.push_back(std::to_string(starting_items_entry.deityid)); @@ -228,9 +250,8 @@ public: insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -249,7 +270,6 @@ public: } static int InsertMany( - Database& db, std::vector starting_items_entries ) { @@ -258,7 +278,6 @@ public: for (auto &starting_items_entry: starting_items_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(starting_items_entry.id)); insert_values.push_back(std::to_string(starting_items_entry.race)); insert_values.push_back(std::to_string(starting_items_entry.class)); insert_values.push_back(std::to_string(starting_items_entry.deityid)); @@ -270,14 +289,13 @@ public: insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -288,11 +306,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -304,19 +322,18 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { StartingItems entry{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = row[11] ? row[11] : ""; all_entries.push_back(entry); } @@ -324,11 +341,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -341,19 +358,18 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { StartingItems entry{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = row[11] ? row[11] : ""; all_entries.push_back(entry); } @@ -361,9 +377,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -374,9 +390,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_task_activities_repository.h b/common/repositories/base/base_task_activities_repository.h index ad7f1fee4..6847c12a0 100644 --- a/common/repositories/base/base_task_activities_repository.h +++ b/common/repositories/base/base_task_activities_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TASK_ACTIVITIES_REPOSITORY_H @@ -66,6 +83,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("task_activities"); @@ -85,7 +117,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -127,11 +159,10 @@ public: } static TaskActivities FindOne( - Database& db, int task_activities_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -166,11 +197,10 @@ public: } static int DeleteOne( - Database& db, int task_activities_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -183,7 +213,6 @@ public: } static int UpdateOne( - Database& db, TaskActivities task_activities_entry ) { @@ -207,7 +236,7 @@ public: update_values.push_back(columns[13] + " = '" + EscapeString(task_activities_entry.zones) + "'"); update_values.push_back(columns[14] + " = " + std::to_string(task_activities_entry.optional)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -221,7 +250,6 @@ public: } static TaskActivities InsertOne( - Database& db, TaskActivities task_activities_entry ) { @@ -243,7 +271,7 @@ public: insert_values.push_back("'" + EscapeString(task_activities_entry.zones) + "'"); insert_values.push_back(std::to_string(task_activities_entry.optional)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -262,7 +290,6 @@ public: } static int InsertMany( - Database& db, std::vector task_activities_entries ) { @@ -292,7 +319,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -303,11 +330,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -341,11 +368,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -380,9 +407,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -393,9 +420,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tasks_repository.h b/common/repositories/base/base_tasks_repository.h index 3d1982bf2..641d1733c 100644 --- a/common/repositories/base/base_tasks_repository.h +++ b/common/repositories/base/base_tasks_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TASKS_REPOSITORY_H @@ -68,6 +85,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tasks"); @@ -87,7 +119,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -130,11 +162,10 @@ public: } static Tasks FindOne( - Database& db, int tasks_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -170,11 +201,10 @@ public: } static int DeleteOne( - Database& db, int tasks_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -187,7 +217,6 @@ public: } static int UpdateOne( - Database& db, Tasks tasks_entry ) { @@ -212,7 +241,7 @@ public: update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.faction_reward)); update_values.push_back(columns[15] + " = '" + EscapeString(tasks_entry.completion_emote) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -226,7 +255,6 @@ public: } static Tasks InsertOne( - Database& db, Tasks tasks_entry ) { @@ -249,7 +277,7 @@ public: insert_values.push_back(std::to_string(tasks_entry.faction_reward)); insert_values.push_back("'" + EscapeString(tasks_entry.completion_emote) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -268,7 +296,6 @@ public: } static int InsertMany( - Database& db, std::vector tasks_entries ) { @@ -299,7 +326,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -310,11 +337,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -349,11 +376,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -389,9 +416,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -402,9 +429,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tasksets_repository.h b/common/repositories/base/base_tasksets_repository.h index c3feb4ccd..1cb822eba 100644 --- a/common/repositories/base/base_tasksets_repository.h +++ b/common/repositories/base/base_tasksets_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TASKSETS_REPOSITORY_H @@ -40,6 +57,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tasksets"); @@ -59,7 +91,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -88,11 +120,10 @@ public: } static Tasksets FindOne( - Database& db, int tasksets_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -114,11 +145,10 @@ public: } static int DeleteOne( - Database& db, int tasksets_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -131,7 +161,6 @@ public: } static int UpdateOne( - Database& db, Tasksets tasksets_entry ) { @@ -142,7 +171,7 @@ public: update_values.push_back(columns[0] + " = " + std::to_string(tasksets_entry.id)); update_values.push_back(columns[1] + " = " + std::to_string(tasksets_entry.taskid)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -156,7 +185,6 @@ public: } static Tasksets InsertOne( - Database& db, Tasksets tasksets_entry ) { @@ -165,7 +193,7 @@ public: insert_values.push_back(std::to_string(tasksets_entry.id)); insert_values.push_back(std::to_string(tasksets_entry.taskid)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -184,7 +212,6 @@ public: } static int InsertMany( - Database& db, std::vector tasksets_entries ) { @@ -201,7 +228,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -212,11 +239,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -237,11 +264,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -263,9 +290,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -276,9 +303,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_timers_repository.h b/common/repositories/base/base_timers_repository.h index f1d6d97b1..459c85c28 100644 --- a/common/repositories/base/base_timers_repository.h +++ b/common/repositories/base/base_timers_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TIMERS_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("timers"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static Timers FindOne( - Database& db, int timers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int timers_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, Timers timers_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(timers_entry.duration)); update_values.push_back(columns[4] + " = " + std::to_string(timers_entry.enable)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static Timers InsertOne( - Database& db, Timers timers_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(timers_entry.duration)); insert_values.push_back(std::to_string(timers_entry.enable)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector timers_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_titles_repository.h b/common/repositories/base/base_titles_repository.h index c108c887b..5bb5cd9f5 100644 --- a/common/repositories/base/base_titles_repository.h +++ b/common/repositories/base/base_titles_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TITLES_REPOSITORY_H @@ -32,6 +49,9 @@ public: std::string prefix; std::string suffix; int title_set; + int min_expansion; + int max_expansion; + std::string content_flags; }; static std::string PrimaryKey() @@ -56,6 +76,9 @@ public: "prefix", "suffix", "title_set", + "min_expansion", + "max_expansion", + "content_flags", }; } @@ -64,6 +87,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("titles"); @@ -83,7 +121,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -105,6 +143,9 @@ public: entry.prefix = ""; entry.suffix = ""; entry.title_set = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -124,11 +165,10 @@ public: } static Titles FindOne( - Database& db, int titles_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -154,6 +194,9 @@ public: entry.prefix = row[11] ? row[11] : ""; entry.suffix = row[12] ? row[12] : ""; entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; return entry; } @@ -162,11 +205,10 @@ public: } static int DeleteOne( - Database& db, int titles_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -179,7 +221,6 @@ public: } static int UpdateOne( - Database& db, Titles titles_entry ) { @@ -200,8 +241,11 @@ public: update_values.push_back(columns[11] + " = '" + EscapeString(titles_entry.prefix) + "'"); update_values.push_back(columns[12] + " = '" + EscapeString(titles_entry.suffix) + "'"); update_values.push_back(columns[13] + " = " + std::to_string(titles_entry.title_set)); + update_values.push_back(columns[14] + " = " + std::to_string(titles_entry.min_expansion)); + update_values.push_back(columns[15] + " = " + std::to_string(titles_entry.max_expansion)); + update_values.push_back(columns[16] + " = '" + EscapeString(titles_entry.content_flags) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -215,13 +259,11 @@ public: } static Titles InsertOne( - Database& db, Titles titles_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(titles_entry.id)); insert_values.push_back(std::to_string(titles_entry.skill_id)); insert_values.push_back(std::to_string(titles_entry.min_skill_value)); insert_values.push_back(std::to_string(titles_entry.max_skill_value)); @@ -235,8 +277,11 @@ public: insert_values.push_back("'" + EscapeString(titles_entry.prefix) + "'"); insert_values.push_back("'" + EscapeString(titles_entry.suffix) + "'"); insert_values.push_back(std::to_string(titles_entry.title_set)); + insert_values.push_back(std::to_string(titles_entry.min_expansion)); + insert_values.push_back(std::to_string(titles_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(titles_entry.content_flags) + "'"); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -255,7 +300,6 @@ public: } static int InsertMany( - Database& db, std::vector titles_entries ) { @@ -264,7 +308,6 @@ public: for (auto &titles_entry: titles_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(titles_entry.id)); insert_values.push_back(std::to_string(titles_entry.skill_id)); insert_values.push_back(std::to_string(titles_entry.min_skill_value)); insert_values.push_back(std::to_string(titles_entry.max_skill_value)); @@ -278,13 +321,16 @@ public: insert_values.push_back("'" + EscapeString(titles_entry.prefix) + "'"); insert_values.push_back("'" + EscapeString(titles_entry.suffix) + "'"); insert_values.push_back(std::to_string(titles_entry.title_set)); + insert_values.push_back(std::to_string(titles_entry.min_expansion)); + insert_values.push_back(std::to_string(titles_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(titles_entry.content_flags) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -295,11 +341,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -325,6 +371,9 @@ public: entry.prefix = row[11] ? row[11] : ""; entry.suffix = row[12] ? row[12] : ""; entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; all_entries.push_back(entry); } @@ -332,11 +381,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -363,6 +412,9 @@ public: entry.prefix = row[11] ? row[11] : ""; entry.suffix = row[12] ? row[12] : ""; entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; all_entries.push_back(entry); } @@ -370,9 +422,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -383,9 +435,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_trader_repository.h b/common/repositories/base/base_trader_repository.h index 1eded1551..71bd9a83f 100644 --- a/common/repositories/base/base_trader_repository.h +++ b/common/repositories/base/base_trader_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRADER_REPOSITORY_H @@ -48,6 +65,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("trader"); @@ -67,7 +99,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -100,11 +132,10 @@ public: } static Trader FindOne( - Database& db, int trader_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -130,11 +161,10 @@ public: } static int DeleteOne( - Database& db, int trader_id ) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -147,7 +177,6 @@ public: } static int UpdateOne( - Database& db, Trader trader_entry ) { @@ -162,7 +191,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(trader_entry.item_cost)); update_values.push_back(columns[5] + " = " + std::to_string(trader_entry.slot_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -176,7 +205,6 @@ public: } static Trader InsertOne( - Database& db, Trader trader_entry ) { @@ -189,7 +217,7 @@ public: insert_values.push_back(std::to_string(trader_entry.item_cost)); insert_values.push_back(std::to_string(trader_entry.slot_id)); - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -208,7 +236,6 @@ public: } static int InsertMany( - Database& db, std::vector trader_entries ) { @@ -229,7 +256,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -240,11 +267,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -269,11 +296,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -299,9 +326,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -312,9 +339,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = database.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tradeskill_recipe_entries_repository.h b/common/repositories/base/base_tradeskill_recipe_entries_repository.h index 13c293c77..dbab250a0 100644 --- a/common/repositories/base/base_tradeskill_recipe_entries_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_entries_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H @@ -52,6 +69,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tradeskill_recipe_entries"); @@ -71,7 +103,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -106,11 +138,10 @@ public: } static TradeskillRecipeEntries FindOne( - Database& db, int tradeskill_recipe_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -138,11 +169,10 @@ public: } static int DeleteOne( - Database& db, int tradeskill_recipe_entries_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -155,7 +185,6 @@ public: } static int UpdateOne( - Database& db, TradeskillRecipeEntries tradeskill_recipe_entries_entry ) { @@ -171,7 +200,7 @@ public: update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entries_entry.salvagecount)); update_values.push_back(columns[7] + " = " + std::to_string(tradeskill_recipe_entries_entry.iscontainer)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -185,13 +214,11 @@ public: } static TradeskillRecipeEntries InsertOne( - Database& db, TradeskillRecipeEntries tradeskill_recipe_entries_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); @@ -200,7 +227,7 @@ public: insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.salvagecount)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.iscontainer)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -219,7 +246,6 @@ public: } static int InsertMany( - Database& db, std::vector tradeskill_recipe_entries_entries ) { @@ -228,7 +254,6 @@ public: for (auto &tradeskill_recipe_entries_entry: tradeskill_recipe_entries_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); @@ -242,7 +267,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +278,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -284,11 +309,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -316,9 +341,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -329,9 +354,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tradeskill_recipe_repository.h b/common/repositories/base/base_tradeskill_recipe_repository.h index 453d8b7dc..2716abbb7 100644 --- a/common/repositories/base/base_tradeskill_recipe_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H @@ -32,7 +49,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -57,7 +73,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -66,6 +81,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tradeskill_recipe"); @@ -85,7 +115,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -93,21 +123,20 @@ public: { TradeskillRecipe entry{}; - entry.id = 0; - entry.name = ""; - entry.tradeskill = 0; - entry.skillneeded = 0; - entry.trivial = 0; - entry.nofail = 0; - entry.replace_container = 0; - entry.notes = ""; - entry.must_learn = 0; - entry.quest = 0; - entry.enabled = 1; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + entry.id = 0; + entry.name = ""; + entry.tradeskill = 0; + entry.skillneeded = 0; + entry.trivial = 0; + entry.nofail = 0; + entry.replace_container = 0; + entry.notes = ""; + entry.must_learn = 0; + entry.quest = 0; + entry.enabled = 1; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -127,11 +156,10 @@ public: } static TradeskillRecipe FindOne( - Database& db, int tradeskill_recipe_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -143,21 +171,20 @@ public: if (results.RowCount() == 1) { TradeskillRecipe entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? row[13] : ""; return entry; } @@ -166,11 +193,10 @@ public: } static int DeleteOne( - Database& db, int tradeskill_recipe_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -183,7 +209,6 @@ public: } static int UpdateOne( - Database& db, TradeskillRecipe tradeskill_recipe_entry ) { @@ -204,9 +229,8 @@ public: update_values.push_back(columns[11] + " = " + std::to_string(tradeskill_recipe_entry.min_expansion)); update_values.push_back(columns[12] + " = " + std::to_string(tradeskill_recipe_entry.max_expansion)); update_values.push_back(columns[13] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); - update_values.push_back(columns[14] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -220,13 +244,11 @@ public: } static TradeskillRecipe InsertOne( - Database& db, TradeskillRecipe tradeskill_recipe_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(tradeskill_recipe_entry.id)); insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'"); insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); @@ -240,9 +262,8 @@ public: insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -261,7 +282,6 @@ public: } static int InsertMany( - Database& db, std::vector tradeskill_recipe_entries ) { @@ -270,7 +290,6 @@ public: for (auto &tradeskill_recipe_entry: tradeskill_recipe_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(tradeskill_recipe_entry.id)); insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'"); insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); @@ -284,14 +303,13 @@ public: insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -302,11 +320,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -318,21 +336,20 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { TradeskillRecipe entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? row[13] : ""; all_entries.push_back(entry); } @@ -340,11 +357,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -357,21 +374,20 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { TradeskillRecipe entry{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? row[13] : ""; all_entries.push_back(entry); } @@ -379,9 +395,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -392,9 +408,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_traps_repository.h b/common/repositories/base/base_traps_repository.h index b76072525..213de6b6d 100644 --- a/common/repositories/base/base_traps_repository.h +++ b/common/repositories/base/base_traps_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRAPS_REPOSITORY_H @@ -42,7 +59,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -77,7 +93,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", }; } @@ -86,6 +101,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("traps"); @@ -105,7 +135,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -137,7 +167,6 @@ public: entry.min_expansion = 0; entry.max_expansion = 0; entry.content_flags = ""; - entry.content_flags_disabled = ""; return entry; } @@ -157,11 +186,10 @@ public: } static Traps FindOne( - Database& db, int traps_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -197,7 +225,6 @@ public: entry.min_expansion = atoi(row[21]); entry.max_expansion = atoi(row[22]); entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; return entry; } @@ -206,11 +233,10 @@ public: } static int DeleteOne( - Database& db, int traps_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -223,7 +249,6 @@ public: } static int UpdateOne( - Database& db, Traps traps_entry ) { @@ -254,9 +279,8 @@ public: update_values.push_back(columns[21] + " = " + std::to_string(traps_entry.min_expansion)); update_values.push_back(columns[22] + " = " + std::to_string(traps_entry.max_expansion)); update_values.push_back(columns[23] + " = '" + EscapeString(traps_entry.content_flags) + "'"); - update_values.push_back(columns[24] + " = '" + EscapeString(traps_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -270,13 +294,11 @@ public: } static Traps InsertOne( - Database& db, Traps traps_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(traps_entry.id)); insert_values.push_back("'" + EscapeString(traps_entry.zone) + "'"); insert_values.push_back(std::to_string(traps_entry.version)); insert_values.push_back(std::to_string(traps_entry.x)); @@ -300,9 +322,8 @@ public: insert_values.push_back(std::to_string(traps_entry.min_expansion)); insert_values.push_back(std::to_string(traps_entry.max_expansion)); insert_values.push_back("'" + EscapeString(traps_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(traps_entry.content_flags_disabled) + "'"); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -321,7 +342,6 @@ public: } static int InsertMany( - Database& db, std::vector traps_entries ) { @@ -330,7 +350,6 @@ public: for (auto &traps_entry: traps_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(traps_entry.id)); insert_values.push_back("'" + EscapeString(traps_entry.zone) + "'"); insert_values.push_back(std::to_string(traps_entry.version)); insert_values.push_back(std::to_string(traps_entry.x)); @@ -354,14 +373,13 @@ public: insert_values.push_back(std::to_string(traps_entry.min_expansion)); insert_values.push_back(std::to_string(traps_entry.max_expansion)); insert_values.push_back("'" + EscapeString(traps_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(traps_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -372,11 +390,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -412,7 +430,6 @@ public: entry.min_expansion = atoi(row[21]); entry.max_expansion = atoi(row[22]); entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; all_entries.push_back(entry); } @@ -420,11 +437,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -461,7 +478,6 @@ public: entry.min_expansion = atoi(row[21]); entry.max_expansion = atoi(row[22]); entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; all_entries.push_back(entry); } @@ -469,9 +485,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -482,9 +498,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tribute_levels_repository.h b/common/repositories/base/base_tribute_levels_repository.h index 2e49dab99..8027b89e0 100644 --- a/common/repositories/base/base_tribute_levels_repository.h +++ b/common/repositories/base/base_tribute_levels_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRIBUTE_LEVELS_REPOSITORY_H @@ -44,6 +61,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tribute_levels"); @@ -63,7 +95,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -94,11 +126,10 @@ public: } static TributeLevels FindOne( - Database& db, int tribute_levels_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -122,11 +153,10 @@ public: } static int DeleteOne( - Database& db, int tribute_levels_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -139,7 +169,6 @@ public: } static int UpdateOne( - Database& db, TributeLevels tribute_levels_entry ) { @@ -152,7 +181,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(tribute_levels_entry.cost)); update_values.push_back(columns[3] + " = " + std::to_string(tribute_levels_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -166,7 +195,6 @@ public: } static TributeLevels InsertOne( - Database& db, TributeLevels tribute_levels_entry ) { @@ -177,7 +205,7 @@ public: insert_values.push_back(std::to_string(tribute_levels_entry.cost)); insert_values.push_back(std::to_string(tribute_levels_entry.item_id)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -196,7 +224,6 @@ public: } static int InsertMany( - Database& db, std::vector tribute_levels_entries ) { @@ -215,7 +242,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -226,11 +253,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -253,11 +280,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -281,9 +308,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -294,9 +321,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_tributes_repository.h b/common/repositories/base/base_tributes_repository.h index 1acd2f63b..d3120d9ae 100644 --- a/common/repositories/base/base_tributes_repository.h +++ b/common/repositories/base/base_tributes_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_TRIBUTES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("tributes"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static Tributes FindOne( - Database& db, int tributes_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int tributes_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, Tributes tributes_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = '" + EscapeString(tributes_entry.descr) + "'"); update_values.push_back(columns[4] + " = " + std::to_string(tributes_entry.isguild)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static Tributes InsertOne( - Database& db, Tributes tributes_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back("'" + EscapeString(tributes_entry.descr) + "'"); insert_values.push_back(std::to_string(tributes_entry.isguild)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector tributes_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_veteran_reward_templates_repository.h b/common/repositories/base/base_veteran_reward_templates_repository.h index f41c1da3c..eeade8c23 100644 --- a/common/repositories/base/base_veteran_reward_templates_repository.h +++ b/common/repositories/base/base_veteran_reward_templates_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_VETERAN_REWARD_TEMPLATES_REPOSITORY_H @@ -46,6 +63,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("veteran_reward_templates"); @@ -65,7 +97,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -97,11 +129,10 @@ public: } static VeteranRewardTemplates FindOne( - Database& db, int veteran_reward_templates_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -126,11 +157,10 @@ public: } static int DeleteOne( - Database& db, int veteran_reward_templates_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -143,7 +173,6 @@ public: } static int UpdateOne( - Database& db, VeteranRewardTemplates veteran_reward_templates_entry ) { @@ -157,7 +186,7 @@ public: update_values.push_back(columns[3] + " = " + std::to_string(veteran_reward_templates_entry.charges)); update_values.push_back(columns[4] + " = " + std::to_string(veteran_reward_templates_entry.reward_slot)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -171,7 +200,6 @@ public: } static VeteranRewardTemplates InsertOne( - Database& db, VeteranRewardTemplates veteran_reward_templates_entry ) { @@ -183,7 +211,7 @@ public: insert_values.push_back(std::to_string(veteran_reward_templates_entry.charges)); insert_values.push_back(std::to_string(veteran_reward_templates_entry.reward_slot)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -202,7 +230,6 @@ public: } static int InsertMany( - Database& db, std::vector veteran_reward_templates_entries ) { @@ -222,7 +249,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -233,11 +260,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -261,11 +288,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -290,9 +317,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -303,9 +330,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_zone_points_repository.h b/common/repositories/base/base_zone_points_repository.h index e34d9bafb..8867e37d7 100644 --- a/common/repositories/base/base_zone_points_repository.h +++ b/common/repositories/base/base_zone_points_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ZONE_POINTS_REPOSITORY_H @@ -38,10 +55,6 @@ public: int min_expansion; int max_expansion; std::string content_flags; - std::string content_flags_disabled; - int is_virtual; - int height; - int width; }; static std::string PrimaryKey() @@ -72,10 +85,6 @@ public: "min_expansion", "max_expansion", "content_flags", - "content_flags_disabled", - "is_virtual", - "height", - "width", }; } @@ -84,6 +93,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("zone_points"); @@ -103,7 +127,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -111,30 +135,26 @@ public: { ZonePoints entry{}; - entry.id = 0; - entry.zone = ""; - entry.version = 0; - entry.number = 1; - entry.y = 0; - entry.x = 0; - entry.z = 0; - entry.heading = 0; - entry.target_y = 0; - entry.target_x = 0; - entry.target_z = 0; - entry.target_heading = 0; - entry.zoneinst = 0; - entry.target_zone_id = 0; - entry.target_instance = 0; - entry.buffer = 0; - entry.client_version_mask = 4294967295; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; - entry.is_virtual = 0; - entry.height = 0; - entry.width = 0; + entry.id = 0; + entry.zone = ""; + entry.version = 0; + entry.number = 1; + entry.y = 0; + entry.x = 0; + entry.z = 0; + entry.heading = 0; + entry.target_y = 0; + entry.target_x = 0; + entry.target_z = 0; + entry.target_heading = 0; + entry.zoneinst = 0; + entry.target_zone_id = 0; + entry.target_instance = 0; + entry.buffer = 0; + entry.client_version_mask = 4294967295; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; return entry; } @@ -154,11 +174,10 @@ public: } static ZonePoints FindOne( - Database& db, int zone_points_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -170,30 +189,26 @@ public: if (results.RowCount() == 1) { ZonePoints entry{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = static_cast(atof(row[4])); + entry.x = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.target_y = static_cast(atof(row[8])); + entry.target_x = static_cast(atof(row[9])); + entry.target_z = static_cast(atof(row[10])); + entry.target_heading = static_cast(atof(row[11])); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = static_cast(atof(row[15])); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; return entry; } @@ -202,11 +217,10 @@ public: } static int DeleteOne( - Database& db, int zone_points_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -219,7 +233,6 @@ public: } static int UpdateOne( - Database& db, ZonePoints zone_points_entry ) { @@ -246,12 +259,8 @@ public: update_values.push_back(columns[17] + " = " + std::to_string(zone_points_entry.min_expansion)); update_values.push_back(columns[18] + " = " + std::to_string(zone_points_entry.max_expansion)); update_values.push_back(columns[19] + " = '" + EscapeString(zone_points_entry.content_flags) + "'"); - update_values.push_back(columns[20] + " = '" + EscapeString(zone_points_entry.content_flags_disabled) + "'"); - update_values.push_back(columns[21] + " = " + std::to_string(zone_points_entry.is_virtual)); - update_values.push_back(columns[22] + " = " + std::to_string(zone_points_entry.height)); - update_values.push_back(columns[23] + " = " + std::to_string(zone_points_entry.width)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -265,13 +274,11 @@ public: } static ZonePoints InsertOne( - Database& db, ZonePoints zone_points_entry ) { std::vector insert_values; - insert_values.push_back(std::to_string(zone_points_entry.id)); insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); insert_values.push_back(std::to_string(zone_points_entry.version)); insert_values.push_back(std::to_string(zone_points_entry.number)); @@ -291,12 +298,8 @@ public: insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.is_virtual)); - insert_values.push_back(std::to_string(zone_points_entry.height)); - insert_values.push_back(std::to_string(zone_points_entry.width)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -315,7 +318,6 @@ public: } static int InsertMany( - Database& db, std::vector zone_points_entries ) { @@ -324,7 +326,6 @@ public: for (auto &zone_points_entry: zone_points_entries) { std::vector insert_values; - insert_values.push_back(std::to_string(zone_points_entry.id)); insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); insert_values.push_back(std::to_string(zone_points_entry.version)); insert_values.push_back(std::to_string(zone_points_entry.number)); @@ -344,17 +345,13 @@ public: insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.is_virtual)); - insert_values.push_back(std::to_string(zone_points_entry.height)); - insert_values.push_back(std::to_string(zone_points_entry.width)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -365,11 +362,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -381,30 +378,26 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { ZonePoints entry{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = static_cast(atof(row[4])); + entry.x = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.target_y = static_cast(atof(row[8])); + entry.target_x = static_cast(atof(row[9])); + entry.target_z = static_cast(atof(row[10])); + entry.target_heading = static_cast(atof(row[11])); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = static_cast(atof(row[15])); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; all_entries.push_back(entry); } @@ -412,11 +405,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -429,30 +422,26 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { ZonePoints entry{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = static_cast(atof(row[4])); + entry.x = static_cast(atof(row[5])); + entry.z = static_cast(atof(row[6])); + entry.heading = static_cast(atof(row[7])); + entry.target_y = static_cast(atof(row[8])); + entry.target_x = static_cast(atof(row[9])); + entry.target_z = static_cast(atof(row[10])); + entry.target_heading = static_cast(atof(row[11])); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = static_cast(atof(row[15])); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; all_entries.push_back(entry); } @@ -460,9 +449,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -473,9 +462,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h index f31b98491..1229ca2ec 100644 --- a/common/repositories/base/base_zone_repository.h +++ b/common/repositories/base/base_zone_repository.h @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_ZONE_REPOSITORY_H @@ -104,11 +121,6 @@ public: int fast_regen_endurance; int npc_max_aggro_dist; int max_movement_update_range; - int min_expansion; - int max_expansion; - std::string content_flags; - std::string content_flags_disabled; - int underworld_teleport_index; }; static std::string PrimaryKey() @@ -205,11 +217,6 @@ public: "fast_regen_endurance", "npc_max_aggro_dist", "max_movement_update_range", - "min_expansion", - "max_expansion", - "content_flags", - "content_flags_disabled", - "underworld_teleport_index", }; } @@ -218,6 +225,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("zone"); @@ -237,7 +259,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -331,11 +353,6 @@ public: entry.fast_regen_endurance = 180; entry.npc_max_aggro_dist = 600; entry.max_movement_update_range = 600; - entry.min_expansion = 0; - entry.max_expansion = 0; - entry.content_flags = ""; - entry.content_flags_disabled = ""; - entry.underworld_teleport_index = 0; return entry; } @@ -355,11 +372,10 @@ public: } static Zone FindOne( - Database& db, int zone_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -457,11 +473,6 @@ public: entry.fast_regen_endurance = atoi(row[83]); entry.npc_max_aggro_dist = atoi(row[84]); entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); return entry; } @@ -470,11 +481,10 @@ public: } static int DeleteOne( - Database& db, int zone_id ) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -487,7 +497,6 @@ public: } static int UpdateOne( - Database& db, Zone zone_entry ) { @@ -580,13 +589,8 @@ public: update_values.push_back(columns[83] + " = " + std::to_string(zone_entry.fast_regen_endurance)); update_values.push_back(columns[84] + " = " + std::to_string(zone_entry.npc_max_aggro_dist)); update_values.push_back(columns[85] + " = " + std::to_string(zone_entry.max_movement_update_range)); - update_values.push_back(columns[86] + " = " + std::to_string(zone_entry.min_expansion)); - update_values.push_back(columns[87] + " = " + std::to_string(zone_entry.max_expansion)); - update_values.push_back(columns[88] + " = '" + EscapeString(zone_entry.content_flags) + "'"); - update_values.push_back(columns[89] + " = '" + EscapeString(zone_entry.content_flags_disabled) + "'"); - update_values.push_back(columns[90] + " = " + std::to_string(zone_entry.underworld_teleport_index)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -600,14 +604,12 @@ public: } static Zone InsertOne( - Database& db, Zone zone_entry ) { std::vector insert_values; insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.id)); insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); @@ -692,13 +694,8 @@ public: insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - insert_values.push_back(std::to_string(zone_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(zone_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -717,7 +714,6 @@ public: } static int InsertMany( - Database& db, std::vector zone_entries ) { @@ -727,7 +723,6 @@ public: std::vector insert_values; insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.id)); insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); @@ -812,18 +807,13 @@ public: insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - insert_values.push_back(std::to_string(zone_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_entry.max_expansion)); - insert_values.push_back("'" + EscapeString(zone_entry.content_flags) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } std::vector insert_values; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -834,11 +824,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All(Database& db) + static std::vector All() { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -936,11 +926,6 @@ public: entry.fast_regen_endurance = atoi(row[83]); entry.npc_max_aggro_dist = atoi(row[84]); entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); all_entries.push_back(entry); } @@ -948,11 +933,11 @@ public: return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(std::string where_filter) { std::vector all_entries; - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -1051,11 +1036,6 @@ public: entry.fast_regen_endurance = atoi(row[83]); entry.npc_max_aggro_dist = atoi(row[84]); entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); all_entries.push_back(entry); } @@ -1063,9 +1043,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -1076,9 +1056,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = content_db.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/repositories/character_expedition_lockouts_repository.h b/common/repositories/character_expedition_lockouts_repository.h deleted file mode 100644 index 006bacae1..000000000 --- a/common/repositories/character_expedition_lockouts_repository.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H -#define EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H - -#include "../database.h" -#include "../expedition_lockout_timer.h" -#include "../string_util.h" -#include "base/base_character_expedition_lockouts_repository.h" -#include - -class CharacterExpeditionLockoutsRepository: public BaseCharacterExpeditionLockoutsRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * CharacterExpeditionLockoutsRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * CharacterExpeditionLockoutsRepository::GetWhereNeverExpires() - * CharacterExpeditionLockoutsRepository::GetWhereXAndY() - * CharacterExpeditionLockoutsRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - - struct CharacterExpeditionLockoutsTimeStamp { - int id; - int character_id; - std::string expedition_name; - std::string event_name; - time_t expire_time; - int duration; - std::string from_expedition_uuid; - }; - - static ExpeditionLockoutTimer GetExpeditionLockoutTimerFromEntry( - CharacterExpeditionLockoutsTimeStamp&& entry) - { - ExpeditionLockoutTimer lockout_timer{ - std::move(entry.from_expedition_uuid), - std::move(entry.expedition_name), - std::move(entry.event_name), - static_cast(entry.expire_time), - static_cast(entry.duration) - }; - - return lockout_timer; - } - - static std::unordered_map> GetManyCharacterLockoutTimers( - Database& db, const std::vector& character_ids, - const std::string& expedition_name, const std::string& ordered_event_name) - { - auto joined_character_ids = fmt::join(character_ids, ","); - - auto results = db.QueryDatabase(fmt::format(SQL( - SELECT - character_id, - UNIX_TIMESTAMP(expire_time), - duration, - event_name, - from_expedition_uuid - FROM character_expedition_lockouts - WHERE - character_id IN ({}) - AND expire_time > NOW() - AND expedition_name = '{}' - ORDER BY - FIELD(character_id, {}), - FIELD(event_name, '{}') DESC - ), - joined_character_ids, - EscapeString(expedition_name), - joined_character_ids, - EscapeString(ordered_event_name) - )); - - std::unordered_map> lockouts; - - for (auto row = results.begin(); row != results.end(); ++row) - { - CharacterExpeditionLockoutsTimeStamp entry{}; - - int col = 0; - entry.character_id = std::strtoul(row[col++], nullptr, 10); - entry.expire_time = std::strtoull(row[col++], nullptr, 10); - entry.duration = std::strtoul(row[col++], nullptr, 10); - entry.event_name = row[col++]; - entry.expedition_name = expedition_name; - entry.from_expedition_uuid = row[col++]; - - auto lockout = GetExpeditionLockoutTimerFromEntry(std::move(entry)); - lockouts[entry.character_id].emplace_back(std::move(lockout)); - } - - return lockouts; - } -}; - -#endif //EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/damageshieldtypes_repository.h b/common/repositories/damageshieldtypes_repository.h deleted file mode 100644 index 3bb4b4fd2..000000000 --- a/common/repositories/damageshieldtypes_repository.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H -#define EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_damageshieldtypes_repository.h" - -class DamageshieldtypesRepository: public BaseDamageshieldtypesRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * DamageshieldtypesRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * DamageshieldtypesRepository::GetWhereNeverExpires() - * DamageshieldtypesRepository::GetWhereXAndY() - * DamageshieldtypesRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - -}; - -#endif //EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/dynamic_zones_repository.h b/common/repositories/dynamic_zones_repository.h deleted file mode 100644 index 27fd406ca..000000000 --- a/common/repositories/dynamic_zones_repository.h +++ /dev/null @@ -1,305 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_DYNAMIC_ZONES_REPOSITORY_H -#define EQEMU_DYNAMIC_ZONES_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_dynamic_zones_repository.h" - -class DynamicZonesRepository: public BaseDynamicZonesRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * DynamicZonesRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * DynamicZonesRepository::GetWhereNeverExpires() - * DynamicZonesRepository::GetWhereXAndY() - * DynamicZonesRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - - struct DynamicZoneInstance - { - uint32_t id; - int instance_id; - int type; - int compass_zone_id; - float compass_x; - float compass_y; - float compass_z; - int safe_return_zone_id; - float safe_return_x; - float safe_return_y; - float safe_return_z; - float safe_return_heading; - float zone_in_x; - float zone_in_y; - float zone_in_z; - float zone_in_heading; - int has_zone_in; - int zone; - int version; - int is_global; - uint32_t start_time; - int duration; - int never_expires; - }; - - static std::string SelectDynamicZoneJoinInstance() - { - return std::string(SQL( - SELECT - dynamic_zones.id, - dynamic_zones.instance_id, - dynamic_zones.type, - dynamic_zones.compass_zone_id, - dynamic_zones.compass_x, - dynamic_zones.compass_y, - dynamic_zones.compass_z, - dynamic_zones.safe_return_zone_id, - dynamic_zones.safe_return_x, - dynamic_zones.safe_return_y, - dynamic_zones.safe_return_z, - dynamic_zones.safe_return_heading, - dynamic_zones.zone_in_x, - dynamic_zones.zone_in_y, - dynamic_zones.zone_in_z, - dynamic_zones.zone_in_heading, - dynamic_zones.has_zone_in, - instance_list.zone, - instance_list.version, - instance_list.is_global, - instance_list.start_time, - instance_list.duration, - instance_list.never_expires - FROM dynamic_zones - INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id - )); - } - - static DynamicZoneInstance FillWithInstanceFromRow(MySQLRequestRow& row) - { - DynamicZoneInstance entry{}; - - int col = 0; - entry.id = strtoul(row[col++], nullptr, 10); - entry.instance_id = strtol(row[col++], nullptr, 10); - entry.type = strtol(row[col++], nullptr, 10); - entry.compass_zone_id = strtol(row[col++], nullptr, 10); - entry.compass_x = strtof(row[col++], nullptr); - entry.compass_y = strtof(row[col++], nullptr); - entry.compass_z = strtof(row[col++], nullptr); - entry.safe_return_zone_id = strtol(row[col++], nullptr, 10); - entry.safe_return_x = strtof(row[col++], nullptr); - entry.safe_return_y = strtof(row[col++], nullptr); - entry.safe_return_z = strtof(row[col++], nullptr); - entry.safe_return_heading = strtof(row[col++], nullptr); - entry.zone_in_x = strtof(row[col++], nullptr); - entry.zone_in_y = strtof(row[col++], nullptr); - entry.zone_in_z = strtof(row[col++], nullptr); - entry.zone_in_heading = strtof(row[col++], nullptr); - entry.has_zone_in = strtol(row[col++], nullptr, 10) != 0; - // from instance_list - entry.zone = strtol(row[col++], nullptr, 10); - entry.version = strtol(row[col++], nullptr, 10); - entry.is_global = strtol(row[col++], nullptr, 10); - entry.start_time = strtoul(row[col++], nullptr, 10); - entry.duration = strtol(row[col++], nullptr, 10); - entry.never_expires = strtol(row[col++], nullptr, 10); - - return entry; - } - - static std::vector GetWithInstance(Database& db, - const std::vector& dynamic_zone_ids) - { - if (dynamic_zone_ids.empty()) - { - return {}; - } - - std::vector all_entries; - - auto results = db.QueryDatabase(fmt::format( - "{} WHERE dynamic_zones.id IN ({}) ORDER BY dynamic_zones.id;", - SelectDynamicZoneJoinInstance(), - fmt::join(dynamic_zone_ids, ",") - )); - - if (results.Success()) - { - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - DynamicZoneInstance entry = FillWithInstanceFromRow(row); - all_entries.emplace_back(std::move(entry)); - } - } - - return all_entries; - } - - static void UpdateCompass(Database& db, uint32_t dz_id, int zone_id, float x, float y, float z) - { - if (dz_id != 0) - { - std::string query = fmt::format(SQL( - UPDATE {} SET - compass_zone_id = {}, - compass_x = {}, - compass_y = {}, - compass_z = {} - WHERE {} = {}; - ), TableName(), zone_id, x, y, z, PrimaryKey(), dz_id); - - db.QueryDatabase(query); - } - } - - static void UpdateSafeReturn(Database& db, uint32_t dz_id, int zone_id, float x, float y, float z, float heading) - { - if (dz_id != 0) - { - std::string query = fmt::format(SQL( - UPDATE {} SET - safe_return_zone_id = {}, - safe_return_x = {}, - safe_return_y = {}, - safe_return_z = {}, - safe_return_heading = {} - WHERE {} = {}; - ), TableName(), zone_id, x, y, z, heading, PrimaryKey(), dz_id); - - db.QueryDatabase(query); - } - } - - static void UpdateZoneIn(Database& db, uint32_t dz_id, uint32_t zone_id, float x, float y, float z, float heading, bool has_zone_in) - { - if (dz_id != 0) - { - std::string query = fmt::format(SQL( - UPDATE {} SET - zone_in_x = {}, - zone_in_y = {}, - zone_in_z = {}, - zone_in_heading = {}, - has_zone_in = {} - WHERE {} = {}; - ), TableName(), x, y, z, heading, has_zone_in, PrimaryKey(), dz_id); - - db.QueryDatabase(query); - } - } - - struct DynamicZoneInstancePlayerCount - { - uint32_t id; - int type; - int instance; - int zone; - int version; - uint32_t start_time; - int duration; - int player_count; - }; - - static std::string SelectDynamicZoneInstancePlayerCount() - { - return std::string(SQL( - SELECT - dynamic_zones.id, - dynamic_zones.type, - instance_list.id, - instance_list.zone, - instance_list.version, - instance_list.start_time, - instance_list.duration, - COUNT(instance_list_player.id) member_count - FROM dynamic_zones - INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id - LEFT JOIN instance_list_player ON instance_list.id = instance_list_player.id - GROUP BY instance_list.id - ORDER BY dynamic_zones.id; - )); - }; - - static std::vector AllDzInstancePlayerCounts(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase(SelectDynamicZoneInstancePlayerCount()); - if (results.Success()) - { - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - DynamicZoneInstancePlayerCount entry{}; - - int col = 0; - entry.id = strtoul(row[col++], nullptr, 10); - entry.type = strtol(row[col++], nullptr, 10); - entry.instance = strtol(row[col++], nullptr, 10); - entry.zone = strtol(row[col++], nullptr, 10); - entry.version = strtol(row[col++], nullptr, 10); - entry.start_time = strtoul(row[col++], nullptr, 10); - entry.duration = strtol(row[col++], nullptr, 10); - entry.player_count = strtol(row[col++], nullptr, 10); - - all_entries.emplace_back(std::move(entry)); - } - } - return all_entries; - } -}; - -#endif //EQEMU_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/expedition_lockouts_repository.h b/common/repositories/expedition_lockouts_repository.h deleted file mode 100644 index 5eab18915..000000000 --- a/common/repositories/expedition_lockouts_repository.h +++ /dev/null @@ -1,122 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H -#define EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_expedition_lockouts_repository.h" - -class ExpeditionLockoutsRepository: public BaseExpeditionLockoutsRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * ExpeditionLockoutsRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * ExpeditionLockoutsRepository::GetWhereNeverExpires() - * ExpeditionLockoutsRepository::GetWhereXAndY() - * ExpeditionLockoutsRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - - struct ExpeditionLockoutsWithTimestamp { - uint32_t id; - uint32_t expedition_id; - std::string event_name; - time_t expire_time; - int duration; - std::string from_expedition_uuid; - }; - - static std::vector GetWithTimestamp( - Database& db, const std::vector& expedition_ids) - { - if (expedition_ids.empty()) - { - return {}; - } - - std::vector all_entries; - - auto results = db.QueryDatabase(fmt::format(SQL( - SELECT - id, - expedition_id, - event_name, - UNIX_TIMESTAMP(expire_time), - duration, - from_expedition_uuid - FROM expedition_lockouts - WHERE expedition_id IN ({}) - ), - fmt::join(expedition_ids, ",") - )); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - ExpeditionLockoutsWithTimestamp entry{}; - - int col = 0; - entry.id = strtoul(row[col++], nullptr, 10); - entry.expedition_id = strtoul(row[col++], nullptr, 10); - entry.event_name = row[col++]; - entry.expire_time = strtoull(row[col++], nullptr, 10); - entry.duration = strtol(row[col++], nullptr, 10); - entry.from_expedition_uuid = row[col++]; - - all_entries.emplace_back(std::move(entry)); - } - - return all_entries; - } -}; - -#endif //EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/expedition_members_repository.h b/common/repositories/expedition_members_repository.h deleted file mode 100644 index 55b5bddd7..000000000 --- a/common/repositories/expedition_members_repository.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_EXPEDITION_MEMBERS_REPOSITORY_H -#define EQEMU_EXPEDITION_MEMBERS_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_expedition_members_repository.h" - -class ExpeditionMembersRepository: public BaseExpeditionMembersRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * ExpeditionMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * ExpeditionMembersRepository::GetWhereNeverExpires() - * ExpeditionMembersRepository::GetWhereXAndY() - * ExpeditionMembersRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - - struct MemberWithName { - uint32_t id; - uint32_t expedition_id; - uint32_t character_id; - int is_current_member; - std::string character_name; - }; - - static std::string SelectMembersWithNames() - { - return std::string(SQL( - SELECT - expedition_members.id, - expedition_members.expedition_id, - expedition_members.character_id, - expedition_members.is_current_member, - character_data.name - FROM expedition_members - INNER JOIN character_data ON expedition_members.character_id = character_data.id - )); - } - - static std::vector GetWithNames(Database& db, - const std::vector& expedition_ids) - { - if (expedition_ids.empty()) - { - return {}; - } - - std::vector all_entries; - - auto results = db.QueryDatabase(fmt::format(SQL( - {} - WHERE expedition_members.expedition_id IN ({}) - AND expedition_members.is_current_member = TRUE; - ), - SelectMembersWithNames(), - fmt::join(expedition_ids, ",") - )); - - if (results.Success()) - { - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - MemberWithName entry{}; - - int col = 0; - entry.id = strtoul(row[col++], nullptr, 10); - entry.expedition_id = strtoul(row[col++], nullptr, 10); - entry.character_id = strtoul(row[col++], nullptr, 10); - entry.is_current_member = strtoul(row[col++], nullptr, 10); - entry.character_name = row[col++]; - - all_entries.emplace_back(std::move(entry)); - } - } - - return all_entries; - } -}; - -#endif //EQEMU_EXPEDITION_MEMBERS_REPOSITORY_H diff --git a/common/repositories/expeditions_repository.h b/common/repositories/expeditions_repository.h deleted file mode 100644 index 47c821060..000000000 --- a/common/repositories/expeditions_repository.h +++ /dev/null @@ -1,219 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_EXPEDITIONS_REPOSITORY_H -#define EQEMU_EXPEDITIONS_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_expeditions_repository.h" - -class ExpeditionsRepository: public BaseExpeditionsRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * ExpeditionsRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * ExpeditionsRepository::GetWhereNeverExpires() - * ExpeditionsRepository::GetWhereXAndY() - * ExpeditionsRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - - struct ExpeditionWithLeader - { - uint32_t id; - std::string uuid; - uint32_t dynamic_zone_id; - std::string expedition_name; - uint32_t min_players; - uint32_t max_players; - int add_replay_on_join; - int is_locked; - uint32_t leader_id; - std::string leader_name; - }; - - static std::string SelectExpeditionsJoinLeader() - { - return std::string(SQL( - SELECT - expeditions.id, - expeditions.uuid, - expeditions.dynamic_zone_id, - expeditions.expedition_name, - expeditions.min_players, - expeditions.max_players, - expeditions.add_replay_on_join, - expeditions.is_locked, - expeditions.leader_id, - character_data.name leader_name - FROM expeditions - INNER JOIN character_data ON expeditions.leader_id = character_data.id - )); - } - - static ExpeditionWithLeader FillExpeditionWithLeaderFromRow(MySQLRequestRow& row) - { - ExpeditionWithLeader entry{}; - - int col = 0; - entry.id = strtoul(row[col++], nullptr, 10); - entry.uuid = row[col++]; - entry.dynamic_zone_id = strtoul(row[col++], nullptr, 10); - entry.expedition_name = row[col++]; - entry.min_players = strtoul(row[col++], nullptr, 10); - entry.max_players = strtoul(row[col++], nullptr, 10); - entry.add_replay_on_join = strtoul(row[col++], nullptr, 10); - entry.is_locked = strtoul(row[col++], nullptr, 10); - entry.leader_id = strtoul(row[col++], nullptr, 10); - entry.leader_name = row[col++]; - - return entry; - } - - static std::vector GetAllWithLeaderName(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase(fmt::format( - "{} ORDER BY expeditions.id;", - SelectExpeditionsJoinLeader() - )); - - if (results.Success()) - { - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - ExpeditionWithLeader entry = FillExpeditionWithLeaderFromRow(row); - all_entries.emplace_back(std::move(entry)); - } - } - - return all_entries; - } - - static ExpeditionWithLeader GetWithLeaderName(Database& db, uint32_t expedition_id) - { - ExpeditionWithLeader entry{}; - - auto results = db.QueryDatabase(fmt::format( - "{} WHERE expeditions.id = {};", - SelectExpeditionsJoinLeader(), - expedition_id - )); - - if (results.Success() && results.RowCount() > 0) - { - auto row = results.begin(); - entry = FillExpeditionWithLeaderFromRow(row); - } - - return entry; - } - - struct CharacterExpedition - { - uint32_t id; - std::string name; - uint32_t expedition_id; - }; - - static std::vector GetCharactersWithExpedition( - Database& db, const std::vector& character_names) - { - if (character_names.empty()) - { - return {}; - } - - std::vector entries; - - auto joined_character_names = fmt::format("'{}'", fmt::join(character_names, "','")); - - auto results = db.QueryDatabase(fmt::format(SQL( - SELECT - character_data.id, - character_data.name, - MAX(expeditions.id) - FROM character_data - LEFT JOIN expedition_members - ON character_data.id = expedition_members.character_id - AND expedition_members.is_current_member = TRUE - LEFT JOIN expeditions - ON expedition_members.expedition_id = expeditions.id - WHERE character_data.name IN ({}) - GROUP BY character_data.id - ORDER BY FIELD(character_data.name, {}) - ), - joined_character_names, - joined_character_names - )); - - if (results.Success()) - { - entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) - { - CharacterExpedition entry{}; - entry.id = std::strtoul(row[0], nullptr, 10); - entry.name = row[1]; - entry.expedition_id = row[2] ? std::strtoul(row[2], nullptr, 10) : 0; - - entries.emplace_back(std::move(entry)); - } - } - - return entries; - } -}; - -#endif //EQEMU_EXPEDITIONS_REPOSITORY_H diff --git a/common/repositories/instance_list_repository.h b/common/repositories/instance_list_repository.h index 6af82e302..312211295 100644 --- a/common/repositories/instance_list_repository.h +++ b/common/repositories/instance_list_repository.h @@ -65,15 +65,6 @@ public: // Custom extended repository methods here - static int UpdateDuration(Database& db, int instance_id, uint32_t new_duration) - { - auto results = db.QueryDatabase(fmt::format( - "UPDATE {} SET duration = {} WHERE {} = {};", - TableName(), new_duration, PrimaryKey(), instance_id - )); - - return (results.Success() ? results.RowsAffected() : 0); - } }; #endif //EQEMU_INSTANCE_LIST_REPOSITORY_H diff --git a/common/repositories/server_scheduled_events_repository.h b/common/repositories/server_scheduled_events_repository.h deleted file mode 100644 index edcc21dbc..000000000 --- a/common/repositories/server_scheduled_events_repository.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_SERVER_SCHEDULED_EVENTS_REPOSITORY_H -#define EQEMU_SERVER_SCHEDULED_EVENTS_REPOSITORY_H - -#include "../database.h" -#include "../string_util.h" -#include "base/base_server_scheduled_events_repository.h" - -class ServerScheduledEventsRepository: public BaseServerScheduledEventsRepository { -public: - - /** - * This file was auto generated and can be modified and extended upon - * - * Base repository methods are automatically - * generated in the "base" version of this repository. The base repository - * is immutable and to be left untouched, while methods in this class - * are used as extension methods for more specific persistence-layer - * accessors or mutators. - * - * Base Methods (Subject to be expanded upon in time) - * - * Note: Not all tables are designed appropriately to fit functionality with all base methods - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * ServerScheduledEventsRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * ServerScheduledEventsRepository::GetWhereNeverExpires() - * ServerScheduledEventsRepository::GetWhereXAndY() - * ServerScheduledEventsRepository::DeleteWhereXAndY() - * - * Most of the above could be covered by base methods, but if you as a developer - * find yourself re-using logic for other parts of the code, its best to just make a - * method that can be re-used easily elsewhere especially if it can use a base repository - * method and encapsulate filters there - */ - - // Custom extended repository methods here - -}; - -#endif //EQEMU_SERVER_SCHEDULED_EVENTS_REPOSITORY_H diff --git a/common/repositories/template/base_repository.template b/common/repositories/template/base_repository.template index 8b1695049..e8d3cec63 100644 --- a/common/repositories/template/base_repository.template +++ b/common/repositories/template/base_repository.template @@ -1,12 +1,29 @@ /** - * DO NOT MODIFY THIS FILE + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + */ + +/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to the repository extending the base. - * Any modifications to base repositories are to be made by the generator only - * - * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + * Any repository modifications are meant to be made to + * the repository extending the base. Any modifications to base repositories are to + * be made by the generator only */ #ifndef EQEMU_BASE_{{TABLE_NAME_UPPER}}_REPOSITORY_H @@ -38,6 +55,21 @@ public: return std::string(implode(", ", Columns())); } + static std::string InsertColumnsRaw() + { + std::vector insert_columns; + + for (auto &column : Columns()) { + if (column == PrimaryKey()) { + continue; + } + + insert_columns.push_back(column); + } + + return std::string(implode(", ", insert_columns)); + } + static std::string TableName() { return std::string("{{TABLE_NAME_VAR}}"); @@ -57,7 +89,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - ColumnsRaw() + InsertColumnsRaw() ); } @@ -85,11 +117,10 @@ public: } static {{TABLE_NAME_STRUCT}} FindOne( - Database& db, int {{TABLE_NAME_VAR}}_id ) { - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -109,11 +140,10 @@ public: } static int DeleteOne( - Database& db, int {{TABLE_NAME_VAR}}_id ) { - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -126,7 +156,6 @@ public: } static int UpdateOne( - Database& db, {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry ) { @@ -136,7 +165,7 @@ public: {{UPDATE_ONE_ENTRIES}} - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), @@ -150,7 +179,6 @@ public: } static {{TABLE_NAME_STRUCT}} InsertOne( - Database& db, {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry ) { @@ -158,7 +186,7 @@ public: {{INSERT_ONE_ENTRIES}} - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -177,7 +205,6 @@ public: } static int InsertMany( - Database& db, std::vector<{{TABLE_NAME_STRUCT}}> {{TABLE_NAME_VAR}}_entries ) { @@ -193,7 +220,7 @@ public: std::vector insert_values; - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -204,11 +231,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector<{{TABLE_NAME_STRUCT}}> All(Database& db) + static std::vector<{{TABLE_NAME_STRUCT}}> All() { std::vector<{{TABLE_NAME_STRUCT}}> all_entries; - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -228,11 +255,11 @@ public: return all_entries; } - static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(Database& db, std::string where_filter) + static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(std::string where_filter) { std::vector<{{TABLE_NAME_STRUCT}}> all_entries; - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -253,9 +280,9 @@ public: return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(std::string where_filter) { - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -266,9 +293,9 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static int Truncate(Database& db) + static int Truncate() { - auto results = db.QueryDatabase( + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( fmt::format( "TRUNCATE TABLE {}", TableName() diff --git a/common/ruletypes.h b/common/ruletypes.h index 5a30bfc2c..594bcd85e 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -36,7 +36,7 @@ RULE_CATEGORY(Character) -RULE_INT(Character, MaxLevel, 65, "Sets the highest level for players that can be reached through experience") +RULE_INT(Character, MaxLevel, 65, "Sets the highest level attainable by experience for players") RULE_BOOL(Character, PerCharacterQglobalMaxLevel, false, "Check for qglobal 'CharMaxLevel' character qglobal (Type 5, \"\"), if player tries to level beyond that point, it will not go beyond that level") RULE_BOOL(Character, PerCharacterBucketMaxLevel, false, "Check for data bucket 'CharMaxLevel', if player tries to level beyond that point, it will not go beyond that level") RULE_INT(Character, MaxExpLevel, 0, "Defines the maximum level that can be reached through experience") @@ -52,13 +52,12 @@ RULE_BOOL(Character, LeaveCorpses, true, "Setting whether you leave a corpse beh RULE_BOOL(Character, LeaveNakedCorpses, false, "Setting whether you leave a corpse without items") RULE_INT(Character, MaxDraggedCorpses, 2, "Maximum number of corpses you can drag at once") RULE_REAL(Character, DragCorpseDistance, 400, "If a player is using /corpsedrag and moving, the corpse will not move until the player exceeds this distance") -RULE_REAL(Character, FinalExpMultiplier, 1, "Added on top of everything else, easy for setting EXP events") RULE_REAL(Character, ExpMultiplier, 0.5, "If greater than 0, the experience gained is multiplied by this value. ") RULE_REAL(Character, AAExpMultiplier, 0.5, "If greater than 0, the AA experience gained is multiplied by this value. ") RULE_REAL(Character, GroupExpMultiplier, 0.5, "The experience in a group is multiplied by this value in addition to the group multiplier. The group multiplier is: 2 members=x 1.2, 3=x1.4, 4=x1.6, 5=x1.8, 6=x2.16") RULE_REAL(Character, RaidExpMultiplier, 0.2, "The experience gained in raids is multiplied by (1-RaidExpMultiplier) ") -RULE_BOOL(Character, UseXPConScaling, true, "When activated, the experience is modified depending on the difference between player level and NPC level. The values from the rules GreenModifier to RedModifier are used") -RULE_INT(Character, ShowExpValues, 0, "Show experience values. 0=normal, 1=show raw experience values, 2=show raw experience values and percent") +RULE_BOOL(Character, UseXPConScaling, true, "When activated, the experience is modified depending on the difference between player level and NPC level. The settings Green/LightBlue/Blue//White/Yellow and RedModifier are used") +RULE_INT(Character, ShowExpValues, 0, "Show expirience values. 0=normal, 1=show raw experience values, 2=show raw experience values and percent") RULE_INT(Character, GreenModifier, 20, "The experience obtained for green con mobs is multiplied by value/100") RULE_INT(Character, LightBlueModifier, 40, "The experience obtained for light-blue con mobs is multiplied by value/100") RULE_INT(Character, BlueModifier, 90, "The experience obtained for blue con mobs is multiplied by value/100") @@ -70,6 +69,7 @@ RULE_INT(Character, HPRegenMultiplier, 100, "The hitpoint regeneration is multip RULE_INT(Character, ManaRegenMultiplier, 100, "The mana regeneration is multiplied by value/100 (up to the caps)") RULE_INT(Character, EnduranceRegenMultiplier, 100, "The endurance regeneration is multiplied by value/100 (up to the caps)") RULE_BOOL(Character, OldMinMana, false, "This is used for servers that want to follow older skill cap formulas so they can still have some regen w/o mediate") +RULE_INT(Character, ConsumptionMultiplier, 100, "Item's hunger restored = value x item's food level. 100=normal, 50=player eat 2x as fast, 200=player eat 2x as slow") RULE_BOOL(Character, HealOnLevel, false, "Setting whether a player should heal completely when leveling") RULE_BOOL(Character, FeignKillsPet, false, "Setting whether Feign Death kills the player pet") RULE_INT(Character, ItemManaRegenCap, 15, "Limit on mana regeneration granted by items") @@ -79,7 +79,7 @@ RULE_INT(Character, ItemAccuracyCap, 150, "Limit on accuracy granted by items") RULE_INT(Character, ItemAvoidanceCap, 100, "Limit on avoidance granted by items") RULE_INT(Character, ItemCombatEffectsCap, 100, "Limit on combat effects granted by items") RULE_INT(Character, ItemShieldingCap, 35, "Limit on shielding granted by items") -RULE_INT(Character, ItemSpellShieldingCap, 35, "Limit on spell shielding granted by items") +RULE_INT(Character, ItemSpellShieldingCap, 35, "Limit on spell shieldung granted by items") RULE_INT(Character, ItemDoTShieldingCap, 35, "Limit on DoT shielding granted by items") RULE_INT(Character, ItemStunResistCap, 35, "Limit on resistance granted by items") RULE_INT(Character, ItemStrikethroughCap, 35, "Limit on strikethrough granted by items") @@ -90,7 +90,7 @@ RULE_INT(Character, ItemClairvoyanceCap, 250, "Limit on clairvoyance granted by RULE_INT(Character, ItemDSMitigationCap, 50, "Limit on damageshield mitigation granted by items") RULE_INT(Character, ItemEnduranceRegenCap, 15, "Limit on endurance regeneration granted by items") RULE_INT(Character, ItemExtraDmgCap, 150, "Cap for bonuses to melee skills like Bash, Frenzy, etc.") -RULE_INT(Character, HasteCap, 100, "Haste cap for non-v3(over haste) haste") +RULE_INT(Character, HasteCap, 100, "Haste cap for non-v3(overhaste) haste") RULE_INT(Character, SkillUpModifier, 100, "The probability for a skill-up is multiplied by value/100") RULE_BOOL(Character, SharedBankPlat, false, "Shared bank platinum. Off by default to prevent duplication") RULE_BOOL(Character, BindAnywhere, false, "Allows players to bind their soul anywhere in the world") @@ -111,14 +111,14 @@ RULE_INT(Character, RespawnFromHoverTimer, 300, "Respawn Window countdown timer, RULE_BOOL(Character, UseNewStatsWindow, true, "Setting whether the new Stats window, which displays all information, should be used") RULE_BOOL(Character, ItemCastsUseFocus, false, "If true, this allows item clickies to use focuses that have limited maximum levels on them") RULE_INT(Character, MinStatusForNoDropExemptions, 80, "This allows status x and higher to trade no drop items") -RULE_INT(Character, SkillCapMaxLevel, 75, "Sets the Maximum Level used for Skill Caps (from skill_caps table). -1 makes it use MaxLevel rule value. It is set to 75 because PEQ only has skill caps up to that level, and grabbing the players' skill past 75 will return 0, breaking all skills past that level. This helps servers with obsurd level caps (75+ level cap) function without any modifications") +RULE_INT(Character, SkillCapMaxLevel, 75, "Sets the Maximum Level used for Skill Caps (from skill_caps table). -1 makes it use MaxLevel rule value. It is set to 75 because PEQ only has skillcaps up to that level, and grabbing the players' skill past 75 will return 0, breaking all skills past that level. This helps servers with obsurd level caps (75+ level cap) function without any modifications") RULE_INT(Character, StatCap, 0, "If StatCap > 0 then this value is used. If it is 0, the value of the following code is used: If Level < 61: 255. If Level >= 61 and the client SoF or newer: 255 + 5 x (level -60). If the client is older than SoF and the level < 71 then: 255 + x (level-60). In all other cases: 330.") RULE_BOOL(Character, CheckCursorEmptyWhenLooting, true, "If true, a player cannot loot a corpse (player or NPC) with an item on their cursor") RULE_BOOL(Character, MaintainIntoxicationAcrossZones, true, "If true, alcohol effects are maintained across zoning and logging out/in") RULE_BOOL(Character, EnableDiscoveredItems, true, "If enabled, it enables EVENT_DISCOVER_ITEM and also saves character names and timestamps for the first time an item is discovered") RULE_BOOL(Character, EnableXTargetting, true, "Enable Extended Targeting Window, for users with UF and later clients") RULE_BOOL(Character, EnableAggroMeter, true, "Enable Aggro Meter, for users with RoF and later clients") -RULE_BOOL(Character, KeepLevelOverMax, false, "Don't de-level a character that has somehow gone over the level cap") +RULE_BOOL(Character, KeepLevelOverMax, false, "Don't delevel a character that has somehow gone over the level cap") RULE_INT(Character, FoodLossPerUpdate, 32, "How much food/water you lose per stamina update") RULE_BOOL(Character, EnableHungerPenalties, false, "Being hungry/thirsty has negative effects -- it does appear normal live servers do not have penalties") RULE_BOOL(Character, EnableFoodRequirement, true, "If disabled, food is no longer required") @@ -128,16 +128,16 @@ RULE_INT(Character, BaseRunSpeedCap, 158, "Base Run Speed Cap, on live it's 158% RULE_INT(Character, OrnamentationAugmentType, 20, "Ornamentation Augment Type") RULE_REAL(Character, EnvironmentDamageMulipliter, 1, "Multiplier for environmental damage like fall damage.") RULE_BOOL(Character, UnmemSpellsOnDeath, true, "Setting whether at death all memorized Spells are forgotten") -RULE_INT(Character, TradeskillUpAlchemy, 2, "Alchemy skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpBaking, 2, "Baking skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpBlacksmithing, 2, "Blacksmithing skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpBrewing, 3, "Brewing skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpFletching, 2, "Fletching skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpJewelcrafting, 2, "Jewelcrafting skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpMakePoison, 2, "Make Poison skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpPottery, 4, "Pottery skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpResearch, 1, "Research skillup rate adjustment. Lower is faster") -RULE_INT(Character, TradeskillUpTinkering, 2, "Tinkering skillup rate adjustment. Lower is faster") +RULE_INT(Character, TradeskillUpAlchemy, 2, "Alchemy skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpBaking, 2, "Baking skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpBlacksmithing, 2, "Blacksmithing skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpBrewing, 3, "Brewing skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpFletching, 2, "Fletching skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpJewelcrafting, 2, "Jewelcrafting skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpMakePoison, 2, "Make Poison skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpPottery, 4, "Pottery skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpResearch, 1, "Research skillup rate adjust. Lower is faster") +RULE_INT(Character, TradeskillUpTinkering, 2, "Tinkering skillup rate adjust. Lower is faster") RULE_BOOL(Character, MarqueeHPUpdates, false, "Will show health percentage in center of screen if health lesser than 100%") RULE_INT(Character, IksarCommonTongue, 95, "Starting value for Common Tongue for Iksars") RULE_INT(Character, OgreCommonTongue, 95, "Starting value for Common Tongue for Ogres") @@ -146,7 +146,7 @@ RULE_BOOL(Character, ActiveInvSnapshots, false, "Takes a periodic snapshot of in RULE_INT(Character, InvSnapshotMinIntervalM, 180, "Minimum time between inventory snapshots (minutes)") RULE_INT(Character, InvSnapshotMinRetryM, 30, "Time to re-attempt an inventory snapshot after a failure (minutes)") RULE_INT(Character, InvSnapshotHistoryD, 30, "Time to keep snapshot entries (days)") -RULE_BOOL(Character, RestrictSpellScribing, false, "Setting whether to restrict spell scribing to allowable races/classes of spell scroll") +RULE_BOOL(Character, RestrictSpellScribing, false, "Setting whether to testricts spell scribing to allowable races/classes of spell scroll") RULE_BOOL(Character, UseStackablePickPocketing, true, "Allows stackable pickpocketed items to stack instead of only being allowed in empty inventory slots") RULE_BOOL(Character, EnableAvoidanceCap, false, "Setting whether the avoidance cap should be activated") RULE_INT(Character, AvoidanceCap, 750, "750 Is a pretty good value, seen people dodge all attacks beyond 1,000 Avoidance") @@ -162,7 +162,6 @@ RULE_BOOL(Character, UseNoJunkFishing, false, "Disregards junk items when fishin RULE_BOOL(Character, SoftDeletes, true, "When characters are deleted in character select, they are only soft deleted") RULE_INT(Character, DefaultGuild, 0, "If not 0, new characters placed into the guild # indicated") RULE_BOOL(Character, ProcessFearedProximity, false, "Processes proximity checks when feared") -RULE_BOOL(Character, EnableCharacterEXPMods, false, "Enables character zone-based experience modifiers.") RULE_CATEGORY_END() RULE_CATEGORY(Mercs) @@ -176,10 +175,12 @@ RULE_INT(Mercs, AggroRadius, 100, "Determines the distance from which a merc wil RULE_INT(Mercs, AggroRadiusPuller, 25, "Determines the distance from which a merc will aggro group member's target, if they have the group role of puller (also used to determine the distance at which a healer merc will begin healing a group member, if they have the group role of puller)") RULE_INT(Mercs, ResurrectRadius, 50, "Determines the distance from which a healer merc will attempt to resurrect a group member's corpse") RULE_INT(Mercs, ScaleRate, 100, "Merc scale factor") +RULE_BOOL(Mercs, MercsUsePathing, true, "Mercs will use node pathing when moving") RULE_BOOL(Mercs, AllowMercSuspendInCombat, true, "Allow merc suspend in combat") RULE_CATEGORY_END() RULE_CATEGORY(Guild) +RULE_INT(Guild, MaxMembers, 2048, "Maximum number of members a guild can have") RULE_BOOL(Guild, PlayerCreationAllowed, false, "Allow players to create a guild using the window in Underfoot+") RULE_INT(Guild, PlayerCreationLimit, 1, "Only allow use of the UF+ window if the account has < than this number of guild leaders on it") RULE_INT(Guild, PlayerCreationRequiredStatus, 0, "Required status to create a guild") @@ -195,7 +196,7 @@ RULE_INT(Skills, MaxTrainSpecializations, 50, "Maximum level a GM trainer will t RULE_INT(Skills, SwimmingStartValue, 100, "Start value of swimming skill") RULE_BOOL(Skills, TrainSenseHeading, false, "Switch whether SenseHeading is trained by use") RULE_INT(Skills, SenseHeadingStartValue, 200, "Start value of sense heading skill") -RULE_BOOL(Skills, SelfLanguageLearning, true, "Enabling self-learning of languages") +RULE_BOOL(Skills, SelfLanguageLearning, true, "Enabling self learning of languages") RULE_BOOL(Skills, RequireTomeHandin, false, "Disable click-to-learn and force hand in to Guild Master") RULE_CATEGORY_END() @@ -210,7 +211,6 @@ RULE_CATEGORY(GM) RULE_INT(GM, MinStatusToSummonItem, 250, "Minimum required status to summon items") RULE_INT(GM, MinStatusToZoneAnywhere, 250, "Minimum required status to zone anywhere") RULE_INT(GM, MinStatusToLevelTarget, 100, "Minimum required status to set the level of a player") -RULE_INT(GM, MinStatusToBypassLockedServer, 100, "Players >= this status can log in to the server even when it is locked") RULE_CATEGORY_END() RULE_CATEGORY(World) @@ -229,6 +229,7 @@ RULE_INT(World, AddMaxClientsStatus, -1, "Accounts with status >= this rule will RULE_BOOL(World, MaxClientsSetByStatus, false, "If true, IP Limiting will be set to the status on the account as long as the status is > MaxClientsPerIP") RULE_BOOL(World, EnableIPExemptions, false, "If true, ip_exemptions table is used, if there is no entry for the IP it will default to RuleI(World, MaxClientsPerIP)") RULE_BOOL(World, ClearTempMerchantlist, true, "Clears temp merchant items when world boots") +RULE_BOOL(World, DeleteStaleCorpeBackups, true, "Deletes stale corpse backups older than 2 weeks") RULE_BOOL(World, GMAccountIPList, false, "Check IP list against GM accounts. This increases the security of GM accounts, e.g. if you only allow localhost '127.0.0.1' for GM accounts. Think carefully about what you enter!") RULE_INT(World, MinGMAntiHackStatus, 1, "Minimum status to check against AntiHack list") RULE_INT(World, SoFStartZoneID, -1, "Sets the Starting Zone for SoF Clients separate from Titanium Clients (-1 is disabled)") @@ -240,16 +241,26 @@ RULE_INT(World, PVPMinLevel, 0, "Minimum level to pvp") RULE_BOOL (World, IsGMPetitionWindowEnabled, false, "Setting whether the GM petition window is available") RULE_INT (World, FVNoDropFlag, 0, "Sets the Firiona Vie settings on the client, allowing trading of no-drop items. 1=for all players, 2=for GM only") RULE_BOOL (World, IPLimitDisconnectAll, false, "Disconnect all current clients by IP if they go over the IP limit. This should allow people to quickly reconnect in the case of dead sessions waiting to timeout") +RULE_BOOL(World, MaxClientsSimplifiedLogic, false, "New logic that only uses ExemptMaxClientsStatus and MaxClientsPerIP. Done on the loginserver. This mimics the P99-style special IP rules") RULE_INT (World, TellQueueSize, 20, "Maximum tell queue size") RULE_BOOL(World, StartZoneSameAsBindOnCreation, true, "Should the start zone always be the same location as your bind?") RULE_BOOL(World, EnforceCharacterLimitAtLogin, false, "Enforce the limit for characters that are online at login") -RULE_BOOL(World, EnableDevTools, true, "Enable or Disable the Developer Tools globally (Most of the time you want this enabled)") RULE_CATEGORY_END() RULE_CATEGORY(Zone) RULE_INT(Zone, ClientLinkdeadMS, 90000, "The time a client remains link dead on the server after a sudden disconnection (milliseconds)") RULE_INT(Zone, GraveyardTimeMS, 1200000, "Time until a player corpse is moved to a zone's graveyard, if one is specified for the zone (milliseconds)") RULE_BOOL(Zone, EnableShadowrest, 1, "Enables or disables the Shadowrest zone feature for player corpses. Default is turned on") +RULE_BOOL(Zone, UsePlayerCorpseBackups, true, "Keeps backups of player corpses") +RULE_INT(Zone, MQWarpExemptStatus, -1, "Required status level to exempt the MQWarpDetector. Set to -1 to disable this feature") +RULE_INT(Zone, MQZoneExemptStatus, -1, "Required status level to exempt the MQZoneDetector. Set to -1 to disable this feature") +RULE_INT(Zone, MQGateExemptStatus, -1, "Required status level to exempt the MQGateDetector. Set to -1 to disable this feature") +RULE_INT(Zone, MQGhostExemptStatus, -1, "Required status level to exempt the MGhostDetector. Set to -1 to disable this feature") +RULE_BOOL(Zone, EnableMQWarpDetector, true, "Enable the MQWarp Detector. Set to False to disable this feature") +RULE_BOOL(Zone, EnableMQZoneDetector, true, "Enable the MQZone Detector. Set to False to disable this feature") +RULE_BOOL(Zone, EnableMQGateDetector, true, "Enable the MQGate Detector. Set to False to disable this feature") +RULE_BOOL(Zone, EnableMQGhostDetector, true, "Enable the MQGhost Detector. Set to False to disable this feature") +RULE_REAL(Zone, MQWarpDetectionDistanceFactor, 9.0, "Distance factor for MQ-Warp detection. Clients move at 4.4 about if in a straight line but with movement and to acct for lag we raise it a bit") RULE_INT(Zone, AutoShutdownDelay, 5000, "How long a dynamic zone stays loaded while empty (milliseconds)") RULE_INT(Zone, PEQZoneReuseTime, 900, "Time between two uses of the #peqzone command (seconds)") RULE_INT(Zone, PEQZoneDebuff1, 4454, "First debuff casted by #peqzone Default is Cursed Keeper's Blight") @@ -279,6 +290,7 @@ RULE_INT(Map, FindBestZHeightAdjust, 1, "Adds this to the current Z before seeki RULE_CATEGORY_END() RULE_CATEGORY(Pathing) +RULE_BOOL(Pathing, Guard, true, "Enable pathing for mobs moving to their guard point") RULE_BOOL(Pathing, Find, true, "Enable pathing for FindPerson requests from the client") RULE_BOOL(Pathing, Fear, true, "Enable pathing for fear") RULE_REAL(Pathing, NavmeshStepSize, 100.0f, "Step size for the movement manager") @@ -288,6 +300,9 @@ RULE_CATEGORY_END() RULE_CATEGORY(Watermap) // enable these to use the water detection code. Requires Water Maps generated by awater utility +RULE_BOOL(Watermap, CheckWaypointsInWaterWhenLoading, false, "Does not apply BestZ as waypoints are loaded if they are in water") +RULE_BOOL(Watermap, CheckForWaterAtWaypoints, false, "Check if a mob has moved into/out of water when at waypoints and sets flymode") +RULE_BOOL(Watermap, CheckForWaterWhenMoving, false, "Checks if a mob has moved into/out of water each time it's loc is recalculated") RULE_BOOL(Watermap, CheckForWaterOnSendTo, false, "Checks if a mob has moved into/out of water on SendTo") RULE_BOOL(Watermap, CheckForWaterWhenFishing, false, "Only lets a player fish near water (if a water map exists for the zone)") RULE_REAL(Watermap, FishingRodLength, 30, "How far in front of player water must be for fishing to work") @@ -296,11 +311,16 @@ RULE_REAL(Watermap, FishingLineStepSize, 1, "Basic step size for fishing calc, t RULE_CATEGORY_END() RULE_CATEGORY(Spells) +RULE_REAL(Spells, ResistChance, 2.0, "chance to resist given no resists and same level") +RULE_REAL(Spells, ResistMod, 0.40, "Multiplier, chance to resist = this * ResistAmount") +RULE_REAL(Spells, PartialHitChance, 0.7, "The chance when a spell is resisted that it will partial hit") +RULE_REAL(Spells, PartialHitChanceFear, 0.25, "The chance when a fear spell is resisted that it will partial hit") RULE_INT(Spells, BaseCritChance, 0, "Base percentage chance that everyone has to crit a spell") RULE_INT(Spells, BaseCritRatio, 100, "Base percentage bonus to damage on a successful spell crit. 100=2xdamage") RULE_INT(Spells, WizCritLevel, 12, "Level wizards first get spell crits") RULE_INT(Spells, WizCritChance, 7, "Wizards crit chance, on top of BaseCritChance") RULE_INT(Spells, WizCritRatio, 0, "Wizards crit bonus, on top of BaseCritRatio (should be 0 for Live-like)") +RULE_INT(Spells, ResistPerLevelDiff, 85, "Resist per level difference. 85=8.5") RULE_INT(Spells, TranslocateTimeLimit, 0, "If not zero, time in seconds to accept a Translocate") RULE_INT(Spells, SacrificeMinLevel, 46, "First level the spell Sacrifice will work on") RULE_INT(Spells, SacrificeMaxLevel, 69, "Last level the spell Sacrifice will work on") @@ -318,7 +338,7 @@ RULE_BOOL(Spells, ReflectMessagesClose, true, "True (Live functionality) is for RULE_INT(Spells, VirusSpreadDistance, 30, "The distance a viral spell will jump to its next victim") RULE_BOOL(Spells, LiveLikeFocusEffects, true, "Determines whether specific healing, dmg and mana reduction focuses are randomized") RULE_INT(Spells, BaseImmunityLevel, 55, "The level that targets start to be immune to stun, fear and mez spells with a maximum level of 0") -RULE_BOOL(Spells, NPCIgnoreBaseImmunity, true, "Whether or not NPC get to ignore the BaseImmunityLevel for their spells") +RULE_BOOL(Spells, NPCIgnoreBaseImmunity, true, "Whether or not NPCget to ignore the BaseImmunityLevel for their spells") RULE_REAL(Spells, AvgSpellProcsPerMinute, 6.0, "Adjust rate for sympathetic spell procs") RULE_INT(Spells, ResistFalloff, 67, "Maximum that level that will adjust our resist chance based on level modifiers") RULE_INT(Spells, CharismaEffectiveness, 10, "Determines how much resist modification charisma applies to charm/pacify checks. Default 10 CHA = -1 resist mod") @@ -368,20 +388,20 @@ RULE_BOOL(Spells, AllowItemTGB, false, "Target group buff (/tgb) doesn't work wi RULE_BOOL(Spells, NPCInnateProcOverride, true, "NPC innate procs override the target type to single target") RULE_BOOL(Spells, OldRainTargets, false, "Use old incorrectly implemented maximum targets for rains") RULE_BOOL(Spells, NPCSpellPush, false, "Enable spell push on NPCs") -RULE_BOOL(Spells, July242002PetResists, true, "Enable Pets using PCs resist change from July 24 2002") RULE_CATEGORY_END() RULE_CATEGORY(Combat) -RULE_REAL(Combat, AERampageSafeZone, 0.018, "max hit ae ramp reduction range") RULE_INT(Combat, PetBaseCritChance, 0, "Pet base crit chance") RULE_INT(Combat, NPCBashKickLevel, 6, "The level that NPCcan KICK/BASH") +RULE_INT(Combat, NPCBashKickStunChance, 15, "Percent chance that a bash/kick will stun") RULE_INT(Combat, MeleeCritDifficulty, 8900, "Value against which is rolled to check if a melee crit is triggered. Lower is easier") -RULE_INT(Combat, ArcheryCritDifficulty, 3400, "Value against which is rolled to check if an archery crit is triggered. Lower is easier") +RULE_INT(Combat, ArcheryCritDifficulty, 3400, "Value against which is rolled to check if a archery crit is triggered. Lower is easier") RULE_INT(Combat, ThrowingCritDifficulty, 1100, "Value against which is rolled to check if a throwing crit is triggered. Lower is easier") RULE_BOOL(Combat, NPCCanCrit, false, "Setting whether an NPC can land critical hits") RULE_BOOL(Combat, UseIntervalAC, true, "Switch whether bonuses, armour class, multipliers, classes and caps should be considered in the calculation of damage values") RULE_INT(Combat, PetAttackMagicLevel, 30, "Level at which pets can cause magic damage") RULE_BOOL(Combat, EnableFearPathing, true, "Setting whether to use pathing during fear") +RULE_REAL(Combat, FleeMultiplier, 2.0, "Determines how quickly a NPC will slow down while fleeing. Decrease multiplier to slow NPC down quicker") RULE_BOOL(Combat, FleeGray, true, "If true FleeGrayHPRatio will be used") RULE_INT(Combat, FleeGrayHPRatio, 50, "HP percentage when a Gray NPC begins to flee") RULE_INT(Combat, FleeGrayMaxLevel, 18, "NPC above this level won't do gray/green con flee") @@ -392,7 +412,9 @@ RULE_REAL(Combat, AvgProcsPerMinute, 2.0, "Average proc rate per minute") RULE_REAL(Combat, ProcPerMinDexContrib, 0.075, "Increases the probability of a proc increased by DEX by the value indicated") RULE_REAL(Combat, BaseProcChance, 0.035, "Base chance for procs") RULE_REAL(Combat, ProcDexDivideBy, 11000, "Divisor for the probability of a proc increased by dexterity") -RULE_REAL(Combat, BaseHitChance, 69.0, "Base chance to hit") +RULE_BOOL(Combat, AdjustSpecialProcPerMinute, true, "Set PPM for special abilities like HeadShot (Live does this as of 4-14)") +RULE_REAL(Combat, AvgSpecialProcsPerMinute, 2.0, "Unclear what best value is atm") +RULE_REAL(Combat, BaseHitChance, 69.0, "Base chance to hiz") RULE_REAL(Combat, NPCBonusHitChance, 26.0, "Bonus chance to hit for NPC") RULE_REAL(Combat, HitFalloffMinor, 5.0, "Hit will fall off up to value over the initial level range (percent)") RULE_REAL(Combat, HitFalloffModerate, 7.0, "Hit will fall off up to value over the three levels after the initial level range (percent)") @@ -405,12 +427,22 @@ RULE_REAL(Combat, MinChancetoHit, 5.0, "Minimum percentage chance to hit with re RULE_REAL(Combat, MaxChancetoHit, 95.0, "Maximum percentage chance to hit with regular melee/ranged") RULE_INT(Combat, MinRangedAttackDist, 25, "Minimum Distance to use Ranged Attacks") RULE_BOOL(Combat, ArcheryBonusRequiresStationary, true, "does the 2x archery bonus chance require a stationary npc") +RULE_REAL(Combat, ArcheryBaseDamageBonus, 1, "Percentage modifier to base archery Damage 0.5=50% base damage, 1=100%,2=200%") RULE_REAL(Combat, ArcheryNPCMultiplier, 1.0, "Value is multiplied by the regular dmg to get the archery dmg") RULE_BOOL(Combat, AssistNoTargetSelf, true, "When assisting a target that does not have a target: true = target self, false = leave target as was before assist (false = live like)") RULE_INT(Combat, MaxRampageTargets, 3, "Maximum number of people hit with rampage") RULE_INT(Combat, DefaultRampageTargets, 1, "Default number of people to hit with rampage") RULE_BOOL(Combat, RampageHitsTarget, false, "Rampage will hit the target if it still has targets left") RULE_INT(Combat, MaxFlurryHits, 2, "Maximum number of extra hits from flurry") +RULE_INT(Combat, MonkDamageTableBonus, 5, "Percentage bonus monks get to their damage table calcs") +RULE_INT(Combat, FlyingKickBonus, 25, "Percentage Modifier that this skill gets to str and skill bonuses") +RULE_INT(Combat, DragonPunchBonus, 20, "Percentage Modifier that this skill gets to str and skill bonuses") +RULE_INT(Combat, EagleStrikeBonus, 15, "Percentage Modifier that this skill gets to str and skill bonuses") +RULE_INT(Combat, TigerClawBonus, 10, "Percentage Modifier that this skill gets to str and skill bonuses") +RULE_INT(Combat, RoundKickBonus, 5, "Percentage Modifier that this skill gets to str and skill bonuses") +RULE_INT(Combat, FrenzyBonus, 0, "Percentage Modifier to damage") +RULE_INT(Combat, BackstabBonus, 0, "Percentage Modifier to damage") +RULE_BOOL(Combat, ProcTargetOnly, true, "true = procs will only affect our target, false = procs will affect all of our targets") RULE_REAL(Combat, NPCACFactor, 2.25, "If UseIntervalAC is enabled, the armor class for NPC is divided by this value") RULE_INT(Combat, ClothACSoftcap, 75, "If OldACSoftcapRules is true: armorclass softcap for cloth armor") RULE_INT(Combat, LeatherACSoftcap, 100, "If OldACSoftcapRules is true: armorclass softcap for leather armor") @@ -445,26 +477,26 @@ RULE_BOOL (Combat,TauntOverLevel, 1, "Allows you to taunt NPC's over warriors le RULE_REAL (Combat,TauntSkillFalloff, 0.33, "For every taunt skill point that's not maxed you lose this percentage chance to taunt") RULE_BOOL (Combat,EXPFromDmgShield, false, "Determine if damage from a damage shield counts for experience gain") RULE_INT(Combat, MonkACBonusWeight, 15, "Usually, a monk under this weight threshold gets an AC bonus") +RULE_INT(Combat, ClientStunLevel, 55, "This is the level where client kicks and bashes can stun the target") RULE_INT(Combat, QuiverHasteCap, 1000, "Quiver haste cap 1000 on live for a while, currently 700 on live") +RULE_BOOL(Combat, UseArcheryBonusRoll, false, "Make the 51+ archery bonus require an actual roll") +RULE_INT(Combat, ArcheryBonusChance, 50, "Chance for 50+ archery bonus damage if Combat:UseArcheryBonusRoll is true") RULE_INT(Combat, BerserkerFrenzyStart, 35, "Percentage Health Points below which Warrior and Berserker start frenzy") RULE_INT(Combat, BerserkerFrenzyEnd, 45, "Percentage Health Points above which Warrior and Berserker end frenzy") RULE_BOOL(Combat, OneProcPerWeapon, true, "If enabled, One proc per weapon per round") -RULE_BOOL(Combat, ProjectileDmgOnImpact, true, "If enabled, projectiles (i.e. arrows) will hit on impact, instead of instantly") -RULE_BOOL(Combat, MeleePush, true, "Enable melee push") +RULE_BOOL(Combat, ProjectileDmgOnImpact, true, "If enabled, projectiles (ie arrows) will hit on impact, instead of instantly") +RULE_BOOL(Combat, MeleePush, true, "Eenable melee push") RULE_INT(Combat, MeleePushChance, 50, "NPC chance the target will be pushed. Made up, 100 actually isn't that bad") RULE_BOOL(Combat, UseLiveCombatRounds, true, "Turn this false if you don't want to worry about fixing up combat rounds for NPCs") -RULE_INT(Combat, NPCAssistCap, 5, "Maximum number of NPC that will assist another NPC at once") +RULE_INT(Combat, NPCAssistCap, 5, "Maxiumium number of NPCthat will assist another NPC at once") RULE_INT(Combat, NPCAssistCapTimer, 6000, "Time a NPC will take to clear assist aggro cap space (milliseconds)") RULE_BOOL(Combat, UseRevampHandToHand, false, "Use h2h revamped dmg/delays I believe this was implemented during SoF") -RULE_BOOL(Combat, ClassicMasterWu, false, "Classic Master Wu uses a random special, modern doesn't") -RULE_REAL(Combat, HitBoxMod, 1.00, "Added to test hit boxes.") +RULE_BOOL(Combat, ClassicMasterWu, false, "Classic master wu uses a random special, modern doesn't") RULE_INT(Combat, LevelToStopDamageCaps, 0, "Level to stop damage caps. 1 will effectively disable them, 20 should give basically same results as old incorrect system") RULE_INT(Combat, LevelToStopACTwinkControl, 50, "Level to stop armorclass twink control. 1 will effectively disable it, 50 should give basically same results as current system") -RULE_BOOL(Combat, ClassicNPCBackstab, false, "True disables NPC facestab - NPC get normal attack if not behind") +RULE_BOOL(Combat, ClassicNPCBackstab, false, "True disables npc facestab - NPCget normal attack if not behind") RULE_BOOL(Combat, UseNPCDamageClassLevelMods, true, "Uses GetClassLevelDamageMod calc in npc_scale_manager") RULE_BOOL(Combat, UseExtendedPoisonProcs, false, "Allow old school poisons to last until characrer zones, at a lower proc rate") -RULE_BOOL(Combat, EnableSneakPull, false, "Enable implementation of Sneak Pull") -RULE_INT(Combat, SneakPullAssistRange, 400, "Modified range of assist for sneak pull") RULE_CATEGORY_END() RULE_CATEGORY(NPC) @@ -473,7 +505,7 @@ RULE_INT(NPC, MajorNPCCorpseDecayTimeMS, 1500000, "NPC corpse decay time, if NPC RULE_INT(NPC, CorpseUnlockTimer, 150000, "Time after which corpses are unlocked for everyone to loot (milliseconds)") RULE_INT(NPC, EmptyNPCCorpseDecayTimeMS, 0, "NPC corpse decay time, if no items are left on the corpse (milliseconds)") RULE_BOOL(NPC, UseItemBonusesForNonPets, true, "Switch whether item bonuses should be used for NPCs who are not pets") -RULE_BOOL(NPC, UseBaneDamage, false, "If NPCs can't inherently hit the target we don't add bane/magic dmg which isn't exactly the same as PCs") +RULE_BOOL(NPC, UseBaneDamage, false, "If NPCs can't inheriently hit the target we don't add bane/magic dmg which isn't exactly the same as PCs") RULE_INT(NPC, SayPauseTimeInSec, 5, "Time span in which an NPC pauses his movement after a Say event without aggro (seconds)") RULE_INT(NPC, OOCRegen, 0, "Enable out-of-combat regeneration for NPC") RULE_BOOL(NPC, BuffFriends, false, "Setting whether NPC should buff other NPC") @@ -481,30 +513,30 @@ RULE_BOOL(NPC, EnableNPCQuestJournal, false, "Setting whether the NPC Quest Jour RULE_INT(NPC, LastFightingDelayMovingMin, 10000, "Minimum time before mob goes home after all aggro loss (milliseconds)") RULE_INT(NPC, LastFightingDelayMovingMax, 20000, "Maximum time before mob goes home after all aggro loss (milliseconds)") RULE_BOOL(NPC, SmartLastFightingDelayMoving, true, "When true, mobs that started going home previously will do so again immediately if still on FD hate list") -RULE_BOOL(NPC, ReturnNonQuestNoDropItems, false, "Returns NO DROP items on NPC that don't have an EVENT_TRADE sub in their script") +RULE_BOOL(NPC, ReturnNonQuestNoDropItems, false, "Returns NO DROP items on NPCthat don't have an EVENT_TRADE sub in their script") RULE_INT(NPC, StartEnrageValue, 9, " Percentage HP that an NPC will begin to enrage") RULE_BOOL(NPC, LiveLikeEnrage, false, "If set to true then only player controlled pets will enrage") -RULE_BOOL(NPC, EnableMeritBasedFaction, false, "If set to true, faction will be given in the same way as experience (solo/group/raid)") +RULE_BOOL(NPC, EnableMeritBasedFaction, false, "If set to true, faction will given in the same way as experience (solo/group/raid)") RULE_INT(NPC, NPCToNPCAggroTimerMin, 500, "Minimum time span after which one NPC aggro another NPC (milliseconds)") RULE_INT(NPC, NPCToNPCAggroTimerMax, 6000, "Maximum time span after which one NPC aggro another NPC (milliseconds)") -RULE_BOOL(NPC, UseClassAsLastName, true, "Uses class archetype as LastName for NPC with none") +RULE_BOOL(NPC, UseClassAsLastName, true, "Uses class archetype as LastName for NPCwith none") RULE_BOOL(NPC, NewLevelScaling, true, "Better level scaling, use old if new formulas would break your server") RULE_INT(NPC, NPCGatePercent, 20, " Percentage at which the NPC Will attempt to gate at") RULE_BOOL(NPC, NPCGateNearBind, false, "Will NPC attempt to gate when near bind location?") RULE_INT(NPC, NPCGateDistanceBind, 75, "Distance from bind before NPC will attempt to gate") RULE_BOOL(NPC, NPCHealOnGate, true, "Will the NPC Heal on Gate") RULE_BOOL(NPC, UseMeditateBasedManaRegen, false, "Based NPC ooc regen on Meditate skill") -RULE_REAL(NPC, NPCHealOnGateAmount, 25, "How much the NPC will heal on gate if enabled") -RULE_BOOL(NPC, AnimalsOpenDoors, true, "Determines or not whether animals open doors or not when they approach them") +RULE_REAL(NPC, NPCHealOnGateAmount, 25, "How much the npc will heal on gate if enabled") RULE_CATEGORY_END() RULE_CATEGORY(Aggro) RULE_BOOL(Aggro, SmartAggroList, true, "Smart aggro list attempts to choose targets in a much smarter fashion, prefering players to pets, sitting and critically injured players to normal players, and players in melee range to players not") RULE_INT(Aggro, SittingAggroMod, 35, "Aggro increase against sitting targets. 35=35%") RULE_INT(Aggro, MeleeRangeAggroMod, 10, "Aggro increase against targets in melee range. 10=10%") -RULE_INT(Aggro, CurrentTargetAggroMod, 0, "Aggro increase against current target. 0% = prefer the current target to any other. Makes it harder for our NPC to switch targets") +RULE_INT(Aggro, CurrentTargetAggroMod, 0, "Aggro increase against current target. 0% = prefer the current target to any other. Makes it harder for our NPCto switch targets") RULE_INT(Aggro, CriticallyWoundedAggroMod, 100, "Aggro increase against critical wounded targets") RULE_INT(Aggro, SpellAggroMod, 100, "Aggro increase for spells") +RULE_INT(Aggro, SongAggroMod, 33, "Aggro increase for songs") RULE_INT(Aggro, PetSpellAggroMod, 10, "Aggro increase for pet spells") RULE_REAL(Aggro, TunnelVisionAggroMod, 0.75, "People not currently the top hate generate this much hate on a Tunnel Vision mob") RULE_INT(Aggro, MaxScalingProcAggro, 400, "Set to -1 for no limit. Maximum amount of aggro that HP scaling SPA effect in a proc will add") @@ -512,8 +544,7 @@ RULE_INT(Aggro, IntAggroThreshold, 75, "Int lesser or equal the value will aggro RULE_BOOL(Aggro, AllowTickPulling, false, "tick pulling is an exploit in an NPC's call for help fixed sometime in 2006 on live") RULE_INT(Aggro, MinAggroLevel, 18, "Minimum level for use with UseLevelAggro") RULE_BOOL(Aggro, UseLevelAggro, true, "MinAggroLevel rule value+ and Undead will aggro regardless of level difference. This will disabled Rule:IntAggroThreshold if set to true") -RULE_INT(Aggro, ClientAggroCheckMovingInterval, 1000, "Interval in which clients actually check for aggro while moving - in milliseconds - this should be lower than ClientAggroCheckIdleInterval") -RULE_INT(Aggro, ClientAggroCheckIdleInterval, 6000, "Interval in which clients actually check for aggro while idle - in milliseconds - this should be higher than ClientAggroCheckMovingInterval") +RULE_INT(Aggro, ClientAggroCheckInterval, 6, "Interval in which clients actually check for aggro - in seconds") RULE_REAL(Aggro, PetAttackRange, 40000.0, "Maximum squared range /pet attack works at default is 200") RULE_BOOL(Aggro, NPCAggroMaxDistanceEnabled, true, "If enabled, NPC's will drop aggro beyond 600 units or what is defined at the zone level") RULE_CATEGORY_END() @@ -536,6 +567,7 @@ RULE_INT(Range, SpellParticles, 135, "The packet range in which spell particles RULE_INT(Range, DamageMessages, 50, "The packet range in which damage messages are sent (non-crit)") RULE_INT(Range, SpellMessages, 75, "The packet range in which spell damage messages are sent") RULE_INT(Range, SongMessages, 75, "The packet range in which song messages are sent") +RULE_INT(Range, MobPositionUpdates, 600, "The packet range in which mob position updates are sent") RULE_INT(Range, ClientPositionUpdates, 300, "Distance in which the own changed position is communicated to other clients") RULE_INT(Range, CriticalDamage, 80, "The packet range in which critical hit messages are sent") RULE_INT(Range, MobCloseScanDistance, 600, "Close scan distance") @@ -555,9 +587,14 @@ RULE_INT(Bots, HealRotationMaxTargets, 12, "Maximum number of heal rotation targ RULE_REAL(Bots, ManaRegen, 2.0, "Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players") RULE_BOOL(Bots, PreferNoManaCommandSpells, true, "Give sorting priority to newer no-mana spells (i.e., 'Bind Affinity')") RULE_BOOL(Bots, QuestableSpawnLimit, false, "Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl") +RULE_BOOL(Bots, QuestableSpells, false, "Anita Thrall's (Anita_Thrall.pl) Bot Spell Scriber quests") RULE_INT(Bots, SpawnLimit, 71, "Number of bots a character can have spawned at one time, You + 71 bots is a 12 group pseudo-raid") +RULE_BOOL(Bots, UpdatePositionWithTimer, false, "Sends a position update with every positive movement timer check") +RULE_BOOL(Bots, UsePathing, true, "Bots will use node pathing when moving") RULE_BOOL(Bots, BotGroupXP, false, "Determines whether client gets experience for bots outside their group") +RULE_BOOL(Bots, BotBardUseOutOfCombatSongs, true, "Determines whether bard bots use additional out of combat songs (optional script)") RULE_BOOL(Bots, BotLevelsWithOwner, false, "Auto-updates spawned bots as owner levels/de-levels (false is original behavior)") +RULE_BOOL(Bots, BotCharacterLevelEnabled, false, "Enables required level to spawn bots") RULE_INT(Bots, BotCharacterLevel, 0, "If level is greater that value player can spawn bots if BotCharacterLevelEnabled is true") RULE_INT(Bots, CasterStopMeleeLevel, 13, "Level at which caster bots stop melee attacks") RULE_INT(Bots, AllowedClasses, 0xFFFFFFFF, "Bitmask of allowed bot classes") @@ -579,7 +616,7 @@ RULE_BOOL(Chat, EnableVoiceMacros, true, "Enable voice macros") RULE_BOOL(Chat, EnableMailKeyIPVerification, true, "Setting whether the authenticity of the client should be verified via its IP address when accessing the InGame mailbox") RULE_BOOL(Chat, EnableAntiSpam, true, "Enable anti-spam system for chat") RULE_BOOL(Chat, SuppressCommandErrors, false, "Do not suppress command errors by default") -RULE_INT(Chat, MinStatusToBypassAntiSpam, 100, "Minimum status to bypass the anti-spam system") +RULE_INT(Chat, MinStatusToBypassAntiSpam, 100, "Minimum status to bypass the anti spam system") RULE_INT(Chat, MinimumMessagesPerInterval, 4, "Minimum number of chat messages allowed per interval. The karma value is added to this value") RULE_INT(Chat, MaximumMessagesPerInterval, 12, "Maximum value of chat messages allowed per interval") RULE_INT(Chat, MaxMessagesBeforeKick, 20, "If an attempt is made to send more than the maximum allowed number of chat messages per interval, the client will be disconnected after this absolute number of messages") @@ -637,10 +674,12 @@ RULE_INT(Adventure, ItemIDToEnablePorts, 41000, "ItemID to enable adventure port RULE_INT(Adventure, LDoNTrapDistanceUse, 625, "LDoN trap distance use") RULE_REAL(Adventure, LDoNBaseTrapDifficulty, 15.0, "LDoN base trap difficulty") RULE_REAL(Adventure, LDoNCriticalFailTrapThreshold, 10.0, "LDoN critical fail trap threshold") +RULE_INT(Adventure, LDoNAdventureExpireTime, 1800, "LDoN adventure expire time (seconds)") RULE_CATEGORY_END() RULE_CATEGORY(AA) RULE_INT(AA, ExpPerPoint, 23976503, "Amount of experience per AA. Is the same as the amount of experience to go from level 51 to level 52") +RULE_BOOL(AA, Stacking, true, "Allow AA that belong to the same group to stack on SOF+ clients") RULE_BOOL(AA, NormalizedAAEnabled, false, "TSS+ change to AA that normalizes AA experience to a fixed # of white con kills independent of level") RULE_INT(AA, NormalizedAANumberOfWhiteConPerAA, 25, "The number of white con kills per AA point") RULE_BOOL(AA, ModernAAScalingEnabled, false, "Are we linearly scaling AA experience based on total # of earned AA?") @@ -667,11 +706,13 @@ RULE_CATEGORY(QueryServ) RULE_BOOL(QueryServ, PlayerLogChat, false, "Log player chat") RULE_BOOL(QueryServ, PlayerLogTrades, false, "Log player trades") RULE_BOOL(QueryServ, PlayerDropItems, false, "Log player dropping items") -RULE_BOOL(QueryServ, PlayerLogHandins, false, "Log player hand ins") +RULE_BOOL(QueryServ, PlayerLogHandins, false, "Log player handins") RULE_BOOL(QueryServ, PlayerLogNPCKills, false, "Log player NPC kills") RULE_BOOL(QueryServ, PlayerLogDeletes, false, "Log player deletes") RULE_BOOL(QueryServ, PlayerLogMoves, false, "Log player moves") RULE_BOOL(QueryServ, PlayerLogMerchantTransactions, false, "Log merchant transactions") +RULE_BOOL(QueryServ, PlayerLogPCCoordinates, false, "Log player coordinates with certain events") +RULE_BOOL(QueryServ, PlayerLogDropItem, false, "Log player drop item") RULE_BOOL(QueryServ, PlayerLogZone, false, "Log player zone events") RULE_BOOL(QueryServ, PlayerLogDeaths, false, "Log player deaths") RULE_BOOL(QueryServ, PlayerLogConnectDisconnect, false, "Logs player connect/disconnect state") @@ -679,9 +720,11 @@ RULE_BOOL(QueryServ, PlayerLogLevels, false, "Log player leveling/deleveling") RULE_BOOL(QueryServ, PlayerLogAARate, false, "Log player AA experience rates") RULE_BOOL(QueryServ, PlayerLogQGlobalUpdate, false, "Log player QGlobal updates") RULE_BOOL(QueryServ, PlayerLogTaskUpdates, false, "Log player Task updates") +RULE_BOOL(QueryServ, PlayerLogKeyringAddition, false, "Log player keyring additions") RULE_BOOL(QueryServ, PlayerLogAAPurchases, false, "Log player AA purchases") RULE_BOOL(QueryServ, PlayerLogTradeSkillEvents, false, "Log player tradeskill transactions") RULE_BOOL(QueryServ, PlayerLogIssuedCommandes, false, "Log player issued commands") +RULE_BOOL(QueryServ, PlayerLogMoneyTransactions, false, "Log player money transaction/splits") RULE_BOOL(QueryServ, PlayerLogAlternateCurrencyTransactions, false, "Log player alternate currency transactions") RULE_CATEGORY_END() @@ -737,21 +780,6 @@ RULE_BOOL(Instances, RecycleInstanceIds, true, "Setting whether free instance ID RULE_INT(Instances, GuildHallExpirationDays, 90, "Amount of days before a Guild Hall instance expires") RULE_CATEGORY_END() -RULE_CATEGORY(Expedition) -RULE_INT(Expedition, MinStatusToBypassPlayerCountRequirements, 80, "Minimum GM status to bypass minimum player requirements for Expedition creation") -RULE_BOOL(Expedition, AlwaysNotifyNewLeaderOnChange, false, "Always notify clients when made expedition leader. If false (live-like) new leaders are only notified when made leader via /dzmakeleader") -RULE_REAL(Expedition, LockoutDurationMultiplier, 1.0, "Multiplies lockout duration by this value when new lockouts are added") -RULE_BOOL(Expedition, EnableInDynamicZoneStatus, false, "Enables the 'In Dynamic Zone' member status in expedition window. If false (live-like) players inside the dynamic zone will show as 'Online'") -RULE_INT(Expedition, ChooseLeaderCooldownTime, 2000, "Cooldown time (milliseconds) between choosing a new leader for automatic leader changes") -RULE_CATEGORY_END() - -RULE_CATEGORY(DynamicZone) -RULE_INT(DynamicZone, ClientRemovalDelayMS, 60000, "Delay (milliseconds) until a client is teleported out of dynamic zone after being removed as member") -RULE_BOOL(DynamicZone, EmptyShutdownEnabled, true, "Enable early instance shutdown for dynamic zones that have no members") -RULE_INT(DynamicZone, EmptyShutdownDelaySeconds, 1500, "Seconds to set dynamic zone instance expiration if early shutdown enabled") -RULE_INT(DynamicZone, WorldProcessRate, 6000, "Timer interval (milliseconds) that systems check their dynamic zone states") -RULE_CATEGORY_END() - #undef RULE_CATEGORY #undef RULE_INT #undef RULE_REAL diff --git a/common/say_link.cpp b/common/say_link.cpp index b47897112..5fb847294 100644 --- a/common/say_link.cpp +++ b/common/say_link.cpp @@ -101,7 +101,7 @@ const std::string &EQ::SayLinkEngine::GenerateLink() m_Error = true; m_Link = ""; LogError("SayLinkEngine::GenerateLink() failed to generate a useable say link"); - LogError(">> LinkType: {}, Lengths: [link: {}({}), body: {}({}), text: {}({})]", + LogError(">> LinkType: {}, Lengths: {link: {}({}), body: {}({}), text: {}({})}", m_LinkType, m_Link.length(), EQ::constants::SAY_LINK_MAXIMUM_SIZE, diff --git a/common/server_event_scheduler.cpp b/common/server_event_scheduler.cpp deleted file mode 100644 index 1034eebfe..000000000 --- a/common/server_event_scheduler.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "../common/database.h" -#include "../common/string_util.h" -#include "server_event_scheduler.h" -#include "../common/cron/croncpp.h" -#include -#include -#include - -ServerEventScheduler::ServerEventScheduler() -{ - m_last_polled_minute = -1; - m_events = {}; - m_active_events = {}; -} - -ServerEventScheduler::~ServerEventScheduler() = default; - -void ServerEventScheduler::LoadScheduledEvents() -{ - if (!ValidateDatabaseConnection()) { - return; - } - - std::time_t time = std::time(nullptr); - std::tm *now = std::localtime(&time); - - m_events = ServerScheduledEventsRepository::GetWhere(*m_database, "deleted_at is null"); - for (auto &e: m_events) { - - auto start = BuildStartTimeFromEvent(e, now); - auto end = BuildEndTimeFromEvent(e, now); - - // data excluded from output because it can be very large - - LogScheduler( - "Loaded Event ({}) [{}] type [{}] start [{}/{}/{} {:02}:{:02}:00] end [{}/{}/{} {:02}:{:02}:00] cron [{}] created [{}]", - e.id, - e.description, - e.event_type, - start.tm_mon + 1, - start.tm_mday, - start.tm_year + 1900, - start.tm_hour, - start.tm_min, - end.tm_mon + 1, - end.tm_mday, - end.tm_year + 1900, - end.tm_hour, - end.tm_min, - e.cron_expression, - e.created_at - ); - } - - LogScheduler("Loaded scheduled events [{}]", m_events.size()); -} - -// checks to see if event is ready to be activated -bool ServerEventScheduler::ValidateEventReadyToActivate( - ServerScheduledEventsRepository::ServerScheduledEvents &e -) -{ - - // if there is a cron expression, it will try to parse it first before falling back to - // alternative time logic - if (!e.cron_expression.empty()) { - try { - auto cron = cron::make_cron(e.cron_expression); - std::time_t cron_now = std::time(nullptr); - std::time_t cron_next = cron::cron_next(cron, cron_now); - - // we have to pad our now window just a tad so we don't miss the cron window - if ((cron_now + 10) >= cron_next) { - LogScheduler("Cron time has been met! Event scheduling ({}) [{}]", e.id, e.description); - return true; - } - - LogSchedulerDetail("Cron now [{}] cron next [{}]\n", cron_now, cron_next); - } - catch (cron::bad_cronexpr const &ex) { - LogScheduler( - "Error: Cron expression error [{}] see [https://github.com/mariusbancila/croncpp#cron-expressions]", - ex.what() - ); - } - - return false; - } - - std::time_t time = std::time(nullptr); - std::tm *now = std::localtime(&time); - time_t now_time_unix = mktime(now); - auto start = BuildStartTimeFromEvent(e, now); - auto end = BuildEndTimeFromEvent(e, now); - time_t start_time_unix = mktime(&start); - - bool doesnt_end = ( - e.year_end == 0 && - e.month_end == 0 && - e.day_end == 0 && - e.hour_end == 0 && - e.minute_end == 0 - ); - - time_t end_time_unix; - if (!doesnt_end) { - end_time_unix = mktime(&end); - } - - if (now_time_unix >= start_time_unix && (doesnt_end || now_time_unix < end_time_unix)) { - LogSchedulerDetail( - "[ValidateEventReadyToActivate] now_time [{}] start_time [{}] doesnt_end [{}] end_time [{}]", - now_time_unix, - start_time_unix, - doesnt_end ? "true" : "false", - end_time_unix - ); - return true; - } - - return false; -} - -ServerEventScheduler *ServerEventScheduler::SetDatabase(Database *db) -{ - m_database = db; - - return this; -} - -bool ServerEventScheduler::ValidateDatabaseConnection() -{ - if (!m_database) { - LogError("[ServerEventScheduler::LoadScheduledEvents] No database connection"); - return false; - } - - return true; -} - -// in this function we simply look at events we have internally and events -// in the database and determine if any edits have been made -// this helps inform decisions to tell all zones to reload their events -bool ServerEventScheduler::CheckIfEventsChanged() -{ - auto events = ServerScheduledEventsRepository::GetWhere(*m_database, "deleted_at is null"); - - // first check if the size changed, if it did this is the easiest step - if (m_events.size() != events.size()) { - LogSchedulerDetail("[CheckIfEventsChanged] Event size has changed"); - m_events = events; - return true; - } - - // compare fields of database fields to internal events to see if any fields changed - for (auto &e: m_events) { - for (auto &dbe: events) { - if (dbe.id == e.id) { - if ( - dbe.description != e.description || - dbe.event_type != e.event_type || - dbe.event_data != e.event_data || - dbe.minute_start != e.minute_start || - dbe.hour_start != e.hour_start || - dbe.day_start != e.day_start || - dbe.month_start != e.month_start || - dbe.year_start != e.year_start || - dbe.minute_end != e.minute_end || - dbe.hour_end != e.hour_end || - dbe.day_end != e.day_end || - dbe.month_end != e.month_end || - dbe.year_end != e.year_end || - dbe.cron_expression != e.cron_expression || - dbe.created_at != e.created_at || - dbe.deleted_at != e.deleted_at - ) { - LogSchedulerDetail("[CheckIfEventsChanged] Field change detected"); - m_events = events; - return true; - } - } - } - } - - return false; -} - -// checks if event is active -bool ServerEventScheduler::IsEventActive(ServerScheduledEventsRepository::ServerScheduledEvents &e) -{ - for (auto &a: m_active_events) { - if (a.id == e.id) { - return true; - } - } - - return false; -} - -bool ServerEventScheduler::RemoveActiveEvent(ServerScheduledEventsRepository::ServerScheduledEvents &e) -{ - m_active_events.erase( - std::remove_if( - m_active_events.begin(), - m_active_events.end(), - [&](ServerScheduledEventsRepository::ServerScheduledEvents const &active_event) { - return active_event.id == e.id; - } - ), - m_active_events.end()); - - return false; -} - -std::tm ServerEventScheduler::BuildStartTimeFromEvent( - ServerScheduledEventsRepository::ServerScheduledEvents &e, - std::tm *now -) -{ - struct tm time{}; - time.tm_year = ((e.year_start > 0) ? e.year_start - 1900 : now->tm_year); - time.tm_mon = ((e.month_start > 0) ? e.month_start - 1 : now->tm_mon); - time.tm_mday = ((e.day_start > 0) ? e.day_start : now->tm_mday); - time.tm_hour = ((e.hour_start > 0) ? e.hour_start : now->tm_hour); - time.tm_min = ((e.minute_start > 0) ? e.minute_start : now->tm_min); - time.tm_sec = 0; - time.tm_isdst = now->tm_isdst; - - return time; -} - -std::tm ServerEventScheduler::BuildEndTimeFromEvent( - ServerScheduledEventsRepository::ServerScheduledEvents &e, - std::tm *now -) -{ - struct tm time{}; - time.tm_year = ((e.year_end > 0) ? e.year_end - 1900 : now->tm_year); - time.tm_mon = ((e.month_end > 0) ? e.month_end - 1 : now->tm_mon); - time.tm_mday = ((e.day_end > 0) ? e.day_end : now->tm_mday); - time.tm_hour = ((e.hour_end > 0) ? e.hour_end : now->tm_hour); - time.tm_min = ((e.minute_end > 0) ? e.minute_end : now->tm_min); - time.tm_sec = 0; - time.tm_isdst = now->tm_isdst; - - return time; -} diff --git a/common/server_event_scheduler.h b/common/server_event_scheduler.h deleted file mode 100644 index 5671eaf7c..000000000 --- a/common/server_event_scheduler.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef EQEMU_SERVER_EVENT_SCHEDULER_H -#define EQEMU_SERVER_EVENT_SCHEDULER_H - -#include "../common/repositories/server_scheduled_events_repository.h" -#include -#include - -namespace ServerEvents { - static const std::string EVENT_TYPE_HOT_ZONE_ACTIVE = "hot_zone_activate"; - static const std::string EVENT_TYPE_BROADCAST = "broadcast"; - static const std::string EVENT_TYPE_RELOAD_WORLD = "reload_world"; - static const std::string EVENT_TYPE_RULE_CHANGE = "rule_change"; - static const std::string EVENT_TYPE_CONTENT_FLAG_CHANGE = "content_flag_change"; -} - -class ServerEventScheduler { -public: - virtual ~ServerEventScheduler(); - ServerEventScheduler(); - ServerEventScheduler *SetDatabase(Database *db); - void LoadScheduledEvents(); - bool CheckIfEventsChanged(); - -protected: - - // events directly from the database - std::vector m_events; - - // used to track only when it is convenient to undo an action from an active event - // typically there should be two separate events to turn something on / off - // hotzones use this right now simply to keep us from toggling off the hotzone - // every minute we trigger and then immediately turning it right back on - std::vector m_active_events; - - // simple ticker used to determine when the last polled minute was so that when the minute - // changes we fire checking the scheduler - int m_last_polled_minute; - - // validates an event is currently active or not - bool ValidateEventReadyToActivate(ServerScheduledEventsRepository::ServerScheduledEvents &e); - - // is event active - bool IsEventActive(ServerScheduledEventsRepository::ServerScheduledEvents &e); - - // remove active event - bool RemoveActiveEvent(ServerScheduledEventsRepository::ServerScheduledEvents &e); - - // build time object from event - std::tm BuildStartTimeFromEvent(ServerScheduledEventsRepository::ServerScheduledEvents &e, tm *now); - std::tm BuildEndTimeFromEvent(ServerScheduledEventsRepository::ServerScheduledEvents &e, tm *now); - - // reference to database - Database *m_database; - bool ValidateDatabaseConnection(); -}; - -#endif //EQEMU_SERVER_EVENT_SCHEDULER_H diff --git a/common/servertalk.h b/common/servertalk.h index b7c59e123..5ed3b3306 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -140,34 +140,6 @@ #define ServerOP_LFPUpdate 0x0213 #define ServerOP_LFPMatches 0x0214 #define ServerOP_ClientVersionSummary 0x0215 - -#define ServerOP_ExpeditionCreate 0x0400 -#define ServerOP_ExpeditionDeleted 0x0401 -#define ServerOP_ExpeditionLeaderChanged 0x0402 -#define ServerOP_ExpeditionLockout 0x0403 -#define ServerOP_ExpeditionMemberChange 0x0404 -#define ServerOP_ExpeditionMemberSwap 0x0405 -#define ServerOP_ExpeditionMemberStatus 0x0406 -#define ServerOP_ExpeditionGetMemberStatuses 0x0407 -#define ServerOP_ExpeditionDzAddPlayer 0x0408 -#define ServerOP_ExpeditionDzMakeLeader 0x0409 -#define ServerOP_ExpeditionCharacterLockout 0x040d -#define ServerOP_ExpeditionSaveInvite 0x040e -#define ServerOP_ExpeditionRequestInvite 0x040f -#define ServerOP_ExpeditionReplayOnJoin 0x0410 -#define ServerOP_ExpeditionLockState 0x0411 -#define ServerOP_ExpeditionMembersRemoved 0x0412 -#define ServerOP_ExpeditionLockoutDuration 0x0414 -#define ServerOP_ExpeditionExpireWarning 0x0416 - -#define ServerOP_DzAddRemoveCharacter 0x0450 -#define ServerOP_DzRemoveAllCharacters 0x0451 -#define ServerOP_DzSetSecondsRemaining 0x0452 -#define ServerOP_DzDurationUpdate 0x0453 -#define ServerOP_DzSetCompass 0x0454 -#define ServerOP_DzSetSafeReturn 0x0455 -#define ServerOP_DzSetZoneIn 0x0456 - #define ServerOP_LSInfo 0x1000 #define ServerOP_LSStatus 0x1001 #define ServerOP_LSClientAuthLeg 0x1002 @@ -221,7 +193,6 @@ #define ServerOP_UCSServerStatusRequest 0x4009 #define ServerOP_UCSServerStatusReply 0x4010 #define ServerOP_HotReloadQuests 0x4011 -#define ServerOP_UpdateSchedulerEvents 0x4012 #define ServerOP_CZCastSpellPlayer 0x4500 #define ServerOP_CZCastSpellGroup 0x4501 @@ -286,7 +257,6 @@ #define ServerOP_CZTaskRemoveGroup 0x4560 #define ServerOP_CZTaskRemoveRaid 0x4561 #define ServerOP_CZTaskRemoveGuild 0x4562 -#define ServerOP_CZClientMessageString 0x4563 #define ServerOP_WWAssignTask 0x4750 #define ServerOP_WWCastSpell 0x4751 @@ -320,7 +290,7 @@ #define ServerOP_QSPlayerDropItem 0x5007 /* Query Serv Generic Packet Flag/Type Enumeration */ -enum { QSG_LFGuild = 0 }; +enum { QSG_LFGuild = 0 }; enum { QSG_LFGuild_PlayerMatches = 0, QSG_LFGuild_UpdatePlayerInfo, QSG_LFGuild_RequestPlayerInfo, QSG_LFGuild_UpdateGuildInfo, QSG_LFGuild_GuildMatches, QSG_LFGuild_RequestGuildInfo }; @@ -1463,14 +1433,6 @@ struct CZNPCSignal_Struct { uint32 signal; }; -struct CZClientMessageString_Struct { - uint32 string_id; - uint16 chat_type; - char character_name[64]; - uint32 args_size; - char args[1]; // null delimited -}; - struct CZClientSignalByName_Struct { char character_name[64]; uint32 signal; @@ -1933,7 +1895,7 @@ struct WWRemoveTask_Struct { uint32 task_id; uint8 min_status; uint8 max_status; - + }; struct WWResetActivity_Struct { @@ -1996,140 +1958,6 @@ struct UCSServerStatus_Struct { }; }; -struct ServerExpeditionID_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint32 sender_instance_id; -}; - -struct ServerExpeditionLeaderID_Struct { - uint32 expedition_id; - uint32 leader_id; -}; - -struct ServerExpeditionMemberChange_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint8 removed; // 0: added, 1: removed - uint32 char_id; - char char_name[64]; -}; - -struct ServerExpeditionMemberSwap_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint32 add_char_id; - uint32 remove_char_id; - char add_char_name[64]; - char remove_char_name[64]; -}; - -struct ServerExpeditionMemberStatus_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint8 status; // 0: unknown 1: Online 2: Offline 3: In Dynamic Zone 4: Link Dead - uint32 character_id; -}; - -struct ServerExpeditionMemberStatusEntry_Struct { - uint32 character_id; - uint8 online_status; // 0: unknown 1: Online 2: Offline 3: In Dynamic Zone 4: Link Dead -}; - -struct ServerExpeditionMemberStatuses_Struct { - uint32 expedition_id; - uint32 count; - ServerExpeditionMemberStatusEntry_Struct entries[0]; -}; - -struct ServerExpeditionLockout_Struct { - uint32 expedition_id; - uint64 expire_time; - uint32 duration; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint8 remove; - uint8 members_only; - int seconds_adjust; - char event_name[256]; -}; - -struct ServerExpeditionLockState_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint8 enabled; - uint8 lock_msg; // 0: none, 1: closing 2: trial begin -}; - -struct ServerExpeditionSetting_Struct { - uint32 expedition_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint8 enabled; -}; - -struct ServerExpeditionCharacterLockout_Struct { - uint8 remove; - uint32 character_id; - uint64 expire_time; - uint32 duration; - char uuid[37]; - char expedition_name[128]; - char event_name[256]; -}; - -struct ServerExpeditionCharacterID_Struct { - uint32_t character_id; -}; - -struct ServerExpeditionExpireWarning_Struct { - uint32_t expedition_id; - uint32_t minutes_remaining; -}; - -struct ServerDzCommand_Struct { - uint32 expedition_id; - uint8 is_char_online; // 0: target name is offline, 1: online - char requester_name[64]; - char target_name[64]; - char remove_name[64]; // used for swap command -}; - -struct ServerDzCommandMakeLeader_Struct { - uint32 expedition_id; - uint32 requester_id; - uint8 is_online; // set by world, 0: new leader name offline, 1: online - uint8 is_success; // set by world, 0: makeleader failed, 1: success (is online member) - char new_leader_name[64]; -}; - -struct ServerDzLocation_Struct { - uint32 dz_id; - uint32 sender_zone_id; - uint16 sender_instance_id; - uint32 zone_id; - float y; - float x; - float z; - float heading; -}; - -struct ServerDzCharacter_Struct { - uint16 zone_id; - uint16 instance_id; - uint8 remove; // 0: added 1: removed - uint32 character_id; -}; - -struct ServerDzSetDuration_Struct { - uint32 dz_id; - uint32 seconds; -}; - #pragma pack() #endif diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 6f2af55a3..d26d2d820 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -928,8 +928,8 @@ bool SharedDatabase::LoadItems(const std::string &prefix) { mutex.Lock(); std::string file_name = Config->SharedMemDir + prefix + std::string("items"); LogInfo("[Shared Memory] Attempting to load file [{}]", file_name); - items_mmf = std::make_unique(file_name); - items_hash = std::make_unique>(reinterpret_cast(items_mmf->Get()), items_mmf->Size()); + items_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name)); + items_hash = std::unique_ptr>(new EQ::FixedMemoryHashSet(reinterpret_cast(items_mmf->Get()), items_mmf->Size())); mutex.Unlock(); } catch(std::exception& ex) { LogError("Error Loading Items: {}", ex.what()); @@ -1353,8 +1353,8 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) { mutex.Lock(); std::string file_name = Config->SharedMemDir + prefix + std::string("faction"); LogInfo("[Shared Memory] Attempting to load file [{}]", file_name); - faction_mmf = std::make_unique(file_name); - faction_hash = std::make_unique>(reinterpret_cast(faction_mmf->Get()), faction_mmf->Size()); + faction_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name)); + faction_hash = std::unique_ptr>(new EQ::FixedMemoryHashSet(reinterpret_cast(faction_mmf->Get()), faction_mmf->Size())); mutex.Unlock(); } catch(std::exception& ex) { LogError("Error Loading npc factions: {}", ex.what()); @@ -1555,7 +1555,7 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) { mutex.Lock(); std::string file_name = Config->SharedMemDir + prefix + std::string("skill_caps"); LogInfo("[Shared Memory] Attempting to load file [{}]", file_name); - skill_caps_mmf = std::make_unique(file_name); + skill_caps_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name)); mutex.Unlock(); } catch(std::exception &ex) { LogError("Error loading skill caps: {}", ex.what()); @@ -1712,7 +1712,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const mutex.Lock(); std::string file_name = Config->SharedMemDir + prefix + std::string("spells"); - spells_mmf = std::make_unique(file_name); + spells_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name)); LogInfo("[Shared Memory] Attempting to load file [{}]", file_name); *records = *reinterpret_cast(spells_mmf->Get()); *sp = reinterpret_cast((char*)spells_mmf->Get() + 4); @@ -1920,7 +1920,7 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) { mutex.Lock(); std::string file_name = Config->SharedMemDir + prefix + std::string("base_data"); - base_data_mmf = std::make_unique(file_name); + base_data_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name)); mutex.Unlock(); } catch(std::exception& ex) { LogError("Error Loading Base Data: {}", ex.what()); @@ -2223,15 +2223,15 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) { EQ::IPCMutex mutex("loot"); mutex.Lock(); std::string file_name_lt = Config->SharedMemDir + prefix + std::string("loot_table"); - loot_table_mmf = std::make_unique(file_name_lt); - loot_table_hash = std::make_unique>( + loot_table_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name_lt)); + loot_table_hash = std::unique_ptr>(new EQ::FixedMemoryVariableHashSet( reinterpret_cast(loot_table_mmf->Get()), - loot_table_mmf->Size()); + loot_table_mmf->Size())); std::string file_name_ld = Config->SharedMemDir + prefix + std::string("loot_drop"); - loot_drop_mmf = std::make_unique(file_name_ld); - loot_drop_hash = std::make_unique>( + loot_drop_mmf = std::unique_ptr(new EQ::MemoryMappedFile(file_name_ld)); + loot_drop_hash = std::unique_ptr>(new EQ::FixedMemoryVariableHashSet( reinterpret_cast(loot_drop_mmf->Get()), - loot_drop_mmf->Size()); + loot_drop_mmf->Size())); mutex.Unlock(); } catch(std::exception &ex) { LogError("Error loading loot: {}", ex.what()); diff --git a/common/spdat.cpp b/common/spdat.cpp index fe6e4db9c..3f0ae6e41 100644 --- a/common/spdat.cpp +++ b/common/spdat.cpp @@ -1271,7 +1271,7 @@ bool IsSpellUsableThisZoneType(uint16 spell_id, uint8 zone_type) return false; } -const char* GetSpellName(uint16 spell_id) +const char* GetSpellName(int16 spell_id) { return spells[spell_id].name; } diff --git a/common/spdat.h b/common/spdat.h index d6d6ef144..811825757 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -981,6 +981,6 @@ uint32 GetNimbusEffect(uint16 spell_id); int32 GetFuriousBash(uint16 spell_id); bool IsShortDurationBuff(uint16 spell_id); bool IsSpellUsableThisZoneType(uint16 spell_id, uint8 zone_type); -const char *GetSpellName(uint16 spell_id); +const char *GetSpellName(int16 spell_id); #endif diff --git a/common/string_util.cpp b/common/string_util.cpp index 6c97dd076..680c2822b 100644 --- a/common/string_util.cpp +++ b/common/string_util.cpp @@ -74,6 +74,18 @@ const std::string str_tolower(std::string s) return s; } +std::vector split(std::string str_to_split, char delimiter) +{ + std::stringstream ss(str_to_split); + std::string item; + std::vector exploded_values; + while (std::getline(ss, item, delimiter)) { + exploded_values.push_back(item); + } + + return exploded_values; +} + const std::string str_toupper(std::string s) { std::transform( @@ -101,32 +113,16 @@ const std::string StringFormat(const char *format, ...) return output; } -std::vector SplitString(const std::string &str, const char delim) { +std::vector SplitString(const std::string &str, char delim) { std::vector ret; - std::string::size_type start = 0; - auto end = str.find(delim); - while (end != std::string::npos) { - ret.emplace_back(str, start, end - start); - start = end + 1; - end = str.find(delim, start); - } - // this will catch the last word since the string is unlikely to end with a delimiter - if (str.length() > start) - ret.emplace_back(str, start, str.length() - start); - return ret; -} + std::stringstream ss(str); + std::string item; -std::string::size_type search_deliminated_string(const std::string &haystack, const std::string &needle, const char deliminator) -{ - // this shouldn't go out of bounds, even without obvious bounds checks - auto pos = haystack.find(needle); - while (pos != std::string::npos) { - auto c = haystack[pos + needle.length()]; - if ((c == '\0' || c == deliminator) && (pos == 0 || haystack[pos - 1] == deliminator)) - return pos; - pos = haystack.find(needle, pos + needle.length()); - } - return std::string::npos; + while(std::getline(ss, item, delim)) { + ret.push_back(item); + } + + return ret; } std::string implode(std::string glue, std::vector src) @@ -346,6 +342,54 @@ void MakeLowerString(const char *source, char *target) { *target = 0; } +int MakeAnyLenString(char** ret, const char* format, ...) { + int buf_len = 128; + int chars = -1; + va_list argptr, tmpargptr; + va_start(argptr, format); + while (chars == -1 || chars >= buf_len) { + safe_delete_array(*ret); + if (chars == -1) + buf_len *= 2; + else + buf_len = chars + 1; + *ret = new char[buf_len]; + va_copy(tmpargptr, argptr); + chars = vsnprintf(*ret, buf_len, format, tmpargptr); + } + va_end(argptr); + return chars; +} + +uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) { + if (*bufsize == 0) + *bufsize = 256; + if (*ret == 0) + *strlen = 0; + int chars = -1; + char* oldret = 0; + va_list argptr, tmpargptr; + va_start(argptr, format); + while (chars == -1 || chars >= (int32)(*bufsize - *strlen)) { + if (chars == -1) + *bufsize += 256; + else + *bufsize += chars + 25; + oldret = *ret; + *ret = new char[*bufsize]; + if (oldret) { + if (*strlen) + memcpy(*ret, oldret, *strlen); + safe_delete_array(oldret); + } + va_copy(tmpargptr, argptr); + chars = vsnprintf(&(*ret)[*strlen], (*bufsize - *strlen), format, tmpargptr); + } + va_end(argptr); + *strlen += chars; + return *strlen; +} + uint32 hextoi(const char* num) { if (num == nullptr) return 0; @@ -548,15 +592,3 @@ std::string numberToWords(unsigned long long int n) return res; } - -// first letter capitalized and rest made lower case -std::string FormatName(const std::string& char_name) -{ - std::string formatted(char_name); - if (!formatted.empty()) - { - std::transform(formatted.begin(), formatted.end(), formatted.begin(), ::tolower); - formatted[0] = ::toupper(formatted[0]); - } - return formatted; -} diff --git a/common/string_util.h b/common/string_util.h index 5fd91281c..0d602e395 100644 --- a/common/string_util.h +++ b/common/string_util.h @@ -39,6 +39,7 @@ const std::string str_tolower(std::string s); const std::string str_toupper(std::string s); const std::string ucfirst(std::string s); +std::vector split(std::string str_to_split, char delimiter); const std::string StringFormat(const char* format, ...); const std::string vStringFormat(const char* format, va_list args); std::vector wrap(std::vector &src, std::string character); @@ -176,8 +177,7 @@ std::vector join_tuple(const std::string &glue, const std::pair SplitString(const std::string &s, const char delim = ','); -std::string::size_type search_deliminated_string(const std::string &haystack, const std::string &needle, const char deliminator = ','); +std::vector SplitString(const std::string &s, char delim); std::string EscapeString(const char *src, size_t sz); std::string EscapeString(const std::string &s); bool StringIsNumber(const std::string &s); @@ -198,12 +198,14 @@ char* strn0cpy(char* dest, const char* source, uint32 size); const char *ConvertArray(int input, char *returnchar); const char *ConvertArrayF(float input, char *returnchar); const char *MakeLowerString(const char *source); +int MakeAnyLenString(char** ret, const char* format, ...); +uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...); uint32 hextoi(const char* num); uint64 hextoi64(const char* num); void MakeLowerString(const char *source, char *target); void RemoveApostrophes(std::string &s); std::string convert2digit(int n, std::string suffix); std::string numberToWords(unsigned long long int n); -std::string FormatName(const std::string& char_name); + #endif diff --git a/common/version.h b/common/version.h index af6a207e5..0dd15a90f 100644 --- a/common/version.h +++ b/common/version.h @@ -34,7 +34,7 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9165 +#define CURRENT_BINARY_DATABASE_VERSION 9155 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9027 diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index c50b58e09..ea0eee4ac 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -29,7 +29,7 @@ WorldServer::WorldServer(std::map &zones, const char m_config(config), m_zones(zones) { - m_connection = std::make_unique(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey); + m_connection.reset(new EQ::Net::ServertalkClient(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey)); m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) { OnConnected(); }); @@ -138,4 +138,4 @@ void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool ru m_connection->SendPacket(pack); safe_delete(pack); -} +} \ No newline at end of file diff --git a/libs/zlibng/.github/workflows/analyze.yml b/libs/zlibng/.github/workflows/analyze.yml deleted file mode 100644 index 7c848ef02..000000000 --- a/libs/zlibng/.github/workflows/analyze.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: CI Static Analysis -on: [push, pull_request] -jobs: - GCC-10: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Install packages (Ubuntu) - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - sudo apt-get install -y gcc-10 - - name: Generate project files - run: | - cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=OFF -DWITH_CODE_COVERAGE=OFF -DWITH_MAINTAINER_WARNINGS=OFF - env: - CC: gcc-10 - CFLAGS: "-fanalyzer -Werror -Wanalyzer-double-fclose -Wanalyzer-double-free -Wanalyzer-exposure-through-output-file -Wanalyzer-file-leak -Wanalyzer-free-of-non-heap -Wanalyzer-malloc-leak -Wanalyzer-null-argument -Wanalyzer-null-dereference -Wanalyzer-possible-null-argument -Wanalyzer-possible-null-dereference -Wanalyzer-stale-setjmp-buffer -Wanalyzer-tainted-array-index -Wanalyzer-unsafe-call-within-signal-handler -Wanalyzer-use-after-free -Wanalyzer-use-of-pointer-in-stale-stack-frame" - CI: true - - name: Compile source code - run: | - cmake --build . --config Release > /dev/null - Clang-12: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Install packages (Ubuntu) - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - - sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" -y - sudo apt install clang-tools-12 -y - - name: Generate project files - run: | - scan-build-12 --status-bugs cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=OFF -DWITH_CODE_COVERAGE=OFF -DWITH_MAINTAINER_WARNINGS=OFF - env: - CI: true - - name: Compile source code - run: | - scan-build-12 --status-bugs cmake --build . --config Release > /dev/null diff --git a/libs/zlibng/.github/workflows/cmake.yml b/libs/zlibng/.github/workflows/cmake.yml deleted file mode 100644 index 4eaec6c4b..000000000 --- a/libs/zlibng/.github/workflows/cmake.yml +++ /dev/null @@ -1,381 +0,0 @@ -name: CI CMake -on: [push, pull_request] -jobs: - ci-cmake: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Ubuntu GCC - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_SANITIZER=Address - codecov: ubuntu_gcc - - - name: Ubuntu GCC OSB -O1 No Unaligned64 - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_UNALIGNED=ON -DUNALIGNED64_OK=OFF -DWITH_SANITIZER=Undefined - build-dir: ../build - build-src-dir: ../zlib-ng - codecov: ubuntu_gcc_osb - cflags: -O1 -g3 - - - name: Ubuntu GCC -O3 No Unaligned - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_UNALIGNED=OFF - codecov: ubuntu_gcc_o3 - cflags: -O3 - - - name: Ubuntu GCC Link Zlib - os: ubuntu-latest - compiler: gcc - cmake-args: -DZLIB_DUAL_LINK=ON - - - name: Ubuntu GCC No AVX2 - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_AVX2=OFF -DWITH_SANITIZER=Undefined - codecov: ubuntu_gcc_no_avx2 - - - name: Ubuntu GCC No SSE2 - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_SSE2=OFF -DWITH_SANITIZER=Undefined - codecov: ubuntu_gcc_no_sse2 - - - name: Ubuntu GCC No SSE4 - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_SSE4=OFF -DWITH_SANITIZER=Undefined - codecov: ubuntu_gcc_no_sse4 - - - name: Ubuntu GCC No PCLMULQDQ - os: ubuntu-latest - compiler: gcc - cmake-args: -DWITH_PCLMULQDQ=OFF -DWITH_SANITIZER=Undefined - codecov: ubuntu_gcc_no_pclmulqdq - - - name: Ubuntu GCC Compat No Opt - os: ubuntu-latest - compiler: gcc - cmake-args: -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Address - codecov: ubuntu_gcc_compat_no_opt - cflags: -DNOT_TWEAK_COMPILER - - - name: Ubuntu GCC ARM SF - os: ubuntu-latest - compiler: arm-linux-gnueabi-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DWITH_SANITIZER=Address - packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross - codecov: ubuntu_gcc_armsf - - - name: Ubuntu GCC ARM SF Compat No Opt - os: ubuntu-latest - compiler: arm-linux-gnueabi-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined - packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross - codecov: ubuntu_gcc_armsf_compat_no_opt - - - name: Ubuntu GCC ARM HF - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_SANITIZER=Address - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - codecov: ubuntu_gcc_armhf - - - name: Ubuntu GCC ARM HF No ACLE - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_ACLE=OFF -DWITH_SANITIZER=Address - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - codecov: ubuntu_gcc_armhf_no_acle - - - name: Ubuntu GCC ARM HF No NEON - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_NEON=OFF -DWITH_SANITIZER=Address - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - codecov: ubuntu_gcc_armhf_no_neon - - - name: Ubuntu GCC ARM HF Compat No Opt - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - codecov: ubuntu_gcc_armhf_compat_no_opt - - - name: Ubuntu GCC AARCH64 - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_SANITIZER=Address - asan-options: detect_leaks=0 - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - codecov: ubuntu_gcc_aarch64 - - - name: Ubuntu GCC AARCH64 No ACLE - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_ACLE=OFF -DWITH_SANITIZER=Undefined - asan-options: detect_leaks=0 - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - codecov: ubuntu_gcc_aarch64_no_acle - - - name: Ubuntu GCC AARCH64 No NEON - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_NEON=OFF -DWITH_SANITIZER=Undefined - asan-options: detect_leaks=0 - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - codecov: ubuntu_gcc_aarch64_no_neon - - - name: Ubuntu GCC AARCH64 Compat No Opt - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined - asan-options: detect_leaks=0 - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - codecov: ubuntu_gcc_aarch64_compat_no_opt - - - name: Ubuntu GCC PPC - os: ubuntu-latest - compiler: powerpc-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake - packages: qemu gcc-powerpc-linux-gnu libc-dev-powerpc-cross - ldflags: -static - codecov: ubuntu_gcc_ppc - - - name: Ubuntu GCC PPC64 - os: ubuntu-latest - compiler: powerpc64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64.cmake - packages: qemu gcc-powerpc64-linux-gnu libc-dev-ppc64-cross - ldflags: -static - codecov: ubuntu_gcc_ppc64 - - - name: Ubuntu GCC PPC64LE - os: ubuntu-latest - compiler: powerpc64le-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake - packages: qemu gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross - codecov: ubuntu_gcc_ppc64le - - - name: Ubuntu GCC SPARC64 - os: ubuntu-latest - compiler: sparc64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-sparc64.cmake - packages: qemu gcc-sparc64-linux-gnu libc-dev-sparc64-cross - ldflags: -static - codecov: ubuntu_gcc_sparc64 - - - name: Ubuntu GCC S390X - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_SANITIZER=Address - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - ldflags: -static - codecov: ubuntu_gcc_s390x - - - name: Ubuntu GCC S390X DFLTCC - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Address - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - ldflags: -static - codecov: ubuntu_gcc_s390x - - - name: Ubuntu GCC S390X DFLTCC Compat - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DZLIB_COMPAT=ON -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Undefined - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - ldflags: -static - codecov: ubuntu_gcc_s390x - - - name: Ubuntu MinGW i686 - os: ubuntu-latest - compiler: i686-w64-mingw32-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake - packages: wine32 gcc-mingw-w64 - # Codecov disabled due to gcov locking issue error - - - name: Ubuntu MinGW x86_64 - os: ubuntu-latest - compiler: x86_64-w64-mingw32-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-x86_64.cmake - packages: wine-stable gcc-mingw-w64 - codecov: ubuntu_gcc_mingw_x86_64 - - - name: Ubuntu Clang - os: ubuntu-latest - compiler: clang - packages: llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - codecov: ubuntu_clang - - - name: Ubuntu Clang Inflate Strict - os: ubuntu-latest - compiler: clang - cmake-args: -DWITH_INFLATE_STRICT=ON - packages: llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - codecov: ubuntu_clang_inflate_strict - - - name: Ubuntu Clang Inflate Allow Invalid Dist - os: ubuntu-latest - compiler: clang - cmake-args: -DWITH_INFLATE_ALLOW_INVALID_DIST=ON - packages: llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - codecov: ubuntu_clang_inflate_allow_invalid_dist - - - name: Ubuntu Clang Memory Map - os: ubuntu-latest - compiler: clang - cflags: -DUSE_MMAP - packages: llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - codecov: ubuntu_clang_mmap - - - name: Ubuntu Clang Debug - os: ubuntu-latest - compiler: clang - packages: llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - codecov: ubuntu_clang_debug - build-config: Debug - - - name: Ubuntu Clang MSAN - os: ubuntu-latest - compiler: clang - cmake-args: -GNinja -DWITH_SANITIZER=Memory - packages: ninja-build llvm-6.0 - gcov-exec: llvm-cov-6.0 gcov - cflags: -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins - codecov: ubuntu_clang_msan - - - name: Windows MSVC Win32 - os: windows-latest - compiler: cl - cmake-args: -A Win32 - - - name: Windows MSVC Win64 - os: windows-latest - compiler: cl - cmake-args: -A x64 - - - name: Windows MSVC ARM No Test - os: windows-latest - compiler: cl - cmake-args: -A ARM - - - name: Windows MSVC ARM64 No Test - os: windows-latest - compiler: cl - cmake-args: -A ARM64 - - - name: Windows GCC - os: windows-latest - compiler: gcc - cmake-args: -G Ninja - codecov: win64_gcc - - - name: Windows GCC Compat No Opt - os: windows-latest - compiler: gcc - cmake-args: -G Ninja -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF - codecov: win64_gcc_compat_no_opt - - - name: macOS Clang - os: macos-latest - compiler: clang - cmake-args: -DWITH_SANITIZER=Address - codecov: macos_clang - - - name: macOS GCC - os: macos-latest - compiler: gcc-10 - cmake-args: -DWITH_SANITIZER=Undefined - packages: gcc@10 - gcov-exec: gcov-10 - codecov: macos_gcc - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Checkout test corpora - uses: actions/checkout@v2 - with: - repository: nmoinvaz/corpora - path: test/data/corpora - - - name: Install packages (Ubuntu) - if: runner.os == 'Linux' && matrix.packages - run: | - sudo dpkg --add-architecture i386 # Required for wine32 - sudo apt-get update - sudo apt-get install -y ${{ matrix.packages }} - - - name: Install packages (Windows) - if: runner.os == 'Windows' - run: | - choco install ninja ${{ matrix.packages }} --no-progress - - - name: Install packages (macOS) - if: runner.os == 'macOS' - run: | - brew install ninja ${{ matrix.packages }} - env: - HOMEBREW_NO_INSTALL_CLEANUP: 1 - - - name: Install codecov.io tools - if: matrix.codecov - run: | - python -u -m pip install codecov - - - name: Generate project files - # Shared libaries turned off for qemu ppc* and sparc & reduce code coverage sources - run: | - mkdir ${{ matrix.build-dir || '.not-used' }} - cd ${{ matrix.build-dir || '.' }} - cmake ${{ matrix.build-src-dir || '.' }} ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=ON -DWITH_CODE_COVERAGE=ON -DWITH_MAINTAINER_WARNINGS=ON - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - LDFLAGS: ${{ matrix.ldflags }} - CI: true - - - name: Compile source code - run: | - cd ${{ matrix.build-dir || '.' }} - cmake --build . --config ${{ matrix.build-config || 'Release' }} - - - name: Run test cases - # Don't run tests on Windows ARM - if: runner.os != 'Windows' || contains(matrix.name, 'ARM') == false - run: | - cd ${{ matrix.build-dir || '.' }} - ctest --verbose -C Release --output-on-failure --max-width 120 -j 6 - env: - ASAN_OPTIONS: ${{ matrix.asan-options || 'verbosity=0' }}:abort_on_error=1 - MSAN_OPTIONS: ${{ matrix.msan-options || 'verbosity=0' }}:abort_on_error=1 - TSAN_OPTIONS: ${{ matrix.tsan-options || 'verbosity=0' }}:abort_on_error=1 - LSAN_OPTIONS: ${{ matrix.lsan-options || 'verbosity=0' }}:abort_on_error=1 - - - name: Upload coverage report - if: matrix.codecov && ( env.CODECOV_TOKEN_SECRET != '' || github.repository == 'zlib-ng/zlib-ng' ) - shell: bash - run: | - bash tools/codecov-upload.sh - env: - # Codecov does not yet support GitHub Actions - CODECOV_TOKEN_SECRET: "${{secrets.CODECOV_TOKEN}}" - CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN || 'e4fdf847-f541-4ab1-9d50-3d27e5913906' }}" - CODECOV_FLAGS: "${{ matrix.codecov }}" - CODECOV_NAME: "${{ matrix.name }}" - CODECOV_EXEC: "${{ matrix.gcov-exec || 'gcov' }}" - CODECOV_DIR: "${{ matrix.build-dir || '.' }}" diff --git a/libs/zlibng/.github/workflows/configure.yml b/libs/zlibng/.github/workflows/configure.yml deleted file mode 100644 index 750f30d71..000000000 --- a/libs/zlibng/.github/workflows/configure.yml +++ /dev/null @@ -1,185 +0,0 @@ -name: CI Configure -on: [push, pull_request] -jobs: - ci-configure: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Ubuntu GCC - os: ubuntu-latest - compiler: gcc - configure-args: --warn - - - name: Ubuntu GCC OSB - os: ubuntu-latest - compiler: gcc - configure-args: --warn - build-dir: ../build - build-src-dir: ../zlib-ng - - - name: Ubuntu GCC Compat No Opt - os: ubuntu-latest - compiler: gcc - configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies - - - name: Ubuntu GCC ARM SF - os: ubuntu-latest - compiler: arm-linux-gnueabi-gcc - configure-args: --warn - chost: arm-linux-gnueabi - packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross - - - name: Ubuntu GCC ARM SF Compat No Opt - os: ubuntu-latest - compiler: arm-linux-gnueabi-gcc - configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies - chost: arm-linux-gnueabi - packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross - - - name: Ubuntu GCC ARM HF - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - configure-args: --warn - chost: arm-linux-gnueabihf - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - - - name: Ubuntu GCC ARM HF No ACLE - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - configure-args: --warn --without-acle - chost: arm-linux-gnueabihf - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - - - name: Ubuntu GCC ARM HF No NEON - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - configure-args: --warn --without-neon - chost: arm-linux-gnueabihf - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - - - name: Ubuntu GCC ARM HF Compat No Opt - os: ubuntu-latest - compiler: arm-linux-gnueabihf-gcc - configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies - chost: arm-linux-gnueabihf - packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross - - - name: Ubuntu GCC AARCH64 - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - configure-args: --warn - chost: aarch64-linux-gnu - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - - - name: Ubuntu GCC AARCH64 No ACLE - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - configure-args: --warn --without-acle - chost: aarch64-linux-gnu - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - - - name: Ubuntu GCC AARCH64 No NEON - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - configure-args: --warn --without-neon - chost: aarch64-linux-gnu - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - - - name: Ubuntu GCC AARCH64 Compat No Opt - os: ubuntu-latest - compiler: aarch64-linux-gnu-gcc - configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies - chost: aarch64-linux-gnu - packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross - - - name: Ubuntu GCC PPC - os: ubuntu-latest - compiler: powerpc-linux-gnu-gcc - configure-args: --warn --static - chost: powerpc-linux-gnu - packages: qemu gcc-powerpc-linux-gnu libc-dev-powerpc-cross - cflags: -static - ldflags: -static - - - name: Ubuntu GCC PPC64 - os: ubuntu-latest - compiler: powerpc64-linux-gnu-gcc - configure-args: --warn --static - chost: powerpc-linux-gnu - packages: qemu gcc-powerpc64-linux-gnu libc-dev-ppc64-cross - cflags: -static - ldflags: -static - - - name: Ubuntu GCC PPC64LE - os: ubuntu-latest - compiler: powerpc64le-linux-gnu-gcc - configure-args: --warn - chost: powerpc64le-linux-gnu - packages: qemu gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross - - - name: Ubuntu GCC S390X - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - configure-args: --warn --static - chost: s390x-linux-gnu - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - cflags: -static - ldflags: -static - - - name: Ubuntu GCC S390X DFLTCC - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - configure-args: --warn --static --with-dfltcc-deflate --with-dfltcc-inflate - chost: s390x-linux-gnu - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - cflags: -static - ldflags: -static - - - name: Ubuntu GCC S390X DFLTCC Compat - os: ubuntu-latest - compiler: s390x-linux-gnu-gcc - configure-args: --warn --zlib-compat --static --with-dfltcc-deflate --with-dfltcc-inflate - chost: s390x-linux-gnu - packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross - cflags: -static - ldflags: -static - - - name: macOS GCC - os: macOS-latest - compiler: gcc - configure-args: --warn - - steps: - - name: Checkout repository - uses: actions/checkout@v1 - - - name: Install packages (Ubuntu) - if: runner.os == 'Linux' && matrix.packages - run: | - sudo apt-get update - sudo apt-get install -y ${{ matrix.packages }} - - - name: Generate project files - run: | - mkdir ${{ matrix.build-dir || '.not-used' }} - cd ${{ matrix.build-dir || '.' }} - ${{ matrix.build-src-dir || '.' }}/configure ${{ matrix.configure-args }} - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - LDFLAGS: ${{ matrix.ldflags }} - CHOST: ${{ matrix.chost }} - CI: true - - - name: Compile source code - run: | - cd ${{ matrix.build-dir || '.' }} - make -j2 - - - name: Run test cases - run: | - cd ${{ matrix.build-dir || '.' }} - make test diff --git a/libs/zlibng/.github/workflows/fuzz.yml b/libs/zlibng/.github/workflows/fuzz.yml deleted file mode 100644 index e7ddaea5b..000000000 --- a/libs/zlibng/.github/workflows/fuzz.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: CI Fuzz -on: [pull_request] -jobs: - Fuzzing: - runs-on: ubuntu-latest - steps: - - name: Build Fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'zlib-ng' - dry-run: false - - name: Run Fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: 'zlib-ng' - fuzz-seconds: 600 - dry-run: false - - name: Upload Crash - uses: actions/upload-artifact@v1 - if: failure() - with: - name: artifacts - path: ./out/artifacts diff --git a/libs/zlibng/.github/workflows/libpng.yml b/libs/zlibng/.github/workflows/libpng.yml deleted file mode 100644 index fe970dd15..000000000 --- a/libs/zlibng/.github/workflows/libpng.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: CI Libpng -on: [pull_request] -jobs: - pngtest: - name: Ubuntu Clang - runs-on: ubuntu-latest - - steps: - - name: Checkout repository (zlib-ng) - uses: actions/checkout@v1 - - - name: Generate project files (zlib-ng) - run: | - cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF - env: - CC: clang - CFLAGS: -fPIC - CI: true - - - name: Compile source code (zlib-ng) - run: | - cmake --build . --config Release - - - name: Checkout repository (libpng) - uses: actions/checkout@v2 - with: - repository: glennrp/libpng - path: libpng - - - name: Generate project files (libpng) - run: | - cd libpng - cmake . -DCMAKE_BUILD_TYPE=Release -DPNG_TESTS=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR=.. -DZLIB_LIBRARY=$PWD/../libz.a - env: - CC: clang - CI: true - - - name: Compile source code (libpng) - run: | - cd libpng - cmake --build . --config Release - - - name: Run test cases (libpng) - run: | - cd libpng - ctest -C Release --output-on-failure --max-width 120 diff --git a/libs/zlibng/.github/workflows/nmake.yml b/libs/zlibng/.github/workflows/nmake.yml deleted file mode 100644 index 38c0b42eb..000000000 --- a/libs/zlibng/.github/workflows/nmake.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: CI NMake -on: [push, pull_request] -jobs: - ci-cmake: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Windows NMake x86 - os: windows-latest - makefile: win32/Makefile.msc - vc-vars: x86 - - - name: Windows NMake x64 - os: windows-latest - makefile: win32/Makefile.msc - vc-vars: x86_amd64 - - - name: Windows NMake ARM No Test - os: windows-latest - makefile: win32/Makefile.arm - vc-vars: x86_arm - - - name: Windows NMake ARM64 No Test - os: windows-latest - makefile: win32/Makefile.a64 - vc-vars: x86_arm64 - - steps: - - name: Checkout repository - uses: actions/checkout@v1 - - - name: Compile source code - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-vars }} - nmake -f ${{ matrix.makefile }} - - - name: Run test cases - shell: cmd - # Don't run tests on Windows ARM - if: contains(matrix.vc-vars, 'arm') == false - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-vars }} - nmake -f ${{ matrix.makefile }} test - nmake -f ${{ matrix.makefile }} testdll diff --git a/libs/zlibng/.github/workflows/pkgcheck.yml b/libs/zlibng/.github/workflows/pkgcheck.yml deleted file mode 100644 index a34ad94f3..000000000 --- a/libs/zlibng/.github/workflows/pkgcheck.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: CI Pkgcheck -on: [push, pull_request] -jobs: - ci-pkgcheck: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Ubuntu GCC - os: ubuntu-latest - compiler: gcc - - - name: Ubuntu GCC -m32 - os: ubuntu-latest - compiler: gcc - packages: gcc-multilib - cmake-args: -DCMAKE_C_FLAGS=-m32 - cflags: -m32 - ldflags: -m32 - - - name: Ubuntu GCC ARM HF - os: ubuntu-latest - chost: arm-linux-gnueabihf - compiler: arm-linux-gnueabihf-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf - packages: qemu gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - - - name: Ubuntu GCC AARCH64 - os: ubuntu-latest - chost: aarch64-linux-gnu - compiler: aarch64-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake - packages: qemu gcc-aarch64-linux-gnu libc6-dev-arm64-cross - - - name: Ubuntu GCC PPC - os: ubuntu-latest - chost: powerpc-linux-gnu - compiler: powerpc-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake - packages: qemu gcc-powerpc-linux-gnu libc6-dev-powerpc-cross - - - name: Ubuntu GCC PPC64LE - os: ubuntu-latest - chost: powerpc64le-linux-gnu - compiler: powerpc64le-linux-gnu-gcc - cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake - packages: qemu gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross - - - name: macOS Clang - os: macOS-latest - compiler: clang - - steps: - - name: Checkout repository - uses: actions/checkout@v1 - - - name: Install packages (Ubuntu) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends abigail-tools ninja-build diffoscope ${{ matrix.packages }} - - - name: Install packages (macOS) - if: runner.os == 'macOS' - run: | - brew install ninja diffoscope ${{ matrix.packages }} - env: - HOMEBREW_NO_INSTALL_CLEANUP: 1 - - - name: Select Xcode version (macOS) - # Use a version of Xcode that supports ZERO_AR_DATE until CMake supports - # AppleClang linking with libtool using -D argument - # https://gitlab.kitware.com/cmake/cmake/-/issues/19852 - if: runner.os == 'macOS' - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '12.1.1' - - - name: Compare builds - run: | - sh test/pkgcheck.sh - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - CHOST: ${{ matrix.chost }} - CMAKE_ARGS: ${{ matrix.cmake-args }} - LDFLAGS: ${{ matrix.ldflags }} - - - name: Compare builds (compat) - run: | - sh test/pkgcheck.sh --zlib-compat - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - CHOST: ${{ matrix.chost }} - CMAKE_ARGS: ${{ matrix.cmake-args }} - LDFLAGS: ${{ matrix.ldflags }} - - - name: Check ABI - # macOS runner does not contain abigail - if: runner.os != 'macOS' - run: | - sh test/abicheck.sh --refresh_if - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - CHOST: ${{ matrix.chost }} - LDFLAGS: ${{ matrix.ldflags }} - - - name: Check ABI (compat) - # macOS runner does not contain abigail - if: runner.os != 'macOS' - run: | - sh test/abicheck.sh --zlib-compat --refresh_if - env: - CC: ${{ matrix.compiler }} - CFLAGS: ${{ matrix.cflags }} - CHOST: ${{ matrix.chost }} - LDFLAGS: ${{ matrix.ldflags }} diff --git a/libs/zlibng/.github/workflows/release.yml b/libs/zlibng/.github/workflows/release.yml deleted file mode 100644 index c2a306172..000000000 --- a/libs/zlibng/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: CI Release -on: - push: - tags: - - '*' -jobs: - ci-cmake: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: Windows MSVC Win32 - os: windows-latest - compiler: cl - cmake-args: -A Win32 - deploy-name: win32 - - - name: Windows MSVC Win32 Compat - os: windows-latest - compiler: cl - cmake-args: -A Win32 -DZLIB_COMPAT=ON - deploy-name: win32-compat - - - name: Windows MSVC Win64 - os: windows-latest - compiler: cl - cmake-args: -A x64 - deploy-name: win64 - - - name: Windows MSVC Win64 Compat - os: windows-latest - compiler: cl - cmake-args: -A x64 -DZLIB_COMPAT=ON - deploy-name: win64-compat - - steps: - - name: Checkout repository - uses: actions/checkout@v1 - - - name: Set environment variables - shell: bash - run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - - - name: Generate project files - run: | - cmake . ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Release -DZLIB_ENABLE_TESTS=ON -DCMAKE_INSTALL_PREFIX=out -DINSTALL_UTILS=ON - env: - CC: ${{ matrix.compiler }} - CI: true - - - name: Compile source code - run: | - cmake --build . --config Release --target install - - - name: Package release (Windows) - if: runner.os == 'Windows' - run: | - cd out - 7z a -tzip ../zlib-ng-${{ matrix.deploy-name }}.zip bin include lib ../LICENSE.md ../README.md - - - name: Upload release (Windows) - uses: svenstaro/upload-release-action@v1-release - if: runner.os == 'Windows' - with: - asset_name: zlib-ng-${{ matrix.deploy-name }}.zip - file: zlib-ng-${{ matrix.deploy-name }}.zip - tag: ${{env.tag}} - repo_token: ${{ secrets.GITHUB_TOKEN }} - overwrite: true - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/libs/zlibng/.gitignore b/libs/zlibng/.gitignore index 23f9fd159..50e5ee6fa 100644 --- a/libs/zlibng/.gitignore +++ b/libs/zlibng/.gitignore @@ -13,18 +13,14 @@ *.gcno *.gcov -/adler32_test -/adler32_testsh /example /example64 /examplesh /libz.so* /libz-ng.so* -/makefixed /minigzip /minigzip64 /minigzipsh -/switchlevels /zlib.pc /zlib-ng.pc /CVE-2003-0107 @@ -50,9 +46,8 @@ foo.gz CMakeCache.txt CMakeFiles Testing -/*.cmake +*.cmake *.stackdump -*._h zconf.h zconf.h.cmakein zconf.h.included @@ -66,7 +61,6 @@ a.out /Makefile /arch/arm/Makefile /arch/generic/Makefile -/arch/power/Makefile /arch/x86/Makefile .kdev4 *.kdev4 @@ -77,10 +71,6 @@ a.out /zlib.dir /zlibstatic.dir /win32/Debug -/build/ -/build[.-]*/ -/btmp[12]/ -/pkgtmp[12]/ /.idea /cmake-build-debug diff --git a/libs/zlibng/.shellcheckrc b/libs/zlibng/.shellcheckrc deleted file mode 100644 index 89a1625ff..000000000 --- a/libs/zlibng/.shellcheckrc +++ /dev/null @@ -1 +0,0 @@ -disable=SC2140,SC2086,SC2046,SC2015,SC1097,SC1035,SC1036,SC1007,SC2154,SC2155,SC2000,SC2034,SC2016,SC1091,SC1090,SC2212,SC2143,SC2129,SC2102,SC2069,SC1041,SC1042,SC1044,SC1046,SC1119,SC1110,SC1111,SC1112,SC1102,SC1105,SC1101,SC1004,SC1003,SC1012,SC2068,SC2065,SC2064,SC2063,SC2059,SC2053,SC2048,SC2044,SC2032,SC2031,SC2030,SC2029,SC2025,SC2024,SC2022,SC2018,SC2019,SC2017,SC2014,SC2013,SC2012,SC2009,SC2001,SC2098,SC2096,SC2094,SC2091,SC2092,SC2088,SC2087,SC2076,SC2072,SC2071,SC2223,SC2221,SC2222,SC2217,SC2207,SC2206,SC2205,SC2190,SC2188,SC2187,SC2185,SC2179,SC2178,SC2174,SC2168,SC2167,SC2163,SC2161,SC2160,SC2153,SC2150,SC2148,SC2147,SC2146,SC2142,SC2139,SC2126,SC2123,SC2120,SC2119,SC2117,SC2114,SC1117,SC2164,SC1083,SC2004,SC2125,SC2128,SC2011,SC1008,SC1019,SC2093,SC1132,SC1129,SC2236,SC2237,SC2231,SC2230,SC2229,SC2106,SC2102,SC2243,SC2244,SC2245,SC2247,SC2248,SC2249,SC2250,SC2251,SC2252,SC2181 diff --git a/libs/zlibng/.travis.yml b/libs/zlibng/.travis.yml new file mode 100644 index 000000000..a27e41472 --- /dev/null +++ b/libs/zlibng/.travis.yml @@ -0,0 +1,283 @@ +language: c +cache: ccache +dist: xenial + +env: + global: + - BUILDDIR=. + - MAKER="make -j2" + - TESTER="make test" + +matrix: + include: + - os: windows + compiler: clang + env: + - GENERATOR="cmake . " + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - os: windows + compiler: clang + env: + - GENERATOR="cmake ..\\zlib-ng -DZLIB_COMPAT=ON" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - BUILDDIR=..\\build + - os: windows + compiler: gcc + env: + - GENERATOR="cmake ." + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + + - os: linux + compiler: gcc + env: GENERATOR="./configure --warn" + - os: linux + compiler: gcc + env: GENERATOR="cmake . -DZLIB_COMPAT=OFF -DWITH_GZFILEOP=ON -DWITH_NEW_STRATEGIES=YES -DWITH_OPTIM=ON" + - os: linux + compiler: gcc + env: + - GENERATOR="../zlib-ng/configure --warn --zlib-compat" + - BUILDDIR=../build + - os: linux + compiler: gcc + env: GENERATOR="./configure --warn --zlib-compat --without-optimizations --without-new-strategies" + - os: linux + compiler: gcc + env: GENERATOR="cmake ." + - os: linux + compiler: gcc + env: + - GENERATOR="cmake ../zlib-ng" + - BUILDDIR=../build + + - os: linux + compiler: clang + env: GENERATOR="./configure --warn --zlib-compat" + - os: linux + compiler: clang + env: + - GENERATOR="cmake ../zlib-ng" + - BUILDDIR=../build + - os: linux + compiler: clang + env: + - GENERATOR="scan-build -v --status-bugs cmake ../zlib-ng" + - MAKER="scan-build -v --status-bugs make" + - BUILDDIR=../build + + - os: osx + compiler: gcc + env: GENERATOR="./configure --warn --zlib-compat" + - os: osx + compiler: gcc + env: + - GENERATOR="../zlib-ng/configure --warn --zlib-compat" + - BUILDDIR=../build + - os: osx + compiler: gcc + env: GENERATOR="cmake ." + + - os: osx + compiler: clang + env: GENERATOR="./configure --warn --zlib-compat" + - os: osx + compiler: clang + env: + - GENERATOR="cmake ../zlib-ng" + - BUILDDIR=../build + + # compiling for linux-ppc64le variants + - os: linux-ppc64le + compiler: gcc + env: GENERATOR="cmake ." + - os: linux-ppc64le + compiler: gcc + env: + - GENERATOR="cmake ../zlib-ng" + - BUILDDIR=../build + + - os: linux-ppc64le + compiler: clang + env: GENERATOR="./configure --warn --zlib-compat" + - os: linux-ppc64le + compiler: clang + env: + - GENERATOR="cmake ../zlib-ng" + - BUILDDIR=../build + + # Cross compiling for arm variants + - os: linux + compiler: aarch64-linux-gnu-gcc + addons: + apt: + packages: + - qemu + - gcc-aarch64-linux-gnu + - libc-dev-arm64-cross + # For all aarch64 implementations NEON is mandatory, while crypto/crc are not. + env: + - GENERATOR="./configure --warn --zlib-compat" + - CHOST=aarch64-linux-gnu + - os: linux + compiler: aarch64-linux-gnu-gcc + addons: + apt: + packages: + - qemu + - gcc-aarch64-linux-gnu + - libc-dev-arm64-cross + # For all aarch64 implementations NEON is mandatory, while crypto/crc are not. + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake . -DZLIB_COMPAT=ON" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - os: linux + compiler: aarch64-linux-gnu-gcc + addons: + apt: + packages: + - qemu + - gcc-aarch64-linux-gnu + - libc-dev-arm64-cross + env: + - GENERATOR="./configure --warn --zlib-compat" + - CHOST=aarch64-linux-gnu + - os: linux + compiler: aarch64-linux-gnu-gcc + addons: + apt: + packages: + - qemu + - gcc-aarch64-linux-gnu + - libc-dev-arm64-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake ." + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + # Hard-float subsets + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="./configure --warn" + - CHOST=arm-linux-gnueabihf + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake . -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="./configure --warn --zlib-compat --without-neon" + - CHOST=arm-linux-gnueabihf + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake . -DZLIB_COMPAT=ON -DWITH_NEON=OFF -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="./configure --warn --zlib-compat" + - CHOST=arm-linux-gnueabihf + - os: linux + compiler: arm-linux-gnueabihf-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabihf + - libc-dev-armhf-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake . -DZLIB_COMPAT=ON -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + # Soft-float subset + - os: linux + compiler: arm-linux-gnueabi-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabi + - libc-dev-armel-cross + env: + - GENERATOR="./configure" + - CHOST=arm-linux-gnueabi + - os: linux + compiler: arm-linux-gnueabi-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabi + - libc-dev-armel-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake . -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + - os: linux + compiler: arm-linux-gnueabi-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabi + - libc-dev-armel-cross + env: + - GENERATOR="./configure --zlib-compat" + - CHOST=arm-linux-gnueabi + - os: linux + compiler: arm-linux-gnueabi-gcc + addons: + apt: + packages: + - qemu + - gcc-arm-linux-gnueabi + - libc-dev-armel-cross + env: + - GENERATOR="cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake . -DZLIB_COMPAT=ON -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi" + - MAKER="cmake --build . --config Release" + - TESTER="ctest --verbose -C Release" + +script: + - mkdir -p $BUILDDIR + - cd $BUILDDIR + - $GENERATOR + - $MAKER + - $TESTER diff --git a/libs/zlibng/CMakeLists.txt b/libs/zlibng/CMakeLists.txt index 05087781e..9767a00c8 100644 --- a/libs/zlibng/CMakeLists.txt +++ b/libs/zlibng/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 3.5.1) if(CMAKE_VERSION VERSION_LESS 3.12) - cmake_policy(VERSION ${CMAKE_VERSION}) + cmake_policy(VERSION ${CMAKE_VERSION}) else() - cmake_policy(VERSION 3.5.1...3.13.2) + cmake_policy(VERSION 3.5.1...3.13.2) endif() -message(STATUS "Using CMake version ${CMAKE_VERSION}") set(CMAKE_MACOSX_RPATH 1) @@ -12,17 +11,17 @@ set(CMAKE_MACOSX_RPATH 1) # Configuration items that affect the global compiler envirionment standards # should be issued before the "project" command. if(NOT CMAKE_C_STANDARD) - set(CMAKE_C_STANDARD 99) # The C standard whose features are requested to build this target + set (CMAKE_C_STANDARD 99) # The C standard whose features are requested to build this target endif() if(NOT CMAKE_C_STANDARD_REQUIRED) - set(CMAKE_C_STANDARD_REQUIRED ON) # Boolean describing whether the value of C_STANDARD is a requirement + set (CMAKE_C_STANDARD_REQUIRED ON) # Boolean describing whether the value of C_STANDARD is a requirement endif() if(NOT CMAKE_C_EXTENSIONS) - set(CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested + set (CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested endif() set(VALID_C_STANDARDS "99" "11") -if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS) - MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in know standards list\n ${VALID_C_STANDARDS}") +if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS ) + MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in know standards list\n ${VALID_C_STANDARDS}") endif() # Parse the full version number from zlib.h and include in ZLIB_FULL_VERSION @@ -34,13 +33,15 @@ string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" message(STATUS "ZLIB_HEADER_VERSION: ${ZLIB_HEADER_VERSION}") message(STATUS "ZLIBNG_HEADER_VERSION: ${ZLIBNG_HEADER_VERSION}") -project(zlib VERSION ${ZLIB_HEADER_VERSION} LANGUAGES C) +project(zlib + VERSION ${ZLIB_HEADER_VERSION} + LANGUAGES C) -set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") +set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") +set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") +set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") +set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") include(CheckTypeSize) include(CheckSymbolExists) @@ -51,13 +52,6 @@ include(CheckCSourceRuns) include(CMakeDependentOption) include(FeatureSummary) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect-arch.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect-sanitizer.cmake) - -if(CMAKE_TOOLCHAIN_FILE) - message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}") -endif() - # Make sure we use an appropriate BUILD_TYPE by default, "Release" to be exact # this should select the maximum generic optimisation on the current platform (i.e. -O3 for gcc/clang) if(NOT CMAKE_BUILD_TYPE) @@ -69,67 +63,64 @@ else() add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (selected)") endif() +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(stddef.h HAVE_STDDEF_H) +check_include_file(sys/sdt.h HAVE_SYS_SDT_H) + +if(CMAKE_OSX_ARCHITECTURES) + # If multiple architectures are requested (universal build), pick only the first + list(GET CMAKE_OSX_ARCHITECTURES 0 ARCH) +else() + set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) +endif() +message(STATUS "Architecture: ${ARCH}") +if(CMAKE_TOOLCHAIN_FILE) + message(STATUS "Using cmake toolchain: ${CMAKE_TOOLCHAIN_FILE}") +endif() + # # Options parsing # -macro(add_option name description value) - option(${name} ${description} ${value}) - add_feature_info(${name} ${name} ${description}) -endmacro() - -add_option(WITH_GZFILEOP "Compile with support for gzFile related functions" ON) -add_option(ZLIB_COMPAT "Compile with zlib compatible API" OFF) -add_option(ZLIB_ENABLE_TESTS "Build test binaries" ON) -add_option(ZLIB_DUAL_LINK "Dual link tests against system zlib" OFF) -add_option(WITH_SANITIZER "Build with sanitizer (Memory, Address, Undefined)" OFF) -add_option(WITH_FUZZERS "Build test/fuzz" OFF) -add_option(WITH_OPTIM "Build with optimisation" ON) -add_option(WITH_NEW_STRATEGIES "Use new strategies" ON) -add_option(WITH_NATIVE_INSTRUCTIONS +option(WITH_GZFILEOP "Compile with support for gzFile related functions" OFF) +option(ZLIB_COMPAT "Compile with zlib compatible API" OFF) +option(ZLIB_ENABLE_TESTS "Build test binaries" ON) +option(WITH_SANITIZERS "Build with address sanitizer and all supported sanitizers other than memory sanitizer" OFF) +option(WITH_MSAN "Build with memory sanitizer" OFF) +option(WITH_FUZZERS "Build test/fuzz" OFF) +option(WITH_OPTIM "Build with optimisation" ON) +option(WITH_NEW_STRATEGIES "Use new strategies" ON) +option(WITH_NATIVE_INSTRUCTIONS "Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF) -add_option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF) -add_option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF) -add_option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF) -add_option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF) -add_option(WITH_UNALIGNED "Support unaligned reads on platforms that support it" ON) - -if(BASEARCH_ARM_FOUND) - add_option(WITH_ACLE "Build with ACLE" ON) - add_option(WITH_NEON "Build with NEON intrinsics" ON) -elseif(BASEARCH_PPC_FOUND) - add_option(WITH_POWER8 "Build with optimisations for POWER8" ON) -elseif(BASEARCH_S360_FOUND) - add_option(WITH_DFLTCC_DEFLATE "Use DEFLATE CONVERSION CALL instruction for compression on IBM Z" OFF) - add_option(WITH_DFLTCC_INFLATE "Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z" OFF) -elseif(BASEARCH_X86_FOUND) - add_option(WITH_AVX2 "Build with AVX2" ON) - add_option(WITH_SSE2 "Build with SSE2" ON) - add_option(WITH_SSSE3 "Build with SSSE3" ON) - add_option(WITH_SSE4 "Build with SSE4" ON) - add_option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON) +if("${ARCH}" MATCHES "arm" OR "${ARCH}" MATCHES "aarch64") + option(WITH_ACLE "Build with ACLE CRC" ON) + option(WITH_NEON "Build with NEON intrinsics" ON) +elseif("${ARCH}" MATCHES "s390x") + option(WITH_DFLTCC_DEFLATE "Use DEFLATE CONVERSION CALL instruction for compression on IBM Z" OFF) + option(WITH_DFLTCC_INFLATE "Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z" OFF) endif() -add_option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF) -mark_as_advanced(FORCE - ZLIB_DUAL_LINK - WITH_ACLE WITH_NEON - WITH_DFLTCC_DEFLATE - WITH_DFLTCC_INFLATE - WITH_AVX2 WITH_SSE2 - WITH_SSSE3 WITH_SSE4 - WITH_PCLMULQDQ - WITH_POWER8 - WITH_INFLATE_STRICT - WITH_INFLATE_ALLOW_INVALID_DIST - WITH_UNALIGNED - INSTALL_UTILS - ) +add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Provide a zlib-compatible API") +add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile-related functions") +add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation") +add_feature_info(WITH_SANITIZERS WITH_SANITIZERS "Build with address sanitizer and all supported sanitizers other than memory sanitizer") +add_feature_info(WITH_MSAN WITH_MSAN "Build with memory sanitizer") +add_feature_info(WITH_FUZZERS WITH_FUZZERS "Build test/fuzz") +add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies") +if("${ARCH}" MATCHES "arm" OR "${ARCH}" MATCHES "aarch64") + add_feature_info(WITH_ACLE WITH_ACLE "Build with ACLE CRC") + add_feature_info(WITH_NEON WITH_NEON "Build with NEON intrinsics") +endif() -if(ZLIB_COMPAT) +if (ZLIB_COMPAT) add_definitions(-DZLIB_COMPAT) set(WITH_GZFILEOP ON) - set(SUFFIX "-ng") + set(LIBNAME1 libz) + set(LIBNAME2 zlib) + set(SUFFIX "") else() + set(LIBNAME1 libz-ng) + set(LIBNAME2 zlib-ng) set(SUFFIX "-ng") endif() @@ -137,48 +128,36 @@ if(WITH_GZFILEOP) add_definitions(-DWITH_GZFILEOP) endif() -if("${CMAKE_C_COMPILER}" MATCHES "icc" OR "${CMAKE_C_COMPILER}" MATCHES "icpc" OR "${CMAKE_C_COMPILER}" MATCHES "icl") - if(CMAKE_HOST_UNIX OR APPLE) - set(WARNFLAGS "-w3") - set(WARNFLAGS_MAINTAINER "-w3 -Wcheck -Wremarks") - set(WARNFLAGS_DISABLE "") - if(BASEARCH_X86_FOUND) - set(AVX2FLAG "-mavx2") +if(${CMAKE_C_COMPILER} MATCHES "icc" OR ${CMAKE_C_COMPILER} MATCHES "icpc" OR ${CMAKE_C_COMPILER} MATCHES "icl") + if(WITH_NATIVE_INSTRUCTIONS) + message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") + endif() + if(CMAKE_HOST_UNIX) + if(NOT SSE2FLAG) set(SSE2FLAG "-msse2") - set(SSSE3FLAG "-mssse3") + endif() + if(NOT SSE4FLAG) set(SSE4FLAG "-msse4.2") endif() else() - set(WARNFLAGS "/W3") - set(WARNFLAGS_MAINTAINER "/W5") - set(WARNFLAGS_DISABLE "") - if(BASEARCH_X86_FOUND) - set(AVX2FLAG "/arch:AVX2") + if(NOT SSE2FLAG) set(SSE2FLAG "/arch:SSE2") - set(SSSE3FLAG "/arch:SSSE3") + endif() + if(NOT SSE4FLAG) set(SSE4FLAG "/arch:SSE4.2") endif() endif() - if(WITH_NATIVE_INSTRUCTIONS) - message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") - endif() elseif(MSVC) # TODO. ICC can be used through MSVC. I'm not sure if we'd ever see that combination # (who'd use cmake from an IDE...) but checking for ICC before checking for MSVC should # avoid mistakes. # /Oi ? - set(WARNFLAGS "/W3") - set(WARNFLAGS_MAINTAINER "/W4") - set(WARNFLAGS_DISABLE "") - if(BASEARCH_ARM_FOUND) - add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE) - if(NOT "${ARCH}" MATCHES "aarch64") - set(NEONFLAG "/arch:VFPv4") - endif() - elseif(BASEARCH_X86_FOUND) - if(NOT "${ARCH}" MATCHES "x86_64") - set(SSE2FLAG "/arch:SSE2") - endif() + if(NOT ${ARCH} MATCHES "AMD64") + set(SSE2FLAG "/arch:SSE2") + endif() + if("${ARCH}" MATCHES "arm") + add_definitions("-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1") + set(NEONFLAG "/arch:VFPv4") endif() if(WITH_NATIVE_INSTRUCTIONS) message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") @@ -188,160 +167,85 @@ else() if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") set(__GNUC__ ON) endif() - # Enable warnings in GCC and Clang - if(__GNUC__) - set(WARNFLAGS "-Wall") - set(WARNFLAGS_MAINTAINER "-Wextra -Wpedantic") - set(WARNFLAGS_DISABLE "-Wno-implicit-fallthrough") - endif() if(WITH_NATIVE_INSTRUCTIONS) if(__GNUC__) - if(BASEARCH_PPC_FOUND) - set(NATIVEFLAG "-mcpu=native") - else() - set(NATIVEFLAG "-march=native") - endif() + set(NATIVEFLAG "-march=native") else() message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not implemented yet on this configuration") endif() endif() + if(__GNUC__ AND "${ARCH}" MATCHES "arm") + execute_process(COMMAND ${CMAKE_C_COMPILER} "-dumpmachine" + OUTPUT_VARIABLE GCC_MACHINE) + if ("${GCC_MACHINE}" MATCHES "eabihf") + set(FLOATABI "-mfloat-abi=hard") + else() + set(FLOATABI "-mfloat-abi=softfp") + endif() + endif() if(NOT NATIVEFLAG) - if(__GNUC__) - if(BASEARCH_ARM_FOUND) - if(NOT CMAKE_C_FLAGS MATCHES "-mfloat-abi") - # Check support for ARM floating point - execute_process(COMMAND ${CMAKE_C_COMPILER} "-dumpmachine" - OUTPUT_VARIABLE GCC_MACHINE) - if("${GCC_MACHINE}" MATCHES "gnueabihf") - set(FLOATABI "-mfloat-abi=hard") - elseif("${GCC_MACHINE}" MATCHES ".*gnueabi") - set(FLOATABI "-mfloat-abi=softfp") - endif() - message(STATUS "ARM floating point arch: ${FLOATABI}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLOATABI}") - endif() - # NEON - if("${ARCH}" MATCHES "aarch64") - set(NEONFLAG "-march=armv8-a+simd") - else() - # Check whether -mfpu=neon is available - set(CMAKE_REQUIRED_FLAGS "-mfpu=neon") - check_c_source_compiles( - "int main() { return 0; }" - MFPU_NEON_AVAILABLE FAIL_REGEX "not supported") - set(CMAKE_REQUIRED_FLAGS) - if(MFPU_NEON_AVAILABLE) - set(NEONFLAG "-mfpu=neon") - endif() - endif() - # ACLE - set(ACLEFLAG "-march=armv8-a+crc") - elseif(BASEARCH_PPC_FOUND) - set(POWER8FLAG "-mcpu=power8") - elseif(BASEARCH_X86_FOUND) - set(AVX2FLAG "-mavx2") + if(NOT SSE2FLAG) + if(__GNUC__) set(SSE2FLAG "-msse2") - set(SSSE3FLAG "-mssse3") + endif() + endif() + if(NOT SSE4FLAG) + if(__GNUC__) set(SSE4FLAG "-msse4") + endif() + endif() + if(NOT PCLMULFLAG) + if(__GNUC__) set(PCLMULFLAG "-mpclmul") endif() endif() - endif() -endif() - -# Replace optimization level 3 added by default with level 2 -if(NOT MSVC AND NOT CMAKE_C_FLAGS MATCHES "([\\/\\-]O)3") - string(REGEX REPLACE "([\\/\\-]O)3" "\\12" - CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) -endif() - -# Set architecture alignment requirements -if(WITH_UNALIGNED) - if(BASEARCH_ARM_FOUND OR (BASEARCH_PPC_FOUND AND "${ARCH}" MATCHES "powerpc64le") OR BASEARCH_X86_FOUND) - if(NOT DEFINED UNALIGNED_OK) - set(UNALIGNED_OK TRUE) + if("${ARCH}" MATCHES "arm") + set(ACLEFLAG "-march=armv8-a+crc") + set(NEONFLAG "${FLOATABI} -mfpu=neon") + elseif("${ARCH}" MATCHES "aarch64") + set(ACLEFLAG "-march=armv8-a+crc") + set(NEONFLAG "-march=armv8-a+crc+simd") + endif() + else() + set(SSE2FLAG ${NATIVEFLAG}) + set(SSE4FLAG ${NATIVEFLAG}) + set(PCLMULFLAG ${NATIVEFLAG}) + if("${ARCH}" MATCHES "arm") + set(ACLEFLAG "${NATIVEFLAG}") + set(NEONFLAG "${FLOATABI} -mfpu=neon") + elseif("${ARCH}" MATCHES "aarch64") + set(ACLEFLAG "${NATIVEFLAG}") + set(NEONFLAG "${NATIVEFLAG}") endif() endif() - if(UNALIGNED_OK) - add_definitions(-DUNALIGNED_OK) - message(STATUS "Architecture supports unaligned reads") - endif() - if(BASEARCH_ARM_FOUND) - if(NOT DEFINED UNALIGNED64_OK) - if("${ARCH}" MATCHES "(arm(v[8-9])?|aarch64)") - set(UNALIGNED64_OK TRUE) - endif() - endif() - endif() - if(BASEARCH_PPC_FOUND) - if(NOT DEFINED UNALIGNED64_OK) - if("${ARCH}" MATCHES "powerpc64le") - set(UNALIGNED64_OK TRUE) - endif() - endif() - endif() - if(BASEARCH_X86_FOUND) - if(NOT DEFINED UNALIGNED64_OK) - set(UNALIGNED64_OK TRUE) - endif() - endif() - if(UNALIGNED64_OK) - add_definitions(-DUNALIGNED64_OK) - message(STATUS "Architecture supports unaligned reads of > 4 bytes") - endif() -else() - message(STATUS "Unaligned reads manually disabled") endif() -# Apply warning compiler flags -if(WITH_MAINTAINER_WARNINGS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNFLAGS} ${WARNFLAGS_MAINTAINER} ${WARNFLAGS_DISABLE}") -else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNFLAGS} ${WARNFLAGS_DISABLE}") -endif() - -# Set code coverage compiler flags -if(WITH_CODE_COVERAGE) - if(CMAKE_C_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS "-O0 ${CMAKE_C_FLAGS} -coverage") - elseif(__GNUC__) - # Some versions of GCC don't support -coverage shorthand - set(CMAKE_C_FLAGS "-O0 ${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs -fprofile-values") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov -fprofile-arcs") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcov -fprofile-arcs") - endif() -endif() - -# Set native instruction set compiler flag -if(WITH_NATIVE_INSTRUCTIONS AND DEFINED NATIVEFLAG) - # Apply flag to all source files and compilation checks - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NATIVEFLAG}") -endif() - -# -# Check for stndard/system includes -# -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdarg.h HAVE_STDARG_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) -check_include_file(sys/sdt.h HAVE_SYS_SDT_H) -check_include_file(unistd.h HAVE_UNISTD_H) - # # Check to see if we have large file support # set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) +# We add these other definitions here because CheckTypeSize.cmake +# in CMake 2.4.x does not automatically do so and we want +# compatibility with CMake 2.4.x. +if(HAVE_SYS_TYPES_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) +endif() +if(HAVE_STDINT_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) +endif() +if(HAVE_STDDEF_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) +endif() check_type_size(off64_t OFF64_T) if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) + add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) else() - check_type_size(_off64_t _OFF64_T) - if(HAVE__OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) - else() - check_type_size(__off64_t __OFF64_T) - endif() + check_type_size(_off64_t _OFF64_T) + if(HAVE__OFF64_T) + add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) + else() + check_type_size(__off64_t __OFF64_T) + endif() endif() set(CMAKE_REQUIRED_DEFINITIONS) # clear variable @@ -357,81 +261,104 @@ if(NOT HAVE_STRERROR) add_definitions(-DNO_STRERROR) endif() -if(WITH_SANITIZER STREQUAL "Address") - add_address_sanitizer() -elseif(WITH_SANITIZER STREQUAL "Memory") - add_memory_sanitizer() -elseif(WITH_SANITIZER STREQUAL "Undefined") - add_undefined_sanitizer() +# +# Check for unistd.h and stdarg.h +# +check_include_file(unistd.h Z_HAVE_UNISTD_H) + +if(WITH_SANITIZERS AND WITH_MSAN) + message(FATAL_ERROR "Memory sanitizer is incompatible with address sanitizer") endif() -# -# Check whether compiler supports -fno-semantic-interposition parameter -# -set(CMAKE_REQUIRED_FLAGS "-fno-semantic-interposition") -check_c_source_compiles( - "int main() { return 0; }" - HAVE_NO_INTERPOSITION -) -set(CMAKE_REQUIRED_FLAGS) +if(WITH_MSAN) + set(CMAKE_REQUIRED_FLAGS "-fsanitize=memory") + check_c_source_compiles("int main() { return 0; }" HAS_MSAN FAIL_REGEX "not supported") + if(${HAS_MSAN}) + set(SANITIZERS_FLAGS "-fsanitize=memory") + message(STATUS "Adding memory sanitizer flag: ${SANITIZERS_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZERS_FLAGS}") + endif() +endif() + +if(WITH_SANITIZERS) + set(_sanitize_flags + bool + address + array-bounds + float-divide-by-zero + function + integer-divide-by-zero + return + shift + signed-integer-overflow + undefined + unsigned-integer-overflow + vla-bound + vptr + ) + set(SANITIZERS_FLAGS "") + foreach(_flag ${_sanitize_flags}) + set(CMAKE_REQUIRED_FLAGS "-fsanitize=${_flag}") + check_c_source_compiles("int main() { return 0; }" + HAS_SANITIZER_${_flag} FAIL_REGEX "not supported") + if(${HAS_SANITIZER_${_flag}}) + if("${SANITIZERS_FLAGS}" STREQUAL "") + set(SANITIZERS_FLAGS "-fsanitize=${_flag}") + else() + set(SANITIZERS_FLAGS "${SANITIZERS_FLAGS},${_flag}") + endif() + endif() + set(CMAKE_REQUIRED_FLAGS) + endforeach() + message(STATUS "Adding sanitizers flags: ${SANITIZERS_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZERS_FLAGS}") +endif() # # Check if we can hide zlib internal symbols that are linked between separate source files using hidden # check_c_source_compiles( - "#define Z_INTERNAL __attribute__((visibility (\"hidden\"))) - int Z_INTERNAL foo; - int main() { - return 0; + "#define ZLIB_INTERNAL __attribute__((visibility (\"hidden\"))) + int ZLIB_INTERNAL foo; + int main() + { + return 0; }" HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "not supported") if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN) - add_definitions(-DHAVE_VISIBILITY_HIDDEN) + add_definitions(-DHAVE_HIDDEN) endif() # # Check if we can hide zlib internal symbols that are linked between separate source files using internal # check_c_source_compiles( - "#define Z_INTERNAL __attribute__((visibility (\"internal\"))) - int Z_INTERNAL foo; - int main() { - return 0; + "#define ZLIB_INTERNAL __attribute__((visibility (\"internal\"))) + int ZLIB_INTERNAL foo; + int main() + { + return 0; }" HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "not supported") if(HAVE_ATTRIBUTE_VISIBILITY_INTERNAL) - add_definitions(-DHAVE_VISIBILITY_INTERNAL) + add_definitions(-DHAVE_INTERNAL) endif() # -# check for __builtin_ctz() support in the compiler +# check for __builtin_ctzl() support in the compiler # check_c_source_compiles( - "int main(void) { + "int main(void) + { unsigned int zero = 0; - long test = __builtin_ctz(zero); + long test = __builtin_ctzl(zero); (void)test; return 0; }" - HAVE_BUILTIN_CTZ + HAVE_BUILTIN_CTZL ) -if(HAVE_BUILTIN_CTZ) - add_definitions(-DHAVE_BUILTIN_CTZ) -endif() -# -# check for __builtin_ctzll() support in the compiler -# -check_c_source_compiles( - "int main(void) { - unsigned int zero = 0; - long test = __builtin_ctzll(zero); - (void)test; - return 0; - }" - HAVE_BUILTIN_CTZLL -) -if(HAVE_BUILTIN_CTZLL) - add_definitions(-DHAVE_BUILTIN_CTZLL) +if(HAVE_BUILTIN_CTZL) + add_definitions(-DHAVE_BUILTIN_CTZL) endif() # @@ -439,32 +366,28 @@ endif() # check_c_source_compiles( "#include - int main() { - ptrdiff_t *a; - (void)a; - return 0; - }" + int main() { ptrdiff_t *a; return 0; }" HAVE_PTRDIFF_T ) if(NOT HAVE_PTRDIFF_T) - set(NEED_PTRDIFF_T 1) + set(NEED_PTRDIFF_T 1) - check_type_size("void *" SIZEOF_DATA_PTR) - message(STATUS "sizeof(void *) is ${SIZEOF_DATA_PTR} bytes") + check_type_size("void *" SIZEOF_DATA_PTR) + message(STATUS "sizeof(void *) is ${SIZEOF_DATA_PTR} bytes") - if(${SIZEOF_DATA_PTR} MATCHES "4") - set(PTRDIFF_TYPE "uint32_t") - elseif(${SIZEOF_DATA_PTR} MATCHES "8") - set(PTRDIFF_TYPE "uint64_t") - else() - message(FATAL_ERROR "sizeof(void *) is neither 32 nor 64 bit") - endif() + if(${SIZEOF_DATA_PTR} MATCHES "4") + set(PTRDIFF_TYPE "uint32_t") + elseif(${SIZEOF_DATA_PTR} MATCHES "8") + set(PTRDIFF_TYPE "uint64_t") + else() + message(FATAL_ERROR "sizeof(void *) is neither 32 nor 64 bit") + endif() endif() -# Macro to check if source compiles -# (and, when compiling very natively, also runs). +# Macro to check if source compiles when cross-compiling +# or runs when compiling natively macro(check_c_source_compile_or_run source flag) - if(CMAKE_CROSSCOMPILING OR NOT WITH_NATIVE_INSTRUCTIONS) + if(CMAKE_CROSSCOMPILING) check_c_source_compiles("${source}" ${flag}) else() check_c_source_runs("${source}" ${flag}) @@ -477,95 +400,67 @@ if(MSVC) set(CMAKE_DEBUG_POSTFIX "d") add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) -endif() - -if(BASEARCH_PPC_FOUND) - # Check if we have what we need for POWER8 optimizations - set(CMAKE_REQUIRED_FLAGS "${POWER8FLAG}") - check_c_source_compiles( - "#include - int main() { - return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07); - }" - HAVE_POWER8 - ) - set(CMAKE_REQUIRED_FLAGS) -elseif(BASEARCH_X86_FOUND) - # Check whether compiler supports SSE2 instrinics - set(CMAKE_REQUIRED_FLAGS "${SSE2FLAG}") +else() + # + # Not MSVC, so we need to check if we have the MS-style SSE etc. intrinsics + # + if(WITH_NATIVE_INSTRUCTIONS) + set(CMAKE_REQUIRED_FLAGS "${NATIVEFLAG}") + else() + set(CMAKE_REQUIRED_FLAGS "${SSE2FLAG}") + endif() check_c_source_compile_or_run( "#include - int main(void) { + int main(void) + { __m128i zero = _mm_setzero_si128(); (void)zero; return 0; }" HAVE_SSE2_INTRIN ) - # Check whether compiler supports SSSE3 intrinsics - set(CMAKE_REQUIRED_FLAGS "${SSSE3FLAG}") + set(CMAKE_REQUIRED_FLAGS) + + if(WITH_NATIVE_INSTRUCTIONS) + set(CMAKE_REQUIRED_FLAGS "${NATIVEFLAG}") + else() + # Use the generic SSE4 enabler option to check for the SSE4.2 instruction we require: + set(CMAKE_REQUIRED_FLAGS "${SSE4FLAG}") + endif() check_c_source_compile_or_run( - "#include - int main(void) { - __m128i u, v, w; - u = _mm_set1_epi32(1); - v = _mm_set1_epi32(2); - w = _mm_hadd_epi32(u, v); - (void)w; - return 0; - }" - HAVE_SSSE3_INTRIN - ) - # Check whether compiler supports SSE4 CRC inline asm - set(CMAKE_REQUIRED_FLAGS "${SSE4FLAG}") - check_c_source_compile_or_run( - "int main(void) { + "int main(void) + { unsigned val = 0, h = 0; - #if defined(_MSC_VER) - { __asm mov edx, h __asm mov eax, val __asm crc32 eax, edx __asm mov val, eax } - #else __asm__ __volatile__ ( \"crc32 %1,%0\" : \"+r\" (h) : \"r\" (val) ); - #endif - return (int)h; + return (int) h; }" - HAVE_SSE42CRC_INLINE_ASM + HAVE_SSE42_INTRIN ) - # Check whether compiler supports SSE4 CRC intrinsics check_c_source_compile_or_run( - "#include - int main(void) { + "int main(void) + { unsigned crc = 0; char c = 'c'; - #if defined(_MSC_VER) - crc = _mm_crc32_u32(crc, c); - #else crc = __builtin_ia32_crc32qi(crc, c); - #endif (void)crc; return 0; }" HAVE_SSE42CRC_INTRIN ) - # Check whether compiler supports SSE4.2 compare string instrinics - check_c_source_compile_or_run( - "#include - int main(void) { - unsigned char a[64] = { 0 }; - unsigned char b[64] = { 0 }; - __m128i xmm_src0, xmm_src1; - xmm_src0 = _mm_loadu_si128((__m128i *)(char *)a); - xmm_src1 = _mm_loadu_si128((__m128i *)(char *)b); - return _mm_cmpestri(xmm_src0, 16, xmm_src1, 16, 0); - }" - HAVE_SSE42CMPSTR_INTRIN - ) - # Check whether compiler supports PCLMULQDQ intrinsics - set(CMAKE_REQUIRED_FLAGS "${PCLMULFLAG}") - if(NOT (APPLE AND "${ARCH}" MATCHES "i386")) + set(CMAKE_REQUIRED_FLAGS) + + if(WITH_NATIVE_INSTRUCTIONS) + set(CMAKE_REQUIRED_FLAGS "${NATIVEFLAG}") + else() + set(CMAKE_REQUIRED_FLAGS "${PCLMULFLAG}") + endif() + if(NOT (APPLE AND ${ARCH} MATCHES "i386")) # The pclmul code currently crashes on Mac in 32bit mode. Avoid for now. check_c_source_compile_or_run( "#include - int main(void) { + #include + int main(void) + { __m128i a = _mm_setzero_si128(); __m128i b = _mm_setzero_si128(); __m128i c = _mm_clmulepi64_si128(a, b, 0x10); @@ -577,180 +472,150 @@ elseif(BASEARCH_X86_FOUND) else() set(HAVE_PCLMULQDQ_INTRIN NO) endif() - # Check whether compiler supports AVX2 intrinics - set(CMAKE_REQUIRED_FLAGS "${AVX2FLAG}") - check_c_source_compile_or_run( - "#include - int main(void) { - __m256i x = _mm256_set1_epi16(2); - const __m256i y = _mm256_set1_epi16(1); - x = _mm256_subs_epu16(x, y); - (void)x; - return 0; - }" - HAVE_AVX2_INTRIN - ) set(CMAKE_REQUIRED_FLAGS) - - # FORCE_SSE2 option will only be shown if HAVE_SSE2_INTRIN is true - if("${ARCH}" MATCHES "i[3-6]86") - cmake_dependent_option(FORCE_SSE2 "Always assume CPU is SSE2 capable" OFF "HAVE_SSE2_INTRIN" OFF) - endif() endif() -# -# Enable deflate_quick at level 1 -# -if(NOT WITH_NEW_STRATEGIES) - add_definitions(-DNO_QUICK_STRATEGY) +# Check whether -mfpu=neon is available +set(CMAKE_REQUIRED_FLAGS "-mfpu=neon") +check_c_source_compiles( + "int main() + { + return 0; + }" + MFPU_NEON_AVAILABLE FAIL_REGEX "not supported") +set(CMAKE_REQUIRED_FLAGS) + +# FORCE_SSE2 option will only be shown if HAVE_SSE2_INTRIN is true +if("${ARCH}" MATCHES "i[3-6]86") + cmake_dependent_option(FORCE_SSE2 "Always assume CPU is SSE2 capable" OFF "HAVE_SSE2_INTRIN" OFF) endif() + # # Enable deflate_medium at level 4-6 # if(NOT WITH_NEW_STRATEGIES) add_definitions(-DNO_MEDIUM_STRATEGY) endif() -# -# Enable inflate compilation options -# -if(WITH_INFLATE_STRICT) - add_definitions(-DINFLATE_STRICT) - message(STATUS "Inflate strict distance checking enabled") -endif() -if(WITH_INFLATE_ALLOW_INVALID_DIST) - add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR) - message(STATUS "Inflate zero data for invalid distances enabled") -endif() +# +# Macro to add either the given intrinsics option to the global compiler options, +# or ${NATIVEFLAG} (-march=native) if that is appropriate and possible. +# An alternative version of this macro would take a file argument, and set ${flag} +# only for that file as opposed to ${NATIVEFLAG} globally, to limit side-effect of +# using ${flag} globally. +# +macro(add_intrinsics_option flag) + if(WITH_NATIVE_INSTRUCTIONS AND NATIVEFLAG) + if (NOT "${CMAKE_C_FLAGS} " MATCHES ".*${NATIVEFLAG} .*") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NATIVEFLAG}") + endif() + else() + if (NOT "${CMAKE_C_FLAGS} " MATCHES ".*${flag} .*") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif() + endif() +endmacro() set(ZLIB_ARCH_SRCS) -set(ZLIB_ARCH_HDRS) set(ARCHDIR "arch/generic") -if(BASEARCH_ARM_FOUND) - set(ARCHDIR "arch/arm") -elseif(BASEARCH_PPC_FOUND) - set(ARCHDIR "arch/power") -elseif(BASEARCH_S360_FOUND) - set(ARCHDIR "arch/s390") -elseif(BASEARCH_X86_FOUND) +if("${ARCH}" MATCHES "x86_64" OR "${ARCH}" MATCHES "AMD64" OR "${ARCH}" MATCHES "i[3-6]86") set(ARCHDIR "arch/x86") - if(NOT ${ARCH} MATCHES "x86_64") - add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"") - endif() + add_definitions(-DUNALIGNED_OK) + add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"") +elseif("${ARCH}" MATCHES "arm" OR "${ARCH}" MATCHES "aarch64") + set(ARCHDIR "arch/arm") + add_definitions(-DUNALIGNED_OK) +elseif("${ARCH}" MATCHES "s390x") + set(ARCHDIR "arch/s390") else() message(STATUS "No optimized architecture: using ${ARCHDIR}") endif() - +if("${ARCH}" MATCHES "arm" OR "${ARCH}" MATCHES "aarch64") + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/armfeature.c ${ARCHDIR}/fill_window_arm.c) +endif() if(WITH_OPTIM) - if(BASEARCH_ARM_FOUND) - add_definitions(-DARM_FEATURES) - list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm.h) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/armfeature.c) - if(WITH_ACLE AND NOT MSVC) - add_definitions(-DARM_ACLE_CRC_HASH) - set(ACLE_SRCS ${ARCHDIR}/crc32_acle.c ${ARCHDIR}/insert_string_acle.c) - set_property(SOURCE ${ACLE_SRCS} PROPERTY COMPILE_FLAGS "${ACLEFLAG}") - list(APPEND ZLIB_ARCH_SRCS ${ACLE_SRCS}) - add_feature_info(ACLE_CRC 1 "Support ACLE optimized CRC hash generation, using \"${ACLEFLAG}\"") + if("${ARCH}" MATCHES "arm") + if(WITH_ACLE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc32_acle.c ${ARCHDIR}/insert_string_acle.c) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ACLEFLAG}") + add_definitions("-DARM_ACLE_CRC_HASH") + add_feature_info(ACLE_CRC 1 "Support CRC hash generation using the ACLE instruction set, using \"${ACLEFLAG}\"") endif() if(WITH_NEON) - add_definitions(-DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH) - set(NEON_SRCS ${ARCHDIR}/adler32_neon.c ${ARCHDIR}/chunkset_neon.c ${ARCHDIR}/slide_neon.c) - list(APPEND ZLIB_ARCH_SRCS ${NEON_SRCS}) - set_property(SOURCE ${NEON_SRCS} PROPERTY COMPILE_FLAGS "${NEONFLAG}") + if(MFPU_NEON_AVAILABLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NEONFLAG}") + endif() + add_definitions("-DARM_NEON_ADLER32") if(MSVC) - add_definitions(-D__ARM_NEON__) - endif() - add_feature_info(NEON_ADLER32 1 "Support NEON instructions in adler32, using \"${NEONFLAG}\"") - add_feature_info(NEON_SLIDEHASH 1 "Support NEON instructions in slide_hash, using \"${NEONFLAG}\"") + add_definitions("-D__ARM_NEON__=1") + endif(MSVC) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/adler32_neon.c) + add_feature_info(NEON_FILLWINDOW 1 "Support NEON instructions in fill_window_arm, using \"${NEONFLAG}\"") endif() - elseif(BASEARCH_PPC_FOUND) - if(WITH_POWER8 AND HAVE_POWER8) - add_definitions(-DPOWER8) - add_definitions(-DPOWER_FEATURES) - add_definitions(-DPOWER8_VSX_ADLER32) - add_definitions(-DPOWER8_VSX_SLIDEHASH) - list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power.h) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power.c) - set(POWER8_SRCS ${ARCHDIR}/adler32_power8.c ${ARCHDIR}/slide_hash_power8.c) - list(APPEND ZLIB_ARCH_SRCS ${POWER8_SRCS}) - set_property(SOURCE ${POWER8_SRCS} PROPERTY COMPILE_FLAGS "${POWER8FLAG}") + elseif("${ARCH}" MATCHES "aarch64") + if(WITH_ACLE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc32_acle.c ${ARCHDIR}/insert_string_acle.c) + add_definitions("-DARM_ACLE_CRC_HASH") + add_feature_info(ACLE_CRC 1 "Support CRC hash generation using the ACLE instruction set, using \"${ACLEFLAG}\"") endif() - elseif(BASEARCH_S360_FOUND) - if(WITH_DFLTCC_DEFLATE OR WITH_DFLTCC_INFLATE) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_common.c) - add_definitions(-DGZBUFSIZE=262144) + # We need to check WITH_NEON first + if(WITH_NEON) + add_definitions("-DARM_NEON_ADLER32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NEONFLAG}") + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/adler32_neon.c) + add_feature_info(NEON_FILLWINDOW 1 "Support NEON instructions in fill_window_arm, using \"${NEONFLAG}\"") + elseif(WITH_ACLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ACLEFLAG}") endif() - if(WITH_DFLTCC_DEFLATE) - add_definitions(-DS390_DFLTCC_DEFLATE) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_deflate.c) - endif() - if(WITH_DFLTCC_INFLATE) - add_definitions(-DS390_DFLTCC_INFLATE) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_inflate.c) - endif() - elseif(BASEARCH_X86_FOUND) - add_definitions(-DX86_FEATURES) - list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86.h) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86.c) - if(MSVC) - list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h) - endif() - if(WITH_AVX2 AND HAVE_AVX2_INTRIN) - add_definitions(-DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET) - set(AVX2_SRCS ${ARCHDIR}/slide_avx.c) - add_feature_info(AVX2_SLIDEHASH 1 "Support AVX2 optimized slide_hash, using \"${AVX2FLAG}\"") - list(APPEND AVX2_SRCS ${ARCHDIR}/chunkset_avx.c) - add_feature_info(AVX_CHUNKSET 1 "Support AVX optimized chunkset, using \"${AVX2FLAG}\"") - list(APPEND AVX2_SRCS ${ARCHDIR}/compare258_avx.c) - add_feature_info(AVX2_COMPARE258 1 "Support AVX2 optimized compare258, using \"${AVX2FLAG}\"") - list(APPEND AVX2_SRCS ${ARCHDIR}/adler32_avx.c) - add_feature_info(AVX2_ADLER32 1 "Support AVX2-accelerated adler32, using \"${AVX2FLAG}\"") - list(APPEND ZLIB_ARCH_SRCS ${AVX2_SRCS}) - set_property(SOURCE ${AVX2_SRCS} PROPERTY COMPILE_FLAGS "${AVX2FLAG}") - endif() - if(WITH_SSE4 AND (HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN)) - add_definitions(-DX86_SSE42_CRC_HASH) - set(SSE42_SRCS ${ARCHDIR}/insert_string_sse.c) - add_feature_info(SSE42_CRC 1 "Support SSE4.2 optimized CRC hash generation, using \"${SSE4FLAG}\"") - list(APPEND ZLIB_ARCH_SRCS ${SSE42_SRCS}) - set_property(SOURCE ${SSE42_SRCS} PROPERTY COMPILE_FLAGS "${SSE4FLAG}") + elseif("${ARCHDIR}" MATCHES "arch/x86") + add_definitions("-DX86_CPUID") + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/x86.c) + if(HAVE_SSE42_INTRIN) + add_definitions(-DX86_SSE4_2_CRC_HASH) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/insert_string_sse.c) + add_feature_info(SSE4_CRC 1 "Support CRC hash generation using the SSE4.2 instruction set, using \"${SSE4FLAG}\"") + add_intrinsics_option("${SSE4FLAG}") if(HAVE_SSE42CRC_INTRIN) - add_definitions(-DX86_SSE42_CRC_INTRIN) + add_definitions(-DX86_SSE4_2_CRC_INTRIN) + endif() + if(WITH_NEW_STRATEGIES) + add_definitions(-DX86_QUICK_STRATEGY) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/deflate_quick.c) + add_feature_info(SSE4DEFLATE 1 "Support SSE4.2-accelerated quick compression") endif() endif() - if(HAVE_SSE42CMPSTR_INTRIN) - add_definitions(-DX86_SSE42_CMP_STR) - set(SSE42_SRCS ${ARCHDIR}/compare258_sse.c) - add_feature_info(SSE42_COMPARE258 1 "Support SSE4.2 optimized compare258, using \"${SSE4FLAG}\"") - list(APPEND ZLIB_ARCH_SRCS ${SSE42_SRCS}) - set_property(SOURCE ${SSE42_SRCS} PROPERTY COMPILE_FLAGS "${SSE4FLAG}") - endif() - if(WITH_SSE2 AND HAVE_SSE2_INTRIN) - add_definitions(-DX86_SSE2 -DX86_SSE2_CHUNKSET -DX86_SSE2_SLIDEHASH) - set(SSE2_SRCS ${ARCHDIR}/chunkset_sse.c ${ARCHDIR}/slide_sse.c) - list(APPEND ZLIB_ARCH_SRCS ${SSE2_SRCS}) + if(HAVE_SSE2_INTRIN) + add_definitions(-DX86_SSE2) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/fill_window_sse.c) if(NOT ${ARCH} MATCHES "x86_64") - set_property(SOURCE ${SSE2_SRCS} PROPERTY COMPILE_FLAGS "${SSE2FLAG}") + add_intrinsics_option("${SSE2FLAG}") add_feature_info(FORCE_SSE2 FORCE_SSE2 "Assume CPU is SSE2 capable") if(FORCE_SSE2) add_definitions(-DX86_NOCHECK_SSE2) endif() endif() endif() - if(WITH_SSSE3 AND HAVE_SSSE3_INTRIN) - add_definitions(-DX86_SSSE3 -DX86_SSSE3_ADLER32) - set(SSSE3_SRCS ${ARCHDIR}/adler32_ssse3.c) - add_feature_info(SSSE3_ADLER32 1 "Support SSSE3-accelerated adler32, using \"${SSSE3FLAG}\"") - list(APPEND ZLIB_ARCH_SRCS ${SSSE3_SRCS}) - set_property(SOURCE ${SSSE3_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG}") - endif() - if(WITH_PCLMULQDQ AND HAVE_PCLMULQDQ_INTRIN AND WITH_SSSE3 AND WITH_SSE4) + if(HAVE_PCLMULQDQ_INTRIN) add_definitions(-DX86_PCLMULQDQ_CRC) - set(PCLMULQDQ_SRCS ${ARCHDIR}/crc_folding.c) - add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${SSSE3FLAG} ${SSE4FLAG} ${PCLMULFLAG}\"") - list(APPEND ZLIB_ARCH_SRCS ${PCLMULQDQ_SRCS}) - set_property(SOURCE ${PCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG} ${SSE4FLAG} ${PCLMULFLAG}") + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc_folding.c) + add_intrinsics_option("${PCLMULFLAG}") + if(HAVE_SSE42_INTRIN) + add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG}\"") + else() + add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG} ${SSE4FLAG}\"") + endif() + endif() + elseif("${ARCH}" MATCHES "s390x") + if(WITH_DFLTCC_DEFLATE OR WITH_DFLTCC_INFLATE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/dfltcc_common.c) + endif() + if(WITH_DFLTCC_DEFLATE) + add_definitions(-DS390_DFLTCC_DEFLATE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/dfltcc_deflate.c) + endif() + if(WITH_DFLTCC_INFLATE) + add_definitions(-DS390_DFLTCC_INFLATE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/dfltcc_inflate.c) endif() endif() endif() @@ -764,13 +629,15 @@ macro(generate_cmakein input output) file(REMOVE ${output}) file(STRINGS ${input} _lines) foreach(_line IN LISTS _lines) - string(REGEX REPLACE "#ifdef HAVE_UNISTD_H.*" "@ZCONF_UNISTD_LINE@" _line "${_line}") - string(REGEX REPLACE "#ifdef HAVE_STDARG_H.*" "@ZCONF_STDARG_LINE@" _line "${_line}") - string(REGEX REPLACE "#ifdef NEED_PTRDIFF_T.*" "@ZCONF_PTRDIFF_LINE@" _line "${_line}") - if(NEED_PTRDIFF_T) - string(REGEX REPLACE "typedef PTRDIFF_TYPE" "typedef @PTRDIFF_TYPE@" _line "${_line}") - endif() file(APPEND ${output} "${_line}\n") + + if (_line STREQUAL "#define ZCONF_H" OR _line STREQUAL "#define ZCONFNG_H") + file(APPEND ${output} "#cmakedefine Z_HAVE_UNISTD_H\n") + if(NOT HAVE_PTRDIFF_T) + file(APPEND ${output} "#cmakedefine NEED_PTRDIFF_T\n") + file(APPEND ${output} "#cmakedefine PTRDIFF_TYPE ${PTRDIFF_TYPE}\n") + endif() + endif() endforeach() endmacro(generate_cmakein) @@ -798,18 +665,12 @@ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) endif() endif() -# Refer to prefix symbolically to ease relocation by end user, -# as Makefile-generated .pc file does. -if(INC_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/include") - set(PC_INC_INSTALL_DIR "\${prefix}/include") -else() - set(PC_INC_INSTALL_DIR "${INSTALL_INC_DIR}") -endif() -if(LIB_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib") - set(PC_LIB_INSTALL_DIR "\${exec_prefix}/lib") -else() - set(PC_LIB_INSTALL_DIR "${INSTALL_LIB_DIR}") -endif() +set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME2}.pc) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein + ${ZLIB_PC} @ONLY) +configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein + ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY) + #============================================================================ # zlib @@ -820,55 +681,37 @@ set(ZLIB_PUBLIC_HDRS zlib${SUFFIX}.h ) set(ZLIB_PRIVATE_HDRS - adler32_p.h - chunkset_tpl.h - crc32_p.h - crc32_tbl.h - crc32_comb_tbl.h + crc32.h deflate.h - deflate_p.h functable.h + gzguts.h inffast.h - inffixed_tbl.h + inffixed.h inflate.h - inflate_p.h inftrees.h - insert_string_tpl.h - match_tpl.h trees.h - trees_emit.h - trees_tbl.h - zbuild.h - zendian.h zutil.h ) set(ZLIB_SRCS adler32.c - chunkset.c - compare258.c compress.c crc32.c - crc32_comb.c deflate.c deflate_fast.c deflate_medium.c - deflate_quick.c deflate_slow.c functable.c - infback.c - inffast.c inflate.c + infback.c inftrees.c - insert_string.c + inffast.c trees.c uncompr.c zutil.c ) -set(ZLIB_GZFILE_PRIVATE_HDRS - gzguts.h -) set(ZLIB_GZFILE_SRCS + gzclose.c gzlib.c gzread.c gzwrite.c @@ -896,120 +739,65 @@ if(MINGW OR MSYS) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) endif() -set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_HDRS} ${ZLIB_ARCH_SRCS} ${ZLIB_DLL_SRCS} - ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ARCH_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ARCH_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + if(WITH_GZFILEOP) - list(APPEND ZLIB_ALL_SRCS ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS}) + target_sources(zlib PRIVATE ${ZLIB_GZFILE_SRCS}) + target_sources(zlibstatic PRIVATE ${ZLIB_GZFILE_SRCS}) endif() -if(NOT DEFINED BUILD_SHARED_LIBS) - add_library(zlib SHARED ${ZLIB_ALL_SRCS}) - add_library(zlibstatic STATIC ${ZLIB_ALL_SRCS}) +set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +set_target_properties(zlib PROPERTIES SOVERSION 1) - set(ZLIB_INSTALL_LIBRARIES zlib zlibstatic) +if (ZLIB_COMPAT) + set(ZLIB_FULL_VERSION ${ZLIB_HEADER_VERSION}) else() - add_library(zlib ${ZLIB_ALL_SRCS}) - - set(ZLIB_INSTALL_LIBRARIES zlib) + set(ZLIB_FULL_VERSION ${ZLIBNG_HEADER_VERSION}) +endif() +if(NOT CYGWIN) + # This property causes shared libraries on Linux to have the full version + # encoded into their final filename. We disable this on Cygwin because + # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll + # seems to be the default. + # + # This has no effect with MSVC, on that platform the version info for + # the DLL comes from the resource file win32/zlib1.rc + set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) endif() -foreach(ZLIB_INSTALL_LIBRARY ${ZLIB_INSTALL_LIBRARIES}) - target_include_directories(${ZLIB_INSTALL_LIBRARY} PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -endforeach() -if(WIN32) - set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES OUTPUT_NAME zlib${SUFFIX}) -else() +if(UNIX) # On unix-like platforms the library is almost always called libz - set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES OUTPUT_NAME z${SUFFIX}) -endif() - -if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) - set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) - - if(ZLIB_COMPAT) - set(ZLIB_FULL_VERSION ${ZLIB_HEADER_VERSION}.zlib-ng) - set_target_properties(zlib PROPERTIES SOVERSION 1) - else() - set(ZLIB_FULL_VERSION ${ZLIBNG_HEADER_VERSION}) - set_target_properties(zlib PROPERTIES SOVERSION 2) - endif() - - if(NOT CYGWIN) - # This property causes shared libraries on Linux to have the full version - # encoded into their final filename. We disable this on Cygwin because - # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll - # seems to be the default. - # - # This has no effect with MSVC, on that platform the version info for - # the DLL comes from the resource file win32/zlib1.rc - set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) - endif() - - if(UNIX) - if(HAVE_NO_INTERPOSITION) - set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-fno-semantic-interposition") - endif() - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS - "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.map\"") - else() - # Match configure/make's behavior (i.e. don't use @rpath on mac). - set_target_properties(zlib PROPERTIES INSTALL_NAME_DIR "${LIB_INSTALL_DIR}") - endif() - elseif(MSYS) - # Suppress version number from shared library name - set(CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION 0) - elseif(WIN32) - # Creates zlib1.dll when building shared library version - if(ZLIB_COMPAT) - set_target_properties(zlib PROPERTIES SUFFIX "1.dll") - else() - set_target_properties(zlib PROPERTIES SUFFIX "2.dll") - endif() + set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z${SUFFIX}) + if(NOT APPLE) + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME2}.map\"") endif() +elseif(MSYS) + # Suppress version number from shared library name + set(CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION 0) +elseif(BUILD_SHARED_LIBS AND WIN32) + # Creates zlib1.dll when building shared library version + set_target_properties(zlib PROPERTIES SUFFIX "1.dll") endif() -if(HAVE_STDARG_H) - SET(ZCONF_STDARG_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") -else() - SET(ZCONF_STDARG_LINE "#ifdef HAVE_STDARG_H /* may be set to #if 1 by configure/cmake/etc */") +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + install(TARGETS zlib zlibstatic + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) endif() -if(HAVE_UNISTD_H) - SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") -else() - SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */") +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES zlib${SUFFIX}.h DESTINATION "${INSTALL_INC_DIR}" RENAME zlib${SUFFIX}.h) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h DESTINATION "${INSTALL_INC_DIR}" RENAME zconf${SUFFIX}.h) endif() -if(NEED_PTRDIFF_T) - SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") -else() - SET(ZCONF_PTRDIFF_LINE "#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */") +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3" RENAME zlib${SUFFIX}.3) endif() - -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.pc) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY) - -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${ZLIB_INSTALL_LIBRARIES} - RUNTIME DESTINATION "${BIN_INSTALL_DIR}" - ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" - LIBRARY DESTINATION "${LIB_INSTALL_DIR}") -endif() -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) - install(FILES zlib${SUFFIX}.h - DESTINATION "${INC_INSTALL_DIR}" RENAME zlib${SUFFIX}.h) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h - DESTINATION "${INC_INSTALL_DIR}" RENAME zconf${SUFFIX}.h) -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) - install(FILES zlib.3 DESTINATION "${MAN_INSTALL_DIR}/man3" RENAME zlib${SUFFIX}.3) -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) - install(FILES ${ZLIB_PC} DESTINATION "${PKGCONFIG_INSTALL_DIR}") +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") endif() #============================================================================ @@ -1017,115 +805,33 @@ endif() #============================================================================ option(ZLIB_ENABLE_TESTS "Build test binaries" ON) -if(ZLIB_ENABLE_TESTS) +if (ZLIB_ENABLE_TESTS) enable_testing() macro(configure_test_executable target) - target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + target_link_libraries(${target} zlib) if(NOT WITH_GZFILEOP) target_compile_definitions(${target} PUBLIC -DWITH_GZFILEOP) - target_sources(${target} PRIVATE ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS}) - endif() - if(ZLIB_DUAL_LINK) - find_package(ZLIB) - if(ZLIB_FOUND) - target_link_libraries(${target} ${ZLIB_LIBRARIES}) - endif() + target_sources(${target} PRIVATE ${ZLIB_GZFILE_SRCS}) endif() endmacro() - add_executable(adler32_test test/adler32_test.c) - configure_test_executable(adler32_test) - target_link_libraries(adler32_test zlib) - - set(ADLER32TEST_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME adler32_test COMMAND ${ADLER32TEST_COMMAND}) - add_executable(example test/example.c) configure_test_executable(example) - target_link_libraries(example zlib) + add_test(NAME example COMMAND example${CMAKE_EXECUTABLE_SUFFIX}) - set(EXAMPLE_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME example COMMAND ${EXAMPLE_COMMAND}) - - set(MINIGZIP_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) add_executable(minigzip test/minigzip.c) configure_test_executable(minigzip) - if(NOT DEFINED BUILD_SHARED_LIBS) - target_link_libraries(minigzip zlibstatic) - else() - target_link_libraries(minigzip zlib) + + if(HAVE_OFF64_T) + add_executable(example64 test/example.c) + configure_test_executable(example64) + set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + add_test(NAME example64 COMMAND example64${CMAKE_EXECUTABLE_SUFFIX}) + + add_executable(minigzip64 test/minigzip.c) + configure_test_executable(minigzip64) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() - if(BASEARCH_S360_FOUND) - if(WITH_DFLTCC_DEFLATE OR WITH_DFLTCC_INFLATE) - set_source_files_properties(test/minigzip.c PROPERTIES COMPILE_DEFINITIONS BUFLEN=262144) - endif() - endif() - - set(MINIDEFLATE_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_executable(minideflate test/minideflate.c) - configure_test_executable(minideflate) - target_link_libraries(minideflate zlib) - - if(INSTALL_UTILS) - install(TARGETS minigzip minideflate - RUNTIME DESTINATION "${BIN_INSTALL_DIR}" - ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" - LIBRARY DESTINATION "${LIB_INSTALL_DIR}") - endif() - - set(SWITCHLEVELS_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_executable(switchlevels test/switchlevels.c) - configure_test_executable(switchlevels) - target_link_libraries(switchlevels zlib) - - add_executable(infcover test/infcover.c inftrees.c) - configure_test_executable(infcover) - target_link_libraries(infcover zlib) - - add_executable(makefixed tools/makefixed.c inftrees.c) - target_include_directories(makefixed PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - - set(MAKEFIXED_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME makefixed - COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${MAKEFIXED_COMMAND}" - -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/inffixed_tbl._h - -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/inffixed_tbl.h - -DIGNORE_LINE_ENDINGS=ON - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) - - add_executable(maketrees tools/maketrees.c trees.c zutil.c) - target_include_directories(maketrees PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - - set(MAKETREES_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME maketrees - COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${MAKETREES_COMMAND}" - -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/trees_tbl._h - -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/trees_tbl.h - -DIGNORE_LINE_ENDINGS=ON - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) - - add_executable(makecrct tools/makecrct.c) - target_include_directories(makecrct PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - - set(MAKECRCT_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME makecrct-crc32 - COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${MAKECRCT_COMMAND}" - -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/crc32_tbl._h - -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/crc32_tbl.h - -DIGNORE_LINE_ENDINGS=ON - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) - - set(MAKECRCT_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -c) - add_test(NAME makecrct-crc32-combine - COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${MAKECRCT_COMMAND}" - -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/crc32_comb_tbl._h - -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/crc32_comb_tbl.h - -DIGNORE_LINE_ENDINGS=ON - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) if(WITH_FUZZERS) set(FUZZERS checksum compress example_small example_large example_flush example_dict minigzip) @@ -1133,73 +839,10 @@ if(ZLIB_ENABLE_TESTS) foreach(FUZZER ${FUZZERS}) add_executable(${FUZZER}_fuzzer test/fuzz/${FUZZER}_fuzzer.c test/fuzz/standalone_fuzz_target_runner.c) configure_test_executable(${FUZZER}_fuzzer) - target_link_libraries(${FUZZER}_fuzzer zlib) - set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ALL_SRC_FILES}) - add_test(NAME ${FUZZER}_fuzzer COMMAND ${FUZZER_COMMAND}) + add_test(${FUZZER}_fuzzer ${FUZZER}_fuzzer${CMAKE_EXECUTABLE_SUFFIX} ${ALL_SRC_FILES}) endforeach() endif() - macro(test_minigzip name path) - # Construct compression arguments for minigzip - set(compress_args -k -c) - foreach(extra_arg IN ITEMS "${ARGN}") - list(APPEND compress_args ${extra_arg}) - endforeach() - - # Create unique friendly string for test - string(REPLACE ";" "" arg_list "${ARGN}") - string(REPLACE " " "" arg_list "${arg_list}") - string(REPLACE "-" "" arg_list "${arg_list}") - - set(test_id minigzip-${name}-${arg_list}) - - if(NOT TEST ${test_id}) - add_test(NAME ${test_id} - COMMAND ${CMAKE_COMMAND} - "-DTARGET=${MINIGZIP_COMMAND}" - "-DCOMPRESS_ARGS=${compress_args}" - "-DDECOMPRESS_ARGS=-d;-c" - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${path} - -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/${path}-${test_id}.gz - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - endif() - endmacro() - - set(TEST_CONFIGS - -R # Z_RLE - -h # Z_HUFFMAN_ONLY - -T # Direct store - -0 # No compression - -1 # Deflate quick - -4 # Deflate medium (lazy matches) - "-5;-F" # Deflate medium (Z_FIXED) - -6 # Deflate medium - -9 # Deflate slow - "-9;-f" # Deflate slow (Z_FILTERED) - ) - - file(GLOB_RECURSE TEST_FILE_PATHS - LIST_DIRECTORIES false - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/test/data/*) - - foreach(TEST_FILE_PATH ${TEST_FILE_PATHS}) - if("${TEST_FILE_PATH}" MATCHES ".gz$" OR "${TEST_FILE_PATH}" MATCHES ".out$" OR - "${TEST_FILE_PATH}" MATCHES "/.git/" OR "${TEST_FILE_PATH}" MATCHES ".md$") - continue() - endif() - foreach(TEST_CONFIG ${TEST_CONFIGS}) - get_filename_component(TEST_NAME ${TEST_FILE_PATH} NAME_WE) - if (TEST_NAME STREQUAL "") - continue() - endif() - test_minigzip(${TEST_NAME} ${TEST_FILE_PATH} ${TEST_CONFIG}) - endforeach() - endforeach() - - test_minigzip("detect-text" "test/data/lcet10.txt" -A) - test_minigzip("detect-binary" "test/data/paper-100k.pdf" -A) - set(CVES CVE-2002-0059 CVE-2004-0797 CVE-2005-1849 CVE-2005-2096) foreach(CVE ${CVES}) set(CVE_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -d) @@ -1214,72 +857,9 @@ if(ZLIB_ENABLE_TESTS) if(NOT WIN32 AND ZLIB_COMPAT) add_executable(CVE-2003-0107 test/CVE-2003-0107.c) target_link_libraries(CVE-2003-0107 zlib) - set(CVE20030107_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME CVE-2003-0107 COMMAND ${CVE20030107_COMMAND}) + add_test(NAME CVE-2003-0107 COMMAND CVE-2003-0107) endif() - - set(INFCOVER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - add_test(NAME infcover COMMAND ${INFCOVER_COMMAND}) - - add_test(NAME GH-361 - COMMAND ${CMAKE_COMMAND} - "-DTARGET=${MINIGZIP_COMMAND}" - "-DCOMPRESS_ARGS=-c;-k;-4" - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/GH-361/test.txt - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-364 - COMMAND ${CMAKE_COMMAND} - "-DCOMPRESS_TARGET=${SWITCHLEVELS_COMMAND}" - "-DCOMPRESS_ARGS=1;5;9;3" - "-DDECOMPRESS_TARGET=${MINIGZIP_COMMAND}" - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/GH-364/test.bin - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-382 - COMMAND ${CMAKE_COMMAND} - "-DTARGET=${MINIDEFLATE_COMMAND}" - "-DCOMPRESS_ARGS=-c;-m;1;-w;-15;-1;-s;4" - "-DDECOMPRESS_ARGS=-c;-d;-m;1;-w;-15" - -DGZIP_VERIFY=OFF - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/GH-382/defneg3.dat - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-536-segfault - COMMAND ${CMAKE_COMMAND} - "-DCOMPRESS_TARGET=${SWITCHLEVELS_COMMAND}" - "-DCOMPRESS_ARGS=6;9744;1;91207" - "-DDECOMPRESS_TARGET=${MINIGZIP_COMMAND}" - -DCOMPARE=OFF - -DGZIP_VERIFY=OFF - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/data/lcet10.txt - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-536-incomplete-read - COMMAND ${CMAKE_COMMAND} - "-DCOMPRESS_TARGET=${SWITCHLEVELS_COMMAND}" - "-DCOMPRESS_ARGS=6;88933;1;195840;2;45761" - "-DDECOMPRESS_TARGET=${MINIGZIP_COMMAND}" - -DCOMPARE=OFF - -DGZIP_VERIFY=OFF - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/data/lcet10.txt - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-536-zero-stored-block - COMMAND ${CMAKE_COMMAND} - "-DCOMPRESS_TARGET=${SWITCHLEVELS_COMMAND}" - "-DCOMPRESS_ARGS=6;15248;1;1050;2;25217" - "-DDECOMPRESS_TARGET=${MINIGZIP_COMMAND}" - -DCOMPARE=OFF - -DGZIP_VERIFY=OFF - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/data/lcet10.txt - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) - - add_test(NAME GH-751 - COMMAND ${CMAKE_COMMAND} - "-DTARGET=${MINIGZIP_COMMAND}" - -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/test/GH-751/test.txt - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-compress.cmake) endif() -FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES) +# FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES) + diff --git a/libs/zlibng/ChangeLog.zlib b/libs/zlibng/ChangeLog.zlib new file mode 100644 index 000000000..d38c0a842 --- /dev/null +++ b/libs/zlibng/ChangeLog.zlib @@ -0,0 +1,1521 @@ +## +# THIS IS AN UNMAINTAINED COPY OF THE ORIGINAL FILE DISTRIBUTED WITH ZLIB 1.2.9 +## + + + + + ChangeLog file for zlib + +Changes in 1.2.11 (15 Jan 2017) +- Fix deflate stored bug when pulling last block from window +- Permit immediate deflateParams changes before any deflate input + +Changes in 1.2.10 (2 Jan 2017) +- Avoid warnings on snprintf() return value +- Fix bug in deflate_stored() for zero-length input +- Fix bug in gzwrite.c that produced corrupt gzip files +- Remove files to be installed before copying them in Makefile.in +- Add warnings when compiling with assembler code + +Changes in 1.2.9 (31 Dec 2016) +- Fix contrib/minizip to permit unzipping with desktop API [Zouzou] +- Improve contrib/blast to return unused bytes +- Assure that gzoffset() is correct when appending +- Improve compress() and uncompress() to support large lengths +- Fix bug in test/example.c where error code not saved +- Remedy Coverity warning [Randers-Pehrson] +- Improve speed of gzprintf() in transparent mode +- Fix inflateInit2() bug when windowBits is 16 or 32 +- Change DEBUG macro to ZLIB_DEBUG +- Avoid uninitialized access by gzclose_w() +- Allow building zlib outside of the source directory +- Fix bug that accepted invalid zlib header when windowBits is zero +- Fix gzseek() problem on MinGW due to buggy _lseeki64 there +- Loop on write() calls in gzwrite.c in case of non-blocking I/O +- Add --warn (-w) option to ./configure for more compiler warnings +- Reject a window size of 256 bytes if not using the zlib wrapper +- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE +- Add --debug (-d) option to ./configure to define ZLIB_DEBUG +- Fix bugs in creating a very large gzip header +- Add uncompress2() function, which returns the input size used +- Assure that deflateParams() will not switch functions mid-block +- Dramatically speed up deflation for level 0 (storing) +- Add gzfread(), duplicating the interface of fread() +- Add gzfwrite(), duplicating the interface of fwrite() +- Add deflateGetDictionary() function +- Use snprintf() for later versions of Microsoft C +- Fix *Init macros to use z_ prefix when requested +- Replace as400 with os400 for OS/400 support [Monnerat] +- Add crc32_z() and adler32_z() functions with size_t lengths +- Update Visual Studio project files [AraHaan] + +Changes in 1.2.8 (28 Apr 2013) +- Update contrib/minizip/iowin32.c for Windows RT [Vollant] +- Do not force Z_CONST for C++ +- Clean up contrib/vstudio [Roß] +- Correct spelling error in zlib.h +- Fix mixed line endings in contrib/vstudio + +Changes in 1.2.7.3 (13 Apr 2013) +- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc + +Changes in 1.2.7.2 (13 Apr 2013) +- Change check for a four-byte type back to hexadecimal +- Fix typo in win32/Makefile.msc +- Add casts in gzwrite.c for pointer differences + +Changes in 1.2.7.1 (24 Mar 2013) +- Replace use of unsafe string functions with snprintf if available +- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink] +- Fix gzgetc undefine when Z_PREFIX set [Turk] +- Eliminate use of mktemp in Makefile (not always available) +- Fix bug in 'F' mode for gzopen() +- Add inflateGetDictionary() function +- Correct comment in deflate.h +- Use _snprintf for snprintf in Microsoft C +- On Darwin, only use /usr/bin/libtool if libtool is not Apple +- Delete "--version" file if created by "ar --version" [Richard G.] +- Fix configure check for veracity of compiler error return codes +- Fix CMake compilation of static lib for MSVC2010 x64 +- Remove unused variable in infback9.c +- Fix argument checks in gzlog_compress() and gzlog_write() +- Clean up the usage of z_const and respect const usage within zlib +- Clean up examples/gzlog.[ch] comparisons of different types +- Avoid shift equal to bits in type (caused endless loop) +- Fix uninitialized value bug in gzputc() introduced by const patches +- Fix memory allocation error in examples/zran.c [Nor] +- Fix bug where gzopen(), gzclose() would write an empty file +- Fix bug in gzclose() when gzwrite() runs out of memory +- Check for input buffer malloc failure in examples/gzappend.c +- Add note to contrib/blast to use binary mode in stdio +- Fix comparisons of differently signed integers in contrib/blast +- Check for invalid code length codes in contrib/puff +- Fix serious but very rare decompression bug in inftrees.c +- Update inflateBack() comments, since inflate() can be faster +- Use underscored I/O function names for WINAPI_FAMILY +- Add _tr_flush_bits to the external symbols prefixed by --zprefix +- Add contrib/vstudio/vc10 pre-build step for static only +- Quote --version-script argument in CMakeLists.txt +- Don't specify --version-script on Apple platforms in CMakeLists.txt +- Fix casting error in contrib/testzlib/testzlib.c +- Fix types in contrib/minizip to match result of get_crc_table() +- Simplify contrib/vstudio/vc10 with 'd' suffix +- Add TOP support to win32/Makefile.msc +- Suport i686 and amd64 assembler builds in CMakeLists.txt +- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h +- Add vc11 and vc12 build files to contrib/vstudio +- Add gzvprintf() as an undocumented function in zlib +- Fix configure for Sun shell +- Remove runtime check in configure for four-byte integer type +- Add casts and consts to ease user conversion to C++ +- Add man pages for minizip and miniunzip +- In Makefile uninstall, don't rm if preceding cd fails +- Do not return Z_BUF_ERROR if deflateParam() has nothing to write + +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no library use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminancy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assmebler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + +Changes in 1.2.5 (19 Apr 2010) +- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] +- Default to libdir as sharedlibdir in configure [Nieder] +- Update copyright dates on modified source files +- Update trees.c to be able to generate modified trees.h +- Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] + +Changes in 1.2.4.5 (18 Apr 2010) +- Set sharedlibdir in configure [Torok] +- Set LDFLAGS in Makefile.in [Bar-Lev] +- Avoid mkdir objs race condition in Makefile.in [Bowler] +- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays +- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C +- Don't use hidden attribute when it is a warning generator (e.g. Solaris) + +Changes in 1.2.4.4 (18 Apr 2010) +- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok] +- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty +- Try to use bash or ksh regardless of functionality of /bin/sh +- Fix configure incompatibility with NetBSD sh +- Remove attempt to run under bash or ksh since have better NetBSD fix +- Fix win32/Makefile.gcc for MinGW [Bar-Lev] +- Add diagnostic messages when using CROSS_PREFIX in configure +- Added --sharedlibdir option to configure [Weigelt] +- Use hidden visibility attribute when available [Frysinger] + +Changes in 1.2.4.3 (10 Apr 2010) +- Only use CROSS_PREFIX in configure for ar and ranlib if they exist +- Use CROSS_PREFIX for nm [Bar-Lev] +- Assume _LARGEFILE64_SOURCE defined is equivalent to true +- Avoid use of undefined symbols in #if with && and || +- Make *64 prototypes in gzguts.h consistent with functions +- Add -shared load option for MinGW in configure [Bowler] +- Move z_off64_t to public interface, use instead of off64_t +- Remove ! from shell test in configure (not portable to Solaris) +- Change +0 macro tests to -0 for possibly increased portability + +Changes in 1.2.4.2 (9 Apr 2010) +- Add consistent carriage returns to readme.txt's in masmx86 and masmx64 +- Really provide prototypes for *64 functions when building without LFS +- Only define unlink() in minigzip.c if unistd.h not included +- Update README to point to contrib/vstudio project files +- Move projects/vc6 to old/ and remove projects/ +- Include stdlib.h in minigzip.c for setmode() definition under WinCE +- Clean up assembler builds in win32/Makefile.msc [Rowe] +- Include sys/types.h for Microsoft for off_t definition +- Fix memory leak on error in gz_open() +- Symbolize nm as $NM in configure [Weigelt] +- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt] +- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined +- Fix bug in gzeof() to take into account unused input data +- Avoid initialization of structures with variables in puff.c +- Updated win32/README-WIN32.txt [Rowe] + +Changes in 1.2.4.1 (28 Mar 2010) +- Remove the use of [a-z] constructs for sed in configure [gentoo 310225] +- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech] +- Restore "for debugging" comment on sprintf() in gzlib.c +- Remove fdopen for MVS from gzguts.h +- Put new README-WIN32.txt in win32 [Rowe] +- Add check for shell to configure and invoke another shell if needed +- Fix big fat stinking bug in gzseek() on uncompressed files +- Remove vestigial F_OPEN64 define in zutil.h +- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE +- Avoid errors on non-LFS systems when applications define LFS macros +- Set EXE to ".exe" in configure for MINGW [Kahle] +- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill] +- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev] +- Add DLL install in win32/makefile.gcc [Bar-Lev] +- Allow Linux* or linux* from uname in configure [Bar-Lev] +- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev] +- Add cross-compilation prefixes to configure [Bar-Lev] +- Match type exactly in gz_load() invocation in gzread.c +- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func +- Provide prototypes for *64 functions when building zlib without LFS +- Don't use -lc when linking shared library on MinGW +- Remove errno.h check in configure and vestigial errno code in zutil.h + +Changes in 1.2.4 (14 Mar 2010) +- Fix VER3 extraction in configure for no fourth subversion +- Update zlib.3, add docs to Makefile.in to make .pdf out of it +- Add zlib.3.pdf to distribution +- Don't set error code in gzerror() if passed pointer is NULL +- Apply destination directory fixes to CMakeLists.txt [Lowman] +- Move #cmakedefine's to a new zconf.in.cmakein +- Restore zconf.h for builds that don't use configure or cmake +- Add distclean to dummy Makefile for convenience +- Update and improve INDEX, README, and FAQ +- Update CMakeLists.txt for the return of zconf.h [Lowman] +- Update contrib/vstudio/vc9 and vc10 [Vollant] +- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc +- Apply license and readme changes to contrib/asm686 [Raiter] +- Check file name lengths and add -c option in minigzip.c [Li] +- Update contrib/amd64 and contrib/masmx86/ [Vollant] +- Avoid use of "eof" parameter in trees.c to not shadow library variable +- Update make_vms.com for removal of zlibdefs.h [Zinser] +- Update assembler code and vstudio projects in contrib [Vollant] +- Remove outdated assembler code contrib/masm686 and contrib/asm586 +- Remove old vc7 and vc8 from contrib/vstudio +- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe] +- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open() +- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant] +- Remove *64 functions from win32/zlib.def (they're not 64-bit yet) +- Fix bug in void-returning vsprintf() case in gzwrite.c +- Fix name change from inflate.h in contrib/inflate86/inffas86.c +- Check if temporary file exists before removing in make_vms.com [Zinser] +- Fix make install and uninstall for --static option +- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta] +- Update readme.txt in contrib/masmx64 and masmx86 to assemble + +Changes in 1.2.3.9 (21 Feb 2010) +- Expunge gzio.c +- Move as400 build information to old +- Fix updates in contrib/minizip and contrib/vstudio +- Add const to vsnprintf test in configure to avoid warnings [Weigelt] +- Delete zconf.h (made by configure) [Weigelt] +- Change zconf.in.h to zconf.h.in per convention [Weigelt] +- Check for NULL buf in gzgets() +- Return empty string for gzgets() with len == 1 (like fgets()) +- Fix description of gzgets() in zlib.h for end-of-file, NULL return +- Update minizip to 1.1 [Vollant] +- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c +- Note in zlib.h that gzerror() should be used to distinguish from EOF +- Remove use of snprintf() from gzlib.c +- Fix bug in gzseek() +- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant] +- Fix zconf.h generation in CMakeLists.txt [Lowman] +- Improve comments in zconf.h where modified by configure + +Changes in 1.2.3.8 (13 Feb 2010) +- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer] +- Use z_off64_t in gz_zero() and gz_skip() to match state->skip +- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t) +- Revert to Makefile.in from 1.2.3.6 (live with the clutter) +- Fix missing error return in gzflush(), add zlib.h note +- Add *64 functions to zlib.map [Levin] +- Fix signed/unsigned comparison in gz_comp() +- Use SFLAGS when testing shared linking in configure +- Add --64 option to ./configure to use -m64 with gcc +- Fix ./configure --help to correctly name options +- Have make fail if a test fails [Levin] +- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson] +- Remove assembler object files from contrib + +Changes in 1.2.3.7 (24 Jan 2010) +- Always gzopen() with O_LARGEFILE if available +- Fix gzdirect() to work immediately after gzopen() or gzdopen() +- Make gzdirect() more precise when the state changes while reading +- Improve zlib.h documentation in many places +- Catch memory allocation failure in gz_open() +- Complete close operation if seek forward in gzclose_w() fails +- Return Z_ERRNO from gzclose_r() if close() fails +- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL +- Return zero for gzwrite() errors to match zlib.h description +- Return -1 on gzputs() error to match zlib.h description +- Add zconf.in.h to allow recovery from configure modification [Weigelt] +- Fix static library permissions in Makefile.in [Weigelt] +- Avoid warnings in configure tests that hide functionality [Weigelt] +- Add *BSD and DragonFly to Linux case in configure [gentoo 123571] +- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212] +- Avoid access of uninitialized data for first inflateReset2 call [Gomes] +- Keep object files in subdirectories to reduce the clutter somewhat +- Remove default Makefile and zlibdefs.h, add dummy Makefile +- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_ +- Remove zlibdefs.h completely -- modify zconf.h instead + +Changes in 1.2.3.6 (17 Jan 2010) +- Avoid void * arithmetic in gzread.c and gzwrite.c +- Make compilers happier with const char * for gz_error message +- Avoid unused parameter warning in inflate.c +- Avoid signed-unsigned comparison warning in inflate.c +- Indent #pragma's for traditional C +- Fix usage of strwinerror() in glib.c, change to gz_strwinerror() +- Correct email address in configure for system options +- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser] +- Update zlib.map [Brown] +- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok] +- Apply various fixes to CMakeLists.txt [Lowman] +- Add checks on len in gzread() and gzwrite() +- Add error message for no more room for gzungetc() +- Remove zlib version check in gzwrite() +- Defer compression of gzprintf() result until need to +- Use snprintf() in gzdopen() if available +- Remove USE_MMAP configuration determination (only used by minigzip) +- Remove examples/pigz.c (available separately) +- Update examples/gun.c to 1.6 + +Changes in 1.2.3.5 (8 Jan 2010) +- Add space after #if in zutil.h for some compilers +- Fix relatively harmless bug in deflate_fast() [Exarevsky] +- Fix same problem in deflate_slow() +- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown] +- Add deflate_rle() for faster Z_RLE strategy run-length encoding +- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding +- Change name of "write" variable in inffast.c to avoid library collisions +- Fix premature EOF from gzread() in gzio.c [Brown] +- Use zlib header window size if windowBits is 0 in inflateInit2() +- Remove compressBound() call in deflate.c to avoid linking compress.o +- Replace use of errno in gz* with functions, support WinCE [Alves] +- Provide alternative to perror() in minigzip.c for WinCE [Alves] +- Don't use _vsnprintf on later versions of MSVC [Lowman] +- Add CMake build script and input file [Lowman] +- Update contrib/minizip to 1.1 [Svensson, Vollant] +- Moved nintendods directory from contrib to . +- Replace gzio.c with a new set of routines with the same functionality +- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above +- Update contrib/minizip to 1.1b +- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h + +Changes in 1.2.3.4 (21 Dec 2009) +- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility +- Update comments in configure and Makefile.in for default --shared +- Fix test -z's in configure [Marquess] +- Build examplesh and minigzipsh when not testing +- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h +- Import LDFLAGS from the environment in configure +- Fix configure to populate SFLAGS with discovered CFLAGS options +- Adapt make_vms.com to the new Makefile.in [Zinser] +- Add zlib2ansi script for C++ compilation [Marquess] +- Add _FILE_OFFSET_BITS=64 test to make test (when applicable) +- Add AMD64 assembler code for longest match to contrib [Teterin] +- Include options from $SFLAGS when doing $LDSHARED +- Simplify 64-bit file support by introducing z_off64_t type +- Make shared object files in objs directory to work around old Sun cc +- Use only three-part version number for Darwin shared compiles +- Add rc option to ar in Makefile.in for when ./configure not run +- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4* +- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile +- Protect against _FILE_OFFSET_BITS being defined when compiling zlib +- Rename Makefile.in targets allstatic to static and allshared to shared +- Fix static and shared Makefile.in targets to be independent +- Correct error return bug in gz_open() by setting state [Brown] +- Put spaces before ;;'s in configure for better sh compatibility +- Add pigz.c (parallel implementation of gzip) to examples/ +- Correct constant in crc32.c to UL [Leventhal] +- Reject negative lengths in crc32_combine() +- Add inflateReset2() function to work like inflateEnd()/inflateInit2() +- Include sys/types.h for _LARGEFILE64_SOURCE [Brown] +- Correct typo in doc/algorithm.txt [Janik] +- Fix bug in adler32_combine() [Zhu] +- Catch missing-end-of-block-code error in all inflates and in puff + Assures that random input to inflate eventually results in an error +- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/ +- Update ENOUGH and its usage to reflect discovered bounds +- Fix gzerror() error report on empty input file [Brown] +- Add ush casts in trees.c to avoid pedantic runtime errors +- Fix typo in zlib.h uncompress() description [Reiss] +- Correct inflate() comments with regard to automatic header detection +- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays) +- Put new version of gzlog (2.0) in examples with interruption recovery +- Add puff compile option to permit invalid distance-too-far streams +- Add puff TEST command options, ability to read piped input +- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but + _LARGEFILE64_SOURCE not defined +- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart +- Fix deflateSetDictionary() to use all 32K for output consistency +- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h) +- Clear bytes after deflate lookahead to avoid use of uninitialized data +- Change a limit in inftrees.c to be more transparent to Coverity Prevent +- Update win32/zlib.def with exported symbols from zlib.h +- Correct spelling errors in zlib.h [Willem, Sobrado] +- Allow Z_BLOCK for deflate() to force a new block +- Allow negative bits in inflatePrime() to delete existing bit buffer +- Add Z_TREES flush option to inflate() to return at end of trees +- Add inflateMark() to return current state information for random access +- Add Makefile for NintendoDS to contrib [Costa] +- Add -w in configure compile tests to avoid spurious warnings [Beucler] +- Fix typos in zlib.h comments for deflateSetDictionary() +- Fix EOF detection in transparent gzread() [Maier] + +Changes in 1.2.3.3 (2 October 2006) +- Make --shared the default for configure, add a --static option +- Add compile option to permit invalid distance-too-far streams +- Add inflateUndermine() function which is required to enable above +- Remove use of "this" variable name for C++ compatibility [Marquess] +- Add testing of shared library in make test, if shared library built +- Use ftello() and fseeko() if available instead of ftell() and fseek() +- Provide two versions of all functions that use the z_off_t type for + binary compatibility -- a normal version and a 64-bit offset version, + per the Large File Support Extension when _LARGEFILE64_SOURCE is + defined; use the 64-bit versions by default when _FILE_OFFSET_BITS + is defined to be 64 +- Add a --uname= option to configure to perhaps help with cross-compiling + +Changes in 1.2.3.2 (3 September 2006) +- Turn off silly Borland warnings [Hay] +- Use off64_t and define _LARGEFILE64_SOURCE when present +- Fix missing dependency on inffixed.h in Makefile.in +- Rig configure --shared to build both shared and static [Teredesai, Truta] +- Remove zconf.in.h and instead create a new zlibdefs.h file +- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant] +- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt] + +Changes in 1.2.3.1 (16 August 2006) +- Add watcom directory with OpenWatcom make files [Daniel] +- Remove #undef of FAR in zconf.in.h for MVS [Fedtke] +- Update make_vms.com [Zinser] +- Use -fPIC for shared build in configure [Teredesai, Nicholson] +- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] +- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck] +- Add some FAQ entries about the contrib directory +- Update the MVS question in the FAQ +- Avoid extraneous reads after EOF in gzio.c [Brown] +- Correct spelling of "successfully" in gzio.c [Randers-Pehrson] +- Add comments to zlib.h about gzerror() usage [Brown] +- Set extra flags in gzip header in gzopen() like deflate() does +- Make configure options more compatible with double-dash conventions + [Weigelt] +- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen] +- Fix uninstall target in Makefile.in [Truta] +- Add pkgconfig support [Weigelt] +- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt] +- Replace set_data_type() with a more accurate detect_data_type() in + trees.c, according to the txtvsbin.txt document [Truta] +- Swap the order of #include and #include "zlib.h" in + gzio.c, example.c and minigzip.c [Truta] +- Shut up annoying VS2005 warnings about standard C deprecation [Rowe, + Truta] (where?) +- Fix target "clean" from win32/Makefile.bor [Truta] +- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe] +- Update zlib www home address in win32/DLL_FAQ.txt [Truta] +- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove] +- Enable browse info in the "Debug" and "ASM Debug" configurations in + the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta] +- Add pkgconfig support [Weigelt] +- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h, + for use in win32/zlib1.rc [Polushin, Rowe, Truta] +- Add a document that explains the new text detection scheme to + doc/txtvsbin.txt [Truta] +- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta] +- Move algorithm.txt into doc/ [Truta] +- Synchronize FAQ with website +- Fix compressBound(), was low for some pathological cases [Fearnley] +- Take into account wrapper variations in deflateBound() +- Set examples/zpipe.c input and output to binary mode for Windows +- Update examples/zlib_how.html with new zpipe.c (also web site) +- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems + that gcc became pickier in 4.0) +- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain + un-versioned, the patch adds versioning only for symbols introduced in + zlib-1.2.0 or later. It also declares as local those symbols which are + not designed to be exported." [Levin] +- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure +- Do not initialize global static by default in trees.c, add a response + NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess] +- Don't use strerror() in gzio.c under WinCE [Yakimov] +- Don't use errno.h in zutil.h under WinCE [Yakimov] +- Move arguments for AR to its usage to allow replacing ar [Marot] +- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson] +- Improve inflateInit() and inflateInit2() documentation +- Fix structure size comment in inflate.h +- Change configure help option from --h* to --help [Santos] + +Changes in 1.2.3 (18 July 2005) +- Apply security vulnerability fixes to contrib/infback9 as well +- Clean up some text files (carriage returns, trailing space) +- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] + +Changes in 1.2.2.4 (11 July 2005) +- Add inflatePrime() function for starting inflation at bit boundary +- Avoid some Visual C warnings in deflate.c +- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit + compile +- Fix some spelling errors in comments [Betts] +- Correct inflateInit2() error return documentation in zlib.h +- Add zran.c example of compressed data random access to examples + directory, shows use of inflatePrime() +- Fix cast for assignments to strm->state in inflate.c and infback.c +- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] +- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] +- Add cast in trees.c t avoid a warning [Oberhumer] +- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] +- Update make_vms.com [Zinser] +- Initialize state->write in inflateReset() since copied in inflate_fast() +- Be more strict on incomplete code sets in inflate_table() and increase + ENOUGH and MAXD -- this repairs a possible security vulnerability for + invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for + discovering the vulnerability and providing test cases. +- Add ia64 support to configure for HP-UX [Smith] +- Add error return to gzread() for format or i/o error [Levin] +- Use malloc.h for OS/2 [Necasek] + +Changes in 1.2.2.3 (27 May 2005) +- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile +- Typecast fread() return values in gzio.c [Vollant] +- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) +- Fix crc check bug in gzread() after gzungetc() [Heiner] +- Add the deflateTune() function to adjust internal compression parameters +- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) +- Remove an incorrect assertion in examples/zpipe.c +- Add C++ wrapper in infback9.h [Donais] +- Fix bug in inflateCopy() when decoding fixed codes +- Note in zlib.h how much deflateSetDictionary() actually uses +- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) +- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] +- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] +- Add gzdirect() function to indicate transparent reads +- Update contrib/minizip [Vollant] +- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] +- Add casts in crc32.c to avoid warnings [Oberhumer] +- Add contrib/masmx64 [Vollant] +- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] + +Changes in 1.2.2.2 (30 December 2004) +- Replace structure assignments in deflate.c and inflate.c with zmemcpy to + avoid implicit memcpy calls (portability for no-library compilation) +- Increase sprintf() buffer size in gzdopen() to allow for large numbers +- Add INFLATE_STRICT to check distances against zlib header +- Improve WinCE errno handling and comments [Chang] +- Remove comment about no gzip header processing in FAQ +- Add Z_FIXED strategy option to deflateInit2() to force fixed trees +- Add updated make_vms.com [Coghlan], update README +- Create a new "examples" directory, move gzappend.c there, add zpipe.c, + fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. +- Add FAQ entry and comments in deflate.c on uninitialized memory access +- Add Solaris 9 make options in configure [Gilbert] +- Allow strerror() usage in gzio.c for STDC +- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] +- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] +- Use z_off_t for adler32_combine() and crc32_combine() lengths +- Make adler32() much faster for small len +- Use OS_CODE in deflate() default gzip header + +Changes in 1.2.2.1 (31 October 2004) +- Allow inflateSetDictionary() call for raw inflate +- Fix inflate header crc check bug for file names and comments +- Add deflateSetHeader() and gz_header structure for custom gzip headers +- Add inflateGetheader() to retrieve gzip headers +- Add crc32_combine() and adler32_combine() functions +- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list +- Use zstreamp consistently in zlib.h (inflate_back functions) +- Remove GUNZIP condition from definition of inflate_mode in inflate.h + and in contrib/inflate86/inffast.S [Truta, Anderson] +- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] +- Update projects/README.projects and projects/visualc6 [Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] +- Deprecate Z_ASCII; use Z_TEXT instead [Truta] +- Use a new algorithm for setting strm->data_type in trees.c [Truta] +- Do not define an exit() prototype in zutil.c unless DEBUG defined +- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] +- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() +- Fix Darwin build version identification [Peterson] + +Changes in 1.2.2 (3 October 2004) +- Update zlib.h comments on gzip in-memory processing +- Set adler to 1 in inflateReset() to support Java test suite [Walles] +- Add contrib/dotzlib [Ravn] +- Update win32/DLL_FAQ.txt [Truta] +- Update contrib/minizip [Vollant] +- Move contrib/visual-basic.txt to old/ [Truta] +- Fix assembler builds in projects/visualc6/ [Truta] + +Changes in 1.2.1.2 (9 September 2004) +- Update INDEX file +- Fix trees.c to update strm->data_type (no one ever noticed!) +- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] +- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) +- Add limited multitasking protection to DYNAMIC_CRC_TABLE +- Add NO_vsnprintf for VMS in zutil.h [Mozilla] +- Don't declare strerror() under VMS [Mozilla] +- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize +- Update contrib/ada [Anisimkov] +- Update contrib/minizip [Vollant] +- Fix configure to not hardcode directories for Darwin [Peterson] +- Fix gzio.c to not return error on empty files [Brown] +- Fix indentation; update version in contrib/delphi/ZLib.pas and + contrib/pascal/zlibpas.pas [Truta] +- Update mkasm.bat in contrib/masmx86 [Truta] +- Update contrib/untgz [Truta] +- Add projects/README.projects [Truta] +- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] +- Remove an unnecessary assignment to curr in inftrees.c [Truta] +- Add OS/2 to exe builds in configure [Poltorak] +- Remove err dummy parameter in zlib.h [Kientzle] + +Changes in 1.2.1.1 (9 January 2004) +- Update email address in README +- Several FAQ updates +- Fix a big fat bug in inftrees.c that prevented decoding valid + dynamic blocks with only literals and no distance codes -- + Thanks to "Hot Emu" for the bug report and sample file +- Add a note to puff.c on no distance codes case. + +Changes in 1.2.1 (17 November 2003) +- Remove a tab in contrib/gzappend/gzappend.c +- Update some interfaces in contrib for new zlib functions +- Update zlib version number in some contrib entries +- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] +- Support shared libraries on Hurd and KFreeBSD [Brown] +- Fix error in NO_DIVIDE option of adler32.c + +Changes in 1.2.0.8 (4 November 2003) +- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas +- Add experimental NO_DIVIDE #define in adler32.c + - Possibly faster on some processors (let me know if it is) +- Correct Z_BLOCK to not return on first inflate call if no wrap +- Fix strm->data_type on inflate() return to correctly indicate EOB +- Add deflatePrime() function for appending in the middle of a byte +- Add contrib/gzappend for an example of appending to a stream +- Update win32/DLL_FAQ.txt [Truta] +- Delete Turbo C comment in README [Truta] +- Improve some indentation in zconf.h [Truta] +- Fix infinite loop on bad input in configure script [Church] +- Fix gzeof() for concatenated gzip files [Johnson] +- Add example to contrib/visual-basic.txt [Michael B.] +- Add -p to mkdir's in Makefile.in [vda] +- Fix configure to properly detect presence or lack of printf functions +- Add AS400 support [Monnerat] +- Add a little Cygwin support [Wilson] + +Changes in 1.2.0.7 (21 September 2003) +- Correct some debug formats in contrib/infback9 +- Cast a type in a debug statement in trees.c +- Change search and replace delimiter in configure from % to # [Beebe] +- Update contrib/untgz to 0.2 with various fixes [Truta] +- Add build support for Amiga [Nikl] +- Remove some directories in old that have been updated to 1.2 +- Add dylib building for Mac OS X in configure and Makefile.in +- Remove old distribution stuff from Makefile +- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X +- Update links in README + +Changes in 1.2.0.6 (13 September 2003) +- Minor FAQ updates +- Update contrib/minizip to 1.00 [Vollant] +- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] +- Update POSTINC comment for 68060 [Nikl] +- Add contrib/infback9 with deflate64 decoding (unsupported) +- For MVS define NO_vsnprintf and undefine FAR [van Burik] +- Add pragma for fdopen on MVS [van Burik] + +Changes in 1.2.0.5 (8 September 2003) +- Add OF to inflateBackEnd() declaration in zlib.h +- Remember start when using gzdopen in the middle of a file +- Use internal off_t counters in gz* functions to properly handle seeks +- Perform more rigorous check for distance-too-far in inffast.c +- Add Z_BLOCK flush option to return from inflate at block boundary +- Set strm->data_type on return from inflate + - Indicate bits unused, if at block boundary, and if in last block +- Replace size_t with ptrdiff_t in crc32.c, and check for correct size +- Add condition so old NO_DEFLATE define still works for compatibility +- FAQ update regarding the Windows DLL [Truta] +- INDEX update: add qnx entry, remove aix entry [Truta] +- Install zlib.3 into mandir [Wilson] +- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] +- Adapt the zlib interface to the new DLL convention guidelines [Truta] +- Introduce ZLIB_WINAPI macro to allow the export of functions using + the WINAPI calling convention, for Visual Basic [Vollant, Truta] +- Update msdos and win32 scripts and makefiles [Truta] +- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] +- Add contrib/ada [Anisimkov] +- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] +- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] +- Add contrib/masm686 [Truta] +- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm + [Truta, Vollant] +- Update contrib/delphi; rename to contrib/pascal; add example [Truta] +- Remove contrib/delphi2; add a new contrib/delphi [Truta] +- Avoid inclusion of the nonstandard in contrib/iostream, + and fix some method prototypes [Truta] +- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip + [Truta] +- Avoid the use of backslash (\) in contrib/minizip [Vollant] +- Fix file time handling in contrib/untgz; update makefiles [Truta] +- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines + [Vollant] +- Remove contrib/vstudio/vc15_16 [Vollant] +- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] +- Update README.contrib [Truta] +- Invert the assignment order of match_head and s->prev[...] in + INSERT_STRING [Truta] +- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings + [Truta] +- Compare function pointers with 0, not with NULL or Z_NULL [Truta] +- Fix prototype of syncsearch in inflate.c [Truta] +- Introduce ASMINF macro to be enabled when using an ASM implementation + of inflate_fast [Truta] +- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] +- Modify test_gzio in example.c to take a single file name as a + parameter [Truta] +- Exit the example.c program if gzopen fails [Truta] +- Add type casts around strlen in example.c [Truta] +- Remove casting to sizeof in minigzip.c; give a proper type + to the variable compared with SUFFIX_LEN [Truta] +- Update definitions of STDC and STDC99 in zconf.h [Truta] +- Synchronize zconf.h with the new Windows DLL interface [Truta] +- Use SYS16BIT instead of __32BIT__ to distinguish between + 16- and 32-bit platforms [Truta] +- Use far memory allocators in small 16-bit memory models for + Turbo C [Truta] +- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in + zlibCompileFlags [Truta] +- Cygwin has vsnprintf [Wilson] +- In Windows16, OS_CODE is 0, as in MSDOS [Truta] +- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] + +Changes in 1.2.0.4 (10 August 2003) +- Minor FAQ updates +- Be more strict when checking inflateInit2's windowBits parameter +- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well +- Add gzip wrapper option to deflateInit2 using windowBits +- Add updated QNX rule in configure and qnx directory [Bonnefoy] +- Make inflate distance-too-far checks more rigorous +- Clean up FAR usage in inflate +- Add casting to sizeof() in gzio.c and minigzip.c + +Changes in 1.2.0.3 (19 July 2003) +- Fix silly error in gzungetc() implementation [Vollant] +- Update contrib/minizip and contrib/vstudio [Vollant] +- Fix printf format in example.c +- Correct cdecl support in zconf.in.h [Anisimkov] +- Minor FAQ updates + +Changes in 1.2.0.2 (13 July 2003) +- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons +- Attempt to avoid warnings in crc32.c for pointer-int conversion +- Add AIX to configure, remove aix directory [Bakker] +- Add some casts to minigzip.c +- Improve checking after insecure sprintf() or vsprintf() calls +- Remove #elif's from crc32.c +- Change leave label to inf_leave in inflate.c and infback.c to avoid + library conflicts +- Remove inflate gzip decoding by default--only enable gzip decoding by + special request for stricter backward compatibility +- Add zlibCompileFlags() function to return compilation information +- More typecasting in deflate.c to avoid warnings +- Remove leading underscore from _Capital #defines [Truta] +- Fix configure to link shared library when testing +- Add some Windows CE target adjustments [Mai] +- Remove #define ZLIB_DLL in zconf.h [Vollant] +- Add zlib.3 [Rodgers] +- Update RFC URL in deflate.c and algorithm.txt [Mai] +- Add zlib_dll_FAQ.txt to contrib [Truta] +- Add UL to some constants [Truta] +- Update minizip and vstudio [Vollant] +- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h +- Expand use of NO_DUMMY_DECL to avoid all dummy structures +- Added iostream3 to contrib [Schwardt] +- Replace rewind() with fseek() for WinCE [Truta] +- Improve setting of zlib format compression level flags + - Report 0 for huffman and rle strategies and for level == 0 or 1 + - Report 2 only for level == 6 +- Only deal with 64K limit when necessary at compile time [Truta] +- Allow TOO_FAR check to be turned off at compile time [Truta] +- Add gzclearerr() function [Souza] +- Add gzungetc() function + +Changes in 1.2.0.1 (17 March 2003) +- Add Z_RLE strategy for run-length encoding [Truta] + - When Z_RLE requested, restrict matches to distance one + - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE +- Correct FASTEST compilation to allow level == 0 +- Clean up what gets compiled for FASTEST +- Incorporate changes to zconf.in.h [Vollant] + - Refine detection of Turbo C need for dummy returns + - Refine ZLIB_DLL compilation + - Include additional header file on VMS for off_t typedef +- Try to use _vsnprintf where it supplants vsprintf [Vollant] +- Add some casts in inffast.c +- Enchance comments in zlib.h on what happens if gzprintf() tries to + write more than 4095 bytes before compression +- Remove unused state from inflateBackEnd() +- Remove exit(0) from minigzip.c, example.c +- Get rid of all those darn tabs +- Add "check" target to Makefile.in that does the same thing as "test" +- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in +- Update contrib/inflate86 [Anderson] +- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] +- Add msdos and win32 directories with makefiles [Truta] +- More additions and improvements to the FAQ + +Changes in 1.2.0 (9 March 2003) +- New and improved inflate code + - About 20% faster + - Does not allocate 32K window unless and until needed + - Automatically detects and decompresses gzip streams + - Raw inflate no longer needs an extra dummy byte at end + - Added inflateBack functions using a callback interface--even faster + than inflate, useful for file utilities (gzip, zip) + - Added inflateCopy() function to record state for random access on + externally generated deflate streams (e.g. in gzip files) + - More readable code (I hope) +- New and improved crc32() + - About 50% faster, thanks to suggestions from Rodney Brown +- Add deflateBound() and compressBound() functions +- Fix memory leak in deflateInit2() +- Permit setting dictionary for raw deflate (for parallel deflate) +- Fix const declaration for gzwrite() +- Check for some malloc() failures in gzio.c +- Fix bug in gzopen() on single-byte file 0x1f +- Fix bug in gzread() on concatenated file with 0x1f at end of buffer + and next buffer doesn't start with 0x8b +- Fix uncompress() to return Z_DATA_ERROR on truncated input +- Free memory at end of example.c +- Remove MAX #define in trees.c (conflicted with some libraries) +- Fix static const's in deflate.c, gzio.c, and zutil.[ch] +- Declare malloc() and free() in gzio.c if STDC not defined +- Use malloc() instead of calloc() in zutil.c if int big enough +- Define STDC for AIX +- Add aix/ with approach for compiling shared library on AIX +- Add HP-UX support for shared libraries in configure +- Add OpenUNIX support for shared libraries in configure +- Use $cc instead of gcc to build shared library +- Make prefix directory if needed when installing +- Correct Macintosh avoidance of typedef Byte in zconf.h +- Correct Turbo C memory allocation when under Linux +- Use libz.a instead of -lz in Makefile (assure use of compiled library) +- Update configure to check for snprintf or vsnprintf functions and their + return value, warn during make if using an insecure function +- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that + is lost when library is used--resolution is to build new zconf.h +- Documentation improvements (in zlib.h): + - Document raw deflate and inflate + - Update RFCs URL + - Point out that zlib and gzip formats are different + - Note that Z_BUF_ERROR is not fatal + - Document string limit for gzprintf() and possible buffer overflow + - Note requirement on avail_out when flushing + - Note permitted values of flush parameter of inflate() +- Add some FAQs (and even answers) to the FAQ +- Add contrib/inflate86/ for x86 faster inflate +- Add contrib/blast/ for PKWare Data Compression Library decompression +- Add contrib/puff/ simple inflate for deflate format description + +Changes in 1.1.4 (11 March 2002) +- ZFREE was repeated on same allocation on some error conditions. + This creates a security problem described in + http://www.zlib.org/advisory-2002-03-11.txt +- Returned incorrect error (Z_MEM_ERROR) on some invalid data +- Avoid accesses before window for invalid distances with inflate window + less than 32K. +- force windowBits > 8 to avoid a bug in the encoder for a window size + of 256 bytes. (A complete fix will be available in 1.1.5). + +Changes in 1.1.3 (9 July 1998) +- fix "an inflate input buffer bug that shows up on rare but persistent + occasions" (Mark) +- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) +- fix gzseek(..., SEEK_SET) in write mode +- fix crc check after a gzeek (Frank Faubert) +- fix miniunzip when the last entry in a zip file is itself a zip file + (J Lillge) +- add contrib/asm586 and contrib/asm686 (Brian Raiter) + See http://www.muppetlabs.com/~breadbox/software/assembly.html +- add support for Delphi 3 in contrib/delphi (Bob Dellaca) +- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) +- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) +- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) +- added a FAQ file + +- Support gzdopen on Mac with Metrowerks (Jason Linhart) +- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) +- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) +- avoid some warnings with Borland C (Tom Tanner) +- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) +- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) +- allow several arguments to configure (Tim Mooney, Frodo Looijaard) +- use libdir and includedir in Makefile.in (Tim Mooney) +- support shared libraries on OSF1 V4 (Tim Mooney) +- remove so_locations in "make clean" (Tim Mooney) +- fix maketree.c compilation error (Glenn, Mark) +- Python interface to zlib now in Python 1.5 (Jeremy Hylton) +- new Makefile.riscos (Rich Walker) +- initialize static descriptors in trees.c for embedded targets (Nick Smith) +- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) +- add the OS/2 files in Makefile.in too (Andrew Zabolotny) +- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) +- fix maketree.c to allow clean compilation of inffixed.h (Mark) +- fix parameter check in deflateCopy (Gunther Nikl) +- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) +- Many portability patches by Christian Spieler: + . zutil.c, zutil.h: added "const" for zmem* + . Make_vms.com: fixed some typos + . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists + . msdos/Makefile.msc: remove "default rtl link library" info from obj files + . msdos/Makefile.*: use model-dependent name for the built zlib library + . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: + new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) +- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) +- replace __far with _far for better portability (Christian Spieler, Tom Lane) +- fix test for errno.h in configure (Tim Newsham) + +Changes in 1.1.2 (19 March 98) +- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) + See http://www.winimage.com/zLibDll/unzip.html +- preinitialize the inflate tables for fixed codes, to make the code + completely thread safe (Mark) +- some simplifications and slight speed-up to the inflate code (Mark) +- fix gzeof on non-compressed files (Allan Schrum) +- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) +- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) +- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) +- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) +- do not wrap extern "C" around system includes (Tom Lane) +- mention zlib binding for TCL in README (Andreas Kupries) +- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) +- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) +- allow "configure --prefix $HOME" (Tim Mooney) +- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) +- move Makefile.sas to amiga/Makefile.sas + +Changes in 1.1.1 (27 Feb 98) +- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) +- remove block truncation heuristic which had very marginal effect for zlib + (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the + compression ratio on some files. This also allows inlining _tr_tally for + matches in deflate_slow. +- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) + +Changes in 1.1.0 (24 Feb 98) +- do not return STREAM_END prematurely in inflate (John Bowler) +- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) +- compile with -DFASTEST to get compression code optimized for speed only +- in minigzip, try mmap'ing the input file first (Miguel Albrecht) +- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain + on Sun but significant on HP) + +- add a pointer to experimental unzip library in README (Gilles Vollant) +- initialize variable gcc in configure (Chris Herborth) + +Changes in 1.0.9 (17 Feb 1998) +- added gzputs and gzgets functions +- do not clear eof flag in gzseek (Mark Diekhans) +- fix gzseek for files in transparent mode (Mark Diekhans) +- do not assume that vsprintf returns the number of bytes written (Jens Krinke) +- replace EXPORT with ZEXPORT to avoid conflict with other programs +- added compress2 in zconf.h, zlib.def, zlib.dnt +- new asm code from Gilles Vollant in contrib/asm386 +- simplify the inflate code (Mark): + . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() + . ZALLOC the length list in inflate_trees_fixed() instead of using stack + . ZALLOC the value area for huft_build() instead of using stack + . Simplify Z_FINISH check in inflate() + +- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 +- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) +- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with + the declaration of FAR (Gilles VOllant) +- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) +- read_buf buf parameter of type Bytef* instead of charf* +- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) +- do not redeclare unlink in minigzip.c for WIN32 (John Bowler) +- fix check for presence of directories in "make install" (Ian Willis) + +Changes in 1.0.8 (27 Jan 1998) +- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) +- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) +- added compress2() to allow setting the compression level +- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) +- use constant arrays for the static trees in trees.c instead of computing + them at run time (thanks to Ken Raeburn for this suggestion). To create + trees.h, compile with GEN_TREES_H and run "make test". +- check return code of example in "make test" and display result +- pass minigzip command line options to file_compress +- simplifying code of inflateSync to avoid gcc 2.8 bug + +- support CC="gcc -Wall" in configure -s (QingLong) +- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) +- fix test for shared library support to avoid compiler warnings +- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) +- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) +- do not use fdopen for Metrowerks on Mac (Brad Pettit)) +- add checks for gzputc and gzputc in example.c +- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) +- use const for the CRC table (Ken Raeburn) +- fixed "make uninstall" for shared libraries +- use Tracev instead of Trace in infblock.c +- in example.c use correct compressed length for test_sync +- suppress +vnocompatwarnings in configure for HPUX (not always supported) + +Changes in 1.0.7 (20 Jan 1998) +- fix gzseek which was broken in write mode +- return error for gzseek to negative absolute position +- fix configure for Linux (Chun-Chung Chen) +- increase stack space for MSC (Tim Wegner) +- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) +- define EXPORTVA for gzprintf (Gilles Vollant) +- added man page zlib.3 (Rick Rodgers) +- for contrib/untgz, fix makedir() and improve Makefile + +- check gzseek in write mode in example.c +- allocate extra buffer for seeks only if gzseek is actually called +- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) +- add inflateSyncPoint in zconf.h +- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def + +Changes in 1.0.6 (19 Jan 1998) +- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and + gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) +- Fix a deflate bug occurring only with compression level 0 (thanks to + Andy Buckler for finding this one). +- In minigzip, pass transparently also the first byte for .Z files. +- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() +- check Z_FINISH in inflate (thanks to Marc Schluper) +- Implement deflateCopy (thanks to Adam Costello) +- make static libraries by default in configure, add --shared option. +- move MSDOS or Windows specific files to directory msdos +- suppress the notion of partial flush to simplify the interface + (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) +- suppress history buffer provided by application to simplify the interface + (this feature was not implemented anyway in 1.0.4) +- next_in and avail_in must be initialized before calling inflateInit or + inflateInit2 +- add EXPORT in all exported functions (for Windows DLL) +- added Makefile.nt (thanks to Stephen Williams) +- added the unsupported "contrib" directory: + contrib/asm386/ by Gilles Vollant + 386 asm code replacing longest_match(). + contrib/iostream/ by Kevin Ruland + A C++ I/O streams interface to the zlib gz* functions + contrib/iostream2/ by Tyge Løvset + Another C++ I/O streams interface + contrib/untgz/ by "Pedro A. Aranda Guti\irrez" + A very simple tar.gz file extractor using zlib + contrib/visual-basic.txt by Carlos Rios + How to use compress(), uncompress() and the gz* functions from VB. +- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression + level) in minigzip (thanks to Tom Lane) + +- use const for rommable constants in deflate +- added test for gzseek and gztell in example.c +- add undocumented function inflateSyncPoint() (hack for Paul Mackerras) +- add undocumented function zError to convert error code to string + (for Tim Smithers) +- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code. +- Use default memcpy for Symantec MSDOS compiler. +- Add EXPORT keyword for check_func (needed for Windows DLL) +- add current directory to LD_LIBRARY_PATH for "make test" +- create also a link for libz.so.1 +- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) +- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) +- added -soname for Linux in configure (Chun-Chung Chen, +- assign numbers to the exported functions in zlib.def (for Windows DLL) +- add advice in zlib.h for best usage of deflateSetDictionary +- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) +- allow compilation with ANSI keywords only enabled for TurboC in large model +- avoid "versionString"[0] (Borland bug) +- add NEED_DUMMY_RETURN for Borland +- use variable z_verbose for tracing in debug mode (L. Peter Deutsch). +- allow compilation with CC +- defined STDC for OS/2 (David Charlap) +- limit external names to 8 chars for MVS (Thomas Lund) +- in minigzip.c, use static buffers only for 16-bit systems +- fix suffix check for "minigzip -d foo.gz" +- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) +- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) +- added makelcc.bat for lcc-win32 (Tom St Denis) +- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) +- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. +- check for unistd.h in configure (for off_t) +- remove useless check parameter in inflate_blocks_free +- avoid useless assignment of s->check to itself in inflate_blocks_new +- do not flush twice in gzclose (thanks to Ken Raeburn) +- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h +- use NO_ERRNO_H instead of enumeration of operating systems with errno.h +- work around buggy fclose on pipes for HP/UX +- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) +- fix configure if CC is already equal to gcc + +Changes in 1.0.5 (3 Jan 98) +- Fix inflate to terminate gracefully when fed corrupted or invalid data +- Use const for rommable constants in inflate +- Eliminate memory leaks on error conditions in inflate +- Removed some vestigial code in inflate +- Update web address in README + +Changes in 1.0.4 (24 Jul 96) +- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF + bit, so the decompressor could decompress all the correct data but went + on to attempt decompressing extra garbage data. This affected minigzip too. +- zlibVersion and gzerror return const char* (needed for DLL) +- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) +- use z_error only for DEBUG (avoid problem with DLLs) + +Changes in 1.0.3 (2 Jul 96) +- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS + small and medium models; this makes the library incompatible with previous + versions for these models. (No effect in large model or on other systems.) +- return OK instead of BUF_ERROR if previous deflate call returned with + avail_out as zero but there is nothing to do +- added memcmp for non STDC compilers +- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) +- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) +- better check for 16-bit mode MSC (avoids problem with Symantec) + +Changes in 1.0.2 (23 May 96) +- added Windows DLL support +- added a function zlibVersion (for the DLL support) +- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) +- Bytef is define's instead of typedef'd only for Borland C +- avoid reading uninitialized memory in example.c +- mention in README that the zlib format is now RFC1950 +- updated Makefile.dj2 +- added algorithm.doc + +Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] +- fix array overlay in deflate.c which sometimes caused bad compressed data +- fix inflate bug with empty stored block +- fix MSDOS medium model which was broken in 0.99 +- fix deflateParams() which could generate bad compressed data. +- Bytef is define'd instead of typedef'ed (work around Borland bug) +- added an INDEX file +- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), + Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) +- speed up adler32 for modern machines without auto-increment +- added -ansi for IRIX in configure +- static_init_done in trees.c is an int +- define unlink as delete for VMS +- fix configure for QNX +- add configure branch for SCO and HPUX +- avoid many warnings (unused variables, dead assignments, etc...) +- no fdopen for BeOS +- fix the Watcom fix for 32 bit mode (define FAR as empty) +- removed redefinition of Byte for MKWERKS +- work around an MWKERKS bug (incorrect merge of all .h files) + +Changes in 0.99 (27 Jan 96) +- allow preset dictionary shared between compressor and decompressor +- allow compression level 0 (no compression) +- add deflateParams in zlib.h: allow dynamic change of compression level + and compression strategy. +- test large buffers and deflateParams in example.c +- add optional "configure" to build zlib as a shared library +- suppress Makefile.qnx, use configure instead +- fixed deflate for 64-bit systems (detected on Cray) +- fixed inflate_blocks for 64-bit systems (detected on Alpha) +- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) +- always return Z_BUF_ERROR when deflate() has nothing to do +- deflateInit and inflateInit are now macros to allow version checking +- prefix all global functions and types with z_ with -DZ_PREFIX +- make falloc completely reentrant (inftrees.c) +- fixed very unlikely race condition in ct_static_init +- free in reverse order of allocation to help memory manager +- use zlib-1.0/* instead of zlib/* inside the tar.gz +- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith + -Wconversion -Wstrict-prototypes -Wmissing-prototypes" +- allow gzread on concatenated .gz files +- deflateEnd now returns Z_DATA_ERROR if it was premature +- deflate is finally (?) fully deterministic (no matches beyond end of input) +- Document Z_SYNC_FLUSH +- add uninstall in Makefile +- Check for __cpluplus in zlib.h +- Better test in ct_align for partial flush +- avoid harmless warnings for Borland C++ +- initialize hash_head in deflate.c +- avoid warning on fdopen (gzio.c) for HP cc -Aa +- include stdlib.h for STDC compilers +- include errno.h for Cray +- ignore error if ranlib doesn't exist +- call ranlib twice for NeXTSTEP +- use exec_prefix instead of prefix for libz.a +- renamed ct_* as _tr_* to avoid conflict with applications +- clear z->msg in inflateInit2 before any error return +- initialize opaque in example.c, gzio.c, deflate.c and inflate.c +- fixed typo in zconf.h (_GNUC__ => __GNUC__) +- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) +- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) +- in fcalloc, normalize pointer if size > 65520 bytes +- don't use special fcalloc for 32 bit Borland C++ +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... +- use Z_BINARY instead of BINARY +- document that gzclose after gzdopen will close the file +- allow "a" as mode in gzopen. +- fix error checking in gzread +- allow skipping .gz extra-field on pipes +- added reference to Perl interface in README +- put the crc table in FAR data (I dislike more and more the medium model :) +- added get_crc_table +- added a dimension to all arrays (Borland C can't count). +- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast +- guard against multiple inclusion of *.h (for precompiled header on Mac) +- Watcom C pretends to be Microsoft C small model even in 32 bit mode. +- don't use unsized arrays to avoid silly warnings by Visual C++: + warning C4746: 'inflate_mask' : unsized array treated as '__far' + (what's wrong with far data in far model?). +- define enum out of inflate_blocks_state to allow compilation with C++ + +Changes in 0.95 (16 Aug 95) +- fix MSDOS small and medium model (now easier to adapt to any compiler) +- inlined send_bits +- fix the final (:-) bug for deflate with flush (output was correct but + not completely flushed in rare occasions). +- default window size is same for compression and decompression + (it's now sufficient to set MAX_WBITS in zconf.h). +- voidp -> voidpf and voidnp -> voidp (for consistency with other + typedefs and because voidnp was not near in large model). + +Changes in 0.94 (13 Aug 95) +- support MSDOS medium model +- fix deflate with flush (could sometimes generate bad output) +- fix deflateReset (zlib header was incorrectly suppressed) +- added support for VMS +- allow a compression level in gzopen() +- gzflush now calls fflush +- For deflate with flush, flush even if no more input is provided. +- rename libgz.a as libz.a +- avoid complex expression in infcodes.c triggering Turbo C bug +- work around a problem with gcc on Alpha (in INSERT_STRING) +- don't use inline functions (problem with some gcc versions) +- allow renaming of Byte, uInt, etc... with #define. +- avoid warning about (unused) pointer before start of array in deflate.c +- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c +- avoid reserved word 'new' in trees.c + +Changes in 0.93 (25 June 95) +- temporarily disable inline functions +- make deflate deterministic +- give enough lookahead for PARTIAL_FLUSH +- Set binary mode for stdin/stdout in minigzip.c for OS/2 +- don't even use signed char in inflate (not portable enough) +- fix inflate memory leak for segmented architectures + +Changes in 0.92 (3 May 95) +- don't assume that char is signed (problem on SGI) +- Clear bit buffer when starting a stored block +- no memcpy on Pyramid +- suppressed inftest.c +- optimized fill_window, put longest_match inline for gcc +- optimized inflate on stored blocks. +- untabify all sources to simplify patches + +Changes in 0.91 (2 May 95) +- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h +- Document the memory requirements in zconf.h +- added "make install" +- fix sync search logic in inflateSync +- deflate(Z_FULL_FLUSH) now works even if output buffer too short +- after inflateSync, don't scare people with just "lo world" +- added support for DJGPP + +Changes in 0.9 (1 May 95) +- don't assume that zalloc clears the allocated memory (the TurboC bug + was Mark's bug after all :) +- let again gzread copy uncompressed data unchanged (was working in 0.71) +- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented +- added a test of inflateSync in example.c +- moved MAX_WBITS to zconf.h because users might want to change that. +- document explicitly that zalloc(64K) on MSDOS must return a normalized + pointer (zero offset) +- added Makefiles for Microsoft C, Turbo C, Borland C++ +- faster crc32() + +Changes in 0.8 (29 April 95) +- added fast inflate (inffast.c) +- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this + is incompatible with previous versions of zlib which returned Z_OK. +- work around a TurboC compiler bug (bad code for b << 0, see infutil.h) + (actually that was not a compiler bug, see 0.81 above) +- gzread no longer reads one extra byte in certain cases +- In gzio destroy(), don't reference a freed structure +- avoid many warnings for MSDOS +- avoid the ERROR symbol which is used by MS Windows + +Changes in 0.71 (14 April 95) +- Fixed more MSDOS compilation problems :( There is still a bug with + TurboC large model. + +Changes in 0.7 (14 April 95) +- Added full inflate support. +- Simplified the crc32() interface. The pre- and post-conditioning + (one's complement) is now done inside crc32(). WARNING: this is + incompatible with previous versions; see zlib.h for the new usage. + +Changes in 0.61 (12 April 95) +- workaround for a bug in TurboC. example and minigzip now work on MSDOS. + +Changes in 0.6 (11 April 95) +- added minigzip.c +- added gzdopen to reopen a file descriptor as gzFile +- added transparent reading of non-gziped files in gzread. +- fixed bug in gzread (don't read crc as data) +- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose). +- don't allocate big arrays in the stack (for MSDOS) +- fix some MSDOS compilation problems + +Changes in 0.5: +- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but + not yet Z_FULL_FLUSH. +- support decompression but only in a single step (forced Z_FINISH) +- added opaque object for zalloc and zfree. +- added deflateReset and inflateReset +- added a variable zlib_version for consistency checking. +- renamed the 'filter' parameter of deflateInit2 as 'strategy'. + Added Z_FILTERED and Z_HUFFMAN_ONLY constants. + +Changes in 0.4: +- avoid "zip" everywhere, use zlib instead of ziplib. +- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush + if compression method == 8. +- added adler32 and crc32 +- renamed deflateOptions as deflateInit2, call one or the other but not both +- added the method parameter for deflateInit2. +- added inflateInit2 +- simplied considerably deflateInit and inflateInit by not supporting + user-provided history buffer. This is supported only in deflateInit2 + and inflateInit2. + +Changes in 0.3: +- prefix all macro names with Z_ +- use Z_FINISH instead of deflateEnd to finish compression. +- added Z_HUFFMAN_ONLY +- added gzerror() diff --git a/libs/zlibng/INDEX b/libs/zlibng/INDEX new file mode 100644 index 000000000..34c80ad9e --- /dev/null +++ b/libs/zlibng/INDEX @@ -0,0 +1,55 @@ +CMakeLists.txt cmake build file +ChangeLog.zlib history of changes up to the fork from zlib 1.2.11 +FAQ.zlib Frequently Asked Questions about zlib, as distributed in zlib 1.2.11 +INDEX this file +Makefile dummy Makefile that tells you to ./configure +Makefile.in template for Unix Makefile +README guess what +README.zlib Copy of the original README file distributed in zlib 1.2.11 +configure configure script for Unix +test/example.c zlib usages examples for build testing +test/minigzip.c minimal gzip-like functionality for build testing +test/infcover.c inf*.c code coverage for build coverage testing +treebuild.xml XML description of source file dependencies +zconf.h.cmakein zconf.h template for cmake +zconf.h.in zconf.h template for configure +zlib.3 Man page for zlib +zlib.3.pdf Man page in PDF format +zlib.map Linux symbol information +zlib.pc.in Template for pkg-config descriptor +zlib.pc.cmakein zlib.pc template for cmake +zlib2ansi perl script to convert source files for C++ compilation + +arch/ architecture-specific code +doc/ documentation for formats and algorithms +win32/ makefiles for Windows + + zlib public header files (required for library use): +zconf.h +zlib.h + + private source files used to build the zlib library: +adler32.c +compress.c +crc32.c +crc32.h +deflate.c +deflate.h +gzclose.c +gzguts.h +gzlib.c +gzread.c +gzwrite.c +infback.c +inffast.c +inffast.h +inffixed.h +inflate.c +inflate.h +inftrees.c +inftrees.h +trees.c +trees.h +uncompr.c +zutil.c +zutil.h diff --git a/libs/zlibng/INDEX.md b/libs/zlibng/INDEX.md deleted file mode 100644 index 5be081c4e..000000000 --- a/libs/zlibng/INDEX.md +++ /dev/null @@ -1,37 +0,0 @@ -Contents --------- - -| Name | Description | -|:-----------------|:---------------------------------------------------------------| -| arch/ | Architecture-specific code | -| doc/ | Documentation for formats and algorithms | -| test/example.c | Zlib usages examples for build testing | -| test/minigzip.c | Minimal gzip-like functionality for build testing | -| test/infcover.c | Inflate code coverage for build testing | -| win32/ | Shared library version resources for Windows | -| CMakeLists.txt | Cmake build script | -| configure | Bash configure/build script | -| adler32.c | Compute the Adler-32 checksum of a data stream | -| chunkset.* | Inline functions to copy small data chunks | -| compress.c | Compress a memory buffer | -| deflate.* | Compress data using the deflate algorithm | -| deflate_fast.c | Compress data using the deflate algorithm with fast strategy | -| deflate_medium.c | Compress data using the deflate algorithm with medium strategy | -| deflate_slow.c | Compress data using the deflate algorithm with slow strategy | -| functable.* | Struct containing function pointers to optimized functions | -| gzguts.h | Internal definitions for gzip operations | -| gzlib.c | Functions common to reading and writing gzip files | -| gzread.c | Read gzip files | -| gzwrite.c | Write gzip files | -| infback.* | Inflate using a callback interface | -| inflate.* | Decompress data | -| inffast.* | Decompress data with speed optimizations | -| inffixed_tbl.h | Table for decoding fixed codes | -| inftrees.h | Generate Huffman trees for efficient decoding | -| trees.* | Output deflated data using Huffman coding | -| uncompr.c | Decompress a memory buffer | -| zconf.h.cmakein | zconf.h template for cmake | -| zendian.h | BYTE_ORDER for endian tests | -| zlib.3 | Man page for zlib | -| zlib.map | Linux symbol information | -| zlib.pc.in | Pkg-config template | diff --git a/libs/zlibng/INSTALL b/libs/zlibng/INSTALL new file mode 100644 index 000000000..7aa87a50d --- /dev/null +++ b/libs/zlibng/INSTALL @@ -0,0 +1,64 @@ +Overview +======== + +There are several methods for compiling and installing zlib-ng, depending +on your favorite operating system and development toolkits. +This document will attempt to give a general overview of some of them. + +PS: We do not recommend running 'make install' unless you know what you + are doing, as this can override the system default zlib library, and + any wrong configuration or incompatability of zlib-ng can make the + whole system unusable. + +On linux distros, an alternative way to use zlib-ng instead of zlib +for specific programs exist, use LD_PRELOAD. +If the program is dynamically linked with zlib, then zlib-ng can take +its place without risking system-wide instability. Ex: +LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.11.zlib-ng /usr/bin/program + + +Configure +========= + +Using the configure script is currently the main method of setting up the +makefiles and preparing for compilation. Configure will attempt to detect +the specifics of your system, and enable some of the relevant options for you. + +Configure accepts several command-line options, some of the most important +ones are detailed below. + +--zlib-compat + This enables options that will ensure that zlib-ng is compiled with all the + functions that a standard zlib library contains, you will need to use this + if you are going to be using zlib-ng as a drop-in replacement for zlib. + +--without-optimizations + This will disable zlib-ng specific optimizations (does not disable strategies). + +--without-new-strategies + This will disable specially optimized strategies, such as deflate_quick and + deflate_medium. + +Run configure like this: +./configure --zlib-compat + +Then you can compile using make: +make +make test + + +Cmake +===== + +Cmake is an alternative to configure, basically letting you do the same thing, +but with different tools and user interfaces. + +Start by initializing cmake: +cmake . + +Then you can start the configuration tui to set the wanted options +ccmake . + +You can now compile using make: +make +make test diff --git a/libs/zlibng/Makefile.in b/libs/zlibng/Makefile.in index 8de3192c9..69fe01165 100644 --- a/libs/zlibng/Makefile.in +++ b/libs/zlibng/Makefile.in @@ -29,8 +29,8 @@ TEST_LIBS=$(LIBNAME1).a LDSHARED=$(CC) LDSHAREDFLAGS=-shared -VER=2.0.0-RC2 -VER1=2 +VER=1.9.9 +VER1=1 STATICLIB=$(LIBNAME1).a SHAREDLIB=$(LIBNAME1).so @@ -51,7 +51,7 @@ RCOBJS= STRIP= RANLIB=ranlib LDCONFIG=ldconfig -LDSHAREDLIBC= +LDSHAREDLIBC=-lc EXE= SRCDIR=. @@ -71,64 +71,12 @@ mandir = ${prefix}/share/man man3dir = ${mandir}/man3 pkgconfigdir = ${libdir}/pkgconfig -OBJZ = \ - adler32.o \ - chunkset.o \ - compare258.o \ - compress.o \ - crc32.o \ - crc32_comb.o \ - deflate.o \ - deflate_fast.o \ - deflate_medium.o \ - deflate_quick.o \ - deflate_slow.o \ - functable.o \ - infback.o \ - inffast.o \ - inflate.o \ - inftrees.o \ - insert_string.o \ - trees.o \ - uncompr.o \ - zutil.o \ - $(ARCH_STATIC_OBJS) - -OBJG = \ - gzlib.o \ - gzread.o \ - gzwrite.o - +OBJZ = adler32.o compress.o crc32.o deflate.o deflate_fast.o deflate_medium.o deflate_slow.o functable.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o $(ARCH_STATIC_OBJS) +OBJG = gzclose.o gzlib.o gzread.o gzwrite.o OBJC = $(OBJZ) $(OBJG) -PIC_OBJZ = \ - adler32.lo \ - chunkset.lo \ - compare258.lo \ - compress.lo \ - crc32.lo \ - crc32_comb.lo \ - deflate.lo \ - deflate_fast.lo \ - deflate_medium.lo \ - deflate_quick.lo \ - deflate_slow.lo \ - functable.lo \ - infback.lo \ - inffast.lo \ - inflate.lo \ - inftrees.lo \ - insert_string.lo \ - trees.lo \ - uncompr.lo \ - zutil.lo \ - $(ARCH_SHARED_OBJS) - -PIC_OBJG = \ - gzlib.lo \ - gzread.lo \ - gzwrite.lo - +PIC_OBJZ = adler32.lo compress.lo crc32.lo deflate.lo deflate_fast.lo deflate_medium.lo deflate_slow.lo functable.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo $(ARCH_SHARED_OBJS) +PIC_OBJG = gzclose.lo gzlib.lo gzread.lo gzwrite.lo PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) OBJS = $(OBJC) @@ -137,9 +85,11 @@ PIC_OBJS = $(PIC_OBJC) all: static shared -static: adler32_test$(EXE) example$(EXE) minigzip$(EXE) fuzzers makefixed$(EXE) maketrees$(EXE) makecrct$(EXE) +static: example$(EXE) minigzip$(EXE) fuzzers -shared: adler32_testsh$(EXE) examplesh$(EXE) minigzipsh$(EXE) +shared: examplesh$(EXE) minigzipsh$(EXE) + +all64: example64$(EXE) minigzip64$(EXE) check: test @@ -231,23 +181,17 @@ $(STATICLIB): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 -adler32_test.o: - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/adler32_test.c - example.o: $(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c minigzip.o: $(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c -makefixed.o: - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makefixed.c +example64.o: + $(CC) $(CFLAGS) -DWITH_GZFILEOP -D_FILE_OFFSET_BITS=64 $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c -maketrees.o: - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/maketrees.c - -makecrct.o: - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makecrct.c +minigzip64.o: + $(CC) $(CFLAGS) -DWITH_GZFILEOP -D_FILE_OFFSET_BITS=64 $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c zlibrc.o: win32/zlib$(SUFFIX)1.rc $(RC) $(RCFLAGS) -o $@ win32/zlib$(SUFFIX)1.rc @@ -265,7 +209,7 @@ $(OBJG): %.o: $(SRCDIR)/%.c $(SHAREDTARGET): $(PIC_OBJS) $(DEFFILE) $(RCOBJS) ifneq ($(SHAREDTARGET),) - $(LDSHARED) $(CFLAGS) $(LDSHAREDFLAGS) $(LDFLAGS) -o $@ $(DEFFILE) $(PIC_OBJS) $(RCOBJS) $(LDSHAREDLIBC) + $(LDSHARED) $(LDSHAREDFLAGS) $(LDFLAGS) -o $@ $(DEFFILE) $(PIC_OBJS) $(RCOBJS) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif @@ -276,56 +220,38 @@ ifneq ($(SHAREDLIB),$(SHAREDTARGET)) endif endif -adler32_test$(EXE): adler32_test.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ adler32_test.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) -ifneq ($(STRIP),) - $(STRIP) $@ -endif - example$(EXE): example.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) + $(CC) $(LDFLAGS) -o $@ example.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif minigzip$(EXE): minigzip.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) -ifneq ($(STRIP),) - $(STRIP) $@ -endif - -adler32_testsh$(EXE): adler32_test.o $(OBJG) $(SHAREDTARGET) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ adler32_test.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC) + $(CC) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif examplesh$(EXE): example.o $(OBJG) $(SHAREDTARGET) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC) + $(CC) $(LDFLAGS) -o $@ example.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif minigzipsh$(EXE): minigzip.o $(OBJG) $(SHAREDTARGET) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC) + $(CC) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif -makefixed$(EXE): makefixed.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ makefixed.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) +example64$(EXE): example64.o $(OBJG) $(STATICLIB) + $(CC) $(LDFLAGS) -o $@ example64.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif -maketrees$(EXE): maketrees.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ maketrees.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) -ifneq ($(STRIP),) - $(STRIP) $@ -endif - -makecrct$(EXE): makecrct.o $(OBJG) $(STATICLIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ makecrct.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) +minigzip64$(EXE): minigzip64.o $(OBJG) $(STATICLIB) + $(CC) $(LDFLAGS) -o $@ minigzip64.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC) ifneq ($(STRIP),) $(STRIP) $@ endif @@ -400,11 +326,11 @@ clean: @if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) clean; fi @if [ -f test/Makefile ]; then $(MAKE) -C test clean; fi rm -f *.o *.lo *~ \ - adler32_test$(EXE) example$(EXE) minigzip$(EXE) \ - adler32_testsh$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ + example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ + example64$(EXE) minigzip64$(EXE) \ checksum_fuzzer$(EXE) compress_fuzzer$(EXE) example_small_fuzzer$(EXE) example_large_fuzzer$(EXE) \ example_flush_fuzzer$(EXE) example_dict_fuzzer$(EXE) minigzip_fuzzer$(EXE) \ - infcover makefixed$(EXE) maketrees$(EXE) makecrct$(EXE) \ + infcover \ $(STATICLIB) $(IMPORTLIB) $(SHAREDLIB) $(SHAREDLIBV) $(SHAREDLIBM) \ foo.gz so_locations \ _match.s maketree @@ -412,8 +338,6 @@ clean: rm -f *.gcda *.gcno *.gcov rm -f a.out a.exe rm -f *.pc - rm -f *._h - rm -rf btmp1 btmp2 pkgtmp1 pkgtmp2 maintainer-clean: distclean distclean: clean diff --git a/libs/zlibng/README.md b/libs/zlibng/README.md index ad14c3ff4..b2be6e59f 100644 --- a/libs/zlibng/README.md +++ b/libs/zlibng/README.md @@ -1,41 +1,10 @@ -## zlib-ng -*zlib data compression library for the next generation systems* +zlib-ng - zlib for the next generation systems Maintained by Hans Kristian Rosbach aka Dead2 (zlib-ng àt circlestorm dót org) -|CI|Status| -|:-|-| -|GitHub Actions|[![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20CMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20Configure/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20NMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions)| -|Buildkite|[![Build status](https://badge.buildkite.com/7bb1ef84356d3baee26202706cc053ee1de871c0c712b65d26.svg?branch=develop)](https://buildkite.com/circlestorm-productions/zlib-ng)| -|CodeFactor|[![CodeFactor](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/badge)](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng)| -|OSS-Fuzz|[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/zlib-ng.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng) -|Codecov|[![codecov.io](https://codecov.io/github/zlib-ng/zlib-ng/coverage.svg?branch=develop)](https://codecov.io/github/zlib-ng/zlib-ng/)| -Features --------- - -* Zlib compatible API with support for dual-linking -* Modernized native API based on zlib API for ease of porting -* Modern C99 syntax and a clean code layout -* Deflate medium and quick algorithms based on Intels zlib fork -* Support for CPU intrinsics when available - * Adler32 implementation using SSSE3, AVX2, Neon & VSX - * CRC32-B implementation using PCLMULQDQ & ACLE - * Hash table implementation using CRC32-C intrinsics on x86 and ARM - * Slide hash implementations using SSE2, AVX2, Neon & VSX - * Compare256/258 implementations using SSE4.2 & AVX2 - * Inflate chunk copying using SSE2, AVX2 & Neon - * Support for hardware-accelerated deflate using IBM Z DFLTCC -* Unaligned memory read/writes and large bit buffer improvements -* Includes improvements from Cloudflare and Intel forks -* Configure, CMake, and NMake build system support -* Comprehensive set of CMake unit tests -* Code sanitizers, fuzzing, and coverage -* GitHub Actions continuous integration on Windows, macOS, and Linux - * Emulated CI for ARM, AARCH64, PPC, PPC64, SPARC64, S390x using qemu - -Fork Motivation +Fork Motivation and History --------------------------- The motivation for this fork was due to seeing several 3rd party @@ -69,97 +38,17 @@ various dead code, all contrib and example code as there is little point in having those in this fork for various reasons. A lot of improvements have gone into zlib-ng since its start, and -numerous people and companies have contributed both small and big -improvements, or valuable testing. +numerous people have contributed both small and big improvements, +or valuable testing. Please read LICENSE.md, it is very simple and very liberal. -Build ------ - -There are two ways to build zlib-ng: - -### Cmake - -To build zlib-ng using the cross-platform makefile generator cmake. - -``` -cmake . -cmake --build . --config Release -ctest --verbose -C Release -``` - -Alternatively, you can use the cmake configuration GUI tool ccmake: - -``` -ccmake . -``` - -### Configure - -To build zlib-ng using the bash configure script: - -``` -./configure -make -make test -``` - -Build Options -------------- -| CMake | configure | Description | Default | -|:-------------------------|:-------------------------|:--------------------------------------------------------------------------------------|---------| -| ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF | -| ZLIB_ENABLE_TESTS | | Build test binaries | ON | -| WITH_GZFILEOP | --without-gzfileops | Compile with support for gzFile related functions | ON | -| WITH_OPTIM | --without-optimizations | Build with optimisations | ON | -| WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON | -| WITH_NATIVE_INSTRUCTIONS | --native | Compiles with full instruction set supported on this host (gcc/clang -march=native) | OFF | -| WITH_SANITIZER | --with-sanitizer | Build with sanitizer (memory, address, undefined) | OFF | -| WITH_FUZZERS | --with-fuzzers | Build test/fuzz | OFF | -| WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF | -| WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF | - -Install -------- - -WARNING: We do not recommend manually installing unless you really -know what you are doing, because this can potentially override the system -default zlib library, and any incompatibility or wrong configuration of -zlib-ng can make the whole system unusable, requiring recovery or reinstall. -If you still want a manual install, we recommend using the /opt/ path prefix. - -For Linux distros, an alternative way to use zlib-ng (if compiled in -zlib-compat mode) instead of zlib, is through the use of the -_LD_PRELOAD_ environment variable. If the program is dynamically linked -with zlib, then zlib-ng will temporarily be used instead by the program, -without risking system-wide instability. - -``` -LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.11.zlib-ng /usr/bin/program -``` - -### Cmake - -To install zlib-ng system-wide using cmake: - -``` -cmake --build . --target install -``` - -### Configure - -To install zlib-ng system-wide using the configure script: - -``` -make install -``` Contributing ------------ -Zlib-ng is a aiming to be open to contributions, and we would be -delighted to receive pull requests on github. +Zlib-ng is a young project, and we aim to be open to contributions, +and we would be delighted to receive pull requests on github. Just remember that any code you submit must be your own and it must be zlib licensed. Help with testing and reviewing of pull requests etc is also very @@ -184,23 +73,9 @@ The deflate and zlib specifications were written by L. Peter Deutsch. zlib was originally created by Jean-loup Gailly (compression) and Mark Adler (decompression). -Advanced Build Options ----------------------- -| CMake | configure | Description | Default | -|:--------------------------------|:----------------------|:--------------------------------------------------------------------|------------------------| -| ZLIB_DUAL_LINK | | Dual link tests with system zlib | OFF | -| | --force-sse2 | Assume SSE2 instructions are always available | ON (x86), OFF (x86_64) | -| WITH_AVX2 | | Build with AVX2 intrinsics | ON | -| WITH_SSE2 | | Build with SSE2 intrinsics | ON | -| WITH_SSE4 | | Build with SSE4 intrinsics | ON | -| WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON | -| WITH_ACLE | --without-acle | Build with ACLE intrinsics | ON | -| WITH_NEON | --without-neon | Build with NEON intrinsics | ON | -| WITH_POWER8 | | Build with POWER8 optimisations | ON | -| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z | OFF | -| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z | OFF | -| WITH_UNALIGNED | | Allow optimizations that use unaligned reads if safe on current arch| ON | -| WITH_INFLATE_STRICT | | Build with strict inflate distance checking | OFF | -| WITH_INFLATE_ALLOW_INVALID_DIST | | Build with zero fill for inflate invalid distances | OFF | -| INSTALL_UTILS | | Copy minigzip and minideflate during install | OFF | +Build Status +------------ + +Travis CI: [![build status](https://api.travis-ci.org/zlib-ng/zlib-ng.svg)](https://travis-ci.org/zlib-ng/zlib-ng/) +Buildkite: [![Build status](https://badge.buildkite.com/7bb1ef84356d3baee26202706cc053ee1de871c0c712b65d26.svg?branch=develop)](https://buildkite.com/circlestorm-productions/zlib-ng) diff --git a/libs/zlibng/README.zlib b/libs/zlibng/README.zlib new file mode 100644 index 000000000..edaad58bc --- /dev/null +++ b/libs/zlibng/README.zlib @@ -0,0 +1,118 @@ +ZLIB DATA COMPRESSION LIBRARY + +zlib 1.2.11 is a general purpose data compression library. All the code is +thread safe. The data format used by the zlib library is described by RFCs +(Request for Comments) 1950 to 1952 in the files +http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and +rfc1952 (gzip format). + +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example +of the library is given in the file test/example.c which also tests that +the library is working correctly. Another example is given in the file +test/minigzip.c. The compression library itself is composed of all source +files in the root directory. + +To compile all files and run the test program, follow the instructions given at +the top of Makefile.in. In short "./configure; make test", and if that goes +well, "make install" should work for most flavors of Unix. For Windows, use +one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use +make_vms.com. + +Questions about zlib should be sent to , or to Gilles Vollant + for the Windows DLL version. The zlib home page is +http://zlib.net/ . Before reporting a problem, please check this site to +verify that you have the latest version of zlib; otherwise get the latest +version and check whether the problem still exists or not. + +PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. + +Mark Nelson wrote an article about zlib for the Jan. 1997 +issue of Dr. Dobb's Journal; a copy of the article is available at +http://marknelson.us/1997/01/01/zlib-engine/ . + +The changes made in version 1.2.11 are documented in the file ChangeLog. + +Unsupported third party contributions are provided in directory contrib/ . + +zlib is available in Java using the java.util.zip package, documented at +http://java.sun.com/developer/technicalArticles/Programming/compression/ . + +A Perl interface to zlib written by Paul Marquess is available +at CPAN (Comprehensive Perl Archive Network) sites, including +http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . + +A Python interface to zlib written by A.M. Kuchling is +available in Python 1.5 and later versions, see +http://docs.python.org/library/zlib.html . + +zlib is built into tcl: http://wiki.tcl.tk/4610 . + +An experimental package to read and write files in .zip format, written on top +of zlib by Gilles Vollant , is available in the +contrib/minizip directory of zlib. + + +Notes for some targets: + +- For Windows DLL versions, please see win32/DLL_FAQ.txt + +- For 64-bit Irix, deflate.c must be compiled without any optimization. With + -O, one libpng test fails. The test works in 32 bit mode (with the -n32 + compiler flag). The compiler bug has been reported to SGI. + +- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works + when compiled with cc. + +- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is + necessary to get gzprintf working correctly. This is done by configure. + +- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with + other compilers. Use "make test" to check your compiler. + +- gzdopen is not supported on RISCOS or BEOS. + +- For PalmOs, see http://palmzlib.sourceforge.net/ + + +Acknowledgments: + + The deflate format used by zlib was defined by Phil Katz. The deflate and + zlib specifications were written by L. Peter Deutsch. Thanks to all the + people who reported problems and suggested various improvements in zlib; they + are too numerous to cite here. + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. We make all +contributions to and distributions of this project solely in our personal +capacity, and are not conveying any rights to any intellectual property of +any third parties. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. diff --git a/libs/zlibng/adler32.c b/libs/zlibng/adler32.c index 7b245fc84..af4104778 100644 --- a/libs/zlibng/adler32.c +++ b/libs/zlibng/adler32.c @@ -3,13 +3,24 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #include "zbuild.h" #include "zutil.h" #include "functable.h" #include "adler32_p.h" +uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t len); +static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2); + +#define DO1(buf, i) {adler += (buf)[i]; sum2 += adler;} +#define DO2(buf, i) DO1(buf, i); DO1(buf, i+1); +#define DO4(buf, i) DO2(buf, i); DO2(buf, i+2); +#define DO8(buf, i) DO4(buf, i); DO4(buf, i+4); +#define DO16(buf) DO8(buf, 0); DO8(buf, 8); + /* ========================================================================= */ -Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t len) { +uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t len) { uint32_t sum2; unsigned n; @@ -18,15 +29,15 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t l adler &= 0xffff; /* in case user likes doing a byte at a time, keep it fast */ - if (UNLIKELY(len == 1)) + if (len == 1) return adler32_len_1(adler, buf, sum2); /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (UNLIKELY(buf == NULL)) + if (buf == NULL) return 1L; /* in case short lengths are provided, keep it somewhat fast */ - if (UNLIKELY(len < 16)) + if (len < 16) return adler32_len_16(adler, buf, len, sum2); /* do length NMAX blocks -- requires just one modulo operation */ @@ -39,15 +50,15 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t l #endif do { #ifdef UNROLL_MORE - DO16(adler, sum2, buf); /* 16 sums unrolled */ + DO16(buf); /* 16 sums unrolled */ buf += 16; #else - DO8(adler, sum2, buf, 0); /* 8 sums unrolled */ + DO8(buf, 0); /* 8 sums unrolled */ buf += 8; #endif } while (--n); - adler %= BASE; - sum2 %= BASE; + MOD(adler); + MOD(sum2); } /* do remaining bytes (less than NMAX, still just one modulo) */ @@ -55,12 +66,12 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t l #ifdef UNROLL_MORE while (len >= 16) { len -= 16; - DO16(adler, sum2, buf); + DO16(buf); buf += 16; #else while (len >= 8) { len -= 8; - DO8(adler, sum2, buf, 0); + DO8(buf, 0); buf += 8; #endif } @@ -69,34 +80,22 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t l adler += *buf++; sum2 += adler; } - adler %= BASE; - sum2 %= BASE; + MOD(adler); + MOD(sum2); } /* return recombined sums */ return adler | (sum2 << 16); } -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(adler32_z)(unsigned long adler, const unsigned char *buf, size_t len) { - return (unsigned long)functable.adler32((uint32_t)adler, buf, len); -} -#else -uint32_t Z_EXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) { +uint32_t ZEXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) { return functable.adler32(adler, buf, len); } -#endif /* ========================================================================= */ -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(adler32)(unsigned long adler, const unsigned char *buf, unsigned int len) { - return (unsigned long)functable.adler32((uint32_t)adler, buf, len); -} -#else -uint32_t Z_EXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) { +uint32_t ZEXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) { return functable.adler32(adler, buf, len); } -#endif /* ========================================================================= */ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2) { @@ -109,11 +108,11 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len return 0xffffffff; /* the derivation of this formula is left as an exercise for the reader */ - len2 %= BASE; /* assumes len2 >= 0 */ + MOD63(len2); /* assumes len2 >= 0 */ rem = (unsigned)len2; sum1 = adler1 & 0xffff; sum2 = rem * sum1; - sum2 %= BASE; + MOD(sum2); sum1 += (adler2 & 0xffff) + BASE - 1; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 >= BASE) sum1 -= BASE; @@ -124,16 +123,10 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len } /* ========================================================================= */ -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off_t len2) { - return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2); -} - -unsigned long Z_EXPORT PREFIX4(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off64_t len2) { - return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2); -} -#else -uint32_t Z_EXPORT PREFIX4(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off64_t len2) { +uint32_t ZEXPORT PREFIX(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off_t len2) { + return adler32_combine_(adler1, adler2, len2); +} + +uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t adler1, uint32_t adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } -#endif diff --git a/libs/zlibng/adler32_p.h b/libs/zlibng/adler32_p.h index 7f75c71e2..676653040 100644 --- a/libs/zlibng/adler32_p.h +++ b/libs/zlibng/adler32_p.h @@ -12,11 +12,45 @@ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ -#define DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);} -#define DO2(sum1, sum2, buf, i) {DO1(sum1, sum2, buf, i); DO1(sum1, sum2, buf, i+1);} -#define DO4(sum1, sum2, buf, i) {DO2(sum1, sum2, buf, i); DO2(sum1, sum2, buf, i+2);} -#define DO8(sum1, sum2, buf, i) {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);} -#define DO16(sum1, sum2, buf) {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);} +/* use NO_DIVIDE if your processor does not do division in hardware -- + try it both ways to see which is faster */ +#ifdef NO_DIVIDE +/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 + (thank you to John Reiser for pointing this out) */ +# define CHOP(a) \ + do { \ + uint32_t tmp = a >> 16; \ + a &= 0xffff; \ + a += (tmp << 4) - tmp; \ + } while (0) +# define MOD28(a) \ + do { \ + CHOP(a); \ + if (a >= BASE) a -= BASE; \ + } while (0) +# define MOD(a) \ + do { \ + CHOP(a); \ + MOD28(a); \ + } while (0) +# define MOD63(a) \ + do { /* this assumes a is not negative */ \ + z_off64_t tmp = a >> 32; \ + a &= 0xffffffffL; \ + a += (tmp << 8) - (tmp << 5) + tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ + if (a >= BASE) a -= BASE; \ + } while (0) +#else +# define MOD(a) a %= BASE +# define MOD28(a) a %= BASE +# define MOD63(a) a %= BASE +#endif static inline uint32_t adler32_len_1(uint32_t adler, const unsigned char *buf, uint32_t sum2) { adler += buf[0]; @@ -36,18 +70,8 @@ static inline uint32_t adler32_len_16(uint32_t adler, const unsigned char *buf, } if (adler >= BASE) adler -= BASE; - sum2 %= BASE; /* only added so many BASE's */ + MOD28(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } -static inline uint32_t adler32_len_64(uint32_t adler, const unsigned char *buf, size_t len, uint32_t sum2) { - while (len >= 16) { - len -= 16; - DO16(adler, sum2, buf); - buf += 16; - } - /* Process tail (len < 16). */ - return adler32_len_16(adler, buf, len, sum2); -} - #endif /* ADLER32_P_H */ diff --git a/libs/zlibng/arch/arm/Makefile.in b/libs/zlibng/arch/arm/Makefile.in index a728d5ab2..a64d591e5 100644 --- a/libs/zlibng/arch/arm/Makefile.in +++ b/libs/zlibng/arch/arm/Makefile.in @@ -6,27 +6,19 @@ CC= CFLAGS= SFLAGS= INCLUDES= -ACLEFLAG= -NEONFLAG= SUFFIX= SRCDIR=. SRCTOP=../.. TOPDIR=$(SRCTOP) -all: \ - adler32_neon.o adler32_neon.lo \ - armfeature.o armfeature.lo \ - chunkset_neon.o chunkset_neon.lo \ - crc32_acle.o crc32_acle.lo \ - slide_neon.o slide_neon.lo \ - insert_string_acle.o insert_string_acle.lo +all: adler32_neon.o adler32_neon.lo armfeature.o armfeature.lo crc32_acle.o crc32_acle.lo fill_window_arm.o fill_window_arm.lo insert_string_acle.o insert_string_acle.lo adler32_neon.o: - $(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c adler32_neon.lo: - $(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c armfeature.o: $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c @@ -34,29 +26,23 @@ armfeature.o: armfeature.lo: $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c -chunkset_neon.o: - $(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c - -chunkset_neon.lo: - $(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c - crc32_acle.o: - $(CC) $(CFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c crc32_acle.lo: - $(CC) $(SFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c -slide_neon.o: - $(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_neon.c +fill_window_arm.o: + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/fill_window_arm.c -slide_neon.lo: - $(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_neon.c +fill_window_arm.lo: + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/fill_window_arm.c insert_string_acle.o: - $(CC) $(CFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c insert_string_acle.lo: - $(CC) $(SFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c mostlyclean: clean clean: diff --git a/libs/zlibng/arch/arm/adler32_neon.c b/libs/zlibng/arch/arm/adler32_neon.c index adda6f61d..3e0ee4dd8 100644 --- a/libs/zlibng/arch/arm/adler32_neon.c +++ b/libs/zlibng/arch/arm/adler32_neon.c @@ -2,16 +2,24 @@ * Copyright (C) 2017 ARM Holdings Inc. * Author: Adenilson Cavalcanti * - * For conditions of distribution and use, see copyright notice in zlib.h + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. */ -#ifdef ARM_NEON_ADLER32 -#ifdef _M_ARM64 -# include -#else -# include -#endif -#include "../../zutil.h" -#include "../../adler32_p.h" +#include "adler32_neon.h" +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +#include +#include "adler32_p.h" static void NEON_accum32(uint32_t *s, const unsigned char *buf, size_t len) { static const uint8_t taps[32] = { @@ -101,7 +109,7 @@ uint32_t adler32_neon(uint32_t adler, const unsigned char *buf, size_t len) { for (i = 0; i < len; i += n) { if ((i + n) > len) - n = (int)(len - i); + n = len - i; if (n < 16) break; diff --git a/libs/zlibng/arch/arm/adler32_neon.h b/libs/zlibng/arch/arm/adler32_neon.h new file mode 100644 index 000000000..1cb278c7c --- /dev/null +++ b/libs/zlibng/arch/arm/adler32_neon.h @@ -0,0 +1,29 @@ +/* Copyright (C) 1995-2011, 2016 Mark Adler + * Copyright (C) 2017 ARM Holdings Inc. + * Author: Adenilson Cavalcanti + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ +#ifndef __ADLER32_NEON__ +#define __ADLER32_NEON__ + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +// Depending on the compiler flavor, size_t may be defined in one or the other header. See: +// http://stackoverflow.com/questions/26410466/gcc-linaro-compiler-throws-error-unknown-type-name-size-t +#include +#include +uint32_t adler32_neon(uint32_t adler, const unsigned char *buf, size_t len); +#endif +#endif diff --git a/libs/zlibng/arch/arm/arm.h b/libs/zlibng/arch/arm/arm.h index 378006efb..baee87f18 100644 --- a/libs/zlibng/arch/arm/arm.h +++ b/libs/zlibng/arch/arm/arm.h @@ -8,6 +8,6 @@ extern int arm_cpu_has_neon; extern int arm_cpu_has_crc32; -void Z_INTERNAL arm_check_features(void); +void ZLIB_INTERNAL arm_check_features(void); #endif /* ARM_H_ */ diff --git a/libs/zlibng/arch/arm/armfeature.c b/libs/zlibng/arch/arm/armfeature.c index cf31a48f0..f7ccdc460 100644 --- a/libs/zlibng/arch/arm/armfeature.c +++ b/libs/zlibng/arch/arm/armfeature.c @@ -1,69 +1,50 @@ -#include "../../zutil.h" +#include "zutil.h" #if defined(__linux__) -# include -# include -#elif defined(__FreeBSD__) && defined(__aarch64__) -# include -# ifndef ID_AA64ISAR0_CRC32_VAL -# define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32 -# endif -#elif defined(__APPLE__) -# include +# include +# include #elif defined(_WIN32) -# include +# include #endif static int arm_has_crc32() { #if defined(__linux__) && defined(HWCAP2_CRC32) - return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0; -#elif defined(__FreeBSD__) && defined(__aarch64__) - return getenv("QEMU_EMULATING") == NULL - && ID_AA64ISAR0_CRC32_VAL(READ_SPECIALREG(id_aa64isar0_el1)) >= ID_AA64ISAR0_CRC32_BASE; -#elif defined(__APPLE__) - int hascrc32; - size_t size = sizeof(hascrc32); - return sysctlbyname("hw.optional.armv8_crc32", &hascrc32, &size, NULL, 0) == 0 - && hascrc32 == 1; + return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0; #elif defined(ARM_NOCHECK_ACLE) - return 1; + return 1; #else - return 0; + return 0; #endif } /* AArch64 has neon. */ -#if !defined(__aarch64__) && !defined(_M_ARM64) -static inline int arm_has_neon() { -#if defined(__linux__) && defined(HWCAP_NEON) +#if !defined(__aarch64__) +static inline int arm_has_neon() +{ + #if defined(__linux__) && defined(HWCAP_NEON) return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0 ? 1 : 0; -#elif defined(__APPLE__) - int hasneon; - size_t size = sizeof(hasneon); - return sysctlbyname("hw.optional.neon", &hasneon, &size, NULL, 0) == 0 - && hasneon == 1; -#elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION) -# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + #elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION) + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) return 1; /* Always supported */ -# endif -#endif + #endif + #endif -#if defined(ARM_NOCHECK_NEON) + #if defined(ARM_NOCHECK_NEON) return 1; -#else + #else return 0; -#endif + #endif } #endif -Z_INTERNAL int arm_cpu_has_neon; -Z_INTERNAL int arm_cpu_has_crc32; +ZLIB_INTERNAL int arm_cpu_has_neon; +ZLIB_INTERNAL int arm_cpu_has_crc32; -void Z_INTERNAL arm_check_features(void) { -#if defined(__aarch64__) || defined(_M_ARM64) - arm_cpu_has_neon = 1; /* always available */ +void ZLIB_INTERNAL arm_check_features(void) { +#if defined(__aarch64__) + arm_cpu_has_neon = 1; /* always available */ #else - arm_cpu_has_neon = arm_has_neon(); + arm_cpu_has_neon = arm_has_neon(); #endif - arm_cpu_has_crc32 = arm_has_crc32(); + arm_cpu_has_crc32 = arm_has_crc32(); } diff --git a/libs/zlibng/arch/arm/chunkset_neon.c b/libs/zlibng/arch/arm/chunkset_neon.c deleted file mode 100644 index e9cbcb1ba..000000000 --- a/libs/zlibng/arch/arm/chunkset_neon.c +++ /dev/null @@ -1,54 +0,0 @@ -/* chunkset_neon.c -- NEON inline functions to copy small data chunks. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifdef ARM_NEON_CHUNKSET -#ifdef _M_ARM64 -# include -#else -# include -#endif -#include "../../zbuild.h" -#include "../../zutil.h" - -typedef uint8x16_t chunk_t; - -#define HAVE_CHUNKMEMSET_1 -#define HAVE_CHUNKMEMSET_2 -#define HAVE_CHUNKMEMSET_4 -#define HAVE_CHUNKMEMSET_8 - -static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) { - *chunk = vld1q_dup_u8(from); -} - -static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) { - *chunk = vreinterpretq_u8_s16(vdupq_n_s16(*(int16_t *)from)); -} - -static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { - *chunk = vreinterpretq_u8_s32(vdupq_n_s32(*(int32_t *)from)); -} - -static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { - *chunk = vcombine_u8(vld1_u8(from), vld1_u8(from)); -} - -#define CHUNKSIZE chunksize_neon -#define CHUNKCOPY chunkcopy_neon -#define CHUNKCOPY_SAFE chunkcopy_safe_neon -#define CHUNKUNROLL chunkunroll_neon -#define CHUNKMEMSET chunkmemset_neon -#define CHUNKMEMSET_SAFE chunkmemset_safe_neon - -static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { - *chunk = vld1q_u8(s); -} - -static inline void storechunk(uint8_t *out, chunk_t *chunk) { - vst1q_u8(out, *chunk); -} - -#include "chunkset_tpl.h" - -#endif diff --git a/libs/zlibng/arch/arm/crc32_acle.c b/libs/zlibng/arch/arm/crc32_acle.c index 88ba6c38c..540603545 100644 --- a/libs/zlibng/arch/arm/crc32_acle.c +++ b/libs/zlibng/arch/arm/crc32_acle.c @@ -5,16 +5,21 @@ * */ -#ifdef ARM_ACLE_CRC_HASH -#ifndef _MSC_VER -# include -#endif -#include "../../zutil.h" +#ifdef __ARM_FEATURE_CRC32 +# include +# ifdef ZLIB_COMPAT +# include +# else +# include +# endif +# ifdef __linux__ +# include +# endif uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { - Z_REGISTER uint32_t c; - Z_REGISTER const uint16_t *buf2; - Z_REGISTER const uint32_t *buf4; + register uint32_t c; + register const uint16_t *buf2; + register const uint32_t *buf4; c = ~crc; if (len && ((ptrdiff_t)buf & 1)) { @@ -31,7 +36,7 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { buf4 = (const uint32_t *) buf; } -#if defined(__aarch64__) +# if defined(__aarch64__) if ((len > sizeof(uint32_t)) && ((ptrdiff_t)buf & sizeof(uint32_t))) { c = __crc32w(c, *buf4++); len -= sizeof(uint32_t); @@ -39,7 +44,7 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { const uint64_t *buf8 = (const uint64_t *) buf4; -#ifdef UNROLL_MORE +# ifdef UNROLL_MORE while (len >= 4 * sizeof(uint64_t)) { c = __crc32d(c, *buf8++); c = __crc32d(c, *buf8++); @@ -47,7 +52,7 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { c = __crc32d(c, *buf8++); len -= 4 * sizeof(uint64_t); } -#endif +# endif while (len >= sizeof(uint64_t)) { c = __crc32d(c, *buf8++); @@ -69,7 +74,7 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { } buf = (const unsigned char *) buf2; -#else /* __aarch64__ */ +# else /* __aarch64__ */ # ifdef UNROLL_MORE while (len >= 8 * sizeof(uint32_t)) { @@ -98,7 +103,7 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { } else { buf = (const unsigned char *) buf4; } -#endif /* __aarch64__ */ +# endif /* __aarch64__ */ if (len) { c = __crc32b(c, *buf); @@ -107,4 +112,4 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { c = ~c; return c; } -#endif +#endif /* __ARM_FEATURE_CRC32 */ diff --git a/libs/zlibng/arch/arm/ctzl.h b/libs/zlibng/arch/arm/ctzl.h index 77218deec..5ebbde456 100644 --- a/libs/zlibng/arch/arm/ctzl.h +++ b/libs/zlibng/arch/arm/ctzl.h @@ -5,7 +5,7 @@ #if defined(_MSC_VER) && !defined(__clang__) static __forceinline unsigned long __builtin_ctzl(unsigned long value) { - return _arm_clz(_arm_rbit(value)); + return _arm_clz(_arm_rbit(value)); } #endif diff --git a/libs/zlibng/arch/arm/fill_window_arm.c b/libs/zlibng/arch/arm/fill_window_arm.c new file mode 100644 index 000000000..c9f042a0d --- /dev/null +++ b/libs/zlibng/arch/arm/fill_window_arm.c @@ -0,0 +1,169 @@ +/* fill_window_arm.c -- Optimized hash table shifting for ARM with support for NEON instructions + * Copyright (C) 2017 Mika T. Lindqvist + * + * Authors: + * Mika T. Lindqvist + * Jun He + * + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zbuild.h" +#include "deflate.h" +#include "deflate_p.h" +#include "functable.h" + +extern ZLIB_INTERNAL int read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size); + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +#include + +/* SIMD version of hash_chain rebase */ +static inline void slide_hash_chain(Pos *table, unsigned int entries, uint16_t window_size) { + register uint16x8_t v, *p; + register size_t n; + + size_t size = entries*sizeof(table[0]); + Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err"); + + Assert(sizeof(Pos) == 2, "Wrong Pos size"); + v = vdupq_n_u16(window_size); + + p = (uint16x8_t *)table; + n = size / (sizeof(uint16x8_t) * 8); + do { + p[0] = vqsubq_u16(p[0], v); + p[1] = vqsubq_u16(p[1], v); + p[2] = vqsubq_u16(p[2], v); + p[3] = vqsubq_u16(p[3], v); + p[4] = vqsubq_u16(p[4], v); + p[5] = vqsubq_u16(p[5], v); + p[6] = vqsubq_u16(p[6], v); + p[7] = vqsubq_u16(p[7], v); + p += 8; + } while (--n); +} +#else +/* generic version for hash rebase */ +static inline void slide_hash_chain(Pos *table, unsigned int entries, uint16_t window_size) { + unsigned int i; + for (i = 0; i < entries; i++) { + table[i] = (table[i] >= window_size) ? (table[i] - window_size) : NIL; + } +} +#endif + +void fill_window_arm(deflate_state *s) { + register unsigned n; + unsigned long more; /* Amount of free space at the end of the window. */ + unsigned int wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = s->window_size - s->lookahead - s->strstart; + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + memcpy(s->window, s->window+wsize, wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + + slide_hash_chain(s->head, s->hash_size, wsize); + slide_hash_chain(s->prev, wsize, wsize); + more += wsize; + } + if (s->strm->avail_in == 0) + break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + unsigned int str = s->strstart - s->insert; + unsigned int insert_cnt = s->insert; + unsigned int slen; + + s->ins_h = s->window[str]; + + if (unlikely(s->lookahead < MIN_MATCH)) + insert_cnt += s->lookahead - MIN_MATCH; + slen = insert_cnt; + if (str >= (MIN_MATCH - 2)) + { + str += 2 - MIN_MATCH; + insert_cnt += MIN_MATCH - 2; + } + if (insert_cnt > 0) + { + functable.insert_string(s, str, insert_cnt); + s->insert -= slen; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + unsigned long curr = s->strstart + (unsigned long)s->lookahead; + unsigned long init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + memset(s->window + curr, 0, init); + s->high_water = curr + init; + } else if (s->high_water < curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = curr + WIN_INIT; + if (init > s->window_size) + init = s->window_size; + init -= s->high_water; + memset(s->window + s->high_water, 0, init); + s->high_water += init; + } + } + + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); +} diff --git a/libs/zlibng/arch/arm/insert_string_acle.c b/libs/zlibng/arch/arm/insert_string_acle.c index 2daf9ba3e..081b936ce 100644 --- a/libs/zlibng/arch/arm/insert_string_acle.c +++ b/libs/zlibng/arch/arm/insert_string_acle.c @@ -5,18 +5,49 @@ * */ -#ifdef ARM_ACLE_CRC_HASH -#ifndef _MSC_VER -# include -#endif -#include "../../zbuild.h" -#include "../../deflate.h" - -#define UPDATE_HASH(s, h, val) \ - h = __crc32w(0, val) - -#define INSERT_STRING insert_string_acle -#define QUICK_INSERT_STRING quick_insert_string_acle - -#include "../../insert_string_tpl.h" +#if defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH) +#include +#include "zbuild.h" +#include "deflate.h" + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count) { + Pos p, lp, ret; + + if (unlikely(count == 0)) { + return s->prev[str & s->w_mask]; + } + + ret = 0; + lp = str + count - 1; /* last position */ + + for (p = str; p <= lp; p++) { + uint32_t val, h, hm; + memcpy(&val, &s->window[p], sizeof(val)); + + if (s->level >= TRIGGER_LEVEL) + val &= 0xFFFFFF; + + h = __crc32w(0, val); + hm = h & s->hash_mask; + + Pos head = s->head[hm]; + if (head != p) { + s->prev[p & s->w_mask] = head; + s->head[hm] = p; + if (p == lp) + ret = head; + } else if (p == lp) { + ret = p; + } + } + return ret; +} #endif diff --git a/libs/zlibng/arch/arm/slide_neon.c b/libs/zlibng/arch/arm/slide_neon.c deleted file mode 100644 index f64fa5b5b..000000000 --- a/libs/zlibng/arch/arm/slide_neon.c +++ /dev/null @@ -1,52 +0,0 @@ -/* slide_neon.c -- Optimized hash table shifting for ARM with support for NEON instructions - * Copyright (C) 2017-2020 Mika T. Lindqvist - * - * Authors: - * Mika T. Lindqvist - * Jun He - * - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#if defined(ARM_NEON_SLIDEHASH) -#ifdef _M_ARM64 -# include -#else -# include -#endif -#include "../../zbuild.h" -#include "../../deflate.h" - -/* SIMD version of hash_chain rebase */ -static inline void slide_hash_chain(Pos *table, unsigned int entries, uint16_t window_size) { - Z_REGISTER uint16x8_t v, *p; - Z_REGISTER size_t n; - - size_t size = entries*sizeof(table[0]); - Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err"); - - Assert(sizeof(Pos) == 2, "Wrong Pos size"); - v = vdupq_n_u16(window_size); - - p = (uint16x8_t *)table; - n = size / (sizeof(uint16x8_t) * 8); - do { - p[0] = vqsubq_u16(p[0], v); - p[1] = vqsubq_u16(p[1], v); - p[2] = vqsubq_u16(p[2], v); - p[3] = vqsubq_u16(p[3], v); - p[4] = vqsubq_u16(p[4], v); - p[5] = vqsubq_u16(p[5], v); - p[6] = vqsubq_u16(p[6], v); - p[7] = vqsubq_u16(p[7], v); - p += 8; - } while (--n); -} - -Z_INTERNAL void slide_hash_neon(deflate_state *s) { - unsigned int wsize = s->w_size; - - slide_hash_chain(s->head, HASH_SIZE, wsize); - slide_hash_chain(s->prev, wsize, wsize); -} -#endif diff --git a/libs/zlibng/arch/power/Makefile.in b/libs/zlibng/arch/power/Makefile.in deleted file mode 100644 index 25ebc9d1d..000000000 --- a/libs/zlibng/arch/power/Makefile.in +++ /dev/null @@ -1,49 +0,0 @@ -# Makefile for POWER-specific files -# Copyright (C) 2020 Matheus Castanho , IBM -# For conditions of distribution and use, see copyright notice in zlib.h - -CC= -CFLAGS= -SFLAGS= -INCLUDES= -SUFFIX= - -SRCDIR=. -SRCTOP=../.. -TOPDIR=$(SRCTOP) - -P8FLAGS=-mcpu=power8 - -all: power.o \ - power.lo \ - adler32_power8.o \ - adler32_power8.lo \ - slide_hash_power8.o \ - slide_hash_power8.lo - -power.o: - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/power.c - -power.lo: - $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/power.c - -adler32_power8.o: - $(CC) $(CFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_power8.c - -adler32_power8.lo: - $(CC) $(SFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_power8.c - -slide_hash_power8.o: - $(CC) $(CFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_power8.c - -slide_hash_power8.lo: - $(CC) $(SFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_power8.c - -mostlyclean: clean -clean: - rm -f *.o *.lo *~ - rm -rf objs - rm -f *.gcda *.gcno *.gcov - -distclean: - rm -f Makefile diff --git a/libs/zlibng/arch/power/adler32_power8.c b/libs/zlibng/arch/power/adler32_power8.c deleted file mode 100644 index cda51aa80..000000000 --- a/libs/zlibng/arch/power/adler32_power8.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Adler32 for POWER8 using VSX instructions. - * Copyright (C) 2020 IBM Corporation - * Author: Rogerio Alves - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Calculate adler32 checksum for 16 bytes at once using POWER8+ VSX (vector) - * instructions. - * - * If adler32 do 1 byte at time on the first iteration s1 is s1_0 (_n means - * iteration n) is the initial value of adler - at start _0 is 1 unless - * adler initial value is different than 1. So s1_1 = s1_0 + c[0] after - * the first calculation. For the iteration s1_2 = s1_1 + c[1] and so on. - * Hence, for iteration N, s1_N = s1_(N-1) + c[N] is the value of s1 on - * after iteration N. - * - * Therefore, for s2 and iteration N, s2_N = s2_0 + N*s1_N + N*c[0] + - * N-1*c[1] + ... + c[N] - * - * In a more general way: - * - * s1_N = s1_0 + sum(i=1 to N)c[i] - * s2_N = s2_0 + N*s1 + sum (i=1 to N)(N-i+1)*c[i] - * - * Where s1_N, s2_N are the values for s1, s2 after N iterations. So if we - * can process N-bit at time we can do this at once. - * - * Since VSX can support 16-bit vector instructions, we can process - * 16-bit at time using N = 16 we have: - * - * s1 = s1_16 = s1_(16-1) + c[16] = s1_0 + sum(i=1 to 16)c[i] - * s2 = s2_16 = s2_0 + 16*s1 + sum(i=1 to 16)(16-i+1)*c[i] - * - * After the first iteration we calculate the adler32 checksum for 16 bytes. - * - * For more background about adler32 please check the RFC: - * https://www.ietf.org/rfc/rfc1950.txt - */ - -#ifdef POWER8_VSX_ADLER32 - -#include -#include "zbuild.h" -#include "zutil.h" -#include "adler32_p.h" - -/* Vector across sum unsigned int (saturate). */ -inline vector unsigned int vec_sumsu(vector unsigned int __a, vector unsigned int __b) { - __b = vec_sld(__a, __a, 8); - __b = vec_add(__b, __a); - __a = vec_sld(__b, __b, 4); - __a = vec_add(__a, __b); - - return __a; -} - -uint32_t adler32_power8(uint32_t adler, const unsigned char* buf, size_t len) { - uint32_t s1 = adler & 0xffff; - uint32_t s2 = (adler >> 16) & 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (UNLIKELY(len == 1)) - return adler32_len_1(s1, buf, s2); - - /* If buffer is empty or len=0 we need to return adler initial value. */ - if (UNLIKELY(buf == NULL)) - return 1; - - /* This is faster than VSX code for len < 64. */ - if (len < 64) - return adler32_len_64(s1, buf, len, s2); - - /* Use POWER VSX instructions for len >= 64. */ - const vector unsigned int v_zeros = { 0 }; - const vector unsigned char v_mul = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, - 6, 5, 4, 3, 2, 1}; - const vector unsigned char vsh = vec_splat_u8(4); - const vector unsigned int vmask = {0xffffffff, 0x0, 0x0, 0x0}; - vector unsigned int vs1 = { 0 }; - vector unsigned int vs2 = { 0 }; - vector unsigned int vs1_save = { 0 }; - vector unsigned int vsum1, vsum2; - vector unsigned char vbuf; - int n; - - vs1[0] = s1; - vs2[0] = s2; - - /* Do length bigger than NMAX in blocks of NMAX size. */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; - do { - vbuf = vec_xl(0, (unsigned char *) buf); - vsum1 = vec_sum4s(vbuf, v_zeros); /* sum(i=1 to 16) buf[i]. */ - /* sum(i=1 to 16) buf[i]*(16-i+1). */ - vsum2 = vec_msum(vbuf, v_mul, v_zeros); - /* Save vs1. */ - vs1_save = vec_add(vs1_save, vs1); - /* Accumulate the sums. */ - vs1 = vec_add(vsum1, vs1); - vs2 = vec_add(vsum2, vs2); - - buf += 16; - } while (--n); - /* Once each block of NMAX size. */ - vs1 = vec_sumsu(vs1, vsum1); - vs1_save = vec_sll(vs1_save, vsh); /* 16*vs1_save. */ - vs2 = vec_add(vs1_save, vs2); - vs2 = vec_sumsu(vs2, vsum2); - - /* vs1[0] = (s1_i + sum(i=1 to 16)buf[i]) mod 65521. */ - vs1[0] = vs1[0] % BASE; - /* vs2[0] = s2_i + 16*s1_save + - sum(i=1 to 16)(16-i+1)*buf[i] mod 65521. */ - vs2[0] = vs2[0] % BASE; - - vs1 = vec_and(vs1, vmask); - vs2 = vec_and(vs2, vmask); - vs1_save = v_zeros; - } - - /* len is less than NMAX one modulo is needed. */ - if (len >= 16) { - while (len >= 16) { - len -= 16; - - vbuf = vec_xl(0, (unsigned char *) buf); - - vsum1 = vec_sum4s(vbuf, v_zeros); /* sum(i=1 to 16) buf[i]. */ - /* sum(i=1 to 16) buf[i]*(16-i+1). */ - vsum2 = vec_msum(vbuf, v_mul, v_zeros); - /* Save vs1. */ - vs1_save = vec_add(vs1_save, vs1); - /* Accumulate the sums. */ - vs1 = vec_add(vsum1, vs1); - vs2 = vec_add(vsum2, vs2); - - buf += 16; - } - /* Since the size will be always less than NMAX we do this once. */ - vs1 = vec_sumsu(vs1, vsum1); - vs1_save = vec_sll(vs1_save, vsh); /* 16*vs1_save. */ - vs2 = vec_add(vs1_save, vs2); - vs2 = vec_sumsu(vs2, vsum2); - } - /* Copy result back to s1, s2 (mod 65521). */ - s1 = vs1[0] % BASE; - s2 = vs2[0] % BASE; - - /* Process tail (len < 16).and return */ - return adler32_len_16(s1, buf, len, s2); -} - -#endif /* POWER8_VSX_ADLER32 */ diff --git a/libs/zlibng/arch/power/power.c b/libs/zlibng/arch/power/power.c deleted file mode 100644 index f93b586d5..000000000 --- a/libs/zlibng/arch/power/power.c +++ /dev/null @@ -1,19 +0,0 @@ -/* POWER feature check - * Copyright (C) 2020 Matheus Castanho , IBM - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "../../zutil.h" - -Z_INTERNAL int power_cpu_has_arch_2_07; - -void Z_INTERNAL power_check_features(void) { - unsigned long hwcap2; - hwcap2 = getauxval(AT_HWCAP2); - -#ifdef POWER8 - if (hwcap2 & PPC_FEATURE2_ARCH_2_07) - power_cpu_has_arch_2_07 = 1; -#endif -} diff --git a/libs/zlibng/arch/power/power.h b/libs/zlibng/arch/power/power.h deleted file mode 100644 index b36c26141..000000000 --- a/libs/zlibng/arch/power/power.h +++ /dev/null @@ -1,13 +0,0 @@ -/* power.h -- check for POWER CPU features - * Copyright (C) 2020 Matheus Castanho , IBM - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifndef POWER_H_ -#define POWER_H_ - -extern int power_cpu_has_arch_2_07; - -void Z_INTERNAL power_check_features(void); - -#endif /* POWER_H_ */ diff --git a/libs/zlibng/arch/power/slide_hash_power8.c b/libs/zlibng/arch/power/slide_hash_power8.c deleted file mode 100644 index b1e30cea0..000000000 --- a/libs/zlibng/arch/power/slide_hash_power8.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Optimized slide_hash for POWER processors - * Copyright (C) 2019-2020 IBM Corporation - * Author: Matheus Castanho - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifdef POWER8_VSX_SLIDEHASH - -#include -#include "zbuild.h" -#include "deflate.h" - -static inline void slide_hash_power8_loop(deflate_state *s, unsigned n_elems, Pos *table_end) { - vector unsigned short vw, vm, *vp; - unsigned chunks; - - /* Each vector register (chunk) corresponds to 128 bits == 8 Posf, - * so instead of processing each of the n_elems in the hash table - * individually, we can do it in chunks of 8 with vector instructions. - * - * This function is only called from slide_hash_power8(), and both calls - * pass n_elems as a power of 2 higher than 2^7, as defined by - * deflateInit2_(), so n_elems will always be a multiple of 8. */ - chunks = n_elems >> 3; - Assert(n_elems % 8 == 0, "Weird hash table size!"); - - /* This type casting is safe since s->w_size is always <= 64KB - * as defined by deflateInit2_() and Posf == unsigned short */ - vw[0] = (Pos) s->w_size; - vw = vec_splat(vw,0); - - vp = (vector unsigned short *) table_end; - - do { - /* Processing 8 elements at a time */ - vp--; - vm = *vp; - - /* This is equivalent to: m >= w_size ? m - w_size : 0 - * Since we are using a saturated unsigned subtraction, any - * values that are > w_size will be set to 0, while the others - * will be subtracted by w_size. */ - *vp = vec_subs(vm,vw); - } while (--chunks); -} - -void Z_INTERNAL slide_hash_power8(deflate_state *s) { - unsigned int n; - Pos *p; - - n = HASH_SIZE; - p = &s->head[n]; - slide_hash_power8_loop(s,n,p); - - n = s->w_size; - p = &s->prev[n]; - slide_hash_power8_loop(s,n,p); -} - -#endif /* POWER8_VSX_SLIDEHASH */ diff --git a/libs/zlibng/arch/s390/README.md b/libs/zlibng/arch/s390/README.md index 641c63a83..6995b106e 100644 --- a/libs/zlibng/arch/s390/README.md +++ b/libs/zlibng/arch/s390/README.md @@ -1,7 +1,6 @@ -# Introduction - -This directory contains SystemZ deflate hardware acceleration support. -It can be enabled using the following build commands: +This directory contains IBM Z DEFLATE CONVERSION CALL support for +zlib-ng. In order to enable it, the following build commands should be +used: $ ./configure --with-dfltcc-deflate --with-dfltcc-inflate $ make @@ -11,206 +10,60 @@ or $ cmake -DWITH_DFLTCC_DEFLATE=1 -DWITH_DFLTCC_INFLATE=1 . $ make -When built like this, zlib-ng would compress using hardware on level 1, -and using software on all other levels. Decompression will always happen -in hardware. In order to enable hardware compression for levels 1-6 -(i.e. to make it used by default) one could add -`-DDFLTCC_LEVEL_MASK=0x7e` to CFLAGS when building zlib-ng. +When built like this, zlib-ng would compress in hardware on level 1, +and in software on all other levels. Decompression will always happen +in hardware. In order to enable DFLTCC compression for levels 1-6 (i.e. +to make it used by default) one could add -DDFLTCC_LEVEL_MASK=0x7e to +CFLAGS when building zlib-ng. -SystemZ deflate hardware acceleration is available on [IBM z15]( -https://www.ibm.com/products/z15) and newer machines under the name [ -"Integrated Accelerator for zEnterprise Data Compression"]( -https://www.ibm.com/support/z-content-solutions/compression/). The -programming interface to it is a machine instruction called DEFLATE -CONVERSION CALL (DFLTCC). It is documented in Chapter 26 of [Principles -of Operation](http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf). Both -the code and the rest of this document refer to this feature simply as -"DFLTCC". - -# Performance - -Performance figures are published [here]( -https://github.com/iii-i/zlib-ng/wiki/Performance-with-dfltcc-patch-applied-and-dfltcc-support-built-on-dfltcc-enabled-machine -). The compression speed-up can be as high as 110x and the decompression -speed-up can be as high as 15x. - -# Limitations - -Two DFLTCC compression calls with identical inputs are not guaranteed to -produce identical outputs. Therefore care should be taken when using -hardware compression when reproducible results are desired. In -particular, zlib-ng-specific `zng_deflateSetParams` call allows setting -`Z_DEFLATE_REPRODUCIBLE` parameter, which disables DFLTCC support for a -particular stream. +Two DFLTCC compression calls produce the same results only when they +both are made on machines of the same generation, and when the +respective buffers have the same offset relative to the start of the +page. Therefore care should be taken when using hardware compression +when reproducible results are desired. DFLTCC does not support every single zlib-ng feature, in particular: -* `inflate(Z_BLOCK)` and `inflate(Z_TREES)` -* `inflateMark()` -* `inflatePrime()` -* `inflateSyncPoint()` +* inflate(Z_BLOCK) and inflate(Z_TREES) +* inflateMark() +* inflatePrime() +* deflateParams() after the first deflate() call When used, these functions will either switch to software, or, in case this is not possible, gracefully fail. -# Code structure - -All SystemZ-specific code lives in `arch/s390` directory and is -integrated with the rest of zlib-ng using hook macros. - -## Hook macros +All SystemZ-specific code lives in a separate file and is integrated +with the rest of zlib-ng using hook macros, which are explained below. DFLTCC takes as arguments a parameter block, an input buffer, an output -buffer and a window. `ZALLOC_STATE()`, `ZFREE_STATE()`, `ZCOPY_STATE()`, -`ZALLOC_WINDOW()` and `TRY_FREE_WINDOW()` macros encapsulate allocation -details for the parameter block (which is allocated alongside zlib-ng -state) and the window (which must be page-aligned). +buffer and a window. ZALLOC_STATE, ZFREE_STATE, ZCOPY_STATE, +ZALLOC_WINDOW and TRY_FREE_WINDOW macros encapsulate allocation details +for the parameter block (which is allocated alongside zlib-ng state) +and the window (which must be page-aligned). -While inflate software and hardware window formats match, this is not -the case for deflate. Therefore, `deflateSetDictionary()` and -`deflateGetDictionary()` need special handling, which is triggered using -`DEFLATE_SET_DICTIONARY_HOOK()` and `DEFLATE_GET_DICTIONARY_HOOK()` -macros. +While for inflate software and hardware window formats match, this is +not the case for deflate. Therefore, deflateSetDictionary and +deflateGetDictionary need special handling, which is triggered using +the DEFLATE_SET_DICTIONARY_HOOK and DEFLATE_GET_DICTIONARY_HOOK macros. -`deflateResetKeep()` and `inflateResetKeep()` update the DFLTCC -parameter block using `DEFLATE_RESET_KEEP_HOOK()` and -`INFLATE_RESET_KEEP_HOOK()` macros. +deflateResetKeep() and inflateResetKeep() update the DFLTCC parameter +block using DEFLATE_RESET_KEEP_HOOK and INFLATE_RESET_KEEP_HOOK macros. -`INFLATE_PRIME_HOOK()`, `INFLATE_MARK_HOOK()` and -`INFLATE_SYNC_POINT_HOOK()` macros make the respective unsupported -calls gracefully fail. - -`DEFLATE_PARAMS_HOOK()` implements switching between hardware and -software compression mid-stream using `deflateParams()`. Switching -normally entails flushing the current block, which might not be possible -in low memory situations. `deflateParams()` uses `DEFLATE_DONE()` hook -in order to detect and gracefully handle such situations. +DEFLATE_PARAMS_HOOK, INFLATE_PRIME_HOOK and INFLATE_MARK_HOOK macros +make the unsupported deflateParams(), inflatePrime() and inflateMark() +calls fail gracefully. The algorithm implemented in hardware has different compression ratio -than the one implemented in software. `DEFLATE_BOUND_ADJUST_COMPLEN()` -and `DEFLATE_NEED_CONSERVATIVE_BOUND()` macros make `deflateBound()` -return the correct results for the hardware implementation. +than the one implemented in software. DEFLATE_BOUND_ADJUST_COMPLEN and +DEFLATE_NEED_CONSERVATIVE_BOUND macros make deflateBound() return the +correct results for the hardware implementation. -Actual compression and decompression are handled by `DEFLATE_HOOK()` and -`INFLATE_TYPEDO_HOOK()` macros. Since inflation with DFLTCC manages the -window on its own, calling `updatewindow()` is suppressed using -`INFLATE_NEED_UPDATEWINDOW()` macro. +Actual compression and decompression are handled by DEFLATE_HOOK and +INFLATE_TYPEDO_HOOK macros. Since inflation with DFLTCC manages the +window on its own, calling updatewindow() is suppressed using +INFLATE_NEED_UPDATEWINDOW() macro. In addition to compression, DFLTCC computes CRC-32 and Adler-32 checksums, therefore, whenever it's used, software checksumming is -suppressed using `DEFLATE_NEED_CHECKSUM()` and `INFLATE_NEED_CHECKSUM()` +suppressed using DEFLATE_NEED_CHECKSUM and INFLATE_NEED_CHECKSUM macros. - -While software always produces reproducible compression results, this -is not the case for DFLTCC. Therefore, zlib-ng users are given the -ability to specify whether or not reproducible compression results -are required. While it is always possible to specify this setting -before the compression begins, it is not always possible to do so in -the middle of a deflate stream - the exact conditions for that are -determined by `DEFLATE_CAN_SET_REPRODUCIBLE()` macro. - -## SystemZ-specific code - -When zlib-ng is built with DFLTCC, the hooks described above are -converted to calls to functions, which are implemented in -`arch/s390/dfltcc_*` files. The functions can be grouped in three broad -categories: - -* Base DFLTCC support, e.g. wrapping the machine instruction - - `dfltcc()` and allocating aligned memory - `dfltcc_alloc_state()`. -* Translating between software and hardware data formats, e.g. - `dfltcc_deflate_set_dictionary()`. -* Translating between software and hardware state machines, e.g. - `dfltcc_deflate()` and `dfltcc_inflate()`. - -The functions from the first two categories are fairly simple, however, -various quirks in both software and hardware state machines make the -functions from the third category quite complicated. - -### `dfltcc_deflate()` function - -This function is called by `deflate()` and has the following -responsibilities: - -* Checking whether DFLTCC can be used with the current stream. If this - is not the case, then it returns `0`, making `deflate()` use some - other function in order to compress in software. Otherwise it returns - `1`. -* Block management and Huffman table generation. DFLTCC ends blocks only - when explicitly instructed to do so by the software. Furthermore, - whether to use fixed or dynamic Huffman tables must also be determined - by the software. Since looking at data in order to gather statistics - would negate performance benefits, the following approach is used: the - first `DFLTCC_FIRST_FHT_BLOCK_SIZE` bytes are placed into a fixed - block, and every next `DFLTCC_BLOCK_SIZE` bytes are placed into - dynamic blocks. -* Writing EOBS. Block Closing Control bit in the parameter block - instructs DFLTCC to write EOBS, however, certain conditions need to be - met: input data length must be non-zero or Continuation Flag must be - set. To put this in simpler terms, DFLTCC will silently refuse to - write EOBS if this is the only thing that it is asked to do. Since the - code has to be able to emit EOBS in software anyway, in order to avoid - tricky corner cases Block Closing Control is never used. Whether to - write EOBS is instead controlled by `soft_bcc` variable. -* Triggering block post-processing. Depending on flush mode, `deflate()` - must perform various additional actions when a block or a stream ends. - `dfltcc_deflate()` informs `deflate()` about this using - `block_state *result` parameter. -* Converting software state fields into hardware parameter block fields, - and vice versa. For example, `wrap` and Check Value Type or `bi_valid` - and Sub-Byte Boundary. Certain fields cannot be translated and must - persist untouched in the parameter block between calls, for example, - Continuation Flag or Continuation State Buffer. -* Handling flush modes and low-memory situations. These aspects are - quite intertwined and pervasive. The general idea here is that the - code must not do anything in software - whether explicitly by e.g. - calling `send_eobs()`, or implicitly - by returning to `deflate()` - with certain return and `*result` values, when Continuation Flag is - set. -* Ending streams. When a new block is started and flush mode is - `Z_FINISH`, Block Header Final parameter block bit is used to mark - this block as final. However, sometimes an empty final block is - needed, and, unfortunately, just like with EOBS, DFLTCC will silently - refuse to do this. The general idea of DFLTCC implementation is to - rely as much as possible on the existing code. Here in order to do - this, the code pretends that it does not support DFLTCC, which makes - `deflate()` call a software compression function, which writes an - empty final block. Whether this is required is controlled by - `need_empty_block` variable. -* Error handling. This is simply converting - Operation-Ending-Supplemental Code to string. Errors can only happen - due to things like memory corruption, and therefore they don't affect - the `deflate()` return code. - -### `dfltcc_inflate()` function - -This function is called by `inflate()` from the `TYPEDO` state (that is, -when all the metadata is parsed and the stream is positioned at the type -bits of deflate block header) and it's responsible for the following: - -* Falling back to software when flush mode is `Z_BLOCK` or `Z_TREES`. - Unfortunately, there is no way to ask DFLTCC to stop decompressing on - block or tree boundary. -* `inflate()` decompression loop management. This is controlled using - the return value, which can be either `DFLTCC_INFLATE_BREAK` or - `DFLTCC_INFLATE_CONTINUE`. -* Converting software state fields into hardware parameter block fields, - and vice versa. For example, `whave` and History Length or `wnext` and - History Offset. -* Ending streams. This instructs `inflate()` to return `Z_STREAM_END` - and is controlled by `last` state field. -* Error handling. Like deflate, error handling comprises - Operation-Ending-Supplemental Code to string conversion. Unlike - deflate, errors may happen due to bad inputs, therefore they are - propagated to `inflate()` by setting `mode` field to `MEM` or `BAD`. - -# Testing - -Given complexity of DFLTCC machine instruction, it is not clear whether -QEMU TCG will ever support it. At the time of writing, one has to have -access to an IBM z15+ VM or LPAR in order to test DFLTCC support. Since -DFLTCC is a non-privileged instruction, neither special VM/LPAR -configuration nor root are required. - -Still, zlib-ng CI has a few QEMU TCG-based configurations that check -whether fallback to software is working. diff --git a/libs/zlibng/arch/s390/dfltcc_common.c b/libs/zlibng/arch/s390/dfltcc_common.c index c82c3b220..2f2e22fd0 100644 --- a/libs/zlibng/arch/s390/dfltcc_common.c +++ b/libs/zlibng/arch/s390/dfltcc_common.c @@ -1,6 +1,6 @@ /* dfltcc_deflate.c - IBM Z DEFLATE CONVERSION CALL general support. */ -#include "../../zbuild.h" +#include "zbuild.h" #include "dfltcc_common.h" #include "dfltcc_detail.h" @@ -12,31 +12,20 @@ `posix_memalign' is not an option. Thus, we overallocate and take the aligned portion of the buffer. */ -static inline int is_dfltcc_enabled(void) { +static inline int is_dfltcc_enabled(void) +{ uint64_t facilities[(DFLTCC_FACILITY / 64) + 1]; - Z_REGISTER uint8_t r0 __asm__("r0"); + register uint8_t r0 __asm__("r0"); memset(facilities, 0, sizeof(facilities)); r0 = sizeof(facilities) / sizeof(facilities[0]) - 1; - /* STFLE is supported since z9-109 and only in z/Architecture mode. When - * compiling with -m31, gcc defaults to ESA mode, however, since the kernel - * is 64-bit, it's always z/Architecture mode at runtime. - */ - __asm__ volatile( -#ifndef __clang__ - ".machinemode push\n" - ".machinemode zarch\n" -#endif - "stfle %[facilities]\n" -#ifndef __clang__ - ".machinemode pop\n" -#endif - : [facilities] "=Q" (facilities), [r0] "+r" (r0) :: "cc"); + __asm__ volatile("stfle %[facilities]\n" : [facilities] "=Q" (facilities), [r0] "+r" (r0) :: "cc"); return is_bit_set((const char *)facilities, DFLTCC_FACILITY); } -void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) { - struct dfltcc_state *dfltcc_state = (struct dfltcc_state *)((char *)strm->state + ALIGN_UP(size, 8)); +void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) +{ + struct dfltcc_state *dfltcc_state = (struct dfltcc_state *)((char *)strm->state + size); struct dfltcc_qaf_param *param = (struct dfltcc_qaf_param *)&dfltcc_state->param; /* Initialize available functions */ @@ -58,17 +47,24 @@ void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) { dfltcc_state->param.ribm = DFLTCC_RIBM; } -void Z_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size) { - return ZALLOC(strm, ALIGN_UP(items * size, 8) + sizeof(struct dfltcc_state), sizeof(unsigned char)); +void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size) +{ + Assert((items * size) % 8 == 0, + "The size of zlib-ng state must be a multiple of 8"); + return ZALLOC(strm, items * size + sizeof(struct dfltcc_state), sizeof(unsigned char)); } -void Z_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size) { - memcpy(dst, src, ALIGN_UP(size, 8) + sizeof(struct dfltcc_state)); +void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size) +{ + memcpy(dst, src, size + sizeof(struct dfltcc_state)); } static const int PAGE_ALIGN = 0x1000; -void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size) { +#define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) + +void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size) +{ void *p; void *w; @@ -83,7 +79,8 @@ void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt siz return w; } -void Z_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w) { +void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w) +{ if (w) ZFREE(strm, *(void **)((unsigned char *)w - sizeof(void *))); } diff --git a/libs/zlibng/arch/s390/dfltcc_common.h b/libs/zlibng/arch/s390/dfltcc_common.h index 5c3be91b9..e206e0431 100644 --- a/libs/zlibng/arch/s390/dfltcc_common.h +++ b/libs/zlibng/arch/s390/dfltcc_common.h @@ -2,17 +2,17 @@ #define DFLTCC_COMMON_H #ifdef ZLIB_COMPAT -#include "../../zlib.h" +#include "zlib.h" #else -#include "../../zlib-ng.h" +#include "zlib-ng.h" #endif -#include "../../zutil.h" +#include "zutil.h" -void Z_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size); -void Z_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size); -void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size); -void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size); -void Z_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w); +void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size); +void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size); +void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size); +void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size); +void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w); #define ZALLOC_STATE dfltcc_alloc_state diff --git a/libs/zlibng/arch/s390/dfltcc_deflate.c b/libs/zlibng/arch/s390/dfltcc_deflate.c index 187865667..adab3e000 100644 --- a/libs/zlibng/arch/s390/dfltcc_deflate.c +++ b/libs/zlibng/arch/s390/dfltcc_deflate.c @@ -13,26 +13,27 @@ $ make */ -#include "../../zbuild.h" -#include "../../zutil.h" -#include "../../deflate.h" -#include "../../trees_emit.h" +#include "zbuild.h" +#include "zutil.h" +#include "deflate.h" #include "dfltcc_deflate.h" #include "dfltcc_detail.h" -static inline int dfltcc_can_deflate_with_params(PREFIX3(streamp) strm, int level, uInt window_bits, int strategy, - int reproducible) { +static inline int dfltcc_are_params_ok(int level, uInt window_bits, int strategy, uint16_t level_mask) +{ + return (level_mask & ((uint16_t)1 << level)) != 0 && + (window_bits == HB_BITS) && + (strategy == Z_FIXED || strategy == Z_DEFAULT_STRATEGY); +} + + +int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); /* Unsupported compression settings */ - if ((dfltcc_state->level_mask & (1 << level)) == 0) - return 0; - if (window_bits != HB_BITS) - return 0; - if (strategy != Z_FIXED && strategy != Z_DEFAULT_STRATEGY) - return 0; - if (reproducible) + if (!dfltcc_are_params_ok(state->level, state->w_bits, state->strategy, dfltcc_state->level_mask)) return 0; /* Unsupported hardware */ @@ -44,13 +45,8 @@ static inline int dfltcc_can_deflate_with_params(PREFIX3(streamp) strm, int leve return 1; } -int Z_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm) { - deflate_state *state = (deflate_state *)strm->state; - - return dfltcc_can_deflate_with_params(strm, state->level, state->w_bits, state->strategy, state->reproducible); -} - -static inline void dfltcc_gdht(PREFIX3(streamp) strm) { +static inline void dfltcc_gdht(PREFIX3(streamp) strm) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param; size_t avail_in = strm->avail_in; @@ -58,7 +54,8 @@ static inline void dfltcc_gdht(PREFIX3(streamp) strm) { dfltcc(DFLTCC_GDHT, param, NULL, NULL, &strm->next_in, &avail_in, NULL); } -static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) { +static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param; size_t avail_in = strm->avail_in; @@ -75,10 +72,11 @@ static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) { return cc; } -static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param) { +static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param) +{ deflate_state *state = (deflate_state *)strm->state; - send_bits(state, bi_reverse(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid); + send_bits(state, bi_reverse(param->eobs >> (15 - param->eobl), param->eobl), param->eobl); flush_pending(strm); if (state->pending != 0) { /* The remaining data is located in pending_out[0:pending]. If someone @@ -95,7 +93,8 @@ static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 #endif } -int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result) { +int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); struct dfltcc_param_v0 *param = &dfltcc_state->param; @@ -105,38 +104,31 @@ int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *res int soft_bcc; int no_flush; - if (!dfltcc_can_deflate(strm)) { - /* Clear history. */ - if (flush == Z_FULL_FLUSH) - param->hl = 0; + if (!dfltcc_can_deflate(strm)) return 0; - } again: masked_avail_in = 0; soft_bcc = 0; no_flush = flush == Z_NO_FLUSH; - /* No input data. Return, except when Continuation Flag is set, which means - * that DFLTCC has buffered some output in the parameter block and needs to - * be called again in order to flush it. + /* Trailing empty block. Switch to software, except when Continuation Flag + * is set, which means that DFLTCC has buffered some output in the + * parameter block and needs to be called again in order to flush it. */ - if (strm->avail_in == 0 && !param->cf) { - /* A block is still open, and the hardware does not support closing - * blocks without adding data. Thus, close it manually. - */ - if (!no_flush && param->bcf) { + if (flush == Z_FINISH && strm->avail_in == 0 && !param->cf) { + if (param->bcf) { + /* A block is still open, and the hardware does not support closing + * blocks without adding data. Thus, close it manually. + */ send_eobs(strm, param); param->bcf = 0; } - /* Let one of deflate_* functions write a trailing empty block. */ - if (flush == Z_FINISH) - return 0; - /* Clear history. */ - if (flush == Z_FULL_FLUSH) - param->hl = 0; - /* Trigger block post-processing if necessary. */ - *result = no_flush ? need_more : block_done; + return 0; + } + + if (strm->avail_in == 0 && !param->cf) { + *result = need_more; return 1; } @@ -162,18 +154,13 @@ again: send_eobs(strm, param); param->bcf = 0; dfltcc_state->block_threshold = strm->total_in + dfltcc_state->block_size; + if (strm->avail_out == 0) { + *result = need_more; + return 1; + } } } - /* No space for compressed data. If we proceed, dfltcc_cmpr() will return - * DFLTCC_CC_OP1_TOO_SHORT without buffering header bits, but we will still - * set BCF=1, which is wrong. Avoid complications and return early. - */ - if (strm->avail_out == 0) { - *result = need_more; - return 1; - } - /* The caller gave us too much data. Pass only one block worth of * uncompressed data to DFLTCC and mask the rest, so that on the next * iteration we start a new block. @@ -193,7 +180,7 @@ again: param->cvt = state->wrap == 2 ? CVT_CRC32 : CVT_ADLER32; if (!no_flush) /* We need to close a block. Always do this in software - when there is - * no input data, the hardware will not honor BCC. */ + * no input data, the hardware will not nohor BCC. */ soft_bcc = 1; if (flush == Z_FINISH && !param->bcf) /* We are about to open a BFINAL block, set Block Header Final bit @@ -208,8 +195,8 @@ again: param->sbb = (unsigned int)state->bi_valid; if (param->sbb > 0) *strm->next_out = (unsigned char)state->bi_buf; - /* Honor history and check value */ - param->nt = 0; + if (param->hl) + param->nt = 0; /* Honor history */ param->cv = state->wrap == 2 ? ZSWAP32(strm->adler) : strm->adler; /* When opening a block, choose a Huffman-Table Type */ @@ -290,60 +277,31 @@ again: fly with deflateParams, we need to convert between hardware and software window formats. */ -static int dfltcc_was_deflate_used(PREFIX3(streamp) strm) { - deflate_state *state = (deflate_state *)strm->state; - struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param; - - return strm->total_in > 0 || param->nt == 0 || param->hl > 0; -} - -int Z_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy, int *flush) { +int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy) +{ deflate_state *state = (deflate_state *)strm->state; + struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); + struct dfltcc_param_v0 *param = &dfltcc_state->param; int could_deflate = dfltcc_can_deflate(strm); - int can_deflate = dfltcc_can_deflate_with_params(strm, level, state->w_bits, strategy, state->reproducible); + int can_deflate = dfltcc_are_params_ok(level, state->w_bits, strategy, dfltcc_state->level_mask); if (can_deflate == could_deflate) /* We continue to work in the same mode - no changes needed */ return Z_OK; - if (!dfltcc_was_deflate_used(strm)) + if (strm->total_in == 0 && param->nt == 1 && param->hl == 0) /* DFLTCC was not used yet - no changes needed */ return Z_OK; - /* For now, do not convert between window formats - simply get rid of the old data instead */ - *flush = Z_FULL_FLUSH; - return Z_OK; -} - -int Z_INTERNAL dfltcc_deflate_done(PREFIX3(streamp) strm, int flush) { - deflate_state *state = (deflate_state *)strm->state; - struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); - struct dfltcc_param_v0 *param = &dfltcc_state->param; - - /* When deflate(Z_FULL_FLUSH) is called with small avail_out, it might - * close the block without resetting the compression state. Detect this - * situation and return that deflation is not done. - */ - if (flush == Z_FULL_FLUSH && strm->avail_out == 0) - return 0; - - /* Return that deflation is not done if DFLTCC is used and either it - * buffered some data (Continuation Flag is set), or has not written EOBS - * yet (Block-Continuation Flag is set). - */ - return !dfltcc_can_deflate(strm) || (!param->cf && !param->bcf); -} - -int Z_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible) { - deflate_state *state = (deflate_state *)strm->state; - - return reproducible != state->reproducible && !dfltcc_was_deflate_used(strm); + /* Switching between hardware and software is not implemented */ + return Z_STREAM_ERROR; } /* Preloading history. */ -static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count) { +static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count) +{ size_t offset; size_t n; @@ -373,19 +331,20 @@ static void append_history(struct dfltcc_param_v0 *param, unsigned char *history } } -int Z_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm, - const unsigned char *dictionary, uInt dict_length) { +int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm, + const unsigned char *dictionary, uInt dict_length) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); struct dfltcc_param_v0 *param = &dfltcc_state->param; append_history(param, state->window, dictionary, dict_length); state->strstart = 1; /* Add FDICT to zlib header */ - state->block_start = state->strstart; /* Make deflate_stored happy */ return Z_OK; } -int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) { +int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) +{ deflate_state *state = (deflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); struct dfltcc_param_v0 *param = &dfltcc_state->param; diff --git a/libs/zlibng/arch/s390/dfltcc_deflate.h b/libs/zlibng/arch/s390/dfltcc_deflate.h index 7e32380bd..93945f0a0 100644 --- a/libs/zlibng/arch/s390/dfltcc_deflate.h +++ b/libs/zlibng/arch/s390/dfltcc_deflate.h @@ -3,14 +3,12 @@ #include "dfltcc_common.h" -int Z_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm); -int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result); -int Z_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy, int *flush); -int Z_INTERNAL dfltcc_deflate_done(PREFIX3(streamp) strm, int flush); -int Z_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible); -int Z_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm, +int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm); +int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result); +int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy); +int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm, const unsigned char *dictionary, uInt dict_length); -int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt* dict_length); +int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt* dict_length); #define DEFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) \ do { \ @@ -27,17 +25,15 @@ int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned cha #define DEFLATE_RESET_KEEP_HOOK(strm) \ dfltcc_reset((strm), sizeof(deflate_state)) -#define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) \ +#define DEFLATE_PARAMS_HOOK(strm, level, strategy) \ do { \ int err; \ \ - err = dfltcc_deflate_params((strm), (level), (strategy), (hook_flush)); \ + err = dfltcc_deflate_params((strm), (level), (strategy)); \ if (err == Z_STREAM_ERROR) \ return err; \ } while (0) -#define DEFLATE_DONE dfltcc_deflate_done - #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \ do { \ if (dfltcc_can_deflate((strm))) \ @@ -51,6 +47,4 @@ int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned cha #define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm))) -#define DEFLATE_CAN_SET_REPRODUCIBLE dfltcc_can_set_reproducible - #endif diff --git a/libs/zlibng/arch/s390/dfltcc_detail.h b/libs/zlibng/arch/s390/dfltcc_detail.h index 4ec03f809..156b2a289 100644 --- a/libs/zlibng/arch/s390/dfltcc_detail.h +++ b/libs/zlibng/arch/s390/dfltcc_detail.h @@ -46,17 +46,18 @@ typedef enum { #define DFLTCC_FACILITY 151 static inline dfltcc_cc dfltcc(int fn, void *param, - unsigned char **op1, size_t *len1, z_const unsigned char **op2, size_t *len2, void *hist) { + unsigned char **op1, size_t *len1, const unsigned char **op2, size_t *len2, void *hist) +{ unsigned char *t2 = op1 ? *op1 : NULL; size_t t3 = len1 ? *len1 : 0; - z_const unsigned char *t4 = op2 ? *op2 : NULL; + const unsigned char *t4 = op2 ? *op2 : NULL; size_t t5 = len2 ? *len2 : 0; - Z_REGISTER int r0 __asm__("r0") = fn; - Z_REGISTER void *r1 __asm__("r1") = param; - Z_REGISTER unsigned char *r2 __asm__("r2") = t2; - Z_REGISTER size_t r3 __asm__("r3") = t3; - Z_REGISTER z_const unsigned char *r4 __asm__("r4") = t4; - Z_REGISTER size_t r5 __asm__("r5") = t5; + register int r0 __asm__("r0") = fn; + register void *r1 __asm__("r1") = param; + register unsigned char *r2 __asm__("r2") = t2; + register size_t r3 __asm__("r3") = t3; + register const unsigned char *r4 __asm__("r4") = t4; + register size_t r5 __asm__("r5") = t5; int cc; __asm__ volatile( @@ -107,11 +108,13 @@ struct dfltcc_qaf_param { static_assert(sizeof(struct dfltcc_qaf_param) == 32, sizeof_struct_dfltcc_qaf_param_is_32); -static inline int is_bit_set(const char *bits, int n) { +static inline int is_bit_set(const char *bits, int n) +{ return bits[n / 8] & (1 << (7 - (n % 8))); } -static inline void clear_bit(char *bits, int n) { +static inline void clear_bit(char *bits, int n) +{ bits[n / 8] &= ~(1 << (7 - (n % 8))); } @@ -172,7 +175,8 @@ struct dfltcc_param_v0 { static_assert(sizeof(struct dfltcc_param_v0) == 1536, sizeof_struct_dfltcc_param_v0_is_1536); -static inline z_const char *oesc_msg(char *buf, int oesc) { +static inline const char *oesc_msg(char *buf, int oesc) +{ if (oesc == 0x00) return NULL; /* Successful completion */ else { @@ -194,6 +198,4 @@ struct dfltcc_state { char msg[64]; /* Buffer for strm->msg */ }; -#define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) - -#define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((char *)(state) + ALIGN_UP(sizeof(*state), 8))) +#define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((state) + 1)) diff --git a/libs/zlibng/arch/s390/dfltcc_inflate.c b/libs/zlibng/arch/s390/dfltcc_inflate.c index f6a7e8f86..cec25f41f 100644 --- a/libs/zlibng/arch/s390/dfltcc_inflate.c +++ b/libs/zlibng/arch/s390/dfltcc_inflate.c @@ -13,14 +13,15 @@ $ make */ -#include "../../zbuild.h" -#include "../../zutil.h" -#include "../../inftrees.h" -#include "../../inflate.h" +#include "zbuild.h" +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" #include "dfltcc_inflate.h" #include "dfltcc_detail.h" -int Z_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) { +int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) +{ struct inflate_state *state = (struct inflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); @@ -32,7 +33,8 @@ int Z_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) { return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) && is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0); } -static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) { +static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) +{ struct inflate_state *state = (struct inflate_state *)strm->state; struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param; size_t avail_in = strm->avail_in; @@ -47,7 +49,8 @@ static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) { return cc; } -dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret) { +dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret) +{ struct inflate_state *state = (struct inflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); struct dfltcc_param_v0 *param = &dfltcc_state->param; @@ -112,14 +115,16 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_CONTINUE; } -int Z_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm) { +int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm) +{ struct inflate_state *state = (struct inflate_state *)strm->state; struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param; return !param->nt; } -int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm) { +int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm) +{ struct inflate_state *state = (struct inflate_state *)strm->state; struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); diff --git a/libs/zlibng/arch/s390/dfltcc_inflate.h b/libs/zlibng/arch/s390/dfltcc_inflate.h index fc8a000f7..aea2bbb73 100644 --- a/libs/zlibng/arch/s390/dfltcc_inflate.h +++ b/libs/zlibng/arch/s390/dfltcc_inflate.h @@ -3,15 +3,15 @@ #include "dfltcc_common.h" -int Z_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm); +int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm); typedef enum { DFLTCC_INFLATE_CONTINUE, DFLTCC_INFLATE_BREAK, DFLTCC_INFLATE_SOFTWARE, } dfltcc_inflate_action; -dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret); -int Z_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm); -int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm); +dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret); +int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm); +int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm); #define INFLATE_RESET_KEEP_HOOK(strm) \ dfltcc_reset((strm), sizeof(struct inflate_state)) @@ -41,9 +41,4 @@ int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm); if (dfltcc_was_inflate_used((strm))) return -(1L << 16); \ } while (0) -#define INFLATE_SYNC_POINT_HOOK(strm) \ - do { \ - if (dfltcc_was_inflate_used((strm))) return Z_STREAM_ERROR; \ - } while (0) - #endif diff --git a/libs/zlibng/arch/x86/INDEX b/libs/zlibng/arch/x86/INDEX new file mode 100644 index 000000000..9ee3802a2 --- /dev/null +++ b/libs/zlibng/arch/x86/INDEX @@ -0,0 +1,3 @@ +fill_window_sse.c SSE2 optimized fill_window +deflate_quick.c SSE4 optimized deflate strategy for use as level 1 +crc_folding.c SSE4 + PCLMULQDQ optimized CRC folding implementation diff --git a/libs/zlibng/arch/x86/INDEX.md b/libs/zlibng/arch/x86/INDEX.md deleted file mode 100644 index 8bf6d08e5..000000000 --- a/libs/zlibng/arch/x86/INDEX.md +++ /dev/null @@ -1,8 +0,0 @@ -Contents --------- - -|Name|Description| -|:-|:-| -|deflate_quick.c|SSE4 optimized deflate strategy for use as level 1| -|crc_folding.c|SSE4 + PCLMULQDQ optimized CRC folding implementation| -|slide_sse2.c|SSE2 optimized slide_hash| diff --git a/libs/zlibng/arch/x86/Makefile.in b/libs/zlibng/arch/x86/Makefile.in index 4f6594e6d..2e473c626 100644 --- a/libs/zlibng/arch/x86/Makefile.in +++ b/libs/zlibng/arch/x86/Makefile.in @@ -8,9 +8,7 @@ SFLAGS= INCLUDES= SUFFIX= -AVX2FLAG=-mavx2 SSE2FLAG=-msse2 -SSSE3FLAG=-mssse3 SSE4FLAG=-msse4 PCLMULFLAG=-mpclmul @@ -18,18 +16,7 @@ SRCDIR=. SRCTOP=../.. TOPDIR=$(SRCTOP) -all: \ - x86.o x86.lo \ - adler32_avx.o adler32.lo \ - adler32_ssse3.o adler32_ssse3.lo \ - chunkset_avx.o chunkset_avx.lo \ - chunkset_sse.o chunkset_sse.lo \ - compare258_avx.o compare258_avx.lo \ - compare258_sse.o compare258_sse.lo \ - insert_string_sse.o insert_string_sse.lo \ - crc_folding.o crc_folding.lo \ - slide_avx.o slide_avx.lo \ - slide_sse.o slide_sse.lo +all: x86.o x86.lo fill_window_sse.o fill_window_sse.lo deflate_quick.o deflate_quick.lo insert_string_sse.o insert_string_sse.lo crc_folding.o crc_folding.lo x86.o: $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/x86.c @@ -37,29 +24,17 @@ x86.o: x86.lo: $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/x86.c -chunkset_avx.o: - $(CC) $(CFLAGS) $(AVX2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_avx.c +fill_window_sse.o: + $(CC) $(CFLAGS) $(SSE2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/fill_window_sse.c -chunkset_avx.lo: - $(CC) $(SFLAGS) $(AVX2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_avx.c +fill_window_sse.lo: + $(CC) $(SFLAGS) $(SSE2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/fill_window_sse.c -chunkset_sse.o: - $(CC) $(CFLAGS) $(SSE2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_sse.c +deflate_quick.o: + $(CC) $(CFLAGS) $(SSE4FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/deflate_quick.c -chunkset_sse.lo: - $(CC) $(SFLAGS) $(SSE2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_sse.c - -compare258_avx.o: - $(CC) $(CFLAGS) $(AVX2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/compare258_avx.c - -compare258_avx.lo: - $(CC) $(SFLAGS) $(AVX2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/compare258_avx.c - -compare258_sse.o: - $(CC) $(CFLAGS) $(SSE4FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/compare258_sse.c - -compare258_sse.lo: - $(CC) $(SFLAGS) $(SSE4FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/compare258_sse.c +deflate_quick.lo: + $(CC) $(SFLAGS) $(SSE4FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/deflate_quick.c insert_string_sse.o: $(CC) $(CFLAGS) $(SSE4FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_sse.c @@ -73,30 +48,6 @@ crc_folding.o: crc_folding.lo: $(CC) $(SFLAGS) $(PCLMULFLAG) $(SSE4FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/crc_folding.c -slide_avx.o: - $(CC) $(CFLAGS) $(AVX2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_avx.c - -slide_avx.lo: - $(CC) $(SFLAGS) $(AVX2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/slide_avx.c - -slide_sse.o: - $(CC) $(CFLAGS) $(SSE2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_sse.c - -slide_sse.lo: - $(CC) $(SFLAGS) $(SSE2FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/slide_sse.c - -adler32_avx.o: $(SRCDIR)/adler32_avx.c - $(CC) $(CFLAGS) $(AVX2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_avx.c - -adler32_avx.lo: $(SRCDIR)/adler32_avx.c - $(CC) $(SFLAGS) $(AVX2FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_avx.c - -adler32_ssse3.o: $(SRCDIR)/adler32_ssse3.c - $(CC) $(CFLAGS) $(SSSE3FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_ssse3.c - -adler32_ssse3.lo: $(SRCDIR)/adler32_ssse3.c - $(CC) $(SFLAGS) $(SSSE3FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_ssse3.c - mostlyclean: clean clean: rm -f *.o *.lo *~ diff --git a/libs/zlibng/arch/x86/adler32_avx.c b/libs/zlibng/arch/x86/adler32_avx.c deleted file mode 100644 index 106324654..000000000 --- a/libs/zlibng/arch/x86/adler32_avx.c +++ /dev/null @@ -1,117 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011 Mark Adler - * Authors: - * Brian Bockelman - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "../../zbuild.h" -#include "../../zutil.h" - -#include "../../adler32_p.h" - -#include - -#ifdef X86_AVX2_ADLER32 - -Z_INTERNAL uint32_t adler32_avx2(uint32_t adler, const unsigned char *buf, size_t len) { - uint32_t sum2; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (UNLIKELY(len == 1)) - return adler32_len_1(adler, buf, sum2); - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (UNLIKELY(buf == NULL)) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (UNLIKELY(len < 16)) - return adler32_len_16(adler, buf, len, sum2); - - uint32_t ALIGNED_(32) s1[8], s2[8]; - - memset(s1, 0, sizeof(s1)); s1[7] = adler; // TODO: would a masked load be faster? - memset(s2, 0, sizeof(s2)); s2[7] = sum2; - - char ALIGNED_(32) dot1[32] = \ - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - __m256i dot1v = _mm256_load_si256((__m256i*)dot1); - char ALIGNED_(32) dot2[32] = \ - {32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, - 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; - __m256i dot2v = _mm256_load_si256((__m256i*)dot2); - short ALIGNED_(32) dot3[16] = \ - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - __m256i dot3v = _mm256_load_si256((__m256i*)dot3); - - // We will need to multiply by - char ALIGNED_(32) shift[16] = {5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - __m128i shiftv = _mm_load_si128((__m128i*)shift); - - while (len >= 32) { - __m256i vs1 = _mm256_load_si256((__m256i*)s1); - __m256i vs2 = _mm256_load_si256((__m256i*)s2); - __m256i vs1_0 = vs1; - - int k = (len < NMAX ? (int)len : NMAX); - k -= k % 32; - len -= k; - - while (k >= 32) { - /* - vs1 = adler + sum(c[i]) - vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] ) - */ - __m256i vbuf = _mm256_loadu_si256((__m256i*)buf); - buf += 32; - k -= 32; - - __m256i v_short_sum1 = _mm256_maddubs_epi16(vbuf, dot1v); // multiply-add, resulting in 8 shorts. - __m256i vsum1 = _mm256_madd_epi16(v_short_sum1, dot3v); // sum 8 shorts to 4 int32_t; - __m256i v_short_sum2 = _mm256_maddubs_epi16(vbuf, dot2v); - vs1 = _mm256_add_epi32(vsum1, vs1); - __m256i vsum2 = _mm256_madd_epi16(v_short_sum2, dot3v); - vs1_0 = _mm256_sll_epi32(vs1_0, shiftv); - vsum2 = _mm256_add_epi32(vsum2, vs2); - vs2 = _mm256_add_epi32(vsum2, vs1_0); - vs1_0 = vs1; - } - - // At this point, we have partial sums stored in vs1 and vs2. There are AVX512 instructions that - // would allow us to sum these quickly (VP4DPWSSD). For now, just unpack and move on. - uint32_t ALIGNED_(32) s1_unpack[8]; - uint32_t ALIGNED_(32) s2_unpack[8]; - - _mm256_store_si256((__m256i*)s1_unpack, vs1); - _mm256_store_si256((__m256i*)s2_unpack, vs2); - - adler = (s1_unpack[0] % BASE) + (s1_unpack[1] % BASE) + (s1_unpack[2] % BASE) + (s1_unpack[3] % BASE) + - (s1_unpack[4] % BASE) + (s1_unpack[5] % BASE) + (s1_unpack[6] % BASE) + (s1_unpack[7] % BASE); - adler %= BASE; - s1[7] = adler; - - sum2 = (s2_unpack[0] % BASE) + (s2_unpack[1] % BASE) + (s2_unpack[2] % BASE) + (s2_unpack[3] % BASE) + - (s2_unpack[4] % BASE) + (s2_unpack[5] % BASE) + (s2_unpack[6] % BASE) + (s2_unpack[7] % BASE); - sum2 %= BASE; - s2[7] = sum2; - } - - while (len) { - len--; - adler += *buf++; - sum2 += adler; - } - adler %= BASE; - sum2 %= BASE; - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -#endif diff --git a/libs/zlibng/arch/x86/adler32_ssse3.c b/libs/zlibng/arch/x86/adler32_ssse3.c deleted file mode 100644 index 101df4fe4..000000000 --- a/libs/zlibng/arch/x86/adler32_ssse3.c +++ /dev/null @@ -1,118 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011 Mark Adler - * Authors: - * Brian Bockelman - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "../../zbuild.h" -#include "../../zutil.h" - -#include "../../adler32_p.h" - -#ifdef X86_SSSE3_ADLER32 - -#include - -Z_INTERNAL uint32_t adler32_ssse3(uint32_t adler, const unsigned char *buf, size_t len) { - uint32_t sum2; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (UNLIKELY(len == 1)) - return adler32_len_1(adler, buf, sum2); - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (UNLIKELY(buf == NULL)) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (UNLIKELY(len < 16)) - return adler32_len_16(adler, buf, len, sum2); - - uint32_t ALIGNED_(16) s1[4], s2[4]; - - s1[0] = s1[1] = s1[2] = 0; s1[3] = adler; - s2[0] = s2[1] = s2[2] = 0; s2[3] = sum2; - - char ALIGNED_(16) dot1[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - __m128i dot1v = _mm_load_si128((__m128i*)dot1); - char ALIGNED_(16) dot2[16] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; - __m128i dot2v = _mm_load_si128((__m128i*)dot2); - short ALIGNED_(16) dot3[8] = {1, 1, 1, 1, 1, 1, 1, 1}; - __m128i dot3v = _mm_load_si128((__m128i*)dot3); - - // We will need to multiply by - //char ALIGNED_(16) shift[4] = {0, 0, 0, 4}; //{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}; - - char ALIGNED_(16) shift[16] = {4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - __m128i shiftv = _mm_load_si128((__m128i*)shift); - - while (len >= 16) { - __m128i vs1 = _mm_load_si128((__m128i*)s1); - __m128i vs2 = _mm_load_si128((__m128i*)s2); - __m128i vs1_0 = vs1; - - int k = (len < NMAX ? (int)len : NMAX); - k -= k % 16; - len -= k; - - while (k >= 16) { - /* - vs1 = adler + sum(c[i]) - vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] ) - - NOTE: 256-bit equivalents are: - _mm256_maddubs_epi16 <- operates on 32 bytes to 16 shorts - _mm256_madd_epi16 <- Sums 16 shorts to 8 int32_t. - We could rewrite the below to use 256-bit instructions instead of 128-bit. - */ - __m128i vbuf = _mm_loadu_si128((__m128i*)buf); - buf += 16; - k -= 16; - - __m128i v_short_sum1 = _mm_maddubs_epi16(vbuf, dot1v); // multiply-add, resulting in 8 shorts. - __m128i vsum1 = _mm_madd_epi16(v_short_sum1, dot3v); // sum 8 shorts to 4 int32_t; - __m128i v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v); - vs1 = _mm_add_epi32(vsum1, vs1); - __m128i vsum2 = _mm_madd_epi16(v_short_sum2, dot3v); - vs1_0 = _mm_sll_epi32(vs1_0, shiftv); - vsum2 = _mm_add_epi32(vsum2, vs2); - vs2 = _mm_add_epi32(vsum2, vs1_0); - vs1_0 = vs1; - } - - // At this point, we have partial sums stored in vs1 and vs2. There are AVX512 instructions that - // would allow us to sum these quickly (VP4DPWSSD). For now, just unpack and move on. - - uint32_t ALIGNED_(16) s1_unpack[4]; - uint32_t ALIGNED_(16) s2_unpack[4]; - - _mm_store_si128((__m128i*)s1_unpack, vs1); - _mm_store_si128((__m128i*)s2_unpack, vs2); - - adler = (s1_unpack[0] % BASE) + (s1_unpack[1] % BASE) + (s1_unpack[2] % BASE) + (s1_unpack[3] % BASE); - adler %= BASE; - s1[3] = adler; - - sum2 = (s2_unpack[0] % BASE) + (s2_unpack[1] % BASE) + (s2_unpack[2] % BASE) + (s2_unpack[3] % BASE); - sum2 %= BASE; - s2[3] = sum2; - } - - while (len) { - len--; - adler += *buf++; - sum2 += adler; - } - adler %= BASE; - sum2 %= BASE; - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -#endif diff --git a/libs/zlibng/arch/x86/chunkset_avx.c b/libs/zlibng/arch/x86/chunkset_avx.c deleted file mode 100644 index eb76c0db9..000000000 --- a/libs/zlibng/arch/x86/chunkset_avx.c +++ /dev/null @@ -1,50 +0,0 @@ -/* chunkset_avx.c -- AVX inline functions to copy small data chunks. - * For conditions of distribution and use, see copyright notice in zlib.h - */ -#include "zbuild.h" -#include "zutil.h" - -#ifdef X86_AVX_CHUNKSET -#include - -typedef __m256i chunk_t; - -#define HAVE_CHUNKMEMSET_1 -#define HAVE_CHUNKMEMSET_2 -#define HAVE_CHUNKMEMSET_4 -#define HAVE_CHUNKMEMSET_8 - -static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) { - *chunk = _mm256_set1_epi8(*(int8_t *)from); -} - -static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) { - *chunk = _mm256_set1_epi16(*(int16_t *)from); -} - -static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { - *chunk = _mm256_set1_epi32(*(int32_t *)from); -} - -static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { - *chunk = _mm256_set1_epi64x(*(int64_t *)from); -} - -static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { - *chunk = _mm256_loadu_si256((__m256i *)s); -} - -static inline void storechunk(uint8_t *out, chunk_t *chunk) { - _mm256_storeu_si256((__m256i *)out, *chunk); -} - -#define CHUNKSIZE chunksize_avx -#define CHUNKCOPY chunkcopy_avx -#define CHUNKCOPY_SAFE chunkcopy_safe_avx -#define CHUNKUNROLL chunkunroll_avx -#define CHUNKMEMSET chunkmemset_avx -#define CHUNKMEMSET_SAFE chunkmemset_safe_avx - -#include "chunkset_tpl.h" - -#endif diff --git a/libs/zlibng/arch/x86/chunkset_sse.c b/libs/zlibng/arch/x86/chunkset_sse.c deleted file mode 100644 index 1d5a0faa9..000000000 --- a/libs/zlibng/arch/x86/chunkset_sse.c +++ /dev/null @@ -1,51 +0,0 @@ -/* chunkset_sse.c -- SSE inline functions to copy small data chunks. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zbuild.h" -#include "zutil.h" - -#ifdef X86_SSE2 -#include - -typedef __m128i chunk_t; - -#define HAVE_CHUNKMEMSET_1 -#define HAVE_CHUNKMEMSET_2 -#define HAVE_CHUNKMEMSET_4 -#define HAVE_CHUNKMEMSET_8 - -static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) { - *chunk = _mm_set1_epi8(*(int8_t *)from); -} - -static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) { - *chunk = _mm_set1_epi16(*(int16_t *)from); -} - -static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { - *chunk = _mm_set1_epi32(*(int32_t *)from); -} - -static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { - *chunk = _mm_set1_epi64x(*(int64_t *)from); -} - -static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { - *chunk = _mm_loadu_si128((__m128i *)s); -} - -static inline void storechunk(uint8_t *out, chunk_t *chunk) { - _mm_storeu_si128((__m128i *)out, *chunk); -} - -#define CHUNKSIZE chunksize_sse2 -#define CHUNKCOPY chunkcopy_sse2 -#define CHUNKCOPY_SAFE chunkcopy_safe_sse2 -#define CHUNKUNROLL chunkunroll_sse2 -#define CHUNKMEMSET chunkmemset_sse2 -#define CHUNKMEMSET_SAFE chunkmemset_safe_sse2 - -#include "chunkset_tpl.h" - -#endif diff --git a/libs/zlibng/arch/x86/compare258_avx.c b/libs/zlibng/arch/x86/compare258_avx.c deleted file mode 100644 index d9108fdeb..000000000 --- a/libs/zlibng/arch/x86/compare258_avx.c +++ /dev/null @@ -1,67 +0,0 @@ -/* compare258_avx.c -- AVX2 version of compare258 - * Copyright Mika T. Lindqvist - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "../../zbuild.h" -#include "../../zutil.h" - -#include "fallback_builtins.h" - -#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) - -#include -#ifdef _MSC_VER -# include -#endif - -/* UNALIGNED_OK, AVX2 intrinsic comparison */ -static inline uint32_t compare256_unaligned_avx2_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - __m256i ymm_src0, ymm_src1, ymm_cmp; - ymm_src0 = _mm256_loadu_si256((__m256i*)src0); - ymm_src1 = _mm256_loadu_si256((__m256i*)src1); - ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1); /* non-identical bytes = 00, identical bytes = FF */ - unsigned mask = (unsigned)_mm256_movemask_epi8(ymm_cmp); - if (mask != 0xFFFFFFFF) { - uint32_t match_byte = (uint32_t)__builtin_ctz(~mask); /* Invert bits so identical = 0 */ - return len + match_byte; - } - - src0 += 32, src1 += 32, len += 32; - - ymm_src0 = _mm256_loadu_si256((__m256i*)src0); - ymm_src1 = _mm256_loadu_si256((__m256i*)src1); - ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1); - mask = (unsigned)_mm256_movemask_epi8(ymm_cmp); - if (mask != 0xFFFFFFFF) { - uint32_t match_byte = (uint32_t)__builtin_ctz(~mask); - return len + match_byte; - } - - src0 += 32, src1 += 32, len += 32; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_unaligned_avx2_static(const unsigned char *src0, const unsigned char *src1) { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return (*src0 == *src1); - - return compare256_unaligned_avx2_static(src0+2, src1+2) + 2; -} - -Z_INTERNAL uint32_t compare258_unaligned_avx2(const unsigned char *src0, const unsigned char *src1) { - return compare258_unaligned_avx2_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_unaligned_avx2 -#define COMPARE256 compare256_unaligned_avx2_static -#define COMPARE258 compare258_unaligned_avx2_static - -#include "match_tpl.h" - -#endif diff --git a/libs/zlibng/arch/x86/compare258_sse.c b/libs/zlibng/arch/x86/compare258_sse.c deleted file mode 100644 index 17534c051..000000000 --- a/libs/zlibng/arch/x86/compare258_sse.c +++ /dev/null @@ -1,74 +0,0 @@ -/* compare258_sse.c -- SSE4.2 version of compare258 - * - * Copyright (C) 2013 Intel Corporation. All rights reserved. - * Authors: - * Wajdi Feghali - * Jim Guilford - * Vinodh Gopal - * Erdinc Ozturk - * Jim Kukunas - * - * Portions are Copyright (C) 2016 12Sided Technology, LLC. - * Author: - * Phil Vachon - * - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "../../zbuild.h" -#include "../../zutil.h" - -#ifdef X86_SSE42_CMP_STR - -#include -#ifdef _MSC_VER -# include -#endif - -/* UNALIGNED_OK, SSE4.2 intrinsic comparison */ -static inline uint32_t compare256_unaligned_sse4_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - #define mode _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_EACH | _SIDD_NEGATIVE_POLARITY - __m128i xmm_src0, xmm_src1; - uint32_t ret; - - xmm_src0 = _mm_loadu_si128((__m128i *)src0); - xmm_src1 = _mm_loadu_si128((__m128i *)src1); - ret = (uint32_t)_mm_cmpestri(xmm_src0, 16, xmm_src1, 16, mode); - if (_mm_cmpestrc(xmm_src0, 16, xmm_src1, 16, mode)) { - return len + ret; - } - src0 += 16, src1 += 16, len += 16; - - xmm_src0 = _mm_loadu_si128((__m128i *)src0); - xmm_src1 = _mm_loadu_si128((__m128i *)src1); - ret = (uint32_t)_mm_cmpestri(xmm_src0, 16, xmm_src1, 16, mode); - if (_mm_cmpestrc(xmm_src0, 16, xmm_src1, 16, mode)) { - return len + ret; - } - src0 += 16, src1 += 16, len += 16; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_unaligned_sse4_static(const unsigned char *src0, const unsigned char *src1) { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return (*src0 == *src1); - - return compare256_unaligned_sse4_static(src0+2, src1+2) + 2; -} - -Z_INTERNAL uint32_t compare258_unaligned_sse4(const unsigned char *src0, const unsigned char *src1) { - return compare258_unaligned_sse4_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_unaligned_sse4 -#define COMPARE256 compare256_unaligned_sse4_static -#define COMPARE258 compare258_unaligned_sse4_static - -#include "match_tpl.h" - -#endif diff --git a/libs/zlibng/arch/x86/crc_folding.c b/libs/zlibng/arch/x86/crc_folding.c index 918bd9468..eb178f55c 100644 --- a/libs/zlibng/arch/x86/crc_folding.c +++ b/libs/zlibng/arch/x86/crc_folding.c @@ -1,5 +1,5 @@ /* - * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ + * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ * instruction. * * A white paper describing this algorithm can be found at: @@ -18,14 +18,14 @@ #ifdef X86_PCLMULQDQ_CRC -#include "../../zbuild.h" +#include "zbuild.h" #include #include #include #include "crc_folding.h" -Z_INTERNAL void crc_fold_init(deflate_state *const s) { +ZLIB_INTERNAL void crc_fold_init(deflate_state *const s) { /* CRC_SAVE */ _mm_storeu_si128((__m128i *)s->crc0 + 0, _mm_cvtsi32_si128(0x9db42487)); _mm_storeu_si128((__m128i *)s->crc0 + 1, _mm_setzero_si128()); @@ -227,10 +227,9 @@ static void partial_fold(const size_t len, __m128i *xmm_crc0, __m128i *xmm_crc1, *xmm_crc3 = _mm_castps_si128(ps_res); } -Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const unsigned char *src, long len) { +ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const unsigned char *src, long len) { unsigned long algn_diff; __m128i xmm_t0, xmm_t1, xmm_t2, xmm_t3; - char ALIGNED_(16) partial_buf[16] = { 0 }; /* CRC_LOAD */ __m128i xmm_crc0 = _mm_loadu_si128((__m128i *)s->crc0 + 0); @@ -242,14 +241,11 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const if (len < 16) { if (len == 0) return; - - memcpy(partial_buf, src, len); - xmm_crc_part = _mm_loadu_si128((const __m128i *)partial_buf); - memcpy(dst, partial_buf, len); + xmm_crc_part = _mm_loadu_si128((__m128i *)src); goto partial; } - algn_diff = ((uintptr_t)16 - ((uintptr_t)src & 0xF)) & 0xF; + algn_diff = (0 - (uintptr_t)src) & 0xF; if (algn_diff) { xmm_crc_part = _mm_loadu_si128((__m128i *)src); _mm_storeu_si128((__m128i *)dst, xmm_crc_part); @@ -259,8 +255,6 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const len -= algn_diff; partial_fold(algn_diff, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3, &xmm_crc_part); - } else { - xmm_crc_part = _mm_setzero_si128(); } while ((len -= 64) >= 0) { @@ -311,7 +305,7 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const goto done; dst += 48; - memcpy(&xmm_crc_part, (__m128i *)src + 3, len); + xmm_crc_part = _mm_load_si128((__m128i *)src + 3); } else if (len + 32 >= 0) { len += 32; @@ -330,7 +324,7 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const goto done; dst += 32; - memcpy(&xmm_crc_part, (__m128i *)src + 2, len); + xmm_crc_part = _mm_load_si128((__m128i *)src + 2); } else if (len + 48 >= 0) { len += 48; @@ -346,18 +340,16 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const goto done; dst += 16; - memcpy(&xmm_crc_part, (__m128i *)src + 1, len); + xmm_crc_part = _mm_load_si128((__m128i *)src + 1); } else { len += 64; if (len == 0) goto done; - memcpy(&xmm_crc_part, src, len); + xmm_crc_part = _mm_load_si128((__m128i *)src); } - _mm_storeu_si128((__m128i *)partial_buf, xmm_crc_part); - memcpy(dst, partial_buf, len); - partial: + _mm_storeu_si128((__m128i *)dst, xmm_crc_part); partial_fold(len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3, &xmm_crc_part); done: /* CRC_SAVE */ @@ -385,7 +377,7 @@ static const unsigned ALIGNED_(16) crc_mask2[4] = { 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; -uint32_t Z_INTERNAL crc_fold_512to32(deflate_state *const s) { +uint32_t ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s) { const __m128i xmm_mask = _mm_load_si128((__m128i *)crc_mask); const __m128i xmm_mask2 = _mm_load_si128((__m128i *)crc_mask2); @@ -455,3 +447,4 @@ uint32_t Z_INTERNAL crc_fold_512to32(deflate_state *const s) { } #endif + diff --git a/libs/zlibng/arch/x86/crc_folding.h b/libs/zlibng/arch/x86/crc_folding.h index 0d3c24b29..22bfa9864 100644 --- a/libs/zlibng/arch/x86/crc_folding.h +++ b/libs/zlibng/arch/x86/crc_folding.h @@ -10,10 +10,10 @@ #ifndef CRC_FOLDING_H_ #define CRC_FOLDING_H_ -#include "../../deflate.h" +#include "deflate.h" -Z_INTERNAL void crc_fold_init(deflate_state *const); -Z_INTERNAL uint32_t crc_fold_512to32(deflate_state *const); -Z_INTERNAL void crc_fold_copy(deflate_state *const, unsigned char *, const unsigned char *, long); +ZLIB_INTERNAL void crc_fold_init(deflate_state *const); +ZLIB_INTERNAL uint32_t crc_fold_512to32(deflate_state *const); +ZLIB_INTERNAL void crc_fold_copy(deflate_state *const, unsigned char *, const unsigned char *, long); #endif diff --git a/libs/zlibng/arch/x86/ctzl.h b/libs/zlibng/arch/x86/ctzl.h new file mode 100644 index 000000000..bc9e9bd5b --- /dev/null +++ b/libs/zlibng/arch/x86/ctzl.h @@ -0,0 +1,25 @@ +#ifndef X86_CTZL_H +#define X86_CTZL_H + +#include +#ifdef X86_CPUID +# include "x86.h" +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +/* This is not a general purpose replacement for __builtin_ctzl. The function expects that value is != 0 + * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked + */ +static __forceinline unsigned long __builtin_ctzl(unsigned long value) +{ +#ifdef X86_CPUID + if (x86_cpu_has_tzcnt) + return _tzcnt_u32(value); +#endif + unsigned long trailing_zero; + _BitScanForward(&trailing_zero, value); + return trailing_zero; +} +#endif + +#endif diff --git a/libs/zlibng/arch/x86/deflate_quick.c b/libs/zlibng/arch/x86/deflate_quick.c new file mode 100644 index 000000000..0c5196926 --- /dev/null +++ b/libs/zlibng/arch/x86/deflate_quick.c @@ -0,0 +1,2405 @@ +/* + * The deflate_quick deflate strategy, designed to be used when cycles are + * at a premium. + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * Authors: + * Wajdi Feghali + * Jim Guilford + * Vinodh Gopal + * Erdinc Ozturk + * Jim Kukunas + * + * Portions are Copyright (C) 2016 12Sided Technology, LLC. + * Author: + * Phil Vachon + * + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zbuild.h" +#include +#ifdef _MSC_VER +# include +#endif +#include "deflate.h" +#include "memcopy.h" + +#ifdef ZLIB_DEBUG +#include +#endif + +extern void fill_window_sse(deflate_state *s); +extern void flush_pending(PREFIX3(stream) *strm); + +static inline long compare258(const unsigned char *const src0, const unsigned char *const src1) { +#ifdef _MSC_VER + long cnt; + + cnt = 0; + do { +#define mode _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_EACH | _SIDD_NEGATIVE_POLARITY + + int ret; + __m128i xmm_src0, xmm_src1; + + xmm_src0 = _mm_loadu_si128((__m128i *)(src0 + cnt)); + xmm_src1 = _mm_loadu_si128((__m128i *)(src1 + cnt)); + ret = _mm_cmpestri(xmm_src0, 16, xmm_src1, 16, mode); + if (_mm_cmpestrc(xmm_src0, 16, xmm_src1, 16, mode)) { + cnt += ret; + break; + } + cnt += 16; + + xmm_src0 = _mm_loadu_si128((__m128i *)(src0 + cnt)); + xmm_src1 = _mm_loadu_si128((__m128i *)(src1 + cnt)); + ret = _mm_cmpestri(xmm_src0, 16, xmm_src1, 16, mode); + if (_mm_cmpestrc(xmm_src0, 16, xmm_src1, 16, mode)) { + cnt += ret; + break; + } + cnt += 16; + } while (cnt < 256); + + if (*(unsigned short *)(src0 + cnt) == *(unsigned short *)(src1 + cnt)) { + cnt += 2; + } else if (*(src0 + cnt) == *(src1 + cnt)) { + cnt++; + } + return cnt; +#else + uintptr_t ax, dx, cx; + __m128i xmm_src0; + + ax = 16; + dx = 16; + /* set cx to something, otherwise gcc thinks it's used + uninitalised */ + cx = 0; + + __asm__ __volatile__ ( + "1:" + "movdqu -16(%[src0], %[ax]), %[xmm_src0]\n\t" + "pcmpestri $0x18, -16(%[src1], %[ax]), %[xmm_src0]\n\t" + "jc 2f\n\t" + "add $16, %[ax]\n\t" + + "movdqu -16(%[src0], %[ax]), %[xmm_src0]\n\t" + "pcmpestri $0x18, -16(%[src1], %[ax]), %[xmm_src0]\n\t" + "jc 2f\n\t" + "add $16, %[ax]\n\t" + + "cmp $256 + 16, %[ax]\n\t" + "jb 1b\n\t" + +# if !defined(__x86_64__) + "movzwl -16(%[src0], %[ax]), %[dx]\n\t" +# else + "movzwq -16(%[src0], %[ax]), %[dx]\n\t" +# endif + "xorw -16(%[src1], %[ax]), %%dx\n\t" + "jnz 3f\n\t" + + "add $2, %[ax]\n\t" + "jmp 4f\n\t" + "3:\n\t" + "rep; bsf %[dx], %[cx]\n\t" + "shr $3, %[cx]\n\t" + "2:" + "add %[cx], %[ax]\n\t" + "4:" + : [ax] "+a" (ax), + [cx] "+c" (cx), + [dx] "+d" (dx), + [xmm_src0] "=x" (xmm_src0) + : [src0] "r" (src0), + [src1] "r" (src1) + : "cc" + ); + return ax - 16; +#endif +} + +static const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1]; +static const unsigned quick_dist_codes[8192]; + +static inline void quick_send_bits(deflate_state *const s, + const int value1, const int length1, + const int value2, const int length2) { + unsigned offset2 = s->bi_valid + length1; + unsigned width = s->bi_valid + length1 + length2; + unsigned bytes_out = width / 8; + + /* Concatenate the new bits with the bits currently in the buffer */ + unsigned out = s->bi_buf | (value1 << s->bi_valid); + if (width < 32) { + out |= (value2 << offset2); + /* Shift out the valid LSBs written out. */ + s->bi_buf = out >> (bytes_out * 8); + } else /* width => 32 */ { + unsigned bits_that_fit = 32 - offset2; + unsigned mask = (1 << bits_that_fit) - 1; + /* Zero out the high bits of value2 such that the shift by offset2 will + not cause undefined behavior. */ + out |= ((value2 & mask) << offset2); + + /* Save in s->bi_buf the bits of value2 that do not fit: they will be + written in a next full byte. */ + s->bi_buf = (width == 32) ? 0 : value2 >> bits_that_fit; + } + + s->bi_valid = width - (bytes_out * 8); + + /* Taking advantage of the fact that LSB comes first, write to output buffer */ + memcpy(s->pending_buf + s->pending, &out, sizeof(out)); + + s->pending += bytes_out; +} + +static inline void static_emit_ptr(deflate_state *const s, const int lc, const unsigned dist) { + unsigned code1 = quick_len_codes[lc] >> 8; + unsigned len1 = quick_len_codes[lc] & 0xFF; + unsigned code2 = quick_dist_codes[dist-1] >> 8; + unsigned len2 = quick_dist_codes[dist-1] & 0xFF; + quick_send_bits(s, code1, len1, code2, len2); +} + +const ct_data static_ltree[L_CODES+2]; + +static inline void static_emit_lit(deflate_state *const s, const int lit) { + quick_send_bits(s, static_ltree[lit].Code, static_ltree[lit].Len, 0, 0); + Tracecv(isgraph(lit), (stderr, " '%c' ", lit)); +} + +static void static_emit_tree(deflate_state *const s, const int flush) { + unsigned last; + + last = flush == Z_FINISH ? 1 : 0; + Tracev((stderr, "\n--- Emit Tree: Last: %u\n", last)); + send_bits(s, (STATIC_TREES << 1)+ last, 3); +#ifdef ZLIB_DEBUG + s->compressed_len += 3; +#endif +} + +static void static_emit_end_block(deflate_state *const s, int last) { + send_code(s, END_BLOCK, static_ltree); +#ifdef ZLIB_DEBUG + s->compressed_len += 7; /* 7 bits for EOB */ +#endif + Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %zu\n", last, s->pending, s->strm->total_out)); + + if (last) + bi_windup(s); + + s->block_start = s->strstart; + flush_pending(s->strm); + s->block_open = 0; +} + +static inline Pos quick_insert_string(deflate_state *const s, const Pos str) { + Pos ret; + unsigned h = 0; + +#ifdef _MSC_VER + h = _mm_crc32_u32(h, *(unsigned *)(s->window + str)); +#else + __asm__ __volatile__ ( + "crc32l (%[window], %[str], 1), %0\n\t" + : "+r" (h) + : [window] "r" (s->window), + [str] "r" ((uintptr_t)str) + ); +#endif + + ret = s->head[h & s->hash_mask]; + s->head[h & s->hash_mask] = str; + return ret; +} + +ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { + IPos hash_head; + unsigned dist, match_len; + + if (s->block_open == 0) { + static_emit_tree(s, flush); + s->block_open = 1; + } + + do { + if (s->pending + 4 >= s->pending_buf_size) { + flush_pending(s->strm); + return need_more; + } + + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window_sse(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + static_emit_end_block(s, 0); + return need_more; + } + if (s->lookahead == 0) + break; + } + + if (s->lookahead >= MIN_MATCH) { + hash_head = quick_insert_string(s, s->strstart); + dist = s->strstart - hash_head; + + if (dist > 0 && (dist-1) < (s->w_size - 1)) { + match_len = compare258(s->window + s->strstart, s->window + s->strstart - dist); + + if (match_len >= MIN_MATCH) { + if (match_len > s->lookahead) + match_len = s->lookahead; + + if (match_len > MAX_MATCH) + match_len = MAX_MATCH; + + static_emit_ptr(s, match_len - MIN_MATCH, s->strstart - hash_head); + s->lookahead -= match_len; + s->strstart += match_len; + continue; + } + } + } + + static_emit_lit(s, s->window[s->strstart]); + s->strstart++; + s->lookahead--; + } while (s->strm->avail_out != 0); + + if (s->strm->avail_out == 0 && flush != Z_FINISH) + return need_more; + + s->insert = s->strstart < MIN_MATCH - 1 ? s->strstart : MIN_MATCH-1; + if (flush == Z_FINISH) { + static_emit_end_block(s, 1); + if (s->strm->avail_out == 0) + return s->strm->avail_in == 0 ? finish_started : need_more; + else + return finish_done; + } + + static_emit_end_block(s, 0); + return block_done; +} + +static const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = { + 0x00004007, 0x00002007, 0x00006007, 0x00001007, + 0x00005007, 0x00003007, 0x00007007, 0x00000807, + 0x00004808, 0x0000c808, 0x00002808, 0x0000a808, + 0x00006808, 0x0000e808, 0x00001808, 0x00009808, + 0x00005809, 0x0000d809, 0x00015809, 0x0001d809, + 0x00003809, 0x0000b809, 0x00013809, 0x0001b809, + 0x00007809, 0x0000f809, 0x00017809, 0x0001f809, + 0x00000409, 0x00008409, 0x00010409, 0x00018409, + 0x0000440a, 0x0000c40a, 0x0001440a, 0x0001c40a, + 0x0002440a, 0x0002c40a, 0x0003440a, 0x0003c40a, + 0x0000240a, 0x0000a40a, 0x0001240a, 0x0001a40a, + 0x0002240a, 0x0002a40a, 0x0003240a, 0x0003a40a, + 0x0000640a, 0x0000e40a, 0x0001640a, 0x0001e40a, + 0x0002640a, 0x0002e40a, 0x0003640a, 0x0003e40a, + 0x0000140a, 0x0000940a, 0x0001140a, 0x0001940a, + 0x0002140a, 0x0002940a, 0x0003140a, 0x0003940a, + 0x0000540b, 0x0000d40b, 0x0001540b, 0x0001d40b, + 0x0002540b, 0x0002d40b, 0x0003540b, 0x0003d40b, + 0x0004540b, 0x0004d40b, 0x0005540b, 0x0005d40b, + 0x0006540b, 0x0006d40b, 0x0007540b, 0x0007d40b, + 0x0000340b, 0x0000b40b, 0x0001340b, 0x0001b40b, + 0x0002340b, 0x0002b40b, 0x0003340b, 0x0003b40b, + 0x0004340b, 0x0004b40b, 0x0005340b, 0x0005b40b, + 0x0006340b, 0x0006b40b, 0x0007340b, 0x0007b40b, + 0x0000740b, 0x0000f40b, 0x0001740b, 0x0001f40b, + 0x0002740b, 0x0002f40b, 0x0003740b, 0x0003f40b, + 0x0004740b, 0x0004f40b, 0x0005740b, 0x0005f40b, + 0x0006740b, 0x0006f40b, 0x0007740b, 0x0007f40b, + 0x0000030c, 0x0001030c, 0x0002030c, 0x0003030c, + 0x0004030c, 0x0005030c, 0x0006030c, 0x0007030c, + 0x0008030c, 0x0009030c, 0x000a030c, 0x000b030c, + 0x000c030c, 0x000d030c, 0x000e030c, 0x000f030c, + 0x0000830d, 0x0001830d, 0x0002830d, 0x0003830d, + 0x0004830d, 0x0005830d, 0x0006830d, 0x0007830d, + 0x0008830d, 0x0009830d, 0x000a830d, 0x000b830d, + 0x000c830d, 0x000d830d, 0x000e830d, 0x000f830d, + 0x0010830d, 0x0011830d, 0x0012830d, 0x0013830d, + 0x0014830d, 0x0015830d, 0x0016830d, 0x0017830d, + 0x0018830d, 0x0019830d, 0x001a830d, 0x001b830d, + 0x001c830d, 0x001d830d, 0x001e830d, 0x001f830d, + 0x0000430d, 0x0001430d, 0x0002430d, 0x0003430d, + 0x0004430d, 0x0005430d, 0x0006430d, 0x0007430d, + 0x0008430d, 0x0009430d, 0x000a430d, 0x000b430d, + 0x000c430d, 0x000d430d, 0x000e430d, 0x000f430d, + 0x0010430d, 0x0011430d, 0x0012430d, 0x0013430d, + 0x0014430d, 0x0015430d, 0x0016430d, 0x0017430d, + 0x0018430d, 0x0019430d, 0x001a430d, 0x001b430d, + 0x001c430d, 0x001d430d, 0x001e430d, 0x001f430d, + 0x0000c30d, 0x0001c30d, 0x0002c30d, 0x0003c30d, + 0x0004c30d, 0x0005c30d, 0x0006c30d, 0x0007c30d, + 0x0008c30d, 0x0009c30d, 0x000ac30d, 0x000bc30d, + 0x000cc30d, 0x000dc30d, 0x000ec30d, 0x000fc30d, + 0x0010c30d, 0x0011c30d, 0x0012c30d, 0x0013c30d, + 0x0014c30d, 0x0015c30d, 0x0016c30d, 0x0017c30d, + 0x0018c30d, 0x0019c30d, 0x001ac30d, 0x001bc30d, + 0x001cc30d, 0x001dc30d, 0x001ec30d, 0x001fc30d, + 0x0000230d, 0x0001230d, 0x0002230d, 0x0003230d, + 0x0004230d, 0x0005230d, 0x0006230d, 0x0007230d, + 0x0008230d, 0x0009230d, 0x000a230d, 0x000b230d, + 0x000c230d, 0x000d230d, 0x000e230d, 0x000f230d, + 0x0010230d, 0x0011230d, 0x0012230d, 0x0013230d, + 0x0014230d, 0x0015230d, 0x0016230d, 0x0017230d, + 0x0018230d, 0x0019230d, 0x001a230d, 0x001b230d, + 0x001c230d, 0x001d230d, 0x001e230d, 0x0000a308, +}; + +static const unsigned quick_dist_codes[8192] = { + 0x00000005, 0x00001005, 0x00000805, 0x00001805, + 0x00000406, 0x00002406, 0x00001406, 0x00003406, + 0x00000c07, 0x00002c07, 0x00004c07, 0x00006c07, + 0x00001c07, 0x00003c07, 0x00005c07, 0x00007c07, + 0x00000208, 0x00002208, 0x00004208, 0x00006208, + 0x00008208, 0x0000a208, 0x0000c208, 0x0000e208, + 0x00001208, 0x00003208, 0x00005208, 0x00007208, + 0x00009208, 0x0000b208, 0x0000d208, 0x0000f208, + 0x00000a09, 0x00002a09, 0x00004a09, 0x00006a09, + 0x00008a09, 0x0000aa09, 0x0000ca09, 0x0000ea09, + 0x00010a09, 0x00012a09, 0x00014a09, 0x00016a09, + 0x00018a09, 0x0001aa09, 0x0001ca09, 0x0001ea09, + 0x00001a09, 0x00003a09, 0x00005a09, 0x00007a09, + 0x00009a09, 0x0000ba09, 0x0000da09, 0x0000fa09, + 0x00011a09, 0x00013a09, 0x00015a09, 0x00017a09, + 0x00019a09, 0x0001ba09, 0x0001da09, 0x0001fa09, + 0x0000060a, 0x0000260a, 0x0000460a, 0x0000660a, + 0x0000860a, 0x0000a60a, 0x0000c60a, 0x0000e60a, + 0x0001060a, 0x0001260a, 0x0001460a, 0x0001660a, + 0x0001860a, 0x0001a60a, 0x0001c60a, 0x0001e60a, + 0x0002060a, 0x0002260a, 0x0002460a, 0x0002660a, + 0x0002860a, 0x0002a60a, 0x0002c60a, 0x0002e60a, + 0x0003060a, 0x0003260a, 0x0003460a, 0x0003660a, + 0x0003860a, 0x0003a60a, 0x0003c60a, 0x0003e60a, + 0x0000160a, 0x0000360a, 0x0000560a, 0x0000760a, + 0x0000960a, 0x0000b60a, 0x0000d60a, 0x0000f60a, + 0x0001160a, 0x0001360a, 0x0001560a, 0x0001760a, + 0x0001960a, 0x0001b60a, 0x0001d60a, 0x0001f60a, + 0x0002160a, 0x0002360a, 0x0002560a, 0x0002760a, + 0x0002960a, 0x0002b60a, 0x0002d60a, 0x0002f60a, + 0x0003160a, 0x0003360a, 0x0003560a, 0x0003760a, + 0x0003960a, 0x0003b60a, 0x0003d60a, 0x0003f60a, + 0x00000e0b, 0x00002e0b, 0x00004e0b, 0x00006e0b, + 0x00008e0b, 0x0000ae0b, 0x0000ce0b, 0x0000ee0b, + 0x00010e0b, 0x00012e0b, 0x00014e0b, 0x00016e0b, + 0x00018e0b, 0x0001ae0b, 0x0001ce0b, 0x0001ee0b, + 0x00020e0b, 0x00022e0b, 0x00024e0b, 0x00026e0b, + 0x00028e0b, 0x0002ae0b, 0x0002ce0b, 0x0002ee0b, + 0x00030e0b, 0x00032e0b, 0x00034e0b, 0x00036e0b, + 0x00038e0b, 0x0003ae0b, 0x0003ce0b, 0x0003ee0b, + 0x00040e0b, 0x00042e0b, 0x00044e0b, 0x00046e0b, + 0x00048e0b, 0x0004ae0b, 0x0004ce0b, 0x0004ee0b, + 0x00050e0b, 0x00052e0b, 0x00054e0b, 0x00056e0b, + 0x00058e0b, 0x0005ae0b, 0x0005ce0b, 0x0005ee0b, + 0x00060e0b, 0x00062e0b, 0x00064e0b, 0x00066e0b, + 0x00068e0b, 0x0006ae0b, 0x0006ce0b, 0x0006ee0b, + 0x00070e0b, 0x00072e0b, 0x00074e0b, 0x00076e0b, + 0x00078e0b, 0x0007ae0b, 0x0007ce0b, 0x0007ee0b, + 0x00001e0b, 0x00003e0b, 0x00005e0b, 0x00007e0b, + 0x00009e0b, 0x0000be0b, 0x0000de0b, 0x0000fe0b, + 0x00011e0b, 0x00013e0b, 0x00015e0b, 0x00017e0b, + 0x00019e0b, 0x0001be0b, 0x0001de0b, 0x0001fe0b, + 0x00021e0b, 0x00023e0b, 0x00025e0b, 0x00027e0b, + 0x00029e0b, 0x0002be0b, 0x0002de0b, 0x0002fe0b, + 0x00031e0b, 0x00033e0b, 0x00035e0b, 0x00037e0b, + 0x00039e0b, 0x0003be0b, 0x0003de0b, 0x0003fe0b, + 0x00041e0b, 0x00043e0b, 0x00045e0b, 0x00047e0b, + 0x00049e0b, 0x0004be0b, 0x0004de0b, 0x0004fe0b, + 0x00051e0b, 0x00053e0b, 0x00055e0b, 0x00057e0b, + 0x00059e0b, 0x0005be0b, 0x0005de0b, 0x0005fe0b, + 0x00061e0b, 0x00063e0b, 0x00065e0b, 0x00067e0b, + 0x00069e0b, 0x0006be0b, 0x0006de0b, 0x0006fe0b, + 0x00071e0b, 0x00073e0b, 0x00075e0b, 0x00077e0b, + 0x00079e0b, 0x0007be0b, 0x0007de0b, 0x0007fe0b, + 0x0000010c, 0x0000210c, 0x0000410c, 0x0000610c, + 0x0000810c, 0x0000a10c, 0x0000c10c, 0x0000e10c, + 0x0001010c, 0x0001210c, 0x0001410c, 0x0001610c, + 0x0001810c, 0x0001a10c, 0x0001c10c, 0x0001e10c, + 0x0002010c, 0x0002210c, 0x0002410c, 0x0002610c, + 0x0002810c, 0x0002a10c, 0x0002c10c, 0x0002e10c, + 0x0003010c, 0x0003210c, 0x0003410c, 0x0003610c, + 0x0003810c, 0x0003a10c, 0x0003c10c, 0x0003e10c, + 0x0004010c, 0x0004210c, 0x0004410c, 0x0004610c, + 0x0004810c, 0x0004a10c, 0x0004c10c, 0x0004e10c, + 0x0005010c, 0x0005210c, 0x0005410c, 0x0005610c, + 0x0005810c, 0x0005a10c, 0x0005c10c, 0x0005e10c, + 0x0006010c, 0x0006210c, 0x0006410c, 0x0006610c, + 0x0006810c, 0x0006a10c, 0x0006c10c, 0x0006e10c, + 0x0007010c, 0x0007210c, 0x0007410c, 0x0007610c, + 0x0007810c, 0x0007a10c, 0x0007c10c, 0x0007e10c, + 0x0008010c, 0x0008210c, 0x0008410c, 0x0008610c, + 0x0008810c, 0x0008a10c, 0x0008c10c, 0x0008e10c, + 0x0009010c, 0x0009210c, 0x0009410c, 0x0009610c, + 0x0009810c, 0x0009a10c, 0x0009c10c, 0x0009e10c, + 0x000a010c, 0x000a210c, 0x000a410c, 0x000a610c, + 0x000a810c, 0x000aa10c, 0x000ac10c, 0x000ae10c, + 0x000b010c, 0x000b210c, 0x000b410c, 0x000b610c, + 0x000b810c, 0x000ba10c, 0x000bc10c, 0x000be10c, + 0x000c010c, 0x000c210c, 0x000c410c, 0x000c610c, + 0x000c810c, 0x000ca10c, 0x000cc10c, 0x000ce10c, + 0x000d010c, 0x000d210c, 0x000d410c, 0x000d610c, + 0x000d810c, 0x000da10c, 0x000dc10c, 0x000de10c, + 0x000e010c, 0x000e210c, 0x000e410c, 0x000e610c, + 0x000e810c, 0x000ea10c, 0x000ec10c, 0x000ee10c, + 0x000f010c, 0x000f210c, 0x000f410c, 0x000f610c, + 0x000f810c, 0x000fa10c, 0x000fc10c, 0x000fe10c, + 0x0000110c, 0x0000310c, 0x0000510c, 0x0000710c, + 0x0000910c, 0x0000b10c, 0x0000d10c, 0x0000f10c, + 0x0001110c, 0x0001310c, 0x0001510c, 0x0001710c, + 0x0001910c, 0x0001b10c, 0x0001d10c, 0x0001f10c, + 0x0002110c, 0x0002310c, 0x0002510c, 0x0002710c, + 0x0002910c, 0x0002b10c, 0x0002d10c, 0x0002f10c, + 0x0003110c, 0x0003310c, 0x0003510c, 0x0003710c, + 0x0003910c, 0x0003b10c, 0x0003d10c, 0x0003f10c, + 0x0004110c, 0x0004310c, 0x0004510c, 0x0004710c, + 0x0004910c, 0x0004b10c, 0x0004d10c, 0x0004f10c, + 0x0005110c, 0x0005310c, 0x0005510c, 0x0005710c, + 0x0005910c, 0x0005b10c, 0x0005d10c, 0x0005f10c, + 0x0006110c, 0x0006310c, 0x0006510c, 0x0006710c, + 0x0006910c, 0x0006b10c, 0x0006d10c, 0x0006f10c, + 0x0007110c, 0x0007310c, 0x0007510c, 0x0007710c, + 0x0007910c, 0x0007b10c, 0x0007d10c, 0x0007f10c, + 0x0008110c, 0x0008310c, 0x0008510c, 0x0008710c, + 0x0008910c, 0x0008b10c, 0x0008d10c, 0x0008f10c, + 0x0009110c, 0x0009310c, 0x0009510c, 0x0009710c, + 0x0009910c, 0x0009b10c, 0x0009d10c, 0x0009f10c, + 0x000a110c, 0x000a310c, 0x000a510c, 0x000a710c, + 0x000a910c, 0x000ab10c, 0x000ad10c, 0x000af10c, + 0x000b110c, 0x000b310c, 0x000b510c, 0x000b710c, + 0x000b910c, 0x000bb10c, 0x000bd10c, 0x000bf10c, + 0x000c110c, 0x000c310c, 0x000c510c, 0x000c710c, + 0x000c910c, 0x000cb10c, 0x000cd10c, 0x000cf10c, + 0x000d110c, 0x000d310c, 0x000d510c, 0x000d710c, + 0x000d910c, 0x000db10c, 0x000dd10c, 0x000df10c, + 0x000e110c, 0x000e310c, 0x000e510c, 0x000e710c, + 0x000e910c, 0x000eb10c, 0x000ed10c, 0x000ef10c, + 0x000f110c, 0x000f310c, 0x000f510c, 0x000f710c, + 0x000f910c, 0x000fb10c, 0x000fd10c, 0x000ff10c, + 0x0000090d, 0x0000290d, 0x0000490d, 0x0000690d, + 0x0000890d, 0x0000a90d, 0x0000c90d, 0x0000e90d, + 0x0001090d, 0x0001290d, 0x0001490d, 0x0001690d, + 0x0001890d, 0x0001a90d, 0x0001c90d, 0x0001e90d, + 0x0002090d, 0x0002290d, 0x0002490d, 0x0002690d, + 0x0002890d, 0x0002a90d, 0x0002c90d, 0x0002e90d, + 0x0003090d, 0x0003290d, 0x0003490d, 0x0003690d, + 0x0003890d, 0x0003a90d, 0x0003c90d, 0x0003e90d, + 0x0004090d, 0x0004290d, 0x0004490d, 0x0004690d, + 0x0004890d, 0x0004a90d, 0x0004c90d, 0x0004e90d, + 0x0005090d, 0x0005290d, 0x0005490d, 0x0005690d, + 0x0005890d, 0x0005a90d, 0x0005c90d, 0x0005e90d, + 0x0006090d, 0x0006290d, 0x0006490d, 0x0006690d, + 0x0006890d, 0x0006a90d, 0x0006c90d, 0x0006e90d, + 0x0007090d, 0x0007290d, 0x0007490d, 0x0007690d, + 0x0007890d, 0x0007a90d, 0x0007c90d, 0x0007e90d, + 0x0008090d, 0x0008290d, 0x0008490d, 0x0008690d, + 0x0008890d, 0x0008a90d, 0x0008c90d, 0x0008e90d, + 0x0009090d, 0x0009290d, 0x0009490d, 0x0009690d, + 0x0009890d, 0x0009a90d, 0x0009c90d, 0x0009e90d, + 0x000a090d, 0x000a290d, 0x000a490d, 0x000a690d, + 0x000a890d, 0x000aa90d, 0x000ac90d, 0x000ae90d, + 0x000b090d, 0x000b290d, 0x000b490d, 0x000b690d, + 0x000b890d, 0x000ba90d, 0x000bc90d, 0x000be90d, + 0x000c090d, 0x000c290d, 0x000c490d, 0x000c690d, + 0x000c890d, 0x000ca90d, 0x000cc90d, 0x000ce90d, + 0x000d090d, 0x000d290d, 0x000d490d, 0x000d690d, + 0x000d890d, 0x000da90d, 0x000dc90d, 0x000de90d, + 0x000e090d, 0x000e290d, 0x000e490d, 0x000e690d, + 0x000e890d, 0x000ea90d, 0x000ec90d, 0x000ee90d, + 0x000f090d, 0x000f290d, 0x000f490d, 0x000f690d, + 0x000f890d, 0x000fa90d, 0x000fc90d, 0x000fe90d, + 0x0010090d, 0x0010290d, 0x0010490d, 0x0010690d, + 0x0010890d, 0x0010a90d, 0x0010c90d, 0x0010e90d, + 0x0011090d, 0x0011290d, 0x0011490d, 0x0011690d, + 0x0011890d, 0x0011a90d, 0x0011c90d, 0x0011e90d, + 0x0012090d, 0x0012290d, 0x0012490d, 0x0012690d, + 0x0012890d, 0x0012a90d, 0x0012c90d, 0x0012e90d, + 0x0013090d, 0x0013290d, 0x0013490d, 0x0013690d, + 0x0013890d, 0x0013a90d, 0x0013c90d, 0x0013e90d, + 0x0014090d, 0x0014290d, 0x0014490d, 0x0014690d, + 0x0014890d, 0x0014a90d, 0x0014c90d, 0x0014e90d, + 0x0015090d, 0x0015290d, 0x0015490d, 0x0015690d, + 0x0015890d, 0x0015a90d, 0x0015c90d, 0x0015e90d, + 0x0016090d, 0x0016290d, 0x0016490d, 0x0016690d, + 0x0016890d, 0x0016a90d, 0x0016c90d, 0x0016e90d, + 0x0017090d, 0x0017290d, 0x0017490d, 0x0017690d, + 0x0017890d, 0x0017a90d, 0x0017c90d, 0x0017e90d, + 0x0018090d, 0x0018290d, 0x0018490d, 0x0018690d, + 0x0018890d, 0x0018a90d, 0x0018c90d, 0x0018e90d, + 0x0019090d, 0x0019290d, 0x0019490d, 0x0019690d, + 0x0019890d, 0x0019a90d, 0x0019c90d, 0x0019e90d, + 0x001a090d, 0x001a290d, 0x001a490d, 0x001a690d, + 0x001a890d, 0x001aa90d, 0x001ac90d, 0x001ae90d, + 0x001b090d, 0x001b290d, 0x001b490d, 0x001b690d, + 0x001b890d, 0x001ba90d, 0x001bc90d, 0x001be90d, + 0x001c090d, 0x001c290d, 0x001c490d, 0x001c690d, + 0x001c890d, 0x001ca90d, 0x001cc90d, 0x001ce90d, + 0x001d090d, 0x001d290d, 0x001d490d, 0x001d690d, + 0x001d890d, 0x001da90d, 0x001dc90d, 0x001de90d, + 0x001e090d, 0x001e290d, 0x001e490d, 0x001e690d, + 0x001e890d, 0x001ea90d, 0x001ec90d, 0x001ee90d, + 0x001f090d, 0x001f290d, 0x001f490d, 0x001f690d, + 0x001f890d, 0x001fa90d, 0x001fc90d, 0x001fe90d, + 0x0000190d, 0x0000390d, 0x0000590d, 0x0000790d, + 0x0000990d, 0x0000b90d, 0x0000d90d, 0x0000f90d, + 0x0001190d, 0x0001390d, 0x0001590d, 0x0001790d, + 0x0001990d, 0x0001b90d, 0x0001d90d, 0x0001f90d, + 0x0002190d, 0x0002390d, 0x0002590d, 0x0002790d, + 0x0002990d, 0x0002b90d, 0x0002d90d, 0x0002f90d, + 0x0003190d, 0x0003390d, 0x0003590d, 0x0003790d, + 0x0003990d, 0x0003b90d, 0x0003d90d, 0x0003f90d, + 0x0004190d, 0x0004390d, 0x0004590d, 0x0004790d, + 0x0004990d, 0x0004b90d, 0x0004d90d, 0x0004f90d, + 0x0005190d, 0x0005390d, 0x0005590d, 0x0005790d, + 0x0005990d, 0x0005b90d, 0x0005d90d, 0x0005f90d, + 0x0006190d, 0x0006390d, 0x0006590d, 0x0006790d, + 0x0006990d, 0x0006b90d, 0x0006d90d, 0x0006f90d, + 0x0007190d, 0x0007390d, 0x0007590d, 0x0007790d, + 0x0007990d, 0x0007b90d, 0x0007d90d, 0x0007f90d, + 0x0008190d, 0x0008390d, 0x0008590d, 0x0008790d, + 0x0008990d, 0x0008b90d, 0x0008d90d, 0x0008f90d, + 0x0009190d, 0x0009390d, 0x0009590d, 0x0009790d, + 0x0009990d, 0x0009b90d, 0x0009d90d, 0x0009f90d, + 0x000a190d, 0x000a390d, 0x000a590d, 0x000a790d, + 0x000a990d, 0x000ab90d, 0x000ad90d, 0x000af90d, + 0x000b190d, 0x000b390d, 0x000b590d, 0x000b790d, + 0x000b990d, 0x000bb90d, 0x000bd90d, 0x000bf90d, + 0x000c190d, 0x000c390d, 0x000c590d, 0x000c790d, + 0x000c990d, 0x000cb90d, 0x000cd90d, 0x000cf90d, + 0x000d190d, 0x000d390d, 0x000d590d, 0x000d790d, + 0x000d990d, 0x000db90d, 0x000dd90d, 0x000df90d, + 0x000e190d, 0x000e390d, 0x000e590d, 0x000e790d, + 0x000e990d, 0x000eb90d, 0x000ed90d, 0x000ef90d, + 0x000f190d, 0x000f390d, 0x000f590d, 0x000f790d, + 0x000f990d, 0x000fb90d, 0x000fd90d, 0x000ff90d, + 0x0010190d, 0x0010390d, 0x0010590d, 0x0010790d, + 0x0010990d, 0x0010b90d, 0x0010d90d, 0x0010f90d, + 0x0011190d, 0x0011390d, 0x0011590d, 0x0011790d, + 0x0011990d, 0x0011b90d, 0x0011d90d, 0x0011f90d, + 0x0012190d, 0x0012390d, 0x0012590d, 0x0012790d, + 0x0012990d, 0x0012b90d, 0x0012d90d, 0x0012f90d, + 0x0013190d, 0x0013390d, 0x0013590d, 0x0013790d, + 0x0013990d, 0x0013b90d, 0x0013d90d, 0x0013f90d, + 0x0014190d, 0x0014390d, 0x0014590d, 0x0014790d, + 0x0014990d, 0x0014b90d, 0x0014d90d, 0x0014f90d, + 0x0015190d, 0x0015390d, 0x0015590d, 0x0015790d, + 0x0015990d, 0x0015b90d, 0x0015d90d, 0x0015f90d, + 0x0016190d, 0x0016390d, 0x0016590d, 0x0016790d, + 0x0016990d, 0x0016b90d, 0x0016d90d, 0x0016f90d, + 0x0017190d, 0x0017390d, 0x0017590d, 0x0017790d, + 0x0017990d, 0x0017b90d, 0x0017d90d, 0x0017f90d, + 0x0018190d, 0x0018390d, 0x0018590d, 0x0018790d, + 0x0018990d, 0x0018b90d, 0x0018d90d, 0x0018f90d, + 0x0019190d, 0x0019390d, 0x0019590d, 0x0019790d, + 0x0019990d, 0x0019b90d, 0x0019d90d, 0x0019f90d, + 0x001a190d, 0x001a390d, 0x001a590d, 0x001a790d, + 0x001a990d, 0x001ab90d, 0x001ad90d, 0x001af90d, + 0x001b190d, 0x001b390d, 0x001b590d, 0x001b790d, + 0x001b990d, 0x001bb90d, 0x001bd90d, 0x001bf90d, + 0x001c190d, 0x001c390d, 0x001c590d, 0x001c790d, + 0x001c990d, 0x001cb90d, 0x001cd90d, 0x001cf90d, + 0x001d190d, 0x001d390d, 0x001d590d, 0x001d790d, + 0x001d990d, 0x001db90d, 0x001dd90d, 0x001df90d, + 0x001e190d, 0x001e390d, 0x001e590d, 0x001e790d, + 0x001e990d, 0x001eb90d, 0x001ed90d, 0x001ef90d, + 0x001f190d, 0x001f390d, 0x001f590d, 0x001f790d, + 0x001f990d, 0x001fb90d, 0x001fd90d, 0x001ff90d, + 0x0000050e, 0x0000250e, 0x0000450e, 0x0000650e, + 0x0000850e, 0x0000a50e, 0x0000c50e, 0x0000e50e, + 0x0001050e, 0x0001250e, 0x0001450e, 0x0001650e, + 0x0001850e, 0x0001a50e, 0x0001c50e, 0x0001e50e, + 0x0002050e, 0x0002250e, 0x0002450e, 0x0002650e, + 0x0002850e, 0x0002a50e, 0x0002c50e, 0x0002e50e, + 0x0003050e, 0x0003250e, 0x0003450e, 0x0003650e, + 0x0003850e, 0x0003a50e, 0x0003c50e, 0x0003e50e, + 0x0004050e, 0x0004250e, 0x0004450e, 0x0004650e, + 0x0004850e, 0x0004a50e, 0x0004c50e, 0x0004e50e, + 0x0005050e, 0x0005250e, 0x0005450e, 0x0005650e, + 0x0005850e, 0x0005a50e, 0x0005c50e, 0x0005e50e, + 0x0006050e, 0x0006250e, 0x0006450e, 0x0006650e, + 0x0006850e, 0x0006a50e, 0x0006c50e, 0x0006e50e, + 0x0007050e, 0x0007250e, 0x0007450e, 0x0007650e, + 0x0007850e, 0x0007a50e, 0x0007c50e, 0x0007e50e, + 0x0008050e, 0x0008250e, 0x0008450e, 0x0008650e, + 0x0008850e, 0x0008a50e, 0x0008c50e, 0x0008e50e, + 0x0009050e, 0x0009250e, 0x0009450e, 0x0009650e, + 0x0009850e, 0x0009a50e, 0x0009c50e, 0x0009e50e, + 0x000a050e, 0x000a250e, 0x000a450e, 0x000a650e, + 0x000a850e, 0x000aa50e, 0x000ac50e, 0x000ae50e, + 0x000b050e, 0x000b250e, 0x000b450e, 0x000b650e, + 0x000b850e, 0x000ba50e, 0x000bc50e, 0x000be50e, + 0x000c050e, 0x000c250e, 0x000c450e, 0x000c650e, + 0x000c850e, 0x000ca50e, 0x000cc50e, 0x000ce50e, + 0x000d050e, 0x000d250e, 0x000d450e, 0x000d650e, + 0x000d850e, 0x000da50e, 0x000dc50e, 0x000de50e, + 0x000e050e, 0x000e250e, 0x000e450e, 0x000e650e, + 0x000e850e, 0x000ea50e, 0x000ec50e, 0x000ee50e, + 0x000f050e, 0x000f250e, 0x000f450e, 0x000f650e, + 0x000f850e, 0x000fa50e, 0x000fc50e, 0x000fe50e, + 0x0010050e, 0x0010250e, 0x0010450e, 0x0010650e, + 0x0010850e, 0x0010a50e, 0x0010c50e, 0x0010e50e, + 0x0011050e, 0x0011250e, 0x0011450e, 0x0011650e, + 0x0011850e, 0x0011a50e, 0x0011c50e, 0x0011e50e, + 0x0012050e, 0x0012250e, 0x0012450e, 0x0012650e, + 0x0012850e, 0x0012a50e, 0x0012c50e, 0x0012e50e, + 0x0013050e, 0x0013250e, 0x0013450e, 0x0013650e, + 0x0013850e, 0x0013a50e, 0x0013c50e, 0x0013e50e, + 0x0014050e, 0x0014250e, 0x0014450e, 0x0014650e, + 0x0014850e, 0x0014a50e, 0x0014c50e, 0x0014e50e, + 0x0015050e, 0x0015250e, 0x0015450e, 0x0015650e, + 0x0015850e, 0x0015a50e, 0x0015c50e, 0x0015e50e, + 0x0016050e, 0x0016250e, 0x0016450e, 0x0016650e, + 0x0016850e, 0x0016a50e, 0x0016c50e, 0x0016e50e, + 0x0017050e, 0x0017250e, 0x0017450e, 0x0017650e, + 0x0017850e, 0x0017a50e, 0x0017c50e, 0x0017e50e, + 0x0018050e, 0x0018250e, 0x0018450e, 0x0018650e, + 0x0018850e, 0x0018a50e, 0x0018c50e, 0x0018e50e, + 0x0019050e, 0x0019250e, 0x0019450e, 0x0019650e, + 0x0019850e, 0x0019a50e, 0x0019c50e, 0x0019e50e, + 0x001a050e, 0x001a250e, 0x001a450e, 0x001a650e, + 0x001a850e, 0x001aa50e, 0x001ac50e, 0x001ae50e, + 0x001b050e, 0x001b250e, 0x001b450e, 0x001b650e, + 0x001b850e, 0x001ba50e, 0x001bc50e, 0x001be50e, + 0x001c050e, 0x001c250e, 0x001c450e, 0x001c650e, + 0x001c850e, 0x001ca50e, 0x001cc50e, 0x001ce50e, + 0x001d050e, 0x001d250e, 0x001d450e, 0x001d650e, + 0x001d850e, 0x001da50e, 0x001dc50e, 0x001de50e, + 0x001e050e, 0x001e250e, 0x001e450e, 0x001e650e, + 0x001e850e, 0x001ea50e, 0x001ec50e, 0x001ee50e, + 0x001f050e, 0x001f250e, 0x001f450e, 0x001f650e, + 0x001f850e, 0x001fa50e, 0x001fc50e, 0x001fe50e, + 0x0020050e, 0x0020250e, 0x0020450e, 0x0020650e, + 0x0020850e, 0x0020a50e, 0x0020c50e, 0x0020e50e, + 0x0021050e, 0x0021250e, 0x0021450e, 0x0021650e, + 0x0021850e, 0x0021a50e, 0x0021c50e, 0x0021e50e, + 0x0022050e, 0x0022250e, 0x0022450e, 0x0022650e, + 0x0022850e, 0x0022a50e, 0x0022c50e, 0x0022e50e, + 0x0023050e, 0x0023250e, 0x0023450e, 0x0023650e, + 0x0023850e, 0x0023a50e, 0x0023c50e, 0x0023e50e, + 0x0024050e, 0x0024250e, 0x0024450e, 0x0024650e, + 0x0024850e, 0x0024a50e, 0x0024c50e, 0x0024e50e, + 0x0025050e, 0x0025250e, 0x0025450e, 0x0025650e, + 0x0025850e, 0x0025a50e, 0x0025c50e, 0x0025e50e, + 0x0026050e, 0x0026250e, 0x0026450e, 0x0026650e, + 0x0026850e, 0x0026a50e, 0x0026c50e, 0x0026e50e, + 0x0027050e, 0x0027250e, 0x0027450e, 0x0027650e, + 0x0027850e, 0x0027a50e, 0x0027c50e, 0x0027e50e, + 0x0028050e, 0x0028250e, 0x0028450e, 0x0028650e, + 0x0028850e, 0x0028a50e, 0x0028c50e, 0x0028e50e, + 0x0029050e, 0x0029250e, 0x0029450e, 0x0029650e, + 0x0029850e, 0x0029a50e, 0x0029c50e, 0x0029e50e, + 0x002a050e, 0x002a250e, 0x002a450e, 0x002a650e, + 0x002a850e, 0x002aa50e, 0x002ac50e, 0x002ae50e, + 0x002b050e, 0x002b250e, 0x002b450e, 0x002b650e, + 0x002b850e, 0x002ba50e, 0x002bc50e, 0x002be50e, + 0x002c050e, 0x002c250e, 0x002c450e, 0x002c650e, + 0x002c850e, 0x002ca50e, 0x002cc50e, 0x002ce50e, + 0x002d050e, 0x002d250e, 0x002d450e, 0x002d650e, + 0x002d850e, 0x002da50e, 0x002dc50e, 0x002de50e, + 0x002e050e, 0x002e250e, 0x002e450e, 0x002e650e, + 0x002e850e, 0x002ea50e, 0x002ec50e, 0x002ee50e, + 0x002f050e, 0x002f250e, 0x002f450e, 0x002f650e, + 0x002f850e, 0x002fa50e, 0x002fc50e, 0x002fe50e, + 0x0030050e, 0x0030250e, 0x0030450e, 0x0030650e, + 0x0030850e, 0x0030a50e, 0x0030c50e, 0x0030e50e, + 0x0031050e, 0x0031250e, 0x0031450e, 0x0031650e, + 0x0031850e, 0x0031a50e, 0x0031c50e, 0x0031e50e, + 0x0032050e, 0x0032250e, 0x0032450e, 0x0032650e, + 0x0032850e, 0x0032a50e, 0x0032c50e, 0x0032e50e, + 0x0033050e, 0x0033250e, 0x0033450e, 0x0033650e, + 0x0033850e, 0x0033a50e, 0x0033c50e, 0x0033e50e, + 0x0034050e, 0x0034250e, 0x0034450e, 0x0034650e, + 0x0034850e, 0x0034a50e, 0x0034c50e, 0x0034e50e, + 0x0035050e, 0x0035250e, 0x0035450e, 0x0035650e, + 0x0035850e, 0x0035a50e, 0x0035c50e, 0x0035e50e, + 0x0036050e, 0x0036250e, 0x0036450e, 0x0036650e, + 0x0036850e, 0x0036a50e, 0x0036c50e, 0x0036e50e, + 0x0037050e, 0x0037250e, 0x0037450e, 0x0037650e, + 0x0037850e, 0x0037a50e, 0x0037c50e, 0x0037e50e, + 0x0038050e, 0x0038250e, 0x0038450e, 0x0038650e, + 0x0038850e, 0x0038a50e, 0x0038c50e, 0x0038e50e, + 0x0039050e, 0x0039250e, 0x0039450e, 0x0039650e, + 0x0039850e, 0x0039a50e, 0x0039c50e, 0x0039e50e, + 0x003a050e, 0x003a250e, 0x003a450e, 0x003a650e, + 0x003a850e, 0x003aa50e, 0x003ac50e, 0x003ae50e, + 0x003b050e, 0x003b250e, 0x003b450e, 0x003b650e, + 0x003b850e, 0x003ba50e, 0x003bc50e, 0x003be50e, + 0x003c050e, 0x003c250e, 0x003c450e, 0x003c650e, + 0x003c850e, 0x003ca50e, 0x003cc50e, 0x003ce50e, + 0x003d050e, 0x003d250e, 0x003d450e, 0x003d650e, + 0x003d850e, 0x003da50e, 0x003dc50e, 0x003de50e, + 0x003e050e, 0x003e250e, 0x003e450e, 0x003e650e, + 0x003e850e, 0x003ea50e, 0x003ec50e, 0x003ee50e, + 0x003f050e, 0x003f250e, 0x003f450e, 0x003f650e, + 0x003f850e, 0x003fa50e, 0x003fc50e, 0x003fe50e, + 0x0000150e, 0x0000350e, 0x0000550e, 0x0000750e, + 0x0000950e, 0x0000b50e, 0x0000d50e, 0x0000f50e, + 0x0001150e, 0x0001350e, 0x0001550e, 0x0001750e, + 0x0001950e, 0x0001b50e, 0x0001d50e, 0x0001f50e, + 0x0002150e, 0x0002350e, 0x0002550e, 0x0002750e, + 0x0002950e, 0x0002b50e, 0x0002d50e, 0x0002f50e, + 0x0003150e, 0x0003350e, 0x0003550e, 0x0003750e, + 0x0003950e, 0x0003b50e, 0x0003d50e, 0x0003f50e, + 0x0004150e, 0x0004350e, 0x0004550e, 0x0004750e, + 0x0004950e, 0x0004b50e, 0x0004d50e, 0x0004f50e, + 0x0005150e, 0x0005350e, 0x0005550e, 0x0005750e, + 0x0005950e, 0x0005b50e, 0x0005d50e, 0x0005f50e, + 0x0006150e, 0x0006350e, 0x0006550e, 0x0006750e, + 0x0006950e, 0x0006b50e, 0x0006d50e, 0x0006f50e, + 0x0007150e, 0x0007350e, 0x0007550e, 0x0007750e, + 0x0007950e, 0x0007b50e, 0x0007d50e, 0x0007f50e, + 0x0008150e, 0x0008350e, 0x0008550e, 0x0008750e, + 0x0008950e, 0x0008b50e, 0x0008d50e, 0x0008f50e, + 0x0009150e, 0x0009350e, 0x0009550e, 0x0009750e, + 0x0009950e, 0x0009b50e, 0x0009d50e, 0x0009f50e, + 0x000a150e, 0x000a350e, 0x000a550e, 0x000a750e, + 0x000a950e, 0x000ab50e, 0x000ad50e, 0x000af50e, + 0x000b150e, 0x000b350e, 0x000b550e, 0x000b750e, + 0x000b950e, 0x000bb50e, 0x000bd50e, 0x000bf50e, + 0x000c150e, 0x000c350e, 0x000c550e, 0x000c750e, + 0x000c950e, 0x000cb50e, 0x000cd50e, 0x000cf50e, + 0x000d150e, 0x000d350e, 0x000d550e, 0x000d750e, + 0x000d950e, 0x000db50e, 0x000dd50e, 0x000df50e, + 0x000e150e, 0x000e350e, 0x000e550e, 0x000e750e, + 0x000e950e, 0x000eb50e, 0x000ed50e, 0x000ef50e, + 0x000f150e, 0x000f350e, 0x000f550e, 0x000f750e, + 0x000f950e, 0x000fb50e, 0x000fd50e, 0x000ff50e, + 0x0010150e, 0x0010350e, 0x0010550e, 0x0010750e, + 0x0010950e, 0x0010b50e, 0x0010d50e, 0x0010f50e, + 0x0011150e, 0x0011350e, 0x0011550e, 0x0011750e, + 0x0011950e, 0x0011b50e, 0x0011d50e, 0x0011f50e, + 0x0012150e, 0x0012350e, 0x0012550e, 0x0012750e, + 0x0012950e, 0x0012b50e, 0x0012d50e, 0x0012f50e, + 0x0013150e, 0x0013350e, 0x0013550e, 0x0013750e, + 0x0013950e, 0x0013b50e, 0x0013d50e, 0x0013f50e, + 0x0014150e, 0x0014350e, 0x0014550e, 0x0014750e, + 0x0014950e, 0x0014b50e, 0x0014d50e, 0x0014f50e, + 0x0015150e, 0x0015350e, 0x0015550e, 0x0015750e, + 0x0015950e, 0x0015b50e, 0x0015d50e, 0x0015f50e, + 0x0016150e, 0x0016350e, 0x0016550e, 0x0016750e, + 0x0016950e, 0x0016b50e, 0x0016d50e, 0x0016f50e, + 0x0017150e, 0x0017350e, 0x0017550e, 0x0017750e, + 0x0017950e, 0x0017b50e, 0x0017d50e, 0x0017f50e, + 0x0018150e, 0x0018350e, 0x0018550e, 0x0018750e, + 0x0018950e, 0x0018b50e, 0x0018d50e, 0x0018f50e, + 0x0019150e, 0x0019350e, 0x0019550e, 0x0019750e, + 0x0019950e, 0x0019b50e, 0x0019d50e, 0x0019f50e, + 0x001a150e, 0x001a350e, 0x001a550e, 0x001a750e, + 0x001a950e, 0x001ab50e, 0x001ad50e, 0x001af50e, + 0x001b150e, 0x001b350e, 0x001b550e, 0x001b750e, + 0x001b950e, 0x001bb50e, 0x001bd50e, 0x001bf50e, + 0x001c150e, 0x001c350e, 0x001c550e, 0x001c750e, + 0x001c950e, 0x001cb50e, 0x001cd50e, 0x001cf50e, + 0x001d150e, 0x001d350e, 0x001d550e, 0x001d750e, + 0x001d950e, 0x001db50e, 0x001dd50e, 0x001df50e, + 0x001e150e, 0x001e350e, 0x001e550e, 0x001e750e, + 0x001e950e, 0x001eb50e, 0x001ed50e, 0x001ef50e, + 0x001f150e, 0x001f350e, 0x001f550e, 0x001f750e, + 0x001f950e, 0x001fb50e, 0x001fd50e, 0x001ff50e, + 0x0020150e, 0x0020350e, 0x0020550e, 0x0020750e, + 0x0020950e, 0x0020b50e, 0x0020d50e, 0x0020f50e, + 0x0021150e, 0x0021350e, 0x0021550e, 0x0021750e, + 0x0021950e, 0x0021b50e, 0x0021d50e, 0x0021f50e, + 0x0022150e, 0x0022350e, 0x0022550e, 0x0022750e, + 0x0022950e, 0x0022b50e, 0x0022d50e, 0x0022f50e, + 0x0023150e, 0x0023350e, 0x0023550e, 0x0023750e, + 0x0023950e, 0x0023b50e, 0x0023d50e, 0x0023f50e, + 0x0024150e, 0x0024350e, 0x0024550e, 0x0024750e, + 0x0024950e, 0x0024b50e, 0x0024d50e, 0x0024f50e, + 0x0025150e, 0x0025350e, 0x0025550e, 0x0025750e, + 0x0025950e, 0x0025b50e, 0x0025d50e, 0x0025f50e, + 0x0026150e, 0x0026350e, 0x0026550e, 0x0026750e, + 0x0026950e, 0x0026b50e, 0x0026d50e, 0x0026f50e, + 0x0027150e, 0x0027350e, 0x0027550e, 0x0027750e, + 0x0027950e, 0x0027b50e, 0x0027d50e, 0x0027f50e, + 0x0028150e, 0x0028350e, 0x0028550e, 0x0028750e, + 0x0028950e, 0x0028b50e, 0x0028d50e, 0x0028f50e, + 0x0029150e, 0x0029350e, 0x0029550e, 0x0029750e, + 0x0029950e, 0x0029b50e, 0x0029d50e, 0x0029f50e, + 0x002a150e, 0x002a350e, 0x002a550e, 0x002a750e, + 0x002a950e, 0x002ab50e, 0x002ad50e, 0x002af50e, + 0x002b150e, 0x002b350e, 0x002b550e, 0x002b750e, + 0x002b950e, 0x002bb50e, 0x002bd50e, 0x002bf50e, + 0x002c150e, 0x002c350e, 0x002c550e, 0x002c750e, + 0x002c950e, 0x002cb50e, 0x002cd50e, 0x002cf50e, + 0x002d150e, 0x002d350e, 0x002d550e, 0x002d750e, + 0x002d950e, 0x002db50e, 0x002dd50e, 0x002df50e, + 0x002e150e, 0x002e350e, 0x002e550e, 0x002e750e, + 0x002e950e, 0x002eb50e, 0x002ed50e, 0x002ef50e, + 0x002f150e, 0x002f350e, 0x002f550e, 0x002f750e, + 0x002f950e, 0x002fb50e, 0x002fd50e, 0x002ff50e, + 0x0030150e, 0x0030350e, 0x0030550e, 0x0030750e, + 0x0030950e, 0x0030b50e, 0x0030d50e, 0x0030f50e, + 0x0031150e, 0x0031350e, 0x0031550e, 0x0031750e, + 0x0031950e, 0x0031b50e, 0x0031d50e, 0x0031f50e, + 0x0032150e, 0x0032350e, 0x0032550e, 0x0032750e, + 0x0032950e, 0x0032b50e, 0x0032d50e, 0x0032f50e, + 0x0033150e, 0x0033350e, 0x0033550e, 0x0033750e, + 0x0033950e, 0x0033b50e, 0x0033d50e, 0x0033f50e, + 0x0034150e, 0x0034350e, 0x0034550e, 0x0034750e, + 0x0034950e, 0x0034b50e, 0x0034d50e, 0x0034f50e, + 0x0035150e, 0x0035350e, 0x0035550e, 0x0035750e, + 0x0035950e, 0x0035b50e, 0x0035d50e, 0x0035f50e, + 0x0036150e, 0x0036350e, 0x0036550e, 0x0036750e, + 0x0036950e, 0x0036b50e, 0x0036d50e, 0x0036f50e, + 0x0037150e, 0x0037350e, 0x0037550e, 0x0037750e, + 0x0037950e, 0x0037b50e, 0x0037d50e, 0x0037f50e, + 0x0038150e, 0x0038350e, 0x0038550e, 0x0038750e, + 0x0038950e, 0x0038b50e, 0x0038d50e, 0x0038f50e, + 0x0039150e, 0x0039350e, 0x0039550e, 0x0039750e, + 0x0039950e, 0x0039b50e, 0x0039d50e, 0x0039f50e, + 0x003a150e, 0x003a350e, 0x003a550e, 0x003a750e, + 0x003a950e, 0x003ab50e, 0x003ad50e, 0x003af50e, + 0x003b150e, 0x003b350e, 0x003b550e, 0x003b750e, + 0x003b950e, 0x003bb50e, 0x003bd50e, 0x003bf50e, + 0x003c150e, 0x003c350e, 0x003c550e, 0x003c750e, + 0x003c950e, 0x003cb50e, 0x003cd50e, 0x003cf50e, + 0x003d150e, 0x003d350e, 0x003d550e, 0x003d750e, + 0x003d950e, 0x003db50e, 0x003dd50e, 0x003df50e, + 0x003e150e, 0x003e350e, 0x003e550e, 0x003e750e, + 0x003e950e, 0x003eb50e, 0x003ed50e, 0x003ef50e, + 0x003f150e, 0x003f350e, 0x003f550e, 0x003f750e, + 0x003f950e, 0x003fb50e, 0x003fd50e, 0x003ff50e, + 0x00000d0f, 0x00002d0f, 0x00004d0f, 0x00006d0f, + 0x00008d0f, 0x0000ad0f, 0x0000cd0f, 0x0000ed0f, + 0x00010d0f, 0x00012d0f, 0x00014d0f, 0x00016d0f, + 0x00018d0f, 0x0001ad0f, 0x0001cd0f, 0x0001ed0f, + 0x00020d0f, 0x00022d0f, 0x00024d0f, 0x00026d0f, + 0x00028d0f, 0x0002ad0f, 0x0002cd0f, 0x0002ed0f, + 0x00030d0f, 0x00032d0f, 0x00034d0f, 0x00036d0f, + 0x00038d0f, 0x0003ad0f, 0x0003cd0f, 0x0003ed0f, + 0x00040d0f, 0x00042d0f, 0x00044d0f, 0x00046d0f, + 0x00048d0f, 0x0004ad0f, 0x0004cd0f, 0x0004ed0f, + 0x00050d0f, 0x00052d0f, 0x00054d0f, 0x00056d0f, + 0x00058d0f, 0x0005ad0f, 0x0005cd0f, 0x0005ed0f, + 0x00060d0f, 0x00062d0f, 0x00064d0f, 0x00066d0f, + 0x00068d0f, 0x0006ad0f, 0x0006cd0f, 0x0006ed0f, + 0x00070d0f, 0x00072d0f, 0x00074d0f, 0x00076d0f, + 0x00078d0f, 0x0007ad0f, 0x0007cd0f, 0x0007ed0f, + 0x00080d0f, 0x00082d0f, 0x00084d0f, 0x00086d0f, + 0x00088d0f, 0x0008ad0f, 0x0008cd0f, 0x0008ed0f, + 0x00090d0f, 0x00092d0f, 0x00094d0f, 0x00096d0f, + 0x00098d0f, 0x0009ad0f, 0x0009cd0f, 0x0009ed0f, + 0x000a0d0f, 0x000a2d0f, 0x000a4d0f, 0x000a6d0f, + 0x000a8d0f, 0x000aad0f, 0x000acd0f, 0x000aed0f, + 0x000b0d0f, 0x000b2d0f, 0x000b4d0f, 0x000b6d0f, + 0x000b8d0f, 0x000bad0f, 0x000bcd0f, 0x000bed0f, + 0x000c0d0f, 0x000c2d0f, 0x000c4d0f, 0x000c6d0f, + 0x000c8d0f, 0x000cad0f, 0x000ccd0f, 0x000ced0f, + 0x000d0d0f, 0x000d2d0f, 0x000d4d0f, 0x000d6d0f, + 0x000d8d0f, 0x000dad0f, 0x000dcd0f, 0x000ded0f, + 0x000e0d0f, 0x000e2d0f, 0x000e4d0f, 0x000e6d0f, + 0x000e8d0f, 0x000ead0f, 0x000ecd0f, 0x000eed0f, + 0x000f0d0f, 0x000f2d0f, 0x000f4d0f, 0x000f6d0f, + 0x000f8d0f, 0x000fad0f, 0x000fcd0f, 0x000fed0f, + 0x00100d0f, 0x00102d0f, 0x00104d0f, 0x00106d0f, + 0x00108d0f, 0x0010ad0f, 0x0010cd0f, 0x0010ed0f, + 0x00110d0f, 0x00112d0f, 0x00114d0f, 0x00116d0f, + 0x00118d0f, 0x0011ad0f, 0x0011cd0f, 0x0011ed0f, + 0x00120d0f, 0x00122d0f, 0x00124d0f, 0x00126d0f, + 0x00128d0f, 0x0012ad0f, 0x0012cd0f, 0x0012ed0f, + 0x00130d0f, 0x00132d0f, 0x00134d0f, 0x00136d0f, + 0x00138d0f, 0x0013ad0f, 0x0013cd0f, 0x0013ed0f, + 0x00140d0f, 0x00142d0f, 0x00144d0f, 0x00146d0f, + 0x00148d0f, 0x0014ad0f, 0x0014cd0f, 0x0014ed0f, + 0x00150d0f, 0x00152d0f, 0x00154d0f, 0x00156d0f, + 0x00158d0f, 0x0015ad0f, 0x0015cd0f, 0x0015ed0f, + 0x00160d0f, 0x00162d0f, 0x00164d0f, 0x00166d0f, + 0x00168d0f, 0x0016ad0f, 0x0016cd0f, 0x0016ed0f, + 0x00170d0f, 0x00172d0f, 0x00174d0f, 0x00176d0f, + 0x00178d0f, 0x0017ad0f, 0x0017cd0f, 0x0017ed0f, + 0x00180d0f, 0x00182d0f, 0x00184d0f, 0x00186d0f, + 0x00188d0f, 0x0018ad0f, 0x0018cd0f, 0x0018ed0f, + 0x00190d0f, 0x00192d0f, 0x00194d0f, 0x00196d0f, + 0x00198d0f, 0x0019ad0f, 0x0019cd0f, 0x0019ed0f, + 0x001a0d0f, 0x001a2d0f, 0x001a4d0f, 0x001a6d0f, + 0x001a8d0f, 0x001aad0f, 0x001acd0f, 0x001aed0f, + 0x001b0d0f, 0x001b2d0f, 0x001b4d0f, 0x001b6d0f, + 0x001b8d0f, 0x001bad0f, 0x001bcd0f, 0x001bed0f, + 0x001c0d0f, 0x001c2d0f, 0x001c4d0f, 0x001c6d0f, + 0x001c8d0f, 0x001cad0f, 0x001ccd0f, 0x001ced0f, + 0x001d0d0f, 0x001d2d0f, 0x001d4d0f, 0x001d6d0f, + 0x001d8d0f, 0x001dad0f, 0x001dcd0f, 0x001ded0f, + 0x001e0d0f, 0x001e2d0f, 0x001e4d0f, 0x001e6d0f, + 0x001e8d0f, 0x001ead0f, 0x001ecd0f, 0x001eed0f, + 0x001f0d0f, 0x001f2d0f, 0x001f4d0f, 0x001f6d0f, + 0x001f8d0f, 0x001fad0f, 0x001fcd0f, 0x001fed0f, + 0x00200d0f, 0x00202d0f, 0x00204d0f, 0x00206d0f, + 0x00208d0f, 0x0020ad0f, 0x0020cd0f, 0x0020ed0f, + 0x00210d0f, 0x00212d0f, 0x00214d0f, 0x00216d0f, + 0x00218d0f, 0x0021ad0f, 0x0021cd0f, 0x0021ed0f, + 0x00220d0f, 0x00222d0f, 0x00224d0f, 0x00226d0f, + 0x00228d0f, 0x0022ad0f, 0x0022cd0f, 0x0022ed0f, + 0x00230d0f, 0x00232d0f, 0x00234d0f, 0x00236d0f, + 0x00238d0f, 0x0023ad0f, 0x0023cd0f, 0x0023ed0f, + 0x00240d0f, 0x00242d0f, 0x00244d0f, 0x00246d0f, + 0x00248d0f, 0x0024ad0f, 0x0024cd0f, 0x0024ed0f, + 0x00250d0f, 0x00252d0f, 0x00254d0f, 0x00256d0f, + 0x00258d0f, 0x0025ad0f, 0x0025cd0f, 0x0025ed0f, + 0x00260d0f, 0x00262d0f, 0x00264d0f, 0x00266d0f, + 0x00268d0f, 0x0026ad0f, 0x0026cd0f, 0x0026ed0f, + 0x00270d0f, 0x00272d0f, 0x00274d0f, 0x00276d0f, + 0x00278d0f, 0x0027ad0f, 0x0027cd0f, 0x0027ed0f, + 0x00280d0f, 0x00282d0f, 0x00284d0f, 0x00286d0f, + 0x00288d0f, 0x0028ad0f, 0x0028cd0f, 0x0028ed0f, + 0x00290d0f, 0x00292d0f, 0x00294d0f, 0x00296d0f, + 0x00298d0f, 0x0029ad0f, 0x0029cd0f, 0x0029ed0f, + 0x002a0d0f, 0x002a2d0f, 0x002a4d0f, 0x002a6d0f, + 0x002a8d0f, 0x002aad0f, 0x002acd0f, 0x002aed0f, + 0x002b0d0f, 0x002b2d0f, 0x002b4d0f, 0x002b6d0f, + 0x002b8d0f, 0x002bad0f, 0x002bcd0f, 0x002bed0f, + 0x002c0d0f, 0x002c2d0f, 0x002c4d0f, 0x002c6d0f, + 0x002c8d0f, 0x002cad0f, 0x002ccd0f, 0x002ced0f, + 0x002d0d0f, 0x002d2d0f, 0x002d4d0f, 0x002d6d0f, + 0x002d8d0f, 0x002dad0f, 0x002dcd0f, 0x002ded0f, + 0x002e0d0f, 0x002e2d0f, 0x002e4d0f, 0x002e6d0f, + 0x002e8d0f, 0x002ead0f, 0x002ecd0f, 0x002eed0f, + 0x002f0d0f, 0x002f2d0f, 0x002f4d0f, 0x002f6d0f, + 0x002f8d0f, 0x002fad0f, 0x002fcd0f, 0x002fed0f, + 0x00300d0f, 0x00302d0f, 0x00304d0f, 0x00306d0f, + 0x00308d0f, 0x0030ad0f, 0x0030cd0f, 0x0030ed0f, + 0x00310d0f, 0x00312d0f, 0x00314d0f, 0x00316d0f, + 0x00318d0f, 0x0031ad0f, 0x0031cd0f, 0x0031ed0f, + 0x00320d0f, 0x00322d0f, 0x00324d0f, 0x00326d0f, + 0x00328d0f, 0x0032ad0f, 0x0032cd0f, 0x0032ed0f, + 0x00330d0f, 0x00332d0f, 0x00334d0f, 0x00336d0f, + 0x00338d0f, 0x0033ad0f, 0x0033cd0f, 0x0033ed0f, + 0x00340d0f, 0x00342d0f, 0x00344d0f, 0x00346d0f, + 0x00348d0f, 0x0034ad0f, 0x0034cd0f, 0x0034ed0f, + 0x00350d0f, 0x00352d0f, 0x00354d0f, 0x00356d0f, + 0x00358d0f, 0x0035ad0f, 0x0035cd0f, 0x0035ed0f, + 0x00360d0f, 0x00362d0f, 0x00364d0f, 0x00366d0f, + 0x00368d0f, 0x0036ad0f, 0x0036cd0f, 0x0036ed0f, + 0x00370d0f, 0x00372d0f, 0x00374d0f, 0x00376d0f, + 0x00378d0f, 0x0037ad0f, 0x0037cd0f, 0x0037ed0f, + 0x00380d0f, 0x00382d0f, 0x00384d0f, 0x00386d0f, + 0x00388d0f, 0x0038ad0f, 0x0038cd0f, 0x0038ed0f, + 0x00390d0f, 0x00392d0f, 0x00394d0f, 0x00396d0f, + 0x00398d0f, 0x0039ad0f, 0x0039cd0f, 0x0039ed0f, + 0x003a0d0f, 0x003a2d0f, 0x003a4d0f, 0x003a6d0f, + 0x003a8d0f, 0x003aad0f, 0x003acd0f, 0x003aed0f, + 0x003b0d0f, 0x003b2d0f, 0x003b4d0f, 0x003b6d0f, + 0x003b8d0f, 0x003bad0f, 0x003bcd0f, 0x003bed0f, + 0x003c0d0f, 0x003c2d0f, 0x003c4d0f, 0x003c6d0f, + 0x003c8d0f, 0x003cad0f, 0x003ccd0f, 0x003ced0f, + 0x003d0d0f, 0x003d2d0f, 0x003d4d0f, 0x003d6d0f, + 0x003d8d0f, 0x003dad0f, 0x003dcd0f, 0x003ded0f, + 0x003e0d0f, 0x003e2d0f, 0x003e4d0f, 0x003e6d0f, + 0x003e8d0f, 0x003ead0f, 0x003ecd0f, 0x003eed0f, + 0x003f0d0f, 0x003f2d0f, 0x003f4d0f, 0x003f6d0f, + 0x003f8d0f, 0x003fad0f, 0x003fcd0f, 0x003fed0f, + 0x00400d0f, 0x00402d0f, 0x00404d0f, 0x00406d0f, + 0x00408d0f, 0x0040ad0f, 0x0040cd0f, 0x0040ed0f, + 0x00410d0f, 0x00412d0f, 0x00414d0f, 0x00416d0f, + 0x00418d0f, 0x0041ad0f, 0x0041cd0f, 0x0041ed0f, + 0x00420d0f, 0x00422d0f, 0x00424d0f, 0x00426d0f, + 0x00428d0f, 0x0042ad0f, 0x0042cd0f, 0x0042ed0f, + 0x00430d0f, 0x00432d0f, 0x00434d0f, 0x00436d0f, + 0x00438d0f, 0x0043ad0f, 0x0043cd0f, 0x0043ed0f, + 0x00440d0f, 0x00442d0f, 0x00444d0f, 0x00446d0f, + 0x00448d0f, 0x0044ad0f, 0x0044cd0f, 0x0044ed0f, + 0x00450d0f, 0x00452d0f, 0x00454d0f, 0x00456d0f, + 0x00458d0f, 0x0045ad0f, 0x0045cd0f, 0x0045ed0f, + 0x00460d0f, 0x00462d0f, 0x00464d0f, 0x00466d0f, + 0x00468d0f, 0x0046ad0f, 0x0046cd0f, 0x0046ed0f, + 0x00470d0f, 0x00472d0f, 0x00474d0f, 0x00476d0f, + 0x00478d0f, 0x0047ad0f, 0x0047cd0f, 0x0047ed0f, + 0x00480d0f, 0x00482d0f, 0x00484d0f, 0x00486d0f, + 0x00488d0f, 0x0048ad0f, 0x0048cd0f, 0x0048ed0f, + 0x00490d0f, 0x00492d0f, 0x00494d0f, 0x00496d0f, + 0x00498d0f, 0x0049ad0f, 0x0049cd0f, 0x0049ed0f, + 0x004a0d0f, 0x004a2d0f, 0x004a4d0f, 0x004a6d0f, + 0x004a8d0f, 0x004aad0f, 0x004acd0f, 0x004aed0f, + 0x004b0d0f, 0x004b2d0f, 0x004b4d0f, 0x004b6d0f, + 0x004b8d0f, 0x004bad0f, 0x004bcd0f, 0x004bed0f, + 0x004c0d0f, 0x004c2d0f, 0x004c4d0f, 0x004c6d0f, + 0x004c8d0f, 0x004cad0f, 0x004ccd0f, 0x004ced0f, + 0x004d0d0f, 0x004d2d0f, 0x004d4d0f, 0x004d6d0f, + 0x004d8d0f, 0x004dad0f, 0x004dcd0f, 0x004ded0f, + 0x004e0d0f, 0x004e2d0f, 0x004e4d0f, 0x004e6d0f, + 0x004e8d0f, 0x004ead0f, 0x004ecd0f, 0x004eed0f, + 0x004f0d0f, 0x004f2d0f, 0x004f4d0f, 0x004f6d0f, + 0x004f8d0f, 0x004fad0f, 0x004fcd0f, 0x004fed0f, + 0x00500d0f, 0x00502d0f, 0x00504d0f, 0x00506d0f, + 0x00508d0f, 0x0050ad0f, 0x0050cd0f, 0x0050ed0f, + 0x00510d0f, 0x00512d0f, 0x00514d0f, 0x00516d0f, + 0x00518d0f, 0x0051ad0f, 0x0051cd0f, 0x0051ed0f, + 0x00520d0f, 0x00522d0f, 0x00524d0f, 0x00526d0f, + 0x00528d0f, 0x0052ad0f, 0x0052cd0f, 0x0052ed0f, + 0x00530d0f, 0x00532d0f, 0x00534d0f, 0x00536d0f, + 0x00538d0f, 0x0053ad0f, 0x0053cd0f, 0x0053ed0f, + 0x00540d0f, 0x00542d0f, 0x00544d0f, 0x00546d0f, + 0x00548d0f, 0x0054ad0f, 0x0054cd0f, 0x0054ed0f, + 0x00550d0f, 0x00552d0f, 0x00554d0f, 0x00556d0f, + 0x00558d0f, 0x0055ad0f, 0x0055cd0f, 0x0055ed0f, + 0x00560d0f, 0x00562d0f, 0x00564d0f, 0x00566d0f, + 0x00568d0f, 0x0056ad0f, 0x0056cd0f, 0x0056ed0f, + 0x00570d0f, 0x00572d0f, 0x00574d0f, 0x00576d0f, + 0x00578d0f, 0x0057ad0f, 0x0057cd0f, 0x0057ed0f, + 0x00580d0f, 0x00582d0f, 0x00584d0f, 0x00586d0f, + 0x00588d0f, 0x0058ad0f, 0x0058cd0f, 0x0058ed0f, + 0x00590d0f, 0x00592d0f, 0x00594d0f, 0x00596d0f, + 0x00598d0f, 0x0059ad0f, 0x0059cd0f, 0x0059ed0f, + 0x005a0d0f, 0x005a2d0f, 0x005a4d0f, 0x005a6d0f, + 0x005a8d0f, 0x005aad0f, 0x005acd0f, 0x005aed0f, + 0x005b0d0f, 0x005b2d0f, 0x005b4d0f, 0x005b6d0f, + 0x005b8d0f, 0x005bad0f, 0x005bcd0f, 0x005bed0f, + 0x005c0d0f, 0x005c2d0f, 0x005c4d0f, 0x005c6d0f, + 0x005c8d0f, 0x005cad0f, 0x005ccd0f, 0x005ced0f, + 0x005d0d0f, 0x005d2d0f, 0x005d4d0f, 0x005d6d0f, + 0x005d8d0f, 0x005dad0f, 0x005dcd0f, 0x005ded0f, + 0x005e0d0f, 0x005e2d0f, 0x005e4d0f, 0x005e6d0f, + 0x005e8d0f, 0x005ead0f, 0x005ecd0f, 0x005eed0f, + 0x005f0d0f, 0x005f2d0f, 0x005f4d0f, 0x005f6d0f, + 0x005f8d0f, 0x005fad0f, 0x005fcd0f, 0x005fed0f, + 0x00600d0f, 0x00602d0f, 0x00604d0f, 0x00606d0f, + 0x00608d0f, 0x0060ad0f, 0x0060cd0f, 0x0060ed0f, + 0x00610d0f, 0x00612d0f, 0x00614d0f, 0x00616d0f, + 0x00618d0f, 0x0061ad0f, 0x0061cd0f, 0x0061ed0f, + 0x00620d0f, 0x00622d0f, 0x00624d0f, 0x00626d0f, + 0x00628d0f, 0x0062ad0f, 0x0062cd0f, 0x0062ed0f, + 0x00630d0f, 0x00632d0f, 0x00634d0f, 0x00636d0f, + 0x00638d0f, 0x0063ad0f, 0x0063cd0f, 0x0063ed0f, + 0x00640d0f, 0x00642d0f, 0x00644d0f, 0x00646d0f, + 0x00648d0f, 0x0064ad0f, 0x0064cd0f, 0x0064ed0f, + 0x00650d0f, 0x00652d0f, 0x00654d0f, 0x00656d0f, + 0x00658d0f, 0x0065ad0f, 0x0065cd0f, 0x0065ed0f, + 0x00660d0f, 0x00662d0f, 0x00664d0f, 0x00666d0f, + 0x00668d0f, 0x0066ad0f, 0x0066cd0f, 0x0066ed0f, + 0x00670d0f, 0x00672d0f, 0x00674d0f, 0x00676d0f, + 0x00678d0f, 0x0067ad0f, 0x0067cd0f, 0x0067ed0f, + 0x00680d0f, 0x00682d0f, 0x00684d0f, 0x00686d0f, + 0x00688d0f, 0x0068ad0f, 0x0068cd0f, 0x0068ed0f, + 0x00690d0f, 0x00692d0f, 0x00694d0f, 0x00696d0f, + 0x00698d0f, 0x0069ad0f, 0x0069cd0f, 0x0069ed0f, + 0x006a0d0f, 0x006a2d0f, 0x006a4d0f, 0x006a6d0f, + 0x006a8d0f, 0x006aad0f, 0x006acd0f, 0x006aed0f, + 0x006b0d0f, 0x006b2d0f, 0x006b4d0f, 0x006b6d0f, + 0x006b8d0f, 0x006bad0f, 0x006bcd0f, 0x006bed0f, + 0x006c0d0f, 0x006c2d0f, 0x006c4d0f, 0x006c6d0f, + 0x006c8d0f, 0x006cad0f, 0x006ccd0f, 0x006ced0f, + 0x006d0d0f, 0x006d2d0f, 0x006d4d0f, 0x006d6d0f, + 0x006d8d0f, 0x006dad0f, 0x006dcd0f, 0x006ded0f, + 0x006e0d0f, 0x006e2d0f, 0x006e4d0f, 0x006e6d0f, + 0x006e8d0f, 0x006ead0f, 0x006ecd0f, 0x006eed0f, + 0x006f0d0f, 0x006f2d0f, 0x006f4d0f, 0x006f6d0f, + 0x006f8d0f, 0x006fad0f, 0x006fcd0f, 0x006fed0f, + 0x00700d0f, 0x00702d0f, 0x00704d0f, 0x00706d0f, + 0x00708d0f, 0x0070ad0f, 0x0070cd0f, 0x0070ed0f, + 0x00710d0f, 0x00712d0f, 0x00714d0f, 0x00716d0f, + 0x00718d0f, 0x0071ad0f, 0x0071cd0f, 0x0071ed0f, + 0x00720d0f, 0x00722d0f, 0x00724d0f, 0x00726d0f, + 0x00728d0f, 0x0072ad0f, 0x0072cd0f, 0x0072ed0f, + 0x00730d0f, 0x00732d0f, 0x00734d0f, 0x00736d0f, + 0x00738d0f, 0x0073ad0f, 0x0073cd0f, 0x0073ed0f, + 0x00740d0f, 0x00742d0f, 0x00744d0f, 0x00746d0f, + 0x00748d0f, 0x0074ad0f, 0x0074cd0f, 0x0074ed0f, + 0x00750d0f, 0x00752d0f, 0x00754d0f, 0x00756d0f, + 0x00758d0f, 0x0075ad0f, 0x0075cd0f, 0x0075ed0f, + 0x00760d0f, 0x00762d0f, 0x00764d0f, 0x00766d0f, + 0x00768d0f, 0x0076ad0f, 0x0076cd0f, 0x0076ed0f, + 0x00770d0f, 0x00772d0f, 0x00774d0f, 0x00776d0f, + 0x00778d0f, 0x0077ad0f, 0x0077cd0f, 0x0077ed0f, + 0x00780d0f, 0x00782d0f, 0x00784d0f, 0x00786d0f, + 0x00788d0f, 0x0078ad0f, 0x0078cd0f, 0x0078ed0f, + 0x00790d0f, 0x00792d0f, 0x00794d0f, 0x00796d0f, + 0x00798d0f, 0x0079ad0f, 0x0079cd0f, 0x0079ed0f, + 0x007a0d0f, 0x007a2d0f, 0x007a4d0f, 0x007a6d0f, + 0x007a8d0f, 0x007aad0f, 0x007acd0f, 0x007aed0f, + 0x007b0d0f, 0x007b2d0f, 0x007b4d0f, 0x007b6d0f, + 0x007b8d0f, 0x007bad0f, 0x007bcd0f, 0x007bed0f, + 0x007c0d0f, 0x007c2d0f, 0x007c4d0f, 0x007c6d0f, + 0x007c8d0f, 0x007cad0f, 0x007ccd0f, 0x007ced0f, + 0x007d0d0f, 0x007d2d0f, 0x007d4d0f, 0x007d6d0f, + 0x007d8d0f, 0x007dad0f, 0x007dcd0f, 0x007ded0f, + 0x007e0d0f, 0x007e2d0f, 0x007e4d0f, 0x007e6d0f, + 0x007e8d0f, 0x007ead0f, 0x007ecd0f, 0x007eed0f, + 0x007f0d0f, 0x007f2d0f, 0x007f4d0f, 0x007f6d0f, + 0x007f8d0f, 0x007fad0f, 0x007fcd0f, 0x007fed0f, + 0x00001d0f, 0x00003d0f, 0x00005d0f, 0x00007d0f, + 0x00009d0f, 0x0000bd0f, 0x0000dd0f, 0x0000fd0f, + 0x00011d0f, 0x00013d0f, 0x00015d0f, 0x00017d0f, + 0x00019d0f, 0x0001bd0f, 0x0001dd0f, 0x0001fd0f, + 0x00021d0f, 0x00023d0f, 0x00025d0f, 0x00027d0f, + 0x00029d0f, 0x0002bd0f, 0x0002dd0f, 0x0002fd0f, + 0x00031d0f, 0x00033d0f, 0x00035d0f, 0x00037d0f, + 0x00039d0f, 0x0003bd0f, 0x0003dd0f, 0x0003fd0f, + 0x00041d0f, 0x00043d0f, 0x00045d0f, 0x00047d0f, + 0x00049d0f, 0x0004bd0f, 0x0004dd0f, 0x0004fd0f, + 0x00051d0f, 0x00053d0f, 0x00055d0f, 0x00057d0f, + 0x00059d0f, 0x0005bd0f, 0x0005dd0f, 0x0005fd0f, + 0x00061d0f, 0x00063d0f, 0x00065d0f, 0x00067d0f, + 0x00069d0f, 0x0006bd0f, 0x0006dd0f, 0x0006fd0f, + 0x00071d0f, 0x00073d0f, 0x00075d0f, 0x00077d0f, + 0x00079d0f, 0x0007bd0f, 0x0007dd0f, 0x0007fd0f, + 0x00081d0f, 0x00083d0f, 0x00085d0f, 0x00087d0f, + 0x00089d0f, 0x0008bd0f, 0x0008dd0f, 0x0008fd0f, + 0x00091d0f, 0x00093d0f, 0x00095d0f, 0x00097d0f, + 0x00099d0f, 0x0009bd0f, 0x0009dd0f, 0x0009fd0f, + 0x000a1d0f, 0x000a3d0f, 0x000a5d0f, 0x000a7d0f, + 0x000a9d0f, 0x000abd0f, 0x000add0f, 0x000afd0f, + 0x000b1d0f, 0x000b3d0f, 0x000b5d0f, 0x000b7d0f, + 0x000b9d0f, 0x000bbd0f, 0x000bdd0f, 0x000bfd0f, + 0x000c1d0f, 0x000c3d0f, 0x000c5d0f, 0x000c7d0f, + 0x000c9d0f, 0x000cbd0f, 0x000cdd0f, 0x000cfd0f, + 0x000d1d0f, 0x000d3d0f, 0x000d5d0f, 0x000d7d0f, + 0x000d9d0f, 0x000dbd0f, 0x000ddd0f, 0x000dfd0f, + 0x000e1d0f, 0x000e3d0f, 0x000e5d0f, 0x000e7d0f, + 0x000e9d0f, 0x000ebd0f, 0x000edd0f, 0x000efd0f, + 0x000f1d0f, 0x000f3d0f, 0x000f5d0f, 0x000f7d0f, + 0x000f9d0f, 0x000fbd0f, 0x000fdd0f, 0x000ffd0f, + 0x00101d0f, 0x00103d0f, 0x00105d0f, 0x00107d0f, + 0x00109d0f, 0x0010bd0f, 0x0010dd0f, 0x0010fd0f, + 0x00111d0f, 0x00113d0f, 0x00115d0f, 0x00117d0f, + 0x00119d0f, 0x0011bd0f, 0x0011dd0f, 0x0011fd0f, + 0x00121d0f, 0x00123d0f, 0x00125d0f, 0x00127d0f, + 0x00129d0f, 0x0012bd0f, 0x0012dd0f, 0x0012fd0f, + 0x00131d0f, 0x00133d0f, 0x00135d0f, 0x00137d0f, + 0x00139d0f, 0x0013bd0f, 0x0013dd0f, 0x0013fd0f, + 0x00141d0f, 0x00143d0f, 0x00145d0f, 0x00147d0f, + 0x00149d0f, 0x0014bd0f, 0x0014dd0f, 0x0014fd0f, + 0x00151d0f, 0x00153d0f, 0x00155d0f, 0x00157d0f, + 0x00159d0f, 0x0015bd0f, 0x0015dd0f, 0x0015fd0f, + 0x00161d0f, 0x00163d0f, 0x00165d0f, 0x00167d0f, + 0x00169d0f, 0x0016bd0f, 0x0016dd0f, 0x0016fd0f, + 0x00171d0f, 0x00173d0f, 0x00175d0f, 0x00177d0f, + 0x00179d0f, 0x0017bd0f, 0x0017dd0f, 0x0017fd0f, + 0x00181d0f, 0x00183d0f, 0x00185d0f, 0x00187d0f, + 0x00189d0f, 0x0018bd0f, 0x0018dd0f, 0x0018fd0f, + 0x00191d0f, 0x00193d0f, 0x00195d0f, 0x00197d0f, + 0x00199d0f, 0x0019bd0f, 0x0019dd0f, 0x0019fd0f, + 0x001a1d0f, 0x001a3d0f, 0x001a5d0f, 0x001a7d0f, + 0x001a9d0f, 0x001abd0f, 0x001add0f, 0x001afd0f, + 0x001b1d0f, 0x001b3d0f, 0x001b5d0f, 0x001b7d0f, + 0x001b9d0f, 0x001bbd0f, 0x001bdd0f, 0x001bfd0f, + 0x001c1d0f, 0x001c3d0f, 0x001c5d0f, 0x001c7d0f, + 0x001c9d0f, 0x001cbd0f, 0x001cdd0f, 0x001cfd0f, + 0x001d1d0f, 0x001d3d0f, 0x001d5d0f, 0x001d7d0f, + 0x001d9d0f, 0x001dbd0f, 0x001ddd0f, 0x001dfd0f, + 0x001e1d0f, 0x001e3d0f, 0x001e5d0f, 0x001e7d0f, + 0x001e9d0f, 0x001ebd0f, 0x001edd0f, 0x001efd0f, + 0x001f1d0f, 0x001f3d0f, 0x001f5d0f, 0x001f7d0f, + 0x001f9d0f, 0x001fbd0f, 0x001fdd0f, 0x001ffd0f, + 0x00201d0f, 0x00203d0f, 0x00205d0f, 0x00207d0f, + 0x00209d0f, 0x0020bd0f, 0x0020dd0f, 0x0020fd0f, + 0x00211d0f, 0x00213d0f, 0x00215d0f, 0x00217d0f, + 0x00219d0f, 0x0021bd0f, 0x0021dd0f, 0x0021fd0f, + 0x00221d0f, 0x00223d0f, 0x00225d0f, 0x00227d0f, + 0x00229d0f, 0x0022bd0f, 0x0022dd0f, 0x0022fd0f, + 0x00231d0f, 0x00233d0f, 0x00235d0f, 0x00237d0f, + 0x00239d0f, 0x0023bd0f, 0x0023dd0f, 0x0023fd0f, + 0x00241d0f, 0x00243d0f, 0x00245d0f, 0x00247d0f, + 0x00249d0f, 0x0024bd0f, 0x0024dd0f, 0x0024fd0f, + 0x00251d0f, 0x00253d0f, 0x00255d0f, 0x00257d0f, + 0x00259d0f, 0x0025bd0f, 0x0025dd0f, 0x0025fd0f, + 0x00261d0f, 0x00263d0f, 0x00265d0f, 0x00267d0f, + 0x00269d0f, 0x0026bd0f, 0x0026dd0f, 0x0026fd0f, + 0x00271d0f, 0x00273d0f, 0x00275d0f, 0x00277d0f, + 0x00279d0f, 0x0027bd0f, 0x0027dd0f, 0x0027fd0f, + 0x00281d0f, 0x00283d0f, 0x00285d0f, 0x00287d0f, + 0x00289d0f, 0x0028bd0f, 0x0028dd0f, 0x0028fd0f, + 0x00291d0f, 0x00293d0f, 0x00295d0f, 0x00297d0f, + 0x00299d0f, 0x0029bd0f, 0x0029dd0f, 0x0029fd0f, + 0x002a1d0f, 0x002a3d0f, 0x002a5d0f, 0x002a7d0f, + 0x002a9d0f, 0x002abd0f, 0x002add0f, 0x002afd0f, + 0x002b1d0f, 0x002b3d0f, 0x002b5d0f, 0x002b7d0f, + 0x002b9d0f, 0x002bbd0f, 0x002bdd0f, 0x002bfd0f, + 0x002c1d0f, 0x002c3d0f, 0x002c5d0f, 0x002c7d0f, + 0x002c9d0f, 0x002cbd0f, 0x002cdd0f, 0x002cfd0f, + 0x002d1d0f, 0x002d3d0f, 0x002d5d0f, 0x002d7d0f, + 0x002d9d0f, 0x002dbd0f, 0x002ddd0f, 0x002dfd0f, + 0x002e1d0f, 0x002e3d0f, 0x002e5d0f, 0x002e7d0f, + 0x002e9d0f, 0x002ebd0f, 0x002edd0f, 0x002efd0f, + 0x002f1d0f, 0x002f3d0f, 0x002f5d0f, 0x002f7d0f, + 0x002f9d0f, 0x002fbd0f, 0x002fdd0f, 0x002ffd0f, + 0x00301d0f, 0x00303d0f, 0x00305d0f, 0x00307d0f, + 0x00309d0f, 0x0030bd0f, 0x0030dd0f, 0x0030fd0f, + 0x00311d0f, 0x00313d0f, 0x00315d0f, 0x00317d0f, + 0x00319d0f, 0x0031bd0f, 0x0031dd0f, 0x0031fd0f, + 0x00321d0f, 0x00323d0f, 0x00325d0f, 0x00327d0f, + 0x00329d0f, 0x0032bd0f, 0x0032dd0f, 0x0032fd0f, + 0x00331d0f, 0x00333d0f, 0x00335d0f, 0x00337d0f, + 0x00339d0f, 0x0033bd0f, 0x0033dd0f, 0x0033fd0f, + 0x00341d0f, 0x00343d0f, 0x00345d0f, 0x00347d0f, + 0x00349d0f, 0x0034bd0f, 0x0034dd0f, 0x0034fd0f, + 0x00351d0f, 0x00353d0f, 0x00355d0f, 0x00357d0f, + 0x00359d0f, 0x0035bd0f, 0x0035dd0f, 0x0035fd0f, + 0x00361d0f, 0x00363d0f, 0x00365d0f, 0x00367d0f, + 0x00369d0f, 0x0036bd0f, 0x0036dd0f, 0x0036fd0f, + 0x00371d0f, 0x00373d0f, 0x00375d0f, 0x00377d0f, + 0x00379d0f, 0x0037bd0f, 0x0037dd0f, 0x0037fd0f, + 0x00381d0f, 0x00383d0f, 0x00385d0f, 0x00387d0f, + 0x00389d0f, 0x0038bd0f, 0x0038dd0f, 0x0038fd0f, + 0x00391d0f, 0x00393d0f, 0x00395d0f, 0x00397d0f, + 0x00399d0f, 0x0039bd0f, 0x0039dd0f, 0x0039fd0f, + 0x003a1d0f, 0x003a3d0f, 0x003a5d0f, 0x003a7d0f, + 0x003a9d0f, 0x003abd0f, 0x003add0f, 0x003afd0f, + 0x003b1d0f, 0x003b3d0f, 0x003b5d0f, 0x003b7d0f, + 0x003b9d0f, 0x003bbd0f, 0x003bdd0f, 0x003bfd0f, + 0x003c1d0f, 0x003c3d0f, 0x003c5d0f, 0x003c7d0f, + 0x003c9d0f, 0x003cbd0f, 0x003cdd0f, 0x003cfd0f, + 0x003d1d0f, 0x003d3d0f, 0x003d5d0f, 0x003d7d0f, + 0x003d9d0f, 0x003dbd0f, 0x003ddd0f, 0x003dfd0f, + 0x003e1d0f, 0x003e3d0f, 0x003e5d0f, 0x003e7d0f, + 0x003e9d0f, 0x003ebd0f, 0x003edd0f, 0x003efd0f, + 0x003f1d0f, 0x003f3d0f, 0x003f5d0f, 0x003f7d0f, + 0x003f9d0f, 0x003fbd0f, 0x003fdd0f, 0x003ffd0f, + 0x00401d0f, 0x00403d0f, 0x00405d0f, 0x00407d0f, + 0x00409d0f, 0x0040bd0f, 0x0040dd0f, 0x0040fd0f, + 0x00411d0f, 0x00413d0f, 0x00415d0f, 0x00417d0f, + 0x00419d0f, 0x0041bd0f, 0x0041dd0f, 0x0041fd0f, + 0x00421d0f, 0x00423d0f, 0x00425d0f, 0x00427d0f, + 0x00429d0f, 0x0042bd0f, 0x0042dd0f, 0x0042fd0f, + 0x00431d0f, 0x00433d0f, 0x00435d0f, 0x00437d0f, + 0x00439d0f, 0x0043bd0f, 0x0043dd0f, 0x0043fd0f, + 0x00441d0f, 0x00443d0f, 0x00445d0f, 0x00447d0f, + 0x00449d0f, 0x0044bd0f, 0x0044dd0f, 0x0044fd0f, + 0x00451d0f, 0x00453d0f, 0x00455d0f, 0x00457d0f, + 0x00459d0f, 0x0045bd0f, 0x0045dd0f, 0x0045fd0f, + 0x00461d0f, 0x00463d0f, 0x00465d0f, 0x00467d0f, + 0x00469d0f, 0x0046bd0f, 0x0046dd0f, 0x0046fd0f, + 0x00471d0f, 0x00473d0f, 0x00475d0f, 0x00477d0f, + 0x00479d0f, 0x0047bd0f, 0x0047dd0f, 0x0047fd0f, + 0x00481d0f, 0x00483d0f, 0x00485d0f, 0x00487d0f, + 0x00489d0f, 0x0048bd0f, 0x0048dd0f, 0x0048fd0f, + 0x00491d0f, 0x00493d0f, 0x00495d0f, 0x00497d0f, + 0x00499d0f, 0x0049bd0f, 0x0049dd0f, 0x0049fd0f, + 0x004a1d0f, 0x004a3d0f, 0x004a5d0f, 0x004a7d0f, + 0x004a9d0f, 0x004abd0f, 0x004add0f, 0x004afd0f, + 0x004b1d0f, 0x004b3d0f, 0x004b5d0f, 0x004b7d0f, + 0x004b9d0f, 0x004bbd0f, 0x004bdd0f, 0x004bfd0f, + 0x004c1d0f, 0x004c3d0f, 0x004c5d0f, 0x004c7d0f, + 0x004c9d0f, 0x004cbd0f, 0x004cdd0f, 0x004cfd0f, + 0x004d1d0f, 0x004d3d0f, 0x004d5d0f, 0x004d7d0f, + 0x004d9d0f, 0x004dbd0f, 0x004ddd0f, 0x004dfd0f, + 0x004e1d0f, 0x004e3d0f, 0x004e5d0f, 0x004e7d0f, + 0x004e9d0f, 0x004ebd0f, 0x004edd0f, 0x004efd0f, + 0x004f1d0f, 0x004f3d0f, 0x004f5d0f, 0x004f7d0f, + 0x004f9d0f, 0x004fbd0f, 0x004fdd0f, 0x004ffd0f, + 0x00501d0f, 0x00503d0f, 0x00505d0f, 0x00507d0f, + 0x00509d0f, 0x0050bd0f, 0x0050dd0f, 0x0050fd0f, + 0x00511d0f, 0x00513d0f, 0x00515d0f, 0x00517d0f, + 0x00519d0f, 0x0051bd0f, 0x0051dd0f, 0x0051fd0f, + 0x00521d0f, 0x00523d0f, 0x00525d0f, 0x00527d0f, + 0x00529d0f, 0x0052bd0f, 0x0052dd0f, 0x0052fd0f, + 0x00531d0f, 0x00533d0f, 0x00535d0f, 0x00537d0f, + 0x00539d0f, 0x0053bd0f, 0x0053dd0f, 0x0053fd0f, + 0x00541d0f, 0x00543d0f, 0x00545d0f, 0x00547d0f, + 0x00549d0f, 0x0054bd0f, 0x0054dd0f, 0x0054fd0f, + 0x00551d0f, 0x00553d0f, 0x00555d0f, 0x00557d0f, + 0x00559d0f, 0x0055bd0f, 0x0055dd0f, 0x0055fd0f, + 0x00561d0f, 0x00563d0f, 0x00565d0f, 0x00567d0f, + 0x00569d0f, 0x0056bd0f, 0x0056dd0f, 0x0056fd0f, + 0x00571d0f, 0x00573d0f, 0x00575d0f, 0x00577d0f, + 0x00579d0f, 0x0057bd0f, 0x0057dd0f, 0x0057fd0f, + 0x00581d0f, 0x00583d0f, 0x00585d0f, 0x00587d0f, + 0x00589d0f, 0x0058bd0f, 0x0058dd0f, 0x0058fd0f, + 0x00591d0f, 0x00593d0f, 0x00595d0f, 0x00597d0f, + 0x00599d0f, 0x0059bd0f, 0x0059dd0f, 0x0059fd0f, + 0x005a1d0f, 0x005a3d0f, 0x005a5d0f, 0x005a7d0f, + 0x005a9d0f, 0x005abd0f, 0x005add0f, 0x005afd0f, + 0x005b1d0f, 0x005b3d0f, 0x005b5d0f, 0x005b7d0f, + 0x005b9d0f, 0x005bbd0f, 0x005bdd0f, 0x005bfd0f, + 0x005c1d0f, 0x005c3d0f, 0x005c5d0f, 0x005c7d0f, + 0x005c9d0f, 0x005cbd0f, 0x005cdd0f, 0x005cfd0f, + 0x005d1d0f, 0x005d3d0f, 0x005d5d0f, 0x005d7d0f, + 0x005d9d0f, 0x005dbd0f, 0x005ddd0f, 0x005dfd0f, + 0x005e1d0f, 0x005e3d0f, 0x005e5d0f, 0x005e7d0f, + 0x005e9d0f, 0x005ebd0f, 0x005edd0f, 0x005efd0f, + 0x005f1d0f, 0x005f3d0f, 0x005f5d0f, 0x005f7d0f, + 0x005f9d0f, 0x005fbd0f, 0x005fdd0f, 0x005ffd0f, + 0x00601d0f, 0x00603d0f, 0x00605d0f, 0x00607d0f, + 0x00609d0f, 0x0060bd0f, 0x0060dd0f, 0x0060fd0f, + 0x00611d0f, 0x00613d0f, 0x00615d0f, 0x00617d0f, + 0x00619d0f, 0x0061bd0f, 0x0061dd0f, 0x0061fd0f, + 0x00621d0f, 0x00623d0f, 0x00625d0f, 0x00627d0f, + 0x00629d0f, 0x0062bd0f, 0x0062dd0f, 0x0062fd0f, + 0x00631d0f, 0x00633d0f, 0x00635d0f, 0x00637d0f, + 0x00639d0f, 0x0063bd0f, 0x0063dd0f, 0x0063fd0f, + 0x00641d0f, 0x00643d0f, 0x00645d0f, 0x00647d0f, + 0x00649d0f, 0x0064bd0f, 0x0064dd0f, 0x0064fd0f, + 0x00651d0f, 0x00653d0f, 0x00655d0f, 0x00657d0f, + 0x00659d0f, 0x0065bd0f, 0x0065dd0f, 0x0065fd0f, + 0x00661d0f, 0x00663d0f, 0x00665d0f, 0x00667d0f, + 0x00669d0f, 0x0066bd0f, 0x0066dd0f, 0x0066fd0f, + 0x00671d0f, 0x00673d0f, 0x00675d0f, 0x00677d0f, + 0x00679d0f, 0x0067bd0f, 0x0067dd0f, 0x0067fd0f, + 0x00681d0f, 0x00683d0f, 0x00685d0f, 0x00687d0f, + 0x00689d0f, 0x0068bd0f, 0x0068dd0f, 0x0068fd0f, + 0x00691d0f, 0x00693d0f, 0x00695d0f, 0x00697d0f, + 0x00699d0f, 0x0069bd0f, 0x0069dd0f, 0x0069fd0f, + 0x006a1d0f, 0x006a3d0f, 0x006a5d0f, 0x006a7d0f, + 0x006a9d0f, 0x006abd0f, 0x006add0f, 0x006afd0f, + 0x006b1d0f, 0x006b3d0f, 0x006b5d0f, 0x006b7d0f, + 0x006b9d0f, 0x006bbd0f, 0x006bdd0f, 0x006bfd0f, + 0x006c1d0f, 0x006c3d0f, 0x006c5d0f, 0x006c7d0f, + 0x006c9d0f, 0x006cbd0f, 0x006cdd0f, 0x006cfd0f, + 0x006d1d0f, 0x006d3d0f, 0x006d5d0f, 0x006d7d0f, + 0x006d9d0f, 0x006dbd0f, 0x006ddd0f, 0x006dfd0f, + 0x006e1d0f, 0x006e3d0f, 0x006e5d0f, 0x006e7d0f, + 0x006e9d0f, 0x006ebd0f, 0x006edd0f, 0x006efd0f, + 0x006f1d0f, 0x006f3d0f, 0x006f5d0f, 0x006f7d0f, + 0x006f9d0f, 0x006fbd0f, 0x006fdd0f, 0x006ffd0f, + 0x00701d0f, 0x00703d0f, 0x00705d0f, 0x00707d0f, + 0x00709d0f, 0x0070bd0f, 0x0070dd0f, 0x0070fd0f, + 0x00711d0f, 0x00713d0f, 0x00715d0f, 0x00717d0f, + 0x00719d0f, 0x0071bd0f, 0x0071dd0f, 0x0071fd0f, + 0x00721d0f, 0x00723d0f, 0x00725d0f, 0x00727d0f, + 0x00729d0f, 0x0072bd0f, 0x0072dd0f, 0x0072fd0f, + 0x00731d0f, 0x00733d0f, 0x00735d0f, 0x00737d0f, + 0x00739d0f, 0x0073bd0f, 0x0073dd0f, 0x0073fd0f, + 0x00741d0f, 0x00743d0f, 0x00745d0f, 0x00747d0f, + 0x00749d0f, 0x0074bd0f, 0x0074dd0f, 0x0074fd0f, + 0x00751d0f, 0x00753d0f, 0x00755d0f, 0x00757d0f, + 0x00759d0f, 0x0075bd0f, 0x0075dd0f, 0x0075fd0f, + 0x00761d0f, 0x00763d0f, 0x00765d0f, 0x00767d0f, + 0x00769d0f, 0x0076bd0f, 0x0076dd0f, 0x0076fd0f, + 0x00771d0f, 0x00773d0f, 0x00775d0f, 0x00777d0f, + 0x00779d0f, 0x0077bd0f, 0x0077dd0f, 0x0077fd0f, + 0x00781d0f, 0x00783d0f, 0x00785d0f, 0x00787d0f, + 0x00789d0f, 0x0078bd0f, 0x0078dd0f, 0x0078fd0f, + 0x00791d0f, 0x00793d0f, 0x00795d0f, 0x00797d0f, + 0x00799d0f, 0x0079bd0f, 0x0079dd0f, 0x0079fd0f, + 0x007a1d0f, 0x007a3d0f, 0x007a5d0f, 0x007a7d0f, + 0x007a9d0f, 0x007abd0f, 0x007add0f, 0x007afd0f, + 0x007b1d0f, 0x007b3d0f, 0x007b5d0f, 0x007b7d0f, + 0x007b9d0f, 0x007bbd0f, 0x007bdd0f, 0x007bfd0f, + 0x007c1d0f, 0x007c3d0f, 0x007c5d0f, 0x007c7d0f, + 0x007c9d0f, 0x007cbd0f, 0x007cdd0f, 0x007cfd0f, + 0x007d1d0f, 0x007d3d0f, 0x007d5d0f, 0x007d7d0f, + 0x007d9d0f, 0x007dbd0f, 0x007ddd0f, 0x007dfd0f, + 0x007e1d0f, 0x007e3d0f, 0x007e5d0f, 0x007e7d0f, + 0x007e9d0f, 0x007ebd0f, 0x007edd0f, 0x007efd0f, + 0x007f1d0f, 0x007f3d0f, 0x007f5d0f, 0x007f7d0f, + 0x007f9d0f, 0x007fbd0f, 0x007fdd0f, 0x007ffd0f, + 0x00000310, 0x00002310, 0x00004310, 0x00006310, + 0x00008310, 0x0000a310, 0x0000c310, 0x0000e310, + 0x00010310, 0x00012310, 0x00014310, 0x00016310, + 0x00018310, 0x0001a310, 0x0001c310, 0x0001e310, + 0x00020310, 0x00022310, 0x00024310, 0x00026310, + 0x00028310, 0x0002a310, 0x0002c310, 0x0002e310, + 0x00030310, 0x00032310, 0x00034310, 0x00036310, + 0x00038310, 0x0003a310, 0x0003c310, 0x0003e310, + 0x00040310, 0x00042310, 0x00044310, 0x00046310, + 0x00048310, 0x0004a310, 0x0004c310, 0x0004e310, + 0x00050310, 0x00052310, 0x00054310, 0x00056310, + 0x00058310, 0x0005a310, 0x0005c310, 0x0005e310, + 0x00060310, 0x00062310, 0x00064310, 0x00066310, + 0x00068310, 0x0006a310, 0x0006c310, 0x0006e310, + 0x00070310, 0x00072310, 0x00074310, 0x00076310, + 0x00078310, 0x0007a310, 0x0007c310, 0x0007e310, + 0x00080310, 0x00082310, 0x00084310, 0x00086310, + 0x00088310, 0x0008a310, 0x0008c310, 0x0008e310, + 0x00090310, 0x00092310, 0x00094310, 0x00096310, + 0x00098310, 0x0009a310, 0x0009c310, 0x0009e310, + 0x000a0310, 0x000a2310, 0x000a4310, 0x000a6310, + 0x000a8310, 0x000aa310, 0x000ac310, 0x000ae310, + 0x000b0310, 0x000b2310, 0x000b4310, 0x000b6310, + 0x000b8310, 0x000ba310, 0x000bc310, 0x000be310, + 0x000c0310, 0x000c2310, 0x000c4310, 0x000c6310, + 0x000c8310, 0x000ca310, 0x000cc310, 0x000ce310, + 0x000d0310, 0x000d2310, 0x000d4310, 0x000d6310, + 0x000d8310, 0x000da310, 0x000dc310, 0x000de310, + 0x000e0310, 0x000e2310, 0x000e4310, 0x000e6310, + 0x000e8310, 0x000ea310, 0x000ec310, 0x000ee310, + 0x000f0310, 0x000f2310, 0x000f4310, 0x000f6310, + 0x000f8310, 0x000fa310, 0x000fc310, 0x000fe310, + 0x00100310, 0x00102310, 0x00104310, 0x00106310, + 0x00108310, 0x0010a310, 0x0010c310, 0x0010e310, + 0x00110310, 0x00112310, 0x00114310, 0x00116310, + 0x00118310, 0x0011a310, 0x0011c310, 0x0011e310, + 0x00120310, 0x00122310, 0x00124310, 0x00126310, + 0x00128310, 0x0012a310, 0x0012c310, 0x0012e310, + 0x00130310, 0x00132310, 0x00134310, 0x00136310, + 0x00138310, 0x0013a310, 0x0013c310, 0x0013e310, + 0x00140310, 0x00142310, 0x00144310, 0x00146310, + 0x00148310, 0x0014a310, 0x0014c310, 0x0014e310, + 0x00150310, 0x00152310, 0x00154310, 0x00156310, + 0x00158310, 0x0015a310, 0x0015c310, 0x0015e310, + 0x00160310, 0x00162310, 0x00164310, 0x00166310, + 0x00168310, 0x0016a310, 0x0016c310, 0x0016e310, + 0x00170310, 0x00172310, 0x00174310, 0x00176310, + 0x00178310, 0x0017a310, 0x0017c310, 0x0017e310, + 0x00180310, 0x00182310, 0x00184310, 0x00186310, + 0x00188310, 0x0018a310, 0x0018c310, 0x0018e310, + 0x00190310, 0x00192310, 0x00194310, 0x00196310, + 0x00198310, 0x0019a310, 0x0019c310, 0x0019e310, + 0x001a0310, 0x001a2310, 0x001a4310, 0x001a6310, + 0x001a8310, 0x001aa310, 0x001ac310, 0x001ae310, + 0x001b0310, 0x001b2310, 0x001b4310, 0x001b6310, + 0x001b8310, 0x001ba310, 0x001bc310, 0x001be310, + 0x001c0310, 0x001c2310, 0x001c4310, 0x001c6310, + 0x001c8310, 0x001ca310, 0x001cc310, 0x001ce310, + 0x001d0310, 0x001d2310, 0x001d4310, 0x001d6310, + 0x001d8310, 0x001da310, 0x001dc310, 0x001de310, + 0x001e0310, 0x001e2310, 0x001e4310, 0x001e6310, + 0x001e8310, 0x001ea310, 0x001ec310, 0x001ee310, + 0x001f0310, 0x001f2310, 0x001f4310, 0x001f6310, + 0x001f8310, 0x001fa310, 0x001fc310, 0x001fe310, + 0x00200310, 0x00202310, 0x00204310, 0x00206310, + 0x00208310, 0x0020a310, 0x0020c310, 0x0020e310, + 0x00210310, 0x00212310, 0x00214310, 0x00216310, + 0x00218310, 0x0021a310, 0x0021c310, 0x0021e310, + 0x00220310, 0x00222310, 0x00224310, 0x00226310, + 0x00228310, 0x0022a310, 0x0022c310, 0x0022e310, + 0x00230310, 0x00232310, 0x00234310, 0x00236310, + 0x00238310, 0x0023a310, 0x0023c310, 0x0023e310, + 0x00240310, 0x00242310, 0x00244310, 0x00246310, + 0x00248310, 0x0024a310, 0x0024c310, 0x0024e310, + 0x00250310, 0x00252310, 0x00254310, 0x00256310, + 0x00258310, 0x0025a310, 0x0025c310, 0x0025e310, + 0x00260310, 0x00262310, 0x00264310, 0x00266310, + 0x00268310, 0x0026a310, 0x0026c310, 0x0026e310, + 0x00270310, 0x00272310, 0x00274310, 0x00276310, + 0x00278310, 0x0027a310, 0x0027c310, 0x0027e310, + 0x00280310, 0x00282310, 0x00284310, 0x00286310, + 0x00288310, 0x0028a310, 0x0028c310, 0x0028e310, + 0x00290310, 0x00292310, 0x00294310, 0x00296310, + 0x00298310, 0x0029a310, 0x0029c310, 0x0029e310, + 0x002a0310, 0x002a2310, 0x002a4310, 0x002a6310, + 0x002a8310, 0x002aa310, 0x002ac310, 0x002ae310, + 0x002b0310, 0x002b2310, 0x002b4310, 0x002b6310, + 0x002b8310, 0x002ba310, 0x002bc310, 0x002be310, + 0x002c0310, 0x002c2310, 0x002c4310, 0x002c6310, + 0x002c8310, 0x002ca310, 0x002cc310, 0x002ce310, + 0x002d0310, 0x002d2310, 0x002d4310, 0x002d6310, + 0x002d8310, 0x002da310, 0x002dc310, 0x002de310, + 0x002e0310, 0x002e2310, 0x002e4310, 0x002e6310, + 0x002e8310, 0x002ea310, 0x002ec310, 0x002ee310, + 0x002f0310, 0x002f2310, 0x002f4310, 0x002f6310, + 0x002f8310, 0x002fa310, 0x002fc310, 0x002fe310, + 0x00300310, 0x00302310, 0x00304310, 0x00306310, + 0x00308310, 0x0030a310, 0x0030c310, 0x0030e310, + 0x00310310, 0x00312310, 0x00314310, 0x00316310, + 0x00318310, 0x0031a310, 0x0031c310, 0x0031e310, + 0x00320310, 0x00322310, 0x00324310, 0x00326310, + 0x00328310, 0x0032a310, 0x0032c310, 0x0032e310, + 0x00330310, 0x00332310, 0x00334310, 0x00336310, + 0x00338310, 0x0033a310, 0x0033c310, 0x0033e310, + 0x00340310, 0x00342310, 0x00344310, 0x00346310, + 0x00348310, 0x0034a310, 0x0034c310, 0x0034e310, + 0x00350310, 0x00352310, 0x00354310, 0x00356310, + 0x00358310, 0x0035a310, 0x0035c310, 0x0035e310, + 0x00360310, 0x00362310, 0x00364310, 0x00366310, + 0x00368310, 0x0036a310, 0x0036c310, 0x0036e310, + 0x00370310, 0x00372310, 0x00374310, 0x00376310, + 0x00378310, 0x0037a310, 0x0037c310, 0x0037e310, + 0x00380310, 0x00382310, 0x00384310, 0x00386310, + 0x00388310, 0x0038a310, 0x0038c310, 0x0038e310, + 0x00390310, 0x00392310, 0x00394310, 0x00396310, + 0x00398310, 0x0039a310, 0x0039c310, 0x0039e310, + 0x003a0310, 0x003a2310, 0x003a4310, 0x003a6310, + 0x003a8310, 0x003aa310, 0x003ac310, 0x003ae310, + 0x003b0310, 0x003b2310, 0x003b4310, 0x003b6310, + 0x003b8310, 0x003ba310, 0x003bc310, 0x003be310, + 0x003c0310, 0x003c2310, 0x003c4310, 0x003c6310, + 0x003c8310, 0x003ca310, 0x003cc310, 0x003ce310, + 0x003d0310, 0x003d2310, 0x003d4310, 0x003d6310, + 0x003d8310, 0x003da310, 0x003dc310, 0x003de310, + 0x003e0310, 0x003e2310, 0x003e4310, 0x003e6310, + 0x003e8310, 0x003ea310, 0x003ec310, 0x003ee310, + 0x003f0310, 0x003f2310, 0x003f4310, 0x003f6310, + 0x003f8310, 0x003fa310, 0x003fc310, 0x003fe310, + 0x00400310, 0x00402310, 0x00404310, 0x00406310, + 0x00408310, 0x0040a310, 0x0040c310, 0x0040e310, + 0x00410310, 0x00412310, 0x00414310, 0x00416310, + 0x00418310, 0x0041a310, 0x0041c310, 0x0041e310, + 0x00420310, 0x00422310, 0x00424310, 0x00426310, + 0x00428310, 0x0042a310, 0x0042c310, 0x0042e310, + 0x00430310, 0x00432310, 0x00434310, 0x00436310, + 0x00438310, 0x0043a310, 0x0043c310, 0x0043e310, + 0x00440310, 0x00442310, 0x00444310, 0x00446310, + 0x00448310, 0x0044a310, 0x0044c310, 0x0044e310, + 0x00450310, 0x00452310, 0x00454310, 0x00456310, + 0x00458310, 0x0045a310, 0x0045c310, 0x0045e310, + 0x00460310, 0x00462310, 0x00464310, 0x00466310, + 0x00468310, 0x0046a310, 0x0046c310, 0x0046e310, + 0x00470310, 0x00472310, 0x00474310, 0x00476310, + 0x00478310, 0x0047a310, 0x0047c310, 0x0047e310, + 0x00480310, 0x00482310, 0x00484310, 0x00486310, + 0x00488310, 0x0048a310, 0x0048c310, 0x0048e310, + 0x00490310, 0x00492310, 0x00494310, 0x00496310, + 0x00498310, 0x0049a310, 0x0049c310, 0x0049e310, + 0x004a0310, 0x004a2310, 0x004a4310, 0x004a6310, + 0x004a8310, 0x004aa310, 0x004ac310, 0x004ae310, + 0x004b0310, 0x004b2310, 0x004b4310, 0x004b6310, + 0x004b8310, 0x004ba310, 0x004bc310, 0x004be310, + 0x004c0310, 0x004c2310, 0x004c4310, 0x004c6310, + 0x004c8310, 0x004ca310, 0x004cc310, 0x004ce310, + 0x004d0310, 0x004d2310, 0x004d4310, 0x004d6310, + 0x004d8310, 0x004da310, 0x004dc310, 0x004de310, + 0x004e0310, 0x004e2310, 0x004e4310, 0x004e6310, + 0x004e8310, 0x004ea310, 0x004ec310, 0x004ee310, + 0x004f0310, 0x004f2310, 0x004f4310, 0x004f6310, + 0x004f8310, 0x004fa310, 0x004fc310, 0x004fe310, + 0x00500310, 0x00502310, 0x00504310, 0x00506310, + 0x00508310, 0x0050a310, 0x0050c310, 0x0050e310, + 0x00510310, 0x00512310, 0x00514310, 0x00516310, + 0x00518310, 0x0051a310, 0x0051c310, 0x0051e310, + 0x00520310, 0x00522310, 0x00524310, 0x00526310, + 0x00528310, 0x0052a310, 0x0052c310, 0x0052e310, + 0x00530310, 0x00532310, 0x00534310, 0x00536310, + 0x00538310, 0x0053a310, 0x0053c310, 0x0053e310, + 0x00540310, 0x00542310, 0x00544310, 0x00546310, + 0x00548310, 0x0054a310, 0x0054c310, 0x0054e310, + 0x00550310, 0x00552310, 0x00554310, 0x00556310, + 0x00558310, 0x0055a310, 0x0055c310, 0x0055e310, + 0x00560310, 0x00562310, 0x00564310, 0x00566310, + 0x00568310, 0x0056a310, 0x0056c310, 0x0056e310, + 0x00570310, 0x00572310, 0x00574310, 0x00576310, + 0x00578310, 0x0057a310, 0x0057c310, 0x0057e310, + 0x00580310, 0x00582310, 0x00584310, 0x00586310, + 0x00588310, 0x0058a310, 0x0058c310, 0x0058e310, + 0x00590310, 0x00592310, 0x00594310, 0x00596310, + 0x00598310, 0x0059a310, 0x0059c310, 0x0059e310, + 0x005a0310, 0x005a2310, 0x005a4310, 0x005a6310, + 0x005a8310, 0x005aa310, 0x005ac310, 0x005ae310, + 0x005b0310, 0x005b2310, 0x005b4310, 0x005b6310, + 0x005b8310, 0x005ba310, 0x005bc310, 0x005be310, + 0x005c0310, 0x005c2310, 0x005c4310, 0x005c6310, + 0x005c8310, 0x005ca310, 0x005cc310, 0x005ce310, + 0x005d0310, 0x005d2310, 0x005d4310, 0x005d6310, + 0x005d8310, 0x005da310, 0x005dc310, 0x005de310, + 0x005e0310, 0x005e2310, 0x005e4310, 0x005e6310, + 0x005e8310, 0x005ea310, 0x005ec310, 0x005ee310, + 0x005f0310, 0x005f2310, 0x005f4310, 0x005f6310, + 0x005f8310, 0x005fa310, 0x005fc310, 0x005fe310, + 0x00600310, 0x00602310, 0x00604310, 0x00606310, + 0x00608310, 0x0060a310, 0x0060c310, 0x0060e310, + 0x00610310, 0x00612310, 0x00614310, 0x00616310, + 0x00618310, 0x0061a310, 0x0061c310, 0x0061e310, + 0x00620310, 0x00622310, 0x00624310, 0x00626310, + 0x00628310, 0x0062a310, 0x0062c310, 0x0062e310, + 0x00630310, 0x00632310, 0x00634310, 0x00636310, + 0x00638310, 0x0063a310, 0x0063c310, 0x0063e310, + 0x00640310, 0x00642310, 0x00644310, 0x00646310, + 0x00648310, 0x0064a310, 0x0064c310, 0x0064e310, + 0x00650310, 0x00652310, 0x00654310, 0x00656310, + 0x00658310, 0x0065a310, 0x0065c310, 0x0065e310, + 0x00660310, 0x00662310, 0x00664310, 0x00666310, + 0x00668310, 0x0066a310, 0x0066c310, 0x0066e310, + 0x00670310, 0x00672310, 0x00674310, 0x00676310, + 0x00678310, 0x0067a310, 0x0067c310, 0x0067e310, + 0x00680310, 0x00682310, 0x00684310, 0x00686310, + 0x00688310, 0x0068a310, 0x0068c310, 0x0068e310, + 0x00690310, 0x00692310, 0x00694310, 0x00696310, + 0x00698310, 0x0069a310, 0x0069c310, 0x0069e310, + 0x006a0310, 0x006a2310, 0x006a4310, 0x006a6310, + 0x006a8310, 0x006aa310, 0x006ac310, 0x006ae310, + 0x006b0310, 0x006b2310, 0x006b4310, 0x006b6310, + 0x006b8310, 0x006ba310, 0x006bc310, 0x006be310, + 0x006c0310, 0x006c2310, 0x006c4310, 0x006c6310, + 0x006c8310, 0x006ca310, 0x006cc310, 0x006ce310, + 0x006d0310, 0x006d2310, 0x006d4310, 0x006d6310, + 0x006d8310, 0x006da310, 0x006dc310, 0x006de310, + 0x006e0310, 0x006e2310, 0x006e4310, 0x006e6310, + 0x006e8310, 0x006ea310, 0x006ec310, 0x006ee310, + 0x006f0310, 0x006f2310, 0x006f4310, 0x006f6310, + 0x006f8310, 0x006fa310, 0x006fc310, 0x006fe310, + 0x00700310, 0x00702310, 0x00704310, 0x00706310, + 0x00708310, 0x0070a310, 0x0070c310, 0x0070e310, + 0x00710310, 0x00712310, 0x00714310, 0x00716310, + 0x00718310, 0x0071a310, 0x0071c310, 0x0071e310, + 0x00720310, 0x00722310, 0x00724310, 0x00726310, + 0x00728310, 0x0072a310, 0x0072c310, 0x0072e310, + 0x00730310, 0x00732310, 0x00734310, 0x00736310, + 0x00738310, 0x0073a310, 0x0073c310, 0x0073e310, + 0x00740310, 0x00742310, 0x00744310, 0x00746310, + 0x00748310, 0x0074a310, 0x0074c310, 0x0074e310, + 0x00750310, 0x00752310, 0x00754310, 0x00756310, + 0x00758310, 0x0075a310, 0x0075c310, 0x0075e310, + 0x00760310, 0x00762310, 0x00764310, 0x00766310, + 0x00768310, 0x0076a310, 0x0076c310, 0x0076e310, + 0x00770310, 0x00772310, 0x00774310, 0x00776310, + 0x00778310, 0x0077a310, 0x0077c310, 0x0077e310, + 0x00780310, 0x00782310, 0x00784310, 0x00786310, + 0x00788310, 0x0078a310, 0x0078c310, 0x0078e310, + 0x00790310, 0x00792310, 0x00794310, 0x00796310, + 0x00798310, 0x0079a310, 0x0079c310, 0x0079e310, + 0x007a0310, 0x007a2310, 0x007a4310, 0x007a6310, + 0x007a8310, 0x007aa310, 0x007ac310, 0x007ae310, + 0x007b0310, 0x007b2310, 0x007b4310, 0x007b6310, + 0x007b8310, 0x007ba310, 0x007bc310, 0x007be310, + 0x007c0310, 0x007c2310, 0x007c4310, 0x007c6310, + 0x007c8310, 0x007ca310, 0x007cc310, 0x007ce310, + 0x007d0310, 0x007d2310, 0x007d4310, 0x007d6310, + 0x007d8310, 0x007da310, 0x007dc310, 0x007de310, + 0x007e0310, 0x007e2310, 0x007e4310, 0x007e6310, + 0x007e8310, 0x007ea310, 0x007ec310, 0x007ee310, + 0x007f0310, 0x007f2310, 0x007f4310, 0x007f6310, + 0x007f8310, 0x007fa310, 0x007fc310, 0x007fe310, + 0x00800310, 0x00802310, 0x00804310, 0x00806310, + 0x00808310, 0x0080a310, 0x0080c310, 0x0080e310, + 0x00810310, 0x00812310, 0x00814310, 0x00816310, + 0x00818310, 0x0081a310, 0x0081c310, 0x0081e310, + 0x00820310, 0x00822310, 0x00824310, 0x00826310, + 0x00828310, 0x0082a310, 0x0082c310, 0x0082e310, + 0x00830310, 0x00832310, 0x00834310, 0x00836310, + 0x00838310, 0x0083a310, 0x0083c310, 0x0083e310, + 0x00840310, 0x00842310, 0x00844310, 0x00846310, + 0x00848310, 0x0084a310, 0x0084c310, 0x0084e310, + 0x00850310, 0x00852310, 0x00854310, 0x00856310, + 0x00858310, 0x0085a310, 0x0085c310, 0x0085e310, + 0x00860310, 0x00862310, 0x00864310, 0x00866310, + 0x00868310, 0x0086a310, 0x0086c310, 0x0086e310, + 0x00870310, 0x00872310, 0x00874310, 0x00876310, + 0x00878310, 0x0087a310, 0x0087c310, 0x0087e310, + 0x00880310, 0x00882310, 0x00884310, 0x00886310, + 0x00888310, 0x0088a310, 0x0088c310, 0x0088e310, + 0x00890310, 0x00892310, 0x00894310, 0x00896310, + 0x00898310, 0x0089a310, 0x0089c310, 0x0089e310, + 0x008a0310, 0x008a2310, 0x008a4310, 0x008a6310, + 0x008a8310, 0x008aa310, 0x008ac310, 0x008ae310, + 0x008b0310, 0x008b2310, 0x008b4310, 0x008b6310, + 0x008b8310, 0x008ba310, 0x008bc310, 0x008be310, + 0x008c0310, 0x008c2310, 0x008c4310, 0x008c6310, + 0x008c8310, 0x008ca310, 0x008cc310, 0x008ce310, + 0x008d0310, 0x008d2310, 0x008d4310, 0x008d6310, + 0x008d8310, 0x008da310, 0x008dc310, 0x008de310, + 0x008e0310, 0x008e2310, 0x008e4310, 0x008e6310, + 0x008e8310, 0x008ea310, 0x008ec310, 0x008ee310, + 0x008f0310, 0x008f2310, 0x008f4310, 0x008f6310, + 0x008f8310, 0x008fa310, 0x008fc310, 0x008fe310, + 0x00900310, 0x00902310, 0x00904310, 0x00906310, + 0x00908310, 0x0090a310, 0x0090c310, 0x0090e310, + 0x00910310, 0x00912310, 0x00914310, 0x00916310, + 0x00918310, 0x0091a310, 0x0091c310, 0x0091e310, + 0x00920310, 0x00922310, 0x00924310, 0x00926310, + 0x00928310, 0x0092a310, 0x0092c310, 0x0092e310, + 0x00930310, 0x00932310, 0x00934310, 0x00936310, + 0x00938310, 0x0093a310, 0x0093c310, 0x0093e310, + 0x00940310, 0x00942310, 0x00944310, 0x00946310, + 0x00948310, 0x0094a310, 0x0094c310, 0x0094e310, + 0x00950310, 0x00952310, 0x00954310, 0x00956310, + 0x00958310, 0x0095a310, 0x0095c310, 0x0095e310, + 0x00960310, 0x00962310, 0x00964310, 0x00966310, + 0x00968310, 0x0096a310, 0x0096c310, 0x0096e310, + 0x00970310, 0x00972310, 0x00974310, 0x00976310, + 0x00978310, 0x0097a310, 0x0097c310, 0x0097e310, + 0x00980310, 0x00982310, 0x00984310, 0x00986310, + 0x00988310, 0x0098a310, 0x0098c310, 0x0098e310, + 0x00990310, 0x00992310, 0x00994310, 0x00996310, + 0x00998310, 0x0099a310, 0x0099c310, 0x0099e310, + 0x009a0310, 0x009a2310, 0x009a4310, 0x009a6310, + 0x009a8310, 0x009aa310, 0x009ac310, 0x009ae310, + 0x009b0310, 0x009b2310, 0x009b4310, 0x009b6310, + 0x009b8310, 0x009ba310, 0x009bc310, 0x009be310, + 0x009c0310, 0x009c2310, 0x009c4310, 0x009c6310, + 0x009c8310, 0x009ca310, 0x009cc310, 0x009ce310, + 0x009d0310, 0x009d2310, 0x009d4310, 0x009d6310, + 0x009d8310, 0x009da310, 0x009dc310, 0x009de310, + 0x009e0310, 0x009e2310, 0x009e4310, 0x009e6310, + 0x009e8310, 0x009ea310, 0x009ec310, 0x009ee310, + 0x009f0310, 0x009f2310, 0x009f4310, 0x009f6310, + 0x009f8310, 0x009fa310, 0x009fc310, 0x009fe310, + 0x00a00310, 0x00a02310, 0x00a04310, 0x00a06310, + 0x00a08310, 0x00a0a310, 0x00a0c310, 0x00a0e310, + 0x00a10310, 0x00a12310, 0x00a14310, 0x00a16310, + 0x00a18310, 0x00a1a310, 0x00a1c310, 0x00a1e310, + 0x00a20310, 0x00a22310, 0x00a24310, 0x00a26310, + 0x00a28310, 0x00a2a310, 0x00a2c310, 0x00a2e310, + 0x00a30310, 0x00a32310, 0x00a34310, 0x00a36310, + 0x00a38310, 0x00a3a310, 0x00a3c310, 0x00a3e310, + 0x00a40310, 0x00a42310, 0x00a44310, 0x00a46310, + 0x00a48310, 0x00a4a310, 0x00a4c310, 0x00a4e310, + 0x00a50310, 0x00a52310, 0x00a54310, 0x00a56310, + 0x00a58310, 0x00a5a310, 0x00a5c310, 0x00a5e310, + 0x00a60310, 0x00a62310, 0x00a64310, 0x00a66310, + 0x00a68310, 0x00a6a310, 0x00a6c310, 0x00a6e310, + 0x00a70310, 0x00a72310, 0x00a74310, 0x00a76310, + 0x00a78310, 0x00a7a310, 0x00a7c310, 0x00a7e310, + 0x00a80310, 0x00a82310, 0x00a84310, 0x00a86310, + 0x00a88310, 0x00a8a310, 0x00a8c310, 0x00a8e310, + 0x00a90310, 0x00a92310, 0x00a94310, 0x00a96310, + 0x00a98310, 0x00a9a310, 0x00a9c310, 0x00a9e310, + 0x00aa0310, 0x00aa2310, 0x00aa4310, 0x00aa6310, + 0x00aa8310, 0x00aaa310, 0x00aac310, 0x00aae310, + 0x00ab0310, 0x00ab2310, 0x00ab4310, 0x00ab6310, + 0x00ab8310, 0x00aba310, 0x00abc310, 0x00abe310, + 0x00ac0310, 0x00ac2310, 0x00ac4310, 0x00ac6310, + 0x00ac8310, 0x00aca310, 0x00acc310, 0x00ace310, + 0x00ad0310, 0x00ad2310, 0x00ad4310, 0x00ad6310, + 0x00ad8310, 0x00ada310, 0x00adc310, 0x00ade310, + 0x00ae0310, 0x00ae2310, 0x00ae4310, 0x00ae6310, + 0x00ae8310, 0x00aea310, 0x00aec310, 0x00aee310, + 0x00af0310, 0x00af2310, 0x00af4310, 0x00af6310, + 0x00af8310, 0x00afa310, 0x00afc310, 0x00afe310, + 0x00b00310, 0x00b02310, 0x00b04310, 0x00b06310, + 0x00b08310, 0x00b0a310, 0x00b0c310, 0x00b0e310, + 0x00b10310, 0x00b12310, 0x00b14310, 0x00b16310, + 0x00b18310, 0x00b1a310, 0x00b1c310, 0x00b1e310, + 0x00b20310, 0x00b22310, 0x00b24310, 0x00b26310, + 0x00b28310, 0x00b2a310, 0x00b2c310, 0x00b2e310, + 0x00b30310, 0x00b32310, 0x00b34310, 0x00b36310, + 0x00b38310, 0x00b3a310, 0x00b3c310, 0x00b3e310, + 0x00b40310, 0x00b42310, 0x00b44310, 0x00b46310, + 0x00b48310, 0x00b4a310, 0x00b4c310, 0x00b4e310, + 0x00b50310, 0x00b52310, 0x00b54310, 0x00b56310, + 0x00b58310, 0x00b5a310, 0x00b5c310, 0x00b5e310, + 0x00b60310, 0x00b62310, 0x00b64310, 0x00b66310, + 0x00b68310, 0x00b6a310, 0x00b6c310, 0x00b6e310, + 0x00b70310, 0x00b72310, 0x00b74310, 0x00b76310, + 0x00b78310, 0x00b7a310, 0x00b7c310, 0x00b7e310, + 0x00b80310, 0x00b82310, 0x00b84310, 0x00b86310, + 0x00b88310, 0x00b8a310, 0x00b8c310, 0x00b8e310, + 0x00b90310, 0x00b92310, 0x00b94310, 0x00b96310, + 0x00b98310, 0x00b9a310, 0x00b9c310, 0x00b9e310, + 0x00ba0310, 0x00ba2310, 0x00ba4310, 0x00ba6310, + 0x00ba8310, 0x00baa310, 0x00bac310, 0x00bae310, + 0x00bb0310, 0x00bb2310, 0x00bb4310, 0x00bb6310, + 0x00bb8310, 0x00bba310, 0x00bbc310, 0x00bbe310, + 0x00bc0310, 0x00bc2310, 0x00bc4310, 0x00bc6310, + 0x00bc8310, 0x00bca310, 0x00bcc310, 0x00bce310, + 0x00bd0310, 0x00bd2310, 0x00bd4310, 0x00bd6310, + 0x00bd8310, 0x00bda310, 0x00bdc310, 0x00bde310, + 0x00be0310, 0x00be2310, 0x00be4310, 0x00be6310, + 0x00be8310, 0x00bea310, 0x00bec310, 0x00bee310, + 0x00bf0310, 0x00bf2310, 0x00bf4310, 0x00bf6310, + 0x00bf8310, 0x00bfa310, 0x00bfc310, 0x00bfe310, + 0x00c00310, 0x00c02310, 0x00c04310, 0x00c06310, + 0x00c08310, 0x00c0a310, 0x00c0c310, 0x00c0e310, + 0x00c10310, 0x00c12310, 0x00c14310, 0x00c16310, + 0x00c18310, 0x00c1a310, 0x00c1c310, 0x00c1e310, + 0x00c20310, 0x00c22310, 0x00c24310, 0x00c26310, + 0x00c28310, 0x00c2a310, 0x00c2c310, 0x00c2e310, + 0x00c30310, 0x00c32310, 0x00c34310, 0x00c36310, + 0x00c38310, 0x00c3a310, 0x00c3c310, 0x00c3e310, + 0x00c40310, 0x00c42310, 0x00c44310, 0x00c46310, + 0x00c48310, 0x00c4a310, 0x00c4c310, 0x00c4e310, + 0x00c50310, 0x00c52310, 0x00c54310, 0x00c56310, + 0x00c58310, 0x00c5a310, 0x00c5c310, 0x00c5e310, + 0x00c60310, 0x00c62310, 0x00c64310, 0x00c66310, + 0x00c68310, 0x00c6a310, 0x00c6c310, 0x00c6e310, + 0x00c70310, 0x00c72310, 0x00c74310, 0x00c76310, + 0x00c78310, 0x00c7a310, 0x00c7c310, 0x00c7e310, + 0x00c80310, 0x00c82310, 0x00c84310, 0x00c86310, + 0x00c88310, 0x00c8a310, 0x00c8c310, 0x00c8e310, + 0x00c90310, 0x00c92310, 0x00c94310, 0x00c96310, + 0x00c98310, 0x00c9a310, 0x00c9c310, 0x00c9e310, + 0x00ca0310, 0x00ca2310, 0x00ca4310, 0x00ca6310, + 0x00ca8310, 0x00caa310, 0x00cac310, 0x00cae310, + 0x00cb0310, 0x00cb2310, 0x00cb4310, 0x00cb6310, + 0x00cb8310, 0x00cba310, 0x00cbc310, 0x00cbe310, + 0x00cc0310, 0x00cc2310, 0x00cc4310, 0x00cc6310, + 0x00cc8310, 0x00cca310, 0x00ccc310, 0x00cce310, + 0x00cd0310, 0x00cd2310, 0x00cd4310, 0x00cd6310, + 0x00cd8310, 0x00cda310, 0x00cdc310, 0x00cde310, + 0x00ce0310, 0x00ce2310, 0x00ce4310, 0x00ce6310, + 0x00ce8310, 0x00cea310, 0x00cec310, 0x00cee310, + 0x00cf0310, 0x00cf2310, 0x00cf4310, 0x00cf6310, + 0x00cf8310, 0x00cfa310, 0x00cfc310, 0x00cfe310, + 0x00d00310, 0x00d02310, 0x00d04310, 0x00d06310, + 0x00d08310, 0x00d0a310, 0x00d0c310, 0x00d0e310, + 0x00d10310, 0x00d12310, 0x00d14310, 0x00d16310, + 0x00d18310, 0x00d1a310, 0x00d1c310, 0x00d1e310, + 0x00d20310, 0x00d22310, 0x00d24310, 0x00d26310, + 0x00d28310, 0x00d2a310, 0x00d2c310, 0x00d2e310, + 0x00d30310, 0x00d32310, 0x00d34310, 0x00d36310, + 0x00d38310, 0x00d3a310, 0x00d3c310, 0x00d3e310, + 0x00d40310, 0x00d42310, 0x00d44310, 0x00d46310, + 0x00d48310, 0x00d4a310, 0x00d4c310, 0x00d4e310, + 0x00d50310, 0x00d52310, 0x00d54310, 0x00d56310, + 0x00d58310, 0x00d5a310, 0x00d5c310, 0x00d5e310, + 0x00d60310, 0x00d62310, 0x00d64310, 0x00d66310, + 0x00d68310, 0x00d6a310, 0x00d6c310, 0x00d6e310, + 0x00d70310, 0x00d72310, 0x00d74310, 0x00d76310, + 0x00d78310, 0x00d7a310, 0x00d7c310, 0x00d7e310, + 0x00d80310, 0x00d82310, 0x00d84310, 0x00d86310, + 0x00d88310, 0x00d8a310, 0x00d8c310, 0x00d8e310, + 0x00d90310, 0x00d92310, 0x00d94310, 0x00d96310, + 0x00d98310, 0x00d9a310, 0x00d9c310, 0x00d9e310, + 0x00da0310, 0x00da2310, 0x00da4310, 0x00da6310, + 0x00da8310, 0x00daa310, 0x00dac310, 0x00dae310, + 0x00db0310, 0x00db2310, 0x00db4310, 0x00db6310, + 0x00db8310, 0x00dba310, 0x00dbc310, 0x00dbe310, + 0x00dc0310, 0x00dc2310, 0x00dc4310, 0x00dc6310, + 0x00dc8310, 0x00dca310, 0x00dcc310, 0x00dce310, + 0x00dd0310, 0x00dd2310, 0x00dd4310, 0x00dd6310, + 0x00dd8310, 0x00dda310, 0x00ddc310, 0x00dde310, + 0x00de0310, 0x00de2310, 0x00de4310, 0x00de6310, + 0x00de8310, 0x00dea310, 0x00dec310, 0x00dee310, + 0x00df0310, 0x00df2310, 0x00df4310, 0x00df6310, + 0x00df8310, 0x00dfa310, 0x00dfc310, 0x00dfe310, + 0x00e00310, 0x00e02310, 0x00e04310, 0x00e06310, + 0x00e08310, 0x00e0a310, 0x00e0c310, 0x00e0e310, + 0x00e10310, 0x00e12310, 0x00e14310, 0x00e16310, + 0x00e18310, 0x00e1a310, 0x00e1c310, 0x00e1e310, + 0x00e20310, 0x00e22310, 0x00e24310, 0x00e26310, + 0x00e28310, 0x00e2a310, 0x00e2c310, 0x00e2e310, + 0x00e30310, 0x00e32310, 0x00e34310, 0x00e36310, + 0x00e38310, 0x00e3a310, 0x00e3c310, 0x00e3e310, + 0x00e40310, 0x00e42310, 0x00e44310, 0x00e46310, + 0x00e48310, 0x00e4a310, 0x00e4c310, 0x00e4e310, + 0x00e50310, 0x00e52310, 0x00e54310, 0x00e56310, + 0x00e58310, 0x00e5a310, 0x00e5c310, 0x00e5e310, + 0x00e60310, 0x00e62310, 0x00e64310, 0x00e66310, + 0x00e68310, 0x00e6a310, 0x00e6c310, 0x00e6e310, + 0x00e70310, 0x00e72310, 0x00e74310, 0x00e76310, + 0x00e78310, 0x00e7a310, 0x00e7c310, 0x00e7e310, + 0x00e80310, 0x00e82310, 0x00e84310, 0x00e86310, + 0x00e88310, 0x00e8a310, 0x00e8c310, 0x00e8e310, + 0x00e90310, 0x00e92310, 0x00e94310, 0x00e96310, + 0x00e98310, 0x00e9a310, 0x00e9c310, 0x00e9e310, + 0x00ea0310, 0x00ea2310, 0x00ea4310, 0x00ea6310, + 0x00ea8310, 0x00eaa310, 0x00eac310, 0x00eae310, + 0x00eb0310, 0x00eb2310, 0x00eb4310, 0x00eb6310, + 0x00eb8310, 0x00eba310, 0x00ebc310, 0x00ebe310, + 0x00ec0310, 0x00ec2310, 0x00ec4310, 0x00ec6310, + 0x00ec8310, 0x00eca310, 0x00ecc310, 0x00ece310, + 0x00ed0310, 0x00ed2310, 0x00ed4310, 0x00ed6310, + 0x00ed8310, 0x00eda310, 0x00edc310, 0x00ede310, + 0x00ee0310, 0x00ee2310, 0x00ee4310, 0x00ee6310, + 0x00ee8310, 0x00eea310, 0x00eec310, 0x00eee310, + 0x00ef0310, 0x00ef2310, 0x00ef4310, 0x00ef6310, + 0x00ef8310, 0x00efa310, 0x00efc310, 0x00efe310, + 0x00f00310, 0x00f02310, 0x00f04310, 0x00f06310, + 0x00f08310, 0x00f0a310, 0x00f0c310, 0x00f0e310, + 0x00f10310, 0x00f12310, 0x00f14310, 0x00f16310, + 0x00f18310, 0x00f1a310, 0x00f1c310, 0x00f1e310, + 0x00f20310, 0x00f22310, 0x00f24310, 0x00f26310, + 0x00f28310, 0x00f2a310, 0x00f2c310, 0x00f2e310, + 0x00f30310, 0x00f32310, 0x00f34310, 0x00f36310, + 0x00f38310, 0x00f3a310, 0x00f3c310, 0x00f3e310, + 0x00f40310, 0x00f42310, 0x00f44310, 0x00f46310, + 0x00f48310, 0x00f4a310, 0x00f4c310, 0x00f4e310, + 0x00f50310, 0x00f52310, 0x00f54310, 0x00f56310, + 0x00f58310, 0x00f5a310, 0x00f5c310, 0x00f5e310, + 0x00f60310, 0x00f62310, 0x00f64310, 0x00f66310, + 0x00f68310, 0x00f6a310, 0x00f6c310, 0x00f6e310, + 0x00f70310, 0x00f72310, 0x00f74310, 0x00f76310, + 0x00f78310, 0x00f7a310, 0x00f7c310, 0x00f7e310, + 0x00f80310, 0x00f82310, 0x00f84310, 0x00f86310, + 0x00f88310, 0x00f8a310, 0x00f8c310, 0x00f8e310, + 0x00f90310, 0x00f92310, 0x00f94310, 0x00f96310, + 0x00f98310, 0x00f9a310, 0x00f9c310, 0x00f9e310, + 0x00fa0310, 0x00fa2310, 0x00fa4310, 0x00fa6310, + 0x00fa8310, 0x00faa310, 0x00fac310, 0x00fae310, + 0x00fb0310, 0x00fb2310, 0x00fb4310, 0x00fb6310, + 0x00fb8310, 0x00fba310, 0x00fbc310, 0x00fbe310, + 0x00fc0310, 0x00fc2310, 0x00fc4310, 0x00fc6310, + 0x00fc8310, 0x00fca310, 0x00fcc310, 0x00fce310, + 0x00fd0310, 0x00fd2310, 0x00fd4310, 0x00fd6310, + 0x00fd8310, 0x00fda310, 0x00fdc310, 0x00fde310, + 0x00fe0310, 0x00fe2310, 0x00fe4310, 0x00fe6310, + 0x00fe8310, 0x00fea310, 0x00fec310, 0x00fee310, + 0x00ff0310, 0x00ff2310, 0x00ff4310, 0x00ff6310, + 0x00ff8310, 0x00ffa310, 0x00ffc310, 0x00ffe310, + 0x00001310, 0x00003310, 0x00005310, 0x00007310, + 0x00009310, 0x0000b310, 0x0000d310, 0x0000f310, + 0x00011310, 0x00013310, 0x00015310, 0x00017310, + 0x00019310, 0x0001b310, 0x0001d310, 0x0001f310, + 0x00021310, 0x00023310, 0x00025310, 0x00027310, + 0x00029310, 0x0002b310, 0x0002d310, 0x0002f310, + 0x00031310, 0x00033310, 0x00035310, 0x00037310, + 0x00039310, 0x0003b310, 0x0003d310, 0x0003f310, + 0x00041310, 0x00043310, 0x00045310, 0x00047310, + 0x00049310, 0x0004b310, 0x0004d310, 0x0004f310, + 0x00051310, 0x00053310, 0x00055310, 0x00057310, + 0x00059310, 0x0005b310, 0x0005d310, 0x0005f310, + 0x00061310, 0x00063310, 0x00065310, 0x00067310, + 0x00069310, 0x0006b310, 0x0006d310, 0x0006f310, + 0x00071310, 0x00073310, 0x00075310, 0x00077310, + 0x00079310, 0x0007b310, 0x0007d310, 0x0007f310, + 0x00081310, 0x00083310, 0x00085310, 0x00087310, + 0x00089310, 0x0008b310, 0x0008d310, 0x0008f310, + 0x00091310, 0x00093310, 0x00095310, 0x00097310, + 0x00099310, 0x0009b310, 0x0009d310, 0x0009f310, + 0x000a1310, 0x000a3310, 0x000a5310, 0x000a7310, + 0x000a9310, 0x000ab310, 0x000ad310, 0x000af310, + 0x000b1310, 0x000b3310, 0x000b5310, 0x000b7310, + 0x000b9310, 0x000bb310, 0x000bd310, 0x000bf310, + 0x000c1310, 0x000c3310, 0x000c5310, 0x000c7310, + 0x000c9310, 0x000cb310, 0x000cd310, 0x000cf310, + 0x000d1310, 0x000d3310, 0x000d5310, 0x000d7310, + 0x000d9310, 0x000db310, 0x000dd310, 0x000df310, + 0x000e1310, 0x000e3310, 0x000e5310, 0x000e7310, + 0x000e9310, 0x000eb310, 0x000ed310, 0x000ef310, + 0x000f1310, 0x000f3310, 0x000f5310, 0x000f7310, + 0x000f9310, 0x000fb310, 0x000fd310, 0x000ff310, + 0x00101310, 0x00103310, 0x00105310, 0x00107310, + 0x00109310, 0x0010b310, 0x0010d310, 0x0010f310, + 0x00111310, 0x00113310, 0x00115310, 0x00117310, + 0x00119310, 0x0011b310, 0x0011d310, 0x0011f310, + 0x00121310, 0x00123310, 0x00125310, 0x00127310, + 0x00129310, 0x0012b310, 0x0012d310, 0x0012f310, + 0x00131310, 0x00133310, 0x00135310, 0x00137310, + 0x00139310, 0x0013b310, 0x0013d310, 0x0013f310, + 0x00141310, 0x00143310, 0x00145310, 0x00147310, + 0x00149310, 0x0014b310, 0x0014d310, 0x0014f310, + 0x00151310, 0x00153310, 0x00155310, 0x00157310, + 0x00159310, 0x0015b310, 0x0015d310, 0x0015f310, + 0x00161310, 0x00163310, 0x00165310, 0x00167310, + 0x00169310, 0x0016b310, 0x0016d310, 0x0016f310, + 0x00171310, 0x00173310, 0x00175310, 0x00177310, + 0x00179310, 0x0017b310, 0x0017d310, 0x0017f310, + 0x00181310, 0x00183310, 0x00185310, 0x00187310, + 0x00189310, 0x0018b310, 0x0018d310, 0x0018f310, + 0x00191310, 0x00193310, 0x00195310, 0x00197310, + 0x00199310, 0x0019b310, 0x0019d310, 0x0019f310, + 0x001a1310, 0x001a3310, 0x001a5310, 0x001a7310, + 0x001a9310, 0x001ab310, 0x001ad310, 0x001af310, + 0x001b1310, 0x001b3310, 0x001b5310, 0x001b7310, + 0x001b9310, 0x001bb310, 0x001bd310, 0x001bf310, + 0x001c1310, 0x001c3310, 0x001c5310, 0x001c7310, + 0x001c9310, 0x001cb310, 0x001cd310, 0x001cf310, + 0x001d1310, 0x001d3310, 0x001d5310, 0x001d7310, + 0x001d9310, 0x001db310, 0x001dd310, 0x001df310, + 0x001e1310, 0x001e3310, 0x001e5310, 0x001e7310, + 0x001e9310, 0x001eb310, 0x001ed310, 0x001ef310, + 0x001f1310, 0x001f3310, 0x001f5310, 0x001f7310, + 0x001f9310, 0x001fb310, 0x001fd310, 0x001ff310, + 0x00201310, 0x00203310, 0x00205310, 0x00207310, + 0x00209310, 0x0020b310, 0x0020d310, 0x0020f310, + 0x00211310, 0x00213310, 0x00215310, 0x00217310, + 0x00219310, 0x0021b310, 0x0021d310, 0x0021f310, + 0x00221310, 0x00223310, 0x00225310, 0x00227310, + 0x00229310, 0x0022b310, 0x0022d310, 0x0022f310, + 0x00231310, 0x00233310, 0x00235310, 0x00237310, + 0x00239310, 0x0023b310, 0x0023d310, 0x0023f310, + 0x00241310, 0x00243310, 0x00245310, 0x00247310, + 0x00249310, 0x0024b310, 0x0024d310, 0x0024f310, + 0x00251310, 0x00253310, 0x00255310, 0x00257310, + 0x00259310, 0x0025b310, 0x0025d310, 0x0025f310, + 0x00261310, 0x00263310, 0x00265310, 0x00267310, + 0x00269310, 0x0026b310, 0x0026d310, 0x0026f310, + 0x00271310, 0x00273310, 0x00275310, 0x00277310, + 0x00279310, 0x0027b310, 0x0027d310, 0x0027f310, + 0x00281310, 0x00283310, 0x00285310, 0x00287310, + 0x00289310, 0x0028b310, 0x0028d310, 0x0028f310, + 0x00291310, 0x00293310, 0x00295310, 0x00297310, + 0x00299310, 0x0029b310, 0x0029d310, 0x0029f310, + 0x002a1310, 0x002a3310, 0x002a5310, 0x002a7310, + 0x002a9310, 0x002ab310, 0x002ad310, 0x002af310, + 0x002b1310, 0x002b3310, 0x002b5310, 0x002b7310, + 0x002b9310, 0x002bb310, 0x002bd310, 0x002bf310, + 0x002c1310, 0x002c3310, 0x002c5310, 0x002c7310, + 0x002c9310, 0x002cb310, 0x002cd310, 0x002cf310, + 0x002d1310, 0x002d3310, 0x002d5310, 0x002d7310, + 0x002d9310, 0x002db310, 0x002dd310, 0x002df310, + 0x002e1310, 0x002e3310, 0x002e5310, 0x002e7310, + 0x002e9310, 0x002eb310, 0x002ed310, 0x002ef310, + 0x002f1310, 0x002f3310, 0x002f5310, 0x002f7310, + 0x002f9310, 0x002fb310, 0x002fd310, 0x002ff310, + 0x00301310, 0x00303310, 0x00305310, 0x00307310, + 0x00309310, 0x0030b310, 0x0030d310, 0x0030f310, + 0x00311310, 0x00313310, 0x00315310, 0x00317310, + 0x00319310, 0x0031b310, 0x0031d310, 0x0031f310, + 0x00321310, 0x00323310, 0x00325310, 0x00327310, + 0x00329310, 0x0032b310, 0x0032d310, 0x0032f310, + 0x00331310, 0x00333310, 0x00335310, 0x00337310, + 0x00339310, 0x0033b310, 0x0033d310, 0x0033f310, + 0x00341310, 0x00343310, 0x00345310, 0x00347310, + 0x00349310, 0x0034b310, 0x0034d310, 0x0034f310, + 0x00351310, 0x00353310, 0x00355310, 0x00357310, + 0x00359310, 0x0035b310, 0x0035d310, 0x0035f310, + 0x00361310, 0x00363310, 0x00365310, 0x00367310, + 0x00369310, 0x0036b310, 0x0036d310, 0x0036f310, + 0x00371310, 0x00373310, 0x00375310, 0x00377310, + 0x00379310, 0x0037b310, 0x0037d310, 0x0037f310, + 0x00381310, 0x00383310, 0x00385310, 0x00387310, + 0x00389310, 0x0038b310, 0x0038d310, 0x0038f310, + 0x00391310, 0x00393310, 0x00395310, 0x00397310, + 0x00399310, 0x0039b310, 0x0039d310, 0x0039f310, + 0x003a1310, 0x003a3310, 0x003a5310, 0x003a7310, + 0x003a9310, 0x003ab310, 0x003ad310, 0x003af310, + 0x003b1310, 0x003b3310, 0x003b5310, 0x003b7310, + 0x003b9310, 0x003bb310, 0x003bd310, 0x003bf310, + 0x003c1310, 0x003c3310, 0x003c5310, 0x003c7310, + 0x003c9310, 0x003cb310, 0x003cd310, 0x003cf310, + 0x003d1310, 0x003d3310, 0x003d5310, 0x003d7310, + 0x003d9310, 0x003db310, 0x003dd310, 0x003df310, + 0x003e1310, 0x003e3310, 0x003e5310, 0x003e7310, + 0x003e9310, 0x003eb310, 0x003ed310, 0x003ef310, + 0x003f1310, 0x003f3310, 0x003f5310, 0x003f7310, + 0x003f9310, 0x003fb310, 0x003fd310, 0x003ff310, + 0x00401310, 0x00403310, 0x00405310, 0x00407310, + 0x00409310, 0x0040b310, 0x0040d310, 0x0040f310, + 0x00411310, 0x00413310, 0x00415310, 0x00417310, + 0x00419310, 0x0041b310, 0x0041d310, 0x0041f310, + 0x00421310, 0x00423310, 0x00425310, 0x00427310, + 0x00429310, 0x0042b310, 0x0042d310, 0x0042f310, + 0x00431310, 0x00433310, 0x00435310, 0x00437310, + 0x00439310, 0x0043b310, 0x0043d310, 0x0043f310, + 0x00441310, 0x00443310, 0x00445310, 0x00447310, + 0x00449310, 0x0044b310, 0x0044d310, 0x0044f310, + 0x00451310, 0x00453310, 0x00455310, 0x00457310, + 0x00459310, 0x0045b310, 0x0045d310, 0x0045f310, + 0x00461310, 0x00463310, 0x00465310, 0x00467310, + 0x00469310, 0x0046b310, 0x0046d310, 0x0046f310, + 0x00471310, 0x00473310, 0x00475310, 0x00477310, + 0x00479310, 0x0047b310, 0x0047d310, 0x0047f310, + 0x00481310, 0x00483310, 0x00485310, 0x00487310, + 0x00489310, 0x0048b310, 0x0048d310, 0x0048f310, + 0x00491310, 0x00493310, 0x00495310, 0x00497310, + 0x00499310, 0x0049b310, 0x0049d310, 0x0049f310, + 0x004a1310, 0x004a3310, 0x004a5310, 0x004a7310, + 0x004a9310, 0x004ab310, 0x004ad310, 0x004af310, + 0x004b1310, 0x004b3310, 0x004b5310, 0x004b7310, + 0x004b9310, 0x004bb310, 0x004bd310, 0x004bf310, + 0x004c1310, 0x004c3310, 0x004c5310, 0x004c7310, + 0x004c9310, 0x004cb310, 0x004cd310, 0x004cf310, + 0x004d1310, 0x004d3310, 0x004d5310, 0x004d7310, + 0x004d9310, 0x004db310, 0x004dd310, 0x004df310, + 0x004e1310, 0x004e3310, 0x004e5310, 0x004e7310, + 0x004e9310, 0x004eb310, 0x004ed310, 0x004ef310, + 0x004f1310, 0x004f3310, 0x004f5310, 0x004f7310, + 0x004f9310, 0x004fb310, 0x004fd310, 0x004ff310, + 0x00501310, 0x00503310, 0x00505310, 0x00507310, + 0x00509310, 0x0050b310, 0x0050d310, 0x0050f310, + 0x00511310, 0x00513310, 0x00515310, 0x00517310, + 0x00519310, 0x0051b310, 0x0051d310, 0x0051f310, + 0x00521310, 0x00523310, 0x00525310, 0x00527310, + 0x00529310, 0x0052b310, 0x0052d310, 0x0052f310, + 0x00531310, 0x00533310, 0x00535310, 0x00537310, + 0x00539310, 0x0053b310, 0x0053d310, 0x0053f310, + 0x00541310, 0x00543310, 0x00545310, 0x00547310, + 0x00549310, 0x0054b310, 0x0054d310, 0x0054f310, + 0x00551310, 0x00553310, 0x00555310, 0x00557310, + 0x00559310, 0x0055b310, 0x0055d310, 0x0055f310, + 0x00561310, 0x00563310, 0x00565310, 0x00567310, + 0x00569310, 0x0056b310, 0x0056d310, 0x0056f310, + 0x00571310, 0x00573310, 0x00575310, 0x00577310, + 0x00579310, 0x0057b310, 0x0057d310, 0x0057f310, + 0x00581310, 0x00583310, 0x00585310, 0x00587310, + 0x00589310, 0x0058b310, 0x0058d310, 0x0058f310, + 0x00591310, 0x00593310, 0x00595310, 0x00597310, + 0x00599310, 0x0059b310, 0x0059d310, 0x0059f310, + 0x005a1310, 0x005a3310, 0x005a5310, 0x005a7310, + 0x005a9310, 0x005ab310, 0x005ad310, 0x005af310, + 0x005b1310, 0x005b3310, 0x005b5310, 0x005b7310, + 0x005b9310, 0x005bb310, 0x005bd310, 0x005bf310, + 0x005c1310, 0x005c3310, 0x005c5310, 0x005c7310, + 0x005c9310, 0x005cb310, 0x005cd310, 0x005cf310, + 0x005d1310, 0x005d3310, 0x005d5310, 0x005d7310, + 0x005d9310, 0x005db310, 0x005dd310, 0x005df310, + 0x005e1310, 0x005e3310, 0x005e5310, 0x005e7310, + 0x005e9310, 0x005eb310, 0x005ed310, 0x005ef310, + 0x005f1310, 0x005f3310, 0x005f5310, 0x005f7310, + 0x005f9310, 0x005fb310, 0x005fd310, 0x005ff310, + 0x00601310, 0x00603310, 0x00605310, 0x00607310, + 0x00609310, 0x0060b310, 0x0060d310, 0x0060f310, + 0x00611310, 0x00613310, 0x00615310, 0x00617310, + 0x00619310, 0x0061b310, 0x0061d310, 0x0061f310, + 0x00621310, 0x00623310, 0x00625310, 0x00627310, + 0x00629310, 0x0062b310, 0x0062d310, 0x0062f310, + 0x00631310, 0x00633310, 0x00635310, 0x00637310, + 0x00639310, 0x0063b310, 0x0063d310, 0x0063f310, + 0x00641310, 0x00643310, 0x00645310, 0x00647310, + 0x00649310, 0x0064b310, 0x0064d310, 0x0064f310, + 0x00651310, 0x00653310, 0x00655310, 0x00657310, + 0x00659310, 0x0065b310, 0x0065d310, 0x0065f310, + 0x00661310, 0x00663310, 0x00665310, 0x00667310, + 0x00669310, 0x0066b310, 0x0066d310, 0x0066f310, + 0x00671310, 0x00673310, 0x00675310, 0x00677310, + 0x00679310, 0x0067b310, 0x0067d310, 0x0067f310, + 0x00681310, 0x00683310, 0x00685310, 0x00687310, + 0x00689310, 0x0068b310, 0x0068d310, 0x0068f310, + 0x00691310, 0x00693310, 0x00695310, 0x00697310, + 0x00699310, 0x0069b310, 0x0069d310, 0x0069f310, + 0x006a1310, 0x006a3310, 0x006a5310, 0x006a7310, + 0x006a9310, 0x006ab310, 0x006ad310, 0x006af310, + 0x006b1310, 0x006b3310, 0x006b5310, 0x006b7310, + 0x006b9310, 0x006bb310, 0x006bd310, 0x006bf310, + 0x006c1310, 0x006c3310, 0x006c5310, 0x006c7310, + 0x006c9310, 0x006cb310, 0x006cd310, 0x006cf310, + 0x006d1310, 0x006d3310, 0x006d5310, 0x006d7310, + 0x006d9310, 0x006db310, 0x006dd310, 0x006df310, + 0x006e1310, 0x006e3310, 0x006e5310, 0x006e7310, + 0x006e9310, 0x006eb310, 0x006ed310, 0x006ef310, + 0x006f1310, 0x006f3310, 0x006f5310, 0x006f7310, + 0x006f9310, 0x006fb310, 0x006fd310, 0x006ff310, + 0x00701310, 0x00703310, 0x00705310, 0x00707310, + 0x00709310, 0x0070b310, 0x0070d310, 0x0070f310, + 0x00711310, 0x00713310, 0x00715310, 0x00717310, + 0x00719310, 0x0071b310, 0x0071d310, 0x0071f310, + 0x00721310, 0x00723310, 0x00725310, 0x00727310, + 0x00729310, 0x0072b310, 0x0072d310, 0x0072f310, + 0x00731310, 0x00733310, 0x00735310, 0x00737310, + 0x00739310, 0x0073b310, 0x0073d310, 0x0073f310, + 0x00741310, 0x00743310, 0x00745310, 0x00747310, + 0x00749310, 0x0074b310, 0x0074d310, 0x0074f310, + 0x00751310, 0x00753310, 0x00755310, 0x00757310, + 0x00759310, 0x0075b310, 0x0075d310, 0x0075f310, + 0x00761310, 0x00763310, 0x00765310, 0x00767310, + 0x00769310, 0x0076b310, 0x0076d310, 0x0076f310, + 0x00771310, 0x00773310, 0x00775310, 0x00777310, + 0x00779310, 0x0077b310, 0x0077d310, 0x0077f310, + 0x00781310, 0x00783310, 0x00785310, 0x00787310, + 0x00789310, 0x0078b310, 0x0078d310, 0x0078f310, + 0x00791310, 0x00793310, 0x00795310, 0x00797310, + 0x00799310, 0x0079b310, 0x0079d310, 0x0079f310, + 0x007a1310, 0x007a3310, 0x007a5310, 0x007a7310, + 0x007a9310, 0x007ab310, 0x007ad310, 0x007af310, + 0x007b1310, 0x007b3310, 0x007b5310, 0x007b7310, + 0x007b9310, 0x007bb310, 0x007bd310, 0x007bf310, + 0x007c1310, 0x007c3310, 0x007c5310, 0x007c7310, + 0x007c9310, 0x007cb310, 0x007cd310, 0x007cf310, + 0x007d1310, 0x007d3310, 0x007d5310, 0x007d7310, + 0x007d9310, 0x007db310, 0x007dd310, 0x007df310, + 0x007e1310, 0x007e3310, 0x007e5310, 0x007e7310, + 0x007e9310, 0x007eb310, 0x007ed310, 0x007ef310, + 0x007f1310, 0x007f3310, 0x007f5310, 0x007f7310, + 0x007f9310, 0x007fb310, 0x007fd310, 0x007ff310, + 0x00801310, 0x00803310, 0x00805310, 0x00807310, + 0x00809310, 0x0080b310, 0x0080d310, 0x0080f310, + 0x00811310, 0x00813310, 0x00815310, 0x00817310, + 0x00819310, 0x0081b310, 0x0081d310, 0x0081f310, + 0x00821310, 0x00823310, 0x00825310, 0x00827310, + 0x00829310, 0x0082b310, 0x0082d310, 0x0082f310, + 0x00831310, 0x00833310, 0x00835310, 0x00837310, + 0x00839310, 0x0083b310, 0x0083d310, 0x0083f310, + 0x00841310, 0x00843310, 0x00845310, 0x00847310, + 0x00849310, 0x0084b310, 0x0084d310, 0x0084f310, + 0x00851310, 0x00853310, 0x00855310, 0x00857310, + 0x00859310, 0x0085b310, 0x0085d310, 0x0085f310, + 0x00861310, 0x00863310, 0x00865310, 0x00867310, + 0x00869310, 0x0086b310, 0x0086d310, 0x0086f310, + 0x00871310, 0x00873310, 0x00875310, 0x00877310, + 0x00879310, 0x0087b310, 0x0087d310, 0x0087f310, + 0x00881310, 0x00883310, 0x00885310, 0x00887310, + 0x00889310, 0x0088b310, 0x0088d310, 0x0088f310, + 0x00891310, 0x00893310, 0x00895310, 0x00897310, + 0x00899310, 0x0089b310, 0x0089d310, 0x0089f310, + 0x008a1310, 0x008a3310, 0x008a5310, 0x008a7310, + 0x008a9310, 0x008ab310, 0x008ad310, 0x008af310, + 0x008b1310, 0x008b3310, 0x008b5310, 0x008b7310, + 0x008b9310, 0x008bb310, 0x008bd310, 0x008bf310, + 0x008c1310, 0x008c3310, 0x008c5310, 0x008c7310, + 0x008c9310, 0x008cb310, 0x008cd310, 0x008cf310, + 0x008d1310, 0x008d3310, 0x008d5310, 0x008d7310, + 0x008d9310, 0x008db310, 0x008dd310, 0x008df310, + 0x008e1310, 0x008e3310, 0x008e5310, 0x008e7310, + 0x008e9310, 0x008eb310, 0x008ed310, 0x008ef310, + 0x008f1310, 0x008f3310, 0x008f5310, 0x008f7310, + 0x008f9310, 0x008fb310, 0x008fd310, 0x008ff310, + 0x00901310, 0x00903310, 0x00905310, 0x00907310, + 0x00909310, 0x0090b310, 0x0090d310, 0x0090f310, + 0x00911310, 0x00913310, 0x00915310, 0x00917310, + 0x00919310, 0x0091b310, 0x0091d310, 0x0091f310, + 0x00921310, 0x00923310, 0x00925310, 0x00927310, + 0x00929310, 0x0092b310, 0x0092d310, 0x0092f310, + 0x00931310, 0x00933310, 0x00935310, 0x00937310, + 0x00939310, 0x0093b310, 0x0093d310, 0x0093f310, + 0x00941310, 0x00943310, 0x00945310, 0x00947310, + 0x00949310, 0x0094b310, 0x0094d310, 0x0094f310, + 0x00951310, 0x00953310, 0x00955310, 0x00957310, + 0x00959310, 0x0095b310, 0x0095d310, 0x0095f310, + 0x00961310, 0x00963310, 0x00965310, 0x00967310, + 0x00969310, 0x0096b310, 0x0096d310, 0x0096f310, + 0x00971310, 0x00973310, 0x00975310, 0x00977310, + 0x00979310, 0x0097b310, 0x0097d310, 0x0097f310, + 0x00981310, 0x00983310, 0x00985310, 0x00987310, + 0x00989310, 0x0098b310, 0x0098d310, 0x0098f310, + 0x00991310, 0x00993310, 0x00995310, 0x00997310, + 0x00999310, 0x0099b310, 0x0099d310, 0x0099f310, + 0x009a1310, 0x009a3310, 0x009a5310, 0x009a7310, + 0x009a9310, 0x009ab310, 0x009ad310, 0x009af310, + 0x009b1310, 0x009b3310, 0x009b5310, 0x009b7310, + 0x009b9310, 0x009bb310, 0x009bd310, 0x009bf310, + 0x009c1310, 0x009c3310, 0x009c5310, 0x009c7310, + 0x009c9310, 0x009cb310, 0x009cd310, 0x009cf310, + 0x009d1310, 0x009d3310, 0x009d5310, 0x009d7310, + 0x009d9310, 0x009db310, 0x009dd310, 0x009df310, + 0x009e1310, 0x009e3310, 0x009e5310, 0x009e7310, + 0x009e9310, 0x009eb310, 0x009ed310, 0x009ef310, + 0x009f1310, 0x009f3310, 0x009f5310, 0x009f7310, + 0x009f9310, 0x009fb310, 0x009fd310, 0x009ff310, + 0x00a01310, 0x00a03310, 0x00a05310, 0x00a07310, + 0x00a09310, 0x00a0b310, 0x00a0d310, 0x00a0f310, + 0x00a11310, 0x00a13310, 0x00a15310, 0x00a17310, + 0x00a19310, 0x00a1b310, 0x00a1d310, 0x00a1f310, + 0x00a21310, 0x00a23310, 0x00a25310, 0x00a27310, + 0x00a29310, 0x00a2b310, 0x00a2d310, 0x00a2f310, + 0x00a31310, 0x00a33310, 0x00a35310, 0x00a37310, + 0x00a39310, 0x00a3b310, 0x00a3d310, 0x00a3f310, + 0x00a41310, 0x00a43310, 0x00a45310, 0x00a47310, + 0x00a49310, 0x00a4b310, 0x00a4d310, 0x00a4f310, + 0x00a51310, 0x00a53310, 0x00a55310, 0x00a57310, + 0x00a59310, 0x00a5b310, 0x00a5d310, 0x00a5f310, + 0x00a61310, 0x00a63310, 0x00a65310, 0x00a67310, + 0x00a69310, 0x00a6b310, 0x00a6d310, 0x00a6f310, + 0x00a71310, 0x00a73310, 0x00a75310, 0x00a77310, + 0x00a79310, 0x00a7b310, 0x00a7d310, 0x00a7f310, + 0x00a81310, 0x00a83310, 0x00a85310, 0x00a87310, + 0x00a89310, 0x00a8b310, 0x00a8d310, 0x00a8f310, + 0x00a91310, 0x00a93310, 0x00a95310, 0x00a97310, + 0x00a99310, 0x00a9b310, 0x00a9d310, 0x00a9f310, + 0x00aa1310, 0x00aa3310, 0x00aa5310, 0x00aa7310, + 0x00aa9310, 0x00aab310, 0x00aad310, 0x00aaf310, + 0x00ab1310, 0x00ab3310, 0x00ab5310, 0x00ab7310, + 0x00ab9310, 0x00abb310, 0x00abd310, 0x00abf310, + 0x00ac1310, 0x00ac3310, 0x00ac5310, 0x00ac7310, + 0x00ac9310, 0x00acb310, 0x00acd310, 0x00acf310, + 0x00ad1310, 0x00ad3310, 0x00ad5310, 0x00ad7310, + 0x00ad9310, 0x00adb310, 0x00add310, 0x00adf310, + 0x00ae1310, 0x00ae3310, 0x00ae5310, 0x00ae7310, + 0x00ae9310, 0x00aeb310, 0x00aed310, 0x00aef310, + 0x00af1310, 0x00af3310, 0x00af5310, 0x00af7310, + 0x00af9310, 0x00afb310, 0x00afd310, 0x00aff310, + 0x00b01310, 0x00b03310, 0x00b05310, 0x00b07310, + 0x00b09310, 0x00b0b310, 0x00b0d310, 0x00b0f310, + 0x00b11310, 0x00b13310, 0x00b15310, 0x00b17310, + 0x00b19310, 0x00b1b310, 0x00b1d310, 0x00b1f310, + 0x00b21310, 0x00b23310, 0x00b25310, 0x00b27310, + 0x00b29310, 0x00b2b310, 0x00b2d310, 0x00b2f310, + 0x00b31310, 0x00b33310, 0x00b35310, 0x00b37310, + 0x00b39310, 0x00b3b310, 0x00b3d310, 0x00b3f310, + 0x00b41310, 0x00b43310, 0x00b45310, 0x00b47310, + 0x00b49310, 0x00b4b310, 0x00b4d310, 0x00b4f310, + 0x00b51310, 0x00b53310, 0x00b55310, 0x00b57310, + 0x00b59310, 0x00b5b310, 0x00b5d310, 0x00b5f310, + 0x00b61310, 0x00b63310, 0x00b65310, 0x00b67310, + 0x00b69310, 0x00b6b310, 0x00b6d310, 0x00b6f310, + 0x00b71310, 0x00b73310, 0x00b75310, 0x00b77310, + 0x00b79310, 0x00b7b310, 0x00b7d310, 0x00b7f310, + 0x00b81310, 0x00b83310, 0x00b85310, 0x00b87310, + 0x00b89310, 0x00b8b310, 0x00b8d310, 0x00b8f310, + 0x00b91310, 0x00b93310, 0x00b95310, 0x00b97310, + 0x00b99310, 0x00b9b310, 0x00b9d310, 0x00b9f310, + 0x00ba1310, 0x00ba3310, 0x00ba5310, 0x00ba7310, + 0x00ba9310, 0x00bab310, 0x00bad310, 0x00baf310, + 0x00bb1310, 0x00bb3310, 0x00bb5310, 0x00bb7310, + 0x00bb9310, 0x00bbb310, 0x00bbd310, 0x00bbf310, + 0x00bc1310, 0x00bc3310, 0x00bc5310, 0x00bc7310, + 0x00bc9310, 0x00bcb310, 0x00bcd310, 0x00bcf310, + 0x00bd1310, 0x00bd3310, 0x00bd5310, 0x00bd7310, + 0x00bd9310, 0x00bdb310, 0x00bdd310, 0x00bdf310, + 0x00be1310, 0x00be3310, 0x00be5310, 0x00be7310, + 0x00be9310, 0x00beb310, 0x00bed310, 0x00bef310, + 0x00bf1310, 0x00bf3310, 0x00bf5310, 0x00bf7310, + 0x00bf9310, 0x00bfb310, 0x00bfd310, 0x00bff310, + 0x00c01310, 0x00c03310, 0x00c05310, 0x00c07310, + 0x00c09310, 0x00c0b310, 0x00c0d310, 0x00c0f310, + 0x00c11310, 0x00c13310, 0x00c15310, 0x00c17310, + 0x00c19310, 0x00c1b310, 0x00c1d310, 0x00c1f310, + 0x00c21310, 0x00c23310, 0x00c25310, 0x00c27310, + 0x00c29310, 0x00c2b310, 0x00c2d310, 0x00c2f310, + 0x00c31310, 0x00c33310, 0x00c35310, 0x00c37310, + 0x00c39310, 0x00c3b310, 0x00c3d310, 0x00c3f310, + 0x00c41310, 0x00c43310, 0x00c45310, 0x00c47310, + 0x00c49310, 0x00c4b310, 0x00c4d310, 0x00c4f310, + 0x00c51310, 0x00c53310, 0x00c55310, 0x00c57310, + 0x00c59310, 0x00c5b310, 0x00c5d310, 0x00c5f310, + 0x00c61310, 0x00c63310, 0x00c65310, 0x00c67310, + 0x00c69310, 0x00c6b310, 0x00c6d310, 0x00c6f310, + 0x00c71310, 0x00c73310, 0x00c75310, 0x00c77310, + 0x00c79310, 0x00c7b310, 0x00c7d310, 0x00c7f310, + 0x00c81310, 0x00c83310, 0x00c85310, 0x00c87310, + 0x00c89310, 0x00c8b310, 0x00c8d310, 0x00c8f310, + 0x00c91310, 0x00c93310, 0x00c95310, 0x00c97310, + 0x00c99310, 0x00c9b310, 0x00c9d310, 0x00c9f310, + 0x00ca1310, 0x00ca3310, 0x00ca5310, 0x00ca7310, + 0x00ca9310, 0x00cab310, 0x00cad310, 0x00caf310, + 0x00cb1310, 0x00cb3310, 0x00cb5310, 0x00cb7310, + 0x00cb9310, 0x00cbb310, 0x00cbd310, 0x00cbf310, + 0x00cc1310, 0x00cc3310, 0x00cc5310, 0x00cc7310, + 0x00cc9310, 0x00ccb310, 0x00ccd310, 0x00ccf310, + 0x00cd1310, 0x00cd3310, 0x00cd5310, 0x00cd7310, + 0x00cd9310, 0x00cdb310, 0x00cdd310, 0x00cdf310, + 0x00ce1310, 0x00ce3310, 0x00ce5310, 0x00ce7310, + 0x00ce9310, 0x00ceb310, 0x00ced310, 0x00cef310, + 0x00cf1310, 0x00cf3310, 0x00cf5310, 0x00cf7310, + 0x00cf9310, 0x00cfb310, 0x00cfd310, 0x00cff310, + 0x00d01310, 0x00d03310, 0x00d05310, 0x00d07310, + 0x00d09310, 0x00d0b310, 0x00d0d310, 0x00d0f310, + 0x00d11310, 0x00d13310, 0x00d15310, 0x00d17310, + 0x00d19310, 0x00d1b310, 0x00d1d310, 0x00d1f310, + 0x00d21310, 0x00d23310, 0x00d25310, 0x00d27310, + 0x00d29310, 0x00d2b310, 0x00d2d310, 0x00d2f310, + 0x00d31310, 0x00d33310, 0x00d35310, 0x00d37310, + 0x00d39310, 0x00d3b310, 0x00d3d310, 0x00d3f310, + 0x00d41310, 0x00d43310, 0x00d45310, 0x00d47310, + 0x00d49310, 0x00d4b310, 0x00d4d310, 0x00d4f310, + 0x00d51310, 0x00d53310, 0x00d55310, 0x00d57310, + 0x00d59310, 0x00d5b310, 0x00d5d310, 0x00d5f310, + 0x00d61310, 0x00d63310, 0x00d65310, 0x00d67310, + 0x00d69310, 0x00d6b310, 0x00d6d310, 0x00d6f310, + 0x00d71310, 0x00d73310, 0x00d75310, 0x00d77310, + 0x00d79310, 0x00d7b310, 0x00d7d310, 0x00d7f310, + 0x00d81310, 0x00d83310, 0x00d85310, 0x00d87310, + 0x00d89310, 0x00d8b310, 0x00d8d310, 0x00d8f310, + 0x00d91310, 0x00d93310, 0x00d95310, 0x00d97310, + 0x00d99310, 0x00d9b310, 0x00d9d310, 0x00d9f310, + 0x00da1310, 0x00da3310, 0x00da5310, 0x00da7310, + 0x00da9310, 0x00dab310, 0x00dad310, 0x00daf310, + 0x00db1310, 0x00db3310, 0x00db5310, 0x00db7310, + 0x00db9310, 0x00dbb310, 0x00dbd310, 0x00dbf310, + 0x00dc1310, 0x00dc3310, 0x00dc5310, 0x00dc7310, + 0x00dc9310, 0x00dcb310, 0x00dcd310, 0x00dcf310, + 0x00dd1310, 0x00dd3310, 0x00dd5310, 0x00dd7310, + 0x00dd9310, 0x00ddb310, 0x00ddd310, 0x00ddf310, + 0x00de1310, 0x00de3310, 0x00de5310, 0x00de7310, + 0x00de9310, 0x00deb310, 0x00ded310, 0x00def310, + 0x00df1310, 0x00df3310, 0x00df5310, 0x00df7310, + 0x00df9310, 0x00dfb310, 0x00dfd310, 0x00dff310, + 0x00e01310, 0x00e03310, 0x00e05310, 0x00e07310, + 0x00e09310, 0x00e0b310, 0x00e0d310, 0x00e0f310, + 0x00e11310, 0x00e13310, 0x00e15310, 0x00e17310, + 0x00e19310, 0x00e1b310, 0x00e1d310, 0x00e1f310, + 0x00e21310, 0x00e23310, 0x00e25310, 0x00e27310, + 0x00e29310, 0x00e2b310, 0x00e2d310, 0x00e2f310, + 0x00e31310, 0x00e33310, 0x00e35310, 0x00e37310, + 0x00e39310, 0x00e3b310, 0x00e3d310, 0x00e3f310, + 0x00e41310, 0x00e43310, 0x00e45310, 0x00e47310, + 0x00e49310, 0x00e4b310, 0x00e4d310, 0x00e4f310, + 0x00e51310, 0x00e53310, 0x00e55310, 0x00e57310, + 0x00e59310, 0x00e5b310, 0x00e5d310, 0x00e5f310, + 0x00e61310, 0x00e63310, 0x00e65310, 0x00e67310, + 0x00e69310, 0x00e6b310, 0x00e6d310, 0x00e6f310, + 0x00e71310, 0x00e73310, 0x00e75310, 0x00e77310, + 0x00e79310, 0x00e7b310, 0x00e7d310, 0x00e7f310, + 0x00e81310, 0x00e83310, 0x00e85310, 0x00e87310, + 0x00e89310, 0x00e8b310, 0x00e8d310, 0x00e8f310, + 0x00e91310, 0x00e93310, 0x00e95310, 0x00e97310, + 0x00e99310, 0x00e9b310, 0x00e9d310, 0x00e9f310, + 0x00ea1310, 0x00ea3310, 0x00ea5310, 0x00ea7310, + 0x00ea9310, 0x00eab310, 0x00ead310, 0x00eaf310, + 0x00eb1310, 0x00eb3310, 0x00eb5310, 0x00eb7310, + 0x00eb9310, 0x00ebb310, 0x00ebd310, 0x00ebf310, + 0x00ec1310, 0x00ec3310, 0x00ec5310, 0x00ec7310, + 0x00ec9310, 0x00ecb310, 0x00ecd310, 0x00ecf310, + 0x00ed1310, 0x00ed3310, 0x00ed5310, 0x00ed7310, + 0x00ed9310, 0x00edb310, 0x00edd310, 0x00edf310, + 0x00ee1310, 0x00ee3310, 0x00ee5310, 0x00ee7310, + 0x00ee9310, 0x00eeb310, 0x00eed310, 0x00eef310, + 0x00ef1310, 0x00ef3310, 0x00ef5310, 0x00ef7310, + 0x00ef9310, 0x00efb310, 0x00efd310, 0x00eff310, + 0x00f01310, 0x00f03310, 0x00f05310, 0x00f07310, + 0x00f09310, 0x00f0b310, 0x00f0d310, 0x00f0f310, + 0x00f11310, 0x00f13310, 0x00f15310, 0x00f17310, + 0x00f19310, 0x00f1b310, 0x00f1d310, 0x00f1f310, + 0x00f21310, 0x00f23310, 0x00f25310, 0x00f27310, + 0x00f29310, 0x00f2b310, 0x00f2d310, 0x00f2f310, + 0x00f31310, 0x00f33310, 0x00f35310, 0x00f37310, + 0x00f39310, 0x00f3b310, 0x00f3d310, 0x00f3f310, + 0x00f41310, 0x00f43310, 0x00f45310, 0x00f47310, + 0x00f49310, 0x00f4b310, 0x00f4d310, 0x00f4f310, + 0x00f51310, 0x00f53310, 0x00f55310, 0x00f57310, + 0x00f59310, 0x00f5b310, 0x00f5d310, 0x00f5f310, + 0x00f61310, 0x00f63310, 0x00f65310, 0x00f67310, + 0x00f69310, 0x00f6b310, 0x00f6d310, 0x00f6f310, + 0x00f71310, 0x00f73310, 0x00f75310, 0x00f77310, + 0x00f79310, 0x00f7b310, 0x00f7d310, 0x00f7f310, + 0x00f81310, 0x00f83310, 0x00f85310, 0x00f87310, + 0x00f89310, 0x00f8b310, 0x00f8d310, 0x00f8f310, + 0x00f91310, 0x00f93310, 0x00f95310, 0x00f97310, + 0x00f99310, 0x00f9b310, 0x00f9d310, 0x00f9f310, + 0x00fa1310, 0x00fa3310, 0x00fa5310, 0x00fa7310, + 0x00fa9310, 0x00fab310, 0x00fad310, 0x00faf310, + 0x00fb1310, 0x00fb3310, 0x00fb5310, 0x00fb7310, + 0x00fb9310, 0x00fbb310, 0x00fbd310, 0x00fbf310, + 0x00fc1310, 0x00fc3310, 0x00fc5310, 0x00fc7310, + 0x00fc9310, 0x00fcb310, 0x00fcd310, 0x00fcf310, + 0x00fd1310, 0x00fd3310, 0x00fd5310, 0x00fd7310, + 0x00fd9310, 0x00fdb310, 0x00fdd310, 0x00fdf310, + 0x00fe1310, 0x00fe3310, 0x00fe5310, 0x00fe7310, + 0x00fe9310, 0x00feb310, 0x00fed310, 0x00fef310, + 0x00ff1310, 0x00ff3310, 0x00ff5310, 0x00ff7310, + 0x00ff9310, 0x00ffb310, 0x00ffd310, 0x00fff310, +}; diff --git a/libs/zlibng/arch/x86/fill_window_sse.c b/libs/zlibng/arch/x86/fill_window_sse.c new file mode 100644 index 000000000..1c0f863bd --- /dev/null +++ b/libs/zlibng/arch/x86/fill_window_sse.c @@ -0,0 +1,175 @@ +/* + * Fill Window with SSE2-optimized hash shifting + * + * Copyright (C) 2013 Intel Corporation + * Authors: + * Arjan van de Ven + * Jim Kukunas + * + * For conditions of distribution and use, see copyright notice in zlib.h + */ +#ifdef X86_SSE2 + +#include "zbuild.h" +#include +#include "deflate.h" +#include "deflate_p.h" +#include "functable.h" + +extern int read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size); + +ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { + const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); + + register unsigned n; + register Pos *p; + unsigned more; /* Amount of free space at the end of the window. */ + unsigned int wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(unsigned long)s->lookahead -(unsigned long)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + memcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start = (s->match_start >= wsize) ? s->match_start - wsize : 0; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + p -= 8; + do { + __m128i value, result; + + value = _mm_loadu_si128((__m128i *)p); + result = _mm_subs_epu16(value, xmm_wsize); + _mm_storeu_si128((__m128i *)p, result); + + p -= 8; + n -= 8; + } while (n > 0); + + n = wsize; + p = &s->prev[n]; + p -= 8; + do { + __m128i value, result; + + value = _mm_loadu_si128((__m128i *)p); + result = _mm_subs_epu16(value, xmm_wsize); + _mm_storeu_si128((__m128i *)p, result); + + p -= 8; + n -= 8; + } while (n > 0); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + unsigned int str = s->strstart - s->insert; + s->ins_h = s->window[str]; + if (str >= 1) + functable.insert_string(s, str + 2 - MIN_MATCH, 1); +#if MIN_MATCH != 3 +#error Call insert_string() MIN_MATCH-3 more times + while (s->insert) { + functable.insert_string(s, str, 1); + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } +#else + unsigned int count; + if (unlikely(s->lookahead == 1)){ + count = s->insert - 1; + }else{ + count = s->insert; + } + functable.insert_string(s, str, count); + s->insert -= count; +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + unsigned long curr = s->strstart + (unsigned long)(s->lookahead); + unsigned long init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + memset(s->window + curr, 0, (unsigned)init); + s->high_water = curr + init; + } else if (s->high_water < (unsigned long)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (unsigned long)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + memset(s->window + s->high_water, 0, (unsigned)init); + s->high_water += init; + } + } + + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); +} +#endif diff --git a/libs/zlibng/arch/x86/insert_string_sse.c b/libs/zlibng/arch/x86/insert_string_sse.c index d0c316b19..394e50937 100644 --- a/libs/zlibng/arch/x86/insert_string_sse.c +++ b/libs/zlibng/arch/x86/insert_string_sse.c @@ -5,42 +5,52 @@ * */ -#include "../../zbuild.h" -#include +#include "zbuild.h" +#include "deflate.h" + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef X86_SSE4_2_CRC_HASH +ZLIB_INTERNAL Pos insert_string_sse(deflate_state *const s, const Pos str, unsigned int count) { + Pos ret = 0; + unsigned int idx; + unsigned int *ip, val, h; + + for (idx = 0; idx < count; idx++) { + ip = (unsigned *)&s->window[str+idx]; + memcpy(&val, ip, sizeof(val)); + h = 0; + + if (s->level >= TRIGGER_LEVEL) + val &= 0xFFFFFF; + #ifdef _MSC_VER -# include -#endif -#include "../../deflate.h" - -#ifdef X86_SSE42_CRC_INTRIN -# ifdef _MSC_VER -# define UPDATE_HASH(s, h, val)\ - h = _mm_crc32_u32(h, val) -# else -# define UPDATE_HASH(s, h, val)\ - h = __builtin_ia32_crc32si(h, val) -# endif + h = _mm_crc32_u32(h, val); +#elif defined(X86_SSE4_2_CRC_INTRIN) + h = __builtin_ia32_crc32si(h, val); #else -# ifdef _MSC_VER -# define UPDATE_HASH(s, h, val) {\ - __asm mov edx, h\ - __asm mov eax, val\ - __asm crc32 eax, edx\ - __asm mov val, eax\ - } -# else -# define UPDATE_HASH(s, h, val) \ - __asm__ __volatile__ (\ - "crc32 %1,%0\n\t"\ - : "+r" (h)\ - : "r" (val)\ + __asm__ __volatile__ ( + "crc32 %1,%0\n\t" + : "+r" (h) + : "r" (val) ); -# endif #endif - -#define INSERT_STRING insert_string_sse4 -#define QUICK_INSERT_STRING quick_insert_string_sse4 - -#ifdef X86_SSE42_CRC_HASH -# include "../../insert_string_tpl.h" + Pos head = s->head[h & s->hash_mask]; + if (head != str+idx) { + s->prev[(str+idx) & s->w_mask] = head; + s->head[h & s->hash_mask] = str+idx; + if (idx == count-1) + ret = head; + } else if (idx == count - 1) { + ret = str + idx; + } + } + return ret; +} #endif diff --git a/libs/zlibng/arch/x86/slide_avx.c b/libs/zlibng/arch/x86/slide_avx.c deleted file mode 100644 index be9a9b7ea..000000000 --- a/libs/zlibng/arch/x86/slide_avx.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * AVX2 optimized hash slide, based on Intel's slide_sse implementation - * - * Copyright (C) 2017 Intel Corporation - * Authors: - * Arjan van de Ven - * Jim Kukunas - * Mika T. Lindqvist - * - * For conditions of distribution and use, see copyright notice in zlib.h - */ -#include "../../zbuild.h" -#include "../../deflate.h" - -#include - -Z_INTERNAL void slide_hash_avx2(deflate_state *s) { - Pos *p; - unsigned n; - uint16_t wsize = (uint16_t)s->w_size; - const __m256i ymm_wsize = _mm256_set1_epi16((short)wsize); - - n = HASH_SIZE; - p = &s->head[n] - 16; - do { - __m256i value, result; - - value = _mm256_loadu_si256((__m256i *)p); - result= _mm256_subs_epu16(value, ymm_wsize); - _mm256_storeu_si256((__m256i *)p, result); - p -= 16; - n -= 16; - } while (n > 0); - - n = wsize; - p = &s->prev[n] - 16; - do { - __m256i value, result; - - value = _mm256_loadu_si256((__m256i *)p); - result= _mm256_subs_epu16(value, ymm_wsize); - _mm256_storeu_si256((__m256i *)p, result); - - p -= 16; - n -= 16; - } while (n > 0); -} diff --git a/libs/zlibng/arch/x86/slide_sse.c b/libs/zlibng/arch/x86/slide_sse.c deleted file mode 100644 index abf447475..000000000 --- a/libs/zlibng/arch/x86/slide_sse.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SSE optimized hash slide - * - * Copyright (C) 2017 Intel Corporation - * Authors: - * Arjan van de Ven - * Jim Kukunas - * - * For conditions of distribution and use, see copyright notice in zlib.h - */ -#include "../../zbuild.h" -#include "../../deflate.h" - -#include - -Z_INTERNAL void slide_hash_sse2(deflate_state *s) { - Pos *p; - unsigned n; - uint16_t wsize = (uint16_t)s->w_size; - const __m128i xmm_wsize = _mm_set1_epi16((short)wsize); - - n = HASH_SIZE; - p = &s->head[n] - 8; - do { - __m128i value, result; - - value = _mm_loadu_si128((__m128i *)p); - result= _mm_subs_epu16(value, xmm_wsize); - _mm_storeu_si128((__m128i *)p, result); - p -= 8; - n -= 8; - } while (n > 0); - - n = wsize; - p = &s->prev[n] - 8; - do { - __m128i value, result; - - value = _mm_loadu_si128((__m128i *)p); - result= _mm_subs_epu16(value, xmm_wsize); - _mm_storeu_si128((__m128i *)p, result); - - p -= 8; - n -= 8; - } while (n > 0); -} diff --git a/libs/zlibng/arch/x86/x86.c b/libs/zlibng/arch/x86/x86.c index e782cb8ee..382f72a2b 100644 --- a/libs/zlibng/arch/x86/x86.c +++ b/libs/zlibng/arch/x86/x86.c @@ -8,73 +8,61 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#include "../../zutil.h" +#include "zutil.h" #ifdef _MSC_VER -# include +#include #else // Newer versions of GCC and clang come with cpuid.h -# include +#include #endif -Z_INTERNAL int x86_cpu_has_avx2; -Z_INTERNAL int x86_cpu_has_sse2; -Z_INTERNAL int x86_cpu_has_ssse3; -Z_INTERNAL int x86_cpu_has_sse42; -Z_INTERNAL int x86_cpu_has_pclmulqdq; -Z_INTERNAL int x86_cpu_has_tzcnt; +ZLIB_INTERNAL int x86_cpu_has_sse2; +ZLIB_INTERNAL int x86_cpu_has_sse42; +ZLIB_INTERNAL int x86_cpu_has_pclmulqdq; +ZLIB_INTERNAL int x86_cpu_has_tzcnt; static void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) { #ifdef _MSC_VER - unsigned int registers[4]; - __cpuid((int *)registers, info); + unsigned int registers[4]; + __cpuid(registers, info); - *eax = registers[0]; - *ebx = registers[1]; - *ecx = registers[2]; - *edx = registers[3]; + *eax = registers[0]; + *ebx = registers[1]; + *ecx = registers[2]; + *edx = registers[3]; #else - __cpuid(info, *eax, *ebx, *ecx, *edx); + unsigned int _eax; + unsigned int _ebx; + unsigned int _ecx; + unsigned int _edx; + __cpuid(info, _eax, _ebx, _ecx, _edx); + *eax = _eax; + *ebx = _ebx; + *ecx = _ecx; + *edx = _edx; #endif } -static void cpuidex(int info, int subinfo, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) { -#ifdef _MSC_VER - unsigned int registers[4]; - __cpuidex((int *)registers, info, subinfo); +void ZLIB_INTERNAL x86_check_features(void) { + unsigned eax, ebx, ecx, edx; + unsigned maxbasic; - *eax = registers[0]; - *ebx = registers[1]; - *ecx = registers[2]; - *edx = registers[3]; -#else - __cpuid_count(info, subinfo, *eax, *ebx, *ecx, *edx); -#endif -} - -void Z_INTERNAL x86_check_features(void) { - unsigned eax, ebx, ecx, edx; - unsigned maxbasic; - - cpuid(0, &maxbasic, &ebx, &ecx, &edx); - - cpuid(1 /*CPU_PROCINFO_AND_FEATUREBITS*/, &eax, &ebx, &ecx, &edx); - - x86_cpu_has_sse2 = edx & 0x4000000; - x86_cpu_has_ssse3 = ecx & 0x200; - x86_cpu_has_sse42 = ecx & 0x100000; - x86_cpu_has_pclmulqdq = ecx & 0x2; - - if (maxbasic >= 7) { - cpuidex(7, 0, &eax, &ebx, &ecx, &edx); - - // check BMI1 bit - // Reference: https://software.intel.com/sites/default/files/article/405250/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family.pdf - x86_cpu_has_tzcnt = ebx & 0x8; - // check AVX2 bit - x86_cpu_has_avx2 = ebx & 0x20; - } else { - x86_cpu_has_tzcnt = 0; - x86_cpu_has_avx2 = 0; - } + cpuid(0, &maxbasic, &ebx, &ecx, &edx); + + cpuid(1 /*CPU_PROCINFO_AND_FEATUREBITS*/, &eax, &ebx, &ecx, &edx); + + x86_cpu_has_sse2 = edx & 0x4000000; + x86_cpu_has_sse42 = ecx & 0x100000; + x86_cpu_has_pclmulqdq = ecx & 0x2; + + if (maxbasic >= 7) { + cpuid(7, &eax, &ebx, &ecx, &edx); + + // check BMI1 bit + // Reference: https://software.intel.com/sites/default/files/article/405250/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family.pdf + x86_cpu_has_tzcnt = ebx & 0x8; + } else { + x86_cpu_has_tzcnt = 0; + } } diff --git a/libs/zlibng/arch/x86/x86.h b/libs/zlibng/arch/x86/x86.h index 8471e155c..860e64154 100644 --- a/libs/zlibng/arch/x86/x86.h +++ b/libs/zlibng/arch/x86/x86.h @@ -1,18 +1,16 @@ -/* cpu.h -- check for CPU features -* Copyright (C) 2013 Intel Corporation Jim Kukunas -* For conditions of distribution and use, see copyright notice in zlib.h -*/ + /* cpu.h -- check for CPU features + * Copyright (C) 2013 Intel Corporation Jim Kukunas + * For conditions of distribution and use, see copyright notice in zlib.h + */ #ifndef CPU_H_ #define CPU_H_ -extern int x86_cpu_has_avx2; extern int x86_cpu_has_sse2; -extern int x86_cpu_has_ssse3; extern int x86_cpu_has_sse42; extern int x86_cpu_has_pclmulqdq; extern int x86_cpu_has_tzcnt; -void Z_INTERNAL x86_check_features(void); +void ZLIB_INTERNAL x86_check_features(void); #endif /* CPU_H_ */ diff --git a/libs/zlibng/chunkset.c b/libs/zlibng/chunkset.c deleted file mode 100644 index 2aa8d4e47..000000000 --- a/libs/zlibng/chunkset.c +++ /dev/null @@ -1,81 +0,0 @@ -/* chunkset.c -- inline functions to copy small data chunks. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zbuild.h" -#include "zutil.h" - -// We need sizeof(chunk_t) to be 8, no matter what. -#if defined(UNALIGNED64_OK) -typedef uint64_t chunk_t; -#elif defined(UNALIGNED_OK) -typedef struct chunk_t { uint32_t u32[2]; } chunk_t; -#else -typedef struct chunk_t { uint8_t u8[8]; } chunk_t; -#endif - -#define HAVE_CHUNKMEMSET_1 -#define HAVE_CHUNKMEMSET_4 -#define HAVE_CHUNKMEMSET_8 - -static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) { -#if defined(UNALIGNED64_OK) - *chunk = 0x0101010101010101 * (uint8_t)*from; -#elif defined(UNALIGNED_OK) - chunk->u32[0] = 0x01010101 * (uint8_t)*from; - chunk->u32[1] = chunk->u32[0]; -#else - memset(chunk, *from, sizeof(chunk_t)); -#endif -} - -static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { -#if defined(UNALIGNED64_OK) - uint32_t half_chunk; - half_chunk = *(uint32_t *)from; - *chunk = 0x0000000100000001 * (uint64_t)half_chunk; -#elif defined(UNALIGNED_OK) - chunk->u32[0] = *(uint32_t *)from; - chunk->u32[1] = chunk->u32[0]; -#else - uint8_t *chunkptr = (uint8_t *)chunk; - memcpy(chunkptr, from, 4); - memcpy(chunkptr+4, from, 4); -#endif -} - -static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { -#if defined(UNALIGNED64_OK) - *chunk = *(uint64_t *)from; -#elif defined(UNALIGNED_OK) - uint32_t* p = (uint32_t *)from; - chunk->u32[0] = p[0]; - chunk->u32[1] = p[1]; -#else - memcpy(chunk, from, sizeof(chunk_t)); -#endif -} - -static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { - chunkmemset_8((uint8_t *)s, chunk); -} - -static inline void storechunk(uint8_t *out, chunk_t *chunk) { -#if defined(UNALIGNED64_OK) - *(uint64_t *)out = *chunk; -#elif defined(UNALIGNED_OK) - ((uint32_t *)out)[0] = chunk->u32[0]; - ((uint32_t *)out)[1] = chunk->u32[1]; -#else - memcpy(out, chunk, sizeof(chunk_t)); -#endif -} - -#define CHUNKSIZE chunksize_c -#define CHUNKCOPY chunkcopy_c -#define CHUNKCOPY_SAFE chunkcopy_safe_c -#define CHUNKUNROLL chunkunroll_c -#define CHUNKMEMSET chunkmemset_c -#define CHUNKMEMSET_SAFE chunkmemset_safe_c - -#include "chunkset_tpl.h" diff --git a/libs/zlibng/chunkset_tpl.h b/libs/zlibng/chunkset_tpl.h deleted file mode 100644 index 9e8ede559..000000000 --- a/libs/zlibng/chunkset_tpl.h +++ /dev/null @@ -1,172 +0,0 @@ -/* chunkset_tpl.h -- inline functions to copy small data chunks. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* Returns the chunk size */ -Z_INTERNAL uint32_t CHUNKSIZE(void) { - return sizeof(chunk_t); -} - -/* Behave like memcpy, but assume that it's OK to overwrite at least - chunk_t bytes of output even if the length is shorter than this, - that the length is non-zero, and that `from` lags `out` by at least - sizeof chunk_t bytes (or that they don't overlap at all or simply that - the distance is less than the length of the copy). - - Aside from better memory bus utilisation, this means that short copies - (chunk_t bytes or fewer) will fall straight through the loop - without iteration, which will hopefully make the branch prediction more - reliable. */ -Z_INTERNAL uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) { - chunk_t chunk; - --len; - loadchunk(from, &chunk); - storechunk(out, &chunk); - out += (len % sizeof(chunk_t)) + 1; - from += (len % sizeof(chunk_t)) + 1; - len /= sizeof(chunk_t); - while (len > 0) { - loadchunk(from, &chunk); - storechunk(out, &chunk); - out += sizeof(chunk_t); - from += sizeof(chunk_t); - --len; - } - return out; -} - -/* Behave like chunkcopy, but avoid writing beyond of legal output. */ -Z_INTERNAL uint8_t* CHUNKCOPY_SAFE(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe) { - if ((safe - out) < (ptrdiff_t)sizeof(chunk_t)) { - int32_t use_chunk16 = sizeof(chunk_t) > 16 && (len & 16); - if (use_chunk16) { - memcpy(out, from, 16); - out += 16; - from += 16; - } - if (len & 8) { - memcpy(out, from, 8); - out += 8; - from += 8; - } - if (len & 4) { - memcpy(out, from, 4); - out += 4; - from += 4; - } - if (len & 2) { - memcpy(out, from, 2); - out += 2; - from += 2; - } - if (len & 1) { - *out++ = *from++; - } - return out; - } - return CHUNKCOPY(out, from, len); -} - -/* Perform short copies until distance can be rewritten as being at least - sizeof chunk_t. - - This assumes that it's OK to overwrite at least the first - 2*sizeof(chunk_t) bytes of output even if the copy is shorter than this. - This assumption holds because inflate_fast() starts every iteration with at - least 258 bytes of output space available (258 being the maximum length - output from a single token; see inflate_fast()'s assumptions below). */ -Z_INTERNAL uint8_t* CHUNKUNROLL(uint8_t *out, unsigned *dist, unsigned *len) { - unsigned char const *from = out - *dist; - chunk_t chunk; - while (*dist < *len && *dist < sizeof(chunk_t)) { - loadchunk(from, &chunk); - storechunk(out, &chunk); - out += *dist; - *len -= *dist; - *dist += *dist; - } - return out; -} - -/* Copy DIST bytes from OUT - DIST into OUT + DIST * k, for 0 <= k < LEN/DIST. - Return OUT + LEN. */ -Z_INTERNAL uint8_t* CHUNKMEMSET(uint8_t *out, unsigned dist, unsigned len) { - /* Debug performance related issues when len < sizeof(uint64_t): - Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); */ - Assert(dist > 0, "cannot have a distance 0"); - - unsigned char *from = out - dist; - chunk_t chunk; - unsigned sz = sizeof(chunk); - if (len < sz) { - do { - *out++ = *from++; - --len; - } while (len != 0); - return out; - } - -#ifdef HAVE_CHUNKMEMSET_1 - if (dist == 1) { - chunkmemset_1(from, &chunk); - } else -#endif -#ifdef HAVE_CHUNKMEMSET_2 - if (dist == 2) { - chunkmemset_2(from, &chunk); - } else -#endif -#ifdef HAVE_CHUNKMEMSET_4 - if (dist == 4) { - chunkmemset_4(from, &chunk); - } else -#endif -#ifdef HAVE_CHUNKMEMSET_8 - if (dist == 8) { - chunkmemset_8(from, &chunk); - } else -#endif - if (dist == sz) { - loadchunk(from, &chunk); - } else if (dist < sz) { - unsigned char *end = out + len - 1; - while (len > dist) { - out = CHUNKCOPY_SAFE(out, from, dist, end); - len -= dist; - } - if (len > 0) { - out = CHUNKCOPY_SAFE(out, from, len, end); - } - return out; - } else { - out = CHUNKUNROLL(out, &dist, &len); - return CHUNKCOPY(out, out - dist, len); - } - - unsigned rem = len % sz; - len -= rem; - while (len) { - storechunk(out, &chunk); - out += sz; - len -= sz; - } - - /* Last, deal with the case when LEN is not a multiple of SZ. */ - if (rem) - memcpy(out, from, rem); - out += rem; - - return out; -} - -Z_INTERNAL uint8_t* CHUNKMEMSET_SAFE(uint8_t *out, unsigned dist, unsigned len, unsigned left) { - if (left < (unsigned)(3 * sizeof(chunk_t))) { - while (len > 0) { - *out = *(out - dist); - out++; - --len; - } - return out; - } - return CHUNKMEMSET(out, dist, len); -} diff --git a/libs/zlibng/cmake/detect-arch.c b/libs/zlibng/cmake/detect-arch.c deleted file mode 100644 index 571553582..000000000 --- a/libs/zlibng/cmake/detect-arch.c +++ /dev/null @@ -1,99 +0,0 @@ -// archdetect.c -- Detect compiler architecture and raise preprocessor error -// containing a simple arch identifier. -// Copyright (C) 2019 Hans Kristian Rosbach -// Licensed under the Zlib license, see LICENSE.md for details - -// x86_64 -#if defined(__x86_64__) || defined(_M_X64) - #error archfound x86_64 - -// x86 -#elif defined(__i386) || defined(_M_IX86) - #error archfound i686 - -// ARM -#elif defined(__aarch64__) || defined(_M_ARM64) - #error archfound aarch64 -#elif defined(__arm__) || defined(__arm) || defined(_M_ARM) || defined(__TARGET_ARCH_ARM) - #if defined(__ARM64_ARCH_8__) || defined(__ARMv8__) || defined(__ARMv8_A__) - #error archfound armv8 - #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) - #error archfound armv7 - #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6M__) - #error archfound armv6 - #elif defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) - #error archfound armv5 - #elif defined(__ARM_ARCH_4T__) || defined(__TARGET_ARCH_5E__) - #error archfound armv4 - #elif defined(__ARM_ARCH_3__) || defined(__TARGET_ARCH_3M__) - #error archfound armv3 - #elif defined(__ARM_ARCH_2__) - #error archfound armv2 - #endif - -// PowerPC -#elif defined(__powerpc__) || defined(_ppc__) || defined(__PPC__) - #if defined(__64BIT__) || defined(__powerpc64__) || defined(__ppc64__) - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #error archfound powerpc64le - #else - #error archfound powerpc64 - #endif - #else - #error archfound powerpc - #endif - -// --------------- Less common architectures alphabetically below --------------- - -// ALPHA -#elif defined(__alpha__) || defined(__alpha) - #error archfound alpha - -// Blackfin -#elif defined(__BFIN__) - #error archfound blackfin - -// Itanium -#elif defined(__ia64) || defined(_M_IA64) - #error archfound ia64 - -// MIPS -#elif defined(__mips__) || defined(__mips) - #error archfound mips - -// Motorola 68000-series -#elif defined(__m68k__) - #error archfound m68k - -// SuperH -#elif defined(__sh__) - #error archfound sh - -// SPARC -#elif defined(__sparc__) || defined(__sparc) - #if defined(__sparcv9) || defined(__sparc_v9__) - #error archfound sparc9 - #elif defined(__sparcv8) || defined(__sparc_v8__) - #error archfound sparc8 - #endif - -// SystemZ -#elif defined(__370__) - #error archfound s370 -#elif defined(__s390__) - #error archfound s390 -#elif defined(__s390x) || defined(__zarch__) - #error archfound s390x - -// PARISC -#elif defined(__hppa__) - #error archfound parisc - -// RS-6000 -#elif defined(__THW_RS6000) - #error archfound rs6000 - -// return 'unrecognized' if we do not know what architecture this is -#else - #error archfound unrecognized -#endif diff --git a/libs/zlibng/cmake/detect-arch.cmake b/libs/zlibng/cmake/detect-arch.cmake deleted file mode 100644 index b80d6666f..000000000 --- a/libs/zlibng/cmake/detect-arch.cmake +++ /dev/null @@ -1,93 +0,0 @@ -# detect-arch.cmake -- Detect compiler architecture and set ARCH and BASEARCH -# Copyright (C) 2019 Hans Kristian Rosbach -# Licensed under the Zlib license, see LICENSE.md for details -set(ARCHDETECT_FOUND TRUE) - -if(CMAKE_OSX_ARCHITECTURES) - # If multiple architectures are requested (universal build), pick only the first - list(GET CMAKE_OSX_ARCHITECTURES 0 ARCH) -elseif(MSVC) - if("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "X86") - set(ARCH "i686") - elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "x64") - set(ARCH "x86_64") - elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM" OR "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARMV7") - set(ARCH "arm") - elseif ("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64") - set(ARCH "aarch64") - endif() -elseif(CMAKE_CROSSCOMPILING) - set(ARCH ${CMAKE_C_COMPILER_TARGET}) -else() - # Let preprocessor parse archdetect.c and raise an error containing the arch identifier - enable_language(C) - try_run( - run_result_unused - compile_result_unused - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect-arch.c - COMPILE_OUTPUT_VARIABLE RAWOUTPUT - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - ) - - # Find basearch tag, and extract the arch word into BASEARCH variable - string(REGEX REPLACE ".*archfound ([a-zA-Z0-9_]+).*" "\\1" ARCH "${RAWOUTPUT}") - if(NOT ARCH) - set(ARCH unknown) - endif() -endif() - -# Make sure we have ARCH set -if(NOT ARCH OR ARCH STREQUAL "unknown") - set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) - message(STATUS "Arch not recognized, falling back to cmake arch: '${ARCH}'") -else() - message(STATUS "Arch detected: '${ARCH}'") -endif() - -# Base arch detection -if("${ARCH}" MATCHES "(x86_64|AMD64|i[3-6]86)") - set(BASEARCH "x86") - set(BASEARCH_X86_FOUND TRUE) -elseif("${ARCH}" MATCHES "(arm(v[0-9])?|aarch64)") - set(BASEARCH "arm") - set(BASEARCH_ARM_FOUND TRUE) -elseif("${ARCH}" MATCHES "ppc(64(le)?)?|powerpc(64(le)?)?") - set(BASEARCH "ppc") - set(BASEARCH_PPC_FOUND TRUE) -elseif("${ARCH}" MATCHES "alpha") - set(BASEARCH "alpha") - set(BASEARCH_ALPHA_FOUND TRUE) -elseif("${ARCH}" MATCHES "blackfin") - set(BASEARCH "blackfin") - set(BASEARCH_BLACKFIN_FOUND TRUE) -elseif("${ARCH}" MATCHES "ia64") - set(BASEARCH "ia64") - set(BASEARCH_IA64_FOUND TRUE) -elseif("${ARCH}" MATCHES "mips") - set(BASEARCH "mips") - set(BASEARCH_MIPS_FOUND TRUE) -elseif("${ARCH}" MATCHES "m68k") - set(BASEARCH "m68k") - set(BASEARCH_M68K_FOUND TRUE) -elseif("${ARCH}" MATCHES "sh") - set(BASEARCH "sh") - set(BASEARCH_SH_FOUND TRUE) -elseif("${ARCH}" MATCHES "sparc[89]?") - set(BASEARCH "sparc") - set(BASEARCH_SPARC_FOUND TRUE) -elseif("${ARCH}" MATCHES "s3[679]0x?") - set(BASEARCH "s360") - set(BASEARCH_S360_FOUND TRUE) -elseif("${ARCH}" MATCHES "parisc") - set(BASEARCH "parisc") - set(BASEARCH_PARISC_FOUND TRUE) -elseif("${ARCH}" MATCHES "rs6000") - set(BASEARCH "rs6000") - set(BASEARCH_RS6000_FOUND TRUE) -else() - set(BASEARCH "x86") - set(BASEARCH_X86_FOUND TRUE) - message(STATUS "Basearch '${ARCH}' not recognized, defaulting to 'x86'.") -endif() -message(STATUS "Basearch of '${ARCH}' has been detected as: '${BASEARCH}'") diff --git a/libs/zlibng/cmake/detect-sanitizer.cmake b/libs/zlibng/cmake/detect-sanitizer.cmake deleted file mode 100644 index 172a8d558..000000000 --- a/libs/zlibng/cmake/detect-sanitizer.cmake +++ /dev/null @@ -1,123 +0,0 @@ -# detect-sanitizer.cmake -- Detect supported compiler sanitizer flags -# Licensed under the Zlib license, see LICENSE.md for details - -macro(check_sanitizer_support known_checks supported_checks) - set(available_checks "") - - # Build list of supported sanitizer flags by incrementally trying compilation with - # known sanitizer checks - - foreach(check ${known_checks}) - if(available_checks STREQUAL "") - set(compile_checks "${check}") - else() - set(compile_checks "${available_checks},${check}") - endif() - - set(CMAKE_REQUIRED_FLAGS "-fsanitize=${compile_checks}") - - check_c_source_compiles("int main() { return 0; }" HAS_SANITIZER_${check} - FAIL_REGEX "not supported|unrecognized command|unknown option") - - set(CMAKE_REQUIRED_FLAGS) - - if(HAS_SANITIZER_${check}) - set(available_checks ${compile_checks}) - endif() - endforeach() - - set(${supported_checks} ${available_checks}) -endmacro() - -macro(add_address_sanitizer) - set(known_checks - address - pointer-compare - pointer-subtract - ) - - check_sanitizer_support("${known_checks}" supported_checks) - if(NOT ${supported_checks} STREQUAL "") - message(STATUS "Address sanitizer is enabled: ${supported_checks}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}") - else() - message(STATUS "Address sanitizer is not supported") - endif() - - if(CMAKE_CROSSCOMPILING_EMULATOR) - # Only check for leak sanitizer if not cross-compiling due to qemu crash - message(WARNING "Leak sanitizer is not supported when cross compiling") - else() - # Leak sanitizer requires address sanitizer - check_sanitizer_support("leak" supported_checks) - if(NOT ${supported_checks} STREQUAL "") - message(STATUS "Leak sanitizer is enabled: ${supported_checks}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}") - else() - message(STATUS "Leak sanitizer is not supported") - endif() - endif() -endmacro() - -macro(add_memory_sanitizer) - check_sanitizer_support("memory" supported_checks) - if(NOT ${supported_checks} STREQUAL "") - message(STATUS "Memory sanitizer is enabled: ${supported_checks}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}") - else() - message(STATUS "Memory sanitizer is not supported") - endif() -endmacro() - -macro(add_undefined_sanitizer) - set(known_checks - array-bounds - bool - bounds - builtin - enum - float-cast-overflow - float-divide-by-zero - function - integer-divide-by-zero - local-bounds - null - nonnull-attribute - pointer-overflow - return - returns-nonnull-attribute - shift - shift-base - shift-exponent - signed-integer-overflow - undefined - unsigned-integer-overflow - unsigned-shift-base - vla-bound - vptr - ) - - # Only check for alignment sanitizer flag if unaligned access is not supported - if(NOT UNALIGNED_OK) - list(APPEND known_checks alignment) - endif() - # Object size sanitizer has no effect at -O0 and produces compiler warning if enabled - if(NOT CMAKE_C_FLAGS MATCHES "-O0") - list(APPEND known_checks object-size) - endif() - - check_sanitizer_support("${known_checks}" supported_checks) - - if(NOT ${supported_checks} STREQUAL "") - message(STATUS "Undefined behavior sanitizer is enabled: ${supported_checks}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}") - - # Group sanitizer flag -fsanitize=undefined will automatically add alignment, even if - # it is not in our sanitize flag list, so we need to explicitly disable alignment sanitizing. - if(UNALIGNED_OK) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=alignment") - endif() - else() - message(STATUS "UNdefined behavior sanitizer is not supported") - endif() -endmacro() \ No newline at end of file diff --git a/libs/zlibng/cmake/run-and-compare.cmake b/libs/zlibng/cmake/run-and-compare.cmake deleted file mode 100644 index 0e9343373..000000000 --- a/libs/zlibng/cmake/run-and-compare.cmake +++ /dev/null @@ -1,48 +0,0 @@ -if(NOT DEFINED OUTPUT OR NOT DEFINED COMPARE OR NOT DEFINED COMMAND) - message(FATAL_ERROR "Run and compare arguments missing") -endif() - -if(INPUT) - # Run command with stdin input and redirect stdout to output - execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${COMMAND}" - -DINPUT=${INPUT} - -DOUTPUT=${OUTPUT} - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) -else() - # Run command and redirect stdout to output - execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${COMMAND}" - -DOUTPUT=${OUTPUT} - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) -endif() - -if(CMD_RESULT) - message(FATAL_ERROR "Run before compare failed: ${CMD_RESULT}") -endif() - -# Use configure_file to normalize line-endings -if(IGNORE_LINE_ENDINGS) - configure_file(${COMPARE} ${COMPARE}.cmp NEWLINE_STYLE LF) - set(COMPARE ${COMPARE}.cmp) - configure_file(${OUTPUT} ${OUTPUT}.cmp NEWLINE_STYLE LF) - set(OUTPUT ${OUTPUT}.cmp) -endif() - -# Compare that output is equal to specified file -execute_process(COMMAND ${CMAKE_COMMAND} - -E compare_files ${COMPARE} ${OUTPUT} - RESULT_VARIABLE CMD_RESULT) - -# Delete temporary files used to normalize line-endings -if(IGNORE_LINE_ENDINGS) - file(REMOVE ${COMPARE} ${OUTPUT}) -endif() - -if(CMD_RESULT) - message(FATAL_ERROR "Run compare failed: ${CMD_RESULT}") -endif() \ No newline at end of file diff --git a/libs/zlibng/cmake/run-and-redirect.cmake b/libs/zlibng/cmake/run-and-redirect.cmake deleted file mode 100644 index 30c574112..000000000 --- a/libs/zlibng/cmake/run-and-redirect.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# If no output is specified, discard output -if(NOT DEFINED OUTPUT) - if(WIN32) - set(OUTPUT NUL) - else() - set(OUTPUT /dev/null) - endif() -endif() - -if(INPUT) - # Check to see that input file exists - if(NOT EXISTS ${INPUT}) - message(FATAL_ERROR "Cannot find input: ${INPUT}") - endif() - # Execute with both stdin and stdout file - execute_process(COMMAND ${COMMAND} - RESULT_VARIABLE CMD_RESULT - INPUT_FILE ${INPUT} - OUTPUT_FILE ${OUTPUT}) -else() - # Execute with only stdout file - execute_process(COMMAND ${COMMAND} - RESULT_VARIABLE CMD_RESULT - OUTPUT_FILE ${OUTPUT}) -endif() - -# Check if exit code is in list of successful exit codes -if(SUCCESS_EXIT) - list(FIND SUCCESS_EXIT ${CMD_RESULT} _INDEX) - if (${_INDEX} GREATER -1) - set(CMD_RESULT 0) - endif() -endif() - -# Check to see if successful -if(CMD_RESULT) - message(FATAL_ERROR "${COMMAND} failed: ${CMD_RESULT}") -endif() diff --git a/libs/zlibng/cmake/test-compress.cmake b/libs/zlibng/cmake/test-compress.cmake deleted file mode 100644 index 75355bc73..000000000 --- a/libs/zlibng/cmake/test-compress.cmake +++ /dev/null @@ -1,188 +0,0 @@ -if(TARGET) - set(COMPRESS_TARGET ${TARGET}) - set(DECOMPRESS_TARGET ${TARGET}) -endif() - -if(NOT DEFINED INPUT OR NOT DEFINED COMPRESS_TARGET OR NOT DEFINED DECOMPRESS_TARGET) - message(FATAL_ERROR "Compress test arguments missing") -endif() - -# Set default values -if(NOT DEFINED COMPARE) - set(COMPARE ON) -endif() -if(NOT DEFINED COMPRESS_ARGS) - set(COMPRESS_ARGS -c -k) -endif() -if(NOT DEFINED DECOMPRESS_ARGS) - set(DECOMPRESS_ARGS -d -c) -endif() -if(NOT DEFINED GZIP_VERIFY) - set(GZIP_VERIFY ON) -endif() -if(NOT DEFINED SUCCESS_EXIT) - set(SUCCESS_EXIT 0) -endif() - -# Generate unique output path so multiple tests can be executed at the same time -if(NOT OUTPUT) - # Output name based on input and unique id - string(RANDOM UNIQUE_ID) - set(OUTPUT ${INPUT}-${UNIQUE_ID}) -else() - # Output name appends unique id in case multiple tests with same output name - string(RANDOM LENGTH 6 UNIQUE_ID) - set(OUTPUT ${OUTPUT}-${UNIQUE_ID}) -endif() -string(REPLACE ".gz" "" OUTPUT "${OUTPUT}") - -macro(cleanup) - # Cleanup temporary mingizip files - file(REMOVE ${OUTPUT}.gz ${OUTPUT}.out) - # Cleanup temporary gzip files - file(REMOVE ${OUTPUT}.gzip.gz ${OUTPUT}.gzip.out) -endmacro() - -# Compress input file -if(NOT EXISTS ${INPUT}) - message(FATAL_ERROR "Cannot find compress input: ${INPUT}") -endif() - -set(COMPRESS_COMMAND ${COMPRESS_TARGET} ${COMPRESS_ARGS}) - -execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${COMPRESS_COMMAND}" - -DINPUT=${INPUT} - -DOUTPUT=${OUTPUT}.gz - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) - -if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Compress failed: ${CMD_RESULT}") -endif() - -# Decompress output -if(NOT EXISTS ${OUTPUT}.gz) - cleanup() - message(FATAL_ERROR "Cannot find decompress input: ${OUTPUT}.gz") -endif() - -set(DECOMPRESS_COMMAND ${DECOMPRESS_TARGET} ${DECOMPRESS_ARGS}) - -execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${DECOMPRESS_COMMAND}" - -DINPUT=${OUTPUT}.gz - -DOUTPUT=${OUTPUT}.out - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) - -if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Decompress failed: ${CMD_RESULT}") -endif() - -if(COMPARE) - # Compare decompressed output with original input file - execute_process(COMMAND ${CMAKE_COMMAND} - -E compare_files ${INPUT} ${OUTPUT}.out - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Compare minigzip decompress failed: ${CMD_RESULT}") - endif() -endif() - -if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") - # Transparent writing does not use gzip format - find_program(GZIP gzip) - if(GZIP) - if(NOT EXISTS ${OUTPUT}.gz) - cleanup() - message(FATAL_ERROR "Cannot find gzip decompress input: ${OUTPUT}.gz") - endif() - - # Check gzip can decompress our compressed output - set(GZ_DECOMPRESS_COMMAND ${GZIP} --decompress) - - execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${GZ_DECOMPRESS_COMMAND}" - -DINPUT=${OUTPUT}.gz - -DOUTPUT=${OUTPUT}.gzip.out - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Gzip decompress failed: ${CMD_RESULT}") - endif() - - # Compare gzip output with original input file - execute_process(COMMAND ${CMAKE_COMMAND} - -E compare_files ${INPUT} ${OUTPUT}.gzip.out - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Compare gzip decompress failed: ${CMD_RESULT}") - endif() - - if(NOT EXISTS ${OUTPUT}.gz) - cleanup() - message(FATAL_ERROR "Cannot find gzip compress input: ${INPUT}") - endif() - - # Compress input file with gzip - set(GZ_COMPRESS_COMMAND ${GZIP} --stdout) - - execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${GZ_COMPRESS_COMMAND}" - -DINPUT=${INPUT} - -DOUTPUT=${OUTPUT}.gzip.gz - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Gzip compress failed: ${CMD_RESULT}") - endif() - - if(NOT EXISTS ${OUTPUT}.gz) - cleanup() - message(FATAL_ERROR "Cannot find minigzip decompress input: ${OUTPUT}.gzip.gz") - endif() - - # Check minigzip can decompress gzip compressed output - execute_process(COMMAND ${CMAKE_COMMAND} - "-DCOMMAND=${DECOMPRESS_COMMAND}" - -DINPUT=${OUTPUT}.gzip.gz - -DOUTPUT=${OUTPUT}.gzip.out - "-DSUCCESS_EXIT=${SUCCESS_EXIT}" - -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Minigzip decompress gzip failed: ${CMD_RESULT}") - endif() - - if(COMPARE) - # Compare original input file with gzip decompressed output - execute_process(COMMAND ${CMAKE_COMMAND} - -E compare_files ${INPUT} ${OUTPUT}.gzip.out - RESULT_VARIABLE CMD_RESULT) - - if(CMD_RESULT) - cleanup() - message(FATAL_ERROR "Compare minigzip decompress gzip failed: ${CMD_RESULT}") - endif() - endif() - endif() -endif() - -cleanup() \ No newline at end of file diff --git a/libs/zlibng/cmake/toolchain-aarch64.cmake b/libs/zlibng/cmake/toolchain-aarch64.cmake deleted file mode 100644 index 31894fdcd..000000000 --- a/libs/zlibng/cmake/toolchain-aarch64.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR aarch64) -set(CMAKE_SYSTEM_VERSION 1) - -message(STATUS "Using cross-compile toolchain: ${CROSS_COMPILE_TOOLCHAIN}") - -set(CMAKE_C_COMPILER_TARGET "aarch64-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "aarch64-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64 -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-arm.cmake b/libs/zlibng/cmake/toolchain-arm.cmake deleted file mode 100644 index 0e3c5c377..000000000 --- a/libs/zlibng/cmake/toolchain-arm.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR arm) -set(CMAKE_SYSTEM_VERSION 1) - -message(STATUS "Using cross-compile toolchain: ${CMAKE_C_COMPILER_TARGET}") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-mingw-i686.cmake b/libs/zlibng/cmake/toolchain-mingw-i686.cmake deleted file mode 100644 index 588ec0ef9..000000000 --- a/libs/zlibng/cmake/toolchain-mingw-i686.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) - -set(CMAKE_C_COMPILER_TARGET i686) -set(CMAKE_CXX_COMPILER_TARGET i686) - -set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) -set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) -set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR wine) - -set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/libs/zlibng/cmake/toolchain-mingw-x86_64.cmake b/libs/zlibng/cmake/toolchain-mingw-x86_64.cmake deleted file mode 100644 index c778b7222..000000000 --- a/libs/zlibng/cmake/toolchain-mingw-x86_64.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) - -set(CMAKE_C_COMPILER_TARGET x86_64) -set(CMAKE_CXX_COMPILER_TARGET x86_64) - -set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) -set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) -set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR wine) - -set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/libs/zlibng/cmake/toolchain-powerpc.cmake b/libs/zlibng/cmake/toolchain-powerpc.cmake deleted file mode 100644 index 4f7f8e92f..000000000 --- a/libs/zlibng/cmake/toolchain-powerpc.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR powerpc) -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_C_COMPILER_TARGET "powerpc-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "powerpc-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-powerpc64.cmake b/libs/zlibng/cmake/toolchain-powerpc64.cmake deleted file mode 100644 index 4be3bbd59..000000000 --- a/libs/zlibng/cmake/toolchain-powerpc64.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR ppc64) -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_C_COMPILER_TARGET "powerpc64-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "powerpc64-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64 -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-powerpc64le.cmake b/libs/zlibng/cmake/toolchain-powerpc64le.cmake deleted file mode 100644 index 5535f616f..000000000 --- a/libs/zlibng/cmake/toolchain-powerpc64le.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR ppc64le) -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_C_COMPILER_TARGET "powerpc64le-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "powerpc64le-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64le -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-s390x.cmake b/libs/zlibng/cmake/toolchain-s390x.cmake deleted file mode 100644 index 41bc0d101..000000000 --- a/libs/zlibng/cmake/toolchain-s390x.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR s390x) -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_C_COMPILER_TARGET "s390x-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "s390x-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-s390x -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/cmake/toolchain-sparc64.cmake b/libs/zlibng/cmake/toolchain-sparc64.cmake deleted file mode 100644 index f0cd99565..000000000 --- a/libs/zlibng/cmake/toolchain-sparc64.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR sparc64) -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_C_COMPILER_TARGET "sparc64-linux-gnu") -set(CMAKE_CXX_COMPILER_TARGET "sparc64-linux-gnu") - -set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_CROSSCOMPILING_EMULATOR qemu-sparc64 -L /usr/${CMAKE_C_COMPILER_TARGET}/) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc) -if(NOT C_COMPILER_FULL_PATH) - message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found") -endif() -set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) - -find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++) -if(CXX_COMPILER_FULL_PATH) - set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) -endif() diff --git a/libs/zlibng/compare258.c b/libs/zlibng/compare258.c deleted file mode 100644 index bc41638ae..000000000 --- a/libs/zlibng/compare258.c +++ /dev/null @@ -1,186 +0,0 @@ -/* compare258.c -- aligned and unaligned versions of compare258 - * Copyright (C) 2020 Nathan Moinvaziri - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zbuild.h" -#include "zutil.h" - -#include "fallback_builtins.h" - -/* ALIGNED, byte comparison */ -static inline uint32_t compare256_c_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - if (*src0 != *src1) - return len + (*src0 == *src1); - src0 += 1, src1 += 1, len += 1; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_c_static(const unsigned char *src0, const unsigned char *src1) { - if (*src0 != *src1) - return 0; - src0 += 1, src1 += 1; - if (*src0 != *src1) - return 1; - src0 += 1, src1 += 1; - - return compare256_c_static(src0, src1) + 2; -} - -Z_INTERNAL uint32_t compare258_c(const unsigned char *src0, const unsigned char *src1) { - return compare258_c_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_c -#define COMPARE256 compare256_c_static -#define COMPARE258 compare258_c_static - -#include "match_tpl.h" - -#ifdef UNALIGNED_OK -/* UNALIGNED_OK, 16-bit integer comparison */ -static inline uint32_t compare256_unaligned_16_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return len + (*src0 == *src1); - src0 += 2, src1 += 2, len += 2; - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return len + (*src0 == *src1); - src0 += 2, src1 += 2, len += 2; - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return len + (*src0 == *src1); - src0 += 2, src1 += 2, len += 2; - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return len + (*src0 == *src1); - src0 += 2, src1 += 2, len += 2; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_unaligned_16_static(const unsigned char *src0, const unsigned char *src1) { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return (*src0 == *src1); - - return compare256_unaligned_16_static(src0+2, src1+2) + 2; -} - -Z_INTERNAL uint32_t compare258_unaligned_16(const unsigned char *src0, const unsigned char *src1) { - return compare258_unaligned_16_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_unaligned_16 -#define COMPARE256 compare256_unaligned_16_static -#define COMPARE258 compare258_unaligned_16_static - -#include "match_tpl.h" - -#ifdef HAVE_BUILTIN_CTZ -/* UNALIGNED_OK, 32-bit integer comparison */ -static inline uint32_t compare256_unaligned_32_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - uint32_t sv = *(uint32_t *)src0; - uint32_t mv = *(uint32_t *)src1; - uint32_t diff = sv ^ mv; - - if (diff) { - uint32_t match_byte = __builtin_ctz(diff) / 8; - return len + match_byte; - } - - src0 += 4, src1 += 4, len += 4; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_unaligned_32_static(const unsigned char *src0, const unsigned char *src1) { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return (*src0 == *src1); - - return compare256_unaligned_32_static(src0+2, src1+2) + 2; -} - -Z_INTERNAL uint32_t compare258_unaligned_32(const unsigned char *src0, const unsigned char *src1) { - return compare258_unaligned_32_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_unaligned_32 -#define COMPARE256 compare256_unaligned_32_static -#define COMPARE258 compare258_unaligned_32_static - -#include "match_tpl.h" - -#endif - -#if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) -/* UNALIGNED64_OK, 64-bit integer comparison */ -static inline uint32_t compare256_unaligned_64_static(const unsigned char *src0, const unsigned char *src1) { - uint32_t len = 0; - - do { - uint64_t sv = *(uint64_t *)src0; - uint64_t mv = *(uint64_t *)src1; - uint64_t diff = sv ^ mv; - - if (diff) { - uint64_t match_byte = __builtin_ctzll(diff) / 8; - return len + (uint32_t)match_byte; - } - - src0 += 8, src1 += 8, len += 8; - } while (len < 256); - - return 256; -} - -static inline uint32_t compare258_unaligned_64_static(const unsigned char *src0, const unsigned char *src1) { - if (*(uint16_t *)src0 != *(uint16_t *)src1) - return (*src0 == *src1); - - return compare256_unaligned_64_static(src0+2, src1+2) + 2; -} - -Z_INTERNAL uint32_t compare258_unaligned_64(const unsigned char *src0, const unsigned char *src1) { - return compare258_unaligned_64_static(src0, src1); -} - -#define LONGEST_MATCH longest_match_unaligned_64 -#define COMPARE256 compare256_unaligned_64_static -#define COMPARE258 compare258_unaligned_64_static - -#include "match_tpl.h" - -#endif - -#endif diff --git a/libs/zlibng/compress.c b/libs/zlibng/compress.c index d5379591d..6b493fda5 100644 --- a/libs/zlibng/compress.c +++ b/libs/zlibng/compress.c @@ -3,12 +3,14 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #define ZLIB_INTERNAL #include "zbuild.h" #if defined(ZLIB_COMPAT) -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif /* =========================================================================== @@ -22,7 +24,7 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, +int ZEXPORT PREFIX(compress2)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen, int level) { PREFIX3(stream) stream; int err; @@ -42,7 +44,7 @@ int Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_size_t *destLen, const uns stream.next_out = dest; stream.avail_out = 0; - stream.next_in = (z_const unsigned char *)source; + stream.next_in = (const unsigned char *)source; stream.avail_in = 0; do { @@ -64,7 +66,7 @@ int Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_size_t *destLen, const uns /* =========================================================================== */ -int Z_EXPORT PREFIX(compress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen) { +int ZEXPORT PREFIX(compress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen) { return PREFIX(compress2)(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } @@ -72,12 +74,6 @@ int Z_EXPORT PREFIX(compress)(unsigned char *dest, z_size_t *destLen, const unsi If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ -z_size_t Z_EXPORT PREFIX(compressBound)(z_size_t sourceLen) { -#ifndef NO_QUICK_STRATEGY - /* Quick deflate strategy worse case is 9 bits per literal, rounded to nearest byte, - plus the size of block & gzip headers and footers */ - return sourceLen + ((sourceLen + 13 + 7) >> 3) + 18; -#else +z_size_t ZEXPORT PREFIX(compressBound)(z_size_t sourceLen) { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; -#endif } diff --git a/libs/zlibng/configure b/libs/zlibng/configure index 171a76876..5f50a33cb 100644 --- a/libs/zlibng/configure +++ b/libs/zlibng/configure @@ -23,11 +23,9 @@ BUILDDIR=$(pwd) # set command prefix for cross-compilation if [ -n "${CHOST}" ]; then - # normalize the chost before parsing it - NORM_CHOST=$(sh "$SRCDIR"/tools/config.sub $CHOST) - uname="$(echo "${NORM_CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')" + uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" CROSS_PREFIX="${CHOST}-" - ARCH="$(echo "${NORM_CHOST}" | sed -e 's/-.*//')" + ARCH="`echo "${CHOST}" | sed -e 's/-.*//'`" else ARCH="`uname -m`" fi @@ -70,8 +68,8 @@ fi # set defaults before processing command line options LDCONFIG=${LDCONFIG-"ldconfig"} -LDFLAGS=${LDFLAGS} -LDSHAREDLIBC="${LDSHAREDLIBC}" +LDFLAGS=${LDFLAGS-"-L."} +LDSHAREDLIBC="${LDSHAREDLIBC--lc}" DEFFILE= RC= RCFLAGS= @@ -87,7 +85,7 @@ includedir=${includedir-'${prefix}/include'} mandir=${mandir-'${prefix}/share/man'} shared_ext='.so' shared=1 -gzfileops=1 +gzfileops=0 compat=0 cover=0 build32=0 @@ -96,19 +94,16 @@ buildacle=1 buildneon=1 builddfltccdeflate=0 builddfltccinflate=0 -with_sanitizer="" +with_sanitizers=0 +with_msan=0 with_fuzzers=0 floatabi= native=0 forcesse2=0 -avx2flag="-mavx2" sse2flag="-msse2" -ssse3flag="-mssse3" sse4flag="-msse4" sse42flag="-msse4.2" pclmulflag="-mpclmul" -acleflag= -neonflag= without_optimizations=0 without_new_strategies=0 gcc=0 @@ -148,7 +143,7 @@ case "$1" in echo ' [--warn] Enables extra compiler warnings' | tee -a configure.log echo ' [--debug] Enables extra debug prints during operation' | tee -a configure.log echo ' [--zlib-compat] Compiles for zlib-compatible API instead of zlib-ng API' | tee -a configure.log - echo ' [--without-gzfileops] Compiles with the gzfile parts of the API enabled' | tee -a configure.log + echo ' [--with-gzfileops] Compiles with the gzfile parts of the API enabled' | tee -a configure.log echo ' [--without-optimizations] Compiles without support for optional instruction sets' | tee -a configure.log echo ' [--without-new-strategies] Compiles without using new additional deflate strategies' | tee -a configure.log echo ' [--without-acle] Compiles without ARM C Language Extensions' | tee -a configure.log @@ -156,9 +151,9 @@ case "$1" in echo ' [--with-dfltcc-deflate] Use DEFLATE CONVERSION CALL instruction for compression on IBM Z' | tee -a configure.log echo ' [--with-dfltcc-inflate] Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z' | tee -a configure.log echo ' [--force-sse2] Assume SSE2 instructions are always available (disabled by default on x86, enabled on x86_64)' | tee -a configure.log - echo ' [--with-sanitizer] Build with sanitizer (memory, address, undefined)' | tee -a configure.log + echo ' [--with-sanitizers] Build with address sanitizer and all supported sanitizers other than memory sanitizer (disabled by default)' | tee -a configure.log + echo ' [--with-msan] Build with memory sanitizer (disabled by default)' | tee -a configure.log echo ' [--with-fuzzers] Build test/fuzz (disabled by default)' | tee -a configure.log - echo ' [--native] Compiles with full instruction set supported on this host' | tee -a configure.log exit 0 ;; -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; @@ -173,7 +168,7 @@ case "$1" in -s* | --shared | --enable-shared) shared=1; shift ;; -t | --static) shared=0; shift ;; --zlib-compat) compat=1; shift ;; - --without-gzfileops) gzfileops=0; shift ;; + --with-gzfileops) gzfileops=1; shift ;; --cover) cover=1; shift ;; -3* | --32) build32=1; shift ;; -6* | --64) build64=1; shift ;; @@ -190,7 +185,8 @@ case "$1" in -oldstrat | --without-new-strategies) without_new_strategies=1; shift;; -w* | --warn) warn=1; shift ;; -d* | --debug) debug=1; shift ;; - --with-sanitizer=*) with_sanitizer=`echo $1 | sed 's/.*=//'`; shift ;; + --with-sanitizers) with_sanitizers=1; shift ;; + --with-msan) with_msan=1; shift ;; --with-fuzzers) with_fuzzers=1; shift ;; *) @@ -329,12 +325,6 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then else ARCH=native fi ;; - powerpc | ppc) - ARCH=powerpc ;; - powerpc64 | ppc64) - ARCH=powerpc64 ;; - powerpc64le | ppc64le) - ARCH=powerpc64le ;; esac CFLAGS="-O2 ${CFLAGS}" if test -n "${ARCHS}"; then @@ -342,19 +332,13 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then LDFLAGS="${LDFLAGS} ${ARCHS}" fi CFLAGS="${CFLAGS} -Wall" - SFLAGS="${CFLAGS} -fPIC" + SFLAGS="-O2 ${CFLAGS} -fPIC" if test $native -eq 1; then - case $ARCH in - powerpc*) - NATIVE_FLAG="-mcpu=native" ;; - *) - NATIVE_FLAG="-march=native" ;; - esac - CFLAGS="${CFLAGS} ${NATIVE_FLAG}" - SFLAGS="${SFLAGS} ${NATIVE_FLAG}" + CFLAGS="${CFLAGS} -march=native" + SFLAGS="${SFLAGS} -march=native" fi if test "$warn" -eq 1; then - CFLAGS="${CFLAGS} -Wextra -Wpedantic -Wno-implicit-fallthrough" + CFLAGS="${CFLAGS} -Wextra -Wpedantic" fi if test $debug -eq 1; then CFLAGS="${CFLAGS} -DZLIB_DEBUG" @@ -366,10 +350,10 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then case "$uname" in Linux* | linux* | GNU | GNU/* | solaris*) LDSHARED=${LDSHARED-"$cc"} - LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}" ;; + LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.1,--version-script,${SRCDIR}/${MAPNAME}" ;; *BSD | *bsd* | DragonFly) LDSHARED=${LDSHARED-"$cc"} - LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}" + LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.1,--version-script,${SRCDIR}/${MAPNAME}" LDCONFIG="ldconfig -m" ;; CYGWIN* | Cygwin* | cygwin*) ARFLAGS="rcs" @@ -445,7 +429,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 # (alain.bonnefoy@icbt.com) LDSHARED=${LDSHARED-"$cc"} - LDSHAREDFLAGS="-shared -Wl,-h${LIBNAME}.so.${VER1}" ;; + LDSHAREDFLAGS="-shared -Wl,-h${LIBNAME}.so.1" ;; HP-UX*) LDSHARED=${LDSHARED-"$cc"} LDSHAREDFLAGS="-shared" @@ -473,7 +457,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then ARFLAGS="-o" ;; aarch64) LDSHARED=${LDSHARED-"$cc"} - LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1} -Wl,--version-script,${SRCDIR}/${MAPNAME}" + LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.1 -Wl,--version-script,${SRCDIR}/${MAPNAME}" LDSHAREDLIBC="-Wl,--start-group -lc -lrdimon -Wl,--end-group" ;; *) LDSHARED=${LDSHARED-"$cc"} @@ -571,10 +555,14 @@ fi echo >> configure.log -if test "$with_sanitizer" = "address"; then - echo -n "Checking for address sanitizer... " | tee -a configure.log +if test $with_sanitizers -eq 1; then + if test $with_msan -eq 1; then + echo "Error: --with-sanitizers and --with-msan cannot be used together" + exit 1 + fi + echo -n "Checking for sanitizers ASan/UBSan... " | tee -a configure.log sanitizers="" - for san in address pointer-compare pointer-subtract; do + for san in bool address array-bounds float-divide-by-zero function integer-divide-by-zero return shift signed-integer-overflow undefined unsigned-integer-overflow vla-bound vptr; do if try $CC -c $CFLAGS $test.c -fsanitize=$san ; then if test -n "$sanitizers"; then sanitizers="$sanitizers,$san" @@ -593,21 +581,11 @@ if test "$with_sanitizer" = "address"; then echo No | tee -a configure.log fi - echo -n "Checking for leak sanitizer... " | tee -a configure.log - if try $CC -c $CFLAGS $test.c -fsanitize=leak; then - echo "-fsanitize=leak" | tee -a configure.log - CFLAGS="$CFLAGS -fsanitize=leak" - SFLAGS="$SFLAGS -fsanitize=leak" - LDFLAGS="$LDFLAGS -fsanitize=leak" - else - echo No | tee -a configure.log - fi - echo >> configure.log fi -if test "$with_sanitizer" = "memory"; then - echo -n "Checking for memory sanitizer... " | tee -a configure.log +if test $with_msan -eq 1; then + echo -n "Checking for MSan... " | tee -a configure.log if try $CC -c $CFLAGS $test.c -fsanitize=memory ; then echo "-fsanitize=memory" | tee -a configure.log CFLAGS="$CFLAGS -fsanitize=memory" @@ -620,31 +598,6 @@ if test "$with_sanitizer" = "memory"; then echo >> configure.log fi -if test "$with_sanitizer" = "undefined"; then - echo -n "Checking for undefined behavior sanitizer... " | tee -a configure.log - sanitizers="" - for san in array-bounds bool bounds builtin enum float-cast-overflow float-divide-by-zero function integer-divide-by-zero local-bounds null nonnull-attribute object-size pointer-overflow return returns-nonnull-attribute shift shift-base shift-exponent signed-integer-overflow undefined unsigned-integer-overflow unsigned-shift-base vla-bound vptr; do - if try $CC -c $CFLAGS $test.c -fsanitize=$san; then - if test -n "$sanitizers"; then - sanitizers="$sanitizers,$san" - else - sanitizers="$san" - fi - fi - done - - if test -n "$sanitizers"; then - echo "-fsanitize=$sanitizers" | tee -a configure.log - CFLAGS="$CFLAGS -fsanitize=$sanitizers" - SFLAGS="$SFLAGS -fsanitize=$sanitizers" - LDFLAGS="$LDFLAGS -fsanitize=$sanitizers" - else - echo No | tee -a configure.log - fi - - echo >> configure.log -fi - # see if shared library build supported cat > $test.c < test.c - cat > $test.c <> configure.log 2>&1; then - echo "Checking for -no-semantic-interposition... Yes." | tee -a configure.log - SFLAGS="$SFLAGS -fno-semantic-interposition" -else - echo "Checking for -no-semantic-interposition... No." | tee -a configure.log -fi - # see if we can hide zlib internal symbols that are linked between separate source files using hidden if test "$gcc" -eq 1; then echo >> configure.log cat > $test.c <> configure.log echo "Checking for attribute(visibility(hidden)) support... Yes." | tee -a configure.log else @@ -891,13 +836,13 @@ fi if test "$gcc" -eq 1; then echo >> configure.log cat > $test.c <> configure.log echo "Checking for attribute(visibility(internal)) support... Yes." | tee -a configure.log else @@ -906,43 +851,26 @@ EOF fi fi -# Check for __builtin_ctz() support in compiler +# Check for __builtin_ctzl() support in compiler cat > $test.c << EOF int main(void) { unsigned int zero = 0; - long test = __builtin_ctz(zero); + long test = __builtin_ctzl(zero); (void)test; return 0; } EOF if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then - echo "Checking for __builtin_ctz ... Yes." | tee -a configure.log - CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZ" - SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZ" + echo "Checking for __builtin_ctzl ... Yes." | tee -a configure.log + CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZL" + SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZL" else - echo "Checking for __builtin_ctz ... No." | tee -a configure.log -fi - -# Check for __builtin_ctzll() support in compiler -cat > $test.c << EOF -int main(void) { - unsigned long long zero = 0; - long test = __builtin_ctzll(zero); - (void)test; - return 0; -} -EOF -if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then - echo "Checking for __builtin_ctzll ... Yes." | tee -a configure.log - CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZLL" - SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZLL" -else - echo "Checking for __builtin_ctzll ... No." | tee -a configure.log + echo "Checking for __builtin_ctzl ... No." | tee -a configure.log fi # Check for SSE2 intrinsics case "${ARCH}" in - i386 | i486 | i586 | i686 | x86_64) + i386 | i486 | i586 | i686) cat > $test.c << EOF #include int main(void) { @@ -961,48 +889,6 @@ EOF ;; esac -# Check for SSSE3 intrinsics - -cat > $test.c << EOF -#include -int main(void) -{ - __m128i u, v, w; - u = _mm_set1_epi32(1); - v = _mm_set1_epi32(2); - w = _mm_hadd_epi32(u, v); - (void)w; - return 0; -} -EOF -if try ${CC} ${CFLAGS} ${ssse3flag} $test.c; then - echo "Checking for SSSE3 intrinsics ... Yes." | tee -a configure.log - HAVE_SSSE3_INTRIN=1 -else - echo "Checking for SSSE3 intrinsics ... No." | tee -a configure.log - HAVE_SSSE3_INTRIN=0 -fi - -# Check for SSE4.2 CRC inline assembly -case "${ARCH}" in - i386 | i486 | i586 | i686 | x86_64) - cat > $test.c << EOF -int main(void) { - unsigned val = 0, h = 0; - __asm__ __volatile__ ( "crc32 %1,%0" : "+r" (h) : "r" (val) ); - return (int) h; -} -EOF - if try ${CC} ${CFLAGS} ${sse42flag} $test.c; then - echo "Checking for SSE4.2 CRC inline assembly ... Yes." | tee -a configure.log - HAVE_SSE42CRC_INLINE_ASM=1 - else - echo "Checking for SSE4.2 CRC inline assembly ... No." | tee -a configure.log - HAVE_SSE42CRC_INLINE_ASM=0 - fi - ;; -esac - # Check for SSE4.2 CRC intrinsics case "${ARCH}" in i386 | i486 | i586 | i686 | x86_64) @@ -1025,31 +911,6 @@ EOF ;; esac -# Check for SSE4.2 compare string intrinsics -case "${ARCH}" in - i386 | i486 | i586 | i686 | x86_64) - cat > $test.c << EOF -#include -int main(void) -{ - unsigned char a[64] = { 0 }; - unsigned char b[64] = { 0 }; - __m128i xmm_src0, xmm_src1; - xmm_src0 = _mm_loadu_si128((__m128i *)(char *)a); - xmm_src1 = _mm_loadu_si128((__m128i *)(char *)b); - return _mm_cmpestri(xmm_src0, 16, xmm_src1, 16, 0); -} -EOF - if try ${CC} ${CFLAGS} ${sse42flag} $test.c; then - echo "Checking for SSE4.2 compare string intrinsics ... Yes." | tee -a configure.log - HAVE_SSE42CMPSTR_INTRIN=1 - else - echo "Checking for SSE4.2 compare string intrinsics ... No." | tee -a configure.log - HAVE_SSE42CMPSTR_INTRIN=0 - fi - ;; -esac - # Check for PCLMULQDQ intrinsics case "${ARCH}" in i386 | i486 | i586 | i686 | x86_64) @@ -1072,11 +933,6 @@ EOF HAVE_PCLMULQDQ_INTRIN=0 fi - # Enable deflate_medium at level 1 - if test $without_new_strategies -eq 1; then - CFLAGS="${CFLAGS} -DNO_QUICK_STRATEGY" - SFLAGS="${SFLAGS} -DNO_QUICK_STRATEGY" - fi # Enable deflate_medium at level 4-6 if test $without_new_strategies -eq 1; then CFLAGS="${CFLAGS} -DNO_MEDIUM_STRATEGY" @@ -1085,30 +941,6 @@ EOF ;; esac -# Check for AVX2 intrinsics -case "${ARCH}" in - i386 | i486 | i586 | i686 | x86_64) - cat > $test.c << EOF -#include -int main(void) { - __m256i x = _mm256_set1_epi16(2); - const __m256i y = _mm256_set1_epi16(1); - x = _mm256_subs_epu16(x, y); - (void)x; - return 0; -} -EOF - if try ${CC} ${CFLAGS} ${avx2flag} $test.c; then - echo "Checking for AVX2 intrinsics ... Yes." | tee -a configure.log - HAVE_AVX2_INTRIN=1 - else - echo "Checking for AVX2 intrinsics ... No." | tee -a configure.log - HAVE_AVX2_INTRIN=0 - fi - ;; -esac - - # Check whether -mfpu=neon is available on ARM processors. case "${ARCH}" in arm*) @@ -1125,22 +957,6 @@ EOF ;; esac -# Check whether features needed by POWER optimisations are available -case "${ARCH}" in - powerpc*) - cat > $test.c << EOF -#include -int main() { return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07); } -EOF - if try $CC -c $CFLAGS -mcpu=power8 $test.c; then - HAVE_POWER8=1 - echo "Check whether POWER8 instructions are available ... Yes." | tee -a configure.log - else - HAVE_POWER8=0 - echo "Check whether POWER8 instructions are available ... No." | tee -a configure.log - fi -esac - # Check whether sys/sdt.h is available cat > $test.c << EOF #include @@ -1160,66 +976,81 @@ ARCH_SHARED_OBJS='' # Set ARCH specific FLAGS case "${ARCH}" in - # x86/amd64 specific optimizations - i386 | i486 | i586 | i686 |x86_64) + # x86 specific optimizations + i386 | i486 | i586 | i686) ARCHDIR=arch/x86 - CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" + CFLAGS="${CFLAGS} -DUNALIGNED_OK" + SFLAGS="${SFLAGS} -DUNALIGNED_OK" - # Enable arch-specific optimizations + # Enable arch-specific optimizations? if test $without_optimizations -eq 0; then - CFLAGS="${CFLAGS} -DX86_FEATURES" - SFLAGS="${SFLAGS} -DX86_FEATURES" + CFLAGS="${CFLAGS} -DX86_CPUID" + SFLAGS="${SFLAGS} -DX86_CPUID" ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} x86.o" ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} x86.lo" - if test ${HAVE_AVX2_INTRIN} -eq 1; then - CFLAGS="${CFLAGS} -DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET" - SFLAGS="${SFLAGS} -DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} slide_avx.o chunkset_avx.o compare258_avx.o adler32_avx.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} slide_avx.lo chunkset_avx.lo compare258_avx.lo adler32_avx.lo" - fi - - if test ${HAVE_SSE42CRC_INTRIN} -eq 1 || test ${HAVE_SSE42CRC_INLINE_ASM} -eq 1; then - CFLAGS="${CFLAGS} -DX86_SSE42_CRC_HASH" - SFLAGS="${SFLAGS} -DX86_SSE42_CRC_HASH" - - if test ${HAVE_SSE42CRC_INTRIN} -eq 1; then - CFLAGS="${CFLAGS} -DX86_SSE42_CRC_INTRIN" - SFLAGS="${SFLAGS} -DX86_SSE42_CRC_INTRIN" - fi - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} insert_string_sse.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} insert_string_sse.lo" - fi - - if test ${HAVE_SSE42CMPSTR_INTRIN} -eq 1; then - CFLAGS="${CFLAGS} -DX86_SSE42_CMP_STR" - SFLAGS="${SFLAGS} -DX86_SSE42_CMP_STR" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} compare258_sse.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} compare258_sse.lo" - fi - if test ${HAVE_SSE2_INTRIN} -eq 1; then - CFLAGS="${CFLAGS} -DX86_SSE2 -DX86_SSE2_CHUNKSET" - SFLAGS="${SFLAGS} -DX86_SSE2 -DX86_SSE2_CHUNKSET" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} chunkset_sse.o slide_sse.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} chunkset_sse.lo slide_sse.lo" + CFLAGS="${CFLAGS} -DX86_SSE2" + SFLAGS="${SFLAGS} -DX86_SSE2" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} fill_window_sse.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} fill_window_sse.lo" if test $forcesse2 -eq 1; then CFLAGS="${CFLAGS} -DX86_NOCHECK_SSE2" SFLAGS="${SFLAGS} -DX86_NOCHECK_SSE2" fi + + # Enable deflate_quick at level 1? + # requires SSE2: code uses fill_window_sse + if test $without_new_strategies -eq 0; then + CFLAGS="${CFLAGS} -DX86_QUICK_STRATEGY" + SFLAGS="${SFLAGS} -DX86_QUICK_STRATEGY" + + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} deflate_quick.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} deflate_quick.lo" + fi fi - if test ${HAVE_SSSE3_INTRIN} -eq 1; then - CFLAGS="${CFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32" - SFLAGS="${SFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_ssse3.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_ssse3.lo" + if test ${HAVE_SSE42CRC_INTRIN} -eq 1; then + CFLAGS="${CFLAGS} -DX86_SSE4_2_CRC_INTRIN" + SFLAGS="${SFLAGS} -DX86_SSE4_2_CRC_INTRIN" + fi + + CFLAGS="${CFLAGS} -DX86_SSE4_2_CRC_HASH" + SFLAGS="${SFLAGS} -DX86_SSE4_2_CRC_HASH" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} insert_string_sse.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} insert_string_sse.lo" + + if test ${HAVE_PCLMULQDQ_INTRIN} -eq 1; then + CFLAGS="${CFLAGS} -DX86_PCLMULQDQ_CRC" + SFLAGS="${SFLAGS} -DX86_PCLMULQDQ_CRC" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc_folding.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc_folding.lo" + fi + + fi + ;; + + # x86_64 specific optimizations + x86_64) + ARCHDIR=arch/x86 + + CFLAGS="${CFLAGS} -DUNALIGNED_OK" + SFLAGS="${SFLAGS} -DUNALIGNED_OK" + + # Enable arch-specific optimizations? + if test $without_optimizations -eq 0; then + CFLAGS="${CFLAGS} -DX86_CPUID -DX86_SSE2 -DX86_SSE4_2_CRC_HASH" + SFLAGS="${SFLAGS} -DX86_CPUID -DX86_SSE2 -DX86_SSE4_2_CRC_HASH" + + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} x86.o fill_window_sse.o insert_string_sse.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} x86.lo fill_window_sse.lo insert_string_sse.lo" + + if test ${HAVE_SSE42CRC_INTRIN} -eq 1; then + CFLAGS="${CFLAGS} -DX86_SSE4_2_CRC_INTRIN" + SFLAGS="${SFLAGS} -DX86_SSE4_2_CRC_INTRIN" fi if test ${HAVE_PCLMULQDQ_INTRIN} -eq 1; then @@ -1228,20 +1059,24 @@ case "${ARCH}" in ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc_folding.o" ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc_folding.lo" fi + + # Enable deflate_quick at level 1? + if test $without_new_strategies -eq 0; then + CFLAGS="${CFLAGS} -DX86_QUICK_STRATEGY" + SFLAGS="${SFLAGS} -DX86_QUICK_STRATEGY" + + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} deflate_quick.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} deflate_quick.lo" + fi fi ;; # ARM specific optimizations - arm*) + arm | armv[3467]l | armv4b | armv4tl | armv5tel | armv5tejl | armv[67]hl | armv7hnl | armv[78]-a | armv8-a+* | armv8.[1234]-a | armv8.[1234]-a+*) [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=arm ARCHDIR=arch/arm - - if test $without_optimizations -eq 0; then - CFLAGS="${CFLAGS} -DARM_FEATURES" - SFLAGS="${SFLAGS} -DARM_FEATURES" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo" - fi + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o fill_window_arm.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo fill_window_arm.lo" GCC_MACHINE=$(${CC} -dumpmachine) case "${GCC_MACHINE}" in @@ -1250,103 +1085,90 @@ case "${ARCH}" in *gnueabi) floatabi="-mfloat-abi=softfp" ;; esac - CFLAGS="${CFLAGS} ${floatabi}" - SFLAGS="${SFLAGS} ${floatabi}" case "${ARCH}" in armv[345]*) - if test $without_optimizations -eq 0; then - if test $buildacle -eq 1; then - echo ACLE support not available - fi + if test $buildacle -eq 1; then + echo ACLE support not available + fi - if test $buildneon -eq 1; then - echo NEON support not available - fi + if test $buildneon -eq 1; then + echo NEON support not available fi ;; armv6l | armv6hl) CFLAGS="${CFLAGS} -DUNALIGNED_OK" SFLAGS="${SFLAGS} -DUNALIGNED_OK" - if test $without_optimizations -eq 0; then - if test $buildacle -eq 1; then - echo ACLE support not available - fi + if test $buildacle -eq 1; then + echo ACLE support not available + fi - if test $buildneon -eq 1; then - echo NEON support not available - fi + if test $buildneon -eq 1; then + echo NEON support not available fi ;; arm | armv7*) CFLAGS="${CFLAGS} -DUNALIGNED_OK" SFLAGS="${SFLAGS} -DUNALIGNED_OK" - if test $without_optimizations -eq 0; then - if test $buildacle -eq 1; then - echo ACLE support not available - fi + if test $buildacle -eq 1; then + echo ACLE support not available + fi - if test $buildneon -eq 1; then - if test $MFPU_NEON_AVAILABLE -eq 1;then - neonflag="-mfpu=neon" - fi + if test $buildneon -eq 1; then + CFLAGS="${CFLAGS} ${floatabi} -mfpu=neon -DARM_NEON_ADLER32" + SFLAGS="${SFLAGS} ${floatabi} -mfpu=neon -DARM_NEON_ADLER32" - CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo" - fi + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo" fi ;; armv8-a | armv8-a+simd) - CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" + CFLAGS="${CFLAGS} -DUNALIGNED_OK" + SFLAGS="${SFLAGS} -DUNALIGNED_OK" - if test $without_optimizations -eq 0; then - if test $buildacle -eq 1; then - echo ACLE support not available + if test $buildacle -eq 1; then + echo ACLE support not available + fi + + if test $buildneon -eq 1; then + CFLAGS="${CFLAGS} ${floatabi}" + SFLAGS="${SFLAGS} ${floatabi}" + + if test $MFPU_NEON_AVAILABLE -eq 1;then + CFLAGS="${CFLAGS} -mfpu=neon" + SFLAGS="${SFLAGS} -mfpu=neon" fi - if test $buildneon -eq 1; then - if test $MFPU_NEON_AVAILABLE -eq 1;then - neonflag="-mfpu=neon" - fi + CFLAGS="${CFLAGS} -DARM_NEON_ADLER32" + SFLAGS="${SFLAGS} -DARM_NEON_ADLER32" - CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo" - fi + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo" fi ;; armv8-a+crc | armv8-a+crc+simd | armv8.[1234]-a | armv8.[1234]-a+simd) - CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" + CFLAGS="-march=${ARCH} ${CFLAGS} -DARM_ACLE_CRC_HASH -DUNALIGNED_OK" + SFLAGS="-march=${ARCH} ${SFLAGS} -DARM_ACLE_CRC_HASH -DUNALIGNED_OK" - acleflag="-march=${ARCH}" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo" - if test $without_optimizations -eq 0; then - CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH" - SFLAGS="${SFLAGS} -DARM_ACLE_CRC_HASH" + if test $buildneon -eq 1; then + CFLAGS="${CFLAGS} ${floatabi}" + SFLAGS="${SFLAGS} ${floatabi}" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo" - - if test $buildneon -eq 1; then - if test $MFPU_NEON_AVAILABLE -eq 1;then - neonflag="-mfpu=neon" - fi - - CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo" + if test $MFPU_NEON_AVAILABLE -eq 1;then + CFLAGS="${CFLAGS} -mfpu=neon" + SFLAGS="${SFLAGS} -mfpu=neon" fi + + CFLAGS="${CFLAGS} -DARM_NEON_ADLER32" + SFLAGS="${SFLAGS} -DARM_NEON_ADLER32" + + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo" fi ;; esac @@ -1356,98 +1178,61 @@ case "${ARCH}" in aarch64) [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=aarch64 ARCHDIR=arch/arm + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o fill_window_arm.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo fill_window_arm.lo" if test $native -eq 0; then - ARCH="armv8-a" + ARCH="armv8-a" else - ARCH="native" + ARCH="native" fi - - if test $without_optimizations -eq 0; then - CFLAGS="${CFLAGS} -DARM_FEATURES" - SFLAGS="${SFLAGS} -DARM_FEATURES" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo" - - if test $buildacle -eq 1; then - if test $native -eq 0; then - ARCH="${ARCH}+crc" - fi - CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH" - SFLAGS="${SFLAGS} -DARM_ACLE_CRC_HASH" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo" - fi - - if test $buildneon -eq 1; then - if test $native -eq 0; then - ARCH="${ARCH}+simd" - fi - CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo" - fi + if test $buildacle -eq 1; then + if test $native -eq 0; then + ARCH="${ARCH}+crc" + fi + CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH" + SFLAGS="${SFLAGS} -DARM_ACLE_CRC_HASH" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo" fi - - neonflag="-march=${ARCH}" - acleflag="-march=${ARCH}" - - CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" + if test $buildneon -eq 1; then + if test $native -eq 0; then + ARCH="${ARCH}+simd" + fi + CFLAGS="${CFLAGS} -DARM_NEON_ADLER32" + SFLAGS="${SFLAGS} -DARM_NEON_ADLER32" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo" + fi + CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK" + SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK" ;; - powerpc*) - case "${ARCH}" in - powerpc) - [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc - ;; - powerpc64) - [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64 - ;; - powerpc64le) - [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64le - CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK" - ;; - esac - - ARCHDIR=arch/power - - if test $without_optimizations -eq 0; then - if test $HAVE_POWER8 -eq 1; then - CFLAGS="${CFLAGS} -DPOWER8 -DPOWER_FEATURES -DPOWER8_VSX_ADLER32 -DPOWER8_VSX_SLIDEHASH" - SFLAGS="${SFLAGS} -DPOWER8 -DPOWER_FEATURES -DPOWER8_VSX_ADLER32 -DPOWER8_VSX_SLIDEHASH" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} power.o adler32_power8.o slide_hash_power8.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} power.lo adler32_power8.lo slide_hash_power8.lo" - fi - fi + powerpc) + [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc + ;; + powerpc64) + [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64 ;; s390x) [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=s390x ARCHDIR=arch/s390 - - if test $without_optimizations -eq 0; then - if test $builddfltccdeflate -eq 1 -o $builddfltccinflate -eq 1; then - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_common.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_common.lo" - fi - - if test $builddfltccdeflate -eq 1; then - CFLAGS="${CFLAGS} -DS390_DFLTCC_DEFLATE" - SFLAGS="${SFLAGS} -DS390_DFLTCC_DEFLATE" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_deflate.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_deflate.lo" - ARCH="${ARCH}+dfltcc-deflate" - fi - - if test $builddfltccinflate -eq 1; then - CFLAGS="${CFLAGS} -DS390_DFLTCC_INFLATE" - SFLAGS="${SFLAGS} -DS390_DFLTCC_INFLATE" - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_inflate.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_inflate.lo" - ARCH="${ARCH}+dfltcc-inflate" - fi + if test $builddfltccdeflate -eq 1 -o $builddfltccinflate -eq 1; then + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_common.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_common.lo" + fi + if test $builddfltccdeflate -eq 1; then + CFLAGS="${CFLAGS} -DS390_DFLTCC_DEFLATE" + SFLAGS="${SFLAGS} -DS390_DFLTCC_DEFLATE" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_deflate.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_deflate.lo" + ARCH="${ARCH}+dfltcc-deflate" + fi + if test $builddfltccinflate -eq 1; then + CFLAGS="${CFLAGS} -DS390_DFLTCC_INFLATE" + SFLAGS="${SFLAGS} -DS390_DFLTCC_INFLATE" + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_inflate.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_inflate.lo" + ARCH="${ARCH}+dfltcc-inflate" fi ;; *) @@ -1501,24 +1286,12 @@ echo prefix = $prefix >> configure.log echo sharedlibdir = $sharedlibdir >> configure.log echo uname = $uname >> configure.log echo sse2flag = $sse2flag >> configure.log -echo ssse3flag = $ssse3flag >> configure.log echo sse4flag = $sse4flag >> configure.log echo pclmulflag = $pclmulflag >> configure.log -echo acleflag = $acleflag >> configure.log -echo neonflag = $neonflag >> configure.log echo ARCHDIR = ${ARCHDIR} >> configure.log echo ARCH_STATIC_OBJS = ${ARCH_STATIC_OBJS} >> configure.log echo ARCH_SHARED_OBJS = ${ARCH_SHARED_OBJS} >> configure.log -# Handle sed incompatibilities when using -i -replace_in_file() { - if [ "$OS" = 'Darwin' ]; then - sed -i '.tmp' -e "$1" "$2" - else - sed -i'.tmp' -e "$1" "$2" - fi -} - # update Makefile with the configure results INCLUDES="-I$SRCDIR" @@ -1574,7 +1347,7 @@ sed < $SRCDIR/Makefile.in " " > Makefile # Append header files dependences. -for file in $(ls -1 $SRCDIR/*.c $SRCDIR/test/*.c $SRCDIR/test/fuzz/*.c $SRCDIR/$ARCHDIR/*.c $SRCDIR/tools/*.c); do +for file in $(ls -1 $SRCDIR/*.c $SRCDIR/test/*.c $SRCDIR/test/fuzz/*.c $SRCDIR/$ARCHDIR/*.c); do short_name=$(echo $file | sed -e "s#$SRCDIR/##g") incs=$(grep -h include $file | sed -n 's/# *\include *"\(.*\.h\)".*/\1/p' | sort | uniq) includes=$(for i in $incs; do @@ -1593,7 +1366,17 @@ for file in $(ls -1 $SRCDIR/*.c $SRCDIR/test/*.c $SRCDIR/test/fuzz/*.c $SRCDIR/$ if grep -q "^$obj:" Makefile; then # Replace the existing line with a line with all dependences. - $(replace_in_file "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" Makefile) + sed -i "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" Makefile + + # Special case example64 and minigzip64. + case "$obj" in + example.o) + sed -i "s#example64.o:.*#example64.o: \$(SRCDIR)/$short_name $includes#g" Makefile + ;; + minigzip.o) + sed -i "s#minigzip64.o:.*#minigzip64.o: \$(SRCDIR)/$short_name $includes#g" Makefile + ;; + esac else # Append at the end of Makefile a new line with the header dependences. echo "$obj: \$(SRCDIR)/$short_name $includes" >> Makefile @@ -1608,7 +1391,7 @@ for file in $(ls -1 $SRCDIR/*.c $SRCDIR/test/*.c $SRCDIR/test/fuzz/*.c $SRCDIR/$ if grep -q "^$lobj:" Makefile; then # Replace the existing line with a line with all dependences. - $(replace_in_file "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" Makefile) + sed -i "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" Makefile else # Append at the end of Makefile a new line with the header dependences. echo "$lobj: \$(SRCDIR)/$short_name $includes" >> Makefile @@ -1631,13 +1414,9 @@ sed < $SRCDIR/$ARCHDIR/Makefile.in " /^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR# /^SRCTOP *=/s#=.*#=$SRCDIR# /^TOPDIR *=/s#=.*#=$BUILDDIR# -/^AVX2FLAG *=/s#=.*#=$avx2flag# /^SSE2FLAG *=/s#=.*#=$sse2flag# -/^SSSE3FLAG *=/s#=.*#=$ssse3flag# /^SSE4FLAG *=/s#=.*#=$sse4flag# /^PCLMULFLAG *=/s#=.*#=$pclmulflag# -/^ACLEFLAG *=/s#=.*#=$acleflag# -/^NEONFLAG *=/s#=.*#=$neonflag# " > $ARCHDIR/Makefile # Append header files dependences. @@ -1659,7 +1438,7 @@ for file in $(ls -1 $SRCDIR/$ARCHDIR/*.c); do short_name=$(basename $file) if grep -q "^$obj:" $ARCHDIR/Makefile; then # Replace the existing line with a line with all dependences. - $(replace_in_file "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile) + sed -i "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile else # Append at the end of Makefile a new line with the header dependences. echo "$obj: \$(SRCDIR)/$short_name $includes" >> $ARCHDIR/Makefile @@ -1667,7 +1446,7 @@ for file in $(ls -1 $SRCDIR/$ARCHDIR/*.c); do if grep -q "^$lobj:" $ARCHDIR/Makefile; then # Replace the existing line with a line with all dependences. - $(replace_in_file "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile) + sed -i "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile else # Append at the end of Makefile a new line with the header dependences. echo "$lobj: \$(SRCDIR)/$short_name $includes" >> $ARCHDIR/Makefile @@ -1689,7 +1468,6 @@ sed < $SRCDIR/test/Makefile.in " /^COMPATTESTS *=/s#=.*#=$COMPATTESTS# /^QEMU_RUN *=/s#=.*#=$QEMU_RUN# /^WITH_FUZZERS *=/s#=.*#=$with_fuzzers# -/^LIBNAME *=/s#=.*#=$LIBNAME# " > test/Makefile # create zlib.pc with the configure results diff --git a/libs/zlibng/crc32.c b/libs/zlibng/crc32.c index 4b488e617..6c495a57a 100644 --- a/libs/zlibng/crc32.c +++ b/libs/zlibng/crc32.c @@ -9,40 +9,251 @@ * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. */ -#include "zbuild.h" -#include "zendian.h" -#include +/* @(#) $Id$ */ + +# include "zbuild.h" +# include "gzendian.h" +# include + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + + DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. A main() + routine is also produced, so that this one source file can be compiled to an + executable. + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + #include "deflate.h" #include "functable.h" -#include "crc32_tbl.h" + + +/* Local functions for crc concatenation */ +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ +static uint32_t gf2_matrix_times(const uint32_t *mat, uint32_t vec); +static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2); +static void crc32_combine_gen_(uint32_t *op, z_off64_t len2); + +/* ========================================================================= */ +static uint32_t gf2_matrix_times(const uint32_t *mat, uint32_t vec) { + uint32_t sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +#ifdef DYNAMIC_CRC_TABLE +volatile int crc_table_empty = 1; +static uint32_t crc_table[8][256]; +static uint32_t crc_comb[GF2_DIM][GF2_DIM]; +void make_crc_table(void); +static void gf2_matrix_square(uint32_t *square, const uint32_t *mat); +#ifdef MAKECRCH +static void write_table(FILE *, const uint32_t *, int); +#endif /* MAKECRCH */ + +/* ========================================================================= */ +static void gf2_matrix_square(uint32_t *square, const uint32_t *mat) { + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +void make_crc_table() { + uint32_t c; + int n, k; + uint32_t poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320) */ + poly = 0; + for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) + poly |= (uint32_t)1 << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (uint32_t)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = ZSWAP32(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = ZSWAP32(c); + } + } + + /* generate zero operators table for crc32_combine() */ + + /* generate the operator to apply a single zero bit to a CRC -- the + first row adds the polynomial if the low bit is a 1, and the + remaining rows shift the CRC right one bit */ + k = GF2_DIM - 3; + crc_comb[k][0] = 0xedb88320UL; /* CRC-32 polynomial */ + uint32_t row = 1; + for (n = 1; n < GF2_DIM; n++) { + crc_comb[k][n] = row; + row <<= 1; + } + + /* generate operators that apply 2, 4, and 8 zeros to a CRC, putting + the last one, the operator for one zero byte, at the 0 position */ + gf2_matrix_square(crc_comb[k + 1], crc_comb[k]); + gf2_matrix_square(crc_comb[k + 2], crc_comb[k + 1]); + gf2_matrix_square(crc_comb[0], crc_comb[k + 2]); + + /* generate operators for applying 2^n zero bytes to a CRC, filling out + the remainder of the table -- the operators repeat after GF2_DIM + values of n, so the table only needs GF2_DIM entries, regardless of + the size of the length being processed */ + for (n = 1; n < k; n++) + gf2_matrix_square(crc_comb[n], crc_comb[n - 1]); + + /* mark tables as complete, in case someone else is waiting */ + crc_table_empty = 0; + } else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + {} + } +#ifdef MAKECRCH + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + + /* write out CRC table to crc32.h */ + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "static const uint32_t "); + fprintf(out, "crc_table[8][256] =\n{\n {\n"); + write_table(out, crc_table[0], 256); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k], 256); + } + fprintf(out, " }\n};\n"); + + /* write out zero operator table to crc32.h */ + fprintf(out, "\nstatic const uint32_t "); + fprintf(out, "crc_comb[%d][%d] =\n{\n {\n", GF2_DIM, GF2_DIM); + write_table(out, crc_comb[0], GF2_DIM); + for (k = 1; k < GF2_DIM; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_comb[k], GF2_DIM); + } + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +static void write_table(FILE *out, const uint32_t *table, int k) { + int n; + + for (n = 0; n < k; n++) + fprintf(out, "%s0x%08" PRIx32 "%s", n % 5 ? "" : " ", + (uint32_t)(table[n]), + n == k - 1 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} + +int main() +{ + make_crc_table(); + return 0; +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(), + * and tables of zero operator matrices for crc32_combine(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ /* ========================================================================= * This function can be used by asm versions of crc32() */ -const uint32_t * Z_EXPORT PREFIX(get_crc_table)(void) { +const uint32_t * ZEXPORT PREFIX(get_crc_table)(void) { +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ return (const uint32_t *)crc_table; } -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(crc32_z)(unsigned long crc, const unsigned char *buf, size_t len) { - if (buf == NULL) return 0; - - return (unsigned long)functable.crc32((uint32_t)crc, buf, len); -} -#else -uint32_t Z_EXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) { +uint32_t ZEXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) { if (buf == NULL) return 0; return functable.crc32(crc, buf, len); } -#endif /* ========================================================================= */ #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 #define DO4 DO1; DO1; DO1; DO1 /* ========================================================================= */ -Z_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uint64_t len) { +ZLIB_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uint64_t len) +{ crc = crc ^ 0xffffffff; #ifdef UNROLL_MORE @@ -63,15 +274,9 @@ Z_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uint64 return crc ^ 0xffffffff; } -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(crc32)(unsigned long crc, const unsigned char *buf, unsigned int len) { - return (unsigned long)PREFIX(crc32_z)((uint32_t)crc, buf, len); -} -#else -uint32_t Z_EXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t len) { +uint32_t ZEXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t len) { return PREFIX(crc32_z)(crc, buf, len); } -#endif /* This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit @@ -93,9 +298,9 @@ uint32_t Z_EXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 /* ========================================================================= */ -Z_INTERNAL uint32_t crc32_little(uint32_t crc, const unsigned char *buf, uint64_t len) { - Z_REGISTER uint32_t c; - Z_REGISTER const uint32_t *buf4; +ZLIB_INTERNAL uint32_t crc32_little(uint32_t crc, const unsigned char *buf, uint64_t len) { + register uint32_t c; + register const uint32_t *buf4; c = crc; c = ~c; @@ -135,9 +340,9 @@ Z_INTERNAL uint32_t crc32_little(uint32_t crc, const unsigned char *buf, uint64_ #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 /* ========================================================================= */ -Z_INTERNAL uint32_t crc32_big(uint32_t crc, const unsigned char *buf, uint64_t len) { - Z_REGISTER uint32_t c; - Z_REGISTER const uint32_t *buf4; +ZLIB_INTERNAL uint32_t crc32_big(uint32_t crc, const unsigned char *buf, uint64_t len) { + register uint32_t c; + register const uint32_t *buf4; c = ZSWAP32(crc); c = ~c; @@ -169,19 +374,45 @@ Z_INTERNAL uint32_t crc32_big(uint32_t crc, const unsigned char *buf, uint64_t l } #endif /* BYTE_ORDER == BIG_ENDIAN */ + +/* ========================================================================= */ +static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) { + int n; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + + if (len2 > 0) + /* operator for 2^n zeros repeats every GF2_DIM n values */ + for (n = 0; len2; n = (n + 1) % GF2_DIM, len2 >>= 1) + if (len2 & 1) + crc1 = gf2_matrix_times(crc_comb[n], crc1); + return crc1 ^ crc2; +} + +/* ========================================================================= */ +uint32_t ZEXPORT PREFIX(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off_t len2) { + return crc32_combine_(crc1, crc2, len2); +} + +uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t crc1, uint32_t crc2, z_off64_t len2) { + return crc32_combine_(crc1, crc2, len2); +} + #ifdef X86_PCLMULQDQ_CRC #include "arch/x86/x86.h" #include "arch/x86/crc_folding.h" -Z_INTERNAL void crc_finalize(deflate_state *const s) { +ZLIB_INTERNAL void crc_finalize(deflate_state *const s) { if (x86_cpu_has_pclmulqdq) s->strm->adler = crc_fold_512to32(s); } #endif -Z_INTERNAL void crc_reset(deflate_state *const s) { +ZLIB_INTERNAL void crc_reset(deflate_state *const s) { #ifdef X86_PCLMULQDQ_CRC - x86_check_features(); if (x86_cpu_has_pclmulqdq) { crc_fold_init(s); return; @@ -190,7 +421,7 @@ Z_INTERNAL void crc_reset(deflate_state *const s) { s->strm->adler = PREFIX(crc32)(0L, NULL, 0); } -Z_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) { +ZLIB_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) { #ifdef X86_PCLMULQDQ_CRC if (x86_cpu_has_pclmulqdq) { crc_fold_copy(strm->state, dst, strm->next_in, size); @@ -200,3 +431,68 @@ Z_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigne memcpy(dst, strm->next_in, size); strm->adler = PREFIX(crc32)(strm->adler, dst, size); } + +/* ========================================================================= */ +static void crc32_combine_gen_(uint32_t *op, z_off64_t len2) +{ + uint32_t row; + int j; + unsigned i; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + + /* if len2 is zero or negative, return the identity matrix */ + if (len2 <= 0) { + row = 1; + for (j = 0; j < GF2_DIM; j++) { + op[j] = row; + row <<= 1; + } + return; + } + + /* at least one bit in len2 is set -- find it, and copy the operator + corresponding to that position into op */ + i = 0; + for (;;) { + if (len2 & 1) { + for (j = 0; j < GF2_DIM; j++) + op[j] = crc_comb[i][j]; + break; + } + len2 >>= 1; + i = (i + 1) % GF2_DIM; + } + + /* for each remaining bit set in len2 (if any), multiply op by the operator + corresponding to that position */ + for (;;) { + len2 >>= 1; + i = (i + 1) % GF2_DIM; + if (len2 == 0) + break; + if (len2 & 1) + for (j = 0; j < GF2_DIM; j++) + op[j] = gf2_matrix_times(crc_comb[i], op[j]); + } +} + +/* ========================================================================= */ +void ZEXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2) +{ + crc32_combine_gen_(op, len2); +} + +void ZEXPORT PREFIX(crc32_combine_gen64)(uint32_t *op, z_off64_t len2) +{ + crc32_combine_gen_(op, len2); +} + +/* ========================================================================= */ +uint32_t ZEXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t *op) +{ + return gf2_matrix_times(op, crc1) ^ crc2; +} diff --git a/libs/zlibng/crc32_tbl.h b/libs/zlibng/crc32.h similarity index 62% rename from libs/zlibng/crc32_tbl.h rename to libs/zlibng/crc32.h index ee2030c6c..47ca7c068 100644 --- a/libs/zlibng/crc32_tbl.h +++ b/libs/zlibng/crc32.h @@ -1,8 +1,8 @@ -#ifndef CRC32_TBL_H_ -#define CRC32_TBL_H_ +#ifndef CRC32_H_ +#define CRC32_H_ -/* crc32_tbl.h -- tables for rapid CRC calculation - * Generated automatically by makecrct.c +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c */ static const uint32_t crc_table[8][256] = @@ -441,4 +441,295 @@ static const uint32_t crc_table[8][256] = } }; -#endif /* CRC32_TBL_H_ */ +static const uint32_t crc_comb[32][32] = +{ + { + 0x77073096UL, 0xee0e612cUL, 0x076dc419UL, 0x0edb8832UL, 0x1db71064UL, + 0x3b6e20c8UL, 0x76dc4190UL, 0xedb88320UL, 0x00000001UL, 0x00000002UL, + 0x00000004UL, 0x00000008UL, 0x00000010UL, 0x00000020UL, 0x00000040UL, + 0x00000080UL, 0x00000100UL, 0x00000200UL, 0x00000400UL, 0x00000800UL, + 0x00001000UL, 0x00002000UL, 0x00004000UL, 0x00008000UL, 0x00010000UL, + 0x00020000UL, 0x00040000UL, 0x00080000UL, 0x00100000UL, 0x00200000UL, + 0x00400000UL, 0x00800000UL + }, + { + 0x191b3141UL, 0x32366282UL, 0x646cc504UL, 0xc8d98a08UL, 0x4ac21251UL, + 0x958424a2UL, 0xf0794f05UL, 0x3b83984bUL, 0x77073096UL, 0xee0e612cUL, + 0x076dc419UL, 0x0edb8832UL, 0x1db71064UL, 0x3b6e20c8UL, 0x76dc4190UL, + 0xedb88320UL, 0x00000001UL, 0x00000002UL, 0x00000004UL, 0x00000008UL, + 0x00000010UL, 0x00000020UL, 0x00000040UL, 0x00000080UL, 0x00000100UL, + 0x00000200UL, 0x00000400UL, 0x00000800UL, 0x00001000UL, 0x00002000UL, + 0x00004000UL, 0x00008000UL + }, + { + 0xb8bc6765UL, 0xaa09c88bUL, 0x8f629757UL, 0xc5b428efUL, 0x5019579fUL, + 0xa032af3eUL, 0x9b14583dUL, 0xed59b63bUL, 0x01c26a37UL, 0x0384d46eUL, + 0x0709a8dcUL, 0x0e1351b8UL, 0x1c26a370UL, 0x384d46e0UL, 0x709a8dc0UL, + 0xe1351b80UL, 0x191b3141UL, 0x32366282UL, 0x646cc504UL, 0xc8d98a08UL, + 0x4ac21251UL, 0x958424a2UL, 0xf0794f05UL, 0x3b83984bUL, 0x77073096UL, + 0xee0e612cUL, 0x076dc419UL, 0x0edb8832UL, 0x1db71064UL, 0x3b6e20c8UL, + 0x76dc4190UL, 0xedb88320UL + }, + { + 0xccaa009eUL, 0x4225077dUL, 0x844a0efaUL, 0xd3e51bb5UL, 0x7cbb312bUL, + 0xf9766256UL, 0x299dc2edUL, 0x533b85daUL, 0xa6770bb4UL, 0x979f1129UL, + 0xf44f2413UL, 0x33ef4e67UL, 0x67de9cceUL, 0xcfbd399cUL, 0x440b7579UL, + 0x8816eaf2UL, 0xcb5cd3a5UL, 0x4dc8a10bUL, 0x9b914216UL, 0xec53826dUL, + 0x03d6029bUL, 0x07ac0536UL, 0x0f580a6cUL, 0x1eb014d8UL, 0x3d6029b0UL, + 0x7ac05360UL, 0xf580a6c0UL, 0x30704bc1UL, 0x60e09782UL, 0xc1c12f04UL, + 0x58f35849UL, 0xb1e6b092UL + }, + { + 0xae689191UL, 0x87a02563UL, 0xd4314c87UL, 0x73139f4fUL, 0xe6273e9eUL, + 0x173f7b7dUL, 0x2e7ef6faUL, 0x5cfdedf4UL, 0xb9fbdbe8UL, 0xa886b191UL, + 0x8a7c6563UL, 0xcf89cc87UL, 0x44629f4fUL, 0x88c53e9eUL, 0xcafb7b7dUL, + 0x4e87f0bbUL, 0x9d0fe176UL, 0xe16ec4adUL, 0x19ac8f1bUL, 0x33591e36UL, + 0x66b23c6cUL, 0xcd6478d8UL, 0x41b9f7f1UL, 0x8373efe2UL, 0xdd96d985UL, + 0x605cb54bUL, 0xc0b96a96UL, 0x5a03d36dUL, 0xb407a6daUL, 0xb37e4bf5UL, + 0xbd8d91abUL, 0xa06a2517UL + }, + { + 0xf1da05aaUL, 0x38c50d15UL, 0x718a1a2aUL, 0xe3143454UL, 0x1d596ee9UL, + 0x3ab2ddd2UL, 0x7565bba4UL, 0xeacb7748UL, 0x0ee7e8d1UL, 0x1dcfd1a2UL, + 0x3b9fa344UL, 0x773f4688UL, 0xee7e8d10UL, 0x078c1c61UL, 0x0f1838c2UL, + 0x1e307184UL, 0x3c60e308UL, 0x78c1c610UL, 0xf1838c20UL, 0x38761e01UL, + 0x70ec3c02UL, 0xe1d87804UL, 0x18c1f649UL, 0x3183ec92UL, 0x6307d924UL, + 0xc60fb248UL, 0x576e62d1UL, 0xaedcc5a2UL, 0x86c88d05UL, 0xd6e01c4bUL, + 0x76b13ed7UL, 0xed627daeUL + }, + { + 0x8f352d95UL, 0xc51b5d6bUL, 0x5147bc97UL, 0xa28f792eUL, 0x9e6ff41dUL, + 0xe7aeee7bUL, 0x142cdab7UL, 0x2859b56eUL, 0x50b36adcUL, 0xa166d5b8UL, + 0x99bcad31UL, 0xe8085c23UL, 0x0b61be07UL, 0x16c37c0eUL, 0x2d86f81cUL, + 0x5b0df038UL, 0xb61be070UL, 0xb746c6a1UL, 0xb5fc8b03UL, 0xb0881047UL, + 0xba6126cfUL, 0xafb34bdfUL, 0x841791ffUL, 0xd35e25bfUL, 0x7dcd4d3fUL, + 0xfb9a9a7eUL, 0x2c4432bdUL, 0x5888657aUL, 0xb110caf4UL, 0xb95093a9UL, + 0xa9d02113UL, 0x88d14467UL + }, + { + 0x33fff533UL, 0x67ffea66UL, 0xcfffd4ccUL, 0x448eafd9UL, 0x891d5fb2UL, + 0xc94bb925UL, 0x49e6740bUL, 0x93cce816UL, 0xfce8d66dUL, 0x22a0aa9bUL, + 0x45415536UL, 0x8a82aa6cUL, 0xce745299UL, 0x4799a373UL, 0x8f3346e6UL, + 0xc5178b8dUL, 0x515e115bUL, 0xa2bc22b6UL, 0x9e09432dUL, 0xe763801bUL, + 0x15b60677UL, 0x2b6c0ceeUL, 0x56d819dcUL, 0xadb033b8UL, 0x80116131UL, + 0xdb53c423UL, 0x6dd68e07UL, 0xdbad1c0eUL, 0x6c2b3e5dUL, 0xd8567cbaUL, + 0x6bddff35UL, 0xd7bbfe6aUL + }, + { + 0xce3371cbUL, 0x4717e5d7UL, 0x8e2fcbaeUL, 0xc72e911dUL, 0x552c247bUL, + 0xaa5848f6UL, 0x8fc197adUL, 0xc4f2291bUL, 0x52955477UL, 0xa52aa8eeUL, + 0x9124579dUL, 0xf939a97bUL, 0x290254b7UL, 0x5204a96eUL, 0xa40952dcUL, + 0x9363a3f9UL, 0xfdb641b3UL, 0x201d8527UL, 0x403b0a4eUL, 0x8076149cUL, + 0xdb9d2f79UL, 0x6c4b58b3UL, 0xd896b166UL, 0x6a5c648dUL, 0xd4b8c91aUL, + 0x72009475UL, 0xe40128eaUL, 0x13735795UL, 0x26e6af2aUL, 0x4dcd5e54UL, + 0x9b9abca8UL, 0xec447f11UL + }, + { + 0x1072db28UL, 0x20e5b650UL, 0x41cb6ca0UL, 0x8396d940UL, 0xdc5cb4c1UL, + 0x63c86fc3UL, 0xc790df86UL, 0x5450b94dUL, 0xa8a1729aUL, 0x8a33e375UL, + 0xcf16c0abUL, 0x455c8717UL, 0x8ab90e2eUL, 0xce031a1dUL, 0x4777327bUL, + 0x8eee64f6UL, 0xc6adcfadUL, 0x562a991bUL, 0xac553236UL, 0x83db622dUL, + 0xdcc7c21bUL, 0x62fe8277UL, 0xc5fd04eeUL, 0x508b0f9dUL, 0xa1161f3aUL, + 0x995d3835UL, 0xe9cb762bUL, 0x08e7ea17UL, 0x11cfd42eUL, 0x239fa85cUL, + 0x473f50b8UL, 0x8e7ea170UL + }, + { + 0xf891f16fUL, 0x2a52e49fUL, 0x54a5c93eUL, 0xa94b927cUL, 0x89e622b9UL, + 0xc8bd4333UL, 0x4a0b8027UL, 0x9417004eUL, 0xf35f06ddUL, 0x3dcf0bfbUL, + 0x7b9e17f6UL, 0xf73c2fecUL, 0x35095999UL, 0x6a12b332UL, 0xd4256664UL, + 0x733bca89UL, 0xe6779512UL, 0x179e2c65UL, 0x2f3c58caUL, 0x5e78b194UL, + 0xbcf16328UL, 0xa293c011UL, 0x9e568663UL, 0xe7dc0a87UL, 0x14c9134fUL, + 0x2992269eUL, 0x53244d3cUL, 0xa6489a78UL, 0x97e032b1UL, 0xf4b16323UL, + 0x3213c007UL, 0x6427800eUL + }, + { + 0x88b6ba63UL, 0xca1c7287UL, 0x4f49e34fUL, 0x9e93c69eUL, 0xe6568b7dUL, + 0x17dc10bbUL, 0x2fb82176UL, 0x5f7042ecUL, 0xbee085d8UL, 0xa6b00df1UL, + 0x96111da3UL, 0xf7533d07UL, 0x35d77c4fUL, 0x6baef89eUL, 0xd75df13cUL, + 0x75cae439UL, 0xeb95c872UL, 0x0c5a96a5UL, 0x18b52d4aUL, 0x316a5a94UL, + 0x62d4b528UL, 0xc5a96a50UL, 0x5023d2e1UL, 0xa047a5c2UL, 0x9bfe4dc5UL, + 0xec8d9dcbUL, 0x026a3dd7UL, 0x04d47baeUL, 0x09a8f75cUL, 0x1351eeb8UL, + 0x26a3dd70UL, 0x4d47bae0UL + }, + { + 0x5ad8a92cUL, 0xb5b15258UL, 0xb013a2f1UL, 0xbb5643a3UL, 0xaddd8107UL, + 0x80ca044fUL, 0xdae50edfUL, 0x6ebb1bffUL, 0xdd7637feUL, 0x619d69bdUL, + 0xc33ad37aUL, 0x5d04a0b5UL, 0xba09416aUL, 0xaf638495UL, 0x85b60f6bUL, + 0xd01d1897UL, 0x7b4b376fUL, 0xf6966edeUL, 0x365ddbfdUL, 0x6cbbb7faUL, + 0xd9776ff4UL, 0x699fd9a9UL, 0xd33fb352UL, 0x7d0e60e5UL, 0xfa1cc1caUL, + 0x2f4885d5UL, 0x5e910baaUL, 0xbd221754UL, 0xa13528e9UL, 0x991b5793UL, + 0xe947a967UL, 0x09fe548fUL + }, + { + 0xb566f6e2UL, 0xb1bceb85UL, 0xb808d14bUL, 0xab60a4d7UL, 0x8db04fefUL, + 0xc011999fUL, 0x5b52357fUL, 0xb6a46afeUL, 0xb639d3bdUL, 0xb702a13bUL, + 0xb5744437UL, 0xb1998e2fUL, 0xb8421a1fUL, 0xabf5327fUL, 0x8c9b62bfUL, + 0xc247c33fUL, 0x5ffe803fUL, 0xbffd007eUL, 0xa48b06bdUL, 0x92670b3bUL, + 0xffbf1037UL, 0x240f262fUL, 0x481e4c5eUL, 0x903c98bcUL, 0xfb083739UL, + 0x2d616833UL, 0x5ac2d066UL, 0xb585a0ccUL, 0xb07a47d9UL, 0xbb8589f3UL, + 0xac7a15a7UL, 0x83852d0fUL + }, + { + 0x9d9129bfUL, 0xe053553fUL, 0x1bd7ac3fUL, 0x37af587eUL, 0x6f5eb0fcUL, + 0xdebd61f8UL, 0x660bc5b1UL, 0xcc178b62UL, 0x435e1085UL, 0x86bc210aUL, + 0xd6094455UL, 0x77638eebUL, 0xeec71dd6UL, 0x06ff3dedUL, 0x0dfe7bdaUL, + 0x1bfcf7b4UL, 0x37f9ef68UL, 0x6ff3ded0UL, 0xdfe7bda0UL, 0x64be7d01UL, + 0xc97cfa02UL, 0x4988f245UL, 0x9311e48aUL, 0xfd52cf55UL, 0x21d498ebUL, + 0x43a931d6UL, 0x875263acUL, 0xd5d5c119UL, 0x70da8473UL, 0xe1b508e6UL, + 0x181b178dUL, 0x30362f1aUL + }, + { + 0x2ee43a2cUL, 0x5dc87458UL, 0xbb90e8b0UL, 0xac50d721UL, 0x83d0a803UL, + 0xdcd05647UL, 0x62d1aacfUL, 0xc5a3559eUL, 0x5037ad7dUL, 0xa06f5afaUL, + 0x9bafb3b5UL, 0xec2e612bUL, 0x032dc417UL, 0x065b882eUL, 0x0cb7105cUL, + 0x196e20b8UL, 0x32dc4170UL, 0x65b882e0UL, 0xcb7105c0UL, 0x4d930dc1UL, + 0x9b261b82UL, 0xed3d3145UL, 0x010b64cbUL, 0x0216c996UL, 0x042d932cUL, + 0x085b2658UL, 0x10b64cb0UL, 0x216c9960UL, 0x42d932c0UL, 0x85b26580UL, + 0xd015cd41UL, 0x7b5a9cc3UL + }, + { + 0x1b4511eeUL, 0x368a23dcUL, 0x6d1447b8UL, 0xda288f70UL, 0x6f2018a1UL, + 0xde403142UL, 0x67f164c5UL, 0xcfe2c98aUL, 0x44b49555UL, 0x89692aaaUL, + 0xc9a35315UL, 0x4837a06bUL, 0x906f40d6UL, 0xfbaf87edUL, 0x2c2e099bUL, + 0x585c1336UL, 0xb0b8266cUL, 0xba014a99UL, 0xaf739373UL, 0x859620a7UL, + 0xd05d470fUL, 0x7bcb885fUL, 0xf79710beUL, 0x345f273dUL, 0x68be4e7aUL, + 0xd17c9cf4UL, 0x79883fa9UL, 0xf3107f52UL, 0x3d51f8e5UL, 0x7aa3f1caUL, + 0xf547e394UL, 0x31fec169UL + }, + { + 0xbce15202UL, 0xa2b3a245UL, 0x9e1642cbUL, 0xe75d83d7UL, 0x15ca01efUL, + 0x2b9403deUL, 0x572807bcUL, 0xae500f78UL, 0x87d118b1UL, 0xd4d33723UL, + 0x72d76807UL, 0xe5aed00eUL, 0x102ca65dUL, 0x20594cbaUL, 0x40b29974UL, + 0x816532e8UL, 0xd9bb6391UL, 0x6807c163UL, 0xd00f82c6UL, 0x7b6e03cdUL, + 0xf6dc079aUL, 0x36c90975UL, 0x6d9212eaUL, 0xdb2425d4UL, 0x6d394de9UL, + 0xda729bd2UL, 0x6f9431e5UL, 0xdf2863caUL, 0x6521c1d5UL, 0xca4383aaUL, + 0x4ff60115UL, 0x9fec022aUL + }, + { + 0xff08e5efUL, 0x2560cd9fUL, 0x4ac19b3eUL, 0x9583367cUL, 0xf0776ab9UL, + 0x3b9fd333UL, 0x773fa666UL, 0xee7f4cccUL, 0x078f9fd9UL, 0x0f1f3fb2UL, + 0x1e3e7f64UL, 0x3c7cfec8UL, 0x78f9fd90UL, 0xf1f3fb20UL, 0x3896f001UL, + 0x712de002UL, 0xe25bc004UL, 0x1fc68649UL, 0x3f8d0c92UL, 0x7f1a1924UL, + 0xfe343248UL, 0x271962d1UL, 0x4e32c5a2UL, 0x9c658b44UL, 0xe3ba10c9UL, + 0x1c0527d3UL, 0x380a4fa6UL, 0x70149f4cUL, 0xe0293e98UL, 0x1b237b71UL, + 0x3646f6e2UL, 0x6c8dedc4UL + }, + { + 0x6f76172eUL, 0xdeec2e5cUL, 0x66a95af9UL, 0xcd52b5f2UL, 0x41d46da5UL, + 0x83a8db4aUL, 0xdc20b0d5UL, 0x633067ebUL, 0xc660cfd6UL, 0x57b099edUL, + 0xaf6133daUL, 0x85b361f5UL, 0xd017c5abUL, 0x7b5e8d17UL, 0xf6bd1a2eUL, + 0x360b321dUL, 0x6c16643aUL, 0xd82cc874UL, 0x6b2896a9UL, 0xd6512d52UL, + 0x77d35ce5UL, 0xefa6b9caUL, 0x043c75d5UL, 0x0878ebaaUL, 0x10f1d754UL, + 0x21e3aea8UL, 0x43c75d50UL, 0x878ebaa0UL, 0xd46c7301UL, 0x73a9e043UL, + 0xe753c086UL, 0x15d6874dUL + }, + { + 0x56f5cab9UL, 0xadeb9572UL, 0x80a62ca5UL, 0xda3d5f0bUL, 0x6f0bb857UL, + 0xde1770aeUL, 0x675fe71dUL, 0xcebfce3aUL, 0x460e9a35UL, 0x8c1d346aUL, + 0xc34b6e95UL, 0x5de7db6bUL, 0xbbcfb6d6UL, 0xacee6bedUL, 0x82add19bUL, + 0xde2aa577UL, 0x67244cafUL, 0xce48995eUL, 0x47e034fdUL, 0x8fc069faUL, + 0xc4f1d5b5UL, 0x5292ad2bUL, 0xa5255a56UL, 0x913bb2edUL, 0xf906639bUL, + 0x297dc177UL, 0x52fb82eeUL, 0xa5f705dcUL, 0x909f0df9UL, 0xfa4f1db3UL, + 0x2fef3d27UL, 0x5fde7a4eUL + }, + { + 0x385993acUL, 0x70b32758UL, 0xe1664eb0UL, 0x19bd9b21UL, 0x337b3642UL, + 0x66f66c84UL, 0xcdecd908UL, 0x40a8b451UL, 0x815168a2UL, 0xd9d3d705UL, + 0x68d6a84bUL, 0xd1ad5096UL, 0x782ba76dUL, 0xf0574edaUL, 0x3bdf9bf5UL, + 0x77bf37eaUL, 0xef7e6fd4UL, 0x058dd9e9UL, 0x0b1bb3d2UL, 0x163767a4UL, + 0x2c6ecf48UL, 0x58dd9e90UL, 0xb1bb3d20UL, 0xb8077c01UL, 0xab7ffe43UL, + 0x8d8efac7UL, 0xc06cf3cfUL, 0x5ba8e1dfUL, 0xb751c3beUL, 0xb5d2813dUL, + 0xb0d4043bUL, 0xbad90e37UL + }, + { + 0xb4247b20UL, 0xb339f001UL, 0xbd02e643UL, 0xa174cac7UL, 0x999893cfUL, + 0xe84021dfUL, 0x0bf145ffUL, 0x17e28bfeUL, 0x2fc517fcUL, 0x5f8a2ff8UL, + 0xbf145ff0UL, 0xa559b9a1UL, 0x91c27503UL, 0xf8f5ec47UL, 0x2a9adecfUL, + 0x5535bd9eUL, 0xaa6b7b3cUL, 0x8fa7f039UL, 0xc43ee633UL, 0x530cca27UL, + 0xa619944eUL, 0x97422eddUL, 0xf5f55bfbUL, 0x309bb1b7UL, 0x6137636eUL, + 0xc26ec6dcUL, 0x5fac8bf9UL, 0xbf5917f2UL, 0xa5c329a5UL, 0x90f7550bUL, + 0xfa9fac57UL, 0x2e4e5eefUL + }, + { + 0x695186a7UL, 0xd2a30d4eUL, 0x7e371cddUL, 0xfc6e39baUL, 0x23ad7535UL, + 0x475aea6aUL, 0x8eb5d4d4UL, 0xc61aafe9UL, 0x57445993UL, 0xae88b326UL, + 0x8660600dUL, 0xd7b1c65bUL, 0x74128af7UL, 0xe82515eeUL, 0x0b3b2d9dUL, + 0x16765b3aUL, 0x2cecb674UL, 0x59d96ce8UL, 0xb3b2d9d0UL, 0xbc14b5e1UL, + 0xa3586d83UL, 0x9dc1dd47UL, 0xe0f2bccfUL, 0x1a947fdfUL, 0x3528ffbeUL, + 0x6a51ff7cUL, 0xd4a3fef8UL, 0x7236fbb1UL, 0xe46df762UL, 0x13aae885UL, + 0x2755d10aUL, 0x4eaba214UL + }, + { + 0x66bc001eUL, 0xcd78003cUL, 0x41810639UL, 0x83020c72UL, 0xdd751ea5UL, + 0x619b3b0bUL, 0xc3367616UL, 0x5d1dea6dUL, 0xba3bd4daUL, 0xaf06aff5UL, + 0x857c59abUL, 0xd189b517UL, 0x78626c6fUL, 0xf0c4d8deUL, 0x3af8b7fdUL, + 0x75f16ffaUL, 0xebe2dff4UL, 0x0cb4b9a9UL, 0x19697352UL, 0x32d2e6a4UL, + 0x65a5cd48UL, 0xcb4b9a90UL, 0x4de63361UL, 0x9bcc66c2UL, 0xece9cbc5UL, + 0x02a291cbUL, 0x05452396UL, 0x0a8a472cUL, 0x15148e58UL, 0x2a291cb0UL, + 0x54523960UL, 0xa8a472c0UL + }, + { + 0xb58b27b3UL, 0xb0674927UL, 0xbbbf940fUL, 0xac0e2e5fUL, 0x836d5affUL, + 0xddabb3bfUL, 0x6026613fUL, 0xc04cc27eUL, 0x5be882bdUL, 0xb7d1057aUL, + 0xb4d30cb5UL, 0xb2d71f2bUL, 0xbedf3817UL, 0xa6cf766fUL, 0x96efea9fUL, + 0xf6aed37fUL, 0x362ca0bfUL, 0x6c59417eUL, 0xd8b282fcUL, 0x6a1403b9UL, + 0xd4280772UL, 0x732108a5UL, 0xe642114aUL, 0x17f524d5UL, 0x2fea49aaUL, + 0x5fd49354UL, 0xbfa926a8UL, 0xa4234b11UL, 0x93379063UL, 0xfd1e2687UL, + 0x214d4b4fUL, 0x429a969eUL + }, + { + 0xfe273162UL, 0x273f6485UL, 0x4e7ec90aUL, 0x9cfd9214UL, 0xe28a2269UL, + 0x1e654293UL, 0x3cca8526UL, 0x79950a4cUL, 0xf32a1498UL, 0x3d252f71UL, + 0x7a4a5ee2UL, 0xf494bdc4UL, 0x32587dc9UL, 0x64b0fb92UL, 0xc961f724UL, + 0x49b2e809UL, 0x9365d012UL, 0xfdbaa665UL, 0x20044a8bUL, 0x40089516UL, + 0x80112a2cUL, 0xdb535219UL, 0x6dd7a273UL, 0xdbaf44e6UL, 0x6c2f8f8dUL, + 0xd85f1f1aUL, 0x6bcf3875UL, 0xd79e70eaUL, 0x744de795UL, 0xe89bcf2aUL, + 0x0a469815UL, 0x148d302aUL + }, + { + 0xd3c98813UL, 0x7ce21667UL, 0xf9c42cceUL, 0x28f95fddUL, 0x51f2bfbaUL, + 0xa3e57f74UL, 0x9cbbf8a9UL, 0xe206f713UL, 0x1f7ce867UL, 0x3ef9d0ceUL, + 0x7df3a19cUL, 0xfbe74338UL, 0x2cbf8031UL, 0x597f0062UL, 0xb2fe00c4UL, + 0xbe8d07c9UL, 0xa66b09d3UL, 0x97a715e7UL, 0xf43f2d8fUL, 0x330f5d5fUL, + 0x661ebabeUL, 0xcc3d757cUL, 0x430becb9UL, 0x8617d972UL, 0xd75eb4a5UL, + 0x75cc6f0bUL, 0xeb98de16UL, 0x0c40ba6dUL, 0x188174daUL, 0x3102e9b4UL, + 0x6205d368UL, 0xc40ba6d0UL + }, + { + 0xf7d6deb4UL, 0x34dcbb29UL, 0x69b97652UL, 0xd372eca4UL, 0x7d94df09UL, + 0xfb29be12UL, 0x2d227a65UL, 0x5a44f4caUL, 0xb489e994UL, 0xb262d569UL, + 0xbfb4ac93UL, 0xa4185f67UL, 0x9341b88fUL, 0xfdf2775fUL, 0x2095e8ffUL, + 0x412bd1feUL, 0x8257a3fcUL, 0xdfde41b9UL, 0x64cd8533UL, 0xc99b0a66UL, + 0x4847128dUL, 0x908e251aUL, 0xfa6d4c75UL, 0x2fab9eabUL, 0x5f573d56UL, + 0xbeae7aacUL, 0xa62df319UL, 0x972ae073UL, 0xf524c6a7UL, 0x31388b0fUL, + 0x6271161eUL, 0xc4e22c3cUL + }, + { + 0xedb88320UL, 0x00000001UL, 0x00000002UL, 0x00000004UL, 0x00000008UL, + 0x00000010UL, 0x00000020UL, 0x00000040UL, 0x00000080UL, 0x00000100UL, + 0x00000200UL, 0x00000400UL, 0x00000800UL, 0x00001000UL, 0x00002000UL, + 0x00004000UL, 0x00008000UL, 0x00010000UL, 0x00020000UL, 0x00040000UL, + 0x00080000UL, 0x00100000UL, 0x00200000UL, 0x00400000UL, 0x00800000UL, + 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL, 0x10000000UL, + 0x20000000UL, 0x40000000UL + }, + { + 0x76dc4190UL, 0xedb88320UL, 0x00000001UL, 0x00000002UL, 0x00000004UL, + 0x00000008UL, 0x00000010UL, 0x00000020UL, 0x00000040UL, 0x00000080UL, + 0x00000100UL, 0x00000200UL, 0x00000400UL, 0x00000800UL, 0x00001000UL, + 0x00002000UL, 0x00004000UL, 0x00008000UL, 0x00010000UL, 0x00020000UL, + 0x00040000UL, 0x00080000UL, 0x00100000UL, 0x00200000UL, 0x00400000UL, + 0x00800000UL, 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL, + 0x10000000UL, 0x20000000UL + }, + { + 0x1db71064UL, 0x3b6e20c8UL, 0x76dc4190UL, 0xedb88320UL, 0x00000001UL, + 0x00000002UL, 0x00000004UL, 0x00000008UL, 0x00000010UL, 0x00000020UL, + 0x00000040UL, 0x00000080UL, 0x00000100UL, 0x00000200UL, 0x00000400UL, + 0x00000800UL, 0x00001000UL, 0x00002000UL, 0x00004000UL, 0x00008000UL, + 0x00010000UL, 0x00020000UL, 0x00040000UL, 0x00080000UL, 0x00100000UL, + 0x00200000UL, 0x00400000UL, 0x00800000UL, 0x01000000UL, 0x02000000UL, + 0x04000000UL, 0x08000000UL + } +}; +#endif /* CRC32_H_ */ diff --git a/libs/zlibng/crc32_comb.c b/libs/zlibng/crc32_comb.c deleted file mode 100644 index 092c595d9..000000000 --- a/libs/zlibng/crc32_comb.c +++ /dev/null @@ -1,108 +0,0 @@ -/* crc32_comb.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016, 2018 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -#include "zbuild.h" -#include -#include "deflate.h" -#include "crc32_p.h" -#include "crc32_comb_tbl.h" - - -/* Local functions for crc concatenation */ -static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2); -static void crc32_combine_gen_(uint32_t *op, z_off64_t len2); - -/* ========================================================================= */ -static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) { - int n; - - if (len2 > 0) - /* operator for 2^n zeros repeats every GF2_DIM n values */ - for (n = 0; len2; n = (n + 1) % GF2_DIM, len2 >>= 1) - if (len2 & 1) - crc1 = gf2_matrix_times(crc_comb[n], crc1); - return crc1 ^ crc2; -} - -/* ========================================================================= */ -#ifdef ZLIB_COMPAT -unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) { - return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2); -} - -unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) { - return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2); -} -#else -uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) { - return crc32_combine_(crc1, crc2, len2); -} -#endif - -/* ========================================================================= */ - -static void crc32_combine_gen_(uint32_t *op, z_off64_t len2) { - uint32_t row; - int j; - unsigned i; - - /* if len2 is zero or negative, return the identity matrix */ - if (len2 <= 0) { - row = 1; - for (j = 0; j < GF2_DIM; j++) { - op[j] = row; - row <<= 1; - } - return; - } - - /* at least one bit in len2 is set -- find it, and copy the operator - corresponding to that position into op */ - i = 0; - for (;;) { - if (len2 & 1) { - for (j = 0; j < GF2_DIM; j++) - op[j] = crc_comb[i][j]; - break; - } - len2 >>= 1; - i = (i + 1) % GF2_DIM; - } - - /* for each remaining bit set in len2 (if any), multiply op by the operator - corresponding to that position */ - for (;;) { - len2 >>= 1; - i = (i + 1) % GF2_DIM; - if (len2 == 0) - break; - if (len2 & 1) - for (j = 0; j < GF2_DIM; j++) - op[j] = gf2_matrix_times(crc_comb[i], op[j]); - } -} - -/* ========================================================================= */ - -#ifdef ZLIB_COMPAT -void Z_EXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2) { - crc32_combine_gen_(op, len2); -} -#endif - -void Z_EXPORT PREFIX4(crc32_combine_gen)(uint32_t *op, z_off64_t len2) { - crc32_combine_gen_(op, len2); -} - -/* ========================================================================= */ -uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t *op) { - return gf2_matrix_times(op, crc1) ^ crc2; -} diff --git a/libs/zlibng/crc32_comb_tbl.h b/libs/zlibng/crc32_comb_tbl.h deleted file mode 100644 index 43818c3e0..000000000 --- a/libs/zlibng/crc32_comb_tbl.h +++ /dev/null @@ -1,300 +0,0 @@ -#ifndef CRC32_COMB_TBL_H_ -#define CRC32_COMB_TBL_H_ - -/* crc32_comb_tbl.h -- zero operators table for CRC combine - * Generated automatically by makecrct.c - */ - -static const uint32_t crc_comb[32][32] = -{ - { - 0x77073096, 0xee0e612c, 0x076dc419, 0x0edb8832, 0x1db71064, - 0x3b6e20c8, 0x76dc4190, 0xedb88320, 0x00000001, 0x00000002, - 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, - 0x00000080, 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, 0x00010000, - 0x00020000, 0x00040000, 0x00080000, 0x00100000, 0x00200000, - 0x00400000, 0x00800000 - }, - { - 0x191b3141, 0x32366282, 0x646cc504, 0xc8d98a08, 0x4ac21251, - 0x958424a2, 0xf0794f05, 0x3b83984b, 0x77073096, 0xee0e612c, - 0x076dc419, 0x0edb8832, 0x1db71064, 0x3b6e20c8, 0x76dc4190, - 0xedb88320, 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, - 0x00000200, 0x00000400, 0x00000800, 0x00001000, 0x00002000, - 0x00004000, 0x00008000 - }, - { - 0xb8bc6765, 0xaa09c88b, 0x8f629757, 0xc5b428ef, 0x5019579f, - 0xa032af3e, 0x9b14583d, 0xed59b63b, 0x01c26a37, 0x0384d46e, - 0x0709a8dc, 0x0e1351b8, 0x1c26a370, 0x384d46e0, 0x709a8dc0, - 0xe1351b80, 0x191b3141, 0x32366282, 0x646cc504, 0xc8d98a08, - 0x4ac21251, 0x958424a2, 0xf0794f05, 0x3b83984b, 0x77073096, - 0xee0e612c, 0x076dc419, 0x0edb8832, 0x1db71064, 0x3b6e20c8, - 0x76dc4190, 0xedb88320 - }, - { - 0xccaa009e, 0x4225077d, 0x844a0efa, 0xd3e51bb5, 0x7cbb312b, - 0xf9766256, 0x299dc2ed, 0x533b85da, 0xa6770bb4, 0x979f1129, - 0xf44f2413, 0x33ef4e67, 0x67de9cce, 0xcfbd399c, 0x440b7579, - 0x8816eaf2, 0xcb5cd3a5, 0x4dc8a10b, 0x9b914216, 0xec53826d, - 0x03d6029b, 0x07ac0536, 0x0f580a6c, 0x1eb014d8, 0x3d6029b0, - 0x7ac05360, 0xf580a6c0, 0x30704bc1, 0x60e09782, 0xc1c12f04, - 0x58f35849, 0xb1e6b092 - }, - { - 0xae689191, 0x87a02563, 0xd4314c87, 0x73139f4f, 0xe6273e9e, - 0x173f7b7d, 0x2e7ef6fa, 0x5cfdedf4, 0xb9fbdbe8, 0xa886b191, - 0x8a7c6563, 0xcf89cc87, 0x44629f4f, 0x88c53e9e, 0xcafb7b7d, - 0x4e87f0bb, 0x9d0fe176, 0xe16ec4ad, 0x19ac8f1b, 0x33591e36, - 0x66b23c6c, 0xcd6478d8, 0x41b9f7f1, 0x8373efe2, 0xdd96d985, - 0x605cb54b, 0xc0b96a96, 0x5a03d36d, 0xb407a6da, 0xb37e4bf5, - 0xbd8d91ab, 0xa06a2517 - }, - { - 0xf1da05aa, 0x38c50d15, 0x718a1a2a, 0xe3143454, 0x1d596ee9, - 0x3ab2ddd2, 0x7565bba4, 0xeacb7748, 0x0ee7e8d1, 0x1dcfd1a2, - 0x3b9fa344, 0x773f4688, 0xee7e8d10, 0x078c1c61, 0x0f1838c2, - 0x1e307184, 0x3c60e308, 0x78c1c610, 0xf1838c20, 0x38761e01, - 0x70ec3c02, 0xe1d87804, 0x18c1f649, 0x3183ec92, 0x6307d924, - 0xc60fb248, 0x576e62d1, 0xaedcc5a2, 0x86c88d05, 0xd6e01c4b, - 0x76b13ed7, 0xed627dae - }, - { - 0x8f352d95, 0xc51b5d6b, 0x5147bc97, 0xa28f792e, 0x9e6ff41d, - 0xe7aeee7b, 0x142cdab7, 0x2859b56e, 0x50b36adc, 0xa166d5b8, - 0x99bcad31, 0xe8085c23, 0x0b61be07, 0x16c37c0e, 0x2d86f81c, - 0x5b0df038, 0xb61be070, 0xb746c6a1, 0xb5fc8b03, 0xb0881047, - 0xba6126cf, 0xafb34bdf, 0x841791ff, 0xd35e25bf, 0x7dcd4d3f, - 0xfb9a9a7e, 0x2c4432bd, 0x5888657a, 0xb110caf4, 0xb95093a9, - 0xa9d02113, 0x88d14467 - }, - { - 0x33fff533, 0x67ffea66, 0xcfffd4cc, 0x448eafd9, 0x891d5fb2, - 0xc94bb925, 0x49e6740b, 0x93cce816, 0xfce8d66d, 0x22a0aa9b, - 0x45415536, 0x8a82aa6c, 0xce745299, 0x4799a373, 0x8f3346e6, - 0xc5178b8d, 0x515e115b, 0xa2bc22b6, 0x9e09432d, 0xe763801b, - 0x15b60677, 0x2b6c0cee, 0x56d819dc, 0xadb033b8, 0x80116131, - 0xdb53c423, 0x6dd68e07, 0xdbad1c0e, 0x6c2b3e5d, 0xd8567cba, - 0x6bddff35, 0xd7bbfe6a - }, - { - 0xce3371cb, 0x4717e5d7, 0x8e2fcbae, 0xc72e911d, 0x552c247b, - 0xaa5848f6, 0x8fc197ad, 0xc4f2291b, 0x52955477, 0xa52aa8ee, - 0x9124579d, 0xf939a97b, 0x290254b7, 0x5204a96e, 0xa40952dc, - 0x9363a3f9, 0xfdb641b3, 0x201d8527, 0x403b0a4e, 0x8076149c, - 0xdb9d2f79, 0x6c4b58b3, 0xd896b166, 0x6a5c648d, 0xd4b8c91a, - 0x72009475, 0xe40128ea, 0x13735795, 0x26e6af2a, 0x4dcd5e54, - 0x9b9abca8, 0xec447f11 - }, - { - 0x1072db28, 0x20e5b650, 0x41cb6ca0, 0x8396d940, 0xdc5cb4c1, - 0x63c86fc3, 0xc790df86, 0x5450b94d, 0xa8a1729a, 0x8a33e375, - 0xcf16c0ab, 0x455c8717, 0x8ab90e2e, 0xce031a1d, 0x4777327b, - 0x8eee64f6, 0xc6adcfad, 0x562a991b, 0xac553236, 0x83db622d, - 0xdcc7c21b, 0x62fe8277, 0xc5fd04ee, 0x508b0f9d, 0xa1161f3a, - 0x995d3835, 0xe9cb762b, 0x08e7ea17, 0x11cfd42e, 0x239fa85c, - 0x473f50b8, 0x8e7ea170 - }, - { - 0xf891f16f, 0x2a52e49f, 0x54a5c93e, 0xa94b927c, 0x89e622b9, - 0xc8bd4333, 0x4a0b8027, 0x9417004e, 0xf35f06dd, 0x3dcf0bfb, - 0x7b9e17f6, 0xf73c2fec, 0x35095999, 0x6a12b332, 0xd4256664, - 0x733bca89, 0xe6779512, 0x179e2c65, 0x2f3c58ca, 0x5e78b194, - 0xbcf16328, 0xa293c011, 0x9e568663, 0xe7dc0a87, 0x14c9134f, - 0x2992269e, 0x53244d3c, 0xa6489a78, 0x97e032b1, 0xf4b16323, - 0x3213c007, 0x6427800e - }, - { - 0x88b6ba63, 0xca1c7287, 0x4f49e34f, 0x9e93c69e, 0xe6568b7d, - 0x17dc10bb, 0x2fb82176, 0x5f7042ec, 0xbee085d8, 0xa6b00df1, - 0x96111da3, 0xf7533d07, 0x35d77c4f, 0x6baef89e, 0xd75df13c, - 0x75cae439, 0xeb95c872, 0x0c5a96a5, 0x18b52d4a, 0x316a5a94, - 0x62d4b528, 0xc5a96a50, 0x5023d2e1, 0xa047a5c2, 0x9bfe4dc5, - 0xec8d9dcb, 0x026a3dd7, 0x04d47bae, 0x09a8f75c, 0x1351eeb8, - 0x26a3dd70, 0x4d47bae0 - }, - { - 0x5ad8a92c, 0xb5b15258, 0xb013a2f1, 0xbb5643a3, 0xaddd8107, - 0x80ca044f, 0xdae50edf, 0x6ebb1bff, 0xdd7637fe, 0x619d69bd, - 0xc33ad37a, 0x5d04a0b5, 0xba09416a, 0xaf638495, 0x85b60f6b, - 0xd01d1897, 0x7b4b376f, 0xf6966ede, 0x365ddbfd, 0x6cbbb7fa, - 0xd9776ff4, 0x699fd9a9, 0xd33fb352, 0x7d0e60e5, 0xfa1cc1ca, - 0x2f4885d5, 0x5e910baa, 0xbd221754, 0xa13528e9, 0x991b5793, - 0xe947a967, 0x09fe548f - }, - { - 0xb566f6e2, 0xb1bceb85, 0xb808d14b, 0xab60a4d7, 0x8db04fef, - 0xc011999f, 0x5b52357f, 0xb6a46afe, 0xb639d3bd, 0xb702a13b, - 0xb5744437, 0xb1998e2f, 0xb8421a1f, 0xabf5327f, 0x8c9b62bf, - 0xc247c33f, 0x5ffe803f, 0xbffd007e, 0xa48b06bd, 0x92670b3b, - 0xffbf1037, 0x240f262f, 0x481e4c5e, 0x903c98bc, 0xfb083739, - 0x2d616833, 0x5ac2d066, 0xb585a0cc, 0xb07a47d9, 0xbb8589f3, - 0xac7a15a7, 0x83852d0f - }, - { - 0x9d9129bf, 0xe053553f, 0x1bd7ac3f, 0x37af587e, 0x6f5eb0fc, - 0xdebd61f8, 0x660bc5b1, 0xcc178b62, 0x435e1085, 0x86bc210a, - 0xd6094455, 0x77638eeb, 0xeec71dd6, 0x06ff3ded, 0x0dfe7bda, - 0x1bfcf7b4, 0x37f9ef68, 0x6ff3ded0, 0xdfe7bda0, 0x64be7d01, - 0xc97cfa02, 0x4988f245, 0x9311e48a, 0xfd52cf55, 0x21d498eb, - 0x43a931d6, 0x875263ac, 0xd5d5c119, 0x70da8473, 0xe1b508e6, - 0x181b178d, 0x30362f1a - }, - { - 0x2ee43a2c, 0x5dc87458, 0xbb90e8b0, 0xac50d721, 0x83d0a803, - 0xdcd05647, 0x62d1aacf, 0xc5a3559e, 0x5037ad7d, 0xa06f5afa, - 0x9bafb3b5, 0xec2e612b, 0x032dc417, 0x065b882e, 0x0cb7105c, - 0x196e20b8, 0x32dc4170, 0x65b882e0, 0xcb7105c0, 0x4d930dc1, - 0x9b261b82, 0xed3d3145, 0x010b64cb, 0x0216c996, 0x042d932c, - 0x085b2658, 0x10b64cb0, 0x216c9960, 0x42d932c0, 0x85b26580, - 0xd015cd41, 0x7b5a9cc3 - }, - { - 0x1b4511ee, 0x368a23dc, 0x6d1447b8, 0xda288f70, 0x6f2018a1, - 0xde403142, 0x67f164c5, 0xcfe2c98a, 0x44b49555, 0x89692aaa, - 0xc9a35315, 0x4837a06b, 0x906f40d6, 0xfbaf87ed, 0x2c2e099b, - 0x585c1336, 0xb0b8266c, 0xba014a99, 0xaf739373, 0x859620a7, - 0xd05d470f, 0x7bcb885f, 0xf79710be, 0x345f273d, 0x68be4e7a, - 0xd17c9cf4, 0x79883fa9, 0xf3107f52, 0x3d51f8e5, 0x7aa3f1ca, - 0xf547e394, 0x31fec169 - }, - { - 0xbce15202, 0xa2b3a245, 0x9e1642cb, 0xe75d83d7, 0x15ca01ef, - 0x2b9403de, 0x572807bc, 0xae500f78, 0x87d118b1, 0xd4d33723, - 0x72d76807, 0xe5aed00e, 0x102ca65d, 0x20594cba, 0x40b29974, - 0x816532e8, 0xd9bb6391, 0x6807c163, 0xd00f82c6, 0x7b6e03cd, - 0xf6dc079a, 0x36c90975, 0x6d9212ea, 0xdb2425d4, 0x6d394de9, - 0xda729bd2, 0x6f9431e5, 0xdf2863ca, 0x6521c1d5, 0xca4383aa, - 0x4ff60115, 0x9fec022a - }, - { - 0xff08e5ef, 0x2560cd9f, 0x4ac19b3e, 0x9583367c, 0xf0776ab9, - 0x3b9fd333, 0x773fa666, 0xee7f4ccc, 0x078f9fd9, 0x0f1f3fb2, - 0x1e3e7f64, 0x3c7cfec8, 0x78f9fd90, 0xf1f3fb20, 0x3896f001, - 0x712de002, 0xe25bc004, 0x1fc68649, 0x3f8d0c92, 0x7f1a1924, - 0xfe343248, 0x271962d1, 0x4e32c5a2, 0x9c658b44, 0xe3ba10c9, - 0x1c0527d3, 0x380a4fa6, 0x70149f4c, 0xe0293e98, 0x1b237b71, - 0x3646f6e2, 0x6c8dedc4 - }, - { - 0x6f76172e, 0xdeec2e5c, 0x66a95af9, 0xcd52b5f2, 0x41d46da5, - 0x83a8db4a, 0xdc20b0d5, 0x633067eb, 0xc660cfd6, 0x57b099ed, - 0xaf6133da, 0x85b361f5, 0xd017c5ab, 0x7b5e8d17, 0xf6bd1a2e, - 0x360b321d, 0x6c16643a, 0xd82cc874, 0x6b2896a9, 0xd6512d52, - 0x77d35ce5, 0xefa6b9ca, 0x043c75d5, 0x0878ebaa, 0x10f1d754, - 0x21e3aea8, 0x43c75d50, 0x878ebaa0, 0xd46c7301, 0x73a9e043, - 0xe753c086, 0x15d6874d - }, - { - 0x56f5cab9, 0xadeb9572, 0x80a62ca5, 0xda3d5f0b, 0x6f0bb857, - 0xde1770ae, 0x675fe71d, 0xcebfce3a, 0x460e9a35, 0x8c1d346a, - 0xc34b6e95, 0x5de7db6b, 0xbbcfb6d6, 0xacee6bed, 0x82add19b, - 0xde2aa577, 0x67244caf, 0xce48995e, 0x47e034fd, 0x8fc069fa, - 0xc4f1d5b5, 0x5292ad2b, 0xa5255a56, 0x913bb2ed, 0xf906639b, - 0x297dc177, 0x52fb82ee, 0xa5f705dc, 0x909f0df9, 0xfa4f1db3, - 0x2fef3d27, 0x5fde7a4e - }, - { - 0x385993ac, 0x70b32758, 0xe1664eb0, 0x19bd9b21, 0x337b3642, - 0x66f66c84, 0xcdecd908, 0x40a8b451, 0x815168a2, 0xd9d3d705, - 0x68d6a84b, 0xd1ad5096, 0x782ba76d, 0xf0574eda, 0x3bdf9bf5, - 0x77bf37ea, 0xef7e6fd4, 0x058dd9e9, 0x0b1bb3d2, 0x163767a4, - 0x2c6ecf48, 0x58dd9e90, 0xb1bb3d20, 0xb8077c01, 0xab7ffe43, - 0x8d8efac7, 0xc06cf3cf, 0x5ba8e1df, 0xb751c3be, 0xb5d2813d, - 0xb0d4043b, 0xbad90e37 - }, - { - 0xb4247b20, 0xb339f001, 0xbd02e643, 0xa174cac7, 0x999893cf, - 0xe84021df, 0x0bf145ff, 0x17e28bfe, 0x2fc517fc, 0x5f8a2ff8, - 0xbf145ff0, 0xa559b9a1, 0x91c27503, 0xf8f5ec47, 0x2a9adecf, - 0x5535bd9e, 0xaa6b7b3c, 0x8fa7f039, 0xc43ee633, 0x530cca27, - 0xa619944e, 0x97422edd, 0xf5f55bfb, 0x309bb1b7, 0x6137636e, - 0xc26ec6dc, 0x5fac8bf9, 0xbf5917f2, 0xa5c329a5, 0x90f7550b, - 0xfa9fac57, 0x2e4e5eef - }, - { - 0x695186a7, 0xd2a30d4e, 0x7e371cdd, 0xfc6e39ba, 0x23ad7535, - 0x475aea6a, 0x8eb5d4d4, 0xc61aafe9, 0x57445993, 0xae88b326, - 0x8660600d, 0xd7b1c65b, 0x74128af7, 0xe82515ee, 0x0b3b2d9d, - 0x16765b3a, 0x2cecb674, 0x59d96ce8, 0xb3b2d9d0, 0xbc14b5e1, - 0xa3586d83, 0x9dc1dd47, 0xe0f2bccf, 0x1a947fdf, 0x3528ffbe, - 0x6a51ff7c, 0xd4a3fef8, 0x7236fbb1, 0xe46df762, 0x13aae885, - 0x2755d10a, 0x4eaba214 - }, - { - 0x66bc001e, 0xcd78003c, 0x41810639, 0x83020c72, 0xdd751ea5, - 0x619b3b0b, 0xc3367616, 0x5d1dea6d, 0xba3bd4da, 0xaf06aff5, - 0x857c59ab, 0xd189b517, 0x78626c6f, 0xf0c4d8de, 0x3af8b7fd, - 0x75f16ffa, 0xebe2dff4, 0x0cb4b9a9, 0x19697352, 0x32d2e6a4, - 0x65a5cd48, 0xcb4b9a90, 0x4de63361, 0x9bcc66c2, 0xece9cbc5, - 0x02a291cb, 0x05452396, 0x0a8a472c, 0x15148e58, 0x2a291cb0, - 0x54523960, 0xa8a472c0 - }, - { - 0xb58b27b3, 0xb0674927, 0xbbbf940f, 0xac0e2e5f, 0x836d5aff, - 0xddabb3bf, 0x6026613f, 0xc04cc27e, 0x5be882bd, 0xb7d1057a, - 0xb4d30cb5, 0xb2d71f2b, 0xbedf3817, 0xa6cf766f, 0x96efea9f, - 0xf6aed37f, 0x362ca0bf, 0x6c59417e, 0xd8b282fc, 0x6a1403b9, - 0xd4280772, 0x732108a5, 0xe642114a, 0x17f524d5, 0x2fea49aa, - 0x5fd49354, 0xbfa926a8, 0xa4234b11, 0x93379063, 0xfd1e2687, - 0x214d4b4f, 0x429a969e - }, - { - 0xfe273162, 0x273f6485, 0x4e7ec90a, 0x9cfd9214, 0xe28a2269, - 0x1e654293, 0x3cca8526, 0x79950a4c, 0xf32a1498, 0x3d252f71, - 0x7a4a5ee2, 0xf494bdc4, 0x32587dc9, 0x64b0fb92, 0xc961f724, - 0x49b2e809, 0x9365d012, 0xfdbaa665, 0x20044a8b, 0x40089516, - 0x80112a2c, 0xdb535219, 0x6dd7a273, 0xdbaf44e6, 0x6c2f8f8d, - 0xd85f1f1a, 0x6bcf3875, 0xd79e70ea, 0x744de795, 0xe89bcf2a, - 0x0a469815, 0x148d302a - }, - { - 0xd3c98813, 0x7ce21667, 0xf9c42cce, 0x28f95fdd, 0x51f2bfba, - 0xa3e57f74, 0x9cbbf8a9, 0xe206f713, 0x1f7ce867, 0x3ef9d0ce, - 0x7df3a19c, 0xfbe74338, 0x2cbf8031, 0x597f0062, 0xb2fe00c4, - 0xbe8d07c9, 0xa66b09d3, 0x97a715e7, 0xf43f2d8f, 0x330f5d5f, - 0x661ebabe, 0xcc3d757c, 0x430becb9, 0x8617d972, 0xd75eb4a5, - 0x75cc6f0b, 0xeb98de16, 0x0c40ba6d, 0x188174da, 0x3102e9b4, - 0x6205d368, 0xc40ba6d0 - }, - { - 0xf7d6deb4, 0x34dcbb29, 0x69b97652, 0xd372eca4, 0x7d94df09, - 0xfb29be12, 0x2d227a65, 0x5a44f4ca, 0xb489e994, 0xb262d569, - 0xbfb4ac93, 0xa4185f67, 0x9341b88f, 0xfdf2775f, 0x2095e8ff, - 0x412bd1fe, 0x8257a3fc, 0xdfde41b9, 0x64cd8533, 0xc99b0a66, - 0x4847128d, 0x908e251a, 0xfa6d4c75, 0x2fab9eab, 0x5f573d56, - 0xbeae7aac, 0xa62df319, 0x972ae073, 0xf524c6a7, 0x31388b0f, - 0x6271161e, 0xc4e22c3c - }, - { - 0xedb88320, 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, - 0x00000200, 0x00000400, 0x00000800, 0x00001000, 0x00002000, - 0x00004000, 0x00008000, 0x00010000, 0x00020000, 0x00040000, - 0x00080000, 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, - 0x20000000, 0x40000000 - }, - { - 0x76dc4190, 0xedb88320, 0x00000001, 0x00000002, 0x00000004, - 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, 0x00001000, - 0x00002000, 0x00004000, 0x00008000, 0x00010000, 0x00020000, - 0x00040000, 0x00080000, 0x00100000, 0x00200000, 0x00400000, - 0x00800000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000 - }, - { - 0x1db71064, 0x3b6e20c8, 0x76dc4190, 0xedb88320, 0x00000001, - 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, - 0x00000040, 0x00000080, 0x00000100, 0x00000200, 0x00000400, - 0x00000800, 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, 0x00100000, - 0x00200000, 0x00400000, 0x00800000, 0x01000000, 0x02000000, - 0x04000000, 0x08000000 - } -}; - -#endif /* CRC32_COMB_TBL_H_ */ diff --git a/libs/zlibng/crc32_p.h b/libs/zlibng/crc32_p.h deleted file mode 100644 index 47b4b3751..000000000 --- a/libs/zlibng/crc32_p.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CRC32_P_H_ -#define CRC32_P_H_ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - - -static inline uint32_t gf2_matrix_times(const uint32_t *mat, uint32_t vec) { - uint32_t sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - - -#endif /* CRC32_P_H_ */ diff --git a/libs/zlibng/deflate.c b/libs/zlibng/deflate.c index 1707f75c2..dd4edff0e 100644 --- a/libs/zlibng/deflate.c +++ b/libs/zlibng/deflate.c @@ -47,12 +47,15 @@ * */ +/* @(#) $Id$ */ + #include "zbuild.h" #include "deflate.h" #include "deflate_p.h" +#include "match_p.h" #include "functable.h" -const char PREFIX(deflate_copyright)[] = " deflate 1.2.11.f Copyright 1995-2016 Jean-loup Gailly and Mark Adler "; +const char deflate_copyright[] = " deflate 1.2.11.f Copyright 1995-2016 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -80,9 +83,7 @@ const char PREFIX(deflate_copyright)[] = " deflate 1.2.11.f Copyright 1995-2016 /* Invoked at the end of deflateResetKeep(). Useful for initializing arch-specific extension blocks. */ # define DEFLATE_RESET_KEEP_HOOK(strm) do {} while (0) /* Invoked at the beginning of deflateParams(). Useful for updating arch-specific compression parameters. */ -# define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) do {} while (0) -/* Returns whether the last deflate(flush) operation did everything it's supposed to do. */ -# define DEFLATE_DONE(strm, flush) 1 +# define DEFLATE_PARAMS_HOOK(strm, level, strategy) do {} while (0) /* Adjusts the upper bound on compressed data length based on compression parameters and uncompressed data length. * Useful when arch-specific deflation code behaves differently than regular zlib-ng algorithms. */ # define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, sourceLen) do {} while (0) @@ -93,8 +94,6 @@ const char PREFIX(deflate_copyright)[] = " deflate 1.2.11.f Copyright 1995-2016 # define DEFLATE_HOOK(strm, flush, bstate) 0 /* Returns whether zlib-ng should compute a checksum. Set to 0 if arch-specific deflation code already does that. */ # define DEFLATE_NEED_CHECKSUM(strm) 1 -/* Returns whether reproducibility parameter can be set to a given value. */ -# define DEFLATE_CAN_SET_REPRODUCIBLE(strm, reproducible) 1 #endif /* =========================================================================== @@ -104,17 +103,19 @@ typedef block_state (*compress_func) (deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ static int deflateStateCheck (PREFIX3(stream) *strm); +static void slide_hash (deflate_state *s); static block_state deflate_stored (deflate_state *s, int flush); -Z_INTERNAL block_state deflate_fast (deflate_state *s, int flush); -Z_INTERNAL block_state deflate_quick (deflate_state *s, int flush); +ZLIB_INTERNAL block_state deflate_fast (deflate_state *s, int flush); +ZLIB_INTERNAL block_state deflate_quick (deflate_state *s, int flush); #ifndef NO_MEDIUM_STRATEGY -Z_INTERNAL block_state deflate_medium (deflate_state *s, int flush); +ZLIB_INTERNAL block_state deflate_medium (deflate_state *s, int flush); #endif -Z_INTERNAL block_state deflate_slow (deflate_state *s, int flush); +ZLIB_INTERNAL block_state deflate_slow (deflate_state *s, int flush); static block_state deflate_rle (deflate_state *s, int flush); static block_state deflate_huff (deflate_state *s, int flush); static void lm_init (deflate_state *s); -Z_INTERNAL unsigned read_buf (PREFIX3(stream) *strm, unsigned char *buf, unsigned size); +static void putShortMSB (deflate_state *s, uint16_t b); +ZLIB_INTERNAL unsigned read_buf (PREFIX3(stream) *strm, unsigned char *buf, unsigned size); extern void crc_reset(deflate_state *const s); #ifdef X86_PCLMULQDQ_CRC @@ -126,6 +127,9 @@ extern void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned lo * Local data */ +#define NIL 0 +/* Tail of hash chains */ + /* Values for max_lazy_match, good_match and max_chain_length, depending on * the desired pack level (0..9). The values given below have been tuned to * exclude worst case performance for pathological files. Better values may be @@ -143,7 +147,7 @@ static const config configuration_table[10] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -#ifndef NO_QUICK_STRATEGY +#ifdef X86_QUICK_STRATEGY /* 1 */ {4, 4, 8, 4, deflate_quick}, /* 2 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ #else @@ -177,10 +181,12 @@ static const config configuration_table[10] = { /* =========================================================================== - * Initialize the hash table. prev[] will be initialized on the fly. + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) do { \ - memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \ + s->head[s->hash_size - 1] = NIL; \ + memset((unsigned char *)s->head, 0, (unsigned)(s->hash_size - 1) * sizeof(*s->head)); \ } while (0) /* =========================================================================== @@ -188,80 +194,80 @@ static const config configuration_table[10] = { * bit values at the expense of memory usage). We slide even when level == 0 to * keep the hash table consistent if we switch back to level > 0 later. */ -Z_INTERNAL void slide_hash_c(deflate_state *s) { - Pos *p; +static void slide_hash(deflate_state *s) { unsigned n; + Pos *p; unsigned int wsize = s->w_size; - n = HASH_SIZE; + n = s->hash_size; p = &s->head[n]; #ifdef NOT_TWEAK_COMPILER - do { - unsigned m; - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : 0); - } while (--n); + do { + unsigned m; + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); #else - /* As of I make this change, gcc (4.8.*) isn't able to vectorize - * this hot loop using saturated-subtraction on x86-64 architecture. - * To avoid this defect, we can change the loop such that - * o. the pointer advance forward, and - * o. demote the variable 'm' to be local to the loop, and - * choose type "Pos" (instead of 'unsigned int') for the - * variable to avoid unncessary zero-extension. - */ - { - unsigned int i; - Pos *q = p - n; - for (i = 0; i < n; i++) { - Pos m = *q; - Pos t = (Pos)wsize; - *q++ = (Pos)(m >= t ? m-t: 0); - } - } -#endif /* NOT_TWEAK_COMPILER */ + /* As of I make this change, gcc (4.8.*) isn't able to vectorize + * this hot loop using saturated-subtraction on x86-64 architecture. + * To avoid this defect, we can change the loop such that + * o. the pointer advance forward, and + * o. demote the variable 'm' to be local to the loop, and + * choose type "Pos" (instead of 'unsigned int') for the + * variable to avoid unncessary zero-extension. + */ + { + unsigned int i; + Pos *q = p - n; + for (i = 0; i < n; i++) { + Pos m = *q; + Pos t = wsize; + *q++ = (Pos)(m >= t ? m-t: NIL); + } + } - n = wsize; - p = &s->prev[n]; +#endif /* NOT_TWEAK_COMPILER */ + n = wsize; + p = &s->prev[n]; #ifdef NOT_TWEAK_COMPILER - do { - unsigned m; - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : 0); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); + do { + unsigned m; + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); #else - { - unsigned int i; - Pos *q = p - n; - for (i = 0; i < n; i++) { - Pos m = *q; - Pos t = (Pos)wsize; - *q++ = (Pos)(m >= t ? m-t: 0); - } - } + { + unsigned int i; + Pos *q = p - n; + for (i = 0; i < n; i++) { + Pos m = *q; + Pos t = wsize; + *q++ = (Pos)(m >= t ? m-t: NIL); + } + } #endif /* NOT_TWEAK_COMPILER */ } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateInit_)(PREFIX3(stream) *strm, int32_t level, const char *version, int32_t stream_size) { +int ZEXPORT PREFIX(deflateInit_)(PREFIX3(stream) *strm, int level, const char *version, int stream_size) { return PREFIX(deflateInit2_)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* Todo: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int32_t method, int32_t windowBits, - int32_t memLevel, int32_t strategy, const char *version, int32_t stream_size) { - uint32_t window_padding = 0; +int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method, int windowBits, + int memLevel, int strategy, const char *version, int stream_size) { + unsigned window_padding = 0; deflate_state *s; int wrap = 1; static const char my_version[] = PREFIX2(VERSION); -#if defined(X86_FEATURES) +#ifdef X86_CPUID x86_check_features(); -#elif defined(ARM_FEATURES) +#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) arm_check_features(); #endif @@ -273,11 +279,11 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int strm->msg = NULL; if (strm->zalloc == NULL) { - strm->zalloc = zng_calloc; + strm->zalloc = zcalloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zng_cfree; + strm->zfree = zcfree; if (level == Z_DEFAULT_COMPRESSION) level = 6; @@ -299,7 +305,7 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ -#if !defined(NO_QUICK_STRATEGY) && !defined(S390_DFLTCC_DEFLATE) +#ifdef X86_QUICK_STRATEGY if (level == 1) windowBits = 13; #endif @@ -317,6 +323,19 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; +#ifdef X86_SSE4_2_CRC_HASH + if (x86_cpu_has_sse42) + s->hash_bits = (unsigned int)15; + else +#endif + s->hash_bits = (unsigned int)memLevel + 7; + + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; +#if !defined(__x86_64__) && !defined(_M_X64) && !defined(__i386) && !defined(_M_IX86) + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); +#endif + #ifdef X86_PCLMULQDQ_CRC window_padding = 8; #endif @@ -324,7 +343,7 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int s->window = (unsigned char *) ZALLOC_WINDOW(strm, s->w_size + window_padding, 2*sizeof(unsigned char)); s->prev = (Pos *) ZALLOC(strm, s->w_size, sizeof(Pos)); memset(s->prev, 0, s->w_size * sizeof(Pos)); - s->head = (Pos *) ZALLOC(strm, HASH_SIZE, sizeof(Pos)); + s->head = (Pos *) ZALLOC(strm, s->hash_size, sizeof(Pos)); s->high_water = 0; /* nothing written to s->window yet */ @@ -370,9 +389,10 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int */ s->pending_buf = (unsigned char *) ZALLOC(strm, s->lit_bufsize, 4); - s->pending_buf_size = s->lit_bufsize * 4; + s->pending_buf_size = (unsigned long)s->lit_bufsize * 4; - if (s->window == NULL || s->prev == NULL || s->head == NULL || s->pending_buf == NULL) { + if (s->window == NULL || s->prev == NULL || s->head == NULL || + s->pending_buf == NULL) { s->status = FINISH_STATE; strm->msg = ERR_MSG(Z_MEM_ERROR); PREFIX(deflateEnd)(strm); @@ -387,8 +407,8 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int s->level = level; s->strategy = strategy; + s->method = (unsigned char)method; s->block_open = 0; - s->reproducible = 0; return PREFIX(deflateReset)(strm); } @@ -398,7 +418,8 @@ int32_t Z_EXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int32_t level, int */ static int deflateStateCheck (PREFIX3(stream) *strm) { deflate_state *s; - if (strm == NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + if (strm == NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) return 1; s = strm->state; if (s == NULL || s->strm != strm || (s->status != INIT_STATE && @@ -416,7 +437,7 @@ static int deflateStateCheck (PREFIX3(stream) *strm) { } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8_t *dictionary, uint32_t dictLength) { +int ZEXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const unsigned char *dictionary, unsigned int dictLength) { deflate_state *s; unsigned int str, n; int wrap; @@ -441,7 +462,7 @@ int32_t Z_EXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8 if (wrap == 0) { /* already empty otherwise */ CLEAR_HASH(s); s->strstart = 0; - s->block_start = 0; + s->block_start = 0L; s->insert = 0; } dictionary += dictLength - s->w_size; /* use the tail */ @@ -452,30 +473,30 @@ int32_t Z_EXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8 avail = strm->avail_in; next = strm->next_in; strm->avail_in = dictLength; - strm->next_in = (z_const unsigned char *)dictionary; - fill_window(s); + strm->next_in = (const unsigned char *)dictionary; + functable.fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; n = s->lookahead - (MIN_MATCH-1); functable.insert_string(s, str, n); s->strstart = str + n; s->lookahead = MIN_MATCH-1; - fill_window(s); + functable.fill_window(s); } s->strstart += s->lookahead; - s->block_start = (int)s->strstart; + s->block_start = (long)s->strstart; s->insert = s->lookahead; s->lookahead = 0; - s->prev_length = MIN_MATCH-1; + s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; - strm->next_in = (z_const unsigned char *)next; + strm->next_in = next; strm->avail_in = avail; s->wrap = wrap; return Z_OK; } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, uint8_t *dictionary, uint32_t *dictLength) { +int ZEXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int *dictLength) { deflate_state *s; unsigned int len; @@ -494,11 +515,12 @@ int32_t Z_EXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, uint8_t *di } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { deflate_state *s; - if (deflateStateCheck(strm)) + if (deflateStateCheck(strm)) { return Z_STREAM_ERROR; + } strm->total_in = strm->total_out = 0; strm->msg = NULL; /* use zfree if we ever allocate msg dynamically */ @@ -508,9 +530,9 @@ int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { s->pending = 0; s->pending_out = s->pending_buf; - if (s->wrap < 0) + if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - + } s->status = #ifdef GZIP s->wrap == 2 ? GZIP_STATE : @@ -522,10 +544,10 @@ int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { crc_reset(s); else #endif - strm->adler = ADLER32_INITIAL_VALUE; + strm->adler = functable.adler32(0L, NULL, 0); s->last_flush = -2; - zng_tr_init(s); + _tr_init(s); DEFLATE_RESET_KEEP_HOOK(strm); /* hook for IBM Z DFLTCC */ @@ -533,7 +555,7 @@ int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateReset)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(deflateReset)(PREFIX3(stream) *strm) { int ret; ret = PREFIX(deflateResetKeep)(strm); @@ -543,7 +565,7 @@ int32_t Z_EXPORT PREFIX(deflateReset)(PREFIX3(stream) *strm) { } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateSetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { +int ZEXPORT PREFIX(deflateSetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; @@ -551,7 +573,7 @@ int32_t Z_EXPORT PREFIX(deflateSetHeader)(PREFIX3(stream) *strm, PREFIX(gz_heade } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflatePending)(PREFIX3(stream) *strm, uint32_t *pending, int32_t *bits) { +int ZEXPORT PREFIX(deflatePending)(PREFIX3(stream) *strm, uint32_t *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != NULL) @@ -562,38 +584,33 @@ int32_t Z_EXPORT PREFIX(deflatePending)(PREFIX3(stream) *strm, uint32_t *pending } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int32_t bits, int32_t value) { +int ZEXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int bits, int value) { deflate_state *s; - uint64_t value64 = (uint64_t)value; - int32_t put; + int put; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - if (bits < 0 || bits > BIT_BUF_SIZE || bits > (int32_t)(sizeof(value) << 3) || - s->sym_buf < s->pending_out + ((BIT_BUF_SIZE + 7) >> 3)) + if (bits < 0 || bits > 16 || + s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; do { - put = BIT_BUF_SIZE - s->bi_valid; + put = Buf_size - s->bi_valid; if (put > bits) put = bits; - if (s->bi_valid == 0) - s->bi_buf = value64; - else - s->bi_buf |= (value64 & ((UINT64_C(1) << put) - 1)) << s->bi_valid; + s->bi_buf |= (uint16_t)((value & ((1 << put) - 1)) << s->bi_valid); s->bi_valid += put; - zng_tr_flush_bits(s); - value64 >>= put; + _tr_flush_bits(s); + value >>= put; bits -= put; } while (bits); return Z_OK; } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int32_t strategy) { +int ZEXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int level, int strategy) { deflate_state *s; compress_func func; - int hook_flush = Z_NO_FLUSH; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -601,25 +618,25 @@ int32_t Z_EXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int if (level == Z_DEFAULT_COMPRESSION) level = 6; - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; - DEFLATE_PARAMS_HOOK(strm, level, strategy, &hook_flush); /* hook for IBM Z DFLTCC */ + } + DEFLATE_PARAMS_HOOK(strm, level, strategy); /* hook for IBM Z DFLTCC */ func = configuration_table[s->level].func; - if (((strategy != s->strategy || func != configuration_table[level].func) && s->last_flush != -2) - || hook_flush != Z_NO_FLUSH) { - /* Flush the last buffer. Use Z_BLOCK mode, unless the hook requests a "stronger" one. */ - int flush = RANK(hook_flush) > RANK(Z_BLOCK) ? hook_flush : Z_BLOCK; - int err = PREFIX(deflate)(strm, flush); + if ((strategy != s->strategy || func != configuration_table[level].func) && + s->last_flush != -2) { + /* Flush the last buffer: */ + int err = PREFIX(deflate)(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; - if (strm->avail_in || ((int)s->strstart - s->block_start) + s->lookahead || !DEFLATE_DONE(strm, flush)) + if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) return Z_BUF_ERROR; } if (s->level != level) { if (s->level == 0 && s->matches != 0) { if (s->matches == 1) { - functable.slide_hash(s); + slide_hash(s); } else { CLEAR_HASH(s); } @@ -636,7 +653,7 @@ int32_t Z_EXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateTune)(PREFIX3(stream) *strm, int32_t good_length, int32_t max_lazy, int32_t nice_length, int32_t max_chain) { +int ZEXPORT PREFIX(deflateTune)(PREFIX3(stream) *strm, int good_length, int max_lazy, int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) @@ -666,7 +683,7 @@ int32_t Z_EXPORT PREFIX(deflateTune)(PREFIX3(stream) *strm, int32_t good_length, * upper bound of about 14% expansion does not seem onerous for output buffer * allocation. */ -unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long sourceLen) { +unsigned long ZEXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long sourceLen) { deflate_state *s; unsigned long complen, wraplen; @@ -718,39 +735,49 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long /* if not default parameters, return conservative bound */ if (DEFLATE_NEED_CONSERVATIVE_BOUND(strm) || /* hook for IBM Z DFLTCC */ - s->w_bits != 15 || HASH_BITS < 15) + s->w_bits != 15 || s->hash_bits != 8 + 7) return complen + wraplen; /* default settings: return tight bound for that case */ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13 - 6 + wraplen; } +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +static void putShortMSB(deflate_state *s, uint16_t b) { + put_byte(s, (unsigned char)(b >> 8)); + put_byte(s, (unsigned char)(b & 0xff)); +} + /* ========================================================================= * Flush as much pending output as possible. All deflate() output, except for * some deflate_stored() output, goes through this function so some * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -Z_INTERNAL void flush_pending(PREFIX3(stream) *strm) { +ZLIB_INTERNAL void flush_pending(PREFIX3(stream) *strm) { uint32_t len; deflate_state *s = strm->state; - zng_tr_flush_bits(s); + _tr_flush_bits(s); len = s->pending; if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; - Tracev((stderr, "[FLUSH]")); memcpy(strm->next_out, s->pending_out, len); strm->next_out += len; s->pending_out += len; strm->total_out += len; strm->avail_out -= len; s->pending -= len; - if (s->pending == 0) + if (s->pending == 0) { s->pending_out = s->pending_buf; + } } /* =========================================================================== @@ -763,21 +790,21 @@ Z_INTERNAL void flush_pending(PREFIX3(stream) *strm) { } while (0) /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { - int32_t old_flush; /* value of flush param for previous deflate call */ +int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) { + int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; - if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) + if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { return Z_STREAM_ERROR; + } s = strm->state; - if (strm->next_out == NULL || (strm->avail_in != 0 && strm->next_in == NULL) - || (s->status == FINISH_STATE && flush != Z_FINISH)) { + if (strm->next_out == NULL || (strm->avail_in != 0 && strm->next_in == NULL) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } - if (strm->avail_out == 0) { + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - } old_flush = s->last_flush; s->last_flush = flush; @@ -796,16 +823,17 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { return Z_OK; } - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) { + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && + flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { + if (s->status == FINISH_STATE && strm->avail_in != 0) { ERR_RETURN(strm, Z_BUF_ERROR); } @@ -826,16 +854,17 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { else level_flags = 3; header |= (level_flags << 6); - if (s->strstart != 0) - header |= PRESET_DICT; + if (s->strstart != 0) header |= PRESET_DICT; header += 31 - (header % 31); - put_short_msb(s, (uint16_t)header); + putShortMSB(s, header); /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) - put_uint32_msb(s, strm->adler); - strm->adler = ADLER32_INITIAL_VALUE; + if (s->strstart != 0) { + putShortMSB(s, (uint16_t)(strm->adler >> 16)); + putShortMSB(s, (uint16_t)(strm->adler)); + } + strm->adler = functable.adler32(0L, NULL, 0); s->status = BUSY_STATE; /* Compression must start with an empty pending buffer */ @@ -853,7 +882,10 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { put_byte(s, 139); put_byte(s, 8); if (s->gzhead == NULL) { - put_uint32(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); put_byte(s, 0); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); @@ -866,18 +898,25 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { s->last_flush = -1; return Z_OK; } - } else { + } + else { put_byte(s, (s->gzhead->text ? 1 : 0) + (s->gzhead->hcrc ? 2 : 0) + (s->gzhead->extra == NULL ? 0 : 4) + (s->gzhead->name == NULL ? 0 : 8) + (s->gzhead->comment == NULL ? 0 : 16) ); - put_uint32(s, s->gzhead->time); - put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); + put_byte(s, (unsigned char)(s->gzhead->time & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (unsigned char)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != NULL) - put_short(s, (uint16_t)s->gzhead->extra_len); + if (s->gzhead->extra != NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } if (s->gzhead->hcrc) strm->adler = PREFIX(crc32)(strm->adler, s->pending_buf, s->pending); s->gzindex = 0; @@ -913,7 +952,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { if (s->status == NAME_STATE) { if (s->gzhead->name != NULL) { uint32_t beg = s->pending; /* start of bytes to update crc */ - unsigned char val; + int val; do { if (s->pending == s->pending_buf_size) { @@ -936,7 +975,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { if (s->status == COMMENT_STATE) { if (s->gzhead->comment != NULL) { uint32_t beg = s->pending; /* start of bytes to update crc */ - unsigned char val; + int val; do { if (s->pending == s->pending_buf_size) { @@ -964,7 +1003,8 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { return Z_OK; } } - put_short(s, (uint16_t)strm->adler); + put_byte(s, (unsigned char)(strm->adler & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 8) & 0xff)); crc_reset(s); } s->status = BUSY_STATE; @@ -987,6 +1027,9 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { s->level == 0 ? deflate_stored(s, flush) : s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s->strategy == Z_RLE ? deflate_rle(s, flush) : +#ifdef X86_QUICK_STRATEGY + (s->level == 1 && !x86_cpu_has_sse42) ? deflate_fast(s, flush) : +#endif (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { @@ -1007,9 +1050,9 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { - zng_tr_align(s); + _tr_align(s); } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - zng_tr_stored_block(s, (char*)0, 0L, 0); + _tr_stored_block(s, (char*)0, 0L, 0); /* For a full flush, this empty block will be recognized * as a special marker by inflate_sync(). */ @@ -1017,21 +1060,23 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { CLEAR_HASH(s); /* forget history */ if (s->lookahead == 0) { s->strstart = 0; - s->block_start = 0; + s->block_start = 0L; s->insert = 0; } } } flush_pending(strm); if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; } } } if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) + return Z_STREAM_END; /* Write the trailer */ #ifdef GZIP @@ -1039,28 +1084,32 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { # ifdef X86_PCLMULQDQ_CRC crc_finalize(s); # endif - put_uint32(s, strm->adler); - put_uint32(s, (uint32_t)strm->total_in); + put_byte(s, (unsigned char)(strm->adler & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 8) & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 16) & 0xff)); + put_byte(s, (unsigned char)((strm->adler >> 24) & 0xff)); + put_byte(s, (unsigned char)(strm->total_in & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 8) & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 16) & 0xff)); + put_byte(s, (unsigned char)((strm->total_in >> 24) & 0xff)); } else #endif - if (s->wrap == 1) - put_uint32_msb(s, strm->adler); + { + putShortMSB(s, (uint16_t)(strm->adler >> 16)); + putShortMSB(s, (uint16_t)strm->adler); + } flush_pending(strm); /* If avail_out is zero, the application will call deflate again * to flush the rest. */ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - if (s->pending == 0) { - Assert(s->bi_valid == 0, "bi_buf not flushed"); - return Z_STREAM_END; - } - return Z_OK; + return s->pending != 0 ? Z_OK : Z_STREAM_END; } /* ========================================================================= */ -int32_t Z_EXPORT PREFIX(deflateEnd)(PREFIX3(stream) *strm) { - int32_t status; +int ZEXPORT PREFIX(deflateEnd)(PREFIX3(stream) *strm) { + int status; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1082,13 +1131,13 @@ int32_t Z_EXPORT PREFIX(deflateEnd)(PREFIX3(stream) *strm) { /* ========================================================================= * Copy the source state to the destination state. */ -int32_t Z_EXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { +int ZEXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { deflate_state *ds; deflate_state *ss; - uint32_t window_padding = 0; - if (deflateStateCheck(source) || dest == NULL) + if (deflateStateCheck(source) || dest == NULL) { return Z_STREAM_ERROR; + } ss = source->state; @@ -1101,13 +1150,9 @@ int32_t Z_EXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou ZCOPY_STATE((void *)ds, (void *)ss, sizeof(deflate_state)); ds->strm = dest; -#ifdef X86_PCLMULQDQ_CRC - window_padding = 8; -#endif - - ds->window = (unsigned char *) ZALLOC_WINDOW(dest, ds->w_size + window_padding, 2*sizeof(unsigned char)); + ds->window = (unsigned char *) ZALLOC_WINDOW(dest, ds->w_size, 2*sizeof(unsigned char)); ds->prev = (Pos *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Pos *) ZALLOC(dest, HASH_SIZE, sizeof(Pos)); + ds->head = (Pos *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); ds->pending_buf = (unsigned char *) ZALLOC(dest, ds->lit_bufsize, 4); if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) { @@ -1117,8 +1162,8 @@ int32_t Z_EXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(unsigned char)); memcpy((void *)ds->prev, (void *)ss->prev, ds->w_size * sizeof(Pos)); - memcpy((void *)ds->head, (void *)ss->head, HASH_SIZE * sizeof(Pos)); - memcpy(ds->pending_buf, ss->pending_buf, ds->pending_buf_size); + memcpy((void *)ds->head, (void *)ss->head, ds->hash_size * sizeof(Pos)); + memcpy(ds->pending_buf, ss->pending_buf, (unsigned int)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->sym_buf = ds->pending_buf + ds->lit_bufsize; @@ -1137,7 +1182,7 @@ int32_t Z_EXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { +ZLIB_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { uint32_t len = strm->avail_in; if (len > size) @@ -1149,11 +1194,13 @@ Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned if (!DEFLATE_NEED_CHECKSUM(strm)) { memcpy(buf, strm->next_in, len); + } else #ifdef GZIP - } else if (strm->state->wrap == 2) { + if (strm->state->wrap == 2) copy_with_crc(strm, buf, len); + else #endif - } else { + { memcpy(buf, strm->next_in, len); if (strm->state->wrap == 1) strm->adler = functable.adler32(strm->adler, buf, len); @@ -1168,7 +1215,7 @@ Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned * Initialize the "longest match" routines for a new zlib stream */ static void lm_init(deflate_state *s) { - s->window_size = 2 * s->w_size; + s->window_size = (unsigned long)2L*s->w_size; CLEAR_HASH(s); @@ -1180,12 +1227,13 @@ static void lm_init(deflate_state *s) { s->max_chain_length = configuration_table[s->level].max_chain; s->strstart = 0; - s->block_start = 0; + s->block_start = 0L; s->lookahead = 0; s->insert = 0; - s->prev_length = MIN_MATCH-1; + s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; s->match_start = 0; + s->ins_h = 0; } #ifdef ZLIB_DEBUG @@ -1195,23 +1243,12 @@ static void lm_init(deflate_state *s) { /* =========================================================================== * Check that the match at match_start is indeed a match. */ -void check_match(deflate_state *s, Pos start, Pos match, int length) { - /* check that the match length is valid*/ - if (length < MIN_MATCH || length > MAX_MATCH) { - fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); - z_error("invalid match length"); - } - /* check that the match isn't at the same position as the start string */ - if (match == start) { - fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); - z_error("invalid match position"); - } +void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ if (memcmp(s->window + match, s->window + start, length) != EQUAL) { - int32_t i = 0; fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); do { - fprintf(stderr, " %03d: match [%02x] start [%02x]\n", i++, s->window[match++], s->window[start++]); + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); } while (--length != 0); z_error("invalid match"); } @@ -1237,32 +1274,27 @@ void check_match(deflate_state *s, Pos start, Pos match, int length) { * option -- not supported here). */ -void Z_INTERNAL fill_window(deflate_state *s) { +void ZLIB_INTERNAL fill_window_c(deflate_state *s) { unsigned n; - unsigned int more; /* Amount of free space at the end of the window. */ + unsigned more; /* Amount of free space at the end of the window. */ unsigned int wsize = s->w_size; Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); do { - more = s->window_size - s->lookahead - s->strstart; + more = (unsigned)(s->window_size -(unsigned long)s->lookahead -(unsigned long)s->strstart); /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (s->strstart >= wsize+MAX_DIST(s)) { - memcpy(s->window, s->window+wsize, (unsigned)wsize); - if (s->match_start >= wsize) { - s->match_start -= wsize; - } else { - s->match_start = 0; - s->prev_length = 0; - } + memcpy(s->window, s->window+wsize, (unsigned)wsize - more); + s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (int)wsize; + s->block_start -= (long) wsize; if (s->insert > s->strstart) s->insert = s->strstart; - functable.slide_hash(s); + slide_hash(s); more += wsize; } if (s->strm->avail_in == 0) @@ -1287,12 +1319,13 @@ void Z_INTERNAL fill_window(deflate_state *s) { /* Initialize the hash value now that we have some input: */ if (s->lookahead + s->insert >= MIN_MATCH) { unsigned int str = s->strstart - s->insert; + s->ins_h = s->window[str]; if (str >= 1) - functable.quick_insert_string(s, str + 2 - MIN_MATCH); + functable.insert_string(s, str + 2 - MIN_MATCH, 1); #if MIN_MATCH != 3 #error Call insert_string() MIN_MATCH-3 more times while (s->insert) { - functable.quick_insert_string(s, str); + functable.insert_string(s, str, 1); str++; s->insert--; if (s->lookahead + s->insert < MIN_MATCH) @@ -1300,15 +1333,13 @@ void Z_INTERNAL fill_window(deflate_state *s) { } #else unsigned int count; - if (UNLIKELY(s->lookahead == 1)) { + if (unlikely(s->lookahead == 1)){ count = s->insert - 1; - } else { + }else{ count = s->insert; } - if (count > 0) { - functable.insert_string(s, str, count); - s->insert -= count; - } + functable.insert_string(s,str,count); + s->insert -= count; #endif } /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, @@ -1324,8 +1355,8 @@ void Z_INTERNAL fill_window(deflate_state *s) { * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. */ if (s->high_water < s->window_size) { - unsigned int curr = s->strstart + s->lookahead; - unsigned int init; + unsigned long curr = s->strstart + (unsigned long)(s->lookahead); + unsigned long init; if (s->high_water < curr) { /* Previous high water mark below current data -- zero WIN_INIT @@ -1334,17 +1365,17 @@ void Z_INTERNAL fill_window(deflate_state *s) { init = s->window_size - curr; if (init > WIN_INIT) init = WIN_INIT; - memset(s->window + curr, 0, init); + memset(s->window + curr, 0, (unsigned)init); s->high_water = curr + init; - } else if (s->high_water < curr + WIN_INIT) { + } else if (s->high_water < (unsigned long)curr + WIN_INIT) { /* High water mark at or above current data, but below current data * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up * to end of window, whichever is less. */ - init = curr + WIN_INIT - s->high_water; + init = (unsigned long)curr + WIN_INIT - s->high_water; if (init > s->window_size - s->high_water) init = s->window_size - s->high_water; - memset(s->window + s->high_water, 0, init); + memset(s->window + s->high_water, 0, (unsigned)init); s->high_water += init; } } @@ -1392,7 +1423,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { break; /* maximum stored block length that will fit in avail_out: */ have = s->strm->avail_out - have; - left = (int)s->strstart - s->block_start; /* bytes left in window */ + left = s->strstart - s->block_start; /* bytes left in window */ if (len > (unsigned long)left + s->strm->avail_in) len = left + s->strm->avail_in; /* limit len to the input */ if (len > have) @@ -1410,19 +1441,22 @@ static block_state deflate_stored(deflate_state *s, int flush) { * including any pending bits. This also updates the debugging counts. */ last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; - zng_tr_stored_block(s, (char *)0, 0L, last); + _tr_stored_block(s, (char *)0, 0L, last); /* Replace the lengths in the dummy stored block with len. */ - s->pending -= 4; - put_short(s, (uint16_t)len); - put_short(s, (uint16_t)~len); + s->pending_buf[s->pending - 4] = len; + s->pending_buf[s->pending - 3] = len >> 8; + s->pending_buf[s->pending - 2] = ~len; + s->pending_buf[s->pending - 1] = ~len >> 8; /* Write the stored block header bytes. */ flush_pending(s->strm); +#ifdef ZLIB_DEBUG /* Update debugging counts for the data about to be copied. */ - cmpr_bits_add(s, len << 3); - sent_bits_add(s, len << 3); + s->compressed_len += len << 3; + s->bits_sent += len << 3; +#endif /* Copy uncompressed bytes from the window to next_out. */ if (left) { @@ -1432,7 +1466,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { s->strm->next_out += left; s->strm->avail_out -= left; s->strm->total_out += left; - s->block_start += (int)left; + s->block_start += left; len -= left; } @@ -1463,7 +1497,8 @@ static block_state deflate_stored(deflate_state *s, int flush) { memcpy(s->window, s->strm->next_in - s->w_size, s->w_size); s->strstart = s->w_size; s->insert = s->strstart; - } else { + } + else { if (s->window_size - s->strstart <= used) { /* Slide the window down. */ s->strstart -= s->w_size; @@ -1477,7 +1512,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { s->strstart += used; s->insert += MIN(used, s->w_size - s->insert); } - s->block_start = (int)s->strstart; + s->block_start = s->strstart; } if (s->high_water < s->strstart) s->high_water = s->strstart; @@ -1487,14 +1522,15 @@ static block_state deflate_stored(deflate_state *s, int flush) { return finish_done; /* If flushing and all input has been consumed, then done. */ - if (flush != Z_NO_FLUSH && flush != Z_FINISH && s->strm->avail_in == 0 && (int)s->strstart == s->block_start) + if (flush != Z_NO_FLUSH && flush != Z_FINISH && + s->strm->avail_in == 0 && (long)s->strstart == s->block_start) return block_done; /* Fill the window with any remaining input. */ have = s->window_size - s->strstart; - if (s->strm->avail_in > have && s->block_start >= (int)s->w_size) { + if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { /* Slide the window down. */ - s->block_start -= (int)s->w_size; + s->block_start -= s->w_size; s->strstart -= s->w_size; memcpy(s->window, s->window + s->w_size, s->strstart); if (s->matches < 2) @@ -1522,12 +1558,15 @@ static block_state deflate_stored(deflate_state *s, int flush) { /* maximum stored block length that will fit in pending: */ have = MIN(s->pending_buf_size - have, MAX_STORED); min_block = MIN(have, s->w_size); - left = (int)s->strstart - s->block_start; - if (left >= min_block || ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && s->strm->avail_in == 0 && left <= have)) { + left = s->strstart - s->block_start; + if (left >= min_block || + ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && + s->strm->avail_in == 0 && left <= have)) { len = MIN(left, have); - last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0; - zng_tr_stored_block(s, (char *)s->window + s->block_start, len, last); - s->block_start += (int)len; + last = flush == Z_FINISH && s->strm->avail_in == 0 && + len == left ? 1 : 0; + _tr_stored_block(s, (char *)s->window + s->block_start, len, last); + s->block_start += len; flush_pending(s->strm); } @@ -1542,10 +1581,9 @@ static block_state deflate_stored(deflate_state *s, int flush) { * deflate switches away from Z_RLE.) */ static block_state deflate_rle(deflate_state *s, int flush) { - int bflush = 0; /* set if current block must be flushed */ + int bflush; /* set if current block must be flushed */ unsigned int prev; /* byte at distance one to match */ unsigned char *scan, *strend; /* scan goes up to strend for length of run */ - uint32_t match_len = 0; for (;;) { /* Make sure that we always have enough lookahead, except @@ -1553,14 +1591,16 @@ static block_state deflate_rle(deflate_state *s, int flush) { * for the longest run, plus one for the unrolled loop. */ if (s->lookahead <= MAX_MATCH) { - fill_window(s); - if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) + functable.fill_window(s); + if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { return need_more; + } if (s->lookahead == 0) break; /* flush the current block */ } /* See how many times the previous byte repeats */ + s->match_length = 0; if (s->lookahead >= MIN_MATCH && s->strstart > 0) { scan = s->window + s->strstart - 1; prev = *scan; @@ -1572,25 +1612,26 @@ static block_state deflate_rle(deflate_state *s, int flush) { prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && scan < strend); - match_len = MAX_MATCH - (unsigned int)(strend - scan); - if (match_len > s->lookahead) - match_len = s->lookahead; + s->match_length = MAX_MATCH - (unsigned int)(strend - scan); + if (s->match_length > s->lookahead) + s->match_length = s->lookahead; } - Assert(scan <= s->window + s->window_size - 1, "wild scan"); + Assert(scan <= s->window+(unsigned int)(s->window_size-1), "wild scan"); } /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (match_len >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, match_len); + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, s->match_length); - bflush = zng_tr_tally_dist(s, 1, match_len - MIN_MATCH); + _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); - s->lookahead -= match_len; - s->strstart += match_len; - match_len = 0; + s->lookahead -= s->match_length; + s->strstart += s->match_length; + s->match_length = 0; } else { /* No match, output a literal byte */ - bflush = zng_tr_tally_lit(s, s->window[s->strstart]); + Tracevv((stderr, "%c", s->window[s->strstart])); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } @@ -1612,12 +1653,12 @@ static block_state deflate_rle(deflate_state *s, int flush) { * (It will be regenerated if this run of deflate switches away from Huffman.) */ static block_state deflate_huff(deflate_state *s, int flush) { - int bflush = 0; /* set if current block must be flushed */ + int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we have a literal to write. */ if (s->lookahead == 0) { - fill_window(s); + functable.fill_window(s); if (s->lookahead == 0) { if (flush == Z_NO_FLUSH) return need_more; @@ -1626,7 +1667,9 @@ static block_state deflate_huff(deflate_state *s, int flush) { } /* Output a literal byte */ - bflush = zng_tr_tally_lit(s, s->window[s->strstart]); + s->match_length = 0; + Tracevv((stderr, "%c", s->window[s->strstart])); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; if (bflush) @@ -1642,141 +1685,28 @@ static block_state deflate_huff(deflate_state *s, int flush) { return block_done; } -#ifndef ZLIB_COMPAT -/* ========================================================================= - * Checks whether buffer size is sufficient and whether this parameter is a duplicate. +#ifdef ZLIB_DEBUG +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. */ -static int32_t deflateSetParamPre(zng_deflate_param_value **out, size_t min_size, zng_deflate_param_value *param) { - int32_t buf_error = param->size < min_size; +void send_bits(deflate_state *s, int value, int length) { + Tracevv((stderr, " l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (unsigned long)length; - if (*out != NULL) { - (*out)->status = Z_BUF_ERROR; - buf_error = 1; + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (uint16_t)value << s->bi_valid; + put_short(s, s->bi_buf); + s->bi_buf = (uint16_t)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= (uint16_t)value << s->bi_valid; + s->bi_valid += length; } - *out = param; - return buf_error; -} - -/* ========================================================================= */ -int32_t Z_EXPORT zng_deflateSetParams(zng_stream *strm, zng_deflate_param_value *params, size_t count) { - size_t i; - deflate_state *s; - zng_deflate_param_value *new_level = NULL; - zng_deflate_param_value *new_strategy = NULL; - zng_deflate_param_value *new_reproducible = NULL; - int param_buf_error; - int version_error = 0; - int buf_error = 0; - int stream_error = 0; - int ret; - int val; - - /* Initialize the statuses. */ - for (i = 0; i < count; i++) - params[i].status = Z_OK; - - /* Check whether the stream state is consistent. */ - if (deflateStateCheck(strm)) - return Z_STREAM_ERROR; - s = strm->state; - - /* Check buffer sizes and detect duplicates. */ - for (i = 0; i < count; i++) { - switch (params[i].param) { - case Z_DEFLATE_LEVEL: - param_buf_error = deflateSetParamPre(&new_level, sizeof(int), ¶ms[i]); - break; - case Z_DEFLATE_STRATEGY: - param_buf_error = deflateSetParamPre(&new_strategy, sizeof(int), ¶ms[i]); - break; - case Z_DEFLATE_REPRODUCIBLE: - param_buf_error = deflateSetParamPre(&new_reproducible, sizeof(int), ¶ms[i]); - break; - default: - params[i].status = Z_VERSION_ERROR; - version_error = 1; - param_buf_error = 0; - break; - } - if (param_buf_error) { - params[i].status = Z_BUF_ERROR; - buf_error = 1; - } - } - /* Exit early if small buffers or duplicates are detected. */ - if (buf_error) - return Z_BUF_ERROR; - - /* Apply changes, remember if there were errors. */ - if (new_level != NULL || new_strategy != NULL) { - ret = PREFIX(deflateParams)(strm, new_level == NULL ? s->level : *(int *)new_level->buf, - new_strategy == NULL ? s->strategy : *(int *)new_strategy->buf); - if (ret != Z_OK) { - if (new_level != NULL) - new_level->status = Z_STREAM_ERROR; - if (new_strategy != NULL) - new_strategy->status = Z_STREAM_ERROR; - stream_error = 1; - } - } - if (new_reproducible != NULL) { - val = *(int *)new_reproducible->buf; - if (DEFLATE_CAN_SET_REPRODUCIBLE(strm, val)) { - s->reproducible = val; - } else { - new_reproducible->status = Z_STREAM_ERROR; - stream_error = 1; - } - } - - /* Report version errors only if there are no real errors. */ - return stream_error ? Z_STREAM_ERROR : (version_error ? Z_VERSION_ERROR : Z_OK); -} - -/* ========================================================================= */ -int32_t Z_EXPORT zng_deflateGetParams(zng_stream *strm, zng_deflate_param_value *params, size_t count) { - deflate_state *s; - size_t i; - int32_t buf_error = 0; - int32_t version_error = 0; - - /* Initialize the statuses. */ - for (i = 0; i < count; i++) - params[i].status = Z_OK; - - /* Check whether the stream state is consistent. */ - if (deflateStateCheck(strm)) - return Z_STREAM_ERROR; - s = strm->state; - - for (i = 0; i < count; i++) { - switch (params[i].param) { - case Z_DEFLATE_LEVEL: - if (params[i].size < sizeof(int)) - params[i].status = Z_BUF_ERROR; - else - *(int *)params[i].buf = s->level; - break; - case Z_DEFLATE_STRATEGY: - if (params[i].size < sizeof(int)) - params[i].status = Z_BUF_ERROR; - else - *(int *)params[i].buf = s->strategy; - break; - case Z_DEFLATE_REPRODUCIBLE: - if (params[i].size < sizeof(int)) - params[i].status = Z_BUF_ERROR; - else - *(int *)params[i].buf = s->reproducible; - break; - default: - params[i].status = Z_VERSION_ERROR; - version_error = 1; - break; - } - if (params[i].status == Z_BUF_ERROR) - buf_error = 1; - } - return buf_error ? Z_BUF_ERROR : (version_error ? Z_VERSION_ERROR : Z_OK); } #endif diff --git a/libs/zlibng/deflate.h b/libs/zlibng/deflate.h index 03ea3126f..bbe8f6b07 100644 --- a/libs/zlibng/deflate.h +++ b/libs/zlibng/deflate.h @@ -10,8 +10,10 @@ subject to change. Applications should only use zlib.h. */ +/* @(#) $Id$ */ + #include "zutil.h" -#include "zendian.h" +#include "gzendian.h" /* define NO_GZIP when compiling if you want to disable gzip header and trailer creation by deflate(). NO_GZIP would be used to avoid linking in @@ -21,6 +23,10 @@ # define GZIP #endif +#define NIL 0 +/* Tail of hash chains */ + + /* =========================================================================== * Internal compression state. */ @@ -46,7 +52,7 @@ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ -#define BIT_BUF_SIZE 64 +#define Buf_size 16 /* size of bit buffer in bi_buf */ #define END_BLOCK 256 @@ -64,10 +70,6 @@ #define FINISH_STATE 666 /* stream complete */ /* Stream status */ -#define HASH_BITS 16u /* log2(HASH_SIZE) */ -#define HASH_SIZE 65536u /* number of elements in hash table */ -#define HASH_MASK (HASH_SIZE - 1u) /* HASH_SIZE-1 */ - /* Data structure describing a single value and its code string. */ typedef struct ct_data_s { @@ -95,47 +97,34 @@ typedef struct tree_desc_s { } tree_desc; typedef uint16_t Pos; +typedef unsigned IPos; /* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. + * save space in the various tables. IPos is used only for parameter passing. */ typedef struct internal_state { PREFIX3(stream) *strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ unsigned char *pending_buf; /* output still pending */ + unsigned long pending_buf_size; /* size of pending_buf */ unsigned char *pending_out; /* next pending byte to output to the stream */ - uint32_t pending_buf_size; /* size of pending_buf */ uint32_t pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - uint32_t gzindex; /* where in extra, name, or comment */ PREFIX(gz_headerp) gzhead; /* gzip header information to write */ - int status; /* as the name implies */ + uint32_t gzindex; /* where in extra, name, or comment */ + unsigned char method; /* can only be DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ - int reproducible; /* Whether reproducible compression results are required. */ - int block_open; - /* Whether or not a block is currently open for the QUICK deflation scheme. - * This is set to 1 if there is an active block, or 0 if the block was just closed. - */ +#ifdef X86_PCLMULQDQ_CRC + unsigned crc0[4 * 5]; +#endif /* used by deflate.c: */ unsigned int w_size; /* LZ77 window size (32K by default) */ unsigned int w_bits; /* log2(w_size) (8..16) */ unsigned int w_mask; /* w_size - 1 */ - unsigned int lookahead; /* number of valid bytes ahead in window */ - - unsigned int high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - - unsigned int window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ unsigned char *window; /* Sliding window. Input bytes are read into the second half of the window, @@ -147,24 +136,44 @@ typedef struct internal_state { * To do: use the user input buffer as sliding window. */ + unsigned long window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + Pos *prev; /* Link to older string with same hash index. To limit the size of this * array to 64K, this link is maintained only for the last 32K strings. * An index in this array is thus a window index modulo 32K. */ - Pos *head; /* Heads of the hash chains or 0. */ + Pos *head; /* Heads of the hash chains or NIL. */ - int block_start; + unsigned int ins_h; /* hash index of string to be inserted */ + unsigned int hash_size; /* number of elements in hash table */ + unsigned int hash_bits; /* log2(hash_size) */ + unsigned int hash_mask; /* hash_size-1 */ + + #if !defined(__x86_64__) && !defined(_M_X64) && !defined(__i386) && !defined(_M_IX86) + unsigned int hash_shift; + #endif + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; /* Window position at the beginning of the current output block. Gets * negative when the window is moved backwards. */ unsigned int match_length; /* length of best match */ - Pos prev_match; /* previous match */ + IPos prev_match; /* previous match */ int match_available; /* set if previous match exists */ unsigned int strstart; /* start of string to insert */ unsigned int match_start; /* start of matching string */ + unsigned int lookahead; /* number of valid bytes ahead in window */ unsigned int prev_length; /* Length of the best match at previous step. Matches not greater than this @@ -172,13 +181,15 @@ typedef struct internal_state { */ unsigned int max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this length. - * A higher limit improves compression ratio but degrades the speed. + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. */ unsigned int max_lazy_match; - /* Attempt to find a better match only when the current match is strictly smaller - * than this value. This mechanism is used only for compression levels >= 4. + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. */ # define max_insert_length max_lazy_match /* Insert new strings in the hash table only if the match length is not @@ -194,11 +205,6 @@ typedef struct internal_state { int nice_match; /* Stop searching when current match exceeds this */ -#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86) - /* Only used if X86_PCLMULQDQ_CRC is defined */ - unsigned crc0[4 * 5]; -#endif - /* used by trees.c: */ /* Didn't use ct_data typedef below to suppress compiler warning */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ @@ -223,6 +229,8 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ + unsigned char *sym_buf; /* buffer for distances and literals/lengths */ + unsigned int lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for * limiting lit_bufsize to 64K: @@ -243,31 +251,41 @@ typedef struct internal_state { * - I can't count above 4 */ - unsigned char *sym_buf; /* buffer for distances and literals/lengths */ - unsigned int sym_next; /* running index in sym_buf */ - unsigned int sym_end; /* symbol table full when sym_next reaches this */ + unsigned int sym_next; /* running index in sym_buf */ + unsigned int sym_end; /* symbol table full when sym_next reaches this */ unsigned long opt_len; /* bit length of current block with optimal trees */ unsigned long static_len; /* bit length of current block with static trees */ unsigned int matches; /* number of string matches in current block */ unsigned int insert; /* bytes at end of window left to insert */ - /* compressed_len and bits_sent are only used if ZLIB_DEBUG is defined */ +#ifdef ZLIB_DEBUG unsigned long compressed_len; /* total bit length of compressed file mod 2^32 */ unsigned long bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif - /* Reserved for future use and alignment purposes */ - char *reserved_p; + uint16_t bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ - uint64_t bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least significant bits). */ + unsigned long high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + int block_open; + /* Whether or not a block is currently open for the QUICK deflation scheme. + * This is set to 1 if there is an active block, or 0 if the block was just + * closed. + */ - int32_t bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit are always zero. */ - - /* Reserved for future use and alignment purposes */ - int32_t reserved[11]; -} ALIGNED_(8) deflate_state; +} deflate_state; typedef enum { need_more, /* block not completed, need more input or more output */ @@ -279,88 +297,18 @@ typedef enum { /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ -#define put_byte(s, c) { \ - s->pending_buf[s->pending++] = (unsigned char)(c); \ -} +#define put_byte(s, c) {s->pending_buf[s->pending++] = (unsigned char)(c);} /* =========================================================================== * Output a short LSB first on the stream. - * IN assertion: there is enough room in pending_buf. + * IN assertion: there is enough room in pendingBuf. */ static inline void put_short(deflate_state *s, uint16_t w) { -#if defined(UNALIGNED_OK) - *(uint16_t *)(&s->pending_buf[s->pending]) = w; - s->pending += 2; -#else - put_byte(s, (w & 0xff)); - put_byte(s, ((w >> 8) & 0xff)); -#endif -} - -/* =========================================================================== - * Output a short MSB first on the stream. - * IN assertion: there is enough room in pending_buf. - */ -static inline void put_short_msb(deflate_state *s, uint16_t w) { - put_byte(s, ((w >> 8) & 0xff)); - put_byte(s, (w & 0xff)); -} - -/* =========================================================================== - * Output a 32-bit unsigned int LSB first on the stream. - * IN assertion: there is enough room in pending_buf. - */ -static inline void put_uint32(deflate_state *s, uint32_t dw) { -#if defined(UNALIGNED_OK) - *(uint32_t *)(&s->pending_buf[s->pending]) = dw; - s->pending += 4; -#else - put_byte(s, (dw & 0xff)); - put_byte(s, ((dw >> 8) & 0xff)); - put_byte(s, ((dw >> 16) & 0xff)); - put_byte(s, ((dw >> 24) & 0xff)); -#endif -} - -/* =========================================================================== - * Output a 32-bit unsigned int MSB first on the stream. - * IN assertion: there is enough room in pending_buf. - */ -static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { -#if defined(UNALIGNED_OK) - *(uint32_t *)(&s->pending_buf[s->pending]) = ZSWAP32(dw); - s->pending += 4; -#else - put_byte(s, ((dw >> 24) & 0xff)); - put_byte(s, ((dw >> 16) & 0xff)); - put_byte(s, ((dw >> 8) & 0xff)); - put_byte(s, (dw & 0xff)); -#endif -} - -/* =========================================================================== - * Output a 64-bit unsigned int LSB first on the stream. - * IN assertion: there is enough room in pending_buf. - */ -static inline void put_uint64(deflate_state *s, uint64_t lld) { -#if defined(UNALIGNED64_OK) - *(uint64_t *)(&s->pending_buf[s->pending]) = lld; - s->pending += 8; -#elif defined(UNALIGNED_OK) - *(uint32_t *)(&s->pending_buf[s->pending]) = lld & 0xffffffff; - s->pending += 4; - *(uint32_t *)(&s->pending_buf[s->pending]) = (lld >> 32) & 0xffffffff; - s->pending += 4; -#else - put_byte(s, (lld & 0xff)); - put_byte(s, ((lld >> 8) & 0xff)); - put_byte(s, ((lld >> 16) & 0xff)); - put_byte(s, ((lld >> 24) & 0xff)); - put_byte(s, ((lld >> 32) & 0xff)); - put_byte(s, ((lld >> 40) & 0xff)); - put_byte(s, ((lld >> 48) & 0xff)); - put_byte(s, ((lld >> 56) & 0xff)); +#if BYTE_ORDER == BIG_ENDIAN + w = ZSWAP16(w); #endif + memcpy(&(s->pending_buf[s->pending]), &w, sizeof(uint16_t)); + s->pending += 2; } #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) @@ -378,34 +326,120 @@ static inline void put_uint64(deflate_state *s, uint64_t lld) { memory checker errors from longest match routines */ -void Z_INTERNAL fill_window(deflate_state *s); -void Z_INTERNAL slide_hash_c(deflate_state *s); +void ZLIB_INTERNAL fill_window_c(deflate_state *s); /* in trees.c */ -void Z_INTERNAL zng_tr_init(deflate_state *s); -void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last); -void Z_INTERNAL zng_tr_flush_bits(deflate_state *s); -void Z_INTERNAL zng_tr_align(deflate_state *s); -void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last); -unsigned Z_INTERNAL bi_reverse(unsigned code, int len); -void Z_INTERNAL flush_pending(PREFIX3(streamp) strm); -#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)]) +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last); +void ZLIB_INTERNAL bi_windup(deflate_state *s); +unsigned ZLIB_INTERNAL bi_reverse(unsigned code, int len); +void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm); + +#define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never + * must not have side effects. _dist_code[256] and _dist_code[257] are never * used. */ -/* Bit buffer and compress bits calculation debugging */ -#ifdef ZLIB_DEBUG -# define cmpr_bits_add(s, len) s->compressed_len += (len) -# define cmpr_bits_align(s) s->compressed_len = (s->compressed_len + 7) & ~7L -# define sent_bits_add(s, bits) s->bits_sent += (bits) -# define sent_bits_align(s) s->bits_sent = (s->bits_sent + 7) & ~7L +#ifndef ZLIB_DEBUG +/* Inline versions of _tr_tally for speed: */ + +# if defined(GEN_TREES_H) + extern unsigned char ZLIB_INTERNAL _length_code[]; + extern unsigned char ZLIB_INTERNAL _dist_code[]; +# else + extern const unsigned char ZLIB_INTERNAL _length_code[]; + extern const unsigned char ZLIB_INTERNAL _dist_code[]; +# endif + +# define _tr_tally_lit(s, c, flush) \ + { unsigned char cc = (c); \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { unsigned char len = (unsigned char)(length); \ + uint16_t dist = (uint16_t)(distance); \ + s->sym_buf[s->sym_next++] = dist; \ + s->sym_buf[s->sym_next++] = dist >> 8; \ + s->sym_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } #else -# define cmpr_bits_add(s, len) (void)(len) -# define cmpr_bits_align(s) -# define sent_bits_add(s, bits) (void)(bits) -# define sent_bits_align(s) +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, (unsigned)(distance), (unsigned)(length)) +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ + +#ifdef NOT_TWEAK_COMPILER +#define TRIGGER_LEVEL 6 +#else +#define TRIGGER_LEVEL 5 +#endif + +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86) +#define UPDATE_HASH(s, h, i) \ + do {\ + if (s->level < TRIGGER_LEVEL) \ + h = (3483 * (s->window[i]) +\ + 23081* (s->window[i+1]) +\ + 6954 * (s->window[i+2]) +\ + 20947* (s->window[i+3])) & s->hash_mask;\ + else\ + h = (25881* (s->window[i]) +\ + 24674* (s->window[i+1]) +\ + 25811* (s->window[i+2])) & s->hash_mask;\ + } while (0) +#else +# define UPDATE_HASH(s, h, i) (h = (((h) << s->hash_shift) ^ (s->window[i + (MIN_MATCH-1)])) & s->hash_mask) +#endif + +#ifndef ZLIB_DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) +/* Send a code of the given tree. c and tree must not have side effects */ + +#else /* ZLIB_DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose > 2) { \ + fprintf(stderr, "\ncd %3d ", (c)); \ + } \ + send_bits(s, tree[c].Code, tree[c].Len); \ + } +#endif + +#ifdef ZLIB_DEBUG +void send_bits(deflate_state *s, int value, int length); +#else +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = (int)value;\ + s->bi_buf |= (uint16_t)val << s->bi_valid;\ + put_short(s, s->bi_buf);\ + s->bi_buf = (uint16_t)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (uint16_t)(value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} #endif #endif /* DEFLATE_H_ */ diff --git a/libs/zlibng/deflate_fast.c b/libs/zlibng/deflate_fast.c index 14718ba14..07f29f396 100644 --- a/libs/zlibng/deflate_fast.c +++ b/libs/zlibng/deflate_fast.c @@ -7,6 +7,7 @@ #include "zbuild.h" #include "deflate.h" #include "deflate_p.h" +#include "match_p.h" #include "functable.h" /* =========================================================================== @@ -16,11 +17,9 @@ * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { - Pos hash_head; /* head of the hash chain */ - int bflush = 0; /* set if current block must be flushed */ - int64_t dist; - uint32_t match_len = 0; +ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { + IPos hash_head; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we always have enough lookahead, except @@ -29,78 +28,93 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) { + functable.fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } - if (UNLIKELY(s->lookahead == 0)) + if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ + hash_head = NIL; if (s->lookahead >= MIN_MATCH) { - hash_head = functable.quick_insert_string(s, s->strstart); - dist = (int64_t)s->strstart - hash_head; - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match length < MIN_MATCH - */ - - if (dist <= MAX_DIST(s) && dist > 0) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - match_len = functable.longest_match(s, hash_head); - /* longest_match() sets match_start */ - } + hash_head = functable.insert_string(s, s->strstart, 1); } - if (match_len >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, match_len); + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match(s, hash_head); + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); - bflush = zng_tr_tally_dist(s, s->strstart - s->match_start, match_len - MIN_MATCH); + _tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush); - s->lookahead -= match_len; + s->lookahead -= s->match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ - if (match_len <= s->max_insert_length && s->lookahead >= MIN_MATCH) { - match_len--; /* string at strstart already in table */ + if (s->match_length <= s->max_insert_length && s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ s->strstart++; - - functable.insert_string(s, s->strstart, match_len); - s->strstart += match_len; +#ifdef NOT_TWEAK_COMPILER + do { + functable.insert_string(s, s->strstart, 1); + s->strstart++; + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); +#else + { + functable.insert_string(s, s->strstart, s->match_length); + s->strstart += s->match_length; + s->match_length = 0; + } +#endif } else { - s->strstart += match_len; -#if MIN_MATCH != 3 + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; +#ifndef NOT_TWEAK_COMPILER functable.insert_string(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2); #else - functable.quick_insert_string(s, s->strstart + 2 - MIN_MATCH); + functable.insert_string(s, s->strstart + 2 - MIN_MATCH, 1); +#if MIN_MATCH != 3 +#warning Call insert_string() MIN_MATCH-3 more times +#endif #endif /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */ } - match_len = 0; } else { /* No match, output a literal byte */ - bflush = zng_tr_tally_lit(s, s->window[s->strstart]); + Tracevv((stderr, "%c", s->window[s->strstart])); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } - if (UNLIKELY(bflush)) + if (bflush) FLUSH_BLOCK(s, 0); } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (UNLIKELY(flush == Z_FINISH)) { + if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } - if (UNLIKELY(s->sym_next)) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } diff --git a/libs/zlibng/deflate_medium.c b/libs/zlibng/deflate_medium.c index dad550cd1..330d255c8 100644 --- a/libs/zlibng/deflate_medium.c +++ b/libs/zlibng/deflate_medium.c @@ -7,50 +7,72 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ #ifndef NO_MEDIUM_STRATEGY -#include #include "zbuild.h" #include "deflate.h" #include "deflate_p.h" +#include "match_p.h" #include "functable.h" struct match { - uint16_t match_start; - uint16_t match_length; - uint16_t strstart; - uint16_t orgstart; + unsigned int match_start; + unsigned int match_length; + unsigned int strstart; + unsigned int orgstart; }; +#define MAX_DIST2 ((1 << MAX_WBITS) - MIN_LOOKAHEAD) + +static int tr_tally_dist(deflate_state *s, int distance, int length) { + return _tr_tally(s, distance, length); +} + +static int tr_tally_lit(deflate_state *s, int c) { + return _tr_tally(s, 0, c); +} + static int emit_match(deflate_state *s, struct match match) { - int bflush = 0; + int flush = 0; /* matches that are not long enough we need to emit as literals */ if (match.match_length < MIN_MATCH) { while (match.match_length) { - bflush += zng_tr_tally_lit(s, s->window[match.strstart]); + flush += tr_tally_lit(s, s->window[match.strstart]); s->lookahead--; match.strstart++; match.match_length--; } - return bflush; + return flush; } check_match(s, match.strstart, match.match_start, match.match_length); - bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); + flush += tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); s->lookahead -= match.match_length; - return bflush; + return flush; } static void insert_match(deflate_state *s, struct match match) { - if (UNLIKELY(s->lookahead <= (unsigned int)(match.match_length + MIN_MATCH))) + if (unlikely(s->lookahead <= match.match_length + MIN_MATCH)) return; /* matches that are not long enough we need to emit as literals */ - if (LIKELY(match.match_length < MIN_MATCH)) { + if (match.match_length < MIN_MATCH) { +#ifdef NOT_TWEAK_COMPILER + while (match.match_length) { + match.strstart++; + match.match_length--; + + if (match.match_length) { + if (match.strstart >= match.orgstart) { + functable.insert_string(s, match.strstart, 1); + } + } + } +#else match.strstart++; match.match_length--; - if (UNLIKELY(match.match_length > 0)) { + if (match.match_length > 0) { if (match.strstart >= match.orgstart) { if (match.strstart + match.match_length - 1 >= match.orgstart) { functable.insert_string(s, match.strstart, match.match_length); @@ -61,6 +83,7 @@ static void insert_match(deflate_state *s, struct match match) { match.match_length = 0; } } +#endif return; } @@ -70,35 +93,48 @@ static void insert_match(deflate_state *s, struct match match) { if (match.match_length <= 16* s->max_insert_length && s->lookahead >= MIN_MATCH) { match.match_length--; /* string at strstart already in table */ match.strstart++; - - if (LIKELY(match.strstart >= match.orgstart)) { - if (LIKELY(match.strstart + match.match_length - 1 >= match.orgstart)) { +#ifdef NOT_TWEAK_COMPILER + do { + if (likely(match.strstart >= match.orgstart)) { + functable.insert_string(s, match.strstart, 1); + } + match.strstart++; + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--match.match_length != 0); +#else + if (likely(match.strstart >= match.orgstart)) { + if (likely(match.strstart + match.match_length - 1 >= match.orgstart)) { functable.insert_string(s, match.strstart, match.match_length); } else { functable.insert_string(s, match.strstart, match.orgstart - match.strstart + 1); } - } else if (match.orgstart < match.strstart + match.match_length) { - functable.insert_string(s, match.orgstart, match.strstart + match.match_length - match.orgstart); } match.strstart += match.match_length; match.match_length = 0; +#endif } else { match.strstart += match.match_length; match.match_length = 0; + s->ins_h = s->window[match.strstart]; if (match.strstart >= (MIN_MATCH - 2)) -#if MIN_MATCH != 3 +#ifndef NOT_TWEAK_COMPILER functable.insert_string(s, match.strstart + 2 - MIN_MATCH, MIN_MATCH - 2); #else - functable.quick_insert_string(s, match.strstart + 2 - MIN_MATCH); + functable.insert_string(s, match.strstart + 2 - MIN_MATCH, 1); +#if MIN_MATCH != 3 +#warning Call insert_string() MIN_MATCH-3 more times #endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ } } static void fizzle_matches(deflate_state *s, struct match *current, struct match *next) { - Pos limit; + IPos limit; unsigned char *match, *orig; int changed = 0; struct match c, n; @@ -107,36 +143,36 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match if (current->match_length <= 1) return; - if (UNLIKELY(current->match_length > 1 + next->match_start)) + if (unlikely(current->match_length > 1 + next->match_start)) return; - if (UNLIKELY(current->match_length > 1 + next->strstart)) + if (unlikely(current->match_length > 1 + next->strstart)) return; match = s->window - current->match_length + 1 + next->match_start; orig = s->window - current->match_length + 1 + next->strstart; /* quick exit check.. if this fails then don't bother with anything else */ - if (LIKELY(*match != *orig)) + if (likely(*match != *orig)) return; c = *current; n = *next; /* step one: try to move the "next" match to the left as much as possible */ - limit = next->strstart > MAX_DIST(s) ? next->strstart - (Pos)MAX_DIST(s) : 0; + limit = next->strstart > MAX_DIST2 ? next->strstart - MAX_DIST2 : 0; match = s->window + n.match_start - 1; orig = s->window + n.strstart - 1; while (*match == *orig) { - if (UNLIKELY(c.match_length < 1)) + if (c.match_length < 1) break; - if (UNLIKELY(n.strstart <= limit)) + if (n.strstart <= limit) break; - if (UNLIKELY(n.match_length >= 256)) + if (n.match_length >= 256) break; - if (UNLIKELY(n.match_start <= 1)) + if (n.match_start <= 1) break; n.strstart--; @@ -160,18 +196,15 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match } } -Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { - /* Align the first struct to start on a new cacheline, this allows us to fit both structs in one cacheline */ - ALIGNED_(16) struct match current_match; - struct match next_match; +ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { + struct match current_match, next_match; memset(¤t_match, 0, sizeof(struct match)); memset(&next_match, 0, sizeof(struct match)); for (;;) { - Pos hash_head = 0; /* head of the hash chain */ - int bflush = 0; /* set if current block must be flushed */ - int64_t dist; + IPos hash_head = 0; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes @@ -179,14 +212,15 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { * string following the next current_match. */ if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); + functable.fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } - if (UNLIKELY(s->lookahead == 0)) + if (s->lookahead == 0) break; /* flush the current block */ next_match.match_length = 0; } + s->prev_length = 2; /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: @@ -196,63 +230,63 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { if (next_match.match_length > 0) { current_match = next_match; next_match.match_length = 0; + } else { hash_head = 0; if (s->lookahead >= MIN_MATCH) { - hash_head = functable.quick_insert_string(s, s->strstart); + hash_head = functable.insert_string(s, s->strstart, 1); } - current_match.strstart = (uint16_t)s->strstart; + /* set up the initial match to be a 1 byte literal */ + current_match.match_start = 0; + current_match.match_length = 1; + current_match.strstart = s->strstart; current_match.orgstart = current_match.strstart; /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ - dist = (int64_t)s->strstart - hash_head; - if (dist <= MAX_DIST(s) && dist > 0) { + if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST2) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - current_match.match_length = (uint16_t)functable.longest_match(s, hash_head); - current_match.match_start = (uint16_t)s->match_start; - if (UNLIKELY(current_match.match_length < MIN_MATCH)) + current_match.match_length = longest_match(s, hash_head); + current_match.match_start = s->match_start; + if (current_match.match_length < MIN_MATCH) current_match.match_length = 1; - if (UNLIKELY(current_match.match_start >= current_match.strstart)) { + if (current_match.match_start >= current_match.strstart) { /* this can happen due to some restarts */ current_match.match_length = 1; } - } else { - /* Set up the match to be a 1 byte literal */ - current_match.match_start = 0; - current_match.match_length = 1; } } insert_match(s, current_match); /* now, look ahead one */ - if (LIKELY(s->lookahead > MIN_LOOKAHEAD && (uint32_t)(current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD))) { + if (s->lookahead > MIN_LOOKAHEAD && (current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD)) { s->strstart = current_match.strstart + current_match.match_length; - hash_head = functable.quick_insert_string(s, s->strstart); + hash_head = functable.insert_string(s, s->strstart, 1); - next_match.strstart = (uint16_t)s->strstart; + /* set up the initial match to be a 1 byte literal */ + next_match.match_start = 0; + next_match.match_length = 1; + next_match.strstart = s->strstart; next_match.orgstart = next_match.strstart; /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ - - dist = (int64_t)s->strstart - hash_head; - if (dist <= MAX_DIST(s) && dist > 0) { + if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST2) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - next_match.match_length = (uint16_t)functable.longest_match(s, hash_head); - next_match.match_start = (uint16_t)s->match_start; - if (UNLIKELY(next_match.match_start >= next_match.strstart)) { + next_match.match_length = longest_match(s, hash_head); + next_match.match_start = s->match_start; + if (next_match.match_start >= next_match.strstart) { /* this can happen due to some restarts */ next_match.match_length = 1; } @@ -260,13 +294,13 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { next_match.match_length = 1; else fizzle_matches(s, ¤t_match, &next_match); - } else { - /* Set up the match to be a 1 byte literal */ - next_match.match_start = 0; - next_match.match_length = 1; } + /* short matches with a very long distance are rarely a good idea encoding wise */ + if (next_match.match_length == 3 && (next_match.strstart - next_match.match_start) > 12000) + next_match.match_length = 1; s->strstart = current_match.strstart; + } else { next_match.match_length = 0; } @@ -277,7 +311,7 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { /* move the "cursor" forward */ s->strstart += current_match.match_length; - if (UNLIKELY(bflush)) + if (bflush) FLUSH_BLOCK(s, 0); } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; @@ -285,7 +319,7 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { FLUSH_BLOCK(s, 1); return finish_done; } - if (UNLIKELY(s->sym_next)) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; diff --git a/libs/zlibng/deflate_p.h b/libs/zlibng/deflate_p.h index 102a4de06..69a7c82a0 100644 --- a/libs/zlibng/deflate_p.h +++ b/libs/zlibng/deflate_p.h @@ -12,45 +12,39 @@ /* Forward declare common non-inlined functions declared in deflate.c */ #ifdef ZLIB_DEBUG -void check_match(deflate_state *s, Pos start, Pos match, int length); +void check_match(deflate_state *s, IPos start, IPos match, int length); #else #define check_match(s, start, match, length) #endif void flush_pending(PREFIX3(stream) *strm); /* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). */ -extern const unsigned char Z_INTERNAL zng_length_code[]; -extern const unsigned char Z_INTERNAL zng_dist_code[]; +static inline Pos insert_string_c(deflate_state *const s, const Pos str, unsigned int count) { + Pos ret = 0; + unsigned int idx; -static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { - /* c is the unmatched char */ - s->sym_buf[s->sym_next++] = 0; - s->sym_buf[s->sym_next++] = 0; - s->sym_buf[s->sym_next++] = c; - s->dyn_ltree[c].Freq++; - Tracevv((stderr, "%c", c)); - Assert(c <= (MAX_MATCH-MIN_MATCH), "zng_tr_tally: bad literal"); - return (s->sym_next == s->sym_end); -} + for (idx = 0; idx < count; idx++) { + UPDATE_HASH(s, s->ins_h, str+idx); -static inline int zng_tr_tally_dist(deflate_state *s, uint32_t dist, uint32_t len) { - /* dist: distance of matched string */ - /* len: match length-MIN_MATCH */ - s->sym_buf[s->sym_next++] = (uint8_t)(dist); - s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); - s->sym_buf[s->sym_next++] = (uint8_t)len; - s->matches++; - dist--; - Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, - "zng_tr_tally: bad match"); - - s->dyn_ltree[zng_length_code[len]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - return (s->sym_next == s->sym_end); + Pos head = s->head[s->ins_h]; + if (head != str+idx) { + s->prev[(str+idx) & s->w_mask] = head; + s->head[s->ins_h] = str+idx; + if (idx == count - 1) + ret = head; + } else if (idx == count - 1) { + ret = str + idx; + } + } + return ret; } /* =========================================================================== @@ -58,13 +52,14 @@ static inline int zng_tr_tally_dist(deflate_state *s, uint32_t dist, uint32_t le * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK_ONLY(s, last) { \ - zng_tr_flush_block(s, (s->block_start >= 0 ? \ + _tr_flush_block(s, (s->block_start >= 0L ? \ (char *)&s->window[(unsigned)s->block_start] : \ NULL), \ - (uint32_t)((int)s->strstart - s->block_start), \ + (unsigned long)((long)s->strstart - s->block_start), \ (last)); \ - s->block_start = (int)s->strstart; \ + s->block_start = s->strstart; \ flush_pending(s->strm); \ + Tracev((stderr, "[FLUSH]")); \ } /* Same but force premature exit if necessary. */ diff --git a/libs/zlibng/deflate_quick.c b/libs/zlibng/deflate_quick.c deleted file mode 100644 index 268cce80d..000000000 --- a/libs/zlibng/deflate_quick.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The deflate_quick deflate strategy, designed to be used when cycles are - * at a premium. - * - * Copyright (C) 2013 Intel Corporation. All rights reserved. - * Authors: - * Wajdi Feghali - * Jim Guilford - * Vinodh Gopal - * Erdinc Ozturk - * Jim Kukunas - * - * Portions are Copyright (C) 2016 12Sided Technology, LLC. - * Author: - * Phil Vachon - * - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zbuild.h" -#include "deflate.h" -#include "deflate_p.h" -#include "functable.h" -#include "trees_emit.h" - -extern const ct_data static_ltree[L_CODES+2]; -extern const ct_data static_dtree[D_CODES]; - -#define QUICK_START_BLOCK(s, last) { \ - zng_tr_emit_tree(s, STATIC_TREES, last); \ - s->block_open = 1 + (int)last; \ - s->block_start = (int)s->strstart; \ -} - -#define QUICK_END_BLOCK(s, last) { \ - if (s->block_open) { \ - zng_tr_emit_end_block(s, static_ltree, last); \ - s->block_open = 0; \ - s->block_start = (int)s->strstart; \ - flush_pending(s->strm); \ - if (s->strm->avail_out == 0) \ - return (last) ? finish_started : need_more; \ - } \ -} - -Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { - Pos hash_head; - int64_t dist; - unsigned match_len, last; - - - last = (flush == Z_FINISH) ? 1 : 0; - if (UNLIKELY(last && s->block_open != 2)) { - /* Emit end of previous block */ - QUICK_END_BLOCK(s, 0); - /* Emit start of last block */ - QUICK_START_BLOCK(s, last); - } else if (UNLIKELY(s->block_open == 0 && s->lookahead > 0)) { - /* Start new block only when we have lookahead data, so that if no - input data is given an empty block will not be written */ - QUICK_START_BLOCK(s, last); - } - - for (;;) { - if (UNLIKELY(s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size)) { - flush_pending(s->strm); - if (s->strm->avail_out == 0) { - return (last && s->strm->avail_in == 0) ? finish_started : need_more; - } - } - - if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) { - fill_window(s); - if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) { - return need_more; - } - if (UNLIKELY(s->lookahead == 0)) - break; - - if (UNLIKELY(s->block_open == 0)) { - /* Start new block when we have lookahead data, so that if no - input data is given an empty block will not be written */ - QUICK_START_BLOCK(s, last); - } - } - - if (LIKELY(s->lookahead >= MIN_MATCH)) { - hash_head = functable.quick_insert_string(s, s->strstart); - dist = (int64_t)s->strstart - hash_head; - - if (dist <= MAX_DIST(s) && dist > 0) { - match_len = functable.compare258(s->window + s->strstart, s->window + hash_head); - - if (match_len >= MIN_MATCH) { - if (UNLIKELY(match_len > s->lookahead)) - match_len = s->lookahead; - - check_match(s, s->strstart, hash_head, match_len); - - zng_tr_emit_dist(s, static_ltree, static_dtree, match_len - MIN_MATCH, (uint32_t)dist); - s->lookahead -= match_len; - s->strstart += match_len; - continue; - } - } - } - - zng_tr_emit_lit(s, static_ltree, s->window[s->strstart]); - s->strstart++; - s->lookahead--; - } - - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (UNLIKELY(last)) { - QUICK_END_BLOCK(s, 1); - return finish_done; - } - - QUICK_END_BLOCK(s, 0); - return block_done; -} diff --git a/libs/zlibng/deflate_slow.c b/libs/zlibng/deflate_slow.c index cac8a9629..f4c8af769 100644 --- a/libs/zlibng/deflate_slow.c +++ b/libs/zlibng/deflate_slow.c @@ -7,18 +7,26 @@ #include "zbuild.h" #include "deflate.h" #include "deflate_p.h" +#include "match_p.h" #include "functable.h" +/* =========================================================================== + * Local data + */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + /* =========================================================================== * Same as deflate_medium, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { - Pos hash_head; /* head of hash chain */ +ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { + IPos hash_head; /* head of hash chain */ int bflush; /* set if current block must be flushed */ - int64_t dist; - uint32_t match_len; /* Process the input block. */ for (;;) { @@ -28,53 +36,57 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) { + functable.fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } - if (UNLIKELY(s->lookahead == 0)) + if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ - hash_head = 0; - if (LIKELY(s->lookahead >= MIN_MATCH)) { - hash_head = functable.quick_insert_string(s, s->strstart); + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + hash_head = functable.insert_string(s, s->strstart, 1); } /* Find the longest match, discarding those <= prev_length. */ - s->prev_match = (Pos)s->match_start; - match_len = MIN_MATCH-1; - dist = (int64_t)s->strstart - hash_head; + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; - if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match) { + if (hash_head != NIL && s->prev_length < s->max_lazy_match && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - match_len = functable.longest_match(s, hash_head); + s->match_length = longest_match(s, hash_head); /* longest_match() sets match_start */ - if (match_len <= 5 && (s->strategy == Z_FILTERED)) { + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && s->strstart - s->match_start > TOO_FAR) +#endif + )) { + /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ - match_len = MIN_MATCH-1; + s->match_length = MIN_MATCH-1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ - if (s->prev_length >= MIN_MATCH && match_len <= s->prev_length) { + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { unsigned int max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ check_match(s, s->strstart-1, s->prev_match, s->prev_length); - bflush = zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH); + _tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not @@ -83,55 +95,70 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { */ s->lookahead -= s->prev_length-1; - unsigned int mov_fwd = s->prev_length - 2; - if (max_insert > s->strstart) { - unsigned int insert_cnt = mov_fwd; - if (UNLIKELY(insert_cnt > max_insert - s->strstart)) - insert_cnt = max_insert - s->strstart; - - functable.insert_string(s, s->strstart + 1, insert_cnt); - } - s->prev_length = 0; +#ifdef NOT_TWEAK_COMPILER + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + functable.insert_string(s, s->strstart, 1); + } + } while (--s->prev_length != 0); s->match_available = 0; - s->strstart += mov_fwd + 1; + s->match_length = MIN_MATCH-1; + s->strstart++; +#else + { + unsigned int mov_fwd = s->prev_length - 2; + if (max_insert > s->strstart) { + unsigned int insert_cnt = mov_fwd; + if (unlikely(insert_cnt > max_insert - s->strstart)) + insert_cnt = max_insert - s->strstart; - if (UNLIKELY(bflush)) - FLUSH_BLOCK(s, 0); + functable.insert_string(s, s->strstart + 1, insert_cnt); + } + s->prev_length = 0; + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart += mov_fwd + 1; + } +#endif /*NOT_TWEAK_COMPILER*/ + + if (bflush) FLUSH_BLOCK(s, 0); } else if (s->match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ - bflush = zng_tr_tally_lit(s, s->window[s->strstart-1]); - if (UNLIKELY(bflush)) + Tracevv((stderr, "%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { FLUSH_BLOCK_ONLY(s, 0); - s->prev_length = match_len; + } s->strstart++; s->lookahead--; - if (UNLIKELY(s->strm->avail_out == 0)) + if (s->strm->avail_out == 0) return need_more; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ - s->prev_length = match_len; s->match_available = 1; s->strstart++; s->lookahead--; } } Assert(flush != Z_NO_FLUSH, "no flush?"); - if (UNLIKELY(s->match_available)) { - (void) zng_tr_tally_lit(s, s->window[s->strstart-1]); + if (s->match_available) { + Tracevv((stderr, "%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (UNLIKELY(flush == Z_FINISH)) { + if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } - if (UNLIKELY(s->sym_next)) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } diff --git a/libs/zlibng/fallback_builtins.h b/libs/zlibng/fallback_builtins.h deleted file mode 100644 index 314ad3267..000000000 --- a/libs/zlibng/fallback_builtins.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef X86_BUILTIN_CTZ_H -#define X86_BUILTIN_CTZ_H - -#if defined(_MSC_VER) && !defined(__clang__) -#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_ARM) || defined(_M_ARM64) - -#include -#ifdef X86_FEATURES -# include "arch/x86/x86.h" -#endif - -/* This is not a general purpose replacement for __builtin_ctz. The function expects that value is != 0 - * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked - */ -static __forceinline unsigned long __builtin_ctz(uint32_t value) { -#ifdef X86_FEATURES - if (x86_cpu_has_tzcnt) - return _tzcnt_u32(value); -#endif - unsigned long trailing_zero; - _BitScanForward(&trailing_zero, value); - return trailing_zero; -} -#define HAVE_BUILTIN_CTZ - -#ifdef _M_AMD64 -/* This is not a general purpose replacement for __builtin_ctzll. The function expects that value is != 0 - * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward64 is not checked - */ -static __forceinline unsigned long long __builtin_ctzll(uint64_t value) { -#ifdef X86_FEATURES - if (x86_cpu_has_tzcnt) - return _tzcnt_u64(value); -#endif - unsigned long trailing_zero; - _BitScanForward64(&trailing_zero, value); - return trailing_zero; -} -#define HAVE_BUILTIN_CTZLL -#endif - -#endif -#endif -#endif diff --git a/libs/zlibng/functable.c b/libs/zlibng/functable.c index acae44641..108509798 100644 --- a/libs/zlibng/functable.c +++ b/libs/zlibng/functable.c @@ -4,95 +4,40 @@ */ #include "zbuild.h" -#include "zendian.h" +#include "functable.h" #include "deflate.h" #include "deflate_p.h" -#include "functable.h" - -#ifdef X86_FEATURES -# include "fallback_builtins.h" -#endif +#include "gzendian.h" /* insert_string */ -extern void insert_string_c(deflate_state *const s, const uint32_t str, uint32_t count); -#ifdef X86_SSE42_CRC_HASH -extern void insert_string_sse4(deflate_state *const s, const uint32_t str, uint32_t count); +#ifdef X86_SSE4_2_CRC_HASH +extern Pos insert_string_sse(deflate_state *const s, const Pos str, unsigned int count); #elif defined(ARM_ACLE_CRC_HASH) -extern void insert_string_acle(deflate_state *const s, const uint32_t str, uint32_t count); +extern Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count); #endif -/* quick_insert_string */ -extern Pos quick_insert_string_c(deflate_state *const s, const uint32_t str); -#ifdef X86_SSE42_CRC_HASH -extern Pos quick_insert_string_sse4(deflate_state *const s, const uint32_t str); -#elif defined(ARM_ACLE_CRC_HASH) -extern Pos quick_insert_string_acle(deflate_state *const s, const uint32_t str); -#endif - -/* slide_hash */ +/* fill_window */ #ifdef X86_SSE2 -void slide_hash_sse2(deflate_state *s); -#elif defined(ARM_NEON_SLIDEHASH) -void slide_hash_neon(deflate_state *s); -#elif defined(POWER8_VSX_SLIDEHASH) -void slide_hash_power8(deflate_state *s); -#endif -#ifdef X86_AVX2 -void slide_hash_avx2(deflate_state *s); +extern void fill_window_sse(deflate_state *s); +#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) +extern void fill_window_arm(deflate_state *s); #endif /* adler32 */ extern uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t len); -#ifdef ARM_NEON_ADLER32 +#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32) extern uint32_t adler32_neon(uint32_t adler, const unsigned char *buf, size_t len); #endif -#ifdef X86_SSSE3_ADLER32 -extern uint32_t adler32_ssse3(uint32_t adler, const unsigned char *buf, size_t len); -#endif -#ifdef X86_AVX2_ADLER32 -extern uint32_t adler32_avx2(uint32_t adler, const unsigned char *buf, size_t len); -#endif -#ifdef POWER8_VSX_ADLER32 -extern uint32_t adler32_power8(uint32_t adler, const unsigned char* buf, size_t len); + +ZLIB_INTERNAL uint32_t crc32_generic(uint32_t, const unsigned char *, uint64_t); + +#ifdef DYNAMIC_CRC_TABLE +extern volatile int crc_table_empty; +extern void make_crc_table(void); #endif -/* memory chunking */ -extern uint32_t chunksize_c(void); -extern uint8_t* chunkcopy_c(uint8_t *out, uint8_t const *from, unsigned len); -extern uint8_t* chunkcopy_safe_c(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe); -extern uint8_t* chunkunroll_c(uint8_t *out, unsigned *dist, unsigned *len); -extern uint8_t* chunkmemset_c(uint8_t *out, unsigned dist, unsigned len); -extern uint8_t* chunkmemset_safe_c(uint8_t *out, unsigned dist, unsigned len, unsigned left); -#ifdef X86_SSE2_CHUNKSET -extern uint32_t chunksize_sse2(void); -extern uint8_t* chunkcopy_sse2(uint8_t *out, uint8_t const *from, unsigned len); -extern uint8_t* chunkcopy_safe_sse2(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe); -extern uint8_t* chunkunroll_sse2(uint8_t *out, unsigned *dist, unsigned *len); -extern uint8_t* chunkmemset_sse2(uint8_t *out, unsigned dist, unsigned len); -extern uint8_t* chunkmemset_safe_sse2(uint8_t *out, unsigned dist, unsigned len, unsigned left); -#endif -#ifdef X86_AVX_CHUNKSET -extern uint32_t chunksize_avx(void); -extern uint8_t* chunkcopy_avx(uint8_t *out, uint8_t const *from, unsigned len); -extern uint8_t* chunkcopy_safe_avx(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe); -extern uint8_t* chunkunroll_avx(uint8_t *out, unsigned *dist, unsigned *len); -extern uint8_t* chunkmemset_avx(uint8_t *out, unsigned dist, unsigned len); -extern uint8_t* chunkmemset_safe_avx(uint8_t *out, unsigned dist, unsigned len, unsigned left); -#endif -#ifdef ARM_NEON_CHUNKSET -extern uint32_t chunksize_neon(void); -extern uint8_t* chunkcopy_neon(uint8_t *out, uint8_t const *from, unsigned len); -extern uint8_t* chunkcopy_safe_neon(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe); -extern uint8_t* chunkunroll_neon(uint8_t *out, unsigned *dist, unsigned *len); -extern uint8_t* chunkmemset_neon(uint8_t *out, unsigned dist, unsigned len); -extern uint8_t* chunkmemset_safe_neon(uint8_t *out, unsigned dist, unsigned len, unsigned left); -#endif - -/* CRC32 */ -Z_INTERNAL uint32_t crc32_generic(uint32_t, const unsigned char *, uint64_t); - -#ifdef ARM_ACLE_CRC_HASH +#ifdef __ARM_FEATURE_CRC32 extern uint32_t crc32_acle(uint32_t, const unsigned char *, uint64_t); #endif @@ -102,365 +47,87 @@ extern uint32_t crc32_little(uint32_t, const unsigned char *, uint64_t); extern uint32_t crc32_big(uint32_t, const unsigned char *, uint64_t); #endif -/* compare258 */ -extern uint32_t compare258_c(const unsigned char *src0, const unsigned char *src1); -#ifdef UNALIGNED_OK -extern uint32_t compare258_unaligned_16(const unsigned char *src0, const unsigned char *src1); -extern uint32_t compare258_unaligned_32(const unsigned char *src0, const unsigned char *src1); -#ifdef UNALIGNED64_OK -extern uint32_t compare258_unaligned_64(const unsigned char *src0, const unsigned char *src1); -#endif -#ifdef X86_SSE42_CMP_STR -extern uint32_t compare258_unaligned_sse4(const unsigned char *src0, const unsigned char *src1); -#endif -#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) -extern uint32_t compare258_unaligned_avx2(const unsigned char *src0, const unsigned char *src1); -#endif -#endif +/* stub definitions */ +ZLIB_INTERNAL Pos insert_string_stub(deflate_state *const s, const Pos str, unsigned int count); +ZLIB_INTERNAL void fill_window_stub(deflate_state *s); +ZLIB_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, size_t len); +ZLIB_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t len); -/* longest_match */ -extern uint32_t longest_match_c(deflate_state *const s, Pos cur_match); -#ifdef UNALIGNED_OK -extern uint32_t longest_match_unaligned_16(deflate_state *const s, Pos cur_match); -extern uint32_t longest_match_unaligned_32(deflate_state *const s, Pos cur_match); -#ifdef UNALIGNED64_OK -extern uint32_t longest_match_unaligned_64(deflate_state *const s, Pos cur_match); -#endif -#ifdef X86_SSE42_CMP_STR -extern uint32_t longest_match_unaligned_sse4(deflate_state *const s, Pos cur_match); -#endif -#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) -extern uint32_t longest_match_unaligned_avx2(deflate_state *const s, Pos cur_match); -#endif -#endif +/* functable init */ +ZLIB_INTERNAL __thread struct functable_s functable = {fill_window_stub,insert_string_stub,adler32_stub,crc32_stub}; -Z_INTERNAL Z_TLS struct functable_s functable; - -Z_INTERNAL void cpu_check_features(void) -{ - static int features_checked = 0; - if (features_checked) - return; -#if defined(X86_FEATURES) - x86_check_features(); -#elif defined(ARM_FEATURES) - arm_check_features(); -#elif defined(POWER_FEATURES) - power_check_features(); -#endif - features_checked = 1; -} /* stub functions */ -Z_INTERNAL void insert_string_stub(deflate_state *const s, const uint32_t str, uint32_t count) { +ZLIB_INTERNAL Pos insert_string_stub(deflate_state *const s, const Pos str, unsigned int count) { // Initialize default + functable.insert_string=&insert_string_c; - functable.insert_string = &insert_string_c; - cpu_check_features(); - -#ifdef X86_SSE42_CRC_HASH + #ifdef X86_SSE4_2_CRC_HASH if (x86_cpu_has_sse42) - functable.insert_string = &insert_string_sse4; -#elif defined(ARM_ACLE_CRC_HASH) + functable.insert_string=&insert_string_sse; + #elif defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH) if (arm_cpu_has_crc32) - functable.insert_string = &insert_string_acle; -#endif + functable.insert_string=&insert_string_acle; + #endif - functable.insert_string(s, str, count); + return functable.insert_string(s, str, count); } -Z_INTERNAL Pos quick_insert_string_stub(deflate_state *const s, const uint32_t str) { - functable.quick_insert_string = &quick_insert_string_c; +ZLIB_INTERNAL void fill_window_stub(deflate_state *s) { + // Initialize default + functable.fill_window=&fill_window_c; -#ifdef X86_SSE42_CRC_HASH - if (x86_cpu_has_sse42) - functable.quick_insert_string = &quick_insert_string_sse4; -#elif defined(ARM_ACLE_CRC_HASH) - if (arm_cpu_has_crc32) - functable.quick_insert_string = &quick_insert_string_acle; -#endif - - return functable.quick_insert_string(s, str); -} - -Z_INTERNAL void slide_hash_stub(deflate_state *s) { - - functable.slide_hash = &slide_hash_c; - cpu_check_features(); - -#ifdef X86_SSE2 -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) + #ifdef X86_SSE2 + # if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) if (x86_cpu_has_sse2) -# endif - functable.slide_hash = &slide_hash_sse2; -#elif defined(ARM_NEON_SLIDEHASH) -# ifndef ARM_NOCHECK_NEON - if (arm_cpu_has_neon) -# endif - functable.slide_hash = &slide_hash_neon; -#endif -#ifdef X86_AVX2 - if (x86_cpu_has_avx2) - functable.slide_hash = &slide_hash_avx2; -#endif -#ifdef POWER8_VSX_SLIDEHASH - if (power_cpu_has_arch_2_07) - functable.slide_hash = &slide_hash_power8; -#endif + # endif + functable.fill_window=&fill_window_sse; + #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) + functable.fill_window=&fill_window_arm; + #endif - functable.slide_hash(s); + functable.fill_window(s); } -Z_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, size_t len) { +ZLIB_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, size_t len) { // Initialize default - functable.adler32 = &adler32_c; - cpu_check_features(); + functable.adler32=&adler32_c; -#ifdef ARM_NEON_ADLER32 -# ifndef ARM_NOCHECK_NEON + #if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32) if (arm_cpu_has_neon) -# endif - functable.adler32 = &adler32_neon; -#endif -#ifdef X86_SSSE3_ADLER32 - if (x86_cpu_has_ssse3) - functable.adler32 = &adler32_ssse3; -#endif -#ifdef X86_AVX2_ADLER32 - if (x86_cpu_has_avx2) - functable.adler32 = &adler32_avx2; -#endif -#ifdef POWER8_VSX_ADLER32 - if (power_cpu_has_arch_2_07) - functable.adler32 = &adler32_power8; -#endif + functable.adler32=&adler32_neon; + #endif return functable.adler32(adler, buf, len); } -Z_INTERNAL uint32_t chunksize_stub(void) { - // Initialize default - functable.chunksize = &chunksize_c; +ZLIB_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t len) { -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunksize = &chunksize_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunksize = &chunksize_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunksize = &chunksize_neon; -#endif - return functable.chunksize(); -} + Assert(sizeof(uint64_t) >= sizeof(size_t), + "crc32_z takes size_t but internally we have a uint64_t len"); +/* return a function pointer for optimized arches here after a capability test */ -Z_INTERNAL uint8_t* chunkcopy_stub(uint8_t *out, uint8_t const *from, unsigned len) { - // Initialize default - functable.chunkcopy = &chunkcopy_c; +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunkcopy = &chunkcopy_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunkcopy = &chunkcopy_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunkcopy = &chunkcopy_neon; -#endif - - return functable.chunkcopy(out, from, len); -} - -Z_INTERNAL uint8_t* chunkcopy_safe_stub(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe) { - // Initialize default - functable.chunkcopy_safe = &chunkcopy_safe_c; - -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunkcopy_safe = &chunkcopy_safe_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunkcopy_safe = &chunkcopy_safe_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunkcopy_safe = &chunkcopy_safe_neon; -#endif - - return functable.chunkcopy_safe(out, from, len, safe); -} - -Z_INTERNAL uint8_t* chunkunroll_stub(uint8_t *out, unsigned *dist, unsigned *len) { - // Initialize default - functable.chunkunroll = &chunkunroll_c; - -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunkunroll = &chunkunroll_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunkunroll = &chunkunroll_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunkunroll = &chunkunroll_neon; -#endif - - return functable.chunkunroll(out, dist, len); -} - -Z_INTERNAL uint8_t* chunkmemset_stub(uint8_t *out, unsigned dist, unsigned len) { - // Initialize default - functable.chunkmemset = &chunkmemset_c; - -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunkmemset = &chunkmemset_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunkmemset = &chunkmemset_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunkmemset = &chunkmemset_neon; -#endif - - return functable.chunkmemset(out, dist, len); -} - -Z_INTERNAL uint8_t* chunkmemset_safe_stub(uint8_t *out, unsigned dist, unsigned len, unsigned left) { - // Initialize default - functable.chunkmemset_safe = &chunkmemset_safe_c; - -#ifdef X86_SSE2_CHUNKSET -# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) - if (x86_cpu_has_sse2) -# endif - functable.chunkmemset_safe = &chunkmemset_safe_sse2; -#endif -#ifdef X86_AVX_CHUNKSET - if (x86_cpu_has_avx2) - functable.chunkmemset_safe = &chunkmemset_safe_avx; -#endif -#ifdef ARM_NEON_CHUNKSET - if (arm_cpu_has_neon) - functable.chunkmemset_safe = &chunkmemset_safe_neon; -#endif - - return functable.chunkmemset_safe(out, dist, len, left); -} - -Z_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t len) { - int32_t use_byfour = sizeof(void *) == sizeof(ptrdiff_t); - - Assert(sizeof(uint64_t) >= sizeof(size_t), - "crc32_z takes size_t but internally we have a uint64_t len"); - /* return a function pointer for optimized arches here after a capability test */ - - cpu_check_features(); - - if (use_byfour) { + if (sizeof(void *) == sizeof(ptrdiff_t)) { #if BYTE_ORDER == LITTLE_ENDIAN - functable.crc32 = crc32_little; -# if defined(ARM_ACLE_CRC_HASH) - if (arm_cpu_has_crc32) - functable.crc32 = crc32_acle; + functable.crc32=crc32_little; +# if defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH) + if (arm_cpu_has_crc32) + functable.crc32=crc32_acle; # endif #elif BYTE_ORDER == BIG_ENDIAN - functable.crc32 = crc32_big; + functable.crc32=crc32_big; #else # error No endian defined #endif } else { - functable.crc32 = crc32_generic; + functable.crc32=crc32_generic; } return functable.crc32(crc, buf, len); } - -Z_INTERNAL uint32_t compare258_stub(const unsigned char *src0, const unsigned char *src1) { - - functable.compare258 = &compare258_c; - -#ifdef UNALIGNED_OK -# if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) - functable.compare258 = &compare258_unaligned_64; -# elif defined(HAVE_BUILTIN_CTZ) - functable.compare258 = &compare258_unaligned_32; -# else - functable.compare258 = &compare258_unaligned_16; -# endif -# ifdef X86_SSE42_CMP_STR - if (x86_cpu_has_sse42) - functable.compare258 = &compare258_unaligned_sse4; -# endif -# if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) - if (x86_cpu_has_avx2) - functable.compare258 = &compare258_unaligned_avx2; -# endif -#endif - - return functable.compare258(src0, src1); -} - -Z_INTERNAL uint32_t longest_match_stub(deflate_state *const s, Pos cur_match) { - - functable.longest_match = &longest_match_c; - -#ifdef UNALIGNED_OK -# if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) - functable.longest_match = &longest_match_unaligned_64; -# elif defined(HAVE_BUILTIN_CTZ) - functable.longest_match = &longest_match_unaligned_32; -# else - functable.longest_match = &longest_match_unaligned_16; -# endif -# ifdef X86_SSE42_CMP_STR - if (x86_cpu_has_sse42) - functable.longest_match = &longest_match_unaligned_sse4; -# endif -# if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) - if (x86_cpu_has_avx2) - functable.longest_match = &longest_match_unaligned_avx2; -# endif -#endif - - return functable.longest_match(s, cur_match); -} - -/* functable init */ -Z_INTERNAL Z_TLS struct functable_s functable = { - insert_string_stub, - quick_insert_string_stub, - adler32_stub, - crc32_stub, - slide_hash_stub, - compare258_stub, - longest_match_stub, - chunksize_stub, - chunkcopy_stub, - chunkcopy_safe_stub, - chunkunroll_stub, - chunkmemset_stub, - chunkmemset_safe_stub -}; diff --git a/libs/zlibng/functable.h b/libs/zlibng/functable.h index 276c284a0..280651c32 100644 --- a/libs/zlibng/functable.h +++ b/libs/zlibng/functable.h @@ -9,21 +9,13 @@ #include "deflate.h" struct functable_s { - void (* insert_string) (deflate_state *const s, const uint32_t str, uint32_t count); - Pos (* quick_insert_string)(deflate_state *const s, const uint32_t str); - uint32_t (* adler32) (uint32_t adler, const unsigned char *buf, size_t len); - uint32_t (* crc32) (uint32_t crc, const unsigned char *buf, uint64_t len); - void (* slide_hash) (deflate_state *s); - uint32_t (* compare258) (const unsigned char *src0, const unsigned char *src1); - uint32_t (* longest_match) (deflate_state *const s, Pos cur_match); - uint32_t (* chunksize) (void); - uint8_t* (* chunkcopy) (uint8_t *out, uint8_t const *from, unsigned len); - uint8_t* (* chunkcopy_safe) (uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe); - uint8_t* (* chunkunroll) (uint8_t *out, unsigned *dist, unsigned *len); - uint8_t* (* chunkmemset) (uint8_t *out, unsigned dist, unsigned len); - uint8_t* (* chunkmemset_safe) (uint8_t *out, unsigned dist, unsigned len, unsigned left); + void (* fill_window) (deflate_state *s); + Pos (* insert_string) (deflate_state *const s, const Pos str, unsigned int count); + uint32_t (* adler32) (uint32_t adler, const unsigned char *buf, size_t len); + uint32_t (* crc32) (uint32_t crc, const unsigned char *buf, uint64_t len); }; -Z_INTERNAL extern Z_TLS struct functable_s functable; +ZLIB_INTERNAL extern __thread struct functable_s functable; + #endif diff --git a/libs/zlibng/gzclose.c b/libs/zlibng/gzclose.c new file mode 100644 index 000000000..bafb774c8 --- /dev/null +++ b/libs/zlibng/gzclose.c @@ -0,0 +1,24 @@ +/* gzclose.c -- zlib gzclose() function + * Copyright (C) 2004, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zbuild.h" +#include "gzguts.h" + +/* gzclose() is in a separate file so that it is linked in only if it is used. + That way the other gzclose functions can be used instead to avoid linking in + unneeded compression or decompression routines. */ +int ZEXPORT PREFIX(gzclose)(gzFile file) { +#ifndef NO_GZCOMPRESS + gz_state *state; + + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_state *)file; + + return state->mode == GZ_READ ? PREFIX(gzclose_r)(file) : PREFIX(gzclose_w)(file); +#else + return PREFIX(gzclose_r)(file); +#endif +} diff --git a/libs/zlibng/gzendian.h b/libs/zlibng/gzendian.h new file mode 100644 index 000000000..5ee4cd387 --- /dev/null +++ b/libs/zlibng/gzendian.h @@ -0,0 +1,60 @@ +/* gzendian.h -- define BYTE_ORDER for endian tests + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifndef ENDIAN_H_ +#define ENDIAN_H_ + +/* First check whether the compiler knows the target __BYTE_ORDER__. */ +#if defined(__BYTE_ORDER__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# if !defined(LITTLE_ENDIAN) +# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +# endif +# if !defined(BYTE_ORDER) +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# if !defined(BIG_ENDIAN) +# define BIG_ENDIAN __ORDER_BIG_ENDIAN__ +# endif +# if !defined(BYTE_ORDER) +# define BYTE_ORDER BIG_ENDIAN +# endif +# endif +#elif defined(__MINGW32__) +# include +#elif defined(WIN32) || defined(_WIN32) +# define LITTLE_ENDIAN 1234 +# define BIG_ENDIAN 4321 +# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) +# define BYTE_ORDER LITTLE_ENDIAN +# else +# error Unknown endianness! +# endif +#elif defined(__linux__) +# include +#elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__) +# include +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) +# include +#elif defined(__sun) || defined(sun) +# include +# if !defined(LITTLE_ENDIAN) +# define LITTLE_ENDIAN 4321 +# endif +# if !defined(BIG_ENDIAN) +# define BIG_ENDIAN 1234 +# endif +# if !defined(BYTE_ORDER) +# if defined(_BIG_ENDIAN) +# define BYTE_ORDER BIG_ENDIAN +# else +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# endif +#else +# include +#endif + +#endif diff --git a/libs/zlibng/gzguts.h b/libs/zlibng/gzguts.h index 16029607f..c2ff7bb96 100644 --- a/libs/zlibng/gzguts.h +++ b/libs/zlibng/gzguts.h @@ -14,12 +14,12 @@ # endif #endif -#if defined(HAVE_VISIBILITY_INTERNAL) -# define Z_INTERNAL __attribute__((visibility ("internal"))) -#elif defined(HAVE_VISIBILITY_HIDDEN) -# define Z_INTERNAL __attribute__((visibility ("hidden"))) +#if defined(HAVE_INTERNAL) +# define ZLIB_INTERNAL __attribute__((visibility ("internal"))) +#elif defined(HAVE_HIDDEN) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else -# define Z_INTERNAL +# define ZLIB_INTERNAL #endif #include @@ -29,12 +29,12 @@ #include #if defined(ZLIB_COMPAT) -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif -#ifdef _WIN32 +#ifdef WIN32 # include #endif @@ -42,8 +42,11 @@ # include /* for lseek(), read(), close(), write(), unlink() */ #endif -#if defined(_WIN32) +#if defined(_MSC_VER) || defined(WIN32) # include +#endif + +#if defined(_WIN32) || defined(__MINGW__) # define WIDECHAR #endif @@ -55,7 +58,7 @@ #endif /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -#if !defined(STDC99) && !defined(__CYGWIN__) && !defined(__MINGW__) && defined(_WIN32) +#if !defined(STDC99) && !defined(__CYGWIN__) && !defined(__MINGW__) && defined(WIN32) # if !defined(vsnprintf) # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) # define vsnprintf _vsnprintf @@ -78,6 +81,14 @@ # define zstrerror() "stdio error (consult errno)" #endif +/* provide prototypes for these when building zlib without LFS */ +#if (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) && defined(WITH_GZFILEOP) + ZEXTERN gzFile ZEXPORT PREFIX(gzopen64)(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT PREFIX(gztell64)(gzFile); + ZEXTERN z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile); +#endif + /* default memLevel */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 @@ -87,8 +98,10 @@ /* default i/o buffer size -- double this for output when reading (this and twice this must be able to fit in an unsigned type) */ -#ifndef GZBUFSIZE -# define GZBUFSIZE 8192 +#if defined(S390_DFLTCC_DEFLATE) || defined(S390_DFLTCC_INFLATE) +#define GZBUFSIZE 262144 /* DFLTCC works faster with larger buffers */ +#else +#define GZBUFSIZE 8192 #endif /* gzip modes, also provide a little integrity check on the passed structure */ @@ -126,7 +139,6 @@ typedef struct { /* just for writing */ int level; /* compression level */ int strategy; /* compression strategy */ - int reset; /* true if a reset is pending after a Z_FINISH */ /* seek request */ z_off64_t skip; /* amount to skip (already rewound if backwards) */ int seek; /* true if seek request pending */ @@ -139,7 +151,7 @@ typedef struct { typedef gz_state *gz_statep; /* shared functions */ -void Z_INTERNAL gz_error(gz_state *, int, const char *); +void ZLIB_INTERNAL gz_error(gz_state *, int, const char *); /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed @@ -147,7 +159,7 @@ void Z_INTERNAL gz_error(gz_state *, int, const char *); #ifdef INT_MAX # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) #else -unsigned Z_INTERNAL gz_intmax(void); +unsigned ZLIB_INTERNAL gz_intmax(void); # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) #endif diff --git a/libs/zlibng/gzlib.c b/libs/zlibng/gzlib.c index 490551667..dbf27aa43 100644 --- a/libs/zlibng/gzlib.c +++ b/libs/zlibng/gzlib.c @@ -4,10 +4,9 @@ */ #include "zbuild.h" -#include "zutil_p.h" #include "gzguts.h" -#if defined(_WIN32) +#if defined(WIN32) && !defined(__BORLANDC__) # define LSEEK _lseeki64 #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 @@ -29,8 +28,6 @@ static void gz_reset(gz_state *state) { state->past = 0; /* have not read past end yet */ state->how = LOOK; /* look for gzip header */ } - else /* for writing ... */ - state->reset = 0; /* no deflateReset pending */ state->seek = 0; /* no seek request pending */ gz_error(state, Z_OK, NULL); /* clear error */ state->x.pos = 0; /* no uncompressed data yet */ @@ -54,7 +51,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { return NULL; /* allocate gzFile structure to return */ - state = (gz_state *)zng_alloc(sizeof(gz_state)); + state = (gz_state *)malloc(sizeof(gz_state)); if (state == NULL) return NULL; state->size = 0; /* no buffers allocated yet */ @@ -83,7 +80,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { break; #endif case '+': /* can't read and write at the same time */ - zng_free(state); + free(state); return NULL; case 'b': /* ignore -- will request binary anyway */ break; @@ -121,14 +118,14 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { /* must provide an "r", "w", or "a" */ if (state->mode == GZ_NONE) { - zng_free(state); + free(state); return NULL; } /* can't force transparent read */ if (state->mode == GZ_READ) { if (state->direct) { - zng_free(state); + free(state); return NULL; } state->direct = 1; /* for empty file */ @@ -137,7 +134,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { /* save the path name for error messages */ #ifdef WIDECHAR if (fd == -2) { - len = wcstombs(NULL, (const wchar_t *)path, 0); + len = wcstombs(NULL, path, 0); if (len == (size_t)-1) len = 0; } else @@ -145,13 +142,13 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { len = strlen((const char *)path); state->path = (char *)malloc(len + 1); if (state->path == NULL) { - zng_free(state); + free(state); return NULL; } #ifdef WIDECHAR if (fd == -2) if (len) { - wcstombs(state->path, (const wchar_t *)path, len + 1); + wcstombs(state->path, path, len + 1); } else { *(state->path) = 0; } @@ -182,15 +179,15 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { /* open the file with the appropriate flags (or just use fd) */ state->fd = fd > -1 ? fd : ( -#if defined(_WIN32) - fd == -2 ? _wopen((const wchar_t *)path, oflag, 0666) : +#if defined(WIN32) || defined(__MINGW__) + fd == -2 ? _wopen(path, oflag, 0666) : #elif __CYGWIN__ fd == -2 ? open(state->path, oflag, 0666) : #endif open((const char *)path, oflag, 0666)); if (state->fd == -1) { free(state->path); - zng_free(state); + free(state); return NULL; } if (state->mode == GZ_APPEND) { @@ -212,18 +209,17 @@ static gzFile gz_open(const void *path, int fd, const char *mode) { } /* -- see zlib.h -- */ -gzFile Z_EXPORT PREFIX(gzopen)(const char *path, const char *mode) { +gzFile ZEXPORT PREFIX(gzopen)(const char *path, const char *mode) { return gz_open(path, -1, mode); } -#ifdef ZLIB_COMPAT -gzFile Z_EXPORT PREFIX4(gzopen)(const char *path, const char *mode) { - return gz_open(path, -1, mode); -} -#endif - /* -- see zlib.h -- */ -gzFile Z_EXPORT PREFIX(gzdopen)(int fd, const char *mode) { +gzFile ZEXPORT PREFIX(gzopen64)(const char *path, const char *mode) { + return gz_open(path, -1, mode); +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT PREFIX(gzdopen)(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; @@ -237,27 +233,13 @@ gzFile Z_EXPORT PREFIX(gzdopen)(int fd, const char *mode) { /* -- see zlib.h -- */ #ifdef WIDECHAR -gzFile Z_EXPORT PREFIX(gzopen_w)(const wchar_t *path, const char *mode) { +gzFile ZEXPORT PREFIX(gzopen_w)(const wchar_t *path, const char *mode) { return gz_open(path, -2, mode); } #endif -int Z_EXPORT PREFIX(gzclose)(gzFile file) { -#ifndef NO_GZCOMPRESS - gz_state *state; - - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_state *)file; - - return state->mode == GZ_READ ? PREFIX(gzclose_r)(file) : PREFIX(gzclose_w)(file); -#else - return PREFIX(gzclose_r)(file); -#endif -} - /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) { +int ZEXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) { gz_state *state; /* get internal structure and check integrity */ @@ -281,7 +263,7 @@ int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzrewind)(gzFile file) { +int ZEXPORT PREFIX(gzrewind)(gzFile file) { gz_state *state; /* get internal structure */ @@ -301,7 +283,7 @@ int Z_EXPORT PREFIX(gzrewind)(gzFile file) { } /* -- see zlib.h -- */ -z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) { +z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_state *state; @@ -372,17 +354,15 @@ z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) { } /* -- see zlib.h -- */ -#ifdef ZLIB_COMPAT -z_off_t Z_EXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) { +z_off_t ZEXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) { z_off64_t ret; - ret = PREFIX4(gzseek)(file, (z_off64_t)offset, whence); + ret = PREFIX(gzseek64)(file, (z_off64_t)offset, whence); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -#endif /* -- see zlib.h -- */ -z_off64_t Z_EXPORT PREFIX4(gztell)(gzFile file) { +z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) { gz_state *state; /* get internal structure and check integrity */ @@ -397,18 +377,15 @@ z_off64_t Z_EXPORT PREFIX4(gztell)(gzFile file) { } /* -- see zlib.h -- */ -#ifdef ZLIB_COMPAT -z_off_t Z_EXPORT PREFIX(gztell)(gzFile file) { - +z_off_t ZEXPORT PREFIX(gztell)(gzFile file) { z_off64_t ret; - ret = PREFIX4(gztell)(file); + ret = PREFIX(gztell64)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -#endif /* -- see zlib.h -- */ -z_off64_t Z_EXPORT PREFIX4(gzoffset)(gzFile file) { +z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) { z_off64_t offset; gz_state *state; @@ -429,17 +406,15 @@ z_off64_t Z_EXPORT PREFIX4(gzoffset)(gzFile file) { } /* -- see zlib.h -- */ -#ifdef ZLIB_COMPAT -z_off_t Z_EXPORT PREFIX(gzoffset)(gzFile file) { +z_off_t ZEXPORT PREFIX(gzoffset)(gzFile file) { z_off64_t ret; - ret = PREFIX4(gzoffset)(file); + ret = PREFIX(gzoffset64)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -#endif /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzeof)(gzFile file) { +int ZEXPORT PREFIX(gzeof)(gzFile file) { gz_state *state; /* get internal structure and check integrity */ @@ -454,7 +429,7 @@ int Z_EXPORT PREFIX(gzeof)(gzFile file) { } /* -- see zlib.h -- */ -const char * Z_EXPORT PREFIX(gzerror)(gzFile file, int *errnum) { +const char * ZEXPORT PREFIX(gzerror)(gzFile file, int *errnum) { gz_state *state; /* get internal structure and check integrity */ @@ -471,7 +446,7 @@ const char * Z_EXPORT PREFIX(gzerror)(gzFile file, int *errnum) { } /* -- see zlib.h -- */ -void Z_EXPORT PREFIX(gzclearerr)(gzFile file) { +void ZEXPORT PREFIX(gzclearerr)(gzFile file) { gz_state *state; /* get internal structure and check integrity */ @@ -495,7 +470,7 @@ void Z_EXPORT PREFIX(gzclearerr)(gzFile file) { memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */ -void Z_INTERNAL gz_error(gz_state *state, int err, const char *msg) { +void ZLIB_INTERNAL gz_error(gz_state *state, int err, const char *msg) { /* free previously allocated message and clear */ if (state->msg != NULL) { if (state->err != Z_MEM_ERROR) @@ -529,7 +504,7 @@ void Z_INTERNAL gz_error(gz_state *state, int err, const char *msg) { available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned Z_INTERNAL gz_intmax() { +unsigned ZLIB_INTERNAL gz_intmax() { unsigned p, q; p = 1; diff --git a/libs/zlibng/gzread.c b/libs/zlibng/gzread.c index c3b3a035f..e041a3817 100644 --- a/libs/zlibng/gzread.c +++ b/libs/zlibng/gzread.c @@ -4,7 +4,6 @@ */ #include "zbuild.h" -#include "zutil_p.h" #include "gzguts.h" /* Local functions */ @@ -84,11 +83,11 @@ static int gz_look(gz_state *state) { /* allocate read buffers and inflate memory */ if (state->size == 0) { /* allocate buffers */ - state->in = (unsigned char *)zng_alloc(state->want); - state->out = (unsigned char *)zng_alloc(state->want << 1); + state->in = (unsigned char *)malloc(state->want); + state->out = (unsigned char *)malloc(state->want << 1); if (state->in == NULL || state->out == NULL) { - zng_free(state->out); - zng_free(state->in); + free(state->out); + free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } @@ -101,8 +100,8 @@ static int gz_look(gz_state *state) { state->strm.avail_in = 0; state->strm.next_in = NULL; if (PREFIX(inflateInit2)(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ - zng_free(state->out); - zng_free(state->in); + free(state->out); + free(state->in); state->size = 0; gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; @@ -344,7 +343,7 @@ static size_t gz_read(gz_state *state, void *buf, size_t len) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, unsigned len) { +int ZEXPORT PREFIX(gzread)(gzFile file, void *buf, unsigned len) { gz_state *state; /* get internal structure */ @@ -376,7 +375,7 @@ int Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, unsigned len) { } /* -- see zlib.h -- */ -size_t Z_EXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile file) { +size_t ZEXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile file) { size_t len; gz_state *state; @@ -395,11 +394,11 @@ size_t Z_EXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile fi return 0; /* compute bytes to read -- error on overflow */ - if (size && SIZE_MAX / size < nitems) { + len = nitems * size; + if (size && len / size != nitems) { gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); return 0; } - len = nitems * size; /* read len or fewer bytes to buf, return the number of full items read */ return len ? gz_read(state, buf, len) / size : 0; @@ -408,7 +407,7 @@ size_t Z_EXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile fi /* -- see zlib.h -- */ #undef gzgetc #undef zng_gzgetc -int Z_EXPORT PREFIX(gzgetc)(gzFile file) { +int ZEXPORT PREFIX(gzgetc)(gzFile file) { unsigned char buf[1]; gz_state *state; @@ -432,12 +431,12 @@ int Z_EXPORT PREFIX(gzgetc)(gzFile file) { return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; } -int Z_EXPORT PREFIX(gzgetc_)(gzFile file) { +int ZEXPORT PREFIX(gzgetc_)(gzFile file) { return PREFIX(gzgetc)(file); } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzungetc)(int c, gzFile file) { +int ZEXPORT PREFIX(gzungetc)(int c, gzFile file) { gz_state *state; /* get internal structure */ @@ -493,7 +492,7 @@ int Z_EXPORT PREFIX(gzungetc)(int c, gzFile file) { } /* -- see zlib.h -- */ -char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) { +char * ZEXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) { unsigned left, n; char *str; unsigned char *eol; @@ -520,31 +519,29 @@ char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) { the contents, let the user worry about that) */ str = buf; left = (unsigned)len - 1; - if (left) { - do { - /* assure that something is in the output buffer */ - if (state->x.have == 0 && gz_fetch(state) == -1) - return NULL; /* error */ - if (state->x.have == 0) { /* end of file */ - state->past = 1; /* read past end */ - break; /* return what we have */ - } + if (left) do { + /* assure that something is in the output buffer */ + if (state->x.have == 0 && gz_fetch(state) == -1) + return NULL; /* error */ + if (state->x.have == 0) { /* end of file */ + state->past = 1; /* read past end */ + break; /* return what we have */ + } - /* look for end-of-line in current output buffer */ - n = state->x.have > left ? left : state->x.have; - eol = (unsigned char *)memchr(state->x.next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - state->x.next) + 1; + /* look for end-of-line in current output buffer */ + n = state->x.have > left ? left : state->x.have; + eol = (unsigned char *)memchr(state->x.next, '\n', n); + if (eol != NULL) + n = (unsigned)(eol - state->x.next) + 1; - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->x.next, n); - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); - } + /* copy through end-of-line, or remainder if not found */ + memcpy(buf, state->x.next, n); + state->x.have -= n; + state->x.next += n; + state->x.pos += n; + left -= n; + buf += n; + } while (left && eol == NULL); /* return terminated string, or if nothing, end of file */ if (buf == str) @@ -554,7 +551,7 @@ char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzdirect)(gzFile file) { +int ZEXPORT PREFIX(gzdirect)(gzFile file) { gz_state *state; /* get internal structure */ @@ -573,7 +570,7 @@ int Z_EXPORT PREFIX(gzdirect)(gzFile file) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzclose_r)(gzFile file) { +int ZEXPORT PREFIX(gzclose_r)(gzFile file) { int ret, err; gz_state *state; @@ -590,13 +587,13 @@ int Z_EXPORT PREFIX(gzclose_r)(gzFile file) { /* free memory and close file */ if (state->size) { PREFIX(inflateEnd)(&(state->strm)); - zng_free(state->out); - zng_free(state->in); + free(state->out); + free(state->in); } err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; gz_error(state, Z_OK, NULL); free(state->path); ret = close(state->fd); - zng_free(state); + free(state); return ret ? Z_ERRNO : err; } diff --git a/libs/zlibng/gzwrite.c b/libs/zlibng/gzwrite.c index c4e178f9a..20e1d5c63 100644 --- a/libs/zlibng/gzwrite.c +++ b/libs/zlibng/gzwrite.c @@ -4,7 +4,6 @@ */ #include "zbuild.h" -#include "zutil_p.h" #include #include "gzguts.h" @@ -22,19 +21,18 @@ static int gz_init(gz_state *state) { PREFIX3(stream) *strm = &(state->strm); /* allocate input buffer (double size for gzprintf) */ - state->in = (unsigned char *)zng_alloc(state->want << 1); + state->in = (unsigned char *)malloc(state->want << 1); if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } - memset(state->in, 0, state->want << 1); /* only need output buffer and deflate state if compressing */ if (!state->direct) { /* allocate output buffer */ - state->out = (unsigned char *)zng_alloc(state->want); + state->out = (unsigned char *)malloc(state->want); if (state->out == NULL) { - zng_free(state->in); + free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } @@ -45,8 +43,8 @@ static int gz_init(gz_state *state) { strm->opaque = NULL; ret = PREFIX(deflateInit2)(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); if (ret != Z_OK) { - zng_free(state->out); - zng_free(state->in); + free(state->out); + free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } @@ -92,15 +90,6 @@ static int gz_comp(gz_state *state, int flush) { return 0; } - /* check for a pending reset */ - if (state->reset) { - /* don't start a new gzip member unless there is data to write */ - if (strm->avail_in == 0) - return 0; - PREFIX(deflateReset)(strm); - state->reset = 0; - } - /* run deflate() on provided input until it produces no more output */ ret = Z_OK; do { @@ -132,7 +121,8 @@ static int gz_comp(gz_state *state, int flush) { /* if that completed a deflate stream, allow another to start */ if (flush == Z_FINISH) - state->reset = 1; + PREFIX(deflateReset)(strm); + /* all done, no errors */ return 0; } @@ -213,7 +203,7 @@ static size_t gz_write(gz_state *state, void const *buf, size_t len) { return 0; /* directly compress user buffer to file */ - state->strm.next_in = (z_const unsigned char *) buf; + state->strm.next_in = (const unsigned char *)buf; do { unsigned n = (unsigned)-1; if (n > len) @@ -231,7 +221,7 @@ static size_t gz_write(gz_state *state, void const *buf, size_t len) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) { +int ZEXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) { gz_state *state; /* get internal structure */ @@ -255,7 +245,7 @@ int Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) { } /* -- see zlib.h -- */ -size_t Z_EXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gzFile file) { +size_t ZEXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gzFile file) { size_t len; gz_state *state; @@ -284,7 +274,7 @@ size_t Z_EXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gz } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzputc)(gzFile file, int c) { +int ZEXPORT PREFIX(gzputc)(gzFile file, int c) { unsigned have; unsigned char buf[1]; gz_state *state; @@ -329,7 +319,7 @@ int Z_EXPORT PREFIX(gzputc)(gzFile file, int c) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) { +int ZEXPORT PREFIX(gzputs)(gzFile file, const char *s) { size_t len, put; gz_state *state; @@ -353,7 +343,7 @@ int Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) { } /* -- see zlib.h -- */ -int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) { +int ZEXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) { int len; unsigned left; char *next; @@ -409,7 +399,7 @@ int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) { return len; } -int Z_EXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) { +int ZEXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) { va_list va; int ret; @@ -420,7 +410,7 @@ int Z_EXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzflush)(gzFile file, int flush) { +int ZEXPORT PREFIX(gzflush)(gzFile file, int flush) { gz_state *state; /* get internal structure */ @@ -449,7 +439,7 @@ int Z_EXPORT PREFIX(gzflush)(gzFile file, int flush) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) { +int ZEXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) { gz_state *state; PREFIX3(stream) *strm; @@ -487,7 +477,7 @@ int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) { } /* -- see zlib.h -- */ -int Z_EXPORT PREFIX(gzclose_w)(gzFile file) { +int ZEXPORT PREFIX(gzclose_w)(gzFile file) { int ret = Z_OK; gz_state *state; @@ -513,14 +503,14 @@ int Z_EXPORT PREFIX(gzclose_w)(gzFile file) { if (state->size) { if (!state->direct) { (void)PREFIX(deflateEnd)(&(state->strm)); - zng_free(state->out); + free(state->out); } - zng_free(state->in); + free(state->in); } gz_error(state, Z_OK, NULL); free(state->path); if (close(state->fd) == -1) ret = Z_ERRNO; - zng_free(state); + free(state); return ret; } diff --git a/libs/zlibng/infback.c b/libs/zlibng/infback.c index eecf03ada..b4fb562b1 100644 --- a/libs/zlibng/infback.c +++ b/libs/zlibng/infback.c @@ -15,8 +15,9 @@ #include "inftrees.h" #include "inflate.h" #include "inffast.h" -#include "inflate_p.h" -#include "functable.h" + +/* function prototypes */ +static void fixedtables(struct inflate_state *state); /* strm provides memory allocation functions in zalloc and zfree, or @@ -25,8 +26,8 @@ windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowBits, uint8_t *window, - const char *version, int32_t stream_size) { +int ZEXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int windowBits, unsigned char *window, + const char *version, int stream_size) { struct inflate_state *state; if (version == NULL || version[0] != PREFIX2(VERSION)[0] || stream_size != (int)(sizeof(PREFIX3(stream)))) @@ -35,12 +36,12 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB return Z_STREAM_ERROR; strm->msg = NULL; /* in case we return an error */ if (strm->zalloc == NULL) { - strm->zalloc = zng_calloc; + strm->zalloc = zcalloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zng_cfree; - state = (struct inflate_state *) ZALLOC(strm, 1, sizeof(struct inflate_state)); + strm->zfree = zcfree; + state = (struct inflate_state *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); @@ -51,14 +52,90 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB state->window = window; state->wnext = 0; state->whave = 0; - state->chunksize = functable.chunksize(); return Z_OK; } /* - Private macros for inflateBack() - Look in inflate_p.h for macros shared with inflate() -*/ + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +static void fixedtables(struct inflate_state *state) { +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +/* Macros for inflateBack(): */ + +/* Load returned state from inflate_fast() */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Set state from registers for inflate_fast() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) /* Assure that some input is available. If input is requested, but denied, then return a Z_BUF_ERROR from inflateBack(). */ @@ -80,10 +157,37 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB do { \ PULL(); \ have--; \ - hold += ((unsigned)(*next++) << bits); \ + hold += (*next++ << bits); \ bits += 8; \ } while (0) +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + (hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + /* Assure that some output space is available, by writing out the window if it's full. If the write fails, return from inflateBack() with a Z_BUF_ERROR. */ @@ -121,25 +225,25 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() + was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is NULL or the state was not initialized. */ -int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc, out_func out, void *out_desc) { +int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc, out_func out, void *out_desc) { struct inflate_state *state; - z_const unsigned char *next; /* next input */ - unsigned char *put; /* next output */ - unsigned have, left; /* available input and output */ - uint32_t hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int32_t ret; /* return code */ + const unsigned char *next; /* next input */ + unsigned char *put; /* next output */ + unsigned have, left; /* available input and output */ + uint32_t hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ static const uint16_t order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; @@ -212,8 +316,10 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in copy = state->length; PULL(); ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; + if (copy > have) + copy = have; + if (copy > left) + copy = left; memcpy(put, next, copy); have -= copy; next += copy; @@ -242,9 +348,9 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in } #endif Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; /* get code length code lengths (not a typo) */ + state->have = 0; while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (uint16_t)BITS(3); @@ -253,22 +359,23 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; - state->lencode = (const code *)(state->next); + state->lencode = (code const *)(state->next); state->lenbits = 7; - ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); + ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; /* get length and distance code code lengths */ + state->have = 0; while (state->have < state->nlen + state->ndist) { for (;;) { here = state->lencode[BITS(state->lenbits)]; - if (here.bits <= bits) break; + if (here.bits <= bits) + break; PULLBYTE(); } if (here.val < 16) { @@ -283,7 +390,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in state->mode = BAD; break; } - len = state->lens[state->have - 1]; + len = (unsigned)(state->lens[state->have - 1]); copy = 3 + BITS(2); DROPBITS(2); } else if (here.val == 17) { @@ -304,10 +411,8 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in state->mode = BAD; break; } - while (copy) { - --copy; + while (copy--) state->lens[state->have++] = (uint16_t)len; - } } } @@ -326,17 +431,17 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in values here (9 and 6) without reading the comments in inftrees.h concerning the ENOUGH constants, which depend on those values */ state->next = state->codes; - state->lencode = (const code *)(state->next); + state->lencode = (code const *)(state->next); state->lenbits = 9; - ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } - state->distcode = (const code *)(state->next); + state->distcode = (code const *)(state->next); state->distbits = 6; - ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist, + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; @@ -353,7 +458,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in RESTORE(); if (state->whave < state->wsize) state->whave = state->wsize - left; - zng_inflate_fast(strm, state->wsize); + inflate_fast(strm, state->wsize); LOAD(); break; } @@ -368,7 +473,8 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in if (here.op && (here.op & 0xf0) == 0) { last = here; for (;;) { - here = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)last.bits + (unsigned)here.bits <= bits) break; PULLBYTE(); @@ -379,7 +485,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in state->length = here.val; /* process literal */ - if ((int)(here.op) == 0) { + if (here.op == 0) { Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", here.val)); @@ -406,7 +512,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in /* length code -- get extra bits, if any */ state->extra = (here.op & 15); - if (state->extra) { + if (state->extra != 0) { NEEDBITS(state->extra); state->length += BITS(state->extra); DROPBITS(state->extra); @@ -437,21 +543,19 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in break; } state->offset = here.val; - state->extra = (here.op & 15); /* get distance extra bits, if any */ - if (state->extra) { + state->extra = (here.op & 15); + if (state->extra != 0) { NEEDBITS(state->extra); state->offset += BITS(state->extra); DROPBITS(state->extra); } -#ifdef INFLATE_STRICT if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } -#endif Tracevv((stderr, "inflate: distance %u\n", state->offset)); /* copy match from window to output */ @@ -500,7 +604,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in return ret; } -int32_t Z_EXPORT PREFIX(inflateBackEnd)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateBackEnd)(PREFIX3(stream) *strm) { if (strm == NULL || strm->state == NULL || strm->zfree == NULL) return Z_STREAM_ERROR; ZFREE(strm, strm->state); diff --git a/libs/zlibng/inffast.c b/libs/zlibng/inffast.c index 18ce570e9..bd9b2a1c4 100644 --- a/libs/zlibng/inffast.c +++ b/libs/zlibng/inffast.c @@ -8,21 +8,19 @@ #include "inftrees.h" #include "inflate.h" #include "inffast.h" -#include "inflate_p.h" -#include "functable.h" +#include "memcopy.h" +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + (hold & ((UINT64_C(1) << (n)) - 1)) -/* Load 64 bits from IN and place the bytes at offset BITS in the result. */ -static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) { - uint64_t chunk; - memcpy(&chunk, in, sizeof(chunk)); +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) -#if BYTE_ORDER == LITTLE_ENDIAN - return chunk << bits; -#else - return ZSWAP64(chunk) << bits; -#endif -} /* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is @@ -62,15 +60,17 @@ static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) { requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { +void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { /* start: inflate()'s starting value for strm->avail_out */ struct inflate_state *state; - z_const unsigned char *in; /* local strm->next_in */ + const unsigned char *in; /* local strm->next_in */ const unsigned char *last; /* have enough input while in < last */ unsigned char *out; /* local strm->next_out */ unsigned char *beg; /* inflate()'s initial strm->next_out */ unsigned char *end; /* while out < end, enough space available */ +#ifdef INFFAST_CHUNKSIZE unsigned char *safe; /* can use chunkcopy provided out < safe */ +#endif #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif @@ -136,7 +136,10 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { out = strm->next_out; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - (INFLATE_FAST_MIN_LEFT - 1)); + +#ifdef INFFAST_CHUNKSIZE safe = out + strm->avail_out; +#endif #ifdef INFLATE_STRICT dmax = state->dmax; #endif @@ -171,13 +174,15 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { } else if (op & 16) { /* length base */ len = here->val; op &= 15; /* number of extra bits */ - if (bits < op) { - hold |= load_64_bits(in, bits); - in += 6; - bits += 48; + if (op) { + if (bits < op) { + hold |= load_64_bits(in, bits); + in += 6; + bits += 48; + } + len += BITS(op); + DROPBITS(op); } - len += BITS(op); - DROPBITS(op); Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { hold |= load_64_bits(in, bits); @@ -199,7 +204,8 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { dist += BITS(op); #ifdef INFLATE_STRICT if (dist > dmax) { - SET_BAD("invalid distance too far back"); + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; break; } #endif @@ -210,7 +216,8 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { op = dist - op; /* distance back in window */ if (op > whave) { if (state->sane) { - SET_BAD("invalid distance too far back"); + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; break; } #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR @@ -233,6 +240,7 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { } #endif } +#ifdef INFFAST_CHUNKSIZE from = window; if (wnext == 0) { /* very common case */ from += wsize - op; @@ -243,7 +251,7 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { from += wsize - op; if (op < len) { /* some from end of window */ len -= op; - out = functable.chunkcopy_safe(out, from, op, safe); + out = chunkcopysafe(out, from, op, safe); from = window; /* more from start of window */ op = wnext; /* This (rare) case can create a situation where @@ -253,28 +261,81 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { } if (op < len) { /* still need some from output */ len -= op; - out = functable.chunkcopy_safe(out, from, op, safe); - out = functable.chunkunroll(out, &dist, &len); - out = functable.chunkcopy_safe(out, out - dist, len, safe); + out = chunkcopysafe(out, from, op, safe); + out = chunkunroll(out, &dist, &len); + out = chunkcopysafe(out, out - dist, len, safe); } else { - out = functable.chunkcopy_safe(out, from, len, safe); + out = chunkcopysafe(out, from, len, safe); } +#else + from = window; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = window; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + } else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + + out = chunk_copy(out, from, (int) (out - from), len); +#endif } else { - /* Whole reference is in range of current output. No range checks are - necessary because we start with room for at least 258 bytes of output, - so unroll and roundoff operations can write beyond `out+len` so long - as they stay within 258 bytes of `out`. +#ifdef INFFAST_CHUNKSIZE + /* Whole reference is in range of current output. No + range checks are necessary because we start with room + for at least 258 bytes of output, so unroll and roundoff + operations can write beyond `out+len` so long as they + stay within 258 bytes of `out`. */ - if (dist >= len || dist >= state->chunksize) - out = functable.chunkcopy(out, out - dist, len); + if (dist >= len || dist >= INFFAST_CHUNKSIZE) + out = chunkcopy(out, out - dist, len); else - out = functable.chunkmemset(out, dist, len); + out = chunkmemset(out, dist, len); +#else + if (len < sizeof(uint64_t)) + out = set_bytes(out, out - dist, dist, len); + else if (dist == 1) + out = byte_memset(out, len); + else + out = chunk_memset(out, out - dist, dist, len); +#endif } } else if ((op & 64) == 0) { /* 2nd level distance code */ here = dcode + here->val + BITS(op); goto dodist; } else { - SET_BAD("invalid distance code"); + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; break; } } else if ((op & 64) == 0) { /* 2nd level length code */ @@ -285,7 +346,8 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { state->mode = TYPE; break; } else { - SET_BAD("invalid literal/length code"); + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; break; } } while (in < last && out < end); @@ -299,10 +361,12 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) { /* update state and return */ strm->next_in = in; strm->next_out = out; - strm->avail_in = (unsigned)(in < last ? (INFLATE_FAST_MIN_HAVE - 1) + (last - in) - : (INFLATE_FAST_MIN_HAVE - 1) - (in - last)); - strm->avail_out = (unsigned)(out < end ? (INFLATE_FAST_MIN_LEFT - 1) + (end - out) - : (INFLATE_FAST_MIN_LEFT - 1) - (out - end)); + strm->avail_in = + (unsigned)(in < last ? (INFLATE_FAST_MIN_HAVE - 1) + (last - in) + : (INFLATE_FAST_MIN_HAVE - 1) - (in - last)); + strm->avail_out = + (unsigned)(out < end ? (INFLATE_FAST_MIN_LEFT - 1) + (end - out) + : (INFLATE_FAST_MIN_LEFT - 1) - (out - end)); Assert(bits <= 32, "Remaining bits greater than 32"); state->hold = (uint32_t)hold; diff --git a/libs/zlibng/inffast.h b/libs/zlibng/inffast.h index 179a65da6..9ad21abc8 100644 --- a/libs/zlibng/inffast.h +++ b/libs/zlibng/inffast.h @@ -10,7 +10,7 @@ subject to change. Applications should only use zlib.h. */ -void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start); +void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start); #define INFLATE_FAST_MIN_HAVE 8 #define INFLATE_FAST_MIN_LEFT 258 diff --git a/libs/zlibng/inffixed.h b/libs/zlibng/inffixed.h new file mode 100644 index 000000000..d62832776 --- /dev/null +++ b/libs/zlibng/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/libs/zlibng/inffixed_tbl.h b/libs/zlibng/inffixed_tbl.h deleted file mode 100644 index 7292fa06e..000000000 --- a/libs/zlibng/inffixed_tbl.h +++ /dev/null @@ -1,94 +0,0 @@ -/* inffixed_tbl.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - -/* WARNING: this file should *not* be used by applications. - * It is part of the implementation of this library and is - * subject to change. Applications should only use zlib.h. - */ - -static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} -}; - -static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} -}; diff --git a/libs/zlibng/inflate.c b/libs/zlibng/inflate.c index 5c30816dd..8a8d328f9 100644 --- a/libs/zlibng/inflate.c +++ b/libs/zlibng/inflate.c @@ -3,13 +3,89 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common wnext == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + #include "zbuild.h" #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" -#include "inflate_p.h" -#include "inffixed_tbl.h" +#include "memcopy.h" #include "functable.h" /* Architecture-specific hooks. */ @@ -35,13 +111,21 @@ # define INFLATE_NEED_UPDATEWINDOW(strm) 1 /* Invoked at the beginning of inflateMark(). Useful for updating arch-specific pointers and offsets. */ # define INFLATE_MARK_HOOK(strm) do {} while (0) -/* Invoked at the beginning of inflateSyncPoint(). Useful for performing arch-specific state checks. */ -#define INFLATE_SYNC_POINT_HOOK(strm) do {} while (0) +#endif + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif #endif /* function prototypes */ static int inflateStateCheck(PREFIX3(stream) *strm); +static void fixedtables(struct inflate_state *state); static int updatewindow(PREFIX3(stream) *strm, const unsigned char *end, uint32_t copy); +#ifdef BUILDFIXED + void makefixed(void); +#endif static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len); static int inflateStateCheck(PREFIX3(stream) *strm) { @@ -54,7 +138,7 @@ static int inflateStateCheck(PREFIX3(stream) *strm) { return 0; } -int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -65,10 +149,9 @@ int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { if (state->wrap) /* to support ill-conceived Java test suite */ strm->adler = state->wrap & 1; state->mode = HEAD; - state->check = ADLER32_INITIAL_VALUE; + state->check = functable.adler32(0L, NULL, 0); state->last = 0; state->havedict = 0; - state->flags = -1; state->dmax = 32768U; state->head = NULL; state->hold = 0; @@ -81,7 +164,7 @@ int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { return Z_OK; } -int32_t Z_EXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -93,7 +176,7 @@ int32_t Z_EXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) { return PREFIX(inflateResetKeep)(strm); } -int32_t Z_EXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int32_t windowBits) { +int ZEXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int windowBits) { int wrap; struct inflate_state *state; @@ -128,13 +211,13 @@ int32_t Z_EXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int32_t windowBits return PREFIX(inflateReset)(strm); } -int32_t Z_EXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int32_t windowBits, const char *version, int32_t stream_size) { - int32_t ret; +int ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int windowBits, const char *version, int stream_size) { + int ret; struct inflate_state *state; -#if defined(X86_FEATURES) +#ifdef X86_CPUID x86_check_features(); -#elif defined(ARM_FEATURES) +#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) arm_check_features(); #endif @@ -144,11 +227,11 @@ int32_t Z_EXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int32_t windowBits return Z_STREAM_ERROR; strm->msg = NULL; /* in case we return an error */ if (strm->zalloc == NULL) { - strm->zalloc = zng_calloc; + strm->zalloc = zcalloc; strm->opaque = NULL; } if (strm->zfree == NULL) - strm->zfree = zng_cfree; + strm->zfree = zcfree; state = (struct inflate_state *) ZALLOC_STATE(strm, 1, sizeof(struct inflate_state)); if (state == NULL) return Z_MEM_ERROR; @@ -157,7 +240,6 @@ int32_t Z_EXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int32_t windowBits state->strm = strm; state->window = NULL; state->mode = HEAD; /* to pass state test in inflateReset2() */ - state->chunksize = functable.chunksize(); ret = PREFIX(inflateReset2)(strm, windowBits); if (ret != Z_OK) { ZFREE_STATE(strm, state); @@ -166,11 +248,11 @@ int32_t Z_EXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int32_t windowBits return ret; } -int32_t Z_EXPORT PREFIX(inflateInit_)(PREFIX3(stream) *strm, const char *version, int32_t stream_size) { +int ZEXPORT PREFIX(inflateInit_)(PREFIX3(stream) *strm, const char *version, int stream_size) { return PREFIX(inflateInit2_)(strm, DEF_WBITS, version, stream_size); } -int32_t Z_EXPORT PREFIX(inflatePrime)(PREFIX3(stream) *strm, int32_t bits, int32_t value) { +int ZEXPORT PREFIX(inflatePrime)(PREFIX3(stream) *strm, int bits, int value) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -192,24 +274,133 @@ int32_t Z_EXPORT PREFIX(inflatePrime)(PREFIX3(stream) *strm, int32_t bits, int32 /* Return state with length and distance decoding tables and index sizes set to - fixed code decoding. This returns fixed tables from inffixed_tbl.h. + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. */ +static void fixedtables(struct inflate_state *state) { +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; -void Z_INTERNAL fixedtables(struct inflate_state *state) { + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } -int Z_INTERNAL inflate_ensure_window(struct inflate_state *state) { +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed(void) { + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) + printf("\n "); + printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, + state.lencode[low].bits, state.lencode[low].val); + if (++low == size) + break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) + printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); + if (++low == size) + break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state) +{ /* if it hasn't been done already, allocate space for the window */ if (state->window == NULL) { +#ifdef INFFAST_CHUNKSIZE unsigned wsize = 1U << state->wbits; - state->window = (unsigned char *) ZALLOC_WINDOW(state->strm, wsize + state->chunksize, sizeof(unsigned char)); + state->window = (unsigned char *) ZALLOC_WINDOW(state->strm, wsize + INFFAST_CHUNKSIZE, sizeof(unsigned char)); if (state->window == Z_NULL) return 1; - memset(state->window + wsize, 0, state->chunksize); + memset(state->window + wsize, 0, INFFAST_CHUNKSIZE); +#else + state->window = (unsigned char *) ZALLOC_WINDOW(state->strm, 1U << state->wbits, sizeof(unsigned char)); + if (state->window == NULL) + return 1; +#endif } /* if window not in use yet, initialize */ @@ -236,7 +427,7 @@ int Z_INTERNAL inflate_ensure_window(struct inflate_state *state) { output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t copy) { +static int updatewindow(PREFIX3(stream) *strm, const unsigned char *end, uint32_t copy) { struct inflate_state *state; uint32_t dist; @@ -270,13 +461,66 @@ static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t return 0; } +/* Macros for inflate(): */ -/* - Private macros for inflate() - Look in inflate_p.h for macros shared with inflateBack() -*/ +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? PREFIX(crc32)(check, buf, len) : functable.adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) functable.adler32(check, buf, len) +#endif -/* Get a byte of input into the bit accumulator, or return from inflate() if there is no input available. */ +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = PREFIX(crc32)(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = PREFIX(crc32)(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ #define PULLBYTE() \ do { \ if (have == 0) goto inf_leave; \ @@ -285,6 +529,32 @@ static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t bits += 8; \ } while (0) +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + (hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + /* inflate() uses a state machine to process as much input data and generate as much output data as possible before returning. The state machine is @@ -367,7 +637,7 @@ static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { +int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { struct inflate_state *state; const unsigned char *next; /* next input */ unsigned char *put; /* next output */ @@ -380,7 +650,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { code here; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ - int32_t ret; /* return code */ + int ret; /* return code */ #ifdef GUNZIP unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ #endif @@ -416,6 +686,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->mode = FLAGS; break; } + state->flags = 0; /* expect zlib header */ if (state->head != NULL) state->head->done = -1; if (!(state->wrap & 1) || /* check if zlib header allowed */ @@ -423,11 +694,13 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { if ( #endif ((BITS(8) << 8) + (hold >> 8)) % 31) { - SET_BAD("incorrect header check"); + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; break; } if (BITS(4) != Z_DEFLATED) { - SET_BAD("unknown compression method"); + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; break; } DROPBITS(4); @@ -435,27 +708,28 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { if (state->wbits == 0) state->wbits = len; if (len > 15 || len > state->wbits) { - SET_BAD("invalid window size"); + strm->msg = (char *)"invalid window size"; + state->mode = BAD; break; } state->dmax = 1U << len; - state->flags = 0; /* indicate zlib header */ Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = ADLER32_INITIAL_VALUE; + strm->adler = state->check = functable.adler32(0L, NULL, 0); state->mode = hold & 0x200 ? DICTID : TYPE; INITBITS(); break; #ifdef GUNZIP - case FLAGS: NEEDBITS(16); state->flags = (int)(hold); if ((state->flags & 0xff) != Z_DEFLATED) { - SET_BAD("unknown compression method"); + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; break; } if (state->flags & 0xe000) { - SET_BAD("unknown header flags set"); + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; break; } if (state->head != NULL) @@ -464,7 +738,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { CRC2(state->check, hold); INITBITS(); state->mode = TIME; - case TIME: NEEDBITS(32); if (state->head != NULL) @@ -473,7 +746,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { CRC4(state->check, hold); INITBITS(); state->mode = OS; - case OS: NEEDBITS(16); if (state->head != NULL) { @@ -484,7 +756,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; - case EXLEN: if (state->flags & 0x0400) { NEEDBITS(16); @@ -498,14 +769,14 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->head->extra = NULL; } state->mode = EXTRA; - case EXTRA: if (state->flags & 0x0400) { copy = state->length; if (copy > have) copy = have; if (copy) { - if (state->head != NULL && state->head->extra != NULL) { + if (state->head != NULL && + state->head->extra != NULL) { len = state->head->extra_len - state->length; memcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? @@ -522,7 +793,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } state->length = 0; state->mode = NAME; - case NAME: if (state->flags & 0x0800) { if (have == 0) goto inf_leave; @@ -543,7 +813,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } state->length = 0; state->mode = COMMENT; - case COMMENT: if (state->flags & 0x1000) { if (have == 0) goto inf_leave; @@ -564,12 +833,12 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->head->comment = NULL; } state->mode = HCRC; - case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); if ((state->wrap & 4) && hold != (state->check & 0xffff)) { - SET_BAD("header crc mismatch"); + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; break; } INITBITS(); @@ -587,21 +856,17 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { strm->adler = state->check = ZSWAP32(hold); INITBITS(); state->mode = DICT; - case DICT: if (state->havedict == 0) { RESTORE(); return Z_NEED_DICT; } - strm->adler = state->check = ADLER32_INITIAL_VALUE; + strm->adler = state->check = functable.adler32(0L, NULL, 0); state->mode = TYPE; - case TYPE: if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; - case TYPEDO: - /* determine and dispatch block type */ INFLATE_TYPEDO_HOOK(strm, flush); /* hook for IBM Z DFLTCC */ if (state->last) { BYTEBITS(); @@ -630,17 +895,17 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->mode = TABLE; break; case 3: - SET_BAD("invalid block type"); + strm->msg = (char *)"invalid block type"; + state->mode = BAD; } DROPBITS(2); break; - case STORED: - /* get and verify stored block length */ BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - SET_BAD("invalid stored block lengths"); + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; break; } state->length = (uint16_t)hold; @@ -649,12 +914,9 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->mode = COPY_; if (flush == Z_TREES) goto inf_leave; - case COPY_: state->mode = COPY; - case COPY: - /* copy stored block from input to output */ copy = state->length; if (copy) { if (copy > have) copy = have; @@ -671,9 +933,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { Tracev((stderr, "inflate: stored end\n")); state->mode = TYPE; break; - case TABLE: - /* get dynamic table entries descriptor */ NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); @@ -683,16 +943,15 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { - SET_BAD("too many length or distance symbols"); + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; break; } #endif Tracev((stderr, "inflate: table sizes ok\n")); state->have = 0; state->mode = LENLENS; - case LENLENS: - /* get code length code lengths (not a typo) */ while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (uint16_t)BITS(3); @@ -703,17 +962,16 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->next = state->codes; state->lencode = (const code *)(state->next); state->lenbits = 7; - ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); + ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { - SET_BAD("invalid code lengths set"); + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); state->have = 0; state->mode = CODELENS; - case CODELENS: - /* get length and distance code code lengths */ while (state->have < state->nlen + state->ndist) { for (;;) { here = state->lencode[BITS(state->lenbits)]; @@ -728,7 +986,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { NEEDBITS(here.bits + 2); DROPBITS(here.bits); if (state->have == 0) { - SET_BAD("invalid bit length repeat"); + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; break; } len = state->lens[state->have - 1]; @@ -748,7 +1007,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { - SET_BAD("invalid bit length repeat"); + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; break; } while (copy) { @@ -764,7 +1024,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { /* check for end-of-block code (better have one) */ if (state->lens[256] == 0) { - SET_BAD("invalid code -- missing end-of-block"); + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; break; } @@ -774,40 +1035,38 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->next = state->codes; state->lencode = (const code *)(state->next); state->lenbits = 9; - ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { - SET_BAD("invalid literal/lengths set"); + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; break; } state->distcode = (const code *)(state->next); state->distbits = 6; - ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist, + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { - SET_BAD("invalid distances set"); + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN_; if (flush == Z_TREES) goto inf_leave; - case LEN_: state->mode = LEN; - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_LEFT) { + if (have >= INFLATE_FAST_MIN_HAVE && + left >= INFLATE_FAST_MIN_LEFT) { RESTORE(); - zng_inflate_fast(strm, out); + inflate_fast(strm, out); LOAD(); if (state->mode == TYPE) state->back = -1; break; } state->back = 0; - - /* get a literal, length, or end-of-block code */ for (;;) { here = state->lencode[BITS(state->lenbits)]; if (here.bits <= bits) @@ -828,8 +1087,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { DROPBITS(here.bits); state->back += here.bits; state->length = here.val; - - /* process literal */ if ((int)(here.op) == 0) { Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? "inflate: literal '%c'\n" : @@ -837,27 +1094,20 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->mode = LIT; break; } - - /* process end of block */ if (here.op & 32) { Tracevv((stderr, "inflate: end of block\n")); state->back = -1; state->mode = TYPE; break; } - - /* invalid code */ if (here.op & 64) { - SET_BAD("invalid literal/length code"); + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; break; } - - /* length code */ state->extra = (here.op & 15); state->mode = LENEXT; - case LENEXT: - /* get extra bits, if any */ if (state->extra) { NEEDBITS(state->extra); state->length += BITS(state->extra); @@ -867,9 +1117,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { Tracevv((stderr, "inflate: length %u\n", state->length)); state->was = state->length; state->mode = DIST; - case DIST: - /* get distance code */ for (;;) { here = state->distcode[BITS(state->distbits)]; if (here.bits <= bits) @@ -890,15 +1138,14 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { DROPBITS(here.bits); state->back += here.bits; if (here.op & 64) { - SET_BAD("invalid distance code"); + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; break; } state->offset = here.val; state->extra = (here.op & 15); state->mode = DISTEXT; - case DISTEXT: - /* get distance extra bits, if any */ if (state->extra) { NEEDBITS(state->extra); state->offset += BITS(state->extra); @@ -907,22 +1154,22 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } #ifdef INFLATE_STRICT if (state->offset > state->dmax) { - SET_BAD("invalid distance too far back"); + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; break; } #endif Tracevv((stderr, "inflate: distance %u\n", state->offset)); state->mode = MATCH; - case MATCH: - /* copy match from window to output */ if (left == 0) goto inf_leave; copy = out - left; if (state->offset > copy) { /* copy from window */ copy = state->offset - copy; if (copy > state->whave) { if (state->sane) { - SET_BAD("invalid distance too far back"); + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; break; } #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR @@ -952,21 +1199,32 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { copy = state->length; if (copy > left) copy = left; - - put = functable.chunkcopy_safe(put, from, copy, put + left); +#if defined(INFFAST_CHUNKSIZE) + put = chunkcopysafe(put, from, copy, put + left); +#else + if (copy >= sizeof(uint64_t)) + put = chunk_memcpy(put, from, copy); + else + put = copy_bytes(put, from, copy); +#endif } else { /* copy from output */ copy = state->length; if (copy > left) copy = left; - - put = functable.chunkmemset_safe(put, state->offset, copy, left); +#if defined(INFFAST_CHUNKSIZE) + put = chunkmemsetsafe(put, state->offset, copy, left); +#else + if (copy >= sizeof(uint64_t)) + put = chunk_memset(put, put - state->offset, state->offset, copy); + else + put = set_bytes(put, put - state->offset, state->offset, copy); +#endif } left -= copy; state->length -= copy; if (state->length == 0) state->mode = LEN; break; - case LIT: if (left == 0) goto inf_leave; @@ -974,7 +1232,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { left--; state->mode = LEN; break; - case CHECK: if (state->wrap) { NEEDBITS(32); @@ -989,7 +1246,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->flags ? hold : #endif ZSWAP32(hold)) != state->check) { - SET_BAD("incorrect data check"); + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; break; } INITBITS(); @@ -997,12 +1255,12 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } #ifdef GUNZIP state->mode = LENGTH; - case LENGTH: if (state->wrap && state->flags) { NEEDBITS(32); - if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { - SET_BAD("incorrect length check"); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; break; } INITBITS(); @@ -1010,22 +1268,16 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } #endif state->mode = DONE; - case DONE: - /* inflate stream terminated properly */ ret = Z_STREAM_END; goto inf_leave; - case BAD: ret = Z_DATA_ERROR; goto inf_leave; - case MEM: return Z_MEM_ERROR; - case SYNC: - - default: /* can't happen, but makes compilers happy */ + default: return Z_STREAM_ERROR; } @@ -1059,7 +1311,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { return ret; } -int32_t Z_EXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1072,7 +1324,7 @@ int32_t Z_EXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) { return Z_OK; } -int32_t Z_EXPORT PREFIX(inflateGetDictionary)(PREFIX3(stream) *strm, uint8_t *dictionary, uint32_t *dictLength) { +int ZEXPORT PREFIX(inflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int *dictLength) { struct inflate_state *state; /* check state */ @@ -1090,10 +1342,10 @@ int32_t Z_EXPORT PREFIX(inflateGetDictionary)(PREFIX3(stream) *strm, uint8_t *di return Z_OK; } -int32_t Z_EXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const uint8_t *dictionary, uint32_t dictLength) { +int ZEXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const unsigned char *dictionary, unsigned int dictLength) { struct inflate_state *state; unsigned long dictid; - int32_t ret; + int ret; /* check state */ if (inflateStateCheck(strm)) @@ -1104,7 +1356,8 @@ int32_t Z_EXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const uint8 /* check for correct dictionary identifier */ if (state->mode == DICT) { - dictid = functable.adler32(ADLER32_INITIAL_VALUE, dictionary, dictLength); + dictid = functable.adler32(0L, NULL, 0); + dictid = functable.adler32(dictid, dictionary, dictLength); if (dictid != state->check) return Z_DATA_ERROR; } @@ -1121,7 +1374,7 @@ int32_t Z_EXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const uint8 return Z_OK; } -int32_t Z_EXPORT PREFIX(inflateGetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { +int ZEXPORT PREFIX(inflateGetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { struct inflate_state *state; /* check state */ @@ -1148,8 +1401,9 @@ int32_t Z_EXPORT PREFIX(inflateGetHeader)(PREFIX3(stream) *strm, PREFIX(gz_heade called again with more data and the *have state. *have is initialized to zero for the first call. */ -static uint32_t syncsearch(uint32_t *have, const uint8_t *buf, uint32_t len) { - uint32_t got, next; +static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len) { + uint32_t got; + uint32_t next; got = *have; next = 0; @@ -1166,9 +1420,8 @@ static uint32_t syncsearch(uint32_t *have, const uint8_t *buf, uint32_t len) { return next; } -int32_t Z_EXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { unsigned len; /* number of bytes to look at or looked at */ - int flags; /* temporary to save header status */ size_t in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state *state; @@ -1204,17 +1457,13 @@ int32_t Z_EXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; - if (state->flags == -1) - state->wrap = 0; /* if no header yet, treat as raw */ - else - state->wrap &= ~4; /* no point in computing a check value now */ - flags = state->flags; + if (state->mode == HEAD) + state->wrap = 0; /* never processed header, so assume raw */ in = strm->total_in; out = strm->total_out; PREFIX(inflateReset)(strm); strm->total_in = in; strm->total_out = out; - state->flags = flags; state->mode = TYPE; return Z_OK; } @@ -1227,17 +1476,16 @@ int32_t Z_EXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int32_t Z_EXPORT PREFIX(inflateSyncPoint)(PREFIX3(stream) *strm) { +int ZEXPORT PREFIX(inflateSyncPoint)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - INFLATE_SYNC_POINT_HOOK(strm); state = (struct inflate_state *)strm->state; return state->mode == STORED && state->bits == 0; } -int32_t Z_EXPORT PREFIX(inflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { +int ZEXPORT PREFIX(inflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { struct inflate_state *state; struct inflate_state *copy; unsigned char *window; @@ -1249,12 +1497,13 @@ int32_t Z_EXPORT PREFIX(inflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou state = (struct inflate_state *)source->state; /* allocate space */ - copy = (struct inflate_state *)ZALLOC_STATE(source, 1, sizeof(struct inflate_state)); + copy = (struct inflate_state *) + ZALLOC_STATE(source, 1, sizeof(struct inflate_state)); if (copy == NULL) return Z_MEM_ERROR; window = NULL; if (state->window != NULL) { - window = (unsigned char *)ZALLOC_WINDOW(source, 1U << state->wbits, sizeof(unsigned char)); + window = (unsigned char *) ZALLOC_WINDOW(source, 1U << state->wbits, sizeof(unsigned char)); if (window == NULL) { ZFREE_STATE(source, copy); return Z_MEM_ERROR; @@ -1279,7 +1528,7 @@ int32_t Z_EXPORT PREFIX(inflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou return Z_OK; } -int32_t Z_EXPORT PREFIX(inflateUndermine)(PREFIX3(stream) *strm, int32_t subvert) { +int ZEXPORT PREFIX(inflateUndermine)(PREFIX3(stream) *strm, int subvert) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1295,7 +1544,7 @@ int32_t Z_EXPORT PREFIX(inflateUndermine)(PREFIX3(stream) *strm, int32_t subvert #endif } -int32_t Z_EXPORT PREFIX(inflateValidate)(PREFIX3(stream) *strm, int32_t check) { +int ZEXPORT PREFIX(inflateValidate)(PREFIX3(stream) *strm, int check) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1308,19 +1557,18 @@ int32_t Z_EXPORT PREFIX(inflateValidate)(PREFIX3(stream) *strm, int32_t check) { return Z_OK; } -long Z_EXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) { +long ZEXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) return -65536; INFLATE_MARK_HOOK(strm); /* hook for IBM Z DFLTCC */ state = (struct inflate_state *)strm->state; - return (long)(((unsigned long)((long)state->back)) << 16) + - (state->mode == COPY ? state->length : + return ((long)(state->back) << 16) + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long Z_EXPORT PREFIX(inflateCodesUsed)(PREFIX3(stream) *strm) { +unsigned long ZEXPORT PREFIX(inflateCodesUsed)(PREFIX3(stream) *strm) { struct inflate_state *state; if (strm == NULL || strm->state == NULL) return (unsigned long)-1; diff --git a/libs/zlibng/inflate.h b/libs/zlibng/inflate.h index a42749465..01fb1f9b0 100644 --- a/libs/zlibng/inflate.h +++ b/libs/zlibng/inflate.h @@ -11,9 +11,10 @@ #ifndef INFLATE_H_ #define INFLATE_H_ -/* define NO_GZIP when compiling if you want to disable gzip header and trailer decoding by inflate(). - NO_GZIP would be used to avoid linking in the crc code when it is not needed. - For shared libraries, gzip decoding should be left enabled. */ +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ #ifndef NO_GZIP # define GUNZIP #endif @@ -88,8 +89,7 @@ struct inflate_state { int wrap; /* bit 0 true for zlib, bit 1 true for gzip, bit 2 true to validate check value */ int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags, 0 if zlib, or - -1 if raw or no header yet */ + int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ @@ -125,10 +125,8 @@ struct inflate_state { int sane; /* if false, allow invalid distance too far */ int back; /* bits back of last unprocessed length/lit */ unsigned was; /* initial length of match */ - uint32_t chunksize; /* size of memory copying chunk */ }; -int Z_INTERNAL inflate_ensure_window(struct inflate_state *state); -void Z_INTERNAL fixedtables(struct inflate_state *state); +int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state); #endif /* INFLATE_H_ */ diff --git a/libs/zlibng/inflate_p.h b/libs/zlibng/inflate_p.h deleted file mode 100644 index 76fe2dccb..000000000 --- a/libs/zlibng/inflate_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/* inflate_p.h -- Private inline functions and macros shared with more than one deflate method - * - */ - -#ifndef INFLATE_P_H -#define INFLATE_P_H - -/* - * Macros shared by inflate() and inflateBack() - */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? PREFIX(crc32)(check, buf, len) : functable.adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) functable.adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = PREFIX(crc32)(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = PREFIX(crc32)(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = (z_const unsigned char *)next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Ensure that there is at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate()/inflateBack(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - (hold & ((1U << (unsigned)(n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -#endif - -/* Set mode=BAD and prepare error message */ -#define SET_BAD(errmsg) \ - do { \ - state->mode = BAD; \ - strm->msg = (char *)errmsg; \ - } while (0) diff --git a/libs/zlibng/inftrees.c b/libs/zlibng/inftrees.c index faf1d249d..51e85375c 100644 --- a/libs/zlibng/inftrees.c +++ b/libs/zlibng/inftrees.c @@ -9,7 +9,7 @@ #define MAXBITS 15 -const char PREFIX(inflate_copyright)[] = " inflate 1.2.11.f Copyright 1995-2016 Mark Adler "; +const char inflate_copyright[] = " inflate 1.2.11.f Copyright 1995-2016 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -29,8 +29,8 @@ const char PREFIX(inflate_copyright)[] = " inflate 1.2.11.f Copyright 1995-2016 table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ -int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes, - code * *table, unsigned *bits, uint16_t *work) { +int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes, + code * *table, unsigned *bits, uint16_t *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ diff --git a/libs/zlibng/inftrees.h b/libs/zlibng/inftrees.h index 7758737c2..eaf3df1ca 100644 --- a/libs/zlibng/inftrees.h +++ b/libs/zlibng/inftrees.h @@ -60,7 +60,7 @@ typedef enum { DISTS } codetype; -int Z_INTERNAL zng_inflate_table (codetype type, uint16_t *lens, unsigned codes, +int ZLIB_INTERNAL inflate_table (codetype type, uint16_t *lens, unsigned codes, code * *table, unsigned *bits, uint16_t *work); #endif /* INFTREES_H_ */ diff --git a/libs/zlibng/insert_string.c b/libs/zlibng/insert_string.c deleted file mode 100644 index 4ddf9ae5d..000000000 --- a/libs/zlibng/insert_string.c +++ /dev/null @@ -1,25 +0,0 @@ -/* insert_string_c -- insert_string variant for c - * - * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - */ - -#include "zbuild.h" -#include "deflate.h" - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define HASH_SLIDE 16 // Number of bits to slide hash - -#define UPDATE_HASH(s, h, val) \ - h = ((val * 2654435761U) >> HASH_SLIDE); - -#define INSERT_STRING insert_string_c -#define QUICK_INSERT_STRING quick_insert_string_c - -#include "insert_string_tpl.h" diff --git a/libs/zlibng/insert_string_tpl.h b/libs/zlibng/insert_string_tpl.h deleted file mode 100644 index 9796e5196..000000000 --- a/libs/zlibng/insert_string_tpl.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef INSERT_STRING_H_ -#define INSERT_STRING_H_ - -/* insert_string.h -- Private insert_string functions shared with more than - * one insert string implementation - * - * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler - * - * Copyright (C) 2013 Intel Corporation. All rights reserved. - * Authors: - * Wajdi Feghali - * Jim Guilford - * Vinodh Gopal - * Erdinc Ozturk - * Jim Kukunas - * - * Portions are Copyright (C) 2016 12Sided Technology, LLC. - * Author: - * Phil Vachon - * - * For conditions of distribution and use, see copyright notice in zlib.h - * - */ - -/* =========================================================================== - * Quick insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - */ -Z_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, const uint32_t str) { - Pos head; - uint8_t *strstart = s->window + str; - uint32_t val, hm, h = 0; - -#ifdef UNALIGNED_OK - val = *(uint32_t *)(strstart); -#else - val = ((uint32_t)(strstart[0])); - val |= ((uint32_t)(strstart[1]) << 8); - val |= ((uint32_t)(strstart[2]) << 16); - val |= ((uint32_t)(strstart[3]) << 24); -#endif - - UPDATE_HASH(s, h, val); - hm = h & HASH_MASK; - - head = s->head[hm]; - if (LIKELY(head != str)) { - s->prev[str & s->w_mask] = head; - s->head[hm] = (Pos)str; - } - return head; -} - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -Z_INTERNAL void INSERT_STRING(deflate_state *const s, const uint32_t str, uint32_t count) { - uint8_t *strstart = s->window + str; - uint8_t *strend = strstart + count - 1; /* last position */ - - for (Pos idx = (Pos)str; strstart <= strend; idx++, strstart++) { - uint32_t val, hm, h = 0; - -#ifdef UNALIGNED_OK - val = *(uint32_t *)(strstart); -#else - val = ((uint32_t)(strstart[0])); - val |= ((uint32_t)(strstart[1]) << 8); - val |= ((uint32_t)(strstart[2]) << 16); - val |= ((uint32_t)(strstart[3]) << 24); -#endif - - UPDATE_HASH(s, h, val); - hm = h & HASH_MASK; - - Pos head = s->head[hm]; - if (LIKELY(head != idx)) { - s->prev[idx & s->w_mask] = head; - s->head[hm] = idx; - } - } -} -#endif diff --git a/libs/zlibng/match_p.h b/libs/zlibng/match_p.h new file mode 100644 index 000000000..b956d8d52 --- /dev/null +++ b/libs/zlibng/match_p.h @@ -0,0 +1,512 @@ +/* + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is garbage. + * + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >=1 + * OUT assertion: the match length is not greater than s->lookahead + */ + +#include "zbuild.h" +#include "deflate.h" + +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + + /* ARM 32-bit clang/gcc builds perform better, on average, with std2. Both gcc and clang and define __GNUC__. */ +# if defined(__GNUC__) && defined(__arm__) && !defined(__aarch64__) +# define std2_longest_match + /* Only use std3_longest_match for little_endian systems, also avoid using it with + non-gcc compilers since the __builtin_ctzl() function might not be optimized. */ +# elif(defined(__GNUC__) && defined(HAVE_BUILTIN_CTZL) && ((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \ + || defined(__LITTLE_ENDIAN__))) +# define std3_longest_match +# elif(defined(_MSC_VER) && defined(_WIN32)) +# define std3_longest_match +# else +# define std2_longest_match +# endif + +#else +# define std1_longest_match +#endif + + +#if defined(_MSC_VER) && !defined(__clang__) +# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) +# include "arch/x86/ctzl.h" +# elif defined(_M_ARM) +# include "arch/arm/ctzl.h" +# endif +#endif + + + +#ifdef std1_longest_match + +/* + * Standard longest_match + * + */ +static inline unsigned longest_match(deflate_state *const s, IPos cur_match) { + const unsigned wmask = s->w_mask; + const Pos *prev = s->prev; + + unsigned chain_length; + IPos limit; + unsigned int len, best_len, nice_match; + unsigned char *scan, *match, *strend, scan_end, scan_end1; + + /* + * The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple + * of 16. It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* + * Do not waste too much time if we already have a good match + */ + best_len = s->prev_length; + chain_length = s->max_chain_length; + if (best_len >= s->good_match) + chain_length >>= 2; + + /* + * Do not looks for matches beyond the end of the input. This is + * necessary to make deflate deterministic + */ + nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : (unsigned int)s->nice_match; + + /* + * Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0 + */ + limit = s->strstart > MAX_DIST(s) ? s->strstart - MAX_DIST(s) : 0; + + scan = s->window + s->strstart; + strend = s->window + s->strstart + MAX_MATCH; + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; + + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); + do { + if (cur_match >= s->strstart) { + break; + } + match = s->window + cur_match; + + /* + * Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks + * below for insufficient lookahead only occur occasionally + * for performance reasons. Therefore uninitialized memory + * will be accessed and conditional jumps will be made that + * depend on those values. However the length of the match + * is limited to the lookahead, so the output of deflate is not + * affected by the uninitialized values. + */ + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) + continue; + + /* + * The check at best_len-1 can be removed because it will + * be made again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since + * they are always equal when the other bytes match, given + * that the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2; + match++; + Assert(*scan == *match, "match[2]?"); + + /* + * We check for insufficient lookahead only every 8th + * comparision; the 256th check will be made at strstart + 258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned int)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) + break; + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; + } else { + /* + * The probability of finding a match later if we here + * is pretty low, so for performance it's best to + * outright stop here for the lower compression levels + */ + if (s->level < TRIGGER_LEVEL) + break; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length); + + if ((unsigned int)best_len <= s->lookahead) + return best_len; + return s->lookahead; +} +#endif + +#ifdef std2_longest_match +/* + * UNALIGNED_OK longest_match + * + */ +static inline unsigned longest_match(deflate_state *const s, IPos cur_match) { + const unsigned wmask = s->w_mask; + const Pos *prev = s->prev; + + uint16_t scan_start, scan_end; + unsigned chain_length; + IPos limit; + unsigned int len, best_len, nice_match; + unsigned char *scan, *strend; + + /* + * The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple + * of 16. It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* + * Do not waste too much time if we already have a good match + */ + best_len = s->prev_length; + chain_length = s->max_chain_length; + if (best_len >= s->good_match) + chain_length >>= 2; + + /* + * Do not look for matches beyond the end of the input. This is + * necessary to make deflate deterministic + */ + nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : s->nice_match; + + /* + * Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0 + */ + limit = s->strstart > MAX_DIST(s) ? s->strstart - MAX_DIST(s) : 0; + + scan = s->window + s->strstart; + strend = s->window + s->strstart + MAX_MATCH - 1; + memcpy(&scan_start, scan, sizeof(scan_start)); + memcpy(&scan_end, scan + best_len - 1, sizeof(scan_end)); + + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); + do { + unsigned char *match; + if (cur_match >= s->strstart) { + break; + } + match = s->window + cur_match; + + /* + * Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks + * below for insufficient lookahead only occur occasionally + * for performance reasons. Therefore uninitialized memory + * will be accessed and conditional jumps will be made that + * depend on those values. However the length of the match + * is limited to the lookahead, so the output of deflate is not + * affected by the uninitialized values. + */ + uint16_t val; + memcpy(&val, match + best_len - 1, sizeof(val)); + if (likely(val != scan_end)) + continue; + + memcpy(&val, match, sizeof(val)); + if (val != scan_start) + continue; + + /* It is not necessary to compare scan[2] and match[2] since + * they are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. Compare 2 + * bytes at a time at strstart+3, +5, ... up to strstart+257. + * We check for insufficient lookahead only every 4th + * comparison; the 128th check will be made at strstart+257. + * If MAX_MATCH-2 is not a multiple of 8, it is necessary to + * put more guard bytes at the end of the window, or to check + * more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++; + match++; + + do { + uint16_t mval, sval; + + memcpy(&mval, match, sizeof(mval)); + memcpy(&sval, scan, sizeof(sval)); + if (mval != sval) + break; + match += sizeof(mval); + scan += sizeof(sval); + + memcpy(&mval, match, sizeof(mval)); + memcpy(&sval, scan, sizeof(sval)); + if (mval != sval) + break; + match += sizeof(mval); + scan += sizeof(sval); + + memcpy(&mval, match, sizeof(mval)); + memcpy(&sval, scan, sizeof(sval)); + if (mval != sval) + break; + match += sizeof(mval); + scan += sizeof(sval); + + memcpy(&mval, match, sizeof(mval)); + memcpy(&sval, scan, sizeof(sval)); + if (mval != sval) + break; + match += sizeof(mval); + scan += sizeof(sval); + } while (scan < strend); + + /* + * Here, scan <= window + strstart + 257 + */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) + scan++; + + len = (MAX_MATCH -1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) + break; + memcpy(&scan_end, scan + best_len - 1, sizeof(scan_end)); + } else { + /* + * The probability of finding a match later if we here + * is pretty low, so for performance it's best to + * outright stop here for the lower compression levels + */ + if (s->level < TRIGGER_LEVEL) + break; + } + } while (--chain_length && (cur_match = prev[cur_match & wmask]) > limit); + + if ((unsigned)best_len <= s->lookahead) + return best_len; + return s->lookahead; +} +#endif + +#ifdef std3_longest_match +/* longest_match() with minor change to improve performance (in terms of + * execution time). + * + * The pristine longest_match() function is sketched below (strip the + * then-clause of the "#ifdef UNALIGNED_OK"-directive) + * + * ------------------------------------------------------------ + * unsigned int longest_match(...) { + * ... + * do { + * match = s->window + cur_match; //s0 + * if (*(ushf*)(match+best_len-1) != scan_end || //s1 + * *(ushf*)match != scan_start) continue; //s2 + * ... + * + * do { + * } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + * *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + * *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + * *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + * scan < strend); //s3 + * + * ... + * } while(cond); //s4 + * + * ------------------------------------------------------------- + * + * The change include: + * + * 1) The hottest statements of the function is: s0, s1 and s4. Pull them + * together to form a new loop. The benefit is two-fold: + * + * o. Ease the compiler to yield good code layout: the conditional-branch + * corresponding to s1 and its biased target s4 become very close (likely, + * fit in the same cache-line), hence improving instruction-fetching + * efficiency. + * + * o. Ease the compiler to promote "s->window" into register. "s->window" + * is loop-invariant; it is supposed to be promoted into register and keep + * the value throughout the entire loop. However, there are many such + * loop-invariant, and x86-family has small register file; "s->window" is + * likely to be chosen as register-allocation victim such that its value + * is reloaded from memory in every single iteration. By forming a new loop, + * "s->window" is loop-invariant of that newly created tight loop. It is + * lot easier for compiler to promote this quantity to register and keep + * its value throughout the entire small loop. + * + * 2) Transfrom s3 such that it examines sizeof(long)-byte-match at a time. + * This is done by: + * ------------------------------------------------ + * v1 = load from "scan" by sizeof(long) bytes + * v2 = load from "match" by sizeof(lnog) bytes + * v3 = v1 xor v2 + * match-bit = little-endian-machine(yes-for-x86) ? + * count-trailing-zero(v3) : + * count-leading-zero(v3); + * + * match-byte = match-bit/8 + * + * "scan" and "match" advance if necessary + * ------------------------------------------------- + */ + +static inline unsigned longest_match(deflate_state *const s, IPos cur_match) { + unsigned int strstart = s->strstart; + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + unsigned char *window = s->window; + register unsigned char *scan = window + strstart; /* current string */ + register unsigned char *match; /* matched string */ + register unsigned int len; /* length of current match */ + unsigned int best_len = s->prev_length; /* best match length so far */ + unsigned int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = strstart > (IPos)MAX_DIST(s) ? + strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Pos *prev = s->prev; + unsigned int wmask = s->w_mask; + + register unsigned char *strend = window + strstart + MAX_MATCH; + + uint16_t scan_start, scan_end; + + memcpy(&scan_start, scan, sizeof(scan_start)); + memcpy(&scan_end, scan+best_len-1, sizeof(scan_end)); + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((unsigned int)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((unsigned long)strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + if (cur_match >= strstart) { + break; + } + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ + int cont = 1; + do { + match = window + cur_match; + if (likely(memcmp(match+best_len-1, &scan_end, sizeof(scan_end)) != 0)) { + if ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0) { + continue; + } else { + cont = 0; + } + } + break; + } while (1); + + if (!cont) + break; + + if (memcmp(match, &scan_start, sizeof(scan_start)) != 0) + continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + scan += 2, match+=2; + Assert(*scan == *match, "match[2]?"); + do { + unsigned long sv, mv, xor; + + memcpy(&sv, scan, sizeof(sv)); + memcpy(&mv, match, sizeof(mv)); + + xor = sv ^ mv; + + if (xor) { + int match_byte = __builtin_ctzl(xor) / 8; + scan += match_byte; + break; + } else { + scan += sizeof(unsigned long); + match += sizeof(unsigned long); + } + } while (scan < strend); + + if (scan > strend) + scan = strend; + + Assert(scan <= window + (unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) + break; + memcpy(&scan_end, scan+best_len-1, sizeof(scan_end)); + } else { + /* + * The probability of finding a match later if we here + * is pretty low, so for performance it's best to + * outright stop here for the lower compression levels + */ + if (s->level < TRIGGER_LEVEL) + break; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); + + if ((unsigned int)best_len <= s->lookahead) + return (unsigned int)best_len; + return s->lookahead; +} +#endif diff --git a/libs/zlibng/match_tpl.h b/libs/zlibng/match_tpl.h deleted file mode 100644 index b15ca17b9..000000000 --- a/libs/zlibng/match_tpl.h +++ /dev/null @@ -1,180 +0,0 @@ - -#include "zbuild.h" -#include "deflate.h" -#include "functable.h" - -#ifndef MATCH_TPL_H -#define MATCH_TPL_H - -#ifdef UNALIGNED_OK -# ifdef UNALIGNED64_OK -typedef uint64_t bestcmp_t; -# else -typedef uint32_t bestcmp_t; -# endif -#else -typedef uint8_t bestcmp_t; -#endif - -#define EARLY_EXIT_TRIGGER_LEVEL 5 - -#endif - -/* Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is garbage. - * - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >=1 - * OUT assertion: the match length is not greater than s->lookahead - */ -Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { - unsigned int strstart = s->strstart; - const unsigned wmask = s->w_mask; - unsigned char *window = s->window; - unsigned char *scan = window + strstart; - Z_REGISTER unsigned char *mbase_start = window; - Z_REGISTER unsigned char *mbase_end; - const Pos *prev = s->prev; - Pos limit; - int32_t early_exit; - uint32_t chain_length, nice_match, best_len, offset; - uint32_t lookahead = s->lookahead; - bestcmp_t scan_end; -#ifndef UNALIGNED_OK - bestcmp_t scan_end0; -#else - bestcmp_t scan_start; -#endif - -#define GOTO_NEXT_CHAIN \ - if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \ - continue; \ - return best_len; - - /* The code is optimized for MAX_MATCH-2 multiple of 16. */ - Assert(MAX_MATCH == 258, "Code too clever"); - - best_len = s->prev_length ? s->prev_length : 1; - - /* Calculate read offset which should only extend an extra byte - * to find the next best match length. - */ - offset = best_len-1; -#ifdef UNALIGNED_OK - if (best_len >= sizeof(uint32_t)) { - offset -= 2; -#ifdef UNALIGNED64_OK - if (best_len >= sizeof(uint64_t)) - offset -= 4; -#endif - } -#endif - - scan_end = *(bestcmp_t *)(scan+offset); -#ifndef UNALIGNED_OK - scan_end0 = *(bestcmp_t *)(scan+offset+1); -#else - scan_start = *(bestcmp_t *)(scan); -#endif - mbase_end = (mbase_start+offset); - - /* Do not waste too much time if we already have a good match */ - chain_length = s->max_chain_length; - early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL; - if (best_len >= s->good_match) - chain_length >>= 2; - nice_match = (uint32_t)s->nice_match; - - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0 - */ - limit = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0; - - Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); - for (;;) { - if (cur_match >= strstart) - break; - - /* Skip to next match if the match length cannot increase or if the match length is - * less than 2. Note that the checks below for insufficient lookahead only occur - * occasionally for performance reasons. - * Therefore uninitialized memory will be accessed and conditional jumps will be made - * that depend on those values. However the length of the match is limited to the - * lookahead, so the output of deflate is not affected by the uninitialized values. - */ -#ifdef UNALIGNED_OK - if (best_len < sizeof(uint32_t)) { - for (;;) { - if (*(uint16_t *)(mbase_end+cur_match) == (uint16_t)scan_end && - *(uint16_t *)(mbase_start+cur_match) == (uint16_t)scan_start) - break; - GOTO_NEXT_CHAIN; - } -# ifdef UNALIGNED64_OK - } else if (best_len >= sizeof(uint64_t)) { - for (;;) { - if (*(uint64_t *)(mbase_end+cur_match) == (uint64_t)scan_end && - *(uint64_t *)(mbase_start+cur_match) == (uint64_t)scan_start) - break; - GOTO_NEXT_CHAIN; - } -# endif - } else { - for (;;) { - if (*(uint32_t *)(mbase_end+cur_match) == (uint32_t)scan_end && - *(uint32_t *)(mbase_start+cur_match) == (uint32_t)scan_start) - break; - GOTO_NEXT_CHAIN; - } - } -#else - for (;;) { - if (mbase_end[cur_match] == scan_end && mbase_end[cur_match+1] == scan_end0 && - mbase_start[cur_match] == scan[0] && mbase_start[cur_match+1] == scan[1]) - break; - GOTO_NEXT_CHAIN; - } -#endif - uint32_t len = COMPARE256(scan+2, mbase_start+cur_match+2) + 2; - Assert(scan+len <= window+(unsigned)(s->window_size-1), "wild scan"); - - if (len > best_len) { - s->match_start = cur_match; - /* Do not look for matches beyond the end of the input. */ - if (len > lookahead) - return lookahead; - best_len = len; - if (best_len >= nice_match) - return best_len; - - offset = best_len-1; -#ifdef UNALIGNED_OK - if (best_len >= sizeof(uint32_t)) { - offset -= 2; -#ifdef UNALIGNED64_OK - if (best_len >= sizeof(uint64_t)) - offset -= 4; -#endif - } -#endif - scan_end = *(bestcmp_t *)(scan+offset); -#ifndef UNALIGNED_OK - scan_end0 = *(bestcmp_t *)(scan+offset+1); -#endif - mbase_end = (mbase_start+offset); - } else if (UNLIKELY(early_exit)) { - /* The probability of finding a match later if we here is pretty low, so for - * performance it's best to outright stop here for the lower compression levels - */ - break; - } - GOTO_NEXT_CHAIN; - } - - return best_len; -} - -#undef LONGEST_MATCH -#undef COMPARE256 -#undef COMPARE258 diff --git a/libs/zlibng/memcopy.h b/libs/zlibng/memcopy.h new file mode 100644 index 000000000..301aa5f73 --- /dev/null +++ b/libs/zlibng/memcopy.h @@ -0,0 +1,674 @@ +/* memcopy.h -- inline functions to copy small data chunks. + * For conditions of distribution and use, see copyright notice in zlib.h + */ +#ifndef MEMCOPY_H_ + #define MEMCOPY_H_ + + #include "gzendian.h" + +/* Load 64 bits from IN and place the bytes at offset BITS in the result. */ +static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) { + uint64_t chunk; + memcpy(&chunk, in, sizeof(chunk)); + + #if BYTE_ORDER == LITTLE_ENDIAN + return chunk << bits; + #else + return ZSWAP64(chunk) << bits; + #endif +} + + #if (defined(__GNUC__) || defined(__clang__)) && defined(__ARM_NEON__) + #include +typedef uint8x16_t inffast_chunk_t; + #define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t) + #endif + + #if defined(X86_SSE2) + #include +typedef __m128i inffast_chunk_t; + #define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t) + #endif + + #ifdef INFFAST_CHUNKSIZE +/* + Ask the compiler to perform a wide, unaligned load with an machine + instruction appropriate for the inffast_chunk_t type. + */ +static inline inffast_chunk_t loadchunk(unsigned char const* s) { + inffast_chunk_t c; + memcpy(&c, s, sizeof(c)); + return c; +} + +/* + Ask the compiler to perform a wide, unaligned store with an machine + instruction appropriate for the inffast_chunk_t type. + */ +static inline void storechunk(unsigned char* d, inffast_chunk_t c) { + memcpy(d, &c, sizeof(c)); +} + +/* + Behave like memcpy, but assume that it's OK to overwrite at least + INFFAST_CHUNKSIZE bytes of output even if the length is shorter than this, + that the length is non-zero, and that `from` lags `out` by at least + INFFAST_CHUNKSIZE bytes (or that they don't overlap at all or simply that + the distance is less than the length of the copy). + + Aside from better memory bus utilisation, this means that short copies + (INFFAST_CHUNKSIZE bytes or fewer) will fall straight through the loop + without iteration, which will hopefully make the branch prediction more + reliable. + */ +static inline unsigned char* chunkcopy(unsigned char *out, unsigned char const *from, unsigned len) { + --len; + storechunk(out, loadchunk(from)); + out += (len % INFFAST_CHUNKSIZE) + 1; + from += (len % INFFAST_CHUNKSIZE) + 1; + len /= INFFAST_CHUNKSIZE; + while (len > 0) { + storechunk(out, loadchunk(from)); + out += INFFAST_CHUNKSIZE; + from += INFFAST_CHUNKSIZE; + --len; + } + return out; +} + +/* + Behave like chunkcopy, but avoid writing beyond of legal output. + */ +static inline unsigned char* chunkcopysafe(unsigned char *out, unsigned char const *from, unsigned len, + unsigned char *safe) { + if ((safe - out) < (ptrdiff_t)INFFAST_CHUNKSIZE) { + if (len & 8) { + memcpy(out, from, 8); + out += 8; + from += 8; + } + if (len & 4) { + memcpy(out, from, 4); + out += 4; + from += 4; + } + if (len & 2) { + memcpy(out, from, 2); + out += 2; + from += 2; + } + if (len & 1) { + *out++ = *from++; + } + return out; + } + return chunkcopy(out, from, len); +} + +/* + Perform short copies until distance can be rewritten as being at least + INFFAST_CHUNKSIZE. + + This assumes that it's OK to overwrite at least the first + 2*INFFAST_CHUNKSIZE bytes of output even if the copy is shorter than this. + This assumption holds because inflate_fast() starts every iteration with at + least 258 bytes of output space available (258 being the maximum length + output from a single token; see inflate_fast()'s assumptions below). + */ +static inline unsigned char* chunkunroll(unsigned char *out, unsigned *dist, unsigned *len) { + unsigned char const *from = out - *dist; + while (*dist < *len && *dist < INFFAST_CHUNKSIZE) { + storechunk(out, loadchunk(from)); + out += *dist; + *len -= *dist; + *dist += *dist; + } + return out; +} + +static inline inffast_chunk_t chunkmemset_1(unsigned char *from) { + #if defined(X86_SSE2) + int8_t c; + memcpy(&c, from, sizeof(c)); + return _mm_set1_epi8(c); + #elif defined(__ARM_NEON__) || defined(__ARM_NEON) + return vld1q_dup_u8(from); + #endif +} + +static inline inffast_chunk_t chunkmemset_2(unsigned char *from) { + int16_t c; + memcpy(&c, from, sizeof(c)); + #if defined(X86_SSE2) + return _mm_set1_epi16(c); + #elif defined(__ARM_NEON__) || defined(__ARM_NEON) + return vreinterpretq_u8_s16(vdupq_n_s16(c)); + #endif +} + +static inline inffast_chunk_t chunkmemset_4(unsigned char *from) { + int32_t c; + memcpy(&c, from, sizeof(c)); + #if defined(X86_SSE2) + return _mm_set1_epi32(c); + #elif defined(__ARM_NEON__) || defined(__ARM_NEON) + return vreinterpretq_u8_s32(vdupq_n_s32(c)); + #endif +} + +static inline inffast_chunk_t chunkmemset_8(unsigned char *from) { + #if defined(X86_SSE2) + int64_t c; + memcpy(&c, from, sizeof(c)); + return _mm_set1_epi64x(c); + #elif defined(__ARM_NEON__) || defined(__ARM_NEON) + return vcombine_u8(vld1_u8(from), vld1_u8(from)); + #endif +} + + #if defined(__ARM_NEON__) || defined(__ARM_NEON) +static inline unsigned char *chunkmemset_3(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) { + uint8x8x3_t chunks; + unsigned sz = sizeof(chunks); + if (len < sz) { + out = chunkunroll(out, &dist, &len); + return chunkcopy(out, out - dist, len); + } + + /* Load 3 bytes 'a,b,c' from FROM and duplicate across all lanes: + chunks[0] = {a,a,a,a,a,a,a,a} + chunks[1] = {b,b,b,b,b,b,b,b} + chunks[2] = {c,c,c,c,c,c,c,c}. */ + chunks = vld3_dup_u8(from); + + unsigned rem = len % sz; + len -= rem; + while (len) { + /* Store "a,b,c, ..., a,b,c". */ + vst3_u8(out, chunks); + out += sz; + len -= sz; + } + + if (!rem) + return out; + + /* Last, deal with the case when LEN is not a multiple of SZ. */ + out = chunkunroll(out, &dist, &rem); + return chunkcopy(out, out - dist, rem); +} + #endif + + #if defined(__aarch64__) +static inline unsigned char *chunkmemset_6(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) { + uint16x8x3_t chunks; + unsigned sz = sizeof(chunks); + if (len < sz) { + out = chunkunroll(out, &dist, &len); + return chunkcopy(out, out - dist, len); + } + + /* Load 6 bytes 'ab,cd,ef' from FROM and duplicate across all lanes: + chunks[0] = {ab,ab,ab,ab,ab,ab,ab,ab} + chunks[1] = {cd,cd,cd,cd,cd,cd,cd,cd} + chunks[2] = {ef,ef,ef,ef,ef,ef,ef,ef}. */ + chunks = vld3q_dup_u16((unsigned short *)from); + + unsigned rem = len % sz; + len -= rem; + while (len) { + /* Store "ab,cd,ef, ..., ab,cd,ef". */ + vst3q_u16((unsigned short *)out, chunks); + out += sz; + len -= sz; + } + + if (rem) + return out; + + /* Last, deal with the case when LEN is not a multiple of SZ. */ + out = chunkunroll(out, &dist, &rem); + return chunkcopy(out, out - dist, rem); +} + #endif + +/* Copy DIST bytes from OUT - DIST into OUT + DIST * k, for 0 <= k < LEN/DIST. Return OUT + LEN. */ +static inline unsigned char *chunkmemset(unsigned char *out, unsigned dist, unsigned len) { + Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); + Assert(dist > 0, "cannot have a distance 0"); + + unsigned char *from = out - dist; + inffast_chunk_t chunk; + unsigned sz = sizeof(chunk); + if (len < sz) { + do { + *out++ = *from++; + --len; + } while (len != 0); + return out; + } + + switch (dist) { + case 1: { + chunk = chunkmemset_1(from); + break; + } + case 2: { + chunk = chunkmemset_2(from); + break; + } + #if defined(__ARM_NEON__) || defined(__ARM_NEON) + case 3: + return chunkmemset_3(out, from, dist, len); + #endif + case 4: { + chunk = chunkmemset_4(from); + break; + } + #if defined(__aarch64__) + case 6: + return chunkmemset_6(out, from, dist, len); + #endif + case 8: { + chunk = chunkmemset_8(from); + break; + } + case 16: + memcpy(&chunk, from, sz); + break; + + default: + out = chunkunroll(out, &dist, &len); + return chunkcopy(out, out - dist, len); + } + + unsigned rem = len % sz; + len -= rem; + while (len) { + memcpy(out, &chunk, sz); + out += sz; + len -= sz; + } + + /* Last, deal with the case when LEN is not a multiple of SZ. */ + if (rem) + memcpy(out, &chunk, rem); + out += rem; + return out; +} + +static inline unsigned char* chunkmemsetsafe(unsigned char *out, unsigned dist, unsigned len, unsigned left) { + if (left < (unsigned)(3 * INFFAST_CHUNKSIZE)) { + while (len > 0) { + *out = *(out - dist); + out++; + --len; + } + return out; + } + + return chunkmemset(out, dist, len); +} + + #else /* INFFAST_CHUNKSIZE */ + +static inline unsigned char *copy_1_bytes(unsigned char *out, unsigned char *from) { + *out++ = *from; + return out; +} + +static inline unsigned char *copy_2_bytes(unsigned char *out, unsigned char *from) { + uint16_t chunk; + unsigned sz = sizeof(chunk); + memcpy(&chunk, from, sz); + memcpy(out, &chunk, sz); + return out + sz; +} + +static inline unsigned char *copy_3_bytes(unsigned char *out, unsigned char *from) { + out = copy_1_bytes(out, from); + return copy_2_bytes(out, from + 1); +} + +static inline unsigned char *copy_4_bytes(unsigned char *out, unsigned char *from) { + uint32_t chunk; + unsigned sz = sizeof(chunk); + memcpy(&chunk, from, sz); + memcpy(out, &chunk, sz); + return out + sz; +} + +static inline unsigned char *copy_5_bytes(unsigned char *out, unsigned char *from) { + out = copy_1_bytes(out, from); + return copy_4_bytes(out, from + 1); +} + +static inline unsigned char *copy_6_bytes(unsigned char *out, unsigned char *from) { + out = copy_2_bytes(out, from); + return copy_4_bytes(out, from + 2); +} + +static inline unsigned char *copy_7_bytes(unsigned char *out, unsigned char *from) { + out = copy_3_bytes(out, from); + return copy_4_bytes(out, from + 3); +} + +static inline unsigned char *copy_8_bytes(unsigned char *out, unsigned char *from) { + uint64_t chunk; + unsigned sz = sizeof(chunk); + memcpy(&chunk, from, sz); + memcpy(out, &chunk, sz); + return out + sz; +} + +/* Copy LEN bytes (7 or fewer) from FROM into OUT. Return OUT + LEN. */ +static inline unsigned char *copy_bytes(unsigned char *out, unsigned char *from, unsigned len) { + Assert(len < 8, "copy_bytes should be called with less than 8 bytes"); + + #ifndef UNALIGNED_OK + while (len--) { + *out++ = *from++; + } + return out; + #else + switch (len) { + case 7: + return copy_7_bytes(out, from); + case 6: + return copy_6_bytes(out, from); + case 5: + return copy_5_bytes(out, from); + case 4: + return copy_4_bytes(out, from); + case 3: + return copy_3_bytes(out, from); + case 2: + return copy_2_bytes(out, from); + case 1: + return copy_1_bytes(out, from); + case 0: + return out; + default: + Assert(0, "should not happen"); + } + + return out; + #endif /* UNALIGNED_OK */ +} + +/* Copy LEN bytes (7 or fewer) from FROM into OUT. Return OUT + LEN. */ +static inline unsigned char *set_bytes(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) { + Assert(len < 8, "set_bytes should be called with less than 8 bytes"); + + #ifndef UNALIGNED_OK + (void)dist; + while (len--) { + *out++ = *from++; + } + return out; + #else + if (dist >= len) + return copy_bytes(out, from, len); + + switch (dist) { + case 6: + Assert(len == 7, "len should be exactly 7"); + out = copy_6_bytes(out, from); + return copy_1_bytes(out, from); + + case 5: + Assert(len == 6 || len == 7, "len should be either 6 or 7"); + out = copy_5_bytes(out, from); + return copy_bytes(out, from, len - 5); + + case 4: + Assert(len == 5 || len == 6 || len == 7, "len should be either 5, 6, or 7"); + out = copy_4_bytes(out, from); + return copy_bytes(out, from, len - 4); + + case 3: + Assert(4 <= len && len <= 7, "len should be between 4 and 7"); + out = copy_3_bytes(out, from); + switch (len) { + case 7: + return copy_4_bytes(out, from); + case 6: + return copy_3_bytes(out, from); + case 5: + return copy_2_bytes(out, from); + case 4: + return copy_1_bytes(out, from); + default: + Assert(0, "should not happen"); + break; + } + + case 2: + Assert(3 <= len && len <= 7, "len should be between 3 and 7"); + out = copy_2_bytes(out, from); + switch (len) { + case 7: + out = copy_4_bytes(out, from); + out = copy_1_bytes(out, from); + return out; + case 6: + out = copy_4_bytes(out, from); + return out; + case 5: + out = copy_2_bytes(out, from); + out = copy_1_bytes(out, from); + return out; + case 4: + out = copy_2_bytes(out, from); + return out; + case 3: + out = copy_1_bytes(out, from); + return out; + default: + Assert(0, "should not happen"); + break; + } + + case 1: + Assert(2 <= len && len <= 7, "len should be between 2 and 7"); + unsigned char c = *from; + switch (len) { + case 7: + memset(out, c, 7); + return out + 7; + case 6: + memset(out, c, 6); + return out + 6; + case 5: + memset(out, c, 5); + return out + 5; + case 4: + memset(out, c, 4); + return out + 4; + case 3: + memset(out, c, 3); + return out + 3; + case 2: + memset(out, c, 2); + return out + 2; + default: + Assert(0, "should not happen"); + break; + } + } + return out; + #endif /* UNALIGNED_OK */ +} + +/* Byte by byte semantics: copy LEN bytes from OUT + DIST and write them to OUT. Return OUT + LEN. */ +static inline unsigned char *chunk_memcpy(unsigned char *out, unsigned char *from, unsigned len) { + unsigned sz = sizeof(uint64_t); + Assert(len >= sz, "chunk_memcpy should be called on larger chunks"); + + /* Copy a few bytes to make sure the loop below has a multiple of SZ bytes to be copied. */ + copy_8_bytes(out, from); + + unsigned rem = len % sz; + len /= sz; + out += rem; + from += rem; + + unsigned by8 = len % sz; + len -= by8; + switch (by8) { + case 7: + out = copy_8_bytes(out, from); + from += sz; + case 6: + out = copy_8_bytes(out, from); + from += sz; + case 5: + out = copy_8_bytes(out, from); + from += sz; + case 4: + out = copy_8_bytes(out, from); + from += sz; + case 3: + out = copy_8_bytes(out, from); + from += sz; + case 2: + out = copy_8_bytes(out, from); + from += sz; + case 1: + out = copy_8_bytes(out, from); + from += sz; + } + + while (len) { + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + out = copy_8_bytes(out, from); + from += sz; + + len -= 8; + } + + return out; +} + +/* Memset LEN bytes in OUT with the value at OUT - 1. Return OUT + LEN. */ +static inline unsigned char *byte_memset(unsigned char *out, unsigned len) { + unsigned sz = sizeof(uint64_t); + Assert(len >= sz, "byte_memset should be called on larger chunks"); + + unsigned char *from = out - 1; + unsigned char c = *from; + + /* First, deal with the case when LEN is not a multiple of SZ. */ + memset(out, c, sz); + unsigned rem = len % sz; + len /= sz; + out += rem; + + unsigned by8 = len % 8; + len -= by8; + switch (by8) { + case 7: + memset(out, c, sz); + out += sz; + case 6: + memset(out, c, sz); + out += sz; + case 5: + memset(out, c, sz); + out += sz; + case 4: + memset(out, c, sz); + out += sz; + case 3: + memset(out, c, sz); + out += sz; + case 2: + memset(out, c, sz); + out += sz; + case 1: + memset(out, c, sz); + out += sz; + } + + while (len) { + /* When sz is a constant, the compiler replaces __builtin_memset with an + inline version that does not incur a function call overhead. */ + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + memset(out, c, sz); + out += sz; + len -= 8; + } + + return out; +} + +/* Copy DIST bytes from OUT - DIST into OUT + DIST * k, for 0 <= k < LEN/DIST. Return OUT + LEN. */ +static inline unsigned char *chunk_memset(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) { + if (dist >= len) + return chunk_memcpy(out, from, len); + + Assert(len >= sizeof(uint64_t), "chunk_memset should be called on larger chunks"); + + /* Double up the size of the memset pattern until reaching the largest pattern of size less than SZ. */ + unsigned sz = sizeof(uint64_t); + while (dist < len && dist < sz) { + copy_8_bytes(out, from); + + out += dist; + len -= dist; + dist += dist; + + /* Make sure the next memcpy has at least SZ bytes to be copied. */ + if (len < sz) + /* Finish up byte by byte when there are not enough bytes left. */ + return set_bytes(out, from, dist, len); + } + + return chunk_memcpy(out, from, len); +} + +/* Byte by byte semantics: copy LEN bytes from FROM and write them to OUT. Return OUT + LEN. */ +static inline unsigned char *chunk_copy(unsigned char *out, unsigned char *from, int dist, unsigned len) { + if (len < sizeof(uint64_t)) { + if (dist > 0) + return set_bytes(out, from, dist, len); + + return copy_bytes(out, from, len); + } + + if (dist == 1) + return byte_memset(out, len); + + if (dist > 0) + return chunk_memset(out, from, dist, len); + + return chunk_memcpy(out, from, len); +} + #endif /* INFFAST_CHUNKSIZE */ +#endif /* MEMCOPY_H_ */ diff --git a/libs/zlibng/test/.gitignore b/libs/zlibng/test/.gitignore index 96a3cad07..2c3af0a08 100644 --- a/libs/zlibng/test/.gitignore +++ b/libs/zlibng/test/.gitignore @@ -1,5 +1,2 @@ # ignore Makefiles; they're all automatically generated Makefile -/switchlevels -/switchlevels.dSYM/ -/switchlevels.exe diff --git a/libs/zlibng/test/CVE-2003-0107.c b/libs/zlibng/test/CVE-2003-0107.c index 51c79b2cd..306421e9f 100644 --- a/libs/zlibng/test/CVE-2003-0107.c +++ b/libs/zlibng/test/CVE-2003-0107.c @@ -5,18 +5,16 @@ #include int main(void) { - gzFile f; - int ret; +gzFile f; +int ret; - if(!(f = gzopen("/dev/null", "w"))) { - perror("/dev/null"); - exit(1); - } - - ret = gzprintf(f, "%10240s", ""); - printf("gzprintf -> %d\n", ret); - ret = gzclose(f); - printf("gzclose -> %d [%d]\n", ret, errno); - - exit(0); +if(!(f = gzopen("/dev/null", "w"))) { +perror("/dev/null"); +exit(1); +} +ret = gzprintf(f, "%10240s", ""); +printf("gzprintf -> %d\n", ret); +ret = gzclose(f); +printf("gzclose -> %d [%d]\n", ret, errno); +exit(0); } diff --git a/libs/zlibng/test/GH-361/test.txt b/libs/zlibng/test/GH-361/test.txt deleted file mode 100644 index 2b102819f..000000000 --- a/libs/zlibng/test/GH-361/test.txt +++ /dev/null @@ -1,4 +0,0 @@ -.....-.u..|u....-...!..A.#?)9.._B..F..| -00000650 fa 13 88 89 2c 1f 81 0f e4 e9 ce 39 a0 87 2e 2e |....,......9....| -00000660 a5 0c 08 9c ec fc 88 6d 16 02 0a a0 3d fc 36 29 |.......m....=.6)| -00000670 8d f5 c3 ba 1d 07 f4 78 e1 a0 41 f9 89 15 a5 69 |.......x..A.... \ No newline at end of file diff --git a/libs/zlibng/test/GH-364/test.bin b/libs/zlibng/test/GH-364/test.bin deleted file mode 100644 index 1b1cb4d44..000000000 Binary files a/libs/zlibng/test/GH-364/test.bin and /dev/null differ diff --git a/libs/zlibng/test/GH-382/defneg3.dat b/libs/zlibng/test/GH-382/defneg3.dat deleted file mode 100644 index 5fa6a0804..000000000 --- a/libs/zlibng/test/GH-382/defneg3.dat +++ /dev/null @@ -1 +0,0 @@ -oÌ™Ì?ÌOÌÃÌḩÌÕÌ>ÌÌÌàÌ̹̘ÌÔÌEÌsÌ—ÌÌ4̢̙̑Ì6ÌÌØÌæÌ\ÌÌÌ5̪̲̕ÌmÌÌ–Ìç̺̜ÌÙ̧ÌÌíÌíÌ–ÌÌëÌmÌìÌÎ̵ÌGÌïÌOÌÛÌ ÌÃÌòÌÎÌôÌ„Ì;Ì”ÌýÌ’ÌÓÌÀÌ×Ì,ÌÑÌ¢ÌáÌAÌ9Ì»ÌæÌ‚ÌÂÌsÌý̼ÌÝÌÌ­ÌeÌòÌÝÌUÌuÌí̱ÌËÌwÌùÌ•ÌDÌß̋̽Ìt̞̣̹ÌöÌôÌOÌîÌíÌ…ÌpÌGÌḭ̀ÌÀÌ(ÌÌÌ̤Ì{Ì“ÌßÌïÌÕÌÌøÌÌMÌ#ÌÌí̵ÌdÌ·ÌIÌßÌhÌ_ÌpÌJÌÇÌ¢ÌÎÌÌoÌÌêÌÁÌ;Ì<̘ÌZÌÈÌÑÌoÌW̄̿Ì}ÌáÌÌÌ:Ìá̧̻̕ÌeÌFÌtÌ(ÌEÌoÌàÌpÌÌ¢Ì(Ì;ÌþÌëÌóÌ!̹̹ÌÉÌÌœÌîÌÖÌ4ÌÈÌ3ÌëÌ‹ÌBÌŽÌÆÌuÌPÌ6Ì“ÌþÌ&̦̳̕ÌÁÌðÌ»ÌÌÌTÌÀ̧ÌbÌÌÒÌÕÌëÌ{ÌÆÌ¡ÌÊÌNÌ9ÌÇÌÌBÌÑ \ No newline at end of file diff --git a/libs/zlibng/test/GH-751/test.txt b/libs/zlibng/test/GH-751/test.txt deleted file mode 100644 index ef2143ece..000000000 --- a/libs/zlibng/test/GH-751/test.txt +++ /dev/null @@ -1 +0,0 @@ -abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc diff --git a/libs/zlibng/test/INDEX b/libs/zlibng/test/INDEX new file mode 100644 index 000000000..f167df87e --- /dev/null +++ b/libs/zlibng/test/INDEX @@ -0,0 +1,10 @@ +Makefile.in: template for Unix Makefile + +CVE-2003-0107.c: +CVE-2002-0059 : +CVE-2004-0797 : +CVE-2005-1849 : +CVE-2005-2096 : test cases for the relevant CVEs + +testCVEinputs.sh: script to run tests for CVEs where input data is supplied + diff --git a/libs/zlibng/test/Makefile.in b/libs/zlibng/test/Makefile.in index 97b8be753..4b858f744 100644 --- a/libs/zlibng/test/Makefile.in +++ b/libs/zlibng/test/Makefile.in @@ -7,15 +7,14 @@ CFLAGS= EXE= SRCDIR= SRCTOP= -LIBNAME= -TEST_LDFLAGS=-L.. ../$(LIBNAME).a +TEST_LDFLAGS=-L.. ../libz.a WITH_FUZZERS= COMPATTESTS = QEMU_RUN= QEMU_VER:=$(shell command -v $(QEMU_RUN) --version 2> /dev/null) -all: oldtests cvetests $(COMPATTESTS) fuzzer ghtests +all: oldtests cvetests $(COMPATTESTS) fuzzer oldtests: #set by ../configure check_cross_dep: @@ -46,28 +45,35 @@ fuzzer: endif teststatic: check_cross_dep - @TMPST=tmpst_$$$$; \ - HELLOST=tmphellost_$$$$; \ - if echo hello world | ${QEMU_RUN} ../minigzip$(EXE) > $$HELLOST && ${QEMU_RUN} ../minigzip$(EXE) -d < $$HELLOST && ${QEMU_RUN} ../example$(EXE) $$TMPST && ${QEMU_RUN} ../adler32_test$(EXE); then \ + @TMPST=tmpst_$$; \ + if echo hello world | ${QEMU_RUN} ../minigzip$(EXE) | ${QEMU_RUN} ../minigzip$(EXE) -d && ${QEMU_RUN} ../example$(EXE) $$TMPST ; then \ echo ' *** zlib test OK ***'; \ else \ echo ' *** zlib test FAILED ***'; exit 1; \ - fi; \ - rm -f $$TMPST $$HELLOST + fi + @rm -f tmpst_$$ testshared: check_cross_dep @LD_LIBRARY_PATH=`pwd`/..:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ LD_LIBRARYN32_PATH=`pwd`/..:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ DYLD_LIBRARY_PATH=`pwd`/..:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ SHLIB_PATH=`pwd`/..:$(SHLIB_PATH) ; export SHLIB_PATH; \ - TMPSH=tmpsh_$$$$; \ - HELLOSH=tmphellosh_$$$$; \ - if echo hello world | ${QEMU_RUN} ../minigzipsh$(EXE) > $$HELLOSH && ${QEMU_RUN} ../minigzipsh$(EXE) -d < $$HELLOSH && ${QEMU_RUN} ../examplesh$(EXE) $$TMPSH && ${QEMU_RUN} ../adler32_testsh$(EXE); then \ + TMPSH=tmpsh_$$; \ + if echo hello world | ${QEMU_RUN} ../minigzipsh$(EXE) | ${QEMU_RUN} ../minigzipsh$(EXE) -d && ${QEMU_RUN} ../examplesh$(EXE) $$TMPSH; then \ echo ' *** zlib shared test OK ***'; \ else \ echo ' *** zlib shared test FAILED ***'; exit 1; \ - fi; \ - rm -f $$TMPSH $$HELLOSH + fi + @rm -f tmpsh_$$ + +test64: check_cross_dep + @TMP64=tmp64_$$; \ + if echo hello world | ${QEMU_RUN} ../minigzip64$(EXE) | ${QEMU_RUN} ../minigzip64$(EXE) -d && ${QEMU_RUN} ../example64$(EXE) $$TMP64; then \ + echo ' *** zlib 64-bit test OK ***'; \ + else \ + echo ' *** zlib 64-bit test FAILED ***'; exit 1; \ + fi + @rm -f tmp64_$$ cvetests: testCVEinputs @@ -90,27 +96,10 @@ CVE-2003-0107.o: $(SRCDIR)/CVE-2003-0107.c CVE-2003-0107$(EXE): CVE-2003-0107.o $(CC) $(CFLAGS) -o $@ CVE-2003-0107.o $(TEST_LDFLAGS) -.PHONY: ghtests -ghtests: testGH-361 testGH-364 testGH-751 - -.PHONY: testGH-361 -testGH-361: - $(QEMU_RUN) ../minigzip$(EXE) -4 <$(SRCDIR)/GH-361/test.txt >/dev/null - -switchlevels$(EXE): $(SRCDIR)/switchlevels.c - $(CC) $(CFLAGS) -I.. -I$(SRCTOP) -o $@ $< $(TEST_LDFLAGS) - -.PHONY: testGH-364 -testGH-364: switchlevels$(EXE) - $(QEMU_RUN) ./switchlevels$(EXE) 1 5 9 3 <$(SRCDIR)/GH-364/test.bin >/dev/null - -.PHONY: testGH-751 -testGH-751: - $(QEMU_RUN) ../minigzip$(EXE) <$(SRCDIR)/GH-751/test.txt | $(QEMU_RUN) ../minigzip$(EXE) -d >/dev/null clean: rm -f *.o *.gcda *.gcno *.gcov - rm -f CVE-2003-0107$(EXE) switchlevels$(EXE) + rm -f CVE-2003-0107$(EXE) distclean: rm -f Makefile diff --git a/libs/zlibng/test/README.md b/libs/zlibng/test/README.md deleted file mode 100644 index 247d5bac7..000000000 --- a/libs/zlibng/test/README.md +++ /dev/null @@ -1,36 +0,0 @@ -Contents --------- - -|Name|Description| -|-|-| -|[CVE-2003-0107.c](https://nvd.nist.gov/vuln/detail/CVE-2003-0107)|Buffer overflow in the gzprintf function, requires ZLIB_COMPAT| -|[CVE-2002-0059](https://nvd.nist.gov/vuln/detail/CVE-2002-0059)|inflateEnd to release memory more than once| -|[CVE-2004-0797](https://nvd.nist.gov/vuln/detail/CVE-2004-0797)|Error handling in inflate and inflateBack causes crash| -|[CVE-2005-1849](https://nvd.nist.gov/vuln/detail/CVE-2005-1849)|inftrees.h bug causes crash| -|[CVE-2005-2096](https://nvd.nist.gov/vuln/detail/CVE-2005-2096)|Buffer overflow when incomplete code description -|[GH-361](https://github.com/zlib-ng/zlib-ng/issues/361)|Test case for overlapping matches| -|[GH-364](https://github.com/zlib-ng/zlib-ng/issues/364)|Test case for switching compression levels| -|[GH-382](https://github.com/zlib-ng/zlib-ng/issues/382)|Test case for deflateEnd returning -3 in deflate quick| - -Copying -------- - -Some of the files in _test_ are licensed differently: - - - test/data/fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and - is licensed under the Creative Commons Attribution 3.0 license - (CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/ - for more information. - - - test/data/paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper - “Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA - Replication Timing in _Drosophila_†by Federico Comoglio and Renato Paro, - which is licensed under the CC-BY license. See - http://www.ploscompbiol.org/static/license for more information. - - - test/data/lcet10.txt is from Project Gutenberg. It does not have expired - copyright, but is still in the public domain according to the license information. - (http://www.gutenberg.org/ebooks/53). - - - test/GH-382/defneg3.dat was the smallest file generated by Nathan Moinvaziri - that reproduced GH-382. It is licensed under the terms of the zlib license. diff --git a/libs/zlibng/test/abi/ignore b/libs/zlibng/test/abi/ignore deleted file mode 100644 index dba3639cb..000000000 --- a/libs/zlibng/test/abi/ignore +++ /dev/null @@ -1,12 +0,0 @@ -# See https://sourceware.org/libabigail/manual/libabigail-concepts.html#suppression-specifications - -[suppress_type] - name = internal_state - -[suppress_type] - name_regexp = z_stream.* - -# Size varies with version number -[suppress_variable] - name = zlibng_string - diff --git a/libs/zlibng/test/abi/zlib-v1.2.11-arm-linux-gnueabihf.abi b/libs/zlibng/test/abi/zlib-v1.2.11-arm-linux-gnueabihf.abi deleted file mode 100644 index 152a742cf..000000000 --- a/libs/zlibng/test/abi/zlib-v1.2.11-arm-linux-gnueabihf.abi +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/zlibng/test/abi/zlib-v1.2.11-x86_64-linux-gnu.abi b/libs/zlibng/test/abi/zlib-v1.2.11-x86_64-linux-gnu.abi deleted file mode 100644 index 00a520c63..000000000 --- a/libs/zlibng/test/abi/zlib-v1.2.11-x86_64-linux-gnu.abi +++ /dev/null @@ -1,1037 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/zlibng/test/abicheck.md b/libs/zlibng/test/abicheck.md deleted file mode 100644 index 6e9e58aad..000000000 --- a/libs/zlibng/test/abicheck.md +++ /dev/null @@ -1,59 +0,0 @@ -ABI Compatibility test ----------------------- - -abicheck.sh uses libabigail to check ABI stability. -It will abort if the current source -tree has a change that breaks binary compatibility. - -This protects against the common scenario where: -- an app is compiled against the current zlib-ng -- the system package manager updates the zlib-ng shared library -- the app now crashes because some symbol is - missing or some public structure or parameter - has changed type or size - -If run with --zlib-compat, it verifies that the -current source tree generates a library that -is ABI-compatible with the reference release -of classic zlib. This ensures that building -zlib-ng with --zlib-compat does what it says on the tin. - -abicheck.sh is not perfect, but it can catch -many common compatibility issues. - -Cached files test/abi/*.abi ---------------------------- - -Comparing to the old version of zlib (or zlib-ng) -means someone has to check out and build -the previous source tree and extract its .abi -using abidw. This can be slow. - -If you don't mind the slowness, run abicheck.sh --refresh_if, -and it will download and build the reference version -and extract the .abi on the spot if needed. -(FIXME: should this be the default?) - -On the next run, the reference .abi file will already be -present, and that step will be skipped. -It's stored in the tests/abi directory, -in a file with the architecture and git hash in the name. - -If you're running continuous integration -which clear out the source tree on each run, -and you don't want your build machines -constantly downloading and building the old -version, you can check the .abi file into git. - -To make this easier, a helper script could be written to automatically build -all the configurations tested by .github/worflows/abicheck.yml -Then they could be checked into git en masse by a maintainer -when a new platform is added or a new major version (which -intentionally breaks backwards compatibility) is being prepared. - -Further reading ---------------- - -- https://sourceware.org/libabigail/manual/ -- https://developers.redhat.com/blog/2014/10/23/comparing-abis-for-compatibility-with-libabigail-part-1/ -- https://developers.redhat.com/blog/2020/04/02/how-to-write-an-abi-compliance-checker-using-libabigail/ diff --git a/libs/zlibng/test/abicheck.sh b/libs/zlibng/test/abicheck.sh deleted file mode 100644 index 89199a59a..000000000 --- a/libs/zlibng/test/abicheck.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/sh -set -ex -TESTDIR="$(cd $(dirname "$0"); pwd)" - -usage() { - cat <<_EOF_ -Usage: $0 [--zlib-compat][--refresh][--refresh-if] - -Build shared library with -ggdb, then compare its ABI to the stable -ABI, and abort if differences found. - -Options: ---zlib-compat - check the ABI of the zlib-compatible flavor of zlib-ng. ---refresh - build the reference library and extract its ABI rather than using a stored ABI file. ---refresh-if - refresh only if ABI file not present. - -Obeys CHOST, CONFIGURE_ARGS, CFLAGS, and LDFLAGS. - -Requires libabigail (on Ubuntu, install package abigail-tools). -_EOF_ -} - -# Print the multiarch tuple for the current (non-cross) machine, -# or the empty string if unavailable. -detect_chost() { - dpkg-architecture -qDEB_HOST_MULTIARCH || - $CC -print-multiarch || - $CC -print-search-dirs | sed 's/:/\n/g' | grep -E '^/lib/[^/]+$' | sed 's%.*/%%' || - true -} - -if ! test -f "configure" -then - echo "Please run from top of source tree" - exit 1 -fi - -suffix="-ng" -CONFIGURE_ARGS_NG="$CONFIGURE_ARGS" -refresh=false -refresh_if=false -for arg -do - case "$arg" in - --zlib-compat) - suffix="" - CONFIGURE_ARGS_NG="$CONFIGURE_ARGS_NG --zlib-compat" - ;; - --refresh) - refresh=true - ;; - --refresh_if) - refresh_if=true - ;; - --help) - usage - exit 0 - ;; - *) - echo "Unknown arg '$arg'" - usage - exit 1 - ;; - esac -done - -# Choose reference repo and commit -if test "$suffix" = "" -then - # Reference is zlib 1.2.11 - ABI_GIT_REPO=https://github.com/madler/zlib.git - ABI_GIT_COMMIT=v1.2.11 -else - # Reference should be the tag for zlib-ng 2.0 - # but until that bright, shining day, use some - # random recent SHA. Annoyingly, can't shorten it. - ABI_GIT_REPO=https://github.com/zlib-ng/zlib-ng.git - ABI_GIT_COMMIT=56ce27343bf295ae9457f8e3d38ec96d2f949a1c -fi -# FIXME: even when using a tag, check the hash. - -# Test compat build for ABI compatibility with zlib -if test "$CHOST" = "" -then - # Note: don't export CHOST here, as we don't want configure seeing it - # when it's just the name for the build machine. - # Leave it as a plain shell variable, not an environment variable. - CHOST=$(detect_chost) - # Support -m32 for non-cross builds. - case "$CFLAGS" in - *-m32*) M32="-m32";; - *) M32="";; - esac -fi - -# Canonicalize CHOST to work around bug in original zlib's configure -export CHOST=$(sh $TESTDIR/../tools/config.sub $CHOST) - -if test "$CHOST" = "" -then - echo "abicheck: SKIP, as we don't know CHOST" - exit 0 -fi - -ABIFILE="test/abi/zlib$suffix-$ABI_GIT_COMMIT-$CHOST$M32.abi" -if ! $refresh && $refresh_if && ! test -f "$ABIFILE" -then - refresh=true -fi -abidw --version - -if $refresh -then - # Check out reference source - rm -rf btmp1 - mkdir -p btmp1/src.d - cd btmp1/src.d - git init - git remote add origin $ABI_GIT_REPO - git fetch origin $ABI_GIT_COMMIT - git reset --hard FETCH_HEAD - cd .. - # Build unstripped, uninstalled, very debug shared library - CFLAGS="$CFLAGS -ggdb" sh src.d/configure $CONFIGURE_ARGS - make -j2 - cd .. - # Find shared library, extract its abi - dylib1=$(find btmp1 -type f -name '*.dylib*' -print -o -type f -name '*.so.*' -print) - abidw $dylib1 > "$ABIFILE" - # Maintainers may wish to check $ABIFILE into git when a new - # target is added, or when a major release happens that is - # intended to change the ABI. Alternately, this script could - # just always rebuild the reference source, and dispense with - # caching abi files in git (but that would slow builds down). -fi - -if test -f "$ABIFILE" -then - ABIFILE="$ABIFILE" -else - echo "abicheck: SKIP: $ABIFILE not found; rerun with --refresh or --refresh_if" - exit 0 -fi - -# Build unstripped, uninstalled, very debug shared library -rm -rf btmp2 -mkdir btmp2 -cd btmp2 -CFLAGS="$CFLAGS -ggdb" ../configure $CONFIGURE_ARGS_NG -make -j2 -cd .. -# Find shared library, extract its abi -dylib2=$(find btmp2 -type f -name '*.dylib*' -print -o -type f -name '*.so.*' -print) -abidw $dylib2 > btmp2/zlib${suffix}-built.abi - -# Compare it to the reference -# FIXME: use --no-added-syms for now, but we probably want to be more strict. -if abidiff --no-added-syms --suppressions test/abi/ignore "$ABIFILE" btmp2/zlib${suffix}-built.abi -then - echo "abicheck: PASS" -else - echo "abicheck: FAIL" - exit 1 -fi diff --git a/libs/zlibng/test/adler32_test.c b/libs/zlibng/test/adler32_test.c deleted file mode 100644 index f681877d3..000000000 --- a/libs/zlibng/test/adler32_test.c +++ /dev/null @@ -1,365 +0,0 @@ -/* adler32_test.c -- unit test for adler32 in the zlib compression library - * Copyright (C) 2020 IBM Corporation - * Author: Rogerio Alves - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include -#include - -#include "zbuild.h" -#ifdef ZLIB_COMPAT -# include "zlib.h" -#else -# include "zlib-ng.h" -#endif - -typedef struct { - uint32_t line; - uint32_t adler; - const uint8_t *buf; - uint32_t len; - uint32_t expect; -} adler32_test; - -void test_adler32(uint32_t adler, const uint8_t *buf, uint32_t len, uint32_t chk, uint32_t line) { - uint32_t res = PREFIX(adler32)(adler, buf, len); - if (res != chk) { - fprintf(stderr, "FAIL [%d]: adler32 returned 0x%08X expected 0x%08X\n", - line, res, chk); - exit(1); - } -} - -static const uint8_t long_string[5552] = { - 'q','j','d','w','q','4','8','m','B','u','k','J','V','U','z','V','V','f','M','j','i','q','S','W','L','5','G','n','F','S','P','Q', - 'Q','D','i','6','m','E','9','Z','a','A','P','h','9','d','r','b','5','t','X','U','U','L','w','q','e','k','E','H','6','W','7','k', - 'A','x','N','Q','R','k','d','V','5','y','n','U','N','W','Q','Y','i','W','5','9','R','p','D','C','x','p','u','h','C','a','m','r', - 'z','n','z','A','d','J','6','u','N','e','r','x','7','Q','3','v','V','h','H','S','H','S','f','K','f','e','E','T','9','J','f','K', - 'w','t','x','J','2','y','7','B','x','X','X','p','G','b','T','g','3','k','U','6','E','Z','M','t','J','q','v','n','S','T','6','x', - '5','x','4','P','z','p','M','F','V','b','d','m','f','G','n','J','m','w','z','K','8','a','q','E','D','e','b','3','h','B','V','g', - 'y','3','P','L','5','8','r','z','X','b','Q','g','H','7','L','c','Z','B','3','C','4','y','t','u','k','z','h','v','C','Y','p','p', - '8','H','v','5','X','w','4','L','R','V','V','4','U','C','8','4','T','E','a','N','Z','S','7','U','u','z','f','H','p','P','J','u', - 'Y','Z','h','T','6','e','v','z','V','F','h','u','y','H','b','k','J','M','f','3','6','g','y','L','E','W','t','B','B','d','d','9', - 'u','M','Z','k','F','G','f','h','q','k','5','k','f','r','M','7','c','M','7','y','n','u','8','b','d','7','Q','f','E','m','F','K', - 'x','W','f','B','2','F','8','5','q','z','y','3','R','i','U','m','X','k','h','N','J','y','B','C','h','u','x','4','f','k','J','5', - '6','X','T','W','h','8','J','4','m','K','p','N','3','g','C','g','A','E','e','Z','x','A','P','2','E','4','t','Q','5','X','Y','j', - '6','m','b','h','G','a','v','6','t','v','6','C','M','G','P','u','B','C','A','V','b','2','9','d','2','c','5','a','b','X','w','V', - 'G','6','a','7','c','8','G','6','K','U','Q','m','w','P','V','5','N','x','b','v','x','E','N','C','A','N','t','v','N','B','z','X', - 'B','R','q','U','n','i','A','Q','d','m','a','D','7','Y','f','3','J','8','Y','m','w','Z','b','w','r','H','q','E','j','c','u','E', - 'i','i','S','b','n','G','P','a','F','j','c','R','D','D','G','F','v','i','a','i','M','7','B','e','w','m','L','E','F','2','Y','4', - '4','7','Y','C','t','y','q','7','2','V','G','m','m','E','e','V','u','m','L','p','R','X','W','z','V','K','E','k','p','V','r','J', - 'd','N','3','t','i','u','S','V','w','2','w','U','Q','3','F','q','4','h','q','k','B','7','R','X','B','F','Q','Z','b','b','4','E', - 'K','v','T','B','w','k','V','C','x','d','K','g','N','S','u','k','p','9','z','w','c','y','U','M','V','E','2','Y','P','F','h','9', - 'T','y','h','w','b','9','P','w','G','c','W','W','k','j','J','Q','N','B','U','G','6','9','U','b','v','a','N','9','N','C','G','n', - 'x','R','6','9','Q','C','h','e','j','P','U','h','U','R','i','4','T','B','W','5','w','m','J','p','e','7','r','9','t','c','9','Z', - 'j','p','r','F','C','e','U','P','x','T','A','N','7','6','a','i','y','e','w','F','C','X','H','Y','G','C','q','q','m','A','t','7', - 'z','u','D','S','L','U','C','f','7','e','t','G','V','F','u','c','x','5','M','7','N','i','M','6','h','2','n','H','S','h','K','M', - 'd','T','z','X','d','x','x','4','q','z','d','D','a','2','X','r','p','r','R','m','U','U','y','S','H','c','a','F','e','Z','a','U', - 'P','9','V','J','e','q','j','Y','M','x','e','v','K','7','M','P','N','2','b','6','f','P','h','H','4','U','X','k','n','f','Q','M', - '9','9','a','J','N','e','w','y','f','F','P','p','a','F','Y','a','M','L','W','i','T','M','B','3','U','v','X','v','G','p','7','a', - 'f','u','4','S','y','X','9','g','g','b','B','G','c','i','M','U','n','m','a','7','q','f','9','n','Q','2','V','L','6','e','T','R', - '2','4','9','d','6','Q','B','Y','q','2','4','9','G','Q','E','b','Y','5','u','2','T','Q','G','L','5','n','4','Y','2','y','G','F', - 'j','c','8','M','G','L','e','3','a','N','v','A','A','W','t','R','S','2','i','D','R','8','j','d','Q','3','6','C','V','M','e','w', - 'j','U','Z','w','M','4','b','m','8','J','P','Q','L','P','R','c','r','b','V','C','3','N','8','K','4','d','W','D','N','U','A','A', - '2','J','p','b','D','d','p','j','N','C','k','A','j','B','a','c','u','v','L','X','U','B','4','U','X','W','e','C','b','C','u','d', - 'A','v','U','z','P','t','D','e','5','y','Y','c','x','K','4','7','j','e','e','D','M','5','K','B','Q','6','d','p','T','T','R','j', - 'M','E','E','M','r','N','6','8','7','q','x','F','S','x','E','U','4','d','B','6','5','W','C','e','m','J','e','5','j','w','V','J', - 'w','v','d','7','v','f','K','u','m','8','h','W','T','e','Q','j','M','8','R','Y','d','B','R','2','r','F','j','7','d','E','q','V', - 'k','e','j','P','9','3','X','R','p','R','b','A','v','7','4','A','M','2','k','r','E','7','X','3','7','k','5','c','B','7','W','5', - 'u','J','B','Q','R','2','V','7','h','Q','h','9','g','G','y','c','c','x','M','z','7','G','2','J','w','v','j','5','9','E','b','k', - 'z','W','T','C','b','4','K','R','X','T','k','V','S','G','2','j','d','6','y','E','4','P','H','K','w','a','m','F','Z','x','9','j', - 'i','2','d','X','u','a','4','a','M','z','8','p','p','z','g','t','H','5','Y','L','Q','c','R','F','m','E','n','G','X','d','f','7', - 'x','8','j','g','J','z','D','S','a','S','h','y','5','h','Y','N','p','w','Y','W','h','E','N','v','8','Q','D','W','Z','k','f','e', - 'r','Z','D','7','R','D','T','2','H','X','z','G','X','f','v','E','z','P','v','U','H','e','4','R','W','U','x','t','t','4','w','p', - 'r','z','K','9','f','g','h','P','r','f','v','k','h','c','e','5','8','a','L','F','J','M','G','R','a','N','q','S','g','W','e','7', - 'R','K','R','A','B','z','6','v','S','p','w','n','e','x','k','E','r','j','f','Y','x','8','9','z','e','T','6','E','G','v','9','f', - 'D','A','N','v','y','U','7','D','M','2','E','5','W','G','6','b','9','q','g','Y','F','f','k','q','Q','E','x','Y','C','R','G','6', - 'R','h','4','J','d','U','D','b','9','b','8','r','f','V','d','g','b','2','z','Z','d','m','X','v','j','Y','d','w','K','8','G','r', - 'v','j','N','y','c','h','u','5','z','g','J','H','a','Z','b','z','G','C','r','P','f','y','P','6','F','P','h','7','9','w','7','y', - 'R','3','n','E','h','G','D','4','m','Y','E','q','k','a','f','a','R','B','q','t','W','E','T','p','H','7','k','X','2','d','X','6', - 'W','n','H','m','w','M','i','Y','M','E','F','5','R','p','p','y','c','b','q','R','9','Y','t','T','7','w','u','K','M','Q','z','n', - 'P','7','g','x','6','R','4','x','N','v','w','M','6','j','K','v','7','a','Y','4','a','M','6','n','z','3','E','2','V','N','4','i', - 'E','f','u','W','J','W','e','8','3','Q','e','a','F','P','c','3','P','k','i','z','d','q','m','q','M','a','d','8','D','3','F','M', - 'e','d','E','j','z','V','e','d','z','H','D','J','8','X','g','E','i','u','c','7','A','w','S','J','2','A','e','8','r','q','C','m', - '9','9','a','g','2','y','y','P','M','e','8','3','T','r','m','8','j','v','r','p','M','Z','Y','g','a','9','2','d','H','B','m','9', - '4','6','a','Z','V','u','S','H','g','3','X','h','i','N','3','B','S','E','k','9','k','2','9','R','A','i','3','L','X','M','B','S', - '4','S','F','F','F','w','u','d','M','T','9','K','B','7','R','U','R','8','D','8','T','5','U','t','E','R','x','n','x','h','v','k', - 'B','N','k','E','U','T','t','p','r','u','Z','h','t','E','4','i','P','z','f','z','q','M','p','f','A','K','2','D','t','j','f','c', - 'Y','E','N','M','x','k','g','7','T','U','2','c','d','V','g','2','z','L','i','j','Y','q','b','T','A','y','v','a','t','N','5','t', - 'Z','5','n','D','a','y','G','n','P','x','V','k','M','8','t','J','Z','G','g','5','9','R','h','P','P','J','N','X','p','G','J','p', - '2','y','A','v','d','G','U','z','3','V','M','y','q','U','N','M','Y','p','B','Z','U','h','j','q','z','q','x','w','7','d','J','Q', - 'u','F','q','3','m','9','c','Q','W','d','6','7','b','V','M','7','P','j','r','k','9','h','R','z','m','b','i','B','u','E','L','9', - 'k','v','h','h','W','2','K','e','M','U','Q','p','A','Q','Y','J','G','E','T','U','L','f','q','G','4','z','K','K','y','a','U','W', - 'K','D','P','c','N','D','V','S','Y','6','T','p','R','y','y','J','a','T','J','W','Q','9','p','F','P','X','y','k','9','z','z','4', - 'G','d','a','z','X','n','h','4','J','P','W','V','D','r','U','m','a','8','a','b','X','F','J','X','L','4','S','X','5','W','p','W', - 'h','y','x','B','f','d','C','X','w','7','r','g','V','T','H','a','i','4','N','v','c','w','n','2','3','A','i','A','J','9','N','c', - 'z','7','n','n','3','n','h','n','i','R','i','b','E','h','k','U','c','c','U','6','f','x','q','N','y','H','M','e','J','B','U','B', - 'r','g','a','8','V','a','G','V','y','u','c','c','v','C','H','W','y','g','z','Q','2','4','k','S','m','f','e','G','H','v','Q','3', - 'P','e','f','S','V','P','c','U','e','3','P','x','d','c','7','c','f','g','D','w','2','t','q','y','g','2','Q','V','4','K','a','Q', - 'g','B','b','L','x','9','m','a','K','4','i','x','g','Q','M','9','W','N','2','w','p','v','2','k','B','y','9','k','A','c','f','Z', - 'D','R','A','S','d','v','w','f','f','q','t','K','3','j','x','D','G','P','n','u','r','v','U','k','A','2','d','R','N','T','G','4', - 'B','g','k','t','h','7','J','k','F','A','C','g','W','g','J','F','z','S','Q','c','v','M','b','D','e','H','Q','S','j','v','G','E', - 'R','k','f','i','P','E','F','N','6','y','p','b','t','M','c','Q','B','7','g','w','J','7','3','d','V','E','m','z','6','6','P','P', - 'd','i','r','J','H','D','H','J','r','b','n','v','z','W','e','u','g','B','u','Z','2','m','D','5','h','F','X','B','2','r','6','w', - 'u','Y','4','N','X','K','a','v','V','3','j','B','r','r','C','c','w','R','g','S','8','V','b','F','2','N','M','c','K','8','Y','E', - 'E','N','K','X','K','V','B','x','n','Q','p','a','q','f','k','t','z','Y','E','P','Z','y','n','a','c','B','V','a','x','b','d','X', - 'r','d','8','P','H','F','v','r','V','5','g','J','w','6','i','h','d','d','p','J','c','c','Y','S','q','W','m','U','5','G','b','H', - 'N','z','E','Z','K','E','y','M','c','G','i','d','w','Z','D','N','N','w','S','t','g','y','a','Y','b','H','e','M','N','f','Y','Y', - '7','a','9','b','M','U','k','a','V','k','C','n','a','k','U','H','A','M','i','v','k','t','a','d','i','3','F','d','5','2','A','p', - 'U','c','J','U','R','h','G','d','A','Y','v','q','X','c','w','r','x','4','j','3','4','b','F','d','a','L','N','J','3','Z','g','6', - 'W','Q','R','u','P','t','M','A','3','F','6','y','K','Y','G','2','t','v','u','p','w','b','G','S','K','5','p','4','d','E','w','6', - 'g','t','V','4','b','2','n','b','Z','3','3','f','m','d','2','c','a','m','j','X','U','E','D','6','6','F','w','H','9','7','Z','Y', - 'd','X','C','K','i','g','p','F','Y','n','2','b','F','4','R','u','V','k','f','d','J','i','a','b','X','H','7','v','K','a','Q','i', - 'W','M','j','M','i','a','i','n','F','h','r','q','4','w','x','m','4','q','y','F','8','w','i','4','D','B','A','L','B','U','u','K', - 'v','K','n','a','Q','i','e','k','v','Q','U','5','w','Q','c','r','A','6','M','w','y','g','n','e','v','K','7','W','u','2','y','f', - 'Q','u','e','r','y','a','w','V','p','f','Q','z','C','u','i','i','9','S','P','q','L','r','C','H','S','3','E','p','8','S','m','Q', - 'S','K','r','V','b','J','R','m','w','c','n','Q','N','Q','4','M','u','f','X','S','f','U','Z','x','U','4','j','K','4','G','z','X', - '7','Q','j','R','h','i','G','m','q','c','V','T','x','U','a','E','b','Q','q','E','i','F','K','7','K','i','R','J','5','Y','F','V', - 'B','7','R','8','M','i','f','j','Z','w','j','b','B','u','p','N','Y','r','S','r','f','h','E','J','T','B','P','R','D','V','K','A', - 'Z','A','R','j','z','f','B','i','Y','L','F','G','V','Y','w','R','C','P','G','m','9','7','C','5','e','y','w','N','K','N','a','Q', - 'j','a','W','3','2','f','G','w','n','M','6','F','u','K','8','g','8','M','G','r','e','9','Z','z','y','2','G','U','k','G','6','m', - 'A','D','4','n','b','8','a','q','S','m','S','6','5','R','5','D','5','S','B','g','X','T','8','Q','V','d','A','n','g','y','8','a', - 'h','7','K','9','H','D','J','F','w','G','4','w','T','J','F','f','i','8','X','e','B','J','K','H','7','V','y','X','7','E','8','S', - 'A','d','b','w','S','8','Y','a','J','d','j','E','V','J','T','E','U','R','5','7','V','M','E','v','D','3','z','5','r','k','z','v', - 'e','m','A','7','P','8','j','X','E','f','Q','q','8','D','g','y','8','j','A','e','B','c','c','M','z','k','2','c','q','v','v','y', - 'Q','y','h','g','p','v','M','m','m','C','G','D','k','8','u','T','n','Q','H','G','H','f','b','J','j','5','X','c','i','7','7','q', - 'b','R','8','b','b','z','f','f','h','Y','Q','7','u','B','X','e','i','j','M','q','C','T','M','v','t','J','J','w','b','F','v','J', - 'm','e','2','u','e','8','L','V','G','q','A','j','m','7','m','g','m','5','i','r','p','p','U','y','F','6','f','b','u','6','q','L', - 'M','E','t','V','W','C','t','e','p','w','a','n','w','y','X','h','8','e','G','C','H','q','r','X','G','9','c','h','7','k','8','M', - 'G','b','a','m','Y','Q','w','8','J','z','a','F','r','4','W','M','j','P','q','a','z','U','y','u','3','b','Z','f','Y','5','7','g', - 'N','M','h','M','a','3','C','K','6','6','f','a','p','i','f','q','k','T','i','z','w','f','Z','c','H','L','X','g','6','m','g','r', - 'w','Y','u','K','8','L','p','8','P','R','A','R','A','b','Z','V','a','x','V','c','G','A','H','t','Y','6','P','T','L','W','N','z', - 'g','z','k','d','E','v','C','t','Z','M','Z','K','4','w','9','5','D','W','f','U','8','5','u','6','b','5','B','8','g','y','C','E', - 'Q','z','e','9','p','N','S','P','D','D','f','x','k','Z','4','R','v','X','V','k','p','b','n','t','c','F','R','e','x','9','C','D', - 'J','2','6','f','Z','D','w','J','R','j','j','9','b','w','N','N','p','R','f','Z','z','j','F','r','Q','e','F','x','f','t','V','V', - 'A','y','J','G','W','Z','H','r','D','5','M','u','H','V','L','N','U','V','X','z','j','9','r','v','e','d','R','c','u','V','x','r', - 'c','6','k','L','h','q','w','U','W','Q','g','G','F','C','t','E','a','D','h','x','9','5','P','R','Z','E','M','5','f','4','2','t', - 'A','6','f','r','X','G','X','Y','B','8','G','E','n','B','v','x','f','M','R','f','B','z','Y','3','2','q','z','G','t','P','C','6', - '6','r','z','J','r','c','n','d','6','h','e','w','D','D','h','V','L','u','i','b','5','K','d','S','y','9','N','p','E','r','D','k', - 'B','z','u','v','d','Q','p','K','5','m','J','r','b','Y','Z','7','p','M','J','F','E','q','x','f','E','K','U','U','4','f','a','6', - 'g','5','a','q','D','U','8','F','y','R','a','P','5','5','x','z','6','V','T','P','D','m','y','7','U','5','C','A','7','Q','h','w', - 'r','6','x','g','Q','i','b','K','F','p','B','X','Q','h','i','E','r','C','z','v','x','W','Q','6','p','6','b','M','K','V','x','u', - 'k','d','R','S','k','Q','p','n','h','d','Q','Y','x','n','x','5','K','t','5','w','A','5','p','k','F','z','W','p','j','U','y','V', - 'x','G','m','y','L','A','X','H','G','A','a','J','5','E','P','q','E','U','7','p','6','A','9','n','d','G','D','g','i','h','t','W', - 'b','c','E','2','P','d','y','J','M','u','4','g','P','S','X','J','v','w','3','v','D','q','U','i','U','T','q','E','Y','5','2','t', - 'b','j','P','2','j','D','9','y','i','B','5','Y','3','X','L','w','m','V','X','z','X','r','Z','d','H','L','A','H','k','R','X','5', - 'i','L','m','q','3','p','a','G','P','j','g','h','R','P','Y','U','z','M','5','R','M','A','E','Q','V','c','w','r','4','M','S','k', - 'N','D','i','R','R','x','t','q','T','i','u','N','K','R','x','Z','K','a','g','G','y','9','c','j','J','S','9','3','H','T','f','F', - 'q','6','D','W','F','K','h','e','p','p','b','q','N','k','A','C','m','y','u','B','J','v','q','D','e','j','e','b','2','w','R','t', - 'J','N','j','F','T','A','8','L','m','X','i','T','g','j','c','V','4','V','h','2','h','R','p','2','9','k','c','c','G','D','h','z', - 't','i','h','t','W','R','n','Y','i','8','u','6','G','9','T','P','9','9','J','P','Y','R','h','X','K','z','h','L','W','r','C','U', - '2','L','T','k','2','m','6','W','L','P','T','Z','z','t','i','H','5','G','w','t','E','v','z','k','b','H','b','b','W','W','u','b', - 'i','h','C','Q','n','H','N','u','5','u','K','X','r','M','W','U','3','Y','k','P','2','k','x','f','x','C','w','z','z','b','G','8', - 'y','W','e','j','v','2','v','r','t','q','z','p','Y','d','w','6','Z','D','J','L','9','F','z','G','U','4','a','8','H','6','U','a', - 'q','7','y','Q','J','v','m','D','P','S','j','q','v','t','n','t','g','j','3','t','8','f','K','K','7','b','W','d','F','i','N','K', - 'a','R','V','V','V','v','m','A','Q','2','y','j','c','t','f','k','j','7','X','y','j','b','U','F','w','W','3','9','6','A','S','J', - 'p','q','2','Z','7','L','p','b','7','b','5','i','p','r','r','h','P','M','h','j','c','y','e','u','h','B','d','9','9','u','f','d', - 'g','u','p','w','u','9','S','c','L','U','g','A','y','V','F','V','6','D','D','X','i','V','m','u','Y','P','J','v','L','T','A','F', - 'M','Q','H','Z','6','v','8','p','A','L','P','z','C','V','a','C','h','X','j','W','8','G','z','j','d','M','4','u','x','w','H','g', - 'V','q','K','z','b','g','2','3','D','N','y','G','X','F','T','v','T','L','y','v','L','9','g','c','C','R','8','L','A','7','Y','N', - 't','n','R','6','b','n','m','9','i','h','t','T','F','a','V','N','J','J','3','J','q','p','W','7','b','T','G','r','M','k','a','7', - 'D','H','v','y','T','A','C','U','P','u','q','L','R','Y','4','q','h','y','f','F','J','x','K','7','N','B','v','3','a','Z','M','t', - 'U','x','8','9','V','E','t','j','K','r','u','Y','Y','A','u','w','Y','2','y','Q','z','S','n','J','B','2','t','X','x','K','z','g', - '6','d','n','i','7','Z','N','F','Q','6','w','N','r','b','k','d','W','X','S','t','c','U','m','6','4','2','e','w','6','x','Z','a', - 'Q','A','7','4','h','H','z','r','e','J','q','j','w','4','q','c','i','R','4','x','n','r','j','r','P','g','E','7','t','k','b','Z', - 'r','A','b','d','g','i','G','V','D','E','U','L','b','J','U','q','2','S','K','m','A','U','L','k','Q','4','N','p','k','G','C','6', - 'R','Z','B','y','B','B','j','y','x','L','d','h','L','G','6','x','H','z','T','5','d','Y','4','2','m','q','Q','y','H','6','c','N', - 'u','m','U','v','i','Y','Z','7','4','L','K','F','b','v','2','Y','h','x','8','a','R','w','q','x','E','a','T','y','m','C','2','Q', - 'U','T','D','Q','v','u','M','9','D','8','r','8','b','m','p','E','7','C','T','9','B','A','G','k','b','G','z','Z','G','L','N','k', - 'h','3','k','J','e','f','d','x','F','8','W','K','7','T','6','h','H','V','C','h','P','u','H','e','v','w','z','P','K','r','D','G', - 'X','Z','B','X','f','H','Q','4','e','D','y','W','Z','6','4','K','A','e','a','F','S','N','h','x','S','W','J','c','E','P','g','j', - 'a','w','T','m','Z','X','E','P','Y','R','M','2','R','2','X','N','F','X','Y','W','x','z','p','J','g','n','D','4','i','p','6','N', - 'r','9','G','k','E','h','T','h','U','h','x','B','Q','9','H','7','w','U','P','Q','d','G','6','q','p','j','j','v','C','a','X','J', - 'N','G','Y','w','f','H','C','x','F','k','z','3','9','r','h','8','7','5','V','i','V','C','R','q','x','N','2','2','i','W','F','U', - '7','T','H','f','z','E','a','n','u','Q','t','U','Y','G','t','3','A','m','r','6','d','f','e','n','e','z','F','u','U','N','8','m', - 'h','p','R','N','S','H','6','6','V','M','S','t','q','P','E','i','u','y','g','8','L','Q','Y','Y','G','e','W','W','C','G','y','b', - 'y','t','u','P','R','P','5','m','N','K','B','Z','w','f','t','k','x','3','L','b','q','d','w','S','G','E','h','R','F','4','q','e', - '5','6','F','2','n','q','T','R','y','f','n','Y','h','2','F','u','x','M','i','i','h','w','G','C','Z','v','i','C','a','X','U','C', - 'Y','8','d','h','R','x','V','n','v','G','i','D','a','U','p','U','a','e','b','F','w','P','d','X','n','K','h','9','H','r','b','g', - '2','f','m','X','k','m','q','6','n','5','b','G','H','d','R','9','D','U','c','r','Z','Y','W','S','Z','x','p','t','x','y','4','k', - 'j','F','U','t','C','i','e','i','b','p','e','4','C','z','h','3','3','5','Q','P','n','G','i','A','8','c','Q','z','B','a','V','4', - '2','B','2','z','u','u','3','i','L','w','y','g','K','H','k','y','2','B','b','e','5','e','4','e','U','4','z','n','P','z','a','c', - 'E','f','u','M','G','C','g','z','j','4','E','7','R','t','D','K','c','t','p','g','W','H','C','H','J','Q','J','c','F','5','4','W', - 'K','7','j','h','A','T','K','z','t','S','f','f','j','C','c','8','n','7','c','T','U','R','Q','E','7','A','W','Z','z','K','5','j', - '2','H','k','a','j','g','g','W','w','4','T','A','9','J','U','e','S','N','P','K','d','k','L','Q','G','Z','e','W','i','H','u','j', - 'C','z','4','E','2','v','5','L','u','9','Z','a','9','A','b','C','M','G','X','B','C','2','Y','Z','e','U','n','E','5','Y','n','y', - 'F','h','H','p','9','j','Y','F','V','w','Y','r','8','Q','f','C','J','4','T','t','z','Q','N','M','e','7','4','3','y','E','M','m', - 'b','S','c','h','w','a','X','E','d','E','z','t','h','9','k','p','A','k','K','H','x','q','K','Z','B','u','a','9','3','U','U','u', - '8','E','D','v','y','k','W','Y','X','k','r','R','D','X','n','Q','V','d','e','D','g','x','E','V','Y','w','k','m','K','r','H','D', - 't','2','6','N','U','g','3','t','B','9','t','u','M','D','z','Y','K','z','K','r','V','5','i','e','p','M','d','t','w','6','a','f', - 'f','W','k','L','i','g','M','V','M','Y','b','x','e','4','h','h','Y','g','w','Z','m','e','e','6','R','W','M','x','G','y','V','n', - '6','e','g','A','g','K','a','N','7','p','a','u','E','4','6','M','t','X','h','g','b','j','p','5','x','x','B','P','3','J','M','7', - 'j','Z','P','y','e','Q','Z','e','t','j','3','t','F','V','x','m','b','b','B','y','J','L','L','9','3','R','a','5','j','S','V','t', - 'e','2','6','m','H','w','r','w','r','6','Q','3','x','z','m','A','d','x','t','E','H','c','Z','x','c','P','j','r','u','U','W','k', - '6','g','X','g','n','f','n','7','H','M','B','t','v','6','v','x','g','M','f','e','2','w','m','y','d','H','S','q','c','K','U','H', - '2','X','h','d','p','Q','7','J','X','i','X','f','a','z','V','A','F','2','8','z','v','h','C','h','e','4','g','z','w','z','h','q', - 'p','6','B','n','m','8','h','W','U','7','z','h','T','6','J','f','4','Z','n','Q','W','z','2','N','4','t','g','7','u','4','X','2', - 'C','F','L','n','J','n','m','j','3','P','3','Y','e','J','R','A','H','e','R','D','z','7','u','X','Y','y','D','w','J','m','G','U', - 'P','H','5','S','d','a','F','F','Y','c','M','f','3','3','L','v','V','B','U','C','A','d','N','H','Q','h','7','8','4','r','p','G', - 'v','M','D','H','7','e','E','r','i','K','Q','i','B','D','M','Z','p','c','R','G','u','c','H','a','N','k','E','f','9','R','7','x', - '6','3','5','u','x','3','h','v','p','6','q','r','j','u','f','W','T','q','P','n','Y','L','B','6','U','w','P','2','T','W','R','g', - '2','3','3','e','N','V','a','j','b','e','4','T','u','J','u','u','F','B','D','G','H','x','x','k','5','G','e','3','4','B','m','L', - 'S','b','i','t','T','p','M','D','Z','A','A','i','r','J','p','4','H','U','A','G','y','d','Q','5','U','R','F','8','q','a','S','H', - 'n','5','z','9','g','3','u','R','H','m','G','m','b','p','c','L','Z','Y','u','m','i','K','A','Q','R','T','X','G','t','b','8','7', - '7','6','w','M','N','f','R','G','r','L','m','q','n','7','5','k','X','8','g','u','K','7','Y','w','K','q','U','e','W','A','r','i', - 'Z','a','p','q','L','5','P','u','n','t','y','G','x','C','N','X','q','P','r','U','v','A','r','r','q','e','f','c','z','M','7','N', - '6','a','z','Z','a','t','f','p','4','v','J','Y','j','h','M','D','t','k','A','B','p','Q','A','y','x','X','7','p','S','8','m','M', - 'y','K','B','A','5','2','7','b','y','R','K','q','A','u','3','J'}; - -static const adler32_test tests[] = { - {__LINE__, 0x1, (const uint8_t *)0x0, 0, 0x1}, - {__LINE__, 0x1, (const uint8_t *)"", 1, 0x10001}, - {__LINE__, 0x1, (const uint8_t *)"a", 1, 0x620062}, - {__LINE__, 0x1, (const uint8_t *)"abacus", 6, 0x8400270}, - {__LINE__, 0x1, (const uint8_t *)"backlog", 7, 0xb1f02d4}, - {__LINE__, 0x1, (const uint8_t *)"campfire", 8, 0xea10348}, - {__LINE__, 0x1, (const uint8_t *)"delta", 5, 0x61a020b}, - {__LINE__, 0x1, (const uint8_t *)"executable", 10, 0x16fa0423}, - {__LINE__, 0x1, (const uint8_t *)"file", 4, 0x41401a1}, - {__LINE__, 0x1, (const uint8_t *)"greatest", 8, 0xefa0360}, - {__LINE__, 0x1, (const uint8_t *)"inverter", 8, 0xf6f0370}, - {__LINE__, 0x1, (const uint8_t *)"jigsaw", 6, 0x8bd0286}, - {__LINE__, 0x1, (const uint8_t *)"karate", 6, 0x8a50279}, - {__LINE__, 0x1, (const uint8_t *)"landscape", 9, 0x126a03ac}, - {__LINE__, 0x1, (const uint8_t *)"machine", 7, 0xb5302d6}, - {__LINE__, 0x1, (const uint8_t *)"nanometer", 9, 0x12d803ca}, - {__LINE__, 0x1, (const uint8_t *)"oblivion", 8, 0xf220363}, - {__LINE__, 0x1, (const uint8_t *)"panama", 6, 0x8a1026f}, - {__LINE__, 0x1, (const uint8_t *)"quest", 5, 0x6970233}, - {__LINE__, 0x1, (const uint8_t *)"resource", 8, 0xf8d0369}, - {__LINE__, 0x1, (const uint8_t *)"secret", 6, 0x8d10287}, - {__LINE__, 0x1, (const uint8_t *)"ultimate", 8, 0xf8d0366}, - {__LINE__, 0x1, (const uint8_t *)"vector", 6, 0x8fb0294}, - {__LINE__, 0x1, (const uint8_t *)"walrus", 6, 0x918029f}, - {__LINE__, 0x1, (const uint8_t *)"xeno", 4, 0x45e01bb}, - {__LINE__, 0x1, (const uint8_t *)"yelling", 7, 0xbfe02f5}, - {__LINE__, 0x1, (const uint8_t *)"zero", 4, 0x46e01c1}, - {__LINE__, 0x1, (const uint8_t *)"4BJD7PocN1VqX0jXVpWB", 20, 0x3eef064d}, - {__LINE__, 0x1, (const uint8_t *)"F1rPWI7XvDs6nAIRx41l", 20, 0x425d065f}, - {__LINE__, 0x1, (const uint8_t *)"ldhKlsVkPFOveXgkGtC2", 20, 0x4f1a073e}, - {__LINE__, 0x1, (const uint8_t *)"5KKnGOOrs8BvJ35iKTOS", 20, 0x42290650}, - {__LINE__, 0x1, (const uint8_t *)"0l1tw7GOcem06Ddu7yn4", 20, 0x43fd0690}, - {__LINE__, 0x1, (const uint8_t *)"MCr47CjPIn9R1IvE1Tm5", 20, 0x3f770609}, - {__LINE__, 0x1, (const uint8_t *)"UcixbzPKTIv0SvILHVdO", 20, 0x4c7c0703}, - {__LINE__, 0x1, (const uint8_t *)"dGnAyAhRQDsWw0ESou24", 20, 0x48ac06b7}, - {__LINE__, 0x1, (const uint8_t *)"di0nvmY9UYMYDh0r45XT", 20, 0x489a0698}, - {__LINE__, 0x1, (const uint8_t *)"2XKDwHfAhFsV0RhbqtvH", 20, 0x44a906e6}, - {__LINE__, 0x1, (const uint8_t *)"ZhrANFIiIvRnqClIVyeD", 20, 0x4a29071c}, - {__LINE__, 0x1, (const uint8_t *)"v7Q9ehzioTOVeDIZioT1", 20, 0x4a7706f9}, - {__LINE__, 0x1, (const uint8_t *)"Yod5hEeKcYqyhfXbhxj2", 20, 0x4ce60769}, - {__LINE__, 0x1, (const uint8_t *)"GehSWY2ay4uUKhehXYb0", 20, 0x48ae06e5}, - {__LINE__, 0x1, (const uint8_t *)"kwytJmq6UqpflV8Y8GoE", 20, 0x51d60750}, - {__LINE__, 0x1, (const uint8_t *)"70684206568419061514", 20, 0x2b100414}, - {__LINE__, 0x1, (const uint8_t *)"42015093765128581010", 20, 0x2a550405}, - {__LINE__, 0x1, (const uint8_t *)"88214814356148806939", 20, 0x2b450423}, - {__LINE__, 0x1, (const uint8_t *)"43472694284527343838", 20, 0x2b460421}, - {__LINE__, 0x1, (const uint8_t *)"49769333513942933689", 20, 0x2bc1042b}, - {__LINE__, 0x1, (const uint8_t *)"54979784887993251199", 20, 0x2ccd043d}, - {__LINE__, 0x1, (const uint8_t *)"58360544869206793220", 20, 0x2b68041a}, - {__LINE__, 0x1, (const uint8_t *)"27347953487840714234", 20, 0x2b84041d}, - {__LINE__, 0x1, (const uint8_t *)"07650690295365319082", 20, 0x2afa0417}, - {__LINE__, 0x1, (const uint8_t *)"42655507906821911703", 20, 0x2aff0412}, - {__LINE__, 0x1, (const uint8_t *)"29977409200786225655", 20, 0x2b8d0420}, - {__LINE__, 0x1, (const uint8_t *)"85181542907229116674", 20, 0x2b140419}, - {__LINE__, 0x1, (const uint8_t *)"87963594337989416799", 20, 0x2c8e043f}, - {__LINE__, 0x1, (const uint8_t *)"21395988329504168551", 20, 0x2b68041f}, - {__LINE__, 0x1, (const uint8_t *)"51991013580943379423", 20, 0x2af10417}, - {__LINE__, 0x1, (const uint8_t *)"*]+@!);({_$;}[_},?{?;(_?,=-][@", 30, 0x7c9d0841}, - {__LINE__, 0x1, (const uint8_t *)"_@:_).&(#.[:[{[:)$++-($_;@[)}+", 30, 0x71060751}, - {__LINE__, 0x1, (const uint8_t *)"&[!,[$_==}+.]@!;*(+},[;:)$;)-@", 30, 0x7095070a}, - {__LINE__, 0x1, (const uint8_t *)"]{.[.+?+[[=;[?}_#&;[=)__$$:+=_", 30, 0x82530815}, - {__LINE__, 0x1, (const uint8_t *)"-%.)=/[@].:.(:,()$;=%@-$?]{%+%", 30, 0x61250661}, - {__LINE__, 0x1, (const uint8_t *)"+]#$(@&.=:,*];/.!]%/{:){:@(;)$", 30, 0x642006a3}, - {__LINE__, 0x1, (const uint8_t *)")-._.:?[&:.=+}(*$/=!.${;(=$@!}", 30, 0x674206cb}, - {__LINE__, 0x1, (const uint8_t *)":(_*&%/[[}+,?#$&*+#[([*-/#;%(]", 30, 0x67670680}, - {__LINE__, 0x1, (const uint8_t *)"{[#-;:$/{)(+[}#]/{&!%(@)%:@-$:", 30, 0x7547070f}, - {__LINE__, 0x1, (const uint8_t *)"_{$*,}(&,@.)):=!/%(&(,,-?$}}}!", 30, 0x69ea06ee}, - {__LINE__, 0x1, (const uint8_t *)"e$98KNzqaV)Y:2X?]77].{gKRD4G5{mHZk,Z)SpU%L3FSgv!Wb8MLAFdi{+fp)c,@8m6v)yXg@]HBDFk?.4&}g5_udE*JHCiH=aL", 100, 0x1b01e92}, - {__LINE__, 0x1, (const uint8_t *)"r*Fd}ef+5RJQ;+W=4jTR9)R*p!B;]Ed7tkrLi;88U7g@3v!5pk2X6D)vt,.@N8c]@yyEcKi[vwUu@.Ppm@C6%Mv*3Nw}Y,58_aH)", 100, 0xfbdb1e96}, - {__LINE__, 0x1, (const uint8_t *)"h{bcmdC+a;t+Cf{6Y_dFq-{X4Yu&7uNfVDh?q&_u.UWJU],-GiH7ADzb7-V.Q%4=+v!$L9W+T=bP]$_:]Vyg}A.ygD.r;h-D]m%&", 100, 0x47a61ec8}, - {__LINE__, 0x1, (const uint8_t *)long_string, 5552, 0x8b81718f}, - {__LINE__, 0x7a30360d, (const uint8_t *)0x0, 0, 0x1}, - {__LINE__, 0x6fd767ee, (const uint8_t *)"", 1, 0xd7c567ee}, - {__LINE__, 0xefeb7589, (const uint8_t *)"a", 1, 0x65e475ea}, - {__LINE__, 0x61cf7e6b, (const uint8_t *)"abacus", 6, 0x60b880da}, - {__LINE__, 0xdc712e2, (const uint8_t *)"backlog", 7, 0x9d0d15b5}, - {__LINE__, 0xad23c7fd, (const uint8_t *)"campfire", 8, 0xfbfecb44}, - {__LINE__, 0x85cb2317, (const uint8_t *)"delta", 5, 0x3b622521}, - {__LINE__, 0x9eed31b0, (const uint8_t *)"executable", 10, 0xa6db35d2}, - {__LINE__, 0xb94f34ca, (const uint8_t *)"file", 4, 0x9096366a}, - {__LINE__, 0xab058a2, (const uint8_t *)"greatest", 8, 0xded05c01}, - {__LINE__, 0x5bff2b7a, (const uint8_t *)"inverter", 8, 0xc7452ee9}, - {__LINE__, 0x605c9a5f, (const uint8_t *)"jigsaw", 6, 0x7899ce4}, - {__LINE__, 0x51bdeea5, (const uint8_t *)"karate", 6, 0xf285f11d}, - {__LINE__, 0x85c21c79, (const uint8_t *)"landscape", 9, 0x98732024}, - {__LINE__, 0x97216f56, (const uint8_t *)"machine", 7, 0xadf4722b}, - {__LINE__, 0x18444af2, (const uint8_t *)"nanometer", 9, 0xcdb34ebb}, - {__LINE__, 0xbe6ce359, (const uint8_t *)"oblivion", 8, 0xe8b7e6bb}, - {__LINE__, 0x843071f1, (const uint8_t *)"panama", 6, 0x389e745f}, - {__LINE__, 0xf2480c60, (const uint8_t *)"quest", 5, 0x36c90e92}, - {__LINE__, 0x2d2feb3d, (const uint8_t *)"resource", 8, 0x9705eea5}, - {__LINE__, 0x7490310a, (const uint8_t *)"secret", 6, 0xa3a63390}, - {__LINE__, 0x97d247d4, (const uint8_t *)"ultimate", 8, 0xe6154b39}, - {__LINE__, 0x93cf7599, (const uint8_t *)"vector", 6, 0x5e87782c}, - {__LINE__, 0x73c84278, (const uint8_t *)"walrus", 6, 0xbc84516}, - {__LINE__, 0x228a87d1, (const uint8_t *)"xeno", 4, 0x4646898b}, - {__LINE__, 0xa7a048d0, (const uint8_t *)"yelling", 7, 0xb1654bc4}, - {__LINE__, 0x1f0ded40, (const uint8_t *)"zero", 4, 0xd8a4ef00}, - {__LINE__, 0xa804a62f, (const uint8_t *)"4BJD7PocN1VqX0jXVpWB", 20, 0xe34eac7b}, - {__LINE__, 0x508fae6a, (const uint8_t *)"F1rPWI7XvDs6nAIRx41l", 20, 0x33f2b4c8}, - {__LINE__, 0xe5adaf4f, (const uint8_t *)"ldhKlsVkPFOveXgkGtC2", 20, 0xe7b1b68c}, - {__LINE__, 0x67136a40, (const uint8_t *)"5KKnGOOrs8BvJ35iKTOS", 20, 0xf6a0708f}, - {__LINE__, 0xb00c4a10, (const uint8_t *)"0l1tw7GOcem06Ddu7yn4", 20, 0xbd8f509f}, - {__LINE__, 0x2e0c84b5, (const uint8_t *)"MCr47CjPIn9R1IvE1Tm5", 20, 0xcc298abd}, - {__LINE__, 0x81238d44, (const uint8_t *)"UcixbzPKTIv0SvILHVdO", 20, 0xd7809446}, - {__LINE__, 0xf853aa92, (const uint8_t *)"dGnAyAhRQDsWw0ESou24", 20, 0x9525b148}, - {__LINE__, 0x5a692325, (const uint8_t *)"di0nvmY9UYMYDh0r45XT", 20, 0x620029bc}, - {__LINE__, 0x3275b9f, (const uint8_t *)"2XKDwHfAhFsV0RhbqtvH", 20, 0x70916284}, - {__LINE__, 0x38371feb, (const uint8_t *)"ZhrANFIiIvRnqClIVyeD", 20, 0xd52706}, - {__LINE__, 0xafc8bf62, (const uint8_t *)"v7Q9ehzioTOVeDIZioT1", 20, 0xeeb4c65a}, - {__LINE__, 0x9b07db73, (const uint8_t *)"Yod5hEeKcYqyhfXbhxj2", 20, 0xde3e2db}, - {__LINE__, 0xe75b214, (const uint8_t *)"GehSWY2ay4uUKhehXYb0", 20, 0x4171b8f8}, - {__LINE__, 0x72d0fe6f, (const uint8_t *)"kwytJmq6UqpflV8Y8GoE", 20, 0xa66a05cd}, - {__LINE__, 0xf857a4b1, (const uint8_t *)"70684206568419061514", 20, 0x1f9a8c4}, - {__LINE__, 0x54b8e14, (const uint8_t *)"42015093765128581010", 20, 0x49c19218}, - {__LINE__, 0xd6aa5616, (const uint8_t *)"88214814356148806939", 20, 0xbbfc5a38}, - {__LINE__, 0x11e63098, (const uint8_t *)"43472694284527343838", 20, 0x93434b8}, - {__LINE__, 0xbe92385, (const uint8_t *)"49769333513942933689", 20, 0xfe1827af}, - {__LINE__, 0x49511de0, (const uint8_t *)"54979784887993251199", 20, 0xcba8221c}, - {__LINE__, 0x3db13bc1, (const uint8_t *)"58360544869206793220", 20, 0x14643fda}, - {__LINE__, 0xbb899bea, (const uint8_t *)"27347953487840714234", 20, 0x1604a006}, - {__LINE__, 0xf6cd9436, (const uint8_t *)"07650690295365319082", 20, 0xb69f984c}, - {__LINE__, 0x9109e6c3, (const uint8_t *)"42655507906821911703", 20, 0xc43eead4}, - {__LINE__, 0x75770fc, (const uint8_t *)"29977409200786225655", 20, 0x707751b}, - {__LINE__, 0x69b1d19b, (const uint8_t *)"85181542907229116674", 20, 0xf5bdd5b3}, - {__LINE__, 0xc6132975, (const uint8_t *)"87963594337989416799", 20, 0x2fed2db3}, - {__LINE__, 0xd58cb00c, (const uint8_t *)"21395988329504168551", 20, 0xc2a2b42a}, - {__LINE__, 0xb63b8caa, (const uint8_t *)"51991013580943379423", 20, 0xdf0590c0}, - {__LINE__, 0x8a45a2b8, (const uint8_t *)"*]+@!);({_$;}[_},?{?;(_?,=-][@", 30, 0x1980aaf8}, - {__LINE__, 0xcbe95b78, (const uint8_t *)"_@:_).&(#.[:[{[:)$++-($_;@[)}+", 30, 0xf58662c8}, - {__LINE__, 0x4ef8a54b, (const uint8_t *)"&[!,[$_==}+.]@!;*(+},[;:)$;)-@", 30, 0x1f65ac54}, - {__LINE__, 0x76ad267a, (const uint8_t *)"]{.[.+?+[[=;[?}_#&;[=)__$$:+=_", 30, 0x7b792e8e}, - {__LINE__, 0x569e613c, (const uint8_t *)"-%.)=/[@].:.(:,()$;=%@-$?]{%+%", 30, 0x1d61679c}, - {__LINE__, 0x36aa61da, (const uint8_t *)"+]#$(@&.=:,*];/.!]%/{:){:@(;)$", 30, 0x12ec687c}, - {__LINE__, 0xf67222df, (const uint8_t *)")-._.:?[&:.=+}(*$/=!.${;(=$@!}", 30, 0x740329a9}, - {__LINE__, 0x74b34fd3, (const uint8_t *)":(_*&%/[[}+,?#$&*+#[([*-/#;%(]", 30, 0x374c5652}, - {__LINE__, 0x351fd770, (const uint8_t *)"{[#-;:$/{)(+[}#]/{&!%(@)%:@-$:", 30, 0xeadfde7e}, - {__LINE__, 0xc45aef77, (const uint8_t *)"_{$*,}(&,@.)):=!/%(&(,,-?$}}}!", 30, 0x3fcbf664}, - {__LINE__, 0xd034ea71, (const uint8_t *)"e$98KNzqaV)Y:2X?]77].{gKRD4G5{mHZk,Z)SpU%L3FSgv!Wb8MLAFdi{+fp)c,@8m6v)yXg@]HBDFk?.4&}g5_udE*JHCiH=aL", 100, 0x6b080911}, - {__LINE__, 0xdeadc0de, (const uint8_t *)"r*Fd}ef+5RJQ;+W=4jTR9)R*p!B;]Ed7tkrLi;88U7g@3v!5pk2X6D)vt,.@N8c]@yyEcKi[vwUu@.Ppm@C6%Mv*3Nw}Y,58_aH)", 100, 0x355fdf73}, - {__LINE__, 0xba5eba11, (const uint8_t *)"h{bcmdC+a;t+Cf{6Y_dFq-{X4Yu&7uNfVDh?q&_u.UWJU],-GiH7ADzb7-V.Q%4=+v!$L9W+T=bP]$_:]Vyg}A.ygD.r;h-D]m%&", 100, 0xb48bd8d8}, - {__LINE__, 0x7712aa45, (const uint8_t *)long_string, 5552, 0x7dc51be2}, -}; - -static const int test_size = sizeof(tests) / sizeof(tests[0]); - -int main(void) { - int i; - for (i = 0; i < test_size; i++) { - test_adler32(tests[i].adler, tests[i].buf, tests[i].len, tests[i].expect, tests[i].line); - } - - return 0; -} diff --git a/libs/zlibng/test/data/fireworks.jpg b/libs/zlibng/test/data/fireworks.jpg deleted file mode 100644 index 078cf1755..000000000 Binary files a/libs/zlibng/test/data/fireworks.jpg and /dev/null differ diff --git a/libs/zlibng/test/data/lcet10.txt b/libs/zlibng/test/data/lcet10.txt deleted file mode 100644 index 26b187d04..000000000 --- a/libs/zlibng/test/data/lcet10.txt +++ /dev/null @@ -1,7519 +0,0 @@ - - -The Project Gutenberg Etext of LOC WORKSHOP ON ELECTRONIC TEXTS - - - - - WORKSHOP ON ELECTRONIC TEXTS - - PROCEEDINGS - - - - Edited by James Daly - - - - - - - - 9-10 June 1992 - - - Library of Congress - Washington, D.C. - - - - Supported by a Grant from the David and Lucile Packard Foundation - - - *** *** *** ****** *** *** *** - - - TABLE OF CONTENTS - - -Acknowledgements - -Introduction - -Proceedings - Welcome - Prosser Gifford and Carl Fleischhauer - - Session I. Content in a New Form: Who Will Use It and What Will They Do? - James Daly (Moderator) - Avra Michelson, Overview - Susan H. Veccia, User Evaluation - Joanne Freeman, Beyond the Scholar - Discussion - - Session II. Show and Tell - Jacqueline Hess (Moderator) - Elli Mylonas, Perseus Project - Discussion - Eric M. Calaluca, Patrologia Latina Database - Carl Fleischhauer and Ricky Erway, American Memory - Discussion - Dorothy Twohig, The Papers of George Washington - Discussion - Maria L. Lebron, The Online Journal of Current Clinical Trials - Discussion - Lynne K. Personius, Cornell mathematics books - Discussion - - Session III. Distribution, Networks, and Networking: - Options for Dissemination - Robert G. Zich (Moderator) - Clifford A. Lynch - Discussion - Howard Besser - Discussion - Ronald L. Larsen - Edwin B. Brownrigg - Discussion - - Session IV. Image Capture, Text Capture, Overview of Text and - Image Storage Formats - William L. Hooton (Moderator) - A) Principal Methods for Image Capture of Text: - direct scanning, use of microform - Anne R. Kenney - Pamela Q.J. Andre - Judith A. Zidar - Donald J. Waters - Discussion - B) Special Problems: bound volumes, conservation, - reproducing printed halftones - George Thoma - Carl Fleischhauer - Discussion - C) Image Standards and Implications for Preservation - Jean Baronas - Patricia Battin - Discussion - D) Text Conversion: OCR vs. rekeying, standards of accuracy - and use of imperfect texts, service bureaus - Michael Lesk - Ricky Erway - Judith A. Zidar - Discussion - - Session V. Approaches to Preparing Electronic Texts - Susan Hockey (Moderator) - Stuart Weibel - Discussion - C.M. Sperberg-McQueen - Discussion - Eric M. Calaluca - Discussion - - Session VI. Copyright Issues - Marybeth Peters - - Session VII. Conclusion - Prosser Gifford (Moderator) - General discussion - -Appendix I: Program - -Appendix II: Abstracts - -Appendix III: Directory of Participants - - - *** *** *** ****** *** *** *** - - - Acknowledgements - -I would like to thank Carl Fleischhauer and Prosser Gifford for the -opportunity to learn about areas of human activity unknown to me a scant -ten months ago, and the David and Lucile Packard Foundation for -supporting that opportunity. The help given by others is acknowledged on -a separate page. - - 19 October 1992 - - - *** *** *** ****** *** *** *** - - - INTRODUCTION - -The Workshop on Electronic Texts (1) drew together representatives of -various projects and interest groups to compare ideas, beliefs, -experiences, and, in particular, methods of placing and presenting -historical textual materials in computerized form. Most attendees gained -much in insight and outlook from the event. But the assembly did not -form a new nation, or, to put it another way, the diversity of projects -and interests was too great to draw the representatives into a cohesive, -action-oriented body.(2) - -Everyone attending the Workshop shared an interest in preserving and -providing access to historical texts. But within this broad field the -attendees represented a variety of formal, informal, figurative, and -literal groups, with many individuals belonging to more than one. These -groups may be defined roughly according to the following topics or -activities: - -* Imaging -* Searchable coded texts -* National and international computer networks -* CD-ROM production and dissemination -* Methods and technology for converting older paper materials into -electronic form -* Study of the use of digital materials by scholars and others - -This summary is arranged thematically and does not follow the actual -sequence of presentations. - -NOTES: - (1) In this document, the phrase electronic text is used to mean - any computerized reproduction or version of a document, book, - article, or manuscript (including images), and not merely a machine- - readable or machine-searchable text. - - (2) The Workshop was held at the Library of Congress on 9-10 June - 1992, with funding from the David and Lucile Packard Foundation. - The document that follows represents a summary of the presentations - made at the Workshop and was compiled by James DALY. This - introduction was written by DALY and Carl FLEISCHHAUER. - - -PRESERVATION AND IMAGING - -Preservation, as that term is used by archivists,(3) was most explicitly -discussed in the context of imaging. Anne KENNEY and Lynne PERSONIUS -explained how the concept of a faithful copy and the user-friendliness of -the traditional book have guided their project at Cornell University.(4) -Although interested in computerized dissemination, participants in the -Cornell project are creating digital image sets of older books in the -public domain as a source for a fresh paper facsimile or, in a future -phase, microfilm. The books returned to the library shelves are -high-quality and useful replacements on acid-free paper that should last -a long time. To date, the Cornell project has placed little or no -emphasis on creating searchable texts; one would not be surprised to find -that the project participants view such texts as new editions, and thus -not as faithful reproductions. - -In her talk on preservation, Patricia BATTIN struck an ecumenical and -flexible note as she endorsed the creation and dissemination of a variety -of types of digital copies. Do not be too narrow in defining what counts -as a preservation element, BATTIN counseled; for the present, at least, -digital copies made with preservation in mind cannot be as narrowly -standardized as, say, microfilm copies with the same objective. Setting -standards precipitously can inhibit creativity, but delay can result in -chaos, she advised. - -In part, BATTIN's position reflected the unsettled nature of image-format -standards, and attendees could hear echoes of this unsettledness in the -comments of various speakers. For example, Jean BARONAS reviewed the -status of several formal standards moving through committees of experts; -and Clifford LYNCH encouraged the use of a new guideline for transmitting -document images on Internet. Testimony from participants in the National -Agricultural Library's (NAL) Text Digitization Program and LC's American -Memory project highlighted some of the challenges to the actual creation -or interchange of images, including difficulties in converting -preservation microfilm to digital form. Donald WATERS reported on the -progress of a master plan for a project at Yale University to convert -books on microfilm to digital image sets, Project Open Book (POB). - -The Workshop offered rather less of an imaging practicum than planned, -but "how-to" hints emerge at various points, for example, throughout -KENNEY's presentation and in the discussion of arcana such as -thresholding and dithering offered by George THOMA and FLEISCHHAUER. - -NOTES: - (3) Although there is a sense in which any reproductions of - historical materials preserve the human record, specialists in the - field have developed particular guidelines for the creation of - acceptable preservation copies. - - (4) Titles and affiliations of presenters are given at the - beginning of their respective talks and in the Directory of - Participants (Appendix III). - - -THE MACHINE-READABLE TEXT: MARKUP AND USE - -The sections of the Workshop that dealt with machine-readable text tended -to be more concerned with access and use than with preservation, at least -in the narrow technical sense. Michael SPERBERG-McQUEEN made a forceful -presentation on the Text Encoding Initiative's (TEI) implementation of -the Standard Generalized Markup Language (SGML). His ideas were echoed -by Susan HOCKEY, Elli MYLONAS, and Stuart WEIBEL. While the -presentations made by the TEI advocates contained no practicum, their -discussion focused on the value of the finished product, what the -European Community calls reusability, but what may also be termed -durability. They argued that marking up--that is, coding--a text in a -well-conceived way will permit it to be moved from one computer -environment to another, as well as to be used by various users. Two -kinds of markup were distinguished: 1) procedural markup, which -describes the features of a text (e.g., dots on a page), and 2) -descriptive markup, which describes the structure or elements of a -document (e.g., chapters, paragraphs, and front matter). - -The TEI proponents emphasized the importance of texts to scholarship. -They explained how heavily coded (and thus analyzed and annotated) texts -can underlie research, play a role in scholarly communication, and -facilitate classroom teaching. SPERBERG-McQUEEN reminded listeners that -a written or printed item (e.g., a particular edition of a book) is -merely a representation of the abstraction we call a text. To concern -ourselves with faithfully reproducing a printed instance of the text, -SPERBERG-McQUEEN argued, is to concern ourselves with the representation -of a representation ("images as simulacra for the text"). The TEI proponents' -interest in images tends to focus on corollary materials for use in teaching, -for example, photographs of the Acropolis to accompany a Greek text. - -By the end of the Workshop, SPERBERG-McQUEEN confessed to having been -converted to a limited extent to the view that electronic images -constitute a promising alternative to microfilming; indeed, an -alternative probably superior to microfilming. But he was not convinced -that electronic images constitute a serious attempt to represent text in -electronic form. HOCKEY and MYLONAS also conceded that their experience -at the Pierce Symposium the previous week at Georgetown University and -the present conference at the Library of Congress had compelled them to -reevaluate their perspective on the usefulness of text as images. -Attendees could see that the text and image advocates were in -constructive tension, so to say. - -Three nonTEI presentations described approaches to preparing -machine-readable text that are less rigorous and thus less expensive. In -the case of the Papers of George Washington, Dorothy TWOHIG explained -that the digital version will provide a not-quite-perfect rendering of -the transcribed text--some 135,000 documents, available for research -during the decades while the perfect or print version is completed. -Members of the American Memory team and the staff of NAL's Text -Digitization Program (see below) also outlined a middle ground concerning -searchable texts. In the case of American Memory, contractors produce -texts with about 99-percent accuracy that serve as "browse" or -"reference" versions of written or printed originals. End users who need -faithful copies or perfect renditions must refer to accompanying sets of -digital facsimile images or consult copies of the originals in a nearby -library or archive. American Memory staff argued that the high cost of -producing 100-percent accurate copies would prevent LC from offering -access to large parts of its collections. - - -THE MACHINE-READABLE TEXT: METHODS OF CONVERSION - -Although the Workshop did not include a systematic examination of the -methods for converting texts from paper (or from facsimile images) into -machine-readable form, nevertheless, various speakers touched upon this -matter. For example, WEIBEL reported that OCLC has experimented with a -merging of multiple optical character recognition systems that will -reduce errors from an unacceptable rate of 5 characters out of every -l,000 to an unacceptable rate of 2 characters out of every l,000. - -Pamela ANDRE presented an overview of NAL's Text Digitization Program and -Judith ZIDAR discussed the technical details. ZIDAR explained how NAL -purchased hardware and software capable of performing optical character -recognition (OCR) and text conversion and used its own staff to convert -texts. The process, ZIDAR said, required extensive editing and project -staff found themselves considering alternatives, including rekeying -and/or creating abstracts or summaries of texts. NAL reckoned costs at -$7 per page. By way of contrast, Ricky ERWAY explained that American -Memory had decided from the start to contract out conversion to external -service bureaus. The criteria used to select these contractors were cost -and quality of results, as opposed to methods of conversion. ERWAY noted -that historical documents or books often do not lend themselves to OCR. -Bound materials represent a special problem. In her experience, quality -control--inspecting incoming materials, counting errors in samples--posed -the most time-consuming aspect of contracting out conversion. ERWAY -reckoned American Memory's costs at $4 per page, but cautioned that fewer -cost-elements had been included than in NAL's figure. - - -OPTIONS FOR DISSEMINATION - -The topic of dissemination proper emerged at various points during the -Workshop. At the session devoted to national and international computer -networks, LYNCH, Howard BESSER, Ronald LARSEN, and Edwin BROWNRIGG -highlighted the virtues of Internet today and of the network that will -evolve from Internet. Listeners could discern in these narratives a -vision of an information democracy in which millions of citizens freely -find and use what they need. LYNCH noted that a lack of standards -inhibits disseminating multimedia on the network, a topic also discussed -by BESSER. LARSEN addressed the issues of network scalability and -modularity and commented upon the difficulty of anticipating the effects -of growth in orders of magnitude. BROWNRIGG talked about the ability of -packet radio to provide certain links in a network without the need for -wiring. However, the presenters also called attention to the -shortcomings and incongruities of present-day computer networks. For -example: 1) Network use is growing dramatically, but much network -traffic consists of personal communication (E-mail). 2) Large bodies of -information are available, but a user's ability to search across their -entirety is limited. 3) There are significant resources for science and -technology, but few network sources provide content in the humanities. -4) Machine-readable texts are commonplace, but the capability of the -system to deal with images (let alone other media formats) lags behind. -A glimpse of a multimedia future for networks, however, was provided by -Maria LEBRON in her overview of the Online Journal of Current Clinical -Trials (OJCCT), and the process of scholarly publishing on-line. - -The contrasting form of the CD-ROM disk was never systematically -analyzed, but attendees could glean an impression from several of the -show-and-tell presentations. The Perseus and American Memory examples -demonstrated recently published disks, while the descriptions of the -IBYCUS version of the Papers of George Washington and Chadwyck-Healey's -Patrologia Latina Database (PLD) told of disks to come. According to -Eric CALALUCA, PLD's principal focus has been on converting Jacques-Paul -Migne's definitive collection of Latin texts to machine-readable form. -Although everyone could share the network advocates' enthusiasm for an -on-line future, the possibility of rolling up one's sleeves for a session -with a CD-ROM containing both textual materials and a powerful retrieval -engine made the disk seem an appealing vessel indeed. The overall -discussion suggested that the transition from CD-ROM to on-line networked -access may prove far slower and more difficult than has been anticipated. - - -WHO ARE THE USERS AND WHAT DO THEY DO? - -Although concerned with the technicalities of production, the Workshop -never lost sight of the purposes and uses of electronic versions of -textual materials. As noted above, those interested in imaging discussed -the problematical matter of digital preservation, while the TEI proponents -described how machine-readable texts can be used in research. This latter -topic received thorough treatment in the paper read by Avra MICHELSON. -She placed the phenomenon of electronic texts within the context of -broader trends in information technology and scholarly communication. - -Among other things, MICHELSON described on-line conferences that -represent a vigorous and important intellectual forum for certain -disciplines. Internet now carries more than 700 conferences, with about -80 percent of these devoted to topics in the social sciences and the -humanities. Other scholars use on-line networks for "distance learning." -Meanwhile, there has been a tremendous growth in end-user computing; -professors today are less likely than their predecessors to ask the -campus computer center to process their data. Electronic texts are one -key to these sophisticated applications, MICHELSON reported, and more and -more scholars in the humanities now work in an on-line environment. -Toward the end of the Workshop, Michael LESK presented a corollary to -MICHELSON's talk, reporting the results of an experiment that compared -the work of one group of chemistry students using traditional printed -texts and two groups using electronic sources. The experiment -demonstrated that in the event one does not know what to read, one needs -the electronic systems; the electronic systems hold no advantage at the -moment if one knows what to read, but neither do they impose a penalty. - -DALY provided an anecdotal account of the revolutionizing impact of the -new technology on his previous methods of research in the field of classics. -His account, by extrapolation, served to illustrate in part the arguments -made by MICHELSON concerning the positive effects of the sudden and radical -transformation being wrought in the ways scholars work. - -Susan VECCIA and Joanne FREEMAN delineated the use of electronic -materials outside the university. The most interesting aspect of their -use, FREEMAN said, could be seen as a paradox: teachers in elementary -and secondary schools requested access to primary source materials but, -at the same time, found that "primariness" itself made these materials -difficult for their students to use. - - -OTHER TOPICS - -Marybeth PETERS reviewed copyright law in the United States and offered -advice during a lively discussion of this subject. But uncertainty -remains concerning the price of copyright in a digital medium, because a -solution remains to be worked out concerning management and synthesis of -copyrighted and out-of-copyright pieces of a database. - -As moderator of the final session of the Workshop, Prosser GIFFORD directed -discussion to future courses of action and the potential role of LC in -advancing them. Among the recommendations that emerged were the following: - - * Workshop participants should 1) begin to think about working - with image material, but structure and digitize it in such a - way that at a later stage it can be interpreted into text, and - 2) find a common way to build text and images together so that - they can be used jointly at some stage in the future, with - appropriate network support, because that is how users will want - to access these materials. The Library might encourage attempts - to bring together people who are working on texts and images. - - * A network version of American Memory should be developed or - consideration should be given to making the data in it - available to people interested in doing network multimedia. - Given the current dearth of digital data that is appealing and - unencumbered by extremely complex rights problems, developing a - network version of American Memory could do much to help make - network multimedia a reality. - - * Concerning the thorny issue of electronic deposit, LC should - initiate a catalytic process in terms of distributed - responsibility, that is, bring together the distributed - organizations and set up a study group to look at all the - issues related to electronic deposit and see where we as a - nation should move. For example, LC might attempt to persuade - one major library in each state to deal with its state - equivalent publisher, which might produce a cooperative project - that would be equitably distributed around the country, and one - in which LC would be dealing with a minimal number of publishers - and minimal copyright problems. LC must also deal with the - concept of on-line publishing, determining, among other things, - how serials such as OJCCT might be deposited for copyright. - - * Since a number of projects are planning to carry out - preservation by creating digital images that will end up in - on-line or near-line storage at some institution, LC might play - a helpful role, at least in the near term, by accelerating how - to catalog that information into the Research Library Information - Network (RLIN) and then into OCLC, so that it would be accessible. - This would reduce the possibility of multiple institutions digitizing - the same work. - - -CONCLUSION - -The Workshop was valuable because it brought together partisans from -various groups and provided an occasion to compare goals and methods. -The more committed partisans frequently communicate with others in their -groups, but less often across group boundaries. The Workshop was also -valuable to attendees--including those involved with American Memory--who -came less committed to particular approaches or concepts. These -attendees learned a great deal, and plan to select and employ elements of -imaging, text-coding, and networked distribution that suit their -respective projects and purposes. - -Still, reality rears its ugly head: no breakthrough has been achieved. -On the imaging side, one confronts a proliferation of competing -data-interchange standards and a lack of consensus on the role of digital -facsimiles in preservation. In the realm of machine-readable texts, one -encounters a reasonably mature standard but methodological difficulties -and high costs. These latter problems, of course, represent a special -impediment to the desire, as it is sometimes expressed in the popular -press, "to put the [contents of the] Library of Congress on line." In -the words of one participant, there was "no solution to the economic -problems--the projects that are out there are surviving, but it is going -to be a lot of work to transform the information industry, and so far the -investment to do that is not forthcoming" (LESK, per litteras). - - - *** *** *** ****** *** *** *** - - - PROCEEDINGS - - -WELCOME - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -GIFFORD * Origin of Workshop in current Librarian's desire to make LC's -collections more widely available * Desiderata arising from the prospect -of greater interconnectedness * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -After welcoming participants on behalf of the Library of Congress, -American Memory (AM), and the National Demonstration Lab, Prosser -GIFFORD, director for scholarly programs, Library of Congress, located -the origin of the Workshop on Electronic Texts in a conversation he had -had considerably more than a year ago with Carl FLEISCHHAUER concerning -some of the issues faced by AM. On the assumption that numerous other -people were asking the same questions, the decision was made to bring -together as many of these people as possible to ask the same questions -together. In a deeper sense, GIFFORD said, the origin of the Workshop -lay in the desire of the current Librarian of Congress, James H. -Billington, to make the collections of the Library, especially those -offering unique or unusual testimony on aspects of the American -experience, available to a much wider circle of users than those few -people who can come to Washington to use them. This meant that the -emphasis of AM, from the outset, has been on archival collections of the -basic material, and on making these collections themselves available, -rather than selected or heavily edited products. - -From AM's emphasis followed the questions with which the Workshop began: -who will use these materials, and in what form will they wish to use -them. But an even larger issue deserving mention, in GIFFORD's view, was -the phenomenal growth in Internet connectivity. He expressed the hope -that the prospect of greater interconnectedness than ever before would -lead to: 1) much more cooperative and mutually supportive endeavors; 2) -development of systems of shared and distributed responsibilities to -avoid duplication and to ensure accuracy and preservation of unique -materials; and 3) agreement on the necessary standards and development of -the appropriate directories and indices to make navigation -straightforward among the varied resources that are, and increasingly -will be, available. In this connection, GIFFORD requested that -participants reflect from the outset upon the sorts of outcomes they -thought the Workshop might have. Did those present constitute a group -with sufficient common interests to propose a next step or next steps, -and if so, what might those be? They would return to these questions the -following afternoon. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -FLEISCHHAUER * Core of Workshop concerns preparation and production of -materials * Special challenge in conversion of textual materials * -Quality versus quantity * Do the several groups represented share common -interests? * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Carl FLEISCHHAUER, coordinator, American Memory, Library of Congress, -emphasized that he would attempt to represent the people who perform some -of the work of converting or preparing materials and that the core of -the Workshop had to do with preparation and production. FLEISCHHAUER -then drew a distinction between the long term, when many things would be -available and connected in the ways that GIFFORD described, and the short -term, in which AM not only has wrestled with the issue of what is the -best course to pursue but also has faced a variety of technical -challenges. - -FLEISCHHAUER remarked AM's endeavors to deal with a wide range of library -formats, such as motion picture collections, sound-recording collections, -and pictorial collections of various sorts, especially collections of -photographs. In the course of these efforts, AM kept coming back to -textual materials--manuscripts or rare printed matter, bound materials, -etc. Text posed the greatest conversion challenge of all. Thus, the -genesis of the Workshop, which reflects the problems faced by AM. These -problems include physical problems. For example, those in the library -and archive business deal with collections made up of fragile and rare -manuscript items, bound materials, especially the notoriously brittle -bound materials of the late nineteenth century. These are precious -cultural artifacts, however, as well as interesting sources of -information, and LC desires to retain and conserve them. AM needs to -handle things without damaging them. Guillotining a book to run it -through a sheet feeder must be avoided at all costs. - -Beyond physical problems, issues pertaining to quality arose. For -example, the desire to provide users with a searchable text is affected -by the question of acceptable level of accuracy. One hundred percent -accuracy is tremendously expensive. On the other hand, the output of -optical character recognition (OCR) can be tremendously inaccurate. -Although AM has attempted to find a middle ground, uncertainty persists -as to whether or not it has discovered the right solution. - -Questions of quality arose concerning images as well. FLEISCHHAUER -contrasted the extremely high level of quality of the digital images in -the Cornell Xerox Project with AM's efforts to provide a browse-quality -or access-quality image, as opposed to an archival or preservation image. -FLEISCHHAUER therefore welcomed the opportunity to compare notes. - -FLEISCHHAUER observed in passing that conversations he had had about -networks have begun to signal that for various forms of media a -determination may be made that there is a browse-quality item, or a -distribution-and-access-quality item that may coexist in some systems -with a higher quality archival item that would be inconvenient to send -through the network because of its size. FLEISCHHAUER referred, of -course, to images more than to searchable text. - -As AM considered those questions, several conceptual issues arose: ought -AM occasionally to reproduce materials entirely through an image set, at -other times, entirely through a text set, and in some cases, a mix? -There probably would be times when the historical authenticity of an -artifact would require that its image be used. An image might be -desirable as a recourse for users if one could not provide 100-percent -accurate text. Again, AM wondered, as a practical matter, if a -distinction could be drawn between rare printed matter that might exist -in multiple collections--that is, in ten or fifteen libraries. In such -cases, the need for perfect reproduction would be less than for unique -items. Implicit in his remarks, FLEISCHHAUER conceded, was the admission -that AM has been tilting strongly towards quantity and drawing back a -little from perfect quality. That is, it seemed to AM that society would -be better served if more things were distributed by LC--even if they were -not quite perfect--than if fewer things, perfectly represented, were -distributed. This was stated as a proposition to be tested, with -responses to be gathered from users. - -In thinking about issues related to reproduction of materials and seeing -other people engaged in parallel activities, AM deemed it useful to -convene a conference. Hence, the Workshop. FLEISCHHAUER thereupon -surveyed the several groups represented: 1) the world of images (image -users and image makers); 2) the world of text and scholarship and, within -this group, those concerned with language--FLEISCHHAUER confessed to finding -delightful irony in the fact that some of the most advanced thinkers on -computerized texts are those dealing with ancient Greek and Roman materials; -3) the network world; and 4) the general world of library science, which -includes people interested in preservation and cataloging. - -FLEISCHHAUER concluded his remarks with special thanks to the David and -Lucile Packard Foundation for its support of the meeting, the American -Memory group, the Office for Scholarly Programs, the National -Demonstration Lab, and the Office of Special Events. He expressed the -hope that David Woodley Packard might be able to attend, noting that -Packard's work and the work of the foundation had sponsored a number of -projects in the text area. - - ****** - -SESSION I. CONTENT IN A NEW FORM: WHO WILL USE IT AND WHAT WILL THEY DO? - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DALY * Acknowledgements * A new Latin authors disk * Effects of the new -technology on previous methods of research * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Serving as moderator, James DALY acknowledged the generosity of all the -presenters for giving of their time, counsel, and patience in planning -the Workshop, as well as of members of the American Memory project and -other Library of Congress staff, and the David and Lucile Packard -Foundation and its executive director, Colburn S. Wilbur. - -DALY then recounted his visit in March to the Center for Electronic Texts -in the Humanities (CETH) and the Department of Classics at Rutgers -University, where an old friend, Lowell Edmunds, introduced him to the -department's IBYCUS scholarly personal computer, and, in particular, the -new Latin CD-ROM, containing, among other things, almost all classical -Latin literary texts through A.D. 200. Packard Humanities Institute -(PHI), Los Altos, California, released this disk late in 1991, with a -nominal triennial licensing fee. - -Playing with the disk for an hour or so at Rutgers brought home to DALY -at once the revolutionizing impact of the new technology on his previous -methods of research. Had this disk been available two or three years -earlier, DALY contended, when he was engaged in preparing a commentary on -Book 10 of Virgil's Aeneid for Cambridge University Press, he would not -have required a forty-eight-square-foot table on which to spread the -numerous, most frequently consulted items, including some ten or twelve -concordances to key Latin authors, an almost equal number of lexica to -authors who lacked concordances, and where either lexica or concordances -were lacking, numerous editions of authors antedating and postdating Virgil. - -Nor, when checking each of the average six to seven words contained in -the Virgilian hexameter for its usage elsewhere in Virgil's works or -other Latin authors, would DALY have had to maintain the laborious -mechanical process of flipping through these concordances, lexica, and -editions each time. Nor would he have had to frequent as often the -Milton S. Eisenhower Library at the Johns Hopkins University to consult -the Thesaurus Linguae Latinae. Instead of devoting countless hours, or -the bulk of his research time, to gathering data concerning Virgil's use -of words, DALY--now freed by PHI's Latin authors disk from the -tyrannical, yet in some ways paradoxically happy scholarly drudgery-- -would have been able to devote that same bulk of time to analyzing and -interpreting Virgilian verbal usage. - -Citing Theodore Brunner, Gregory Crane, Elli MYLONAS, and Avra MICHELSON, -DALY argued that this reversal in his style of work, made possible by the -new technology, would perhaps have resulted in better, more productive -research. Indeed, even in the course of his browsing the Latin authors -disk at Rutgers, its powerful search, retrieval, and highlighting -capabilities suggested to him several new avenues of research into -Virgil's use of sound effects. This anecdotal account, DALY maintained, -may serve to illustrate in part the sudden and radical transformation -being wrought in the ways scholars work. - - ****** - -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -MICHELSON * Elements related to scholarship and technology * Electronic -texts within the context of broader trends within information technology -and scholarly communication * Evaluation of the prospects for the use of -electronic texts * Relationship of electronic texts to processes of -scholarly communication in humanities research * New exchange formats -created by scholars * Projects initiated to increase scholarly access to -converted text * Trend toward making electronic resources available -through research and education networks * Changes taking place in -scholarly communication among humanities scholars * Network-mediated -scholarship transforming traditional scholarly practices * Key -information technology trends affecting the conduct of scholarly -communication over the next decade * The trend toward end-user computing -* The trend toward greater connectivity * Effects of these trends * Key -transformations taking place * Summary of principal arguments * -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Avra MICHELSON, Archival Research and Evaluation Staff, National Archives -and Records Administration (NARA), argued that establishing who will use -electronic texts and what they will use them for involves a consideration -of both information technology and scholarship trends. This -consideration includes several elements related to scholarship and -technology: 1) the key trends in information technology that are most -relevant to scholarship; 2) the key trends in the use of currently -available technology by scholars in the nonscientific community; and 3) -the relationship between these two very distinct but interrelated trends. -The investment in understanding this relationship being made by -information providers, technologists, and public policy developers, as -well as by scholars themselves, seems to be pervasive and growing, -MICHELSON contended. She drew on collaborative work with Jeff Rothenberg -on the scholarly use of technology. - -MICHELSON sought to place the phenomenon of electronic texts within the -context of broader trends within information technology and scholarly -communication. She argued that electronic texts are of most use to -researchers to the extent that the researchers' working context (i.e., -their relevant bibliographic sources, collegial feedback, analytic tools, -notes, drafts, etc.), along with their field's primary and secondary -sources, also is accessible in electronic form and can be integrated in -ways that are unique to the on-line environment. - -Evaluation of the prospects for the use of electronic texts includes two -elements: 1) an examination of the ways in which researchers currently -are using electronic texts along with other electronic resources, and 2) -an analysis of key information technology trends that are affecting the -long-term conduct of scholarly communication. MICHELSON limited her -discussion of the use of electronic texts to the practices of humanists -and noted that the scientific community was outside the panel's overview. - -MICHELSON examined the nature of the current relationship of electronic -texts in particular, and electronic resources in general, to what she -maintained were, essentially, five processes of scholarly communication -in humanities research. Researchers 1) identify sources, 2) communicate -with their colleagues, 3) interpret and analyze data, 4) disseminate -their research findings, and 5) prepare curricula to instruct the next -generation of scholars and students. This examination would produce a -clearer understanding of the synergy among these five processes that -fuels the tendency of the use of electronic resources for one process to -stimulate its use for other processes of scholarly communication. - -For the first process of scholarly communication, the identification of -sources, MICHELSON remarked the opportunity scholars now enjoy to -supplement traditional word-of-mouth searches for sources among their -colleagues with new forms of electronic searching. So, for example, -instead of having to visit the library, researchers are able to explore -descriptions of holdings in their offices. Furthermore, if their own -institutions' holdings prove insufficient, scholars can access more than -200 major American library catalogues over Internet, including the -universities of California, Michigan, Pennsylvania, and Wisconsin. -Direct access to the bibliographic databases offers intellectual -empowerment to scholars by presenting a comprehensive means of browsing -through libraries from their homes and offices at their convenience. - -The second process of communication involves communication among -scholars. Beyond the most common methods of communication, scholars are -using E-mail and a variety of new electronic communications formats -derived from it for further academic interchange. E-mail exchanges are -growing at an astonishing rate, reportedly 15 percent a month. They -currently constitute approximately half the traffic on research and -education networks. Moreover, the global spread of E-mail has been so -rapid that it is now possible for American scholars to use it to -communicate with colleagues in close to 140 other countries. - -Other new exchange formats created by scholars and operating on Internet -include more than 700 conferences, with about 80 percent of these devoted -to topics in the social sciences and humanities. The rate of growth of -these scholarly electronic conferences also is astonishing. From l990 to -l991, 200 new conferences were identified on Internet. From October 1991 -to June 1992, an additional 150 conferences in the social sciences and -humanities were added to this directory of listings. Scholars have -established conferences in virtually every field, within every different -discipline. For example, there are currently close to 600 active social -science and humanities conferences on topics such as art and -architecture, ethnomusicology, folklore, Japanese culture, medical -education, and gifted and talented education. The appeal to scholars of -communicating through these conferences is that, unlike any other medium, -electronic conferences today provide a forum for global communication -with peers at the front end of the research process. - -Interpretation and analysis of sources constitutes the third process of -scholarly communication that MICHELSON discussed in terms of texts and -textual resources. The methods used to analyze sources fall somewhere on -a continuum from quantitative analysis to qualitative analysis. -Typically, evidence is culled and evaluated using methods drawn from both -ends of this continuum. At one end, quantitative analysis involves the -use of mathematical processes such as a count of frequencies and -distributions of occurrences or, on a higher level, regression analysis. -At the other end of the continuum, qualitative analysis typically -involves nonmathematical processes oriented toward language -interpretation or the building of theory. Aspects of this work involve -the processing--either manual or computational--of large and sometimes -massive amounts of textual sources, although the use of nontextual -sources as evidence, such as photographs, sound recordings, film footage, -and artifacts, is significant as well. - -Scholars have discovered that many of the methods of interpretation and -analysis that are related to both quantitative and qualitative methods -are processes that can be performed by computers. For example, computers -can count. They can count brush strokes used in a Rembrandt painting or -perform regression analysis for understanding cause and effect. By means -of advanced technologies, computers can recognize patterns, analyze text, -and model concepts. Furthermore, computers can complete these processes -faster with more sources and with greater precision than scholars who -must rely on manual interpretation of data. But if scholars are to use -computers for these processes, source materials must be in a form -amenable to computer-assisted analysis. For this reason many scholars, -once they have identified the sources that are key to their research, are -converting them to machine-readable form. Thus, a representative example -of the numerous textual conversion projects organized by scholars around -the world in recent years to support computational text analysis is the -TLG, the Thesaurus Linguae Graecae. This project is devoted to -converting the extant ancient texts of classical Greece. (Editor's note: -according to the TLG Newsletter of May l992, TLG was in use in thirty-two -different countries. This figure updates MICHELSON's previous count by one.) - -The scholars performing these conversions have been asked to recognize -that the electronic sources they are converting for one use possess value -for other research purposes as well. As a result, during the past few -years, humanities scholars have initiated a number of projects to -increase scholarly access to converted text. So, for example, the Text -Encoding Initiative (TEI), about which more is said later in the program, -was established as an effort by scholars to determine standard elements -and methods for encoding machine-readable text for electronic exchange. -In a second effort to facilitate the sharing of converted text, scholars -have created a new institution, the Center for Electronic Texts in the -Humanities (CETH). The center estimates that there are 8,000 series of -source texts in the humanities that have been converted to -machine-readable form worldwide. CETH is undertaking an international -search for converted text in the humanities, compiling it into an -electronic library, and preparing bibliographic descriptions of the -sources for the Research Libraries Information Network's (RLIN) -machine-readable data file. The library profession has begun to initiate -large conversion projects as well, such as American Memory. - -While scholars have been making converted text available to one another, -typically on disk or on CD-ROM, the clear trend is toward making these -resources available through research and education networks. Thus, the -American and French Research on the Treasury of the French Language -(ARTFL) and the Dante Project are already available on Internet. -MICHELSON summarized this section on interpretation and analysis by -noting that: 1) increasing numbers of humanities scholars in the library -community are recognizing the importance to the advancement of -scholarship of retrospective conversion of source materials in the arts -and humanities; and 2) there is a growing realization that making the -sources available on research and education networks maximizes their -usefulness for the analysis performed by humanities scholars. - -The fourth process of scholarly communication is dissemination of -research findings, that is, publication. Scholars are using existing -research and education networks to engineer a new type of publication: -scholarly-controlled journals that are electronically produced and -disseminated. Although such journals are still emerging as a -communication format, their number has grown, from approximately twelve -to thirty-six during the past year (July 1991 to June 1992). Most of -these electronic scholarly journals are devoted to topics in the -humanities. As with network conferences, scholarly enthusiasm for these -electronic journals stems from the medium's unique ability to advance -scholarship in a way that no other medium can do by supporting global -feedback and interchange, practically in real time, early in the research -process. Beyond scholarly journals, MICHELSON remarked the delivery of -commercial full-text products, such as articles in professional journals, -newsletters, magazines, wire services, and reference sources. These are -being delivered via on-line local library catalogues, especially through -CD-ROMs. Furthermore, according to MICHELSON, there is general optimism -that the copyright and fees issues impeding the delivery of full text on -existing research and education networks soon will be resolved. - -The final process of scholarly communication is curriculum development -and instruction, and this involves the use of computer information -technologies in two areas. The first is the development of -computer-oriented instructional tools, which includes simulations, -multimedia applications, and computer tools that are used to assist in -the analysis of sources in the classroom, etc. The Perseus Project, a -database that provides a multimedia curriculum on classical Greek -civilization, is a good example of the way in which entire curricula are -being recast using information technologies. It is anticipated that the -current difficulty in exchanging electronically computer-based -instructional software, which in turn makes it difficult for one scholar -to build upon the work of others, will be resolved before too long. -Stand-alone curricular applications that involve electronic text will be -sharable through networks, reinforcing their significance as intellectual -products as well as instructional tools. - -The second aspect of electronic learning involves the use of research and -education networks for distance education programs. Such programs -interactively link teachers with students in geographically scattered -locations and rely on the availability of electronic instructional -resources. Distance education programs are gaining wide appeal among -state departments of education because of their demonstrated capacity to -bring advanced specialized course work and an array of experts to many -classrooms. A recent report found that at least 32 states operated at -least one statewide network for education in 1991, with networks under -development in many of the remaining states. - -MICHELSON summarized this section by noting two striking changes taking -place in scholarly communication among humanities scholars. First is the -extent to which electronic text in particular, and electronic resources -in general, are being infused into each of the five processes described -above. As mentioned earlier, there is a certain synergy at work here. -The use of electronic resources for one process tends to stimulate its -use for other processes, because the chief course of movement is toward a -comprehensive on-line working context for humanities scholars that -includes on-line availability of key bibliographies, scholarly feedback, -sources, analytical tools, and publications. MICHELSON noted further -that the movement toward a comprehensive on-line working context for -humanities scholars is not new. In fact, it has been underway for more -than forty years in the humanities, since Father Roberto Busa began -developing an electronic concordance of the works of Saint Thomas Aquinas -in 1949. What we are witnessing today, MICHELSON contended, is not the -beginning of this on-line transition but, for at least some humanities -scholars, the turning point in the transition from a print to an -electronic working context. Coinciding with the on-line transition, the -second striking change is the extent to which research and education -networks are becoming the new medium of scholarly communication. The -existing Internet and the pending National Education and Research Network -(NREN) represent the new meeting ground where scholars are going for -bibliographic information, scholarly dialogue and feedback, the most -current publications in their field, and high-level educational -offerings. Traditional scholarly practices are undergoing tremendous -transformations as a result of the emergence and growing prominence of -what is called network-mediated scholarship. - -MICHELSON next turned to the second element of the framework she proposed -at the outset of her talk for evaluating the prospects for electronic -text, namely the key information technology trends affecting the conduct -of scholarly communication over the next decade: 1) end-user computing -and 2) connectivity. - -End-user computing means that the person touching the keyboard, or -performing computations, is the same as the person who initiates or -consumes the computation. The emergence of personal computers, along -with a host of other forces, such as ubiquitous computing, advances in -interface design, and the on-line transition, is prompting the consumers -of computation to do their own computing, and is thus rendering obsolete -the traditional distinction between end users and ultimate users. - -The trend toward end-user computing is significant to consideration of -the prospects for electronic texts because it means that researchers are -becoming more adept at doing their own computations and, thus, more -competent in the use of electronic media. By avoiding programmer -intermediaries, computation is becoming central to the researcher's -thought process. This direct involvement in computing is changing the -researcher's perspective on the nature of research itself, that is, the -kinds of questions that can be posed, the analytical methodologies that -can be used, the types and amount of sources that are appropriate for -analyses, and the form in which findings are presented. The trend toward -end-user computing means that, increasingly, electronic media and -computation are being infused into all processes of humanities -scholarship, inspiring remarkable transformations in scholarly -communication. - -The trend toward greater connectivity suggests that researchers are using -computation increasingly in network environments. Connectivity is -important to scholarship because it erases the distance that separates -students from teachers and scholars from their colleagues, while allowing -users to access remote databases, share information in many different -media, connect to their working context wherever they are, and -collaborate in all phases of research. - -The combination of the trend toward end-user computing and the trend -toward connectivity suggests that the scholarly use of electronic -resources, already evident among some researchers, will soon become an -established feature of scholarship. The effects of these trends, along -with ongoing changes in scholarly practices, point to a future in which -humanities researchers will use computation and electronic communication -to help them formulate ideas, access sources, perform research, -collaborate with colleagues, seek peer review, publish and disseminate -results, and engage in many other professional and educational activities. - -In summary, MICHELSON emphasized four points: 1) A portion of humanities -scholars already consider electronic texts the preferred format for -analysis and dissemination. 2) Scholars are using these electronic -texts, in conjunction with other electronic resources, in all the -processes of scholarly communication. 3) The humanities scholars' -working context is in the process of changing from print technology to -electronic technology, in many ways mirroring transformations that have -occurred or are occurring within the scientific community. 4) These -changes are occurring in conjunction with the development of a new -communication medium: research and education networks that are -characterized by their capacity to advance scholarship in a wholly unique -way. - -MICHELSON also reiterated her three principal arguments: l) Electronic -texts are best understood in terms of the relationship to other -electronic resources and the growing prominence of network-mediated -scholarship. 2) The prospects for electronic texts lie in their capacity -to be integrated into the on-line network of electronic resources that -comprise the new working context for scholars. 3) Retrospective conversion -of portions of the scholarly record should be a key strategy as information -providers respond to changes in scholarly communication practices. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -VECCIA * AM's evaluation project and public users of electronic resources -* AM and its design * Site selection and evaluating the Macintosh -implementation of AM * Characteristics of the six public libraries -selected * Characteristics of AM's users in these libraries * Principal -ways AM is being used * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Susan VECCIA, team leader, and Joanne FREEMAN, associate coordinator, -American Memory, Library of Congress, gave a joint presentation. First, -by way of introduction, VECCIA explained her and FREEMAN's roles in -American Memory (AM). Serving principally as an observer, VECCIA has -assisted with the evaluation project of AM, placing AM collections in a -variety of different sites around the country and helping to organize and -implement that project. FREEMAN has been an associate coordinator of AM -and has been involved principally with the interpretative materials, -preparing some of the electronic exhibits and printed historical -information that accompanies AM and that is requested by users. VECCIA -and FREEMAN shared anecdotal observations concerning AM with public users -of electronic resources. Notwithstanding a fairly structured evaluation -in progress, both VECCIA and FREEMAN chose not to report on specifics in -terms of numbers, etc., because they felt it was too early in the -evaluation project to do so. - -AM is an electronic archive of primary source materials from the Library -of Congress, selected collections representing a variety of formats-- -photographs, graphic arts, recorded sound, motion pictures, broadsides, -and soon, pamphlets and books. In terms of the design of this system, -the interpretative exhibits have been kept separate from the primary -resources, with good reason. Accompanying this collection are printed -documentation and user guides, as well as guides that FREEMAN prepared for -teachers so that they may begin using the content of the system at once. - -VECCIA described the evaluation project before talking about the public -users of AM, limiting her remarks to public libraries, because FREEMAN -would talk more specifically about schools from kindergarten to twelfth -grade (K-12). Having started in spring 1991, the evaluation currently -involves testing of the Macintosh implementation of AM. Since the -primary goal of this evaluation is to determine the most appropriate -audience or audiences for AM, very different sites were selected. This -makes evaluation difficult because of the varying degrees of technology -literacy among the sites. AM is situated in forty-four locations, of -which six are public libraries and sixteen are schools. Represented -among the schools are elementary, junior high, and high schools. -District offices also are involved in the evaluation, which will -conclude in summer 1993. - -VECCIA focused the remainder of her talk on the six public libraries, one -of which doubles as a state library. They represent a range of -geographic areas and a range of demographic characteristics. For -example, three are located in urban settings, two in rural settings, and -one in a suburban setting. A range of technical expertise is to be found -among these facilities as well. For example, one is an "Apple library of -the future," while two others are rural one-room libraries--in one, AM -sits at the front desk next to a tractor manual. - -All public libraries have been extremely enthusiastic, supportive, and -appreciative of the work that AM has been doing. VECCIA characterized -various users: Most users in public libraries describe themselves as -general readers; of the students who use AM in the public libraries, -those in fourth grade and above seem most interested. Public libraries -in rural sites tend to attract retired people, who have been highly -receptive to AM. Users tend to fall into two additional categories: -people interested in the content and historical connotations of these -primary resources, and those fascinated by the technology. The format -receiving the most comments has been motion pictures. The adult users in -public libraries are more comfortable with IBM computers, whereas young -people seem comfortable with either IBM or Macintosh, although most of -them seem to come from a Macintosh background. This same tendency is -found in the schools. - -What kinds of things do users do with AM? In a public library there are -two main goals or ways that AM is being used: as an individual learning -tool, and as a leisure activity. Adult learning was one area that VECCIA -would highlight as a possible application for a tool such as AM. She -described a patron of a rural public library who comes in every day on -his lunch hour and literally reads AM, methodically going through the -collection image by image. At the end of his hour he makes an electronic -bookmark, puts it in his pocket, and returns to work. The next day he -comes in and resumes where he left off. Interestingly, this man had -never been in the library before he used AM. In another small, rural -library, the coordinator reports that AM is a popular activity for some -of the older, retired people in the community, who ordinarily would not -use "those things,"--computers. Another example of adult learning in -public libraries is book groups, one of which, in particular, is using AM -as part of its reading on industrialization, integration, and urbanization -in the early 1900s. - -One library reports that a family is using AM to help educate their -children. In another instance, individuals from a local museum came in -to use AM to prepare an exhibit on toys of the past. These two examples -emphasize the mission of the public library as a cultural institution, -reaching out to people who do not have the same resources available to -those who live in a metropolitan area or have access to a major library. -One rural library reports that junior high school students in large -numbers came in one afternoon to use AM for entertainment. A number of -public libraries reported great interest among postcard collectors in the -Detroit collection, which was essentially a collection of images used on -postcards around the turn of the century. Train buffs are similarly -interested because that was a time of great interest in railroading. -People, it was found, relate to things that they know of firsthand. For -example, in both rural public libraries where AM was made available, -observers reported that the older people with personal remembrances of -the turn of the century were gravitating to the Detroit collection. -These examples served to underscore MICHELSON's observation re the -integration of electronic tools and ideas--that people learn best when -the material relates to something they know. - -VECCIA made the final point that in many cases AM serves as a -public-relations tool for the public libraries that are testing it. In -one case, AM is being used as a vehicle to secure additional funding for -the library. In another case, AM has served as an inspiration to the -staff of a major local public library in the South to think about ways to -make its own collection of photographs more accessible to the public. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -FREEMAN * AM and archival electronic resources in a school environment * -Questions concerning context * Questions concerning the electronic format -itself * Computer anxiety * Access and availability of the system * -Hardware * Strengths gained through the use of archival resources in -schools * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Reiterating an observation made by VECCIA, that AM is an archival -resource made up of primary materials with very little interpretation, -FREEMAN stated that the project has attempted to bridge the gap between -these bare primary materials and a school environment, and in that cause -has created guided introductions to AM collections. Loud demand from the -educational community, chiefly from teachers working with the upper -grades of elementary school through high school, greeted the announcement -that AM would be tested around the country. - -FREEMAN reported not only on what was learned about AM in a school -environment, but also on several universal questions that were raised -concerning archival electronic resources in schools. She discussed -several strengths of this type of material in a school environment as -opposed to a highly structured resource that offers a limited number of -paths to follow. - -FREEMAN first raised several questions about using AM in a school -environment. There is often some difficulty in developing a sense of -what the system contains. Many students sit down at a computer resource -and assume that, because AM comes from the Library of Congress, all of -American history is now at their fingertips. As a result of that sort of -mistaken judgment, some students are known to conclude that AM contains -nothing of use to them when they look for one or two things and do not -find them. It is difficult to discover that middle ground where one has -a sense of what the system contains. Some students grope toward the idea -of an archive, a new idea to them, since they have not previously -experienced what it means to have access to a vast body of somewhat -random information. - -Other questions raised by FREEMAN concerned the electronic format itself. -For instance, in a school environment it is often difficult both for -teachers and students to gain a sense of what it is they are viewing. -They understand that it is a visual image, but they do not necessarily -know that it is a postcard from the turn of the century, a panoramic -photograph, or even machine-readable text of an eighteenth-century -broadside, a twentieth-century printed book, or a nineteenth-century -diary. That distinction is often difficult for people in a school -environment to grasp. Because of that, it occasionally becomes difficult -to draw conclusions from what one is viewing. - -FREEMAN also noted the obvious fear of the computer, which constitutes a -difficulty in using an electronic resource. Though students in general -did not suffer from this anxiety, several older students feared that they -were computer-illiterate, an assumption that became self-fulfilling when -they searched for something but failed to find it. FREEMAN said she -believed that some teachers also fear computer resources, because they -believe they lack complete control. FREEMAN related the example of -teachers shooing away students because it was not their time to use the -system. This was a case in which the situation had to be extremely -structured so that the teachers would not feel that they had lost their -grasp on what the system contained. - -A final question raised by FREEMAN concerned access and availability of -the system. She noted the occasional existence of a gap in communication -between school librarians and teachers. Often AM sits in a school -library and the librarian is the person responsible for monitoring the -system. Teachers do not always take into their world new library -resources about which the librarian is excited. Indeed, at the sites -where AM had been used most effectively within a library, the librarian -was required to go to specific teachers and instruct them in its use. As -a result, several AM sites will have in-service sessions over a summer, -in the hope that perhaps, with a more individualized link, teachers will -be more likely to use the resource. - -A related issue in the school context concerned the number of -workstations available at any one location. Centralization of equipment -at the district level, with teachers invited to download things and walk -away with them, proved unsuccessful because the hours these offices were -open were also school hours. - -Another issue was hardware. As VECCIA observed, a range of sites exists, -some technologically advanced and others essentially acquiring their -first computer for the primary purpose of using it in conjunction with -AM's testing. Users at technologically sophisticated sites want even -more sophisticated hardware, so that they can perform even more -sophisticated tasks with the materials in AM. But once they acquire a -newer piece of hardware, they must learn how to use that also; at an -unsophisticated site it takes an extremely long time simply to become -accustomed to the computer, not to mention the program offered with the -computer. All of these small issues raise one large question, namely, -are systems like AM truly rewarding in a school environment, or do they -simply act as innovative toys that do little more than spark interest? - -FREEMAN contended that the evaluation project has revealed several strengths -that were gained through the use of archival resources in schools, including: - - * Psychic rewards from using AM as a vast, rich database, with - teachers assigning various projects to students--oral presentations, - written reports, a documentary, a turn-of-the-century newspaper-- - projects that start with the materials in AM but are completed using - other resources; AM thus is used as a research tool in conjunction - with other electronic resources, as well as with books and items in - the library where the system is set up. - - * Students are acquiring computer literacy in a humanities context. - - * This sort of system is overcoming the isolation between disciplines - that often exists in schools. For example, many English teachers are - requiring their students to write papers on historical topics - represented in AM. Numerous teachers have reported that their - students are learning critical thinking skills using the system. - - * On a broader level, AM is introducing primary materials, not only - to students but also to teachers, in an environment where often - simply none exist--an exciting thing for the students because it - helps them learn to conduct research, to interpret, and to draw - their own conclusions. In learning to conduct research and what it - means, students are motivated to seek knowledge. That relates to - another positive outcome--a high level of personal involvement of - students with the materials in this system and greater motivation to - conduct their own research and draw their own conclusions. - - * Perhaps the most ironic strength of these kinds of archival - electronic resources is that many of the teachers AM interviewed - were desperate, it is no exaggeration to say, not only for primary - materials but for unstructured primary materials. These would, they - thought, foster personally motivated research, exploration, and - excitement in their students. Indeed, these materials have done - just that. Ironically, however, this lack of structure produces - some of the confusion to which the newness of these kinds of - resources may also contribute. The key to effective use of archival - products in a school environment is a clear, effective introduction - to the system and to what it contains. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Nothing known, quantitatively, about the number of -humanities scholars who must see the original versus those who would -settle for an edited transcript, or about the ways in which humanities -scholars are using information technology * Firm conclusions concerning -the manner and extent of the use of supporting materials in print -provided by AM to await completion of evaluative study * A listener's -reflections on additional applications of electronic texts * Role of -electronic resources in teaching elementary research skills to students * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the discussion that followed the presentations by MICHELSON, -VECCIA, and FREEMAN, additional points emerged. - -LESK asked if MICHELSON could give any quantitative estimate of the -number of humanities scholars who must see or want to see the original, -or the best possible version of the material, versus those who typically -would settle for an edited transcript. While unable to provide a figure, -she offered her impressions as an archivist who has done some reference -work and has discussed this issue with other archivists who perform -reference, that those who use archives and those who use primary sources -for what would be considered very high-level scholarly research, as -opposed to, say, undergraduate papers, were few in number, especially -given the public interest in using primary sources to conduct -genealogical or avocational research and the kind of professional -research done by people in private industry or the federal government. -More important in MICHELSON's view was that, quantitatively, nothing is -known about the ways in which, for example, humanities scholars are using -information technology. No studies exist to offer guidance in creating -strategies. The most recent study was conducted in 1985 by the American -Council of Learned Societies (ACLS), and what it showed was that 50 -percent of humanities scholars at that time were using computers. That -constitutes the extent of our knowledge. - -Concerning AM's strategy for orienting people toward the scope of -electronic resources, FREEMAN could offer no hard conclusions at this -point, because she and her colleagues were still waiting to see, -particularly in the schools, what has been made of their efforts. Within -the system, however, AM has provided what are called electronic exhibits- --such as introductions to time periods and materials--and these are -intended to offer a student user a sense of what a broadside is and what -it might tell her or him. But FREEMAN conceded that the project staff -would have to talk with students next year, after teachers have had a -summer to use the materials, and attempt to discover what the students -were learning from the materials. In addition, FREEMAN described -supporting materials in print provided by AM at the request of local -teachers during a meeting held at LC. These included time lines, -bibliographies, and other materials that could be reproduced on a -photocopier in a classroom. Teachers could walk away with and use these, -and in this way gain a better understanding of the contents. But again, -reaching firm conclusions concerning the manner and extent of their use -would have to wait until next year. - -As to the changes she saw occurring at the National Archives and Records -Administration (NARA) as a result of the increasing emphasis on -technology in scholarly research, MICHELSON stated that NARA at this -point was absorbing the report by her and Jeff Rothenberg addressing -strategies for the archival profession in general, although not for the -National Archives specifically. NARA is just beginning to establish its -role and what it can do. In terms of changes and initiatives that NARA -can take, no clear response could be given at this time. - -GREENFIELD remarked two trends mentioned in the session. Reflecting on -DALY's opening comments on how he could have used a Latin collection of -text in an electronic form, he said that at first he thought most scholars -would be unwilling to do that. But as he thought of that in terms of the -original meaning of research--that is, having already mastered these texts, -researching them for critical and comparative purposes--for the first time, -the electronic format made a lot of sense. GREENFIELD could envision -growing numbers of scholars learning the new technologies for that very -aspect of their scholarship and for convenience's sake. - -Listening to VECCIA and FREEMAN, GREENFIELD thought of an additional -application of electronic texts. He realized that AM could be used as a -guide to lead someone to original sources. Students cannot be expected -to have mastered these sources, things they have never known about -before. Thus, AM is leading them, in theory, to a vast body of -information and giving them a superficial overview of it, enabling them -to select parts of it. GREENFIELD asked if any evidence exists that this -resource will indeed teach the new user, the K-12 students, how to do -research. Scholars already know how to do research and are applying -these new tools. But he wondered why students would go beyond picking -out things that were most exciting to them. - -FREEMAN conceded the correctness of GREENFIELD's observation as applied -to a school environment. The risk is that a student would sit down at a -system, play with it, find some things of interest, and then walk away. -But in the relatively controlled situation of a school library, much will -depend on the instructions a teacher or a librarian gives a student. She -viewed the situation not as one of fine-tuning research skills but of -involving students at a personal level in understanding and researching -things. Given the guidance one can receive at school, it then becomes -possible to teach elementary research skills to students, which in fact -one particular librarian said she was teaching her fifth graders. -FREEMAN concluded that introducing the idea of following one's own path -of inquiry, which is essentially what research entails, involves more -than teaching specific skills. To these comments VECCIA added the -observation that the individual teacher and the use of a creative -resource, rather than AM itself, seemed to make the key difference. -Some schools and some teachers are making excellent use of the nature -of critical thinking and teaching skills, she said. - -Concurring with these remarks, DALY closed the session with the thought that -the more that producers produced for teachers and for scholars to use with -their students, the more successful their electronic products would prove. - - ****** - -SESSION II. SHOW AND TELL - -Jacqueline HESS, director, National Demonstration Laboratory, served as -moderator of the "show-and-tell" session. She noted that a -question-and-answer period would follow each presentation. - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -MYLONAS * Overview and content of Perseus * Perseus' primary materials -exist in a system-independent, archival form * A concession * Textual -aspects of Perseus * Tools to use with the Greek text * Prepared indices -and full-text searches in Perseus * English-Greek word search leads to -close study of words and concepts * Navigating Perseus by tracing down -indices * Using the iconography to perform research * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Elli MYLONAS, managing editor, Perseus Project, Harvard University, first -gave an overview of Perseus, a large, collaborative effort based at -Harvard University but with contributors and collaborators located at -numerous universities and colleges in the United States (e.g., Bowdoin, -Maryland, Pomona, Chicago, Virginia). Funded primarily by the -Annenberg/CPB Project, with additional funding from Apple, Harvard, and -the Packard Humanities Institute, among others, Perseus is a multimedia, -hypertextual database for teaching and research on classical Greek -civilization, which was released in February 1992 in version 1.0 and -distributed by Yale University Press. - -Consisting entirely of primary materials, Perseus includes ancient Greek -texts and translations of those texts; catalog entries--that is, museum -catalog entries, not library catalog entries--on vases, sites, coins, -sculpture, and archaeological objects; maps; and a dictionary, among -other sources. The number of objects and the objects for which catalog -entries exist are accompanied by thousands of color images, which -constitute a major feature of the database. Perseus contains -approximately 30 megabytes of text, an amount that will double in -subsequent versions. In addition to these primary materials, the Perseus -Project has been building tools for using them, making access and -navigation easier, the goal being to build part of the electronic -environment discussed earlier in the morning in which students or -scholars can work with their sources. - -The demonstration of Perseus will show only a fraction of the real work -that has gone into it, because the project had to face the dilemma of -what to enter when putting something into machine-readable form: should -one aim for very high quality or make concessions in order to get the -material in? Since Perseus decided to opt for very high quality, all of -its primary materials exist in a system-independent--insofar as it is -possible to be system-independent--archival form. Deciding what that -archival form would be and attaining it required much work and thought. -For example, all the texts are marked up in SGML, which will be made -compatible with the guidelines of the Text Encoding Initiative (TEI) when -they are issued. - -Drawings are postscript files, not meeting international standards, but -at least designed to go across platforms. Images, or rather the real -archival forms, consist of the best available slides, which are being -digitized. Much of the catalog material exists in database form--a form -that the average user could use, manipulate, and display on a personal -computer, but only at great cost. Thus, this is where the concession -comes in: All of this rich, well-marked-up information is stripped of -much of its content; the images are converted into bit-maps and the text -into small formatted chunks. All this information can then be imported -into HyperCard and run on a mid-range Macintosh, which is what Perseus -users have. This fact has made it possible for Perseus to attain wide -use fairly rapidly. Without those archival forms the HyperCard version -being demonstrated could not be made easily, and the project could not -have the potential to move to other forms and machines and software as -they appear, none of which information is in Perseus on the CD. - -Of the numerous multimedia aspects of Perseus, MYLONAS focused on the -textual. Part of what makes Perseus such a pleasure to use, MYLONAS -said, is this effort at seamless integration and the ability to move -around both visual and textual material. Perseus also made the decision -not to attempt to interpret its material any more than one interprets by -selecting. But, MYLONAS emphasized, Perseus is not courseware: No -syllabus exists. There is no effort to define how one teaches a topic -using Perseus, although the project may eventually collect papers by -people who have used it to teach. Rather, Perseus aims to provide -primary material in a kind of electronic library, an electronic sandbox, -so to say, in which students and scholars who are working on this -material can explore by themselves. With that, MYLONAS demonstrated -Perseus, beginning with the Perseus gateway, the first thing one sees -upon opening Perseus--an effort in part to solve the contextualizing -problem--which tells the user what the system contains. - -MYLONAS demonstrated only a very small portion, beginning with primary -texts and running off the CD-ROM. Having selected Aeschylus' Prometheus -Bound, which was viewable in Greek and English pretty much in the same -segments together, MYLONAS demonstrated tools to use with the Greek text, -something not possible with a book: looking up the dictionary entry form -of an unfamiliar word in Greek after subjecting it to Perseus' -morphological analysis for all the texts. After finding out about a -word, a user may then decide to see if it is used anywhere else in Greek. -Because vast amounts of indexing support all of the primary material, one -can find out where else all forms of a particular Greek word appear-- -often not a trivial matter because Greek is highly inflected. Further, -since the story of Prometheus has to do with the origins of sacrifice, a -user may wish to study and explore sacrifice in Greek literature; by -typing sacrifice into a small window, a user goes to the English-Greek -word list--something one cannot do without the computer (Perseus has -indexed the definitions of its dictionary)--the string sacrifice appears -in the definitions of these sixty-five words. One may then find out -where any of those words is used in the work(s) of a particular author. -The English definitions are not lemmatized. - -All of the indices driving this kind of usage were originally devised for -speed, MYLONAS observed; in other words, all that kind of information-- -all forms of all words, where they exist, the dictionary form they belong -to--were collected into databases, which will expedite searching. Then -it was discovered that one can do things searching in these databases -that could not be done searching in the full texts. Thus, although there -are full-text searches in Perseus, much of the work is done behind the -scenes, using prepared indices. Re the indexing that is done behind the -scenes, MYLONAS pointed out that without the SGML forms of the text, it -could not be done effectively. Much of this indexing is based on the -structures that are made explicit by the SGML tagging. - -It was found that one of the things many of Perseus' non-Greek-reading -users do is start from the dictionary and then move into the close study -of words and concepts via this kind of English-Greek word search, by which -means they might select a concept. This exercise has been assigned to -students in core courses at Harvard--to study a concept by looking for the -English word in the dictionary, finding the Greek words, and then finding -the words in the Greek but, of course, reading across in the English. -That tells them a great deal about what a translation means as well. - -Should one also wish to see images that have to do with sacrifice, that -person would go to the object key word search, which allows one to -perform a similar kind of index retrieval on the database of -archaeological objects. Without words, pictures are useless; Perseus has -not reached the point where it can do much with images that are not -cataloged. Thus, although it is possible in Perseus with text and images -to navigate by knowing where one wants to end up--for example, a -red-figure vase from the Boston Museum of Fine Arts--one can perform this -kind of navigation very easily by tracing down indices. MYLONAS -illustrated several generic scenes of sacrifice on vases. The features -demonstrated derived from Perseus 1.0; version 2.0 will implement even -better means of retrieval. - -MYLONAS closed by looking at one of the pictures and noting again that -one can do a great deal of research using the iconography as well as the -texts. For instance, students in a core course at Harvard this year were -highly interested in Greek concepts of foreigners and representations of -non-Greeks. So they performed a great deal of research, both with texts -(e.g., Herodotus) and with iconography on vases and coins, on how the -Greeks portrayed non-Greeks. At the same time, art historians who study -iconography were also interested, and were able to use this material. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Indexing and searchability of all English words in Perseus * -Several features of Perseus 1.0 * Several levels of customization -possible * Perseus used for general education * Perseus' effects on -education * Contextual information in Perseus * Main challenge and -emphasis of Perseus * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Several points emerged in the discussion that followed MYLONAS's presentation. - -Although MYLONAS had not demonstrated Perseus' ability to cross-search -documents, she confirmed that all English words in Perseus are indexed -and can be searched. So, for example, sacrifice could have been searched -in all texts, the historical essay, and all the catalogue entries with -their descriptions--in short, in all of Perseus. - -Boolean logic is not in Perseus 1.0 but will be added to the next -version, although an effort is being made not to restrict Perseus to a -database in which one just performs searching, Boolean or otherwise. It -is possible to move laterally through the documents by selecting a word -one is interested in and selecting an area of information one is -interested in and trying to look that word up in that area. - -Since Perseus was developed in HyperCard, several levels of customization -are possible. Simple authoring tools exist that allow one to create -annotated paths through the information, which are useful for note-taking -and for guided tours for teaching purposes and for expository writing. -With a little more ingenuity it is possible to begin to add or substitute -material in Perseus. - -Perseus has not been used so much for classics education as for general -education, where it seemed to have an impact on the students in the core -course at Harvard (a general required course that students must take in -certain areas). Students were able to use primary material much more. - -The Perseus Project has an evaluation team at the University of Maryland -that has been documenting Perseus' effects on education. Perseus is very -popular, and anecdotal evidence indicates that it is having an effect at -places other than Harvard, for example, test sites at Ball State -University, Drury College, and numerous small places where opportunities -to use vast amounts of primary data may not exist. One documented effect -is that archaeological, anthropological, and philological research is -being done by the same person instead of by three different people. - -The contextual information in Perseus includes an overview essay, a -fairly linear historical essay on the fifth century B.C. that provides -links into the primary material (e.g., Herodotus, Thucydides, and -Plutarch), via small gray underscoring (on the screen) of linked -passages. These are handmade links into other material. - -To different extents, most of the production work was done at Harvard, -where the people and the equipment are located. Much of the -collaborative activity involved data collection and structuring, because -the main challenge and the emphasis of Perseus is the gathering of -primary material, that is, building a useful environment for studying -classical Greece, collecting data, and making it useful. -Systems-building is definitely not the main concern. Thus, much of the -work has involved writing essays, collecting information, rewriting it, -and tagging it. That can be done off site. The creative link for the -overview essay as well as for both systems and data was collaborative, -and was forged via E-mail and paper mail with professors at Pomona and -Bowdoin. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -CALALUCA * PLD's principal focus and contribution to scholarship * -Various questions preparatory to beginning the project * Basis for -project * Basic rule in converting PLD * Concerning the images in PLD * -Running PLD under a variety of retrieval softwares * Encoding the -database a hard-fought issue * Various features demonstrated * Importance -of user documentation * Limitations of the CD-ROM version * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Eric CALALUCA, vice president, Chadwyck-Healey, Inc., demonstrated a -software interpretation of the Patrologia Latina Database (PLD). PLD's -principal focus from the beginning of the project about three-and-a-half -years ago was on converting Migne's Latin series, and in the end, -CALALUCA suggested, conversion of the text will be the major contribution -to scholarship. CALALUCA stressed that, as possibly the only private -publishing organization at the Workshop, Chadwyck-Healey had sought no -federal funds or national foundation support before embarking upon the -project, but instead had relied upon a great deal of homework and -marketing to accomplish the task of conversion. - -Ever since the possibilities of computer-searching have emerged, scholars -in the field of late ancient and early medieval studies (philosophers, -theologians, classicists, and those studying the history of natural law -and the history of the legal development of Western civilization) have -been longing for a fully searchable version of Western literature, for -example, all the texts of Augustine and Bernard of Clairvaux and -Boethius, not to mention all the secondary and tertiary authors. - -Various questions arose, CALALUCA said. Should one convert Migne? -Should the database be encoded? Is it necessary to do that? How should -it be delivered? What about CD-ROM? Since this is a transitional -medium, why even bother to create software to run on a CD-ROM? Since -everybody knows people will be networking information, why go to the -trouble--which is far greater with CD-ROM than with the production of -magnetic data? Finally, how does one make the data available? Can many -of the hurdles to using electronic information that some publishers have -imposed upon databases be eliminated? - -The PLD project was based on the principle that computer-searching of -texts is most effective when it is done with a large database. Because -PLD represented a collection that serves so many disciplines across so -many periods, it was irresistible. - -The basic rule in converting PLD was to do no harm, to avoid the sins of -intrusion in such a database: no introduction of newer editions, no -on-the-spot changes, no eradicating of all possible falsehoods from an -edition. Thus, PLD is not the final act in electronic publishing for -this discipline, but simply the beginning. The conversion of PLD has -evoked numerous unanticipated questions: How will information be used? -What about networking? Can the rights of a database be protected? -Should one protect the rights of a database? How can it be made -available? - -Those converting PLD also tried to avoid the sins of omission, that is, -excluding portions of the collections or whole sections. What about the -images? PLD is full of images, some are extremely pious -nineteenth-century representations of the Fathers, while others contain -highly interesting elements. The goal was to cover all the text of Migne -(including notes, in Greek and in Hebrew, the latter of which, in -particular, causes problems in creating a search structure), all the -indices, and even the images, which are being scanned in separately -searchable files. - -Several North American institutions that have placed acquisition requests -for the PLD database have requested it in magnetic form without software, -which means they are already running it without software, without -anything demonstrated at the Workshop. - -What cannot practically be done is go back and reconvert and re-encode -data, a time-consuming and extremely costly enterprise. CALALUCA sees -PLD as a database that can, and should, be run under a variety of -retrieval softwares. This will permit the widest possible searches. -Consequently, the need to produce a CD-ROM of PLD, as well as to develop -software that could handle some 1.3 gigabyte of heavily encoded text, -developed out of conversations with collection development and reference -librarians who wanted software both compassionate enough for the -pedestrian but also capable of incorporating the most detailed -lexicographical studies that a user desires to conduct. In the end, the -encoding and conversion of the data will prove the most enduring -testament to the value of the project. - -The encoding of the database was also a hard-fought issue: Did the -database need to be encoded? Were there normative structures for encoding -humanist texts? Should it be SGML? What about the TEI--will it last, -will it prove useful? CALALUCA expressed some minor doubts as to whether -a data bank can be fully TEI-conformant. Every effort can be made, but -in the end to be TEI-conformant means to accept the need to make some -firm encoding decisions that can, indeed, be disputed. The TEI points -the publisher in a proper direction but does not presume to make all the -decisions for him or her. Essentially, the goal of encoding was to -eliminate, as much as possible, the hindrances to information-networking, -so that if an institution acquires a database, everybody associated with -the institution can have access to it. - -CALALUCA demonstrated a portion of Volume 160, because it had the most -anomalies in it. The software was created by Electronic Book -Technologies of Providence, RI, and is called Dynatext. The software -works only with SGML-coded data. - -Viewing a table of contents on the screen, the audience saw how Dynatext -treats each element as a book and attempts to simplify movement through a -volume. Familiarity with the Patrologia in print (i.e., the text, its -source, and the editions) will make the machine-readable versions highly -useful. (Software with a Windows application was sought for PLD, -CALALUCA said, because this was the main trend for scholarly use.) - -CALALUCA also demonstrated how a user can perform a variety of searches -and quickly move to any part of a volume; the look-up screen provides -some basic, simple word-searching. - -CALALUCA argued that one of the major difficulties is not the software. -Rather, in creating a product that will be used by scholars representing -a broad spectrum of computer sophistication, user documentation proves -to be the most important service one can provide. - -CALALUCA next illustrated a truncated search under mysterium within ten -words of virtus and how one would be able to find its contents throughout -the entire database. He said that the exciting thing about PLD is that -many of the applications in the retrieval software being written for it -will exceed the capabilities of the software employed now for the CD-ROM -version. The CD-ROM faces genuine limitations, in terms of speed and -comprehensiveness, in the creation of a retrieval software to run it. -CALALUCA said he hoped that individual scholars will download the data, -if they wish, to their personal computers, and have ready access to -important texts on a constant basis, which they will be able to use in -their research and from which they might even be able to publish. - -(CALALUCA explained that the blue numbers represented Migne's column numbers, -which are the standard scholarly references. Pulling up a note, he stated -that these texts were heavily edited and the image files would appear simply -as a note as well, so that one could quickly access an image.) - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -FLEISCHHAUER/ERWAY * Several problems with which AM is still wrestling * -Various search and retrieval capabilities * Illustration of automatic -stemming and a truncated search * AM's attempt to find ways to connect -cataloging to the texts * AM's gravitation towards SGML * Striking a -balance between quantity and quality * How AM furnishes users recourse to -images * Conducting a search in a full-text environment * Macintosh and -IBM prototypes of AM * Multimedia aspects of AM * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -A demonstration of American Memory by its coordinator, Carl FLEISCHHAUER, -and Ricky ERWAY, associate coordinator, Library of Congress, concluded -the morning session. Beginning with a collection of broadsides from the -Continental Congress and the Constitutional Convention, the only text -collection in a presentable form at the time of the Workshop, FLEISCHHAUER -highlighted several of the problems with which AM is still wrestling. -(In its final form, the disk will contain two collections, not only the -broadsides but also the full text with illustrations of a set of -approximately 300 African-American pamphlets from the period 1870 to 1910.) - -As FREEMAN had explained earlier, AM has attempted to use a small amount -of interpretation to introduce collections. In the present case, the -contractor, a company named Quick Source, in Silver Spring, MD., used -software called Toolbook and put together a modestly interactive -introduction to the collection. Like the two preceding speakers, -FLEISCHHAUER argued that the real asset was the underlying collection. - -FLEISCHHAUER proceeded to describe various search and retrieval -capabilities while ERWAY worked the computer. In this particular package -the "go to" pull-down allowed the user in effect to jump out of Toolbook, -where the interactive program was located, and enter the third-party -software used by AM for this text collection, which is called Personal -Librarian. This was the Windows version of Personal Librarian, a -software application put together by a company in Rockville, Md. - -Since the broadsides came from the Revolutionary War period, a search was -conducted using the words British or war, with the default operator reset -as or. FLEISCHHAUER demonstrated both automatic stemming (which finds -other forms of the same root) and a truncated search. One of Personal -Librarian's strongest features, the relevance ranking, was represented by -a chart that indicated how often words being sought appeared in -documents, with the one receiving the most "hits" obtaining the highest -score. The "hit list" that is supplied takes the relevance ranking into -account, making the first hit, in effect, the one the software has -selected as the most relevant example. - -While in the text of one of the broadside documents, FLEISCHHAUER -remarked AM's attempt to find ways to connect cataloging to the texts, -which it does in different ways in different manifestations. In the case -shown, the cataloging was pasted on: AM took MARC records that were -written as on-line records right into one of the Library's mainframe -retrieval programs, pulled them out, and handed them off to the contractor, -who massaged them somewhat to display them in the manner shown. One of -AM's questions is, Does the cataloguing normally performed in the mainframe -work in this context, or had AM ought to think through adjustments? - -FLEISCHHAUER made the additional point that, as far as the text goes, AM -has gravitated towards SGML (he pointed to the boldface in the upper part -of the screen). Although extremely limited in its ability to translate -or interpret SGML, Personal Librarian will furnish both bold and italics -on screen; a fairly easy thing to do, but it is one of the ways in which -SGML is useful. - -Striking a balance between quantity and quality has been a major concern -of AM, with accuracy being one of the places where project staff have -felt that less than 100-percent accuracy was not unacceptable. -FLEISCHHAUER cited the example of the standard of the rekeying industry, -namely 99.95 percent; as one service bureau informed him, to go from -99.95 to 100 percent would double the cost. - -FLEISCHHAUER next demonstrated how AM furnishes users recourse to images, -and at the same time recalled LESK's pointed question concerning the -number of people who would look at those images and the number who would -work only with the text. If the implication of LESK's question was -sound, FLEISCHHAUER said, it raised the stakes for text accuracy and -reduced the value of the strategy for images. - -Contending that preservation is always a bugaboo, FLEISCHHAUER -demonstrated several images derived from a scan of a preservation -microfilm that AM had made. He awarded a grade of C at best, perhaps a -C minus or a C plus, for how well it worked out. Indeed, the matter of -learning if other people had better ideas about scanning in general, and, -in particular, scanning from microfilm, was one of the factors that drove -AM to attempt to think through the agenda for the Workshop. Skew, for -example, was one of the issues that AM in its ignorance had not reckoned -would prove so difficult. - -Further, the handling of images of the sort shown, in a desktop computer -environment, involved a considerable amount of zooming and scrolling. -Ultimately, AM staff feel that perhaps the paper copy that is printed out -might be the most useful one, but they remain uncertain as to how much -on-screen reading users will do. - -Returning to the text, FLEISCHHAUER asked viewers to imagine a person who -might be conducting a search in a full-text environment. With this -scenario, he proceeded to illustrate other features of Personal Librarian -that he considered helpful; for example, it provides the ability to -notice words as one reads. Clicking the "include" button on the bottom -of the search window pops the words that have been highlighted into the -search. Thus, a user can refine the search as he or she reads, -re-executing the search and continuing to find things in the quest for -materials. This software not only contains relevance ranking, Boolean -operators, and truncation, it also permits one to perform word algebra, -so to say, where one puts two or three words in parentheses and links -them with one Boolean operator and then a couple of words in another set -of parentheses and asks for things within so many words of others. - -Until they became acquainted recently with some of the work being done in -classics, the AM staff had not realized that a large number of the -projects that involve electronic texts were being done by people with a -profound interest in language and linguistics. Their search strategies -and thinking are oriented to those fields, as is shown in particular by -the Perseus example. As amateur historians, the AM staff were thinking -more of searching for concepts and ideas than for particular words. -Obviously, FLEISCHHAUER conceded, searching for concepts and ideas and -searching for words may be two rather closely related things. - -While displaying several images, FLEISCHHAUER observed that the Macintosh -prototype built by AM contains a greater diversity of formats. Echoing a -previous speaker, he said that it was easier to stitch things together in -the Macintosh, though it tended to be a little more anemic in search and -retrieval. AM, therefore, increasingly has been investigating -sophisticated retrieval engines in the IBM format. - -FLEISCHHAUER demonstrated several additional examples of the prototype -interfaces: One was AM's metaphor for the network future, in which a -kind of reading-room graphic suggests how one would be able to go around -to different materials. AM contains a large number of photographs in -analog video form worked up from a videodisc, which enable users to make -copies to print or incorporate in digital documents. A frame-grabber is -built into the system, making it possible to bring an image into a window -and digitize or print it out. - -FLEISCHHAUER next demonstrated sound recording, which included texts. -Recycled from a previous project, the collection included sixty 78-rpm -phonograph records of political speeches that were made during and -immediately after World War I. These constituted approximately three -hours of audio, as AM has digitized it, which occupy 150 megabytes on a -CD. Thus, they are considerably compressed. From the catalogue card, -FLEISCHHAUER proceeded to a transcript of a speech with the audio -available and with highlighted text following it as it played. -A photograph has been added and a transcription made. - -Considerable value has been added beyond what the Library of Congress -normally would do in cataloguing a sound recording, which raises several -questions for AM concerning where to draw lines about how much value it can -afford to add and at what point, perhaps, this becomes more than AM could -reasonably do or reasonably wish to do. FLEISCHHAUER also demonstrated -a motion picture. As FREEMAN had reported earlier, the motion picture -materials have proved the most popular, not surprisingly. This says more -about the medium, he thought, than about AM's presentation of it. - -Because AM's goal was to bring together things that could be used by -historians or by people who were curious about history, -turn-of-the-century footage seemed to represent the most appropriate -collections from the Library of Congress in motion pictures. These were -the very first films made by Thomas Edison's company and some others at -that time. The particular example illustrated was a Biograph film, -brought in with a frame-grabber into a window. A single videodisc -contains about fifty titles and pieces of film from that period, all of -New York City. Taken together, AM believes, they provide an interesting -documentary resource. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Using the frame-grabber in AM * Volume of material processed -and to be processed * Purpose of AM within LC * Cataloguing and the -nature of AM's material * SGML coding and the question of quality versus -quantity * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the question-and-answer period that followed FLEISCHHAUER's -presentation, several clarifications were made. - -AM is bringing in motion pictures from a videodisc. The frame-grabber -devices create a window on a computer screen, which permits users to -digitize a single frame of the movie or one of the photographs. It -produces a crude, rough-and-ready image that high school students can -incorporate into papers, and that has worked very nicely in this way. - -Commenting on FLEISCHHAUER's assertion that AM was looking more at -searching ideas than words, MYLONAS argued that without words an idea -does not exist. FLEISCHHAUER conceded that he ought to have articulated -his point more clearly. MYLONAS stated that they were in fact both -talking about the same thing. By searching for words and by forcing -people to focus on the word, the Perseus Project felt that they would get -them to the idea. The way one reviews results is tailored more to one -kind of user than another. - -Concerning the total volume of material that has been processed in this -way, AM at this point has in retrievable form seven or eight collections, -all of them photographic. In the Macintosh environment, for example, -there probably are 35,000-40,000 photographs. The sound recordings -number sixty items. The broadsides number about 300 items. There are -500 political cartoons in the form of drawings. The motion pictures, as -individual items, number sixty to seventy. - -AM also has a manuscript collection, the life history portion of one of -the federal project series, which will contain 2,900 individual -documents, all first-person narratives. AM has in process about 350 -African-American pamphlets, or about 12,000 printed pages for the period -1870-1910. Also in the works are some 4,000 panoramic photographs. AM -has recycled a fair amount of the work done by LC's Prints and -Photographs Division during the Library's optical disk pilot project in -the 1980s. For example, a special division of LC has tooled up and -thought through all the ramifications of electronic presentation of -photographs. Indeed, they are wheeling them out in great barrel loads. -The purpose of AM within the Library, it is hoped, is to catalyze several -of the other special collection divisions which have no particular -experience with, in some cases, mixed feelings about, an activity such as -AM. Moreover, in many cases the divisions may be characterized as not -only lacking experience in "electronifying" things but also in automated -cataloguing. MARC cataloguing as practiced in the United States is -heavily weighted toward the description of monograph and serial -materials, but is much thinner when one enters the world of manuscripts -and things that are held in the Library's music collection and other -units. In response to a comment by LESK, that AM's material is very -heavily photographic, and is so primarily because individual records have -been made for each photograph, FLEISCHHAUER observed that an item-level -catalog record exists, for example, for each photograph in the Detroit -Publishing collection of 25,000 pictures. In the case of the Federal -Writers Project, for which nearly 3,000 documents exist, representing -information from twenty-six different states, AM with the assistance of -Karen STUART of the Manuscript Division will attempt to find some way not -only to have a collection-level record but perhaps a MARC record for each -state, which will then serve as an umbrella for the 100-200 documents -that come under it. But that drama remains to be enacted. The AM staff -is conservative and clings to cataloguing, though of course visitors tout -artificial intelligence and neural networks in a manner that suggests that -perhaps one need not have cataloguing or that much of it could be put aside. - -The matter of SGML coding, FLEISCHHAUER conceded, returned the discussion -to the earlier treated question of quality versus quantity in the Library -of Congress. Of course, text conversion can be done with 100-percent -accuracy, but it means that when one's holdings are as vast as LC's only -a tiny amount will be exposed, whereas permitting lower levels of -accuracy can lead to exposing or sharing larger amounts, but with the -quality correspondingly impaired. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TWOHIG * A contrary experience concerning electronic options * Volume of -material in the Washington papers and a suggestion of David Packard * -Implications of Packard's suggestion * Transcribing the documents for the -CD-ROM * Accuracy of transcriptions * The CD-ROM edition of the Founding -Fathers documents * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Finding encouragement in a comment of MICHELSON's from the morning -session--that numerous people in the humanities were choosing electronic -options to do their work--Dorothy TWOHIG, editor, The Papers of George -Washington, opened her illustrated talk by noting that her experience -with literary scholars and numerous people in editing was contrary to -MICHELSON's. TWOHIG emphasized literary scholars' complete ignorance of -the technological options available to them or their reluctance or, in -some cases, their downright hostility toward these options. - -After providing an overview of the five Founding Fathers projects -(Jefferson at Princeton, Franklin at Yale, John Adams at the -Massachusetts Historical Society, and Madison down the hall from her at -the University of Virginia), TWOHIG observed that the Washington papers, -like all of the projects, include both sides of the Washington -correspondence and deal with some 135,000 documents to be published with -extensive annotation in eighty to eighty-five volumes, a project that -will not be completed until well into the next century. Thus, it was -with considerable enthusiasm several years ago that the Washington Papers -Project (WPP) greeted David Packard's suggestion that the papers of the -Founding Fathers could be published easily and inexpensively, and to the -great benefit of American scholarship, via CD-ROM. - -In pragmatic terms, funding from the Packard Foundation would expedite -the transcription of thousands of documents waiting to be put on disk in -the WPP offices. Further, since the costs of collecting, editing, and -converting the Founding Fathers documents into letterpress editions were -running into the millions of dollars, and the considerable staffs -involved in all of these projects were devoting their careers to -producing the work, the Packard Foundation's suggestion had a -revolutionary aspect: Transcriptions of the entire corpus of the -Founding Fathers papers would be available on CD-ROM to public and -college libraries, even high schools, at a fraction of the cost-- -$100-$150 for the annual license fee--to produce a limited university -press run of 1,000 of each volume of the published papers at $45-$150 per -printed volume. Given the current budget crunch in educational systems -and the corresponding constraints on librarians in smaller institutions -who wish to add these volumes to their collections, producing the -documents on CD-ROM would likely open a greatly expanded audience for the -papers. TWOHIG stressed, however, that development of the Founding -Fathers CD-ROM is still in its infancy. Serious software problems remain -to be resolved before the material can be put into readable form. - -Funding from the Packard Foundation resulted in a major push to -transcribe the 75,000 or so documents of the Washington papers remaining -to be transcribed onto computer disks. Slides illustrated several of the -problems encountered, for example, the present inability of CD-ROM to -indicate the cross-outs (deleted material) in eighteenth century -documents. TWOHIG next described documents from various periods in the -eighteenth century that have been transcribed in chronological order and -delivered to the Packard offices in California, where they are converted -to the CD-ROM, a process that is expected to consume five years to -complete (that is, reckoning from David Packard's suggestion made several -years ago, until about July 1994). TWOHIG found an encouraging -indication of the project's benefits in the ongoing use made by scholars -of the search functions of the CD-ROM, particularly in reducing the time -spent in manually turning the pages of the Washington papers. - -TWOHIG next furnished details concerning the accuracy of transcriptions. -For instance, the insertion of thousands of documents on the CD-ROM -currently does not permit each document to be verified against the -original manuscript several times as in the case of documents that appear -in the published edition. However, the transcriptions receive a cursory -check for obvious typos, the misspellings of proper names, and other -errors from the WPP CD-ROM editor. Eventually, all documents that appear -in the electronic version will be checked by project editors. Although -this process has met with opposition from some of the editors on the -grounds that imperfect work may leave their offices, the advantages in -making this material available as a research tool outweigh fears about the -misspelling of proper names and other relatively minor editorial matters. - -Completion of all five Founding Fathers projects (i.e., retrievability -and searchability of all of the documents by proper names, alternate -spellings, or varieties of subjects) will provide one of the richest -sources of this size for the history of the United States in the latter -part of the eighteenth century. Further, publication on CD-ROM will -allow editors to include even minutiae, such as laundry lists, not -included in the printed volumes. - -It seems possible that the extensive annotation provided in the printed -volumes eventually will be added to the CD-ROM edition, pending -negotiations with the publishers of the papers. At the moment, the -Founding Fathers CD-ROM is accessible only on the IBYCUS, a computer -developed out of the Thesaurus Linguae Graecae project and designed for -the use of classical scholars. There are perhaps 400 IBYCUS computers in -the country, most of which are in university classics departments. -Ultimately, it is anticipated that the CD-ROM edition of the Founding -Fathers documents will run on any IBM-compatible or Macintosh computer -with a CD-ROM drive. Numerous changes in the software will also occur -before the project is completed. (Editor's note: an IBYCUS was -unavailable to demonstrate the CD-ROM.) - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Several additional features of WPP clarified * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Discussion following TWOHIG's presentation served to clarify several -additional features, including (1) that the project's primary -intellectual product consists in the electronic transcription of the -material; (2) that the text transmitted to the CD-ROM people is not -marked up; (3) that cataloging and subject-indexing of the material -remain to be worked out (though at this point material can be retrieved -by name); and (4) that because all the searching is done in the hardware, -the IBYCUS is designed to read a CD-ROM which contains only sequential -text files. Technically, it then becomes very easy to read the material -off and put it on another device. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -LEBRON * Overview of the history of the joint project between AAAS and -OCLC * Several practices the on-line environment shares with traditional -publishing on hard copy * Several technical and behavioral barriers to -electronic publishing * How AAAS and OCLC arrived at the subject of -clinical trials * Advantages of the electronic format and other features -of OJCCT * An illustrated tour of the journal * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Maria LEBRON, managing editor, The Online Journal of Current Clinical -Trials (OJCCT), presented an illustrated overview of the history of the -joint project between the American Association for the Advancement of -Science (AAAS) and the Online Computer Library Center, Inc. (OCLC). The -joint venture between AAAS and OCLC owes its beginning to a -reorganization launched by the new chief executive officer at OCLC about -three years ago and combines the strengths of these two disparate -organizations. In short, OJCCT represents the process of scholarly -publishing on line. - -LEBRON next discussed several practices the on-line environment shares -with traditional publishing on hard copy--for example, peer review of -manuscripts--that are highly important in the academic world. LEBRON -noted in particular the implications of citation counts for tenure -committees and grants committees. In the traditional hard-copy -environment, citation counts are readily demonstrable, whereas the -on-line environment represents an ethereal medium to most academics. - -LEBRON remarked several technical and behavioral barriers to electronic -publishing, for instance, the problems in transmission created by special -characters or by complex graphics and halftones. In addition, she noted -economic limitations such as the storage costs of maintaining back issues -and market or audience education. - -Manuscripts cannot be uploaded to OJCCT, LEBRON explained, because it is -not a bulletin board or E-mail, forms of electronic transmission of -information that have created an ambience clouding people's understanding -of what the journal is attempting to do. OJCCT, which publishes -peer-reviewed medical articles dealing with the subject of clinical -trials, includes text, tabular material, and graphics, although at this -time it can transmit only line illustrations. - -Next, LEBRON described how AAAS and OCLC arrived at the subject of -clinical trials: It is 1) a highly statistical discipline that 2) does -not require halftones but can satisfy the needs of its audience with line -illustrations and graphic material, and 3) there is a need for the speedy -dissemination of high-quality research results. Clinical trials are -research activities that involve the administration of a test treatment -to some experimental unit in order to test its usefulness before it is -made available to the general population. LEBRON proceeded to give -additional information on OJCCT concerning its editor-in-chief, editorial -board, editorial content, and the types of articles it publishes -(including peer-reviewed research reports and reviews), as well as -features shared by other traditional hard-copy journals. - -Among the advantages of the electronic format are faster dissemination of -information, including raw data, and the absence of space constraints -because pages do not exist. (This latter fact creates an interesting -situation when it comes to citations.) Nor are there any issues. AAAS's -capacity to download materials directly from the journal to a -subscriber's printer, hard drive, or floppy disk helps ensure highly -accurate transcription. Other features of OJCCT include on-screen alerts -that allow linkage of subsequently published documents to the original -documents; on-line searching by subject, author, title, etc.; indexing of -every single word that appears in an article; viewing access to an -article by component (abstract, full text, or graphs); numbered -paragraphs to replace page counts; publication in Science every thirty -days of indexing of all articles published in the journal; -typeset-quality screens; and Hypertext links that enable subscribers to -bring up Medline abstracts directly without leaving the journal. - -After detailing the two primary ways to gain access to the journal, -through the OCLC network and Compuserv if one desires graphics or through -the Internet if just an ASCII file is desired, LEBRON illustrated the -speedy editorial process and the coding of the document using SGML tags -after it has been accepted for publication. She also gave an illustrated -tour of the journal, its search-and-retrieval capabilities in particular, -but also including problems associated with scanning in illustrations, -and the importance of on-screen alerts to the medical profession re -retractions or corrections, or more frequently, editorials, letters to -the editors, or follow-up reports. She closed by inviting the audience -to join AAAS on 1 July, when OJCCT was scheduled to go on-line. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Additional features of OJCCT * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -In the lengthy discussion that followed LEBRON's presentation, these -points emerged: - - * The SGML text can be tailored as users wish. - - * All these articles have a fairly simple document definition. - - * Document-type definitions (DTDs) were developed and given to OJCCT - for coding. - - * No articles will be removed from the journal. (Because there are - no back issues, there are no lost issues either. Once a subscriber - logs onto the journal he or she has access not only to the currently - published materials, but retrospectively to everything that has been - published in it. Thus the table of contents grows bigger. The date - of publication serves to distinguish between currently published - materials and older materials.) - - * The pricing system for the journal resembles that for most medical - journals: for 1992, $95 for a year, plus telecommunications charges - (there are no connect time charges); for 1993, $110 for the - entire year for single users, though the journal can be put on a - local area network (LAN). However, only one person can access the - journal at a time. Site licenses may come in the future. - - * AAAS is working closely with colleagues at OCLC to display - mathematical equations on screen. - - * Without compromising any steps in the editorial process, the - technology has reduced the time lag between when a manuscript is - originally submitted and the time it is accepted; the review process - does not differ greatly from the standard six-to-eight weeks - employed by many of the hard-copy journals. The process still - depends on people. - - * As far as a preservation copy is concerned, articles will be - maintained on the computer permanently and subscribers, as part of - their subscription, will receive a microfiche-quality archival copy - of everything published during that year; in addition, reprints can - be purchased in much the same way as in a hard-copy environment. - Hard copies are prepared but are not the primary medium for the - dissemination of the information. - - * Because OJCCT is not yet on line, it is difficult to know how many - people would simply browse through the journal on the screen as - opposed to downloading the whole thing and printing it out; a mix of - both types of users likely will result. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -PERSONIUS * Developments in technology over the past decade * The CLASS -Project * Advantages for technology and for the CLASS Project * -Developing a network application an underlying assumption of the project -* Details of the scanning process * Print-on-demand copies of books * -Future plans include development of a browsing tool * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Lynne PERSONIUS, assistant director, Cornell Information Technologies for -Scholarly Information Services, Cornell University, first commented on -the tremendous impact that developments in technology over the past ten -years--networking, in particular--have had on the way information is -handled, and how, in her own case, these developments have counterbalanced -Cornell's relative geographical isolation. Other significant technologies -include scanners, which are much more sophisticated than they were ten years -ago; mass storage and the dramatic savings that result from it in terms of -both space and money relative to twenty or thirty years ago; new and -improved printing technologies, which have greatly affected the distribution -of information; and, of course, digital technologies, whose applicability to -library preservation remains at issue. - -Given that context, PERSONIUS described the College Library Access and -Storage System (CLASS) Project, a library preservation project, -primarily, and what has been accomplished. Directly funded by the -Commission on Preservation and Access and by the Xerox Corporation, which -has provided a significant amount of hardware, the CLASS Project has been -working with a development team at Xerox to develop a software -application tailored to library preservation requirements. Within -Cornell, participants in the project have been working jointly with both -library and information technologies. The focus of the project has been -on reformatting and saving books that are in brittle condition. -PERSONIUS showed Workshop participants a brittle book, and described how -such books were the result of developments in papermaking around the -beginning of the Industrial Revolution. The papermaking process was -changed so that a significant amount of acid was introduced into the -actual paper itself, which deteriorates as it sits on library shelves. - -One of the advantages for technology and for the CLASS Project is that -the information in brittle books is mostly out of copyright and thus -offers an opportunity to work with material that requires library -preservation, and to create and work on an infrastructure to save the -material. Acknowledging the familiarity of those working in preservation -with this information, PERSONIUS noted that several things are being -done: the primary preservation technology used today is photocopying of -brittle material. Saving the intellectual content of the material is the -main goal. With microfilm copy, the intellectual content is preserved on -the assumption that in the future the image can be reformatted in any -other way that then exists. - -An underlying assumption of the CLASS Project from the beginning was -that it would develop a network application. Project staff scan books -at a workstation located in the library, near the brittle material. -An image-server filing system is located at a distance from that -workstation, and a printer is located in another building. All of the -materials digitized and stored on the image-filing system are cataloged -in the on-line catalogue. In fact, a record for each of these electronic -books is stored in the RLIN database so that a record exists of what is -in the digital library throughout standard catalogue procedures. In the -future, researchers working from their own workstations in their offices, -or their networks, will have access--wherever they might be--through a -request server being built into the new digital library. A second -assumption is that the preferred means of finding the material will be by -looking through a catalogue. PERSONIUS described the scanning process, -which uses a prototype scanner being developed by Xerox and which scans a -very high resolution image at great speed. Another significant feature, -because this is a preservation application, is the placing of the pages -that fall apart one for one on the platen. Ordinarily, a scanner could -be used with some sort of a document feeder, but because of this -application that is not feasible. Further, because CLASS is a -preservation application, after the paper replacement is made there, a -very careful quality control check is performed. An original book is -compared to the printed copy and verification is made, before proceeding, -that all of the image, all of the information, has been captured. Then, -a new library book is produced: The printed images are rebound by a -commercial binder and a new book is returned to the shelf. -Significantly, the books returned to the library shelves are beautiful -and useful replacements on acid-free paper that should last a long time, -in effect, the equivalent of preservation photocopies. Thus, the project -has a library of digital books. In essence, CLASS is scanning and -storing books as 600 dot-per-inch bit-mapped images, compressed using -Group 4 CCITT (i.e., the French acronym for International Consultative -Committee for Telegraph and Telephone) compression. They are stored as -TIFF files on an optical filing system that is composed of a database -used for searching and locating the books and an optical jukebox that -stores 64 twelve-inch platters. A very-high-resolution printed copy of -these books at 600 dots per inch is created, using a Xerox DocuTech -printer to make the paper replacements on acid-free paper. - -PERSONIUS maintained that the CLASS Project presents an opportunity to -introduce people to books as digital images by using a paper medium. -Books are returned to the shelves while people are also given the ability -to print on demand--to make their own copies of books. (PERSONIUS -distributed copies of an engineering journal published by engineering -students at Cornell around 1900 as an example of what a print-on-demand -copy of material might be like. This very cheap copy would be available -to people to use for their own research purposes and would bridge the gap -between an electronic work and the paper that readers like to have.) -PERSONIUS then attempted to illustrate a very early prototype of -networked access to this digital library. Xerox Corporation has -developed a prototype of a view station that can send images across the -network to be viewed. - -The particular library brought down for demonstration contained two -mathematics books. CLASS is developing and will spend the next year -developing an application that allows people at workstations to browse -the books. Thus, CLASS is developing a browsing tool, on the assumption -that users do not want to read an entire book from a workstation, but -would prefer to be able to look through and decide if they would like to -have a printed copy of it. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Re retrieval software * "Digital file copyright" * Scanning -rate during production * Autosegmentation * Criteria employed in -selecting books for scanning * Compression and decompression of images * -OCR not precluded * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the question-and-answer period that followed her presentation, -PERSONIUS made these additional points: - - * Re retrieval software, Cornell is developing a Unix-based server - as well as clients for the server that support multiple platforms - (Macintosh, IBM and Sun workstations), in the hope that people from - any of those platforms will retrieve books; a further operating - assumption is that standard interfaces will be used as much as - possible, where standards can be put in place, because CLASS - considers this retrieval software a library application and would - like to be able to look at material not only at Cornell but at other - institutions. - - * The phrase "digital file copyright by Cornell University" was - added at the advice of Cornell's legal staff with the caveat that it - probably would not hold up in court. Cornell does not want people - to copy its books and sell them but would like to keep them - available for use in a library environment for library purposes. - - * In production the scanner can scan about 300 pages per hour, - capturing 600 dots per inch. - - * The Xerox software has filters to scan halftone material and avoid - the moire patterns that occur when halftone material is scanned. - Xerox has been working on hardware and software that would enable - the scanner itself to recognize this situation and deal with it - appropriately--a kind of autosegmentation that would enable the - scanner to handle halftone material as well as text on a single page. - - * The books subjected to the elaborate process described above were - selected because CLASS is a preservation project, with the first 500 - books selected coming from Cornell's mathematics collection, because - they were still being heavily used and because, although they were - in need of preservation, the mathematics library and the mathematics - faculty were uncomfortable having them microfilmed. (They wanted a - printed copy.) Thus, these books became a logical choice for this - project. Other books were chosen by the project's selection committees - for experiments with the technology, as well as to meet a demand or need. - - * Images will be decompressed before they are sent over the line; at - this time they are compressed and sent to the image filing system - and then sent to the printer as compressed images; they are returned - to the workstation as compressed 600-dpi images and the workstation - decompresses and scales them for display--an inefficient way to - access the material though it works quite well for printing and - other purposes. - - * CLASS is also decompressing on Macintosh and IBM, a slow process - right now. Eventually, compression and decompression will take - place on an image conversion server. Trade-offs will be made, based - on future performance testing, concerning where the file is - compressed and what resolution image is sent. - - * OCR has not been precluded; images are being stored that have been - scanned at a high resolution, which presumably would suit them well - to an OCR process. Because the material being scanned is about 100 - years old and was printed with less-than-ideal technologies, very - early and preliminary tests have not produced good results. But the - project is capturing an image that is of sufficient resolution to be - subjected to OCR in the future. Moreover, the system architecture - and the system plan have a logical place to store an OCR image if it - has been captured. But that is not being done now. - - ****** - -SESSION III. DISTRIBUTION, NETWORKS, AND NETWORKING: OPTIONS FOR -DISSEMINATION - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -ZICH * Issues pertaining to CD-ROMs * Options for publishing in CD-ROM * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Robert ZICH, special assistant to the associate librarian for special -projects, Library of Congress, and moderator of this session, first noted -the blessed but somewhat awkward circumstance of having four very -distinguished people representing networks and networking or at least -leaning in that direction, while lacking anyone to speak from the -strongest possible background in CD-ROMs. ZICH expressed the hope that -members of the audience would join the discussion. He stressed the -subtitle of this particular session, "Options for Dissemination," and, -concerning CD-ROMs, the importance of determining when it would be wise -to consider dissemination in CD-ROM versus networks. A shopping list of -issues pertaining to CD-ROMs included: the grounds for selecting -commercial publishers, and in-house publication where possible versus -nonprofit or government publication. A similar list for networks -included: determining when one should consider dissemination through a -network, identifying the mechanisms or entities that exist to place items -on networks, identifying the pool of existing networks, determining how a -producer would choose between networks, and identifying the elements of -a business arrangement in a network. - -Options for publishing in CD-ROM: an outside publisher versus -self-publication. If an outside publisher is used, it can be nonprofit, -such as the Government Printing Office (GPO) or the National Technical -Information Service (NTIS), in the case of government. The pros and cons -associated with employing an outside publisher are obvious. Among the -pros, there is no trouble getting accepted. One pays the bill and, in -effect, goes one's way. Among the cons, when one pays an outside -publisher to perform the work, that publisher will perform the work it is -obliged to do, but perhaps without the production expertise and skill in -marketing and dissemination that some would seek. There is the body of -commercial publishers that do possess that kind of expertise in -distribution and marketing but that obviously are selective. In -self-publication, one exercises full control, but then one must handle -matters such as distribution and marketing. Such are some of the options -for publishing in the case of CD-ROM. - -In the case of technical and design issues, which are also important, -there are many matters which many at the Workshop already knew a good -deal about: retrieval system requirements and costs, what to do about -images, the various capabilities and platforms, the trade-offs between -cost and performance, concerns about local-area networkability, -interoperability, etc. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -LYNCH * Creating networked information is different from using networks -as an access or dissemination vehicle * Networked multimedia on a large -scale does not yet work * Typical CD-ROM publication model a two-edged -sword * Publishing information on a CD-ROM in the present world of -immature standards * Contrast between CD-ROM and network pricing * -Examples demonstrated earlier in the day as a set of insular information -gems * Paramount need to link databases * Layering to become increasingly -necessary * Project NEEDS and the issues of information reuse and active -versus passive use * X-Windows as a way of differentiating between -network access and networked information * Barriers to the distribution -of networked multimedia information * Need for good, real-time delivery -protocols * The question of presentation integrity in client-server -computing in the academic world * Recommendations for producing multimedia -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Clifford LYNCH, director, Library Automation, University of California, -opened his talk with the general observation that networked information -constituted a difficult and elusive topic because it is something just -starting to develop and not yet fully understood. LYNCH contended that -creating genuinely networked information was different from using -networks as an access or dissemination vehicle and was more sophisticated -and more subtle. He invited the members of the audience to extrapolate, -from what they heard about the preceding demonstration projects, to what -sort of a world of electronics information--scholarly, archival, -cultural, etc.--they wished to end up with ten or fifteen years from now. -LYNCH suggested that to extrapolate directly from these projects would -produce unpleasant results. - -Putting the issue of CD-ROM in perspective before getting into -generalities on networked information, LYNCH observed that those engaged -in multimedia today who wish to ship a product, so to say, probably do -not have much choice except to use CD-ROM: networked multimedia on a -large scale basically does not yet work because the technology does not -exist. For example, anybody who has tried moving images around over the -Internet knows that this is an exciting touch-and-go process, a -fascinating and fertile area for experimentation, research, and -development, but not something that one can become deeply enthusiastic -about committing to production systems at this time. - -This situation will change, LYNCH said. He differentiated CD-ROM from -the practices that have been followed up to now in distributing data on -CD-ROM. For LYNCH the problem with CD-ROM is not its portability or its -slowness but the two-edged sword of having the retrieval application and -the user interface inextricably bound up with the data, which is the -typical CD-ROM publication model. It is not a case of publishing data -but of distributing a typically stand-alone, typically closed system, -all--software, user interface, and data--on a little disk. Hence, all -the between-disk navigational issues as well as the impossibility in most -cases of integrating data on one disk with that on another. Most CD-ROM -retrieval software does not network very gracefully at present. However, -in the present world of immature standards and lack of understanding of -what network information is or what the ground rules are for creating or -using it, publishing information on a CD-ROM does add value in a very -real sense. - -LYNCH drew a contrast between CD-ROM and network pricing and in doing so -highlighted something bizarre in information pricing. A large -institution such as the University of California has vendors who will -offer to sell information on CD-ROM for a price per year in four digits, -but for the same data (e.g., an abstracting and indexing database) on -magnetic tape, regardless of how many people may use it concurrently, -will quote a price in six digits. - -What is packaged with the CD-ROM in one sense adds value--a complete -access system, not just raw, unrefined information--although it is not -generally perceived that way. This is because the access software, -although it adds value, is viewed by some people, particularly in the -university environment where there is a very heavy commitment to -networking, as being developed in the wrong direction. - -Given that context, LYNCH described the examples demonstrated as a set of -insular information gems--Perseus, for example, offers nicely linked -information, but would be very difficult to integrate with other -databases, that is, to link together seamlessly with other source files -from other sources. It resembles an island, and in this respect is -similar to numerous stand-alone projects that are based on videodiscs, -that is, on the single-workstation concept. - -As scholarship evolves in a network environment, the paramount need will -be to link databases. We must link personal databases to public -databases, to group databases, in fairly seamless ways--which is -extremely difficult in the environments under discussion with copies of -databases proliferating all over the place. - -The notion of layering also struck LYNCH as lurking in several of the -projects demonstrated. Several databases in a sense constitute -information archives without a significant amount of navigation built in. -Educators, critics, and others will want a layered structure--one that -defines or links paths through the layers to allow users to reach -specific points. In LYNCH's view, layering will become increasingly -necessary, and not just within a single resource but across resources -(e.g., tracing mythology and cultural themes across several classics -databases as well as a database of Renaissance culture). This ability to -organize resources, to build things out of multiple other things on the -network or select pieces of it, represented for LYNCH one of the key -aspects of network information. - -Contending that information reuse constituted another significant issue, -LYNCH commended to the audience's attention Project NEEDS (i.e., National -Engineering Education Delivery System). This project's objective is to -produce a database of engineering courseware as well as the components -that can be used to develop new courseware. In a number of the existing -applications, LYNCH said, the issue of reuse (how much one can take apart -and reuse in other applications) was not being well considered. He also -raised the issue of active versus passive use, one aspect of which is -how much information will be manipulated locally by users. Most people, -he argued, may do a little browsing and then will wish to print. LYNCH -was uncertain how these resources would be used by the vast majority of -users in the network environment. - -LYNCH next said a few words about X-Windows as a way of differentiating -between network access and networked information. A number of the -applications demonstrated at the Workshop could be rewritten to use X -across the network, so that one could run them from any X-capable device- --a workstation, an X terminal--and transact with a database across the -network. Although this opens up access a little, assuming one has enough -network to handle it, it does not provide an interface to develop a -program that conveniently integrates information from multiple databases. -X is a viewing technology that has limits. In a real sense, it is just a -graphical version of remote log-in across the network. X-type applications -represent only one step in the progression towards real access. - -LYNCH next discussed barriers to the distribution of networked multimedia -information. The heart of the problem is a lack of standards to provide -the ability for computers to talk to each other, retrieve information, -and shuffle it around fairly casually. At the moment, little progress is -being made on standards for networked information; for example, present -standards do not cover images, digital voice, and digital video. A -useful tool kit of exchange formats for basic texts is only now being -assembled. The synchronization of content streams (i.e., synchronizing a -voice track to a video track, establishing temporal relations between -different components in a multimedia object) constitutes another issue -for networked multimedia that is just beginning to receive attention. - -Underlying network protocols also need some work; good, real-time -delivery protocols on the Internet do not yet exist. In LYNCH's view, -highly important in this context is the notion of networked digital -object IDs, the ability of one object on the network to point to another -object (or component thereof) on the network. Serious bandwidth issues -also exist. LYNCH was uncertain if billion-bit-per-second networks would -prove sufficient if numerous people ran video in parallel. - -LYNCH concluded by offering an issue for database creators to consider, -as well as several comments about what might constitute good trial -multimedia experiments. In a networked information world the database -builder or service builder (publisher) does not exercise the same -extensive control over the integrity of the presentation; strange -programs "munge" with one's data before the user sees it. Serious -thought must be given to what guarantees integrity of presentation. Part -of that is related to where one draws the boundaries around a networked -information service. This question of presentation integrity in -client-server computing has not been stressed enough in the academic -world, LYNCH argued, though commercial service providers deal with it -regularly. - -Concerning multimedia, LYNCH observed that good multimedia at the moment -is hideously expensive to produce. He recommended producing multimedia -with either very high sale value, or multimedia with a very long life -span, or multimedia that will have a very broad usage base and whose -costs therefore can be amortized among large numbers of users. In this -connection, historical and humanistically oriented material may be a good -place to start, because it tends to have a longer life span than much of -the scientific material, as well as a wider user base. LYNCH noted, for -example, that American Memory fits many of the criteria outlined. He -remarked the extensive discussion about bringing the Internet or the -National Research and Education Network (NREN) into the K-12 environment -as a way of helping the American educational system. - -LYNCH closed by noting that the kinds of applications demonstrated struck -him as excellent justifications of broad-scale networking for K-12, but -that at this time no "killer" application exists to mobilize the K-12 -community to obtain connectivity. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Dearth of genuinely interesting applications on the network -a slow-changing situation * The issue of the integrity of presentation in -a networked environment * Several reasons why CD-ROM software does not -network * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the discussion period that followed LYNCH's presentation, several -additional points were made. - -LYNCH reiterated even more strongly his contention that, historically, -once one goes outside high-end science and the group of those who need -access to supercomputers, there is a great dearth of genuinely -interesting applications on the network. He saw this situation changing -slowly, with some of the scientific databases and scholarly discussion -groups and electronic journals coming on as well as with the availability -of Wide Area Information Servers (WAIS) and some of the databases that -are being mounted there. However, many of those things do not seem to -have piqued great popular interest. For instance, most high school -students of LYNCH's acquaintance would not qualify as devotees of serious -molecular biology. - -Concerning the issue of the integrity of presentation, LYNCH believed -that a couple of information providers have laid down the law at least on -certain things. For example, his recollection was that the National -Library of Medicine feels strongly that one needs to employ the -identifier field if he or she is to mount a database commercially. The -problem with a real networked environment is that one does not know who -is reformatting and reprocessing one's data when one enters a client -server mode. It becomes anybody's guess, for example, if the network -uses a Z39.50 server, or what clients are doing with one's data. A data -provider can say that his contract will only permit clients to have -access to his data after he vets them and their presentation and makes -certain it suits him. But LYNCH held out little expectation that the -network marketplace would evolve in that way, because it required too -much prior negotiation. - -CD-ROM software does not network for a variety of reasons, LYNCH said. -He speculated that CD-ROM publishers are not eager to have their products -really hook into wide area networks, because they fear it will make their -data suppliers nervous. Moreover, until relatively recently, one had to -be rather adroit to run a full TCP/IP stack plus applications on a -PC-size machine, whereas nowadays it is becoming easier as PCs grow -bigger and faster. LYNCH also speculated that software providers had not -heard from their customers until the last year or so, or had not heard -from enough of their customers. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -BESSER * Implications of disseminating images on the network; planning -the distribution of multimedia documents poses two critical -implementation problems * Layered approach represents the way to deal -with users' capabilities * Problems in platform design; file size and its -implications for networking * Transmission of megabyte size images -impractical * Compression and decompression at the user's end * Promising -trends for compression * A disadvantage of using X-Windows * A project at -the Smithsonian that mounts images on several networks * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Howard BESSER, School of Library and Information Science, University of -Pittsburgh, spoke primarily about multimedia, focusing on images and the -broad implications of disseminating them on the network. He argued that -planning the distribution of multimedia documents posed two critical -implementation problems, which he framed in the form of two questions: -1) What platform will one use and what hardware and software will users -have for viewing of the material? and 2) How can one deliver a -sufficiently robust set of information in an accessible format in a -reasonable amount of time? Depending on whether network or CD-ROM is the -medium used, this question raises different issues of storage, -compression, and transmission. - -Concerning the design of platforms (e.g., sound, gray scale, simple -color, etc.) and the various capabilities users may have, BESSER -maintained that a layered approach was the way to deal with users' -capabilities. A result would be that users with less powerful -workstations would simply have less functionality. He urged members of -the audience to advocate standards and accompanying software that handle -layered functionality across a wide variety of platforms. - -BESSER also addressed problems in platform design, namely, deciding how -large a machine to design for situations when the largest number of users -have the lowest level of the machine, and one desires higher -functionality. BESSER then proceeded to the question of file size and -its implications for networking. He discussed still images in the main. -For example, a digital color image that fills the screen of a standard -mega-pel workstation (Sun or Next) will require one megabyte of storage -for an eight-bit image or three megabytes of storage for a true color or -twenty-four-bit image. Lossless compression algorithms (that is, -computational procedures in which no data is lost in the process of -compressing [and decompressing] an image--the exact bit-representation is -maintained) might bring storage down to a third of a megabyte per image, -but not much further than that. The question of size makes it difficult -to fit an appropriately sized set of these images on a single disk or to -transmit them quickly enough on a network. - -With these full screen mega-pel images that constitute a third of a -megabyte, one gets 1,000-3,000 full-screen images on a one-gigabyte disk; -a standard CD-ROM represents approximately 60 percent of that. Storing -images the size of a PC screen (just 8 bit color) increases storage -capacity to 4,000-12,000 images per gigabyte; 60 percent of that gives -one the size of a CD-ROM, which in turn creates a major problem. One -cannot have full-screen, full-color images with lossless compression; one -must compress them or use a lower resolution. For megabyte-size images, -anything slower than a T-1 speed is impractical. For example, on a -fifty-six-kilobaud line, it takes three minutes to transfer a -one-megabyte file, if it is not compressed; and this speed assumes ideal -circumstances (no other user contending for network bandwidth). Thus, -questions of disk access, remote display, and current telephone -connection speed make transmission of megabyte-size images impractical. - -BESSER then discussed ways to deal with these large images, for example, -compression and decompression at the user's end. In this connection, the -issues of how much one is willing to lose in the compression process and -what image quality one needs in the first place are unknown. But what is -known is that compression entails some loss of data. BESSER urged that -more studies be conducted on image quality in different situations, for -example, what kind of images are needed for what kind of disciplines, and -what kind of image quality is needed for a browsing tool, an intermediate -viewing tool, and archiving. - -BESSER remarked two promising trends for compression: from a technical -perspective, algorithms that use what is called subjective redundancy -employ principles from visual psycho-physics to identify and remove -information from the image that the human eye cannot perceive; from an -interchange and interoperability perspective, the JPEG (i.e., Joint -Photographic Experts Group, an ISO standard) compression algorithms also -offer promise. These issues of compression and decompression, BESSER -argued, resembled those raised earlier concerning the design of different -platforms. Gauging the capabilities of potential users constitutes a -primary goal. BESSER advocated layering or separating the images from -the applications that retrieve and display them, to avoid tying them to -particular software. - -BESSER detailed several lessons learned from his work at Berkeley with -Imagequery, especially the advantages and disadvantages of using -X-Windows. In the latter category, for example, retrieval is tied -directly to one's data, an intolerable situation in the long run on a -networked system. Finally, BESSER described a project of Jim Wallace at -the Smithsonian Institution, who is mounting images in a extremely -rudimentary way on the Compuserv and Genie networks and is preparing to -mount them on America On Line. Although the average user takes over -thirty minutes to download these images (assuming a fairly fast modem), -nevertheless, images have been downloaded 25,000 times. - -BESSER concluded his talk with several comments on the business -arrangement between the Smithsonian and Compuserv. He contended that not -enough is known concerning the value of images. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Creating digitized photographic collections nearly -impossible except with large organizations like museums * Need for study -to determine quality of images users will tolerate * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the brief exchange between LESK and BESSER that followed, several -clarifications emerged. - -LESK argued that the photographers were far ahead of BESSER: It is -almost impossible to create such digitized photographic collections -except with large organizations like museums, because all the -photographic agencies have been going crazy about this and will not sign -licensing agreements on any sort of reasonable terms. LESK had heard -that National Geographic, for example, had tried to buy the right to use -some image in some kind of educational production for $100 per image, but -the photographers will not touch it. They want accounting and payment -for each use, which cannot be accomplished within the system. BESSER -responded that a consortium of photographers, headed by a former National -Geographic photographer, had started assembling its own collection of -electronic reproductions of images, with the money going back to the -cooperative. - -LESK contended that BESSER was unnecessarily pessimistic about multimedia -images, because people are accustomed to low-quality images, particularly -from video. BESSER urged the launching of a study to determine what -users would tolerate, what they would feel comfortable with, and what -absolutely is the highest quality they would ever need. Conceding that -he had adopted a dire tone in order to arouse people about the issue, -BESSER closed on a sanguine note by saying that he would not be in this -business if he did not think that things could be accomplished. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -LARSEN * Issues of scalability and modularity * Geometric growth of the -Internet and the role played by layering * Basic functions sustaining -this growth * A library's roles and functions in a network environment * -Effects of implementation of the Z39.50 protocol for information -retrieval on the library system * The trade-off between volumes of data -and its potential usage * A snapshot of current trends * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Ronald LARSEN, associate director for information technology, University -of Maryland at College Park, first addressed the issues of scalability -and modularity. He noted the difficulty of anticipating the effects of -orders-of-magnitude growth, reflecting on the twenty years of experience -with the Arpanet and Internet. Recalling the day's demonstrations of -CD-ROM and optical disk material, he went on to ask if the field has yet -learned how to scale new systems to enable delivery and dissemination -across large-scale networks. - -LARSEN focused on the geometric growth of the Internet from its inception -circa 1969 to the present, and the adjustments required to respond to -that rapid growth. To illustrate the issue of scalability, LARSEN -considered computer networks as including three generic components: -computers, network communication nodes, and communication media. Each -component scales (e.g., computers range from PCs to supercomputers; -network nodes scale from interface cards in a PC through sophisticated -routers and gateways; and communication media range from 2,400-baud -dial-up facilities through 4.5-Mbps backbone links, and eventually to -multigigabit-per-second communication lines), and architecturally, the -components are organized to scale hierarchically from local area networks -to international-scale networks. Such growth is made possible by -building layers of communication protocols, as BESSER pointed out. -By layering both physically and logically, a sense of scalability is -maintained from local area networks in offices, across campuses, through -bridges, routers, campus backbones, fiber-optic links, etc., up into -regional networks and ultimately into national and international -networks. - -LARSEN then illustrated the geometric growth over a two-year period-- -through September 1991--of the number of networks that comprise the -Internet. This growth has been sustained largely by the availability of -three basic functions: electronic mail, file transfer (ftp), and remote -log-on (telnet). LARSEN also reviewed the growth in the kind of traffic -that occurs on the network. Network traffic reflects the joint contributions -of a larger population of users and increasing use per user. Today one sees -serious applications involving moving images across the network--a rarity -ten years ago. LARSEN recalled and concurred with BESSER's main point -that the interesting problems occur at the application level. - -LARSEN then illustrated a model of a library's roles and functions in a -network environment. He noted, in particular, the placement of on-line -catalogues onto the network and patrons obtaining access to the library -increasingly through local networks, campus networks, and the Internet. -LARSEN supported LYNCH's earlier suggestion that we need to address -fundamental questions of networked information in order to build -environments that scale in the information sense as well as in the -physical sense. - -LARSEN supported the role of the library system as the access point into -the nation's electronic collections. Implementation of the Z39.50 -protocol for information retrieval would make such access practical and -feasible. For example, this would enable patrons in Maryland to search -California libraries, or other libraries around the world that are -conformant with Z39.50 in a manner that is familiar to University of -Maryland patrons. This client-server model also supports moving beyond -secondary content into primary content. (The notion of how one links -from secondary content to primary content, LARSEN said, represents a -fundamental problem that requires rigorous thought.) After noting -numerous network experiments in accessing full-text materials, including -projects supporting the ordering of materials across the network, LARSEN -revisited the issue of transmitting high-density, high-resolution color -images across the network and the large amounts of bandwidth they -require. He went on to address the bandwidth and synchronization -problems inherent in sending full-motion video across the network. - -LARSEN illustrated the trade-off between volumes of data in bytes or -orders of magnitude and the potential usage of that data. He discussed -transmission rates (particularly, the time it takes to move various forms -of information), and what one could do with a network supporting -multigigabit-per-second transmission. At the moment, the network -environment includes a composite of data-transmission requirements, -volumes and forms, going from steady to bursty (high-volume) and from -very slow to very fast. This aggregate must be considered in the design, -construction, and operation of multigigabyte networks. - -LARSEN's objective is to use the networks and library systems now being -constructed to increase access to resources wherever they exist, and -thus, to evolve toward an on-line electronic virtual library. - -LARSEN concluded by offering a snapshot of current trends: continuing -geometric growth in network capacity and number of users; slower -development of applications; and glacial development and adoption of -standards. The challenge is to design and develop each new application -system with network access and scalability in mind. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -BROWNRIGG * Access to the Internet cannot be taken for granted * Packet -radio and the development of MELVYL in 1980-81 in the Division of Library -Automation at the University of California * Design criteria for packet -radio * A demonstration project in San Diego and future plans * Spread -spectrum * Frequencies at which the radios will run and plans to -reimplement the WAIS server software in the public domain * Need for an -infrastructure of radios that do not move around * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Edwin BROWNRIGG, executive director, Memex Research Institute, first -polled the audience in order to seek out regular users of the Internet as -well as those planning to use it some time in the future. With nearly -everybody in the room falling into one category or the other, BROWNRIGG -made a point re access, namely that numerous individuals, especially those -who use the Internet every day, take for granted their access to it, the -speeds with which they are connected, and how well it all works. -However, as BROWNRIGG discovered between 1987 and 1989 in Australia, -if one wants access to the Internet but cannot afford it or has some -physical boundary that prevents her or him from gaining access, it can -be extremely frustrating. He suggested that because of economics and -physical barriers we were beginning to create a world of haves and have-nots -in the process of scholarly communication, even in the United States. - -BROWNRIGG detailed the development of MELVYL in academic year 1980-81 in -the Division of Library Automation at the University of California, in -order to underscore the issue of access to the system, which at the -outset was extremely limited. In short, the project needed to build a -network, which at that time entailed use of satellite technology, that is, -putting earth stations on campus and also acquiring some terrestrial links -from the State of California's microwave system. The installation of -satellite links, however, did not solve the problem (which actually -formed part of a larger problem involving politics and financial resources). -For while the project team could get a signal onto a campus, it had no means -of distributing the signal throughout the campus. The solution involved -adopting a recent development in wireless communication called packet radio, -which combined the basic notion of packet-switching with radio. The project -used this technology to get the signal from a point on campus where it -came down, an earth station for example, into the libraries, because it -found that wiring the libraries, especially the older marble buildings, -would cost $2,000-$5,000 per terminal. - -BROWNRIGG noted that, ten years ago, the project had neither the public -policy nor the technology that would have allowed it to use packet radio -in any meaningful way. Since then much had changed. He proceeded to -detail research and development of the technology, how it is being -deployed in California, and what direction he thought it would take. -The design criteria are to produce a high-speed, one-time, low-cost, -high-quality, secure, license-free device (packet radio) that one can -plug in and play today, forget about it, and have access to the Internet. -By high speed, BROWNRIGG meant 1 megabyte and 1.5 megabytes. Those units -have been built, he continued, and are in the process of being -type-certified by an independent underwriting laboratory so that they can -be type-licensed by the Federal Communications Commission. As is the -case with citizens band, one will be able to purchase a unit and not have -to worry about applying for a license. - -The basic idea, BROWNRIGG elaborated, is to take high-speed radio data -transmission and create a backbone network that at certain strategic -points in the network will "gateway" into a medium-speed packet radio -(i.e., one that runs at 38.4 kilobytes), so that perhaps by 1994-1995 -people, like those in the audience for the price of a VCR could purchase -a medium-speed radio for the office or home, have full network connectivity -to the Internet, and partake of all its services, with no need for an FCC -license and no regular bill from the local common carrier. BROWNRIGG -presented several details of a demonstration project currently taking -place in San Diego and described plans, pending funding, to install a -full-bore network in the San Francisco area. This network will have 600 -nodes running at backbone speeds, and 100 of these nodes will be libraries, -which in turn will be the gateway ports to the 38.4 kilobyte radios that -will give coverage for the neighborhoods surrounding the libraries. - -BROWNRIGG next explained Part 15.247, a new rule within Title 47 of the -Code of Federal Regulations enacted by the FCC in 1985. This rule -challenged the industry, which has only now risen to the occasion, to -build a radio that would run at no more than one watt of output power and -use a fairly exotic method of modulating the radio wave called spread -spectrum. Spread spectrum in fact permits the building of networks so -that numerous data communications can occur simultaneously, without -interfering with each other, within the same wide radio channel. - -BROWNRIGG explained that the frequencies at which the radios would run -are very short wave signals. They are well above standard microwave and -radar. With a radio wave that small, one watt becomes a tremendous punch -per bit and thus makes transmission at reasonable speed possible. In -order to minimize the potential for congestion, the project is -undertaking to reimplement software which has been available in the -networking business and is taken for granted now, for example, TCP/IP, -routing algorithms, bridges, and gateways. In addition, the project -plans to take the WAIS server software in the public domain and -reimplement it so that one can have a WAIS server on a Mac instead of a -Unix machine. The Memex Research Institute believes that libraries, in -particular, will want to use the WAIS servers with packet radio. This -project, which has a team of about twelve people, will run through 1993 -and will include the 100 libraries already mentioned as well as other -professionals such as those in the medical profession, engineering, and -law. Thus, the need is to create an infrastructure of radios that do not -move around, which, BROWNRIGG hopes, will solve a problem not only for -libraries but for individuals who, by and large today, do not have access -to the Internet from their homes and offices. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Project operating frequencies * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During a brief discussion period, which also concluded the day's -proceedings, BROWNRIGG stated that the project was operating in four -frequencies. The slow speed is operating at 435 megahertz, and it would -later go up to 920 megahertz. With the high-speed frequency, the -one-megabyte radios will run at 2.4 gigabits, and 1.5 will run at 5.7. -At 5.7, rain can be a factor, but it would have to be tropical rain, -unlike what falls in most parts of the United States. - - ****** - -SESSION IV. IMAGE CAPTURE, TEXT CAPTURE, OVERVIEW OF TEXT AND - IMAGE STORAGE FORMATS - -William HOOTON, vice president of operations, I-NET, moderated this session. - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -KENNEY * Factors influencing development of CXP * Advantages of using -digital technology versus photocopy and microfilm * A primary goal of -CXP; publishing challenges * Characteristics of copies printed * Quality -of samples achieved in image capture * Several factors to be considered -in choosing scanning * Emphasis of CXP on timely and cost-effective -production of black-and-white printed facsimiles * Results of producing -microfilm from digital files * Advantages of creating microfilm * Details -concerning production * Costs * Role of digital technology in library -preservation * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Anne KENNEY, associate director, Department of Preservation and -Conservation, Cornell University, opened her talk by observing that the -Cornell Xerox Project (CXP) has been guided by the assumption that the -ability to produce printed facsimiles or to replace paper with paper -would be important, at least for the present generation of users and -equipment. She described three factors that influenced development of -the project: 1) Because the project has emphasized the preservation of -deteriorating brittle books, the quality of what was produced had to be -sufficiently high to return a paper replacement to the shelf. CXP was -only interested in using: 2) a system that was cost-effective, which -meant that it had to be cost-competitive with the processes currently -available, principally photocopy and microfilm, and 3) new or currently -available product hardware and software. - -KENNEY described the advantages that using digital technology offers over -both photocopy and microfilm: 1) The potential exists to create a higher -quality reproduction of a deteriorating original than conventional -light-lens technology. 2) Because a digital image is an encoded -representation, it can be reproduced again and again with no resulting -loss of quality, as opposed to the situation with light-lens processes, -in which there is discernible difference between a second and a -subsequent generation of an image. 3) A digital image can be manipulated -in a number of ways to improve image capture; for example, Xerox has -developed a windowing application that enables one to capture a page -containing both text and illustrations in a manner that optimizes the -reproduction of both. (With light-lens technology, one must choose which -to optimize, text or the illustration; in preservation microfilming, the -current practice is to shoot an illustrated page twice, once to highlight -the text and the second time to provide the best capture for the -illustration.) 4) A digital image can also be edited, density levels -adjusted to remove underlining and stains, and to increase legibility for -faint documents. 5) On-screen inspection can take place at the time of -initial setup and adjustments made prior to scanning, factors that -substantially reduce the number of retakes required in quality control. - -A primary goal of CXP has been to evaluate the paper output printed on -the Xerox DocuTech, a high-speed printer that produces 600-dpi pages from -scanned images at a rate of 135 pages a minute. KENNEY recounted several -publishing challenges to represent faithful and legible reproductions of -the originals that the 600-dpi copy for the most part successfully -captured. For example, many of the deteriorating volumes in the project -were heavily illustrated with fine line drawings or halftones or came in -languages such as Japanese, in which the buildup of characters comprised -of varying strokes is difficult to reproduce at lower resolutions; a -surprising number of them came with annotations and mathematical -formulas, which it was critical to be able to duplicate exactly. - -KENNEY noted that 1) the copies are being printed on paper that meets the -ANSI standards for performance, 2) the DocuTech printer meets the machine -and toner requirements for proper adhesion of print to page, as described -by the National Archives, and thus 3) paper product is considered to be -the archival equivalent of preservation photocopy. - -KENNEY then discussed several samples of the quality achieved in the -project that had been distributed in a handout, for example, a copy of a -print-on-demand version of the 1911 Reed lecture on the steam turbine, -which contains halftones, line drawings, and illustrations embedded in -text; the first four loose pages in the volume compared the capture -capabilities of scanning to photocopy for a standard test target, the -IEEE standard 167A 1987 test chart. In all instances scanning proved -superior to photocopy, though only slightly more so in one. - -Conceding the simplistic nature of her review of the quality of scanning -to photocopy, KENNEY described it as one representation of the kinds of -settings that could be used with scanning capabilities on the equipment -CXP uses. KENNEY also pointed out that CXP investigated the quality -achieved with binary scanning only, and noted the great promise in gray -scale and color scanning, whose advantages and disadvantages need to be -examined. She argued further that scanning resolutions and file formats -can represent a complex trade-off between the time it takes to capture -material, file size, fidelity to the original, and on-screen display; and -printing and equipment availability. All these factors must be taken -into consideration. - -CXP placed primary emphasis on the production in a timely and -cost-effective manner of printed facsimiles that consisted largely of -black-and-white text. With binary scanning, large files may be -compressed efficiently and in a lossless manner (i.e., no data is lost in -the process of compressing [and decompressing] an image--the exact -bit-representation is maintained) using Group 4 CCITT (i.e., the French -acronym for International Consultative Committee for Telegraph and -Telephone) compression. CXP was getting compression ratios of about -forty to one. Gray-scale compression, which primarily uses JPEG, is much -less economical and can represent a lossy compression (i.e., not -lossless), so that as one compresses and decompresses, the illustration -is subtly changed. While binary files produce a high-quality printed -version, it appears 1) that other combinations of spatial resolution with -gray and/or color hold great promise as well, and 2) that gray scale can -represent a tremendous advantage for on-screen viewing. The quality -associated with binary and gray scale also depends on the equipment used. -For instance, binary scanning produces a much better copy on a binary -printer. - -Among CXP's findings concerning the production of microfilm from digital -files, KENNEY reported that the digital files for the same Reed lecture -were used to produce sample film using an electron beam recorder. The -resulting film was faithful to the image capture of the digital files, -and while CXP felt that the text and image pages represented in the Reed -lecture were superior to that of the light-lens film, the resolution -readings for the 600 dpi were not as high as standard microfilming. -KENNEY argued that the standards defined for light-lens technology are -not totally transferable to a digital environment. Moreover, they are -based on definition of quality for a preservation copy. Although making -this case will prove to be a long, uphill struggle, CXP plans to continue -to investigate the issue over the course of the next year. - -KENNEY concluded this portion of her talk with a discussion of the -advantages of creating film: it can serve as a primary backup and as a -preservation master to the digital file; it could then become the print -or production master and service copies could be paper, film, optical -disks, magnetic media, or on-screen display. - -Finally, KENNEY presented details re production: - - * Development and testing of a moderately-high resolution production - scanning workstation represented a third goal of CXP; to date, 1,000 - volumes have been scanned, or about 300,000 images. - - * The resulting digital files are stored and used to produce - hard-copy replacements for the originals and additional prints on - demand; although the initial costs are high, scanning technology - offers an affordable means for reformatting brittle material. - - * A technician in production mode can scan 300 pages per hour when - performing single-sheet scanning, which is a necessity when working - with truly brittle paper; this figure is expected to increase - significantly with subsequent iterations of the software from Xerox; - a three-month time-and-cost study of scanning found that the average - 300-page book would take about an hour and forty minutes to scan - (this figure included the time for setup, which involves keying in - primary bibliographic data, going into quality control mode to - define page size, establishing front-to-back registration, and - scanning sample pages to identify a default range of settings for - the entire book--functions not dissimilar to those performed by - filmers or those preparing a book for photocopy). - - * The final step in the scanning process involved rescans, which - happily were few and far between, representing well under 1 percent - of the total pages scanned. - -In addition to technician time, CXP costed out equipment, amortized over -four years, the cost of storing and refreshing the digital files every -four years, and the cost of printing and binding, book-cloth binding, a -paper reproduction. The total amounted to a little under $65 per single -300-page volume, with 30 percent overhead included--a figure competitive -with the prices currently charged by photocopy vendors. - -Of course, with scanning, in addition to the paper facsimile, one is left -with a digital file from which subsequent copies of the book can be -produced for a fraction of the cost of photocopy, with readers afforded -choices in the form of these copies. - -KENNEY concluded that digital technology offers an electronic means for a -library preservation effort to pay for itself. If a brittle-book program -included the means of disseminating reprints of books that are in demand -by libraries and researchers alike, the initial investment in capture -could be recovered and used to preserve additional but less popular -books. She disclosed that an economic model for a self-sustaining -program could be developed for CXP's report to the Commission on -Preservation and Access (CPA). - -KENNEY stressed that the focus of CXP has been on obtaining high quality -in a production environment. The use of digital technology is viewed as -an affordable alternative to other reformatting options. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -ANDRE * Overview and history of NATDP * Various agricultural CD-ROM -products created inhouse and by service bureaus * Pilot project on -Internet transmission * Additional products in progress * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Pamela ANDRE, associate director for automation, National Agricultural -Text Digitizing Program (NATDP), National Agricultural Library (NAL), -presented an overview of NATDP, which has been underway at NAL the last -four years, before Judith ZIDAR discussed the technical details. ANDRE -defined agricultural information as a broad range of material going from -basic and applied research in the hard sciences to the one-page pamphlets -that are distributed by the cooperative state extension services on such -things as how to grow blueberries. - -NATDP began in late 1986 with a meeting of representatives from the -land-grant library community to deal with the issue of electronic -information. NAL and forty-five of these libraries banded together to -establish this project--to evaluate the technology for converting what -were then source documents in paper form into electronic form, to provide -access to that digital information, and then to distribute it. -Distributing that material to the community--the university community as -well as the extension service community, potentially down to the county -level--constituted the group's chief concern. - -Since January 1988 (when the microcomputer-based scanning system was -installed at NAL), NATDP has done a variety of things, concerning which -ZIDAR would provide further details. For example, the first technology -considered in the project's discussion phase was digital videodisc, which -indicates how long ago it was conceived. - -Over the four years of this project, four separate CD-ROM products on -four different agricultural topics were created, two at a -scanning-and-OCR station installed at NAL, and two by service bureaus. -Thus, NATDP has gained comparative information in terms of those relative -costs. Each of these products contained the full ASCII text as well as -page images of the material, or between 4,000 and 6,000 pages of material -on these disks. Topics included aquaculture, food, agriculture and -science (i.e., international agriculture and research), acid rain, and -Agent Orange, which was the final product distributed (approximately -eighteen months before the Workshop). - -The third phase of NATDP focused on delivery mechanisms other than -CD-ROM. At the suggestion of Clifford LYNCH, who was a technical -consultant to the project at this point, NATDP became involved with the -Internet and initiated a project with the help of North Carolina State -University, in which fourteen of the land-grant university libraries are -transmitting digital images over the Internet in response to interlibrary -loan requests--a topic for another meeting. At this point, the pilot -project had been completed for about a year and the final report would be -available shortly after the Workshop. In the meantime, the project's -success had led to its extension. (ANDRE noted that one of the first -things done under the program title was to select a retrieval package to -use with subsequent products; Windows Personal Librarian was the package -of choice after a lengthy evaluation.) - -Three additional products had been planned and were in progress: - - 1) An arrangement with the American Society of Agronomy--a - professional society that has published the Agronomy Journal since - about 1908--to scan and create bit-mapped images of its journal. - ASA granted permission first to put and then to distribute this - material in electronic form, to hold it at NAL, and to use these - electronic images as a mechanism to deliver documents or print out - material for patrons, among other uses. Effectively, NAL has the - right to use this material in support of its program. - (Significantly, this arrangement offers a potential cooperative - model for working with other professional societies in agriculture - to try to do the same thing--put the journals of particular interest - to agriculture research into electronic form.) - - 2) An extension of the earlier product on aquaculture. - - 3) The George Washington Carver Papers--a joint project with - Tuskegee University to scan and convert from microfilm some 3,500 - images of Carver's papers, letters, and drawings. - -It was anticipated that all of these products would appear no more than -six months after the Workshop. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -ZIDAR * (A separate arena for scanning) * Steps in creating a database * -Image capture, with and without performing OCR * Keying in tracking data -* Scanning, with electronic and manual tracking * Adjustments during -scanning process * Scanning resolutions * Compression * De-skewing and -filtering * Image capture from microform: the papers and letters of -George Washington Carver * Equipment used for a scanning system * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Judith ZIDAR, coordinator, National Agricultural Text Digitizing Program -(NATDP), National Agricultural Library (NAL), illustrated the technical -details of NATDP, including her primary responsibility, scanning and -creating databases on a topic and putting them on CD-ROM. - -(ZIDAR remarked a separate arena from the CD-ROM projects, although the -processing of the material is nearly identical, in which NATDP is also -scanning material and loading it on a Next microcomputer, which in turn -is linked to NAL's integrated library system. Thus, searches in NAL's -bibliographic database will enable people to pull up actual page images -and text for any documents that have been entered.) - -In accordance with the session's topic, ZIDAR focused her illustrated -talk on image capture, offering a primer on the three main steps in the -process: 1) assemble the printed publications; 2) design the database -(database design occurs in the process of preparing the material for -scanning; this step entails reviewing and organizing the material, -defining the contents--what will constitute a record, what kinds of -fields will be captured in terms of author, title, etc.); 3) perform a -certain amount of markup on the paper publications. NAL performs this -task record by record, preparing work sheets or some other sort of -tracking material and designing descriptors and other enhancements to be -added to the data that will not be captured from the printed publication. -Part of this process also involves determining NATDP's file and directory -structure: NATDP attempts to avoid putting more than approximately 100 -images in a directory, because placing more than that on a CD-ROM would -reduce the access speed. - -This up-front process takes approximately two weeks for a -6,000-7,000-page database. The next step is to capture the page images. -How long this process takes is determined by the decision whether or not -to perform OCR. Not performing OCR speeds the process, whereas text -capture requires greater care because of the quality of the image: it -has to be straighter and allowance must be made for text on a page, not -just for the capture of photographs. - -NATDP keys in tracking data, that is, a standard bibliographic record -including the title of the book and the title of the chapter, which will -later either become the access information or will be attached to the -front of a full-text record so that it is searchable. - -Images are scanned from a bound or unbound publication, chiefly from -bound publications in the case of NATDP, however, because often they are -the only copies and the publications are returned to the shelves. NATDP -usually scans one record at a time, because its database tracking system -tracks the document in that way and does not require further logical -separating of the images. After performing optical character -recognition, NATDP moves the images off the hard disk and maintains a -volume sheet. Though the system tracks electronically, all the -processing steps are also tracked manually with a log sheet. - -ZIDAR next illustrated the kinds of adjustments that one can make when -scanning from paper and microfilm, for example, redoing images that need -special handling, setting for dithering or gray scale, and adjusting for -brightness or for the whole book at one time. - -NATDP is scanning at 300 dots per inch, a standard scanning resolution. -Though adequate for capturing text that is all of a standard size, 300 -dpi is unsuitable for any kind of photographic material or for very small -text. Many scanners allow for different image formats, TIFF, of course, -being a de facto standard. But if one intends to exchange images with -other people, the ability to scan other image formats, even if they are -less common, becomes highly desirable. - -CCITT Group 4 is the standard compression for normal black-and-white -images, JPEG for gray scale or color. ZIDAR recommended 1) using the -standard compressions, particularly if one attempts to make material -available and to allow users to download images and reuse them from -CD-ROMs; and 2) maintaining the ability to output an uncompressed image, -because in image exchange uncompressed images are more likely to be able -to cross platforms. - -ZIDAR emphasized the importance of de-skewing and filtering as -requirements on NATDP's upgraded system. For instance, scanning bound -books, particularly books published by the federal government whose pages -are skewed, and trying to scan them straight if OCR is to be performed, -is extremely time-consuming. The same holds for filtering of -poor-quality or older materials. - -ZIDAR described image capture from microform, using as an example three -reels from a sixty-seven-reel set of the papers and letters of George -Washington Carver that had been produced by Tuskegee University. These -resulted in approximately 3,500 images, which NATDP had had scanned by -its service contractor, Science Applications International Corporation -(SAIC). NATDP also created bibliographic records for access. (NATDP did -not have such specialized equipment as a microfilm scanner. - -Unfortunately, the process of scanning from microfilm was not an -unqualified success, ZIDAR reported: because microfilm frame sizes vary, -occasionally some frames were missed, which without spending much time -and money could not be recaptured. - -OCR could not be performed from the scanned images of the frames. The -bleeding in the text simply output text, when OCR was run, that could not -even be edited. NATDP tested for negative versus positive images, -landscape versus portrait orientation, and single- versus dual-page -microfilm, none of which seemed to affect the quality of the image; but -also on none of them could OCR be performed. - -In selecting the microfilm they would use, therefore, NATDP had other -factors in mind. ZIDAR noted two factors that influenced the quality of -the images: 1) the inherent quality of the original and 2) the amount of -size reduction on the pages. - -The Carver papers were selected because they are informative and visually -interesting, treat a single subject, and are valuable in their own right. -The images were scanned and divided into logical records by SAIC, then -delivered, and loaded onto NATDP's system, where bibliographic -information taken directly from the images was added. Scanning was -completed in summer 1991 and by the end of summer 1992 the disk was -scheduled to be published. - -Problems encountered during processing included the following: Because -the microfilm scanning had to be done in a batch, adjustment for -individual page variations was not possible. The frame size varied on -account of the nature of the material, and therefore some of the frames -were missed while others were just partial frames. The only way to go -back and capture this material was to print out the page with the -microfilm reader from the missing frame and then scan it in from the -page, which was extremely time-consuming. The quality of the images -scanned from the printout of the microfilm compared unfavorably with that -of the original images captured directly from the microfilm. The -inability to perform OCR also was a major disappointment. At the time, -computer output microfilm was unavailable to test. - -The equipment used for a scanning system was the last topic addressed by -ZIDAR. The type of equipment that one would purchase for a scanning -system included: a microcomputer, at least a 386, but preferably a 486; -a large hard disk, 380 megabyte at minimum; a multi-tasking operating -system that allows one to run some things in batch in the background -while scanning or doing text editing, for example, Unix or OS/2 and, -theoretically, Windows; a high-speed scanner and scanning software that -allows one to make the various adjustments mentioned earlier; a -high-resolution monitor (150 dpi ); OCR software and hardware to perform -text recognition; an optical disk subsystem on which to archive all the -images as the processing is done; file management and tracking software. - -ZIDAR opined that the software one purchases was more important than the -hardware and might also cost more than the hardware, but it was likely to -prove critical to the success or failure of one's system. In addition to -a stand-alone scanning workstation for image capture, then, text capture -requires one or two editing stations networked to this scanning station -to perform editing. Editing the text takes two or three times as long as -capturing the images. - -Finally, ZIDAR stressed the importance of buying an open system that allows -for more than one vendor, complies with standards, and can be upgraded. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -WATERS *Yale University Library's master plan to convert microfilm to -digital imagery (POB) * The place of electronic tools in the library of -the future * The uses of images and an image library * Primary input from -preservation microfilm * Features distinguishing POB from CXP and key -hypotheses guiding POB * Use of vendor selection process to facilitate -organizational work * Criteria for selecting vendor * Finalists and -results of process for Yale * Key factor distinguishing vendors * -Components, design principles, and some estimated costs of POB * Role of -preservation materials in developing imaging market * Factors affecting -quality and cost * Factors affecting the usability of complex documents -in image form * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Donald WATERS, head of the Systems Office, Yale University Library, -reported on the progress of a master plan for a project at Yale to -convert microfilm to digital imagery, Project Open Book (POB). Stating -that POB was in an advanced stage of planning, WATERS detailed, in -particular, the process of selecting a vendor partner and several key -issues under discussion as Yale prepares to move into the project itself. -He commented first on the vision that serves as the context of POB and -then described its purpose and scope. - -WATERS sees the library of the future not necessarily as an electronic -library but as a place that generates, preserves, and improves for its -clients ready access to both intellectual and physical recorded -knowledge. Electronic tools must find a place in the library in the -context of this vision. Several roles for electronic tools include -serving as: indirect sources of electronic knowledge or as "finding" -aids (the on-line catalogues, the article-level indices, registers for -documents and archives); direct sources of recorded knowledge; full-text -images; and various kinds of compound sources of recorded knowledge (the -so-called compound documents of Hypertext, mixed text and image, -mixed-text image format, and multimedia). - -POB is looking particularly at images and an image library, the uses to -which images will be put (e.g., storage, printing, browsing, and then use -as input for other processes), OCR as a subsequent process to image -capture, or creating an image library, and also possibly generating -microfilm. - -While input will come from a variety of sources, POB is considering -especially input from preservation microfilm. A possible outcome is that -the film and paper which provide the input for the image library -eventually may go off into remote storage, and that the image library may -be the primary access tool. - -The purpose and scope of POB focus on imaging. Though related to CXP, -POB has two features which distinguish it: 1) scale--conversion of -10,000 volumes into digital image form; and 2) source--conversion from -microfilm. Given these features, several key working hypotheses guide -POB, including: 1) Since POB is using microfilm, it is not concerned with -the image library as a preservation medium. 2) Digital imagery can improve -access to recorded knowledge through printing and network distribution at -a modest incremental cost of microfilm. 3) Capturing and storing documents -in a digital image form is necessary to further improvements in access. -(POB distinguishes between the imaging, digitizing process and OCR, -which at this stage it does not plan to perform.) - -Currently in its first or organizational phase, POB found that it could -use a vendor selection process to facilitate a good deal of the -organizational work (e.g., creating a project team and advisory board, -confirming the validity of the plan, establishing the cost of the project -and a budget, selecting the materials to convert, and then raising the -necessary funds). - -POB developed numerous selection criteria, including: a firm committed -to image-document management, the ability to serve as systems integrator -in a large-scale project over several years, interest in developing the -requisite software as a standard rather than a custom product, and a -willingness to invest substantial resources in the project itself. - -Two vendors, DEC and Xerox, were selected as finalists in October 1991, -and with the support of the Commission on Preservation and Access, each -was commissioned to generate a detailed requirements analysis for the -project and then to submit a formal proposal for the completion of the -project, which included a budget and costs. The terms were that POB would -pay the loser. The results for Yale of involving a vendor included: -broad involvement of Yale staff across the board at a relatively low -cost, which may have long-term significance in carrying out the project -(twenty-five to thirty university people are engaged in POB); better -understanding of the factors that affect corporate response to markets -for imaging products; a competitive proposal; and a more sophisticated -view of the imaging markets. - -The most important factor that distinguished the vendors under -consideration was their identification with the customer. The size and -internal complexity of the company also was an important factor. POB was -looking at large companies that had substantial resources. In the end, -the process generated for Yale two competitive proposals, with Xerox's -the clear winner. WATERS then described the components of the proposal, -the design principles, and some of the costs estimated for the process. - -Components are essentially four: a conversion subsystem, a -network-accessible storage subsystem for 10,000 books (and POB expects -200 to 600 dpi storage), browsing stations distributed on the campus -network, and network access to the image printers. - -Among the design principles, POB wanted conversion at the highest -possible resolution. Assuming TIFF files, TIFF files with Group 4 -compression, TCP/IP, and ethernet network on campus, POB wanted a -client-server approach with image documents distributed to the -workstations and made accessible through native workstation interfaces -such as Windows. POB also insisted on a phased approach to -implementation: 1) a stand-alone, single-user, low-cost entry into the -business with a workstation focused on conversion and allowing POB to -explore user access; 2) movement into a higher-volume conversion with -network-accessible storage and multiple access stations; and 3) a -high-volume conversion, full-capacity storage, and multiple browsing -stations distributed throughout the campus. - -The costs proposed for start-up assumed the existence of the Yale network -and its two DocuTech image printers. Other start-up costs are estimated -at $1 million over the three phases. At the end of the project, the annual -operating costs estimated primarily for the software and hardware proposed -come to about $60,000, but these exclude costs for labor needed in the -conversion process, network and printer usage, and facilities management. - -Finally, the selection process produced for Yale a more sophisticated -view of the imaging markets: the management of complex documents in -image form is not a preservation problem, not a library problem, but a -general problem in a broad, general industry. Preservation materials are -useful for developing that market because of the qualities of the -material. For example, much of it is out of copyright. The resolution -of key issues such as the quality of scanning and image browsing also -will affect development of that market. - -The technology is readily available but changing rapidly. In this -context of rapid change, several factors affect quality and cost, to -which POB intends to pay particular attention, for example, the various -levels of resolution that can be achieved. POB believes it can bring -resolution up to 600 dpi, but an interpolation process from 400 to 600 is -more likely. The variation quality in microfilm will prove to be a -highly important factor. POB may reexamine the standards used to film in -the first place by looking at this process as a follow-on to microfilming. - -Other important factors include: the techniques available to the -operator for handling material, the ways of integrating quality control -into the digitizing work flow, and a work flow that includes indexing and -storage. POB's requirement was to be able to deal with quality control -at the point of scanning. Thus, thanks to Xerox, POB anticipates having -a mechanism which will allow it not only to scan in batch form, but to -review the material as it goes through the scanner and control quality -from the outset. - -The standards for measuring quality and costs depend greatly on the uses -of the material, including subsequent OCR, storage, printing, and -browsing. But especially at issue for POB is the facility for browsing. -This facility, WATERS said, is perhaps the weakest aspect of imaging -technology and the most in need of development. - -A variety of factors affect the usability of complex documents in image -form, among them: 1) the ability of the system to handle the full range -of document types, not just monographs but serials, multi-part -monographs, and manuscripts; 2) the location of the database of record -for bibliographic information about the image document, which POB wants -to enter once and in the most useful place, the on-line catalog; 3) a -document identifier for referencing the bibliographic information in one -place and the images in another; 4) the technique for making the basic -internal structure of the document accessible to the reader; and finally, -5) the physical presentation on the CRT of those documents. POB is ready -to complete this phase now. One last decision involves deciding which -material to scan. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * TIFF files constitute de facto standard * NARA's experience -with image conversion software and text conversion * RFC 1314 * -Considerable flux concerning available hardware and software solutions * -NAL through-put rate during scanning * Window management questions * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -In the question-and-answer period that followed WATERS's presentation, -the following points emerged: - - * ZIDAR's statement about using TIFF files as a standard meant de - facto standard. This is what most people use and typically exchange - with other groups, across platforms, or even occasionally across - display software. - - * HOLMES commented on the unsuccessful experience of NARA in - attempting to run image-conversion software or to exchange between - applications: What are supposedly TIFF files go into other software - that is supposed to be able to accept TIFF but cannot recognize the - format and cannot deal with it, and thus renders the exchange - useless. Re text conversion, he noted the different recognition - rates obtained by substituting the make and model of scanners in - NARA's recent test of an "intelligent" character-recognition product - for a new company. In the selection of hardware and software, - HOLMES argued, software no longer constitutes the overriding factor - it did until about a year ago; rather it is perhaps important to - look at both now. - - * Danny Cohen and Alan Katz of the University of Southern California - Information Sciences Institute began circulating as an Internet RFC - (RFC 1314) about a month ago a standard for a TIFF interchange - format for Internet distribution of monochrome bit-mapped images, - which LYNCH said he believed would be used as a de facto standard. - - * FLEISCHHAUER's impression from hearing these reports and thinking - about AM's experience was that there is considerable flux concerning - available hardware and software solutions. HOOTON agreed and - commented at the same time on ZIDAR's statement that the equipment - employed affects the results produced. One cannot draw a complete - conclusion by saying it is difficult or impossible to perform OCR - from scanning microfilm, for example, with that device, that set of - parameters, and system requirements, because numerous other people - are accomplishing just that, using other components, perhaps. - HOOTON opined that both the hardware and the software were highly - important. Most of the problems discussed today have been solved in - numerous different ways by other people. Though it is good to be - cognizant of various experiences, this is not to say that it will - always be thus. - - * At NAL, the through-put rate of the scanning process for paper, - page by page, performing OCR, ranges from 300 to 600 pages per day; - not performing OCR is considerably faster, although how much faster - is not known. This is for scanning from bound books, which is much - slower. - - * WATERS commented on window management questions: DEC proposed an - X-Windows solution which was problematical for two reasons. One was - POB's requirement to be able to manipulate images on the workstation - and bring them down to the workstation itself and the other was - network usage. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -THOMA * Illustration of deficiencies in scanning and storage process * -Image quality in this process * Different costs entailed by better image -quality * Techniques for overcoming various de-ficiencies: fixed -thresholding, dynamic thresholding, dithering, image merge * Page edge -effects * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -George THOMA, chief, Communications Engineering Branch, National Library -of Medicine (NLM), illustrated several of the deficiencies discussed by -the previous speakers. He introduced the topic of special problems by -noting the advantages of electronic imaging. For example, it is regenerable -because it is a coded file, and real-time quality control is possible with -electronic capture, whereas in photographic capture it is not. - -One of the difficulties discussed in the scanning and storage process was -image quality which, without belaboring the obvious, means different -things for maps, medical X-rays, or broadcast television. In the case of -documents, THOMA said, image quality boils down to legibility of the -textual parts, and fidelity in the case of gray or color photo print-type -material. Legibility boils down to scan density, the standard in most -cases being 300 dpi. Increasing the resolution with scanners that -perform 600 or 1200 dpi, however, comes at a cost. - -Better image quality entails at least four different kinds of costs: 1) -equipment costs, because the CCD (i.e., charge-couple device) with -greater number of elements costs more; 2) time costs that translate to -the actual capture costs, because manual labor is involved (the time is -also dependent on the fact that more data has to be moved around in the -machine in the scanning or network devices that perform the scanning as -well as the storage); 3) media costs, because at high resolutions larger -files have to be stored; and 4) transmission costs, because there is just -more data to be transmitted. - -But while resolution takes care of the issue of legibility in image -quality, other deficiencies have to do with contrast and elements on the -page scanned or the image that needed to be removed or clarified. Thus, -THOMA proceeded to illustrate various deficiencies, how they are -manifested, and several techniques to overcome them. - -Fixed thresholding was the first technique described, suitable for -black-and-white text, when the contrast does not vary over the page. One -can have many different threshold levels in scanning devices. Thus, -THOMA offered an example of extremely poor contrast, which resulted from -the fact that the stock was a heavy red. This is the sort of image that -when microfilmed fails to provide any legibility whatsoever. Fixed -thresholding is the way to change the black-to-red contrast to the -desired black-to-white contrast. - -Other examples included material that had been browned or yellowed by -age. This was also a case of contrast deficiency, and correction was -done by fixed thresholding. A final example boils down to the same -thing, slight variability, but it is not significant. Fixed thresholding -solves this problem as well. The microfilm equivalent is certainly legible, -but it comes with dark areas. Though THOMA did not have a slide of the -microfilm in this case, he did show the reproduced electronic image. - -When one has variable contrast over a page or the lighting over the page -area varies, especially in the case where a bound volume has light -shining on it, the image must be processed by a dynamic thresholding -scheme. One scheme, dynamic averaging, allows the threshold level not to -be fixed but to be recomputed for every pixel from the neighboring -characteristics. The neighbors of a pixel determine where the threshold -should be set for that pixel. - -THOMA showed an example of a page that had been made deficient by a -variety of techniques, including a burn mark, coffee stains, and a yellow -marker. Application of a fixed-thresholding scheme, THOMA argued, might -take care of several deficiencies on the page but not all of them. -Performing the calculation for a dynamic threshold setting, however, -removes most of the deficiencies so that at least the text is legible. - -Another problem is representing a gray level with black-and-white pixels -by a process known as dithering or electronic screening. But dithering -does not provide good image quality for pure black-and-white textual -material. THOMA illustrated this point with examples. Although its -suitability for photoprint is the reason for electronic screening or -dithering, it cannot be used for every compound image. In the document -that was distributed by CXP, THOMA noticed that the dithered image of the -IEEE test chart evinced some deterioration in the text. He presented an -extreme example of deterioration in the text in which compounded -documents had to be set right by other techniques. The technique -illustrated by the present example was an image merge in which the page -is scanned twice and the settings go from fixed threshold to the -dithering matrix; the resulting images are merged to give the best -results with each technique. - -THOMA illustrated how dithering is also used in nonphotographic or -nonprint materials with an example of a grayish page from a medical text, -which was reproduced to show all of the gray that appeared in the -original. Dithering provided a reproduction of all the gray in the -original of another example from the same text. - -THOMA finally illustrated the problem of bordering, or page-edge, -effects. Books and bound volumes that are placed on a photocopy machine -or a scanner produce page-edge effects that are undesirable for two -reasons: 1) the aesthetics of the image; after all, if the image is to -be preserved, one does not necessarily want to keep all of its -deficiencies; 2) compression (with the bordering problem THOMA -illustrated, the compression ratio deteriorated tremendously). One way -to eliminate this more serious problem is to have the operator at the -point of scanning window the part of the image that is desirable and -automatically turn all of the pixels out of that picture to white. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -FLEISCHHAUER * AM's experience with scanning bound materials * Dithering -* -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Carl FLEISCHHAUER, coordinator, American Memory, Library of Congress, -reported AM's experience with scanning bound materials, which he likened -to the problems involved in using photocopying machines. Very few -devices in the industry offer book-edge scanning, let alone book cradles. -The problem may be unsolvable, FLEISCHHAUER said, because a large enough -market does not exist for a preservation-quality scanner. AM is using a -Kurzweil scanner, which is a book-edge scanner now sold by Xerox. - -Devoting the remainder of his brief presentation to dithering, -FLEISCHHAUER related AM's experience with a contractor who was using -unsophisticated equipment and software to reduce moire patterns from -printed halftones. AM took the same image and used the dithering -algorithm that forms part of the same Kurzweil Xerox scanner; it -disguised moire patterns much more effectively. - -FLEISCHHAUER also observed that dithering produces a binary file which is -useful for numerous purposes, for example, printing it on a laser printer -without having to "re-halftone" it. But it tends to defeat efficient -compression, because the very thing that dithers to reduce moire patterns -also tends to work against compression schemes. AM thought the -difference in image quality was worth it. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Relative use as a criterion for POB's selection of books to -be converted into digital form * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the discussion period, WATERS noted that one of the criteria for -selecting books among the 10,000 to be converted into digital image form -would be how much relative use they would receive--a subject still -requiring evaluation. The challenge will be to understand whether -coherent bodies of material will increase usage or whether POB should -seek material that is being used, scan that, and make it more accessible. -POB might decide to digitize materials that are already heavily used, in -order to make them more accessible and decrease wear on them. Another -approach would be to provide a large body of intellectually coherent -material that may be used more in digital form than it is currently used -in microfilm. POB would seek material that was out of copyright. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -BARONAS * Origin and scope of AIIM * Types of documents produced in -AIIM's standards program * Domain of AIIM's standardization work * AIIM's -structure * TC 171 and MS23 * Electronic image management standards * -Categories of EIM standardization where AIIM standards are being -developed * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Jean BARONAS, senior manager, Department of Standards and Technology, -Association for Information and Image Management (AIIM), described the -not-for-profit association and the national and international programs -for standardization in which AIIM is active. - -Accredited for twenty-five years as the nation's standards development -organization for document image management, AIIM began life in a library -community developing microfilm standards. Today the association -maintains both its library and business-image management standardization -activities--and has moved into electronic image-management -standardization (EIM). - -BARONAS defined the program's scope. AIIM deals with: 1) the -terminology of standards and of the technology it uses; 2) methods of -measurement for the systems, as well as quality; 3) methodologies for -users to evaluate and measure quality; 4) the features of apparatus used -to manage and edit images; and 5) the procedures used to manage images. - -BARONAS noted that three types of documents are produced in the AIIM -standards program: the first two, accredited by the American National -Standards Institute (ANSI), are standards and standard recommended -practices. Recommended practices differ from standards in that they -contain more tutorial information. A technical report is not an ANSI -standard. Because AIIM's policies and procedures for developing -standards are approved by ANSI, its standards are labeled ANSI/AIIM, -followed by the number and title of the standard. - -BARONAS then illustrated the domain of AIIM's standardization work. For -example, AIIM is the administrator of the U.S. Technical Advisory Group -(TAG) to the International Standards Organization's (ISO) technical -committee, TC l7l Micrographics and Optical Memories for Document and -Image Recording, Storage, and Use. AIIM officially works through ANSI in -the international standardization process. - -BARONAS described AIIM's structure, including its board of directors, its -standards board of twelve individuals active in the image-management -industry, its strategic planning and legal admissibility task forces, and -its National Standards Council, which is comprised of the members of a -number of organizations who vote on every AIIM standard before it is -published. BARONAS pointed out that AIIM's liaisons deal with numerous -other standards developers, including the optical disk community, office -and publishing systems, image-codes-and-character set committees, and the -National Information Standards Organization (NISO). - -BARONAS illustrated the procedures of TC l7l, which covers all aspects of -image management. When AIIM's national program has conceptualized a new -project, it is usually submitted to the international level, so that the -member countries of TC l7l can simultaneously work on the development of -the standard or the technical report. BARONAS also illustrated a classic -microfilm standard, MS23, which deals with numerous imaging concepts that -apply to electronic imaging. Originally developed in the l970s, revised -in the l980s, and revised again in l991, this standard is scheduled for -another revision. MS23 is an active standard whereby users may propose -new density ranges and new methods of evaluating film images in the -standard's revision. - -BARONAS detailed several electronic image-management standards, for -instance, ANSI/AIIM MS44, a quality-control guideline for scanning 8.5" -by 11" black-and-white office documents. This standard is used with the -IEEE fax image--a continuous tone photographic image with gray scales, -text, and several continuous tone pictures--and AIIM test target number -2, a representative document used in office document management. - -BARONAS next outlined the four categories of EIM standardization in which -AIIM standards are being developed: transfer and retrieval, evaluation, -optical disc and document scanning applications, and design and -conversion of documents. She detailed several of the main projects of -each: 1) in the category of image transfer and retrieval, a bi-level -image transfer format, ANSI/AIIM MS53, which is a proposed standard that -describes a file header for image transfer between unlike systems when -the images are compressed using G3 and G4 compression; 2) the category of -image evaluation, which includes the AIIM-proposed TR26 tutorial on image -resolution (this technical report will treat the differences and -similarities between classical or photographic and electronic imaging); -3) design and conversion, which includes a proposed technical report -called "Forms Design Optimization for EIM" (this report considers how -general-purpose business forms can be best designed so that scanning is -optimized; reprographic characteristics such as type, rules, background, -tint, and color will likewise be treated in the technical report); 4) -disk and document scanning applications includes a project a) on planning -platters and disk management, b) on generating an application profile for -EIM when images are stored and distributed on CD-ROM, and c) on -evaluating SCSI2, and how a common command set can be generated for SCSI2 -so that document scanners are more easily integrated. (ANSI/AIIM MS53 -will also apply to compressed images.) - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -BATTIN * The implications of standards for preservation * A major -obstacle to successful cooperation * A hindrance to access in the digital -environment * Standards a double-edged sword for those concerned with the -preservation of the human record * Near-term prognosis for reliable -archival standards * Preservation concerns for electronic media * Need -for reconceptualizing our preservation principles * Standards in the real -world and the politics of reproduction * Need to redefine the concept of -archival and to begin to think in terms of life cycles * Cooperation and -the La Guardia Eight * Concerns generated by discussions on the problems -of preserving text and image * General principles to be adopted in a -world without standards * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Patricia BATTIN, president, the Commission on Preservation and Access -(CPA), addressed the implications of standards for preservation. She -listed several areas where the library profession and the analog world of -the printed book had made enormous contributions over the past hundred -years--for example, in bibliographic formats, binding standards, and, most -important, in determining what constitutes longevity or archival quality. - -Although standards have lightened the preservation burden through the -development of national and international collaborative programs, -nevertheless, a pervasive mistrust of other people's standards remains a -major obstacle to successful cooperation, BATTIN said. - -The zeal to achieve perfection, regardless of the cost, has hindered -rather than facilitated access in some instances, and in the digital -environment, where no real standards exist, has brought an ironically -just reward. - -BATTIN argued that standards are a double-edged sword for those concerned -with the preservation of the human record, that is, the provision of -access to recorded knowledge in a multitude of media as far into the -future as possible. Standards are essential to facilitate -interconnectivity and access, but, BATTIN said, as LYNCH pointed out -yesterday, if set too soon they can hinder creativity, expansion of -capability, and the broadening of access. The characteristics of -standards for digital imagery differ radically from those for analog -imagery. And the nature of digital technology implies continuing -volatility and change. To reiterate, precipitous standard-setting can -inhibit creativity, but delayed standard-setting results in chaos. - -Since in BATTIN'S opinion the near-term prognosis for reliable archival -standards, as defined by librarians in the analog world, is poor, two -alternatives remain: standing pat with the old technology, or -reconceptualizing. - -Preservation concerns for electronic media fall into two general domains. -One is the continuing assurance of access to knowledge originally -generated, stored, disseminated, and used in electronic form. This -domain contains several subdivisions, including 1) the closed, -proprietary systems discussed the previous day, bundled information such -as electronic journals and government agency records, and electronically -produced or captured raw data; and 2) the application of digital -technologies to the reformatting of materials originally published on a -deteriorating analog medium such as acid paper or videotape. - -The preservation of electronic media requires a reconceptualizing of our -preservation principles during a volatile, standardless transition which -may last far longer than any of us envision today. BATTIN urged the -necessity of shifting focus from assessing, measuring, and setting -standards for the permanence of the medium to the concept of managing -continuing access to information stored on a variety of media and -requiring a variety of ever-changing hardware and software for access--a -fundamental shift for the library profession. - -BATTIN offered a primer on how to move forward with reasonable confidence -in a world without standards. Her comments fell roughly into two sections: -1) standards in the real world and 2) the politics of reproduction. - -In regard to real-world standards, BATTIN argued the need to redefine the -concept of archive and to begin to think in terms of life cycles. In -the past, the naive assumption that paper would last forever produced a -cavalier attitude toward life cycles. The transient nature of the -electronic media has compelled people to recognize and accept upfront the -concept of life cycles in place of permanency. - -Digital standards have to be developed and set in a cooperative context -to ensure efficient exchange of information. Moreover, during this -transition period, greater flexibility concerning how concepts such as -backup copies and archival copies in the CXP are defined is necessary, -or the opportunity to move forward will be lost. - -In terms of cooperation, particularly in the university setting, BATTIN -also argued the need to avoid going off in a hundred different -directions. The CPA has catalyzed a small group of universities called -the La Guardia Eight--because La Guardia Airport is where meetings take -place--Harvard, Yale, Cornell, Princeton, Penn State, Tennessee, -Stanford, and USC, to develop a digital preservation consortium to look -at all these issues and develop de facto standards as we move along, -instead of waiting for something that is officially blessed. Continuing -to apply analog values and definitions of standards to the digital -environment, BATTIN said, will effectively lead to forfeiture of the -benefits of digital technology to research and scholarship. - -Under the second rubric, the politics of reproduction, BATTIN reiterated -an oft-made argument concerning the electronic library, namely, that it -is more difficult to transform than to create, and nowhere is that belief -expressed more dramatically than in the conversion of brittle books to -new media. Preserving information published in electronic media involves -making sure the information remains accessible and that digital -information is not lost through reproduction. In the analog world of -photocopies and microfilm, the issue of fidelity to the original becomes -paramount, as do issues of "Whose fidelity?" and "Whose original?" - -BATTIN elaborated these arguments with a few examples from a recent study -conducted by the CPA on the problems of preserving text and image. -Discussions with scholars, librarians, and curators in a variety of -disciplines dependent on text and image generated a variety of concerns, -for example: 1) Copy what is, not what the technology is capable of. -This is very important for the history of ideas. Scholars wish to know -what the author saw and worked from. And make available at the -workstation the opportunity to erase all the defects and enhance the -presentation. 2) The fidelity of reproduction--what is good enough, what -can we afford, and the difference it makes--issues of subjective versus -objective resolution. 3) The differences between primary and secondary -users. Restricting the definition of primary user to the one in whose -discipline the material has been published runs one headlong into the -reality that these printed books have had a host of other users from a -host of other disciplines, who not only were looking for very different -things, but who also shared values very different from those of the -primary user. 4) The relationship of the standard of reproduction to new -capabilities of scholarship--the browsing standard versus an archival -standard. How good must the archival standard be? Can a distinction be -drawn between potential users in setting standards for reproduction? -Archival storage, use copies, browsing copies--ought an attempt to set -standards even be made? 5) Finally, costs. How much are we prepared to -pay to capture absolute fidelity? What are the trade-offs between vastly -enhanced access, degrees of fidelity, and costs? - -These standards, BATTIN concluded, serve to complicate further the -reproduction process, and add to the long list of technical standards -that are necessary to ensure widespread access. Ways to articulate and -analyze the costs that are attached to the different levels of standards -must be found. - -Given the chaos concerning standards, which promises to linger for the -foreseeable future, BATTIN urged adoption of the following general -principles: - - * Strive to understand the changing information requirements of - scholarly disciplines as more and more technology is integrated into - the process of research and scholarly communication in order to meet - future scholarly needs, not to build for the past. Capture - deteriorating information at the highest affordable resolution, even - though the dissemination and display technologies will lag. - - * Develop cooperative mechanisms to foster agreement on protocols - for document structure and other interchange mechanisms necessary - for widespread dissemination and use before official standards are - set. - - * Accept that, in a transition period, de facto standards will have - to be developed. - - * Capture information in a way that keeps all options open and - provides for total convertibility: OCR, scanning of microfilm, - producing microfilm from scanned documents, etc. - - * Work closely with the generators of information and the builders - of networks and databases to ensure that continuing accessibility is - a primary concern from the beginning. - - * Piggyback on standards under development for the broad market, and - avoid library-specific standards; work with the vendors, in order to - take advantage of that which is being standardized for the rest of - the world. - - * Concentrate efforts on managing permanence in the digital world, - rather than perfecting the longevity of a particular medium. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Additional comments on TIFF * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the brief discussion period that followed BATTIN's presentation, -BARONAS explained that TIFF was not developed in collaboration with or -under the auspices of AIIM. TIFF is a company product, not a standard, -is owned by two corporations, and is always changing. BARONAS also -observed that ANSI/AIIM MS53, a bi-level image file transfer format that -allows unlike systems to exchange images, is compatible with TIFF as well -as with DEC's architecture and IBM's MODCA/IOCA. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -HOOTON * Several questions to be considered in discussing text conversion -* -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -HOOTON introduced the final topic, text conversion, by noting that it is -becoming an increasingly important part of the imaging business. Many -people now realize that it enhances their system to be able to have more -and more character data as part of their imaging system. Re the issue of -OCR versus rekeying, HOOTON posed several questions: How does one get -text into computer-readable form? Does one use automated processes? -Does one attempt to eliminate the use of operators where possible? -Standards for accuracy, he said, are extremely important: it makes a -major difference in cost and time whether one sets as a standard 98.5 -percent acceptance or 99.5 percent. He mentioned outsourcing as a -possibility for converting text. Finally, what one does with the image -to prepare it for the recognition process is also important, he said, -because such preparation changes how recognition is viewed, as well as -facilitates recognition itself. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -LESK * Roles of participants in CORE * Data flow * The scanning process * -The image interface * Results of experiments involving the use of -electronic resources and traditional paper copies * Testing the issue of -serendipity * Conclusions * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Michael LESK, executive director, Computer Science Research, Bell -Communications Research, Inc. (Bellcore), discussed the Chemical Online -Retrieval Experiment (CORE), a cooperative project involving Cornell -University, OCLC, Bellcore, and the American Chemical Society (ACS). - -LESK spoke on 1) how the scanning was performed, including the unusual -feature of page segmentation, and 2) the use made of the text and the -image in experiments. - -Working with the chemistry journals (because ACS has been saving its -typesetting tapes since the mid-1970s and thus has a significant back-run -of the most important chemistry journals in the United States), CORE is -attempting to create an automated chemical library. Approximately a -quarter of the pages by square inch are made up of images of -quasi-pictorial material; dealing with the graphic components of the -pages is extremely important. LESK described the roles of participants -in CORE: 1) ACS provides copyright permission, journals on paper, -journals on microfilm, and some of the definitions of the files; 2) at -Bellcore, LESK chiefly performs the data preparation, while Dennis Egan -performs experiments on the users of chemical abstracts, and supplies the -indexing and numerous magnetic tapes; 3) Cornell provides the site of the -experiment; 4) OCLC develops retrieval software and other user interfaces. -Various manufacturers and publishers have furnished other help. - -Concerning data flow, Bellcore receives microfilm and paper from ACS; the -microfilm is scanned by outside vendors, while the paper is scanned -inhouse on an Improvision scanner, twenty pages per minute at 300 dpi, -which provides sufficient quality for all practical uses. LESK would -prefer to have more gray level, because one of the ACS journals prints on -some colored pages, which creates a problem. - -Bellcore performs all this scanning, creates a page-image file, and also -selects from the pages the graphics, to mix with the text file (which is -discussed later in the Workshop). The user is always searching the ASCII -file, but she or he may see a display based on the ASCII or a display -based on the images. - -LESK illustrated how the program performs page analysis, and the image -interface. (The user types several words, is presented with a list-- -usually of the titles of articles contained in an issue--that derives -from the ASCII, clicks on an icon and receives an image that mirrors an -ACS page.) LESK also illustrated an alternative interface, based on text -on the ASCII, the so-called SuperBook interface from Bellcore. - -LESK next presented the results of an experiment conducted by Dennis Egan -and involving thirty-six students at Cornell, one third of them -undergraduate chemistry majors, one third senior undergraduate chemistry -majors, and one third graduate chemistry students. A third of them -received the paper journals, the traditional paper copies and chemical -abstracts on paper. A third received image displays of the pictures of -the pages, and a third received the text display with pop-up graphics. - -The students were given several questions made up by some chemistry -professors. The questions fell into five classes, ranging from very easy -to very difficult, and included questions designed to simulate browsing -as well as a traditional information retrieval-type task. - -LESK furnished the following results. In the straightforward question -search--the question being, what is the phosphorus oxygen bond distance -and hydroxy phosphate?--the students were told that they could take -fifteen minutes and, then, if they wished, give up. The students with -paper took more than fifteen minutes on average, and yet most of them -gave up. The students with either electronic format, text or image, -received good scores in reasonable time, hardly ever had to give up, and -usually found the right answer. - -In the browsing study, the students were given a list of eight topics, -told to imagine that an issue of the Journal of the American Chemical -Society had just appeared on their desks, and were also told to flip -through it and to find topics mentioned in the issue. The average scores -were about the same. (The students were told to answer yes or no about -whether or not particular topics appeared.) The errors, however, were -quite different. The students with paper rarely said that something -appeared when it had not. But they often failed to find something -actually mentioned in the issue. The computer people found numerous -things, but they also frequently said that a topic was mentioned when it -was not. (The reason, of course, was that they were performing word -searches. They were finding that words were mentioned and they were -concluding that they had accomplished their task.) - -This question also contained a trick to test the issue of serendipity. -The students were given another list of eight topics and instructed, -without taking a second look at the journal, to recall how many of this -new list of eight topics were in this particular issue. This was an -attempt to see if they performed better at remembering what they were not -looking for. They all performed about the same, paper or electronics, -about 62 percent accurate. In short, LESK said, people were not very -good when it came to serendipity, but they were no worse at it with -computers than they were with paper. - -(LESK gave a parenthetical illustration of the learning curve of students -who used SuperBook.) - -The students using the electronic systems started off worse than the ones -using print, but by the third of the three sessions in the series had -caught up to print. As one might expect, electronics provide a much -better means of finding what one wants to read; reading speeds, once the -object of the search has been found, are about the same. - -Almost none of the students could perform the hard task--the analogous -transformation. (It would require the expertise of organic chemists to -complete.) But an interesting result was that the students using the text -search performed terribly, while those using the image system did best. -That the text search system is driven by text offers the explanation. -Everything is focused on the text; to see the pictures, one must press -on an icon. Many students found the right article containing the answer -to the question, but they did not click on the icon to bring up the right -figure and see it. They did not know that they had found the right place, -and thus got it wrong. - -The short answer demonstrated by this experiment was that in the event -one does not know what to read, one needs the electronic systems; the -electronic systems hold no advantage at the moment if one knows what to -read, but neither do they impose a penalty. - -LESK concluded by commenting that, on one hand, the image system was easy -to use. On the other hand, the text display system, which represented -twenty man-years of work in programming and polishing, was not winning, -because the text was not being read, just searched. The much easier -system is highly competitive as well as remarkably effective for the -actual chemists. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -ERWAY * Most challenging aspect of working on AM * Assumptions guiding -AM's approach * Testing different types of service bureaus * AM's -requirement for 99.95 percent accuracy * Requirements for text-coding * -Additional factors influencing AM's approach to coding * Results of AM's -experience with rekeying * Other problems in dealing with service bureaus -* Quality control the most time-consuming aspect of contracting out -conversion * Long-term outlook uncertain * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -To Ricky ERWAY, associate coordinator, American Memory, Library of -Congress, the constant variety of conversion projects taking place -simultaneously represented perhaps the most challenging aspect of working -on AM. Thus, the challenge was not to find a solution for text -conversion but a tool kit of solutions to apply to LC's varied -collections that need to be converted. ERWAY limited her remarks to the -process of converting text to machine-readable form, and the variety of -LC's text collections, for example, bound volumes, microfilm, and -handwritten manuscripts. - -Two assumptions have guided AM's approach, ERWAY said: 1) A desire not -to perform the conversion inhouse. Because of the variety of formats and -types of texts, to capitalize the equipment and have the talents and -skills to operate them at LC would be extremely expensive. Further, the -natural inclination to upgrade to newer and better equipment each year -made it reasonable for AM to focus on what it did best and seek external -conversion services. Using service bureaus also allowed AM to have -several types of operations take place at the same time. 2) AM was not a -technology project, but an effort to improve access to library -collections. Hence, whether text was converted using OCR or rekeying -mattered little to AM. What mattered were cost and accuracy of results. - -AM considered different types of service bureaus and selected three to -perform several small tests in order to acquire a sense of the field. -The sample collections with which they worked included handwritten -correspondence, typewritten manuscripts from the 1940s, and -eighteenth-century printed broadsides on microfilm. On none of these -samples was OCR performed; they were all rekeyed. AM had several special -requirements for the three service bureaus it had engaged. For instance, -any errors in the original text were to be retained. Working from bound -volumes or anything that could not be sheet-fed also constituted a factor -eliminating companies that would have performed OCR. - -AM requires 99.95 percent accuracy, which, though it sounds high, often -means one or two errors per page. The initial batch of test samples -contained several handwritten materials for which AM did not require -text-coding. The results, ERWAY reported, were in all cases fairly -comparable: for the most part, all three service bureaus achieved 99.95 -percent accuracy. AM was satisfied with the work but surprised at the cost. - -As AM began converting whole collections, it retained the requirement for -99.95 percent accuracy and added requirements for text-coding. AM needed -to begin performing work more than three years ago before LC requirements -for SGML applications had been established. Since AM's goal was simply -to retain any of the intellectual content represented by the formatting -of the document (which would be lost if one performed a straight ASCII -conversion), AM used "SGML-like" codes. These codes resembled SGML tags -but were used without the benefit of document-type definitions. AM found -that many service bureaus were not yet SGML-proficient. - -Additional factors influencing the approach AM took with respect to -coding included: 1) the inability of any known microcomputer-based -user-retrieval software to take advantage of SGML coding; and 2) the -multiple inconsistencies in format of the older documents, which -confirmed AM in its desire not to attempt to force the different formats -to conform to a single document-type definition (DTD) and thus create the -need for a separate DTD for each document. - -The five text collections that AM has converted or is in the process of -converting include a collection of eighteenth-century broadsides, a -collection of pamphlets, two typescript document collections, and a -collection of 150 books. - -ERWAY next reviewed the results of AM's experience with rekeying, noting -again that because the bulk of AM's materials are historical, the quality -of the text often does not lend itself to OCR. While non-English -speakers are less likely to guess or elaborate or correct typos in the -original text, they are also less able to infer what we would; they also -are nearly incapable of converting handwritten text. Another -disadvantage of working with overseas keyers is that they are much less -likely to telephone with questions, especially on the coding, with the -result that they develop their own rules as they encounter new -situations. - -Government contracting procedures and time frames posed a major challenge -to performing the conversion. Many service bureaus are not accustomed to -retaining the image, even if they perform OCR. Thus, questions of image -format and storage media were somewhat novel to many of them. ERWAY also -remarked other problems in dealing with service bureaus, for example, -their inability to perform text conversion from the kind of microfilm -that LC uses for preservation purposes. - -But quality control, in ERWAY's experience, was the most time-consuming -aspect of contracting out conversion. AM has been attempting to perform -a 10-percent quality review, looking at either every tenth document or -every tenth page to make certain that the service bureaus are maintaining -99.95 percent accuracy. But even if they are complying with the -requirement for accuracy, finding errors produces a desire to correct -them and, in turn, to clean up the whole collection, which defeats the -purpose to some extent. Even a double entry requires a -character-by-character comparison to the original to meet the accuracy -requirement. LC is not accustomed to publish imperfect texts, which -makes attempting to deal with the industry standard an emotionally -fraught issue for AM. As was mentioned in the previous day's discussion, -going from 99.95 to 99.99 percent accuracy usually doubles costs and -means a third keying or another complete run-through of the text. - -Although AM has learned much from its experiences with various collections -and various service bureaus, ERWAY concluded pessimistically that no -breakthrough has been achieved. Incremental improvements have occurred -in some of the OCR technology, some of the processes, and some of the -standards acceptances, which, though they may lead to somewhat lower costs, -do not offer much encouragement to many people who are anxiously awaiting -the day that the entire contents of LC are available on-line. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -ZIDAR * Several answers to why one attempts to perform full-text -conversion * Per page cost of performing OCR * Typical problems -encountered during editing * Editing poor copy OCR vs. rekeying * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Judith ZIDAR, coordinator, National Agricultural Text Digitizing Program -(NATDP), National Agricultural Library (NAL), offered several answers to -the question of why one attempts to perform full-text conversion: 1) -Text in an image can be read by a human but not by a computer, so of -course it is not searchable and there is not much one can do with it. 2) -Some material simply requires word-level access. For instance, the legal -profession insists on full-text access to its material; with taxonomic or -geographic material, which entails numerous names, one virtually requires -word-level access. 3) Full text permits rapid browsing and searching, -something that cannot be achieved in an image with today's technology. -4) Text stored as ASCII and delivered in ASCII is standardized and highly -portable. 5) People just want full-text searching, even those who do not -know how to do it. NAL, for the most part, is performing OCR at an -actual cost per average-size page of approximately $7. NAL scans the -page to create the electronic image and passes it through the OCR device. - -ZIDAR next rehearsed several typical problems encountered during editing. -Praising the celerity of her student workers, ZIDAR observed that editing -requires approximately five to ten minutes per page, assuming that there -are no large tables to audit. Confusion among the three characters I, 1, -and l, constitutes perhaps the most common problem encountered. Zeroes -and O's also are frequently confused. Double M's create a particular -problem, even on clean pages. They are so wide in most fonts that they -touch, and the system simply cannot tell where one letter ends and the -other begins. Complex page formats occasionally fail to columnate -properly, which entails rescanning as though one were working with a -single column, entering the ASCII, and decolumnating for better -searching. With proportionally spaced text, OCR can have difficulty -discerning what is a space and what are merely spaces between letters, as -opposed to spaces between words, and therefore will merge text or break -up words where it should not. - -ZIDAR said that it can often take longer to edit a poor-copy OCR than to -key it from scratch. NAL has also experimented with partial editing of -text, whereby project workers go into and clean up the format, removing -stray characters but not running a spell-check. NAL corrects typos in -the title and authors' names, which provides a foothold for searching and -browsing. Even extremely poor-quality OCR (e.g., 60-percent accuracy) -can still be searched, because numerous words are correct, while the -important words are probably repeated often enough that they are likely -to be found correct somewhere. Librarians, however, cannot tolerate this -situation, though end users seem more willing to use this text for -searching, provided that NAL indicates that it is unedited. ZIDAR -concluded that rekeying of text may be the best route to take, in spite -of numerous problems with quality control and cost. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Modifying an image before performing OCR * NAL's costs per -page *AM's costs per page and experience with Federal Prison Industries * -Elements comprising NATDP's costs per page * OCR and structured markup * -Distinction between the structure of a document and its representation -when put on the screen or printed * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -HOOTON prefaced the lengthy discussion that followed with several -comments about modifying an image before one reaches the point of -performing OCR. For example, in regard to an application containing a -significant amount of redundant data, such as form-type data, numerous -companies today are working on various kinds of form renewal, prior to -going through a recognition process, by using dropout colors. Thus, -acquiring access to form design or using electronic means are worth -considering. HOOTON also noted that conversion usually makes or breaks -one's imaging system. It is extremely important, extremely costly in -terms of either capital investment or service, and determines the quality -of the remainder of one's system, because it determines the character of -the raw material used by the system. - -Concerning the four projects undertaken by NAL, two inside and two -performed by outside contractors, ZIDAR revealed that an in-house service -bureau executed the first at a cost between $8 and $10 per page for -everything, including building of the database. The project undertaken -by the Consultative Group on International Agricultural Research (CGIAR) -cost approximately $10 per page for the conversion, plus some expenses -for the software and building of the database. The Acid Rain Project--a -two-disk set produced by the University of Vermont, consisting of -Canadian publications on acid rain--cost $6.70 per page for everything, -including keying of the text, which was double keyed, scanning of the -images, and building of the database. The in-house project offered -considerable ease of convenience and greater control of the process. On -the other hand, the service bureaus know their job and perform it -expeditiously, because they have more people. - -As a useful comparison, ERWAY revealed AM's costs as follows: $0.75 -cents to $0.85 cents per thousand characters, with an average page -containing 2,700 characters. Requirements for coding and imaging -increase the costs. Thus, conversion of the text, including the coding, -costs approximately $3 per page. (This figure does not include the -imaging and database-building included in the NAL costs.) AM also -enjoyed a happy experience with Federal Prison Industries, which -precluded the necessity of going through the request-for-proposal process -to award a contract, because it is another government agency. The -prisoners performed AM's rekeying just as well as other service bureaus -and proved handy as well. AM shipped them the books, which they would -photocopy on a book-edge scanner. They would perform the markup on -photocopies, return the books as soon as they were done with them, -perform the keying, and return the material to AM on WORM disks. - -ZIDAR detailed the elements that constitute the previously noted cost of -approximately $7 per page. Most significant is the editing, correction -of errors, and spell-checkings, which though they may sound easy to -perform require, in fact, a great deal of time. Reformatting text also -takes a while, but a significant amount of NAL's expenses are for equipment, -which was extremely expensive when purchased because it was one of the few -systems on the market. The costs of equipment are being amortized over -five years but are still quite high, nearly $2,000 per month. - -HOCKEY raised a general question concerning OCR and the amount of editing -required (substantial in her experience) to generate the kind of -structured markup necessary for manipulating the text on the computer or -loading it into any retrieval system. She wondered if the speakers could -extend the previous question about the cost-benefit of adding or exerting -structured markup. ERWAY noted that several OCR systems retain italics, -bolding, and other spatial formatting. While the material may not be in -the format desired, these systems possess the ability to remove the -original materials quickly from the hands of the people performing the -conversion, as well as to retain that information so that users can work -with it. HOCKEY rejoined that the current thinking on markup is that one -should not say that something is italic or bold so much as why it is that -way. To be sure, one needs to know that something was italicized, but -how can one get from one to the other? One can map from the structure to -the typographic representation. - -FLEISCHHAUER suggested that, given the 100 million items the Library -holds, it may not be possible for LC to do more than report that a thing -was in italics as opposed to why it was italics, although that may be -desirable in some contexts. Promising to talk a bit during the afternoon -session about several experiments OCLC performed on automatic recognition -of document elements, and which they hoped to extend, WEIBEL said that in -fact one can recognize the major elements of a document with a fairly -high degree of reliability, at least as good as OCR. STEVENS drew a -useful distinction between standard, generalized markup (i.e., defining -for a document-type definition the structure of the document), and what -he termed a style sheet, which had to do with italics, bolding, and other -forms of emphasis. Thus, two different components are at work, one being -the structure of the document itself (its logic), and the other being its -representation when it is put on the screen or printed. - - ****** - -SESSION V. APPROACHES TO PREPARING ELECTRONIC TEXTS - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -HOCKEY * Text in ASCII and the representation of electronic text versus -an image * The need to look at ways of using markup to assist retrieval * -The need for an encoding format that will be reusable and multifunctional -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Susan HOCKEY, director, Center for Electronic Texts in the Humanities -(CETH), Rutgers and Princeton Universities, announced that one talk -(WEIBEL's) was moved into this session from the morning and that David -Packard was unable to attend. The session would attempt to focus more on -what one can do with a text in ASCII and the representation of electronic -text rather than just an image, what one can do with a computer that -cannot be done with a book or an image. It would be argued that one can -do much more than just read a text, and from that starting point one can -use markup and methods of preparing the text to take full advantage of -the capability of the computer. That would lead to a discussion of what -the European Community calls REUSABILITY, what may better be termed -DURABILITY, that is, how to prepare or make a text that will last a long -time and that can be used for as many applications as possible, which -would lead to issues of improving intellectual access. - -HOCKEY urged the need to look at ways of using markup to facilitate retrieval, -not just for referencing or to help locate an item that is retrieved, but also to put markup tags in -a text to help retrieve the thing sought either with linguistic tagging or -interpretation. HOCKEY also argued that little advancement had occurred in -the software tools currently available for retrieving and searching text. -She pressed the desideratum of going beyond Boolean searches and performing -more sophisticated searching, which the insertion of more markup in the text -would facilitate. Thinking about electronic texts as opposed to images means -considering material that will never appear in print form, or print will not -be its primary form, that is, material which only appears in electronic form. -HOCKEY alluded to the history and the need for markup and tagging and -electronic text, which was developed through the use of computers in the -humanities; as MICHELSON had observed, Father Busa had started in 1949 -to prepare the first-ever text on the computer. - -HOCKEY remarked several large projects, particularly in Europe, for the -compilation of dictionaries, language studies, and language analysis, in -which people have built up archives of text and have begun to recognize -the need for an encoding format that will be reusable and multifunctional, -that can be used not just to print the text, which may be assumed to be a -byproduct of what one wants to do, but to structure it inside the computer -so that it can be searched, built into a Hypertext system, etc. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -WEIBEL * OCLC's approach to preparing electronic text: retroconversion, -keying of texts, more automated ways of developing data * Project ADAPT -and the CORE Project * Intelligent character recognition does not exist * -Advantages of SGML * Data should be free of procedural markup; -descriptive markup strongly advocated * OCLC's interface illustrated * -Storage requirements and costs for putting a lot of information on line * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Stuart WEIBEL, senior research scientist, Online Computer Library Center, -Inc. (OCLC), described OCLC's approach to preparing electronic text. He -argued that the electronic world into which we are moving must -accommodate not only the future but the past as well, and to some degree -even the present. Thus, starting out at one end with retroconversion and -keying of texts, one would like to move toward much more automated ways -of developing data. - -For example, Project ADAPT had to do with automatically converting -document images into a structured document database with OCR text as -indexing and also a little bit of automatic formatting and tagging of -that text. The CORE project hosted by Cornell University, Bellcore, -OCLC, the American Chemical Society, and Chemical Abstracts, constitutes -WEIBEL's principal concern at the moment. This project is an example of -converting text for which one already has a machine-readable version into -a format more suitable for electronic delivery and database searching. -(Since Michael LESK had previously described CORE, WEIBEL would say -little concerning it.) Borrowing a chemical phrase, de novo synthesis, -WEIBEL cited the Online Journal of Current Clinical Trials as an example -of de novo electronic publishing, that is, a form in which the primary -form of the information is electronic. - -Project ADAPT, then, which OCLC completed a couple of years ago and in -fact is about to resume, is a model in which one takes page images either -in paper or microfilm and converts them automatically to a searchable -electronic database, either on-line or local. The operating assumption -is that accepting some blemishes in the data, especially for -retroconversion of materials, will make it possible to accomplish more. -Not enough money is available to support perfect conversion. - -WEIBEL related several steps taken to perform image preprocessing -(processing on the image before performing optical character -recognition), as well as image postprocessing. He denied the existence -of intelligent character recognition and asserted that what is wanted is -page recognition, which is a long way off. OCLC has experimented with -merging of multiple optical character recognition systems that will -reduce errors from an unacceptable rate of 5 characters out of every -l,000 to an unacceptable rate of 2 characters out of every l,000, but it -is not good enough. It will never be perfect. - -Concerning the CORE Project, WEIBEL observed that Bellcore is taking the -topography files, extracting the page images, and converting those -topography files to SGML markup. LESK hands that data off to OCLC, which -builds that data into a Newton database, the same system that underlies -the on-line system in virtually all of the reference products at OCLC. -The long-term goal is to make the systems interoperable so that not just -Bellcore's system and OCLC's system can access this data, but other -systems can as well, and the key to that is the Z39.50 common command -language and the full-text extension. Z39.50 is fine for MARC records, -but is not enough to do it for full text (that is, make full texts -interoperable). - -WEIBEL next outlined the critical role of SGML for a variety of purposes, -for example, as noted by HOCKEY, in the world of extremely large -databases, using highly structured data to perform field searches. -WEIBEL argued that by building the structure of the data in (i.e., the -structure of the data originally on a printed page), it becomes easy to -look at a journal article even if one cannot read the characters and know -where the title or author is, or what the sections of that document would be. -OCLC wants to make that structure explicit in the database, because it will -be important for retrieval purposes. - -The second big advantage of SGML is that it gives one the ability to -build structure into the database that can be used for display purposes -without contaminating the data with instructions about how to format -things. The distinction lies between procedural markup, which tells one -where to put dots on the page, and descriptive markup, which describes -the elements of a document. - -WEIBEL believes that there should be no procedural markup in the data at -all, that the data should be completely unsullied by information about -italics or boldness. That should be left up to the display device, -whether that display device is a page printer or a screen display device. -By keeping one's database free of that kind of contamination, one can -make decisions down the road, for example, reorganize the data in ways -that are not cramped by built-in notions of what should be italic and -what should be bold. WEIBEL strongly advocated descriptive markup. As -an example, he illustrated the index structure in the CORE data. With -subsequent illustrated examples of markup, WEIBEL acknowledged the common -complaint that SGML is hard to read in its native form, although markup -decreases considerably once one gets into the body. Without the markup, -however, one would not have the structure in the data. One can pass -markup through a LaTeX processor and convert it relatively easily to a -printed version of the document. - -WEIBEL next illustrated an extremely cluttered screen dump of OCLC's -system, in order to show as much as possible the inherent capability on -the screen. (He noted parenthetically that he had become a supporter of -X-Windows as a result of the progress of the CORE Project.) WEIBEL also -illustrated the two major parts of the interface: l) a control box that -allows one to generate lists of items, which resembles a small table of -contents based on key words one wishes to search, and 2) a document -viewer, which is a separate process in and of itself. He demonstrated -how to follow links through the electronic database simply by selecting -the appropriate button and bringing them up. He also noted problems that -remain to be accommodated in the interface (e.g., as pointed out by LESK, -what happens when users do not click on the icon for the figure). - -Given the constraints of time, WEIBEL omitted a large number of ancillary -items in order to say a few words concerning storage requirements and -what will be required to put a lot of things on line. Since it is -extremely expensive to reconvert all of this data, especially if it is -just in paper form (and even if it is in electronic form in typesetting -tapes), he advocated building journals electronically from the start. In -that case, if one only has text graphics and indexing (which is all that -one needs with de novo electronic publishing, because there is no need to -go back and look at bit-maps of pages), one can get 10,000 journals of -full text, or almost 6 million pages per year. These pages can be put in -approximately 135 gigabytes of storage, which is not all that much, -WEIBEL said. For twenty years, something less than three terabytes would -be required. WEIBEL calculated the costs of storing this information as -follows: If a gigabyte costs approximately $1,000, then a terabyte costs -approximately $1 million to buy in terms of hardware. One also needs a -building to put it in and a staff like OCLC to handle that information. -So, to support a terabyte, multiply by five, which gives $5 million per -year for a supported terabyte of data. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Tapes saved by ACS are the typography files originally -supporting publication of the journal * Cost of building tagged text into -the database * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the question-and-answer period that followed WEIBEL's -presentation, these clarifications emerged. The tapes saved by the -American Chemical Society are the typography files that originally -supported the publication of the journal. Although they are not tagged -in SGML, they are tagged in very fine detail. Every single sentence is -marked, all the registry numbers, all the publications issues, dates, and -volumes. No cost figures on tagging material on a per-megabyte basis -were available. Because ACS's typesetting system runs from tagged text, -there is no extra cost per article. It was unknown what it costs ACS to -keyboard the tagged text rather than just keyboard the text in the -cheapest process. In other words, since one intends to publish things -and will need to build tagged text into a typography system in any case, -if one does that in such a way that it can drive not only typography but -an electronic system (which is what ACS intends to do--move to SGML -publishing), the marginal cost is zero. The marginal cost represents the -cost of building tagged text into the database, which is small. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -SPERBERG-McQUEEN * Distinction between texts and computers * Implications -of recognizing that all representation is encoding * Dealing with -complicated representations of text entails the need for a grammar of -documents * Variety of forms of formal grammars * Text as a bit-mapped -image does not represent a serious attempt to represent text in -electronic form * SGML, the TEI, document-type declarations, and the -reusability and longevity of data * TEI conformance explicitly allows -extension or modification of the TEI tag set * Administrative background -of the TEI * Several design goals for the TEI tag set * An absolutely -fixed requirement of the TEI Guidelines * Challenges the TEI has -attempted to face * Good texts not beyond economic feasibility * The -issue of reproducibility or processability * The issue of mages as -simulacra for the text redux * One's model of text determines what one's -software can do with a text and has economic consequences * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Prior to speaking about SGML and markup, Michael SPERBERG-McQUEEN, editor, -Text Encoding Initiative (TEI), University of Illinois-Chicago, first drew -a distinction between texts and computers: Texts are abstract cultural -and linguistic objects while computers are complicated physical devices, -he said. Abstract objects cannot be placed inside physical devices; with -computers one can only represent text and act upon those representations. - -The recognition that all representation is encoding, SPERBERG-McQUEEN -argued, leads to the recognition of two things: 1) The topic description -for this session is slightly misleading, because there can be no discussion -of pros and cons of text-coding unless what one means is pros and cons of -working with text with computers. 2) No text can be represented in a -computer without some sort of encoding; images are one way of encoding text, -ASCII is another, SGML yet another. There is no encoding without some -information loss, that is, there is no perfect reproduction of a text that -allows one to do away with the original. Thus, the question becomes, -What is the most useful representation of text for a serious work? -This depends on what kind of serious work one is talking about. - -The projects demonstrated the previous day all involved highly complex -information and fairly complex manipulation of the textual material. -In order to use that complicated information, one has to calculate it -slowly or manually and store the result. It needs to be stored, therefore, -as part of one's representation of the text. Thus, one needs to store the -structure in the text. To deal with complicated representations of text, -one needs somehow to control the complexity of the representation of a text; -that means one needs a way of finding out whether a document and an -electronic representation of a document is legal or not; and that -means one needs a grammar of documents. - -SPERBERG-McQUEEN discussed the variety of forms of formal grammars, -implicit and explicit, as applied to text, and their capabilities. He -argued that these grammars correspond to different models of text that -different developers have. For example, one implicit model of the text -is that there is no internal structure, but just one thing after another, -a few characters and then perhaps a start-title command, and then a few -more characters and an end-title command. SPERBERG-McQUEEN also -distinguished several kinds of text that have a sort of hierarchical -structure that is not very well defined, which, typically, corresponds -to grammars that are not very well defined, as well as hierarchies that -are very well defined (e.g., the Thesaurus Linguae Graecae) and extremely -complicated things such as SGML, which handle strictly hierarchical data -very nicely. - -SPERBERG-McQUEEN conceded that one other model not illustrated on his two -displays was the model of text as a bit-mapped image, an image of a page, -and confessed to having been converted to a limited extent by the -Workshop to the view that electronic images constitute a promising, -probably superior alternative to microfilming. But he was not convinced -that electronic images represent a serious attempt to represent text in -electronic form. Many of their problems stem from the fact that they are -not direct attempts to represent the text but attempts to represent the -page, thus making them representations of representations. - -In this situation of increasingly complicated textual information and the -need to control that complexity in a useful way (which begs the question -of the need for good textual grammars), one has the introduction of SGML. -With SGML, one can develop specific document-type declarations -for specific text types or, as with the TEI, attempts to generate -general document-type declarations that can handle all sorts of text. -The TEI is an attempt to develop formats for text representation that -will ensure the kind of reusability and longevity of data discussed earlier. -It offers a way to stay alive in the state of permanent technological -revolution. - -It has been a continuing challenge in the TEI to create document grammars -that do some work in controlling the complexity of the textual object but -also allowing one to represent the real text that one will find. -Fundamental to the notion of the TEI is that TEI conformance allows one -the ability to extend or modify the TEI tag set so that it fits the text -that one is attempting to represent. - -SPERBERG-McQUEEN next outlined the administrative background of the TEI. -The TEI is an international project to develop and disseminate guidelines -for the encoding and interchange of machine-readable text. It is -sponsored by the Association for Computers in the Humanities, the -Association for Computational Linguistics, and the Association for -Literary and Linguistic Computing. Representatives of numerous other -professional societies sit on its advisory board. The TEI has a number -of affiliated projects that have provided assistance by testing drafts of -the guidelines. - -Among the design goals for the TEI tag set, the scheme first of all must -meet the needs of research, because the TEI came out of the research -community, which did not feel adequately served by existing tag sets. -The tag set must be extensive as well as compatible with existing and -emerging standards. In 1990, version 1.0 of the Guidelines was released -(SPERBERG-McQUEEN illustrated their contents). - -SPERBERG-McQUEEN noted that one problem besetting electronic text has -been the lack of adequate internal or external documentation for many -existing electronic texts. The TEI guidelines as currently formulated -contain few fixed requirements, but one of them is this: There must -always be a document header, an in-file SGML tag that provides -1) a bibliographic description of the electronic object one is talking -about (that is, who included it, when, what for, and under which title); -and 2) the copy text from which it was derived, if any. If there was -no copy text or if the copy text is unknown, then one states as much. -Version 2.0 of the Guidelines was scheduled to be completed in fall 1992 -and a revised third version is to be presented to the TEI advisory board -for its endorsement this coming winter. The TEI itself exists to provide -a markup language, not a marked-up text. - -Among the challenges the TEI has attempted to face is the need for a -markup language that will work for existing projects, that is, handle the -level of markup that people are using now to tag only chapter, section, -and paragraph divisions and not much else. At the same time, such a -language also will be able to scale up gracefully to handle the highly -detailed markup which many people foresee as the future destination of -much electronic text, and which is not the future destination but the -present home of numerous electronic texts in specialized areas. - -SPERBERG-McQUEEN dismissed the lowest-common-denominator approach as -unable to support the kind of applications that draw people who have -never been in the public library regularly before, and make them come -back. He advocated more interesting text and more intelligent text. -Asserting that it is not beyond economic feasibility to have good texts, -SPERBERG-McQUEEN noted that the TEI Guidelines listing 200-odd tags -contains tags that one is expected to enter every time the relevant -textual feature occurs. It contains all the tags that people need now, -and it is not expected that everyone will tag things in the same way. - -The question of how people will tag the text is in large part a function -of their reaction to what SPERBERG-McQUEEN termed the issue of -reproducibility. What one needs to be able to reproduce are the things -one wants to work with. Perhaps a more useful concept than that of -reproducibility or recoverability is that of processability, that is, -what can one get from an electronic text without reading it again -in the original. He illustrated this contention with a page from -Jan Comenius's bilingual Introduction to Latin. - -SPERBERG-McQUEEN returned at length to the issue of images as simulacra -for the text, in order to reiterate his belief that in the long run more -than images of pages of particular editions of the text are needed, -because just as second-generation photocopies and second-generation -microfilm degenerate, so second-generation representations tend to -degenerate, and one tends to overstress some relatively trivial aspects -of the text such as its layout on the page, which is not always -significant, despite what the text critics might say, and slight other -pieces of information such as the very important lexical ties between the -English and Latin versions of Comenius's bilingual text, for example. -Moreover, in many crucial respects it is easy to fool oneself concerning -what a scanned image of the text will accomplish. For example, in order -to study the transmission of texts, information concerning the text -carrier is necessary, which scanned images simply do not always handle. -Further, even the high-quality materials being produced at Cornell use -much of the information that one would need if studying those books as -physical objects. It is a choice that has been made. It is an arguably -justifiable choice, but one does not know what color those pen strokes in -the margin are or whether there was a stain on the page, because it has -been filtered out. One does not know whether there were rips in the page -because they do not show up, and on a couple of the marginal marks one -loses half of the mark because the pen is very light and the scanner -failed to pick it up, and so what is clearly a checkmark in the margin of -the original becomes a little scoop in the margin of the facsimile. -Standard problems for facsimile editions, not new to electronics, but -also true of light-lens photography, and are remarked here because it is -important that we not fool ourselves that even if we produce a very nice -image of this page with good contrast, we are not replacing the -manuscript any more than microfilm has replaced the manuscript. - -The TEI comes from the research community, where its first allegiance -lies, but it is not just an academic exercise. It has relevance far -beyond those who spend all of their time studying text, because one's -model of text determines what one's software can do with a text. Good -models lead to good software. Bad models lead to bad software. That has -economic consequences, and it is these economic consequences that have -led the European Community to help support the TEI, and that will lead, -SPERBERG-McQUEEN hoped, some software vendors to realize that if they -provide software with a better model of the text they can make a killing. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Implications of different DTDs and tag sets * ODA versus SGML * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -During the discussion that followed, several additional points were made. -Neither AAP (i.e., Association of American Publishers) nor CALS (i.e., -Computer-aided Acquisition and Logistics Support) has a document-type -definition for ancient Greek drama, although the TEI will be able to -handle that. Given this state of affairs and assuming that the -technical-journal producers and the commercial vendors decide to use the -other two types, then an institution like the Library of Congress, which -might receive all of their publications, would have to be able to handle -three different types of document definitions and tag sets and be able to -distinguish among them. - -Office Document Architecture (ODA) has some advantages that flow from its -tight focus on office documents and clear directions for implementation. -Much of the ODA standard is easier to read and clearer at first reading -than the SGML standard, which is extremely general. What that means is -that if one wants to use graphics in TIFF and ODA, one is stuck, because -ODA defines graphics formats while TIFF does not, whereas SGML says the -world is not waiting for this work group to create another graphics format. -What is needed is an ability to use whatever graphics format one wants. - -The TEI provides a socket that allows one to connect the SGML document to -the graphics. The notation that the graphics are in is clearly a choice -that one needs to make based on her or his environment, and that is one -advantage. SGML is less megalomaniacal in attempting to define formats -for all kinds of information, though more megalomaniacal in attempting to -cover all sorts of documents. The other advantage is that the model of -text represented by SGML is simply an order of magnitude richer and more -flexible than the model of text offered by ODA. Both offer hierarchical -structures, but SGML recognizes that the hierarchical model of the text -that one is looking at may not have been in the minds of the designers, -whereas ODA does not. - -ODA is not really aiming for the kind of document that the TEI wants to -encompass. The TEI can handle the kind of material ODA has, as well as a -significantly broader range of material. ODA seems to be very much -focused on office documents, which is what it started out being called-- -office document architecture. - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -CALALUCA * Text-encoding from a publisher's perspective * -Responsibilities of a publisher * Reproduction of Migne's Latin series -whole and complete with SGML tags based on perceived need and expected -use * Particular decisions arising from the general decision to produce -and publish PLD * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -The final speaker in this session, Eric CALALUCA, vice president, -Chadwyck-Healey, Inc., spoke from the perspective of a publisher re -text-encoding, rather than as one qualified to discuss methods of -encoding data, and observed that the presenters sitting in the room, -whether they had chosen to or not, were acting as publishers: making -choices, gathering data, gathering information, and making assessments. -CALALUCA offered the hard-won conviction that in publishing very large -text files (such as PLD), one cannot avoid making personal judgments of -appropriateness and structure. - -In CALALUCA's view, encoding decisions stem from prior judgments. Two -notions have become axioms for him in the consideration of future sources -for electronic publication: 1) electronic text publishing is as personal -as any other kind of publishing, and questions of if and how to encode -the data are simply a consequence of that prior decision; 2) all -personal decisions are open to criticism, which is unavoidable. - -CALALUCA rehearsed his role as a publisher or, better, as an intermediary -between what is viewed as a sound idea and the people who would make use -of it. Finding the specialist to advise in this process is the core of -that function. The publisher must monitor and hug the fine line between -giving users what they want and suggesting what they might need. One -responsibility of a publisher is to represent the desires of scholars and -research librarians as opposed to bullheadedly forcing them into areas -they would not choose to enter. - -CALALUCA likened the questions being raised today about data structure -and standards to the decisions faced by the Abbe Migne himself during -production of the Patrologia series in the mid-nineteenth century. -Chadwyck-Healey's decision to reproduce Migne's Latin series whole and -complete with SGML tags was also based upon a perceived need and an -expected use. In the same way that Migne's work came to be far more than -a simple handbook for clerics, PLD is already far more than a database -for theologians. It is a bedrock source for the study of Western -civilization, CALALUCA asserted. - -In regard to the decision to produce and publish PLD, the editorial board -offered direct judgments on the question of appropriateness of these -texts for conversion, their encoding and their distribution, and -concluded that the best possible project was one that avoided overt -intrusions or exclusions in so important a resource. Thus, the general -decision to transmit the original collection as clearly as possible with -the widest possible avenues for use led to other decisions: 1) To encode -the data or not, SGML or not, TEI or not. Again, the expected user -community asserted the need for normative tagging structures of important -humanities texts, and the TEI seemed the most appropriate structure for -that purpose. Research librarians, who are trained to view the larger -impact of electronic text sources on 80 or 90 or 100 doctoral -disciplines, loudly approved the decision to include tagging. They see -what is coming better than the specialist who is completely focused on -one edition of Ambrose's De Anima, and they also understand that the -potential uses exceed present expectations. 2) What will be tagged and -what will not. Once again, the board realized that one must tag the -obvious. But in no way should one attempt to identify through encoding -schemes every single discrete area of a text that might someday be -searched. That was another decision. Searching by a column number, an -author, a word, a volume, permitting combination searches, and tagging -notations seemed logical choices as core elements. 3) How does one make -the data available? Tieing it to a CD-ROM edition creates limitations, -but a magnetic tape file that is very large, is accompanied by the -encoding specifications, and that allows one to make local modifications -also allows one to incorporate any changes one may desire within the -bounds of private research, though exporting tag files from a CD-ROM -could serve just as well. Since no one on the board could possibly -anticipate each and every way in which a scholar might choose to mine -this data bank, it was decided to satisfy the basics and make some -provisions for what might come. 4) Not to encode the database would rob -it of the interchangeability and portability these important texts should -accommodate. For CALALUCA, the extensive options presented by full-text -searching require care in text selection and strongly support encoding of -data to facilitate the widest possible search strategies. Better -software can always be created, but summoning the resources, the people, -and the energy to reconvert the text is another matter. - -PLD is being encoded, captured, and distributed, because to -Chadwyck-Healey and the board it offers the widest possible array of -future research applications that can be seen today. CALALUCA concluded -by urging the encoding of all important text sources in whatever way -seems most appropriate and durable at the time, without blanching at the -thought that one's work may require emendation in the future. (Thus, -Chadwyck-Healey produced a very large humanities text database before the -final release of the TEI Guidelines.) - - ****** - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -DISCUSSION * Creating texts with markup advocated * Trends in encoding * -The TEI and the issue of interchangeability of standards * A -misconception concerning the TEI * Implications for an institution like -LC in the event that a multiplicity of DTDs develops * Producing images -as a first step towards possible conversion to full text through -character recognition * The AAP tag sets as a common starting point and -the need for caution * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -HOCKEY prefaced the discussion that followed with several comments in -favor of creating texts with markup and on trends in encoding. In the -future, when many more texts are available for on-line searching, real -problems in finding what is wanted will develop, if one is faced with -millions of words of data. It therefore becomes important to consider -putting markup in texts to help searchers home in on the actual things -they wish to retrieve. Various approaches to refining retrieval methods -toward this end include building on a computer version of a dictionary -and letting the computer look up words in it to obtain more information -about the semantic structure or semantic field of a word, its grammatical -structure, and syntactic structure. - -HOCKEY commented on the present keen interest in the encoding world -in creating: 1) machine-readable versions of dictionaries that can be -initially tagged in SGML, which gives a structure to the dictionary entry; -these entries can then be converted into a more rigid or otherwise -different database structure inside the computer, which can be treated as -a dynamic tool for searching mechanisms; 2) large bodies of text to study -the language. In order to incorporate more sophisticated mechanisms, -more about how words behave needs to be known, which can be learned in -part from information in dictionaries. However, the last ten years have -seen much interest in studying the structure of printed dictionaries -converted into computer-readable form. The information one derives about -many words from those is only partial, one or two definitions of the -common or the usual meaning of a word, and then numerous definitions of -unusual usages. If the computer is using a dictionary to help retrieve -words in a text, it needs much more information about the common usages, -because those are the ones that occur over and over again. Hence the -current interest in developing large bodies of text in computer-readable -form in order to study the language. Several projects are engaged in -compiling, for example, 100 million words. HOCKEY described one with -which she was associated briefly at Oxford University involving -compilation of 100 million words of British English: about 10 percent of -that will contain detailed linguistic tagging encoded in SGML; it will -have word class taggings, with words identified as nouns, verbs, -adjectives, or other parts of speech. This tagging can then be used by -programs which will begin to learn a bit more about the structure of the -language, and then, can go to tag more text. - -HOCKEY said that the more that is tagged accurately, the more one can -refine the tagging process and thus the bigger body of text one can build -up with linguistic tagging incorporated into it. Hence, the more tagging -or annotation there is in the text, the more one may begin to learn about -language and the more it will help accomplish more intelligent OCR. She -recommended the development of software tools that will help one begin to -understand more about a text, which can then be applied to scanning -images of that text in that format and to using more intelligence to help -one interpret or understand the text. - -HOCKEY posited the need to think about common methods of text-encoding -for a long time to come, because building these large bodies of text is -extremely expensive and will only be done once. - -In the more general discussion on approaches to encoding that followed, -these points were made: - -BESSER identified the underlying problem with standards that all have to -struggle with in adopting a standard, namely, the tension between a very -highly defined standard that is very interchangeable but does not work -for everyone because something is lacking, and a standard that is less -defined, more open, more adaptable, but less interchangeable. Contending -that the way in which people use SGML is not sufficiently defined, BESSER -wondered 1) if people resist the TEI because they think it is too defined -in certain things they do not fit into, and 2) how progress with -interchangeability can be made without frightening people away. - -SPERBERG-McQUEEN replied that the published drafts of the TEI had met -with surprisingly little objection on the grounds that they do not allow -one to handle X or Y or Z. Particular concerns of the affiliated -projects have led, in practice, to discussions of how extensions are to -be made; the primary concern of any project has to be how it can be -represented locally, thus making interchange secondary. The TEI has -received much criticism based on the notion that everything in it is -required or even recommended, which, as it happens, is a misconception -from the beginning, because none of it is required and very little is -actually actively recommended for all cases, except that one document -one's source. - -SPERBERG-McQUEEN agreed with BESSER about this trade-off: all the -projects in a set of twenty TEI-conformant projects will not necessarily -tag the material in the same way. One result of the TEI will be that the -easiest problems will be solved--those dealing with the external form of -the information; but the problem that is hardest in interchange is that -one is not encoding what another wants, and vice versa. Thus, after -the adoption of a common notation, the differences in the underlying -conceptions of what is interesting about texts become more visible. -The success of a standard like the TEI will lie in the ability of -the recipient of interchanged texts to use some of what it contains -and to add the information that was not encoded that one wants, in a -layered way, so that texts can be gradually enriched and one does not -have to put in everything all at once. Hence, having a well-behaved -markup scheme is important. - -STEVENS followed up on the paradoxical analogy that BESSER alluded to in -the example of the MARC records, namely, the formats that are the same -except that they are different. STEVENS drew a parallel between -document-type definitions and MARC records for books and serials and maps, -where one has a tagging structure and there is a text-interchange. -STEVENS opined that the producers of the information will set the terms -for the standard (i.e., develop document-type definitions for the users -of their products), creating a situation that will be problematical for -an institution like the Library of Congress, which will have to deal with -the DTDs in the event that a multiplicity of them develops. Thus, -numerous people are seeking a standard but cannot find the tag set that -will be acceptable to them and their clients. SPERBERG-McQUEEN agreed -with this view, and said that the situation was in a way worse: attempting -to unify arbitrary DTDs resembled attempting to unify a MARC record with a -bibliographic record done according to the Prussian instructions. -According to STEVENS, this situation occurred very early in the process. - -WATERS recalled from early discussions on Project Open Book the concern -of many people that merely by producing images, POB was not really -enhancing intellectual access to the material. Nevertheless, not wishing -to overemphasize the opposition between imaging and full text, WATERS -stated that POB views getting the images as a first step toward possibly -converting to full text through character recognition, if the technology -is appropriate. WATERS also emphasized that encoding is involved even -with a set of images. - -SPERBERG-McQUEEN agreed with WATERS that one can create an SGML document -consisting wholly of images. At first sight, organizing graphic images -with an SGML document may not seem to offer great advantages, but the -advantages of the scheme WATERS described would be precisely that -ability to move into something that is more of a multimedia document: -a combination of transcribed text and page images. WEIBEL concurred in -this judgment, offering evidence from Project ADAPT, where a page is -divided into text elements and graphic elements, and in fact the text -elements are organized by columns and lines. These lines may be used as -the basis for distributing documents in a network environment. As one -develops software intelligent enough to recognize what those elements -are, it makes sense to apply SGML to an image initially, that may, in -fact, ultimately become more and more text, either through OCR or edited -OCR or even just through keying. For WATERS, the labor of composing the -document and saying this set of documents or this set of images belongs -to this document constitutes a significant investment. - -WEIBEL also made the point that the AAP tag sets, while not excessively -prescriptive, offer a common starting point; they do not define the -structure of the documents, though. They have some recommendations about -DTDs one could use as examples, but they do just suggest tag sets. For -example, the CORE project attempts to use the AAP markup as much as -possible, but there are clearly areas where structure must be added. -That in no way contradicts the use of AAP tag sets. - -SPERBERG-McQUEEN noted that the TEI prepared a long working paper early -on about the AAP tag set and what it lacked that the TEI thought it -needed, and a fairly long critique of the naming conventions, which has -led to a very different style of naming in the TEI. He stressed the -importance of the opposition between prescriptive markup, the kind that a -publisher or anybody can do when producing documents de novo, and -descriptive markup, in which one has to take what the text carrier -provides. In these particular tag sets it is easy to overemphasize this -opposition, because the AAP tag set is extremely flexible. Even if one -just used the DTDs, they allow almost anything to appear almost anywhere. - - ****** - -SESSION VI. COPYRIGHT ISSUES - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -PETERS * Several cautions concerning copyright in an electronic -environment * Review of copyright law in the United States * The notion -of the public good and the desirability of incentives to promote it * -What copyright protects * Works not protected by copyright * The rights -of copyright holders * Publishers' concerns in today's electronic -environment * Compulsory licenses * The price of copyright in a digital -medium and the need for cooperation * Additional clarifications * Rough -justice oftentimes the outcome in numerous copyright matters * Copyright -in an electronic society * Copyright law always only sets up the -boundaries; anything can be changed by contract * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Marybeth PETERS, policy planning adviser to the Register of Copyrights, -Library of Congress, made several general comments and then opened the -floor to discussion of subjects of interest to the audience. - -Having attended several sessions in an effort to gain a sense of what -people did and where copyright would affect their lives, PETERS expressed -the following cautions: - - * If one takes and converts materials and puts them in new forms, - then, from a copyright point of view, one is creating something and - will receive some rights. - - * However, if what one is converting already exists, a question - immediately arises about the status of the materials in question. - - * Putting something in the public domain in the United States offers - some freedom from anxiety, but distributing it throughout the world - on a network is another matter, even if one has put it in the public - domain in the United States. Re foreign laws, very frequently a - work can be in the public domain in the United States but protected - in other countries. Thus, one must consider all of the places a - work may reach, lest one unwittingly become liable to being faced - with a suit for copyright infringement, or at least a letter - demanding discussion of what one is doing. - -PETERS reviewed copyright law in the United States. The U.S. -Constitution effectively states that Congress has the power to enact -copyright laws for two purposes: 1) to encourage the creation and -dissemination of intellectual works for the good of society as a whole; -and, significantly, 2) to give creators and those who package and -disseminate materials the economic rewards that are due them. - -Congress strives to strike a balance, which at times can become an -emotional issue. The United States has never accepted the notion of the -natural right of an author so much as it has accepted the notion of the -public good and the desirability of incentives to promote it. This state -of affairs, however, has created strains on the international level and -is the reason for several of the differences in the laws that we have. -Today the United States protects almost every kind of work that can be -called an expression of an author. The standard for gaining copyright -protection is simply originality. This is a low standard and means that -a work is not copied from something else, as well as shows a certain -minimal amount of authorship. One can also acquire copyright protection -for making a new version of preexisting material, provided it manifests -some spark of creativity. - -However, copyright does not protect ideas, methods, systems--only the way -that one expresses those things. Nor does copyright protect anything -that is mechanical, anything that does not involve choice, or criteria -concerning whether or not one should do a thing. For example, the -results of a process called declicking, in which one mechanically removes -impure sounds from old recordings, are not copyrightable. On the other -hand, the choice to record a song digitally and to increase the sound of -violins or to bring up the tympani constitutes the results of conversion -that are copyrightable. Moreover, if a work is protected by copyright in -the United States, one generally needs the permission of the copyright -owner to convert it. Normally, who will own the new--that is, converted- --material is a matter of contract. In the absence of a contract, the -person who creates the new material is the author and owner. But people -do not generally think about the copyright implications until after the -fact. PETERS stressed the need when dealing with copyrighted works to -think about copyright in advance. One's bargaining power is much greater -up front than it is down the road. - -PETERS next discussed works not protected by copyright, for example, any -work done by a federal employee as part of his or her official duties is -in the public domain in the United States. The issue is not wholly free -of doubt concerning whether or not the work is in the public domain -outside the United States. Other materials in the public domain include: -any works published more than seventy-five years ago, and any work -published in the United States more than twenty-eight years ago, whose -copyright was not renewed. In talking about the new technology and -putting material in a digital form to send all over the world, PETERS -cautioned, one must keep in mind that while the rights may not be an -issue in the United States, they may be in different parts of the world, -where most countries previously employed a copyright term of the life of -the author plus fifty years. - -PETERS next reviewed the economics of copyright holding. Simply, -economic rights are the rights to control the reproduction of a work in -any form. They belong to the author, or in the case of a work made for -hire, the employer. The second right, which is critical to conversion, -is the right to change a work. The right to make new versions is perhaps -one of the most significant rights of authors, particularly in an -electronic world. The third right is the right to publish the work and -the right to disseminate it, something that everyone who deals in an -electronic medium needs to know. The basic rule is if a copy is sold, -all rights of distribution are extinguished with the sale of that copy. -The key is that it must be sold. A number of companies overcome this -obstacle by leasing or renting their product. These companies argue that -if the material is rented or leased and not sold, they control the uses -of a work. The fourth right, and one very important in a digital world, -is a right of public performance, which means the right to show the work -sequentially. For example, copyright owners control the showing of a -CD-ROM product in a public place such as a public library. The reverse -side of public performance is something called the right of public -display. Moral rights also exist, which at the federal level apply only -to very limited visual works of art, but in theory may apply under -contract and other principles. Moral rights may include the right of an -author to have his or her name on a work, the right of attribution, and -the right to object to distortion or mutilation--the right of integrity. - -The way copyright law is worded gives much latitude to activities such as -preservation; to use of material for scholarly and research purposes when -the user does not make multiple copies; and to the generation of -facsimile copies of unpublished works by libraries for themselves and -other libraries. But the law does not allow anyone to become the -distributor of the product for the entire world. In today's electronic -environment, publishers are extremely concerned that the entire world is -networked and can obtain the information desired from a single copy in a -single library. Hence, if there is to be only one sale, which publishers -may choose to live with, they will obtain their money in other ways, for -example, from access and use. Hence, the development of site licenses -and other kinds of agreements to cover what publishers believe they -should be compensated for. Any solution that the United States takes -today has to consider the international arena. - -Noting that the United States is a member of the Berne Convention and -subscribes to its provisions, PETERS described the permissions process. -She also defined compulsory licenses. A compulsory license, of which the -United States has had a few, builds into the law the right to use a work -subject to certain terms and conditions. In the international arena, -however, the ability to use compulsory licenses is extremely limited. -Thus, clearinghouses and other collectives comprise one option that has -succeeded in providing for use of a work. Often overlooked when one -begins to use copyrighted material and put products together is how -expensive the permissions process and managing it is. According to -PETERS, the price of copyright in a digital medium, whatever solution is -worked out, will include managing and assembling the database. She -strongly recommended that publishers and librarians or people with -various backgrounds cooperate to work out administratively feasible -systems, in order to produce better results. - -In the lengthy question-and-answer period that followed PETERS's -presentation, the following points emerged: - - * The Copyright Office maintains that anything mechanical and - totally exhaustive probably is not protected. In the event that - what an individual did in developing potentially copyrightable - material is not understood, the Copyright Office will ask about the - creative choices the applicant chose to make or not to make. As a - practical matter, if one believes she or he has made enough of those - choices, that person has a right to assert a copyright and someone - else must assert that the work is not copyrightable. The more - mechanical, the more automatic, a thing is, the less likely it is to - be copyrightable. - - * Nearly all photographs are deemed to be copyrightable, but no one - worries about them much, because everyone is free to take the same - image. Thus, a photographic copyright represents what is called a - "thin" copyright. The photograph itself must be duplicated, in - order for copyright to be violated. - - * The Copyright Office takes the position that X-rays are not - copyrightable because they are mechanical. It can be argued - whether or not image enhancement in scanning can be protected. One - must exercise care with material created with public funds and - generally in the public domain. An article written by a federal - employee, if written as part of official duties, is not - copyrightable. However, control over a scientific article written - by a National Institutes of Health grantee (i.e., someone who - receives money from the U.S. government), depends on NIH policy. If - the government agency has no policy (and that policy can be - contained in its regulations, the contract, or the grant), the - author retains copyright. If a provision of the contract, grant, or - regulation states that there will be no copyright, then it does not - exist. When a work is created, copyright automatically comes into - existence unless something exists that says it does not. - - * An enhanced electronic copy of a print copy of an older reference - work in the public domain that does not contain copyrightable new - material is a purely mechanical rendition of the original work, and - is not copyrightable. - - * Usually, when a work enters the public domain, nothing can remove - it. For example, Congress recently passed into law the concept of - automatic renewal, which means that copyright on any work published - between l964 and l978 does not have to be renewed in order to - receive a seventy-five-year term. But any work not renewed before - 1964 is in the public domain. - - * Concerning whether or not the United States keeps track of when - authors die, nothing was ever done, nor is anything being done at - the moment by the Copyright Office. - - * Software that drives a mechanical process is itself copyrightable. - If one changes platforms, the software itself has a copyright. The - World Intellectual Property Organization will hold a symposium 28 - March through 2 April l993, at Harvard University, on digital - technology, and will study this entire issue. If one purchases a - computer software package, such as MacPaint, and creates something - new, one receives protection only for that which has been added. - -PETERS added that often in copyright matters, rough justice is the -outcome, for example, in collective licensing, ASCAP (i.e., American -Society of Composers, Authors, and Publishers), and BMI (i.e., Broadcast -Music, Inc.), where it may seem that the big guys receive more than their -due. Of course, people ought not to copy a creative product without -paying for it; there should be some compensation. But the truth of the -world, and it is not a great truth, is that the big guy gets played on -the radio more frequently than the little guy, who has to do much more -until he becomes a big guy. That is true of every author, every -composer, everyone, and, unfortunately, is part of life. - -Copyright always originates with the author, except in cases of works -made for hire. (Most software falls into this category.) When an author -sends his article to a journal, he has not relinquished copyright, though -he retains the right to relinquish it. The author receives absolutely -everything. The less prominent the author, the more leverage the -publisher will have in contract negotiations. In order to transfer the -rights, the author must sign an agreement giving them away. - -In an electronic society, it is important to be able to license a writer -and work out deals. With regard to use of a work, it usually is much -easier when a publisher holds the rights. In an electronic era, a real -problem arises when one is digitizing and making information available. -PETERS referred again to electronic licensing clearinghouses. Copyright -ought to remain with the author, but as one moves forward globally in the -electronic arena, a middleman who can handle the various rights becomes -increasingly necessary. - -The notion of copyright law is that it resides with the individual, but -in an on-line environment, where a work can be adapted and tinkered with -by many individuals, there is concern. If changes are authorized and -there is no agreement to the contrary, the person who changes a work owns -the changes. To put it another way, the person who acquires permission -to change a work technically will become the author and the owner, unless -some agreement to the contrary has been made. It is typical for the -original publisher to try to control all of the versions and all of the -uses. Copyright law always only sets up the boundaries. Anything can be -changed by contract. - - ****** - -SESSION VII. CONCLUSION - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -GENERAL DISCUSSION * Two questions for discussion * Different emphases in -the Workshop * Bringing the text and image partisans together * -Desiderata in planning the long-term development of something * Questions -surrounding the issue of electronic deposit * Discussion of electronic -deposit as an allusion to the issue of standards * Need for a directory -of preservation projects in digital form and for access to their -digitized files * CETH's catalogue of machine-readable texts in the -humanities * What constitutes a publication in the electronic world? * -Need for LC to deal with the concept of on-line publishing * LC's Network -Development Office exploring the limits of MARC as a standard in terms -of handling electronic information * Magnitude of the problem and the -need for distributed responsibility in order to maintain and store -electronic information * Workshop participants to be viewed as a starting -point * Development of a network version of AM urged * A step toward AM's -construction of some sort of apparatus for network access * A delicate -and agonizing policy question for LC * Re the issue of electronic -deposit, LC urged to initiate a catalytic process in terms of distributed -responsibility * Suggestions for cooperative ventures * Commercial -publishers' fears * Strategic questions for getting the image and text -people to think through long-term cooperation * Clarification of the -driving force behind both the Perseus and the Cornell Xerox projects * -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -In his role as moderator of the concluding session, GIFFORD raised two -questions he believed would benefit from discussion: 1) Are there enough -commonalities among those of us that have been here for two days so that -we can see courses of action that should be taken in the future? And, if -so, what are they and who might take them? 2) Partly derivative from -that, but obviously very dangerous to LC as host, do you see a role for -the Library of Congress in all this? Of course, the Library of Congress -holds a rather special status in a number of these matters, because it is -not perceived as a player with an economic stake in them, but are there -roles that LC can play that can help advance us toward where we are heading? - -Describing himself as an uninformed observer of the technicalities of the -last two days, GIFFORD detected three different emphases in the Workshop: -1) people who are very deeply committed to text; 2) people who are almost -passionate about images; and 3) a few people who are very committed to -what happens to the networks. In other words, the new networking -dimension, the accessibility of the processability, the portability of -all this across the networks. How do we pull those three together? - -Adding a question that reflected HOCKEY's comment that this was the -fourth workshop she had attended in the previous thirty days, FLEISCHHAUER -wondered to what extent this meeting had reinvented the wheel, or if it -had contributed anything in the way of bringing together a different group -of people from those who normally appear on the workshop circuit. - -HOCKEY confessed to being struck at this meeting and the one the -Electronic Pierce Consortium organized the previous week that this was a -coming together of people working on texts and not images. Attempting to -bring the two together is something we ought to be thinking about for the -future: How one can think about working with image material to begin -with, but structuring it and digitizing it in such a way that at a later -stage it can be interpreted into text, and find a common way of building -text and images together so that they can be used jointly in the future, -with the network support to begin there because that is how people will -want to access it. - -In planning the long-term development of something, which is what is -being done in electronic text, HOCKEY stressed the importance not only -of discussing the technical aspects of how one does it but particularly -of thinking about what the people who use the stuff will want to do. -But conversely, there are numerous things that people start to do with -electronic text or material that nobody ever thought of in the beginning. - -LESK, in response to the question concerning the role of the Library of -Congress, remarked the often suggested desideratum of having electronic -deposit: Since everything is now computer-typeset, an entire decade of -material that was machine-readable exists, but the publishers frequently -did not save it; has LC taken any action to have its copyright deposit -operation start collecting these machine-readable versions? In the -absence of PETERS, GIFFORD replied that the question was being -actively considered but that that was only one dimension of the problem. -Another dimension is the whole question of the integrity of the original -electronic document. It becomes highly important in science to prove -authorship. How will that be done? - -ERWAY explained that, under the old policy, to make a claim for a -copyright for works that were published in electronic form, including -software, one had to submit a paper copy of the first and last twenty -pages of code--something that represented the work but did not include -the entire work itself and had little value to anyone. As a temporary -measure, LC has claimed the right to demand electronic versions of -electronic publications. This measure entails a proactive role for the -Library to say that it wants a particular electronic version. Publishers -then have perhaps a year to submit it. But the real problem for LC is -what to do with all this material in all these different formats. Will -the Library mount it? How will it give people access to it? How does LC -keep track of the appropriate computers, software, and media? The situation -is so hard to control, ERWAY said, that it makes sense for each publishing -house to maintain its own archive. But LC cannot enforce that either. - -GIFFORD acknowledged LESK's suggestion that establishing a priority -offered the solution, albeit a fairly complicated one. But who maintains -that register?, he asked. GRABER noted that LC does attempt to collect a -Macintosh version and the IBM-compatible version of software. It does -not collect other versions. But while true for software, BYRUM observed, -this reply does not speak to materials, that is, all the materials that -were published that were on somebody's microcomputer or driver tapes -at a publishing office across the country. LC does well to acquire -specific machine-readable products selectively that were intended to be -machine-readable. Materials that were in machine-readable form at one time, -BYRUM said, would be beyond LC's capability at the moment, insofar as -attempting to acquire, organize, and preserve them are concerned--and -preservation would be the most important consideration. In this -connection, GIFFORD reiterated the need to work out some sense of -distributive responsibility for a number of these issues, which -inevitably will require significant cooperation and discussion. -Nobody can do it all. - -LESK suggested that some publishers may look with favor on LC beginning -to serve as a depository of tapes in an electronic manuscript standard. -Publishers may view this as a service that they did not have to perform -and they might send in tapes. However, SPERBERG-McQUEEN countered, -although publishers have had equivalent services available to them for a -long time, the electronic text archive has never turned away or been -flooded with tapes and is forever sending feedback to the depositor. -Some publishers do send in tapes. - -ANDRE viewed this discussion as an allusion to the issue of standards. -She recommended that the AAP standard and the TEI, which has already been -somewhat harmonized internationally and which also shares several -compatibilities with the AAP, be harmonized to ensure sufficient -compatibility in the software. She drew the line at saying LC ought to -be the locus or forum for such harmonization. - -Taking the group in a slightly different direction, but one where at -least in the near term LC might play a helpful role, LYNCH remarked the -plans of a number of projects to carry out preservation by creating -digital images that will end up in on-line or near-line storage at some -institution. Presumably, LC will link this material somehow to its -on-line catalog in most cases. Thus, it is in a digital form. LYNCH had -the impression that many of these institutions would be willing to make -those files accessible to other people outside the institution, provided -that there is no copyright problem. This desideratum will require -propagating the knowledge that those digitized files exist, so that they -can end up in other on-line catalogs. Although uncertain about the -mechanism for achieving this result, LYNCH said that it warranted -scrutiny because it seemed to be connected to some of the basic issues of -cataloging and distribution of records. It would be foolish, given the -amount of work that all of us have to do and our meager resources, to -discover multiple institutions digitizing the same work. Re microforms, -LYNCH said, we are in pretty good shape. - -BATTIN called this a big problem and noted that the Cornell people (who -had already departed) were working on it. At issue from the beginning -was to learn how to catalog that information into RLIN and then into -OCLC, so that it would be accessible. That issue remains to be resolved. -LYNCH rejoined that putting it into OCLC or RLIN was helpful insofar as -somebody who is thinking of performing preservation activity on that work -could learn about it. It is not necessarily helpful for institutions to -make that available. BATTIN opined that the idea was that it not only be -for preservation purposes but for the convenience of people looking for -this material. She endorsed LYNCH's dictum that duplication of this -effort was to be avoided by every means. - -HOCKEY informed the Workshop about one major current activity of CETH, -namely a catalogue of machine-readable texts in the humanities. Held on -RLIN at present, the catalogue has been concentrated on ASCII as opposed -to digitized images of text. She is exploring ways to improve the -catalogue and make it more widely available, and welcomed suggestions -about these concerns. CETH owns the records, which are not just -restricted to RLIN, and can distribute them however it wishes. - -Taking up LESK's earlier question, BATTIN inquired whether LC, since it -is accepting electronic files and designing a mechanism for dealing with -that rather than putting books on shelves, would become responsible for -the National Copyright Depository of Electronic Materials. Of course -that could not be accomplished overnight, but it would be something LC -could plan for. GIFFORD acknowledged that much thought was being devoted -to that set of problems and returned the discussion to the issue raised -by LYNCH--whether or not putting the kind of records that both BATTIN and -HOCKEY have been talking about in RLIN is not a satisfactory solution. -It seemed to him that RLIN answered LYNCH's original point concerning -some kind of directory for these kinds of materials. In a situation -where somebody is attempting to decide whether or not to scan this or -film that or to learn whether or not someone has already done so, LYNCH -suggested, RLIN is helpful, but it is not helpful in the case of a local, -on-line catalogue. Further, one would like to have her or his system be -aware that that exists in digital form, so that one can present it to a -patron, even though one did not digitize it, if it is out of copyright. -The only way to make those linkages would be to perform a tremendous -amount of real-time look-up, which would be awkward at best, or -periodically to yank the whole file from RLIN and match it against one's -own stuff, which is a nuisance. - -But where, ERWAY inquired, does one stop including things that are -available with Internet, for instance, in one's local catalogue? -It almost seems that that is LC's means to acquire access to them. -That represents LC's new form of library loan. Perhaps LC's new on-line -catalogue is an amalgamation of all these catalogues on line. LYNCH -conceded that perhaps that was true in the very long term, but was not -applicable to scanning in the short term. In his view, the totals cited -by Yale, 10,000 books over perhaps a four-year period, and 1,000-1,500 -books from Cornell, were not big numbers, while searching all over -creation for relatively rare occurrences will prove to be less efficient. -As GIFFORD wondered if this would not be a separable file on RLIN and -could be requested from them, BATTIN interjected that it was easily -accessible to an institution. SEVERTSON pointed out that that file, cum -enhancements, was available with reference information on CD-ROM, which -makes it a little more available. - -In HOCKEY's view, the real question facing the Workshop is what to put in -this catalogue, because that raises the question of what constitutes a -publication in the electronic world. (WEIBEL interjected that Eric Joule -in OCLC's Office of Research is also wrestling with this particular -problem, while GIFFORD thought it sounded fairly generic.) HOCKEY -contended that a majority of texts in the humanities are in the hands -of either a small number of large research institutions or individuals -and are not generally available for anyone else to access at all. -She wondered if these texts ought to be catalogued. - -After argument proceeded back and forth for several minutes over why -cataloguing might be a necessary service, LEBRON suggested that this -issue involved the responsibility of a publisher. The fact that someone -has created something electronically and keeps it under his or her -control does not constitute publication. Publication implies -dissemination. While it would be important for a scholar to let other -people know that this creation exists, in many respects this is no -different from an unpublished manuscript. That is what is being accessed -in there, except that now one is not looking at it in the hard-copy but -in the electronic environment. - -LEBRON expressed puzzlement at the variety of ways electronic publishing -has been viewed. Much of what has been discussed throughout these two -days has concerned CD-ROM publishing, whereas in the on-line environment -that she confronts, the constraints and challenges are very different. -Sooner or later LC will have to deal with the concept of on-line -publishing. Taking up the comment ERWAY made earlier about storing -copies, LEBRON gave her own journal as an example. How would she deposit -OJCCT for copyright?, she asked, because the journal will exist in the -mainframe at OCLC and people will be able to access it. Here the -situation is different, ownership versus access, and is something that -arises with publication in the on-line environment, faster than is -sometimes realized. Lacking clear answers to all of these questions -herself, LEBRON did not anticipate that LC would be able to take a role -in helping to define some of them for quite a while. - -GREENFIELD observed that LC's Network Development Office is attempting, -among other things, to explore the limits of MARC as a standard in terms -of handling electronic information. GREENFIELD also noted that Rebecca -GUENTHER from that office gave a paper to the American Society for -Information Science (ASIS) summarizing several of the discussion papers -that were coming out of the Network Development Office. GREENFIELD said -he understood that that office had a list-server soliciting just the kind -of feedback received today concerning the difficulties of identifying and -cataloguing electronic information. GREENFIELD hoped that everybody -would be aware of that and somehow contribute to that conversation. - -Noting two of LC's roles, first, to act as a repository of record for -material that is copyrighted in this country, and second, to make -materials it holds available in some limited form to a clientele that -goes beyond Congress, BESSER suggested that it was incumbent on LC to -extend those responsibilities to all the things being published in -electronic form. This would mean eventually accepting electronic -formats. LC could require that at some point they be in a certain -limited set of formats, and then develop mechanisms for allowing people -to access those in the same way that other things are accessed. This -does not imply that they are on the network and available to everyone. -LC does that with most of its bibliographic records, BESSER said, which -end up migrating to the utility (e.g., OCLC) or somewhere else. But just -as most of LC's books are available in some form through interlibrary -loan or some other mechanism, so in the same way electronic formats ought -to be available to others in some format, though with some copyright -considerations. BESSER was not suggesting that these mechanisms be -established tomorrow, only that they seemed to fall within LC's purview, -and that there should be long-range plans to establish them. - -Acknowledging that those from LC in the room agreed with BESSER -concerning the need to confront difficult questions, GIFFORD underscored -the magnitude of the problem of what to keep and what to select. GIFFORD -noted that LC currently receives some 31,000 items per day, not counting -electronic materials, and argued for much more distributed responsibility -in order to maintain and store electronic information. - -BESSER responded that the assembled group could be viewed as a starting -point, whose initial operating premise could be helping to move in this -direction and defining how LC could do so, for example, in areas of -standardization or distribution of responsibility. - -FLEISCHHAUER added that AM was fully engaged, wrestling with some of the -questions that pertain to the conversion of older historical materials, -which would be one thing that the Library of Congress might do. Several -points mentioned by BESSER and several others on this question have a -much greater impact on those who are concerned with cataloguing and the -networking of bibliographic information, as well as preservation itself. - -Speaking directly to AM, which he considered was a largely uncopyrighted -database, LYNCH urged development of a network version of AM, or -consideration of making the data in it available to people interested in -doing network multimedia. On account of the current great shortage of -digital data that is both appealing and unencumbered by complex rights -problems, this course of action could have a significant effect on making -network multimedia a reality. - -In this connection, FLEISCHHAUER reported on a fragmentary prototype in -LC's Office of Information Technology Services that attempts to associate -digital images of photographs with cataloguing information in ways that -work within a local area network--a step, so to say, toward AM's -construction of some sort of apparatus for access. Further, AM has -attempted to use standard data forms in order to help make that -distinction between the access tools and the underlying data, and thus -believes that the database is networkable. - -A delicate and agonizing policy question for LC, however, which comes -back to resources and unfortunately has an impact on this, is to find -some appropriate, honorable, and legal cost-recovery possibilities. A -certain skittishness concerning cost-recovery has made people unsure -exactly what to do. AM would be highly receptive to discussing further -LYNCH's offer to test or demonstrate its database in a network -environment, FLEISCHHAUER said. - -Returning the discussion to what she viewed as the vital issue of -electronic deposit, BATTIN recommended that LC initiate a catalytic -process in terms of distributed responsibility, that is, bring together -the distributed organizations and set up a study group to look at all -these issues and see where we as a nation should move. The broader -issues of how we deal with the management of electronic information will -not disappear, but only grow worse. - -LESK took up this theme and suggested that LC attempt to persuade one -major library in each state to deal with its state equivalent publisher, -which might produce a cooperative project that would be equitably -distributed around the country, and one in which LC would be dealing with -a minimal number of publishers and minimal copyright problems. - -GRABER remarked the recent development in the scientific community of a -willingness to use SGML and either deposit or interchange on a fairly -standardized format. He wondered if a similar movement was taking place -in the humanities. Although the National Library of Medicine found only -a few publishers to cooperate in a like venture two or three years ago, a -new effort might generate a much larger number willing to cooperate. - -KIMBALL recounted his unit's (Machine-Readable Collections Reading Room) -troubles with the commercial publishers of electronic media in acquiring -materials for LC's collections, in particular the publishers' fear that -they would not be able to cover their costs and would lose control of -their products, that LC would give them away or sell them and make -profits from them. He doubted that the publishing industry was prepared -to move into this area at the moment, given its resistance to allowing LC -to use its machine-readable materials as the Library would like. - -The copyright law now addresses compact disk as a medium, and LC can -request one copy of that, or two copies if it is the only version, and -can request copies of software, but that fails to address magazines or -books or anything like that which is in machine-readable form. - -GIFFORD acknowledged the thorny nature of this issue, which he illustrated -with the example of the cumbersome process involved in putting a copy of a -scientific database on a LAN in LC's science reading room. He also -acknowledged that LC needs help and could enlist the energies and talents -of Workshop participants in thinking through a number of these problems. - -GIFFORD returned the discussion to getting the image and text people to -think through together where they want to go in the long term. MYLONAS -conceded that her experience at the Pierce Symposium the previous week at -Georgetown University and this week at LC had forced her to reevaluate -her perspective on the usefulness of text as images. MYLONAS framed the -issues in a series of questions: How do we acquire machine-readable -text? Do we take pictures of it and perform OCR on it later? Is it -important to obtain very high-quality images and text, etc.? -FLEISCHHAUER agreed with MYLONAS's framing of strategic questions, adding -that a large institution such as LC probably has to do all of those -things at different times. Thus, the trick is to exercise judgment. The -Workshop had added to his and AM's considerations in making those -judgments. Concerning future meetings or discussions, MYLONAS suggested -that screening priorities would be helpful. - -WEIBEL opined that the diversity reflected in this group was a sign both -of the health and of the immaturity of the field, and more time would -have to pass before we convince one another concerning standards. - -An exchange between MYLONAS and BATTIN clarified the point that the -driving force behind both the Perseus and the Cornell Xerox projects was -the preservation of knowledge for the future, not simply for particular -research use. In the case of Perseus, MYLONAS said, the assumption was -that the texts would not be entered again into electronically readable -form. SPERBERG-McQUEEN added that a scanned image would not serve as an -archival copy for purposes of preservation in the case of, say, the Bill -of Rights, in the sense that the scanned images are effectively the -archival copies for the Cornell mathematics books. - - - *** *** *** ****** *** *** *** - - - Appendix I: PROGRAM - - - - WORKSHOP - ON - ELECTRONIC - TEXTS - - - - 9-10 June 1992 - - Library of Congress - Washington, D.C. - - - - Supported by a Grant from the David and Lucile Packard Foundation - - -Tuesday, 9 June 1992 - -NATIONAL DEMONSTRATION LAB, ATRIUM, LIBRARY MADISON - -8:30 AM Coffee and Danish, registration - -9:00 AM Welcome - - Prosser Gifford, Director for Scholarly Programs, and Carl - Fleischhauer, Coordinator, American Memory, Library of - Congress - -9:l5 AM Session I. Content in a New Form: Who Will Use It and What - Will They Do? - - Broad description of the range of electronic information. - Characterization of who uses it and how it is or may be used. - In addition to a look at scholarly uses, this session will - include a presentation on use by students (K-12 and college) - and the general public. - - Moderator: James Daly - Avra Michelson, Archival Research and Evaluation Staff, - National Archives and Records Administration (Overview) - Susan H. Veccia, Team Leader, American Memory, User Evaluation, - and - Joanne Freeman, Associate Coordinator, American Memory, Library - of Congress (Beyond the scholar) - -10:30- -11:00 AM Break - -11:00 AM Session II. Show and Tell. - - Each presentation to consist of a fifteen-minute - statement/show; group discussion will follow lunch. - - Moderator: Jacqueline Hess, Director, National Demonstration - Lab - - 1. A classics project, stressing texts and text retrieval - more than multimedia: Perseus Project, Harvard - University - Elli Mylonas, Managing Editor - - 2. Other humanities projects employing the emerging norms of - the Text Encoding Initiative (TEI): Chadwyck-Healey's - The English Poetry Full Text Database and/or Patrologia - Latina Database - Eric M. Calaluca, Vice President, Chadwyck-Healey, Inc. - - 3. American Memory - Carl Fleischhauer, Coordinator, and - Ricky Erway, Associate Coordinator, Library of Congress - - 4. Founding Fathers example from Packard Humanities - Institute: The Papers of George Washington, University - of Virginia - Dorothy Twohig, Managing Editor, and/or - David Woodley Packard - - 5. An electronic medical journal offering graphics and - full-text searchability: The Online Journal of Current - Clinical Trials, American Association for the Advancement - of Science - Maria L. Lebron, Managing Editor - - 6. A project that offers facsimile images of pages but omits - searchable text: Cornell math books - Lynne K. Personius, Assistant Director, Cornell - Information Technologies for Scholarly Information - Sources, Cornell University - -12:30 PM Lunch (Dining Room A, Library Madison 620. Exhibits - available.) - -1:30 PM Session II. Show and Tell (Cont'd.). - -3:00- -3:30 PM Break - -3:30- -5:30 PM Session III. Distribution, Networks, and Networking: Options - for Dissemination. - - Published disks: University presses and public-sector - publishers, private-sector publishers - Computer networks - - Moderator: Robert G. Zich, Special Assistant to the Associate - Librarian for Special Projects, Library of Congress - Clifford A. Lynch, Director, Library Automation, University of - California - Howard Besser, School of Library and Information Science, - University of Pittsburgh - Ronald L. Larsen, Associate Director of Libraries for - Information Technology, University of Maryland at College - Park - Edwin B. Brownrigg, Executive Director, Memex Research - Institute - -6:30 PM Reception (Montpelier Room, Library Madison 619.) - - ****** - -Wednesday, 10 June 1992 - -DINING ROOM A, LIBRARY MADISON 620 - -8:30 AM Coffee and Danish - -9:00 AM Session IV. Image Capture, Text Capture, Overview of Text and - Image Storage Formats. - - Moderator: William L. Hooton, Vice President of Operations, - I-NET - - A) Principal Methods for Image Capture of Text: - Direct scanning - Use of microform - - Anne R. Kenney, Assistant Director, Department of Preservation - and Conservation, Cornell University - Pamela Q.J. Andre, Associate Director, Automation, and - Judith A. Zidar, Coordinator, National Agricultural Text - Digitizing Program (NATDP), National Agricultural Library - (NAL) - Donald J. Waters, Head, Systems Office, Yale University Library - - B) Special Problems: - Bound volumes - Conservation - Reproducing printed halftones - - Carl Fleischhauer, Coordinator, American Memory, Library of - Congress - George Thoma, Chief, Communications Engineering Branch, - National Library of Medicine (NLM) - -10:30- -11:00 AM Break - -11:00 AM Session IV. Image Capture, Text Capture, Overview of Text and - Image Storage Formats (Cont'd.). - - C) Image Standards and Implications for Preservation - - Jean Baronas, Senior Manager, Department of Standards and - Technology, Association for Information and Image Management - (AIIM) - Patricia Battin, President, The Commission on Preservation and - Access (CPA) - - D) Text Conversion: - OCR vs. rekeying - Standards of accuracy and use of imperfect texts - Service bureaus - - Stuart Weibel, Senior Research Specialist, Online Computer - Library Center, Inc. (OCLC) - Michael Lesk, Executive Director, Computer Science Research, - Bellcore - Ricky Erway, Associate Coordinator, American Memory, Library of - Congress - Pamela Q.J. Andre, Associate Director, Automation, and - Judith A. Zidar, Coordinator, National Agricultural Text - Digitizing Program (NATDP), National Agricultural Library - (NAL) - -12:30- -1:30 PM Lunch - -1:30 PM Session V. Approaches to Preparing Electronic Texts. - - Discussion of approaches to structuring text for the computer; - pros and cons of text coding, description of methods in - practice, and comparison of text-coding methods. - - Moderator: Susan Hockey, Director, Center for Electronic Texts - in the Humanities (CETH), Rutgers and Princeton Universities - David Woodley Packard - C.M. Sperberg-McQueen, Editor, Text Encoding Initiative (TEI), - University of Illinois-Chicago - Eric M. Calaluca, Vice President, Chadwyck-Healey, Inc. - -3:30- -4:00 PM Break - -4:00 PM Session VI. Copyright Issues. - - Marybeth Peters, Policy Planning Adviser to the Register of - Copyrights, Library of Congress - -5:00 PM Session VII. Conclusion. - - General discussion. - What topics were omitted or given short shrift that anyone - would like to talk about now? - Is there a "group" here? What should the group do next, if - anything? What should the Library of Congress do next, if - anything? - Moderator: Prosser Gifford, Director for Scholarly Programs, - Library of Congress - -6:00 PM Adjourn - - - *** *** *** ****** *** *** *** - - - Appendix II: ABSTRACTS - - -SESSION I - -Avra MICHELSON Forecasting the Use of Electronic Texts by - Social Sciences and Humanities Scholars - -This presentation explores the ways in which electronic texts are likely -to be used by the non-scientific scholarly community. Many of the -remarks are drawn from a report the speaker coauthored with Jeff -Rothenberg, a computer scientist at The RAND Corporation. - -The speaker assesses 1) current scholarly use of information technology -and 2) the key trends in information technology most relevant to the -research process, in order to predict how social sciences and humanities -scholars are apt to use electronic texts. In introducing the topic, -current use of electronic texts is explored broadly within the context of -scholarly communication. From the perspective of scholarly -communication, the work of humanities and social sciences scholars -involves five processes: 1) identification of sources, 2) communication -with colleagues, 3) interpretation and analysis of data, 4) dissemination -of research findings, and 5) curriculum development and instruction. The -extent to which computation currently permeates aspects of scholarly -communication represents a viable indicator of the prospects for -electronic texts. - -The discussion of current practice is balanced by an analysis of key -trends in the scholarly use of information technology. These include the -trends toward end-user computing and connectivity, which provide a -framework for forecasting the use of electronic texts through this -millennium. The presentation concludes with a summary of the ways in -which the nonscientific scholarly community can be expected to use -electronic texts, and the implications of that use for information -providers. - -Susan VECCIA and Joanne FREEMAN Electronic Archives for the Public: - Use of American Memory in Public and - School Libraries - -This joint discussion focuses on nonscholarly applications of electronic -library materials, specifically addressing use of the Library of Congress -American Memory (AM) program in a small number of public and school -libraries throughout the United States. AM consists of selected Library -of Congress primary archival materials, stored on optical media -(CD-ROM/videodisc), and presented with little or no editing. Many -collections are accompanied by electronic introductions and user's guides -offering background information and historical context. Collections -represent a variety of formats including photographs, graphic arts, -motion pictures, recorded sound, music, broadsides and manuscripts, -books, and pamphlets. - -In 1991, the Library of Congress began a nationwide evaluation of AM in -different types of institutions. Test sites include public libraries, -elementary and secondary school libraries, college and university -libraries, state libraries, and special libraries. Susan VECCIA and -Joanne FREEMAN will discuss their observations on the use of AM by the -nonscholarly community, using evidence gleaned from this ongoing -evaluation effort. - -VECCIA will comment on the overall goals of the evaluation project, and -the types of public and school libraries included in this study. Her -comments on nonscholarly use of AM will focus on the public library as a -cultural and community institution, often bridging the gap between formal -and informal education. FREEMAN will discuss the use of AM in school -libraries. Use by students and teachers has revealed some broad -questions about the use of electronic resources, as well as definite -benefits gained by the "nonscholar." Topics will include the problem of -grasping content and context in an electronic environment, the stumbling -blocks created by "new" technologies, and the unique skills and interests -awakened through use of electronic resources. - -SESSION II - -Elli MYLONAS The Perseus Project: Interactive Sources and - Studies in Classical Greece - -The Perseus Project (5) has just released Perseus 1.0, the first publicly -available version of its hypertextual database of multimedia materials on -classical Greece. Perseus is designed to be used by a wide audience, -comprised of readers at the student and scholar levels. As such, it must -be able to locate information using different strategies, and it must -contain enough detail to serve the different needs of its users. In -addition, it must be delivered so that it is affordable to its target -audience. [These problems and the solutions we chose are described in -Mylonas, "An Interface to Classical Greek Civilization," JASIS 43:2, -March 1992.] - -In order to achieve its objective, the project staff decided to make a -conscious separation between selecting and converting textual, database, -and image data on the one hand, and putting it into a delivery system on -the other. That way, it is possible to create the electronic data -without thinking about the restrictions of the delivery system. We have -made a great effort to choose system-independent formats for our data, -and to put as much thought and work as possible into structuring it so -that the translation from paper to electronic form will enhance the value -of the data. [A discussion of these solutions as of two years ago is in -Elli Mylonas, Gregory Crane, Kenneth Morrell, and D. Neel Smith, "The -Perseus Project: Data in the Electronic Age," in Accessing Antiquity: -The Computerization of Classical Databases, J. Solomon and T. Worthen -(eds.), University of Arizona Press, in press.] - -Much of the work on Perseus is focused on collecting and converting the -data on which the project is based. At the same time, it is necessary to -provide means of access to the information, in order to make it usable, -and them to investigate how it is used. As we learn more about what -students and scholars from different backgrounds do with Perseus, we can -adjust our data collection, and also modify the system to accommodate -them. In creating a delivery system for general use, we have tried to -avoid favoring any one type of use by allowing multiple forms of access -to and navigation through the system. - -The way text is handled exemplifies some of these principles. All text -in Perseus is tagged using SGML, following the guidelines of the Text -Encoding Initiative (TEI). This markup is used to index the text, and -process it so that it can be imported into HyperCard. No SGML markup -remains in the text that reaches the user, because currently it would be -too expensive to create a system that acts on SGML in real time. -However, the regularity provided by SGML is essential for verifying the -content of the texts, and greatly speeds all the processing performed on -them. The fact that the texts exist in SGML ensures that they will be -relatively easy to port to different hardware and software, and so will -outlast the current delivery platform. Finally, the SGML markup -incorporates existing canonical reference systems (chapter, verse, line, -etc.); indexing and navigation are based on these features. This ensures -that the same canonical reference will always resolve to the same point -within a text, and that all versions of our texts, regardless of delivery -platform (even paper printouts) will function the same way. - -In order to provide tools for users, the text is processed by a -morphological analyzer, and the results are stored in a database. -Together with the index, the Greek-English Lexicon, and the index of all -the English words in the definitions of the lexicon, the morphological -analyses comprise a set of linguistic tools that allow users of all -levels to work with the textual information, and to accomplish different -tasks. For example, students who read no Greek may explore a concept as -it appears in Greek texts by using the English-Greek index, and then -looking up works in the texts and translations, or scholars may do -detailed morphological studies of word use by using the morphological -analyses of the texts. Because these tools were not designed for any one -use, the same tools and the same data can be used by both students and -scholars. - -NOTES: - (5) Perseus is based at Harvard University, with collaborators at - several other universities. The project has been funded primarily - by the Annenberg/CPB Project, as well as by Harvard University, - Apple Computer, and others. It is published by Yale University - Press. Perseus runs on Macintosh computers, under the HyperCard - program. - -Eric CALALUCA - -Chadwyck-Healey embarked last year on two distinct yet related full-text -humanities database projects. - -The English Poetry Full-Text Database and the Patrologia Latina Database -represent new approaches to linguistic research resources. The size and -complexity of the projects present problems for electronic publishers, -but surmountable ones if they remain abreast of the latest possibilities -in data capture and retrieval software techniques. - -The issues which required address prior to the commencement of the -projects were legion: - - 1. Editorial selection (or exclusion) of materials in each - database - - 2. Deciding whether or not to incorporate a normative encoding - structure into the databases? - A. If one is selected, should it be SGML? - B. If SGML, then the TEI? - - 3. Deliver as CD-ROM, magnetic tape, or both? - - 4. Can one produce retrieval software advanced enough for the - postdoctoral linguist, yet accessible enough for unattended - general use? Should one try? - - 5. Re fair and liberal networking policies, what are the risks to - an electronic publisher? - - 6. How does the emergence of national and international education - networks affect the use and viability of research projects - requiring high investment? Do the new European Community - directives concerning database protection necessitate two - distinct publishing projects, one for North America and one for - overseas? - -From new notions of "scholarly fair use" to the future of optical media, -virtually every issue related to electronic publishing was aired. The -result is two projects which have been constructed to provide the quality -research resources with the fewest encumbrances to use by teachers and -private scholars. - -Dorothy TWOHIG - -In spring 1988 the editors of the papers of George Washington, John -Adams, Thomas Jefferson, James Madison, and Benjamin Franklin were -approached by classics scholar David Packard on behalf of the Packard -Humanities Foundation with a proposal to produce a CD-ROM edition of the -complete papers of each of the Founding Fathers. This electronic edition -will supplement the published volumes, making the documents widely -available to students and researchers at reasonable cost. We estimate -that our CD-ROM edition of Washington's Papers will be substantially -completed within the next two years and ready for publication. Within -the next ten years or so, similar CD-ROM editions of the Franklin, Adams, -Jefferson, and Madison papers also will be available. At the Library of -Congress's session on technology, I would like to discuss not only the -experience of the Washington Papers in producing the CD-ROM edition, but -the impact technology has had on these major editorial projects. -Already, we are editing our volumes with an eye to the material that will -be readily available in the CD-ROM edition. The completed electronic -edition will provide immense possibilities for the searching of documents -for information in a way never possible before. The kind of technical -innovations that are currently available and on the drawing board will -soon revolutionize historical research and the production of historical -documents. Unfortunately, much of this new technology is not being used -in the planning stages of historical projects, simply because many -historians are aware only in the vaguest way of its existence. At least -two major new historical editing projects are considering microfilm -editions, simply because they are not aware of the possibilities of -electronic alternatives and the advantages of the new technology in terms -of flexibility and research potential compared to microfilm. In fact, -too many of us in history and literature are still at the stage of -struggling with our PCs. There are many historical editorial projects in -progress presently, and an equal number of literary projects. While the -two fields have somewhat different approaches to textual editing, there -are ways in which electronic technology can be of service to both. - -Since few of the editors involved in the Founding Fathers CD-ROM editions -are technical experts in any sense, I hope to point out in my discussion -of our experience how many of these electronic innovations can be used -successfully by scholars who are novices in the world of new technology. -One of the major concerns of the sponsors of the multitude of new -scholarly editions is the limited audience reached by the published -volumes. Most of these editions are being published in small quantities -and the publishers' price for them puts them out of the reach not only of -individual scholars but of most public libraries and all but the largest -educational institutions. However, little attention is being given to -ways in which technology can bypass conventional publication to make -historical and literary documents more widely available. - -What attracted us most to the CD-ROM edition of The Papers of George -Washington was the fact that David Packard's aim was to make a complete -edition of all of the 135,000 documents we have collected available in an -inexpensive format that would be placed in public libraries, small -colleges, and even high schools. This would provide an audience far -beyond our present 1,000-copy, $45 published edition. Since the CD-ROM -edition will carry none of the explanatory annotation that appears in the -published volumes, we also feel that the use of the CD-ROM will lead many -researchers to seek out the published volumes. - -In addition to ignorance of new technical advances, I have found that too -many editors--and historians and literary scholars--are resistant and -even hostile to suggestions that electronic technology may enhance their -work. I intend to discuss some of the arguments traditionalists are -advancing to resist technology, ranging from distrust of the speed with -which it changes (we are already wondering what is out there that is -better than CD-ROM) to suspicion of the technical language used to -describe electronic developments. - -Maria LEBRON - -The Online Journal of Current Clinical Trials, a joint venture of the -American Association for the Advancement of Science (AAAS) and the Online -Computer Library Center, Inc. (OCLC), is the first peer-reviewed journal -to provide full text, tabular material, and line illustrations on line. -This presentation will discuss the genesis and start-up period of the -journal. Topics of discussion will include historical overview, -day-to-day management of the editorial peer review, and manuscript -tagging and publication. A demonstration of the journal and its features -will accompany the presentation. - -Lynne PERSONIUS - -Cornell University Library, Cornell Information Technologies, and Xerox -Corporation, with the support of the Commission on Preservation and -Access, and Sun Microsystems, Inc., have been collaborating in a project -to test a prototype system for recording brittle books as digital images -and producing, on demand, high-quality archival paper replacements. The -project goes beyond that, however, to investigate some of the issues -surrounding scanning, storing, retrieving, and providing access to -digital images in a network environment. - -The Joint Study in Digital Preservation began in January 1990. Xerox -provided the College Library Access and Storage System (CLASS) software, -a prototype 600-dots-per-inch (dpi) scanner, and the hardware necessary -to support network printing on the DocuTech printer housed in Cornell's -Computing and Communications Center (CCC). - -The Cornell staff using the hardware and software became an integral part -of the development and testing process for enhancements to the CLASS -software system. The collaborative nature of this relationship is -resulting in a system that is specifically tailored to the preservation -application. - -A digital library of 1,000 volumes (or approximately 300,000 images) has -been created and is stored on an optical jukebox that resides in CCC. -The library includes a collection of select mathematics monographs that -provides mathematics faculty with an opportunity to use the electronic -library. The remaining volumes were chosen for the library to test the -various capabilities of the scanning system. - -One project objective is to provide users of the Cornell library and the -library staff with the ability to request facsimiles of digitized images -or to retrieve the actual electronic image for browsing. A prototype -viewing workstation has been created by Xerox, with input into the design -by a committee of Cornell librarians and computer professionals. This -will allow us to experiment with patron access to the images that make up -the digital library. The viewing station provides search, retrieval, and -(ultimately) printing functions with enhancements to facilitate -navigation through multiple documents. - -Cornell currently is working to extend access to the digital library to -readers using workstations from their offices. This year is devoted to -the development of a network resident image conversion and delivery -server, and client software that will support readers who use Apple -Macintosh computers, IBM windows platforms, and Sun workstations. -Equipment for this development was provided by Sun Microsystems with -support from the Commission on Preservation and Access. - -During the show-and-tell session of the Workshop on Electronic Texts, a -prototype view station will be demonstrated. In addition, a display of -original library books that have been digitized will be available for -review with associated printed copies for comparison. The fifteen-minute -overview of the project will include a slide presentation that -constitutes a "tour" of the preservation digitizing process. - -The final network-connected version of the viewing station will provide -library users with another mechanism for accessing the digital library, -and will also provide the capability of viewing images directly. This -will not require special software, although a powerful computer with good -graphics will be needed. - -The Joint Study in Digital Preservation has generated a great deal of -interest in the library community. Unfortunately, or perhaps -fortunately, this project serves to raise a vast number of other issues -surrounding the use of digital technology for the preservation and use of -deteriorating library materials, which subsequent projects will need to -examine. Much work remains. - -SESSION III - -Howard BESSER Networking Multimedia Databases - -What do we have to consider in building and distributing databases of -visual materials in a multi-user environment? This presentation examines -a variety of concerns that need to be addressed before a multimedia -database can be set up in a networked environment. - -In the past it has not been feasible to implement databases of visual -materials in shared-user environments because of technological barriers. -Each of the two basic models for multi-user multimedia databases has -posed its own problem. The analog multimedia storage model (represented -by Project Athena's parallel analog and digital networks) has required an -incredibly complex (and expensive) infrastructure. The economies of -scale that make multi-user setups cheaper per user served do not operate -in an environment that requires a computer workstation, videodisc player, -and two display devices for each user. - -The digital multimedia storage model has required vast amounts of storage -space (as much as one gigabyte per thirty still images). In the past the -cost of such a large amount of storage space made this model a -prohibitive choice as well. But plunging storage costs are finally -making this second alternative viable. - -If storage no longer poses such an impediment, what do we need to -consider in building digitally stored multi-user databases of visual -materials? This presentation will examine the networking and -telecommunication constraints that must be overcome before such databases -can become commonplace and useful to a large number of people. - -The key problem is the vast size of multimedia documents, and how this -affects not only storage but telecommunications transmission time. -Anything slower than T-1 speed is impractical for files of 1 megabyte or -larger (which is likely to be small for a multimedia document). For -instance, even on a 56 Kb line it would take three minutes to transfer a -1-megabyte file. And these figures assume ideal circumstances, and do -not take into consideration other users contending for network bandwidth, -disk access time, or the time needed for remote display. Current common -telephone transmission rates would be completely impractical; few users -would be willing to wait the hour necessary to transmit a single image at -2400 baud. - -This necessitates compression, which itself raises a number of other -issues. In order to decrease file sizes significantly, we must employ -lossy compression algorithms. But how much quality can we afford to -lose? To date there has been only one significant study done of -image-quality needs for a particular user group, and this study did not -look at loss resulting from compression. Only after identifying -image-quality needs can we begin to address storage and network bandwidth -needs. - -Experience with X-Windows-based applications (such as Imagequery, the -University of California at Berkeley image database) demonstrates the -utility of a client-server topology, but also points to the limitation of -current software for a distributed environment. For example, -applications like Imagequery can incorporate compression, but current X -implementations do not permit decompression at the end user's -workstation. Such decompression at the host computer alleviates storage -capacity problems while doing nothing to address problems of -telecommunications bandwidth. - -We need to examine the effects on network through-put of moving -multimedia documents around on a network. We need to examine various -topologies that will help us avoid bottlenecks around servers and -gateways. Experience with applications such as these raise still broader -questions. How closely is the multimedia document tied to the software -for viewing it? Can it be accessed and viewed from other applications? -Experience with the MARC format (and more recently with the Z39.50 -protocols) shows how useful it can be to store documents in a form in -which they can be accessed by a variety of application software. - -Finally, from an intellectual-access standpoint, we need to address the -issue of providing access to these multimedia documents in -interdisciplinary environments. We need to examine terminology and -indexing strategies that will allow us to provide access to this material -in a cross-disciplinary way. - -Ronald LARSEN Directions in High-Performance Networking for - Libraries - -The pace at which computing technology has advanced over the past forty -years shows no sign of abating. Roughly speaking, each five-year period -has yielded an order-of-magnitude improvement in price and performance of -computing equipment. No fundamental hurdles are likely to prevent this -pace from continuing for at least the next decade. It is only in the -past five years, though, that computing has become ubiquitous in -libraries, affecting all staff and patrons, directly or indirectly. - -During these same five years, communications rates on the Internet, the -principal academic computing network, have grown from 56 kbps to 1.5 -Mbps, and the NSFNet backbone is now running 45 Mbps. Over the next five -years, communication rates on the backbone are expected to exceed 1 Gbps. -Growth in both the population of network users and the volume of network -traffic has continued to grow geometrically, at rates approaching 15 -percent per month. This flood of capacity and use, likened by some to -"drinking from a firehose," creates immense opportunities and challenges -for libraries. Libraries must anticipate the future implications of this -technology, participate in its development, and deploy it to ensure -access to the world's information resources. - -The infrastructure for the information age is being put in place. -Libraries face strategic decisions about their role in the development, -deployment, and use of this infrastructure. The emerging infrastructure -is much more than computers and communication lines. It is more than the -ability to compute at a remote site, send electronic mail to a peer -across the country, or move a file from one library to another. The next -five years will witness substantial development of the information -infrastructure of the network. - -In order to provide appropriate leadership, library professionals must -have a fundamental understanding of and appreciation for computer -networking, from local area networks to the National Research and -Education Network (NREN). This presentation addresses these -fundamentals, and how they relate to libraries today and in the near -future. - -Edwin BROWNRIGG Electronic Library Visions and Realities - -The electronic library has been a vision desired by many--and rejected by -some--since Vannevar Bush coined the term memex to describe an automated, -intelligent, personal information system. Variations on this vision have -included Ted Nelson's Xanadau, Alan Kay's Dynabook, and Lancaster's -"paperless library," with the most recent incarnation being the -"Knowledge Navigator" described by John Scully of Apple. But the reality -of library service has been less visionary and the leap to the electronic -library has eluded universities, publishers, and information technology -files. - -The Memex Research Institute (MemRI), an independent, nonprofit research -and development organization, has created an Electronic Library Program -of shared research and development in order to make the collective vision -more concrete. The program is working toward the creation of large, -indexed publicly available electronic image collections of published -documents in academic, special, and public libraries. This strategic -plan is the result of the first stage of the program, which has been an -investigation of the information technologies available to support such -an effort, the economic parameters of electronic service compared to -traditional library operations, and the business and political factors -affecting the shift from print distribution to electronic networked -access. - -The strategic plan envisions a combination of publicly searchable access -databases, image (and text) document collections stored on network "file -servers," local and remote network access, and an intellectual property -management-control system. This combination of technology and -information content is defined in this plan as an E-library or E-library -collection. Some participating sponsors are already developing projects -based on MemRI's recommended directions. - -The E-library strategy projected in this plan is a visionary one that can -enable major changes and improvements in academic, public, and special -library service. This vision is, though, one that can be realized with -today's technology. At the same time, it will challenge the political -and social structure within which libraries operate: in academic -libraries, the traditional emphasis on local collections, extending to -accreditation issues; in public libraries, the potential of electronic -branch and central libraries fully available to the public; and for -special libraries, new opportunities for shared collections and networks. - -The environment in which this strategic plan has been developed is, at -the moment, dominated by a sense of library limits. The continued -expansion and rapid growth of local academic library collections is now -clearly at an end. Corporate libraries, and even law libraries, are -faced with operating within a difficult economic climate, as well as with -very active competition from commercial information sources. For -example, public libraries may be seen as a desirable but not critical -municipal service in a time when the budgets of safety and health -agencies are being cut back. - -Further, libraries in general have a very high labor-to-cost ratio in -their budgets, and labor costs are still increasing, notwithstanding -automation investments. It is difficult for libraries to obtain capital, -startup, or seed funding for innovative activities, and those -technology-intensive initiatives that offer the potential of decreased -labor costs can provoke the opposition of library staff. - -However, libraries have achieved some considerable successes in the past -two decades by improving both their service and their credibility within -their organizations--and these positive changes have been accomplished -mostly with judicious use of information technologies. The advances in -computing and information technology have been well-chronicled: the -continuing precipitous drop in computing costs, the growth of the -Internet and private networks, and the explosive increase in publicly -available information databases. - -For example, OCLC has become one of the largest computer network -organizations in the world by creating a cooperative cataloging network -of more than 6,000 libraries worldwide. On-line public access catalogs -now serve millions of users on more than 50,000 dedicated terminals in -the United States alone. The University of California MELVYL on-line -catalog system has now expanded into an index database reference service -and supports more than six million searches a year. And, libraries have -become the largest group of customers of CD-ROM publishing technology; -more than 30,000 optical media publications such as those offered by -InfoTrac and Silver Platter are subscribed to by U.S. libraries. - -This march of technology continues and in the next decade will result in -further innovations that are extremely difficult to predict. What is -clear is that libraries can now go beyond automation of their order files -and catalogs to automation of their collections themselves--and it is -possible to circumvent the fiscal limitations that appear to obtain -today. - -This Electronic Library Strategic Plan recommends a paradigm shift in -library service, and demonstrates the steps necessary to provide improved -library services with limited capacities and operating investments. - -SESSION IV-A - -Anne KENNEY - -The Cornell/Xerox Joint Study in Digital Preservation resulted in the -recording of 1,000 brittle books as 600-dpi digital images and the -production, on demand, of high-quality and archivally sound paper -replacements. The project, which was supported by the Commission on -Preservation and Access, also investigated some of the issues surrounding -scanning, storing, retrieving, and providing access to digital images in -a network environment. - -Anne Kenney will focus on some of the issues surrounding direct scanning -as identified in the Cornell Xerox Project. Among those to be discussed -are: image versus text capture; indexing and access; image-capture -capabilities; a comparison to photocopy and microfilm; production and -cost analysis; storage formats, protocols, and standards; and the use of -this scanning technology for preservation purposes. - -The 600-dpi digital images produced in the Cornell Xerox Project proved -highly acceptable for creating paper replacements of deteriorating -originals. The 1,000 scanned volumes provided an array of image-capture -challenges that are common to nineteenth-century printing techniques and -embrittled material, and that defy the use of text-conversion processes. -These challenges include diminished contrast between text and background, -fragile and deteriorated pages, uneven printing, elaborate type faces, -faint and bold text adjacency, handwritten text and annotations, nonRoman -languages, and a proliferation of illustrated material embedded in text. -The latter category included high-frequency and low-frequency halftones, -continuous tone photographs, intricate mathematical drawings, maps, -etchings, reverse-polarity drawings, and engravings. - -The Xerox prototype scanning system provided a number of important -features for capturing this diverse material. Technicians used multiple -threshold settings, filters, line art and halftone definitions, -autosegmentation, windowing, and software-editing programs to optimize -image capture. At the same time, this project focused on production. -The goal was to make scanning as affordable and acceptable as -photocopying and microfilming for preservation reformatting. A -time-and-cost study conducted during the last three months of this -project confirmed the economic viability of digital scanning, and these -findings will be discussed here. - -From the outset, the Cornell Xerox Project was predicated on the use of -nonproprietary standards and the use of common protocols when standards -did not exist. Digital files were created as TIFF images which were -compressed prior to storage using Group 4 CCITT compression. The Xerox -software is MS DOS based and utilizes off-the shelf programs such as -Microsoft Windows and Wang Image Wizard. The digital library is designed -to be hardware-independent and to provide interchangeability with other -institutions through network connections. Access to the digital files -themselves is two-tiered: Bibliographic records for the computer files -are created in RLIN and Cornell's local system and access into the actual -digital images comprising a book is provided through a document control -structure and a networked image file-server, both of which will be -described. - -The presentation will conclude with a discussion of some of the issues -surrounding the use of this technology as a preservation tool (storage, -refreshing, backup). - -Pamela ANDRE and Judith ZIDAR - -The National Agricultural Library (NAL) has had extensive experience with -raster scanning of printed materials. Since 1987, the Library has -participated in the National Agricultural Text Digitizing Project (NATDP) -a cooperative effort between NAL and forty-five land grant university -libraries. An overview of the project will be presented, giving its -history and NAL's strategy for the future. - -An in-depth discussion of NATDP will follow, including a description of -the scanning process, from the gathering of the printed materials to the -archiving of the electronic pages. The type of equipment required for a -stand-alone scanning workstation and the importance of file management -software will be discussed. Issues concerning the images themselves will -be addressed briefly, such as image format; black and white versus color; -gray scale versus dithering; and resolution. - -Also described will be a study currently in progress by NAL to evaluate -the usefulness of converting microfilm to electronic images in order to -improve access. With the cooperation of Tuskegee University, NAL has -selected three reels of microfilm from a collection of sixty-seven reels -containing the papers, letters, and drawings of George Washington Carver. -The three reels were converted into 3,500 electronic images using a -specialized microfilm scanner. The selection, filming, and indexing of -this material will be discussed. - -Donald WATERS - -Project Open Book, the Yale University Library's effort to convert 10, -000 books from microfilm to digital imagery, is currently in an advanced -state of planning and organization. The Yale Library has selected a -major vendor to serve as a partner in the project and as systems -integrator. In its proposal, the successful vendor helped isolate areas -of risk and uncertainty as well as key issues to be addressed during the -life of the project. The Yale Library is now poised to decide what -material it will convert to digital image form and to seek funding, -initially for the first phase and then for the entire project. - -The proposal that Yale accepted for the implementation of Project Open -Book will provide at the end of three phases a conversion subsystem, -browsing stations distributed on the campus network within the Yale -Library, a subsystem for storing 10,000 books at 200 and 600 dots per -inch, and network access to the image printers. Pricing for the system -implementation assumes the existence of Yale's campus ethernet network -and its high-speed image printers, and includes other requisite hardware -and software, as well as system integration services. Proposed operating -costs include hardware and software maintenance, but do not include -estimates for the facilities management of the storage devices and image -servers. - -Yale selected its vendor partner in a formal process, partly funded by -the Commission for Preservation and Access. Following a request for -proposal, the Yale Library selected two vendors as finalists to work with -Yale staff to generate a detailed analysis of requirements for Project -Open Book. Each vendor used the results of the requirements analysis to -generate and submit a formal proposal for the entire project. This -competitive process not only enabled the Yale Library to select its -primary vendor partner but also revealed much about the state of the -imaging industry, about the varying, corporate commitments to the markets -for imaging technology, and about the varying organizational dynamics -through which major companies are responding to and seeking to develop -these markets. - -Project Open Book is focused specifically on the conversion of images -from microfilm to digital form. The technology for scanning microfilm is -readily available but is changing rapidly. In its project requirements, -the Yale Library emphasized features of the technology that affect the -technical quality of digital image production and the costs of creating -and storing the image library: What levels of digital resolution can be -achieved by scanning microfilm? How does variation in the quality of -microfilm, particularly in film produced to preservation standards, -affect the quality of the digital images? What technologies can an -operator effectively and economically apply when scanning film to -separate two-up images and to control for and correct image -imperfections? How can quality control best be integrated into -digitizing work flow that includes document indexing and storage? - -The actual and expected uses of digital images--storage, browsing, -printing, and OCR--help determine the standards for measuring their -quality. Browsing is especially important, but the facilities available -for readers to browse image documents is perhaps the weakest aspect of -imaging technology and most in need of development. As it defined its -requirements, the Yale Library concentrated on some fundamental aspects -of usability for image documents: Does the system have sufficient -flexibility to handle the full range of document types, including -monographs, multi-part and multivolume sets, and serials, as well as -manuscript collections? What conventions are necessary to identify a -document uniquely for storage and retrieval? Where is the database of -record for storing bibliographic information about the image document? -How are basic internal structures of documents, such as pagination, made -accessible to the reader? How are the image documents physically -presented on the screen to the reader? - -The Yale Library designed Project Open Book on the assumption that -microfilm is more than adequate as a medium for preserving the content of -deteriorated library materials. As planning in the project has advanced, -it is increasingly clear that the challenge of digital image technology -and the key to the success of efforts like Project Open Book is to -provide a means of both preserving and improving access to those -deteriorated materials. - -SESSION IV-B - -George THOMA - -In the use of electronic imaging for document preservation, there are -several issues to consider, such as: ensuring adequate image quality, -maintaining substantial conversion rates (through-put), providing unique -identification for automated access and retrieval, and accommodating -bound volumes and fragile material. - -To maintain high image quality, image processing functions are required -to correct the deficiencies in the scanned image. Some commercially -available systems include these functions, while some do not. The -scanned raw image must be processed to correct contrast deficiencies-- -both poor overall contrast resulting from light print and/or dark -background, and variable contrast resulting from stains and -bleed-through. Furthermore, the scan density must be adequate to allow -legibility of print and sufficient fidelity in the pseudo-halftoned gray -material. Borders or page-edge effects must be removed for both -compactibility and aesthetics. Page skew must be corrected for aesthetic -reasons and to enable accurate character recognition if desired. -Compound images consisting of both two-toned text and gray-scale -illustrations must be processed appropriately to retain the quality of -each. - -SESSION IV-C - -Jean BARONAS - -Standards publications being developed by scientists, engineers, and -business managers in Association for Information and Image Management -(AIIM) standards committees can be applied to electronic image management -(EIM) processes including: document (image) transfer, retrieval and -evaluation; optical disk and document scanning; and document design and -conversion. When combined with EIM system planning and operations, -standards can assist in generating image databases that are -interchangeable among a variety of systems. The applications of -different approaches for image-tagging, indexing, compression, and -transfer often cause uncertainty concerning EIM system compatibility, -calibration, performance, and upward compatibility, until standard -implementation parameters are established. The AIIM standards that are -being developed for these applications can be used to decrease the -uncertainty, successfully integrate imaging processes, and promote "open -systems." AIIM is an accredited American National Standards Institute -(ANSI) standards developer with more than twenty committees comprised of -300 volunteers representing users, vendors, and manufacturers. The -standards publications that are developed in these committees have -national acceptance and provide the basis for international harmonization -in the development of new International Organization for Standardization -(ISO) standards. - -This presentation describes the development of AIIM's EIM standards and a -new effort at AIIM, a database on standards projects in a wide framework -of imaging industries including capture, recording, processing, -duplication, distribution, display, evaluation, and preservation. The -AIIM Imagery Database will cover imaging standards being developed by -many organizations in many different countries. It will contain -standards publications' dates, origins, related national and -international projects, status, key words, and abstracts. The ANSI Image -Technology Standards Board requested that such a database be established, -as did the ISO/International Electrotechnical Commission Joint Task Force -on Imagery. AIIM will take on the leadership role for the database and -coordinate its development with several standards developers. - -Patricia BATTIN - - Characteristics of standards for digital imagery: - - * Nature of digital technology implies continuing volatility. - - * Precipitous standard-setting not possible and probably not - desirable. - - * Standards are a complex issue involving the medium, the - hardware, the software, and the technical capacity for - reproductive fidelity and clarity. - - * The prognosis for reliable archival standards (as defined by - librarians) in the foreseeable future is poor. - - Significant potential and attractiveness of digital technology as a - preservation medium and access mechanism. - - Productive use of digital imagery for preservation requires a - reconceptualizing of preservation principles in a volatile, - standardless world. - - Concept of managing continuing access in the digital environment - rather than focusing on the permanence of the medium and long-term - archival standards developed for the analog world. - - Transition period: How long and what to do? - - * Redefine "archival." - - * Remove the burden of "archival copy" from paper artifacts. - - * Use digital technology for storage, develop management - strategies for refreshing medium, hardware and software. - - * Create acid-free paper copies for transition period backup - until we develop reliable procedures for ensuring continuing - access to digital files. - -SESSION IV-D - -Stuart WEIBEL The Role of SGML Markup in the CORE Project (6) - -The emergence of high-speed telecommunications networks as a basic -feature of the scholarly workplace is driving the demand for electronic -document delivery. Three distinct categories of electronic -publishing/republishing are necessary to support access demands in this -emerging environment: - - 1.) Conversion of paper or microfilm archives to electronic format - 2.) Conversion of electronic files to formats tailored to - electronic retrieval and display - 3.) Primary electronic publishing (materials for which the - electronic version is the primary format) - -OCLC has experimental or product development activities in each of these -areas. Among the challenges that lie ahead is the integration of these -three types of information stores in coherent distributed systems. - -The CORE (Chemistry Online Retrieval Experiment) Project is a model for -the conversion of large text and graphics collections for which -electronic typesetting files are available (category 2). The American -Chemical Society has made available computer typography files dating from -1980 for its twenty journals. This collection of some 250 journal-years -is being converted to an electronic format that will be accessible -through several end-user applications. - -The use of Standard Generalized Markup Language (SGML) offers the means -to capture the structural richness of the original articles in a way that -will support a variety of retrieval, navigation, and display options -necessary to navigate effectively in very large text databases. - -An SGML document consists of text that is marked up with descriptive tags -that specify the function of a given element within the document. As a -formal language construct, an SGML document can be parsed against a -document-type definition (DTD) that unambiguously defines what elements -are allowed and where in the document they can (or must) occur. This -formalized map of article structure allows the user interface design to -be uncoupled from the underlying database system, an important step -toward interoperability. Demonstration of this separability is a part of -the CORE project, wherein user interface designs born of very different -philosophies will access the same database. - -NOTES: - (6) The CORE project is a collaboration among Cornell University's - Mann Library, Bell Communications Research (Bellcore), the American - Chemical Society (ACS), the Chemical Abstracts Service (CAS), and - OCLC. - -Michael LESK The CORE Electronic Chemistry Library - -A major on-line file of chemical journal literature complete with -graphics is being developed to test the usability of fully electronic -access to documents, as a joint project of Cornell University, the -American Chemical Society, the Chemical Abstracts Service, OCLC, and -Bellcore (with additional support from Sun Microsystems, Springer-Verlag, -DigitaI Equipment Corporation, Sony Corporation of America, and Apple -Computers). Our file contains the American Chemical Society's on-line -journals, supplemented with the graphics from the paper publication. The -indexing of the articles from Chemical Abstracts Documents is available -in both image and text format, and several different interfaces can be -used. Our goals are (1) to assess the effectiveness and acceptability of -electronic access to primary journals as compared with paper, and (2) to -identify the most desirable functions of the user interface to an -electronic system of journals, including in particular a comparison of -page-image display with ASCII display interfaces. Early experiments with -chemistry students on a variety of tasks suggest that searching tasks are -completed much faster with any electronic system than with paper, but -that for reading all versions of the articles are roughly equivalent. - -Pamela ANDRE and Judith ZIDAR - -Text conversion is far more expensive and time-consuming than image -capture alone. NAL's experience with optical character recognition (OCR) -will be related and compared with the experience of having text rekeyed. -What factors affect OCR accuracy? How accurate does full text have to be -in order to be useful? How do different users react to imperfect text? -These are questions that will be explored. For many, a service bureau -may be a better solution than performing the work inhouse; this will also -be discussed. - -SESSION VI - -Marybeth PETERS - -Copyright law protects creative works. Protection granted by the law to -authors and disseminators of works includes the right to do or authorize -the following: reproduce the work, prepare derivative works, distribute -the work to the public, and publicly perform or display the work. In -addition, copyright owners of sound recordings and computer programs have -the right to control rental of their works. These rights are not -unlimited; there are a number of exceptions and limitations. - -An electronic environment places strains on the copyright system. -Copyright owners want to control uses of their work and be paid for any -use; the public wants quick and easy access at little or no cost. The -marketplace is working in this area. Contracts, guidelines on electronic -use, and collective licensing are in use and being refined. - -Issues concerning the ability to change works without detection are more -difficult to deal with. Questions concerning the integrity of the work -and the status of the changed version under the copyright law are to be -addressed. These are public policy issues which require informed -dialogue. - - - *** *** *** ****** *** *** *** - - - Appendix III: DIRECTORY OF PARTICIPANTS - - -PRESENTERS: - - Pamela Q.J. Andre - Associate Director, Automation - National Agricultural Library - 10301 Baltimore Boulevard - Beltsville, MD 20705-2351 - Phone: (301) 504-6813 - Fax: (301) 504-7473 - E-mail: INTERNET: PANDRE@ASRR.ARSUSDA.GOV - - Jean Baronas, Senior Manager - Department of Standards and Technology - Association for Information and Image Management (AIIM) - 1100 Wayne Avenue, Suite 1100 - Silver Spring, MD 20910 - Phone: (301) 587-8202 - Fax: (301) 587-2711 - - Patricia Battin, President - The Commission on Preservation and Access - 1400 16th Street, N.W. - Suite 740 - Washington, DC 20036-2217 - Phone: (202) 939-3400 - Fax: (202) 939-3407 - E-mail: CPA@GWUVM.BITNET - - Howard Besser - Centre Canadien d'Architecture - (Canadian Center for Architecture) - 1920, rue Baile - Montreal, Quebec H3H 2S6 - CANADA - Phone: (514) 939-7001 - Fax: (514) 939-7020 - E-mail: howard@lis.pitt.edu - - Edwin B. Brownrigg, Executive Director - Memex Research Institute - 422 Bonita Avenue - Roseville, CA 95678 - Phone: (916) 784-2298 - Fax: (916) 786-7559 - E-mail: BITNET: MEMEX@CALSTATE.2 - - Eric M. Calaluca, Vice President - Chadwyck-Healey, Inc. - 1101 King Street - Alexandria, VA 223l4 - Phone: (800) 752-05l5 - Fax: (703) 683-7589 - - James Daly - 4015 Deepwood Road - Baltimore, MD 21218-1404 - Phone: (410) 235-0763 - - Ricky Erway, Associate Coordinator - American Memory - Library of Congress - Phone: (202) 707-6233 - Fax: (202) 707-3764 - - Carl Fleischhauer, Coordinator - American Memory - Library of Congress - Phone: (202) 707-6233 - Fax: (202) 707-3764 - - Joanne Freeman - 2000 Jefferson Park Avenue, No. 7 - Charlottesville, VA 22903 - - Prosser Gifford - Director for Scholarly Programs - Library of Congress - Phone: (202) 707-1517 - Fax: (202) 707-9898 - E-mail: pgif@seq1.loc.gov - - Jacqueline Hess, Director - National Demonstration Laboratory - for Interactive Information Technologies - Library of Congress - Phone: (202) 707-4157 - Fax: (202) 707-2829 - - Susan Hockey, Director - Center for Electronic Texts in the Humanities (CETH) - Alexander Library - Rutgers University - 169 College Avenue - New Brunswick, NJ 08903 - Phone: (908) 932-1384 - Fax: (908) 932-1386 - E-mail: hockey@zodiac.rutgers.edu - - William L. Hooton, Vice President - Business & Technical Development - Imaging & Information Systems Group - I-NET - 6430 Rockledge Drive, Suite 400 - Bethesda, MD 208l7 - Phone: (301) 564-6750 - Fax: (513) 564-6867 - - Anne R. Kenney, Associate Director - Department of Preservation and Conservation - 701 Olin Library - Cornell University - Ithaca, NY 14853 - Phone: (607) 255-6875 - Fax: (607) 255-9346 - E-mail: LYDY@CORNELLA.BITNET - - Ronald L. Larsen - Associate Director for Information Technology - University of Maryland at College Park - Room B0224, McKeldin Library - College Park, MD 20742-7011 - Phone: (301) 405-9194 - Fax: (301) 314-9865 - E-mail: rlarsen@libr.umd.edu - - Maria L. Lebron, Managing Editor - The Online Journal of Current Clinical Trials - l333 H Street, N.W. - Washington, DC 20005 - Phone: (202) 326-6735 - Fax: (202) 842-2868 - E-mail: PUBSAAAS@GWUVM.BITNET - - Michael Lesk, Executive Director - Computer Science Research - Bell Communications Research, Inc. - Rm 2A-385 - 445 South Street - Morristown, NJ 07960-l9l0 - Phone: (201) 829-4070 - Fax: (201) 829-5981 - E-mail: lesk@bellcore.com (Internet) or bellcore!lesk (uucp) - - Clifford A. Lynch - Director, Library Automation - University of California, - Office of the President - 300 Lakeside Drive, 8th Floor - Oakland, CA 94612-3350 - Phone: (510) 987-0522 - Fax: (510) 839-3573 - E-mail: calur@uccmvsa - - Avra Michelson - National Archives and Records Administration - NSZ Rm. 14N - 7th & Pennsylvania, N.W. - Washington, D.C. 20408 - Phone: (202) 501-5544 - Fax: (202) 501-5533 - E-mail: tmi@cu.nih.gov - - Elli Mylonas, Managing Editor - Perseus Project - Department of the Classics - Harvard University - 319 Boylston Hall - Cambridge, MA 02138 - Phone: (617) 495-9025, (617) 495-0456 (direct) - Fax: (617) 496-8886 - E-mail: Elli@IKAROS.Harvard.EDU or elli@wjh12.harvard.edu - - David Woodley Packard - Packard Humanities Institute - 300 Second Street, Suite 201 - Los Altos, CA 94002 - Phone: (415) 948-0150 (PHI) - Fax: (415) 948-5793 - - Lynne K. Personius, Assistant Director - Cornell Information Technologies for - Scholarly Information Sources - 502 Olin Library - Cornell University - Ithaca, NY 14853 - Phone: (607) 255-3393 - Fax: (607) 255-9346 - E-mail: JRN@CORNELLC.BITNET - - Marybeth Peters - Policy Planning Adviser to the - Register of Copyrights - Library of Congress - Office LM 403 - Phone: (202) 707-8350 - Fax: (202) 707-8366 - - C. Michael Sperberg-McQueen - Editor, Text Encoding Initiative - Computer Center (M/C 135) - University of Illinois at Chicago - Box 6998 - Chicago, IL 60680 - Phone: (312) 413-0317 - Fax: (312) 996-6834 - E-mail: u35395@uicvm..cc.uic.edu or u35395@uicvm.bitnet - - George R. Thoma, Chief - Communications Engineering Branch - National Library of Medicine - 8600 Rockville Pike - Bethesda, MD 20894 - Phone: (301) 496-4496 - Fax: (301) 402-0341 - E-mail: thoma@lhc.nlm.nih.gov - - Dorothy Twohig, Editor - The Papers of George Washington - 504 Alderman Library - University of Virginia - Charlottesville, VA 22903-2498 - Phone: (804) 924-0523 - Fax: (804) 924-4337 - - Susan H. Veccia, Team leader - American Memory, User Evaluation - Library of Congress - American Memory Evaluation Project - Phone: (202) 707-9104 - Fax: (202) 707-3764 - E-mail: svec@seq1.loc.gov - - Donald J. Waters, Head - Systems Office - Yale University Library - New Haven, CT 06520 - Phone: (203) 432-4889 - Fax: (203) 432-7231 - E-mail: DWATERS@YALEVM.BITNET or DWATERS@YALEVM.YCC.YALE.EDU - - Stuart Weibel, Senior Research Scientist - OCLC - 6565 Frantz Road - Dublin, OH 43017 - Phone: (614) 764-608l - Fax: (614) 764-2344 - E-mail: INTERNET: Stu@rsch.oclc.org - - Robert G. Zich - Special Assistant to the Associate Librarian - for Special Projects - Library of Congress - Phone: (202) 707-6233 - Fax: (202) 707-3764 - E-mail: rzic@seq1.loc.gov - - Judith A. Zidar, Coordinator - National Agricultural Text Digitizing Program - Information Systems Division - National Agricultural Library - 10301 Baltimore Boulevard - Beltsville, MD 20705-2351 - Phone: (301) 504-6813 or 504-5853 - Fax: (301) 504-7473 - E-mail: INTERNET: JZIDAR@ASRR.ARSUSDA.GOV - - -OBSERVERS: - - Helen Aguera, Program Officer - Division of Research - Room 318 - National Endowment for the Humanities - 1100 Pennsylvania Avenue, N.W. - Washington, D.C. 20506 - Phone: (202) 786-0358 - Fax: (202) 786-0243 - - M. Ellyn Blanton, Deputy Director - National Demonstration Laboratory - for Interactive Information Technologies - Library of Congress - Phone: (202) 707-4157 - Fax: (202) 707-2829 - - Charles M. Dollar - National Archives and Records Administration - NSZ Rm. 14N - 7th & Pennsylvania, N.W. - Washington, DC 20408 - Phone: (202) 501-5532 - Fax: (202) 501-5512 - - Jeffrey Field, Deputy to the Director - Division of Preservation and Access - Room 802 - National Endowment for the Humanities - 1100 Pennsylvania Avenue, N.W. - Washington, DC 20506 - Phone: (202) 786-0570 - Fax: (202) 786-0243 - - Lorrin Garson - American Chemical Society - Research and Development Department - 1155 16th Street, N.W. - Washington, D.C. 20036 - Phone: (202) 872-4541 - Fax: E-mail: INTERNET: LRG96@ACS.ORG - - William M. Holmes, Jr. - National Archives and Records Administration - NSZ Rm. 14N - 7th & Pennsylvania, N.W. - Washington, DC 20408 - Phone: (202) 501-5540 - Fax: (202) 501-5512 - E-mail: WHOLMES@AMERICAN.EDU - - Sperling Martin - Information Resource Management - 20030 Doolittle Street - Gaithersburg, MD 20879 - Phone: (301) 924-1803 - - Michael Neuman, Director - The Center for Text and Technology - Academic Computing Center - 238 Reiss Science Building - Georgetown University - Washington, DC 20057 - Phone: (202) 687-6096 - Fax: (202) 687-6003 - E-mail: neuman@guvax.bitnet, neuman@guvax.georgetown.edu - - Barbara Paulson, Program Officer - Division of Preservation and Access - Room 802 - National Endowment for the Humanities - 1100 Pennsylvania Avenue, N.W. - Washington, DC 20506 - Phone: (202) 786-0577 - Fax: (202) 786-0243 - - Allen H. Renear - Senior Academic Planning Analyst - Brown University Computing and Information Services - 115 Waterman Street - Campus Box 1885 - Providence, R.I. 02912 - Phone: (401) 863-7312 - Fax: (401) 863-7329 - E-mail: BITNET: Allen@BROWNVM or - INTERNET: Allen@brownvm.brown.edu - - Susan M. Severtson, President - Chadwyck-Healey, Inc. - 1101 King Street - Alexandria, VA 223l4 - Phone: (800) 752-05l5 - Fax: (703) 683-7589 - - Frank Withrow - U.S. Department of Education - 555 New Jersey Avenue, N.W. - Washington, DC 20208-5644 - Phone: (202) 219-2200 - Fax: (202) 219-2106 - - -(LC STAFF) - - Linda L. Arret - Machine-Readable Collections Reading Room LJ 132 - (202) 707-1490 - - John D. Byrum, Jr. - Descriptive Cataloging Division LM 540 - (202) 707-5194 - - Mary Jane Cavallo - Science and Technology Division LA 5210 - (202) 707-1219 - - Susan Thea David - Congressional Research Service LM 226 - (202) 707-7169 - - Robert Dierker - Senior Adviser for Multimedia Activities LM 608 - (202) 707-6151 - - William W. Ellis - Associate Librarian for Science and Technology LM 611 - (202) 707-6928 - - Ronald Gephart - Manuscript Division LM 102 - (202) 707-5097 - - James Graber - Information Technology Services LM G51 - (202) 707-9628 - - Rich Greenfield - American Memory LM 603 - (202) 707-6233 - - Rebecca Guenther - Network Development LM 639 - (202) 707-5092 - - Kenneth E. Harris - Preservation LM G21 - (202) 707-5213 - - Staley Hitchcock - Manuscript Division LM 102 - (202) 707-5383 - - Bohdan Kantor - Office of Special Projects LM 612 - (202) 707-0180 - - John W. Kimball, Jr - Machine-Readable Collections Reading Room LJ 132 - (202) 707-6560 - - Basil Manns - Information Technology Services LM G51 - (202) 707-8345 - - Sally Hart McCallum - Network Development LM 639 - (202) 707-6237 - - Dana J. Pratt - Publishing Office LM 602 - (202) 707-6027 - - Jane Riefenhauser - American Memory LM 603 - (202) 707-6233 - - William Z. Schenck - Collections Development LM 650 - (202) 707-7706 - - Chandru J. Shahani - Preservation Research and Testing Office (R&T) LM G38 - (202) 707-5607 - - William J. Sittig - Collections Development LM 650 - (202) 707-7050 - - Paul Smith - Manuscript Division LM 102 - (202) 707-5097 - - James L. Stevens - Information Technology Services LM G51 - (202) 707-9688 - - Karen Stuart - Manuscript Division LM 130 - (202) 707-5389 - - Tamara Swora - Preservation Microfilming Office LM G05 - (202) 707-6293 - - Sarah Thomas - Collections Cataloging LM 642 - (202) 707-5333 - - - END - ************************************************************* - -Note: This file has been edited for use on computer networks. This -editing required the removal of diacritics, underlining, and fonts such -as italics and bold. - -kde 11/92 - -[A few of the italics (when used for emphasis) were replaced by CAPS mh] - -*End of The Project Gutenberg Etext of LOC WORKSHOP ON ELECTRONIC ETEXTS - diff --git a/libs/zlibng/test/data/paper-100k.pdf b/libs/zlibng/test/data/paper-100k.pdf deleted file mode 100644 index b3325e4a2..000000000 --- a/libs/zlibng/test/data/paper-100k.pdf +++ /dev/null @@ -1,598 +0,0 @@ - - - C=10 M=100 Y=50 K=0 - CMYK - PROCESS - 10.000002 - 100.000000 - 50.000000 - 0.000000 - - - C=0 M=95 Y=20 K=0 - CMYK - PROCESS - 0.000000 - 94.999999 - 19.999999 - 0.000000 - - - C=25 M=25 Y=40 K=0 - CMYK - PROCESS - 25.000000 - 25.000000 - 39.999998 - 0.000000 - - - C=40 M=45 Y=50 K=5 - CMYK - PROCESS - 39.999998 - 44.999999 - 50.000000 - 5.000001 - - - C=50 M=50 Y=60 K=25 - CMYK - PROCESS - 50.000000 - 50.000000 - 60.000002 - 25.000000 - - - C=55 M=60 Y=65 K=40 - CMYK - PROCESS - 55.000001 - 60.000002 - 64.999998 - 39.999998 - - - C=25 M=40 Y=65 K=0 - CMYK - PROCESS - 25.000000 - 39.999998 - 64.999998 - 0.000000 - - - C=30 M=50 Y=75 K=10 - CMYK - PROCESS - 30.000001 - 50.000000 - 75.000000 - 10.000002 - - - C=35 M=60 Y=80 K=25 - CMYK - PROCESS - 35.000002 - 60.000002 - 80.000001 - 25.000000 - - - C=40 M=65 Y=90 K=35 - CMYK - PROCESS - 39.999998 - 64.999998 - 90.000004 - 35.000002 - - - C=40 M=70 Y=100 K=50 - CMYK - PROCESS - 39.999998 - 69.999999 - 100.000000 - 50.000000 - - - C=50 M=70 Y=80 K=70 - CMYK - PROCESS - 50.000000 - 69.999999 - 80.000001 - 69.999999 - - - - - - Grays - 1 - - - - C=0 M=0 Y=0 K=100 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 100.000000 - - - C=0 M=0 Y=0 K=90 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 89.999402 - - - C=0 M=0 Y=0 K=80 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 79.998797 - - - C=0 M=0 Y=0 K=70 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 69.999701 - - - C=0 M=0 Y=0 K=60 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 59.999102 - - - C=0 M=0 Y=0 K=50 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 50.000000 - - - C=0 M=0 Y=0 K=40 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 39.999402 - - - C=0 M=0 Y=0 K=30 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 29.998803 - - - C=0 M=0 Y=0 K=20 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 19.999701 - - - C=0 M=0 Y=0 K=10 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 9.999102 - - - C=0 M=0 Y=0 K=5 - CMYK - PROCESS - 0.000000 - 0.000000 - 0.000000 - 4.998803 - - - - - - Brights - 1 - - - - C=0 M=100 Y=100 K=0 - CMYK - PROCESS - 0.000000 - 100.000000 - 100.000000 - 0.000000 - - - C=0 M=75 Y=100 K=0 - CMYK - PROCESS - 0.000000 - 75.000000 - 100.000000 - 0.000000 - - - C=0 M=10 Y=95 K=0 - CMYK - PROCESS - 0.000000 - 10.000002 - 94.999999 - 0.000000 - - - C=85 M=10 Y=100 K=0 - CMYK - PROCESS - 84.999996 - 10.000002 - 100.000000 - 0.000000 - - - C=100 M=90 Y=0 K=0 - CMYK - PROCESS - 100.000000 - 90.000004 - 0.000000 - 0.000000 - - - C=60 M=90 Y=0 K=0 - CMYK - PROCESS - 60.000002 - 90.000004 - 0.003099 - 0.003099 - - - - - - - - - Adobe PDF library 9.00 - - - - - - - - - - - - - - - - - - - - - - - - - -endstream endobj 145 0 obj<> endobj 1 0 obj<> endobj 2 0 obj<>/Font<>/ProcSet[/PDF/Text]/ExtGState<>>> endobj 3 0 obj<>stream -hÞ”[MsÜF’½ëWðnmU(s™e{¥ÝñØkjw²`7ÈÆ¨hhÒœÝ_±‡ù½›ïe€&›rl(BÑÄG¡ª2óåËúæ_o’‹ûáÍ·ß|óƒ»H.>Þ½)V¥sæ"–þ§ËWq’\X¯âØ¥÷obÞïïåÇÇ5þ{|ó)ú¥^×íxyºl•D]ÿE~gÅ*vMû¥Þè_YôþÇAÚ¨jqÕÙèÝ·?ób¾*¢]ýPïøW¹rÑØñ‰UÝ×mž©?ôõ04]‹»±\¹}ºüüñßÞ\¯Ê²¼¸NVIîd=ßɼöuÕÊp6wòñîN~¹re¢ßŽU;6c565î–2éc³®v¸„uì» gƒ¿ŠèSšü3Í>_áïD04í½¬îçQwñ#*Îåã¿Èׇ}µ“ÁL%´ÇýmÝË_9f€¹˜ÜÊ0Ü“²^YצYÓN¾9nëpsìe)ë¾9Œ²òŠÃ&ò„|÷€O›"–Ý~lÆíüýms¿•=2yT­×ǾZ?­ø'Ñ=ÊV÷Wø;“ù¨`L)·T0¦XåA4&ÅåÝq'×»êIGJd½×©Å·ÍC7bb©1QßíêðtÓrJ1EãÊ\ES·Ã±çR!â"º«dîwÇ -?‰ÖÝþ°«G³ÞqÏ p§Û¢õÝ_ßâ§‘«}}؉øü+.ÅDûöAèþ¹˜É¤$&þ¼ -*÷vÐoˆ¼:UçTæ¿išÍ‘ksØô÷?ây'ÒÛVƒ^4Ñm]Oß½ëŽA½©Ä$x‹I;#Šúй4Õ.|ö®ëý®oîýŽQˆwÇv­KÊ,ăñ2kd‡6ÕX‹³,–‰4#.CÍ›¿ ²]ó¥Þ=é‹F6­õw¡â–QD1ü{~Û´Õ(µ}ÒËE´œK_ßw•*hZ@CtûEAËgÛ/Ê)rjöòìJÿ´Ñ‡vS×è\a¼ #ŸxhêGý­F𿨓õ¶ïöøØü}l¶cYŒh)ùª¨â(»·ÇTþæNšÒÉþ¨ñÈSb”²áû[,Ê”¥W%üÊ£MswW÷/S2²¨ÌXËGåO¨¥ªáï5Œ´Ìåþr>ë®ýû,ž„Ø ¼Îb`'%ÉóÍÅE,Bþ>ö|$•G0§,1%ñž@ÜèÏT/¿2Ž;ë‡,žBQC)e¸‡™]…MÎR™Ø¶±~˜Rmê[Qž¾ -P c§ ƒ] î©QÉkO‡NFšáJ_¶Øù•ɇ·Íz{θ‡C½nîš5”ÚÉ<Âòe’ƒÚH²˜¥‚Q`Su/JCSI£cÛüvôf“F·M·ëî¡asÖ£ßpΪ?™äŸÆÂ²óy»·Ý€˜'°#‘ó¡°ø;¥nåi*s¨ð#–}ðêÞõO¸‚ß×ëmÕ6າˆY‚Â^õzÉ .R`cß­aôXg|_޽~¬á"ÒÜhjñ@÷þͼ ú,Îø=qr‚Ðf²Î®½Â¥Œš40ÆP“Ûu}€ž`‘Ë@4Ë ë;ÂzRìÏ—¶{í»¯u,"ÞM¡ØOµ&SÔ›&´©÷"a™*W`èÕ"IˆF$—,Ñb¥OÚè¦És=<¦Ò#jáâå¬ú{ˆ~ñ›rå-"ß"· .êYF}V$¹[ù'=ùžªJ’}ÛJéZÄgŽÂ6`v©õÆ&v—‹¬Àeøœ¬z|$Üã¥lUr«»«iÚƒþ]ªÀ³øŽ=Xê3M7ª˜‰-ÉuÕ®• ÛîQ/ç1y°Ü8âöî8ˆÑ@š®ôv…—’å´pËÎÓ:c²‘Ș‰…€ei$ˆŸeTW=]C -Çè]•¼E³Á;ÍÈ»p×~Í -åU{¯»Q*0÷5á.õxr"ÎCŽ¾ë»¡;l›]uùñï³$ÍJĘ‘C…8Þ÷22´?¡Õá×@Hr… ü4AïØÉð$[ˆ­Z«ë3‰£X+!M²·Í?86À[T°¢>yúÙœh×ÝÒ°q ¢Pç$áð -ŒY¸p%«öb¥#XŠ5¡|–b¥^Q*B;óN™ºËJ:”à§3RÕÿüã…ò»¬Èå*ðÄ›9"‰a½­÷x¼pNA -è -S²b' –Uäp‹~tÜ…å6ûC×äs$Œt€Wh¿eÞ¢»+hªq², GFÙIHÆø[W5‡SØa<DèŽìßXÝî¦ÝSq-¾Í˜Ô1æ¨+£"G[»†‘!&f,Ý­pág‘ âä|ùž‰ùç­v0EÂQÍ`ÒŽIYZå)Ž+S ÄÔåðˆwMïï¹@Å]ÁàÚçG\¡Ñµc¬v[ŸøCÝ?0˜!ÿ¨Öâÿ8äÖC1Rµ<*—ªåùŸ`yqY¦ˆ!K5¦_¨Ñq7ß|èM ¾õQS›:¦Y0âªްYuÈIaf>]"B”ç] <-W½{0psõïÛæ¶¹¼f^HãGØè¾Ñ¸ÍÆÁ†dV`)0¥ÉÐÒØYohjVÆBÕ訅ôù¤aRpvã)øP¬¾ßO¢ûÓí%‰Ãâ̹ Wˆ-%Œ~©×— >ì-œ@¨Üe‚\›:¹‘Ô¬¸ ‡+pÌXÈËðI”ûRt/€·¸'* ÓO€.©áXIMh=N`B—šû©epxcš_ ±¾~¿»dâ¦~–§žÐR„‡'%¤ÚWº( &­£o×·+,NyL'³$RxÜa9™KBˆYXW2¿ÆòÓ¨ò³/0Ã,sJý1yX>(f$ÆWò(»J -쇋®ŒÃD~äŸ1R­ÎáîûîQg#¨p©øpœ2 :}R·ŠHX0 ‹â= ³#Î1pëë:º­]³cö®ÕQ3&ŸsdÊëÙÖ̤j¸¾×íoF?¦ÛË8âV&Ñþ–Ó’™âñSnÞ#ÅÂ:tÂb0£2.£»±¡×žz••D-º‹;„¸+,ø=߃`®p©ð!jΰL “D]asÉ ›ÀäáF½cÊÌT óÊ\0ø¦>I/LPaªf¡¿ rF“´ HKìØ™e(ÕÎçO/ìe£ì;ex~ÎZôYï þPŽÉò3c³»d|¾¸Võ4ádOЇÒ)óñZ~Fë$¸Ö•K$tI¦‰@[µAuÆ0\¼d‚ ™FdõÕZ¸sËj†?K~ºoXŽå&=xÕï ìØ6U8¬~.PTZ;@°WaNCnuÿ›ðùè¡ùPä(Ψ-ñ&âfM’¿Ȳñ!<™ó±×4¬lÿ×ÈÄømC ãåÑ5cÂ^A®Ö—Y‹1xU_§–2Ðg¦t´i¦´Mc¡¾%='0Ä>ÿâ·¢ÖÚ“uWHh*ZC‘w3ÿ¨‚ÌH£¶ÛVwAûðкÛa Hœ¯‰Êð“*^¶I˜Ø½SÄ®¡lÖ«p*>Q„!:MÖ¥¥€Ml±µ’™¡Õ²"rÙ9ù1LAéëDà‹m]X؆¡IÓ)ÑW”'Szó»¾S4CBå…lĉ‡™&6¼q“j¦È‚Ÿ©:î ·ŠS³”H+z·ý ãG?_KtÉŒb~£Ùî> 4=t£Uÿ¦® *¡8g2a¨¼Šj£DÖÒ&§üý_ß©Büô¬å{õ -™ Åg­B$E»Ä³Mõt|G -þǨ>#!›8ÂJM:>ž„3ðw•Îy².ê#®­Á’˜3—Ÿ:0QãIó.޵8k±"t›NÈZ}õGÍøØ%@i"çÜ·µL¥ž€·5)³½w?/Æ>Ñ+ú$´.&Ž¡NØô3ꔈ{[ª“-R 韹¡n>Êuš e›ã‰P 4~ð€z¥£åZÝË](œiæîð~ð|¢Máë 6A8°*¡Ÿî‰®;Ù:±üMãõê‡ùh‚!÷¥GͰþÁÖ#;ÌB­Î¡±jPëDía•¦h±¶S~‚¯È—wjyÇ¡Q£|¨ÃãáE‰½êQ÷©ú'ࢳ»ªX -Î|J1c@«Ø"ëA¾'cÝeI3ÈŠ°Z²G£#s>]žME÷Ìnó,ÓÑR\ÉFuNT':òƒnÉöjœD“JÁXI…¹gc÷ëq«¸Ðm¼†7ó̰¬Ž‚5“zÚŽDyò®Öý¬ú¶F ÇAN;·etS?L°£óÙ…1g«B†üÔþBÐ@¨Ï3V̶žºžuÙD»|±“Ão‚nh®ÓAìJF*§ƒgyÆhL¤“V¨²â±VÎBb¬eh£¿¯‚Ì×”†|é0*n7AHRiDª£ÆH‹‚§Ä*ÎH,puÉ¢—)?Ëe —÷°;šÐÉÍ55§îåÎܬÓ_눉8Û3¯¼SíYéMÙˆ tþ¾mî4„BXIâÞŽA…õ•<.}ûú"!‡.ðüõÌd>?3Aq«ÝæÌ‹xîHÁã—Šžt} lh*Qô„®ðLPô3ÉC{ËA+Í¥Þ[Ù²Ìü½“Äþêz'ñw’—/ýéÙKiž„·ŠsoÉEúú›×óý$ö¤¡(ž -{giÉÿ´â0sä -úäIÌÑŸŽ›¬â8õ48²'eö—ŪLL"ã\FxË _¬BOù!¬óÑ'o¯=µ`$žjð† Ï̵õ4ËÝ©Â#,$Y¡·†×»ÛØãÛµì½ÈR²…Gíª,|{`²Œ§öWlÐŒš•/†¬Âpïí¿«aÕšÉ%ã/·÷Š—è[Ó$¦G’¢RŸ"/ŸAØiôŒ£;F«ÓË6ä”’+um`P­þ,ÎåÑkë‹€À••¿¥‘ŠŒ^T½tÄÇfTˆ‚'Íã)É{.\¯Ur!|©ÖOÚÄ -ÛùÙS¹ªÔËvíÿ* - ¡ó«…Å!Xwµrñ»»Fá,ÄûäýXÑ•vvºhë™0z +õ'wJ)s² üüî]hµízoá‰/1#œ—AËû-—ø+Æ/ÇÎ6ñ=ân–ò„f©Ý˜`7‰µötÄòåˆ/­-óÉî(þÀ†¨¿ežÍ>Ίe£h"ÙAOàä'Þê¡ñ¶yôám(‡K@ ®6®~J2U#œ -Òã<‹â†²ÖãrñJqÃä¢óé[ä $ÊÓê‚o0-ó¸xf>f¥A´Q'n¼C*Ë9»Ṳ́ÇOÚ–œè VJ|×vœœØ‚ðª?2*“×( XЦdø\îÓ0)IPÐù«sföèOˆœ§ñ.Í7Î'‡£N£ -„àÅâ8ÉltGÖšÈü®,Ìœ¡Œ¬Kñ‰dîÆG´ÆdOšH^e1g³µ›pÆ5ö%Æ‹$æ$¯Aé¤/9hoZK¿Ä`_Z%SæBõPVçß[þZ¦ì´P7‘ô/¬¥±ŽwV•S6p½O®´‡Quîl6à ×” ˜­F±akï׊¬–'d§yvÕèyi¸ù*m4,Å>éÑ ÜG]ž“Õ 9D7ÿ"˜¶*™éœ¨ºWíAØh8ªD\©›1¥qšuÄ51Ëc¯ƒ÷u«YÔéñyÜתkÒæÌŒÏݱ+ezuœˆÝ¡80T,•ŠÉÀôäÜJµ®™*y‚+š¢Â”L^5•³Fæ–µ¿îzãV1àÜ›gª¼ì¡eþu×­µL[yzÝü#ä·¦cƒñŒA¬m“´×GôüDÛþL-d>ô©šâ{[sGžíÉ•,£ê5yþ¥i5,çiKàèäÖç ôv7eÈä™W -ïĺ‰ái´”[v¡Ÿªx~ÊÖe@UpžéRDOÿï¢ÂUhâåV•F;€uCǾ4Ö&Èä!ˆÖ¼æ3Ð,§3xeÁ(ÏCHϵÍìŬ,Ì{Ë¢j ¯ðAsùJè6ǯBäõ OÆÌÏ€+œ}ø ɯp9)êÈeš;Á)¨g…ùäe»ÓrŸb­Z«Ã‘7N}Ç£4)[V~¥ñæš‹ãóVû@õ‡›¿©P?œe·ýÏ_~‡ -—%Šø_ßþ ëæ¼-wQ[ž ól‡¯²EÏ6bÙ¤çåjc{޷뫾ÖÀs”ÈÉøLÆ2=éÂÿZ%Ë‘H0èÛi4>v:ò26¿ -#œDiæyé -m—È8#ˆuïK˜€àhÑæK#ziT”\Ýûá =e̽òݲ±ž%œ>â¸'o?þ¬¹Þ¨'–{H4Ày±'›ªõ•LŸ=ÇÌëÞ‡x‹ŒŸ¯…ŸÇ‹»jí1|}óc£ª‘^i‹¾ïÝÉÕùtB×}¥[Ñ~¾„VÀ;-9¼l¯ÔNï§[pô#[rÂÙ–øùäë«s¨n!à†¹OŒEtôp·`ÓÜôÖí|v+bþE‚R»šyoXT€`Ûãz§Uw(#äE¸ ¥žRõm÷à3Oý•+´©-ÖÍBoU`úÇÆ{ÌmóŠäÎUÐî”jë›0ÎvU0ù{òÜÕØÓ4AÔ#x/kqC8øÉ&‹(Ž£/^Ôs²äÓY×g2›ê"@grÞ½É6Ò™™â6˜ÚðÕÑL9À9·.o³KùœMPºWtôu)="kúÔRfH©ûkßÊÓoØQ‹Î¤Ä¼B[ÎHi}?Üqí‹sSŠg“°©èxËOhï¢ý” ­S )·C¥Ìa)žÔºYð:ìk=ƱYóÅÑ—".òS²èar/{˜DÒ¦Lç¢t:µ h¢MlÈæÏÚ²KL¾ŒbxD®ºÑÌAÆ/­'–V˜å¥#”_lÇ×wŨŽ{ù-“å™P3´¯°ŒaæÄÚç„ô09úpŒ,Æœ,†ÿsÕ¾;Ð+šW!ÀEëÏ _Ehí¾çÔ­•D6•vÃ$Ñtxéd›ôŒ¢ß&ÜwÑc£my82Ñ+pÔÕFO)ŠW%_6‘AˆgYý<ÈUÈ*:p|+ó<öá¬ðºîµ„Æt}8…,!e„óÉü4@áË„R\s!{ô>ú%!–e -éÌþ¶·É0ÒZw?ŒO~cÇ=L"RÈ'mSQhkŸ£Y¯ð9 -¨ëŸtË žÿ>·ç}½¯T-ŒwÆS0k Í»ªG ®‚Ý÷µÿKâËV6Uøg½’l×ûšç"ñªcéOGžQ¢ëe÷âtd=ÎÙyyÜ<…*‘J-V›Þ©Òoq€ z[áå…X@4¯Va`ñ) ‚º? Ù-aoN`,‡ÝiîšÙÀ´*¦Í…æ¿ü™v6j›øi–dçØÅS…4DÎõš¸ :QßæÜð°ƒ>ü·Z‹¼l­êúQ]güÎõYêà"ÁïÍb}$ˆ âP#í™è‰òqŠc²¥ÍiGY^;ò;®äaEv0ÌÐqಙ±Þ•“¢º¢ -Œ…¡øª^ÌJ÷d49[ŸºaArë]½÷ îŒvFMTQÒ¨8ÃvǾ¹=2IžÇ>V´l“¹;öãVy Èg½;®›¦Ó]áâŒ(—f„¤¬7#6vûæ7Ãã[M Å?oª} 2´ -€£ŒCf© `Ü ôsthC“ÿ‰BV.ÿ]àXA™+YýýDZ’mGÓ'̇ ˜ó£Li7ŒõÓ‚F©¾¥ðÿœè[нÿ¨Ð¤§­ E¦¼¸.e‘ÂQuù?ÿå§›°ØwÝþp9–bË¿¥÷„I±)ÿp6»ôøø¸:ìºA(?cï𳫮Ǚ -ÇtZzy]:œþ­jZËM±—iœX§e§ÿ«Û÷µúï=arÝ?`KhŇaÀ &ˤk¢¯%óûuÇÆ&e/þO€¦±.µ -endstream endobj 4 0 obj<> endobj 5 0 obj<>/ProcSet[/PDF/Text]/ExtGState<>>> endobj 6 0 obj<>stream -hÞÌ[Û’äÆq}çWì‹#0Ž™.uá‡%)YT¥][K>`z03»M=Ãa8üþ^ç9Y…KO/I…eKÁ.¦ª²2Ož¼Ô¯þí]öæaøäÓ÷Ÿüê7îMöæýý'å¦r®x“ÊáÒ–›ÔöÏ‹I3óæýþ“”ôrñ~‹ÿ=ò!ùíp¬®2¿©’ôê¦0~S$õUš øC^•?ø«Oöu•Yù廦Ço©üÖÝã*ß”I½Ý^eÕÆ&Í0´W™Ì"¹Ý5úœI¶òn±É“n_ã¦KÆö°‘»…‘ë·».½ÜoxÅÈ8õî*ËäßÝ5~±xåñ*Ëå£Õ'»v1ˤ›«ÌÉ﮾}ÿ;Y×M¶É¼Á|.ë;ö ^Ë“»Vfhäý±}šr©“»g,-O°2—æae¶²r5Èœø¬ÇVF.“9z½h¾™ìøµLæ"Z™ÿI…éÒLÆå¤Éã˱ƒÜ‹y]Cû#„“͛ŚÊÜèššZÌ·H,=¶ -¿Ì=‘-·.Ï!þnçmrÛj|T&ÞõíUžb·!|ÑáËSU26ýS2É®ÖMxÁ•Ìñ¶Ÿu¨¦ÁVeÆÅÝÕéøË¢ÂšÞÿ3V‚ù@Ínwøº“A®nŒLÇR ú‡›õëÔÇñ܃îÝɈ.¶œG‘´ÇQÅÒv Ãh‹‘Éy -•ßl{¡Júf‡Uù¤[Ì¢HºÃðI‰Jã‹Ï­l‡3òÆQÕj×^Q7ó¢¶âÂçó*•Ïížfá“Ã(~^zä ÞΖšWNž>4?Œxˆ{ÜLzÛan2Âp›Xé3^)ñ©BÀšñbå©jaØVUϹIïÌ,‡¡6œý¯~S(žT"¹#\„ˈ'N.r—åÀ“Ég¢X7NF…b¢ÙX`ßR¥Ä´ Ñ¼ÃØ··'™”LÎë†è-ÅŽT^ýÍ™ñu>€½1ïÚÃÃly–OFÝaûK*í à!KîpEÝÙq¸’›¡UÅÜcÈðaÁA[ƹ©>ŠªÎoÒ,{ãd~EšzÂOõ;$æÚŽØ!5z‚Д‡þí»;H[6y§Áyg¢n:(âBôµ¥frûË„š ¡S3]%³ÄS™èCƒ©8Ž;7ÍœsÔUÞlªªZÃÊeT ø~Àë¸VX\|þû·ºQåÒ¶Ðñ|9Yu$¯«ò/ðÚ÷úÚI Q&]->7k³ÂB–.k¤3Mn~Ôå7óºÚq£c•ÉûGhå €.€‚]Ó~Óäjuk»ø·ºƒ·–W·õ 3ž'ªÂ6- S -0F(=8G;ŒqKkÕola»“§º7ÈÛ—ø†x‰¤~“|Ù( ¨e˜ Ööövнév'Uƒ‘Ô ÊøN J¼ïá;%õþ­fÖC=ÂÓYò.Â_³•äÌm…Ë?1¤‡çY ?f“¯šñQ—ÛÝ JÝLrßõ—¬ç®ë€O»AÅöÍ•`hÚö¡°zïÚXE›o¯õȲpˆŠ"ªðN™²÷ÇF©ãžK Ë3oj’<öy8ªo¯ûAA£D­ d6–üvÉy船L{§`ÕaÈÒÉ$=`.Ä;JEA§‡NöšTøˆß^UñHß mÇÝ Öâ“ëK¶{_ouêí -S*›™¹¹Í¡C+·9 öuôÐ7£ZË -s1@µ4)Ljƒ{ØÑ?5*õâÑè<ð góœ²z BÄ›ªè‘¾ö“€Ø1eø è‹ÅjE<µZÀ“\&¡…¦Ål )49ªkÁv5Om §r;”ávíuáÇ]§÷BX6y$§ ½k‡­FÈtÙä¢Ö=ù‹pÿa« Ñ ¿ãþŽqi´ìiƒ„ÓİT9p}eW÷hTÊ×Þ‘S0^Åþ­ò8{¦˜XG¾D|áÉsÍ÷AOÇ0ƒ}Àd~žeQø /8‹ix‚§]ˆÐe›K°§?dZ n~8FF¨Ë¥‚áôñs#³´¥cØ·nß©„F,ûp#QÈ“Zh¶e= ÿXËöæiäéÖ ÛÓÇ+1© vóÙ§_jìYÂå…v<Û Áœ¨½)¿UKЈ+’ð< êú›öá ° Z3,?Ëè•v§AtÄX~‚ÈôEwš~ÐðØHT)æ&zñÎÝûlEë^ÂÑP¨ºÉ9×”Ý(¯ìëö ¡NVEßn¨²”QGP‹¬À7êË /.þû›«Ò˜êIÕ$AçÒɇl˜g‘M"ïá$”!¹)ŽÂÇ,Âáæ¾ÛöT%ÛÜñÂþ>‰ë½ ±¤‚=¯Œ lW.á_æõæþB†XÀy߃A9¥ÇDqGl9õÇn€[°þgÃ%Ô6yíæÝQj»Ú"ÍÂÞ@²@êƒòH ~N·ÜÞ)56OI€¿?1š'©„Ðltœ÷"Þk}BwChh½}œ÷QxÅá.z@Œ™{È\e,à+¹Òbe²úŽ Ó£Pâ†ð˜± ¸AËœa^2½vêú„(ÚÇ[|aš™Œ -[Q†ÇvGç!ß&¿æJƒáÛrËÌGsHy!üÉ­RmØ/· < +±Pª¯?ûL½uÆ$¥¦'<ܾ©ÁTf.`­¦rÛBH‡&Fâh»R–3Ú€ÀNpz¯Òùs³ \õ:’ºdØ`‘j·{ù18æ c1;¶×ÄYL™1Üڧ&f³ŽÝ3y“åbFmx Ù'—#Šû3áÏÑ½É ü Yìš'*#ySåq9¢¼¿t Gç(zhïäþݵtÜ‘¸¨qLû#FßÊÀ”¢Ód·Ê,”£p™&§5°ÈB¦QX·€rb‹^c‹,×›‰ -²pë¿Â­4ÜÂòõNîdᎩ*nýËÙK¹Ïâ[6]Å1HI|¨÷à€¢.\‘dŸª’EÕ!æ¿;%´Ú ó©û—A›ªtÅÚ”çÀÉÞo¯•y™äSuiÖ³"NîÄÌ2Ro­µî‰¾üØ>Óß#Ó-Ϭ±‚?ž¿'ÀðÍ•ä7^–dÏÀ}8=<ÀJÈñWû‡·¤Ô½°Žé A Üp)a|áa°5Ö! œÊ2>hÈhe“†*ƒk$W{3•–EMY2ƒ<{J¹•²´ Ž’fÉï»±¾Ý½@P• 9ayóHf*ÛEКMC ÁzH¤u&j~D¾mõ‘lòMòÇí â*“C7Æk\ȃô~x‰uªA¨nÃ:*~R³·>ÕLóEÙöÂ,èõJˆ¬e—hGl1³³$*•™œi”o’cW,Ý=¶ý„*E¥œvasBœc>GY|Å72²Aœ£¬»öNŸô* ¡¶]ß7"·F“¼•zaù°r -³`Œ©¡’† ZhÇB\é&À_@»W†,ð䫵GÛòyZFãú׫›Ì -¶e %ˆÔ™¹ûÍÈ• :ê_qÇ&ŸÁ¿Ò §«ª\«Õûú»†ô¯Ýý ½“S˜HÚµ6>¨ã,è%·]NR ÒÎY YKbÌØÇfÊw[:^Ìø—ã®I¡é[úùŠL[`~¤)CY2æ=+Ø$T¿çÌð¦K^>œ1윕fVàh÷á3× > -`ÿÐîe’ŽÂ'…ý§kežZ¥DÈ.)ìS-È+¬Pš*×Ú±,¿þâbsfÜ&­¼û[›…ÀŒŒ0Qäb˜GÇ…ê3fµ"ñ±»Tzþ?.-gð÷E¨,ÿÛq¢6à:ñ¹Ò¼¸Dø¢`=<¢6l™XœÜ¶-cýö+\6C,` ­6Ý},°ÐR/CÇõž–ä¡õ‹ð6„¦EÐг¸žCV>mðN1`-dnC LOêô?Û-“?]CÎøY.í"n"5,à ‘)…8‡)–e7[ %7ö -´°%™s5lQœòrYx³–èZ,–"¾p¹ › ?¦¯9~œ9ƒË!`€Ýç¨R9r@ø:ÇìüšŽMö½®æ4~@K`^!ÌAòl)±ôÊOmw¸³L¼8³h®œ@/ªokÆÄ“›öš÷*ÖÜBÝ6àÚúW ’¹é8ag*Ƙ°³Y̸9ëÖìA,gêŒaa÷Nóч—Kê´ y -cÐ1ŠˆÙ›Gù6¤¾ýôf )J²ý»€'Ú^çÑNï»a‡ÒÔ@©õ=-› -[w®ÌÞ‹I `3¢&"ÚBSݨ±SñšÈiHÅÜ—h#ScÞɦږŶšƒ> ¦Ðm›ah†Îq%‚«ÂqUHnÈoÆî†K5%‰»ø&èb'l1´}`‹)Í4ÙàÅʘÐá H´Ý®{½Þ-?ZÄ>†Ó(ï³¼i,‹¯Ù ®Æ±Å%fH1ë̾)d4lcˆœKgËÂËY€xaÁëOt›uê¥K{™W­ú­Æ„mˆû¢}êuB¹OIé”/j®ñŒg/ò$ÄYú«2ÔΗêSh‘úP1eæŠÞî‹Ãv'¨©ÀœFMâØŒ¾µÚœ ò¿˜z` r~™plT¯²=÷¢€çù1ëýG°43ö"–ê€etÉËÀPøAþ×V`–wK³ÞÿeÞV—} -€½æºW!Xá³)CÎKÛfœÓ0`•Ô#¨R‰Ž»¢ñ&4RB‡.lø¡ì±71ï jæ‹*xÞ„¶²“òxüíÕW{6Ý®|µ'\DŽâ¦{ÖUþ•1$Ÿ÷ÝÐÛ]½«|¤p“ÇÛh»®GLÄ3‘-kÓn…¦uPäíño©ìŠT)Öðk91ЦÐpî…)ˆ² ¯tóÂ,Vr[*6.Àck*ä?šÙQøÓ`ûúY\X­­^yµÔÐh\´èú£ºÃØØ´šì&–#þpÐÀ¥XVš†zßè=*¤ÊàÅ¡~ /ØœÖC"](¸þÉ¿ÉF¾Z,á°_ +9ŒZg÷¢VÃÒØ4}g\5(ÿ¿¤oP;€Äú6IùŒ›)¼zDôHYr³_ƒ›) -é;¨ÏQ¦ÓÉZ63ëôîÙE ®Ö†°)krA²…Clóýü"¹œ–S" -Ùl­,ðµòfÛ„2à„oi5qõkUtŽáS²Ù„[2FÒüðØÞ¶cìßuÏš|È3¾ÖŸ - #S7©cÁÚHG°[ »šþiáÇ.ãØMï2ùùÔ>uë8Lt¼È}T€cÓS¹:kyh¡Íå”y•áQÀàNÝî”îa¯֒À€lb©`æ«Ö¾z­dè \Õýä/vZÎ1²þÎC|ÊsÇlÑâ+©'!þu"Ù,Žïë—XeN÷2`8²P-’YwÒRêU/hÚá´¿Õ‚˜çË,ï›¾ÑæTÜÚ¶ýöÔŽ¡A¼ä>Fé‰S‹e(´áxÄ £ñéE6ªo×­s‡ö}_!ôNû½@Á5þFã@Ñ—Õb§ôwÝ)y'xsvä“ã~óD¾d³ÌÍaùB¯W¹"ÃV-f”IÿÕ›záUyÁ¸”áÒŸerYŠ<Á˜jŠÉC²á–0Ÿ8;íØG–Yk,1)ÝžºÝS¸u K…Tò`Sµ! iþzA¬ËW)™Y!!¢åßgÙ`I“&³.ªÚlv§…‡C -SM™tè|,ç1=€î¥jù+õÖ!¹$—°¡Ú-sYH‹P‹) -=€ò‘\™ª²Yfy6}†ÔmZUùl_™föRþ,ä‹çc\,Jp#´ÝYãÛÀ1™Ë’ˆƒ†Ç!Ü/X2;?Å1çÎxR‚äPŒfw]—×V)‡Wy3öZ.&ã1ôVßTÚŽˆTãä˜È‚—<¬BnûòsY¸Q(â´(åÞѱs‡F©dÍ\n&«zPgÙ¦i²ŠI-üʲËSó¢§²IF|ätn>¸`óL´Ûô\2ŽÆ¯s­j ìlºìÒuÌ¢„F*Ç8;p¼áٽࢠí^.›ü"ÀÖ('Æ™ŽÇÚèœÕ¾¥A]YÐ5‡i„T `‘“×^ -çÙ¤}Š•öu”µ,v\bß¡㑜 Êøœr_æ# -jÆa“÷YÄâ‚åK5y¯ž?2_ÒÃúâBŽíL>»0ÌÈ÷Ùв2”TÚ´,äöûS­]*ûZûžðÀúï7ÉWï”M2MJÿy9Åâyû‚.ñî¸ýž©$†ƒ»®Ü3°ÁǼ™²°4ëAÀ3í2‡ÆxÊKhŒùx6tª3|ûæöå#‰!XPq-c¥Å_ïÌ[ -Rì)?¶ÛGTà ØÄçØÍ;¥1Q[Õ=;mts9CºŠ<ÓxÇi_ˆ>ô9xqy$ìò¢ ä ¯4r¨wìfcƒé[ßqó=Pm•ï"c’Oì«G±íªôÅÌ܈—ç’×™ ãÛ+Jç–X´ÞÍdZºÐޤ© m¿G·¹F¼å¢•P£êØhN^O;jòé,ln—Ïf‚wÍìÌtðËcÇ#–Q…*çF<÷-¤쵊…ýkÎAro”äå‚0{ªlõ¹ØÀ2'FB'`,ú¯[ -Mb 7,¤ÿû!t™M½—Á®*L¸iWý^jôÚat¦ßQ8ZêÌÍDG-;FtÔæZø˜•’?•‹Þ•Zí† Ïâ×ÇÂÄÝT>.‰pV1Ì”É*—a«Ò¶2Ÿ:0½à¤:¨lh³*%ÔºA[ïæ¢r`Ùýа5I{©ž Tmdžø9 -mQFëæ¬ëLusWÄî íªšbë4²î%> cŒeS¶Dí 8iHc˜–C"‰]:ˆm˜ùL1‘ÕãeìøðÁhC3ˆvø, Î:Õ/ÞXd¤Iÿ¦-¹6µåÇ|±³15kÜG}1«c>ñ­¥—iwšG÷S&óZ{›mr× Çvlôn¡¾‰ç\Cq˜GyWYö, ¦* ÖV« -Ã?Š˜Šì'ÄÄ#>È£h>ۼ纽åÚgö†ë¹¢Ð9˜©èÉ£œýñùR{yˆjÖð,–Ä_ ë•gÉ#4¼¡'7¶ÿ³$v뱜ÿ©èG>×­š2¦rJkÙ!¤Y,Ë3Óü!ј—ÿˆÎÄU?¹tVQ×%»Œ½Tyåbê7gÎþ¬è¨Ï‚,m 'ÕÔ”’.¨ºàL> £Ã'Ãã¡8ŠTrïBS6*Ÿ±wÚóˆmèv6Þ/’2x¡dRfëµYì€V¡k-Œ–JÏ}ÙîC\´Ð°eg>;Àdìy‘Ü0U¨ >³a™!ÅfT 9+K—û M -VÏB…¼ ÑŸâN½7—y ÖÞxúU³csɆG$˜•ÏåJìÍ/3÷ÚÅ"ˆ˜> -DãvË…‚<4јΛ|Ø€`íܾÀyæl\[æ> kû¶¼kGàšSiø%MB!‰MB¬™kŸñ Ë_´·Å_È•²þrž ]Õdª>Í™0— ê^þ÷Æ‹*_M˜ÿñ„nãgÃëx” îè«é r‘ÇCH»µÉ4‡¨þ´Šp¹ÅïŠiLèÛÍŠêÍØ[é[(¨¯¿üû˜ý쬆Êüê§ì:{ÑÖ5“ü§Ð†NåùùysÜuÃöŠ4Y^EÚ¦ëÑ'ãxˆ¹¸º©\…³¤¿«'MƒQGó438Å€­ŸünwÚ³cAX–â÷ð€©°%_ Nṯ¯eóûM–¦…É´Mé×ï?ùW)Ý» -endstream endobj 7 0 obj<> endobj 8 0 obj<>/XObject<>/ProcSet[/PDF/Text/ImageC]/ExtGState<>>> endobj 9 0 obj<>stream -hÞœZÉrãF½ë+t™pF„QPð­7íðÒ¶¾´ú’ 7Ð(ZމùŒùÞÉ—YÅÅ-M8&Ñ µdåòòeB_üóV]oÆ«×wW_|•_«ë»õ•OË<7×ýO3gܵ*ò´4>¿¾Û^e$M7ÕCµœš¾gs£UZ&‹z:Ôu‡Ÿ6uÉ×ßãr©Iî“ÙÇ»oé`eäd¥R–ö½{{• ³»_ñRËËÔ¹L…Wÿ¯²°.ÍH¾ð. ïTXfËÒ…W_^.£Ã\^VÞåŸïø!¹Ä:-’Ûýn×ÖÛº›ªá 7*R›|ÕlöC_&õÉ­}}?»á‹Í]¸4æz®Rå}!›-ûnÝ Û¦ÛÌæÚ*RIß-i¹6Ž–W›ªéð#Oódz¨&<z–Ñ"é÷, ­‡j[úá¿¡ÝP¯Ö>oTËåžÌÑÔ#Ës÷w:¾Q-é¿ë'1EžTÓt™ñ¡®Œ–4J¢Žõoûšå3ÊCÖ5ž -zšj1q‘tûí‚Wñ§)뺚H5c_Ý6Û¦­†öéæ$Ðz?ÐV´Úæ9­©Ÿênä+XW’F°u¢Ž³2Üö«ºÅ•,žð¾ û4ݲ݇¥¹ ÂÊÒŸx5¿­›/ª±^ÎÞÔ.A“5Lêe¹ÉuÒÖu _Í‹T‘®û-=“D:ùà²<‡6î‡ø´Ý·SóX M5…=óäëfµb×'¡óäûjøÔ?žNÿ—"Í-9‹N–tN5ÁØ6ÃÆ‰¶åWA'«§?â§§Ÿ"”ÍJz&¼ûáÍoßÉ€¡¹æãé¬U³bu‘ØìÐÜØlºfÝ,«nj¡DºF™4ÛÝÐ?ÖòóÒ¥0b¢S±Ö-ø,ŠÉ%èöêÅ(ÎíóQœ–eùÄp¡âªBÿ)†­³ªn…—síRE÷¸ ÉU5qdä3gA1>ô‡î~–F¼º«>±1 ¦T2õ›~{#Ábá#‡INÖ O"wãNMGJ¿ ×*6ÞùäÍë÷çáIrÎFô1R:m%dƾբųÉè|þ?GÌ®eÐpÚ“ m³y`ƒ:$EŽ!ËáMt.æ\ÀeÃ0‹ãÄ‚ú(‹8s@„HÄ ·?¼ÂPFÖê]‹«…Y†dœšnpz¾6p×q¿ÙÔã$°çèVÒ6Ay²çtèeœ\´žÎ”9óL#²à·¥ß„T“è „êvÕ05U %Ä÷ÛsàÎ3h¦éÖý° ²cž î6Øà[üÚ7'†.S&Ëj V7<Ô˜ÆXÇa{ÓÚâ,Š %ZB°Ðåss. ðЬ,)^rŸZc9Û~HîH)9ùÙÐï7ØNpÐØŒ]µOcŸ³Š-óXW `F°|»˜Í=é½éª˜  Ã+ÊZi%ñÐŒ´¢2º ãtZ3›Ã.ë`sÚD—0àC5,ú¡‘%Eó— -¨Ø³ÁKhæÓ>Ä -á-bìJjcSœÄÉ*XœjA—G®Ý#lÈS½ø Ý›Üòèƒt8Ò#8B„ጢó òaærzOæ#XS¢ó¯k -Žg²².,{˜e¬Ü’4È3 /oV4‘$‘i!Ua’O¾«Æ™¢Ä -Ÿ¦T¢¡Å™ÂÕa9˜£‘„,9ìÅñT€@@ŠlÞ=DTnÉË›™¢‡;z -! ¥€¸"%ß1ô€ŸÍ8ײår°¢-m®6SHÌØl‰8ÑîJpÒxP‚-=ŒF?:HO±Þ>ý1S`"@œÌÁQxªÂ=±3"êô–’ D@%V$ʲYhzØô,]-ã*`cÍÑh!ÚØ@Çã8Š’Øº©q”¡Õ4#¿Ô:‡’B–Æ Ž±„[$j/>EN7â›¶št¼XàRžÈnð¹Ä÷ÉWŒaª¶\bH'Ð&ëuÉT ´‡ <à/¦)x‹›¹•D1 *僆y9b›Û‘ëʾdCámðW-î–‘ºü¦Ç+lkÞ“LÃ<3î3!ÌáJëç\ÁåyW0Z`PËsH0É¢’XÍý–I½d÷.hæsÕcÅ$mV ¬bxΑ×ÌÚ²å1:oιÒZ$~Åñ$ÝĘüU»Ý ŽÑ“àPrD&S¼%ò«f^´8²Üú hm!;=U`óMÝsxÔ"É44ÐKšàa!2Ü„ô0±B)ª›Nð‚IŒ‡Ó7,—Jvý(‘‰{+á8ª8G;ã)÷í^¡ 6ô Ib=8=Ì »–¿Œ)´%$€9fåuÈ - Ç;Ü¢á <™Ÿõ4ÍX=R,‘ æä4B^2ˆòÁ:l©“P¯Ê(ï²ò3˜t"®'×TÌÎñŠE_Õ;#tZñ| u­$`Õ2`Pä žjv+böeDƒwwW¿]YhÇjNPTm§%UÜ\‚ÛkàÊÜõr{õÅ7[uý¶¿úIŠ÷À¯i¯"“¥á1ïsJo^R[,Z-Wu*Ånt»|¨A‰–RcX$W²ˆ$…À‘5ZuLç–£Ÿ Ó?ËP#5ª˜—+U«A)8‡Y2P’^r`ø”Y‘6q9Â1±ë\*rÉsà¼lR°ñ©ò¼`[.™Ïb)qŸ¼ºŸqUÇá^D<Ž.T‘Ø[*/§¡âĉèDI¤ -rѵü(ƒ6²âB¦ô\E†ŠúÎ2acôy¢1胰ûX)5¡¶™Ô[wýÏ7²ž2v»¯ãÁtRMbiË âŒUÔ#ù©eÚ¨$ÌÞ£dÂh3XòX×yÑ3i–±¬[_–ad›Â—ìváÑ0(“—Äg)®¼+àw‰Â²Ï}Ô’—[¸k. -bd˜|ΰ± -¤¤*ÇÓ…¶Ó‡$Mg(Ï£O!¢Ña27¨âfþX6fæü*Ÿ_€ -âåâlc^Œ60P•]Þäñd“ .OÂÔ(¿•ª4—ž·ªUÃà` -Ãl»ml ‰ÈåTu›¶alS0õPGþmOT +rsÉwì¡FÒb`¥ŒD^ÑOܸ)l(ï䈊ћöRÂlòi!8ýîÒ$·SäÕhù‰pÈ^Ìox^#™ýîöVv†WIA]cï8Ey},˜%T -ÃÂìö!ÏÛX {”»äÈCó{LL -x?WëgiÂæ{Ÿ,úiâîwDÖúsœh, -g=4èáI)ý=,AiSûAv—tò’V Hº8‘éøé' -Æ.”{Ÿ¼fgÉ@—Þ Þçè3î%×1tÍ•_É}vˆ•´ÀÐqØÏ2Ø>ÿþöl‹¯BM>Âd(§Öû.~Å)‹øE%Ó¢Ø8ê;­†æxËTaWbrRÇÚœlûÍ ÁŽ´”™¿Øeʪ¿îÈvEiòk¸qŒw°F!mæH´ŽôÚË|aË¢Œùâ~õì[ÉPœ%T¨ÖE¤6ÌÙñFùåDë(äÄ¿‚Öj!sªž48Ù…‘ÓM Ö±<ÙøX裸ËHW࢕ëÕ†Â5ŦœXÑÊãvä†ý ^âv %œ— -ã†OEЀ¸ßDÚ÷0yl³Ýoe¹“ø ú=¼) -ÆósVCuè„u˜³3WÕø ²¸p(wxJ4l_Eâ@£’‡[Xž›'4íÔTÄ\8&+‰Ô“ &! xd|0Œ0Â}G‰D}Ž@…:Fh¨Ï¾þd:Þ}Š\©è>áS¥FYlWDำp„|ò“Ö<Ê·æ1„¸b&ø¹`«DŸThcˆoŠ -iŒ×m*‡ùHTÔ%#„2¼|ÐÊ;!óñs{)º¹).Xl¤3™„ZËÅ%ò~F¨†pÇâ¼ú€ÊÏ@Ÿï×Ö¤›U*& ¤úÃ~ò^´$ -E™Nn2îGÑù ÀÌiü¯s°+Å•—¢½Ž½ Ùßq7šžtï|,ðÆXãóØEìÛ¾Ÿd¹âæ[Ëê崴‡èé)6ëF[€ÕB¼]ÛO©¼Sò)WޔϹ”Ðt<G\É|s$™Üëëeß­æÜ°V|ÍÙŸVHÓŒ¹ïø¸B.ßY,€ÿñëâçèo‰+MÚd”ûJFñD¿P¡ƒ‡¾Öš¤ô>|!¹GwÉæy$|¶ Þóè¬&ÃfäÞåtþ²™[÷ÌéL&Þβ„]Õq©Ö­BqM€V^Â=KÄõþgÌW#§‘64Íδ9ÉC€ä^ª÷©Žõø^¤ñ&“&Á?.‘Ê‘ò"Rëäž¹À;f þÇ QJÅÿ|ƒcÚ„˜.Tò¾®†‘gæJ€©1•k.<ëõºYrA!âÇP”É(Ck™h% Ä/M§ÏÔØö,þþ\®ÜH=§¤~fÈe/ˆð”£ñ‹·xóßós˜nF‚K&ðê‚à&‹†"bꇋö!ÚRÄ6ÞÓŸþÂàÄ+â_øÓõDLøý%:HÅ$]é,V}ó%)SQ53㯜_üÚjÓÝrѤ<è:MÉ ‘(¾”¥-m¯zžÎç­~âÍ„ ¯¤¿‰ÅVpD -™ÓßÒŸò½S£øó9†þÈw"·óxàM‡"žøþ»oå3Q‘¼é·»PÝs¢×@æ× aßÖÁ4ä_øF‡û‡”°n\Š#ÑÒÍLû„¤Œd`gó2/‘]¿­º}øÓ(@“&R‰ïy aÇ éÛý]GžF“¿*òËÌö›qä¦f‰†’’eê´¾V¢âØ0ÿ¯¹ à -endstream endobj 10 0 obj<> endobj 11 0 obj<>stream -hÞTP»nÃ0 ÜõStmt4¼äxèµ›]‘hW@M ´<øï+)N‚ <€GîH¹o-Ùò‹î0À`É0ÎnapÁÑ”«ÃÖeÔ“ò £¸[ç€SKƒƒºò;çÀ+ìNåÛkñò“ ²¥v}ùsŽD·xÿ‡R€š Bîß•ÿP‚̺Ù¯¡Ê}¹Y;ƒ³WYшPWØ\É<ÏnŠË ‹ëfQTÇFÄÝMªtÌ=^˜c¸|qŽÌ-áý)Þùä•Jü 0fdi` -endstream endobj 12 0 obj<>stream -hÞbd`ad`ddò ðò ðÑvL) 0q6q5µ‰ŠþæËùÝ÷«ægëyþ+‚Ýßy…@ÜHꀀ‘Ÿ™‘‘IH‹ïû¢ï³¾ÿmXñ»Ärj.+ˆr@tEñâ¼¼ââ¼¼ÅÅ+V,^¼BŽ ÀªÅ'c -endstream endobj 13 0 obj<> endobj 14 0 obj<>stream -hÞìÛO«+ÇÁ'àûÄlf˜Í+È:AÙ½Œ ÖÖÆzg6Yi“¥ !Ûƒ÷?€£p Z_o´t6ƒ áÞ…!Èp `4' ƒÁp¦¸‹vWÿÓ¿sԭ硸Ü#u—ZUÝ­î_U?>p6»ÝîEƒétª}ÆêîîîÅ æo-—Ëõz½ßïµ'À¥…K¯–˳ív«‰FéÄ<¿"Ü]Jõ.'ÏóÉdÒ~=¦•Fé¼y~n0×뵆¸„p¡Õy=–繆Ÿ³çù‘>À%ÌçóÎ+±,Ë4Àø\(϶ۭæ8£ý~ßç2l:j+€ñ¹\žïFà¼V«•™7«)ÏŸN§ó.7’ëõZ œK¸Bë™ç/—KÍ02My~x½ÏêÛív6›5ÝH. - p›Íæ ‡%ó<×hcrbž„[ŦH:ja€³X,µW\MWbY–i4€19=Ïl-¦…N—çyíµÖd2Ùï÷fVÜ‚³äù<àr²,«½ÖZ­Váݦ)úÛíVÓŒÆEóüÉd¢…N×”Øïv»ðîz½®}w¹\j:€Ñ8Kžn$k+Y,ZàDM×ZÓé´X Ïó¦‡%Ã[`Î’ç/—ËÚJÖëµ8QÓµV–e-À žç7Õ'ŒpŠÉdR{¹µßïã2ÛíÖ%À¸5¥ñËårÛj½^¯V«p‡Øôp÷f³Ñ¼' -]µ×Zóù¼²dÓ…Y¸rÓŒ#ДçŸh¹\j[€ÓÍçóÚË­õz]Y²ež†fKäù¡N pºý~ßtÅ•çù) 08çÍó'“I:U €ã:å¾i2–e`è.1?±Xì÷{m p¢étZ{¹µÙlj—_¯×µË‡z4&ÀÐ]"Ï7 àtÛí¶é‰È¦Uò<ïÖ®jÓ¤ƒv¹¿kn$Ã2³Ù¬=Òoz€yž7]_ív»–›fõ¡N 0\My~ÿ©õáÆ0,Üôd÷t:ÕȇZ¯×gv2Ô©a†ëô<¿°ÛíÜ9œKçSGujX€á:WžßRÕb±ÐÎýµÌ”8Q¨Yó Ôóüý~_[Õt:ÕÎý­V« åùËåRó Ôóü éÎQ;ô7™L.”燚ó<×ÂC$ϸ*ëõúÅ%…ú52À1Ïßívò|€-‹Ú ªét:?DX¾¶žÙl¦‘†èŒy~Ó½g¸ÔÎ}ì÷û¦ ›Íæ ªZæZ„·45Ààœ+Ïϲ¬é†qµZig€>š®©&“ɵ5MÑ_.—š`pNÌó·Ûíz½žÏç/š™ÐÓyø–Ñ<ϵ6À°4åùç2ŸÏ52@Ûíö¼$ò@OËå²ö‚j:]çb±¨­s6›ip€a¹hž*×Â}äy>™LÎ~MµÙlÌ»‡ËåùËåRóô´^¯›.«öûý)57 ¸Z–Käùáž1Ë2m Ðßl6«½² -¯ŸXójµjºfËó\Ë ÅyóüpWnOœBpkò<Ÿ7Øl6'V¾Ûíš*ßn·`(Öëõü«Õêî­,Ë­¢ö §‡‡Wîó,ûòåKí×ìÍë׿úégŸ|ª)àš½÷λ¿úé‡ïðæõk­WÎ5cuÿÕ«WÚ€ýâ‹_ýÇ´(ŸgÙÃÃ6«õáûx f¬Þ{çÝpÖ4¹¿¿y~(ï½ó®9¢pµ¾|ù²x &¹Zcd>ϲй¿ûècãª4ùÝG—#ý"PúÛ×_k¸6ÅAúÛ_ÿæ¯_|¡AÆ$Ž®†ÎýòåK @ª˜ñ›©>\¡?þþñ ýðýÞ¼~­MF#thù ì) €‘ùêÕ«ß}ôq,ŸgÙ¡å³O>­Íó¥úp!á ‹Çì¡3±Ã!_9Hÿò§? ~¯Ä›×¯Ë'äCWOGWîòðð aÆáó,kIãÏU>|ÿƒCSG Éï>ú8\á>tõßþú7•#4¼êü>»¿}ýu¹_]=ô`zúÕ¹£ñ4y~Œ•L…Ó˜çÿåOn:B¿ÏëÄ\ÔEóüPù—/_jägqézïwÃZùÓŸ4&‚Á‘ç•2-ÄG08òü±rB …øGž?VNÈ´ÁàÈóÇÊ €â#yþX9!ÐB|ƒ#Ï+'dZˆ`päùcå„ @ ñ Ž<¬œ®ÄÝÝÝ‹·¶Ûíõl•øèP¡ûŠ~ ª5xòü±rBnÙ~¿ß6Ëó¼iÅÍfs÷Öz½•t~Ðn·+–ϲ,ü¿vyþÑBOµôcKõé—Ê–,Viê&y>ÏNž?Vò|à–ŽVm`»Ùl¦ÓieÉÕjÕô»Ýn>ŸW–¯¤ƒòü£Å½Vm®Þ¿_ -áõårYY>ì é(€<Ÿg'Ï+y>pËÒD·=Ï_¯×åì7˜L&ÅŸËå2­·ÛÅf³YX>Ž„?+ѱ<ÿhíã2i®~P¿<¾ óÃë1ÃËÇ?C=•H_žÏ³“ç•<¸eEžß3wÝív1òÝï÷Å‹å¤w½^——o)ñd2)Gôqšwe@ž´¢éBoöYøÐ~ ‹EñVVŠFãàN¨­¼°<Ÿg'Ï+y>pËŠÜu³ÙôY8Næ¯ÌÇÎó¼˜ì]Éuc>Ÿ%yZ¬*Ž <Êóëõ:´I¹‰Ú»fµZõ©öÐ~‰ùüb±hªª<”#ÏçÙÉóÇJžܬ<Ïûççûý¾iòv°Z­Ò¨¿˜^ ù ›Í&”kóüíÏúja3еÂw<±•ž1>*Òõ>ß½xD¢g~~h¿ÄyûéÈBÜ…ÊQmž\„O,Öê3¨‘<¬äùÀÍŠ¹kŸ…³,k™ÌŸF¸»Ý®x¥iÒxñî|>¯”óü<ÏÊŴÿBøX MƒãGo…eÊk§¤úƒÈóûËÑ/E{Îf³–,ïE•!ì9ÅB¹Gjóùòþ­¬>¨ò`4‘ç•<¸Yëõºižvj±X”cóT%nÏÿërà˜ç‡UŠ ç©ðzebzܲÖd29: -¾þ:Ñgû¡ýÒ™ÿ§OU”óü8·¿Ot®„Ö‘K'yþXÉó€›U$±“ÉdþÖb±¯4åÞEÌnª­˜Mgqǘ·©Â˜ÙÆ|>®RTUž¿Ùlâ¬ûJ°Óã"Ìß"ÆÚá£c:Ý4½¼Óõçù±æ? M××Ú/±ò¬!-F…Êq•¢+=Ç\Ò)÷cø7~ñ°zèô8ÐgØ‚'Ï+y>Àà„ÛÀí/¥ÚpǺMq·ê wµáF8¦ñþ:܇6ÝY× -ŸnœÃ-pyªa¹´„-íMV «Ç<$V¶Íì•¡i2êYv¶güŽa»ûY9l9ñ@†¢itøihš;§ß§*óºÓé÷é¼îøJí4ìp:Š?aåSSLƒðÒŠ¿¤ÇMí¾þäùc%ÏœKäù-3Øû$ÛMÉl6+f/—ŸyoÏáËSéÊâDè¦í,ϻ묭¼m§¤ã6Ö Ô)y~LMÓ¸eît1\~bŠ?ãÏPíÔciÐ9ÏóÊ*-gÝ4Žî“÷©¹Épóüø8C¹×í—Ø¼MóÂë•YG÷Hgžß§fx”ç—<`p.‘ç7MW.¢Î2ôߤÅbQ¹GÞívéb•H$|Pšü‡ÛÕÊ„›åtƒÓq‡Ú‡BýY–•+ ÿ·áµ#1ݽMcÍóÓOO;:ìw%éw—çÃ-H“ÕÎyÝ•U:#ô´Â[Îó[¾ì)¿AG4re•ÎæM+”çóìäùc%Ïœ³çùiî] ·›f£Ei˜ßãËQj´f wiòþìü¬°LSD¿ßïÓ1‚–»é[p;yþ釡PF)ýQ‹lí¯Iü=ç„xÂiú9+~ËÊ?7}R÷b­øÀc¿Œ7|‘£Oz#ÈóË× GôKûNÚ¶õHyšAçHØæ³ÿ.3Jòü±’ç ÎÙóüøPy ½ã fg>ÿX—޶Ü`¦cåÁ‚bôùjñ~6*?þè|ûÚùü•§ Ú…ûñmIü¸PIøjóŸ…ÿWª-žQ,°Z­6›MŸO õ„Ãò±òPIh™þO´lÛAÝV ûIQIøOø³eú'êEË”¿`gåíûjî9±Ëb¢ê/wel“ðŸâ•ÙlVy<¤ÒéÀÐ¥á|ùÅp^JW©âÓì=ª|c%MQsí6ĪZ~²[¶¤Ó óü4œ?¢_j³÷BœcPþˆ£{¤i–BŸ-2yþXÉóçìy~e¢ûr¹\¯×•h¹gL³Ùö,zþKíy~Ëçîv»JUå(5­*|¯Î¦¨ m:ïºÒÅ}ýjµzQ'~ñðŸJÄÕ[¾þ~¿O·¶²z{ú*oª¡ÈˆúäùE/4mÃl6«]«Ož6¯©é -Óé´ç¨Gô¢KÜÚ¦é÷é~噫˜šVÆéЇ¹Ây»rŠo…˯Ç3mz>ŒQäç™J=éZå -ËçÕÚÅXíqÏ 7Ïc¸•ñ‘Cû%^¥ ?¢|ISî‘Ú¹q­J…í(ÆjýÜÐIž?Vò|€Á9ož¿ÙlÒ4>Ïó–Yôi6{ô=f–;Ô¶RŸ‰Óéýƒ¾Kšç·'Ò¡©Ó¡“J^é‡í¬h5¨ÕVf˜§Ãy~ûÆ·lCgžß¹y ÓDò| "œNk³ÖxLO2ñÔWy+®R9éÅçÅ*§ô¦zÊç™ðVåW ¾[9۔ϫáƒ*_*~V: ÑÓ•çùÅóqéëñ‹§ƒ#‡öËci(§|E‘+ÑÞ#ñÝ´GâZá­Ê—*ÿúŸòÀ7Bž?Vò|€Á9ož_‰mãóÝqrZçÓâu1i¸«Í²¬6$i‘ƼEdn®ÍÒíé¹bq·~\óV¶¿3rO?«iª|Yÿ0¿%Òo™Tß™uz†ùµÛЙç´y-ƒM;ª<n\ñ#8›ÍÂÉöî­ðŸxŽmT§ˆp/ÖŠ¯Ôžâ©#Ô\|PüñMãÜbáðÑÅqøˆ¸mq 3¬Õ”ÇeÂGT¶íE×t-®<Ï/~’B[ÅoÄÙJ\¿<þòÇ«ø òÞRÙ¸pñ)a±¸måK¬´Gâ®UÔ¾~±Vù‚-½6€”<¬äùƒsÆÀàœ1ÏOoùã i|=Êšojsì–l¿e“:ç?—ãÓ¦Ûít{úßü¦Ðÿ‘öôs+Ï5Ôå†Íó<Í«ËADÚei|”~J¦)¤QI¡ÓĻҕVJ§>¦ÛYžLØžçW>=‹I¿`Ӟг›:²tÿé\Šp)†\ço…ÿô|¾,œLÂùªX+œâ:,Ba±bù°bÓð_1nß –×jú -çù•Ï -ßèˆÇÜ*ž1> -_omiÞÐq±GÚ¯Žè—(´dø òÞRÛ¶¡Úbœ·ügŸ)ÿö•?+8âÉGn™<¬äùƒsÆ<¿2ñ¯2¼’ú†?[ªª Ø$|P¸«mº“­ “›L§ÓôÖûzòü4I¨ÌµKç–§-YÞ€J§„Õk›1ÒKGj*i!¥_ތʷ¨M?ÒÌ¿¥¡ZöðÚ¾«l^vÈ]ª<ŸJžvâ£'Ó4– ‡’ç•2Ààœ+ÏÏó¼=×MgA·Ï -Ûn·iÜÅ7Mœ ]ûŒyËtýr¬}=y~g÷•g­7U7 ÿC¡a›fà÷œÜž.7£Rye(J·6~ÐAy~¨?Ǫږ4_QžœÅß¾þúó,+Ê—/_>ïÆÈó{ -={-|©+ÜBy>ç"Ï+y>Ààœ+ÏOço6›òýÓã²ív»\.{û“ɤi–~±…‹Å¢g°_¾óPžŸnXKž:¨O_¨´[8ÿé³ÿ¤#M›úú®AÓÖÞPéŠñ ‘°ña¯hùÖOÖMò|àó,‹qÊï>úøy7FžßÓõ'œò|ngoç8ò|€Á9Wž?›Í:gYW–™N¸bÜívëõº3Û¯<Pk»ÝfYÖ™íÇ)èéHDX·çf‡%z*¡²ÍóÓ »ÿ~“¦×Sý7£§øeÛ*Ïó>ƒ8¡§*#POÙMò|@ž?Dò|n‡<¬äùƒs–O.¤­7#´aå­PgZCøÄÊqZ*}«v¸!ýOÜMò|@ž?DNn‡½}¬äùƒS´ö£ìJ&\NÔkµÏ…NÓѰ@S¤^oÉÌÓ:lj:Cûñm¤¼\.+ ¯V«ö +>.#Øï÷iø_ Òûx‚íÙÞPµV´mOÐMM‡aùQ`ÜäùC$áävØÛÇJž08'æùiÛ'¸®¬þ¬,pD¤ß”™é·Ì¥?"Ò?.Ì|ª<ÿ &jj™Îþ -Ö¹=#ýétZyt¢³¡ÚÒ‹'è¦,ËäùpãäùC$áävØÛÇJž08§äùéÔît†|­4¹ UU–Ùï÷ý·- H˦N§Ó>õL&“tKRi:}܆µ{²<ÿñí,ýö& --Óþ]Z"ý"!ï¹íãaKGú4TgÍÅwì|ºäBÝÔ4N$χÛ!Ï" '·ÃÞ>Vò|€ÁY¯×wGÙï÷›Í¦òbmH› -‹UVlJÑw»Ýjµjš^ϲ¬2[»IøˆårÙ”Z/‹Ðý'Ò‡%ÃG78´aMÂê•Vêì¾´ýÓJZ¶*ÔÚ¡ÜÚ¡¹Âw ߥOË„eBýqõÉdj‹›tèf”{*lCØ ÂÎptC›jû@ew -Úûg隸‹†¯9/9ôa`¸äùC$áävØÛÇJžÀåìv»íÏš¢Ýž¶%'¦îçÝ0n“<ˆ$œÜ{ûXÉó€èþþþó,‹¥çbåòåË—Mkýíë¯›Ö -o5­Õ´J(a3ݼs•rVöÞ;ïž½þÐ ×SþúÅåøèª¶í òáûÄoñ—?ýy(›ýððàÔÄ¡äùc%Ï¢žAAe±ri™¬^žÓ^)-qSÓ*E°|èæ)ÊÍ–¦c³åxi:0[Žeå¢=Ø¿üö׿)9´®rÍ¥<.Y¤Ê—/_¾|®aåûûû¦Ušf\?:µåÍë×M«„·šÖjZ¥²m®ð€±’ç+Š<_ž¯(Š¢t^n÷º®å²üÀQ¥ô¼æt…ŒÕEóüÏ>ùTž¯(ò|EQEž/Ï8ÝEóü–Û1y¾¢ÈóEQyþAM«Èó€1¬<ÿáááÐÍSy~ÿãEž¯(Š¢Èó®Ö°òü#6OQäùýy¾¢(Š"ϸZò|E‘çËóEQy>Àõ{óúu¸iŠ¥çbåòÙ'Ÿ6­ÞjZëË—/+ o6›»»»ívÛ´Êq›7”"=PäùŠ¢(Š<ÿQžpõÖëõ‹Ÿm6 Â-{óúõß¾þúôê©­ÿáá¡i•ûûûÚUÂëgÙ$¥ùêիϳLQŠ2ô1kåŒå½wÞ•çwn›k €‹úß~øß&“¢ü×bqhÐÑBgÔ2딉dÀÉóàúÉóàúýßÿú?ÿó¿ÿ¢ü¯ÿüÏß}ôñAåÍë×Ú.m>Ÿ¿øÙÝÝ€+$Ï€ë'Ï€ë'ÏžÑ~ÿãrùÝ‹ÿ¯(áÿáÍ)y>ð\v»&“ob˜_”ðŠHRò|àYl6yæe6{£} Bž<½õú_µI~,«Õ½V€2y>ðIJìûö0¿(›M®­ ’çOi¹ü®O˜ÊdòMžÿ¤Å  ÏžLÿ0¿(óù· €´Ûí¶Ûí~¿/¿(Ïž@žÿ4›½9(Ì/ÊÝÝ?µ5k·Û¥oÕ&öåÓÐ^ž\ÚÑa~Q¶ÛkCèo¿ÿ15¡ìv?hJˬV÷óù·E ÿ¿»ûgKɲtàhEö¾ÝnÓ·jûöwåùÀEív?L§?:Ì%¬žç?iIh±ßÿ¸^ÿk¹ü®r¸ÍçßJõ Yöý‰'¢Í&׌Jž Ån÷ÃdòÍ)ZQ‹hLH¯,û>íGYx׈Øf“Ÿ~"ò¸G烰Ýþû,a~Q²ì{M -=3üJY.¿»ñv;ñ)¡ò,};!‘ç?¯Í&_,þ1ŸÊrùÝ~ÿ£6Ôzý¯žùØlöf·û!PK†Å4,7(üÐÜÝýóÐ ßásÄé¨O }aŸ ?yþ3Z.¿«Ü×O&߸µ‡ŠƒÂü<ÿ)¬þíÌ*ãÂp;V«û³¤Ðóù·7ۆ皜÷ˆ.'Üçn6›»_ -/îv; ”<ÿ¹dÙ÷Mw÷Óéß·Ûk"x¬öj ˱X8ˆ:W •kanǹÂü¢l6ù ¶áy'ç;\BžçY–Íf³­&“Éb±X¯×Z yþ³è„|sö¸qýÃüÚ@¬OzFíÌ-ØïæŽÎ#n6{£µ·íöß—H¡ÃÁuSÏ‘]hr~Q6›ÜŽ -pŠív[žrŸeYí¤µh·Û…ef³Y\Ë,}`äùO)Ïêœ-l$<öŽû<À²Ùäõ¬V÷Úœ»\ÝòtÌÈtNÎï[l_=ô‘à‹Å¢¸Ͳì Ãòq@3×o~šÊc‰òüv‹Å?N‰MÂÍþvûo͈ƒ¥˜Ü:ërù]çñåàb¬²ìûCg݇0¬µÛýðØc,àFŽövè“Æ¯V÷î.§¸ ],G¬»Z­ŠÕÛ§ôŒ<¿EŸD±OY,þ‘ç?iOF¬s"ëdòM‘4öÔçјP§#‹ñ {uØ·ûŒ‡©˜á—u>,3Ÿ;úf¼»ûg{#ô^ìì g!€£m·Ûâ&t³Ù±ú~¿w Ü&y~“õú_g óã-–}¯U«öèìÐ0¿Vé<²n!–äÖtÎ  ì÷?¶WöJÂo܈۰3‡ïêèX.¿³Ó!æùGO°w Ü&y~­ÎÉÇ•ùüÛ#RMžWžÿtw÷ÏÐwE1.Sk:ý{Ëžt£…;«Ð;ÚŸÑèÆ -ÇZŸz:™ õŒxbyg~åû×Ö~~ Å/;Àbž¿^¯XÝü|àfÉóSáÆ¼}^_œ!Ù9‹ò\•yÆa6{SéÄðʈs°#l6yûnJs-ÿè<¬SŒFç¼úp¸õ¬ªój¬cagœœ_è<ÅyPà8ÅMèl6;bÝpëzâô~€’çWäùO3ñBY.¿+–¯Í{oyV䘬×ÿj -…âÀcWä~b[õ9$ÃèF༹qg¬ÞÝï_3žwr~¡sœåˆ:X,Å}høOžçýW̲¬Xq2™hFàÖÈóËòü§>á|X¦²b–}ßgJÿègEŽIçÔVMTØï¼tÌjè<¦FKrk:‡®}%ü6õ›³OÎ/„–ï©·j·ÛÅ[ÑÉd²\.7›MK°–ϲl:ƵŸš¸5òü²åò»>a~íìúýþÇöYÊ'Æ2<™žÃ:fcڧž+ãêœp»ZÝßòî}CÍç߯$3ìÃáEûçh¥£³÷γÙÈNe—˜œ_è¼BȲïíÆ‡Z¯×/êÌ©œáGËåR—sÐóƒOIžu†¡L&ß´çð›MÞ9Á²i’?×`»ýwÏG-ŒÈÚwøõú_ç;Y}Û~lÞÚŽšeßÿöÍ/ÄŽì<ðzôCD*a‡! Å&Æ,¤À;ì—ÆYðîãZ{`½YÖS/Æ »‚Ç ˜fÈ,fm‡‚dÿqÏNU´ØRÆÊÄÓ‰Ù†3šY:Es©ò¢XL¼Ñg§ÜËáγKiÆ|XzÞîKqÏHÖašë´Dg¤Ï èÁ"åÃF ì@ЧÒä|Žt =Ö ‚ -oÓÃá^¨Wƒü²ÒëÂKý ‚ ˆá0‚.ý_‘•-`YSúðÕqœ¬-zÞùü ˜ª¸²|IwREÜ=ÙF¢h¾TÎs隺¥H%aéYª=»dÒ—&õ£ÛûZ4øëûQÁKHË;£¬:9ŸoJ¢Ç:ADKA^ö ‚ ¢‡¸®ÛG<÷Þð wguunÍ4M~›Q%ÿ°, þäû~͵*g/ôÜç+ŠÜÜþVš.‡çé_èfQ—ùЛ$E9¸=ƒV­¿³òÅÝ4$ gåÊ| -EiK=~XåaÔêpX=Éù iü¥”ÀAQ'ð"¬"7~ãÉßþÜK¯fôg/ÿ!‚ :Cžïa²{á©øžoÛ6ûÆ4M×u‡ïD€KC=Oî¹Ï—¾•3-EóÜ—ºøҥ¤âÖá8;Š.Ô4×KO8o5Ð õgƒC±ølêÏÒ”ï(¸ 5Ï£5;>wà°íQ{›±žä|†t£ô) l‚ ˆrñ}õ1ƒÁÞÍK/ñù8ýëO?ÿM8à›G¯Ì?øÙWß~'õ€?µQל>}úÌ™3O=õ™«¶C]I]IèÆ“O>Ùê®ìÀÿžç±{IýçATâŽãÄ„ý°ƒb@¡Ï>_jÚ™,j®Ä¼Ab)¤‚K4]dAÕ§O)' < ·(ŽÉ¬}ï ÛÛÛë999¡¡Øj¨+©+ êÊâ ‡Ã.ù|×uSî ø#ëé_?|+ã8*ç÷ÙçK5»a\)%; g¸j€Ã÷£^5¾Hs,ù±ººGÍöGH‹9ÎNu—vÝ[ŽŽ©,¥äGj¡K‹ ‡w¥Û7ÚØ’u&ç7ÕwA]%Š"ö®-bš&ÓõüE;‰a1ó_Äç_Ü=f®þüÖ~¼<ž">ÿÚGÆææÑýK{÷6'íØ‚½¹¹ÉtÓññ1 ÈVC]Ù666¨+©+›¢c>ŸIï,Ý ÿ„°;õ<¯ñªŠ[U¶"öÖ竸Ü»4á–ÞýkFjc(“! gx»•ÓóêU#3â‡i®«Ÿì8;´ì4H#9Þx$®;\¤!°Šb|5ï­ ‚è*âÛhL×Ã[¶išü7–eÁÉðU¿Ä ‰ŠŠ¾Ÿ>·†q¥‘버Ì6zÈv«`ž´L‘¯kséÇJG*x—Ê¥‡3U6¡´QáöaªÔà íLbyƒÉùŠÓ¶º¸ AD@:KÍÊÀç™l¥¼ƒã>Ÿ |æç/íÝC|þædvq÷XL×'‚ ˆ¶Ð1ŸÏ2LÓ\Í€ÿ³±šMÕ•Œ%ç+¦è÷Óçã&°R¯%5l®{‹ê‚©Jº²º5í!¸¿ª4Vf -®¾ÛÕªž7–ŽÌe‡eÍm{¤®ô¡g)ŒU:èti@¡O¢f“óÒgJëÖ"‚ ˆÚàÆ^c“õ<ùëâqŠ~‰ï°¸Ïçß»ú(cäæÑ}Äç_Ü=ÞœÌÄt}êk‚ ¢-tÌçóç{*­!ü?cFêuñÿpzèó¥£R‘¢â“)¯²i2ÇC9ìðý¨žúÀHƒ¾nWwKZm¡}jRʽHGfî8£J¤@ fÕ6þ{‹t£V=.ÌU·O­DOÎW¬F· AÔ7© öø_µù|Qàßž>€ß >ÿÜèdþÿxíÎ õ5AÑ:æóyz€¶>‰8††aÖ{èóñ ùÒù¤2Ç4×)K¶þ®¯awúWT@†q¥žëG«¬xMv -T}#Åv8¼«É}2-A!ÝÀ_ëi|­¶Ð:$ç3¤‘bx¦ÓÈ'‚HÂïûÈ_uðù€wuŸùùËãG#ç·&ˆÒ?™?? ÃÕÂTZ½¬ä|†ã8YŸí›Ï—ŒrzáÝÞîuÈÏ츈f‡mj¨ €ÔÈB+ü3®­j€¾éàE ¢’?_|] -ÙJs2»¸{̾?{ý€úš ‚h óùšcÛ¶tw@VbCß|¾&úBV¨'²Ðƒ}YþEÌ Œö6c#þéïФÙÚ%î‰í -Q9jsËÐp›<âßÀjìº·à—¾Á¼¨ÓÍV‡tå¯9‘[šâ®s³ã§þð(¾Ѷ;‚ ˆTLÓdï¡A,ûYþ -œã³I¤>ÿòxÊüü…Ñ!üxóè>âó/íÝÛœÌø“=‚ ˆv@>¿‘¦F°,+õã½òùRwQ§ý“æZÖ ïR‚©T™Â µPVV¶Zš‹Ô¼©M%xZ¬þ“oÒ*nA%¶“•zHߤ)뢅ú8Îô;ÜHë<¿tgVý= 'u)øþ!­RY9‚ ˆ.Á-:àºnVZŒ(ŠÇaŸ2M³ÜšdùüÅãœüµ£ÛÓðýÉü!âóÏoMÄ®Ý9¡¾&‚ Zùüz€fxVƒ”T]ß+Ÿ+ôš#£h.u;ôú_O;ÃáûQmUÒMè)¢g*¯´V:oyð¼q#a&•W¬¥Oè8X—ªrØöHÿ Mxì‰ÝEýµ’nºÑ³1ñ0DýÉù üYÓÈ&‚ ý±,Kå¥uñ蟇Ðu]ñíð}¿”j¨øüçnDˆÒO¸<Öú¿”ƒƒƒõõõíííùœžS톺’º’ÐýýýÖueß|~žç9޳òø`0DQTõuyfB*|"'¹±?>Þ£qwT¿<÷ýHê©ô—Tš#Í®¿ëñ*i›¢‡Ã¬6žÝݔٓ†3©Íö¼qEW‡õPejÄZ²¸„ƒ}ËÚ(EãWt¨¹»›Úk€W¬Îmkê©gKRŠ>ADà•9öÒšõNšÜ–oÜeU#‡Ï¿¸{Œøü›G÷oOœßš¬íÌêÜë9>>¦Ùj¨+©+ êÊâôÇçAKà†Q©!‡`øµÇñ}?öOÎâqƒçy<íÁ4ÍX”¡ŸEsÏÛöøFÏ 4ib#ÕÆU¤Îv7FΠ…g‡™:¨¶#WÐMåÄJÓtõL)×VúIãbz®HR^ÃÜ—Åä&¦ÜFÕ°>”•ß"ùÌ.õ š^mCum¬0>¯)EŸ " x…÷YöÒªâóá6™¨V„>s2C|þ¥½{miü›7o2Ý4›ÍÚRgE¢( l[†™çya"Ÿ‚¡5DÁÇ>”QQæg‡»2uA`99G§ÔÐÀöö6ôãÆÆ†JW€„̶m>ÎáG|ï’Ê(Uo‡Ó¤?,Õ•úL®>ø|˜#†aœBKª˜æ0;àÒ0UÅIŸ/ž2Ó4aš‹¿/îóƒ`S4ð£†Y妹®a¯t×€æ ÆÌá#mkÛ£¦’f¥©’pXÖFývEÚé -4i8LçÙ]]–{n JÒlózrŒa­Æ[¯ y†»€›]öE×½¥[w‡w¥’5¯¶éîY輡@Ú׎O‚ ˆ¶†!“T¸ŒÍGŸ2ˆøüó[“µíññqÇ pEŽã – e¥kÆR7¡üÔ¡ÈÇ\EÑE÷¼+³XÊ7f,öˆçyÒr`̈©¢—êJXMÓDFi–âS¥¶mgÝ£ÊÇYª‹z´…ÖÍÊ>ø|X½¹Ì‡o\×eòÀ`01…^ -©ÿÉ >?ëƒ}~–™¬MF)È»Úú -iv±VJ?¦l/ÆRy¶¦¹îº·êläd˜)u”6x’æEëÓN7Tx{ÂðÓª1a"Hg1XÆa…YÊ™Ãx€6g|~L=ªÎÆGL}² ¡&ÒpFSA϶LpÍc‹ …­7ºÅG‚ ú’wÍ^Þ?øÁJ}þÉÉÉ|þË3Î^?@”¾´>bQYÀ pµTQ,õQE6ƒd9*>Ÿ— -(šR¯õà²EáÖ+V”ŠÏ·,KZ”ëºY>¿þ¶Â#Vbä(iÔsŒÒX­Ô?žÌp¦Ñ®yQ}ðù|‡Ir -ÃíêJQñùYw‘Ïç#Y¦ZüýºñthÛé¬ôó9ü¬¦®!yruuO¥ª ¦qJSôµÚ”¡ú®´†Ãáݶ,GM­H¾5¥ß«8Ùz“µiØÝ1ô—äŠÓG‡<¤ùÚî¹#‚è61—Êúúúk¯½†²··çlll°d˵#ÄçÿôŸßQ/*øœ§ÁÉT”bQ¯¿þº(óÇ¥+üõÙgŸ=}ú4’bÍ ÉÓO?½š—õÆo<ùä“<+8™<ÏÊÓ>ô¡qKÎä†ä•W^ɺÜp8äAÏóÄ?qS -ßdÝ \‘ÛN¸õ`Ž¢ë•,*õd^_b]+ -†Sì|îókn«¯}ík*I¹/¼ð?-k”ž9s&«Vb~òÇ>ö±X­’Mº¿¿+j0$cÌã7˜,**J½¨ÍÍMiQìœsçÎuÛçû¾Ï&r”ábgÖÓZù|n÷ù¸è{≷©UìL©åËJ)¯¨Vp¡’u-knœÅ} -Ú•o¿¸„Š„3w>Òýÿü™ŸÖ_«Ôq¥(úšõùÒœØWÿþûü ˜J§UjØ®ÎUô³Ï¼Ù „‡öYYÙ‚Ã4׋—CWTúõ¯íÒ½ÐÚŸ ¢aò¤PÅ(æçç;ßA -a)Ž›››óù£÷—ÉlŽøüW¶"õ¢RáÙ’± p**«¨3gÎdYúXQpEžkSܬ­­!µúÊW¾’šü,ú|äa óÇΡ\ª(•ü|^žŸ=ȃeYHQ| q'5?¿ž¶‚Í -ßøÆ7ð¢ž}öYƒH¥Ï=÷R+Q0Æj•lÒÔämÅ¡i½ª¨¨ñx¬R”J~þ+¯¼ÒmŸÏÆrßJ*Y;¹J§~ŸÓ\_4íóß~† ´/=ûtðù ó“ªôK¯UÎkRâá8;ÏÿùbÆUÑ®À§>þñ«_ë‰'ÞŠ]¨)ç#MÑOæi×P«Ø¸‚ ‚Û×Fj•:Úq|æOÞhÜç[ÖÞãÜšÖY«d~ûÅ*îs)7º‹‹îq` -ü…w ágŸy7¿o]þÝß{kY¥Ïùš×vߤkQƒOœØ¸:ÿ7?TYŽšõùxl1ù4ojm_çìõƒ,Ÿï]ݧžªÑsª¸ž<ëtnHðBø D|>^žüœz!ø¥çy,hUMî5è9K­Y'óä®> ìB¸óç]œÚq0á÷<àèû>Rf ‹[‰µU¥xÓIÛŸ§7§ÖF5ŒmÖP0ÚkP¦„ -¥?auƒ|¾¢ï6ëó¿ðÅ˸êI:ä¦ìJÍ¥º/©ôË­•çkHËÇ,ÏüÉ0®Tì -ôÝgŸy76`ªÜ;T˜ å/;J¡Î©éýêíŸö‚ßóx–Üâ}ÕÑyŸÏVïä¨F&~¹Q9i³çðù_þò—áµ”w޲>ÂÏažËmÛ£“““ØGøñàAú8põÔóÕkÅßú­©ÞŸþiØH­ MRÏçw¥ -(¦ô˪Õ÷‡{ð×4ùIûúÌ3ëçßÊj«o}k7G -ñK/Ý®´—íùRô«®W0*Ô«W[­²z0Šæxmÿê¯nÕ_+4”T>ýëÿ\s­¤ãêoÿöê|ðtðýBs0¦Š &Ÿ~úzk»tjÃí7þĉ+XT¥›qê¯?ð'TêÓ¼Áµ}¡¢¸Ù›A‘ -¼b§šØÜäöù—ÇSÄç_»sBUŽãàJVEŸoÛ6;MÔ¤‹e|>³¢¿å‰âYP3£\Ÿ¿ÒïSKø³|~ª æ†+}<íŸWÏìùV<|”ÂTâñˆ|íÏ£lb؋Dz΢R:ïóy Jú°`ë<,57{ŸŸoÖø~”CHÖƒÎuË"¦ŠMÌÒ/ˆT=5x@k8ÎÜlÍßçwñ(’J2¹6+IÎýzÀ}ô‚ní‰WضGMU .N “Ñ|Ó-ë0ÍuÏ—µöªokb³‰/#•"Í͆Y¯áÓÀ—£:¥7©†í)]ÞµõA=dYŸíÎÉ¥½{'ó‡·§Ÿ¿¶sDm[ܦ4ÞRŸÏÒ°³ö(šR®nD1Ë ÅŠYÊð{>jážPºÏ}²Ñö§ŠwþKè) ž‚~ä#_^T|>7áC™*£Ôó<¶×¾&ÛD±ýùlââÚ„; ø`†Fãµ¢¸Un&³ùÍ£û é¼Ïç#“ ¬sxŒ‡ªÔˆÏ¼¸a’««{ÍõÑ–žr§N¥×R·aˆ›‚Æô¼ñpxwñXb@ÅŠ›j?¤-’ùŒ|)ú5 h ʽì5ð®†)­•¶v—³»øü…ÉË–ˆrG.á¬K5(}i¤ÁÇ"¬“zúgm+†#]Þ5\E ‚ úÉR>s2cºþÂè~ô®îgùü³×ô¿÷ù|>wwwÇažMg †Yj…ŸSPwsCbYÖJ1¾O^KÅ”ÞÔbæ3×G©J9kG@¬+³®ëºß7Œ¿œ™ïQ4Ç ‰¢ÃG*rœÅ©îXYÙÒY–j›¢‡Nšš×R4 /Jc[0´ŸâtÎÒæ0ÅRBÐàpˆûk®± ¹—Màf¥ж—µMƒ×vãŽty×y0AôŠ¥|þµ;'ÜØÃF‡HŠþdöè_ “ùÛG÷Ù÷º±½½½¾¾þÔSOinòERefYJ4$80lŸ/5¥ISÄÿšª‚ `%dù|Ö•ÀÉÉIò¯®û}ÍM¾x¬¬|ï¦|#'µ>ëÅ$ü÷7ÝûR÷S}~Ö~ të»T79PlVW*îþP_ñ¤Ø¶ƒÀã)Ü…&kË/-î@‰M@ žŒèÚجYY.wÙsçüÖ¤H9}ðù !´„G‘9[.Mù|ék#ïÚ¸Þ±¬ ÍG—¢Ò‡sr¸©áð.®=³Ì´*îð3fʾ4aµŠ*¬sÔ†£aŠ>Lê–îwÀËõÛ3if»¶©Å­C*Ò .›ŠGºnk¾(áku#ïYmc‹ JÑ'‚hKùüÉlÎuýædviïâó¯ÝyäpÎ݈à{ï꾆Jssóõ×_o‘ÌÏrõû|&íc¶GÝ”&MÏg†ord„BW2s˜š Ü"™ÏŽ0Äœd>?æí91ÏŸêóù†‹ÜVM,vcc#µ+ë÷ùl &CHêeÚó |hÏÚLiƒdueœ½~@ùùËÞi,ö„/ïUW¦Ÿ¿ÐOžKmd+Þ «PúùÒò¡‹ë¯0œ­®îåˆ#äÛ>ЊœgÞ2øíÔŸ¢¯aˆA}„ã³Æ÷#}*£sK¶XØÕ7Uñ®®¶=Ò¿ u“熖Zð§¥èAp|߇Rx?µ,+öZ ¿´mÛó¼Š^®—òù‹÷k“›G÷ŸÏ¼ -ÿñòxªS“?âðððµ×^#ŸÏá†D´µ"0a(rkšfêXB€îºnÒØÇ|óYÕHíÊíííÝÝÝÔ¿¶Îçö:¿Tw+ú|èYöhv±»c¿Lõùb¿ÃØpg0,µ^‰Å²®ÜÛÛË:§,ŸŸUN†Pq)ŽÅ8T¢0€“Iø0ìùÜasê·œ#€Õ -²º²tbæ"EuÌçóÑžu u˜°\ìØdó·æz6èó¥B²æŒDÜFjžÎ'RDéC§@³Ã­‡ëÞZYÙR—]¼døl¹7åû‘mª“ùp§Q¤ãnV<"V³õ•Zèúã %6fBUjwKŸ\„âšYÅH†KK—ÓV,MZm¸“þw¡DLºs¤EÑg‚ ˆŠ€÷PÑðH3¢KÑ^Öç¯í1mrîF´t}ò`'œßš°/Œõì$GQCR»‰»Ç‚A©ÏgDQÄM+•:˜Û/â_<3¦µ“n0&îÔX¾ïóñPÊŠ'¥|ÏH,;ˆï…šºà0· ÉÖKýýåñ”?w -^¢o>_ôù Y]ÍO‡k—C“:"nŠ  à°¬²Ä8”V*‰¢¹çña£U…+E«ýö&ç+N™zê/­,S­ <µeÍT_á̲zAºšµEÛâq(¸ÍÞV&7øÿ$m ôATAEÉl|àS%æs.ëó7'3nN&³9×õ©œÀM‹wUÓMâA¨‡TšÅ4ÍT£ÅÅc2%8 .Å}>ày^RuÏ † %§Î è£ÜÁ¬ ›æ‹­ù†ñ—xrþ¢2ŸŸ´÷IßåóÓÚ¡„TY-ŽÛÜ>Ÿoëƒ&P¥üб}(Å}/TŒÏÙІôpL…­N°$F‡ì)Ï£‚W!ŸßÍú|ß4q€Ò\¸Ö)_é•~Æ•ÚÔSÍággÙ½15ZóÒÑ$E¿íÉù \çÖ“¢/µ»5ç9÷ -ÆêJ?uÓ²HWi¨O[ZO«”x­6 T7pîFÄäÉÚÎÑÍ£ûˆÏ‡‚l¹´wº¾ -DÙ¥¢:y&¶˜·¼XÆçÃP¬ÔçÇٲ†}«©Èç/ÞŸŸL×_¨ù|‘ xDYè‹]jDQÄï]Ü„¢>JÅr·¿"lgJêvBÉü|ñ4¾ðo?)´Á|~#4îó=oÜø«÷px·KRE¤¥}TµçT$ g0œl{$Íiì’‘êÇF/®%ëÉl/ŽÔ¯šæzu#J–ƤŠ'„¥Ì©R4µô*­‹#k"Ò5 +”‚ôŸJÑ'¢‡0o–TRà|®ô“Tqrøü‹»ÇLžœ½~?">Ÿ°¶sÄ~<¿5¡®¯.7bŠ> žçÓ§ê>Ÿ›U×u“c)‡]a™Øbi±a¿ì(í0Õù|Ñá‹n?ÙÅ|„ð|û,]ÏC?ȨPôù¢ô}*ü^b÷¨>JáŽø®Üí«RlÇA û A dÿêyôOo/ΟZ\,´DÏo„Æ}~Íñ×Õò¨q¯ÒöœØJ•¾m4tãP%ß [cz¶ÁMÕ!MÑ7ÍõfX‹ÂaRÅZ ”îqhé.¡–²Ô² ψe—Aé^Œ–¦^㱞æÒõ°u<<ÑÆ;"‚(Ϧö?>„Rר¤xç]“ÞÉõ -YîÔÓþù5 Qúâ•©8J¡pöŠ­´E|>û ´ 2 àº4ȳ·dÓñýbO?dþfèû˺VšNœY¹©¹‹ñù ™C³¬J[@úú_ƒ‚¨š*”¾i®·ÂÓÁÔóÆÐ–R ]i'žUÞ®p˜t5¨(I®‹‹Ð–ÚÝVãûÞ)±õPe`À9®{KºXµÚØhpwÍ®W t¤)úé#¢WðW×ÜoÊ%¾Ãæðù'ó‡ÜÏßž>¸´wñù×îœLfsþãæ„¸UÁ»’õfR| ®(á›äþnH<ÏK;P‚hQbéôE|>ÿ¬ã81¥?r½\J «íTçóB"tê& Tñ.›Xiðq©Aö©û| â†ÆŠ…mÛ΢±‘–:Èaâðñ–§Èí{ùÊe&[ZOë'¼;`p&ÿÊ.þÄ»Ð'wðtÕ硆zêàóƒ`Ú`~/ž[unsm”«ô]÷ÙE}€¾hÊw)9_eA¨(ÂhÛ£NÚݶÏ&ènÅUfYVð7 gЃ*¿í›ÂOo|ƒ@PŠ>A§í>¸vçäüÖäâî1|óè>âó×vŽàœ³×Øì#DEˆ’w+CüeVnsì489&Þ‹øü˜§…Y} |ß•Þ7*õù<‡<µÁSÅ»èâLÓ„Xßá^]Zlbæ<¿(ä±`Dª_ÊpBÉ™RÄsŠS Ú‡54¯yj ­Ïˆ+Cê(bå/¼}àôÃÇ>ÿÝ"—#Ÿß[Ÿ¿½®V—~&¡•&6×>&÷ú“–ß7¤[Ñ$êRr>_¤Þµ\».Í¿íLT±ÀxF[²Lã«G*ÝRøÓÜuoUwi<¼Ïú–6©4ç¡ÒV%‚Њ0 UW¾ï—˜«œÏçÇ@|þÙëpÂÅÝcöãù­ €Já³IŸ% }¾iš©þ¤ˆÏ_¤yZ˲báƒÞR©Ï‡^àIæÛg‰wX‹#M8_Êç/;^1XR²ò±ká° Rê+â9¡@¾a!õ¢©¶>#­¬Æ‰þÁÞ`ÇÊÊõ"—ëªÏ_)@ õÔÄçK³|+J?ƒ·`üºËBwœee h«–&7ö©….]v/9Ÿ!ì†q¥ÄIÚqAkœ¥‚¡¶=‚©!ͩ•JõꞪ †ªv·wCADx6æ²öFÔA¥¤q–âó/Œ¥?™ÍoOœ½~à]Ýßœh´ëàà`}}}{{{>ïÚ–íÁ``Û¶˜® ýëº.>ÞàS«(žç!% ‡CvZî'0¼á㢨1 nDºêpW¦ÎYF‘“Ù/S–$¹Âð.Nþ ~ã8Ž(«aøÁoTƒX¬zWÂÉ0¤ÅÑWd£ ýðk!àu^ªý³&T[Œ^Á0¹:±*eVòÀ ²=ÇöW>ÿöKEêÜUŸ¯y=5ñù ™Ôª"O^jíªÛÐ ¾‰MmW˜®‡›…F†šŽV'ˆöèY|<—î|ðÄãVg•K#_¶=*åBž7®çBDñù…oæ*å¨Tw×ÞPÅ…ÃpÖHV@=àwG>Ÿ ˆ^!戦ʱTƒ7´eeÍ•âó/§ˆÏ¿vçDÏ^ØØØXÌññ1ÉVC]I]It¯+ù^¶ÔÝ"¿ä pÿ½÷žÏ?|ËûŸEêL>¿-TäóñHøRúà6²í¯ÿD‘¦û~TÖµ¤á°Vïæˆ¢¹TÞoL•«Ð*¤A0•n¦(xtc¾ñ ž¼õ_´Æ 2zÞ˜¦'A½BLdeɇ®ë²ÔP–2mÛ¶˜Ì ß—’œ¿(Éçßž>@|þÚΑž]póæM¦›f3úOµÝPWv†íímèÇ êJêJÑ®gn^¸¶jþfÈ|þïœú_ó%·¼!Wì@Ï_–(š×):ðð%¼m$¦ø¨.1g´:9Ÿ Ž´1 ¦RKwT±/‰(ô¸4j–ûèÌCGš*_Åþ¯F6Ôܪ©÷Ø=AKE‘mÛ§–Ç4Í ˜²)ÅçÞÕý,ŸÒ¶ŽIvêJêJ¢{]麮eY™Éù‹ÅÎËÎ{Éù‹ÿj¾T°ÂäóÛBE>!³[%&õe½‹Çpx—–¢uàIªe)ân'çs¤æZ;wá*ÁÒt-e9Ûu©»ñ¹Ïúr/‡GߪØß×°hÄþu«ŽA´ß÷Å×RÃ0à½53M1eùü £C$Eÿöôõ5AQ.ƒÏÿÊç¿â|³`iäóÛBu>_*¸Êrì•j:‚h(šã±*økÚw>9Ÿ!M3.’i,]…|?¢ñ¬-ƒÁ¾4(¬rÀdÇMñ)©aûà«P¹Á |6uéíæycÛÁßPÈ " CÏóÇWTÃ0bÙøðKx]õ}¿ŠK—åó/§ˆÏ‡¿R/AåbÿÇè=Ÿÿó_ ¾[°4òù2 àF kÄ_Vçóµ$õù~„ Ú½N´Ïã#¼à<êIr>cuu¿Ù|û†pÛ ¬„4’5'™,½¬Æïvf5Þ8%®Ò¸[÷Â%A„”åóoO >ÿÂèšš ‚(Ãøerþïœúá÷ý( -•Ö1Ÿ·³ú˜VßS÷±»¨ÔçK5WÁsiö2¥ÅÀ4׫ÛêbÛ#<Ö·Æô¼ñ²«´Ìn›ÞÎ]iYêf‡ã씵ÑLs\÷Vé°¢ÐAQeù|À»ºŸåóáOÔÔAD¢(bIÚžç…a(þéÔ©ŸŸ:µøð'ÞýwŸ¿÷ôóGýãéú/ÿïý§,AÇ|~7¨ßç/döluu¯Háø‹?½ûÝ@šBŸ{œKSa ÎÐ66¦a\Y*Î(Íù‡eŠÆp‹pœß·HqmkEm‚ B¤DŸatˆ¤èßž> Ö&‚ –b0†qJÀu]þ×uúò^ŽÄgÍêöÿð¿½Ey®E>_Cñù¸ì*’ýÓr½Ahü•Z› ‚PÇ÷ýSi0¥‹˜ÌçÇÿøVž2ù| iÄçGѼ - XÖFßR‹‰Þ"õƦ¹¾¬7îar>_”ð`E3 hÛ#¼ÏÓèm#A0uœ˜V0T˜Æ§¸ .Û™o‡v+r !ˆµ¬ezÞ ùŠ%mqÝ[åê÷~&ç3¤f‰ÀïáãÒ\eZ…ˆî! „Á˜Ï½nH7ÎІ;‚ ¢: -úüÉlî]ÝÿêÛï\Ü=†Ï^?Ȳ+pµ6A¡H©2ÿ /á™rîFô«GYOœÕäyâÏצ|~Lñ—ôe3úà¥^j†Ã»ÔãD—f•Ã_Õ}Wo“ó9R!ŸLöýHªi":Œ4’‡mr”,W„¥ö'‚ ª£ Ï¿<žŠº~mçIÑ¿=}À>5™Íù÷ 2ŸÏÇãñññ1 ƒ¶ÓÛ®Œ¢h8AЙ; -Ãpmmmk ûnÙuÝ•ÇÀ7ð‘Š* ; VßÃ÷ýê®E³2 tnRæhå?ðgÊ—Ö'NŽ+’Ïצ|þB¦Îgg©Òl{„¿ø/[ A´iV¹úÈ—zé'ç3¤ .äƒ`꺷¤1ÄR¬&AhŽÊΔe£Ò• 8‡Ÿ ‚¨Ž‚>ÿöô¨ë¯Ý9AìÊ¥½{ì#bJƒloo¯?æää¤íýÈåÆp8Ì}²hHÇQ¹®iš5H•^ueŽ~ ü7\HªÌ謓ù²@«Ô ÿH¾Å„ñ£ýJ8}úô/~ñ‹ÔàfùUØí†¡2ìÕ‰¢Z@Û"–e‰ ã” (Ú*«ÂâÌÎA* Åg%ôlòöÿèÏ^@ž2üøëËyÔ(ù|mW¹F|¾ôm]]ú~„eW:¯"‰ÞbYÅsÂ¥©þ=‰ˆ­®îáišëp,¥ñsì• ˆ«‡Ê¤€'µb*2&µÀä<—ÇÓÉlŽ–ó[8ÿÒÞ=1¥¿A677™nê@^wé>ß0 i9Aˆž­AŸß¥®TÇ÷ý¤o/Ýç*ùÿ¢z-âó766>ùÉOB!®ë&ÿE\Ȳ,ø†ý& CøQ1è Ül–ɱm›×Aä”2©!3ŸÏà -©ÐèÊ"³’ ï$_Z{[Åç¿~9ÌqQòùÕ1Ì õ¦|þâQÌz÷‡*^Å$PÑééÿ–µ!-Dê±ûã¢óéúÒó“ ¢EÁTÅÀÃiÒ¢Td>M(‚ ¢Šûü £CæOàøñìõıÀ 7î‹)ý Þûáááöööîînú±tŸø¾—㺮&>¿K]©3Û±äüE5>?U­‹ÄÔkŸ]ÉRôSãìB±‘É2öU‚R X`Âó<î¡Y˜ZäF=Y‚øÙ$±HA²aù„ÂSKˆ)}‡èÁÁÌʽ½½¥Úß¶mÇq`xÃ7I™ÿOþ¶ŠÌ‡ãÆFžÕ€|~uœ*FS>_ªáõÎÁ­¾ëÞ YYÙ¢BtÛåi…ál8¼ëûÌ2JÎçHã#9Ó\§-BD·Qñð–µOE™/-‡ ‚ ŠSÜçÇòí×vŽÇróèþâý)ýÔ¥P…ÏO͉ÉÉ}~ogn2/½ -Ÿ/Í~‡¡R–Ï L–Ã*–z*#‡‡HØ-gèy2æ¥68 CÑTÃËNd±±hNgÖ±Øä|ô?¯"óÿûÚF¾ -Ï¯Ž–ú|xWysG¬¾JN`òЉÞƒ\:‰ß÷#¥M8` Êú¸¢Ì‡ÕŒëAD ÷ù±|ûkwNÍriïÞBHé?¿5¡.(…r}>ó†a …A žL>¿NÂ0dmîy^ìOåú|Þ¹xö;Óàüäâ>Ÿ._Í®EQÁ‹ò¨„eYxilG@ªW´Á<ëAʼn\|ÝÖÞé¬ R¥îç^zUÅçÿõ•wòÕ|~u¬‰>WýèQ÷fLHÆ>nYø§VW÷ôê*‚¨jØ+=«¼‡ÉùŒ(šã–ÊÌ'™Obm‘ÎetÔ<ª Èíýa|àô¯«È|8®Žþ%_Èç·…:}¾J‚}LŽÁ[?û¬ç¥'So=¡DM;\þûŠŠ4ô…ãì´ÎäÍçsšM¥ó½ï}ïàà€¢¬+ŠÓd>AQ'¥øüó[fQÖvŽàdz×Ór2(:ÿÍ íG+r}~EìÇq² -aÂͲ,nÀ’R%îè8†aÀ™mqŒ‚÷N¹>Nzu1¸€\Ú󼤤…3³F,œ i¸T’í Àe~†©ù½1x| -ó"r!ß÷EÕÉ€–WÙéÐì¨f½‰$çøŸQôù{?#Ÿßqêôù/·•#åÕóÆRi0Þ¥Þ$úƒb‚ëRLÏÞ¶gŽ¥ Ûñ˜cë¸zõêÑÑM%¢*azÑÌÃ7*!’ùADÍ”âó/íÝcåìõG‘ýµ#Ä´0Ï? )×çÃ÷,íÙ0ŒÔ‚ àÉÉY>Ÿ ÏTLÓ¤\ý|ð†M5´¥û|îÕ³²Ö™†eZ;µ´(в -¢ãx -zR°û¾Ï. -’Ž"$Þ$ÂkˆìIQAÑóËÅZUq"óÐIìBÉðY,z¢ÿ¨fõL­ÿÓÏ“=5V°Q -*±E˜20_HæAÚRŠÏ¿ytŸ»øqs2CdËÅÝc8¾Š!¢ ¥û|®×Rõ&OfÃ0Õ—Âï™q…¯pòð=àž¤mYu\X¨…5~ò¯¥û|îÕSÓàaxˆÁ…ÔÒøhßÃil$À7¢|Nfl¨Ä‚J¬4(J1¤èó˲¸*åˆ ’o"óé)–ÀûÚÚø%\ާ¾ã{„8à›ä>Æç^zUÅçÿý›Û¹«A>¿-ÔìóäûÛÅAä`8¼KÉù%²ºº'Ý+亷ÂvCÄûpœ•†d>A¡-¥ø|àÜè«o¿s~kߟÌ"²… |ÑùOfM¿ÒÞòo:‹‹+Z?q·‡YwÀå†ã8«2¸.C|>ONfG/Þ­LȧúRn,“ZRÌÖ.˜ ­ÔîƸÎÔP¥=XÓemàÝ}$ ܨ#>ñžk…“—ã%@·.Ò|>H©+ ÷Ò©Á¹àIìlcHê˜Ìîz¹Ï­àHcjƒ‹ñ,Öh©sñùð'îç=Ïã¿gÝJ íÆ?’ükãðý>l£GÖþ‚â3ð¼øÒÚÁ^ŽGÌ7îX(Èç·ƒú}þãáq^íËòƒÁ>õ#ÑOT4%ç«cÛ£TÁíLŽ‘ JÙ.D2Ÿ ‚hв|> jy¦÷³v&ÿñæÑÿgßÜ£âªÎþŸ?»Þµº^úÇûG»Ö»Þù½ï]ËÚMâ-ÈÜu !$$“û ¹z‰bÔÞMÆK¶VÆKÒX'*jm©£F£fLˆ¤Da A,r ad~ÏœÍl7ç²çÀœ3ÃÀ÷³ž•3‡3ûìËs2Ÿýœ+©ì‚3%‘ÃcÒ&jý†!Ê ëH|~$fSõÞ˜Ë7æ }©æTx!q²ê*#Ôt y—ðÎ7[°¢´ŽÜçÓ@k¼:‡Ybš*ìWýÙâêt¾¹#ÉNÜZÓ+ô‰•F˜iêAùüÄӠŧ«Ðwf$ÞÆœ×ëåÝÅvÄ«–_‚d‹-åð]!êñ© =Þ….Ïd¿äæRrì˾6,àóÓ…”øüØ$±Á꣨ŒfB¡+%¯Ø³NII3“Ô±nwm   Oˆ‹¢„ÏEXnR…>_äxÓ%‰r9ÙÝÅ®hìdåúÝá¾”]’N2Ÿâ¨qý°>Ÿ×Nkªè¹ …B‘x>?ɦŌŒtòùrÈ{›+t³lôù4Ðý6Õëãû24UØ+Ÿïr¹Ø„±ßGà³H2ÏÍ4õðôùfM²¾õ;q»bxŸà`»ò«>–9gQäæò豄j5áóÓ…úüØTIÈê‡B=D0š))iZ,­;·»–þ‹8Á`v¤)ùü‹]½åRVÛ>®½µµµá£§ÓÌç6¶L\nø|¾Êxð_¹ÏçžÍãñˆ‡¹\.z‘NÂ~5ô¥|/€I­2¬F¶q(«ªªêêêÂá°þÝô’ùˬ™ÂâÃAÝw&pa.÷ù‘X= ½x·¯¼JÜðllÂðêë@  ˜WP‹C©×ì4‹Ì®e¸Õ盵“š!ÖØkZeÑç»Ýnýæˆ(ÃéZƒƒÝ@IæªÔw>ë ÉUS¿Èž·³SrsÙ±ÿr"m†ÏORîócf(V¿¤¤ #€DéÓ²¢ðz/Ð1ô_Zh°÷‡ðû[ ó¤#ù|ÂwºÅL¹Ð[ÃáÚ«‰OßaõùVJsÍÖø|Âív3 Ë_ ƒ|〽bæK Kmé#œpû4’U*úwÓ«>_èlÙ‚ëó­¬h³ƒõ>Ÿ›qìhbhž0<ý ;RÄårº}q(‡ Ù³upyNŸ¨—]A³a1,Ú`ÞŸÔ3bXÙ˜3;'GÜ)àçO•Û—¯J±ÙlzÐ|з_äÁ¯Ð»»¼Uâó7nUi3|~º0L|~lÚ Âê»\UŠÆ‰Þ|{|¾æ’’&ú—Öú|<žzÈ|i‡s>¿¬¶]b]:®¤üÚªªªš+6¥“Ï¿0¼‡|>/³ú?×ëõ²W¸”Ô?Ó[lGÀPìÛhõÙP==\~:ù|j­•›dŸÏ7Mö -M öŠ_h±ÙG+ŠBçä…úá,^K]]cuu5 å|þ˜AÂ/p°—®ˆo -6 æ‹k° Ù3+îñx$OFØŽ8”q;“²Ÿcf(óL¹ñÉm¥èˆò”ïX"m†ÏO†•ÏMž»\Uq Œ%0ÜÈ̬†Ì^8çóÏ|Ý-/Ãáò;;;£®ébeäLIµÓ‡|¾¢(ܲW˜’ÍÌÌäÇH|>?I  wEÃD®5ÃýCi](µnøGÜÑK•ÏÄü3¯`çÏ_ˆŠ8îGƒAŸÏG«qû|›@Êdú|>9E».og Ùçeâ>ŸA+Ëï÷S¯jܾ¸r&ËW¥¾WhˆÛíV^vO(è’ÜV¦¯oU^žH›áóÓ…aèóô_bõÝîZŒ0ÜP”pFƧùÒç|~[OX"^JÏ)è|qÈç¬À>###¢ÊXv€ÏçãÄõù"Š¢ˆõâÅV žO•Ïçͬ )Á,«ø‡ƒJ&tQáêKLJàó%×(ŸŸüê,~ðD3‡‡‰Ï …Btul¼¬oX$ÃÇ7DgëYôTáÙc_ TDNxi|~º0l}>ÃÐêgfV+Jc C‚Á.È|púº]¢’ îðz½Ù*ÌMZœóùDé9Eâ^ºÃ}˜ÏváœÏ÷ûý\rû*ÖÕúR¶Héo @îܬÙðÞÖˆtý¶û|>j4 xuºfˆõgãÛìY ^篟º|î%âë,ú|~uVßØÒ¬…È`|>ßÕûpÈ>Ÿš!¿3ÚÒ™ÎÁg”!*ÔU’Jɱï¬}‘Z¿-ë >˜S°8ÿÿþÇ5äøàĉ$4’¾õ»ÝµÙÙçé_`˜C7k‰Ì÷xêÑE†5*cHÎãDdZ÷§fµ¢±S¢_Î|ÝùlÎù|EQØ‹‡Ðfffj–›~I²#YU¿!ðùC#îVˆs>?SÐ4¸\ÂkŠêõgãY|¦ÃÊg‰o™ý­¬??Â/Šæ­dŸ—.™«xúÉ×ón¡Ïû0Ÿoq£gxú|±ÜZË'ÿ;î°ä†Rx ½rï5‘ÎP"Í€ÏOÒÂç ½ðxê!óÀ!¬ø|+ßÇáó5ýé„Y­ië‘è—òúÌg»pÎçn·›‰GC¹jè ¹54±ôbâžvÔÂÂl¯ÄQŸÏ޵A¯ŽõgãžÙåriäDuã’­6ñˆDž¢²î±ycX{ Ÿ.¡³‰Çè¯(î݇®…¯}«¹1ñ†v—-éâß?og©ä†2v~säõÌ[ŸŸ.ÀçÀ ôJßë½€n€ÄÏw¨?ª”–èßi<~nŽú|^KÌ…B⻆¾TttZ:{d†~àŸb¨CA\¸˜Õ „f8œðùïª7Þ†gëÞ½^/~Š~æ›D†ù<îSVT]z0äMbM½]¢B­åeù’þ1ƒAó¨K$±“¸N©ÏëgŸÏÇUÿð|"FÜà0“ùDÑ‘JÉ eåüÒÈ'Þ[ŸŸ.ÀçÀ!*+ÿ]RÒÄ"êA‡€-Àç;ÔŸyž²Úv‰¹ØÕ‹)m Žú|EQ$ÒÌ—jv4˜éPÞ±fäÎù|BtÚfÕéš³Ñaâ_éñx<ú¶ñ½Ãw­3(ŸÏ>—/‰‡7›½Öe¾×ëMp!ë‘‹qjö0ÜA£&‰{(¾óÝÿœºp)ýð½ü·äV²»¼u磕ý½!Á{ -|~ºPýÙgœ81ähooG@Ò€Ïw¨?íòùÝá¾ÃçÛ~qê_Ç›.ѯ'›»$†Çëõf«X‘äfó×%¢wÈt³·hqéÕhFF†Çã1¬-VàþÓívëßåÃa¨‹-Ì£0œNü-3møµ™R^ÛfffîJD„m‹@ HwIæ§úPþ„½(?Ov#ÙøûÞþ»äØt§XûÄѱóó%·t÷I¤1ðù€íÀç;ÔŸvùü†Ž+\­Ð¯»zs/ ]¨Œš|[àeØÃÓÐJ…B|2ÈÏJú].WjL36§.õ-ïça¾w¦ß}àL(XÏo…ž‘ÜJJŽ}É~(«M¨î>°ø|‡úÓ.ŸßÖ接¦­‡^9x¶UâaºÃ}tÌ™¯»égßé–†Ž+I»öp8ÜÒÒÒÙÙ‰e•îÐP677ž¡ …BlÙú|¾9”ï¾û.»ÀAÕƒ´[•¢?×ÃþÚ'ŽZ‘ù'›»i3|>`;ðùõ§]>?"üŠÆ¨É)¯ï¨æüŸoc¿ÒÁI»öººº*•îîn¬¬´f¥×ëåë å-·ÜboRÃdUúý~š´4²ìé þ¤‰žï|÷?ùmBîóÅhë 'Òføütáþ}÷,ÎrTöú’|¾Cýi£:ã¿ôœB¿Ö´õHô øì׃g[“ví555L7¡D?Ý…C©(JFFÆÈ«`¯®®~óÍ7‘œGÆPjV%Ÿ´ìÑþ˜‰!cçç[ôù¼>?ñÛGÊ}>uõ ÝŽyG™!ù/Ðh `qþÿýkÈñÁ‰X¡4àóêO}þ™¯»¹ié÷QHT 30 Wø+»z“sííííuuuXVéÎèÊ@ 0òJôi(,X@×åõz1±ÓšÖÖVZ•MMMü~»!‚Á ø«ž…ûaw„¢#•»ËOY)ÎgO„%Bj}>õ -ç1րχÏ€t>ß¡þ´Ñç‹¿¦­‡^)=§H$L[O˜Žá¿žlîÂ<À -,¤}V³‘‘¡( -Æw$!ç³Û¼½äØìŽp×s/[)Îç·›DH¡Ïû>?.ðùFÀç;ÔŸ6úüˆ ðËë;è×ãM—$B† ü²Úvöëáóm˜çXAQÊ`Á`pÄ\Q(¢+¢1¸# ±Ÿ†Øï÷KdõUÙ³ù ¢ìØ3}~âL¡Ï÷z½ìs].u–€ÑçÓÏù|ƒŠ .  iÀç;ÔŸöúüŠÆN&Xžm¥_/võJ„LYm;s²¹‹¿ÒîÃT€ƒ¦8Ÿß‚ Y¸ï‘þ;ȇ§J߯”Ü>v—‡ÄûH‚¤Ðç»\.&óñdŠDŸÿχ€á |¾Cýi¯Ï¯iëá¾¥­'L¯øN·Hœ @‡ñ_éÏ1Õ`d )΃c¤ì.?Åîw=sÚŠÌçÏy%H -}>ûP¿ß? -§G(òx<™™™Ôô¿‘¸'Àç@ŸïPÚëó»Ã}\³4t\¡WÊë;$Z† üƒg[Ù¯t0¦:ŒB¡¦8ßãñHd>Ão ÷Énwªã;Ålã8ARîóGáHü~?Ÿø|Iˆþ¹Äþ•°Äöl;|¾C>Ÿ(«m5Ë™¯»%Z¦¢±“Ž¡Ù¯϶bªÀÀív‹ÅùŠ¢èý­ˆßïg÷‚]‡ë ´Kno~úÕÅ®ÞãM—ìz¤+…>ŸÕQ57B¡ïpÇS©âõzãþa‚>ÿÅ^ ¿B ,>8ñCk}‹@ #/ðí04D]o ðùùüîp_CÇ^3I?H´ ø5m=üLõQ-F¶Ýæ÷ûEA‡€Ä¡‰T#nÑïÈ# ú|>ZSôoJ.Ÿ -ÛH¼›xFFFÿ_žð¸Ç$w’c-Á`»í)(U>Ÿ’ž7âaRÊÃIÐ狎@ ò=èÐGß"ÄÈ‹Ñö} -`ðùõg4Bé9E"g.võòcè_LõAáõz³U‚Áàæ¯>k†Äãñð?ñûýCn¿¢(™™™­7Êצ€fñÒ˜²á°âÇ̦¡äÃÊl\hÂð?¬šs‚P(DÍàÏa‰óŠ•Ç]f¸Ýn‰»Î ú[ævÜŠn.K9¾¤WÔpŸO=¯¨È‹óé–ÔŸžr]•Ý#¹eøÊöM¿ú|‚åÀá°|’Ÿ ƒÝÀ…ÏG àóŸH#àóêÏ$øüãM—$ræds;Œ‰}0(˜Ù³8ŸÍæ¯.Wü;u(2qC€‰GŸÏǬ5,33“ @ ®Ô9ÌW‹ãÈ…¤•mv°&ÍZ©ëÍyÊkŒ­Ü&hÊÎ.qÈ1ô®ÖïPôA No6|Ôó†çaõÞt™løè_·Û’[^ à[ôƒ¼[ú'Û…€½gá¾É-cìüË••—ímjj}>ßÖdÛ£•RFÀÃ&üBW=Ø¿…ÏG àóŸ£–dúü‹]½9sø|[’¯½µµµººº®®.§û8Úî󉸥þ>ŸÏ.ŸÏÄ£ø -+ëµXó?’†Ò:LjV®>?nQ7¯ÁN<™ÐPVUU%2”š¢tjLI ·Û-‡gffêM¸uŸ¯Ÿ´‘Aî86` ßpéÑ[ú]9öxBÒ¬f(5;€²þ<áq ì.o•Ü2¾ó]꼑ãóÙƒ!ò‡ìʷÄA%+ 6úüŽýÑfŒ¿zÆøçŒÿIÎøŸª‘™3þš™ã¯9~ìÌñã¢1nü¬h\§Æõ³ÆÝ0{ܳÇޤƄÙc'RÌ;iÎØÉs®¥Èšsmöœk§ÌÆÔ¹×PL›{ÍtŠyј¡FN42gª1k~4fÏÏœ£ÆÜhü”bÞÍ?‹›Õ¸E 7Å-?¡¸U±ÈÃ…Ñø1‹E±Èb1[£‘¯‹%ѸÚ, -îqËÀ¸™Ç æˆ%óÆÜ1g`̳ÆÌ‘30f1Ý ò£ñ“hLSÆ”‘=0²„˜¬‹Ic¢úc1‹›DÞM?e±hB,T#W (&RdÞªÆsO>æÐ2ÏɺvF,¦ŒiÙј‹)Ñ›‹,Š)ј‹I±˜¨ÆŠ©ã(nŠÅ±¸AëYLw],ÆGc¼ã(¦‹kcqM,2cñS5~‹ÇâêéÑBñ#5®šq ö+{ëêœh†añ!Õ°l™ÑœÃÒε±ä3VHAãfõg!<]KJ7Ì{c,nÏQ,MMRÓOVY±”•=·?k©‰ëÛÜÕŸ¾bLŸÇ4©Œe³Ù&9MŸÖÌ2Û­²ÌfœÓX*Ò—Qš²š…ÔD4Ø\do:Òd¤¸IÉÆ¼d˜$©IŸÌ”>G¦©Üþ4õm¦¢pÇâ–XÜL1©?æÇb^\37s(&÷ÇìXÌŠÅÌXäPdQ\+É]†é‹g0yÓç1ÃT¦Ïf† í:]BëÏi&iM’Ùâæ·«&fÂçÀp#™>Ÿðn‘ø™îp_2¯½ºººJ¥³³3ÝÇÑ ŸoX~,ÂJI÷KÌêÍëÖÏ9’†Ò"\jÑ Ÿ·zVStH2Ip(Å–¸ÝnÃfñêô“\¾”E¡‰*®ÍaüäfS7 Š HÐÊòÔ_©ÙÕ%íé ýPj¶ZL‹ó‰2¾ÿCÙþoÑ%óªÛÛœBŸ?¨$ø|}þ5[æM{sÏÌ¿ì™ó×Ýó+vßZ±sáßv.~kgAåŽÂ··{ޝ9V¼þïÆw¼[ßÝæ}·hû{E»ßÛzÛû[ï<±åî6ßóÁæû>Üüó7ýêäÆß|´ñÀGúxÃ#Ÿl8øÉúÇO­{âÔÚ'ƒkŸútí3Ÿ®=tz͑ӫŸ;½ú…3«ÊªV=»ê•³+_=»òõ³ž?æùKõŠŠs+Þ:·¢òÜòwÎ-?þ÷Â÷j -OÔ,ûðü²Î/ûøü²Sç—~úùÒÓŸ/­ú¢àìÕµKÎÕ.©©]r¾vÉuKjëòëBùõ¡ü†úÅê7Ö/þ²>¯©>ïŸõyÍ ÑøWC^Ë?Q|ýEÊŠ…mþ[Ž ¹r/5F£«1·[Ë_F£çËÜ+ÑXÐÛÔa5¾Q£/·j"b_Þi¼5ráÖ>Š,èkXÐW¯FhA_Ý‚¾Z5¾XÐ÷ù‚¾ó¹}5¹}Ïí;§Fuî7Ÿå~sVªÜoNÇâÓÜo‚¹ßœÊ ’þ87üQ,N.  Æ‰…½ï/ì}Owö_ØûŽÇõ¾½¨·R·õþmQo…]Ôû—E½o.ºòfÞ•?ç]y#ïÊëj¼–w¥<ïÊ«Ñèy9¯çh,y=/åõ”åõ¼˜×óBÞåçcñÜâËGÔøãâˇ_>¤Æ³‹/?³øòÓj<•ÙŸ¹4ÝOæwÿ!¿û 5~Ÿßý»üîÇ—Dã±%]Æâ·KºYÒõ𒮇–t=¸¤Ë·ä‹K.=Ðüû‚öýÊþ‚ÖK[,ý—oéW¾e;eÿô-kò-k|pÙ…—ýã¡Âú‡ -CÖ>\øÅÃË?xùù‡—·|ph™}ríK¥kËJ×¾PºîùÒuò¯;â_ÿGÿúCO­ö© Ï<½áé§7øŸÞPúô†?<½á‰g6üþ™?»ñ±g7<´é·‡6=rhÓÇ6?xx³ïðæ‡7?ðÇÍ¿ùãæ_ÙüË#[~qdËÏl¹ï¹­ûžÛzÏŸŠJþTt×óE{Ÿ/ºãù¢ÛŸ/ºí…m{^ضëÅm;_ܶýEoq™×[æ-*+ÞZV¼ù¥âM/o|©xC xÝÑâµG·¯>º}ÕÑí+îXñòŽå/ï(|eçÒWv¼²sÉ«;¿º3ïÕ‹^Ý™[¾kAù.÷k»nym÷ͯïžÿúï™óúžY¯ï™ùÆžœ7öLÿóžiÞ3åÍÛXPb™þæžœ¿DÓˬ¿F3̼Šh’¹¹b—»b¥š‹f›¼·¢‘_¹cI厥•;–Un_þööoo_ùvñªcÅ«¯}‡RPñ5 m>¾mËñmEïnÛönQñ{Ñt´ã½¢ïíyoëž÷·ÞþþÖ;NlÙ{bË]'6³ìt/%¨6ßÿá&ÊQ¿8MS¿þhãmØÿÑJV¾7W3[ˆe¶Ëlߦµ¯(­©9­õ‹(›µ«ÙŒ¥².5ƒQîb)«O’…bYÈZ"êã‰È,iÒÑÉÜð‡æé¨?#©éh°éµþŒMJ¯y‰'%5/]æyéO&y闞ΗšòYjú6;ýv`ve§ýÆ JÙ¿ôk£%¤©eõj¦ª‹fªå_¨iŠâï¬8§Æg¿]qö·+ª]qZࣞSz>yÔóÑAŠ•>¶òƒÇVžxlÕ{GãÝÇW½£ÆÛ¿[Uù»UoýnuÅï£ñ—'V¿ùÄš??±æu5^ûÃÚWÕxùɵ”¸OFWYéºþÜUÍ]ÑôõÔ€ôõ”š¾¢ì™o3X4‰Úô¨Ä:ÔŸÄöÿ±?ýú¥²þ<ö³#[îWSÙ½ÑT¶•RÙݱlv§šÐn{¾ˆ²Ùn]BÛf”ÓÖGÓÚv1­y^îÏl˄̖¯f6Š…±ävëkÑüvókÑä6/–ßf«ùbÒC«àó`¸‘dŸ_^ß!Q45m=ɼö††¦›zz’ú¹N`¯Ïg¢^_Ü+Â}2·úCöKŠ¢PK4…ÊLõX¬ÏIC9¨×›v{}>\C1Ρ©"œH2©««£q¬®®ÂPŠ2V>sè]3!oq)ñÃ4åîq}>ƒ?Û’‘‘‘àL`Ý®ïsj¿fÔh‰%³>_3”VŠóy*»§¯¿$¹YL(èº'wS¤5ho›S^Ÿo‹¹qx"yŒÅbö€Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï€QK’}~M[DÑ”×w$ùò;;;G†¶×çsÙ ÍNÂá?ØX/J ËPÑHþÑ0”ûÇÌZÛëóÅQ6; MÍÁ &“!%ŸÀq-‰µâ¿mq)y×Å]4½ã®2+ð½ yƒC¡3ÿVR„-„Ãaq(­ç³Rϸ³*‹Ž(’›Å÷Øüùÿ‹ô(ö¶9…>TŸŸŸŸŸŸŸŸŸŸ`È$Ùçw‡û$ŠÆwº#24ìõù¼’VâEy ?7`z©(Šßï§ÓruIÇ»ÝnI#飙÷£?IÐsŽ`¨Yé÷;ìõùt¯½7; MÍ´1ühMY^ÃÏ£²²eS©"Ÿ|[Áâ6?^óŠÅ¥·ëâú|³쪡ã 7&Ĩ1ìl©*ê¶RœÏ·HˆïýàkÉbwy«ë¿>ŒTØÏ…>?ú4D `ø½Îg©ÐÙø ¥…ÊÓ>|>|>|>|>|>|>|>|>|>|>`dC_ékc‰ -}?¥/’èN’}>qø|›DÔ\ìêÅ  {}~DÐõ†g…¿™Ï§uÇT°!n·[#]éWf†322,jÞÑ ÷·Ô‡úwm÷ù¢®7<‰(üÍ>šŸD ·™NäX¹"Þf3­mxùŒ!,%®"5{^ úüÁ®Ûß!ôïR;™É§nIá½ÏJq>ï1c~0vþç’ÛļÞYû"ç|¶·sú|6“iÖi&îC$îRZoá¿ðùðùðùðùðùðùðùðùðùðù€4…Õ1z½^ú2hXvÈ‹KõtÃê3’ïóO6wIDÍñ¦K”!`»ÏçºÒ°ZR|×ÐçÓÚäK/33³$† ìxW®1aòãÂ=›ÏÈbÙîóy»áÇiÞ5<Ÿ-4èl&Ð|†Ä}ÃÊñ©• r´²”èöÁ‹ç5·‹>Ÿoʈ~°«FßÃâ}ÎÆþÐív§ö~g¥8_<Æã).<ð‰ä6qUvO ø¦HkÐö¦ŽBŸÏ&‰f^‰3œ¦"Ÿ~loÃçÃçÃçÃçÃçÃçÃçÃçÃçÃçF ¼ìÐLžV—‰E¡ëÙ$ßç·õ„%¢¦ôœ’üNèS”ÞÊÊá}æ"…ûZ•ñ`µ÷rŸ/Vàë?N¬Þ7ôù\0ê%0­;¾rù¤:º$»Ã} W†P;ã^ /Æ6Î|8¨KãÎ>LŸX¯AS½ox66ÜúàˆP¶mø¬ÇJŽÒOª¡!_J@€.™–~Ù¢Ïç.öê`W~ÐE+ˆÆp§;ÉX)Ρy"¹G”kÉø†ÈQG¾J$ÍçÓ Òœ·/i¤Jƒ•­[+î‚ñáàS‘ïÜÙ8£àóáóáóáóáóáóáóáóáóáó£ -½ÐȱºL¢ôQ œ|ŸO<Û*Ñ5m=ádö@8T22ZÇŒþAí ›¸J±‚×:Ÿ(í5‹KTý†>_s* |¯ý 3Evé)=»z}§[$Snøµ“Z+¿^Âmø®($­#÷ùi¯o —Òú³Në—cvZ³c×°Ö—’¡Øä]G7)Ã=:@|jLô¨ƒZ5†—/®VºÁÉ÷’ƒ•â|ºSkÿwÜ„ïÿðjúµ¦­G²F -´çו}üNÜ•2’æóùÿO¸0l·kpõ÷6ú-<öÿ.Ã'Dìmø|ø|ø|ø|ø|ø|ø|ø|ø|ø|Àˆ‡1Šf^£VDáOßI¹3aEq¶#N_’ãó/võ>ßVVÛÎ\}Ec§Dלùº;™=.2ŸÅ¿M†É ŸÏš¦XóºÜçZzEQ˜Ûd~X¿¢í]¡¥ç”´ù,žm•_ŽÜ7:áóyi®¦n\ÿºÄç›e: › q/y¸ù|ºïè éy×YA£Fµjä—χ&îXÛˆ_Eó¢•â|êÆy;ïgóÿd}sy}‡Ôçeq¥ äû|þTª|>k‰8p|kF“½nãüχχχχχχχχχÏŒxå÷!z¹AÇð\.—¾Ÿ]E‰~r|þáómÌÀT4vÒ¯òò˲Úö¤]~8L#™ÏÂðB¸ ¢Q^,÷ùš:|ަnßÐç‹V“þC_·¯?›˜±éÏý~ÿRnJ|¾ÙRr»Ýâ=H³:¬û|½Ôª1k6û+³A7|¬ÀÆ[‰x]’mqG#:W}Á&ÿñ¦Kò§i¶>þñðù4 -4‹hEðµC¯” »hbÔ¶0iÈØô¦ ‡>>>>ß:ðùðùðùðùðùðùÀ ï¼üë¶™—qáJÓ!¹‘.$ÇçózËÒs -{E¢k|§[Ø1¬ŒÿàÙÖîpŸC û&J/™¯è C^Ùkñ`ÏèÔ}ÄHòú|EQØßŠÅÌt~:fP–ÒÒÎçK&|\6(Efv°ÞçëÕ}ÄHòžMLÚ\ì{<C·oh5%;¼…ܱ'¸Ekq)‰î]ì1£š™XºC62‘U3¨ `;¢·w»ÝúVIŠó©7®ÊžÍ'ÿÉæ.ÉÒ¸û•O~xJܶ—¤ùüá¿d6Ùø:Òï71ó¯y¨Ä–†Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡ÏŒlÄâI³c¸zÊ0‘Ÿ„Ïç‹{žÑ@r|¾XßÖ¦WÊjÛ%Ò†Žöds—­ -‡Ã---_]}ùüK‹õëÂ^ŸÏ— ׉úW }~D•“ôŠXÉ,ZJzËÆGcØPvvû=¶1”.!>%U>Ÿ [_Lé_‰˜ÒÓyÌÔ.½.ÎøجÊ}B›ïˆBÞúyøÓ †O¦èu¨†¼jRèó©I|\Ì ú}Ãâ|·Û]xà^r/_­÷=úWþsCÇÛ¯eú|q&‹;núQfÓÒÆø|ø|ø|ø|ø|ø|ø|ø|ø|ø|À(Á°$R/q 5$òEr$‘ŸßîãæÌ×Ýô -ý+‘6¬ðòðù6+†sÈÔÕÕUUU}öþûJA’‘1ÌM~›ËÕenòùúj|}ž™Ïçús½§¥SÙ¥ôÙPÝÝ݆oºtðlë07ù¾Ó-4óåO£¤ÊçGtÕø†ûò¦#}>¥eQÿjž“š4iÒÐ|>oϲÜã'ç¡õ¥Ä¯7AŸ?äU“BŸ/Ú`~Õ\ÿÊ‹óéÈüÂåâÖ­|î|ºV󗽤ÐçƒAútÉl… ËífÛFl¶Ó»6îÃÂçÃçÃçÃçÃçÃçÃçÃçÃçÃçF¼"TRx,\ìŒÂ2<=Éñùœoë K¤ÍÁ³­tÌÉæ.þŠMª©©aج®;pÈçG -|½ÞXðù"@ÀãñpÑ缇ñC)'…>_#ð5zŸaý£™Ûç{¯<¥¿ôÒK¥*o¼ñFe ®²+upÿÉíº¸Ù$WkŽ·¾” {Ï.Ÿ?ØU“*ŸÏ»]Ó|¶È‹ó#÷vÅ'¹ôQt¤~ÿ‰²ŸËë;]_ÉÿA+Ó†­'˜EE±wvÁçÃçÃçÃçÃçÃçÃçÃçÃçÃçFV¾ý‰ßǃÁ älðù‘$ú|.çy]eé9E¢nÚz»zù¯ WloR{{{]]]ccãGç|¾Ïçã«IüY¿âD¿Ä\«Ù´ý阑4”q‘[kç|>ßN¥i þ¬o›x¶P(Ä&ƒYY¯f6²¡ljj’ŸÖn¼yµ¿•U ñ¢Ö—_âƒ`‰øüDV ß±±|:.4¸¼Ïé¾·"Þ… ˼ù ôã`EÍYÉMaÿß.hžó²´ðùìÈðh!|>|>|>|>|>|>|>|>|>|>`4`åÛ×)q¿ÃçG’èóõr¾¢±S¢nN6wÑ1϶²_7]Âü—àœÏkòÅZ}ýªM³|’Jéä̺ 7¨†ï:çó#BM¾¦V_2¬\z›9v³ÏÂlá§¢.’oæòV‰byPK‰þŠõ†æÒñù‰¬šäßΨø&ø[âë†ðm ñA­3åù¥ïWJn -÷má?w‡ûœ¸¨4ªÏ‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï‡Ï¤V¾ýq#ÿ†È-%|~ÒÌ*—ó‘†_eµítLy}Géæ9ó_‚s>?ÓGÜ^z½^ÃU)š(·Û-iÿÍ©À ÆZãÒ5}ë„Ï矋}Í õgã•üfíá—#),·xE¢aÎÈÈ0[ ➯Og­,%z‹F¿'âó‡¼jøí,™Ž—·Vó„ß+1Cœ6ü¹-Šæ²«%w„ÝåMOžúJ¼;8Á0÷ù4ÃùûÜèä4vÔ ùŽ¡½-™·~¿ŸÞÕÏy}þU3®»eÞø­ó®ß:÷†­so*š3±hΤms²¶ÍÎöΞâ=Ý;k†wVŽw֬♳‹gÎÝž3_[väܺ#gÁŽœ…;)fäíš±x׌%»¦ìž¾t÷ôe»§î™¶bÏ4Ïž©«ÔX½gêÚÛ¦¬»mÊúÛ¦l¸}ÊÆÛ§lº={óÙ[îÈÞzGÖ6Š;³¼wfß™µýά{³vîÍÚµ7k÷Þ¬=wM¦¸í®É·ß5ùŽ»&Ýy÷¤½wOºëîIwGc"EÉÝïQc_ÉÄ{K&ÞW2ñþ’ ?cqÏ„Ÿ«ñ‹{nú¥¿Ú_«ñ›hܸŽ߯þXˆ…/ˆ¼/Å{c±O{nŒF‰wRÜ¥Æ^5îŒÅjÜ®Æmjì»ÕØ‹7EcÇM>ŠíjÇÂ+ĶX©±U-Ñ8°yBlRc£b±^uj¬Æ~Š5j¬¦˜UB¬TËj,W£Pe±XÚP¨±$ùj,ž¼X,ŠÆoÔøuÞ¤_åMúeÞdŠ_äMþùâÉ?‹Åý‹³îËϺ7?kŸ÷äg•,ɺ[·^ô;´Ì7.ŸF±aù´õ+¢±nÅ´µ+¦¯Y1}µ'«ÔX©†gåô+g,_9£Pe«f,휂U9KVåä¯ÊY¬FÞªœE«r®îÜÕ9 (Öäܺ&ǽ&ç–53o¦X;s¾óÔ˜»vÖœu³f¯›5K™ëf嬧˜M1cýìéfOÛ0{ªS6ÌÎÞ0;kã“7Ι¤ÆÄs&lœ{ÓÆ¹7nœ{æþ¸>ó®Û4oüæyã6ϫƵ[æ]³%úïX5Æm¦—ëb&Eso,ЦŠ ”p¶EÎd5çDÃÛŸy¦ª1Í;‹¥ –…rŠgÎ,žÉrÑœh:Šf¤y±¤DqóŽhjrDzӂ9¹j‚¢XD±«?SåïšÎ’ËWjÊšN)‹byâš¶rÏÔ•BúZË`ýIì¶hS#[HeÙEwd© Í{gˆ9Í0­‰™MLn,³í˜ÙÄ´&æ4–Íx*ÛK\ÑLeœ…,'¢½‘<iÒËEšt´Ý(y¦#ž‘Ô¤t`ËÀŒ¤IJ&%!/í—&𿥕ó’&5jSSüì´x@vÒ$¨_Å”>Gݟߟ¦î¥)1SQÜ¥ÆÞ‚¬;Õ¸£ ëvŠ¥Ù·-ÍÞ‹ÝjìZš½séŠK§lW£xÙo,¶©QT8•bkáÔ-jl.œº‰bùT–¸ús×rž» ÒË`!ƒ±$¶l@›Á’˜>-ZmœÊx6»eí·ÙL“ÐxN›©Ëi<­M‹¥5}f›Ël<¹EóÛ&ãüF‘™?> ô}Sþ][<@þ½8èÝÂ($™>_/ç}§[$§;Üwæën§ 2GŽú| ÓT>ú|þbFF½ÎÍ3ý@¿r_dh¤Å5+VDë{Þ ŸÏå¼™ 7<›¸Ç*¶™~æoy<I;­_µÏ.–ÞéZ*cÐÏ|[ÊìCy“èo³Ï ï¢D|þW ¿ áC‡†8¨£ø^ ý ö¿!b¡{Kï[o˜»¦Ir;øÍ¡jÍÓ[NdŸwïC‚Ù/Cn‰~àÄhÖÑ@Ó1öÎ"¶¦ 7vÅ]3ýÚ·Ñç#ˆ‡|:”åз1òbø_ O¸K1ô–ô ×L³hðx¿¦­‡ ö -7ü†AÇ·õ„Å_1ÿÍpÔ狳hª‘#&>_\bÉñQ£®RÍ$˜s>?"d`C±lx6c7,Ø–çGãóÙÇq (ÁìÙ¾ -âbø@">È«†?7¡Ùksîíé_qìâ¶_Óíü¡­«²{ŠŽ(’ÛÁËÇÿÅ÷é¾àÐu%Ùçk6ȬcoŸ?,ÛÝØÚ7ÜFtö°»ûÀç#ðù€Ï¤5\~ŸåßCåUdâwöQ.“éó»Ã}LÈпì±ü^åõ¡€³¢±óß G}>Á©Þ‚šù|6» E®ËåJš‘0±¦ß[‰8ïó¹ú3ÌÀfÍ -q Í$¥t¹Ì Òç3|>Ÿ¦žãv»%Ë$®Ï§)Mg ‡a³ôùC[5lyÎç…BÔb'ˆ7V³®ÓtÚÅ®ÞÃÁOŸ=üè÷~ðä^PrìËP¨>Þt©¡ãŠs•dŸ¸Afe ‰æ§oðúÚbàë°hÚ'ó>Uàóø|@ÀçÒ±T˜Õnñ·ÄÊ@IÕ½X,jïÃãéH2}>ÑÖ>ÙÜÅ«+»Ã}‡sðl+SÑØÉ~=|¾ ó?íP¥²²²$†ÏçKZ ñ†º1Éõض@­õûý|2¸&ßÞOᅪԱjxwÒD«Y›ãªiãÝóŠì{rï™PÐ%¹Ü´19W‘|ŸÏaIÉDö'Íöœa°ÿ-¸Ýî$·Ð Ÿÿ¾{é ‚EÙ /8´~Ñ·1òbø™ [ÄgÃÙ÷Pú®§)hÔ—_*ŠDçâüHÒ}¾^~o»z:® >Êf,ãI6.Á(ÝÔô¥ï)i†ã[Lg(rxŒë¿B…Ú%7‚9+{’s£Ð糇;4~H|~òÿ«à„Ï|Øsßfè·ÖòÃF!)÷ùÇ›.I4ÎÉæ®ˆZÕ±«ƒ€få¦Üâ‚ÔÂwv|)Uš@`L<Œ18SR¹7û;ß•=¨Ur¬e̘Ëɹú|ö ‰¾ÁiØÅjÒ|>'0Tôf–^0d¾¦gRåó/võJLÎáóm# q¹\))èÖÀi&¤° ¡PHó|œÓYzÔå™ì;ÿ²ä.°p_‡ËÕœœkI¡ÏOm±âóYý›äÂçÀH" -ù|>úv™­âõzÍjÛDŸŸ™™©y´|4“rŸOøN·HdNw¸Ï¡Ïmmm­®®®«« ‡Ã˜ iÍèJæGX‰> eUUV¥xq~ò‹ºEè–*—ù.—‹MÑ`0èñxèNÝ?c[ƒÊÿ¡h—ÜÆÎ¿ì]ûa2×Ô¨òùÌÒûý~ñE}ðÉ–ü Dø|ЗtúJßXC¡zCd8øüòú‰Ì©iëqès««««T:;;1ÒšQ;”g„•ècUZ‡eïÔ>köÿÙ7ûà6ª{ïëOÊ 3âþhfîTÓçÎô™¹£ççÂ-5}á5¡KH€„„n)ÜR¨!ô¦´æ¥o’JHÀ"“@J‚ LE0o /Â/ØØoLŒ¯C­ŒËŠ…õü¼':9ìJÇ+k­]IßÏ|ÇcÉ«ÝÕžõ9»Ÿýp8ì›gŸ}–-L£ {Ge6\:é”iIÿO¡¢«O¯Ì×ñ‚ÏÇãÔ² R‚Á Sÿõt]$>saXohÚ½ -ø|@Ä >¿óHZ"sZŽÏÓv™9Ìd29PÍÔmSêºNÿÂj é¬jÇžžüWÎ -µ;µ¾‹³3Dû]ŒÅ‹³¦æglÃYúw2’þå†1ÿÉ}¹ÝÊ#Wþù#Yqð)^ `JŸOôí{n8× ´ Út±'ðù€ˆ|~:+«ÏlêNÌߦS©´am€¦DSÑu]UÕH$"YÀï÷Ës0eËsSMŸbÏ t}ÒçË-¹S6?ëôE“¡³ïͽ®Ì·vÑçÓ1¡ÃeÇäÓbt0¹{/Ÿx<Λ2p{O—Š¢ð?Ñ/ŽçG£Qö4cÝ|> âŸO4÷ê¥321…–€Ê ºåbJßN%9w³´kay,ö™Ï÷^ã¾QIçÒ)ÓÑÕgæFb•ùâ.ú|>+ŠÂ\=;¢·WUÕï÷MÓœÝ:µ”üimÔq™ÏˆXç›Ì·ÏÿäËáø‘5œKJâx:l¤ÓœO)]_O·ýÓ„ôé=žO(S’3é3ÒŸÏ'F>Mö:6“FŒhcý R¾ìûÌÈ¡/û†Œ|>Þ7<þ1åÆ?ÿøpj&_¤>þWªw4Õ{„r´7q´W?Ú›<Ú36ÑóåDÏøDOj¢çhú£‰ôGéôG“鎥»§&»³“Ý_MvOgºs™®šJöð|um5v ê$“ÅÒ=“´½LHst¶¤º§g͸4_Ζ1IJ£Ï–„4GldT–¯(ÿbù¨p¾°—ÃÒŒHó?ö2,Íç³eÈFÍ–ÏÇ‚{%ÀÜ {ÛFGqü¾¸ºðˆÏo>*Q:ûOàÌ€ -`*W ÉR>pHà+ù€°¡Éï5<.éùoÚ®ûOÌíôWì»»èó™½b«ÏÏíó7^G"ëc:¨¹­šÝ©CMçfDß®à’ÖG eú|ñã‚< Þ?O=Ž-‚ Hí·K€¹aG#”„ƒ“Ö«úxºëóG&¦$V§¥?‰3æ›x<ÎÝ;s¹V‘+ÛCQ¾¼X†m¶{v·Kzþ³–O„ξ7÷v¨b_ßEŸo ÁŽ›Uq³§-Õ·ƒ§AÌÀqÏ¡3DòÀhVàó>AÏTðùót<Ýõù„Ú1*;éì4N~˜?"‘Ȭ2ß$ü øECN£L_2ÓÒŸlJ±¿Ê»ýo~gê·Ûö?ÛÙ921U™#àºÏ/HØè‡MK²÷C!gs°‰Šâs„J~ß9gø|ÏGAàóU„Éç7”uw}ÏÊûü‘‰©æ^Â\MëÁq‰ØéKfpòÀ<‡Mös“ù&)Ø›ôAMÓ¸À?Ö÷ÅaIŸÓö‘…k>g¿ÓèP™ƒà¢ÏgV21µëãAIŸ¿~ÃÃMÿü€ýÎëùç}>kõëjší‰©xžµ‚SCv0dS**ùeùqö‚Ïÿ÷+ÎùÞƒ×Ô@δæ¯39ËFþCÈ÷çjÊÙùü€òЉ4äseãÕ?4ò£!–ùÉÆÐ¹WQÎÛ¸ê|–¦U4­º°iÕEMW-Ü4“E›®ºxÓJŠòðL.yxåâGV^úÈÊ¥F.Û¼âòÍ+–ÍäÊ囯\±ùÊ•[®¼jËòУ˯~tù5.ûÙcË~þز뚗]ß¼ìÍWÜÐ|ÅÍWü*ry8rù-_¶æñËnÛºô×Û–®Û¶ôömKŸXrÇKî~òÒ?<¹øÏ-‹ïyê’û¶_¢nWØ®<´CiÚñÓGž¹øÑg.Žì\´mç–gnßµpçs=½pOô‚Öèßs~ÛÞóc{Ïko=÷­ÖŸ¼S[êß6Oÿì5v ê+ÏÙ+dO>»ó‰Zò\>»fòö³Bv²œ{"Ïäót>;òÙ~î[¦åé{n¨üü,}>;VŠ¢ˆoÒU BûFW8¼±ÔÒ%vAØ,¢2—Oš¦ÑOŒXž’&K:èóÿÏ/6¼ôk/çœòò×nó#!?¶ä'/ϹFÎrþ+ÇsÁ+·]øÊZ–‹(mk¶­]4“[)·ÝúÓ¶[#—´­YüêšK,yuÍÒ¬¹ìk.ÿÇš+bk–ÅnY»åÊØ-+b7¯ŒÝ|Õk7¯zíæ«_[};Õÿ¹oõµ¯Ïäº×Ã׿¾¡ò«ßøÕ¯Þ¸iõ7ÝüæMkÞ¼éÖ7o¼í­×½õËÛßþåoß¹¡ñîz熻ÿyÃÿù‹{öÿ×½ïþ×}ï^¯¾{ýƒï]¿ñýëþàç›?¸ö±øµxíþ쩎ÿ|ºóšg»®ÙÝ}ÍóÝW¿ðQ襞U¯ö®Ú×{Õ¯|§Å{ý+>üäÊîO—|`ÙeƒÚ埼ì‹Áˇ–ŽZ2ùù¥_ /Î _RSß1_ÿó5v ê$Ÿ2rh&Ó,Ÿ-žÉ ‘ƒB´|Œò©‘OŒô³\:“>#éÒ“ÏG—~EéÒe¤ÓH‡Ä|0“,ËûFÞËç]!ûüsÉLÞ9‘©·¼eäM!oi7òº}Kgòš‘Ø×ó#¯iòŠ‘—¼4“c/]6“¿yÑÈ Bþ–O«‘ç…ì½,CÙcd·¨‘çŒìò¬‘3™¤<#äi#;.ŸÉv!Oi1ò¤'Œl3²UÌ“‰i>‘ôcF5²EÈf#y˜eÙñl2Ò´l‚²QÈCFþjäA!¹ßˆ:“£<ŒÜgä/È\òZø"ø|€SÐ-!ÝBì—‹>dbJ¬Õ¤wZú“½CËì?<Á~oîÕÑvP>4h²Q sªŠ¢Ì*ói=º®›>HC ÈlµÔoóùVƒ½’Þþw{?nkû½øÀ·2¸èó骆m—öA|“·Î¬‡zΰ§´Î -\8™¦XJÉχχχÏGàóáóáóáóáóÕ Ä~™¸èó µc”›¶¡½äº¾`è¯}É ™ÌdËÜz6›M¥R8 ª4e-5åáÇє•$‰PÿOÃe1EÌ«Äå2ßô,ÀÔ”ÔcóÞ»óHº¹S“ôöϼ¬5}p€ËÿŠ -}>këózǤô­‡º|èJ)°g:áp¸±8âã†9ŸŸŸŸÀçÃçÃçÃçÃçGÓ4º e7¤ûöq×ç·gƦ©;‘ûzž5-ýÉtvZ4Ben}`` Ë Nç@5ƒ¦DS‚y‚VŸ "‘ˆ¼)©Ç>1Ùê_ŸHºzÊkí‡øï}ÉLž¬»>¿º®«ªª( - Óô‹ƒ•ù­ÓW -tÍààqžó…|>|>|>|>ŸŸŸŸŸ¨%âñ8ľ}ÜõùÖzû¦î„Dò¤³ÓͽºSE›}}}L7¡¸ÚASÖ ===hJï`§2¿ Ì·6å®c¬ën~/þn׋’~þ/Ïõ· ¥ØïjÇh%¿¯7}þ¼ŸŸŸŸŸÀçÃçÃç#ðùï ûlF¹ã3Ö«w}>ÁÎþÃ9¡b¿`ú’™öá£bI9Œ á4¨vД5C"‘ ¦Æ¡p›2Ÿ³Ó”jÇ(ëºÛ_^ÛôÏ$ýü‡ï÷:øÜ¶$êÐçG"‘ÆR Cäàq†Ï‡Ï‡Ï‡ÏGàóáóáóáóáó  r±_çVßuŸ¢h³WÏ}½bßšÖƒãƒãÇøË‘‰)œÞà8eÊ|b¿}×;$|ã¾Ïµ¾Qñn%¿uú|W€Ï‡Ï‡Ï‡ÏGàóáóáóáóáóÀ&ž#ÅfÕ‹ë>¿óHš«›d&›ÎNKT«É7•ôp -]×mÊü`0hs|^Uã¾Ñ…kR’N~ÏîvêØùK*ùÝ=âói7f-›¯êKø|ø|ø|ø|>>>>>ìFM¦>ß]Ÿ/ -üÁñcôNKRb{F&¦xI?Óû¬P÷N{8¶ÿ]׃Á M™O Û\í»½¬Ó^rçxã¾QI¯uõóbþÖƒã>b®û|j2¿ßoçøÓ’Õ{fÂçÃçÃçÃç#ðùðùðùðùðù0+Lã¼M†Ïw×ççŸÌdé¥Xœi ýU,陘Âé "4ä‰3Ñlsöe> ¦š¦•°C;ý¿¹ûÁ³–ž¾hRÒ½?ÔúÁ´ñŒ`püuõ.ÎϹíómN‹€ÏÏÁçÃçÃçÃç#ðùðùðùðùðù€ÚE¢ñ@8ŽÇãu~ˆ¼àóÓÙéÁñcLæ#SáÓÒŸ¤eÔŽãžíÃGqž#‰Pgnïì¸w ÅGr™_ÚÐy ’kñN[çó^r縤{_ÿä»GÏEŸO '^ŸÐ¥K£§JèB¨¡h?<Îðùðùðùðù|>|>|>|>|>0 ñíãŸo¥©;!q>´@ÛPŠý>8~ ‘HÄ*äƒÁ ñKŸ-8bÚ”ù4àÒRt`}!¹î ŸoóI§LK:vÊ© ¾*]Í:‰‹>ŸÏŒP+{¬O*0/>>>>χχχχÏ4þð¦Ïo=(«áìKfh™Áñc#ShA@CݸÕäÓ;6K©iÜ´érƒÁ ®ë¦ÓØ*DFb¹_ð[«}¾O_4)éØoÚ®û|ô]&]<’.ú|¶Q:˜Þ®}ŸOgêóáóáóáóKn>>>>>Š_ÞôùGÒíÓ6”BÃ@îë -Z4ùVñnEÓ4^>7™Oã/_@Q”ÛØ§Änÿ_>ßzŸ¯ûÚ-IIÇ~Öò ŸvÉ+³Â›fµ3™ÂYè)&EUUv}åHe¾é8ÃçÃçÃçÃç#ðùðùðùðùðù€º‚nBÃá°µ(¿$¼éóÓÙi‰öiêN á ÷u í—OÓ >·/óiåk _ -¹ûåŒÏ·þÔG%½:å¤S¦ƒßz'—Ñ=r0+¼iö`%zð£¦g»§–nÎåÇ>>>>χχχχÏÔš¦Aã;ˆ7}>ÑÜ«KÌO2“-‰D¢§§g`` ›Ízê»4e=7eWWš²$TU¥ž¼¤ÒnÞóÛF«Ì§wÄØú5åÏ·Åù[ÏZ>!éÒWnóùr‘ëB¹‘˜‹GÒEŸOXtŽƒ ++vX4'fPØñù´!É)í Ïÿ÷+ÎùÞƒ×Ô@δæ¯39ËFþCÈ÷çjÊÙùü€òЉ4äseãÕ?4ò£!–ùÉÆÐ¹WQÎÛ¸ê|–¦U4­º°iÕEMW-Ü4“E›®ºxÓJŠòðL.yxåâGV^úÈÊ¥F.Û¼âòÍ+–ÍäÊ囯\±ùÊ•[®¼jËòУ˯~tù5.ûÙcË~þز뚗]ß¼ìÍWÜÐ|ÅÍWü*ry8rù-_¶æñËnÛºô×Û–®Û¶ôömKŸXrÇKî~òÒ?<¹øÏ-‹ïyê’û¶_¢nWØ®<´CiÚñÓGž¹øÑg.Žì\´mç–gnßµpçs=½pOô‚Öèßs~ÛÞóc{Ïko=÷­ÖŸ¼S[êß6O]G¨úÊóFö -Ù“Ïî|¢–<—Ï®™¼ý¬,çžÈ3ù<ÏŽ|¶Ÿû–)Oia9o&OyBȶãy“gk>çɧù|s3ò¨-ùl¶ä‘|6²IH“‘…ò‘¿žÈyÀ’û…¨F6äsŸ%¹àDÖ¹WÈ=Fþ|<í<ÊçBþ`ä÷–Ü=“×Yî2r§;X.<žF!¿3ò[!·ù%ëX.šÉùõEûXn³d­[¬rËL^s³‘Õù„‘Ò²yE|> |¬ß‘ãé5Ÿß>,+æì<’.===]©T -gBUƒ¦DS›Äb±‚Ä‹ -…¬+áÛ’eXSþô§O>ÿ͵­ I—~ú¢Iÿɺþx nëósùý‚Ó 8X¢/ñùš¦ÑgŽÐKëã$}>‚ ¨÷ÏS¿c‹ R{Áý`n˜|¾¢(åáH±Y O¯ùüÁñcù³ëÀ˜›dæ0“Éà?«ªASÖ ÔŽ===hÊX,fÕ˜å@k ‡Ã¾R å ®G”ùÅÆÖ” <äó­?uA»¤?oÜ7êóåBgGro‡\?æ.ú|:°t0y•‚üÒ¥¤éŽÀöÍ‘KºîbßÂ:­ƒþD_ŸÞ× Ø´ëFáó>AÏTÖúü2©üM±7§×|>¡vŒó?ô'G6‘J¥  k4emÍfë¹)u]F£¼>™~:¥ôK-˧M[]+ƒv/ ‹í!kÊo|Åç[ú¢$>Éã>_.ºZÉÄÜ=þîúü\)W8´d…÷?¸T0QŠ¢ÐvM¥ðùŸ ‚Àçªøüy:žôù»ŒIÐàø1ü;jMÓTUeõÏŽP´rfDí ãñxÁµE";2_$´tÓÊ Ý’Îü» ™ÀiZn·ûwîú|qÖƒ×|>o÷P¨Òs(ØUŠé>AàóAø|@A7• ŽRÌZÔ ^öùGÒÔ6”¿ zÑu=KÊæm -sÉú©‡g¥þöQE²QîuíÎÈèÓÖ5î+:ÙŠþäóåÂ竹^ÕõqÑ竪*¶;R*VŠ@gd›µ1Сp¼>¨^¼ì󓙬Äç7÷êh>@õR° ŸëÜ2Ÿ5ÏÁäª 5JËØÙ½‘‰©]Æz¥û» »%=ùÊ c'2ý‡è‡ô{ûðQw[ÄEŸÏŠó©É¢Ñ¨NÂbgfå…މu»ðùê¯ùüd&ÛÔP;Fû’zÙÜ«KDP:;T)&ß®(Šªª¦:ä9‰D$5ÿÅ q¶ä{×±|þç’nüêköÞ|ÛÓü¥»-â¢Ïg¥¹ÂÛµïóËœ-27Ø%Šõ|>€ºÅk>¿}ø¨X~ß6”’ˆ Î#iþÁd&KAƒª…H$Bo(rª${n&Ÿ=Jp\Õª£’Þ›'Ñôo-oìöȬ+×}¾³Tì0«Ïƒž¢%A¥ ­[ÿŸ nñšÏïKf¸çIf²âKkZŽ›>Ūú ~Ðuzò¹™|¿ß?ªvdbÊŽÌß²7–|æßøËý‡'Ü=’.ú|æÕ]ÑæÞ$ÓÉYlR|>‹ÅÂápƒ¢(š¦9¾¯ùütvÚT~/qAjÇ(ûTK’½³ëÀÎ@@ƒB(òûý¾9ACŒãeùŒý‡'ìøü—žòÝö?ñ—Ôÿ»{<]ôù‘HÄ;±ëÈe~>PÓPHãÑ< Ð`Î4Ðý{Á¿Òõ+Õ³Bï;kõ½æós9O?%:hdb*÷uw”Ìdq‚j›h4ª(Šo®X,æünˆäzÕ\F—÷ÛdbJ4<âKkZú“ìS¦ª~; t¤Óiœ“U šMYÛP‡¯ªªX³77Eqv†× 2zn§Ÿùü‘¿/´Sœÿôs¯· ¥ØïjǨ޳‹>¿Ø¤¼bØ1ðö·kgmlI:…\9¦=„ÏÔl––”èx„b -=‰ð‹7Õr‹‹Å¸ÕwêžÚƒ>ŸhêN0ÉÓ6”_L:;³TõÛ¡¯¯™CW;hÊš¡§§§š’n½©kUËÖŒñxÜô0wÎPo§¢;Ò’4¾”lxq~‹ïÝ®íøü×^ý˜—ñ·÷BÃÁçϺ¤G.àóµG±À© Y LŠ)tEQŠÉ|†®ëÜí8R­áMŸßzpœIž¦î„ø²`ú’Z&™ÉšÞ™•±±±¡¡!œÕš²fH$Ô”ÃÃÃÕûâñ8/¤Ÿ›Ò§;÷p8\~5>ƒ† ›*€6:G]lçGWÿoÿÉwN[wß«‡ìøü—^îá¿LLy¡í\ôù‘H¤±œÒ;6}>?2ðù0Oˆ£°È|M¬%Rì¾Øï÷Óû@@òÙh4ê`µ†7}~_2Ã=O2“_Zà ;MUýPaâñ8ëÆKõùº®G"‘P($~¼Lh(¡uÚÙº¦i¦Y4ДðµßçZ|ÓÖù|ë)û>ŸUæ¯ß½÷sñ¹­pÑçW:+ò𫎆âˆç†ê yŸ¨=h,¶^85#”O1…ÎއÒÏêº>—úÉ"xÓç§³Ó\ûtI‹/­á.¨m(å5;¨"‘ˆx'Nꬳ¨èæ]UUV#í ´B›&?g<#w›~·ÿÙRZ®Å¹î &ómúügZ»G&¦ÔŽQÖÉ{¤ëÄç‹_³$èÜpdb`ùÀçjêŸÅÙy¡PÈ#½.ÈÍæógõ5ïó‰]Ƙö™˜¢—-ýI‰Jf²9KU?N3@ňD"¢ù¤{ðY—ïÙ‚¶[ÒÔ­p8,~< ÆãñÒ¾y[ƒXœOùæw[¹¡{mkBÒi¿Öþ…±N|~.?°$EÑ4Í#ûŸ¨ah ¦ñ&ÀkSèlV;êóƒãǸ–o>*QCûO°Åø;ôYœf€Ê`’ùòΙnÒYWï ~¿? -•¤[­»1—:ÀCÑ\‹O]ù}.óóy±qßh±›þt$®y®=ãói7è2€ÏÚô»ªªº&‹ø9À£äG<ó|>€ -SL¡³RIºy—|–‹£h4ZþžxÙ狌LLI|~s¯ÎcÚŸ^¦³Ó8ÍÀTâN]t±%u]…BΚü`0H[,Õôjšfz Ùm»ú–oøO¾Ëäó¿}F\Òc¯Ü0VÊ‚ÊáºÏ§vä¿àSÕiwÍ6çHy@%Ï€*BÓ´˜£¸2™‘ß›‡ÃaºæõoôíèMúS±{vÚÛ@ À>^R)f1ªÅçjǨDñJ~¨¼ UæS¯ÎºwG €†9¢¸ƒs/Ànñ…ξÜRœ¿~ášÏ%Ýõé‹&ÝxK;,•ß:ïvÎP(äàFÙD€9>Íqø|¨"Lò¤|bn” J ¿·–ßÓ;Á`ÐYý^E>¿õà¸Dµ ¥ðߨ0¼šZRâN£ ïºË„¶ -…ʶt]W…Fœ2 ³ãÛ~a•ù>ßæ›¶ë’îúœ ¿òfkºëóÅs‰ÚE|ÈB;&Îì¨:ýî8ðùPEԆϧoA÷æüæ½ &ÍbZxîå”Eާ÷}~_2#DMÝ üw*L4õ듳 Ö‡¼®ÓаÃêóO]Ð*é«oÚ®—÷ aqÑçG"¶]EQŠM¤sŒ=ñ§ŸuþŸ¨a¨·wk -9À_„®Öhè^ž¾ÝÈso/ñùÖæU‘Ï'ÔŽQ‰&™˜Â?À#°ør†§`0‡zzë8±Øg…Šóן¾è=IG½pMÊíQWò\óù¬ü>ÈßÃùx¸C+o”Bg£G¦ÀçjêÛi à#õº°ú¨yølt¿ßO×?tgªiÿ+ýN×Hô>+oóøŒuºxw>—÷ùôÓÙÕåóÛ†RMD-im‰D¢§§g`` ›Íâß§ªAS¢)½F<ƒsÓøÔ«ªj<ˆ¦% úü•I:êoŸq̳ßÈEŸÏŽËöˆ.fÜ:] ðK#9Þ˜\Ÿ¨=èÊÁÚë:ÛÛx ºÚá&D^É@åæßËJß]ãÍG…Fuùü‘‰)‰&jêN”´¶žžž.ƒT*åýïДhÊj!Ú´£Zž&ú`uUâÅbŸ56¾Xp¯èó÷HER/×|¾ý ƒlÔvpÈæWDv@}>ÌÅzc”è VÑ4]ðƒA›×<ü’Éû5óJuù|¢©;!Qú#SöW588ÈÌa&“Á?QUƒ¦¬¨{zzª·)y§jßä;åHiøSU•:óJ–óÅZ_eþ7¿ó˜¤‹^¹aÌËòµ}>{lÓ@€ÖL;Àæ•ЉËÃfÐOï8%ø|@íÁæb[qvj6€wàþ$ÚüÝ–²„B!º*òùmC)‰,¢¿–´¶T*\ )kƒl6[½MIÃJ±›ñb„ÃaG©¦i4–‰“*vûÿƒÿ÷gÑ矵üo’.úôE“ñ¸w[ÐEŸÏÎ;b˜owê‘ Ûn àç!{Çtþ°K…J>'’Ÿ¨=ødsu^{€†+”9|Šnc]Üsºe…B´\ªÏZ¨É ¼#;Pu>dbJ"‹šºøwT]×™hµ u¹q'Ôv4-ø!^on*Χ¬Ü𾤋>ó’ÉÁñcžmD}>‹ý~¿ÜÛðrzûÕ rØ3 UPâ¬ßú<ˆ]¨Ä½ñ<>P{Pÿ/>—gPŸŒ#€Z¥Ÿ_ùÛvN±2Œ`0(¹e®sŸO4u'$¾¨/‰"m@E¡›?–º[Ÿõ¹­-ÒRp£Ô™W¾8ÿ¤S8}Q”"éœç<‘ªb¸èó5Mã§G±æSU•-#–Ó—‰u6»* Ÿ¦%Ù‹GJôáó5 õÆâÈ -…œêí<7ó%UŽñw÷¹˜ð)výV‡>?™É6u'ÔŽQæêÛ†RSÔzpÿ€òá–^®ßi1kA]1‚Á`ù÷æÑh´à¨A7þòêng‰<ôKKÒ›-î¢ÏÏ Ã1+ÈTU5–‡þ$§Šós…|>›`½$`»ç‘Kø|@ C×Ô-Ãä æáwÁ¡PÈæGøm{0¬ü³ûe.Òé%íÝ¡Óþ‹ïË¿¬³‡ÎË>¿}ø(³@ͽ:½™˜’˜"µc”0™ÉRð(S/]l±’d¾ýJŽ8R°jmêÉç÷Æ?¥ÍD@×'ýþ¹Ï_ÛªÙ÷ùÔ¥{³ÑÝõùÖ–-Hù“;DXi¸N:‘ -H°%áó8Ýu–t«+ë¤ò - ‹ím,ãû¦ºK­CŸßy$ÍEóóͽºD±2~ú)¾›˜´j±a"Ú—ùjX¶]Vï`©vQDr-¾™:±­;nmá2ÿÔ›ìË|ÊÈÄ”7ÛÝuŸÏW,Å7=¸q¼¹Ãá°õIS÷t‚±º}]×ù¥-ï…–‚Ï€€Ý~òHMÓ -.ÆnK¹¡_\™Ì(WètÃ.Ù½:ôùéì4AGÒôÎþÃYÔzpŸhéO2´ëÀ½Lf²³ú"kU?HˆÇãâ0á÷û‹•CÛ—ùÔµÚyj¬išjàÊ#æ¢dôÜ Áã2Ÿ2co7œõ°èóWnxß¾ÏgÏ[½‰w|~%¡Ë :ñL¢¾àîà“2Ï€Ú@×uEQ¼_0Éäi}>‰À´ŸõéóyA>¯ílîÕ%ʨ/™±Võ@1¨Cæ½.Šüyë¬XÈš MÐÚh[ö?RQÞçZ|ñ?.PÎ….¸M×'é½è“/‹2Ÿb_æ{¼7vÑç³R|:j ºå¤›b¹É…B.Ö@Úñù9¡:ÎdÚëÓçLL‰®>'~I (wþ¬ªßD6›M¥Rø¯©vДhÊ2‰F£¦é]ÅÆ>‘ùš¦ªEñJcˆäZ|ú–oN[Ǽ½ª¾§ë“÷Š2ÿ» O—äóÓÙiÏž~.úüªˆ½|> &¡kºx`RéR¤Ø$A€Z….‡"‘H8nhll¤ë"M>ß7vç>k%]ȱ%Å˹úôùDSw‚é ¶¡×—Ìd%ÊHíMg§Eço]áÀÀ@—A:êýêM‰¦,Q­óð4vÈ‹¨Å#­‡w¼V™ïÖÄ13‰x®ÅGQÎqu‰tݱîSqþÂ5ûìËüæ^Ý˧Ÿ‹>ŸÍ.ôûýè쟨=ÄÙÙv.'@… ìÎ]þp»Z’KžºõùmC)f„šºì^~_0GÒ¢ógUý"}}}Ì¢®»ÚASÖ ===®4%ï ‹Ý8S_ͰÎJ$)¶!êÕYÿoš2æ…gÍ'HÄs;ý¹_äº3¸·ohØ¡õ šd>em«fßç·õòéç¢Ï§!žm—NEwý 4x¹¥àóµG8.8¯GÀ#pw éöY²$¿´ãJ¿n}~_2Ã¥P2“¥wÄò{kZŽç„ª~öRdlll```hh'dµƒ¦¬‰5åððpå7M¬¦iÅþd-™›ƒÌ'Lë¡ÞCŸ‘Ñs»¹_ü ü'ߍ½ßÿ ¦%• #&™ê‚Möe>edbÊ˧Ÿ‹>Ÿ 3‡tV;ç 6gÄtršˆF£Þ)…ÏÔÅæÊojvãI7§Š¢4pÁB¿ðBww÷P¼qƒ¡P¨`9œ©(4dPŸ>ŸàRhÿá z)–ß[£vŒæ„ª~öJ¾̧Åh葯¯Šº\/ FèUs->}Ë7§­ãÞ>ý$Öúºµ8ÿÛgeáš}×né—ôÃk[ M¯ŠævÑç+Ë,FÁ€9@\æ³Çü ÜC”èÃçjq ‹¾pdPÛHª(M>Ÿ¹× -{ú î³dIú -¦oçÈ>T—Ï'Çq™Oì?P“ð>™Pœ€ÚF×uQwÓpÃï|M~F¼uÚ º~›õöœ¾c$¡¯ÀÊõÙtÕù|ÉLV⑚{uZ¦óHš~oêNÐÂøOÌ -u¶öý*uÈ´|Í|wU}‹ú`p«®OF6·Kd>åÇ×i’~ø–û&«å»»èóãñx¬œšcÈÎsÓåGÁ#À®¿T /N6lÒŠ}mŸ¨U¨{gw…ÑhG5õbá=¿7ïUéMnþ@·j÷ù9¡ü¾`àð%Çih°)ó©ç¬%™Ÿ›Þd–ÞïPÓ’Zß ÿ令>óµ[’’Nxõº¯ªå»»èóÝ‚]™Dze|¾¦iÖ§f6? ŸÕÝr™/Þ–ôù¹¯ósù_«Ð—eeawÓ+V¬X´h‘d%Ùlvtt4•JÉ·E Ðb´p%Wõü'£•Ôy$íÊ^aUXVå‘UE£Ñ‚unWE#‚8ÕKN(ª½Ã·Rè—\F§_äÅù>ß‹’xmkÂ4ÆzùXµµµÕ›Ï/øe ¾‡ôùtÙÆÿÑèZm0´¿ò2}þ³;wÒ§ayçíw橇Á±E©½ÔÉE2 2¨ªZÐÛóù9CÚ°?)ŠRÛÇZÿf¥«««££C²’.ƒt:]l™T*Å–¬äª^éøDb“žüè°+{…UaUX•VÅ$¤ÕO\Ÿ¯dZsÍö;Ö½0›Ì_ÿ|@Ò/¹s\Óæå ҟ쬊þjU[·n­7ŸÏ®ìÔçƒAñ´/>§’®Áø ûS]ÊôùâÇy@½žz[AÚK\$*ݲCÓ=©ÄççòÓÌï‘ìÔšvuu HVÒÓÓÃt‡¤Êqtt”-SùUýåƒ/$BÉ­½Âª°*¬ÊÅU½õÖ[gžy¦ØÑIV¥ë:Œv'v% ;{Õ××7ëôÔªb/uÎ*óC¡/½í¨¤û½ôÆ´g¿ uUÍÍÍõæóÙ/>Ó„a=üjÊ‘)ôïÆ+óí;|ø|ÏGAàóÕ/A7½/÷ùÅ>åeâñxC›¡»ï†â:ÍÍÍkÖ¬‘¬$‘H I–Éf³ƒƒƒ´˜D›ÌÓªv“¥}½]Ù+¬ -«ÂªÜZÕž={N9åîfý~¿ÉCŠ«ÒuÕÛVF­«¢-.X°@RÀìñÃNË‹ïëúd`Á½r™ nU”îk·$%Ýïêu_Ü«±±±9ìÕ|¯jïÞ½®û|:QEaC³„‚W5s@Ó4¶BU°â¦#@ÿŸ}³’¢¼÷ýþ­JÝηêƪS™:§NYÇœh+˜_`xµ£øÆ‹´ ¢Øˆb≎c£¶r_0Û®q±MÜ@<‡ã\B¼$\“,îÞŰÍ!ìÉ:=›v˜0÷7ýì>ôÎKOÏìÌÎtÏ÷S¿¢všž~yúy~Ïô§ÍާlýžÿmVö ’ðù|>@ àó~§q|>?£J6µ Ûš÷uÈþφ\„RÛá¼ßŠÅbÝÝÝ.žø\J\J'ªª:Íg(ÊzuË w•^E1ï¦h¡óM¨\é:­hq¾®ÚÔô‘Kî]Ó{î¹>ʊϰ%QRW¬”ÏO”賟š¦qÃωvÄûv¥vÊx”½Á -úü '|ù¢_ F|yÆå—L¿ü²é—_>íò¯M›ø©¯š2aÒ” áð„©á˦O¾lÆäË®™té¬I—^7éÒ믾töÕâ W‹7^%Þt•(]%~ó*ñæ«.¹ùÊKn‰9vÜÊãŠKn·ÇÅUˆÌöoµ€ Û7íã¼ÉŽ탟}uæDèt®µÏ‹Înæ¤Ké4§Ä´ðetîS™F˜l·ÆÕS&P³\9eÂS3MDñõ©©¹¾:m"µÅÄé—O°›±h\ê9Doq‰·¸Ø[|Å[üëôË7¼ùZ•ÒšÿÇTV\^øW/1Ý-¾Rz\ì9¼ôÉ¢}»èqh -ÇDgL;——™±Ÿ_ã1u8¾žßÈWŒŽ+1…"“²âêÑ1itLæÎDxtL9”è2éÎÓx8²bnÌpÄÌáÈäÒk1Ë×:â:v6æ1{8D6Ѱ¸‘ÇH&¿id’F¦!7çLI·äLOÎjôÄtq=Ÿ+³çPgÜz…c¶uœàœ-iœ‘¶â ˜™GæG{Š¯Ï™%3¥}­³fIê]|Šdó#u{63ÒøºøÊKàóUB–evoH÷¡Îåî>Ÿ×›ùèLáóó2”:ëâ”6ˆåýVGGG»{ý*¨p)q)9|:àÀ.ź®;=¼;…6•%ó Õç×û#é]R:fúíµÝEe¾ª~LñßvɽsÖ|ðA—Fe }>u-ï]±²>?wÔä…Ö©ÔîêÊç_zÿìðß -FÌØñè7ùÈ‚_¬^¦¯ZýŽòøÛ+ŸÞ|¿Úºâ•Ÿ,×Z–ýT[º­ùÞ÷__òÁ¦{>|uñîWýöå»?Þx÷7È^ZØùï ®¿ëÐú»¿¸àÈ‹ó½0ÿ¸:ÿ„:¿WÿWu^ßóó>{~žõÅÜøssûŸ›û·g‡c w&ì8Y¹ ÍÒ¾h¿t~aþ‘t¯_@GHÇIG»oƒüûòï^¾ûÿ¼²èׯ,оºhçk‹µéž_¾¾äç?^ònó’·›ïݬ-}ëeo´,ûñ›Ë^ýÉò oÝ·þ­û¨5žÝ¼â›ïjËkö5Ñco¯|tëƒÔ\Ê6åþwW-×W-yï¡Eï=´ðç«yÜÅâ«dâaŠù£cžsߎ;sâ;n‰ÛFÇ­#1§â‘[râf;¾IñËLH£bÍM#q#Åö57äÄ쑸>^7:®Ýþè[ÿ³J™mÊxuþ)Œ_‹©Ùñ(ibº{ìÈÄŒÑ1st\S(¶?:Ë×:âº|q}&ØE?ײ»ë6vðŽ4ªƒ±Ž7Ò oÎêœï?2‡ú­£;;6ëí¬ó;‡ÃÜ_d‚ç8ZðóÕ F†›sÊï­¾ÛŽEöØd±ø½‡î±cÉHÜ«¯¢Xª¯Z64œ—¿»ê>;VŒÄýÛV=°mÕÊ‘xp›BAÃÕH<ô޲:>lÇ#ï<¸fk&µã[[W~ëí•ß¶SÅ¿Ùñ·W>nÇo¯Œü,Of"“dÖmyà»#ñÔæ¾·ùþ§íøþæû)ýÐŽg6¯xæ§+~ôÓÏÚñ\ëŠç[W¨v¼ÐºâÅ·V¬ÏÄ}ÿþÖ}/½uß;6¾ußË?YþН¾¹üµ7—ozsÅë-Ëší œOٯŎ7[–ýäeo½A)qi«¶t³[´¥?k¾÷m;¶6ß»-™ä©ÿxÉ{?Î$Ò_¼¾ä};Ú^_²}Å=;6ÝCi–fÿØ´ø?_[LY÷¿^[L³ eàÿýê¢]v6¦øÍ+‹>²c=ËP¢Þ»ñîÿ›‰LÞþÃÙØ Ó¼³oÃÂý¶¿”I韼´°ãß3ÓÐÿ³g"Š?Ùó¥}óÅ4+õÐÄôÂü£/d¦š›øôôßê|š&(bö •™žì‰©²óQI‘pÄÀpd&Ê¿9‚²ßžL)¬áÈœÂgö¹PüõùyÿmŸ`¯}¦ì”ÿl·µCÝ&Ô8ÔDŸÚÍEM×a·$5é7,¤F¦§–ßc_>KÒµ£ëH×”.ñ;Í÷nÉÌ’K©Ÿ¼þæ2êH/ÙS$õCêŸÔ©WS·§A£†Æ—ôÜ]ðù€*¡iZÞ{CŸÏ+Ðüå±é°##TdƒÁðùDs§å¢•N žÉýJOO3‡ÉdƒÈ×àR†îînºŽå]Ê,-éž'ùÄá…B–>ë‰@gUHZéátkS&ÞËÿkÜøÍïŠÊüpxK:£ O-^û.‰÷†e+ûRÖ„ú|>Sw¢¿³ŠÆêÉ…Þ CRKwæ…;’þà?i¨ñ½o>>>>>>>>>>àwxaýk_îâóùí$Ý]6rÓÆçï>~ÒE+ííÌû­D" p)ƒA*•*ûR:ý<ÍîzÐKA2ßT¡i"ë‰@½Ëü˜‘qøLæSlsW1Œ^AXï.óiË:•YûD´õ7ï¹$^å™ÄßOù¨ûÕÐçó¿a*m–fù¢/P ЯI’Â6´¾®ë.o¸” -ÿé5Æ7àóáóáóáóáóáóáóáóáóáóÀYÛÆ5N^Ÿoš&¿£¤;h´[0|þ‰Á3.Z©¹Ó Øp»î.Ei -EÑ»Ì/´©,™_Ô”Ö˜C7ùÖ¦óoº4£÷GcY§Ä~²hq~4z„òmÏÀéôþˆKÖõcϯö#!UUiûÔó³–S÷¦³·×h˜Ð þ"ý¡¤â -ø|ø|ø|ø|ø|ø|ø|ø|ø|ø|@0pÖ}I’¤Úð{d^uæ40%½ßH|íó·êÿþþÚz0Î>n<sÑJC©³#Êù”Ó\䤮ëìe./ˆ¢X¨29«¼¿ÞßóÚ#s™¯-È´|$òѨu’–(¶•ùŠòaW<É]}QŸOá£þSCŸÏºeI5ê%Áæú܉žýpªÞ~]f,û…χχχχχχχχχÏ˲²t½{Õe:…èhª½G_û|âIúØvxÀÅ)íÿlˆ}k(u¶gàt<™Â q ìª(J“gdY.$ó ÃðÌOZéí"—ùʬ¹™‡·8W”çþ´¨ÌÅ–ôȃTú|°_/Õ{˃•7侓ŸŸŸŸŸŸŸŸŸŸŸ¨9š¦ñW¹ A7°†aÔÉÓ‘°7Ð]=°× \ŠNËÆ×>Ÿä· ¼j4o°uø·Ô}}¨Ø A 4+Š¢w™ï®U)óä\×/yÅŒôV™|kÓyáYæ”óšÖÎW|ò‘Ö¢2_ÖF/­LÉÓ»Ïßy,á£~RCŸÏvM¿^ -=EûજËáóáóáóáóáóáóáóáóáóáóáóu‚®ëtÓš%pè¾UQ”ú1ù¦iºhüB%£•µú¾öù;%˜2R÷õ¥íÂ{­ÄÖI;ªúyÅ> Àhš&‚÷4ë¥Þ>Rò¬Æ3ÖJ²Kb2ßxú‚Ðÿ|ÌiæuýSGû´•ùì+îMsƒ½<åjèó öþH–o¯ ü÷ ÚKĆÕ?ÐE¼Q‘XðùðùðùðùðùðùðùðùðùðùàG Ã(I19Ëõ+øHÂ×>ÿÄà™,k´íP¿‹Yê8Më4wZYû€ ÂiM²kíÙI·6iK' -ç¯ãZ^[X™=Ãøð/2ŸóSÚ,Éçûë5¨qðù–eE Ô»(Šš¦E])ãYRÙ¿:œT¤’>>>>>>>>>>|݉;o«%Ibeo¹*‰Ö¤åªªÒ:ÕN¾öùÄÆ1§œßÛ;èb–vKÐ:»ŸÌªØ˲JzJÅ@É|›ï|©å%I·¬Sü?pªþB!Ë;øW(mz—ùÍ–¿šk|¾sãïÕé…,Ëðùðùðùðùðùðùðùðùðùðùðù€šcFØFÓ4_¡5ÙWj"pø µ$IÞ«ì,ËâV¿RúÝï>籄SÎÇ“©¢rÉYÕÏ*öƒ{(òn))µR‚ X#(ʇN-‰|äü_Mk÷"ó%Iç_éŠ'K*ÎgP}Dà}>ƒ½#±aÄ~D¼A_{#ÀçÃçÃçÃçÃçÃçÃçÃçÃçÃç¿Aö~o8öÛɱÀŠóEQ,㻼â´"O"üîór¾+ž¤%Í–‹_Š'SiG‰éûŸö%>3N —T*ÕׇKðKÉ^VòòTÓ4ç PEQK÷¾ Þœ¼ ¬×õOG7Q{Q“O!Š-¬žß0zé¶Ã%ùüß™'ü5*ÇÁçóòƒ1â½z¡X' ÿ!ø|ø|ø|ø|ø|ø|ø|ø|ø|ø|(Ãçó -ùñ÷ùt;Ïv]Þý8ÿzE”ß}>±ñ@Œ¹£¶ÃiGÅ~ÞØÛ;Hëp+µÁøK{{ûÐБ¯éîîn·Á¥ ê¥Ôu)zú×} <§y! -Õä­ñ!S/¬ÅÃèÍZîEæÓw™Ì—åì#ê1þÐþ‰¿Få8øüzCQ” ->ð|>|>|>|>|>|>|>|>|>|> ᯊ3¸œ÷øÎ8ÝÀVä¥õ²žíºì÷Ö+xäðù\à«ûúècÏÀi¿ÔÜiÑ:û?:gø÷w ®Ûïtuu1 ŒKéw:::r/¥3c»ˆV˲$Iò.óiâ ¯4Z {—ùì)€ª~Ì–\þYI2Ÿ=-õרl@Ÿ_àóáóáóáóáóáóáóáóáóáó HI˜îèº>ÎÏAy»¶, >ßɉÁ3Ü õ œ¦%îE¤ñdj(u–üõ¡¿`@ùþþþîîîcÇŽ¡)üN,£KyüøqöÑ4MQ³$|Þ/RbÌZÓA\ -’)+R>ÿ©að(ó)týÓtæu°^AXÏ–\9÷—^4þ÷ÚºYþøÈ_—ÒÀçðùðùðùðùðùðùðùðùðùðù€¤R>¿&› yI’Êøº¦i|ŸOl;ÔÏkÃ.ºioï ­Óz0Î>Òw1 ¨C(Å ‚àE—$óiMÃ0 -픿í<£ûäcÛ=Ê|Mkg_žpËc×µ}ztÃÞøœµn öÍöoÕÐçSߦž©SÓ¦iR …B¾~µ>>>>>>>>>>ЀÐoØ79t“ö†$I.õ™Õ†°Zâ}¨a\pUäv>>?‹®xÒE71í¿·w}l=Ç€ ÞPÅ£„/IæS¢+”9³¶C™¶®(i¥wI™H˜E×µ¬S’¤—*óey_¨Ìº1ÝÚ”>U”ô’Mq—»cû_ýÛëjèóé7‰Ëë'NèwNM^-¬ uåó/šñÕK˜¸bö˯/¿næÒY×/™%Ý3sÎâ™w.š¹àîwËÓïY8mÙ]ÓV,˜ºrÁTeþ”Õó¦<2/üè¼ð·çNþ·¹“¿sòwN~òŽÉkîŽÉOÝ>ù{·O¢xúöIß¿-?¸mÒ3qõ3,n½úGŽx¶ÒAÛ¤}Ñ~鞺}ÛöAÒÑ>6wò·æ…×Ì Ó)Љ¬š?…ΈÎëþSï»kêò»¦-]8mÉÂé‹åé‹äéòÝÓïº{ÆüE3æ-šA­qû¢™·.δÌÍ÷̤&ºqÉ57,¹æú%×\{ï¬kî5séµ3–^;uÙµSf±œÅu“½Å¤œ¸:'®Ê×_™W8ã¾ë¿‘/¾î!¾–‰ÙYñÕûfoúek•{™Ërc…טPJL,%./öÅÊ_+™‹þuo‘·_}#«ûåtÎ|}xT'Ïn£†µÑbª#¦9bº#f,=3³ƒ†ö¬k–fÆ8Ŭ‘¸Ö×%O;®™=7äÄ#qÓ=,2É„Å7G‚2ÌÍ‹gÞ2sFe¡[eâ6;n‰;ì¸s$æÚ1/3xP6›÷ŒvÜeÇÂáȤ;Yž~·‹±ØŽ{2A&–dbÚ½vP¶\zWfv X~.2¹ô¾SWØA©õ;VÚñ …uyP~h^&VÛñ°ØYz=Ñð Ôým{ÞyÌÊçß±ƒæ 6 ±ˆØó›’جô];ì¹éÜôÄf¨ ÏPÃÓS5¦¤²'²¼Aè3#GûÃá>‹Ü6<ç²³ûž#èÜY#¬³Û„µOd¤Å¨õ¾c·ç·íùñÑ‘)òaûº(ŽYr…=KÒå¦>°xáð,I}‰O‘l~¤ŽM]ýºÌ´8‹Æ×·M†ÏT ~^ö½á8CwâN¿¤iZQ9o†³pTQ”ŠI }>¡îës1Nñdj(u¶õ`|ãXW<‰@ýëç)õÊ”™Þô‚KÚ4M3Kæ»Ôðמ„™Þ.f;Åž"Ø0zeöe~$ò_(~i•µé¼ôVöû¿þá¬Kjìê«ÐÔTjèóY7öRfÀ~ øå×N^êÊç#ˆÕª4ØÑ¶¼ðño}@ýá;ŸŸ¹%Ï*@ ‡Ã‘ÑÐj´×äó5+RœŸ®Ïo;<à"ööbÔPŸð¤Ä¼º‹át¾¯äNIÛqy .ˆµÎd>Åïݺ®*ëK•ùô_(œ¿Îxú‚ÌŽŽfJÂ/ -»½ý4g퀇óú¥†>Ÿí”Àãñõ”mšfÔ†þ(o ðù|>@ àó~‡n ™ýör/\?¨ªêQF9‘$©R2?\Ÿßw“NÍVN€ A‰Ñ‹W/Iæ»lGÓ´,™_Á[y²dþv1,x´Î{÷„õÑè‘‘†íuþ×°Ìß%¥3¡ÓsÖº=*½(œôP`^¿Àç×ôÓ®ÐÈ…ÏG àóŸhL4M£ûb­¦ö=‰…BM~ÅXÕçê¾>ïO¦0¨C,ËRm\¼ºw™ïîç)ÿ;W–뼸Ü!óµ¥™o×õOóµá)IÒ½Ë|Ãèåß ‡·œ«Ø_:1³»÷Bì© ¤×´Å\òêç>¶Ü‚뺠†>Ÿý ðòƒ„½ÜTŸ¶Ñuÿ.¢?r­þ}þSk×Ѫ“¯¼Šá¥_¹¸Ú»CT$èJñ«FW°qN|ÛÖwª4¢ÑÕ§cœ}íuE×§uœ_Aú"0¥Ö[ò'(À_Ð=#+ݬ‡ƒ¡ÛUö|A’¤°ºsgïT©d4À>¿í°[éÞÞA üˆ®ëe¾»Ÿ§¬ë\YQ”º>í|2Ÿ"ù(kEÓŒ‹bKy2?ÑÅ;Ø=yËÌÌîh§´ë̳ô/<ã’T—l¢ýú»kÕÐçÓÔïe"¦_¬óÓÜÈÑM- ØÐ0gW„}Ìú 4FŸ?ÐQ9}Q /Vð¨ÿ~Ð@N9ÿÛ={Š®Oë ÌØw`J€FÀ4MfÅ‹¢(J­nÛëŠûü®xÒE=5wZ/øŽ¬Šú²e~z´Ï¯í‹ZÅ) ósëó£Ñ#‚°¾l™OXÝ¿¥]諾Ìv—>4Ü2’”ž¾ô¤KR½rî`?)J }>ïØî]‘ÿtaº;x°B 竈ªªæ6 |>¨P¸ÁwÀç7˜R ðp5]¡PCOåöù„º¯ÏÅ>Å“)Œ|DeþpŠPUI’œò°I˜…d¾¦µ>=š| -Ql±¬Syv·K6ù*_LSÄÊÍ–KFýâ…gê¼!‹RCŸOЯ¶kµ€;â2?À¿[˜ÏϽ(Yï#Àçƒj… Ð||~#€)‚®ëMeQïe™U&Ø>¿íð€‹}ú¯?õvtttww§Rûþ&‹áRþR:_ªªˆÌ÷ '¢Ee¾e’åÞe>­\pw{äa™¿gT3¾ülÌ%®i‹ ‚ïGem}¾ógL(¢Ù9:u~nû\œŸ†Ï5 - 3øøüFS*ç­®(ŠtKÈ—ÐáAà«Ñ ²iš ÞnÁöù]ñ¤‹€Ú`ü¥Ý&‘H`ùšŽŽ\Ê:GÓ4–“Ýe{¡KIßò(ó³¼_HZéí¢‹Ì7͸(¶x—ùYUýyv·?â¬Ìgüñ÷.étÎÚIòý¨¬­ÏO{{…~º8QÀ烅 Ð||~#€) ¿Á0 ¾œÝŠ¢è\Y×ufõ³–7&Áöù„º¯ÏÅAíÝŸ1NÉd=Á×ôôô0sˆKYo˜¦IIÆù ÕÝ”vwwÓuìèèp^Jï2?¨ï[iZ{!!o½‚°Þ£É§5iýòŽÁýu§‹Âɬ¶Ï{)뜚û|v ì§K.¡P(À•ù ø|PC p:ƒï€Ïo0¥@€áR:ëŽ/·,˹Ü0ŒÀVr–ÛtAòùñdªgà4ûÛÝAí>ƒ‰D—²®ˆF£y=¼{ªI¥RÎKI©[Å—ù†Ñ[HæGÛ~-œ¿Î£ÌÅË:å}¿C©³”?)(£¦‹=ìÊüïÞÞÁB—Ò/¶æ>ä¢4;óW éïÀ›||>¨!P¸ÁwÀç7˜R ÀH’ÄnÀÅùi»Ÿ-§ûÁ¬¯pmšf#7]ð|~ÏÀiæ—vKÐÇ®xÒÅA5wZ>TMÓòJxZX’r§|žUØß€2?ñ™GòÊü¬¢}÷å¥îw÷ñ“,On;ÔbðŒK"åÑz0î󦮟߰À烅 Ð||~#€) 9=k9¿7Ï­Ã7M“ý—ÚØ?Ò‚çó¹ƒR÷õ±%îe¥¬ôt(u¶gà4ûP6ykòiaîCUw4MóhòA(uã¾#ù(Þ¢ëŸ:Ú§™¯ª—±Sž9Y•¾Ÿ¿íP¿¯Û>¿æ(Š’õkÄ0 Z’õÀΩÚÊ/ÎgŒ@>ø(\€Îà;àóL©` -ù|˲ØrºCÌýV( -’Ç.àù|giÏÀiZân¢ööÒ:ÄØ#€¡ÔY (ʆgcfÚ)ÔñTÞ‡…d~ÖkY Jþ’$ÑÁäý_¿ã]æ ÂúhôÈè–9¥ªG"Ñ.»ØÿÙ3‘º?åAßòuÃÂçûø|Pí~…‹Î€Îà àóL©`¸AÊG.²ºÐS€†"x>?="ç)vKÐÇ®xÒE@5wZ´ÿH+c@P6𦠂 ŠbV=­G,Ë¢ïŽQæÓBú¯àe¶‘ö*óE±Å4ãÎïÒGZÈþW–w¸ì¥õ`œ¥DJ§î)Ô~ -ŸïàóAµû.::ƒ/€Ïo0¥@€áR:× 15$Bî·àóÓõù¼ ã[â^\O¦š;-ö7} -€šF¹‡/ -åv˲r7Â(ðÕdYR©êÇe¾,ïȪÀ7Œ^AXï\¡Ð^(%:ß`rÅ)ëÙ¨ß{ |¾/€ÏÕîWP¸è è ¾>¿À” -Æ0ŒBåš’$±ÿÒuݹܲ,ܶ§êóÕ¤ñd*í0üycoïàÎc ö·º¯ -'”TUU-¯ÞÞ#”EiòŒ‹Ìw®&ËrÞÕꎄ™>-º–,ïð(óUõ㜖UÕ/þó“Y¶ß O˜”)…º?å±ûøI¿wuø|¿ÐñÉ'¿Ý³§ìèïï¯öB>ø(\€Îà;àóL©lB¡¿ ‡Ã\=q½C+8ÅŽ,ËÁóØeHŸO8]}z´áÏÖƒñƒgøGZ -48ÌáK’ä¬uW«sK«ëº3…ŽÊ‹ÌWÅm}HK·6eâ÷nì]ækZ»ûwåI·[›ÎKïÉÿæÂPê,øm‡ö6äEæSPõ{·‡Ï•òÁ@átߟß`J€`ã¼ wÚi˲¸¢?E‰D"¢(ò5«ZtZÿÕço;ÔÏ]=[â^b:”:»ñ@ŒýMßÅ€¥JJ†”!)é”.*¾Sþ -•G -C–Ì÷Mbé­Â°ÏßY0 —-ó-ë”(¶8Wxò–™î»s -üƒgx.uÊŸðù R@>ø(\€Îà;àóL©x4MãêÞi§UU-¤†DQlðF ªÏw*©¡ÔYZÒvxÀEFÑú»ŸÌú -ð ©Tª¯¯/‘H )ʆ¿²äRošf÷¨ëº³ø¿(´2}%廬 ó)i.'™/ë£Ñ#Î/Fo(ôÚ¹Î_§¯úò¹ÝÍߘÍKƒOüÊúÁ³g=çS‚ À¨„Ï•òÁ@átߟß`J€FÀ²,UU%IRŹœ>æÚ¡p8Lë7x‹ÕçÇ“)§«§%]ñ¤‹ŒÚv¨?÷+À/tww·Û á•InY¾ ´RD4­ì¾hƒ.ozöjFÞ­™¦éw™o¾ð…è+«-ëTîZÞe¾aôæ\Ó-|ñK«Œ§/6ù´ß˜Qè¸xœpÃ) -—´ù@ó¹Ò}J°•ðù R8åÃ¥_¹xîíw ê?èJñ«¶lÉ½èÆŒÓçO¾ò*ŒŽº1ú|4 /‚Æ |>42¦i*ж‘e¹Pg£TŸŸvT™î>~’>¥Ü -MÕ}}ίl;Ô¾á#ººº˜9D‰¾˲¢Ñ¨Ç§–”C¡Kªª’çc„òpÑò¾àrN뙟´ÒÛEf×§/Î_×Ôô£P赬µÆ"ó IÒÙ -ÒDÙÚtް̧ý&ݺKƒ+7[MMé%›â.i³eÛ ¶2ý›»ŽŽßJø|P)œ>áÇ€2jp²D1ÂQ†ÏG 9>%À>¿+žT÷õm<‹'SlɶCý.nŠÖßÛ;È?òoú§¿¿¿»»ûرchŠh4ªªª,Ë¢(òÊöz80˲ò¾'UÊQE7Nç -…ü(ó­Mç‰_ZÅÍüè““ÌOgžžÄŸ¼ãVuÁÕÃ&Ÿbì.óÓö£ÏžÓŸûüÙ/\ðw—„IñÉÎnZŸVλX,F£òøñãþ>ðù "ÀçC_ŸŸ@rê™ûü\ö6äâ¦Ú8køO žA÷õiš4Š?%úU‚öNG(B©&? -E£Ñ^³™O!M”¹™W”ù*c—ùöGΙ| -úè MK75¥¯œ;è’0<ß_ÓnUàóA¥€Ï‡2¾>>ä Ô3 åóãÉ”‹žÚx –¶ëÁøîã'Ñ7@ýcšfQ+.IR­¯l“O(ŠbϧG9ö'o™Éͼ(¶ðU*#ó‰]Òð¾¶ -飺÷c¤Ù ©)½r³å’0'Üpªv=«ZÀçƒJñÛ={^TÕ‰5«vÊ–`œÔ;[·¢72Ô‚=l'_y•S㤎=ZôÊÒ:HÈHÎ@h(ŸO4wº*ÔäáÔAh8+Š¢ëz­”¸iš²,—gò[–ÏØfŽ]_õe§™·¬Sìÿ+&󉘑ÙÝ.)ó‡g ##ó¿pÁß]RedW­¼I>€2ȪwEƒPÿ8_@xQUÑ  @ÝÂýs¥²8*¥=Äçïít‘T;%0Ä@m1 CUUMÓ<®/IR(¢ñKcY×uÓ4k{üÌä—é,‚Y–Ï9ª§· -ÆÓç¯ãrž›ùJÊür‘åŒÏŸýpÂ%UÎY;@ëOÀçPÐGøøü ‚„  nϯR{6ˆÏ?1xÆER5wZb`œ1MSÓ4EQh :S“ê·Û+:‹¬S( Q Ãh„+nY§B¡×¸œ×´v¶¼d¾e¥!ãó×´Å\RåEá$­¼ËŸ@@à;àóƒ -2€º>¿JíÙ >ŸØxÀÍSÅ“)Œ2Pm,Ë¢¡GƒN—Ju_œ‹išŠ¢¸œHQ軾{x1Âá-\Î+ʇ™EI«d>Aס©)ýÅ Ýž{FvõÑ:¡ Þ#ÂçPÐGøøü ‚„  n1M3ZY–¥ž‘HDÓ4þ¿¬––;Ë_i¹eYÜž èówK¸¨ª½½ƒe ÚH’䮸iÊuu~º®¥ Ÿ™|JA–„¹œ‡·d>'-ù¦ï—!ó5­×öW -šššÒ³vK’ô¿´Ž¢ðÒÀçPÐGøøü ‚„ ÀwhšÆ‘{É=ý/³ú´¦a Þn èó{N»¨ªÖƒqŒ&Pmr58%%EQ(ÕRÒu]–å±ä3h#ŸY¨ª$í/Š-MM?¢-ë”w™ -½æ”ù¼ž_U?®à±ÉrÆç¯is{‰é‹ž¡uêþqS9ÀçPÐGøøü ‚„ À_X–ÅäýëEÑú\é£>¿Ñ|>¡îës±UC©³SÀ;ÑhT×õˆûÃDŽa’$ɲÌÞòÅiVJã³lãñ±ÏÕÌÿ¨ÏÉÈütZžûS/2Xþ·É©px ÿ¯Hä£ -XÊ0ZÂßvIkÚbMMiQ ìX†Ï T ððùA €¿PU•Ý€kšæñ+¦i²¯D"‘FnºÆôùm‡\„Õþφ0¦üE,ëèèèîîN¥RUÝå ¦îeY¦!“+·iI–Η²«$IM‚Íýù…óR† -…øwé0ÖoßøáKeÈ|VÞÏBÖ;‹öÇΙhtóóoº¤ÇÙ'ššÒ^nýÇmTVø|ÊúߟTø ®›J*¶geŸbP ½Ñ˜>¿+žtVÛõcLù‹ŽŽŽv›D"Q½½8]Ÿ ~oLÊ¢¬ßéÒÇmÐKM>¿”mmmÎÇ%”¨ö.•ñî3c”ùâ—VO_îTÇr»Ÿ¤Œwbð ûO¦\r#Å/:×O$…d¾³Ì»Y[Ë mŠ% Qi¼Ð1ÐñÐKJ;õ9‚$I^Ú§ h³´ýR§¯¯oÉ’%Y‚Ö¹iâ—VUFæSü^)û@6ˆeù|u_ŸKb|èñ¿<þîpæl=wßx*•*4*ëyPÀçP*ÐGøøü ‚„ À_(ŠÂnÀ#‘ˆÇ¯˜¦É¾ -5ôLÇ}¾ eT,³Æ»â}SYUÓ¹¨žpjšÍãïþši¨çö˜ôñ»?Þ⢭Ú°íœ<Óz0N#…1 ÃãQÑšQW¼ËO^s>öM9*ï zqݯ ÇÎàQÂ{iy§ s1Ï>uò%Aç¨ë:°MÕ„¶O°Œ#¤ šõ‚€êë{ÌùNÌ'Ý^1™¿§ü‡¼8Ÿ‚½¸ä\’‘]}Ñ>ãw?¼1Ÿ@@à;àóƒ -2¡ë:÷r^ŸeYܰø³¸Ï/¯bÙ‹,­ì¦¼\_Z'÷‹n¸ƒ›¨/\ð.æJÝ×Ç6Õz0ΖÐ×]ŽÊ‹ Î{Tå‰e/ºÛ㦼•ÇÿÎàeSÎÁ -…ø“øüE€e>š¦it²üu¤êA]Žv4–Æt>h ­•÷P .HZéíbÆ·ïýÞSÌИ^’Ì·‡Ã‘ŠË|¢¹ÓbÉmãXÖ’¼ñÝ–£NáO¦‚7^àó(è#||~PABà;¸­*jè†ÝYÚu¹.¸øüq¶Á7UvIöç>ÿ?¸‰š¾t -yâW†‹¼:1x&íðù ž³~u}nª‚Á²¬¼þÙù‰÷÷>ñtø ʨ´Gºjcß|sŠpþº¢>_×?ÍݤñáÑïüS¥d~Úñ¤’ç·pɇo:|¸÷ïY‚|>e}€ï€Ï*HÈüˆa%Õ£Bæ§>ߣþõ5]ñ¤³üžÂÅ_1ÍO¦¯°€‰F£”ÁdY.úd§þ5~ HZé­Â°u§?#­Ô©†ÿeYQ™‰|”³|›•ùÎRüÝÇOÒ’¡ÔY÷âüWßèu>ܤõƒ:¬àó(è#||~PABàS,ËŠD"E+TC¡÷¢ñ`ÓP>ŸP÷õ9Ëï7ˆ¹(¬žÓ´Ns§Å>n;ÔjE >AIU’$MÓ ñ‹°K:'Þ;UË:e½é„];¡¨Ì—$½àf+'óÓŽâ|ʇÌÌï>~Ò%®i‹uV#dBø|ÊúߟTø˲4MË_ápXQ˜|'æóÛ8ËïwK¸X,Z™Öi„ªTP‡ÔVàó´@)Â0 \OÕω÷]’e„õQÿ ¥hq¾(¶Ðú·|HK \ No newline at end of file diff --git a/libs/zlibng/test/example.c b/libs/zlibng/test/example.c index 97ca0029b..964a380d7 100644 --- a/libs/zlibng/test/example.c +++ b/libs/zlibng/test/example.c @@ -3,20 +3,20 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #include "zbuild.h" #ifdef ZLIB_COMPAT # include "zlib.h" #else # include "zlib-ng.h" #endif -#include "deflate.h" #include #include #include #include -#include #define TESTFILE "foo.gz" @@ -40,7 +40,7 @@ void test_compress (unsigned char *compr, z_size_t comprLen,unsigned char * void test_gzio (const char *fname, unsigned char *uncompr, z_size_t uncomprLen); void test_deflate (unsigned char *compr, size_t comprLen); void test_inflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen); -void test_large_deflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen, int zng_params); +void test_large_deflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen); void test_large_inflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen); void test_flush (unsigned char *compr, z_size_t *comprLen); void test_sync (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen); @@ -55,7 +55,8 @@ static free_func zfree = NULL; /* =========================================================================== * Test compress() and uncompress() */ -void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncompr, z_size_t uncomprLen) { +void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncompr, z_size_t uncomprLen) +{ int err; size_t len = strlen(hello)+1; @@ -78,24 +79,21 @@ void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncom /* =========================================================================== * Test read/write of .gz files */ -void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) { +void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) +{ #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); #else int err; - size_t read; - size_t len = strlen(hello)+1; + int len = (int)strlen(hello)+1; gzFile file; - z_off64_t pos; - z_off64_t comprLen; + z_off_t pos; - /* Write gz file with test data */ file = PREFIX(gzopen)(fname, "wb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } - /* Write hello, hello! using gzputs and gzprintf */ PREFIX(gzputc)(file, 'h'); if (PREFIX(gzputs)(file, "ello") != 4) { fprintf(stderr, "gzputs err: %s\n", PREFIX(gzerror)(file, &err)); @@ -105,42 +103,17 @@ void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) { fprintf(stderr, "gzprintf err: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } - /* Write string null-teriminator using gzseek */ - if (PREFIX(gzseek)(file, 1L, SEEK_CUR) < 0) - { - fprintf(stderr, "gzseek error, gztell=%ld\n", (long)PREFIX(gztell)(file)); - exit(1); - } - /* Write hello, hello! using gzfwrite using best compression level */ - if (PREFIX(gzsetparams)(file, Z_BEST_COMPRESSION, Z_DEFAULT_STRATEGY) != Z_OK) { - fprintf(stderr, "gzsetparams err: %s\n", PREFIX(gzerror)(file, &err)); - exit(1); - } - if (PREFIX(gzfwrite)(hello, len, 1, file) == 0) { - fprintf(stderr, "gzfwrite err: %s\n", PREFIX(gzerror)(file, &err)); - exit(1); - } - /* Flush compressed bytes to file */ - if (PREFIX(gzflush)(file, Z_SYNC_FLUSH) != Z_OK) { - fprintf(stderr, "gzflush err: %s\n", PREFIX(gzerror)(file, &err)); - exit(1); - } - comprLen = PREFIX(gzoffset)(file); - if (comprLen <= 0) { - fprintf(stderr, "gzoffset err: %s\n", PREFIX(gzerror)(file, &err)); - exit(1); - } + PREFIX(gzseek)(file, 1L, SEEK_CUR); /* add one zero byte */ PREFIX(gzclose)(file); - /* Open gz file we previously wrote */ file = PREFIX(gzopen)(fname, "rb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } - /* Read uncompressed data - hello, hello! string twice */ - strcpy((char*)uncompr, "garbages"); - if (PREFIX(gzread)(file, uncompr, (unsigned)uncomprLen) != (int)(len + len)) { + strcpy((char*)uncompr, "garbage"); + + if (PREFIX(gzread)(file, uncompr, (unsigned)uncomprLen) != len) { fprintf(stderr, "gzread err: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } @@ -150,28 +123,24 @@ void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) { } else { printf("gzread(): %s\n", (char*)uncompr); } - /* Check position at the end of the gz file */ - if (PREFIX(gzeof)(file) != 1) { - fprintf(stderr, "gzeof err: not reporting end of stream\n"); - exit(1); - } - /* Seek backwards mid-string and check char reading with gzgetc and gzungetc */ - pos = PREFIX(gzseek)(file, -22L, SEEK_CUR); + + pos = PREFIX(gzseek)(file, -8L, SEEK_CUR); if (pos != 6 || PREFIX(gztell)(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", (long)pos, (long)PREFIX(gztell)(file)); exit(1); } + if (PREFIX(gzgetc)(file) != ' ') { fprintf(stderr, "gzgetc error\n"); exit(1); } + if (PREFIX(gzungetc)(' ', file) != ' ') { fprintf(stderr, "gzungetc error\n"); exit(1); } - /* Read first hello, hello! string with gzgets */ - strcpy((char*)uncompr, "garbages"); + PREFIX(gzgets)(file, (char*)uncompr, (int)uncomprLen); if (strlen((char*)uncompr) != 7) { /* " hello!" */ fprintf(stderr, "gzgets err after gzseek: %s\n", PREFIX(gzerror)(file, &err)); @@ -183,63 +152,19 @@ void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) { } else { printf("gzgets() after gzseek: %s\n", (char*)uncompr); } - /* Seek to second hello, hello! string */ - pos = PREFIX(gzseek)(file, 14L, SEEK_SET); - if (pos != 14 || PREFIX(gztell)(file) != pos) { - fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)PREFIX(gztell)(file)); - exit(1); - } - /* Check position not at end of file */ - if (PREFIX(gzeof)(file) != 0) { - fprintf(stderr, "gzeof err: reporting end of stream\n"); - exit(1); - } - /* Read first hello, hello! string with gzfread */ - strcpy((char*)uncompr, "garbages"); - read = PREFIX(gzfread)(uncompr, uncomprLen, 1, file); - if (strcmp((const char *)uncompr, hello) != 0) { - fprintf(stderr, "bad gzgets\n"); - exit(1); - } else { - printf("gzgets(): %s\n", (char*)uncompr); - } - pos = PREFIX(gzoffset)(file); - if (pos < 0 || pos != (comprLen + 10)) { - fprintf(stderr, "gzoffset err: wrong offset at end\n"); - exit(1); - } - /* Trigger an error and clear it with gzclearerr */ - PREFIX(gzfread)(uncompr, (size_t)-1, (size_t)-1, file); - PREFIX(gzerror)(file, &err); - if (err == 0) { - fprintf(stderr, "gzerror err: no error returned\n"); - exit(1); - } - PREFIX(gzclearerr)(file); - PREFIX(gzerror)(file, &err); - if (err != 0) { - fprintf(stderr, "gzclearerr err: not zero %d\n", err); - exit(1); - } PREFIX(gzclose)(file); - - if (PREFIX(gzclose)(NULL) != Z_STREAM_ERROR) { - fprintf(stderr, "gzclose unexpected return when handle null\n"); - exit(1); - } - (void)read; #endif } /* =========================================================================== * Test deflate() with small buffers */ -void test_deflate(unsigned char *compr, size_t comprLen) { +void test_deflate(unsigned char *compr, size_t comprLen) +{ PREFIX3(stream) c_stream; /* compression stream */ int err; - size_t len = strlen(hello)+1; + unsigned long len = (unsigned long)strlen(hello)+1; c_stream.zalloc = zalloc; c_stream.zfree = zfree; @@ -250,7 +175,7 @@ void test_deflate(unsigned char *compr, size_t comprLen) { err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.next_out = compr; while (c_stream.total_in != len && c_stream.total_out < comprLen) { @@ -273,7 +198,8 @@ void test_deflate(unsigned char *compr, size_t comprLen) { /* =========================================================================== * Test inflate() with small buffers */ -void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { +void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) +{ int err; PREFIX3(stream) d_stream; /* decompression stream */ @@ -315,22 +241,10 @@ static unsigned int diff; /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ -void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen, int zng_params) { +void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) +{ PREFIX3(stream) c_stream; /* compression stream */ int err; -#ifndef ZLIB_COMPAT - int level = -1; - int strategy = -1; - zng_deflate_param_value params[2]; - - params[0].param = Z_DEFLATE_LEVEL; - params[0].buf = &level; - params[0].size = sizeof(level); - - params[1].param = Z_DEFLATE_STRATEGY; - params[1].buf = &strategy; - params[1].size = sizeof(strategy); -#endif c_stream.zalloc = zalloc; c_stream.zfree = zfree; @@ -355,27 +269,7 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un } /* Feed in already compressed data and switch to no compression: */ - if (zng_params) { -#ifndef ZLIB_COMPAT - zng_deflateGetParams(&c_stream, params, sizeof(params) / sizeof(params[0])); - if (level != Z_BEST_SPEED) { - fprintf(stderr, "Expected compression level Z_BEST_SPEED, got %d\n", level); - exit(1); - } - if (strategy != Z_DEFAULT_STRATEGY) { - fprintf(stderr, "Expected compression strategy Z_DEFAULT_STRATEGY, got %d\n", strategy); - exit(1); - } - level = Z_NO_COMPRESSION; - strategy = Z_DEFAULT_STRATEGY; - zng_deflateSetParams(&c_stream, params, sizeof(params) / sizeof(params[0])); -#else - fprintf(stderr, "test_large_deflate() called with zng_params=1 in compat mode\n"); - exit(1); -#endif - } else { - PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); - } + PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in = compr; diff = (unsigned int)(c_stream.next_out - compr); c_stream.avail_in = diff; @@ -383,29 +277,7 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un CHECK_ERR(err, "deflate"); /* Switch back to compressing mode: */ - if (zng_params) { -#ifndef ZLIB_COMPAT - level = -1; - strategy = -1; - zng_deflateGetParams(&c_stream, params, sizeof(params) / sizeof(params[0])); - if (level != Z_NO_COMPRESSION) { - fprintf(stderr, "Expected compression level Z_NO_COMPRESSION, got %d\n", level); - exit(1); - } - if (strategy != Z_DEFAULT_STRATEGY) { - fprintf(stderr, "Expected compression strategy Z_DEFAULT_STRATEGY, got %d\n", strategy); - exit(1); - } - level = Z_BEST_COMPRESSION; - strategy = Z_FILTERED; - zng_deflateSetParams(&c_stream, params, sizeof(params) / sizeof(params[0])); -#else - fprintf(stderr, "test_large_deflate() called with zng_params=1 in compat mode\n"); - exit(1); -#endif - } else { - PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); - } + PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); c_stream.next_in = uncompr; c_stream.avail_in = (unsigned int)uncomprLen; err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); @@ -423,7 +295,8 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un /* =========================================================================== * Test inflate() with large buffers */ -void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { +void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) +{ int err; PREFIX3(stream) d_stream; /* decompression stream */ @@ -453,7 +326,7 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2*uncomprLen + diff) { - fprintf(stderr, "bad large inflate: %" PRIu64 "\n", (uint64_t)d_stream.total_out); + fprintf(stderr, "bad large inflate: %zu\n", d_stream.total_out); exit(1); } else { printf("large_inflate(): OK\n"); @@ -463,7 +336,8 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un /* =========================================================================== * Test deflate() with full flush */ -void test_flush(unsigned char *compr, z_size_t *comprLen) { +void test_flush(unsigned char *compr, z_size_t *comprLen) +{ PREFIX3(stream) c_stream; /* compression stream */ int err; unsigned int len = (unsigned int)strlen(hello)+1; @@ -475,7 +349,7 @@ void test_flush(unsigned char *compr, z_size_t *comprLen) { err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.next_out = compr; c_stream.avail_in = 3; c_stream.avail_out = (unsigned int)*comprLen; @@ -498,7 +372,8 @@ void test_flush(unsigned char *compr, z_size_t *comprLen) { /* =========================================================================== * Test inflateSync() */ -void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { +void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) +{ int err; PREFIX3(stream) d_stream; /* decompression stream */ @@ -525,8 +400,9 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si CHECK_ERR(err, "inflateSync"); err = PREFIX(inflate)(&d_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "inflate should report Z_STREAM_END\n"); + if (err != Z_DATA_ERROR) { + fprintf(stderr, "inflate should report DATA_ERROR\n"); + /* Because of incorrect adler32 */ exit(1); } err = PREFIX(inflateEnd)(&d_stream); @@ -538,7 +414,8 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si /* =========================================================================== * Test deflate() with preset dictionary */ -void test_dict_deflate(unsigned char *compr, size_t comprLen) { +void test_dict_deflate(unsigned char *compr, size_t comprLen) +{ PREFIX3(stream) c_stream; /* compression stream */ int err; @@ -558,7 +435,7 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen) { c_stream.next_out = compr; c_stream.avail_out = (unsigned int)comprLen; - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.avail_in = (unsigned int)strlen(hello)+1; err = PREFIX(deflate)(&c_stream, Z_FINISH); @@ -573,7 +450,8 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen) { /* =========================================================================== * Test inflate() with a preset dictionary */ -void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { +void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) +{ int err; PREFIX3(stream) d_stream; /* decompression stream */ @@ -617,392 +495,12 @@ void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *unc } } -/* =========================================================================== - * Test deflateBound() with small buffers - */ -void test_deflate_bound(void) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - unsigned int len = (unsigned int)strlen(hello)+1; - int estimateLen = 0; - unsigned char *outBuf = NULL; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - c_stream.avail_in = len; - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.avail_out = 0; - c_stream.next_out = outBuf; - - err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - /* calculate actual output length and update structure */ - estimateLen = PREFIX(deflateBound)(&c_stream, len); - outBuf = malloc(estimateLen); - - if (outBuf != NULL) { - /* update zlib configuration */ - c_stream.avail_out = estimateLen; - c_stream.next_out = outBuf; - - /* do the compression */ - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) { - printf("deflateBound(): OK\n"); - } else { - CHECK_ERR(err, "deflate"); - } - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - free(outBuf); -} - -/* =========================================================================== - * Test deflateCopy() with small buffers - */ -void test_deflate_copy(unsigned char *compr, size_t comprLen) { - PREFIX3(stream) c_stream, c_stream_copy; /* compression stream */ - int err; - size_t len = strlen(hello)+1; - - memset(&c_stream, 0, sizeof(c_stream)); - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = PREFIX(deflateCopy)(&c_stream_copy, &c_stream); - CHECK_ERR(err, "deflate_copy"); - - if (c_stream.state->status == c_stream_copy.state->status) { - printf("deflate_copy(): OK\n"); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd original"); - - err = PREFIX(deflateEnd)(&c_stream_copy); - CHECK_ERR(err, "deflateEnd copy"); -} - -/* =========================================================================== - * Test deflateGetDictionary() with small buffers - */ -void test_deflate_get_dict(unsigned char *compr, size_t comprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - unsigned char *dictNew = NULL; - unsigned int *dictLen; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_out = compr; - c_stream.avail_out = (uInt)comprLen; - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.avail_in = (unsigned int)strlen(hello)+1; - - err = PREFIX(deflate)(&c_stream, Z_FINISH); - - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); - } - - dictNew = calloc(256, 1); - dictLen = (unsigned int *)calloc(4, 1); - err = PREFIX(deflateGetDictionary)(&c_stream, dictNew, dictLen); - - CHECK_ERR(err, "deflateGetDictionary"); - if (err == Z_OK) { - printf("deflateGetDictionary(): %s\n", dictNew); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - free(dictNew); - free(dictLen); -} - -/* =========================================================================== - * Test deflatePending() with small buffers - */ -void test_deflate_pending(unsigned char *compr, size_t comprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - int *bits = calloc(256, 1); - unsigned *ped = calloc(256, 1); - size_t len = strlen(hello)+1; - - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - - err = PREFIX(deflatePending)(&c_stream, ped, bits); - CHECK_ERR(err, "deflatePending"); - - if (*bits >= 0 && *bits <= 7) { - printf("deflatePending(): OK\n"); - } else { - printf("deflatePending(): error\n"); - } - - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - free(bits); - free(ped); -} - -/* =========================================================================== - * Test deflatePrime() wrapping gzip around deflate stream - */ -void test_deflate_prime(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - PREFIX3(stream) d_stream; /* decompression stream */ - int err; - size_t len = strlen(hello)+1; - uint32_t crc = 0; - - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - /* Raw deflate windowBits is -15 */ - err = PREFIX(deflateInit2)(&c_stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); - CHECK_ERR(err, "deflateInit2"); - - /* Gzip magic number */ - err = PREFIX(deflatePrime)(&c_stream, 16, 0x8b1f); - CHECK_ERR(err, "deflatePrime"); - /* Gzip compression method (deflate) */ - err = PREFIX(deflatePrime)(&c_stream, 8, 0x08); - CHECK_ERR(err, "deflatePrime"); - /* Gzip flags (one byte, using two odd bit calls) */ - err = PREFIX(deflatePrime)(&c_stream, 3, 0x0); - CHECK_ERR(err, "deflatePrime"); - err = PREFIX(deflatePrime)(&c_stream, 5, 0x0); - CHECK_ERR(err, "deflatePrime"); - /* Gzip modified time */ - err = PREFIX(deflatePrime)(&c_stream, 32, 0x0); - CHECK_ERR(err, "deflatePrime"); - /* Gzip extra flags */ - err = PREFIX(deflatePrime)(&c_stream, 8, 0x0); - CHECK_ERR(err, "deflatePrime"); - /* Gzip operating system */ - err = PREFIX(deflatePrime)(&c_stream, 8, 255); - CHECK_ERR(err, "deflatePrime"); - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.avail_in = (uint32_t)len; - c_stream.next_out = compr; - c_stream.avail_out = (uint32_t)comprLen; - - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) - CHECK_ERR(err, "deflate"); - - /* Gzip uncompressed data crc32 */ - crc = PREFIX(crc32)(0, (const uint8_t *)hello, (uint32_t)len); - err = PREFIX(deflatePrime)(&c_stream, 32, crc); - CHECK_ERR(err, "deflatePrime"); - /* Gzip uncompressed data length */ - err = PREFIX(deflatePrime)(&c_stream, 32, (uint32_t)len); - CHECK_ERR(err, "deflatePrime"); - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (void *)0; - - d_stream.next_in = compr; - d_stream.avail_in = (uint32_t)c_stream.total_out; - d_stream.next_out = uncompr; - d_stream.avail_out = (uint32_t)uncomprLen; - d_stream.total_in = 0; - d_stream.total_out = 0; - - /* Inflate with gzip header */ - err = PREFIX(inflateInit2)(&d_stream, MAX_WBITS + 32); - CHECK_ERR(err, "inflateInit"); - - err = PREFIX(inflate)(&d_stream, Z_FINISH); - if (err != Z_BUF_ERROR) { - CHECK_ERR(err, "inflate"); - } - - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (strcmp((const char *)uncompr, hello) != 0) { - fprintf(stderr, "bad deflatePrime\n"); - exit(1); - } - - if (err == Z_OK) { - printf("deflatePrime(): OK\n"); - } -} - -/* =========================================================================== - * Test deflateSetHeader() with small buffers - */ -void test_deflate_set_header(unsigned char *compr, size_t comprLen) { - PREFIX(gz_header) *head = calloc(1, sizeof(PREFIX(gz_header))); - PREFIX3(stream) c_stream; /* compression stream */ - int err; - size_t len = strlen(hello)+1; - - - if (head == NULL) { - printf("out of memory\n"); - exit(1); - } - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - /* gzip */ - err = PREFIX(deflateInit2)(&c_stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY); - CHECK_ERR(err, "deflateInit2"); - - head->text = 1; - err = PREFIX(deflateSetHeader)(&c_stream, head); - CHECK_ERR(err, "deflateSetHeader"); - if (err == Z_OK) { - printf("deflateSetHeader(): OK\n"); - } - - c_stream.next_in = (unsigned char *)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - free(head); -} - -/* =========================================================================== - * Test deflateTune() with small buffers - */ -void test_deflate_tune(unsigned char *compr, size_t comprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - int good_length = 3; - int max_lazy = 5; - int nice_length = 18; - int max_chain = 6; - size_t len = strlen(hello)+1; - - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - err = PREFIX(deflateTune)(&c_stream,(uInt)good_length,(uInt)max_lazy,nice_length,(uInt)max_chain); - CHECK_ERR(err, "deflateTune"); - if (err == Z_OK) { - printf("deflateTune(): OK\n"); - } - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - /* =========================================================================== * Usage: example [output.gz [input.gz]] */ -int main(int argc, char *argv[]) { + +int main(int argc, char *argv[]) +{ unsigned char *compr, *uncompr; z_size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ z_size_t uncomprLen = comprLen; @@ -1037,14 +535,9 @@ int main(int argc, char *argv[]) { test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); - test_large_deflate(compr, comprLen, uncompr, uncomprLen, 0); + test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); -#ifndef ZLIB_COMPAT - test_large_deflate(compr, comprLen, uncompr, uncomprLen, 1); - test_large_inflate(compr, comprLen, uncompr, uncomprLen); -#endif - test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); comprLen = uncomprLen; @@ -1052,14 +545,6 @@ int main(int argc, char *argv[]) { test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); - test_deflate_bound(); - test_deflate_copy(compr, comprLen); - test_deflate_get_dict(compr, comprLen); - test_deflate_set_header(compr, comprLen); - test_deflate_tune(compr, comprLen); - test_deflate_pending(compr, comprLen); - test_deflate_prime(compr, comprLen, uncompr, uncomprLen); - free(compr); free(uncompr); diff --git a/libs/zlibng/test/fuzz/checksum_fuzzer.c b/libs/zlibng/test/fuzz/checksum_fuzzer.c index ef9942111..10fc138fb 100644 --- a/libs/zlibng/test/fuzz/checksum_fuzzer.c +++ b/libs/zlibng/test/fuzz/checksum_fuzzer.c @@ -14,73 +14,60 @@ #endif int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) { - uint32_t crc0 = PREFIX(crc32)(0L, NULL, 0); - uint32_t crc1 = crc0; - uint32_t crc2 = crc0; - uint32_t adler0 = PREFIX(adler32)(0L, NULL, 0); - uint32_t adler1 = adler0; - uint32_t adler2 = adler0; - uint32_t combine1, combine2; - /* Checksum with a buffer of size equal to the first byte in the input. */ - uint32_t buffSize = data[0]; - uint32_t offset = 0; - uint32_t op[32]; + uint32_t crc0 = PREFIX(crc32)(0L, NULL, 0); + uint32_t crc1 = crc0; + uint32_t crc2 = crc0; + uint32_t adler0 = PREFIX(adler32)(0L, NULL, 0); + uint32_t adler1 = adler0; + uint32_t adler2 = adler0; + /* Checksum with a buffer of size equal to the first byte in the input. */ + uint32_t buffSize = data[0]; + uint32_t offset = 0; + uint32_t op[32]; - /* Discard inputs larger than 1Mb. */ - static size_t kMaxSize = 1024 * 1024; - if (dataLen < 1 || dataLen > kMaxSize) - return 0; - - /* Make sure the buffer has at least a byte. */ - if (buffSize == 0) - ++buffSize; - - /* CRC32 */ - PREFIX(crc32_combine_gen)(op, buffSize); - for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) { - uint32_t crc3 = PREFIX(crc32_z)(crc0, data + offset, buffSize); - uint32_t crc4 = PREFIX(crc32_combine_op)(crc1, crc3, op); - crc1 = PREFIX(crc32_z)(crc1, data + offset, buffSize); - assert(crc1 == crc4); - (void)crc1; - (void)crc4; - } - crc1 = PREFIX(crc32_z)(crc1, data + offset, dataLen % buffSize); - - crc2 = PREFIX(crc32_z)(crc2, data, dataLen); - - assert(crc1 == crc2); - (void)crc1; - (void)crc2; - combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen); - combine2 = PREFIX(crc32_combine)(crc1, crc1, (z_off_t)dataLen); - assert(combine1 == combine2); - - /* Fast CRC32 combine. */ - PREFIX(crc32_combine_gen)(op, (z_off_t)dataLen); - combine1 = PREFIX(crc32_combine_op)(crc1, crc2, op); - combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op); - assert(combine1 == combine2); - combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen); - combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op); - assert(combine1 == combine2); - - /* Adler32 */ - for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) - adler1 = PREFIX(adler32_z)(adler1, data + offset, buffSize); - adler1 = PREFIX(adler32_z)(adler1, data + offset, dataLen % buffSize); - - adler2 = PREFIX(adler32_z)(adler2, data, dataLen); - - assert(adler1 == adler2); - (void)adler1; - (void)adler2; - combine1 = PREFIX(adler32_combine)(adler1, adler2, (z_off_t)dataLen); - combine2 = PREFIX(adler32_combine)(adler1, adler1, (z_off_t)dataLen); - assert(combine1 == combine2); - (void)combine1; - (void)combine2; - - /* This function must return 0. */ + /* Discard inputs larger than 1Mb. */ + static size_t kMaxSize = 1024 * 1024; + if (dataLen < 1 || dataLen > kMaxSize) return 0; + + /* Make sure the buffer has at least a byte. */ + if (buffSize == 0) + ++buffSize; + + /* CRC32 */ + PREFIX(crc32_combine_gen)(op, buffSize); + for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) { + uint32_t crc3 = PREFIX(crc32_z)(crc0, data + offset, buffSize); + uint32_t crc4 = PREFIX(crc32_combine_op)(crc1, crc3, op); + crc1 = PREFIX(crc32_z)(crc1, data + offset, buffSize); + assert(crc1 == crc4); + } + crc1 = PREFIX(crc32_z)(crc1, data + offset, dataLen % buffSize); + + crc2 = PREFIX(crc32_z)(crc2, data, dataLen); + + assert(crc1 == crc2); + assert(PREFIX(crc32_combine)(crc1, crc2, dataLen) == + PREFIX(crc32_combine)(crc1, crc1, dataLen)); + + /* Fast CRC32 combine. */ + PREFIX(crc32_combine_gen)(op, dataLen); + assert(PREFIX(crc32_combine_op)(crc1, crc2, op) == + PREFIX(crc32_combine_op)(crc2, crc1, op)); + assert(PREFIX(crc32_combine)(crc1, crc2, dataLen) == + PREFIX(crc32_combine_op)(crc2, crc1, op)); + + /* Adler32 */ + for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) + adler1 = PREFIX(adler32_z)(adler1, data + offset, buffSize); + adler1 = PREFIX(adler32_z)(adler1, data + offset, dataLen % buffSize); + + adler2 = PREFIX(adler32_z)(adler2, data, dataLen); + + assert(adler1 == adler2); + assert(PREFIX(adler32_combine)(adler1, adler2, dataLen) == + PREFIX(adler32_combine)(adler1, adler1, dataLen)); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/compress_fuzzer.c b/libs/zlibng/test/fuzz/compress_fuzzer.c index 9712e882a..e2ccf7177 100644 --- a/libs/zlibng/test/fuzz/compress_fuzzer.c +++ b/libs/zlibng/test/fuzz/compress_fuzzer.c @@ -16,72 +16,72 @@ static const uint8_t *data; static size_t dataLen; -static void check_compress_level(uint8_t *compr, z_size_t comprLen, - uint8_t *uncompr, z_size_t uncomprLen, +static void check_compress_level(uint8_t *compr, size_t comprLen, + uint8_t *uncompr, size_t uncomprLen, int level) { - PREFIX(compress2)(compr, &comprLen, data, dataLen, level); - PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen); + PREFIX(compress2)(compr, &comprLen, data, dataLen, level); + PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen); - /* Make sure compress + uncompress gives back the input data. */ - assert(dataLen == uncomprLen); - assert(0 == memcmp(data, uncompr, dataLen)); + /* Make sure compress + uncompress gives back the input data. */ + assert(dataLen == uncomprLen); + assert(0 == memcmp(data, uncompr, dataLen)); } #define put_byte(s, i, c) {s[i] = (unsigned char)(c);} static void write_zlib_header(uint8_t *s) { - unsigned level_flags = 0; /* compression level (0..3) */ - unsigned w_bits = 8; /* window size log2(w_size) (8..16) */ - unsigned int header = (Z_DEFLATED + ((w_bits-8)<<4)) << 8; - header |= (level_flags << 6); + unsigned level_flags = 0; /* compression level (0..3) */ + unsigned w_bits = 8; /* window size log2(w_size) (8..16) */ + unsigned int header = (Z_DEFLATED + ((w_bits-8)<<4)) << 8; + header |= (level_flags << 6); - header += 31 - (header % 31); + header += 31 - (header % 31); - /* s is guaranteed to be longer than 2 bytes. */ - put_byte(s, 0, (header >> 8)); - put_byte(s, 1, (header & 0xff)); + /* s is guaranteed to be longer than 2 bytes. */ + put_byte(s, 0, (unsigned char)(header >> 8)); + put_byte(s, 1, (unsigned char)(header & 0xff)); } static void check_decompress(uint8_t *compr, size_t comprLen) { - /* We need to write a valid zlib header of size two bytes. Copy the input data - in a larger buffer. Do not modify the input data to avoid libFuzzer error: - fuzz target overwrites its const input. */ - size_t copyLen = dataLen + 2; - uint8_t *copy = (uint8_t *)malloc(copyLen); - memcpy(copy + 2, data, dataLen); - write_zlib_header(copy); + /* We need to write a valid zlib header of size two bytes. Copy the input data + in a larger buffer. Do not modify the input data to avoid libFuzzer error: + fuzz target overwrites its const input. */ + size_t copyLen = dataLen + 2; + uint8_t *copy = (uint8_t *)malloc(copyLen); + memcpy(copy + 2, data, dataLen); + write_zlib_header(copy); - PREFIX(uncompress)(compr, &comprLen, copy, copyLen); - free(copy); + PREFIX(uncompress)(compr, &comprLen, copy, copyLen); + free(copy); } int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) { - /* compressBound does not provide enough space for low compression levels. */ - z_size_t comprLen = 100 + 2 * PREFIX(compressBound)(size); - z_size_t uncomprLen = (z_size_t)size; - uint8_t *compr, *uncompr; + /* compressBound does not provide enough space for low compression levels. */ + size_t comprLen = 100 + 2 * PREFIX(compressBound)(size); + size_t uncomprLen = size; + uint8_t *compr, *uncompr; - /* Discard inputs larger than 1Mb. */ - static size_t kMaxSize = 1024 * 1024; + /* Discard inputs larger than 1Mb. */ + static size_t kMaxSize = 1024 * 1024; - if (size < 1 || size > kMaxSize) - return 0; - - data = d; - dataLen = size; - compr = (uint8_t *)calloc(1, comprLen); - uncompr = (uint8_t *)calloc(1, uncomprLen); - - check_compress_level(compr, comprLen, uncompr, uncomprLen, 1); - check_compress_level(compr, comprLen, uncompr, uncomprLen, 3); - check_compress_level(compr, comprLen, uncompr, uncomprLen, 6); - check_compress_level(compr, comprLen, uncompr, uncomprLen, 7); - - check_decompress(compr, comprLen); - - free(compr); - free(uncompr); - - /* This function must return 0. */ + if (size < 1 || size > kMaxSize) return 0; + + data = d; + dataLen = size; + compr = (uint8_t *)calloc(1, comprLen); + uncompr = (uint8_t *)calloc(1, uncomprLen); + + check_compress_level(compr, comprLen, uncompr, uncomprLen, 1); + check_compress_level(compr, comprLen, uncompr, uncomprLen, 3); + check_compress_level(compr, comprLen, uncompr, uncomprLen, 6); + check_compress_level(compr, comprLen, uncompr, uncomprLen, 7); + + check_decompress(compr, comprLen); + + free(compr); + free(uncompr); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/example_dict_fuzzer.c b/libs/zlibng/test/fuzz/example_dict_fuzzer.c index 027c9a806..b19101173 100644 --- a/libs/zlibng/test/fuzz/example_dict_fuzzer.c +++ b/libs/zlibng/test/fuzz/example_dict_fuzzer.c @@ -24,13 +24,14 @@ static const uint8_t *data; static size_t dataLen; static alloc_func zalloc = NULL; static free_func zfree = NULL; -static unsigned int dictionaryLen = 0; +static size_t dictionaryLen = 0; static unsigned long dictId; /* Adler32 value of the dictionary */ /* =========================================================================== * Test deflate() with preset dictionary */ -void test_dict_deflate(unsigned char **compr, size_t *comprLen) { +void test_dict_deflate(unsigned char **compr, size_t *comprLen) +{ PREFIX3(stream) c_stream; /* compression stream */ int err; int level = data[0] % 11 - 1; /* [-1..9] @@ -57,7 +58,7 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen) { /* deflate would fail for no-compression or for speed levels. */ if (level == 0 || level == 1) - level = -1; + level = -1; c_stream.zalloc = zalloc; c_stream.zfree = zfree; @@ -72,15 +73,15 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen) { CHECK_ERR(err, "deflateSetDictionary"); /* deflateBound does not provide enough space for low compression levels. */ - *comprLen = 100 + 2 * PREFIX(deflateBound)(&c_stream, (unsigned long)dataLen); + *comprLen = 100 + 2 * PREFIX(deflateBound)(&c_stream, dataLen); *compr = (uint8_t *)calloc(1, *comprLen); dictId = c_stream.adler; c_stream.next_out = *compr; c_stream.avail_out = (unsigned int)(*comprLen); - c_stream.next_in = (z_const unsigned char *)data; - c_stream.avail_in = (uint32_t)dataLen; + c_stream.next_in = data; + c_stream.avail_in = dataLen; err = PREFIX(deflate)(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { @@ -95,75 +96,75 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen) { * Test inflate() with a preset dictionary */ void test_dict_inflate(unsigned char *compr, size_t comprLen) { - int err; - PREFIX3(stream) d_stream; /* decompression stream */ - unsigned char *uncompr; + int err; + PREFIX3(stream) d_stream; /* decompression stream */ + unsigned char *uncompr; - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (void *)0; + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (void *)0; - d_stream.next_in = compr; - d_stream.avail_in = (unsigned int)comprLen; + d_stream.next_in = compr; + d_stream.avail_in = (unsigned int)comprLen; - err = PREFIX(inflateInit)(&d_stream); - CHECK_ERR(err, "inflateInit"); + err = PREFIX(inflateInit)(&d_stream); + CHECK_ERR(err, "inflateInit"); - uncompr = (uint8_t *)calloc(1, dataLen); - d_stream.next_out = uncompr; - d_stream.avail_out = (unsigned int)dataLen; + uncompr = (uint8_t *)calloc(1, dataLen); + d_stream.next_out = uncompr; + d_stream.avail_out = (unsigned int)dataLen; - for (;;) { - err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) - break; - if (err == Z_NEED_DICT) { - if (d_stream.adler != dictId) { - fprintf(stderr, "unexpected dictionary"); - exit(1); - } - err = PREFIX(inflateSetDictionary)( - &d_stream, (const unsigned char *)data, dictionaryLen); - } - CHECK_ERR(err, "inflate with dict"); - } - - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (memcmp(uncompr, data, dataLen)) { - fprintf(stderr, "bad inflate with dict\n"); + for (;;) { + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) + break; + if (err == Z_NEED_DICT) { + if (d_stream.adler != dictId) { + fprintf(stderr, "unexpected dictionary"); exit(1); + } + err = PREFIX(inflateSetDictionary)( + &d_stream, (const unsigned char *)data, dictionaryLen); } + CHECK_ERR(err, "inflate with dict"); + } - free(uncompr); + err = PREFIX(inflateEnd)(&d_stream); + CHECK_ERR(err, "inflateEnd"); + + if (memcmp(uncompr, data, dataLen)) { + fprintf(stderr, "bad inflate with dict\n"); + exit(1); + } + + free(uncompr); } int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) { - size_t comprLen = 0; - uint8_t *compr; + size_t comprLen = 0; + uint8_t *compr; - /* Discard inputs larger than 100Kb. */ - static size_t kMaxSize = 100 * 1024; + /* Discard inputs larger than 100Kb. */ + static size_t kMaxSize = 100 * 1024; - if (size < 1 || size > kMaxSize) - return 0; - - data = d; - dataLen = size; - - /* Set up the contents of the dictionary. The size of the dictionary is - intentionally selected to be of unusual size. To help cover more corner - cases, the size of the dictionary is read from the input data. */ - dictionaryLen = data[0]; - if (dictionaryLen > dataLen) - dictionaryLen = (unsigned int)dataLen; - - test_dict_deflate(&compr, &comprLen); - test_dict_inflate(compr, comprLen); - - free(compr); - - /* This function must return 0. */ + if (size < 1 || size > kMaxSize) return 0; + + data = d; + dataLen = size; + + /* Set up the contents of the dictionary. The size of the dictionary is + intentionally selected to be of unusual size. To help cover more corner + cases, the size of the dictionary is read from the input data. */ + dictionaryLen = data[0]; + if (dictionaryLen > dataLen) + dictionaryLen = dataLen; + + test_dict_deflate(&compr, &comprLen); + test_dict_inflate(compr, comprLen); + + free(compr); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/example_flush_fuzzer.c b/libs/zlibng/test/fuzz/example_flush_fuzzer.c index 81ec7e36d..f9f2d3646 100644 --- a/libs/zlibng/test/fuzz/example_flush_fuzzer.c +++ b/libs/zlibng/test/fuzz/example_flush_fuzzer.c @@ -29,96 +29,98 @@ static free_func zfree = NULL; * Test deflate() with full flush */ void test_flush(unsigned char *compr, z_size_t *comprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - unsigned int len = (unsigned int)dataLen; + PREFIX3(stream) c_stream; /* compression stream */ + int err; + unsigned int len = dataLen; - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (void *)0; + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (void *)0; - err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); + err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)data; - c_stream.next_out = compr; - c_stream.avail_in = 3; - c_stream.avail_out = (unsigned int)*comprLen; - err = PREFIX(deflate)(&c_stream, Z_FULL_FLUSH); - CHECK_ERR(err, "deflate flush 1"); + c_stream.next_in = (const unsigned char *)data; + c_stream.next_out = compr; + c_stream.avail_in = 3; + c_stream.avail_out = (unsigned int)*comprLen; + err = PREFIX(deflate)(&c_stream, Z_FULL_FLUSH); + CHECK_ERR(err, "deflate flush 1"); - compr[3]++; /* force an error in first compressed block */ - c_stream.avail_in = len - 3; + compr[3]++; /* force an error in first compressed block */ + c_stream.avail_in = len - 3; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - CHECK_ERR(err, "deflate flush 2"); - } - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); + err = PREFIX(deflate)(&c_stream, Z_FINISH); + if (err != Z_STREAM_END) { + CHECK_ERR(err, "deflate flush 2"); + } + err = PREFIX(deflateEnd)(&c_stream); + CHECK_ERR(err, "deflateEnd"); - *comprLen = (z_size_t)c_stream.total_out; + *comprLen = (z_size_t)c_stream.total_out; } /* =========================================================================== * Test inflateSync() */ -void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - int err; - PREFIX3(stream) d_stream; /* decompression stream */ +void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, + size_t uncomprLen) { + int err; + PREFIX3(stream) d_stream; /* decompression stream */ - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (void *)0; + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (void *)0; - d_stream.next_in = compr; - d_stream.avail_in = 2; /* just read the zlib header */ + d_stream.next_in = compr; + d_stream.avail_in = 2; /* just read the zlib header */ - err = PREFIX(inflateInit)(&d_stream); - CHECK_ERR(err, "inflateInit"); + err = PREFIX(inflateInit)(&d_stream); + CHECK_ERR(err, "inflateInit"); - d_stream.next_out = uncompr; - d_stream.avail_out = (unsigned int)uncomprLen; + d_stream.next_out = uncompr; + d_stream.avail_out = (unsigned int)uncomprLen; - err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); - CHECK_ERR(err, "inflate"); + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); + CHECK_ERR(err, "inflate"); - d_stream.avail_in = (unsigned int)comprLen - 2; /* read all compressed data */ - err = PREFIX(inflateSync)(&d_stream); /* but skip the damaged part */ - CHECK_ERR(err, "inflateSync"); + d_stream.avail_in = (unsigned int)comprLen - 2; /* read all compressed data */ + err = PREFIX(inflateSync)(&d_stream); /* but skip the damaged part */ + CHECK_ERR(err, "inflateSync"); - err = PREFIX(inflate)(&d_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "inflate should report Z_STREAM_END\n"); - exit(1); - } - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); + err = PREFIX(inflate)(&d_stream, Z_FINISH); + if (err != Z_DATA_ERROR) { + fprintf(stderr, "inflate should report DATA_ERROR\n"); + /* Because of incorrect adler32 */ + exit(1); + } + err = PREFIX(inflateEnd)(&d_stream); + CHECK_ERR(err, "inflateEnd"); } int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) { - z_size_t comprLen = 100 + 2 * PREFIX(compressBound)(size); - z_size_t uncomprLen = (z_size_t)size; - uint8_t *compr, *uncompr; + size_t comprLen = 100 + 2 * PREFIX(compressBound)(size); + size_t uncomprLen = size; + uint8_t *compr, *uncompr; - /* Discard inputs larger than 1Mb. */ - static size_t kMaxSize = 1024 * 1024; + /* Discard inputs larger than 1Mb. */ + static size_t kMaxSize = 1024 * 1024; - // This test requires at least 3 bytes of input data. - if (size <= 3 || size > kMaxSize) - return 0; - - data = d; - dataLen = size; - compr = (uint8_t *)calloc(1, comprLen); - uncompr = (uint8_t *)calloc(1, uncomprLen); - - test_flush(compr, &comprLen); - test_sync(compr, comprLen, uncompr, uncomprLen); - - free(compr); - free(uncompr); - - /* This function must return 0. */ + // This test requires at least 3 bytes of input data. + if (size <= 3 || size > kMaxSize) return 0; + + data = d; + dataLen = size; + compr = (uint8_t *)calloc(1, comprLen); + uncompr = (uint8_t *)calloc(1, uncomprLen); + + test_flush(compr, &comprLen); + test_sync(compr, comprLen, uncompr, uncomprLen); + + free(compr); + free(uncompr); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/example_large_fuzzer.c b/libs/zlibng/test/fuzz/example_large_fuzzer.c index bd27a84f1..1e8fedc22 100644 --- a/libs/zlibng/test/fuzz/example_large_fuzzer.c +++ b/libs/zlibng/test/fuzz/example_large_fuzzer.c @@ -29,113 +29,115 @@ static unsigned int diff; /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ -void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; +void test_large_deflate(unsigned char *compr, size_t comprLen, + unsigned char *uncompr, size_t uncomprLen) { + PREFIX3(stream) c_stream; /* compression stream */ + int err; - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (void *)0; + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (void *)0; - err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, "deflateInit"); + err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); + CHECK_ERR(err, "deflateInit"); - c_stream.next_out = compr; - c_stream.avail_out = (unsigned int)comprLen; + c_stream.next_out = compr; + c_stream.avail_out = (unsigned int)comprLen; - /* At this point, uncompr is still mostly zeroes, so it should compress - * very well: - */ - c_stream.next_in = uncompr; - c_stream.avail_in = (unsigned int)uncomprLen; - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate large 1"); - if (c_stream.avail_in != 0) { - fprintf(stderr, "deflate not greedy\n"); - exit(1); - } + /* At this point, uncompr is still mostly zeroes, so it should compress + * very well: + */ + c_stream.next_in = uncompr; + c_stream.avail_in = (unsigned int)uncomprLen; + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate large 1"); + if (c_stream.avail_in != 0) { + fprintf(stderr, "deflate not greedy\n"); + exit(1); + } - /* Feed in already compressed data and switch to no compression: */ - PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); - c_stream.next_in = compr; - diff = (unsigned int)(c_stream.next_out - compr); - c_stream.avail_in = diff; - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate large 2"); + /* Feed in already compressed data and switch to no compression: */ + PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); + c_stream.next_in = compr; + diff = (unsigned int)(c_stream.next_out - compr); + c_stream.avail_in = diff; + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate large 2"); - /* Switch back to compressing mode: */ - PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); - c_stream.next_in = uncompr; - c_stream.avail_in = (unsigned int)uncomprLen; - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate large 3"); + /* Switch back to compressing mode: */ + PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); + c_stream.next_in = uncompr; + c_stream.avail_in = (unsigned int)uncomprLen; + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate large 3"); - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate large should report Z_STREAM_END\n"); - exit(1); - } - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); + err = PREFIX(deflate)(&c_stream, Z_FINISH); + if (err != Z_STREAM_END) { + fprintf(stderr, "deflate large should report Z_STREAM_END\n"); + exit(1); + } + err = PREFIX(deflateEnd)(&c_stream); + CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with large buffers */ -void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - int err; - PREFIX3(stream) d_stream; /* decompression stream */ +void test_large_inflate(unsigned char *compr, size_t comprLen, + unsigned char *uncompr, size_t uncomprLen) { + int err; + PREFIX3(stream) d_stream; /* decompression stream */ - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (void *)0; + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (void *)0; - d_stream.next_in = compr; - d_stream.avail_in = (unsigned int)comprLen; + d_stream.next_in = compr; + d_stream.avail_in = (unsigned int)comprLen; - err = PREFIX(inflateInit)(&d_stream); - CHECK_ERR(err, "inflateInit"); + err = PREFIX(inflateInit)(&d_stream); + CHECK_ERR(err, "inflateInit"); - for (;;) { - d_stream.next_out = uncompr; /* discard the output */ - d_stream.avail_out = (unsigned int)uncomprLen; - err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) - break; - CHECK_ERR(err, "large inflate"); - } + for (;;) { + d_stream.next_out = uncompr; /* discard the output */ + d_stream.avail_out = (unsigned int)uncomprLen; + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) + break; + CHECK_ERR(err, "large inflate"); + } - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); + err = PREFIX(inflateEnd)(&d_stream); + CHECK_ERR(err, "inflateEnd"); - if (d_stream.total_out != 2 * uncomprLen + diff) { - fprintf(stderr, "bad large inflate: %" PRIu64 "\n", (uint64_t)d_stream.total_out); - exit(1); - } + if (d_stream.total_out != 2 * uncomprLen + diff) { + fprintf(stderr, "bad large inflate: %zu\n", d_stream.total_out); + exit(1); + } } int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) { - size_t comprLen = 100 + 3 * size; - size_t uncomprLen = comprLen; - uint8_t *compr, *uncompr; + size_t comprLen = 100 + 3 * size; + size_t uncomprLen = comprLen; + uint8_t *compr, *uncompr; - /* Discard inputs larger than 512Kb. */ - static size_t kMaxSize = 512 * 1024; + /* Discard inputs larger than 512Kb. */ + static size_t kMaxSize = 512 * 1024; - if (size < 1 || size > kMaxSize) - return 0; - - data = d; - dataLen = size; - compr = (uint8_t *)calloc(1, comprLen); - uncompr = (uint8_t *)calloc(1, uncomprLen); - - test_large_deflate(compr, comprLen, uncompr, uncomprLen); - test_large_inflate(compr, comprLen, uncompr, uncomprLen); - - free(compr); - free(uncompr); - - /* This function must return 0. */ + if (size < 1 || size > kMaxSize) return 0; + + data = d; + dataLen = size; + compr = (uint8_t *)calloc(1, comprLen); + uncompr = (uint8_t *)calloc(1, uncomprLen); + + test_large_deflate(compr, comprLen, uncompr, uncomprLen); + test_large_inflate(compr, comprLen, uncompr, uncomprLen); + + free(compr); + free(uncompr); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/example_small_fuzzer.c b/libs/zlibng/test/fuzz/example_small_fuzzer.c index d02a812de..d965c2db8 100644 --- a/libs/zlibng/test/fuzz/example_small_fuzzer.c +++ b/libs/zlibng/test/fuzz/example_small_fuzzer.c @@ -29,95 +29,96 @@ static free_func zfree = NULL; * Test deflate() with small buffers */ void test_deflate(unsigned char *compr, size_t comprLen) { - PREFIX3(stream) c_stream; /* compression stream */ - int err; - unsigned long len = (unsigned long)dataLen; + PREFIX3(stream) c_stream; /* compression stream */ + int err; + unsigned long len = dataLen; - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (void *)0; + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (void *)0; - err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); + err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)data; - c_stream.next_out = compr; + c_stream.next_in = (const unsigned char *)data; + c_stream.next_out = compr; - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate small 1"); - } - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) - break; - CHECK_ERR(err, "deflate small 2"); - } + while (c_stream.total_in != len && c_stream.total_out < comprLen) { + c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate small 1"); + } + /* Finish the stream, still forcing small buffers: */ + for (;;) { + c_stream.avail_out = 1; + err = PREFIX(deflate)(&c_stream, Z_FINISH); + if (err == Z_STREAM_END) + break; + CHECK_ERR(err, "deflate small 2"); + } - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); + err = PREFIX(deflateEnd)(&c_stream); + CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with small buffers */ -void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - int err; - PREFIX3(stream) d_stream; /* decompression stream */ +void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, + size_t uncomprLen) { + int err; + PREFIX3(stream) d_stream; /* decompression stream */ - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (void *)0; + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (void *)0; - d_stream.next_in = compr; - d_stream.avail_in = 0; - d_stream.next_out = uncompr; + d_stream.next_in = compr; + d_stream.avail_in = 0; + d_stream.next_out = uncompr; - err = PREFIX(inflateInit)(&d_stream); - CHECK_ERR(err, "inflateInit"); + err = PREFIX(inflateInit)(&d_stream); + CHECK_ERR(err, "inflateInit"); - while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { - d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ - err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) - break; - CHECK_ERR(err, "inflate"); - } + while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { + d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) + break; + CHECK_ERR(err, "inflate"); + } - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); + err = PREFIX(inflateEnd)(&d_stream); + CHECK_ERR(err, "inflateEnd"); - if (memcmp(uncompr, data, dataLen)) { - fprintf(stderr, "bad inflate\n"); - exit(1); - } + if (memcmp(uncompr, data, dataLen)) { + fprintf(stderr, "bad inflate\n"); + exit(1); + } } int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) { - size_t comprLen = PREFIX(compressBound)(size); - size_t uncomprLen = size; - uint8_t *compr, *uncompr; + size_t comprLen = PREFIX(compressBound)(size); + size_t uncomprLen = size; + uint8_t *compr, *uncompr; - /* Discard inputs larger than 1Mb. */ - static size_t kMaxSize = 1024 * 1024; + /* Discard inputs larger than 1Mb. */ + static size_t kMaxSize = 1024 * 1024; - if (size < 1 || size > kMaxSize) - return 0; - - data = d; - dataLen = size; - compr = (uint8_t *)calloc(1, comprLen); - uncompr = (uint8_t *)calloc(1, uncomprLen); - - test_deflate(compr, comprLen); - test_inflate(compr, comprLen, uncompr, uncomprLen); - - free(compr); - free(uncompr); - - /* This function must return 0. */ + if (size < 1 || size > kMaxSize) return 0; + + data = d; + dataLen = size; + compr = (uint8_t *)calloc(1, comprLen); + uncompr = (uint8_t *)calloc(1, uncomprLen); + + test_deflate(compr, comprLen); + test_inflate(compr, comprLen, uncompr, uncomprLen); + + free(compr); + free(uncompr); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/minigzip_fuzzer.c b/libs/zlibng/test/fuzz/minigzip_fuzzer.c index 1f19126f4..d0c35571f 100644 --- a/libs/zlibng/test/fuzz/minigzip_fuzzer.c +++ b/libs/zlibng/test/fuzz/minigzip_fuzzer.c @@ -12,14 +12,13 @@ * real thing. */ -#define _POSIX_SOURCE 1 /* This file needs POSIX for fileno(). */ -#define _POSIX_C_SOURCE 200112 /* For snprintf(). */ +/* @(#) $Id$ */ #include "zbuild.h" #ifdef ZLIB_COMPAT -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif #include #include @@ -36,7 +35,7 @@ # include #endif -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(WIN32) || defined(__CYGWIN__) # include # include # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) @@ -49,8 +48,8 @@ #endif #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) -#ifndef _WIN32 /* unlink already in stdio.h for Win32 */ -extern int unlink (const char *); +#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ + extern int unlink (const char *); #endif #endif @@ -63,22 +62,23 @@ extern int unlink (const char *); #define BUFLENW (BUFLEN * 3) /* write buffer size */ #define MAX_NAME_LEN 1024 -static const char *prog = "minigzip_fuzzer"; +static char *prog; void error (const char *msg); -void gz_compress (FILE *in, gzFile out); +void gz_compress (FILE *in, gzFile out); #ifdef USE_MMAP -int gz_compress_mmap (FILE *in, gzFile out); +int gz_compress_mmap (FILE *in, gzFile out); #endif -void gz_uncompress (gzFile in, FILE *out); -void file_compress (char *file, char *mode); -void file_uncompress (char *file); +void gz_uncompress (gzFile in, FILE *out); +void file_compress (char *file, char *mode); +void file_uncompress (char *file); int main (int argc, char *argv[]); /* =========================================================================== * Display error message and exit */ -void error(const char *msg) { +void error(const char *msg) +{ fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } @@ -87,7 +87,8 @@ void error(const char *msg) { * Compress input to output then close both files. */ -void gz_compress(FILE *in, gzFile out) { +void gz_compress(FILE *in, gzFile out) +{ char buf[BUFLEN]; int len; int err; @@ -120,11 +121,12 @@ void gz_compress(FILE *in, gzFile out) { /* Try compressing the input file at once using mmap. Return Z_OK if * if success, Z_ERRNO otherwise. */ -int gz_compress_mmap(FILE *in, gzFile out) { +int gz_compress_mmap(FILE *in, gzFile out) +{ int len; int err; int ifd = fileno(in); - char *buf; /* mmap'ed buffer for the entire input file */ + caddr_t buf; /* mmap'ed buffer for the entire input file */ off_t buf_len; /* length of the input file */ struct stat sb; @@ -134,8 +136,8 @@ int gz_compress_mmap(FILE *in, gzFile out) { if (buf_len <= 0) return Z_ERRNO; /* Now do the actual mmap: */ - buf = mmap((void *)0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); - if (buf == (char *)(-1)) return Z_ERRNO; + buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); + if (buf == (caddr_t)(-1)) return Z_ERRNO; /* Compress the whole file at once: */ len = PREFIX(gzwrite)(out, (char *)buf, (unsigned)buf_len); @@ -152,7 +154,8 @@ int gz_compress_mmap(FILE *in, gzFile out) { /* =========================================================================== * Uncompress input to output then close both files. */ -void gz_uncompress(gzFile in, FILE *out) { +void gz_uncompress(gzFile in, FILE *out) +{ char buf[BUFLENW]; int len; int err; @@ -176,9 +179,10 @@ void gz_uncompress(gzFile in, FILE *out) { * Compress the given file: create a corresponding .gz file and remove the * original. */ -void file_compress(char *file, char *mode) { +void file_compress(char *file, char *mode) +{ char outfile[MAX_NAME_LEN]; - FILE *in; + FILE *in; gzFile out; if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { @@ -207,10 +211,11 @@ void file_compress(char *file, char *mode) { /* =========================================================================== * Uncompress the given file and remove the original. */ -void file_uncompress(char *file) { +void file_uncompress(char *file) +{ char buf[MAX_NAME_LEN]; char *infile, *outfile; - FILE *out; + FILE *out; gzFile in; size_t len = strlen(file); @@ -247,75 +252,75 @@ void file_uncompress(char *file) { } int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) { - char *inFileName = "minigzip_fuzzer.out"; - char *outFileName = "minigzip_fuzzer.out.gz"; - char outmode[20]; - FILE *in; - char buf[BUFLEN]; - uint32_t offset = 0; + char *inFileName = "/tmp/minigzip_fuzzer.out"; + char *outFileName = "/tmp/minigzip_fuzzer.out.gz"; + char outmode[20]; + FILE *in; + char buf[BUFLEN]; + uint32_t offset = 0; - /* Discard inputs larger than 1Mb. */ - static size_t kMaxSize = 1024 * 1024; - if (dataLen < 1 || dataLen > kMaxSize) - return 0; - - in = fopen(inFileName, "wb"); - if (fwrite(data, 1, (unsigned)dataLen, in) != dataLen) - error("failed fwrite"); - if (fclose(in)) - error("failed fclose"); - - memset(outmode, 0, sizeof(outmode)); - snprintf(outmode, sizeof(outmode), "%s", "wb"); - - /* Compression level: [0..9]. */ - outmode[2] = data[0] % 10; - - switch (data[0] % 4) { - default: - case 0: - outmode[3] = 0; - break; - case 1: - /* compress with Z_FILTERED */ - outmode[3] = 'f'; - break; - case 2: - /* compress with Z_HUFFMAN_ONLY */ - outmode[3] = 'h'; - break; - case 3: - /* compress with Z_RLE */ - outmode[3] = 'R'; - break; - } - - file_compress(inFileName, outmode); - file_uncompress(outFileName); - - /* Check that the uncompressed file matches the input data. */ - in = fopen(inFileName, "rb"); - if (in == NULL) { - perror(inFileName); - exit(1); - } - - memset(buf, 0, sizeof(buf)); - for (;;) { - int len = (int)fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) - break; - assert(0 == memcmp(data + offset, buf, len)); - offset += len; - } - - if (fclose(in)) - error("failed fclose"); - - /* This function must return 0. */ + /* Discard inputs larger than 1Mb. */ + static size_t kMaxSize = 1024 * 1024; + if (dataLen < 1 || dataLen > kMaxSize) return 0; + + in = fopen(inFileName, "w"); + if (fwrite(data, 1, (unsigned)dataLen, in) != dataLen) + error("failed fwrite"); + if (fclose(in)) + error("failed fclose"); + + memset(outmode, 0, sizeof(outmode)); + snprintf(outmode, sizeof(outmode), "%s", "wb"); + + /* Compression level: [0..9]. */ + outmode[2] = data[0] % 10; + + switch (data[0] % 4) { + default: + case 0: + outmode[3] = 0; + break; + case 1: + /* compress with Z_FILTERED */ + outmode[3] = 'f'; + break; + case 2: + /* compress with Z_HUFFMAN_ONLY */ + outmode[3] = 'h'; + break; + case 3: + /* compress with Z_RLE */ + outmode[3] = 'R'; + break; + } + + file_compress(inFileName, outmode); + file_uncompress(outFileName); + + /* Check that the uncompressed file matches the input data. */ + in = fopen(inFileName, "rb"); + if (in == NULL) { + perror(inFileName); + exit(1); + } + + memset(buf, 0, sizeof(buf)); + for (;;) { + int len = (int)fread(buf, 1, sizeof(buf), in); + if (ferror(in)) { + perror("fread"); + exit(1); + } + if (len == 0) + break; + assert(0 == memcmp(data + offset, buf, len)); + offset += len; + } + + if (fclose(in)) + error("failed fclose"); + + /* This function must return 0. */ + return 0; } diff --git a/libs/zlibng/test/fuzz/standalone_fuzz_target_runner.c b/libs/zlibng/test/fuzz/standalone_fuzz_target_runner.c index a291b4882..5a5c75096 100644 --- a/libs/zlibng/test/fuzz/standalone_fuzz_target_runner.c +++ b/libs/zlibng/test/fuzz/standalone_fuzz_target_runner.c @@ -5,32 +5,31 @@ extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); int main(int argc, char **argv) { - int i; - fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1); + int i; + fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1); - for (i = 1; i < argc; i++) { - size_t len, n_read, err; - unsigned char *buf; - FILE *f = fopen(argv[i], "rb+"); - if (!f) { - /* Failed to open this file: it may be a directory. */ - fprintf(stderr, "Skipping: %s\n", argv[i]); - continue; - } - fprintf(stderr, "Running: %s %s\n", argv[0], argv[i]); - fseek(f, 0, SEEK_END); - len = ftell(f); - fseek(f, 0, SEEK_SET); - buf = (unsigned char *)malloc(len); - n_read = fread(buf, 1, len, f); - assert(n_read == len); - LLVMFuzzerTestOneInput(buf, len); - free(buf); - err = fclose(f); - assert(err == 0); - (void)err; - fprintf(stderr, "Done: %s: (%d bytes)\n", argv[i], (int)n_read); + for (i = 1; i < argc; i++) { + size_t len, n_read, err; + unsigned char *buf; + FILE *f = fopen(argv[i], "rb+"); + if (!f) { + /* Failed to open this file: it may be a directory. */ + fprintf(stderr, "Skipping: %s\n", argv[i]); + continue; } + fprintf(stderr, "Running: %s %s\n", argv[0], argv[i]); + fseek(f, 0, SEEK_END); + len = ftell(f); + fseek(f, 0, SEEK_SET); + buf = (unsigned char *)malloc(len); + n_read = fread(buf, 1, len, f); + assert(n_read == len); + LLVMFuzzerTestOneInput(buf, len); + free(buf); + err = fclose(f); + assert(err == 0); + fprintf(stderr, "Done: %s: (%d bytes)\n", argv[i], (int)n_read); + } - return 0; + return 0; } diff --git a/libs/zlibng/test/infcover.c b/libs/zlibng/test/infcover.c index 3466b202d..2b8ff974a 100644 --- a/libs/zlibng/test/infcover.c +++ b/libs/zlibng/test/infcover.c @@ -8,20 +8,13 @@ #include #include #include -#undef NDEBUG #include -#include -#include +#include "zlib.h" /* get definition of internal structure so we can mess with it (see pull()), and so we can call inflate_trees() (see cover5()) */ #define ZLIB_INTERNAL #include "zbuild.h" -#ifdef ZLIB_COMPAT -# include "zlib.h" -#else -# include "zlib-ng.h" -#endif #include "inftrees.h" #include "inflate.h" @@ -35,7 +28,7 @@ They are used as follows: - PREFIX3(stream) strm; + z_stream strm; mem_setup(&strm) initializes the memory tracking and sets the zalloc, zfree, and opaque members of strm to use memory tracking for all zlib operations on strm @@ -74,7 +67,8 @@ struct mem_zone { }; /* memory allocation routine to pass to zlib */ -static void *mem_alloc(void *mem, unsigned count, unsigned size) { +static void *mem_alloc(void *mem, unsigned count, unsigned size) +{ void *ptr; struct mem_item *item; struct mem_zone *zone = mem; @@ -114,7 +108,8 @@ static void *mem_alloc(void *mem, unsigned count, unsigned size) { } /* memory free routine to pass to zlib */ -static void mem_free(void *mem, void *ptr) { +static void mem_free(void *mem, void *ptr) +{ struct mem_item *item, *next; struct mem_zone *zone = mem; @@ -159,7 +154,8 @@ static void mem_free(void *mem, void *ptr) { /* set up a controlled memory allocation space for monitoring, set the stream parameters to the controlled routines, with opaque pointing to the space */ -static void mem_setup(PREFIX3(stream) *strm) { +static void mem_setup(z_stream *strm) +{ struct mem_zone *zone; zone = malloc(sizeof(struct mem_zone)); @@ -176,28 +172,32 @@ static void mem_setup(PREFIX3(stream) *strm) { } /* set a limit on the total memory allocation, or 0 to remove the limit */ -static void mem_limit(PREFIX3(stream) *strm, size_t limit) { +static void mem_limit(z_stream *strm, size_t limit) +{ struct mem_zone *zone = strm->opaque; zone->limit = limit; } /* show the current total requested allocations in bytes */ -static void mem_used(PREFIX3(stream) *strm, char *prefix) { +static void mem_used(z_stream *strm, char *prefix) +{ struct mem_zone *zone = strm->opaque; - fprintf(stderr, "%s: %" PRIu64 " allocated\n", prefix, (uint64_t)zone->total); + fprintf(stderr, "%s: %zu allocated\n", prefix, zone->total); } /* show the high water allocation in bytes */ -static void mem_high(PREFIX3(stream) *strm, char *prefix) { +static void mem_high(z_stream *strm, char *prefix) +{ struct mem_zone *zone = strm->opaque; - fprintf(stderr, "%s: %" PRIu64 " high water mark\n", prefix, (uint64_t)zone->highwater); + fprintf(stderr, "%s: %zu high water mark\n", prefix, zone->highwater); } /* release the memory allocation zone -- if there are any surprises, notify */ -static void mem_done(PREFIX3(stream) *strm, char *prefix) { +static void mem_done(z_stream *strm, char *prefix) +{ int count = 0; struct mem_item *item, *next; struct mem_zone *zone = strm->opaque; @@ -217,8 +217,8 @@ static void mem_done(PREFIX3(stream) *strm, char *prefix) { /* issue alerts about anything unexpected */ if (count || zone->total) - fprintf(stderr, "** %s: %" PRIu64 " bytes in %d blocks not freed\n", - prefix, (uint64_t)zone->total, count); + fprintf(stderr, "** %s: %zu bytes in %d blocks not freed\n", + prefix, zone->total, count); if (zone->notlifo) fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo); if (zone->rogue) @@ -241,14 +241,12 @@ static void mem_done(PREFIX3(stream) *strm, char *prefix) { by a delimiter, where that single digit writes a byte. The returned data is allocated and must eventually be freed. NULL is returned if out of memory. If the length is not needed, then len can be NULL. */ -static unsigned char *h2b(const char *hex, unsigned *len) { +static unsigned char *h2b(const char *hex, unsigned *len) +{ unsigned char *in, *re; unsigned next, val; - size_t inlen; - inlen = (strlen(hex) + 1) >> 1; - assert(inlen != 0); /* tell static analyzer we won't call malloc(0) */ - in = malloc(inlen); + in = malloc((strlen(hex) + 1) >> 1); if (in == NULL) return NULL; next = 0; @@ -269,7 +267,6 @@ static unsigned char *h2b(const char *hex, unsigned *len) { } while (*hex++); /* go through the loop with the terminating null */ if (len != NULL) *len = next; - assert(next != 0); /* tell static analyzer we won't call realloc(in, 0) */ re = realloc(in, next); return re == NULL ? in : re; } @@ -283,17 +280,18 @@ static unsigned char *h2b(const char *hex, unsigned *len) { header information is collected with inflateGetHeader(). If a zlib stream is looking for a dictionary, then an empty dictionary is provided. inflate() is run until all of the input data is consumed. */ -static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err) { +static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err) +{ int ret; unsigned have; unsigned char *in, *out; - PREFIX3(stream) strm, copy; - PREFIX(gz_header) head; + z_stream strm, copy; + gz_header head; mem_setup(&strm); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit2)(&strm, win); + ret = inflateInit2(&strm, win); if (ret != Z_OK) { mem_done(&strm, what); return; @@ -306,8 +304,7 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int head.name_max = len; head.comment = out; head.comm_max = len; - ret = PREFIX(inflateGetHeader)(&strm, &head); - assert(ret == Z_OK); + ret = inflateGetHeader(&strm, &head); assert(ret == Z_OK); } in = h2b(hex, &have); assert(in != NULL); if (step == 0 || step > have) @@ -318,26 +315,23 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int do { strm.avail_out = len; strm.next_out = out; - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); - assert(err == 9 || ret == err); + ret = inflate(&strm, Z_NO_FLUSH); assert(err == 9 || ret == err); if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_NEED_DICT) break; if (ret == Z_NEED_DICT) { - ret = PREFIX(inflateSetDictionary)(&strm, in, 1); + ret = inflateSetDictionary(&strm, in, 1); assert(ret == Z_DATA_ERROR); mem_limit(&strm, 1); - ret = PREFIX(inflateSetDictionary)(&strm, out, 0); + ret = inflateSetDictionary(&strm, out, 0); assert(ret == Z_MEM_ERROR); mem_limit(&strm, 0); ((struct inflate_state *)strm.state)->mode = DICT; - ret = PREFIX(inflateSetDictionary)(&strm, out, 0); + ret = inflateSetDictionary(&strm, out, 0); assert(ret == Z_OK); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); - assert(ret == Z_BUF_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR); } - ret = PREFIX(inflateCopy)(©, &strm); - assert(ret == Z_OK); - ret = PREFIX(inflateEnd)(©); assert(ret == Z_OK); + ret = inflateCopy(©, &strm); assert(ret == Z_OK); + ret = inflateEnd(©); assert(ret == Z_OK); err = 9; /* don't care next time around */ have += strm.avail_in; strm.avail_in = step > have ? have : step; @@ -345,27 +339,27 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int } while (strm.avail_in); free(in); free(out); - ret = PREFIX(inflateReset2)(&strm, -8); assert(ret == Z_OK); - ret = PREFIX(inflateEnd)(&strm); assert(ret == Z_OK); + ret = inflateReset2(&strm, -8); assert(ret == Z_OK); + ret = inflateEnd(&strm); assert(ret == Z_OK); mem_done(&strm, what); - (void)err; } /* cover all of the lines in inflate.c up to inflate() */ -static void cover_support(void) { +static void cover_support(void) +{ int ret; - PREFIX3(stream) strm; + z_stream strm; mem_setup(&strm); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit)(&strm); assert(ret == Z_OK); + ret = inflateInit(&strm); assert(ret == Z_OK); mem_used(&strm, "inflate init"); - ret = PREFIX(inflatePrime)(&strm, 5, 31); assert(ret == Z_OK); - ret = PREFIX(inflatePrime)(&strm, -1, 0); assert(ret == Z_OK); - ret = PREFIX(inflateSetDictionary)(&strm, NULL, 0); + ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK); + ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK); + ret = inflateSetDictionary(&strm, NULL, 0); assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateEnd)(&strm); assert(ret == Z_OK); + ret = inflateEnd(&strm); assert(ret == Z_OK); mem_done(&strm, "prime"); inf("63 0", "force window allocation", 0, -15, 1, Z_OK); @@ -377,27 +371,27 @@ static void cover_support(void) { mem_setup(&strm); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit_)(&strm, &PREFIX2(VERSION)[1], (int)sizeof(PREFIX3(stream))); + ret = inflateInit_(&strm, ZLIB_VERSION + 1, (int)sizeof(z_stream)); assert(ret == Z_VERSION_ERROR); mem_done(&strm, "wrong version"); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit)(&strm); assert(ret == Z_OK); - ret = PREFIX(inflateEnd)(&strm); assert(ret == Z_OK); + ret = inflateInit(&strm); assert(ret == Z_OK); + ret = inflateEnd(&strm); assert(ret == Z_OK); fputs("inflate built-in memory routines\n", stderr); - (void)ret; } /* cover all inflate() header and trailer cases and code after inflate() */ -static void cover_wrap(void) { +static void cover_wrap(void) +{ int ret; - PREFIX3(stream) strm, copy; + z_stream strm, copy; unsigned char dict[257]; - ret = PREFIX(inflate)(NULL, 0); assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateEnd)(NULL); assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateCopy)(NULL, NULL); assert(ret == Z_STREAM_ERROR); + ret = inflate(NULL, 0); assert(ret == Z_STREAM_ERROR); + ret = inflateEnd(NULL); assert(ret == Z_STREAM_ERROR); + ret = inflateCopy(NULL, NULL); assert(ret == Z_STREAM_ERROR); fputs("inflate bad parameters\n", stderr); inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR); @@ -417,43 +411,39 @@ static void cover_wrap(void) { mem_setup(&strm); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit2)(&strm, -8); + ret = inflateInit2(&strm, -8); strm.avail_in = 2; strm.next_in = (void *)"\x63"; strm.avail_out = 1; strm.next_out = (void *)&ret; mem_limit(&strm, 1); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); mem_limit(&strm, 0); memset(dict, 0, 257); - ret = PREFIX(inflateSetDictionary)(&strm, dict, 257); + ret = inflateSetDictionary(&strm, dict, 257); assert(ret == Z_OK); mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256); - ret = PREFIX(inflatePrime)(&strm, 16, 0); assert(ret == Z_OK); + ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK); strm.avail_in = 2; strm.next_in = (void *)"\x80"; - ret = PREFIX(inflateSync)(&strm); assert(ret == Z_DATA_ERROR); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR); + ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR); strm.avail_in = 4; strm.next_in = (void *)"\0\0\xff\xff"; - ret = PREFIX(inflateSync)(&strm); assert(ret == Z_OK); - (void)PREFIX(inflateSyncPoint)(&strm); - ret = PREFIX(inflateCopy)(©, &strm); assert(ret == Z_MEM_ERROR); + ret = inflateSync(&strm); assert(ret == Z_OK); + (void)inflateSyncPoint(&strm); + ret = inflateCopy(©, &strm); assert(ret == Z_MEM_ERROR); mem_limit(&strm, 0); - ret = PREFIX(inflateUndermine)(&strm, 1); -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - assert(ret == Z_OK); -#else - assert(ret == Z_DATA_ERROR); -#endif - (void)PREFIX(inflateMark)(&strm); - ret = PREFIX(inflateEnd)(&strm); assert(ret == Z_OK); + ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR); + (void)inflateMark(&strm); + ret = inflateEnd(&strm); assert(ret == Z_OK); mem_done(&strm, "miscellaneous, force memory errors"); } /* input and output functions for inflateBack() */ -static unsigned pull(void *desc, z_const unsigned char **buf) { +static unsigned pull(void *desc, const unsigned char **buf) +{ static unsigned int next = 0; static unsigned char dat[] = {0x63, 0, 2, 0}; struct inflate_state *state; @@ -462,65 +452,63 @@ static unsigned pull(void *desc, z_const unsigned char **buf) { next = 0; return 0; /* no input (already provided at next_in) */ } - state = (void *)((PREFIX3(stream) *)desc)->state; + state = (void *)((z_stream *)desc)->state; if (state != NULL) state->mode = SYNC; /* force an otherwise impossible situation */ return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; } -static int push(void *desc, unsigned char *buf, unsigned len) { +static int push(void *desc, unsigned char *buf, unsigned len) +{ buf += len; - (void)buf; return desc != NULL; /* force error if desc not null */ } /* cover inflateBack() up to common deflate data cases and after those */ -static void cover_back(void) { +static void cover_back(void) +{ int ret; - PREFIX3(stream) strm; + z_stream strm; unsigned char win[32768]; - ret = PREFIX(inflateBackInit_)(NULL, 0, win, 0, 0); + ret = inflateBackInit_(NULL, 0, win, 0, 0); assert(ret == Z_VERSION_ERROR); - ret = PREFIX(inflateBackInit)(NULL, 0, win); + ret = inflateBackInit(NULL, 0, win); assert(ret == Z_STREAM_ERROR); + ret = inflateBack(NULL, NULL, NULL, NULL, NULL); assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateBack)(NULL, NULL, NULL, NULL, NULL); - assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateBackEnd)(NULL); assert(ret == Z_STREAM_ERROR); + ret = inflateBackEnd(NULL); assert(ret == Z_STREAM_ERROR); fputs("inflateBack bad parameters\n", stderr); mem_setup(&strm); - ret = PREFIX(inflateBackInit)(&strm, 15, win); - assert(ret == Z_OK); + ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); strm.avail_in = 2; strm.next_in = (void *)"\x03"; - ret = PREFIX(inflateBack)(&strm, pull, NULL, push, NULL); + ret = inflateBack(&strm, pull, NULL, push, NULL); assert(ret == Z_STREAM_END); /* force output error */ strm.avail_in = 3; strm.next_in = (void *)"\x63\x00"; - ret = PREFIX(inflateBack)(&strm, pull, NULL, push, &strm); + ret = inflateBack(&strm, pull, NULL, push, &strm); assert(ret == Z_BUF_ERROR); /* force mode error by mucking with state */ - ret = PREFIX(inflateBack)(&strm, pull, &strm, push, NULL); + ret = inflateBack(&strm, pull, &strm, push, NULL); assert(ret == Z_STREAM_ERROR); - ret = PREFIX(inflateBackEnd)(&strm); assert(ret == Z_OK); + ret = inflateBackEnd(&strm); assert(ret == Z_OK); mem_done(&strm, "inflateBack bad state"); - ret = PREFIX(inflateBackInit)(&strm, 15, win); - assert(ret == Z_OK); - ret = PREFIX(inflateBackEnd)(&strm); assert(ret == Z_OK); + ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); + ret = inflateBackEnd(&strm); assert(ret == Z_OK); fputs("inflateBack built-in memory routines\n", stderr); - (void)ret; } /* do a raw inflate of data in hexadecimal with both inflate and inflateBack */ -static int try(char *hex, char *id, int err) { +static int try(char *hex, char *id, int err) +{ int ret; unsigned len, size; unsigned char *in, *out, *win; char *prefix; - PREFIX3(stream) strm; + z_stream strm; /* convert to hex */ in = h2b(hex, &len); @@ -541,14 +529,14 @@ static int try(char *hex, char *id, int err) { mem_setup(&strm); strm.avail_in = 0; strm.next_in = NULL; - ret = PREFIX(inflateInit2)(&strm, err < 0 ? 47 : -15); + ret = inflateInit2(&strm, err < 0 ? 47 : -15); assert(ret == Z_OK); strm.avail_in = len; strm.next_in = in; do { strm.avail_out = size; strm.next_out = out; - ret = PREFIX(inflate)(&strm, Z_TREES); + ret = inflate(&strm, Z_TREES); assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR); if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT) break; @@ -557,7 +545,7 @@ static int try(char *hex, char *id, int err) { assert(ret == Z_DATA_ERROR); assert(strcmp(id, strm.msg) == 0); } - PREFIX(inflateEnd)(&strm); + inflateEnd(&strm); mem_done(&strm, prefix); /* then with inflateBack */ @@ -565,17 +553,17 @@ static int try(char *hex, char *id, int err) { strcpy(prefix, id); strcat(prefix, "-back"); mem_setup(&strm); - ret = PREFIX(inflateBackInit)(&strm, 15, win); + ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); strm.avail_in = len; strm.next_in = in; - ret = PREFIX(inflateBack)(&strm, pull, NULL, push, NULL); + ret = inflateBack(&strm, pull, NULL, push, NULL); assert(ret != Z_STREAM_ERROR); - if (err && ret != Z_BUF_ERROR) { + if (err) { assert(ret == Z_DATA_ERROR); assert(strcmp(id, strm.msg) == 0); } - PREFIX(inflateBackEnd)(&strm); + inflateBackEnd(&strm); mem_done(&strm, prefix); } @@ -588,7 +576,8 @@ static int try(char *hex, char *id, int err) { } /* cover deflate data cases in both inflate() and inflateBack() */ -static void cover_inflate(void) { +static void cover_inflate(void) +{ try("0 0 0 0 0", "invalid stored block lengths", 1); try("3 0", "fixed", 0); try("6", "invalid block type", 1); @@ -603,11 +592,7 @@ static void cover_inflate(void) { try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1); try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1); try("2 7e ff ff", "invalid distance code", 1); -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 0); -#else try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1); -#endif /* also trailer mismatch just in inflate() */ try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1); @@ -627,7 +612,8 @@ static void cover_inflate(void) { } /* cover remaining lines in inftrees.c */ -static void cover_trees(void) { +static void cover_trees(void) +{ int ret; unsigned bits; uint16_t lens[16], work[16]; @@ -640,18 +626,18 @@ static void cover_trees(void) { lens[15] = 15; next = table; bits = 15; - ret = zng_inflate_table(DISTS, lens, 16, &next, &bits, work); + ret = inflate_table(DISTS, lens, 16, &next, &bits, work); assert(ret == 1); next = table; bits = 1; - ret = zng_inflate_table(DISTS, lens, 16, &next, &bits, work); + ret = inflate_table(DISTS, lens, 16, &next, &bits, work); assert(ret == 1); fputs("inflate_table not enough errors\n", stderr); - (void)ret; } /* cover remaining inffast.c decoding and window copying */ -static void cover_fast(void) { +static void cover_fast(void) +{ inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68" " ff 7f 0f 0 0 0", "fast length extra bits", 0, -8, 258, Z_DATA_ERROR); inf("25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49" @@ -670,8 +656,9 @@ static void cover_fast(void) { Z_STREAM_END); } -int main(void) { - fprintf(stderr, "%s\n", zVersion()); +int main(void) +{ + fprintf(stderr, "%s\n", zlibVersion()); cover_support(); cover_wrap(); cover_back(); diff --git a/libs/zlibng/test/minideflate.c b/libs/zlibng/test/minideflate.c deleted file mode 100644 index 392516852..000000000 --- a/libs/zlibng/test/minideflate.c +++ /dev/null @@ -1,307 +0,0 @@ -/* minideflate.c -- test deflate/inflate under specific conditions - * Copyright (C) 2020 Nathan Moinvaziri - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "zbuild.h" -#ifdef ZLIB_COMPAT -# include "zlib.h" -#else -# include "zlib-ng.h" -#endif - -#if defined(_WIN32) || defined(__CYGWIN__) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif - -#define CHECK_ERR(err, msg) { \ - if (err != Z_OK) { \ - fprintf(stderr, "%s error: %d\n", msg, err); \ - exit(1); \ - } \ -} - -/* =========================================================================== - * deflate() using specialized parameters - */ -void deflate_params(FILE *fin, FILE *fout, int32_t read_buf_size, int32_t write_buf_size, int32_t level, - int32_t window_bits, int32_t mem_level, int32_t strategy, int32_t flush) { - PREFIX3(stream) c_stream; /* compression stream */ - uint8_t *read_buf; - uint8_t *write_buf; - int32_t read; - int err; - - read_buf = (uint8_t *)malloc(read_buf_size); - if (read_buf == NULL) { - fprintf(stderr, "failed to create read buffer (%d)\n", read_buf_size); - return; - } - write_buf = (uint8_t *)malloc(write_buf_size); - if (write_buf == NULL) { - fprintf(stderr, "failed to create write buffer (%d)\n", write_buf_size); - free(read_buf); - return; - } - - c_stream.zalloc = NULL; - c_stream.zfree = NULL; - c_stream.opaque = (void *)0; - c_stream.total_in = 0; - c_stream.total_out = 0; - - err = PREFIX(deflateInit2)(&c_stream, level, Z_DEFLATED, window_bits, mem_level, strategy); - CHECK_ERR(err, "deflateInit2"); - - /* Process input using our read buffer and flush type, - * output to stdout only once write buffer is full */ - do { - read = (int32_t)fread(read_buf, 1, read_buf_size, fin); - if (read <= 0) - break; - - c_stream.next_in = (z_const uint8_t *)read_buf; - c_stream.next_out = write_buf; - c_stream.avail_in = read; - - do { - c_stream.avail_out = write_buf_size; - err = PREFIX(deflate)(&c_stream, flush); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - - if (c_stream.next_out == write_buf + write_buf_size) { - fwrite(write_buf, 1, write_buf_size, fout); - c_stream.next_out = write_buf; - } - } while (c_stream.next_in < read_buf + read); - } while (err == Z_OK); - - /* Finish the stream if necessary */ - if (flush != Z_FINISH) { - c_stream.avail_in = 0; - do { - if (c_stream.next_out == write_buf + write_buf_size) { - fwrite(write_buf, 1, write_buf_size, fout); - c_stream.next_out = write_buf; - } - - c_stream.avail_out = write_buf_size; - err = PREFIX(deflate)(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } while (err == Z_OK); - } - - /* Output remaining data in write buffer */ - if (c_stream.next_out != write_buf) { - fwrite(write_buf, 1, c_stream.next_out - write_buf, fout); - } - - err = PREFIX(deflateEnd)(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - free(read_buf); - free(write_buf); -} - -/* =========================================================================== - * inflate() using specialized parameters - */ -void inflate_params(FILE *fin, FILE *fout, int32_t read_buf_size, int32_t write_buf_size, int32_t window_bits, - int32_t flush) { - PREFIX3(stream) d_stream; /* decompression stream */ - uint8_t *read_buf; - uint8_t *write_buf; - int32_t read; - int err; - - - read_buf = (uint8_t *)malloc(read_buf_size); - if (read_buf == NULL) { - fprintf(stderr, "failed to create read buffer (%d)\n", read_buf_size); - return; - } - write_buf = (uint8_t *)malloc(write_buf_size); - if (write_buf == NULL) { - fprintf(stderr, "failed to create write buffer (%d)\n", write_buf_size); - free(read_buf); - return; - } - - d_stream.zalloc = NULL; - d_stream.zfree = NULL; - d_stream.opaque = (void *)0; - d_stream.total_in = 0; - d_stream.total_out = 0; - - err = PREFIX(inflateInit2)(&d_stream, window_bits); - CHECK_ERR(err, "inflateInit2"); - - /* Process input using our read buffer and flush type, - * output to stdout only once write buffer is full */ - do { - read = (int32_t)fread(read_buf, 1, read_buf_size, fin); - if (read <= 0) - break; - - d_stream.next_in = (z_const uint8_t *)read_buf; - d_stream.next_out = write_buf; - d_stream.avail_in = read; - - do { - d_stream.avail_out = write_buf_size; - err = PREFIX(inflate)(&d_stream, flush); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - - if (d_stream.next_out == write_buf + write_buf_size) { - fwrite(write_buf, 1, write_buf_size, fout); - d_stream.next_out = write_buf; - } - } while (d_stream.next_in < read_buf + read); - } while (err == Z_OK); - - /* Finish the stream if necessary */ - if (flush != Z_FINISH) { - d_stream.avail_in = 0; - do { - if (d_stream.next_out == write_buf + write_buf_size) { - fwrite(write_buf, 1, write_buf_size, fout); - d_stream.next_out = write_buf; - } - - d_stream.avail_out = write_buf_size; - err = PREFIX(inflate)(&d_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "inflate"); - } while (err == Z_OK); - } - - /* Output remaining data in write buffer */ - if (d_stream.next_out != write_buf) { - fwrite(write_buf, 1, d_stream.next_out - write_buf, fout); - } - - err = PREFIX(inflateEnd)(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - free(read_buf); - free(write_buf); -} - -void show_help(void) { - printf("Usage: minideflate [-c] [-f|-h|-R|-F] [-m level] [-r/-t size] [-s flush] [-w bits] [-0 to -9] [input file]\n\n" \ - " -c : write to standard output\n" \ - " -d : decompress\n" \ - " -f : compress with Z_FILTERED\n" \ - " -h : compress with Z_HUFFMAN_ONLY\n" \ - " -R : compress with Z_RLE\n" \ - " -F : compress with Z_FIXED\n" \ - " -m : memory level (1 to 8)\n" \ - " -w : window bits (8 to 15 for gzip, -8 to -15 for zlib)\n" \ - " -s : flush type (0 to 5)\n" \ - " -r : read buffer size\n" \ - " -t : write buffer size\n" \ - " -0 to -9 : compression level\n\n"); -} - -int main(int argc, char **argv) { - int32_t i; - int32_t mem_level = DEF_MEM_LEVEL; - int32_t window_bits = MAX_WBITS; - int32_t strategy = Z_DEFAULT_STRATEGY; - int32_t level = Z_DEFAULT_COMPRESSION; - int32_t read_buf_size = 4096; - int32_t write_buf_size = 4096; - int32_t flush = Z_NO_FLUSH; - uint8_t copyout = 0; - uint8_t uncompr = 0; - char out_file[320]; - FILE *fin = stdin; - FILE *fout = stdout; - - for (i = 1; i < argc; i++) { - if ((strcmp(argv[i], "-m") == 0) && (i + 1 < argc)) - mem_level = atoi(argv[++i]); - else if ((strcmp(argv[i], "-w") == 0) && (i + 1 < argc)) - window_bits = atoi(argv[++i]); - else if ((strcmp(argv[i], "-r") == 0) && (i + 1 < argc)) - read_buf_size = atoi(argv[++i]); - else if ((strcmp(argv[i], "-t") == 0) && (i + 1 < argc)) - write_buf_size = atoi(argv[++i]); - else if ((strcmp(argv[i], "-s") == 0) && (i + 1 < argc)) - flush = atoi(argv[++i]); - else if (strcmp(argv[i], "-c") == 0) - copyout = 1; - else if (strcmp(argv[i], "-d") == 0) - uncompr = 1; - else if (strcmp(argv[i], "-f") == 0) - strategy = Z_FILTERED; - else if (strcmp(argv[i], "-h") == 0) - strategy = Z_HUFFMAN_ONLY; - else if (strcmp(argv[i], "-R") == 0) - strategy = Z_RLE; - else if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9' && argv[i][2] == 0) - level = argv[i][1] - '0'; - else if (strcmp(argv[i], "--help") == 0) { - show_help(); - return 0; - } else if (argv[i][0] == '-') { - show_help(); - return 64; /* EX_USAGE */ - } else - break; - } - - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - if (i != argc) { - fin = fopen(argv[i], "rb+"); - if (fin == NULL) { - fprintf(stderr, "Failed to open file: %s\n", argv[i]); - exit(1); - } - if (!copyout) { - snprintf(out_file, sizeof(out_file), "%s%s", argv[i], (window_bits < 0) ? ".zz" : ".gz"); - fout = fopen(out_file, "wb"); - if (fout == NULL) { - fprintf(stderr, "Failed to open file: %s\n", out_file); - exit(1); - } - } - } - - if (uncompr) { - inflate_params(fin, fout, read_buf_size, write_buf_size, window_bits, flush); - } else { - deflate_params(fin, fout, read_buf_size, write_buf_size, level, window_bits, mem_level, strategy, flush); - } - - if (fin != stdin) { - fclose(fin); - } - if (fout != stdout) { - fclose(fout); - } - - return 0; -} diff --git a/libs/zlibng/test/minigzip.c b/libs/zlibng/test/minigzip.c index 2e4ef8e2a..ebbed9ae3 100644 --- a/libs/zlibng/test/minigzip.c +++ b/libs/zlibng/test/minigzip.c @@ -12,14 +12,16 @@ * real thing. */ +/* @(#) $Id$ */ + #define _POSIX_SOURCE 1 /* This file needs POSIX for fdopen(). */ #define _POSIX_C_SOURCE 200112 /* For snprintf(). */ #include "zbuild.h" #ifdef ZLIB_COMPAT -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif #include @@ -36,7 +38,7 @@ # include #endif -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(WIN32) || defined(__CYGWIN__) # include # include # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) @@ -49,8 +51,8 @@ #endif #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) -#ifndef _WIN32 /* unlink already in stdio.h for Win32 */ -extern int unlink (const char *); +#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ + extern int unlink (const char *); #endif #endif @@ -59,8 +61,10 @@ extern int unlink (const char *); #endif #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) -#ifndef BUFLEN -# define BUFLEN 16384 /* read buffer size */ +#if defined(S390_DFLTCC_DEFLATE) || defined(S390_DFLTCC_INFLATE) +#define BUFLEN 262144 /* DFLTCC works faster with larger buffers */ +#else +#define BUFLEN 16384 /* read buffer size */ #endif #define BUFLENW (BUFLEN * 3) /* write buffer size */ #define MAX_NAME_LEN 1024 @@ -68,19 +72,20 @@ extern int unlink (const char *); static char *prog; void error (const char *msg); -void gz_compress (FILE *in, gzFile out); +void gz_compress (FILE *in, gzFile out); #ifdef USE_MMAP -int gz_compress_mmap (FILE *in, gzFile out); +int gz_compress_mmap (FILE *in, gzFile out); #endif -void gz_uncompress (gzFile in, FILE *out); -void file_compress (char *file, char *mode, int keep); -void file_uncompress (char *file, int keep); +void gz_uncompress (gzFile in, FILE *out); +void file_compress (char *file, char *mode); +void file_uncompress (char *file); int main (int argc, char *argv[]); /* =========================================================================== * Display error message and exit */ -void error(const char *msg) { +void error(const char *msg) +{ fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } @@ -89,8 +94,9 @@ void error(const char *msg) { * Compress input to output then close both files. */ -void gz_compress(FILE *in, gzFile out) { - char *buf; +void gz_compress(FILE *in, gzFile out) +{ + char buf[BUFLEN]; int len; int err; @@ -100,16 +106,12 @@ void gz_compress(FILE *in, gzFile out) { */ if (gz_compress_mmap(in, out) == Z_OK) return; #endif - buf = (char *)calloc(BUFLEN, 1); - if (buf == NULL) { - perror("out of memory"); - exit(1); - } - + /* Clear out the contents of buf before reading from the file to avoid + MemorySanitizer: use-of-uninitialized-value warnings. */ + memset(buf, 0, sizeof(buf)); for (;;) { - len = (int)fread(buf, 1, BUFLEN, in); + len = (int)fread(buf, 1, sizeof(buf), in); if (ferror(in)) { - free(buf); perror("fread"); exit(1); } @@ -117,7 +119,6 @@ void gz_compress(FILE *in, gzFile out) { if (PREFIX(gzwrite)(out, buf, (unsigned)len) != len) error(PREFIX(gzerror)(out, &err)); } - free(buf); fclose(in); if (PREFIX(gzclose)(out) != Z_OK) error("failed gzclose"); } @@ -127,11 +128,12 @@ void gz_compress(FILE *in, gzFile out) { /* Try compressing the input file at once using mmap. Return Z_OK if * if success, Z_ERRNO otherwise. */ -int gz_compress_mmap(FILE *in, gzFile out) { +int gz_compress_mmap(FILE *in, gzFile out) +{ int len; int err; int ifd = fileno(in); - char *buf; /* mmap'ed buffer for the entire input file */ + caddr_t buf; /* mmap'ed buffer for the entire input file */ off_t buf_len; /* length of the input file */ struct stat sb; @@ -141,11 +143,11 @@ int gz_compress_mmap(FILE *in, gzFile out) { if (buf_len <= 0) return Z_ERRNO; /* Now do the actual mmap: */ - buf = mmap((void *)0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); - if (buf == (char *)(-1)) return Z_ERRNO; + buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); + if (buf == (caddr_t)(-1)) return Z_ERRNO; /* Compress the whole file at once: */ - len = PREFIX(gzwrite)(out, buf, (unsigned)buf_len); + len = PREFIX(gzwrite)(out, (char *)buf, (unsigned)buf_len); if (len != (int)buf_len) error(PREFIX(gzerror)(out, &err)); @@ -159,27 +161,21 @@ int gz_compress_mmap(FILE *in, gzFile out) { /* =========================================================================== * Uncompress input to output then close both files. */ -void gz_uncompress(gzFile in, FILE *out) { - char *buf = (char *)malloc(BUFLENW); +void gz_uncompress(gzFile in, FILE *out) +{ + char buf[BUFLENW]; int len; int err; - if (buf == NULL) error("out of memory"); - for (;;) { - len = PREFIX(gzread)(in, buf, BUFLENW); - if (len < 0) { - free(buf); - error(PREFIX(gzerror)(in, &err)); - } + len = PREFIX(gzread)(in, buf, sizeof(buf)); + if (len < 0) error (PREFIX(gzerror)(in, &err)); if (len == 0) break; if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { - free(buf); error("failed fwrite"); } } - free(buf); if (fclose(out)) error("failed fclose"); if (PREFIX(gzclose)(in) != Z_OK) error("failed gzclose"); @@ -190,9 +186,10 @@ void gz_uncompress(gzFile in, FILE *out) { * Compress the given file: create a corresponding .gz file and remove the * original. */ -void file_compress(char *file, char *mode, int keep) { +void file_compress(char *file, char *mode) +{ char outfile[MAX_NAME_LEN]; - FILE *in; + FILE *in; gzFile out; if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { @@ -214,18 +211,18 @@ void file_compress(char *file, char *mode, int keep) { } gz_compress(in, out); - if (!keep) - unlink(file); + unlink(file); } /* =========================================================================== * Uncompress the given file and remove the original. */ -void file_uncompress(char *file, int keep) { +void file_uncompress(char *file) +{ char buf[MAX_NAME_LEN]; char *infile, *outfile; - FILE *out; + FILE *out; gzFile in; size_t len = strlen(file); @@ -258,75 +255,63 @@ void file_uncompress(char *file, int keep) { gz_uncompress(in, out); - if (!keep) - unlink(infile); + unlink(infile); } -void show_help(void) { - printf("Usage: minigzip [-c] [-d] [-k] [-f|-h|-R|-F|-T] [-A] [-0 to -9] [files...]\n\n" \ - " -c : write to standard output\n" \ - " -d : decompress\n" \ - " -k : keep input files\n" \ - " -f : compress with Z_FILTERED\n" \ - " -h : compress with Z_HUFFMAN_ONLY\n" \ - " -R : compress with Z_RLE\n" \ - " -F : compress with Z_FIXED\n" \ - " -T : stored raw\n" \ - " -A : auto detect type\n" \ - " -0 to -9 : compression level\n\n"); -} -int main(int argc, char *argv[]) { +/* =========================================================================== + * Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...] + * -c : write to standard output + * -d : decompress + * -f : compress with Z_FILTERED + * -h : compress with Z_HUFFMAN_ONLY + * -r : compress with Z_RLE + * -0 to -9 : compression level + */ + +int main(int argc, char *argv[]) +{ int copyout = 0; int uncompr = 0; - int keep = 0; - int i = 0; gzFile file; char *bname, outmode[20]; - char *strategy = ""; - char *level = "6"; - char *type = "b"; - prog = argv[i]; - bname = strrchr(argv[i], '/'); + snprintf(outmode, sizeof(outmode), "%s", "wb6 "); + + prog = argv[0]; + bname = strrchr(argv[0], '/'); if (bname) - bname++; + bname++; else - bname = argv[i]; + bname = argv[0]; + argc--, argv++; if (!strcmp(bname, "gunzip")) - uncompr = 1; + uncompr = 1; else if (!strcmp(bname, "zcat")) - copyout = uncompr = 1; + copyout = uncompr = 1; - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-c") == 0) - copyout = 1; - else if (strcmp(argv[i], "-d") == 0) - uncompr = 1; - else if (strcmp(argv[i], "-k") == 0) - keep = 1; - else if (strcmp(argv[i], "-A") == 0) - type = ""; - else if (argv[i][0] == '-' && (argv[i][1] == 'f' || argv[i][1] == 'h' || - argv[i][1] == 'R' || argv[i][1] == 'F' || argv[i][1] == 'T') && argv[i][2] == 0) - strategy = argv[i] + 1; - else if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9' && argv[i][2] == 0) - level = argv[i] + 1; - else if (strcmp(argv[i], "--help") == 0) { - show_help(); - return 0; - } else if (argv[i][0] == '-') { - show_help(); - return 64; /* EX_USAGE */ - } else { - break; - } + while (argc > 0) { + if (strcmp(*argv, "-c") == 0) + copyout = 1; + else if (strcmp(*argv, "-d") == 0) + uncompr = 1; + else if (strcmp(*argv, "-f") == 0) + outmode[3] = 'f'; + else if (strcmp(*argv, "-h") == 0) + outmode[3] = 'h'; + else if (strcmp(*argv, "-r") == 0) + outmode[3] = 'R'; + else if ((*argv)[0] == '-' && (*argv)[1] >= '0' && (*argv)[1] <= '9' && + (*argv)[2] == 0) + outmode[2] = (*argv)[1]; + else + break; + argc--, argv++; } - - snprintf(outmode, sizeof(outmode), "w%s%s%s", type, strategy, level); - - if (i == argc) { + if (outmode[3] == ' ') + outmode[3] = 0; + if (argc == 0) { SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); if (uncompr) { @@ -345,20 +330,20 @@ int main(int argc, char *argv[]) { do { if (uncompr) { if (copyout) { - file = PREFIX(gzopen)(argv[i], "rb"); + file = PREFIX(gzopen)(*argv, "rb"); if (file == NULL) - fprintf(stderr, "%s: can't gzopen %s\n", prog, argv[i]); + fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); else gz_uncompress(file, stdout); } else { - file_uncompress(argv[i], keep); + file_uncompress(*argv); } } else { if (copyout) { - FILE * in = fopen(argv[i], "rb"); + FILE * in = fopen(*argv, "rb"); if (in == NULL) { - perror(argv[i]); + perror(*argv); } else { file = PREFIX(gzdopen)(fileno(stdout), outmode); if (file == NULL) error("can't gzdopen stdout"); @@ -367,10 +352,10 @@ int main(int argc, char *argv[]) { } } else { - file_compress(argv[i], outmode, keep); + file_compress(*argv, outmode); } } - } while (++i < argc); + } while (argv++, --argc); } return 0; } diff --git a/libs/zlibng/test/pkgcheck.sh b/libs/zlibng/test/pkgcheck.sh deleted file mode 100644 index 4c757dff1..000000000 --- a/libs/zlibng/test/pkgcheck.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/sh - -usage() { - cat <<"_EOF_" -Usage: sh test/pkgcheck.sh [--zlib-compat] - -Verifies that the various build systems produce identical results on a Unixlike system. -If --zlib-compat, tests with zlib compatible builds. - -To build the 32 bit version for the current 64 bit arch: - -$ sudo apt install ninja-build diffoscope gcc-multilib -$ export CMAKE_ARGS="-DCMAKE_C_FLAGS=-m32" CFLAGS=-m32 LDFLAGS=-m32 -$ sh test/pkgcheck.sh - -To cross-build, install the appropriate qemu and gcc packages, -and set the environment variables used by configure or cmake. -On Ubuntu, for example (values taken from .github/workflows/pkgconf.yml): - -arm HF: -$ sudo apt install ninja-build diffoscope qemu gcc-arm-linux-gnueabihf libc6-dev-armhf-cross -$ export CHOST=arm-linux-gnueabihf -$ export CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=${CHOST}" - -aarch64: -$ sudo apt install ninja-build diffoscope qemu gcc-aarch64-linux-gnu libc6-dev-arm64-cross -$ export CHOST=aarch64-linux-gnu -$ export CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DCMAKE_C_COMPILER_TARGET=${CHOST}" - -ppc (32 bit big endian): -$ sudo apt install ninja-build diffoscope qemu gcc-powerpc-linux-gnu libc6-dev-powerpc-cross -$ export CHOST=powerpc-linux-gnu -$ export CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake" - -ppc64le: -$ sudo apt install ninja-build diffoscope qemu gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross -$ export CHOST=powerpc64le-linux-gnu -$ export CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake" - -then: -$ export CC=${CHOST}-gcc -$ sh test/pkgcheck.sh [--zlib-compat] - -Note: on Mac, you may also need to do 'sudo xcode-select -r' to get cmake to match configure/make's behavior (i.e. omit -isysroot). -_EOF_ -} - -set -ex - -# Caller can also set CMAKE_ARGS or CONFIGURE_ARGS if desired -CMAKE_ARGS=${CMAKE_ARGS} -CONFIGURE_ARGS=${CONFIGURE_ARGS} - -case "$1" in ---zlib-compat) - suffix="" - CMAKE_ARGS="$CMAKE_ARGS -DZLIB_COMPAT=ON" - CONFIGURE_ARGS="$CONFIGURE_ARGS --zlib-compat" - ;; -"") - suffix="-ng" - ;; -*) - echo "Unknown arg '$1'" - usage - exit 1 - ;; -esac - -if ! test -f "configure" -then - echo "Please run from top of source tree" - exit 1 -fi - -# Tell GNU's ld etc. to use Jan 1 1970 when embedding timestamps -# Probably only needed on older systems (ubuntu 14.04, BSD?) -export SOURCE_DATE_EPOCH=0 -case $(uname) in -Darwin) - # Tell Apple's ar etc. to use zero timestamps - export ZERO_AR_DATE=1 - # What CPU are we running on, exactly? - sysctl -n machdep.cpu.brand_string - sysctl -n machdep.cpu.features - sysctl -n machdep.cpu.leaf7_features - sysctl -n machdep.cpu.extfeatures - ;; -esac - -# Use same compiler for make and cmake builds -if test "$CC"x = ""x -then - if clang --version - then - export CC=clang - elif gcc --version - then - export CC=gcc - fi -fi - -# New build system -# Happens to delete top-level zconf.h -# (which itself is a bug, https://github.com/madler/zlib/issues/162 ) -# which triggers another bug later in configure, -# https://github.com/madler/zlib/issues/499 -rm -rf btmp2 pkgtmp2 -mkdir btmp2 pkgtmp2 -export DESTDIR=$(pwd)/pkgtmp2 -cd btmp2 - cmake -G Ninja ${CMAKE_ARGS} .. - ninja -v - ninja install -cd .. - -# Original build system -rm -rf btmp1 pkgtmp1 -mkdir btmp1 pkgtmp1 -export DESTDIR=$(pwd)/pkgtmp1 -cd btmp1 - case $(uname) in - Darwin) - export LDFLAGS="-Wl,-headerpad_max_install_names" - ;; - esac - ../configure $CONFIGURE_ARGS - make - make install -cd .. - -repack_ar() { - if ! cmp --silent pkgtmp1/usr/local/lib/libz$suffix.a pkgtmp2/usr/local/lib/libz$suffix.a - then - echo "libz$suffix.a does not match. Probably filenames differ (.o vs .c.o). Unpacking and renaming..." - # Note: %% is posix shell syntax meaning "Remove Largest Suffix Pattern", see - # https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02 - cd pkgtmp1; ar x usr/local/lib/libz$suffix.a; rm usr/local/lib/libz$suffix.a; cd .. - cd pkgtmp2; ar x usr/local/lib/libz$suffix.a; rm usr/local/lib/libz$suffix.a; for a in *.c.o; do mv $a ${a%%.c.o}.o; done; cd .. - # Also, remove __.SYMDEF SORTED if present, as it has those funky .c.o names embedded in it. - rm -f pkgtmp[12]/__.SYMDEF\ SORTED - fi -} - -case $(uname) in -Darwin) - # Remove the build uuid. - dylib1=$(find pkgtmp1 -type f -name '*.dylib*') - dylib2=$(find pkgtmp2 -type f -name '*.dylib*') - strip -x -no_uuid "$dylib1" - strip -x -no_uuid "$dylib2" - ;; -esac - -# The ar on newer systems defaults to -D (i.e. deterministic), -# but FreeBSD 12.1, Debian 8, and Ubuntu 14.04 seem to not do that. -# I had trouble passing -D safely to the ar inside CMakeLists.txt, -# so punt and unpack the archive if needed before comparing. -# Also, cmake uses different .o suffix anyway... -repack_ar - -if diff -Nur pkgtmp1 pkgtmp2 -then - echo pkgcheck-cmake-bits-identical PASS -else - echo pkgcheck-cmake-bits-identical FAIL - dylib1=$(find pkgtmp1 -type f -name '*.dylib*' -print -o -type f -name '*.so.*' -print) - dylib2=$(find pkgtmp2 -type f -name '*.dylib*' -print -o -type f -name '*.so.*' -print) - diffoscope $dylib1 $dylib2 | cat - exit 1 -fi - -rm -rf btmp1 btmp2 pkgtmp1 pkgtmp2 - -# any failure would have caused an early exit already -echo "pkgcheck: PASS" diff --git a/libs/zlibng/test/switchlevels.c b/libs/zlibng/test/switchlevels.c deleted file mode 100644 index 0f850113e..000000000 --- a/libs/zlibng/test/switchlevels.c +++ /dev/null @@ -1,169 +0,0 @@ -/* Compresses a user-specified number of chunks from stdin into stdout as a single gzip stream. - * Each chunk is compressed with a user-specified level. - */ - -#include "zbuild.h" -#ifdef ZLIB_COMPAT -# include "zlib.h" -#else -# include "zlib-ng.h" -#endif - -#include -#include -#include - -#if defined(_WIN32) || defined(__CYGWIN__) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -static int read_all(unsigned char *buf, size_t size) { - size_t total_read = 0; - while (total_read < size) { - size_t n_read = fread(buf + total_read, 1, size - total_read, stdin); - if (ferror(stdin)) { - perror("fread\n"); - return 1; - } - if (n_read == 0) { - fprintf(stderr, "Premature EOF\n"); - return 1; - } - total_read += n_read; - } - return 0; -} - -static int write_all(unsigned char *buf, size_t size) { - size_t total_written = 0; - while (total_written < size) { - size_t n_written = fwrite(buf + total_written, 1, size - total_written, stdout); - if (ferror(stdout)) { - perror("fwrite\n"); - return 1; - } - total_written += n_written; - } - return 0; -} - -static int compress_chunk(PREFIX3(stream) *strm, int level, int size, int last) { - int ret = 1; - int err = 0; - unsigned long compsize; - unsigned char *buf; - - if (size <= 0) { - fprintf(stderr, "compress_chunk() invalid size %d\n", size); - goto done; - } - if (level < 0 || level > 9) { - fprintf(stderr, "compress_chunk() invalid level %d\n", level); - goto done; - } - - compsize = 100 + 2 * PREFIX(deflateBound)(strm, size); - buf = malloc(size + compsize); - if (buf == NULL) { - fprintf(stderr, "Out of memory\n"); - goto done; - } - if (read_all(buf, size) != 0) { - goto free_buf; - } - - /* Provide only output buffer to deflateParams(). It might need some space to flush the leftovers from the last - * deflate(), but we don't want it to compress anything new. */ - strm->next_in = NULL; - strm->avail_in = 0; - strm->next_out = buf + size; - strm->avail_out = compsize; - err = PREFIX(deflateParams)(strm, level, Z_DEFAULT_STRATEGY); - if (err != Z_OK) { - fprintf(stderr, "deflateParams() failed with code %d\n", err); - goto free_buf; - } - - /* Provide input buffer to deflate(). */ - strm->next_in = buf; - strm->avail_in = size; - err = PREFIX(deflate)(strm, last ? Z_FINISH : Z_SYNC_FLUSH); - if ((!last && err != Z_OK) || (last && err != Z_STREAM_END)) { - fprintf(stderr, "deflate() failed with code %d\n", err); - goto free_buf; - } - if (strm->avail_in != 0) { - fprintf(stderr, "deflate() did not consume %d bytes of input\n", strm->avail_in); - goto free_buf; - } - if (write_all(buf + size, compsize - strm->avail_out) != 0) { - goto free_buf; - } - ret = 0; - -free_buf: - free(buf); -done: - return ret; -} - -void show_help(void) -{ - printf("Usage: switchlevels [-w bits] level1 size1 [level2 size2 ...]\n\n" \ - " -w : window bits (8 to 15 for gzip, -8 to -15 for zlib)\n\n"); -} - -int main(int argc, char **argv) { - int ret = EXIT_FAILURE; - int err = 0; - int size = 0; - int level = Z_DEFAULT_COMPRESSION; - int level_arg = 1; - int window_bits = MAX_WBITS + 16; - PREFIX3(stream) strm; - - - if ((argc == 1) || (argc == 2 && strcmp(argv[1], "--help") == 0)) { - show_help(); - return 0; - } - - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - - memset(&strm, 0, sizeof(strm)); - - for (int i = 1; i < argc - 1; i++) { - if (strcmp(argv[i], "-w") == 0 && i+1 < argc) { - window_bits = atoi(argv[++i]); - } else { - level_arg = i; - level = atoi(argv[i]); - break; - } - } - - err = PREFIX(deflateInit2)(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY); - if (err != Z_OK) { - fprintf(stderr, "deflateInit() failed with code %d\n", err); - goto done; - } - - for (int i = level_arg; i < argc - 1; i += 2) { - level = atoi(argv[i]); - size = atoi(argv[i + 1]); - if (compress_chunk(&strm, level, size, i + 2 >= argc - 1) != 0) { - goto deflate_end; - } - } - ret = EXIT_SUCCESS; - -deflate_end: - PREFIX(deflateEnd)(&strm); -done: - return ret; -} diff --git a/libs/zlibng/test/testCVEinputs.sh b/libs/zlibng/test/testCVEinputs.sh index 84f6b31c5..8f23438d7 100644 --- a/libs/zlibng/test/testCVEinputs.sh +++ b/libs/zlibng/test/testCVEinputs.sh @@ -15,16 +15,17 @@ CVEs="CVE-2002-0059 CVE-2004-0797 CVE-2005-1849 CVE-2005-2096" for CVE in $CVEs; do fail=0 for testcase in ${TESTDIR}/${CVE}/*.gz; do - ${QEMU_RUN} ../minigzip${EXE} -d < "$testcase" - # we expect that a 1 error code is OK - # for a vulnerable failure we'd expect 134 or similar - if [ $? -ne 1 ] && [ $? -ne 0 ]; then - fail=1 - fi + ${QEMU_RUN} ../minigzip${EXE} -d < "$testcase" + # we expect that a 1 error code is OK + # for a vulnerable failure we'd expect 134 or similar + if [ $? -ne 1 ] && [ $? -ne 0 ]; then + fail=1 + fi done if [ $fail -eq 0 ]; then - echo " --- zlib not vulnerable to $CVE ---"; + echo " --- zlib not vulnerable to $CVE ---"; else - echo " --- zlib VULNERABLE to $CVE ---"; exit 1; + echo " --- zlib VULNERABLE to $CVE ---"; exit 1; fi done + diff --git a/libs/zlibng/tools/codecov-upload.sh b/libs/zlibng/tools/codecov-upload.sh deleted file mode 100644 index e3a48aab7..000000000 --- a/libs/zlibng/tools/codecov-upload.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -ux -cd "$CODECOV_DIR" -python -m codecov --required --flags "$CODECOV_FLAGS" --name "$CODECOV_NAME" --gcov-exec="$CODECOV_EXEC" -if [ $? -ne 0 ]; then - sleep 30 - python -m codecov --required --flags "$CODECOV_FLAGS" --name "$CODECOV_NAME" --gcov-exec="$CODECOV_EXEC" --tries=25 -fi -exit $? diff --git a/libs/zlibng/tools/config.sub b/libs/zlibng/tools/config.sub deleted file mode 100644 index dba175ae3..000000000 --- a/libs/zlibng/tools/config.sub +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# Canonicalize CHOST. -# In particular, converts Debian multiarch tuples into GNU triplets. -# See also -# https://wiki.debian.org/Multiarch/Tuples -# https://wiki.gentoo.org/wiki/CHOST -# If you need an architecture not listed here, file a bug at github.com/zlib-ng/zlib-ng -# and work around the problem by dropping libtool's much more comprehensive config.sub -# on top of this file, see -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub - -case "$1" in -*-*-linux-gnu*) echo $1;; -i686-linux-gnu*|x86_64-linux-gnu*) echo $1 | sed 's/-linux-gnu/-pc-linux-gnu/';; -*-linux-gnu*) echo $1 | sed 's/-linux-gnu/-unknown-linux-gnu/';; -*) echo $1;; -esac diff --git a/libs/zlibng/tools/makecrct.c b/libs/zlibng/tools/makecrct.c deleted file mode 100644 index 323d0c03d..000000000 --- a/libs/zlibng/tools/makecrct.c +++ /dev/null @@ -1,177 +0,0 @@ -/* crc32.c -- output crc32 tables - * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016, 2018 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h -*/ - -#include -#include -#include "zbuild.h" -#include "deflate.h" -#include "crc32_p.h" - -static uint32_t crc_table[8][256]; -static uint32_t crc_comb[GF2_DIM][GF2_DIM]; - -static void gf2_matrix_square(uint32_t *square, const uint32_t *mat); -static void make_crc_table(void); -static void make_crc_combine_table(void); -static void print_crc_table(void); -static void print_crc_combine_table(void); -static void write_table(const uint32_t *, int); - - -/* ========================================================================= */ -static void gf2_matrix_square(uint32_t *square, const uint32_t *mat) { - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -static void make_crc_table(void) { - int n, k; - uint32_t c; - uint32_t poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static const unsigned char p[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26}; - - /* make exclusive-or pattern from polynomial (0xedb88320) */ - poly = 0; - for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) - poly |= (uint32_t)1 << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (uint32_t)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = ZSWAP32(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = ZSWAP32(c); - } - } -} - -static void make_crc_combine_table(void) { - int n, k; - /* generate zero operators table for crc32_combine() */ - - /* generate the operator to apply a single zero bit to a CRC -- the - first row adds the polynomial if the low bit is a 1, and the - remaining rows shift the CRC right one bit */ - k = GF2_DIM - 3; - crc_comb[k][0] = 0xedb88320UL; /* CRC-32 polynomial */ - uint32_t row = 1; - for (n = 1; n < GF2_DIM; n++) { - crc_comb[k][n] = row; - row <<= 1; - } - /* generate operators that apply 2, 4, and 8 zeros to a CRC, putting - the last one, the operator for one zero byte, at the 0 position */ - gf2_matrix_square(crc_comb[k + 1], crc_comb[k]); - gf2_matrix_square(crc_comb[k + 2], crc_comb[k + 1]); - gf2_matrix_square(crc_comb[0], crc_comb[k + 2]); - - /* generate operators for applying 2^n zero bytes to a CRC, filling out - the remainder of the table -- the operators repeat after GF2_DIM - values of n, so the table only needs GF2_DIM entries, regardless of - the size of the length being processed */ - for (n = 1; n < k; n++) - gf2_matrix_square(crc_comb[n], crc_comb[n - 1]); -} - -static void write_table(const uint32_t *table, int k) { - int n; - - for (n = 0; n < k; n++) - printf("%s0x%08" PRIx32 "%s", n % 5 ? "" : " ", - (uint32_t)(table[n]), - n == k - 1 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} - -static void print_crc_table(void) { - int k; - printf("#ifndef CRC32_TBL_H_\n"); - printf("#define CRC32_TBL_H_\n\n"); - printf("/* crc32_tbl.h -- tables for rapid CRC calculation\n"); - printf(" * Generated automatically by makecrct.c\n */\n\n"); - - /* print CRC table */ - printf("static const uint32_t "); - printf("crc_table[8][256] =\n{\n {\n"); - write_table(crc_table[0], 256); - for (k = 1; k < 8; k++) { - printf(" },\n {\n"); - write_table(crc_table[k], 256); - } - printf(" }\n};\n\n"); - - printf("#endif /* CRC32_TBL_H_ */\n"); -} - -static void print_crc_combine_table(void) { - int k; - printf("#ifndef CRC32_COMB_TBL_H_\n"); - printf("#define CRC32_COMB_TBL_H_\n\n"); - printf("/* crc32_comb_tbl.h -- zero operators table for CRC combine\n"); - printf(" * Generated automatically by makecrct.c\n */\n\n"); - - /* print zero operator table */ - printf("static const uint32_t "); - printf("crc_comb[%d][%d] =\n{\n {\n", GF2_DIM, GF2_DIM); - write_table(crc_comb[0], GF2_DIM); - for (k = 1; k < GF2_DIM; k++) { - printf(" },\n {\n"); - write_table(crc_comb[k], GF2_DIM); - } - printf(" }\n};\n\n"); - - printf("#endif /* CRC32_COMB_TBL_H_ */\n"); -} - -// The output of this application can be piped out to recreate crc32.h -int main(int argc, char *argv[]) { - if (argc > 1 && strcmp(argv[1], "-c") == 0) { - make_crc_combine_table(); - print_crc_combine_table(); - } else { - make_crc_table(); - print_crc_table(); - } - return 0; -} diff --git a/libs/zlibng/tools/makefixed.c b/libs/zlibng/tools/makefixed.c deleted file mode 100644 index 7fe71e75e..000000000 --- a/libs/zlibng/tools/makefixed.c +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include "zbuild.h" -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" - -// Build and return state with length and distance decoding tables and index sizes set to fixed code decoding. -void Z_INTERNAL buildfixedtables(struct inflate_state *state) { - static code *lenfix, *distfix; - static code fixed[544]; - - // build fixed huffman tables - unsigned sym, bits; - static code *next; - - // literal/length table - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - zng_inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - // distance table - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - zng_inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - - -// Create fixed tables on the fly and write out a inffixed_tbl.h file that is #include'd above. -// makefixed() writes those tables to stdout, which would be piped to inffixed_tbl.h. -void makefixed(void) { - unsigned low, size; - struct inflate_state state; - - memset(&state, 0, sizeof(state)); - buildfixedtables(&state); - puts("/* inffixed_tbl.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts("/* WARNING: this file should *not* be used by applications."); - puts(" * It is part of the implementation of this library and is"); - puts(" * subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf("static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) - printf("\n "); - printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, - state.lencode[low].bits, state.lencode[low].val); - if (++low == size) - break; - putchar(','); - } - puts("\n};"); - size = 1U << 5; - printf("\nstatic const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) - printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); - if (++low == size) - break; - putchar(','); - } - puts("\n};"); -} - -// The output of this application can be piped out to recreate inffixed_tbl.h -int main(void) { - makefixed(); - return 0; -} diff --git a/libs/zlibng/tools/maketrees.c b/libs/zlibng/tools/maketrees.c deleted file mode 100644 index 337f2fc07..000000000 --- a/libs/zlibng/tools/maketrees.c +++ /dev/null @@ -1,147 +0,0 @@ -/* maketrees.c -- output static huffman trees - * Copyright (C) 1995-2017 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "zbuild.h" -#include "deflate.h" -#include "trees.h" - -static ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see zng_tr_init). - */ - -static ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use 5 bits.) - */ - -static unsigned char dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances 3 .. 258, - * the last 256 values correspond to the top 8 bits of the 15 bit distances. - */ - -static unsigned char length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -static int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -static int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - - -static void tr_static_init(void) { - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - uint16_t bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1 << extra_lbits[code]); n++) { - length_code[length++] = (unsigned char)code; - } - } - Assert(length == 256, "tr_static_init: length != 256"); - /* Note that the length 255 (match length 258) can be represented in two different - * ways: code 284 + 5 bits or code 285, so we overwrite length_code[255] to use the best encoding: - */ - length_code[length-1] = (unsigned char)code; - - /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ - dist = 0; - for (code = 0; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1 << extra_dbits[code]); n++) { - dist_code[dist++] = (unsigned char)code; - } - } - Assert(dist == 256, "tr_static_init: dist != 256"); - dist >>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1 << (extra_dbits[code]-7)); n++) { - dist_code[256 + dist++] = (unsigned char)code; - } - } - Assert(dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) - bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the tree construction - * to get a canonical Huffman tree (longest code all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = (uint16_t)bi_reverse((unsigned)n, 5); - } -} - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -static void gen_trees_header() { - int i; - - printf("#ifndef TREES_TBL_H_\n"); - printf("#define TREES_TBL_H_\n\n"); - - printf("/* header created automatically with maketrees.c */\n\n"); - - printf("Z_INTERNAL const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - printf("{{%3u},{%u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - printf("Z_INTERNAL const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - printf("{{%2u},{%u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - printf("const unsigned char Z_INTERNAL zng_dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - printf("%2u%s", dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - printf("const unsigned char Z_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1] = {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - printf("%2u%s", length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - printf("Z_INTERNAL const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - printf("%d%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - printf("Z_INTERNAL const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - printf("%5d%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10)); - } - - printf("#endif /* TREES_TBL_H_ */\n"); -} - -// The output of this application can be piped out to recreate trees.h -int main(void) { - tr_static_init(); - gen_trees_header(); - return 0; -} diff --git a/libs/zlibng/treebuild.xml b/libs/zlibng/treebuild.xml new file mode 100644 index 000000000..fd75525f9 --- /dev/null +++ b/libs/zlibng/treebuild.xml @@ -0,0 +1,116 @@ + + + + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/zlibng/trees.c b/libs/zlibng/trees.c index efd4d49fb..53c73bde1 100644 --- a/libs/zlibng/trees.c +++ b/libs/zlibng/trees.c @@ -30,12 +30,44 @@ * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + #include "zbuild.h" #include "deflate.h" -#include "trees.h" -#include "trees_emit.h" -#include "trees_tbl.h" +#ifdef ZLIB_DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +static const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +static const unsigned char bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; /* The lengths of the bit length codes are sent in order of decreasing * probability, to avoid transmitting the lengths for unused bit length codes. */ @@ -44,6 +76,42 @@ * Local data. These are initialized only once. */ +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) +/* non ANSI compilers may not accept trees.h */ + +ZLIB_INTERNAL ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +static ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +unsigned char _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +unsigned char _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +static int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +static int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + struct static_tree_desc_s { const ct_data *static_tree; /* static tree or NULL */ const int *extra_bits; /* extra bits for each code or NULL */ @@ -65,9 +133,11 @@ static const static_tree_desc static_bl_desc = * Local (static) routines in this file. */ +static void tr_static_init (void); static void init_block (deflate_state *s); static void pqdownheap (deflate_state *s, ct_data *tree, int k); static void gen_bitlen (deflate_state *s, tree_desc *desc); +static void gen_codes (ct_data *tree, int max_code, uint16_t *bl_count); static void build_tree (deflate_state *s, tree_desc *desc); static void scan_tree (deflate_state *s, ct_data *tree, int max_code); static void send_tree (deflate_state *s, ct_data *tree, int max_code); @@ -77,10 +147,159 @@ static void compress_block (deflate_state *s, const ct_data *ltree, const ct_d static int detect_data_type (deflate_state *s); static void bi_flush (deflate_state *s); +#ifdef GEN_TREES_H +static void gen_trees_header (void); +#endif + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +static void tr_static_init(void) { +#if defined(GEN_TREES_H) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + uint16_t bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) + return; + + /* For some embedded targets, global variables are not initialized: */ +#ifdef NO_INIT_GLOBAL_POINTERS + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; +#endif + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1 << extra_lbits[code]); n++) { + _length_code[length++] = (unsigned char)code; + } + } + Assert(length == 256, "tr_static_init: length != 256"); + /* Note that the length 255 (match length 258) can be represented + * in two different ways: code 284 + 5 bits or code 285, so we + * overwrite length_code[255] to use the best encoding: + */ + _length_code[length-1] = (unsigned char)code; + + /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1 << extra_dbits[code]); n++) { + _dist_code[dist++] = (unsigned char)code; + } + } + Assert(dist == 256, "tr_static_init: dist != 256"); + dist >>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1 << (extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (unsigned char)code; + } + } + Assert(dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) + bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef ZLIB_DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() { + FILE *header = fopen("trees.h", "w"); + int i; + + Assert(header != NULL, "Can't open trees.h"); + fprintf(header, "#ifndef TREES_H_\n"); + fprintf(header, "#define TREES_H_\n\n"); + + fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "ZLIB_INTERNAL const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "static const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "static const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%d%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "static const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5d%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10)); + } + + fprintf(header, "#endif /* TREES_H_ */\n"); + fclose(header); +} +#endif /* GEN_TREES_H */ + /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void Z_INTERNAL zng_tr_init(deflate_state *s) { +void ZLIB_INTERNAL _tr_init(deflate_state *s) { + tr_static_init(); + s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; @@ -206,13 +425,11 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc) { */ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - for (h = s->heap_max + 1; h < HEAP_SIZE; h++) { + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1u; - if (bits > max_length){ - bits = max_length; - overflow++; - } + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) + bits = max_length, overflow++; tree[n].Len = (uint16_t)bits; /* We overwrite tree[n].Dad which is no longer needed */ @@ -236,11 +453,11 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc) { /* Find the first bit length which could increase: */ do { - bits = max_length - 1; + bits = max_length-1; while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2u; /* move one overflow item as its brother */ + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ s->bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] @@ -278,7 +495,7 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc) { * OUT assertion: the field code is set for all tree elements of non * zero code length. */ -Z_INTERNAL void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) { +static void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) { /* tree: the tree to decorate */ /* max_code: largest code with non zero frequency */ /* bl_count: number of codes at each bit length */ @@ -333,8 +550,7 @@ static void build_tree(deflate_state *s, tree_desc *desc) { * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ - s->heap_len = 0; - s->heap_max = HEAP_SIZE; + s->heap_len = 0, s->heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].Freq != 0) { @@ -416,12 +632,12 @@ static void scan_tree(deflate_state *s, ct_data *tree, int max_code) { int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ - uint16_t count = 0; /* repeat count of the current code */ - uint16_t max_count = 7; /* max repeat count */ - uint16_t min_count = 4; /* min repeat count */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ if (nextlen == 0) - max_count = 138, min_count = 3; + max_count = 138, min_count = 3; tree[max_code+1].Len = (uint16_t)0xffff; /* guard */ @@ -472,10 +688,6 @@ static void send_tree(deflate_state *s, ct_data *tree, int max_code) { if (nextlen == 0) max_count = 138, min_count = 3; - // Temp local variables - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].Len; @@ -483,25 +695,25 @@ static void send_tree(deflate_state *s, ct_data *tree, int max_code) { continue; } else if (count < min_count) { do { - send_code(s, curlen, s->bl_tree, bi_buf, bi_valid); + send_code(s, curlen, s->bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree, bi_buf, bi_valid); + send_code(s, curlen, s->bl_tree); count--; } Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree, bi_buf, bi_valid); - send_bits(s, count-3, 2, bi_buf, bi_valid); + send_code(s, REP_3_6, s->bl_tree); + send_bits(s, count-3, 2); } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree, bi_buf, bi_valid); - send_bits(s, count-3, 3, bi_buf, bi_valid); + send_code(s, REPZ_3_10, s->bl_tree); + send_bits(s, count-3, 3); } else { - send_code(s, REPZ_11_138, s->bl_tree, bi_buf, bi_valid); - send_bits(s, count-11, 7, bi_buf, bi_valid); + send_code(s, REPZ_11_138, s->bl_tree); + send_bits(s, count-11, 7); } count = 0; prevlen = curlen; @@ -513,10 +725,6 @@ static void send_tree(deflate_state *s, ct_data *tree, int max_code) { max_count = 7, min_count = 4; } } - - // Store back temp variables - s->bi_buf = bi_buf; - s->bi_valid = bi_valid; } /* =========================================================================== @@ -561,25 +769,16 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); - - // Temp local variables - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5, bi_buf, bi_valid); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5, bi_buf, bi_valid); - send_bits(s, blcodes-4, 4, bi_buf, bi_valid); /* not -3 as stated in appnote.txt */ + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Tracev((stderr, "\nbl code %2u ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3, bi_buf, bi_valid); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); } Tracev((stderr, "\nbl tree: sent %lu", s->bits_sent)); - // Store back temp variables - s->bi_buf = bi_buf; - s->bi_valid = bi_valid; - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ Tracev((stderr, "\nlit tree: sent %lu", s->bits_sent)); @@ -590,29 +789,29 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes /* =========================================================================== * Send a stored block */ -void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last) { +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last) { /* buf: input block */ /* stored_len: length of input block */ /* last: one if this is the last block for a file */ - zng_tr_emit_tree(s, STORED_BLOCK, last); /* send block type */ - zng_tr_emit_align(s); /* align on byte boundary */ - cmpr_bits_align(s); + send_bits(s, (STORED_BLOCK << 1)+last, 3); /* send block type */ + bi_windup(s); /* align on byte boundary */ put_short(s, (uint16_t)stored_len); put_short(s, (uint16_t)~stored_len); - cmpr_bits_add(s, 32); - sent_bits_add(s, 32); - if (stored_len) { + if (stored_len) memcpy(s->pending_buf + s->pending, (unsigned char *)buf, stored_len); - s->pending += stored_len; - cmpr_bits_add(s, stored_len << 3); - sent_bits_add(s, stored_len << 3); - } + s->pending += stored_len; +#ifdef ZLIB_DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (unsigned long)~7L; + s->compressed_len += (stored_len + 4) << 3; + s->bits_sent += 2*16; + s->bits_sent += stored_len<<3; +#endif } /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) { +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { bi_flush(s); } @@ -620,9 +819,12 @@ void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) { * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. */ -void Z_INTERNAL zng_tr_align(deflate_state *s) { - zng_tr_emit_tree(s, STATIC_TREES, 0); - zng_tr_emit_end_block(s, static_ltree, 0); +void ZLIB_INTERNAL _tr_align(deflate_state *s) { + send_bits(s, STATIC_TREES << 1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef ZLIB_DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif bi_flush(s); } @@ -630,7 +832,7 @@ void Z_INTERNAL zng_tr_align(deflate_state *s) { * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last) { +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last) { /* buf: input block, or NULL if too old */ /* stored_len: length of input block */ /* last: one if this is the last block for a file */ @@ -638,11 +840,7 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ int max_blindex = 0; /* index of last bit length code of non zero freq */ /* Build the Huffman trees unless a stored block is forced */ - if (UNLIKELY(s->sym_next == 0)) { - /* Emit an empty static tree block with no codes */ - opt_lenb = static_lenb = 0; - s->static_len = 7; - } else if (s->level > 0) { + if (s->level > 0) { /* Check if the file is binary or text */ if (s->strm->data_type == Z_UNKNOWN) s->strm->data_type = detect_data_type(s); @@ -666,7 +864,7 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ opt_lenb = (s->opt_len+3+7) >> 3; static_lenb = (s->static_len+3+7) >> 3; - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %u lit %u ", + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, s->sym_next / 3)); @@ -678,25 +876,37 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } +#ifdef FORCE_STORED + if (buf != NULL) { /* force stored block */ +#else if (stored_len+4 <= opt_lenb && buf != NULL) { - /* 4: two words for the lengths - * The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ - zng_tr_stored_block(s, buf, stored_len, last); + _tr_stored_block(s, buf, stored_len, last); +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { - zng_tr_emit_tree(s, STATIC_TREES, last); +#endif + send_bits(s, (STATIC_TREES << 1)+last, 3); compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree); - cmpr_bits_add(s, s->static_len); +#ifdef ZLIB_DEBUG + s->compressed_len += 3 + s->static_len; +#endif } else { - zng_tr_emit_tree(s, DYN_TREES, last); + send_bits(s, (DYN_TREES << 1)+last, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree); - cmpr_bits_add(s, s->opt_len); +#ifdef ZLIB_DEBUG + s->compressed_len += 3 + s->opt_len; +#endif } Assert(s->compressed_len == s->bits_sent, "bad compressed size"); /* The above check is made mod 2^32, for files larger than 512 MB @@ -705,11 +915,41 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ init_block(s); if (last) { - zng_tr_emit_align(s); + bi_windup(s); +#ifdef ZLIB_DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif } Tracev((stderr, "\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*last)); } +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { + /* dist: distance of matched string */ + /* lc: match length-MIN_MATCH or unmatched char (if dist==0) */ + s->sym_buf[s->sym_next++] = dist; + s->sym_buf[s->sym_next++] = dist >> 8; + s->sym_buf[s->sym_next++] = lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((uint16_t)dist < (uint16_t)MAX_DIST(s) && + (uint16_t)lc <= (uint16_t)(MAX_MATCH-MIN_MATCH) && + (uint16_t)d_code(dist) < (uint16_t)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + return (s->sym_next == s->sym_end); +} + /* =========================================================================== * Send the block data compressed using the given Huffman trees */ @@ -719,6 +959,8 @@ static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned sx = 0; /* running index in sym_buf */ + int code; /* the code to send */ + int extra; /* number of extra bits to send */ if (s->sym_next != 0) { do { @@ -726,17 +968,35 @@ static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; lc = s->sym_buf[sx++]; if (dist == 0) { - zng_emit_lit(s, ltree, lc); + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr, " '%c' ", lc)); } else { - zng_emit_dist(s, ltree, dtree, lc, dist); + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert(code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned int)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } } /* literal or match pair ? */ /* Check that the overlay between pending_buf and sym_buf is ok: */ - Assert(s->pending < s->lit_bufsize + sx, "pending_buf overflow"); + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); } while (sx < s->sym_next); } - zng_emit_end_block(s, ltree, 0); + send_code(s, END_BLOCK, ltree); } /* =========================================================================== @@ -778,45 +1038,49 @@ static int detect_data_type(deflate_state *s) { return Z_BINARY; } -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -static void bi_flush(deflate_state *s) { - if (s->bi_valid == 64) { - put_uint64(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else { - if (s->bi_valid >= 32) { - put_uint32(s, (uint32_t)s->bi_buf); - s->bi_buf >>= 32; - s->bi_valid -= 32; - } - if (s->bi_valid >= 16) { - put_short(s, (uint16_t)s->bi_buf); - s->bi_buf >>= 16; - s->bi_valid -= 16; - } - if (s->bi_valid >= 8) { - put_byte(s, s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } - } -} - /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ -Z_INTERNAL unsigned bi_reverse(unsigned code, int len) { +ZLIB_INTERNAL unsigned bi_reverse(unsigned code, int len) { /* code: the value to invert */ /* len: its bit length */ - Z_REGISTER unsigned res = 0; + register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +static void bi_flush(deflate_state *s) { + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (unsigned char)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +ZLIB_INTERNAL void bi_windup(deflate_state *s) { + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (unsigned char)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} diff --git a/libs/zlibng/trees.h b/libs/zlibng/trees.h index e57f92648..6fc1c8485 100644 --- a/libs/zlibng/trees.h +++ b/libs/zlibng/trees.h @@ -1,40 +1,132 @@ #ifndef TREES_H_ #define TREES_H_ -/* Constants */ +/* header created automatically with -DGEN_TREES_H */ -#define DIST_CODE_LEN 512 -/* see definition of array dist_code in trees.c */ +ZLIB_INTERNAL const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ +static const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ +const unsigned char ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ +const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ +static const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; -static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; +static const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; -static const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -static const unsigned char bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; - /* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - - -/* Function definitions */ -void gen_codes (ct_data *tree, int max_code, uint16_t *bl_count); - -#endif +#endif /* TREES_H_ */ diff --git a/libs/zlibng/trees_emit.h b/libs/zlibng/trees_emit.h deleted file mode 100644 index 118dbb2d8..000000000 --- a/libs/zlibng/trees_emit.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef TREES_EMIT_H_ -#define TREES_EMIT_H_ - -#include "zbuild.h" -#include "trees.h" - -#ifdef ZLIB_DEBUG -# include -# include -# include -#endif - - -/* trees.h */ -extern Z_INTERNAL const ct_data static_ltree[L_CODES+2]; -extern Z_INTERNAL const ct_data static_dtree[D_CODES]; - -extern const unsigned char Z_INTERNAL zng_dist_code[DIST_CODE_LEN]; -extern const unsigned char Z_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1]; - -extern Z_INTERNAL const int base_length[LENGTH_CODES]; -extern Z_INTERNAL const int base_dist[D_CODES]; - -/* Bit buffer and deflate code stderr tracing */ -#ifdef ZLIB_DEBUG -# define send_bits_trace(s, value, length) { \ - Tracevv((stderr, " l %2d v %4llx ", (int)(length), (long long)(value))); \ - Assert(length > 0 && length <= BIT_BUF_SIZE, "invalid length"); \ - } -# define send_code_trace(s, c) \ - if (z_verbose > 2) { \ - fprintf(stderr, "\ncd %3d ", (c)); \ - } -#else -# define send_bits_trace(s, value, length) -# define send_code_trace(s, c) -#endif - -/* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (64 - bi_valid) bits from value, leaving (width - (64-bi_valid)) - * unused bits in value. - */ -#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\ - uint64_t val = (uint64_t)t_val;\ - uint32_t len = (uint32_t)t_len;\ - uint32_t total_bits = bi_valid + len;\ - send_bits_trace(s, val, len);\ - sent_bits_add(s, len);\ - if (total_bits < BIT_BUF_SIZE) {\ - bi_buf |= val << bi_valid;\ - bi_valid = total_bits;\ - } else if (bi_valid == BIT_BUF_SIZE) {\ - put_uint64(s, bi_buf);\ - bi_buf = val;\ - bi_valid = len;\ - } else {\ - bi_buf |= val << bi_valid;\ - put_uint64(s, bi_buf);\ - bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\ - bi_valid = total_bits - BIT_BUF_SIZE;\ - }\ -} - -/* Send a code of the given tree. c and tree must not have side effects */ -#ifdef ZLIB_DEBUG -# define send_code(s, c, tree, bi_buf, bi_valid) { \ - send_code_trace(s, c); \ - send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid); \ -} -#else -# define send_code(s, c, tree, bi_buf, bi_valid) \ - send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid) -#endif - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -static void bi_windup(deflate_state *s) { - if (s->bi_valid > 56) { - put_uint64(s, s->bi_buf); - } else { - if (s->bi_valid > 24) { - put_uint32(s, (uint32_t)s->bi_buf); - s->bi_buf >>= 32; - s->bi_valid -= 32; - } - if (s->bi_valid > 8) { - put_short(s, (uint16_t)s->bi_buf); - s->bi_buf >>= 16; - s->bi_valid -= 16; - } - if (s->bi_valid > 0) { - put_byte(s, s->bi_buf); - } - } - s->bi_buf = 0; - s->bi_valid = 0; -} - -/* =========================================================================== - * Emit literal code - */ -static inline uint32_t zng_emit_lit(deflate_state *s, const ct_data *ltree, unsigned c) { - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - - send_code(s, c, ltree, bi_buf, bi_valid); - - s->bi_valid = bi_valid; - s->bi_buf = bi_buf; - - Tracecv(isgraph(c), (stderr, " '%c' ", c)); - - return ltree[c].Len; -} - -/* =========================================================================== - * Emit match distance/length code - */ -static inline uint32_t zng_emit_dist(deflate_state *s, const ct_data *ltree, const ct_data *dtree, - uint32_t lc, uint32_t dist) { - uint32_t c, extra; - uint8_t code; - uint64_t match_bits; - uint32_t match_bits_len; - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - - /* Send the length code, len is the match length - MIN_MATCH */ - code = zng_length_code[lc]; - c = code+LITERALS+1; - Assert(c < L_CODES, "bad l_code"); - send_code_trace(s, c); - - match_bits = ltree[c].Code; - match_bits_len = ltree[c].Len; - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - match_bits |= ((uint64_t)lc << match_bits_len); - match_bits_len += extra; - } - - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert(code < D_CODES, "bad d_code"); - send_code_trace(s, code); - - /* Send the distance code */ - match_bits |= ((uint64_t)dtree[code].Code << match_bits_len); - match_bits_len += dtree[code].Len; - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - match_bits |= ((uint64_t)dist << match_bits_len); - match_bits_len += extra; - } - - send_bits(s, match_bits, match_bits_len, bi_buf, bi_valid); - - s->bi_valid = bi_valid; - s->bi_buf = bi_buf; - - return match_bits_len; -} - -/* =========================================================================== - * Emit end block - */ -static inline void zng_emit_end_block(deflate_state *s, const ct_data *ltree, const int last) { - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - send_code(s, END_BLOCK, ltree, bi_buf, bi_valid); - s->bi_valid = bi_valid; - s->bi_buf = bi_buf; - Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %" PRIu64 "\n", - last, s->pending, (uint64_t)s->strm->total_out)); - (void)last; -} - -/* =========================================================================== - * Emit literal and count bits - */ -static inline void zng_tr_emit_lit(deflate_state *s, const ct_data *ltree, unsigned c) { - cmpr_bits_add(s, zng_emit_lit(s, ltree, c)); -} - -/* =========================================================================== - * Emit match and count bits - */ -static inline void zng_tr_emit_dist(deflate_state *s, const ct_data *ltree, const ct_data *dtree, - uint32_t lc, uint32_t dist) { - cmpr_bits_add(s, zng_emit_dist(s, ltree, dtree, lc, dist)); -} - -/* =========================================================================== - * Emit start of block - */ -static inline void zng_tr_emit_tree(deflate_state *s, int type, const int last) { - uint32_t bi_valid = s->bi_valid; - uint64_t bi_buf = s->bi_buf; - uint32_t header_bits = (type << 1) + last; - send_bits(s, header_bits, 3, bi_buf, bi_valid); - cmpr_bits_add(s, 3); - s->bi_valid = bi_valid; - s->bi_buf = bi_buf; - Tracev((stderr, "\n--- Emit Tree: Last: %u\n", last)); -} - -/* =========================================================================== - * Align bit buffer on a byte boundary and count bits - */ -static inline void zng_tr_emit_align(deflate_state *s) { - bi_windup(s); /* align on byte boundary */ - sent_bits_align(s); -} - -/* =========================================================================== - * Emit an end block and align bit buffer if last block - */ -static inline void zng_tr_emit_end_block(deflate_state *s, const ct_data *ltree, const int last) { - zng_emit_end_block(s, ltree, last); - cmpr_bits_add(s, 7); - if (last) - zng_tr_emit_align(s); -} - -#endif diff --git a/libs/zlibng/trees_tbl.h b/libs/zlibng/trees_tbl.h deleted file mode 100644 index a4c68a566..000000000 --- a/libs/zlibng/trees_tbl.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef TREES_TBL_H_ -#define TREES_TBL_H_ - -/* header created automatically with maketrees.c */ - -Z_INTERNAL const ct_data static_ltree[L_CODES+2] = { -{{ 12},{8}}, {{140},{8}}, {{ 76},{8}}, {{204},{8}}, {{ 44},{8}}, -{{172},{8}}, {{108},{8}}, {{236},{8}}, {{ 28},{8}}, {{156},{8}}, -{{ 92},{8}}, {{220},{8}}, {{ 60},{8}}, {{188},{8}}, {{124},{8}}, -{{252},{8}}, {{ 2},{8}}, {{130},{8}}, {{ 66},{8}}, {{194},{8}}, -{{ 34},{8}}, {{162},{8}}, {{ 98},{8}}, {{226},{8}}, {{ 18},{8}}, -{{146},{8}}, {{ 82},{8}}, {{210},{8}}, {{ 50},{8}}, {{178},{8}}, -{{114},{8}}, {{242},{8}}, {{ 10},{8}}, {{138},{8}}, {{ 74},{8}}, -{{202},{8}}, {{ 42},{8}}, {{170},{8}}, {{106},{8}}, {{234},{8}}, -{{ 26},{8}}, {{154},{8}}, {{ 90},{8}}, {{218},{8}}, {{ 58},{8}}, -{{186},{8}}, {{122},{8}}, {{250},{8}}, {{ 6},{8}}, {{134},{8}}, -{{ 70},{8}}, {{198},{8}}, {{ 38},{8}}, {{166},{8}}, {{102},{8}}, -{{230},{8}}, {{ 22},{8}}, {{150},{8}}, {{ 86},{8}}, {{214},{8}}, -{{ 54},{8}}, {{182},{8}}, {{118},{8}}, {{246},{8}}, {{ 14},{8}}, -{{142},{8}}, {{ 78},{8}}, {{206},{8}}, {{ 46},{8}}, {{174},{8}}, -{{110},{8}}, {{238},{8}}, {{ 30},{8}}, {{158},{8}}, {{ 94},{8}}, -{{222},{8}}, {{ 62},{8}}, {{190},{8}}, {{126},{8}}, {{254},{8}}, -{{ 1},{8}}, {{129},{8}}, {{ 65},{8}}, {{193},{8}}, {{ 33},{8}}, -{{161},{8}}, {{ 97},{8}}, {{225},{8}}, {{ 17},{8}}, {{145},{8}}, -{{ 81},{8}}, {{209},{8}}, {{ 49},{8}}, {{177},{8}}, {{113},{8}}, -{{241},{8}}, {{ 9},{8}}, {{137},{8}}, {{ 73},{8}}, {{201},{8}}, -{{ 41},{8}}, {{169},{8}}, {{105},{8}}, {{233},{8}}, {{ 25},{8}}, -{{153},{8}}, {{ 89},{8}}, {{217},{8}}, {{ 57},{8}}, {{185},{8}}, -{{121},{8}}, {{249},{8}}, {{ 5},{8}}, {{133},{8}}, {{ 69},{8}}, -{{197},{8}}, {{ 37},{8}}, {{165},{8}}, {{101},{8}}, {{229},{8}}, -{{ 21},{8}}, {{149},{8}}, {{ 85},{8}}, {{213},{8}}, {{ 53},{8}}, -{{181},{8}}, {{117},{8}}, {{245},{8}}, {{ 13},{8}}, {{141},{8}}, -{{ 77},{8}}, {{205},{8}}, {{ 45},{8}}, {{173},{8}}, {{109},{8}}, -{{237},{8}}, {{ 29},{8}}, {{157},{8}}, {{ 93},{8}}, {{221},{8}}, -{{ 61},{8}}, {{189},{8}}, {{125},{8}}, {{253},{8}}, {{ 19},{9}}, -{{275},{9}}, {{147},{9}}, {{403},{9}}, {{ 83},{9}}, {{339},{9}}, -{{211},{9}}, {{467},{9}}, {{ 51},{9}}, {{307},{9}}, {{179},{9}}, -{{435},{9}}, {{115},{9}}, {{371},{9}}, {{243},{9}}, {{499},{9}}, -{{ 11},{9}}, {{267},{9}}, {{139},{9}}, {{395},{9}}, {{ 75},{9}}, -{{331},{9}}, {{203},{9}}, {{459},{9}}, {{ 43},{9}}, {{299},{9}}, -{{171},{9}}, {{427},{9}}, {{107},{9}}, {{363},{9}}, {{235},{9}}, -{{491},{9}}, {{ 27},{9}}, {{283},{9}}, {{155},{9}}, {{411},{9}}, -{{ 91},{9}}, {{347},{9}}, {{219},{9}}, {{475},{9}}, {{ 59},{9}}, -{{315},{9}}, {{187},{9}}, {{443},{9}}, {{123},{9}}, {{379},{9}}, -{{251},{9}}, {{507},{9}}, {{ 7},{9}}, {{263},{9}}, {{135},{9}}, -{{391},{9}}, {{ 71},{9}}, {{327},{9}}, {{199},{9}}, {{455},{9}}, -{{ 39},{9}}, {{295},{9}}, {{167},{9}}, {{423},{9}}, {{103},{9}}, -{{359},{9}}, {{231},{9}}, {{487},{9}}, {{ 23},{9}}, {{279},{9}}, -{{151},{9}}, {{407},{9}}, {{ 87},{9}}, {{343},{9}}, {{215},{9}}, -{{471},{9}}, {{ 55},{9}}, {{311},{9}}, {{183},{9}}, {{439},{9}}, -{{119},{9}}, {{375},{9}}, {{247},{9}}, {{503},{9}}, {{ 15},{9}}, -{{271},{9}}, {{143},{9}}, {{399},{9}}, {{ 79},{9}}, {{335},{9}}, -{{207},{9}}, {{463},{9}}, {{ 47},{9}}, {{303},{9}}, {{175},{9}}, -{{431},{9}}, {{111},{9}}, {{367},{9}}, {{239},{9}}, {{495},{9}}, -{{ 31},{9}}, {{287},{9}}, {{159},{9}}, {{415},{9}}, {{ 95},{9}}, -{{351},{9}}, {{223},{9}}, {{479},{9}}, {{ 63},{9}}, {{319},{9}}, -{{191},{9}}, {{447},{9}}, {{127},{9}}, {{383},{9}}, {{255},{9}}, -{{511},{9}}, {{ 0},{7}}, {{ 64},{7}}, {{ 32},{7}}, {{ 96},{7}}, -{{ 16},{7}}, {{ 80},{7}}, {{ 48},{7}}, {{112},{7}}, {{ 8},{7}}, -{{ 72},{7}}, {{ 40},{7}}, {{104},{7}}, {{ 24},{7}}, {{ 88},{7}}, -{{ 56},{7}}, {{120},{7}}, {{ 4},{7}}, {{ 68},{7}}, {{ 36},{7}}, -{{100},{7}}, {{ 20},{7}}, {{ 84},{7}}, {{ 52},{7}}, {{116},{7}}, -{{ 3},{8}}, {{131},{8}}, {{ 67},{8}}, {{195},{8}}, {{ 35},{8}}, -{{163},{8}}, {{ 99},{8}}, {{227},{8}} -}; - -Z_INTERNAL const ct_data static_dtree[D_CODES] = { -{{ 0},{5}}, {{16},{5}}, {{ 8},{5}}, {{24},{5}}, {{ 4},{5}}, -{{20},{5}}, {{12},{5}}, {{28},{5}}, {{ 2},{5}}, {{18},{5}}, -{{10},{5}}, {{26},{5}}, {{ 6},{5}}, {{22},{5}}, {{14},{5}}, -{{30},{5}}, {{ 1},{5}}, {{17},{5}}, {{ 9},{5}}, {{25},{5}}, -{{ 5},{5}}, {{21},{5}}, {{13},{5}}, {{29},{5}}, {{ 3},{5}}, -{{19},{5}}, {{11},{5}}, {{27},{5}}, {{ 7},{5}}, {{23},{5}} -}; - -const unsigned char Z_INTERNAL zng_dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const unsigned char Z_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -Z_INTERNAL const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -Z_INTERNAL const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - -#endif /* TREES_TBL_H_ */ diff --git a/libs/zlibng/uncompr.c b/libs/zlibng/uncompr.c index 1435fab97..9f0ac2a0c 100644 --- a/libs/zlibng/uncompr.c +++ b/libs/zlibng/uncompr.c @@ -3,12 +3,14 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#define Z_INTERNAL +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL #include "zbuild.h" #ifdef ZLIB_COMPAT -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif /* =========================================================================== @@ -27,7 +29,7 @@ Z_DATA_ERROR if the input data was corrupted, including if the input data is an incomplete zlib stream. */ -int Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t *sourceLen) { +int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t *sourceLen) { PREFIX3(stream) stream; int err; const unsigned int max = (unsigned int)-1; @@ -38,12 +40,13 @@ int Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const u if (*destLen) { left = *destLen; *destLen = 0; - } else { + } + else { left = 1; dest = buf; } - stream.next_in = (z_const unsigned char *)source; + stream.next_in = (const unsigned char *)source; stream.avail_in = 0; stream.zalloc = NULL; stream.zfree = NULL; @@ -80,6 +83,7 @@ int Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const u err; } -int Z_EXPORT PREFIX(uncompress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen) { +int ZEXPORT PREFIX(uncompress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen) +{ return PREFIX(uncompress2)(dest, destLen, source, &sourceLen); } diff --git a/libs/zlibng/win32/DLL_FAQ.txt b/libs/zlibng/win32/DLL_FAQ.txt index c21298596..12c009018 100644 --- a/libs/zlibng/win32/DLL_FAQ.txt +++ b/libs/zlibng/win32/DLL_FAQ.txt @@ -83,7 +83,7 @@ in the zlib distribution, or at the following location: an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? - In principle, you can do it by assigning calling convention - keywords to the macros Z_EXPORT and Z_EXPORTVA. In practice, + keywords to the macros ZEXPORT and ZEXPORTVA. In practice, it depends on what you mean by "an old ZLIB.DLL", because the old DLL exists in several mutually-incompatible versions. You have to find out first what kind of calling convention is diff --git a/libs/zlibng/win32/Makefile.a64 b/libs/zlibng/win32/Makefile.a64 deleted file mode 100644 index a2f2e6a60..000000000 --- a/libs/zlibng/win32/Makefile.a64 +++ /dev/null @@ -1,208 +0,0 @@ -# Makefile for zlib using Microsoft (Visual) C -# zlib is copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler -# -# Usage: -# nmake -f win32/Makefile.a64 (standard build) -# nmake -f win32/Makefile.a64 LOC=-DFOO (nonstandard build) - -# The toplevel directory of the source tree. -# -TOP = . - -# optional build flags -LOC = - -# variables -STATICLIB = zlib.lib -SHAREDLIB = zlib1.dll -IMPLIB = zdll.lib - -CC = cl -LD = link -AR = lib -RC = rc -CP = copy /y -CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) -WFLAGS = \ - -D_CRT_SECURE_NO_DEPRECATE \ - -D_CRT_NONSTDC_NO_DEPRECATE \ - -DUNALIGNED_OK \ - -DUNALIGNED64_OK \ - -D_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 \ - -DARM_FEATURES \ - # -LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest -ARFLAGS = -nologo -RCFLAGS = /dARM64 /r -DEFFILE = zlib.def -RCFILE = zlib1.rc -RESFILE = zlib1.res -WITH_GZFILEOP = yes -ZLIB_COMPAT = -SUFFIX = - -OBJS = \ - adler32.obj \ - armfeature.obj \ - chunkset.obj \ - compare258.obj \ - compress.obj \ - crc32.obj \ - crc32_comb.obj \ - deflate.obj \ - deflate_fast.obj \ - deflate_slow.obj \ - deflate_quick.obj \ - deflate_medium.obj \ - functable.obj \ - infback.obj \ - inflate.obj \ - inftrees.obj \ - inffast.obj \ - insert_string.obj \ - trees.obj \ - uncompr.obj \ - zutil.obj \ - # -!if "$(ZLIB_COMPAT)" != "" -WITH_GZFILEOP = yes -WFLAGS = $(WFLAGS) -DZLIB_COMPAT -DEFFILE = zlibcompat.def -!else -STATICLIB = zlib-ng.lib -SHAREDLIB = zlib-ng1.dll -IMPLIB = zngdll.lib -DEFFILE = zlib-ng.def -RCFILE = zlib-ng1.rc -RESFILE = zlib-ng1.res -SUFFIX = -ng -!endif - -!if "$(WITH_GZFILEOP)" != "" -WFLAGS = $(WFLAGS) -DWITH_GZFILEOP -OBJS = $(OBJS) gzlib.obj gzread.obj gzwrite.obj -!endif - -WFLAGS = $(WFLAGS) \ - -DARM_ACLE_CRC_HASH \ - -D__ARM_NEON__=1 \ - -DARM_NEON_ADLER32 \ - -DARM_NEON_CHUNKSET \ - -DARM_NEON_SLIDEHASH \ - -DARM_NOCHECK_NEON \ - # -OBJS = $(OBJS) crc32_acle.obj insert_string_acle.obj adler32_neon.obj chunkset_neon.obj slide_neon.obj - -# targets -all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ - example.exe minigzip.exe example_d.exe minigzip_d.exe - -zconf: $(TOP)/zconf$(SUFFIX).h.in - $(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h - -$(STATICLIB): zconf $(OBJS) - $(AR) $(ARFLAGS) -out:$@ $(OBJS) - -$(IMPLIB): $(SHAREDLIB) - -$(SHAREDLIB): zconf $(TOP)/win32/$(DEFFILE) $(OBJS) $(RESFILE) - $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \ - -out:$@ -base:0x55A4C0000 $(OBJS) $(RESFILE) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;2 - -example.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -minigzip.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -example_d.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -minigzip_d.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -{$(TOP)}.c.obj: - $(CC) -c $(WFLAGS) $(CFLAGS) $< - -gzlib2.obj: gzlib.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzlib2.obj gzlib.c - -gzread2.obj: gzread.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzread2.obj gzread.c - -gzwrite2.obj: gzwrite.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzwrite2.obj gzwrite.c - -{$(TOP)/arch/arm}.c.obj: - $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< - -{$(TOP)/test}.c.obj: - $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP $< - -$(TOP)/zconf$(SUFFIX).h: zconf - -SRCDIR = $(TOP) -# Keep the dependences in sync with top-level Makefile.in -adler32.obj: $(SRCDIR)/adler32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/functable.h $(SRCDIR)/adler32_p.h -chunkset.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h -functable.obj: $(SRCDIR)/functable.c $(SRCDIR)/zbuild.h $(SRCDIR)/functable.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/zendian.h $(SRCDIR)/arch/x86/x86.h -gzlib.obj: $(SRCDIR)/gzlib.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzread.obj: $(SRCDIR)/gzread.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzwrite.obj: $(SRCDIR)/gzwrite.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -compress.obj: $(SRCDIR)/compress.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h -uncompr.obj: $(SRCDIR)/uncompr.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h -crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32_tbl.h -crc32_comb.obj: $(SRCDIR)/crc32_comb.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/crc32_comb_tbl.h -deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h -deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h -inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h -inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h -inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h -trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h -zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h - -example.obj: $(TOP)/test/example.c $(TOP)/zbuild.h $(TOP)/zlib$(SUFFIX).h - -minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zbuild.h $(TOP)/zlib$(SUFFIX).h - -$(RESFILE): $(TOP)/win32/$(RCFILE) - $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/$(RCFILE) - -# testing -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -testdll: example_d.exe minigzip_d.exe - example_d - echo hello world | minigzip_d | minigzip_d -d - - -# cleanup -clean: - -del $(STATICLIB) - -del $(SHAREDLIB) - -del $(IMPLIB) - -del *.obj - -del *.res - -del *.exp - -del *.exe - -del *.pdb - -del *.manifest - -distclean: clean - -del zconf$(SUFFIX).h diff --git a/libs/zlibng/win32/Makefile.arm b/libs/zlibng/win32/Makefile.arm index 5ed53f5f3..0b3f94064 100644 --- a/libs/zlibng/win32/Makefile.arm +++ b/libs/zlibng/win32/Makefile.arm @@ -23,53 +23,26 @@ AR = lib RC = rc CP = copy /y CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) -WFLAGS = \ - -D_CRT_SECURE_NO_DEPRECATE \ - -D_CRT_NONSTDC_NO_DEPRECATE \ - -DUNALIGNED_OK \ - -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 \ - -DARM_FEATURES \ - # +WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DUNALIGNED_OK -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest ARFLAGS = -nologo RCFLAGS = /dARM /r DEFFILE = zlib.def RCFILE = zlib1.rc RESFILE = zlib1.res -WITH_GZFILEOP = yes -ZLIB_COMPAT = +WITH_GZFILEOP = WITH_ACLE = WITH_NEON = WITH_VFPV3 = NEON_ARCH = /arch:VFPv4 SUFFIX = -OBJS = \ - adler32.obj \ - armfeature.obj \ - chunkset.obj \ - compare258.obj \ - compress.obj \ - crc32.obj \ - crc32_comb.obj \ - deflate.obj \ - deflate_fast.obj \ - deflate_slow.obj \ - deflate_quick.obj \ - deflate_medium.obj \ - functable.obj \ - infback.obj \ - inflate.obj \ - inftrees.obj \ - inffast.obj \ - insert_string.obj \ - trees.obj \ - uncompr.obj \ - zutil.obj \ - # -!if "$(ZLIB_COMPAT)" != "" -WITH_GZFILEOP = yes -WFLAGS = $(WFLAGS) -DZLIB_COMPAT +OBJS = adler32.obj armfeature.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_slow.obj \ + deflate_medium.obj \ + functable.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj fill_window_arm.obj +!if "$(WITH_GZFILEOP)" != "" +WFLAGS = $(WFLAGS) -DWITH_GZFILEOP +OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj DEFFILE = zlibcompat.def !else STATICLIB = zlib-ng.lib @@ -80,12 +53,6 @@ RCFILE = zlib-ng1.rc RESFILE = zlib-ng1.res SUFFIX = -ng !endif - -!if "$(WITH_GZFILEOP)" != "" -WFLAGS = $(WFLAGS) -DWITH_GZFILEOP -OBJS = $(OBJS) gzlib.obj gzread.obj gzwrite.obj -!endif - !if "$(WITH_ACLE)" != "" WFLAGS = $(WFLAGS) -DARM_ACLE_CRC_HASH OBJS = $(OBJS) crc32_acle.obj insert_string_acle.obj @@ -95,14 +62,8 @@ NEON_ARCH = /arch:VFPv3 !endif !if "$(WITH_NEON)" != "" CFLAGS = $(CFLAGS) $(NEON_ARCH) -WFLAGS = $(WFLAGS) \ - -D__ARM_NEON__=1 \ - -DARM_NEON_ADLER32 \ - -DARM_NEON_CHUNKSET \ - -DARM_NEON_SLIDEHASH \ - -DARM_NOCHECK_NEON \ - # -OBJS = $(OBJS) adler32_neon.obj chunkset_neon.obj slide_neon.obj +WFLAGS = $(WFLAGS) -D__ARM_NEON__=1 -DARM_NEON_ADLER32 -DARM_NOCHECK_NEON +OBJS = $(OBJS) adler32_neon.obj !endif # targets @@ -123,69 +84,58 @@ $(SHAREDLIB): zconf $(TOP)/win32/$(DEFFILE) $(OBJS) $(RESFILE) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;2 -example.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) +example.exe: example.obj $(STATICLIB) + $(LD) $(LDFLAGS) example.obj $(STATICLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -minigzip.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) +minigzip.exe: minigzip.obj $(STATICLIB) + $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -example_d.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) +example_d.exe: example.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -minigzip_d.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) +minigzip_d.exe: minigzip.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 {$(TOP)}.c.obj: $(CC) -c $(WFLAGS) $(CFLAGS) $< -gzlib2.obj: gzlib.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzlib2.obj gzlib.c - -gzread2.obj: gzread.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzread2.obj gzread.c - -gzwrite2.obj: gzwrite.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzwrite2.obj gzwrite.c - {$(TOP)/arch/arm}.c.obj: $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< {$(TOP)/test}.c.obj: - $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP $< + $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< $(TOP)/zconf$(SUFFIX).h: zconf SRCDIR = $(TOP) # Keep the dependences in sync with top-level Makefile.in adler32.obj: $(SRCDIR)/adler32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/functable.h $(SRCDIR)/adler32_p.h -functable.obj: $(SRCDIR)/functable.c $(SRCDIR)/zbuild.h $(SRCDIR)/functable.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/zendian.h $(SRCDIR)/arch/x86/x86.h -gzlib.obj: $(SRCDIR)/gzlib.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzread.obj: $(SRCDIR)/gzread.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzwrite.obj: $(SRCDIR)/gzwrite.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h +functable.obj: $(SRCDIR)/functable.c $(SRCDIR)/zbuild.h $(SRCDIR)/functable.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/gzendian.h $(SRCDIR)/arch/x86/x86.h +gzclose.obj: $(SRCDIR)/gzclose.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzlib.obj: $(SRCDIR)/gzlib.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzread.obj: $(SRCDIR)/gzread.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzwrite.obj: $(SRCDIR)/gzwrite.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h compress.obj: $(SRCDIR)/compress.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h uncompr.obj: $(SRCDIR)/uncompr.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h -chunkset.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h -crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32_tbl.h -crc32_comb.obj: $(SRCDIR)/crc32_comb.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/crc32_comb_tbl.h +crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32.h deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h -deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h +deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h +deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h +deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h -inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h -inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h +inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h +inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h $(SRCDIR)/functable.h inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h -trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h -zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h +trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees.h +zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h example.obj: $(TOP)/test/example.c $(TOP)/zbuild.h $(TOP)/zlib$(SUFFIX).h diff --git a/libs/zlibng/win32/Makefile.msc b/libs/zlibng/win32/Makefile.msc index 85d27b9d7..9f4b884c3 100644 --- a/libs/zlibng/win32/Makefile.msc +++ b/libs/zlibng/win32/Makefile.msc @@ -23,61 +23,21 @@ AR = lib RC = rc CP = copy /y CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) -WFLAGS = \ - -D_CRT_SECURE_NO_DEPRECATE \ - -D_CRT_NONSTDC_NO_DEPRECATE \ - -DX86_FEATURES \ - -DX86_PCLMULQDQ_CRC \ - -DX86_SSE2 \ - -DX86_SSE42_CRC_INTRIN \ - -DX86_SSE42_CRC_HASH \ - -DX86_AVX2 \ - -DX86_AVX_CHUNKSET \ - -DX86_SSE2_CHUNKSET \ - -DUNALIGNED_OK \ - -DUNALIGNED64_OK \ - # +WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DX86_PCLMULQDQ_CRC -DX86_SSE2 -DX86_CPUID -DX86_SSE4_2_CRC_HASH -DUNALIGNED_OK -DX86_QUICK_STRATEGY LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest ARFLAGS = -nologo RCFLAGS = /dWIN32 /r DEFFILE = zlib.def RCFILE = zlib1.rc RESFILE = zlib1.res -WITH_GZFILEOP = yes +WITH_GZFILEOP = ZLIB_COMPAT = SUFFIX = -OBJS = \ - adler32.obj \ - chunkset.obj \ - chunkset_avx.obj \ - chunkset_sse.obj \ - compare258.obj \ - compare258_avx.obj \ - compare258_sse.obj \ - compress.obj \ - crc32.obj \ - crc32_comb.obj \ - crc_folding.obj \ - deflate.obj \ - deflate_fast.obj \ - deflate_quick.obj \ - deflate_slow.obj \ - deflate_medium.obj \ - functable.obj \ - infback.obj \ - inflate.obj \ - inftrees.obj \ - inffast.obj \ - insert_string.obj \ - insert_string_sse.obj \ - slide_avx.obj \ - slide_sse.obj \ - trees.obj \ - uncompr.obj \ - zutil.obj \ - x86.obj \ - # +OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_quick.obj deflate_slow.obj \ + deflate_medium.obj \ + functable.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj \ + x86.obj fill_window_sse.obj insert_string_sse.obj crc_folding.obj !if "$(ZLIB_COMPAT)" != "" WITH_GZFILEOP = yes WFLAGS = $(WFLAGS) -DZLIB_COMPAT @@ -94,7 +54,7 @@ SUFFIX = -ng !if "$(WITH_GZFILEOP)" != "" WFLAGS = $(WFLAGS) -DWITH_GZFILEOP -OBJS = $(OBJS) gzlib.obj gzread.obj gzwrite.obj +OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj !endif # targets @@ -115,72 +75,59 @@ $(SHAREDLIB): zconf $(TOP)/win32/$(DEFFILE) $(OBJS) $(RESFILE) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;2 -example.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) +example.exe: example.obj $(STATICLIB) + $(LD) $(LDFLAGS) example.obj $(STATICLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -minigzip.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) - $(LD) $(LDFLAGS) minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(STATICLIB) +minigzip.exe: minigzip.obj $(STATICLIB) + $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -example_d.exe: example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ example.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) +example_d.exe: example.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 -minigzip_d.exe: minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ minigzip.obj gzlib2.obj gzread2.obj gzwrite2.obj $(IMPLIB) +minigzip_d.exe: minigzip.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;1 {$(TOP)}.c.obj: $(CC) -c $(WFLAGS) $(CFLAGS) $< -gzlib2.obj: gzlib.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzlib2.obj gzlib.c - -gzread2.obj: gzread.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzread2.obj gzread.c - -gzwrite2.obj: gzwrite.c - $(CC) -c $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP -Fogzwrite2.obj gzwrite.c - {$(TOP)/arch/x86}.c.obj: $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< {$(TOP)/test}.c.obj: - $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) -DWITH_GZFILEOP $< + $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< $(TOP)/zconf$(SUFFIX).h: zconf SRCDIR = $(TOP) # Keep the dependences in sync with top-level Makefile.in adler32.obj: $(SRCDIR)/adler32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/functable.h $(SRCDIR)/adler32_p.h -functable.obj: $(SRCDIR)/functable.c $(SRCDIR)/zbuild.h $(SRCDIR)/functable.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/zendian.h $(SRCDIR)/arch/x86/x86.h -gzlib.obj: $(SRCDIR)/gzlib.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzread.obj: $(SRCDIR)/gzread.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h -gzwrite.obj: $(SRCDIR)/gzwrite.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h $(SRCDIR)/zutil_p.h +functable.obj: $(SRCDIR)/functable.c $(SRCDIR)/zbuild.h $(SRCDIR)/functable.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/gzendian.h $(SRCDIR)/arch/x86/x86.h +gzclose.obj: $(SRCDIR)/gzclose.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzlib.obj: $(SRCDIR)/gzlib.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzread.obj: $(SRCDIR)/gzread.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h +gzwrite.obj: $(SRCDIR)/gzwrite.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzguts.h compress.obj: $(SRCDIR)/compress.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h uncompr.obj: $(SRCDIR)/uncompr.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h -chunkset.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h -chunkset_avx.obj: $(SRCDIR)/arch/x86/chunkset_avx.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h -chunkset_sse.obj: $(SRCDIR)/arch/x86/chunkset_sse.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h -crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32_tbl.h -crc32_comb.obj: $(SRCDIR)/crc32_comb.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/crc32_comb_tbl.h +crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/gzendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32.h deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h -deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h +deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h +deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h +deflate_quick.obj: $(SRCDIR)/arch/x86/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/memcopy.h +deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/match_p.h $(SRCDIR)/functable.h infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h -inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h -inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h +inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h +inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h $(SRCDIR)/functable.h inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h -slide_sse.obj: $(SRCDIR)/arch/x86/slide_sse.c $(SRCDIR)/deflate.h -trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h -zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h +trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees.h +zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h example.obj: $(TOP)/test/example.c $(TOP)/zbuild.h $(TOP)/zlib$(SUFFIX).h diff --git a/libs/zlibng/win32/VisualC.txt b/libs/zlibng/win32/VisualC.txt new file mode 100644 index 000000000..579a5fc9e --- /dev/null +++ b/libs/zlibng/win32/VisualC.txt @@ -0,0 +1,3 @@ + +To build zlib using the Microsoft Visual C++ environment, +use the appropriate project from the projects/ directory. diff --git a/libs/zlibng/win32/zlib-ng.def b/libs/zlibng/win32/zlib-ng.def index 467d79009..fd1047f44 100644 --- a/libs/zlibng/win32/zlib-ng.def +++ b/libs/zlibng/win32/zlib-ng.def @@ -17,8 +17,6 @@ EXPORTS zng_deflatePending zng_deflatePrime zng_deflateSetHeader - zng_deflateSetParams - zng_deflateGetParams zng_inflateSetDictionary zng_inflateGetDictionary zng_inflateSync @@ -37,6 +35,9 @@ EXPORTS zng_compressBound zng_uncompress zng_uncompress2 +; large file functions + zng_adler32_combine64 + zng_crc32_combine64 ; checksum functions zng_adler32 zng_adler32_z diff --git a/libs/zlibng/zbuild.h b/libs/zlibng/zbuild.h index 3bd4f4898..f375f2e68 100644 --- a/libs/zlibng/zbuild.h +++ b/libs/zlibng/zbuild.h @@ -3,25 +3,21 @@ /* This has to be first include that defines any types */ #if defined(_MSC_VER) -# if defined(_WIN64) - typedef __int64 ssize_t; -# else - typedef long ssize_t; -# endif +# include + typedef SSIZE_T ssize_t; +# define __thread __declspec(thread) #endif #if defined(ZLIB_COMPAT) # define PREFIX(x) x # define PREFIX2(x) ZLIB_ ## x # define PREFIX3(x) z_ ## x -# define PREFIX4(x) x ## 64 # define zVersion zlibVersion # define z_size_t unsigned long #else # define PREFIX(x) zng_ ## x # define PREFIX2(x) ZLIBNG_ ## x # define PREFIX3(x) zng_ ## x -# define PREFIX4(x) zng_ ## x # define zVersion zlibng_version # define z_size_t size_t #endif diff --git a/libs/zlibng/zconf-ng.h.in b/libs/zlibng/zconf-ng.h.in index 7d54668d3..5d0928de5 100644 --- a/libs/zlibng/zconf-ng.h.in +++ b/libs/zlibng/zconf-ng.h.in @@ -3,11 +3,18 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #ifndef ZCONFNG_H #define ZCONFNG_H -#if !defined(_WIN32) && defined(__WIN32__) -# define _WIN32 +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif #endif #ifdef __STDC_VERSION__ @@ -18,16 +25,6 @@ # endif #endif -/* Clang macro for detecting declspec support - * https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute - */ -#ifndef __has_declspec_attribute -# define __has_declspec_attribute(x) 0 -#endif - -/* Always define z_const as const */ -#define z_const const - /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # define MAX_MEM_LEVEL 9 @@ -55,43 +52,43 @@ for small objects. */ -/* Type declarations */ + /* Type declarations */ -#ifdef ZLIB_INTERNAL -# define Z_INTERNAL ZLIB_INTERNAL -#endif -/* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport))) -# ifdef Z_INTERNAL -# define Z_EXTERN extern __declspec(dllexport) -# else -# define Z_EXTERN extern __declspec(dllimport) +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# define ZEXPORTVA WINAPIV # endif #endif -/* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -#if defined(ZLIB_WINAPI) && defined(_WIN32) -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define Z_EXPORT WINAPI -# define Z_EXPORTVA WINAPIV +#ifndef ZEXTERN +# define ZEXTERN extern #endif - -#ifndef Z_EXTERN -# define Z_EXTERN extern +#ifndef ZEXPORT +# define ZEXPORT #endif -#ifndef Z_EXPORT -# define Z_EXPORT -#endif -#ifndef Z_EXPORTVA -# define Z_EXPORTVA +#ifndef ZEXPORTVA +# define ZEXPORTVA #endif /* Fallback for something that includes us. */ @@ -110,11 +107,11 @@ typedef void const *voidpc; typedef void *voidpf; typedef void *voidp; -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif -#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */ +#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by ./configure */ typedef PTRDIFF_TYPE ptrdiff_t; #endif @@ -162,12 +159,12 @@ typedef PTRDIFF_TYPE ptrdiff_t; # define z_off_t long #endif -#if !defined(_WIN32) && defined(Z_LARGE64) +#if !defined(WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else # if defined(__MSYS__) # define z_off64_t _off64_t -# elif defined(_WIN32) && !defined(__GNUC__) +# elif defined(WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/libs/zlibng/zconf.h.in b/libs/zlibng/zconf.h.in index fcbcbb6b1..79e4cc49c 100644 --- a/libs/zlibng/zconf.h.in +++ b/libs/zlibng/zconf.h.in @@ -3,11 +3,18 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #ifndef ZCONF_H #define ZCONF_H -#if !defined(_WIN32) && defined(__WIN32__) -# define _WIN32 +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif #endif #ifdef __STDC_VERSION__ @@ -18,19 +25,6 @@ # endif #endif -/* Clang macro for detecting declspec support - * https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute - */ -#ifndef __has_declspec_attribute -# define __has_declspec_attribute(x) 0 -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # define MAX_MEM_LEVEL 9 @@ -58,48 +52,43 @@ for small objects. */ -/* Type declarations */ + /* Type declarations */ -#ifndef OF /* function prototypes */ -# define OF(args) args -#endif - -#ifdef ZLIB_INTERNAL -# define Z_INTERNAL ZLIB_INTERNAL -#endif - -/* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport))) -# ifdef Z_INTERNAL -# define Z_EXTERN extern __declspec(dllexport) -# else -# define Z_EXTERN extern __declspec(dllimport) +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# define ZEXPORTVA WINAPIV # endif #endif -/* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -#if defined(ZLIB_WINAPI) && defined(_WIN32) -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define Z_EXPORT WINAPI -# define Z_EXPORTVA WINAPIV +#ifndef ZEXTERN +# define ZEXTERN extern #endif - -#ifndef Z_EXTERN -# define Z_EXTERN extern +#ifndef ZEXPORT +# define ZEXPORT #endif -#ifndef Z_EXPORT -# define Z_EXPORT -#endif -#ifndef Z_EXPORTVA -# define Z_EXPORTVA +#ifndef ZEXPORTVA +# define ZEXPORTVA #endif /* Fallback for something that includes us. */ @@ -118,11 +107,11 @@ typedef void const *voidpc; typedef void *voidpf; typedef void *voidp; -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif -#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */ +#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by ./configure */ typedef PTRDIFF_TYPE ptrdiff_t; #endif @@ -170,12 +159,12 @@ typedef PTRDIFF_TYPE ptrdiff_t; # define z_off_t long #endif -#if !defined(_WIN32) && defined(Z_LARGE64) +#if !defined(WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else # if defined(__MSYS__) # define z_off64_t _off64_t -# elif defined(_WIN32) && !defined(__GNUC__) +# elif defined(WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/libs/zlibng/zendian.h b/libs/zlibng/zendian.h deleted file mode 100644 index 54718ed14..000000000 --- a/libs/zlibng/zendian.h +++ /dev/null @@ -1,60 +0,0 @@ -/* zendian.h -- define BYTE_ORDER for endian tests - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifndef ENDIAN_H_ -#define ENDIAN_H_ - -/* First check whether the compiler knows the target __BYTE_ORDER__. */ -#if defined(__BYTE_ORDER__) -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# if !defined(LITTLE_ENDIAN) -# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ -# endif -# if !defined(BYTE_ORDER) -# define BYTE_ORDER LITTLE_ENDIAN -# endif -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# if !defined(BIG_ENDIAN) -# define BIG_ENDIAN __ORDER_BIG_ENDIAN__ -# endif -# if !defined(BYTE_ORDER) -# define BYTE_ORDER BIG_ENDIAN -# endif -# endif -#elif defined(__MINGW32__) -# include -#elif defined(_WIN32) -# define LITTLE_ENDIAN 1234 -# define BIG_ENDIAN 4321 -# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64) -# define BYTE_ORDER LITTLE_ENDIAN -# else -# error Unknown endianness! -# endif -#elif defined(__linux__) -# include -#elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__) -# include -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) -# include -#elif defined(__sun) || defined(sun) -# include -# if !defined(LITTLE_ENDIAN) -# define LITTLE_ENDIAN 4321 -# endif -# if !defined(BIG_ENDIAN) -# define BIG_ENDIAN 1234 -# endif -# if !defined(BYTE_ORDER) -# if defined(_BIG_ENDIAN) -# define BYTE_ORDER BIG_ENDIAN -# else -# define BYTE_ORDER LITTLE_ENDIAN -# endif -# endif -#else -# include -#endif - -#endif diff --git a/libs/zlibng/zlib-ng.h b/libs/zlibng/zlib-ng.h index 275ded703..3d972a0c5 100644 --- a/libs/zlibng/zlib-ng.h +++ b/libs/zlibng/zlib-ng.h @@ -1,6 +1,7 @@ #ifndef ZNGLIB_H_ #define ZNGLIB_H_ -/* zlib-ng.h -- interface of the 'zlib-ng' compression library, forked from zlib. +/* zlib-ng.h -- interface of the 'zlib-ng' compression library + Forked from and compatible with zlib 1.2.11 Copyright (C) 1995-2016 Jean-loup Gailly and Mark Adler @@ -36,11 +37,11 @@ extern "C" { #endif -#define ZLIBNG_VERSION "2.0.0-RC2" -#define ZLIBNG_VERNUM 0x2000 -#define ZLIBNG_VER_MAJOR 2 -#define ZLIBNG_VER_MINOR 0 -#define ZLIBNG_VER_REVISION 0 +#define ZLIBNG_VERSION "1.9.9" +#define ZLIBNG_VERNUM 0x1990 +#define ZLIBNG_VER_MAJOR 1 +#define ZLIBNG_VER_MINOR 9 +#define ZLIBNG_VER_REVISION 9 #define ZLIBNG_VER_SUBREVISION 0 /* @@ -83,11 +84,11 @@ typedef void (*free_func) (void *opaque, void *address); struct internal_state; typedef struct zng_stream_s { - const uint8_t *next_in; /* next input byte */ + const unsigned char *next_in; /* next input byte */ uint32_t avail_in; /* number of bytes available at next_in */ size_t total_in; /* total number of input bytes read so far */ - uint8_t *next_out; /* next output byte will go here */ + unsigned char *next_out; /* next output byte will go here */ uint32_t avail_out; /* remaining free space at next_out */ size_t total_out; /* total number of bytes output so far */ @@ -111,19 +112,19 @@ typedef zng_stream *zng_streamp; /* Obsolete type, retained for compatibility o for more details on the meanings of these fields. */ typedef struct zng_gz_header_s { - int32_t text; /* true if compressed data believed to be text */ + int text; /* true if compressed data believed to be text */ unsigned long time; /* modification time */ - int32_t xflags; /* extra flags (not used when writing a gzip file) */ - int32_t os; /* operating system */ - uint8_t *extra; /* pointer to extra field or NULL if none */ - uint32_t extra_len; /* extra field length (valid if extra != NULL) */ - uint32_t extra_max; /* space at extra (only when reading header) */ - uint8_t *name; /* pointer to zero-terminated file name or NULL */ - uint32_t name_max; /* space at name (only when reading header) */ - uint8_t *comment; /* pointer to zero-terminated comment or NULL */ - uint32_t comm_max; /* space at comment (only when reading header) */ - int32_t hcrc; /* true if there was or will be a header crc */ - int32_t done; /* true when done reading gzip header (not used when writing a gzip file) */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + unsigned char *extra; /* pointer to extra field or NULL if none */ + unsigned int extra_len; /* extra field length (valid if extra != NULL) */ + unsigned int extra_max; /* space at extra (only when reading header) */ + unsigned char *name; /* pointer to zero-terminated file name or NULL */ + unsigned int name_max; /* space at name (only when reading header) */ + unsigned char *comment; /* pointer to zero-terminated comment or NULL */ + unsigned int comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used when writing a gzip file) */ } zng_gz_header; typedef zng_gz_header *zng_gz_headerp; @@ -203,8 +204,7 @@ typedef zng_gz_header *zng_gz_headerp; /* basic functions */ -Z_EXTERN Z_EXPORT -const char *zlibng_version(void); +ZEXTERN const char * ZEXPORT zlibng_version(void); /* The application can compare zlibng_version and ZLIBNG_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib-ng.h header file used by the application. This check @@ -212,8 +212,7 @@ const char *zlibng_version(void); */ /* -Z_EXTERN Z_EXPORT -int zng_deflateInit(zng_stream *strm, int level); +ZEXTERN int ZEXPORT zng_deflateInit (zng_stream *strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If @@ -235,8 +234,7 @@ int zng_deflateInit(zng_stream *strm, int level); */ -Z_EXTERN Z_EXPORT -int32_t zng_deflate(zng_stream *strm, int32_t flush); +ZEXTERN int ZEXPORT zng_deflate(zng_stream *strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -349,8 +347,7 @@ int32_t zng_deflate(zng_stream *strm, int32_t flush); */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateEnd(zng_stream *strm); +ZEXTERN int ZEXPORT zng_deflateEnd(zng_stream *strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -365,8 +362,7 @@ int32_t zng_deflateEnd(zng_stream *strm); /* -Z_EXTERN Z_EXPORT -int zng_inflateInit(zng_stream *strm); +ZEXTERN int ZEXPORT zng_inflateInit (zng_stream *strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -388,8 +384,7 @@ int zng_inflateInit(zng_stream *strm); */ -Z_EXTERN Z_EXPORT -int32_t zng_inflate(zng_stream *strm, int32_t flush); +ZEXTERN int ZEXPORT zng_inflate(zng_stream *strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -509,8 +504,7 @@ int32_t zng_inflate(zng_stream *strm, int32_t flush); */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateEnd(zng_stream *strm); +ZEXTERN int ZEXPORT zng_inflateEnd(zng_stream *strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -528,8 +522,12 @@ int32_t zng_inflateEnd(zng_stream *strm); */ /* -Z_EXTERN Z_EXPORT -int zng_deflateInit2(zng_stream *strm, int level, int method, int windowBits, int memLevel, int strategy); +ZEXTERN int ZEXPORT zng_deflateInit2 (zng_stream *strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); This is another version of deflateInit with more compression options. The fields zalloc, zfree and opaque must be initialized before by the caller. @@ -596,8 +594,9 @@ int zng_deflateInit2(zng_stream *strm, int level, int method, int windowBits, compression: this will be done by deflate(). */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateSetDictionary(zng_stream *strm, const uint8_t *dictionary, uint32_t dictLength); +ZEXTERN int ZEXPORT zng_deflateSetDictionary(zng_stream *strm, + const unsigned char *dictionary, + unsigned int dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this @@ -639,8 +638,7 @@ int32_t zng_deflateSetDictionary(zng_stream *strm, const uint8_t *dictionary, ui not perform any compression: this will be done by deflate(). */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateGetDictionary(zng_stream *strm, uint8_t *dictionary, uint32_t *dictLength); +ZEXTERN int ZEXPORT zng_deflateGetDictionary (zng_stream *strm, unsigned char *dictionary, unsigned int *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -660,8 +658,7 @@ int32_t zng_deflateGetDictionary(zng_stream *strm, uint8_t *dictionary, uint32_t stream state is inconsistent. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateCopy(zng_stream *dest, zng_stream *source); +ZEXTERN int ZEXPORT zng_deflateCopy(zng_stream *dest, zng_stream *source); /* Sets the destination stream as a complete copy of the source stream. @@ -678,8 +675,7 @@ int32_t zng_deflateCopy(zng_stream *dest, zng_stream *source); destination. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateReset(zng_stream *strm); +ZEXTERN int ZEXPORT zng_deflateReset(zng_stream *strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream @@ -690,8 +686,7 @@ int32_t zng_deflateReset(zng_stream *strm); stream state was inconsistent (such as zalloc or state being NULL). */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateParams(zng_stream *strm, int32_t level, int32_t strategy); +ZEXTERN int ZEXPORT zng_deflateParams(zng_stream *strm, int level, int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be @@ -727,8 +722,7 @@ int32_t zng_deflateParams(zng_stream *strm, int32_t level, int32_t strategy); retried with more output space. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateTune(zng_stream *strm, int32_t good_length, int32_t max_lazy, int32_t nice_length, int32_t max_chain); +ZEXTERN int ZEXPORT zng_deflateTune(zng_stream *strm, int good_length, int max_lazy, int nice_length, int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for @@ -741,8 +735,7 @@ int32_t zng_deflateTune(zng_stream *strm, int32_t good_length, int32_t max_lazy, returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -Z_EXTERN Z_EXPORT -unsigned long zng_deflateBound(zng_stream *strm, unsigned long sourceLen); +ZEXTERN unsigned long ZEXPORT zng_deflateBound(zng_stream *strm, unsigned long sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or @@ -756,8 +749,7 @@ unsigned long zng_deflateBound(zng_stream *strm, unsigned long sourceLen); than Z_FINISH or Z_NO_FLUSH are used. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflatePending(zng_stream *strm, uint32_t *pending, int32_t *bits); +ZEXTERN int ZEXPORT zng_deflatePending(zng_stream *strm, uint32_t *pending, int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not @@ -770,8 +762,7 @@ int32_t zng_deflatePending(zng_stream *strm, uint32_t *pending, int32_t *bits); stream state was inconsistent. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflatePrime(zng_stream *strm, int32_t bits, int32_t value); +ZEXTERN int ZEXPORT zng_deflatePrime(zng_stream *strm, int bits, int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits @@ -786,8 +777,7 @@ int32_t zng_deflatePrime(zng_stream *strm, int32_t bits, int32_t value); source stream state was inconsistent. */ -Z_EXTERN Z_EXPORT -int32_t zng_deflateSetHeader(zng_stream *strm, zng_gz_headerp head); +ZEXTERN int ZEXPORT zng_deflateSetHeader(zng_stream *strm, zng_gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called @@ -811,8 +801,7 @@ int32_t zng_deflateSetHeader(zng_stream *strm, zng_gz_headerp head); */ /* -Z_EXTERN Z_EXPORT -int zng_inflateInit2(zng_stream *strm, int windowBits); +ZEXTERN int ZEXPORT zng_inflateInit2(zng_stream *strm, int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -865,8 +854,7 @@ int zng_inflateInit2(zng_stream *strm, int windowBits); deferred until inflate() is called. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateSetDictionary(zng_stream *strm, const uint8_t *dictionary, uint32_t dictLength); +ZEXTERN int ZEXPORT zng_inflateSetDictionary(zng_stream *strm, const unsigned char *dictionary, unsigned int dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, @@ -887,8 +875,7 @@ int32_t zng_inflateSetDictionary(zng_stream *strm, const uint8_t *dictionary, ui inflate(). */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateGetDictionary(zng_stream *strm, uint8_t *dictionary, uint32_t *dictLength); +ZEXTERN int ZEXPORT zng_inflateGetDictionary(zng_stream *strm, unsigned char *dictionary, unsigned int *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -901,8 +888,7 @@ int32_t zng_inflateGetDictionary(zng_stream *strm, uint8_t *dictionary, uint32_t stream state is inconsistent. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateSync(zng_stream *strm); +ZEXTERN int ZEXPORT zng_inflateSync(zng_stream *strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -921,8 +907,7 @@ int32_t zng_inflateSync(zng_stream *strm); input each time, until success or end of the input data. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateCopy(zng_stream *dest, zng_stream *source); +ZEXTERN int ZEXPORT zng_inflateCopy(zng_stream *dest, zng_stream *source); /* Sets the destination stream as a complete copy of the source stream. @@ -937,8 +922,7 @@ int32_t zng_inflateCopy(zng_stream *dest, zng_stream *source); destination. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateReset(zng_stream *strm); +ZEXTERN int ZEXPORT zng_inflateReset(zng_stream *strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The @@ -948,8 +932,7 @@ int32_t zng_inflateReset(zng_stream *strm); stream state was inconsistent (such as zalloc or state being NULL). */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateReset2(zng_stream *strm, int32_t windowBits); +ZEXTERN int ZEXPORT zng_inflateReset2(zng_stream *strm, int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted @@ -962,8 +945,7 @@ int32_t zng_inflateReset2(zng_stream *strm, int32_t windowBits); the windowBits parameter is invalid. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflatePrime(zng_stream *strm, int32_t bits, int32_t value); +ZEXTERN int ZEXPORT zng_inflatePrime(zng_stream *strm, int bits, int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the @@ -982,8 +964,7 @@ int32_t zng_inflatePrime(zng_stream *strm, int32_t bits, int32_t value); stream state was inconsistent. */ -Z_EXTERN Z_EXPORT -long zng_inflateMark(zng_stream *strm); +ZEXTERN long ZEXPORT zng_inflateMark(zng_stream *strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the @@ -1011,8 +992,7 @@ long zng_inflateMark(zng_stream *strm); source stream state was inconsistent. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateGetHeader(zng_stream *strm, zng_gz_headerp head); +ZEXTERN int ZEXPORT zng_inflateGetHeader(zng_stream *strm, zng_gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided zng_gz_header structure. inflateGetHeader() may be called after @@ -1052,8 +1032,7 @@ int32_t zng_inflateGetHeader(zng_stream *strm, zng_gz_headerp head); */ /* -Z_EXTERN Z_EXPORT -int zng_inflateBackInit(zng_stream *strm, int windowBits, unsigned char *window); +ZEXTERN int ZEXPORT zng_inflateBackInit (zng_stream *strm, int windowBits, unsigned char *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized @@ -1073,11 +1052,10 @@ int zng_inflateBackInit(zng_stream *strm, int windowBits, unsigned char *window) the version of the header file. */ -typedef uint32_t (*in_func) (void *, const uint8_t * *); -typedef int32_t (*out_func) (void *, uint8_t *, uint32_t); +typedef uint32_t (*in_func) (void *, const unsigned char * *); +typedef int (*out_func) (void *, unsigned char *, uint32_t); -Z_EXTERN Z_EXPORT -int32_t zng_inflateBack(zng_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc); +ZEXTERN int ZEXPORT zng_inflateBack(zng_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than @@ -1145,8 +1123,7 @@ int32_t zng_inflateBack(zng_stream *strm, in_func in, void *in_desc, out_func ou cannot return Z_OK. */ -Z_EXTERN Z_EXPORT -int32_t zng_inflateBackEnd(zng_stream *strm); +ZEXTERN int ZEXPORT zng_inflateBackEnd(zng_stream *strm); /* All memory allocated by inflateBackInit() is freed. @@ -1154,8 +1131,7 @@ int32_t zng_inflateBackEnd(zng_stream *strm); state was inconsistent. */ -Z_EXTERN Z_EXPORT -unsigned long zng_zlibCompileFlags(void); +ZEXTERN unsigned long ZEXPORT zng_zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: @@ -1171,7 +1147,7 @@ unsigned long zng_zlibCompileFlags(void); 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed (not supported by zlib-ng) + 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) @@ -1207,8 +1183,7 @@ unsigned long zng_zlibCompileFlags(void); you need special options. */ -Z_EXTERN Z_EXPORT -int32_t zng_compress(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t sourceLen); +ZEXTERN int ZEXPORT zng_compress(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1222,8 +1197,8 @@ int32_t zng_compress(uint8_t *dest, size_t *destLen, const uint8_t *source, size buffer. */ -Z_EXTERN Z_EXPORT -int32_t zng_compress2(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t sourceLen, int32_t level); +ZEXTERN int ZEXPORT zng_compress2(unsigned char *dest, size_t *destLen, const unsigned char *source, + size_t sourceLen, int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -1237,16 +1212,14 @@ int32_t zng_compress2(uint8_t *dest, size_t *destLen, const uint8_t *source, siz Z_STREAM_ERROR if the level parameter is invalid. */ -Z_EXTERN Z_EXPORT -size_t zng_compressBound(size_t sourceLen); +ZEXTERN size_t ZEXPORT zng_compressBound(size_t sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -Z_EXTERN Z_EXPORT -int32_t zng_uncompress(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t sourceLen); +ZEXTERN int ZEXPORT zng_uncompress(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1264,8 +1237,8 @@ int32_t zng_uncompress(uint8_t *dest, size_t *destLen, const uint8_t *source, si */ -Z_EXTERN Z_EXPORT -int32_t zng_uncompress2(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t *sourceLen); +ZEXTERN int ZEXPORT zng_uncompress2 (unsigned char *dest, size_t *destLen, + const unsigned char *source, size_t *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of @@ -1285,9 +1258,9 @@ int32_t zng_uncompress2(uint8_t *dest, size_t *destLen, const uint8_t *source, s typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ -Z_EXTERN Z_EXPORT -gzFile zng_gzopen(const char *path, const char *mode); /* +ZEXTERN gzFile ZEXPORT zng_gzopen(const char *path, const char *mode); + Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only @@ -1323,8 +1296,7 @@ gzFile zng_gzopen(const char *path, const char *mode); file could not be opened. */ -Z_EXTERN Z_EXPORT -gzFile zng_gzdopen(int fd, const char *mode); +ZEXTERN gzFile ZEXPORT zng_gzdopen(int fd, const char *mode); /* gzdopen associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file @@ -1347,8 +1319,7 @@ gzFile zng_gzdopen(int fd, const char *mode); will not detect if fd is invalid (unless fd is -1). */ -Z_EXTERN Z_EXPORT -int32_t zng_gzbuffer(gzFile file, uint32_t size); +ZEXTERN int ZEXPORT zng_gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions. The default buffer size is 8192 bytes. This function must be called after @@ -1364,8 +1335,7 @@ int32_t zng_gzbuffer(gzFile file, uint32_t size); too late. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzsetparams(gzFile file, int32_t level, int32_t strategy); +ZEXTERN int ZEXPORT zng_gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. Previously provided @@ -1376,8 +1346,7 @@ int32_t zng_gzsetparams(gzFile file, int32_t level, int32_t strategy); or Z_MEM_ERROR if there is a memory allocation error. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzread(gzFile file, void *buf, uint32_t len); +ZEXTERN int ZEXPORT zng_gzread(gzFile file, void *buf, unsigned len); /* Reads the given number of uncompressed bytes from the compressed file. If the input file is not in gzip format, gzread copies the given number of @@ -1407,8 +1376,7 @@ int32_t zng_gzread(gzFile file, void *buf, uint32_t len); Z_STREAM_ERROR. */ -Z_EXTERN Z_EXPORT -size_t zng_gzfread(void *buf, size_t size, size_t nitems, gzFile file); +ZEXTERN size_t ZEXPORT zng_gzfread (void *buf, size_t size, size_t nitems, gzFile file); /* Read up to nitems items of size size from file to buf, otherwise operating as gzread() does. This duplicates the interface of stdio's fread(), with @@ -1431,16 +1399,14 @@ size_t zng_gzfread(void *buf, size_t size, size_t nitems, gzFile file); file, reseting and retrying on end-of-file, when size is not 1. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzwrite(gzFile file, void const *buf, uint32_t len); +ZEXTERN int ZEXPORT zng_gzwrite(gzFile file, void const *buf, unsigned len); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ -Z_EXTERN Z_EXPORT -size_t zng_gzfwrite(void const *buf, size_t size, size_t nitems, gzFile file); +ZEXTERN size_t ZEXPORT zng_gzfwrite(void const *buf, size_t size, size_t nitems, gzFile file); /* gzfwrite() writes nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. @@ -1451,8 +1417,7 @@ size_t zng_gzfwrite(void const *buf, size_t size, size_t nitems, gzFile file); is returned, and the error state is set to Z_STREAM_ERROR. */ -Z_EXTERN Z_EXPORTVA -int32_t zng_gzprintf(gzFile file, const char *format, ...); +ZEXTERN int ZEXPORTVA zng_gzprintf(gzFile file, const char *format, ...); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of @@ -1467,8 +1432,7 @@ int32_t zng_gzprintf(gzFile file, const char *format, ...); This can be determined using zlibCompileFlags(). */ -Z_EXTERN Z_EXPORT -int32_t zng_gzputs(gzFile file, const char *s); +ZEXTERN int ZEXPORT zng_gzputs(gzFile file, const char *s); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. @@ -1476,8 +1440,7 @@ int32_t zng_gzputs(gzFile file, const char *s); gzputs returns the number of characters written, or -1 in case of error. */ -Z_EXTERN Z_EXPORT -char * zng_gzgets(gzFile file, char *buf, int32_t len); +ZEXTERN char * ZEXPORT zng_gzgets(gzFile file, char *buf, int len); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file @@ -1490,15 +1453,13 @@ char * zng_gzgets(gzFile file, char *buf, int32_t len); buf are indeterminate. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzputc(gzFile file, int32_t c); +ZEXTERN int ZEXPORT zng_gzputc(gzFile file, int c); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzgetc(gzFile file); +ZEXTERN int ZEXPORT zng_gzgetc(gzFile file); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. @@ -1507,8 +1468,7 @@ int32_t zng_gzgetc(gzFile file); points to has been clobbered or not. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzungetc(int32_t c, gzFile file); +ZEXTERN int ZEXPORT zng_gzungetc(int c, gzFile file); /* Push one character back onto the stream to be read as the first character on the next read. At least one character of push-back is allowed. @@ -1520,8 +1480,7 @@ int32_t zng_gzungetc(int32_t c, gzFile file); gzseek() or gzrewind(). */ -Z_EXTERN Z_EXPORT -int32_t zng_gzflush(gzFile file, int32_t flush); +ZEXTERN int ZEXPORT zng_gzflush(gzFile file, int flush); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number @@ -1536,9 +1495,9 @@ int32_t zng_gzflush(gzFile file, int32_t flush); degrade compression if called too often. */ -Z_EXTERN Z_EXPORT -z_off64_t zng_gzseek(gzFile file, z_off64_t offset, int whence); /* +ZEXTERN z_off_t ZEXPORT zng_gzseek (gzFile file, z_off_t offset, int whence); + Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); @@ -1555,17 +1514,16 @@ z_off64_t zng_gzseek(gzFile file, z_off64_t offset, int whence); would be before the current position. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzrewind(gzFile file); +ZEXTERN int ZEXPORT zng_gzrewind(gzFile file); /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ -Z_EXTERN Z_EXPORT -z_off64_t zng_gztell(gzFile file); /* +ZEXTERN z_off_t ZEXPORT zng_gztell(gzFile file); + Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or @@ -1574,9 +1532,9 @@ z_off64_t zng_gztell(gzFile file); gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ -Z_EXTERN Z_EXPORT -z_off64_t zng_gzoffset(gzFile file); /* +ZEXTERN z_off_t ZEXPORT zng_gzoffset(gzFile file); + Returns the current offset in the file being read or written. This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset @@ -1584,8 +1542,7 @@ z_off64_t zng_gzoffset(gzFile file); for a progress indicator. On error, gzoffset() returns -1. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzeof(gzFile file); +ZEXTERN int ZEXPORT zng_gzeof(gzFile file); /* Returns true (1) if the end-of-file indicator has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set only if the @@ -1600,8 +1557,7 @@ int32_t zng_gzeof(gzFile file); has grown since the previous end of file was detected. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzdirect(gzFile file); +ZEXTERN int ZEXPORT zng_gzdirect(gzFile file); /* Returns true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. @@ -1622,8 +1578,7 @@ int32_t zng_gzdirect(gzFile file); gzip file reading and decompression, which may not be desired.) */ -Z_EXTERN Z_EXPORT -int32_t zng_gzclose(gzFile file); +ZEXTERN int ZEXPORT zng_gzclose(gzFile file); /* Flushes all pending output if necessary, closes the compressed file and deallocates the (de)compression state. Note that once file is closed, you @@ -1636,10 +1591,8 @@ int32_t zng_gzclose(gzFile file); last read ended in the middle of a gzip stream, or Z_OK on success. */ -Z_EXTERN Z_EXPORT -int32_t zng_gzclose_r(gzFile file); -Z_EXTERN Z_EXPORT -int32_t zng_gzclose_w(gzFile file); +ZEXTERN int ZEXPORT zng_gzclose_r(gzFile file); +ZEXTERN int ZEXPORT zng_gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to @@ -1650,8 +1603,7 @@ int32_t zng_gzclose_w(gzFile file); zlib library. */ -Z_EXTERN Z_EXPORT -const char * zng_gzerror(gzFile file, int32_t *errnum); +ZEXTERN const char * ZEXPORT zng_gzerror(gzFile file, int *errnum); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred @@ -1667,8 +1619,7 @@ const char * zng_gzerror(gzFile file, int32_t *errnum); functions above that do not distinguish those cases in their return values. */ -Z_EXTERN Z_EXPORT -void zng_gzclearerr(gzFile file); +ZEXTERN void ZEXPORT zng_gzclearerr(gzFile file); /* Clears the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip @@ -1685,8 +1636,7 @@ void zng_gzclearerr(gzFile file); library. */ -Z_EXTERN Z_EXPORT -uint32_t zng_adler32(uint32_t adler, const uint8_t *buf, uint32_t len); +ZEXTERN uint32_t ZEXPORT zng_adler32(uint32_t adler, const unsigned char *buf, uint32_t len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the @@ -1705,15 +1655,14 @@ uint32_t zng_adler32(uint32_t adler, const uint8_t *buf, uint32_t len); if (adler != original_adler) error(); */ -Z_EXTERN Z_EXPORT -uint32_t zng_adler32_z(uint32_t adler, const uint8_t *buf, size_t len); +ZEXTERN uint32_t ZEXPORT zng_adler32_z (uint32_t adler, const unsigned char *buf, size_t len); /* Same as adler32(), but with a size_t length. */ -Z_EXTERN Z_EXPORT -uint32_t zng_adler32_combine(uint32_t adler1, uint32_t adler2, z_off64_t len2); /* +ZEXTERN uint32_t ZEXPORT zng_adler32_combine(uint32_t adler1, uint32_t adler2, z_off_t len2); + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of @@ -1722,8 +1671,7 @@ uint32_t zng_adler32_combine(uint32_t adler1, uint32_t adler2, z_off64_t len2); negative, the result has no meaning or utility. */ -Z_EXTERN Z_EXPORT -uint32_t zng_crc32(uint32_t crc, const uint8_t *buf, uint32_t len); +ZEXTERN uint32_t ZEXPORT zng_crc32(uint32_t crc, const unsigned char *buf, uint32_t len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is NULL, this function returns the required @@ -1740,16 +1688,14 @@ uint32_t zng_crc32(uint32_t crc, const uint8_t *buf, uint32_t len); if (crc != original_crc) error(); */ -Z_EXTERN Z_EXPORT -uint32_t zng_crc32_z(uint32_t crc, const uint8_t *buf, size_t len); +ZEXTERN uint32_t ZEXPORT zng_crc32_z (uint32_t crc, const unsigned char *buf, size_t len); /* Same as crc32(), but with a size_t length. */ -Z_EXTERN Z_EXPORT -uint32_t zng_crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); - /* +ZEXTERN uint32_t ZEXPORT zng_crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); + Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 @@ -1757,17 +1703,16 @@ uint32_t zng_crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); len2. */ -Z_EXTERN Z_EXPORT -void zng_crc32_combine_gen(uint32_t op[32], z_off64_t len2); - /* +ZEXTERN void ZEXPORT zng_crc32_combine_gen(uint32_t op[32], z_off_t len2); + Generate the operator op corresponding to length len2, to be used with crc32_combine_op(). op must have room for 32 uint32_t values. (32 is the number of bits in the CRC.) */ -Z_EXTERN Z_EXPORT -uint32_t zng_crc32_combine_op(uint32_t crc1, uint32_t crc2, const uint32_t *op); +ZEXTERN uint32_t ZEXPORT zng_crc32_combine_op(uint32_t crc1, uint32_t crc2, + const uint32_t *op); /* Give the same result as crc32_combine(), using op in place of len2. op is is generated from len2 by crc32_combine_gen(). This will be faster than @@ -1779,22 +1724,21 @@ uint32_t zng_crc32_combine_op(uint32_t crc1, uint32_t crc2, const uint32_t *op); /* zng_deflateInit and zng_inflateInit are macros to allow checking the zlib version * and the compiler's view of zng_stream: */ -Z_EXTERN Z_EXPORT int32_t zng_deflateInit_(zng_stream *strm, int32_t level, const char *version, int32_t stream_size); -Z_EXTERN Z_EXPORT int32_t zng_inflateInit_(zng_stream *strm, const char *version, int32_t stream_size); -Z_EXTERN Z_EXPORT int32_t zng_deflateInit2_(zng_stream *strm, int32_t level, int32_t method, int32_t windowBits, int32_t memLevel, - int32_t strategy, const char *version, int32_t stream_size); -Z_EXTERN Z_EXPORT int32_t zng_inflateInit2_(zng_stream *strm, int32_t windowBits, const char *version, int32_t stream_size); -Z_EXTERN Z_EXPORT int32_t zng_inflateBackInit_(zng_stream *strm, int32_t windowBits, uint8_t *window, - const char *version, int32_t stream_size); - -#define zng_deflateInit(strm, level) zng_deflateInit_((strm), (level), ZLIBNG_VERSION, (int32_t)sizeof(zng_stream)) -#define zng_inflateInit(strm) zng_inflateInit_((strm), ZLIBNG_VERSION, (int32_t)sizeof(zng_stream)) +ZEXTERN int ZEXPORT zng_deflateInit_(zng_stream *strm, int level, const char *version, int stream_size); +ZEXTERN int ZEXPORT zng_inflateInit_(zng_stream *strm, const char *version, int stream_size); +ZEXTERN int ZEXPORT zng_deflateInit2_(zng_stream *strm, int level, int method, int windowBits, int memLevel, + int strategy, const char *version, int stream_size); +ZEXTERN int ZEXPORT zng_inflateInit2_(zng_stream *strm, int windowBits, const char *version, int stream_size); +ZEXTERN int ZEXPORT zng_inflateBackInit_(zng_stream *strm, int windowBits, unsigned char *window, + const char *version, int stream_size); +#define zng_deflateInit(strm, level) zng_deflateInit_((strm), (level), ZLIBNG_VERSION, (int)sizeof(zng_stream)) +#define zng_inflateInit(strm) zng_inflateInit_((strm), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #define zng_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ zng_deflateInit2_((strm), (level), (method), (windowBits), (memLevel), \ - (strategy), ZLIBNG_VERSION, (int32_t)sizeof(zng_stream)) -#define zng_inflateInit2(strm, windowBits) zng_inflateInit2_((strm), (windowBits), ZLIBNG_VERSION, (int32_t)sizeof(zng_stream)) + (strategy), ZLIBNG_VERSION, (int)sizeof(zng_stream)) +#define zng_inflateInit2(strm, windowBits) zng_inflateInit2_((strm), (windowBits), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #define zng_inflateBackInit(strm, windowBits, window) \ - zng_inflateBackInit_((strm), (windowBits), (window), ZLIBNG_VERSION, (int32_t)sizeof(zng_stream)) + zng_inflateBackInit_((strm), (windowBits), (window), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #ifdef WITH_GZFILEOP @@ -1810,75 +1754,85 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -Z_EXTERN Z_EXPORT int32_t zng_gzgetc_(gzFile file); /* backward compatibility */ +ZEXTERN int ZEXPORT zng_gzgetc_(gzFile file); /* backward compatibility */ # define zng_gzgetc(g) ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (zng_gzgetc)(g)) +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT zng_gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT zng_gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT zng_gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT zng_gzoffset64(gzFile); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# define zng_gzopen zng_gzopen64 +# define zng_gzseek zng_gzseek64 +# define zng_gztell zng_gztell64 +# define zng_gzoffset zng_gzoffset64 +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT zng_gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT zng_gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT zng_gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT zng_gzoffset64(gzFile); +# endif +#else + ZEXTERN gzFile ZEXPORT zng_gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT zng_gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT zng_gztell(gzFile); + ZEXTERN z_off_t ZEXPORT zng_gzoffset(gzFile); +#endif #endif /* WITH_GZFILEOP */ -typedef enum { - Z_DEFLATE_LEVEL = 0, /* compression level, represented as an int */ - Z_DEFLATE_STRATEGY = 1, /* compression strategy, represented as an int */ - Z_DEFLATE_REPRODUCIBLE = 2, - /* - Whether reproducible compression results are required. Represented as an int, where 0 means that it is allowed - to trade reproducibility for e.g. improved performance or compression ratio, and non-0 means that - reproducibility is strictly required. Reproducibility is guaranteed only when using an identical zlib-ng build. - Default is 0. - */ -} zng_deflate_param; +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN uint32_t ZEXPORT zng_adler32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN uint32_t ZEXPORT zng_crc32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN void ZEXPORT zng_crc32_combine_gen64(uint32_t *op, z_off64_t); +#endif -typedef struct { - zng_deflate_param param; /* parameter ID */ - void *buf; /* parameter value */ - size_t size; /* parameter value size */ - int32_t status; /* result of the last set/get call */ -} zng_deflate_param_value; +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# define zng_adler32_combine zng_adler32_combine64 +# define zng_crc32_combine zng_crc32_combine64 +# define zng_crc32_combine_gen zng_crc32_combine_gen64 +# ifndef Z_LARGE64 + ZEXTERN uint32_t ZEXPORT zng_adler32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT zng_crc32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN void ZEXPORT zng_crc32_combine_gen64(uint32_t *op, z_off64_t); +# endif +#else + ZEXTERN uint32_t ZEXPORT zng_adler32_combine(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT zng_crc32_combine(uint32_t, uint32_t, z_off_t); + ZEXTERN void ZEXPORT zng_crc32_combine_gen(uint32_t *op, z_off_t); +#endif -Z_EXTERN Z_EXPORT -int32_t zng_deflateSetParams(zng_stream *strm, zng_deflate_param_value *params, size_t count); -/* - Sets the values of the given zlib-ng deflate stream parameters. All the buffers are copied internally, so the - caller still owns them after this function returns. Returns Z_OK if success. - - If the size of at least one of the buffers is too small to hold the entire value of the corresponding parameter, - or if the same parameter is specified multiple times, Z_BUF_ERROR is returned. The caller may inspect status fields - in order to determine which of the parameters caused this error. No other changes are performed. - - If the stream state is inconsistent or if at least one of the values cannot be updated, Z_STREAM_ERROR is - returned. The caller may inspect status fields in order to determine which of the parameters caused this error. - Parameters, whose status field is equal to Z_OK, have been applied successfully. If all status fields are not equal - to Z_STREAM_ERROR, then the error was caused by a stream state inconsistency. - - If there are no other errors, but at least one parameter is not supported by the current zlib-ng version, - Z_VERSION_ERROR is returned. The caller may inspect status fields in order to determine which of the parameters - caused this error. -*/ - -Z_EXTERN Z_EXPORT -int32_t zng_deflateGetParams(zng_stream *strm, zng_deflate_param_value *params, size_t count); -/* - Copies the values of the given zlib-ng deflate stream parameters into the user-provided buffers. Returns Z_OK if - success, Z_VERSION_ERROR if at least one parameter is not supported by the current zlib-ng version, Z_STREAM_ERROR - if the stream state is inconsistent, and Z_BUF_ERROR if the size of at least one buffer is too small to hold the - entire value of the corresponding parameter. -*/ /* undocumented functions */ -Z_EXTERN Z_EXPORT const char * zng_zError (int32_t); -Z_EXTERN Z_EXPORT int32_t zng_inflateSyncPoint (zng_stream *); -Z_EXTERN Z_EXPORT const uint32_t * zng_get_crc_table (void); -Z_EXTERN Z_EXPORT int32_t zng_inflateUndermine (zng_stream *, int32_t); -Z_EXTERN Z_EXPORT int32_t zng_inflateValidate (zng_stream *, int32_t); -Z_EXTERN Z_EXPORT unsigned long zng_inflateCodesUsed (zng_stream *); -Z_EXTERN Z_EXPORT int32_t zng_inflateResetKeep (zng_stream *); -Z_EXTERN Z_EXPORT int32_t zng_deflateResetKeep (zng_stream *); +ZEXTERN const char * ZEXPORT zng_zError (int); +ZEXTERN int ZEXPORT zng_inflateSyncPoint (zng_stream *); +ZEXTERN const uint32_t * ZEXPORT zng_get_crc_table (void); +ZEXTERN int ZEXPORT zng_inflateUndermine (zng_stream *, int); +ZEXTERN int ZEXPORT zng_inflateValidate (zng_stream *, int); +ZEXTERN unsigned long ZEXPORT zng_inflateCodesUsed (zng_stream *); +ZEXTERN int ZEXPORT zng_inflateResetKeep (zng_stream *); +ZEXTERN int ZEXPORT zng_deflateResetKeep (zng_stream *); #ifdef WITH_GZFILEOP -# if defined(_WIN32) - Z_EXTERN Z_EXPORT gzFile zng_gzopen_w(const wchar_t *path, const char *mode); -# endif -Z_EXTERN Z_EXPORTVA int32_t zng_gzvprintf(gzFile file, const char *format, va_list va); +# if (defined(WIN32) || defined(__MINGW__)) + ZEXTERN gzFile ZEXPORT zng_gzopen_w(const wchar_t *path, const char *mode); +# endif +ZEXTERN int ZEXPORTVA zng_gzvprintf(gzFile file, const char *format, va_list va); #endif #ifdef __cplusplus diff --git a/libs/zlibng/zlib-ng.map b/libs/zlibng/zlib-ng.map index b0046034c..107d06958 100644 --- a/libs/zlibng/zlib-ng.map +++ b/libs/zlibng/zlib-ng.map @@ -1,14 +1,16 @@ -ZLIB_NG_2.0.0 { +ZLIB_NG_1.9.9 { global: zng_adler32; zng_adler32_c; zng_adler32_combine; + zng_adler32_combine64; zng_adler32_z; zng_compress; zng_compress2; zng_compressBound; zng_crc32; zng_crc32_combine; + zng_crc32_combine64; zng_crc32_combine_gen; zng_crc32_combine_op; zng_crc32_z; @@ -17,7 +19,6 @@ ZLIB_NG_2.0.0 { zng_deflateCopy; zng_deflateEnd; zng_deflateGetDictionary; - zng_deflateGetParams; zng_deflateInit_; zng_deflateInit2_; zng_deflateParams; @@ -27,7 +28,6 @@ ZLIB_NG_2.0.0 { zng_deflateResetKeep; zng_deflateSetDictionary; zng_deflateSetHeader; - zng_deflateSetParams; zng_deflateTune; zng_get_crc_table; zng_inflate; @@ -70,7 +70,7 @@ ZLIB_NG_2.0.0 { _*; }; -ZLIB_NG_GZ_2.0.0 { +ZLIB_NG_GZ_1.9.9 { global: zng_gzbuffer; zng_gzclearerr; diff --git a/libs/zlibng/zlib.3.pdf b/libs/zlibng/zlib.3.pdf new file mode 100644 index 000000000..6fa519c5b Binary files /dev/null and b/libs/zlibng/zlib.3.pdf differ diff --git a/libs/zlibng/zlib.h b/libs/zlibng/zlib.h index 688fe440e..891350013 100644 --- a/libs/zlibng/zlib.h +++ b/libs/zlibng/zlib.h @@ -32,17 +32,17 @@ #include #include -#include "zconf-ng.h" +#include "zconf.h" #ifdef __cplusplus extern "C" { #endif -#define ZLIBNG_VERSION "2.0.0-RC2" -#define ZLIBNG_VERNUM 0x2000 -#define ZLIBNG_VER_MAJOR 2 -#define ZLIBNG_VER_MINOR 0 -#define ZLIBNG_VER_REVISION 0 +#define ZLIBNG_VERSION "1.9.9" +#define ZLIBNG_VERNUM 0x1990 +#define ZLIBNG_VER_MAJOR 1 +#define ZLIBNG_VER_MINOR 9 +#define ZLIBNG_VER_REVISION 9 #define ZLIBNG_VER_SUBREVISION 0 #define ZLIB_VERSION "1.2.11.zlib-ng" @@ -92,15 +92,15 @@ typedef void (*free_func) (void *opaque, void *address); struct internal_state; typedef struct z_stream_s { - z_const unsigned char *next_in; /* next input byte */ + const unsigned char *next_in; /* next input byte */ uint32_t avail_in; /* number of bytes available at next_in */ - unsigned long total_in; /* total number of input bytes read so far */ + size_t total_in; /* total number of input bytes read so far */ unsigned char *next_out; /* next output byte will go here */ uint32_t avail_out; /* remaining free space at next_out */ - unsigned long total_out; /* total number of bytes output so far */ + size_t total_out; /* total number of bytes output so far */ - z_const char *msg; /* last error message, NULL if no error */ + const char *msg; /* last error message, NULL if no error */ struct internal_state *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ @@ -215,7 +215,7 @@ typedef gz_header *gz_headerp; /* basic functions */ -Z_EXTERN const char * Z_EXPORT zlibVersion(void); +ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check @@ -223,7 +223,7 @@ Z_EXTERN const char * Z_EXPORT zlibVersion(void); */ /* -Z_EXTERN int Z_EXPORT deflateInit (z_stream *strm, int level); +ZEXTERN int ZEXPORT deflateInit (z_stream *strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If @@ -245,7 +245,7 @@ Z_EXTERN int Z_EXPORT deflateInit (z_stream *strm, int level); */ -Z_EXTERN int Z_EXPORT deflate(z_stream *strm, int flush); +ZEXTERN int ZEXPORT deflate(z_stream *strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -358,7 +358,7 @@ Z_EXTERN int Z_EXPORT deflate(z_stream *strm, int flush); */ -Z_EXTERN int Z_EXPORT deflateEnd(z_stream *strm); +ZEXTERN int ZEXPORT deflateEnd(z_stream *strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -373,7 +373,7 @@ Z_EXTERN int Z_EXPORT deflateEnd(z_stream *strm); /* -Z_EXTERN int Z_EXPORT inflateInit (z_stream *strm); +ZEXTERN int ZEXPORT inflateInit (z_stream *strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -395,7 +395,7 @@ Z_EXTERN int Z_EXPORT inflateInit (z_stream *strm); */ -Z_EXTERN int Z_EXPORT inflate(z_stream *strm, int flush); +ZEXTERN int ZEXPORT inflate(z_stream *strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -515,7 +515,7 @@ Z_EXTERN int Z_EXPORT inflate(z_stream *strm, int flush); */ -Z_EXTERN int Z_EXPORT inflateEnd(z_stream *strm); +ZEXTERN int ZEXPORT inflateEnd(z_stream *strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -533,7 +533,7 @@ Z_EXTERN int Z_EXPORT inflateEnd(z_stream *strm); */ /* -Z_EXTERN int Z_EXPORT deflateInit2 (z_stream *strm, +ZEXTERN int ZEXPORT deflateInit2 (z_stream *strm, int level, int method, int windowBits, @@ -605,7 +605,7 @@ Z_EXTERN int Z_EXPORT deflateInit2 (z_stream *strm, compression: this will be done by deflate(). */ -Z_EXTERN int Z_EXPORT deflateSetDictionary(z_stream *strm, +ZEXTERN int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength); /* @@ -649,7 +649,7 @@ Z_EXTERN int Z_EXPORT deflateSetDictionary(z_stream *strm, not perform any compression: this will be done by deflate(). */ -Z_EXTERN int Z_EXPORT deflateGetDictionary (z_stream *strm, unsigned char *dictionary, unsigned int *dictLength); +ZEXTERN int ZEXPORT deflateGetDictionary (z_stream *strm, unsigned char *dictionary, unsigned int *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -669,7 +669,7 @@ Z_EXTERN int Z_EXPORT deflateGetDictionary (z_stream *strm, unsigned char *dicti stream state is inconsistent. */ -Z_EXTERN int Z_EXPORT deflateCopy(z_stream *dest, z_stream *source); +ZEXTERN int ZEXPORT deflateCopy(z_stream *dest, z_stream *source); /* Sets the destination stream as a complete copy of the source stream. @@ -686,7 +686,7 @@ Z_EXTERN int Z_EXPORT deflateCopy(z_stream *dest, z_stream *source); destination. */ -Z_EXTERN int Z_EXPORT deflateReset(z_stream *strm); +ZEXTERN int ZEXPORT deflateReset(z_stream *strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream @@ -697,7 +697,7 @@ Z_EXTERN int Z_EXPORT deflateReset(z_stream *strm); stream state was inconsistent (such as zalloc or state being NULL). */ -Z_EXTERN int Z_EXPORT deflateParams(z_stream *strm, int level, int strategy); +ZEXTERN int ZEXPORT deflateParams(z_stream *strm, int level, int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be @@ -733,7 +733,7 @@ Z_EXTERN int Z_EXPORT deflateParams(z_stream *strm, int level, int strategy); retried with more output space. */ -Z_EXTERN int Z_EXPORT deflateTune(z_stream *strm, int good_length, int max_lazy, int nice_length, int max_chain); +ZEXTERN int ZEXPORT deflateTune(z_stream *strm, int good_length, int max_lazy, int nice_length, int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for @@ -746,7 +746,7 @@ Z_EXTERN int Z_EXPORT deflateTune(z_stream *strm, int good_length, int max_lazy, returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -Z_EXTERN unsigned long Z_EXPORT deflateBound(z_stream *strm, unsigned long sourceLen); +ZEXTERN unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or @@ -760,7 +760,7 @@ Z_EXTERN unsigned long Z_EXPORT deflateBound(z_stream *strm, unsigned long sourc than Z_FINISH or Z_NO_FLUSH are used. */ -Z_EXTERN int Z_EXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits); +ZEXTERN int ZEXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not @@ -773,7 +773,7 @@ Z_EXTERN int Z_EXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bit stream state was inconsistent. */ -Z_EXTERN int Z_EXPORT deflatePrime(z_stream *strm, int bits, int value); +ZEXTERN int ZEXPORT deflatePrime(z_stream *strm, int bits, int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits @@ -788,7 +788,7 @@ Z_EXTERN int Z_EXPORT deflatePrime(z_stream *strm, int bits, int value); source stream state was inconsistent. */ -Z_EXTERN int Z_EXPORT deflateSetHeader(z_stream *strm, gz_headerp head); +ZEXTERN int ZEXPORT deflateSetHeader(z_stream *strm, gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called @@ -812,7 +812,7 @@ Z_EXTERN int Z_EXPORT deflateSetHeader(z_stream *strm, gz_headerp head); */ /* -Z_EXTERN int Z_EXPORT inflateInit2(z_stream *strm, int windowBits); +ZEXTERN int ZEXPORT inflateInit2(z_stream *strm, int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -865,7 +865,7 @@ Z_EXTERN int Z_EXPORT inflateInit2(z_stream *strm, int windowBits); deferred until inflate() is called. */ -Z_EXTERN int Z_EXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength); +ZEXTERN int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, @@ -886,7 +886,7 @@ Z_EXTERN int Z_EXPORT inflateSetDictionary(z_stream *strm, const unsigned char * inflate(). */ -Z_EXTERN int Z_EXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength); +ZEXTERN int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -899,7 +899,7 @@ Z_EXTERN int Z_EXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictio stream state is inconsistent. */ -Z_EXTERN int Z_EXPORT inflateSync(z_stream *strm); +ZEXTERN int ZEXPORT inflateSync(z_stream *strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -918,7 +918,7 @@ Z_EXTERN int Z_EXPORT inflateSync(z_stream *strm); input each time, until success or end of the input data. */ -Z_EXTERN int Z_EXPORT inflateCopy(z_stream *dest, z_stream *source); +ZEXTERN int ZEXPORT inflateCopy(z_stream *dest, z_stream *source); /* Sets the destination stream as a complete copy of the source stream. @@ -933,7 +933,7 @@ Z_EXTERN int Z_EXPORT inflateCopy(z_stream *dest, z_stream *source); destination. */ -Z_EXTERN int Z_EXPORT inflateReset(z_stream *strm); +ZEXTERN int ZEXPORT inflateReset(z_stream *strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The @@ -943,7 +943,7 @@ Z_EXTERN int Z_EXPORT inflateReset(z_stream *strm); stream state was inconsistent (such as zalloc or state being NULL). */ -Z_EXTERN int Z_EXPORT inflateReset2(z_stream *strm, int windowBits); +ZEXTERN int ZEXPORT inflateReset2(z_stream *strm, int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted @@ -956,7 +956,7 @@ Z_EXTERN int Z_EXPORT inflateReset2(z_stream *strm, int windowBits); the windowBits parameter is invalid. */ -Z_EXTERN int Z_EXPORT inflatePrime(z_stream *strm, int bits, int value); +ZEXTERN int ZEXPORT inflatePrime(z_stream *strm, int bits, int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the @@ -975,7 +975,7 @@ Z_EXTERN int Z_EXPORT inflatePrime(z_stream *strm, int bits, int value); stream state was inconsistent. */ -Z_EXTERN long Z_EXPORT inflateMark(z_stream *strm); +ZEXTERN long ZEXPORT inflateMark(z_stream *strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the @@ -1003,7 +1003,7 @@ Z_EXTERN long Z_EXPORT inflateMark(z_stream *strm); source stream state was inconsistent. */ -Z_EXTERN int Z_EXPORT inflateGetHeader(z_stream *strm, gz_headerp head); +ZEXTERN int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after @@ -1043,7 +1043,7 @@ Z_EXTERN int Z_EXPORT inflateGetHeader(z_stream *strm, gz_headerp head); */ /* -Z_EXTERN int Z_EXPORT inflateBackInit (z_stream *strm, int windowBits, unsigned char *window); +ZEXTERN int ZEXPORT inflateBackInit (z_stream *strm, int windowBits, unsigned char *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized @@ -1063,10 +1063,10 @@ Z_EXTERN int Z_EXPORT inflateBackInit (z_stream *strm, int windowBits, unsigned the version of the header file. */ -typedef uint32_t (*in_func) (void *, z_const unsigned char * *); +typedef uint32_t (*in_func) (void *, const unsigned char * *); typedef int (*out_func) (void *, unsigned char *, uint32_t); -Z_EXTERN int Z_EXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc); +ZEXTERN int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than @@ -1134,7 +1134,7 @@ Z_EXTERN int Z_EXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out cannot return Z_OK. */ -Z_EXTERN int Z_EXPORT inflateBackEnd(z_stream *strm); +ZEXTERN int ZEXPORT inflateBackEnd(z_stream *strm); /* All memory allocated by inflateBackInit() is freed. @@ -1142,7 +1142,7 @@ Z_EXTERN int Z_EXPORT inflateBackEnd(z_stream *strm); state was inconsistent. */ -Z_EXTERN unsigned long Z_EXPORT zlibCompileFlags(void); +ZEXTERN unsigned long ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: @@ -1158,7 +1158,7 @@ Z_EXTERN unsigned long Z_EXPORT zlibCompileFlags(void); 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed (not supported by zlib-ng) + 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) @@ -1194,7 +1194,7 @@ Z_EXTERN unsigned long Z_EXPORT zlibCompileFlags(void); you need special options. */ -Z_EXTERN int Z_EXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); +ZEXTERN int ZEXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1208,7 +1208,7 @@ Z_EXTERN int Z_EXPORT compress(unsigned char *dest, unsigned long *destLen, cons buffer. */ -Z_EXTERN int Z_EXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source, +ZEXTERN int ZEXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen, int level); /* Compresses the source buffer into the destination buffer. The level @@ -1223,14 +1223,14 @@ Z_EXTERN int Z_EXPORT compress2(unsigned char *dest, unsigned long *destLen, con Z_STREAM_ERROR if the level parameter is invalid. */ -Z_EXTERN unsigned long Z_EXPORT compressBound(unsigned long sourceLen); +ZEXTERN unsigned long ZEXPORT compressBound(unsigned long sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -Z_EXTERN int Z_EXPORT uncompress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); +ZEXTERN int ZEXPORT uncompress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1248,7 +1248,7 @@ Z_EXTERN int Z_EXPORT uncompress(unsigned char *dest, unsigned long *destLen, co */ -Z_EXTERN int Z_EXPORT uncompress2 (unsigned char *dest, unsigned long *destLen, +ZEXTERN int ZEXPORT uncompress2 (unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the @@ -1269,7 +1269,7 @@ Z_EXTERN int Z_EXPORT uncompress2 (unsigned char *dest, unsigned long *d typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* -Z_EXTERN gzFile Z_EXPORT gzopen(const char *path, const char *mode); +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or @@ -1306,7 +1306,7 @@ Z_EXTERN gzFile Z_EXPORT gzopen(const char *path, const char *mode); file could not be opened. */ -Z_EXTERN gzFile Z_EXPORT gzdopen(int fd, const char *mode); +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* gzdopen associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file @@ -1329,7 +1329,7 @@ Z_EXTERN gzFile Z_EXPORT gzdopen(int fd, const char *mode); will not detect if fd is invalid (unless fd is -1). */ -Z_EXTERN int Z_EXPORT gzbuffer(gzFile file, unsigned size); +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions. The default buffer size is 8192 bytes. This function must be called after @@ -1345,7 +1345,7 @@ Z_EXTERN int Z_EXPORT gzbuffer(gzFile file, unsigned size); too late. */ -Z_EXTERN int Z_EXPORT gzsetparams(gzFile file, int level, int strategy); +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. Previously provided @@ -1356,7 +1356,7 @@ Z_EXTERN int Z_EXPORT gzsetparams(gzFile file, int level, int strategy); or Z_MEM_ERROR if there is a memory allocation error. */ -Z_EXTERN int Z_EXPORT gzread(gzFile file, void *buf, unsigned len); +ZEXTERN int ZEXPORT gzread(gzFile file, void *buf, unsigned len); /* Reads the given number of uncompressed bytes from the compressed file. If the input file is not in gzip format, gzread copies the given number of @@ -1386,7 +1386,7 @@ Z_EXTERN int Z_EXPORT gzread(gzFile file, void *buf, unsigned len); Z_STREAM_ERROR. */ -Z_EXTERN size_t Z_EXPORT gzfread (void *buf, size_t size, size_t nitems, gzFile file); +ZEXTERN size_t ZEXPORT gzfread (void *buf, size_t size, size_t nitems, gzFile file); /* Read up to nitems items of size size from file to buf, otherwise operating as gzread() does. This duplicates the interface of stdio's fread(), with @@ -1409,14 +1409,14 @@ Z_EXTERN size_t Z_EXPORT gzfread (void *buf, size_t size, size_t nitems, gzFile file, reseting and retrying on end-of-file, when size is not 1. */ -Z_EXTERN int Z_EXPORT gzwrite(gzFile file, void const *buf, unsigned len); +ZEXTERN int ZEXPORT gzwrite(gzFile file, void const *buf, unsigned len); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ -Z_EXTERN size_t Z_EXPORT gzfwrite(void const *buf, size_t size, size_t nitems, gzFile file); +ZEXTERN size_t ZEXPORT gzfwrite(void const *buf, size_t size, size_t nitems, gzFile file); /* gzfwrite() writes nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. @@ -1427,7 +1427,7 @@ Z_EXTERN size_t Z_EXPORT gzfwrite(void const *buf, size_t size, size_t nitems, g is returned, and the error state is set to Z_STREAM_ERROR. */ -Z_EXTERN int Z_EXPORTVA gzprintf(gzFile file, const char *format, ...); +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of @@ -1442,7 +1442,7 @@ Z_EXTERN int Z_EXPORTVA gzprintf(gzFile file, const char *format, ...); This can be determined using zlibCompileFlags(). */ -Z_EXTERN int Z_EXPORT gzputs(gzFile file, const char *s); +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. @@ -1450,7 +1450,7 @@ Z_EXTERN int Z_EXPORT gzputs(gzFile file, const char *s); gzputs returns the number of characters written, or -1 in case of error. */ -Z_EXTERN char * Z_EXPORT gzgets(gzFile file, char *buf, int len); +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file @@ -1463,13 +1463,13 @@ Z_EXTERN char * Z_EXPORT gzgets(gzFile file, char *buf, int len); buf are indeterminate. */ -Z_EXTERN int Z_EXPORT gzputc(gzFile file, int c); +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ -Z_EXTERN int Z_EXPORT gzgetc(gzFile file); +ZEXTERN int ZEXPORT gzgetc(gzFile file); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. @@ -1478,7 +1478,7 @@ Z_EXTERN int Z_EXPORT gzgetc(gzFile file); points to has been clobbered or not. */ -Z_EXTERN int Z_EXPORT gzungetc(int c, gzFile file); +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* Push one character back onto the stream to be read as the first character on the next read. At least one character of push-back is allowed. @@ -1490,7 +1490,7 @@ Z_EXTERN int Z_EXPORT gzungetc(int c, gzFile file); gzseek() or gzrewind(). */ -Z_EXTERN int Z_EXPORT gzflush(gzFile file, int flush); +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number @@ -1506,7 +1506,7 @@ Z_EXTERN int Z_EXPORT gzflush(gzFile file, int flush); */ /* -Z_EXTERN z_off_t Z_EXPORT gzseek (gzFile file, z_off_t offset, int whence); +ZEXTERN z_off_t ZEXPORT gzseek (gzFile file, z_off_t offset, int whence); Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the @@ -1524,7 +1524,7 @@ Z_EXTERN z_off_t Z_EXPORT gzseek (gzFile file, z_off_t offset, int whence); would be before the current position. */ -Z_EXTERN int Z_EXPORT gzrewind(gzFile file); +ZEXTERN int ZEXPORT gzrewind(gzFile file); /* Rewinds the given file. This function is supported only for reading. @@ -1532,7 +1532,7 @@ Z_EXTERN int Z_EXPORT gzrewind(gzFile file); */ /* -Z_EXTERN z_off_t Z_EXPORT gztell(gzFile file); +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the @@ -1543,7 +1543,7 @@ Z_EXTERN z_off_t Z_EXPORT gztell(gzFile file); */ /* -Z_EXTERN z_off_t Z_EXPORT gzoffset(gzFile file); +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); Returns the current offset in the file being read or written. This offset includes the count of bytes that precede the gzip stream, for example when @@ -1552,7 +1552,7 @@ Z_EXTERN z_off_t Z_EXPORT gzoffset(gzFile file); for a progress indicator. On error, gzoffset() returns -1. */ -Z_EXTERN int Z_EXPORT gzeof(gzFile file); +ZEXTERN int ZEXPORT gzeof(gzFile file); /* Returns true (1) if the end-of-file indicator has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set only if the @@ -1567,7 +1567,7 @@ Z_EXTERN int Z_EXPORT gzeof(gzFile file); has grown since the previous end of file was detected. */ -Z_EXTERN int Z_EXPORT gzdirect(gzFile file); +ZEXTERN int ZEXPORT gzdirect(gzFile file); /* Returns true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. @@ -1588,7 +1588,7 @@ Z_EXTERN int Z_EXPORT gzdirect(gzFile file); gzip file reading and decompression, which may not be desired.) */ -Z_EXTERN int Z_EXPORT gzclose(gzFile file); +ZEXTERN int ZEXPORT gzclose(gzFile file); /* Flushes all pending output if necessary, closes the compressed file and deallocates the (de)compression state. Note that once file is closed, you @@ -1601,8 +1601,8 @@ Z_EXTERN int Z_EXPORT gzclose(gzFile file); last read ended in the middle of a gzip stream, or Z_OK on success. */ -Z_EXTERN int Z_EXPORT gzclose_r(gzFile file); -Z_EXTERN int Z_EXPORT gzclose_w(gzFile file); +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to @@ -1613,7 +1613,7 @@ Z_EXTERN int Z_EXPORT gzclose_w(gzFile file); zlib library. */ -Z_EXTERN const char * Z_EXPORT gzerror(gzFile file, int *errnum); +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred @@ -1629,7 +1629,7 @@ Z_EXTERN const char * Z_EXPORT gzerror(gzFile file, int *errnum); functions above that do not distinguish those cases in their return values. */ -Z_EXTERN void Z_EXPORT gzclearerr(gzFile file); +ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* Clears the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip @@ -1645,7 +1645,7 @@ Z_EXTERN void Z_EXPORT gzclearerr(gzFile file); library. */ -Z_EXTERN unsigned long Z_EXPORT adler32(unsigned long adler, const unsigned char *buf, unsigned int len); +ZEXTERN uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint32_t len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the @@ -1664,13 +1664,13 @@ Z_EXTERN unsigned long Z_EXPORT adler32(unsigned long adler, const unsigned char if (adler != original_adler) error(); */ -Z_EXTERN unsigned long Z_EXPORT adler32_z(unsigned long adler, const unsigned char *buf, size_t len); +ZEXTERN uint32_t ZEXPORT adler32_z (uint32_t adler, const unsigned char *buf, size_t len); /* Same as adler32(), but with a size_t length. */ /* -Z_EXTERN unsigned long Z_EXPORT adler32_combine(unsigned long adler1, unsigned long adler2, z_off_t len2); +ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t adler1, uint32_t adler2, z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for @@ -1680,7 +1680,7 @@ Z_EXTERN unsigned long Z_EXPORT adler32_combine(unsigned long adler1, unsigned l negative, the result has no meaning or utility. */ -Z_EXTERN unsigned long Z_EXPORT crc32(unsigned long crc, const unsigned char *buf, unsigned int len); +ZEXTERN uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, uint32_t len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is NULL, this function returns the required @@ -1697,13 +1697,13 @@ Z_EXTERN unsigned long Z_EXPORT crc32(unsigned long crc, const unsigned char *bu if (crc != original_crc) error(); */ -Z_EXTERN unsigned long Z_EXPORT crc32_z(unsigned long crc, const unsigned char *buf, size_t len); +ZEXTERN uint32_t ZEXPORT crc32_z (uint32_t crc, const unsigned char *buf, size_t len); /* Same as crc32(), but with a size_t length. */ /* -Z_EXTERN unsigned long Z_EXPORT crc32_combine(unsigned long crc1, unsigned long crc2, z_off64_t len2); +ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were @@ -1713,14 +1713,14 @@ Z_EXTERN unsigned long Z_EXPORT crc32_combine(unsigned long crc1, unsigned long */ /* -Z_EXTERN void Z_EXPORT crc32_combine_gen(uint32_t op[32], z_off_t len2); +ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t op[32], z_off_t len2); Generate the operator op corresponding to length len2, to be used with crc32_combine_op(). op must have room for 32 z_crc_t values. (32 is the number of bits in the CRC.) */ -Z_EXTERN uint32_t Z_EXPORT crc32_combine_op(uint32_t crc1, uint32_t crc2, +ZEXTERN uint32_t ZEXPORT crc32_combine_op(uint32_t crc1, uint32_t crc2, const uint32_t *op); /* Give the same result as crc32_combine(), using op in place of len2. op is @@ -1734,12 +1734,12 @@ Z_EXTERN uint32_t Z_EXPORT crc32_combine_op(uint32_t crc1, uint32_t crc2, /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -Z_EXTERN int Z_EXPORT deflateInit_(z_stream *strm, int level, const char *version, int stream_size); -Z_EXTERN int Z_EXPORT inflateInit_(z_stream *strm, const char *version, int stream_size); -Z_EXTERN int Z_EXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, int memLevel, +ZEXTERN int ZEXPORT deflateInit_(z_stream *strm, int level, const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_stream *strm, const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size); -Z_EXTERN int Z_EXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version, int stream_size); -Z_EXTERN int Z_EXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *window, +ZEXTERN int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *window, const char *version, int stream_size); #define deflateInit(strm, level) deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) #define inflateInit(strm) inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) @@ -1763,7 +1763,7 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -Z_EXTERN int Z_EXPORT gzgetc_(gzFile file); /* backward compatibility */ +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ # define gzgetc(g) ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or @@ -1773,13 +1773,10 @@ Z_EXTERN int Z_EXPORT gzgetc_(gzFile file); /* backward compatibility */ * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 - Z_EXTERN gzFile Z_EXPORT gzopen64(const char *, const char *); - Z_EXTERN z_off64_t Z_EXPORT gzseek64(gzFile, z_off64_t, int); - Z_EXTERN z_off64_t Z_EXPORT gztell64(gzFile); - Z_EXTERN z_off64_t Z_EXPORT gzoffset64(gzFile); - Z_EXTERN unsigned long Z_EXPORT adler32_combine64(unsigned long, unsigned long, z_off64_t); - Z_EXTERN unsigned long Z_EXPORT crc32_combine64(unsigned long, unsigned long, z_off64_t); - Z_EXTERN void Z_EXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) @@ -1787,42 +1784,62 @@ Z_EXTERN int Z_EXPORT gzgetc_(gzFile file); /* backward compatibility */ # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); +#endif + + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 # define crc32_combine_gen crc32_combine_gen64 # ifndef Z_LARGE64 - Z_EXTERN gzFile Z_EXPORT gzopen64(const char *, const char *); - Z_EXTERN z_off_t Z_EXPORT gzseek64(gzFile, z_off_t, int); - Z_EXTERN z_off_t Z_EXPORT gztell64(gzFile); - Z_EXTERN z_off_t Z_EXPORT gzoffset64(gzFile); - Z_EXTERN unsigned long Z_EXPORT adler32_combine64(unsigned long, unsigned long, z_off_t); - Z_EXTERN unsigned long Z_EXPORT crc32_combine64(unsigned long, unsigned long, z_off_t); - Z_EXTERN void Z_EXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); + ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); # endif #else - Z_EXTERN gzFile Z_EXPORT gzopen(const char *, const char *); - Z_EXTERN z_off_t Z_EXPORT gzseek(gzFile, z_off_t, int); - Z_EXTERN z_off_t Z_EXPORT gztell(gzFile); - Z_EXTERN z_off_t Z_EXPORT gzoffset(gzFile); - Z_EXTERN unsigned long Z_EXPORT adler32_combine(unsigned long, unsigned long, z_off_t); - Z_EXTERN unsigned long Z_EXPORT crc32_combine(unsigned long, unsigned long, z_off_t); - Z_EXTERN void Z_EXPORT crc32_combine_gen(uint32_t *op, z_off_t); + ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t, uint32_t, z_off_t); + ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t *op, z_off_t); #endif + /* undocumented functions */ -Z_EXTERN const char * Z_EXPORT zError (int); -Z_EXTERN int Z_EXPORT inflateSyncPoint (z_stream *); -Z_EXTERN const uint32_t * Z_EXPORT get_crc_table (void); -Z_EXTERN int Z_EXPORT inflateUndermine (z_stream *, int); -Z_EXTERN int Z_EXPORT inflateValidate (z_stream *, int); -Z_EXTERN unsigned long Z_EXPORT inflateCodesUsed (z_stream *); -Z_EXTERN int Z_EXPORT inflateResetKeep (z_stream *); -Z_EXTERN int Z_EXPORT deflateResetKeep (z_stream *); +ZEXTERN const char * ZEXPORT zError (int); +ZEXTERN int ZEXPORT inflateSyncPoint (z_stream *); +ZEXTERN const uint32_t * ZEXPORT get_crc_table (void); +ZEXTERN int ZEXPORT inflateUndermine (z_stream *, int); +ZEXTERN int ZEXPORT inflateValidate (z_stream *, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed (z_stream *); +ZEXTERN int ZEXPORT inflateResetKeep (z_stream *); +ZEXTERN int ZEXPORT deflateResetKeep (z_stream *); -#if defined(_WIN32) - Z_EXTERN gzFile Z_EXPORT gzopen_w(const wchar_t *path, const char *mode); +#if (defined(WIN32) || defined(__MINGW__)) + ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode); #endif -Z_EXTERN int Z_EXPORTVA gzvprintf(gzFile file, const char *format, va_list va); +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va); #ifdef __cplusplus } diff --git a/libs/zlibng/zlib.map b/libs/zlibng/zlib.map index f608f2bd5..28436d47e 100644 --- a/libs/zlibng/zlib.map +++ b/libs/zlibng/zlib.map @@ -91,10 +91,6 @@ ZLIB_1.2.9 { deflateGetDictionary; adler32_z; crc32_z; -} ZLIB_1.2.7.1; - -ZLIB_1.2.12 { crc32_combine_gen; - crc32_combine_gen64; crc32_combine_op; -} ZLIB_1.2.9; +} ZLIB_1.2.7.1; diff --git a/libs/zlibng/zlib.pc.cmakein b/libs/zlibng/zlib.pc.cmakein index 9b64252dc..0635b6e35 100644 --- a/libs/zlibng/zlib.pc.cmakein +++ b/libs/zlibng/zlib.pc.cmakein @@ -1,12 +1,12 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=@PC_LIB_INSTALL_DIR@ -sharedlibdir=${libdir} -includedir=@PC_INC_INSTALL_DIR@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@INSTALL_LIB_DIR@ +sharedlibdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ Name: zlib@SUFFIX@ Description: zlib-ng compression library -Version: @ZLIB_FULL_VERSION@ +Version: @zlib_VERSION@ Requires: Libs: -L${libdir} -L${sharedlibdir} -lz@SUFFIX@ diff --git a/libs/zlibng/zutil.c b/libs/zlibng/zutil.c index ba36e93f9..4373586bd 100644 --- a/libs/zlibng/zutil.c +++ b/libs/zlibng/zutil.c @@ -3,37 +3,47 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +/* @(#) $Id$ */ + #include "zbuild.h" #include "zutil.h" -#include "zutil_p.h" +#ifdef WITH_GZFILEOP +# include "gzguts.h" +#endif +#ifndef UNALIGNED_OK +# include "malloc.h" +#endif -z_const char * const PREFIX(z_errmsg)[10] = { - (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ - (z_const char *)"stream end", /* Z_STREAM_END 1 */ - (z_const char *)"", /* Z_OK 0 */ - (z_const char *)"file error", /* Z_ERRNO (-1) */ - (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ - (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ - (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ - (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ - (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ - (z_const char *)"" +const char * const z_errmsg[10] = { + (const char *)"need dictionary", /* Z_NEED_DICT 2 */ + (const char *)"stream end", /* Z_STREAM_END 1 */ + (const char *)"", /* Z_OK 0 */ + (const char *)"file error", /* Z_ERRNO (-1) */ + (const char *)"stream error", /* Z_STREAM_ERROR (-2) */ + (const char *)"data error", /* Z_DATA_ERROR (-3) */ + (const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ + (const char *)"buffer error", /* Z_BUF_ERROR (-5) */ + (const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ + (const char *)"" }; const char zlibng_string[] = - " zlib-ng 2.0.0-RC2 forked from zlib"; + " zlib-ng 1.9.9 forked from zlib 1.2.11 "; #ifdef ZLIB_COMPAT -const char * Z_EXPORT zlibVersion(void) { +const char * ZEXPORT zlibVersion(void) +{ return ZLIB_VERSION; } #endif -const char * Z_EXPORT zlibng_version(void) { +const char * ZEXPORT zlibng_version(void) +{ return ZLIBNG_VERSION; } -unsigned long Z_EXPORT PREFIX(zlibCompileFlags)(void) { +unsigned long ZEXPORT PREFIX(zlibCompileFlags)(void) +{ unsigned long flags; flags = 0; @@ -67,7 +77,12 @@ unsigned long Z_EXPORT PREFIX(zlibCompileFlags)(void) { #ifdef ZLIB_WINAPI flags += 1 << 10; #endif - /* Bit 13 reserved for DYNAMIC_CRC_TABLE */ +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif #ifdef NO_GZCOMPRESS flags += 1L << 16; #endif @@ -81,13 +96,15 @@ unsigned long Z_EXPORT PREFIX(zlibCompileFlags)(void) { } #ifdef ZLIB_DEBUG -# include +#include # ifndef verbose # define verbose 0 # endif -int Z_INTERNAL z_verbose = verbose; +int ZLIB_INTERNAL z_verbose = verbose; -void Z_INTERNAL z_error(char *m) { +void ZLIB_INTERNAL z_error (m) + char *m; +{ fprintf(stderr, "%s\n", m); exit(1); } @@ -96,16 +113,28 @@ void Z_INTERNAL z_error(char *m) { /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * Z_EXPORT PREFIX(zError)(int err) { +const char * ZEXPORT PREFIX(zError)(int err) +{ return ERR_MSG(err); } -void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size) { +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size) +{ (void)opaque; - return zng_alloc((size_t)items * (size_t)size); +#ifndef UNALIGNED_OK + return memalign(16, items * size); +#else + return sizeof(unsigned int) > 2 ? (void *)malloc(items * size) : + (void *)calloc(items, size); +#endif } -void Z_INTERNAL zng_cfree(void *opaque, void *ptr) { +void ZLIB_INTERNAL zcfree (void *opaque, void *ptr) +{ (void)opaque; - zng_free(ptr); + free(ptr); } + +#endif /* MY_ZCALLOC */ diff --git a/libs/zlibng/zutil.h b/libs/zlibng/zutil.h index 497cb22b4..8d8ae92ee 100644 --- a/libs/zlibng/zutil.h +++ b/libs/zlibng/zutil.h @@ -10,22 +10,14 @@ subject to change. Applications should only use zlib.h. */ -#if defined(HAVE_VISIBILITY_INTERNAL) -# define Z_INTERNAL __attribute__((visibility ("internal"))) -#elif defined(HAVE_VISIBILITY_HIDDEN) -# define Z_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define Z_INTERNAL -#endif +/* @(#) $Id$ */ -#ifndef __cplusplus -# define Z_REGISTER register +#if defined(HAVE_INTERNAL) +# define ZLIB_INTERNAL __attribute__((visibility ("internal"))) +#elif defined(HAVE_HIDDEN) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else -# define Z_REGISTER -#endif - -#ifndef Z_TLS -# define Z_TLS +# define ZLIB_INTERNAL #endif #include @@ -33,20 +25,19 @@ #include #include #ifdef ZLIB_COMPAT -# include "zlib.h" +# include "zlib.h" #else -# include "zlib-ng.h" +# include "zlib-ng.h" #endif -#include "zbuild.h" typedef unsigned char uch; /* Included for compatibility with external code only */ typedef uint16_t ush; /* Included for compatibility with external code only */ -typedef unsigned long ulg; +typedef unsigned long ulg; -extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) PREFIX(z_errmsg)[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ @@ -76,8 +67,6 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ -#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */ - /* target dependencies */ #ifdef AMIGA @@ -100,6 +89,9 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ #ifdef OS2 # define OS_CODE 6 +# if defined(M_I86) && !defined(Z_SOLO) +# include +# endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) @@ -110,7 +102,7 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ # define OS_CODE 13 #endif -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) # define OS_CODE 10 #endif @@ -122,9 +114,16 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ # define fdopen(fd, type) _fdopen(fd, type) #endif +/* provide prototypes for these when building zlib without LFS */ +#if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) +# include "zbuild.h" /* For PREFIX() */ + ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t); +#endif + /* MS Visual Studio does not allow inline in C, only C++. But it provides __inline instead, so use that. */ -#if defined(_MSC_VER) && !defined(inline) && !defined(__cplusplus) +#if defined(_MSC_VER) && !defined(inline) # define inline __inline #endif @@ -132,47 +131,51 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */ #ifndef OS_CODE # define OS_CODE 3 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ /* Diagnostic functions */ #ifdef ZLIB_DEBUG -# include - extern int Z_INTERNAL z_verbose; - extern void Z_INTERNAL z_error(char *m); -# define Assert(cond, msg) {if (!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose >= 0) fprintf x;} -# define Tracev(x) {if (z_verbose > 0) fprintf x;} -# define Tracevv(x) {if (z_verbose > 1) fprintf x;} -# define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;} -# define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;} +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error(char *m); +# define Assert(cond, msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose >= 0) fprintf x;} +# define Tracev(x) {if (z_verbose > 0) fprintf x;} +# define Tracevv(x) {if (z_verbose > 1) fprintf x;} +# define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;} +# define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;} #else -# define Assert(cond, msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c, x) -# define Tracecv(c, x) +# define Assert(cond, msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c, x) +# define Tracecv(c, x) #endif -void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size); -void Z_INTERNAL zng_cfree(void *opaque, void *ptr); +void ZLIB_INTERNAL *zcalloc(void *opaque, unsigned items, unsigned size); +void ZLIB_INTERNAL zcfree(void *opaque, void *ptr); #define ZALLOC(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (void *)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} /* Reverse the bytes in a value. Use compiler intrinsics when possible to take advantage of hardware implementations. */ -#if defined(_MSC_VER) && (_MSC_VER >= 1300) +#if defined(WIN32) && (_MSC_VER >= 1300) # pragma intrinsic(_byteswap_ulong) # define ZSWAP16(q) _byteswap_ushort(q) # define ZSWAP32(q) _byteswap_ulong(q) # define ZSWAP64(q) _byteswap_uint64(q) #elif defined(__Clang__) || (defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))) # define ZSWAP16(q) __builtin_bswap16(q) # define ZSWAP32(q) __builtin_bswap32(q) # define ZSWAP64(q) __builtin_bswap64(q) @@ -198,7 +201,7 @@ void Z_INTERNAL zng_cfree(void *opaque, void *ptr); #else # define ZSWAP16(q) ((((q) & 0xff) << 8) | (((q) & 0xff00) >> 8)) # define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) # define ZSWAP64(q) \ ((q & 0xFF00000000000000u) >> 56u) | \ ((q & 0x00FF000000000000u) >> 40u) | \ @@ -212,43 +215,33 @@ void Z_INTERNAL zng_cfree(void *opaque, void *ptr); /* Only enable likely/unlikely if the compiler is known to support it */ #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__INTEL_COMPILER) || defined(__Clang__) -# define LIKELY_NULL(x) __builtin_expect((x) != 0, 0) -# define LIKELY(x) __builtin_expect(!!(x), 1) -# define UNLIKELY(x) __builtin_expect(!!(x), 0) -# define PREFETCH_L1(addr) __builtin_prefetch(addr, 0, 3) -# define PREFETCH_L2(addr) __builtin_prefetch(addr, 0, 2) -# define PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 2) -#elif defined(__WIN__) -# include -# define LIKELY_NULL(x) x -# define LIKELY(x) x -# define UNLIKELY(x) x -# define PREFETCH_L1(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) -# define PREFETCH_L2(addr) _mm_prefetch((char *) addr, _MM_HINT_T1) -# define PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T1) +# ifndef likely +# define likely(x) __builtin_expect(!!(x), 1) +# endif +# ifndef unlikely +# define unlikely(x) __builtin_expect(!!(x), 0) +# endif #else -# define LIKELY_NULL(x) x -# define LIKELY(x) x -# define UNLIKELY(x) x -# define PREFETCH_L1(addr) addr -# define PREFETCH_L2(addr) addr -# define PREFETCH_RW(addr) addr +# ifndef likely +# define likely(x) x +# endif +# ifndef unlikely +# define unlikely(x) x +# endif #endif /* (un)likely */ #if defined(_MSC_VER) -# define ALIGNED_(x) __declspec(align(x)) +#define ALIGNED_(x) __declspec(align(x)) #else -# if defined(__GNUC__) -# define ALIGNED_(x) __attribute__ ((aligned(x))) -# endif +#if defined(__GNUC__) +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif #endif -#if defined(X86_FEATURES) -# include "arch/x86/x86.h" -#elif defined(ARM_FEATURES) -# include "arch/arm/arm.h" -#elif defined(POWER_FEATURES) -# include "arch/power/power.h" +#if defined(X86_CPUID) +# include "arch/x86/x86.h" +#elif defined(__aarch64__) || defined(__arm__) || defined(_M_ARM) +# include "arch/arm/arm.h" #endif #endif /* ZUTIL_H_ */ diff --git a/libs/zlibng/zutil_p.h b/libs/zlibng/zutil_p.h deleted file mode 100644 index a5f2e525d..000000000 --- a/libs/zlibng/zutil_p.h +++ /dev/null @@ -1,34 +0,0 @@ -/* zutil_p.h -- Private inline functions used internally in zlib-ng - * - */ - -#ifndef ZUTIL_P_H -#define ZUTIL_P_H - -#ifdef __APPLE__ -# include -#else -# include -#endif - -/* Function to allocate 16 or 64-byte aligned memory */ -static inline void *zng_alloc(size_t size) { -#if defined(_WIN32) - return (void *)_aligned_malloc(size, 64); -#elif defined(__APPLE__) - return (void *)malloc(size); /* MacOS always aligns to 16 bytes */ -#else - return (void *)memalign(64, size); -#endif -} - -/* Function that can free aligned memory */ -static inline void zng_free(void *ptr) { -#if defined(_WIN32) - _aligned_free(ptr); -#else - free(ptr); -#endif -} - -#endif diff --git a/loginserver/server_manager.cpp b/loginserver/server_manager.cpp index 1761e1b15..5cd01a8f9 100644 --- a/loginserver/server_manager.cpp +++ b/loginserver/server_manager.cpp @@ -33,7 +33,7 @@ ServerManager::ServerManager() { int listen_port = server.config.GetVariableInt("general", "listen_port", 5998); - server_connection = std::make_unique(); + server_connection.reset(new EQ::Net::ServertalkServer()); EQ::Net::ServertalkServerOptions opts; opts.port = listen_port; opts.ipv6 = false; @@ -68,7 +68,7 @@ ServerManager::ServerManager() ++iter; } - world_servers.push_back(std::make_unique(world_connection)); + world_servers.push_back(std::unique_ptr(new WorldServer(world_connection))); } ); diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index 43846af32..765c108da 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -72,7 +72,7 @@ WorldServer::WorldServer(std::shared_ptr wo std::bind(&WorldServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2) ); - m_keepalive = std::make_unique(5000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1)); + m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); } WorldServer::~WorldServer() = default; @@ -1317,4 +1317,4 @@ void WorldServer::OnKeepAlive(EQ::Timer *t) { ServerPacket pack(ServerOP_KeepAlive, 0); connection->SendPacket(&pack); -} +} \ No newline at end of file diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index 1c65b92fd..ec34ce7bb 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -52,7 +52,7 @@ WorldServer::~WorldServer() void WorldServer::Connect() { - m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey); + m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey)); m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); } @@ -185,4 +185,4 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } } -} +} \ No newline at end of file diff --git a/tests/string_util_test.h b/tests/string_util_test.h index 1fdd325f9..facb0cc72 100644 --- a/tests/string_util_test.h +++ b/tests/string_util_test.h @@ -29,8 +29,6 @@ public: TEST_ADD(StringUtilTest::StringFormatTest); TEST_ADD(StringUtilTest::EscapeStringTest); TEST_ADD(StringUtilTest::EscapeStringMemoryTest); - TEST_ADD(StringUtilTest::SearchDeliminatedStringTest); - TEST_ADD(StringUtilTest::SplitStringTest); } ~StringUtilTest() { @@ -82,42 +80,6 @@ public: auto s = EscapeString(t, 10); TEST_ASSERT(s.compare("abc\\x00\\n\\r\\\\\\'\\\"\\x1a") == 0); } - - void SearchDeliminatedStringTest() { - std::string h = - "befallen,charasis,dalnir,frontiermtns,gukbottom,iceclad,lakeofillomen,northkarana,qey2hh1,soldunga,southro,wakening,podisease,velketor,akheva,riwwi,bothunder,poair"; - TEST_ASSERT(search_deliminated_string(h, "befallen") == 0); - TEST_ASSERT(search_deliminated_string(h, "charasis") == 9); - TEST_ASSERT(search_deliminated_string(h, "dalnir") == 18); - TEST_ASSERT(search_deliminated_string(h, "frontiermtns") == 25); - TEST_ASSERT(search_deliminated_string(h, "gukbottom") == 38); - TEST_ASSERT(search_deliminated_string(h, "iceclad") == 48); - TEST_ASSERT(search_deliminated_string(h, "lakeofillomen") == 56); - TEST_ASSERT(search_deliminated_string(h, "northkarana") == 70); - TEST_ASSERT(search_deliminated_string(h, "qey2hh1") == 82); - TEST_ASSERT(search_deliminated_string(h, "soldunga") == 90); - TEST_ASSERT(search_deliminated_string(h, "southro") == 99); - TEST_ASSERT(search_deliminated_string(h, "wakening") == 107); - TEST_ASSERT(search_deliminated_string(h, "podisease") == 116); - TEST_ASSERT(search_deliminated_string(h, "velketor") == 126); - TEST_ASSERT(search_deliminated_string(h, "akheva") == 135); - TEST_ASSERT(search_deliminated_string(h, "riwwi") == 142); - TEST_ASSERT(search_deliminated_string(h, "bothunder") == 148); - TEST_ASSERT(search_deliminated_string(h, "poair") == 158); - TEST_ASSERT(search_deliminated_string(h, "pod") == std::string::npos); - TEST_ASSERT(search_deliminated_string(h, "air") == std::string::npos); - TEST_ASSERT(search_deliminated_string(h, "bef") == std::string::npos); - TEST_ASSERT(search_deliminated_string(h, "wwi") == std::string::npos); - } - - void SplitStringTest() { - std::string s = "123,456,789,"; - auto v = SplitString(s, ','); - TEST_ASSERT(v.size() == 3); - TEST_ASSERT(v[0] == "123"); - TEST_ASSERT(v[1] == "456"); - TEST_ASSERT(v[2] == "789"); - } }; #endif diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 18f18a276..2d5d40fb9 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -65,10 +65,14 @@ void Client::SendUptime() { ms -= m * 60000; uint32 s = ms / 1000; - auto message = fmt::format("UCS has been up for {:02}d {:02}h {:02}m {:02}s", d, h, m, s); - GeneralChannelMessage(message); - message = fmt::format("Chat Messages Sent: {}, Mail Messages Sent: {}", ChatMessagesSent, MailMessagesSent); - GeneralChannelMessage(message); + char *Buffer = nullptr; + + MakeAnyLenString(&Buffer, "UCS has been up for %02id %02ih %02im %02is", d, h, m, s); + GeneralChannelMessage(Buffer); + safe_delete_array(Buffer); + MakeAnyLenString(&Buffer, "Chat Messages Sent: %i, Mail Messages Sent: %i", ChatMessagesSent, MailMessagesSent); + GeneralChannelMessage(Buffer); + safe_delete_array(Buffer); } std::vector ParseRecipients(std::string RecipientString) { diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp index 64bdfc2a7..88cff5afd 100644 --- a/ucs/worldserver.cpp +++ b/ucs/worldserver.cpp @@ -48,7 +48,7 @@ void Client55ToServerSayLink(std::string& serverSayLink, const std::string& clie WorldServer::WorldServer() { - m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey); + m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey)); m_connection->OnMessage(std::bind(&WorldServer::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2)); } diff --git a/utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h b/utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h index 3cfd276d6..e732757a4 100644 --- a/utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h +++ b/utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h @@ -720,7 +720,7 @@ struct RaidLeadershipAA_Struct { * Size: 20 Octets */ struct BindStruct { - /*000*/ uint32 zone_id; + /*000*/ uint32 zoneId; /*004*/ float x; /*008*/ float y; /*012*/ float z; @@ -1486,7 +1486,7 @@ struct GMZoneRequest_Struct { /*0068*/ float x; /*0072*/ float y; /*0076*/ float z; -/*0080*/ float heading; +/*0080*/ char unknown0080[4]; /*0084*/ int32 success; // 0 if command failed, 1 if succeeded? /*0088*/ // /*072*/ sint8 success; // =0 client->server, =1 server->client, -X=specific error diff --git a/utils/patches/patch_RoF.conf b/utils/patches/patch_RoF.conf index 76178bf62..31b091ff8 100644 --- a/utils/patches/patch_RoF.conf +++ b/utils/patches/patch_RoF.conf @@ -366,7 +366,6 @@ OP_CancelSneakHide=0x265f OP_AggroMeterLockTarget=0x70b7 OP_AggroMeterTargetInfo=0x18fe OP_AggroMeterUpdate=0x75aa -OP_UnderWorld=0x44f9 # clients sends up when they detect an underworld issue, might be useful for cheat detection OP_DzQuit=0x5fc8 OP_DzListTimers=0x67b9 @@ -375,18 +374,16 @@ OP_DzRemovePlayer=0x0dc1 OP_DzSwapPlayer=0x4995 OP_DzMakeLeader=0x17b2 OP_DzPlayerList=0x1aff -OP_DzExpeditionInvite=0x30df -OP_DzExpeditionInviteResponse=0x15d4 +OP_DzJoinExpeditionConfirm=0x30df +OP_DzJoinExpeditionReply=0x15d4 OP_DzExpeditionInfo=0x3861 -OP_DzExpeditionLockoutTimers=0x0b3b -OP_DzMemberList=0x348f -OP_DzMemberListName=0x26c2 -OP_DzMemberListStatus=0x0000 -OP_DzSetLeaderName=0x4021 +OP_DzExpeditionList=0x0b3b +OP_DzMemberStatus=0x26c2 +OP_DzLeaderStatus=0x4021 OP_DzExpeditionEndsWarning=0x32eb +OP_DzMemberList=0x348f OP_DzCompass=0x0e01 # Was 0x4f09 OP_DzChooseZone=0x6e5e # Maybe 0x29d6 -OP_DzChooseZoneReply=0x0000 # New Opcodes OP_SpawnPositionUpdate=0x0000 # Actually OP_MobUpdate ? diff --git a/utils/patches/patch_RoF2.conf b/utils/patches/patch_RoF2.conf index 96f3258a8..a39fde999 100644 --- a/utils/patches/patch_RoF2.conf +++ b/utils/patches/patch_RoF2.conf @@ -367,29 +367,25 @@ OP_CancelSneakHide=0x0927 OP_AggroMeterLockTarget=0x1643 OP_AggroMeterTargetInfo=0x16bc OP_AggroMeterUpdate=0x1781 -OP_UnderWorld=0x2eb3 # clients sends up when they detect an underworld issue, might be useful for cheat detection -OP_KickPlayers=0x6770 # Expeditions -OP_DzQuit=0xb2e3 -OP_DzListTimers=0x7b68 OP_DzAddPlayer=0x4701 OP_DzRemovePlayer=0x1abc OP_DzSwapPlayer=0x405b OP_DzMakeLeader=0x543d OP_DzPlayerList=0x14c6 -OP_DzExpeditionInvite=0x7f4b -OP_DzExpeditionInviteResponse=0x1950 +OP_DzJoinExpeditionConfirm=0x7f4b +OP_DzJoinExpeditionReply=0x1950 +OP_DzListTimers=0x7b68 OP_DzExpeditionInfo=0x9119 -OP_DzExpeditionLockoutTimers=0x205f +OP_DzExpeditionList=0x205f +OP_DzQuit=0xb2e3 +OP_DzMemberStatus=0x32f0 +OP_DzLeaderStatus=0x3de9 OP_DzMemberList=0x5ae4 -OP_DzMemberListName=0x32f0 -OP_DzMemberListStatus=0x12F5 -OP_DzSetLeaderName=0x3de9 -OP_DzExpeditionEndsWarning=0x5189 +OP_DzExpeditionEndsWarning=0x383c OP_DzCompass=0x3e0e OP_DzChooseZone=0x0b7d -OP_DzChooseZoneReply=0x4de1 # New Opcodes OP_SpawnPositionUpdate=0x0000 # Actually OP_MobUpdate ? diff --git a/utils/patches/patch_SoD.conf b/utils/patches/patch_SoD.conf index 1ef8a138a..619f986c1 100644 --- a/utils/patches/patch_SoD.conf +++ b/utils/patches/patch_SoD.conf @@ -357,7 +357,6 @@ OP_OpenContainer=0x3278 OP_Marquee=0x7dc9 OP_Fling=0x2b88 OP_CancelSneakHide=0x7705 -OP_UnderWorld=0x51ae # clients sends up when they detect an underworld issue, might be useful for cheat detection # Expedition OP_DzQuit=0x054e @@ -367,18 +366,17 @@ OP_DzRemovePlayer=0xa682 OP_DzSwapPlayer=0x0d8d OP_DzMakeLeader=0x1caa OP_DzPlayerList=0x74ca -OP_DzExpeditionInvite=0x1772 -OP_DzExpeditionInviteResponse=0x3c13 +OP_DzJoinExpeditionConfirm=0x1772 +OP_DzJoinExpeditionReply=0x3c13 OP_DzExpeditionInfo=0x128e -OP_DzExpeditionLockoutTimers=0x3657 -OP_DzMemberList=0x74e4 -OP_DzMemberListName=0x4661 -OP_DzMemberListStatus=0x1d99 -OP_DzSetLeaderName=0x226f +OP_DzMemberStatus=0x4661 +OP_DzLeaderStatus=0x226f OP_DzExpeditionEndsWarning=0x1879 +OP_DzExpeditionList=0x3657 +OP_DzMemberList=0x74e4 OP_DzCompass=0x35d3 OP_DzChooseZone=0x0d8a -OP_DzChooseZoneReply=0x5a67 +#0x1d99 was grouped with these too but I don't really know it's purpose. # New Opcodes OP_SpawnPositionUpdate=0x4656 # diff --git a/utils/patches/patch_SoF.conf b/utils/patches/patch_SoF.conf index 1c5fd3eda..6a5d41fb4 100644 --- a/utils/patches/patch_SoF.conf +++ b/utils/patches/patch_SoF.conf @@ -338,7 +338,6 @@ OP_OpenContainer=0x10e3 OP_Marquee=0x2f75 OP_Untargetable=0x3e36 OP_CancelSneakHide=0x5335 -OP_UnderWorld=0x7580 # clients sends up when they detect an underworld issue, might be useful for cheat detection #expedition OP_DzQuit=0x20d6 @@ -348,18 +347,16 @@ OP_DzRemovePlayer=0x2ce8 OP_DzSwapPlayer=0x2c3e OP_DzMakeLeader=0x1a75 OP_DzPlayerList=0x5116 -OP_DzExpeditionInvite=0x1793 -OP_DzExpeditionInviteResponse=0x7a6f +OP_DzJoinExpeditionConfirm=0x1793 +OP_DzJoinExpeditionReply=0x7a6f OP_DzExpeditionInfo=0x60a6 -OP_DzExpeditionLockoutTimers=0x02ac -OP_DzMemberList=0x5e14 -OP_DzMemberListName=0x0516 -OP_DzMemberListStatus=0x0000 -OP_DzSetLeaderName=0x79d3 +OP_DzMemberStatus=0x0516 +OP_DzLeaderStatus=0x79d3 OP_DzExpeditionEndsWarning=0x5153 +OP_DzExpeditionList=0x02ac +OP_DzMemberList=0x5e14 OP_DzCompass=0x531d OP_DzChooseZone=0x3c5b -OP_DzChooseZoneReply=0x0000 #Looting OP_LootRequest=0x36E3 #Trevius 02/16/09 diff --git a/utils/patches/patch_Titanium.conf b/utils/patches/patch_Titanium.conf index 32d434e93..9a7e1e800 100644 --- a/utils/patches/patch_Titanium.conf +++ b/utils/patches/patch_Titanium.conf @@ -297,18 +297,17 @@ OP_DzRemovePlayer=0x540b OP_DzSwapPlayer=0x794a OP_DzMakeLeader=0x0ce9 OP_DzPlayerList=0xada0 -OP_DzExpeditionInvite=0x3817 -OP_DzExpeditionInviteResponse=0x5da9 +OP_DzJoinExpeditionConfirm=0x3817 +OP_DzJoinExpeditionReply=0x5da9 OP_DzExpeditionInfo=0x98e -OP_DzExpeditionLockoutTimers=0x7c12 -OP_DzMemberList=0x9b6 -OP_DzMemberListName=0x1826 -OP_DzMemberListStatus=0x330d -OP_DzSetLeaderName=0x7abc +OP_DzMemberStatus=0x1826 +OP_DzLeaderStatus=0x7abc OP_DzExpeditionEndsWarning=0x1c3f +OP_DzExpeditionList=0x7c12 +OP_DzMemberList=0x9b6 OP_DzCompass=0x28aa OP_DzChooseZone=0x1022 -OP_DzChooseZoneReply=0x20e7 +#0x330d is something but I'm not sure what yet. #bazaar trader stuff stuff: #become and buy from @@ -482,8 +481,6 @@ OP_TaskRequestTimer=0x6a1d OP_RequestClientZoneChange=0x7834 # ShowEQ 10/27/05 OP_SendAATable=0x367d # ShowEQ 10/27/05 -OP_ClearAA=0x5918 -OP_ClearLeadershipAbilities=0x7416 OP_UpdateAA=0x5966 OP_RespondAA=0x3af4 OP_SendAAStats=0x5996 # ShowEQ 10/27/05 @@ -546,7 +543,6 @@ OP_PlayerStateRemove=0x381d OP_VoiceMacroIn=0x2866 # Client to Server OP_VoiceMacroOut=0x2ec6 # Server to Client OP_CameraEffect=0x0937 # Correct -OP_UnderWorld=0x7186 # clients sends up when they detect an underworld issue, might be useful for cheat detection #named unknowns, to make looking for real unknown easier OP_AnnoyingZoneUnknown=0x729c diff --git a/utils/patches/patch_UF.conf b/utils/patches/patch_UF.conf index 8efce91f6..69d6bb1e5 100644 --- a/utils/patches/patch_UF.conf +++ b/utils/patches/patch_UF.conf @@ -368,7 +368,6 @@ OP_OpenContainer=0x041a OP_Marquee=0x3675 OP_Fling=0x51b1 OP_CancelSneakHide=0x7686 -OP_UnderWorld=0x2d9d # clients sends up when they detect an underworld issue, might be useful for cheat detection OP_DzQuit=0x1539 OP_DzListTimers=0x21e9 @@ -377,18 +376,16 @@ OP_DzRemovePlayer=0x054e OP_DzSwapPlayer=0x4661 OP_DzMakeLeader=0x226f OP_DzPlayerList=0x74e4 -OP_DzExpeditionInvite=0x3c5e -OP_DzExpeditionInviteResponse=0x1154 +OP_DzJoinExpeditionConfirm=0x3c5e +OP_DzJoinExpeditionReply=0x1154 OP_DzExpeditionInfo=0x1150 -OP_DzExpeditionLockoutTimers=0x70d8 -OP_DzMemberList=0x15c4 -OP_DzMemberListName=0x2d17 -OP_DzMemberListStatus=0x0d98 -OP_DzSetLeaderName=0x2caf +OP_DzMemberStatus=0x2d17 +OP_DzLeaderStatus=0x2caf OP_DzExpeditionEndsWarning=0x6ac2 +OP_DzExpeditionList=0x70d8 +OP_DzMemberList=0x15c4 OP_DzCompass=0x01cb OP_DzChooseZone=0x65e1 -OP_DzChooseZoneReply=0xa682 #shroud OP_ShroudSelectionWindow=0x72ad diff --git a/utils/scripts/eqemu_server.pl b/utils/scripts/eqemu_server.pl index da79fc448..4c510ff9f 100755 --- a/utils/scripts/eqemu_server.pl +++ b/utils/scripts/eqemu_server.pl @@ -62,8 +62,7 @@ if (-e "skip_internet_connection_check.txt") { # skip self update ############################################# my $skip_self_update_check = 0; -if (-e "eqemu_server_skip_update.txt" || defined($ENV{'EQEMU_SERVER_SKIP_UPDATE'})) { - print "[Info] Skipping self check\n"; +if (-e "eqemu_server_skip_update.txt") { $skip_self_update_check = 1; } @@ -71,8 +70,7 @@ if (-e "eqemu_server_skip_update.txt" || defined($ENV{'EQEMU_SERVER_SKIP_UPDATE' # skip maps update ############################################# my $skip_self_maps_update_check = 0; -if (-e "eqemu_server_skip_maps_update.txt" || defined($ENV{'EQEMU_SERVER_SKIP_MAPS_UPDATE'})) { - print "[Info] Skipping maps update\n"; +if (-e "eqemu_server_skip_maps_update.txt") { $skip_self_maps_update_check = 1; } @@ -108,7 +106,7 @@ if (-e "eqemu_update.pl") { print "[Info] For EQEmu Server management utilities - run eqemu_server.pl\n" if $ARGV[0] eq "ran_from_world"; my $skip_checks = 0; -if ($ARGV[0] && ($ARGV[0] eq "new_server" || $ARGV[0] eq "new_server_with_bots")) { +if ($ARGV[0] && $ARGV[0] eq "new_server") { $skip_checks = 1; } @@ -240,11 +238,10 @@ sub show_install_summary_info } if ($OS eq "Linux") { print "[Install] Linux Utility Scripts:\n"; - print " - server_start.sh Starts EQEmu server (Quiet) with 30 dynamic zones, UCS & Queryserv, dynamic zones\n"; - print " - server_start_with_login.sh Starts EQEmu server (Quiet) with 30 dynamic zones, UCS & Queryserv, dynamic zones\n"; - print " - server_start_dev.sh Starts EQEmu server with 10 dynamic zones, UCS & Queryserv, dynamic zones all verbose\n"; - print " - server_stop.sh Stops EQEmu Server (No warning)\n"; - print " - server_status.sh Prints the status of the EQEmu Server processes\n"; + print " - server_start.sh Starts EQEmu server (Quiet) with 30 dynamic zones, UCS & Queryserv, dynamic zones\n"; + print " - server_start_dev.sh Starts EQEmu server with 10 dynamic zones, UCS & Queryserv, dynamic zones all verbose\n"; + print " - server_stop.sh Stops EQEmu Server (No warning)\n"; + print " - server_status.sh Prints the status of the EQEmu Server processes\n"; } print "[Configure] eqemu_config.json Edit to change server settings and name\n"; @@ -254,7 +251,6 @@ sub show_install_summary_info sub new_server { - $build_options = $_[0]; $file_count = 0; opendir(DIR, ".") or die $!; while (my $file = readdir(DIR)) { @@ -269,7 +265,9 @@ sub new_server exit; } - get_installation_variables(); + if (-e "install_variables.txt" || -e "../install_variables.txt") { + get_installation_variables(); + } while (1) { @@ -309,7 +307,7 @@ sub new_server if ($mysql_pass == 1) { - if ($database_name eq "" && !-e "install_variables.txt" && !-e "../install_variables.txt") { + if ((!-e "install_variables.txt" && !-e "../install_variables.txt")) { print "[New Server] Success! We have a database connection\n"; check_for_input("Specify a NEW database name that PEQ will be installed to: "); @@ -325,12 +323,11 @@ sub new_server } analytics_insertion("new_server::install", $database_name); - # This shouldn't be necessary, as we call do_linux_login_server_setup as the last step in do_installer_routines() - # if ($OS eq "Linux") { - # build_linux_source("login"); - # } + if ($OS eq "Linux") { + build_linux_source("login"); + } - do_installer_routines($build_options); + do_installer_routines(); if ($OS eq "Linux") { print `chmod 755 *.sh`; @@ -418,6 +415,7 @@ sub check_xml_to_json_conversion sub build_linux_source { + $build_options = $_[0]; $cmake_options = ""; @@ -436,9 +434,7 @@ sub build_linux_source } } my $eqemu_server_directory = "/home/eqemu"; - # source between bots and not is the same, just different build results, so use the same source folder, different build folders - my $source_dir = $eqemu_server_directory . '/' . $last_directory . '_source'; - my $build_dir = $eqemu_server_directory . '/' . $last_directory . '_build' . $source_folder_post_fix; + my $source_dir = $eqemu_server_directory . '/' . $last_directory . '_source' . $source_folder_post_fix; $current_directory = trim($current_directory); @@ -450,22 +446,22 @@ sub build_linux_source chdir($source_dir); - if (!-d "$source_dir/.git") { - print `git clone --recurse-submodules https://github.com/EQEmu/Server.git $source_dir`; - } - else { - print `git pull --recurse-submodules`; - } + print `git clone https://github.com/EQEmu/Server.git`; - mkdir($build_dir) if (!-e $build_dir); - chdir($build_dir); + mkdir($source_dir . "/Server/build") if (!-e $source_dir . "/Server/build"); + chdir($source_dir . "/Server"); + + print `git submodule init`; + print `git submodule update`; + + chdir($source_dir . "/Server/build"); print "Generating CMake build files...\n"; if ($os_flavor eq "fedora_core") { - print `cmake $cmake_options -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -DLUA_INCLUDE_DIR=/usr/include/lua-5.1/ -G "Unix Makefiles" $source_dir`; + print `cmake $cmake_options -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -DLUA_INCLUDE_DIR=/usr/include/lua-5.1/ -G "Unix Makefiles" ..`; } else { - print `cmake $cmake_options -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G "Unix Makefiles" $source_dir`; + print `cmake $cmake_options -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G "Unix Makefiles" ..`; } print "Building EQEmu Server code. This will take a while."; @@ -474,22 +470,21 @@ sub build_linux_source chdir($current_directory); - print `ln -s -f $build_dir/bin/eqlaunch .`; - print `ln -s -f $build_dir/bin/export_client_files .`; - print `ln -s -f $build_dir/bin/import_client_files .`; - print `ln -s -f $build_dir/bin/libcommon.a .`; - print `ln -s -f $build_dir/bin/libluabind.a .`; - print `ln -s -f $build_dir/bin/queryserv .`; - print `ln -s -f $build_dir/bin/shared_memory .`; - print `ln -s -f $build_dir/bin/ucs .`; - print `ln -s -f $build_dir/bin/world .`; - print `ln -s -f $build_dir/bin/zone .`; - print `ln -s -f $build_dir/bin/loginserver .`; + print `ln -s -f $source_dir/Server/build/bin/eqlaunch .`; + print `ln -s -f $source_dir/Server/build/bin/export_client_files .`; + print `ln -s -f $source_dir/Server/build/bin/import_client_files .`; + print `ln -s -f $source_dir/Server/build/bin/libcommon.a .`; + print `ln -s -f $source_dir/Server/build/bin/libluabind.a .`; + print `ln -s -f $source_dir/Server/build/bin/queryserv .`; + print `ln -s -f $source_dir/Server/build/bin/shared_memory .`; + print `ln -s -f $source_dir/Server/build/bin/ucs .`; + print `ln -s -f $source_dir/Server/build/bin/world .`; + print `ln -s -f $source_dir/Server/build/bin/zone .`; + print `ln -s -f $source_dir/Server/build/bin/loginserver .`; } sub do_installer_routines { - $build_options = $_[0]; print "[Install] EQEmu Server Installer... LOADING... PLEASE WAIT...\n"; #::: Make some local server directories... @@ -522,25 +517,9 @@ sub do_installer_routines fetch_utility_scripts(); #::: Database Routines - $root_user = $user; - $root_password = $pass; print "[Database] Creating Database '" . $db_name . "'\n"; - if (defined($ENV{'MYSQL_ROOT_PASSWORD'})) - { - # In the case that the user doesn't have privileges to create databases, support passing in the root password during setup - print "[Database] Using 'root' for database management.\n"; - $root_user = "root"; - $root_password = $ENV{'MYSQL_ROOT_PASSWORD'}; - } - print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "DROP DATABASE IF EXISTS $db_name;"`; - print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "CREATE DATABASE $db_name"`; - if (defined($ENV{'MYSQL_ROOT_PASSWORD'})) - { - # If we used root, make sure $user has permissions on db - print "[Database] Assigning ALL PRIVILEGES to $user on $db_name.\n"; - print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "GRANT ALL PRIVILEGES ON $db_name.* TO '$user.%'"`; - print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "FLUSH PRIVILEGES"`; - } + print `"$path" --host $host --user $user --password="$pass" -N -B -e "DROP DATABASE IF EXISTS $db_name;"`; + print `"$path" --host $host --user $user --password="$pass" -N -B -e "CREATE DATABASE $db_name"`; my $world_path = "world"; if (-e "bin/world") { @@ -569,11 +548,6 @@ sub do_installer_routines print "[Database] Fetching and Applying Latest Database Updates...\n"; main_db_management(); - # if bots - if ($build_options =~ /bots/i) { - bots_db_management(); - } - remove_duplicate_rule_values(); if ($OS eq "Windows") { @@ -581,7 +555,7 @@ sub do_installer_routines do_windows_login_server_setup(); } if ($OS eq "Linux") { - do_linux_login_server_setup($build_options); + do_linux_login_server_setup(); } } @@ -731,8 +705,7 @@ sub get_windows_wget { if (!-d "bin") { mkdir("bin"); } - eval "use LWP::Simple qw(getstore);"; - getstore("https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe", "bin\\wget.exe"); + `powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe', 'bin\\wget.exe') "` } } @@ -801,12 +774,6 @@ sub do_self_update_check_routine sub get_installation_variables { - # Read installation variables from the ENV if set, but override them with install_variables.txt - if ($ENV{"MYSQL_HOST"}) { $installation_variables{"mysql_host"} = $ENV{"MYSQL_HOST"}; } - if ($ENV{"MYSQL_DATABASE"}) { $installation_variables{"mysql_eqemu_db_name"} = $ENV{"MYSQL_DATABASE"}; } - if ($ENV{"MYSQL_USER"}) { $installation_variables{"mysql_eqemu_user"} = $ENV{"MYSQL_USER"} } - if ($ENV{"MYSQL_PASSWORD"}) { $installation_variables{"mysql_eqemu_password"} = $ENV{"MYSQL_PASSWORD"} } - #::: Fetch installation variables before building the config if ($OS eq "Linux") { if (-e "../install_variables.txt") { @@ -840,9 +807,9 @@ sub do_install_config_json my $content; open(my $fh, '<', "eqemu_config_template.json") or die "cannot open file $filename"; { - local $/; - $content = <$fh>; - } + local $/; + $content = <$fh>; +} close($fh); $config = $json->decode($content); @@ -858,18 +825,9 @@ sub do_install_config_json $db_name = "peq"; } - if ($installation_variables{"mysql_host"}) { - $host = $installation_variables{"mysql_host"}; - } - else { - $host = "127.0.0.1"; - } - - $config->{"server"}{"database"}{"host"} = $host; $config->{"server"}{"database"}{"username"} = $installation_variables{"mysql_eqemu_user"}; $config->{"server"}{"database"}{"password"} = $installation_variables{"mysql_eqemu_password"}; $config->{"server"}{"database"}{"db"} = $db_name; - $config->{"server"}{"qsdatabase"}{"host"} = $host; $config->{"server"}{"qsdatabase"}{"username"} = $installation_variables{"mysql_eqemu_user"}; $config->{"server"}{"qsdatabase"}{"password"} = $installation_variables{"mysql_eqemu_password"}; $config->{"server"}{"qsdatabase"}{"db"} = $db_name; @@ -895,9 +853,9 @@ sub do_install_config_login_json my $content; open(my $fh, '<', "login_template.json") or die "cannot open file $filename"; { - local $/; - $content = <$fh>; - } + local $/; + $content = <$fh>; +} close($fh); $config = $json->decode($content); @@ -909,14 +867,7 @@ sub do_install_config_login_json $db_name = "peq"; } - if ($installation_variables{"mysql_host"}) { - $host = $installation_variables{"mysql_host"}; - } - else { - $host = "127.0.0.1"; - } - - $config->{"database"}{"host"} = $host; + $config->{"database"}{"host"} = "127.0.0.1"; $config->{"database"}{"user"} = $installation_variables{"mysql_eqemu_user"}; $config->{"database"}{"password"} = $installation_variables{"mysql_eqemu_password"}; $config->{"database"}{"db"} = $db_name; @@ -1135,10 +1086,6 @@ sub show_menu_prompt new_server(); $dc = 1; } - elsif ($input eq "new_server_with_bots") { - new_server("bots"); - $dc = 1; - } elsif ($input eq "setup_bots") { setup_bots(); $dc = 1; @@ -1206,12 +1153,11 @@ sub print_main_menu print "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; print ">>> EQEmu Server Main Menu >>>>>>>>>>>>\n"; print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"; - print " [database] Enter database management menu \n"; - print " [assets] Manage server assets \n"; - print " [new_server] New folder EQEmu/PEQ install - Assumes MySQL/Perl installed \n"; - print " [new_server_with_bots] New folder EQEmu/PEQ install with bots enabled - Assumes MySQL/Perl installed \n"; - print " [setup_bots] Enables bots on server - builds code and database requirements \n"; - print " [conversions] Routines used for conversion of scripts/data \n"; + print " [database] Enter database management menu \n"; + print " [assets] Manage server assets \n"; + print " [new_server] New folder EQEmu/PEQ install - Assumes MySQL/Perl installed \n"; + print " [setup_bots] Enables bots on server - builds code and database requirements \n"; + print " [conversions] Routines used for conversion of scripts/data \n"; print "\n"; print " exit \n"; print "\n"; @@ -1351,12 +1297,12 @@ sub script_exit sub check_db_version_table { if (get_mysql_result("SHOW TABLES LIKE 'db_version'") eq "" && $db) { - print "[Database] Table 'db_version' does not exist.... Creating...\n\n"; print get_mysql_result(" CREATE TABLE db_version ( version int(11) DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO db_version (version) VALUES ('1000');"); + print "[Database] Table 'db_version' does not exist.... Creating...\n\n"; } } @@ -1505,9 +1451,9 @@ sub read_eqemu_config_json my $content; open(my $fh, '<', "eqemu_config.json") or die "cannot open file $filename"; { - local $/; - $content = <$fh>; - } + local $/; + $content = <$fh>; +} close($fh); $config = $json->decode($content); @@ -1749,7 +1695,8 @@ sub do_windows_login_server_setup sub do_linux_login_server_setup { - build_linux_source($_[0]); + + build_linux_source(); for my $file (@files) { $destination_file = $file; @@ -2578,6 +2525,7 @@ sub run_database_check } } + sub fetch_missing_db_update { $db_update = $_[0]; @@ -2759,6 +2707,7 @@ sub quest_heading_convert print "Total matches: " . $total_matches . "\n"; } + sub quest_faction_convert { diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 99f8eb856..193bd1c37 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -33,9 +33,8 @@ my $repository_generation_option = $ARGV[2] ? $ARGV[2] : "all"; ############################################# # world path ############################################# -my $world_binary = ($^O eq "MSWin32") ? "world.exe" : "world"; -my $world_path = $server_path . "/" . $world_binary; -my $world_path_bin = $server_path . "/bin/" . $world_binary; +my $world_path = $server_path . "/world"; +my $world_path_bin = $server_path . "/bin/world"; my $found_world_path = ""; if (-e $world_path) { @@ -82,8 +81,7 @@ my $database_name = $config->{"server"}{"database"}{"db"}; my $host = $config->{"server"}{"database"}{"host"}; my $user = $config->{"server"}{"database"}{"username"}; my $pass = $config->{"server"}{"database"}{"password"}; -my $port = $config->{"server"}{"database"}{"port"}; -my $dsn = "dbi:mysql:$database_name:$host:$port"; +my $dsn = "dbi:mysql:$database_name:$host:3306"; my $connect = DBI->connect($dsn, $user, $pass); my @tables = (); @@ -239,7 +237,7 @@ foreach my $table_to_generate (@tables) { elsif ($column_default eq "''") { $default_value = '""'; } - elsif ((trim($column_default) eq "" || $column_default eq "NULL") && $column_type =~ /text|varchar|datetime/i) { + elsif ((trim($column_default) eq "" || $column_default eq "NULL") && $column_type =~ /text|varchar/i) { $default_value = '""'; } @@ -268,14 +266,16 @@ foreach my $table_to_generate (@tables) { ); } - # insert - my $value = sprintf("\"'\" + EscapeString(%s_entry.%s) + \"'\"", $table_name, $column_name); - if ($data_type =~ /int|float|double|decimal/) { - $value = sprintf('std::to_string(%s_entry.%s)', $table_name, $column_name); - } + # insert one + if ($extra ne "auto_increment") { + my $value = sprintf("\"'\" + EscapeString(%s_entry.%s) + \"'\"", $table_name, $column_name); + if ($data_type =~ /int|float|double|decimal/) { + $value = sprintf('std::to_string(%s_entry.%s)', $table_name, $column_name); + } - $insert_one_entries .= sprintf("\t\tinsert_values.push_back(%s);\n", $value); - $insert_many_entries .= sprintf("\t\t\tinsert_values.push_back(%s);\n", $value); + $insert_one_entries .= sprintf("\t\tinsert_values.push_back(%s);\n", $value); + $insert_many_entries .= sprintf("\t\t\tinsert_values.push_back(%s);\n", $value); + } # find one / all (select) if ($data_type =~ /int/) { diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index 55c8facd7..383293eac 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -409,16 +409,6 @@ 9153|2020_05_09_items_subtype.sql|SHOW COLUMNS from `items` LIKE 'UNK219'|not_empty| 9154|2020_04_11_expansions_content_filters.sql|SHOW COLUMNS from `zone` LIKE 'min_expansion'|empty| 9155|2020_08_15_lootdrop_level_filtering.sql|SHOW COLUMNS from `lootdrop_entries` LIKE 'trivial_min_level'|empty| -9156|2020_08_16_virtual_zonepoints.sql|SHOW COLUMNS from `zone_points` LIKE 'is_virtual'|empty| -9157|2020_09_02_pet_taunting.sql|SHOW COLUMNS from `character_pet_info` LIKE 'taunting'|empty| -9158|2020_12_09_underworld.sql|SHOW COLUMNS from `zone` LIKE 'underworld_teleport_index'|empty| -9159|2020_12_22_expedition_system.sql|SELECT * FROM db_version WHERE version >= 9159|empty| -9160|2021_02_14_npc_exp_mod.sql|SHOW COLUMNS from `npc_types` LIKE 'exp_mod'|empty| -9161|2021_02_15_npc_spell_entries_unsigned.sql|SELECT * FROM db_version WHERE version >= 9161|empty| -9162|2021_02_17_server_scheduled_events.sql|SELECT * FROM db_version WHERE version >= 9162|empty| -9163|2021_04_17_zone_safe_heading_changes.sql|SHOW COLUMNS FROM `zone` LIKE 'safe_heading'|empty| -9164|2021_04_23_character_exp_modifiers.sql|SHOW TABLES LIKE 'character_exp_modifiers'|empty| -9165|2021_04_28_idle_pathing.sql|SHOW COLUMNS FROM `spawn2` LIKE 'path_when_zone_idle'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/required/2020_08_16_virtual_zonepoints.sql b/utils/sql/git/required/2020_08_16_virtual_zonepoints.sql deleted file mode 100644 index 3fb21cd0a..000000000 --- a/utils/sql/git/required/2020_08_16_virtual_zonepoints.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `zone_points` ADD COLUMN `is_virtual` tinyint NOT NULL DEFAULT '0' COMMENT '' AFTER `content_flags_disabled`; -ALTER TABLE `zone_points` ADD COLUMN `height` int NOT NULL DEFAULT '0' COMMENT ''; -ALTER TABLE `zone_points` ADD COLUMN `width` int NOT NULL DEFAULT '0' COMMENT ''; \ No newline at end of file diff --git a/utils/sql/git/required/2020_09_02_pet_taunting.sql b/utils/sql/git/required/2020_09_02_pet_taunting.sql deleted file mode 100644 index f4de1138f..000000000 --- a/utils/sql/git/required/2020_09_02_pet_taunting.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `character_pet_info` ADD COLUMN `taunting` tinyint(1) NOT NULL DEFAULT '1' COMMENT ''; diff --git a/utils/sql/git/required/2020_12_09_underworld.sql b/utils/sql/git/required/2020_12_09_underworld.sql deleted file mode 100644 index f2f2ba032..000000000 --- a/utils/sql/git/required/2020_12_09_underworld.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE `zone` ADD COLUMN `underworld_teleport_index` INT(4) NOT NULL DEFAULT '0'; -UPDATE `zone` SET `underworld` = '-2030' WHERE `zoneidnumber` = '71'; -UPDATE `zone` SET `underworld_teleport_index` = '11' WHERE `zoneidnumber` = '71'; -UPDATE `zone` SET `underworld_teleport_index` = '-1' WHERE `zoneidnumber` = '75'; -UPDATE `zone` SET `underworld_teleport_index` = '-1' WHERE `zoneidnumber` = '150'; - diff --git a/utils/sql/git/required/2020_12_22_expedition_system.sql b/utils/sql/git/required/2020_12_22_expedition_system.sql deleted file mode 100644 index 820940500..000000000 --- a/utils/sql/git/required/2020_12_22_expedition_system.sql +++ /dev/null @@ -1,82 +0,0 @@ -CREATE TABLE `expeditions` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `uuid` VARCHAR(36) NOT NULL, - `dynamic_zone_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `expedition_name` VARCHAR(128) NOT NULL, - `leader_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `min_players` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, - `max_players` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, - `add_replay_on_join` TINYINT(3) UNSIGNED NOT NULL DEFAULT 1, - `is_locked` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY (`id`), - UNIQUE INDEX `dynamic_zone_id` (`dynamic_zone_id`) -) -COLLATE='latin1_swedish_ci' -ENGINE=InnoDB -; - -CREATE TABLE `expedition_lockouts` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `expedition_id` INT(10) UNSIGNED NOT NULL, - `event_name` VARCHAR(256) NOT NULL, - `expire_time` DATETIME NOT NULL DEFAULT current_timestamp(), - `duration` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `from_expedition_uuid` VARCHAR(36) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE INDEX `expedition_id_event_name` (`expedition_id`, `event_name`) -) -COLLATE='latin1_swedish_ci' -ENGINE=InnoDB -; - -CREATE TABLE `expedition_members` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `expedition_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `character_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `is_current_member` TINYINT(3) UNSIGNED NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - UNIQUE INDEX `expedition_id_character_id` (`expedition_id`, `character_id`) -) -COLLATE='latin1_swedish_ci' -ENGINE=InnoDB -; - -CREATE TABLE `character_expedition_lockouts` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `character_id` INT(10) UNSIGNED NOT NULL, - `expedition_name` VARCHAR(128) NOT NULL, - `event_name` VARCHAR(256) NOT NULL, - `expire_time` DATETIME NOT NULL DEFAULT current_timestamp(), - `duration` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `from_expedition_uuid` VARCHAR(36) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE INDEX `character_id_expedition_name_event_name` (`character_id`, `expedition_name`, `event_name`) -) -COLLATE='latin1_swedish_ci' -ENGINE=InnoDB -; - -CREATE TABLE `dynamic_zones` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `instance_id` INT(10) NOT NULL DEFAULT 0, - `type` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, - `compass_zone_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `compass_x` FLOAT NOT NULL DEFAULT 0, - `compass_y` FLOAT NOT NULL DEFAULT 0, - `compass_z` FLOAT NOT NULL DEFAULT 0, - `safe_return_zone_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, - `safe_return_x` FLOAT NOT NULL DEFAULT 0, - `safe_return_y` FLOAT NOT NULL DEFAULT 0, - `safe_return_z` FLOAT NOT NULL DEFAULT 0, - `safe_return_heading` FLOAT NOT NULL DEFAULT 0, - `zone_in_x` FLOAT NOT NULL DEFAULT 0, - `zone_in_y` FLOAT NOT NULL DEFAULT 0, - `zone_in_z` FLOAT NOT NULL DEFAULT 0, - `zone_in_heading` FLOAT NOT NULL DEFAULT 0, - `has_zone_in` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY (`id`), - UNIQUE INDEX `instance_id` (`instance_id`) -) -COLLATE='utf8mb4_general_ci' -ENGINE=InnoDB -; diff --git a/utils/sql/git/required/2021_02_14_npc_exp_mod.sql b/utils/sql/git/required/2021_02_14_npc_exp_mod.sql deleted file mode 100644 index 8cd8372e2..000000000 --- a/utils/sql/git/required/2021_02_14_npc_exp_mod.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `npc_types` ADD COLUMN `exp_mod` INT NOT NULL DEFAULT '100' AFTER `always_aggro`; diff --git a/utils/sql/git/required/2021_02_15_npc_spell_entries_unsigned.sql b/utils/sql/git/required/2021_02_15_npc_spell_entries_unsigned.sql deleted file mode 100644 index cc03b8daa..000000000 --- a/utils/sql/git/required/2021_02_15_npc_spell_entries_unsigned.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `npc_spells_entries` MODIFY `spellid` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0; diff --git a/utils/sql/git/required/2021_02_17_server_scheduled_events.sql b/utils/sql/git/required/2021_02_17_server_scheduled_events.sql deleted file mode 100644 index deb69423f..000000000 --- a/utils/sql/git/required/2021_02_17_server_scheduled_events.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE `server_scheduled_events` -( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) DEFAULT NULL, - `event_type` varchar(100) DEFAULT NULL, - `event_data` text DEFAULT NULL, - `minute_start` int(11) DEFAULT 0, - `hour_start` int(11) DEFAULT 0, - `day_start` int(11) DEFAULT 0, - `month_start` int(11) DEFAULT 0, - `year_start` int(11) DEFAULT 0, - `minute_end` int(11) DEFAULT 0, - `hour_end` int(11) DEFAULT 0, - `day_end` int(11) DEFAULT 0, - `month_end` int(11) DEFAULT 0, - `year_end` int(11) DEFAULT 0, - `cron_expression` varchar(100) DEFAULT NULL, - `created_at` datetime DEFAULT NULL, - `deleted_at` datetime DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; diff --git a/utils/sql/git/required/2021_04_17_zone_safe_heading_changes.sql b/utils/sql/git/required/2021_04_17_zone_safe_heading_changes.sql deleted file mode 100644 index c10a5c6ff..000000000 --- a/utils/sql/git/required/2021_04_17_zone_safe_heading_changes.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE zone ADD COLUMN safe_heading float NOT NULL DEFAULT 0 AFTER safe_z; diff --git a/utils/sql/git/required/2021_04_23_character_exp_modifiers.sql b/utils/sql/git/required/2021_04_23_character_exp_modifiers.sql deleted file mode 100644 index 4a1bcb5de..000000000 --- a/utils/sql/git/required/2021_04_23_character_exp_modifiers.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE `character_exp_modifiers` ( - `character_id` int NOT NULL, - `zone_id` int NOT NULL, - `aa_modifier` float NOT NULL, - `exp_modifier` float NOT NULL, - PRIMARY KEY (`character_id`, `zone_id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact; diff --git a/utils/sql/git/required/2021_04_28_idle_pathing.sql b/utils/sql/git/required/2021_04_28_idle_pathing.sql deleted file mode 100644 index 2249163fc..000000000 --- a/utils/sql/git/required/2021_04_28_idle_pathing.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Add new path_when_zone_idle flag to allow some spawns to path in empty zones -ALTER TABLE spawn2 ADD COLUMN path_when_zone_idle tinyint(1) NOT NULL DEFAULT 0 AFTER pathgrid; - --- Update spawns that used to path in empty zones because of their grid type --- to behave the same using the new mechanism. The code that checked path grid --- types has been removed as it was coincidentally coupled to idle movement. --- The new flag path_when_zone_idle is the new mechanism, and allows any moving --- mob, not just those on grids, to path while the zone is idle. -UPDATE spawn2 s -LEFT JOIN zone z ON z.short_name = s.zone -LEFT JOIN grid g ON g.id = s.pathgrid AND g.zoneid = z.zoneidnumber -SET path_when_zone_idle = 1 -WHERE pathgrid != 0 AND g.type IN (4, 6); diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index 9a7ef5750..ab14ed603 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -7,13 +7,8 @@ SET(world_sources cliententry.cpp clientlist.cpp console.cpp - dynamic_zone.cpp eql_config.cpp eqemu_api_world_data_service.cpp - expedition.cpp - expedition_database.cpp - expedition_message.cpp - expedition_state.cpp launcher_link.cpp launcher_list.cpp lfplist.cpp @@ -25,7 +20,6 @@ SET(world_sources web_interface.cpp web_interface_eqw.cpp wguild_mgr.cpp - world_event_scheduler.cpp world_config.cpp world_console_connection.cpp world_server_command_handler.cpp @@ -43,13 +37,8 @@ SET(world_headers cliententry.h clientlist.h console.h - dynamic_zone.h eql_config.h eqemu_api_world_data_service.h - expedition.h - expedition_database.h - expedition_message.h - expedition_state.h launcher_link.h launcher_list.h lfplist.h @@ -66,7 +55,6 @@ SET(world_headers world_tcp_connection.h world_server_command_handler.h worlddb.h - world_event_scheduler.h world_store.h zonelist.h zoneserver.h diff --git a/world/client.cpp b/world/client.cpp index 03c6195e8..684020137 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -87,17 +87,6 @@ extern uint32 numclients; extern volatile bool RunLoops; extern volatile bool UCSServerAvailable_; -// unused ATM, but here for reference, should match RoF2 -enum class NameApprovalResponse : int { - NotValid = -1, // string ID 1576 - Rejected = 0, // string ID 1581 - Approved = 1, - CharacterLimit = 2, // string ID 1591 older clients mention 1 char on server - ThreeDeity = 3, // string ID 5502. 3 toons same deity team limit - HeadStartPreOoW = 4, // string ID 6862, head start failed due to OoW not being unlocked - HeadStartNoOoW = 5, // string ID 6863, head start failed due to not owning OoW -}; - Client::Client(EQStreamInterface* ieqs) : autobootup_timeout(RuleI(World, ZoneAutobootTimeoutMS)), connect(1000), @@ -508,7 +497,7 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) return false; } - auto length = snprintf(char_name, 64, "%s", (char*)app->pBuffer); + snprintf(char_name, 64, "%s", (char*)app->pBuffer); uchar race = app->pBuffer[64]; uchar clas = app->pBuffer[68]; @@ -520,39 +509,22 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) outapp->pBuffer = new uchar[1]; outapp->size = 1; - bool valid = true; - /* Name must be between 4 and 15 characters long, packet forged if this is true */ - if (length < 4 || length > 15) { + bool valid = false; + if(!database.CheckNameFilter(char_name)) { valid = false; } - /* Name must begin with an upper-case letter, can be sent with some tricking of the client */ + /* Name must begin with an upper-case letter. */ else if (islower(char_name[0])) { valid = false; } - /* Name must not have any spaces, packet forged if this is true */ - else if (strstr(char_name, " ")) { - valid = false; - } - /* I would like to do this later, since it's likely more expensive, but oh well */ - else if (!database.CheckNameFilter(char_name)) { - valid = false; + else if (database.ReserveName(GetAccountID(), char_name)) { + valid = true; } else { - /* Name must not not contain any uppercase letters, can be sent with some tricking of the client */ - for (int i = 1; i < length; ++i) { - if (isupper(char_name[i])) { - valid = false; - break; - } - } + valid = false; } - /* Still not invalid, let's see if it's taken */ - if (valid) { - valid = database.ReserveName(GetAccountID(), char_name); - } - - outapp->pBuffer[0] = valid ? 1 : 0; + outapp->pBuffer[0] = valid? 1 : 0; QueuePacket(outapp); safe_delete(outapp); @@ -1307,23 +1279,23 @@ void Client::Clearance(int8 response) outapp = new EQApplicationPacket(OP_ZoneServerInfo, sizeof(ZoneServerInfo_Struct)); ZoneServerInfo_Struct* zsi = (ZoneServerInfo_Struct*)outapp->pBuffer; - std::string zs_addr; + const char *zs_addr = nullptr; if(cle && cle->IsLocalClient()) { const char *local_addr = zs->GetCLocalAddress(); if(local_addr[0]) { zs_addr = local_addr; } else { - zs_addr = zs->GetIP(); + zs_addr = zs->GetIP().c_str(); - if (zs_addr.empty()) { - zs_addr = WorldConfig::get()->LocalAddress; + if (!zs_addr[0]) { + zs_addr = WorldConfig::get()->LocalAddress.c_str(); } - if(zs_addr == "127.0.0.1") + if(strcmp(zs_addr, "127.0.0.1") == 0) { LogInfo("Local zone address was [{}], setting local address to: [{}]", zs_addr, WorldConfig::get()->LocalAddress.c_str()); - zs_addr = WorldConfig::get()->LocalAddress; + zs_addr = WorldConfig::get()->LocalAddress.c_str(); } else { LogInfo("Local zone address [{}]", zs_addr); } @@ -1334,11 +1306,11 @@ void Client::Clearance(int8 response) if(addr[0]) { zs_addr = addr; } else { - zs_addr = WorldConfig::get()->WorldAddress; + zs_addr = WorldConfig::get()->WorldAddress.c_str(); } } - strcpy(zsi->ip, zs_addr.c_str()); + strcpy(zsi->ip, zs_addr); zsi->port =zs->GetCPort(); LogInfo("Sending client to zone [{}] ([{}]:[{}]) at [{}]:[{}]", zonename, zone_id, instance_id, zsi->ip, zsi->port); QueuePacket(outapp); @@ -1569,25 +1541,25 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) } /* Set Home Binds -- yep, all of them */ - pp.binds[1].zone_id = pp.zone_id; + pp.binds[1].zoneId = pp.zone_id; pp.binds[1].x = pp.x; pp.binds[1].y = pp.y; pp.binds[1].z = pp.z; pp.binds[1].heading = pp.heading; - pp.binds[2].zone_id = pp.zone_id; + pp.binds[2].zoneId = pp.zone_id; pp.binds[2].x = pp.x; pp.binds[2].y = pp.y; pp.binds[2].z = pp.z; pp.binds[2].heading = pp.heading; - pp.binds[3].zone_id = pp.zone_id; + pp.binds[3].zoneId = pp.zone_id; pp.binds[3].x = pp.x; pp.binds[3].y = pp.y; pp.binds[3].z = pp.z; pp.binds[3].heading = pp.heading; - pp.binds[4].zone_id = pp.zone_id; + pp.binds[4].zoneId = pp.zone_id; pp.binds[4].x = pp.x; pp.binds[4].y = pp.y; pp.binds[4].z = pp.z; @@ -1601,7 +1573,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) /* Will either be the same as home or tutorial if enabled. */ if(RuleB(World, StartZoneSameAsBindOnCreation)) { - pp.binds[0].zone_id = pp.zone_id; + pp.binds[0].zoneId = pp.zone_id; pp.binds[0].x = pp.x; pp.binds[0].y = pp.y; pp.binds[0].z = pp.z; @@ -1611,9 +1583,9 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) Log(Logs::Detail, Logs::WorldServer, "Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f", ZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading); Log(Logs::Detail, Logs::WorldServer, "Bind location: %s (%d) %0.2f, %0.2f, %0.2f", - ZoneName(pp.binds[0].zone_id), pp.binds[0].zone_id, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); + ZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); Log(Logs::Detail, Logs::WorldServer, "Home location: %s (%d) %0.2f, %0.2f, %0.2f", - ZoneName(pp.binds[4].zone_id), pp.binds[4].zone_id, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); + ZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); /* Starting Items inventory */ content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin()); @@ -1906,7 +1878,7 @@ void Client::SetClassStartingSkills(PlayerProfile_Struct *pp) i == EQ::skills::SkillAlcoholTolerance || i == EQ::skills::SkillBindWound) continue; - pp->skills[i] = content_db.GetSkillCap(pp->class_, (EQ::skills::SkillType)i, 1); + pp->skills[i] = database.GetSkillCap(pp->class_, (EQ::skills::SkillType)i, 1); } } diff --git a/world/cliententry.h b/world/cliententry.h index 769700403..b4d449c58 100644 --- a/world/cliententry.h +++ b/world/cliententry.h @@ -127,9 +127,6 @@ public: inline void PushToTellQueue(ServerChannelMessage_Struct *scm) { tell_queue.push_back(scm); } void ProcessTellQueue(); - void SetPendingExpeditionInvite(ServerPacket* pack) { p_pending_expedition_invite.reset(pack->Copy()); }; - std::unique_ptr GetPendingExpeditionInvite() { return std::move(p_pending_expedition_invite); } - private: void ClearVars(bool iAll = false); @@ -174,8 +171,6 @@ private: // Tell Queue -- really a vector :D std::vector tell_queue; - - std::unique_ptr p_pending_expedition_invite = nullptr; }; #endif /*CLIENTENTRY_H_*/ diff --git a/world/clientlist.cpp b/world/clientlist.cpp index 0f216c0ee..0149b3b9f 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -46,7 +46,7 @@ ClientList::ClientList() { NextCLEID = 1; - m_tick = std::make_unique(5000, true, std::bind(&ClientList::OnTick, this, std::placeholders::_1)); + m_tick.reset(new EQ::Timer(5000, true, std::bind(&ClientList::OnTick, this, std::placeholders::_1))); } ClientList::~ClientList() { @@ -269,6 +269,8 @@ ClientListEntry* ClientList::FindCLEByLSID(uint32 iLSID) { void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName) { LinkedListIterator iterator(clientlist); + char* output = 0; + uint32 outsize = 0, outlen = 0; int x = 0, y = 0; int namestrlen = iName == 0 ? 0 : strlen(iName); bool addnewline = false; @@ -277,7 +279,6 @@ void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnect strcpy(newline, "\r\n"); else strcpy(newline, "^"); - fmt::memory_buffer out; iterator.Reset(); while(iterator.MoreElements()) { @@ -286,30 +287,31 @@ void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnect struct in_addr in; in.s_addr = cle->GetIP(); if (addnewline) { - fmt::format_to(out, newline); + AppendAnyLenString(&output, &outsize, &outlen, newline); } - fmt::format_to(out, "ID: {} Acc# {} AccName: {} IP: {}", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in)); - fmt::format_to(out, "{} Stale: {} Online: {} Admin: {}", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin()); + AppendAnyLenString(&output, &outsize, &outlen, "ID: %i Acc# %i AccName: %s IP: %s", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in)); + AppendAnyLenString(&output, &outsize, &outlen, "%s Stale: %i Online: %i Admin: %i", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin()); if (cle->LSID()) - fmt::format_to(out, "{} LSID: {} LSName: {} WorldAdmin: {}", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin()); + AppendAnyLenString(&output, &outsize, &outlen, "%s LSID: %i LSName: %s WorldAdmin: %i", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin()); if (cle->CharID()) - fmt:format_to(out, "{} CharID: {} CharName: {} Zone: {} ({})", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone()); - if (out.size() >= 3072) { - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); + AppendAnyLenString(&output, &outsize, &outlen, "%s CharID: %i CharName: %s Zone: %s (%i)", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone()); + if (outlen >= 3072) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); + outsize = 0; + outlen = 0; addnewline = false; - out.clear(); - } else { - addnewline = true; } + else + addnewline = true; y++; } iterator.Advance(); x++; } - fmt::format_to(out, "{}{} CLEs in memory. {} CLEs listed. numplayers = {}.", newline, x, y, numplayers); - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); + AppendAnyLenString(&output, &outsize, &outlen, "%s%i CLEs in memory. %i CLEs listed. numplayers = %i.", newline, x, y, numplayers); + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); } @@ -487,8 +489,15 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S whom->wrace = FROGLOK; // This is what EQEmu uses for the Froglok Race number. } + char* output = 0; + uint32 outsize = 0, outlen = 0; uint32 totalusers=0; uint32 totallength=0; + AppendAnyLenString(&output, &outsize, &outlen, "Players on server:"); + if (connection->IsConsole()) + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); + else + AppendAnyLenString(&output, &outsize, &outlen, "\n"); countclients.Reset(); while(countclients.MoreElements()){ countcle = countclients.GetData(); @@ -713,6 +722,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S //zoneserver_list.SendPacket(pack2); // NO NO NO WHY WOULD YOU SEND IT TO EVERY ZONE SERVER?!? SendPacket(to,pack2); safe_delete(pack2); + safe_delete_array(output); } catch(...){ LogInfo("Unknown error in world's SendWhoAll (probably mem error), ignoring"); @@ -946,12 +956,13 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* if (whom) whomlen = strlen(whom->whom); - fmt::memory_buffer out; - fmt::format_to(out, "Players on server:"); + char* output = 0; + uint32 outsize = 0, outlen = 0; + AppendAnyLenString(&output, &outsize, &outlen, "Players on server:"); if (connection->IsConsole()) - fmt::format_to(out, "\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else - fmt::format_to(out, "\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\n"); iterator.Reset(); while (iterator.MoreElements()) { cle = iterator.GetData(); @@ -1047,17 +1058,18 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* else sprintf(line, " %s[%i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetClassIDName(cle->class_(), cle->level()), cle->name(), GetRaceIDName(cle->race()), tmpguild, tmpZone, LFG, accinfo); - fmt::format_to(out, line); - if (out.size() >= 3584) { - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); - out.clear(); + AppendAnyLenString(&output, &outsize, &outlen, line); + if (outlen >= 3584) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); + outsize = 0; + outlen = 0; } else { if (connection->IsConsole()) - fmt::format_to(out, "\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else - fmt::format_to(out, "\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\n"); } x++; if (x >= 20 && admin < 80) @@ -1067,19 +1079,20 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* } if (x >= 20 && admin < 80) - fmt::format_to(out, "too many results...20 players shown"); + AppendAnyLenString(&output, &outsize, &outlen, "too many results...20 players shown"); else - fmt::format_to(out, "{} players online", x); + AppendAnyLenString(&output, &outsize, &outlen, "%i players online", x); if (admin >= 150 && (whom == 0 || whom->gmlookup != 0xFFFF)) { if (connection->IsConsole()) - fmt::format_to(out, "\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else - fmt::format_to(out, "\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\n"); //console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen); } - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); + if (output) + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); } void ClientList::Add(Client* client) { @@ -1244,7 +1257,7 @@ void ClientList::RemoveCLEByLSID(uint32 iLSID) bool ClientList::IsAccountInGame(uint32 iLSID) { LinkedListIterator iterator(clientlist); - iterator.Reset(); + while (iterator.MoreElements()) { if (iterator.GetData()->LSID() == iLSID && iterator.GetData()->Online() == CLE_Status::InZone) { return true; diff --git a/world/dynamic_zone.cpp b/world/dynamic_zone.cpp deleted file mode 100644 index dad35db82..000000000 --- a/world/dynamic_zone.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "dynamic_zone.h" -#include "expedition.h" -#include "expedition_state.h" -#include "worlddb.h" -#include "zonelist.h" -#include "zoneserver.h" -#include "../common/eqemu_logsys.h" -#include "../common/repositories/instance_list_repository.h" - -extern ZSList zoneserver_list; - -Database& DynamicZone::GetDatabase() -{ - return database; -} - -DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id) -{ - auto expedition = expedition_state.GetExpeditionByDynamicZoneID(dz_id); - if (expedition) - { - return &expedition->GetDynamicZone(); - } - // todo: other system caches - return nullptr; -} - -DynamicZoneStatus DynamicZone::Process(bool force_expire) -{ - DynamicZoneStatus status = DynamicZoneStatus::Normal; - - if (force_expire || IsExpired()) - { - status = DynamicZoneStatus::Expired; - - auto dz_zoneserver = zoneserver_list.FindByInstanceID(GetInstanceID()); - if (!dz_zoneserver || dz_zoneserver->NumPlayers() == 0) // no clients inside dz - { - status = DynamicZoneStatus::ExpiredEmpty; - - if (force_expire && !m_is_pending_early_shutdown && RuleB(DynamicZone, EmptyShutdownEnabled)) - { - SetSecondsRemaining(RuleI(DynamicZone, EmptyShutdownDelaySeconds)); - m_is_pending_early_shutdown = true; - } - } - } - - return status; -} - -void DynamicZone::SetSecondsRemaining(uint32_t seconds_remaining) -{ - auto now = std::chrono::system_clock::now(); - auto new_remaining = std::chrono::seconds(seconds_remaining); - - auto current_remaining = m_expire_time - now; - if (current_remaining > new_remaining) // reduce only - { - LogDynamicZonesDetail("Updating dynamic zone [{}] instance [{}] seconds remaining to [{}]s", - GetID(), GetInstanceID(), seconds_remaining); - - // preserve original start time and adjust duration instead - m_expire_time = now + new_remaining; - m_duration = std::chrono::duration_cast(m_expire_time - m_start_time); - - InstanceListRepository::UpdateDuration(database, - GetInstanceID(), static_cast(m_duration.count())); - - SendZonesDurationUpdate(); // update zone caches and actual instance's timer - } -} - -void DynamicZone::SendZonesDurationUpdate() -{ - constexpr uint32_t packsize = sizeof(ServerDzSetDuration_Struct); - auto pack = std::make_unique(ServerOP_DzDurationUpdate, packsize); - auto packbuf = reinterpret_cast(pack->pBuffer); - packbuf->dz_id = GetID(); - packbuf->seconds = static_cast(m_duration.count()); - zoneserver_list.SendPacket(pack.get()); -} - -void DynamicZone::HandleZoneMessage(ServerPacket* pack) -{ - switch (pack->opcode) - { - case ServerOP_DzSetCompass: - case ServerOP_DzSetSafeReturn: - case ServerOP_DzSetZoneIn: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id); - if (dz) - { - if (pack->opcode == ServerOP_DzSetCompass) - { - dz->SetCompass(buf->zone_id, buf->x, buf->y, buf->z, false); - } - else if (pack->opcode == ServerOP_DzSetSafeReturn) - { - dz->SetSafeReturn(buf->zone_id, buf->x, buf->y, buf->z, buf->heading, false); - } - else if (pack->opcode == ServerOP_DzSetZoneIn) - { - dz->SetZoneInLocation(buf->x, buf->y, buf->z, buf->heading, false); - } - } - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_DzAddRemoveCharacter: - case ServerOP_DzRemoveAllCharacters: - { - auto buf = reinterpret_cast(pack->pBuffer); - ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(buf->instance_id); - if (instance_zs) - { - instance_zs->SendPacket(pack); - } - break; - } - case ServerOP_DzSetSecondsRemaining: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id); - if (dz) - { - dz->SetSecondsRemaining(buf->seconds); - } - break; - } - }; -} - -void DynamicZone::SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) -{ - ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(GetInstanceID()); - if (instance_zs) - { - auto pack = CreateServerAddRemoveCharacterPacket(character_id, remove); - instance_zs->SendPacket(pack.get()); - } -} - -void DynamicZone::SendInstanceRemoveAllCharacters() -{ - ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(GetInstanceID()); - if (instance_zs) - { - auto pack = CreateServerRemoveAllCharactersPacket(); - instance_zs->SendPacket(pack.get()); - } -} - -void DynamicZone::SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) -{ - auto pack = CreateServerDzLocationPacket(server_opcode, location); - zoneserver_list.SendPacket(pack.get()); -} diff --git a/world/dynamic_zone.h b/world/dynamic_zone.h deleted file mode 100644 index 60eb5b65a..000000000 --- a/world/dynamic_zone.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef WORLD_DYNAMIC_ZONE_H -#define WORLD_DYNAMIC_ZONE_H - -#include "../common/dynamic_zone_base.h" - -class Database; -class ServerPacket; - -enum class DynamicZoneStatus -{ - Unknown = 0, - Normal, - Expired, - ExpiredEmpty, -}; - -class DynamicZone : public DynamicZoneBase -{ -public: - using DynamicZoneBase::DynamicZoneBase; // inherit base constructors - - static DynamicZone* FindDynamicZoneByID(uint32_t dz_id); - static void HandleZoneMessage(ServerPacket* pack); - - void SetSecondsRemaining(uint32_t seconds_remaining) override; - - DynamicZoneStatus Process(bool force_expire); - -protected: - Database& GetDatabase() override; - void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override; - void SendInstanceRemoveAllCharacters() override; - void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override; - -private: - void SendZonesDurationUpdate(); - - bool m_is_pending_early_shutdown = false; -}; - -#endif diff --git a/world/expedition.cpp b/world/expedition.cpp deleted file mode 100644 index a68ddd093..000000000 --- a/world/expedition.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition.h" -#include "expedition_database.h" -#include "cliententry.h" -#include "clientlist.h" -#include "zonelist.h" -#include "zoneserver.h" -#include "../common/eqemu_logsys.h" -#include "../common/rulesys.h" - -extern ClientList client_list; -extern ZSList zoneserver_list; - -Expedition::Expedition() : - m_choose_leader_cooldown_timer{ static_cast(RuleI(Expedition, ChooseLeaderCooldownTime)) } -{ - m_warning_cooldown_timer.Enable(); -} - -void Expedition::SetDynamicZone(DynamicZone&& dz) -{ - dz.SetName(GetName()); - dz.SetLeaderName(GetLeaderName()); - - m_dynamic_zone = std::move(dz); -} - -void Expedition::RemoveMember(uint32_t character_id) -{ - RemoveInternalMember(character_id); - - if (character_id == m_leader.id) - { - ChooseNewLeader(); - } -} - -void Expedition::ChooseNewLeader() -{ - if (m_members.empty() || !m_choose_leader_cooldown_timer.Check()) - { - m_choose_leader_needed = true; - return; - } - - auto it = std::find_if(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { - if (member.id != m_leader.id && member.IsOnline()) { - auto member_cle = client_list.FindCLEByCharacterID(member.id); - return (member_cle && member_cle->GetOnline() == CLE_Status::InZone); - } - return false; - }); - - if (it == m_members.end()) - { - // no online members found, fallback to choosing any member - it = std::find_if(m_members.begin(), m_members.end(), - [&](const DynamicZoneMember& member) { return (member.id != m_leader.id); }); - } - - if (it != m_members.end() && SetNewLeader(*it)) - { - m_choose_leader_needed = false; - } -} - -bool Expedition::SetNewLeader(const DynamicZoneMember& member) -{ - if (!HasMember(member.id)) - { - return false; - } - - LogExpeditionsModerate("Replacing [{}] leader [{}] with [{}]", m_id, m_leader.name, member.name); - ExpeditionDatabase::UpdateLeaderID(m_id, member.id); - m_leader = member; - m_dynamic_zone.SetLeaderName(m_leader.name); - SendZonesLeaderChanged(); - return true; -} - -void Expedition::SendZonesExpeditionDeleted() -{ - uint32_t pack_size = sizeof(ServerExpeditionID_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionDeleted, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - zoneserver_list.SendPacket(pack.get()); -} - -void Expedition::SendZonesExpireWarning(uint32_t minutes_remaining) -{ - uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionExpireWarning, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->minutes_remaining = minutes_remaining; - zoneserver_list.SendPacket(pack.get()); -} - -void Expedition::SendZonesLeaderChanged() -{ - uint32_t pack_size = sizeof(ServerExpeditionLeaderID_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionLeaderChanged, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->leader_id = m_leader.id; - zoneserver_list.SendPacket(pack.get()); -} - -void Expedition::CheckExpireWarning() -{ - if (m_warning_cooldown_timer.Check(false)) - { - using namespace std::chrono_literals; - auto remaining = GetDynamicZone().GetDurationRemaining(); - if ((remaining > 14min && remaining < 15min) || - (remaining > 4min && remaining < 5min) || - (remaining > 0min && remaining < 1min)) - { - int minutes = std::chrono::duration_cast(remaining).count() + 1; - SendZonesExpireWarning(minutes); - m_warning_cooldown_timer.Start(70000); // 1 minute 10 seconds - } - } -} - -void Expedition::CheckLeader() -{ - if (m_choose_leader_needed) - { - ChooseNewLeader(); - } -} - -bool Expedition::Process() -{ - // returns true if expedition needs to be deleted from world cache and db - // expedition is not deleted until its dz has no clients to prevent exploits - auto status = m_dynamic_zone.Process(IsEmpty()); // force expire if no members - if (status == DynamicZoneStatus::ExpiredEmpty) - { - LogExpeditions("Expedition [{}] expired or empty, notifying zones and deleting", GetID()); - SendZonesExpeditionDeleted(); - return true; - } - - CheckExpireWarning(); - CheckLeader(); - - return false; -} - -void Expedition::UpdateMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status) -{ - SetInternalMemberStatus(character_id, status); - - // any member status update will trigger a leader fix if leader was offline - if (m_leader.status == DynamicZoneMemberStatus::Offline) - { - ChooseNewLeader(); - } -} - -void Expedition::SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id) -{ - const auto& members = GetMembers(); - - uint32_t members_count = static_cast(members.size()); - uint32_t entries_size = sizeof(ServerExpeditionMemberStatusEntry_Struct) * members_count; - uint32_t pack_size = sizeof(ServerExpeditionMemberStatuses_Struct) + entries_size; - auto pack = std::make_unique(ServerOP_ExpeditionGetMemberStatuses, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->count = members_count; - - for (int i = 0; i < members.size(); ++i) - { - buf->entries[i].character_id = members[i].id; - buf->entries[i].online_status = static_cast(members[i].status); - } - - zoneserver_list.SendPacket(zone_id, instance_id, pack.get()); -} - -void Expedition::CacheMemberStatuses() -{ - // called when a new expedition is cached to fill member statuses - std::string zone_name{}; - std::vector all_clients; - all_clients.reserve(client_list.GetClientCount()); - client_list.GetClients(zone_name.c_str(), all_clients); - - for (const auto& member : m_members) - { - auto it = std::find_if(all_clients.begin(), all_clients.end(), - [&](const ClientListEntry* cle) { return (cle && cle->CharID() == member.id); }); - - auto status = DynamicZoneMemberStatus::Offline; - if (it != all_clients.end()) - { - status = DynamicZoneMemberStatus::Online; - if (GetDynamicZone().IsSameDz((*it)->zone(), (*it)->instance())) - { - status = DynamicZoneMemberStatus::InDynamicZone; - } - } - - SetInternalMemberStatus(member.id, status); - } -} diff --git a/world/expedition.h b/world/expedition.h deleted file mode 100644 index 119f78685..000000000 --- a/world/expedition.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef WORLD_EXPEDITION_H -#define WORLD_EXPEDITION_H - -#include "dynamic_zone.h" -#include "../common/expedition_base.h" -#include "../common/timer.h" -#include - -class Expedition : public ExpeditionBase -{ -public: - Expedition(); - - void RemoveMember(uint32_t character_id); - void CacheMemberStatuses(); - void CheckExpireWarning(); - void CheckLeader(); - void ChooseNewLeader(); - DynamicZone& GetDynamicZone() { return m_dynamic_zone; } - bool Process(); - void SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id); - void SendZonesExpeditionDeleted(); - void SendZonesExpireWarning(uint32_t minutes_remaining); - void SetDynamicZone(DynamicZone&& dz); - bool SetNewLeader(const DynamicZoneMember& member); - void UpdateMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status); - -private: - void SendZonesLeaderChanged(); - - bool m_choose_leader_needed = false; - Timer m_choose_leader_cooldown_timer; - Timer m_warning_cooldown_timer; - DynamicZone m_dynamic_zone; -}; - -#endif diff --git a/world/expedition_database.cpp b/world/expedition_database.cpp deleted file mode 100644 index c3738901a..000000000 --- a/world/expedition_database.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition_database.h" -#include "expedition.h" -#include "worlddb.h" - -void ExpeditionDatabase::PurgeExpiredExpeditions() -{ - std::string query = SQL( - SELECT - expeditions.id - FROM expeditions - LEFT JOIN dynamic_zones ON expeditions.dynamic_zone_id = dynamic_zones.id - LEFT JOIN instance_list ON dynamic_zones.instance_id = instance_list.id - LEFT JOIN - ( - SELECT expedition_id, COUNT(IF(is_current_member = TRUE, 1, NULL)) member_count - FROM expedition_members - GROUP BY expedition_id - ) expedition_members - ON expedition_members.expedition_id = expeditions.id - WHERE - instance_list.id IS NULL - OR expedition_members.member_count IS NULL - OR expedition_members.member_count = 0 - OR (instance_list.start_time + instance_list.duration) <= UNIX_TIMESTAMP(); - ); - - auto results = database.QueryDatabase(query); - if (results.Success()) - { - std::vector expedition_ids; - for (auto row = results.begin(); row != results.end(); ++row) - { - expedition_ids.emplace_back(static_cast(strtoul(row[0], nullptr, 10))); - } - - if (!expedition_ids.empty()) - { - ExpeditionDatabase::MoveMembersToSafeReturn(expedition_ids); - ExpeditionDatabase::DeleteExpeditions(expedition_ids); - } - } -} - -void ExpeditionDatabase::PurgeExpiredCharacterLockouts() -{ - std::string query = SQL( - DELETE FROM character_expedition_lockouts - WHERE expire_time <= NOW(); - ); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::DeleteExpeditions(const std::vector& expedition_ids) -{ - LogExpeditionsDetail("Deleting [{}] expedition(s)", expedition_ids.size()); - - std::string expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ",")); - - if (!expedition_ids_query.empty()) - { - auto query = fmt::format("DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query); - database.QueryDatabase(query); - - query = fmt::format("DELETE FROM expedition_members WHERE expedition_id IN ({});", expedition_ids_query); - database.QueryDatabase(query); - - query = fmt::format("DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_query); - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::UpdateLeaderID(uint32_t expedition_id, uint32_t leader_id) -{ - LogExpeditionsDetail("Updating leader [{}] for expedition [{}]", leader_id, expedition_id); - - auto query = fmt::format(SQL( - UPDATE expeditions SET leader_id = {} WHERE id = {}; - ), leader_id, expedition_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::MoveMembersToSafeReturn(const std::vector& expedition_ids) -{ - LogExpeditionsDetail("Moving members from [{}] expedition(s) to safereturn", expedition_ids.size()); - - // only offline members still in expired dz zones should be updated here - std::string query = fmt::format(SQL( - UPDATE character_data - INNER JOIN expedition_members ON character_data.id = expedition_members.character_id - INNER JOIN expeditions ON expedition_members.expedition_id = expeditions.id - INNER JOIN dynamic_zones ON expeditions.dynamic_zone_id = dynamic_zones.id - INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id - AND character_data.zone_instance = instance_list.id - AND character_data.zone_id = instance_list.zone - SET - zone_id = IF(safe_return_zone_id > 0, safe_return_zone_id, zone_id), - zone_instance = IF(safe_return_zone_id > 0, 0, zone_instance), - x = IF(safe_return_zone_id > 0, safe_return_x, x), - y = IF(safe_return_zone_id > 0, safe_return_y, y), - z = IF(safe_return_zone_id > 0, safe_return_z, z), - heading = IF(safe_return_zone_id > 0, safe_return_heading, heading) - WHERE expeditions.id IN ({}); - ), fmt::join(expedition_ids, ",")); - - database.QueryDatabase(query); -} diff --git a/world/expedition_database.h b/world/expedition_database.h deleted file mode 100644 index b86fd8b5d..000000000 --- a/world/expedition_database.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef WORLD_EXPEDITION_DATABASE_H -#define WORLD_EXPEDITION_DATABASE_H - -#include -#include - -class Expedition; - -namespace ExpeditionDatabase -{ - void DeleteExpeditions(const std::vector& expedition_ids); - void MoveMembersToSafeReturn(const std::vector& expedition_ids); - void PurgeExpiredExpeditions(); - void PurgeExpiredCharacterLockouts(); - void UpdateLeaderID(uint32_t expedition_id, uint32_t leader_id); -}; - -#endif diff --git a/world/expedition_message.cpp b/world/expedition_message.cpp deleted file mode 100644 index 36eee5ceb..000000000 --- a/world/expedition_message.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition.h" -#include "expedition_message.h" -#include "expedition_state.h" -#include "cliententry.h" -#include "clientlist.h" -#include "zonelist.h" -#include "zoneserver.h" -#include "../common/servertalk.h" -#include - -extern ClientList client_list; -extern ZSList zoneserver_list; - -void ExpeditionMessage::HandleZoneMessage(ServerPacket* pack) -{ - switch (pack->opcode) - { - case ServerOP_ExpeditionCreate: - { - auto buf = reinterpret_cast(pack->pBuffer); - expedition_state.CacheFromDatabase(buf->expedition_id); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionMemberChange: - { - auto buf = reinterpret_cast(pack->pBuffer); - expedition_state.MemberChange(buf->expedition_id, { buf->char_id, buf->char_name }, buf->removed); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionMemberSwap: - { - auto buf = reinterpret_cast(pack->pBuffer); - expedition_state.MemberChange(buf->expedition_id, { buf->add_char_id, buf->add_char_name }, false); - expedition_state.MemberChange(buf->expedition_id, { buf->remove_char_id, buf->remove_char_name }, true); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionMembersRemoved: - { - auto buf = reinterpret_cast(pack->pBuffer); - expedition_state.RemoveAllMembers(buf->expedition_id); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionMemberStatus: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = expedition_state.GetExpedition(buf->expedition_id); - if (expedition) - { - auto status = static_cast(buf->status); - expedition->UpdateMemberStatus(buf->character_id, status); - } - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionGetMemberStatuses: - { - ExpeditionMessage::GetMemberStatuses(pack); - break; - } - case ServerOP_ExpeditionDzAddPlayer: - { - ExpeditionMessage::AddPlayer(pack); - break; - } - case ServerOP_ExpeditionDzMakeLeader: - { - ExpeditionMessage::MakeLeader(pack); - break; - } - case ServerOP_ExpeditionCharacterLockout: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto cle = client_list.FindCLEByCharacterID(buf->character_id); - if (cle && cle->Server()) - { - cle->Server()->SendPacket(pack); - } - break; - } - case ServerOP_ExpeditionSaveInvite: - { - ExpeditionMessage::SaveInvite(pack); - break; - } - case ServerOP_ExpeditionRequestInvite: - { - ExpeditionMessage::RequestInvite(pack); - break; - } - } -} - -void ExpeditionMessage::AddPlayer(ServerPacket* pack) -{ - auto buf = reinterpret_cast(pack->pBuffer); - - ClientListEntry* invited_cle = client_list.FindCharacter(buf->target_name); - if (invited_cle && invited_cle->Server()) - { - // continue in the add target's zone - buf->is_char_online = true; - invited_cle->Server()->SendPacket(pack); - } - else - { - // add target not online, return to inviter - ClientListEntry* inviter_cle = client_list.FindCharacter(buf->requester_name); - if (inviter_cle && inviter_cle->Server()) - { - inviter_cle->Server()->SendPacket(pack); - } - } -} - -void ExpeditionMessage::MakeLeader(ServerPacket* pack) -{ - auto buf = reinterpret_cast(pack->pBuffer); - - // notify requester (old leader) and new leader of the result - ZoneServer* new_leader_zs = nullptr; - ClientListEntry* new_leader_cle = client_list.FindCharacter(buf->new_leader_name); - if (new_leader_cle && new_leader_cle->Server()) - { - auto expedition = expedition_state.GetExpedition(buf->expedition_id); - if (expedition) - { - buf->is_success = expedition->SetNewLeader({ new_leader_cle->CharID(), new_leader_cle->name() }); - } - - buf->is_online = true; - new_leader_zs = new_leader_cle->Server(); - new_leader_zs->SendPacket(pack); - } - - // if old and new leader are in the same zone only send one message - ClientListEntry* requester_cle = client_list.FindCLEByCharacterID(buf->requester_id); - if (requester_cle && requester_cle->Server() && requester_cle->Server() != new_leader_zs) - { - requester_cle->Server()->SendPacket(pack); - } -} - -void ExpeditionMessage::GetMemberStatuses(ServerPacket* pack) -{ - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = expedition_state.GetExpedition(buf->expedition_id); - if (expedition) - { - expedition->SendZoneMemberStatuses(buf->sender_zone_id, buf->sender_instance_id); - } -} - -void ExpeditionMessage::SaveInvite(ServerPacket* pack) -{ - auto buf = reinterpret_cast(pack->pBuffer); - - ClientListEntry* invited_cle = client_list.FindCharacter(buf->target_name); - if (invited_cle) - { - // store packet on cle and re-send it when client requests it - buf->is_char_online = true; - pack->opcode = ServerOP_ExpeditionDzAddPlayer; - invited_cle->SetPendingExpeditionInvite(pack); - } -} - -void ExpeditionMessage::RequestInvite(ServerPacket* pack) -{ - auto buf = reinterpret_cast(pack->pBuffer); - ClientListEntry* cle = client_list.FindCLEByCharacterID(buf->character_id); - if (cle) - { - auto invite_pack = cle->GetPendingExpeditionInvite(); - if (invite_pack && cle->Server()) - { - cle->Server()->SendPacket(invite_pack.get()); - } - } -} diff --git a/world/expedition_message.h b/world/expedition_message.h deleted file mode 100644 index 135ef0cba..000000000 --- a/world/expedition_message.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef WORLD_EXPEDITION_MESSAGE_H -#define WORLD_EXPEDITION_MESSAGE_H - -class ServerPacket; - -namespace ExpeditionMessage -{ - void AddPlayer(ServerPacket* pack); - void GetMemberStatuses(ServerPacket* pack); - void HandleZoneMessage(ServerPacket* pack); - void MakeLeader(ServerPacket* pack); - void RequestInvite(ServerPacket* pack); - void SaveInvite(ServerPacket* pack); -}; - -#endif diff --git a/world/expedition_state.cpp b/world/expedition_state.cpp deleted file mode 100644 index 8f3b6b423..000000000 --- a/world/expedition_state.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition_state.h" -#include "expedition.h" -#include "expedition_database.h" -#include "worlddb.h" -#include "../common/eqemu_logsys.h" -#include "../common/repositories/expedition_members_repository.h" -#include - -ExpeditionState expedition_state; - -Expedition* ExpeditionState::GetExpedition(uint32_t expedition_id) -{ - auto it = std::find_if(m_expeditions.begin(), m_expeditions.end(), - [&](const std::unique_ptr& expedition) { - return expedition->GetID() == expedition_id; - }); - - return (it != m_expeditions.end()) ? it->get() : nullptr; -} - -Expedition* ExpeditionState::GetExpeditionByDynamicZoneID(uint32_t dz_id) -{ - auto it = std::find_if(m_expeditions.begin(), m_expeditions.end(), - [&](const std::unique_ptr& expedition) { - return expedition->GetDynamicZone().GetID() == dz_id; - }); - - return (it != m_expeditions.end()) ? it->get() : nullptr; -} - -void ExpeditionState::CacheFromDatabase(uint32_t expedition_id) -{ - if (expedition_id == 0 || GetExpedition(expedition_id)) - { - return; - } - - auto expedition = ExpeditionsRepository::GetWithLeaderName(database, expedition_id); - CacheExpeditions({ std::move(expedition) }); -} - -void ExpeditionState::CacheAllFromDatabase() -{ - BenchTimer benchmark; - - auto expeditions = ExpeditionsRepository::GetAllWithLeaderName(database); - m_expeditions.clear(); - m_expeditions.reserve(expeditions.size()); - - CacheExpeditions(std::move(expeditions)); - - LogExpeditions("Caching [{}] expedition(s) took [{}s]", m_expeditions.size(), benchmark.elapsed()); -} - -void ExpeditionState::CacheExpeditions( - std::vector&& expedition_entries) -{ - // bulk load expedition dzs and members before caching - std::vector expedition_ids; - std::vector dynamic_zone_ids; - for (const auto& entry : expedition_entries) - { - expedition_ids.emplace_back(entry.id); - dynamic_zone_ids.emplace_back(entry.dynamic_zone_id); - } - - auto dynamic_zones = DynamicZonesRepository::GetWithInstance(database, dynamic_zone_ids); - auto expedition_members = ExpeditionMembersRepository::GetWithNames(database, expedition_ids); - - for (auto& entry : expedition_entries) - { - auto expedition = std::make_unique(); - expedition->LoadRepositoryResult(std::move(entry)); - - auto dz_entry_iter = std::find_if(dynamic_zones.begin(), dynamic_zones.end(), - [&](const DynamicZonesRepository::DynamicZoneInstance& dz_entry) { - return dz_entry.id == entry.dynamic_zone_id; - }); - - if (dz_entry_iter != dynamic_zones.end()) - { - expedition->SetDynamicZone(std::move(*dz_entry_iter)); - } - - for (auto& member : expedition_members) - { - if (member.expedition_id == expedition->GetID()) - { - expedition->AddMemberFromRepositoryResult(std::move(member)); - } - } - - // stored on expedition in db but on dz in memory cache - expedition->GetDynamicZone().SetMinPlayers(entry.min_players); - expedition->GetDynamicZone().SetMaxPlayers(entry.max_players); - - expedition->CacheMemberStatuses(); - - m_expeditions.emplace_back(std::move(expedition)); - } -} - -void ExpeditionState::MemberChange( - uint32_t expedition_id, const DynamicZoneMember& member, bool remove) -{ - auto expedition = GetExpedition(expedition_id); - if (expedition) - { - if (remove) { - expedition->RemoveMember(member.id); - } else { - expedition->AddInternalMember(member); - } - } -} - -void ExpeditionState::RemoveAllMembers(uint32_t expedition_id) -{ - auto expedition = GetExpedition(expedition_id); - if (expedition) - { - expedition->ClearInternalMembers(); - } -} - -void ExpeditionState::Process() -{ - if (!m_process_throttle_timer.Check()) - { - return; - } - - std::vector expedition_ids; - - for (auto it = m_expeditions.begin(); it != m_expeditions.end();) - { - bool is_deleted = (*it)->Process(); - if (is_deleted) - { - expedition_ids.emplace_back((*it)->GetID()); - } - it = is_deleted ? m_expeditions.erase(it) : it + 1; - } - - if (!expedition_ids.empty()) - { - ExpeditionDatabase::MoveMembersToSafeReturn(expedition_ids); - ExpeditionDatabase::DeleteExpeditions(expedition_ids); - } -} diff --git a/world/expedition_state.h b/world/expedition_state.h deleted file mode 100644 index 90f4a4293..000000000 --- a/world/expedition_state.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef WORLD_EXPEDITION_STATE_H -#define WORLD_EXPEDITION_STATE_H - -#include "../common/repositories/expeditions_repository.h" -#include "../common/rulesys.h" -#include "../common/timer.h" -#include -#include - -extern class ExpeditionState expedition_state; - -class Expedition; -struct DynamicZoneMember; - -class ExpeditionState -{ -public: - void CacheExpeditions(std::vector&& expedition_entries); - void CacheFromDatabase(uint32_t expedition_id); - void CacheAllFromDatabase(); - Expedition* GetExpedition(uint32_t expedition_id); - Expedition* GetExpeditionByDynamicZoneID(uint32_t dz_id); - void MemberChange(uint32_t expedition_id, const DynamicZoneMember& member, bool remove); - void Process(); - void RemoveAllMembers(uint32_t expedition_id); - -private: - std::vector> m_expeditions; - Timer m_process_throttle_timer{static_cast(RuleI(DynamicZone, WorldProcessRate))}; -}; - -#endif diff --git a/world/launcher_link.cpp b/world/launcher_link.cpp index 8f3fa1aaf..d60933b41 100644 --- a/world/launcher_link.cpp +++ b/world/launcher_link.cpp @@ -45,7 +45,7 @@ LauncherLink::LauncherLink(int id, std::shared_ptrOnMessage(std::bind(&LauncherLink::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_process_timer = std::make_unique(100, true, std::bind(&LauncherLink::Process, this, std::placeholders::_1)); + m_process_timer.reset(new EQ::Timer(100, true, std::bind(&LauncherLink::Process, this, std::placeholders::_1))); } LauncherLink::~LauncherLink() { @@ -296,4 +296,4 @@ void LauncherLink::Shutdown() { auto pack = new ServerPacket(ServerOP_ShutdownAll); SendPacket(pack); delete pack; -} +} \ No newline at end of file diff --git a/world/login_server.cpp b/world/login_server.cpp index da649495e..2533a9bad 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -92,7 +92,7 @@ void LoginServer::ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p) utwrs->response = UserToWorldStatusSuccess; if (Config->Locked) { - if (status < (RuleI(GM, MinStatusToBypassLockedServer))) { + if (status < 100) { LogDebug("[ProcessUsertoWorldReqLeg] Server locked and status is not high enough for account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusWorldUnavail; SendPacket(&outpack); @@ -101,7 +101,7 @@ void LoginServer::ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p) } int32 x = Config->MaxClients; - if ((int32) numplayers >= x && x != -1 && x != 255 && status < (RuleI(GM, MinStatusToBypassLockedServer))) { + if ((int32) numplayers >= x && x != -1 && x != 255 && status < 80) { LogDebug("[ProcessUsertoWorldReqLeg] World at capacity account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusWorldAtCapacity; SendPacket(&outpack); @@ -170,7 +170,7 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) utwrs->response = UserToWorldStatusSuccess; if (Config->Locked == true) { - if (status < (RuleI(GM, MinStatusToBypassLockedServer))) { + if (status < 100) { LogDebug("[ProcessUsertoWorldReq] Server locked and status is not high enough for account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusWorldUnavail; SendPacket(&outpack); @@ -179,7 +179,7 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) } int32 x = Config->MaxClients; - if ((int32) numplayers >= x && x != -1 && x != 255 && status < (RuleI(GM, MinStatusToBypassLockedServer))) { + if ((int32) numplayers >= x && x != -1 && x != 255 && status < 80) { LogDebug("[ProcessUsertoWorldReq] World at capacity account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusWorldAtCapacity; SendPacket(&outpack); @@ -342,7 +342,7 @@ bool LoginServer::Connect() } if (IsLegacy) { - legacy_client = std::make_unique(LoginServerAddress, LoginServerPort, false); + legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false)); legacy_client->OnConnect( [this](EQ::Net::ServertalkLegacyClient *client) { if (client) { @@ -356,12 +356,12 @@ bool LoginServer::Connect() SendStatus(); zoneserver_list.SendLSZones(); - statusupdate_timer = std::make_unique( - + statusupdate_timer.reset( + new EQ::Timer( LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) { SendStatus(); } - + ) ); } else { @@ -448,7 +448,7 @@ bool LoginServer::Connect() ); } else { - client = std::make_unique(LoginServerAddress, LoginServerPort, false, "World", ""); + client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", "")); client->OnConnect( [this](EQ::Net::ServertalkClient *client) { if (client) { @@ -461,12 +461,12 @@ bool LoginServer::Connect() SendStatus(); zoneserver_list.SendLSZones(); - statusupdate_timer = std::make_unique( - + statusupdate_timer.reset( + new EQ::Timer( LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) { SendStatus(); } - ); + )); } else { LogInfo( @@ -552,7 +552,7 @@ bool LoginServer::Connect() ); } - m_keepalive = std::make_unique(5000, true, std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1)); + m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1))); return true; } @@ -649,4 +649,4 @@ void LoginServer::OnKeepAlive(EQ::Timer *t) { ServerPacket pack(ServerOP_KeepAlive, 0); SendPacket(&pack); -} +} \ No newline at end of file diff --git a/world/main.cpp b/world/main.cpp index f150db0e4..49e02859f 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -88,8 +88,6 @@ union semun { #include "queryserv.h" #include "web_interface.h" #include "console.h" -#include "expedition_database.h" -#include "expedition_state.h" #include "../common/net/servertalk_server.h" #include "../zone/data_bucket.h" @@ -97,7 +95,6 @@ union semun { #include "../common/content/world_content_service.h" #include "../common/repositories/merchantlist_temp_repository.h" #include "world_store.h" -#include "world_event_scheduler.h" WorldStore world_store; ClientList client_list; @@ -108,7 +105,6 @@ UCSConnection UCSLink; QueryServConnection QSLink; LauncherList launcher_list; AdventureManager adventure_manager; -WorldEventScheduler event_scheduler; EQ::Random emu_random; volatile bool RunLoops = true; uint32 numclients = 0; @@ -348,6 +344,9 @@ int main(int argc, char** argv) { database.ClearInvSnapshots(); LogInfo("Loading items"); + LogInfo("Purging player sold merchant items"); + MerchantlistTempRepository::Truncate(); + if (!content_db.LoadItems(hotfix_name)) { LogError("Error: Could not load item data. But ignoring"); } @@ -427,35 +426,26 @@ int main(int argc, char** argv) { adventure_manager.LoadLeaderboardInfo(); - LogInfo("Purging expired expeditions"); - ExpeditionDatabase::PurgeExpiredExpeditions(); - ExpeditionDatabase::PurgeExpiredCharacterLockouts(); - LogInfo("Purging expired instances"); database.PurgeExpiredInstances(); Timer PurgeInstanceTimer(450000); PurgeInstanceTimer.Start(450000); - LogInfo("Loading active expeditions"); - expedition_state.CacheAllFromDatabase(); - LogInfo("Loading char create info"); content_db.LoadCharacterCreateAllocations(); content_db.LoadCharacterCreateCombos(); - event_scheduler.SetDatabase(&database)->LoadScheduledEvents(); - std::unique_ptr console; if (Config->TelnetEnabled) { LogInfo("Console (TCP) listener started"); - console = std::make_unique(Config->TelnetIP, Config->TelnetTCPPort); + console.reset(new EQ::Net::ConsoleServer(Config->TelnetIP, Config->TelnetTCPPort)); RegisterConsoleFunctions(console); } zoneserver_list.Init(); std::unique_ptr server_connection; - server_connection = std::make_unique(); + server_connection.reset(new EQ::Net::ServertalkServer()); EQ::Net::ServertalkServerOptions server_opts; server_opts.port = Config->WorldTCPPort; @@ -607,14 +597,11 @@ int main(int argc, char** argv) { } } - event_scheduler.Process(&zoneserver_list); - client_list.Process(); if (PurgeInstanceTimer.Check()) { database.PurgeExpiredInstances(); database.PurgeAllDeletedDataBuckets(); - ExpeditionDatabase::PurgeExpiredCharacterLockouts(); } if (EQTimeTimer.Check()) { @@ -630,7 +617,6 @@ int main(int argc, char** argv) { launcher_list.Process(); LFPGroupList.Process(); adventure_manager.Process(); - expedition_state.Process(); if (InterserverTimer.Check()) { InterserverTimer.Start(); diff --git a/world/ucs.cpp b/world/ucs.cpp index 0af363051..170e49dea 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -32,7 +32,7 @@ void UCSConnection::SetConnection(std::shared_ptr(1000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1)); + m_keepalive.reset(new EQ::Timer(1000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1))); } const std::shared_ptr &UCSConnection::GetConnection() const diff --git a/world/web_interface.cpp b/world/web_interface.cpp index 234031770..773e955b6 100644 --- a/world/web_interface.cpp +++ b/world/web_interface.cpp @@ -146,7 +146,7 @@ WebInterfaceList::~WebInterfaceList() void WebInterfaceList::AddConnection(std::shared_ptr connection) { - m_interfaces.insert(std::make_pair(connection->GetUUID(), std::make_unique(connection))); + m_interfaces.insert(std::make_pair(connection->GetUUID(), std::unique_ptr(new WebInterface(connection)))); } void WebInterfaceList::RemoveConnection(std::shared_ptr connection) diff --git a/world/world_event_scheduler.cpp b/world/world_event_scheduler.cpp deleted file mode 100644 index d32d44758..000000000 --- a/world/world_event_scheduler.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "world_event_scheduler.h" -#include "../common/servertalk.h" -#include - -void WorldEventScheduler::Process(ZSList *zs_list) -{ - std::time_t time = std::time(nullptr); - std::tm *now = std::localtime(&time); - - // once a minute polling - if (m_last_polled_minute != now->tm_min) { - - // refresh; world polls and tells zones if they should update if there is a change - if (CheckIfEventsChanged()) { - LogSchedulerDetail("Event changes detected, forcing zones to refresh their schedules..."); - auto pack = new ServerPacket(ServerOP_UpdateSchedulerEvents, 0); - zs_list->SendPacket(pack); - safe_delete(pack); - } - - int month = (now->tm_mon + 1); - int year = (now->tm_year + 1900); - - LogSchedulerDetail( - "Polling year [{}] month [{}] day [{}] hour [{}] minute [{}]", - year, - month, - now->tm_mday, - now->tm_hour, - now->tm_min - ); - - for (auto &e: m_events) { - - // discard uninteresting events as its less work to calculate time on events we don't care about - // different processes are interested in different events - if ( - e.event_type != ServerEvents::EVENT_TYPE_BROADCAST && - e.event_type != ServerEvents::EVENT_TYPE_RELOAD_WORLD - ) { - continue; - } - - // validate event is ready to activate and run it - if (ValidateEventReadyToActivate(e)) { - if (e.event_type == ServerEvents::EVENT_TYPE_BROADCAST) { - LogScheduler("Sending broadcast [{}]", e.event_data.c_str()); - zs_list->SendEmoteMessage(nullptr, 0, 0, 15, e.event_data.c_str()); - } - - if (e.event_type == ServerEvents::EVENT_TYPE_RELOAD_WORLD) { - LogScheduler("Sending reload world event [{}]", e.event_data.c_str()); - - auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct)); - auto *reload_world = (ReloadWorld_Struct *) pack->pBuffer; - reload_world->Option = 1; - zs_list->SendPacket(pack); - safe_delete(pack); - } - } - } - - m_last_polled_minute = now->tm_min; - } -} diff --git a/world/world_event_scheduler.h b/world/world_event_scheduler.h deleted file mode 100644 index b2a6725df..000000000 --- a/world/world_event_scheduler.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef EQEMU_EVENT_SCHEDULER_H -#define EQEMU_EVENT_SCHEDULER_H - -#include "../common/server_event_scheduler.h" -#include "zonelist.h" - -class WorldEventScheduler : public ServerEventScheduler { -public: - void Process(ZSList *zs_list); -}; - -#endif //EQEMU_EVENT_SCHEDULER_H diff --git a/world/world_server_command_handler.cpp b/world/world_server_command_handler.cpp index b5d226664..0d1eecafc 100644 --- a/world/world_server_command_handler.cpp +++ b/world/world_server_command_handler.cpp @@ -355,14 +355,14 @@ namespace WorldserverCommandHandler { instance_list_entry.duration = 0; instance_list_entry.never_expires = 1; - auto instance_list_inserted = InstanceListRepository::InsertOne(database, instance_list_entry); + auto instance_list_inserted = InstanceListRepository::InsertOne(instance_list_entry); LogInfo("Inserted ID is [{}] zone [{}]", instance_list_inserted.id, instance_list_inserted.zone); /** * Find one */ - auto found_instance_list = InstanceListRepository::FindOne(database, instance_list_inserted.id); + auto found_instance_list = InstanceListRepository::FindOne(instance_list_inserted.id); LogInfo("Found ID is [{}] zone [{}]", found_instance_list.id, found_instance_list.zone); @@ -371,7 +371,7 @@ namespace WorldserverCommandHandler { */ LogInfo("Updating instance id [{}] zone [{}]", found_instance_list.id, found_instance_list.zone); - int update_instance_list_count = InstanceListRepository::UpdateOne(database, found_instance_list); + int update_instance_list_count = InstanceListRepository::UpdateOne(found_instance_list); found_instance_list.zone = 777; @@ -386,7 +386,7 @@ namespace WorldserverCommandHandler { /** * Delete one */ - int deleted = InstanceListRepository::DeleteOne(database, found_instance_list.id); + int deleted = InstanceListRepository::DeleteOne(found_instance_list.id); LogInfo("Deleting one instance [{}] deleted count [{}]", found_instance_list.id, deleted); @@ -411,18 +411,18 @@ namespace WorldserverCommandHandler { /** * Fetch all */ - int inserted_count = InstanceListRepository::InsertMany(database, instance_lists); + int inserted_count = InstanceListRepository::InsertMany(instance_lists); LogInfo("Bulk insertion test, inserted [{}]", inserted_count); - for (auto &entry: InstanceListRepository::GetWhere(database, fmt::format("zone = {}", 999))) { + for (auto &entry: InstanceListRepository::GetWhere(fmt::format("zone = {}", 999))) { LogInfo("Iterating through entry id [{}] zone [{}]", entry.id, entry.zone); } /** * Delete where */ - int deleted_count = InstanceListRepository::DeleteWhere(database, fmt::format("zone = {}", 999)); + int deleted_count = InstanceListRepository::DeleteWhere(fmt::format("zone = {}", 999)); LogInfo("Bulk deletion test, deleted [{}]", deleted_count); @@ -442,7 +442,7 @@ namespace WorldserverCommandHandler { return; } - auto zones = ZoneRepository::GetWhere(content_db, "short_name = 'anguish'"); + auto zones = ZoneRepository::GetWhere("short_name = 'anguish'"); for (auto &zone: zones) { LogInfo( diff --git a/world/world_store.cpp b/world/world_store.cpp index 5a8201124..92be2ce95 100644 --- a/world/world_store.cpp +++ b/world/world_store.cpp @@ -25,7 +25,7 @@ WorldStore::~WorldStore() = default; void WorldStore::LoadZones() { - zones = ZoneRepository::All(content_db); + zones = ZoneRepository::All(); } uint32 WorldStore::GetZoneID(const char *in_zone_name) diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 14decb79d..7bc5a801f 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -54,48 +54,42 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o character_limit = 8; } - std::string character_list_query = fmt::format( - SQL( - SELECT - `id`, - `name`, - `gender`, - `race`, - `class`, - `level`, - `deity`, - `last_login`, - `time_played`, - `hair_color`, - `beard_color`, - `eye_color_1`, - `eye_color_2`, - `hair_style`, - `beard`, - `face`, - `drakkin_heritage`, - `drakkin_tattoo`, - `drakkin_details`, - `zone_id` - FROM - `character_data` - WHERE - `account_id` = {} - AND - `deleted_at` IS NULL - ORDER BY `name` - LIMIT {} - ), + std::string character_list_query = StringFormat( + "SELECT " + "`id`, " // 0 + "name, " // 1 + "gender, " // 2 + "race, " // 3 + "class, " // 4 + "`level`, " // 5 + "deity, " // 6 + "last_login, " // 7 + "time_played, " // 8 + "hair_color, " // 9 + "beard_color, " // 10 + "eye_color_1, " // 11 + "eye_color_2, " // 12 + "hair_style, " // 13 + "beard, " // 14 + "face, " // 15 + "drakkin_heritage, " // 16 + "drakkin_tattoo, " // 17 + "drakkin_details, " // 18 + "zone_id " // 19 + "FROM " + "character_data " + "WHERE `account_id` = %i AND deleted_at IS NULL ORDER BY `name` LIMIT %u", account_id, character_limit ); auto results = database.QueryDatabase(character_list_query); + size_t character_count = results.RowCount(); if (character_count == 0) { - *out_app = new EQApplicationPacket(OP_SendCharInfo, sizeof(CharacterSelect_Struct)); + *out_app = new EQApplicationPacket(OP_SendCharInfo, sizeof(CharacterSelect_Struct)); CharacterSelect_Struct *cs = (CharacterSelect_Struct *) (*out_app)->pBuffer; - cs->CharCount = 0; + cs->CharCount = 0; cs->TotalChars = character_limit; return; } @@ -103,181 +97,155 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o size_t packet_size = sizeof(CharacterSelect_Struct) + (sizeof(CharacterSelectEntry_Struct) * character_count); *out_app = new EQApplicationPacket(OP_SendCharInfo, packet_size); - unsigned char *buff_ptr = (*out_app)->pBuffer; - CharacterSelect_Struct *cs = (CharacterSelect_Struct *) buff_ptr; + unsigned char *buff_ptr = (*out_app)->pBuffer; + CharacterSelect_Struct *cs = (CharacterSelect_Struct *) buff_ptr; - cs->CharCount = character_count; + cs->CharCount = character_count; cs->TotalChars = character_limit; buff_ptr += sizeof(CharacterSelect_Struct); for (auto row = results.begin(); row != results.end(); ++row) { CharacterSelectEntry_Struct *p_character_select_entry_struct = (CharacterSelectEntry_Struct *) buff_ptr; - PlayerProfile_Struct player_profile_struct; - EQ::InventoryProfile inventory_profile; + PlayerProfile_Struct player_profile_struct; + EQ::InventoryProfile inventory_profile; player_profile_struct.SetPlayerProfileVersion(EQ::versions::ConvertClientVersionToMobVersion(client_version)); inventory_profile.SetInventoryVersion(client_version); inventory_profile.SetGMInventory(true); // charsel can not interact with items..but, no harm in setting to full expansion support uint32 character_id = (uint32) atoi(row[0]); - uint8 has_home = 0; - uint8 has_bind = 0; + uint8 has_home = 0; + uint8 has_bind = 0; memset(&player_profile_struct, 0, sizeof(PlayerProfile_Struct)); + memset(p_character_select_entry_struct->Name, 0, sizeof(p_character_select_entry_struct->Name)); strcpy(p_character_select_entry_struct->Name, row[1]); - p_character_select_entry_struct->Class = (uint8) atoi(row[4]); - p_character_select_entry_struct->Race = (uint32) atoi(row[3]); - p_character_select_entry_struct->Level = (uint8) atoi(row[5]); + p_character_select_entry_struct->Class = (uint8) atoi(row[4]); + p_character_select_entry_struct->Race = (uint32) atoi(row[3]); + p_character_select_entry_struct->Level = (uint8) atoi(row[5]); p_character_select_entry_struct->ShroudClass = p_character_select_entry_struct->Class; - p_character_select_entry_struct->ShroudRace = p_character_select_entry_struct->Race; - p_character_select_entry_struct->Zone = (uint16) atoi(row[19]); - p_character_select_entry_struct->Instance = 0; - p_character_select_entry_struct->Gender = (uint8) atoi(row[2]); - p_character_select_entry_struct->Face = (uint8) atoi(row[15]); + p_character_select_entry_struct->ShroudRace = p_character_select_entry_struct->Race; + p_character_select_entry_struct->Zone = (uint16) atoi(row[19]); + p_character_select_entry_struct->Instance = 0; + p_character_select_entry_struct->Gender = (uint8) atoi(row[2]); + p_character_select_entry_struct->Face = (uint8) atoi(row[15]); for (uint32 material_slot = 0; material_slot < EQ::textures::materialCount; material_slot++) { - p_character_select_entry_struct->Equip[material_slot].Material = 0; - p_character_select_entry_struct->Equip[material_slot].Unknown1 = 0; - p_character_select_entry_struct->Equip[material_slot].EliteModel = 0; + p_character_select_entry_struct->Equip[material_slot].Material = 0; + p_character_select_entry_struct->Equip[material_slot].Unknown1 = 0; + p_character_select_entry_struct->Equip[material_slot].EliteModel = 0; p_character_select_entry_struct->Equip[material_slot].HerosForgeModel = 0; - p_character_select_entry_struct->Equip[material_slot].Unknown2 = 0; - p_character_select_entry_struct->Equip[material_slot].Color = 0; + p_character_select_entry_struct->Equip[material_slot].Unknown2 = 0; + p_character_select_entry_struct->Equip[material_slot].Color = 0; } - p_character_select_entry_struct->Unknown15 = 0xFF; - p_character_select_entry_struct->Unknown19 = 0xFF; - p_character_select_entry_struct->DrakkinTattoo = (uint32) atoi(row[17]); - p_character_select_entry_struct->DrakkinDetails = (uint32) atoi(row[18]); - p_character_select_entry_struct->Deity = (uint32) atoi(row[6]); - p_character_select_entry_struct->PrimaryIDFile = 0; // Processed Below + p_character_select_entry_struct->Unknown15 = 0xFF; + p_character_select_entry_struct->Unknown19 = 0xFF; + p_character_select_entry_struct->DrakkinTattoo = (uint32) atoi(row[17]); + p_character_select_entry_struct->DrakkinDetails = (uint32) atoi(row[18]); + p_character_select_entry_struct->Deity = (uint32) atoi(row[6]); + p_character_select_entry_struct->PrimaryIDFile = 0; // Processed Below p_character_select_entry_struct->SecondaryIDFile = 0; // Processed Below - p_character_select_entry_struct->HairColor = (uint8) atoi(row[9]); - p_character_select_entry_struct->BeardColor = (uint8) atoi(row[10]); - p_character_select_entry_struct->EyeColor1 = (uint8) atoi(row[11]); - p_character_select_entry_struct->EyeColor2 = (uint8) atoi(row[12]); - p_character_select_entry_struct->HairStyle = (uint8) atoi(row[13]); - p_character_select_entry_struct->Beard = (uint8) atoi(row[14]); - p_character_select_entry_struct->GoHome = 0; // Processed Below - p_character_select_entry_struct->Tutorial = 0; // Processed Below + p_character_select_entry_struct->HairColor = (uint8) atoi(row[9]); + p_character_select_entry_struct->BeardColor = (uint8) atoi(row[10]); + p_character_select_entry_struct->EyeColor1 = (uint8) atoi(row[11]); + p_character_select_entry_struct->EyeColor2 = (uint8) atoi(row[12]); + p_character_select_entry_struct->HairStyle = (uint8) atoi(row[13]); + p_character_select_entry_struct->Beard = (uint8) atoi(row[14]); + p_character_select_entry_struct->GoHome = 0; // Processed Below + p_character_select_entry_struct->Tutorial = 0; // Processed Below p_character_select_entry_struct->DrakkinHeritage = (uint32) atoi(row[16]); - p_character_select_entry_struct->Unknown1 = 0; - p_character_select_entry_struct->Enabled = 1; - p_character_select_entry_struct->LastLogin = (uint32) atoi(row[7]); // RoF2 value: 1212696584 - p_character_select_entry_struct->Unknown2 = 0; + p_character_select_entry_struct->Unknown1 = 0; + p_character_select_entry_struct->Enabled = 1; + p_character_select_entry_struct->LastLogin = (uint32) atoi(row[7]); // RoF2 value: 1212696584 + p_character_select_entry_struct->Unknown2 = 0; if (RuleB(World, EnableReturnHomeButton)) { int now = time(nullptr); - if ((now - atoi(row[7])) >= RuleI(World, MinOfflineTimeToReturnHome)) + if ((now - atoi(row[7])) >= RuleI(World, MinOfflineTimeToReturnHome)) { p_character_select_entry_struct->GoHome = 1; + } } - if (RuleB(World, EnableTutorialButton) && (p_character_select_entry_struct->Level <= RuleI(World, MaxLevelForTutorial))) + if (RuleB(World, EnableTutorialButton) && (p_character_select_entry_struct->Level <= RuleI(World, MaxLevelForTutorial))) { p_character_select_entry_struct->Tutorial = 1; + } /** * Bind */ - character_list_query = fmt::format( - SQL( - SELECT - `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot` - FROM - `character_bind` - WHERE - `id` = {} - LIMIT 5 - ), + character_list_query = StringFormat( + "SELECT `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot` FROM `character_bind` WHERE `id` = %i LIMIT 5", character_id ); - auto results_bind = database.QueryDatabase(character_list_query); - auto bind_count = results_bind.RowCount(); - for (auto row_b = results_bind.begin(); row_b != results_bind.end(); ++row_b) { + auto results_bind = database.QueryDatabase(character_list_query); + auto bind_count = results_bind.RowCount(); + for (auto row_b = results_bind.begin(); row_b != results_bind.end(); ++row_b) { if (row_b[6] && atoi(row_b[6]) == 4) { has_home = 1; // If our bind count is less than 5, we need to actually make use of this data so lets parse it if (bind_count < 5) { - player_profile_struct.binds[4].zone_id = atoi(row_b[0]); + player_profile_struct.binds[4].zoneId = atoi(row_b[0]); player_profile_struct.binds[4].instance_id = atoi(row_b[1]); - player_profile_struct.binds[4].x = atof(row_b[2]); - player_profile_struct.binds[4].y = atof(row_b[3]); - player_profile_struct.binds[4].z = atof(row_b[4]); - player_profile_struct.binds[4].heading = atof(row_b[5]); + player_profile_struct.binds[4].x = atof(row_b[2]); + player_profile_struct.binds[4].y = atof(row_b[3]); + player_profile_struct.binds[4].z = atof(row_b[4]); + player_profile_struct.binds[4].heading = atof(row_b[5]); } } - - if (row_b[6] && atoi(row_b[6]) == 0) - has_bind = 1; + if (row_b[6] && atoi(row_b[6]) == 0) { has_bind = 1; } } if (has_home == 0 || has_bind == 0) { - std::string character_list_query = fmt::format( - SQL( - SELECT - `zone_id`, `bind_id`, `x`, `y`, `z`, `heading` - FROM - `start_zones` - WHERE - `player_class` = {} - AND - `player_deity` = {} - AND - `player_race` = {} {} - ), + character_list_query = StringFormat( + "SELECT `zone_id`, `bind_id`, `x`, `y`, `z` FROM `start_zones` WHERE `player_class` = %i AND `player_deity` = %i AND `player_race` = %i %s", p_character_select_entry_struct->Class, p_character_select_entry_struct->Deity, p_character_select_entry_struct->Race, ContentFilterCriteria::apply().c_str() ); - auto results_bind = content_db.QueryDatabase(character_list_query); - for (auto row_d = results_bind.begin(); row_d != results_bind.end(); ++row_d) { + auto results_bind = content_db.QueryDatabase(character_list_query); + for (auto row_d = results_bind.begin(); row_d != results_bind.end(); ++row_d) { /* If a bind_id is specified, make them start there */ if (atoi(row_d[1]) != 0) { - player_profile_struct.binds[4].zone_id = (uint32) atoi(row_d[1]); + player_profile_struct.binds[4].zoneId = (uint32) atoi(row_d[1]); content_db.GetSafePoints( - ZoneName(player_profile_struct.binds[4].zone_id, true), + ZoneName(player_profile_struct.binds[4].zoneId), 0, &player_profile_struct.binds[4].x, &player_profile_struct.binds[4].y, - &player_profile_struct.binds[4].z, - &player_profile_struct.binds[4].heading + &player_profile_struct.binds[4].z ); } /* Otherwise, use the zone and coordinates given */ else { - player_profile_struct.binds[4].zone_id = (uint32) atoi(row_d[0]); + player_profile_struct.binds[4].zoneId = (uint32) atoi(row_d[0]); float x = atof(row_d[2]); float y = atof(row_d[3]); float z = atof(row_d[4]); - float heading = atof(row_d[5]); - if (x == 0 && y == 0 && z == 0 && heading == 0) { + if (x == 0 && y == 0 && z == 0) { content_db.GetSafePoints( - ZoneName(player_profile_struct.binds[4].zone_id, true), + ZoneName(player_profile_struct.binds[4].zoneId), 0, &x, &y, - &z, - &heading + &z ); } player_profile_struct.binds[4].x = x; player_profile_struct.binds[4].y = y; player_profile_struct.binds[4].z = z; - player_profile_struct.binds[4].heading = heading; } } player_profile_struct.binds[0] = player_profile_struct.binds[4]; /* If no home bind set, set it */ if (has_home == 0) { - std::string query = fmt::format( - SQL( - REPLACE INTO - `character_bind` - (`id`, `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot`) - VALUES ({}, {}, {}, {}, {}, {}, {}, {}) - ), + std::string query = StringFormat( + "REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)" + " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, - player_profile_struct.binds[4].zone_id, + player_profile_struct.binds[4].zoneId, 0, player_profile_struct.binds[4].x, player_profile_struct.binds[4].y, @@ -285,19 +253,15 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o player_profile_struct.binds[4].heading, 4 ); - auto results_bset = QueryDatabase(query); + auto results_bset = QueryDatabase(query); } /* If no regular bind set, set it */ if (has_bind == 0) { - std::string query = fmt::format( - SQL( - REPLACE INTO - `character_bind` - (`id`, `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot`) - VALUES ({}, {}, {}, {}, {}, {}, {}, {}) - ), + std::string query = StringFormat( + "REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)" + " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, - player_profile_struct.binds[0].zone_id, + player_profile_struct.binds[0].zoneId, 0, player_profile_struct.binds[0].x, player_profile_struct.binds[0].y, @@ -305,7 +269,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o player_profile_struct.binds[0].heading, 0 ); - auto results_bset = QueryDatabase(query); + auto results_bset = QueryDatabase(query); } } /* If our bind count is less than 5, then we have null data that needs to be filled in. */ @@ -313,18 +277,15 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o // we know that home and main bind must be valid here, so we don't check those // we also use home to fill in the null data like live does. for (int i = 1; i < 4; i++) { - if (player_profile_struct.binds[i].zone_id != 0) // we assume 0 is the only invalid one ... + if (player_profile_struct.binds[i].zoneId != 0) { // we assume 0 is the only invalid one ... continue; + } - std::string query = fmt::format( - SQL( - REPLACE INTO - `character_bind` - (`id`, `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot`) - VALUES ({}, {}, {}, {}, {}, {}, {}, {}) - ), + std::string query = StringFormat( + "REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)" + " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, - player_profile_struct.binds[4].zone_id, + player_profile_struct.binds[4].zoneId, 0, player_profile_struct.binds[4].x, player_profile_struct.binds[4].y, @@ -332,45 +293,40 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o player_profile_struct.binds[4].heading, i ); - auto results_bset = QueryDatabase(query); + auto results_bset = QueryDatabase(query); } } - character_list_query = fmt::format( - SQL( - SELECT - `slot`, `red`, `green`, `blue`, `use_tint`, `color` - FROM - `character_material` - WHERE - `id` = {} - ), + character_list_query = StringFormat( + "SELECT slot, red, green, blue, use_tint, color FROM `character_material` WHERE `id` = %u", character_id ); - auto results_b = database.QueryDatabase(character_list_query); - uint8 slot = 0; - for (auto row_b = results_b.begin(); row_b != results_b.end(); ++row_b) { + auto results_b = database.QueryDatabase(character_list_query); + uint8 slot = 0; + for (auto row_b = results_b.begin(); row_b != results_b.end(); ++row_b) { slot = atoi(row_b[0]); - player_profile_struct.item_tint.Slot[slot].Red = atoi(row_b[1]); - player_profile_struct.item_tint.Slot[slot].Green = atoi(row_b[2]); - player_profile_struct.item_tint.Slot[slot].Blue = atoi(row_b[3]); + player_profile_struct.item_tint.Slot[slot].Red = atoi(row_b[1]); + player_profile_struct.item_tint.Slot[slot].Green = atoi(row_b[2]); + player_profile_struct.item_tint.Slot[slot].Blue = atoi(row_b[3]); player_profile_struct.item_tint.Slot[slot].UseTint = atoi(row_b[4]); } if (GetCharSelInventory(account_id, p_character_select_entry_struct->Name, &inventory_profile)) { - const EQ::ItemData *item = nullptr; - const EQ::ItemInstance *inst = nullptr; + const EQ::ItemData *item = nullptr; + const EQ::ItemInstance *inst = nullptr; int16 inventory_slot = 0; + for (uint32 matslot = EQ::textures::textureBegin; matslot < EQ::textures::materialCount; matslot++) { inventory_slot = EQ::InventoryProfile::CalcSlotFromMaterial(matslot); if (inventory_slot == INVALID_INDEX) { continue; } inst = inventory_profile.GetItem(inventory_slot); - if (inst == nullptr) + if (inst == nullptr) { continue; - + } item = inst->GetItem(); - if (item == nullptr) + if (item == nullptr) { continue; + } if (matslot > 6) { uint32 item_id_file = 0; @@ -378,59 +334,54 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o if (inst->GetOrnamentationIDFile() != 0) { item_id_file = inst->GetOrnamentationIDFile(); p_character_select_entry_struct->Equip[matslot].Material = item_id_file; - } else { + } + else { if (strlen(item->IDFile) > 2) { item_id_file = atoi(&item->IDFile[2]); p_character_select_entry_struct->Equip[matslot].Material = item_id_file; } } - if (matslot == EQ::textures::weaponPrimary) { p_character_select_entry_struct->PrimaryIDFile = item_id_file; - } else { + } + else { p_character_select_entry_struct->SecondaryIDFile = item_id_file; } - } else { + } + else { + uint32 color = 0; + if (player_profile_struct.item_tint.Slot[matslot].UseTint) { + color = player_profile_struct.item_tint.Slot[matslot].Color; + } + else { + color = inst->GetColor(); + } + // Armor Materials/Models - uint32 color = ( - player_profile_struct.item_tint.Slot[matslot].UseTint ? - player_profile_struct.item_tint.Slot[matslot].Color : - inst->GetColor() - ); - p_character_select_entry_struct->Equip[matslot].Material = item->Material; - p_character_select_entry_struct->Equip[matslot].EliteModel = item->EliteMaterial; + p_character_select_entry_struct->Equip[matslot].Material = item->Material; + p_character_select_entry_struct->Equip[matslot].EliteModel = item->EliteMaterial; p_character_select_entry_struct->Equip[matslot].HerosForgeModel = inst->GetOrnamentHeroModel(matslot); - p_character_select_entry_struct->Equip[matslot].Color = color; + p_character_select_entry_struct->Equip[matslot].Color = color; } } - } else { + } + else { printf("Error loading inventory for %s\n", p_character_select_entry_struct->Name); } + buff_ptr += sizeof(CharacterSelectEntry_Struct); } } -int WorldDatabase::MoveCharacterToBind(int character_id, uint8 bind_number) +int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) { /* if an invalid bind point is specified, use the primary bind */ - if (bind_number > 4) - bind_number = 0; + if (bindnum > 4) + { + bindnum = 0; + } - std::string query = fmt::format( - SQL( - SELECT - zone_id, instance_id, x, y, z, heading - FROM - character_bind - WHERE - id = {} - AND - slot = {} - LIMIT 1 - ), - character_id, - bind_number - ); + std::string query = StringFormat("SELECT zone_id, instance_id, x, y, z FROM character_bind WHERE id = %u AND slot = %u LIMIT 1", CharID, bindnum); auto results = database.QueryDatabase(query); if(!results.Success() || results.RowCount() == 0) { return 0; @@ -447,27 +398,8 @@ int WorldDatabase::MoveCharacterToBind(int character_id, uint8 bind_number) heading = atof(row[5]); } - query = fmt::format( - SQL( - UPDATE - `character_data` - SET - `zone_id` = {}, - `zone_instance` = {}, - `x` = {}, - `y` = {}, - `z` = {}, - `heading` = {} - WHERE `id` = {} - ), - zone_id, - instance_id, - x, - y, - z, - heading, - character_id - ); + query = StringFormat("UPDATE character_data SET zone_id = '%d', zone_instance = '%d', x = '%f', y = '%f', z = '%f', heading = '%f' WHERE id = %u", + zone_id, instance_id, x, y, z, heading, CharID); results = database.QueryDatabase(query); if(!results.Success()) { @@ -502,7 +434,7 @@ bool WorldDatabase::GetStartZone( p_player_profile_struct->binds[0].x = 0; p_player_profile_struct->binds[0].y = 0; p_player_profile_struct->binds[0].z = 0; - p_player_profile_struct->binds[0].zone_id = 0; + p_player_profile_struct->binds[0].zoneId = 0; p_player_profile_struct->binds[0].instance_id = 0; // see if we have an entry for start_zone. We can support both titanium & SOF+ by having two entries per class/race/deity combo with different zone_ids @@ -548,47 +480,35 @@ bool WorldDatabase::GetStartZone( else { LogInfo("Found starting location in start_zones"); auto row = results.begin(); - p_player_profile_struct->x = atof(row[0]); - p_player_profile_struct->y = atof(row[1]); - p_player_profile_struct->z = atof(row[2]); - p_player_profile_struct->heading = atof(row[3]); - p_player_profile_struct->zone_id = atoi(row[4]); - p_player_profile_struct->binds[0].zone_id = atoi(row[5]); - p_player_profile_struct->binds[0].x = atof(row[6]); - p_player_profile_struct->binds[0].y = atof(row[7]); - p_player_profile_struct->binds[0].z = atof(row[8]); - p_player_profile_struct->binds[0].heading = atof(row[3]); + p_player_profile_struct->x = atof(row[0]); + p_player_profile_struct->y = atof(row[1]); + p_player_profile_struct->z = atof(row[2]); + p_player_profile_struct->heading = atof(row[3]); + p_player_profile_struct->zone_id = atoi(row[4]); + p_player_profile_struct->binds[0].zoneId = atoi(row[5]); + p_player_profile_struct->binds[0].x = atof(row[6]); + p_player_profile_struct->binds[0].y = atof(row[7]); + p_player_profile_struct->binds[0].z = atof(row[8]); } - if ( - p_player_profile_struct->x == 0 && - p_player_profile_struct->y == 0 && - p_player_profile_struct->z == 0 && - p_player_profile_struct->heading == 0 - ) { + if (p_player_profile_struct->x == 0 && p_player_profile_struct->y == 0 && p_player_profile_struct->z == 0) { content_db.GetSafePoints( - ZoneName(p_player_profile_struct->zone_id, true), + ZoneName(p_player_profile_struct->zone_id), 0, &p_player_profile_struct->x, &p_player_profile_struct->y, - &p_player_profile_struct->z, - &p_player_profile_struct->heading + &p_player_profile_struct->z ); } - if ( - p_player_profile_struct->binds[0].x == 0 && - p_player_profile_struct->binds[0].y == 0 && - p_player_profile_struct->binds[0].z == 0 && - p_player_profile_struct->binds[0].heading == 0 - ) { + if (p_player_profile_struct->binds[0].x == 0 && p_player_profile_struct->binds[0].y == 0 && + p_player_profile_struct->binds[0].z == 0) { content_db.GetSafePoints( - ZoneName(p_player_profile_struct->binds[0].zone_id, true), + ZoneName(p_player_profile_struct->binds[0].zoneId), 0, &p_player_profile_struct->binds[0].x, &p_player_profile_struct->binds[0].y, - &p_player_profile_struct->binds[0].z, - &p_player_profile_struct->binds[0].heading + &p_player_profile_struct->binds[0].z ); } @@ -600,11 +520,10 @@ void WorldDatabase::SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCrea in_pp->zone_id = in_cc->start_zone; } else { - in_pp->x = in_pp->binds[0].x = -51.0f; - in_pp->y = in_pp->binds[0].y = -20.0f; - in_pp->z = in_pp->binds[0].z = 0.79f; - in_pp->heading = in_pp->binds[0].heading = 0.0f; - in_pp->zone_id = in_pp->binds[0].zone_id = 394; // Crescent Reach. + in_pp->x = in_pp->binds[0].x = -51; + in_pp->y = in_pp->binds[0].y = -20; + in_pp->z = in_pp->binds[0].z = 0.79; + in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach. } } @@ -617,91 +536,91 @@ void WorldDatabase::SetTitaniumDefaultStartZone(PlayerProfile_Struct* in_pp, Cha if (in_cc->deity == 203) // Cazic-Thule Erudites go to Paineel { in_pp->zone_id = 75; // paineel - in_pp->binds[0].zone_id = 75; + in_pp->binds[0].zoneId = 75; } else { in_pp->zone_id = 24; // erudnext - in_pp->binds[0].zone_id = 38; // tox + in_pp->binds[0].zoneId = 38; // tox } break; } case 1: { in_pp->zone_id = 2; // qeynos2 - in_pp->binds[0].zone_id = 2; // qeynos2 + in_pp->binds[0].zoneId = 2; // qeynos2 break; } case 2: { in_pp->zone_id = 29; // halas - in_pp->binds[0].zone_id = 30; // everfrost + in_pp->binds[0].zoneId = 30; // everfrost break; } case 3: { in_pp->zone_id = 19; // rivervale - in_pp->binds[0].zone_id = 20; // kithicor + in_pp->binds[0].zoneId = 20; // kithicor break; } case 4: { in_pp->zone_id = 9; // freportw - in_pp->binds[0].zone_id = 9; // freportw + in_pp->binds[0].zoneId = 9; // freportw break; } case 5: { in_pp->zone_id = 40; // neriaka - in_pp->binds[0].zone_id = 25; // nektulos + in_pp->binds[0].zoneId = 25; // nektulos break; } case 6: { in_pp->zone_id = 52; // gukta - in_pp->binds[0].zone_id = 46; // innothule + in_pp->binds[0].zoneId = 46; // innothule break; } case 7: { in_pp->zone_id = 49; // oggok - in_pp->binds[0].zone_id = 47; // feerrott + in_pp->binds[0].zoneId = 47; // feerrott break; } case 8: { in_pp->zone_id = 60; // kaladima - in_pp->binds[0].zone_id = 68; // butcher + in_pp->binds[0].zoneId = 68; // butcher break; } case 9: { in_pp->zone_id = 54; // gfaydark - in_pp->binds[0].zone_id = 54; // gfaydark + in_pp->binds[0].zoneId = 54; // gfaydark break; } case 10: { in_pp->zone_id = 61; // felwithea - in_pp->binds[0].zone_id = 54; // gfaydark + in_pp->binds[0].zoneId = 54; // gfaydark break; } case 11: { in_pp->zone_id = 55; // akanon - in_pp->binds[0].zone_id = 56; // steamfont + in_pp->binds[0].zoneId = 56; // steamfont break; } case 12: { in_pp->zone_id = 82; // cabwest - in_pp->binds[0].zone_id = 78; // fieldofbone + in_pp->binds[0].zoneId = 78; // fieldofbone break; } case 13: { in_pp->zone_id = 155; // sharvahl - in_pp->binds[0].zone_id = 155; // sharvahl + in_pp->binds[0].zoneId = 155; // sharvahl break; } } diff --git a/world/worlddb.h b/world/worlddb.h index 6431f175e..42fbf96b6 100644 --- a/world/worlddb.h +++ b/world/worlddb.h @@ -31,7 +31,7 @@ class WorldDatabase : public SharedDatabase { public: bool GetStartZone(PlayerProfile_Struct* p_player_profile_struct, CharCreate_Struct* p_char_create_struct, bool is_titanium); void GetCharSelectInfo(uint32 account_id, EQApplicationPacket **out_app, uint32 client_version_bit); - int MoveCharacterToBind(int character_id, uint8 bind_number = 0); + int MoveCharacterToBind(int CharID, uint8 bindnum = 0); void GetLauncherList(std::vector &result); bool GetCharacterLevel(const char *name, int &level); diff --git a/world/zonelist.cpp b/world/zonelist.cpp index 51acd0c01..3fcc198cd 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -42,8 +42,8 @@ ZSList::ZSList() CurGroupID = 1; memset(pLockedZones, 0, sizeof(pLockedZones)); - m_tick = std::make_unique(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1)); - m_keepalive = std::make_unique(2500, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1)); + m_tick.reset(new EQ::Timer(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1))); + m_keepalive.reset(new EQ::Timer(2500, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1))); } ZSList::~ZSList() { @@ -280,19 +280,20 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con strcpy(locked, "No"); } - fmt::memory_buffer out; + char* output = 0; + uint32 outsize = 0, outlen = 0; if (connection->IsConsole()) { - fmt::format_to(out, "World Locked: {}\r\n", locked); + AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s\r\n", locked); } else { - fmt::format_to(out, "World Locked: {}^", locked); + AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s^", locked); } if (connection->IsConsole()) { - fmt::format_to(out, "Zoneservers online:\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:\r\n"); } else { - fmt::format_to(out, "Zoneservers online:^"); + AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:^"); } int v = 0, w = 0, x = 0, y = 0, z = 0; @@ -332,8 +333,8 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con zone_data_string[0] = 0; } - fmt::format_to(out, - "#{:<3} :: {} :: {}:{:<5} :: {:2} :: {}:{} :: {} :: ({})", + AppendAnyLenString(&output, &outsize, &outlen, + "#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)", zone_server_data->GetID(), is_static_string, addr.c_str(), @@ -345,16 +346,17 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con zone_server_data->GetZoneOSProcessID() ); - if (out.size() >= 3584) { - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); - out.clear(); + if (outlen >= 3584) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); + outsize = 0; + outlen = 0; } else { if (connection->IsConsole()) - fmt::format_to(out, "\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else - fmt::format_to(out, "^"); + AppendAnyLenString(&output, &outsize, &outlen, "^"); } x++; } @@ -363,18 +365,19 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con strcpy(zone_data_string, zone_server_data->GetZoneName()); else zone_data_string[0] = 0; - fmt::format_to(out, " #{} {} {}", zone_server_data->GetID(), is_static_string, zone_data_string); - if (out.size() >= 3584) { - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); - out.clear(); + AppendAnyLenString(&output, &outsize, &outlen, " #%i %s %s", zone_server_data->GetID(), is_static_string, zone_data_string); + if (outlen >= 3584) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + safe_delete(output); + outsize = 0; + outlen = 0; } else { if (connection->IsConsole()) { - fmt::format_to(out, "\r\n"); + AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); } else { - fmt::format_to(out, "^"); + AppendAnyLenString(&output, &outsize, &outlen, "^"); } } x++; @@ -384,16 +387,19 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con } if (connection->IsConsole()) { - fmt::format_to(out, "{} servers listed. {} servers online.\r\n", x, y); + AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.\r\n", x, y); } else { - fmt::format_to(out, "{} servers listed. {} servers online.^", x, y); + AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.^", x, y); } - fmt::format_to(out, "{} zones are static zones, {} zones are booted zones, {} zones available.", z, w, v); + AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.", z, w, v); - auto output = fmt::to_string(out); - connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str()); + if (output) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, output); + } + + safe_delete(output); } void ZSList::SendChannelMessage(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message, ...) { diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 4e37b1d7e..5e2268755 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -36,8 +36,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "ucs.h" #include "queryserv.h" #include "world_store.h" -#include "dynamic_zone.h" -#include "expedition_message.h" extern ClientList client_list; extern GroupLFPList LFPGroupList; @@ -71,12 +69,12 @@ ZoneServer::ZoneServer(std::shared_ptr conn tcpc->OnMessage(std::bind(&ZoneServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); - boot_timer_obj = std::make_unique(100, true, [this](EQ::Timer *obj) { + boot_timer_obj.reset(new EQ::Timer(100, true, [this](EQ::Timer *obj) { if (zone_boot_timer.Check()) { LSBootUpdate(GetZoneID(), true); zone_boot_timer.Disable(); } - }); + })); this->console = console; } @@ -1339,7 +1337,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { } LogInfo("Loading skill caps"); - if (!content_db.LoadSkillCaps(hotfix_name)) { + if (!database.LoadSkillCaps(hotfix_name)) { LogInfo("Error: Could not load skill cap data. But ignoring"); } @@ -1357,46 +1355,6 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { cle->ProcessTellQueue(); break; } - case ServerOP_CZClientMessageString: - { - auto buf = reinterpret_cast(pack->pBuffer); - client_list.SendPacket(buf->character_name, pack); - break; - } - case ServerOP_ExpeditionLockout: - case ServerOP_ExpeditionLockoutDuration: - case ServerOP_ExpeditionLockState: - case ServerOP_ExpeditionReplayOnJoin: - case ServerOP_ExpeditionExpireWarning: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ExpeditionCreate: - case ServerOP_ExpeditionGetMemberStatuses: - case ServerOP_ExpeditionMemberChange: - case ServerOP_ExpeditionMemberStatus: - case ServerOP_ExpeditionMemberSwap: - case ServerOP_ExpeditionMembersRemoved: - case ServerOP_ExpeditionDzAddPlayer: - case ServerOP_ExpeditionDzMakeLeader: - case ServerOP_ExpeditionCharacterLockout: - case ServerOP_ExpeditionSaveInvite: - case ServerOP_ExpeditionRequestInvite: - { - ExpeditionMessage::HandleZoneMessage(pack); - break; - } - case ServerOP_DzAddRemoveCharacter: - case ServerOP_DzRemoveAllCharacters: - case ServerOP_DzSetSecondsRemaining: - case ServerOP_DzSetCompass: - case ServerOP_DzSetSafeReturn: - case ServerOP_DzSetZoneIn: - { - DynamicZone::HandleZoneMessage(pack); - break; - } default: { LogInfo("Unknown ServerOPcode from zone {:#04x}, size [{}]", pack->opcode, pack->size); diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 0430274f9..beacca565 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -22,7 +22,6 @@ SET(zone_sources corpse.cpp data_bucket.cpp doors.cpp - dynamic_zone.cpp effects.cpp embparser.cpp embparser_api.cpp @@ -31,9 +30,6 @@ SET(zone_sources encounter.cpp entity.cpp exp.cpp - expedition.cpp - expedition_database.cpp - expedition_request.cpp fastmath.cpp fearpath.cpp forage.cpp @@ -52,7 +48,6 @@ SET(zone_sources lua_encounter.cpp lua_entity.cpp lua_entity_list.cpp - lua_expedition.cpp lua_general.cpp lua_group.cpp lua_hate_list.cpp @@ -105,10 +100,8 @@ SET(zone_sources perl_client.cpp perl_doors.cpp perl_entity.cpp - perl_expedition.cpp perl_groups.cpp perl_hateentry.cpp - perl_inventory.cpp perl_mob.cpp perl_npc.cpp perl_object.cpp @@ -132,10 +125,6 @@ SET(zone_sources special_attacks.cpp spell_effects.cpp spells.cpp - task_client_state.cpp - task_goal_list_manager.cpp - task_manager.cpp - task_proximity_manager.cpp tasks.cpp titles.cpp tradeskills.cpp @@ -152,10 +141,10 @@ SET(zone_sources zone.cpp zone_config.cpp zonedb.cpp - zone_event_scheduler.cpp zone_reload.cpp zone_store.cpp - zoning.cpp) + zoning.cpp +) SET(zone_headers aa.h @@ -176,7 +165,6 @@ SET(zone_headers corpse.h data_bucket.h doors.h - dynamic_zone.h embparser.h embperl.h embxs.h @@ -184,9 +172,6 @@ SET(zone_headers entity.h errmsg.h event_codes.h - expedition.h - expedition_database.h - expedition_request.h fastmath.h forage.h global_loot_manager.h @@ -202,7 +187,6 @@ SET(zone_headers lua_encounter.h lua_entity.h lua_entity_list.h - lua_expedition.h lua_general.h lua_group.h lua_hate_list.h @@ -246,6 +230,7 @@ SET(zone_headers quest_interface.h questmgr.h quest_parser_collection.h + raid.h raids.h raycast_mesh.h skills.h @@ -253,10 +238,6 @@ SET(zone_headers spawn2.h spawngroup.h string_ids.h - task_client_state.h - task_goal_list_manager.h - task_manager.h - task_proximity_manager.h tasks.h titles.h trap.h @@ -266,12 +247,12 @@ SET(zone_headers worldserver.h xtargetautohaters.h zone.h - zone_event_scheduler.h zone_config.h zonedb.h zonedump.h zone_reload.h - zone_store.h) + zone_store.h +) ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers}) @@ -279,6 +260,6 @@ INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) ADD_DEFINITIONS(-DZONE) -TARGET_LINK_LIBRARIES(zone ${ZONE_LIBS}) +TARGET_LINK_LIBRARIES(zone ${SERVER_LIBS}) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/zone/aa.cpp b/zone/aa.cpp index 0b19065bf..c15d5ba8c 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -448,7 +448,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration) sitem = CorpseToUse->GetWornItem(x); if(sitem){ const EQ::ItemData * itm = database.GetItem(sitem); - npca->AddLootDrop(itm, &npca->itemlist, NPC::NewLootDropEntry(), true); + npca->AddLootDrop(itm, &npca->itemlist, LootDropEntries_Struct{ .equip_item = 1 }, true); } } @@ -494,6 +494,9 @@ void Client::ResetAA() { m_pp.raid_leadership_exp = 0; database.DeleteCharacterLeadershipAAs(CharacterID()); + // undefined for these clients + if (ClientVersionBit() & EQ::versions::maskTitaniumAndEarlier) + Kick("AA Reset on client that doesn't support it"); } void Client::SendClearAA() diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 33221b63a..0cc2d7691 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -468,12 +468,6 @@ bool Mob::IsAttackAllowed(Mob *target, bool isSpellAttack) return false; } - if (target->GetSpecialAbility(IMMUNE_DAMAGE_CLIENT) && IsClient()) - return false; - - if (target->GetSpecialAbility(IMMUNE_DAMAGE_NPC) && IsNPC()) - return false; - // can't damage own pet (applies to everthing) Mob *target_owner = target->GetOwner(); Mob *our_owner = GetOwner(); @@ -806,7 +800,7 @@ bool Mob::IsBeneficialAllowed(Mob *target) return false; } -bool Mob::CombatRange(Mob* other, float fixed_size_mod, bool aeRampage) +bool Mob::CombatRange(Mob* other) { if(!other) return(false); @@ -831,25 +825,13 @@ bool Mob::CombatRange(Mob* other, float fixed_size_mod, bool aeRampage) // this could still use some work, but for now it's an improvement.... - if (size_mod > 29) { + if (size_mod > 29) size_mod *= size_mod; - } else if (size_mod > 19) { + else if (size_mod > 19) size_mod *= size_mod * 2; - } else { + else size_mod *= size_mod * 4; - } - if (other->GetRace() == 184) // Lord Vyemm and other velious dragons - { - size_mod *= 1.75; - } - if (other->GetRace() == 122) // Dracoliche in Fear. Skeletal Dragon - { - size_mod *= 2.25; - } - - size_mod *= RuleR(Combat,HitBoxMod); // used for testing sizemods on different races. - size_mod *= fixed_size_mod; // used to extend the size_mod // prevention of ridiculously sized hit boxes if (size_mod > 10000) @@ -883,15 +865,6 @@ bool Mob::CombatRange(Mob* other, float fixed_size_mod, bool aeRampage) else SetPseudoRoot(false); } - if(aeRampage) { - float multiplyer = GetSize() * RuleR(Combat, AERampageSafeZone); - float ramp_range = (size_mod * multiplyer); - if (_DistNoRoot <= ramp_range) { - return true; - } else { - return false; - } - } if (_DistNoRoot <= size_mod) { @@ -899,11 +872,13 @@ bool Mob::CombatRange(Mob* other, float fixed_size_mod, bool aeRampage) if (flymode != GravityBehavior::Flying && _zDist > 500 && !CheckLastLosState()) { return false; } + return true; } return false; } +//Father Nitwit's LOS code bool Mob::CheckLosFN(Mob *other) { bool Result = false; @@ -1150,9 +1125,7 @@ int32 Mob::CheckHealAggroAmount(uint16 spell_id, Mob *target, uint32 heal_possib for (int o = 0; o < EFFECT_COUNT; o++) { switch (spells[spell_id].effectid[o]) { - case SE_CurrentHP: - case SE_PercentalHeal: - { + case SE_CurrentHP: { if (heal_possible == 0) { AggroAmount += 1; break; diff --git a/zone/attack.cpp b/zone/attack.cpp index 2f85dbaaf..86c326e53 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1655,7 +1655,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQ::skills::Skill d->spawn_id = GetID(); d->killer_id = killerMob ? killerMob->GetID() : 0; d->corpseid = GetID(); - d->bindzoneid = m_pp.binds[0].zone_id; + d->bindzoneid = m_pp.binds[0].zoneId; d->spell_id = spell == SPELL_UNKNOWN ? 0xffffffff : spell; d->attack_skill = spell != SPELL_UNKNOWN ? 0xe7 : attack_skill; d->damage = damage; @@ -1892,7 +1892,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQ::skills::Skill r->MemberZoned(this); dead_timer.Start(5000, true); - m_pp.zone_id = m_pp.binds[0].zone_id; + m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = m_pp.binds[0].instance_id; database.MoveCharacterToZone(this->CharacterID(), m_pp.zone_id); Save(); @@ -2247,7 +2247,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy d->spawn_id = GetID(); d->killer_id = killer_mob ? killer_mob->GetID() : 0; d->bindzoneid = 0; - d->spell_id = 0xffffffff; // Sending spell was causing extra DoT land msg + d->spell_id = spell == SPELL_UNKNOWN ? 0xffffffff : spell; d->attack_skill = SkillDamageTypes[attack_skill]; d->damage = damage; app->priority = 6; @@ -2667,12 +2667,6 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b if (IsFamiliar() || GetSpecialAbility(IMMUNE_AGGRO)) return; - if (GetSpecialAbility(IMMUNE_AGGRO_NPC) && other->IsNPC()) - return; - - if (GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && other->IsClient()) - return; - if (spell_id != SPELL_UNKNOWN && NoDetrimentalSpellAggro(spell_id)) return; @@ -2764,11 +2758,8 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b else { // cb:2007-08-17 // owner must get on list, but he's not actually gained any hate yet - if ( - !owner->GetSpecialAbility(IMMUNE_AGGRO) && - !(this->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && owner->IsClient()) && - !(this->GetSpecialAbility(IMMUNE_AGGRO_NPC) && owner->IsNPC()) - ) { + if (!owner->GetSpecialAbility(IMMUNE_AGGRO)) + { if (owner->IsClient() && !CheckAggro(owner)) owner->CastToClient()->AddAutoXTarget(this); hate_list.AddEntToHateList(owner, 0, 0, false, !iBuffTic); @@ -2777,24 +2768,12 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b } if (mypet && !mypet->IsHeld() && !mypet->IsPetStop()) { // I have a pet, add other to it - if ( - !mypet->IsFamiliar() && - !mypet->GetSpecialAbility(IMMUNE_AGGRO) && - !(mypet->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && this->IsClient()) && - !(mypet->GetSpecialAbility(IMMUNE_AGGRO_NPC) && this->IsNPC()) - ) { + if (!mypet->IsFamiliar() && !mypet->GetSpecialAbility(IMMUNE_AGGRO)) mypet->hate_list.AddEntToHateList(other, 0, 0, bFrenzy); - } } else if (myowner) { // I am a pet, add other to owner if it's NPC/LD - if ( - myowner->IsAIControlled() && - !myowner->GetSpecialAbility(IMMUNE_AGGRO) && - !(this->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && myowner->IsClient()) && - !(this->GetSpecialAbility(IMMUNE_AGGRO_NPC) && myowner->IsNPC()) - ) { + if (myowner->IsAIControlled() && !myowner->GetSpecialAbility(IMMUNE_AGGRO)) myowner->hate_list.AddEntToHateList(other, 0, 0, bFrenzy); - } } if (other->GetTempPetCount()) @@ -3466,55 +3445,16 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const // emote goes with every one ... even npcs entity_list.MessageClose(this, true, RuleI(Range, SpellMessages), Chat::Emote, "%s beams a smile at %s", attacker->GetCleanName(), this->GetCleanName()); } - - // If a client pet is damaged while sitting, stand, fix sit button, - // and remove sitting regen. Removes bug where client clicks sit - // during battle and gains pet hp-regen and bugs the sit button. - if (IsPet()) { - Mob *owner = this->GetOwner(); - if (owner && owner->IsClient()) { - if (GetPetOrder() == SPO_Sit) { - SetPetOrder(SPO_Follow); - } - // fix GUI sit button to be unpressed and stop sitting regen - owner->CastToClient()->SetPetCommandState(PET_BUTTON_SIT, 0); - SetAppearance(eaStanding); - } - } - } //end `if there is some damage being done and theres anattacker person involved` Mob *pet = GetPet(); // pets that have GHold will never automatically add NPCs // pets that have Hold and no Focus will add NPCs if they're engaged // pets that have Hold and Focus will not add NPCs - if ( - pet && - !pet->IsFamiliar() && - !pet->GetSpecialAbility(IMMUNE_AGGRO) && - !pet->IsEngaged() && - attacker && - !(pet->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && attacker->IsClient()) && - !(pet->GetSpecialAbility(IMMUNE_AGGRO_NPC) && attacker->IsNPC()) && - attacker != this && - !attacker->IsCorpse() && - !pet->IsGHeld() && - !attacker->IsTrap() - ) { + if (pet && !pet->IsFamiliar() && !pet->GetSpecialAbility(IMMUNE_AGGRO) && !pet->IsEngaged() && attacker && attacker != this && !attacker->IsCorpse() && !pet->IsGHeld() && !attacker->IsTrap()) + { if (!pet->IsHeld()) { LogAggro("Sending pet [{}] into battle due to attack", pet->GetName()); - if (IsClient()) { - // if pet was sitting his new mode is follow - // following after the battle (live verified) - if (pet->GetPetOrder() == SPO_Sit) { - pet->SetPetOrder(SPO_Follow); - } - - // fix GUI sit button to be unpressed and stop sitting regen - this->CastToClient()->SetPetCommandState(PET_BUTTON_SIT, 0); - pet->SetAppearance(eaStanding); - } - pet->AddToHateList(attacker, 1, 0, true, false, false, spell_id); pet->SetTarget(attacker); MessageString(Chat::NPCQuestSay, PET_ATTACKING, pet->GetCleanName(), attacker->GetCleanName()); diff --git a/zone/bot.cpp b/zone/bot.cpp index 59bdf9788..48e468a05 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1591,7 +1591,7 @@ uint16 Bot::GetPrimarySkillValue() { } uint16 Bot::MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const { - return(content_db.GetSkillCap(class_, skillid, level)); + return(database.GetSkillCap(class_, skillid, level)); } uint32 Bot::GetTotalATK() { @@ -2211,12 +2211,12 @@ bool Bot::Process() return false; } - if (mob_close_scan_timer.Check()) { + if (mob_scan_close.Check()) { LogAIScanClose( "is_moving [{}] bot [{}] timer [{}]", moving ? "true" : "false", GetCleanName(), - mob_close_scan_timer.GetDuration() + mob_scan_close.GetDuration() ); entity_list.ScanCloseClientMobs(close_mobs, this); @@ -8605,8 +8605,6 @@ void Bot::ProcessBotGroupInvite(Client* c, std::string botName) { g->SaveGroupLeaderAA(); database.SetGroupID(c->GetName(), g->GetID(), c->CharacterID()); database.SetGroupID(invitedBot->GetCleanName(), g->GetID(), invitedBot->GetBotID()); - } else { - delete g; } } else { AddBotToGroup(invitedBot, c->GetGroup()); @@ -9082,7 +9080,7 @@ void Bot::CalcBotStats(bool showtext) { SetLevel(GetBotOwner()->GetLevel()); for (int sindex = 0; sindex <= EQ::skills::HIGHEST_SKILL; ++sindex) { - skills[sindex] = content_db.GetSkillCap(GetClass(), (EQ::skills::SkillType)sindex, GetLevel()); + skills[sindex] = database.GetSkillCap(GetClass(), (EQ::skills::SkillType)sindex, GetLevel()); } taunt_timer.Start(1000); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 10b869d9c..1dcebe5fc 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -76,7 +76,7 @@ extern QueryServ* QServ; extern WorldServer worldserver; -extern TaskManager *task_manager; +extern TaskManager *taskmanager; void CatchSignal(int sig_num); diff --git a/zone/client.cpp b/zone/client.cpp index 2d6ad9994..406382662 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -40,9 +40,6 @@ extern volatile bool RunLoops; #include "../common/data_verification.h" #include "../common/profanity_manager.h" #include "data_bucket.h" -#include "expedition.h" -#include "expedition_database.h" -#include "expedition_request.h" #include "position.h" #include "worldserver.h" #include "zonedb.h" @@ -59,8 +56,6 @@ extern volatile bool RunLoops; #include "quest_parser_collection.h" #include "queryserv.h" #include "mob_movement_manager.h" -#include "../common/content/world_content_service.h" -#include "../common/expedition_lockout_timer.h" extern QueryServ* QServ; extern EntityList entity_list; @@ -143,7 +138,7 @@ Client::Client(EQStreamInterface* ieqs) endupkeep_timer(1000), forget_timer(0), autosave_timer(RuleI(Character, AutosaveIntervalS) * 1000), - client_scan_npc_aggro_timer(RuleI(Aggro, ClientAggroCheckIdleInterval)), + client_scan_npc_aggro_timer(RuleI(Aggro, ClientAggroCheckInterval) * 1000), client_zone_wide_full_position_update_timer(5 * 60 * 1000), tribute_timer(Tribute_duration), proximity_timer(ClientProximity_interval), @@ -163,7 +158,7 @@ Client::Client(EQStreamInterface* ieqs) helm_toggle_timer(250), aggro_meter_timer(AGGRO_METER_UPDATE_MS), m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number - m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f,-2.0f), + m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f), m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f), last_region_type(RegionTypeUnsupported), @@ -258,7 +253,7 @@ Client::Client(EQStreamInterface* ieqs) tgb = false; tribute_master_id = 0xFFFFFFFF; tribute_timer.Disable(); - task_state = nullptr; + taskstate = nullptr; TotalSecondsPlayed = 0; keyring.clear(); bind_sight_target = nullptr; @@ -268,7 +263,6 @@ Client::Client(EQStreamInterface* ieqs) InitializeMercInfo(); SetMerc(0); if (RuleI(World, PVPMinLevel) > 0 && level >= RuleI(World, PVPMinLevel) && m_pp.pvp == 0) SetPVP(true, false); - dynamiczone_removal_timer.Disable(); //for good measure: memset(&m_pp, 0, sizeof(m_pp)); @@ -355,8 +349,8 @@ Client::Client(EQStreamInterface* ieqs) /** * GM */ - SetDisplayMobInfoWindow(true); - SetDevToolsEnabled(true); + display_mob_info_window = true; + dev_tools_window_enabled = true; #ifdef BOTS bot_owner_options[booDeathMarquee] = false; @@ -441,7 +435,7 @@ Client::~Client() { if(IsHoveringForRespawn()) { - m_pp.zone_id = m_pp.binds[0].zone_id; + m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = m_pp.binds[0].instance_id; m_Position.x = m_pp.binds[0].x; m_Position.y = m_pp.binds[0].y; @@ -452,7 +446,7 @@ Client::~Client() { // will need this data right away Save(2); // This fails when database destructor is called first on shutdown - safe_delete(task_state); + safe_delete(taskstate); safe_delete(KarmaUpdateTimer); safe_delete(GlobalChatLimiterTimer); safe_delete(qGlobals); @@ -658,7 +652,7 @@ bool Client::Save(uint8 iCommitNow) { /* Save Current Bind Points */ for (int i = 0; i < 5; i++) - if (m_pp.binds[i].zone_id) + if (m_pp.binds[i].zoneId) database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[i], i); /* Save Character Buffs */ @@ -692,7 +686,6 @@ bool Client::Save(uint8 iCommitNow) { pet->GetPetState(m_petinfo.Buffs, m_petinfo.Items, m_petinfo.Name); m_petinfo.petpower = pet->GetPetPower(); m_petinfo.size = pet->GetSize(); - m_petinfo.taunting = pet->CastToNPC()->IsTaunting(); } else { memset(&m_petinfo, 0, sizeof(struct PetInfo)); } @@ -756,7 +749,7 @@ bool Client::AddPacket(const EQApplicationPacket *pApp, bool bAckreq) { return(false); } - auto c = std::make_unique(); + auto c = std::unique_ptr(new CLIENTPACKET); c->ack_req = bAckreq; c->app = pApp->Copy(); @@ -773,7 +766,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) { //drop the packet because it will never get sent. return(false); } - auto c = std::make_unique(); + auto c = std::unique_ptr(new CLIENTPACKET); c->ack_req = bAckreq; c->app = *pApp; @@ -2433,17 +2426,13 @@ bool Client::CheckIncreaseSkill(EQ::skills::SkillType skillid, Mob *against_who, char buffer[24] = { 0 }; snprintf(buffer, 23, "%d %d", skillid, skillval); parse->EventPlayer(EVENT_USE_SKILL, this, buffer, 0); - if (against_who) { - if ( - against_who->GetSpecialAbility(IMMUNE_AGGRO) || - against_who->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) || - against_who->IsClient() || - GetLevelCon(against_who->GetLevel()) == CON_GRAY - ) { + if(against_who) + { + if(against_who->GetSpecialAbility(IMMUNE_AGGRO) || against_who->IsClient() || + GetLevelCon(against_who->GetLevel()) == CON_GRAY) + { //false by default - if (!mod_can_increase_skill(skillid, against_who)) { - return false; - } + if( !mod_can_increase_skill(skillid, against_who) ) { return(false); } } } @@ -2505,7 +2494,7 @@ bool Client::CanHaveSkill(EQ::skills::SkillType skill_id) const { if (ClientVersion() < EQ::versions::ClientVersion::RoF2 && class_ == BERSERKER && skill_id == EQ::skills::Skill1HPiercing) skill_id = EQ::skills::Skill2HPiercing; - return(content_db.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)) > 0); + return(database.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)) > 0); //if you don't have it by max level, then odds are you never will? } @@ -2513,7 +2502,7 @@ uint16 Client::MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 lev if (ClientVersion() < EQ::versions::ClientVersion::RoF2 && class_ == BERSERKER && skillid == EQ::skills::Skill1HPiercing) skillid = EQ::skills::Skill2HPiercing; - return(content_db.GetSkillCap(class_, skillid, level)); + return(database.GetSkillCap(class_, skillid, level)); } uint8 Client::SkillTrainLevel(EQ::skills::SkillType skillid, uint16 class_) @@ -2521,7 +2510,7 @@ uint8 Client::SkillTrainLevel(EQ::skills::SkillType skillid, uint16 class_) if (ClientVersion() < EQ::versions::ClientVersion::RoF2 && class_ == BERSERKER && skillid == EQ::skills::Skill1HPiercing) skillid = EQ::skills::Skill2HPiercing; - return(content_db.GetTrainLevel(class_, skillid, RuleI(Character, MaxLevel))); + return(database.GetTrainLevel(class_, skillid, RuleI(Character, MaxLevel))); } uint16 Client::GetMaxSkillAfterSpecializationRules(EQ::skills::SkillType skillid, uint16 maxSkill) @@ -3161,58 +3150,53 @@ void Client::MessageString(uint32 type, uint32 string_id, const char* message1, if (GetFilter(FilterDamageShields) == FilterHide && type == Chat::DamageShield) return; - if (type == Chat::Emote) - type = 4; + int i = 0, argcount = 0, length = 0; + char *bufptr = nullptr; + const char *message_arg[9] = {0}; - if (!message1) { + if(type==Chat::Emote) + type=4; + + if(!message1) + { MessageString(type, string_id); // use the simple message instead return; } - const char *message_arg[] = { - message1, message2, message3, message4, message5, - message6, message7, message8, message9 - }; + message_arg[i++] = message1; + message_arg[i++] = message2; + message_arg[i++] = message3; + message_arg[i++] = message4; + message_arg[i++] = message5; + message_arg[i++] = message6; + message_arg[i++] = message7; + message_arg[i++] = message8; + message_arg[i++] = message9; - SerializeBuffer buf(20); - buf.WriteInt32(0); // unknown - buf.WriteInt32(string_id); - buf.WriteInt32(type); - for (auto &m : message_arg) { - if (m == nullptr) - break; - buf.WriteString(m); - } + for(; message_arg[argcount]; ++argcount) + length += strlen(message_arg[argcount]) + 1; - buf.WriteInt8(0); // prevent oob in packet translation, maybe clean that up sometime + length += 1; - auto outapp = std::make_unique(OP_FormattedMessage, buf); - - if (distance > 0) - entity_list.QueueCloseClients(this, outapp.get(), false, distance); - else - QueuePacket(outapp.get()); -} - -void Client::MessageString(const CZClientMessageString_Struct* msg) -{ - if (msg) + auto outapp = new EQApplicationPacket(OP_FormattedMessage, sizeof(FormattedMessage_Struct) + length); + FormattedMessage_Struct *fm = (FormattedMessage_Struct *)outapp->pBuffer; + fm->string_id = string_id; + fm->type = type; + bufptr = fm->message; + for(i = 0; i < argcount; i++) { - if (msg->args_size == 0) - { - MessageString(msg->chat_type, msg->string_id); - } - else - { - uint32_t outsize = sizeof(FormattedMessage_Struct) + msg->args_size; - auto outapp = std::make_unique(OP_FormattedMessage, outsize); - auto outbuf = reinterpret_cast(outapp->pBuffer); - outbuf->string_id = msg->string_id; - outbuf->type = msg->chat_type; - memcpy(outbuf->message, msg->args, msg->args_size); - QueuePacket(outapp.get()); - } + strcpy(bufptr, message_arg[i]); + bufptr += strlen(message_arg[i]) + 1; } + + // since we're moving the pointer the 0 offset is correct + bufptr[0] = '\0'; + + if(distance>0) + entity_list.QueueCloseClients(this,outapp,false,distance); + else + QueuePacket(outapp); + safe_delete(outapp); } // helper function, returns true if we should see the message @@ -3281,6 +3265,10 @@ void Client::FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter if (!FilteredMessageCheck(sender, filter)) return; + int i = 0, argcount = 0, length = 0; + char *bufptr = nullptr; + const char *message_arg[9] = {0}; + if (type == Chat::Emote) type = 4; @@ -3289,26 +3277,36 @@ void Client::FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter return; } - const char *message_arg[] = { - message1, message2, message3, message4, message5, - message6, message7, message8, message9 - }; + message_arg[i++] = message1; + message_arg[i++] = message2; + message_arg[i++] = message3; + message_arg[i++] = message4; + message_arg[i++] = message5; + message_arg[i++] = message6; + message_arg[i++] = message7; + message_arg[i++] = message8; + message_arg[i++] = message9; - SerializeBuffer buf(20); - buf.WriteInt32(0); // unknown - buf.WriteInt32(string_id); - buf.WriteInt32(type); - for (auto &m : message_arg) { - if (m == nullptr) - break; - buf.WriteString(m); + for (; message_arg[argcount]; ++argcount) + length += strlen(message_arg[argcount]) + 1; + + length += 1; + + auto outapp = new EQApplicationPacket(OP_FormattedMessage, sizeof(FormattedMessage_Struct) + length); + FormattedMessage_Struct *fm = (FormattedMessage_Struct *)outapp->pBuffer; + fm->string_id = string_id; + fm->type = type; + bufptr = fm->message; + for (i = 0; i < argcount; i++) { + strcpy(bufptr, message_arg[i]); + bufptr += strlen(message_arg[i]) + 1; } - buf.WriteInt8(0); // prevent oob in packet translation, maybe clean that up sometime + // since we're moving the pointer the 0 offset is correct + bufptr[0] = '\0'; - auto outapp = std::make_unique(OP_FormattedMessage, buf); - - QueuePacket(outapp.get()); + QueuePacket(outapp); + safe_delete(outapp); } void Client::Tell_StringID(uint32 string_id, const char *who, const char *message) @@ -3397,13 +3395,6 @@ void Client::LinkDead() if(raid){ raid->MemberZoned(this); } - - Expedition* expedition = GetExpedition(); - if (expedition) - { - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead); - } - // save_timer.Start(2500); linkdead_timer.Start(RuleI(Zone,ClientLinkdeadMS)); SendAppearancePacket(AT_Linkdead, 1); @@ -3959,7 +3950,7 @@ void Client::Sacrifice(Client *caster) Death_Struct *d = (Death_Struct *)app.pBuffer; d->spawn_id = GetID(); d->killer_id = caster ? caster->GetID() : 0; - d->bindzoneid = GetPP().binds[0].zone_id; + d->bindzoneid = GetPP().binds[0].zoneId; d->spell_id = SPELL_UNKNOWN; d->attack_skill = 0xe7; d->damage = 0; @@ -4007,7 +3998,7 @@ void Client::SendOPTranslocateConfirm(Mob *Caster, uint16 SpellID) { PendingTranslocateData.spell_id = ts->SpellID = SpellID; if((SpellID == 1422) || (SpellID == 1334) || (SpellID == 3243)) { - PendingTranslocateData.zone_id = ts->ZoneID = m_pp.binds[0].zone_id; + PendingTranslocateData.zone_id = ts->ZoneID = m_pp.binds[0].zoneId; PendingTranslocateData.instance_id = m_pp.binds[0].instance_id; PendingTranslocateData.x = ts->x = m_pp.binds[0].x; PendingTranslocateData.y = ts->y = m_pp.binds[0].y; @@ -4732,12 +4723,6 @@ void Client::IncrementAggroCount(bool raid_target) uint32 newtimer = raid_target ? RuleI(Character, RestRegenRaidTimeToActivate) : RuleI(Character, RestRegenTimeToActivate); - // When our aggro count is 1 here, we are exiting rest state. We need to pause our current timer, if we have time remaining - // We should not actually have to do anything to the Timer object since the AggroCount counter blocks it from being checked - // and will have it's timer changed when we exit combat so let's not do any extra work - if (AggroCount == 1 && rest_timer.GetRemainingTime()) // the Client::rest_timer is never disabled, so don't need to check - m_pp.RestTimer = std::max(1u, rest_timer.GetRemainingTime() / 1000); // I guess round up? - // save the new timer if it's higher m_pp.RestTimer = std::max(m_pp.RestTimer, newtimer); @@ -4747,6 +4732,10 @@ void Client::IncrementAggroCount(bool raid_target) if(AggroCount > 1) return; + // Pause the rest timer, it's possible the new timer is a non-raid timer we're currently ticking down on a raid timer + if (AggroCount == 1) + m_pp.RestTimer = std::max(m_pp.RestTimer, rest_timer.GetRemainingTime() / 1000); + if (ClientVersion() >= EQ::versions::ClientVersion::SoF) { auto outapp = new EQApplicationPacket(OP_RestState, 1); char *Buffer = (char *)outapp->pBuffer; @@ -4892,7 +4881,7 @@ void Client::SendRespawnBinds() BindStruct* b = &m_pp.binds[0]; RespawnOption opt; opt.name = "Bind Location"; - opt.zone_id = b->zone_id; + opt.zone_id = b->zoneId; opt.instance_id = b->instance_id; opt.x = b->x; opt.y = b->y; @@ -5289,11 +5278,11 @@ void Client::NotifyNewTitlesAvailable() } -void Client::SetStartZone(uint32 zoneid, float x, float y, float z, float heading) +void Client::SetStartZone(uint32 zoneid, float x, float y, float z) { // setting city to zero allows the player to use /setstartcity to set the city themselves if(zoneid == 0) { - m_pp.binds[4].zone_id = 0; + m_pp.binds[4].zoneId = 0; this->Message(Chat::Yellow,"Your starting city has been reset. Use /setstartcity to choose a new one"); return; } @@ -5303,32 +5292,24 @@ void Client::SetStartZone(uint32 zoneid, float x, float y, float z, float headin if(target_zone_name == nullptr) return; - m_pp.binds[4].zone_id = zoneid; + m_pp.binds[4].zoneId = zoneid; if(zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) { m_pp.binds[4].instance_id = zone->GetInstanceID(); } if (x == 0 && y == 0 && z == 0) { - content_db.GetSafePoints( - ZoneName(m_pp.binds[4].zone_id), - 0, - &m_pp.binds[4].x, - &m_pp.binds[4].y, - &m_pp.binds[4].z, - &m_pp.binds[4].heading - ); + content_db.GetSafePoints(ZoneName(m_pp.binds[4].zoneId), 0, &m_pp.binds[4].x, &m_pp.binds[4].y, &m_pp.binds[4].z); } else { m_pp.binds[4].x = x; m_pp.binds[4].y = y; m_pp.binds[4].z = z; - m_pp.binds[4].heading = heading; } } uint32 Client::GetStartZone() { - return m_pp.binds[4].zone_id; + return m_pp.binds[4].zoneId; } void Client::ShowSkillsWindow() @@ -5660,8 +5641,6 @@ void Client::SuspendMinion() CurrentPet->SetMana(m_suspendedminion.Mana); - CurrentPet->SetTaunting(m_suspendedminion.taunting); - MessageString(Chat::Magenta, SUSPEND_MINION_UNSUSPEND, CurrentPet->GetCleanName()); memset(&m_suspendedminion, 0, sizeof(struct PetInfo)); @@ -5673,8 +5652,7 @@ void Client::SuspendMinion() SetPetCommandState(PET_BUTTON_REGROUP, 0); SetPetCommandState(PET_BUTTON_FOLLOW, 1); SetPetCommandState(PET_BUTTON_GUARD, 0); - // Taunt saved on client side for logging on with pet - // In our db for when we zone. + SetPetCommandState(PET_BUTTON_TAUNT, 1); SetPetCommandState(PET_BUTTON_HOLD, 0); SetPetCommandState(PET_BUTTON_GHOLD, 0); SetPetCommandState(PET_BUTTON_FOCUS, 0); @@ -5760,18 +5738,6 @@ void Client::AddCrystals(uint32 Radiant, uint32 Ebon) SendCrystalCounts(); } -void Client::SetEbonCrystals(uint32 value) { - m_pp.currentEbonCrystals = value; - SaveCurrency(); - SendCrystalCounts(); -} - -void Client::SetRadiantCrystals(uint32 value) { - m_pp.currentRadCrystals = value; - SaveCurrency(); - SendCrystalCounts(); -} - // Processes a client request to inspect a SoF+ client's equipment. void Client::ProcessInspectRequest(Client* requestee, Client* requester) { if(requestee && requester) { @@ -6139,12 +6105,21 @@ void Client::CheckEmoteHail(Mob *target, const char* message) void Client::MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count) { - m_has_quest_compass = (count != 0); - m_quest_compass.x = in_x; - m_quest_compass.y = in_y; - m_quest_compass.z = in_z; - SendDzCompassUpdate(); + auto outapp = new EQApplicationPacket(OP_DzCompass, sizeof(ExpeditionInfo_Struct) + + sizeof(ExpeditionCompassEntry_Struct) * count); + ExpeditionCompass_Struct *ecs = (ExpeditionCompass_Struct*)outapp->pBuffer; + //ecs->clientid = GetID(); + ecs->count = count; + + if (count) { + ecs->entries[0].x = in_x; + ecs->entries[0].y = in_y; + ecs->entries[0].z = in_z; + } + + FastQueuePacket(&outapp); + safe_delete(outapp); } void Client::SendZonePoints() @@ -8637,7 +8612,7 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, AddMoneyToPP(copper, silver, gold, platinum, false); if (itemid > 0) - SummonItem(itemid, -1, 0, 0, 0, 0, 0, false, EQ::invslot::slotCursor); + SummonItem(itemid, 0, 0, 0, 0, 0, 0, false, EQ::invslot::slotCursor); if (faction) { @@ -9189,14 +9164,17 @@ void Client::SetDisplayMobInfoWindow(bool display_mob_info_window) Client::display_mob_info_window = display_mob_info_window; } -bool Client::IsDevToolsEnabled() const +bool Client::IsDevToolsWindowEnabled() const { - return dev_tools_enabled && RuleB(World, EnableDevTools); + return dev_tools_window_enabled; } -void Client::SetDevToolsEnabled(bool in_dev_tools_enabled) +/** + * @param in_dev_tools_window_enabled + */ +void Client::SetDevToolsWindowEnabled(bool in_dev_tools_window_enabled) { - Client::dev_tools_enabled = in_dev_tools_enabled; + Client::dev_tools_window_enabled = in_dev_tools_window_enabled; } /** @@ -9367,775 +9345,3 @@ void Client::SendToGuildHall() AssignToInstance(instance_id); MovePC(345, instance_id, -1.00, -1.00, 3.34, 0, 1); } - -void Client::CheckVirtualZoneLines() -{ - for (auto &virtual_zone_point : zone->virtual_zone_point_list) { - float half_width = ((float) virtual_zone_point.width / 2); - - if ( - GetX() > (virtual_zone_point.x - half_width) && - GetX() < (virtual_zone_point.x + half_width) && - GetY() > (virtual_zone_point.y - half_width) && - GetY() < (virtual_zone_point.y + half_width) && - GetZ() >= (virtual_zone_point.z - 10) && - GetZ() < (virtual_zone_point.z + (float) virtual_zone_point.height) - ) { - - MovePC( - virtual_zone_point.target_zone_id, - virtual_zone_point.target_instance, - virtual_zone_point.target_x, - virtual_zone_point.target_y, - virtual_zone_point.target_z, - virtual_zone_point.target_heading - ); - - LogZonePoints( - "Virtual Zone Box Sending player [{}] to [{}]", - GetCleanName(), - zone_store.GetZoneLongName(virtual_zone_point.target_zone_id) - ); - } - } -} - -void Client::ShowDevToolsMenu() -{ - std::string menu_commands_search; - std::string menu_commands_show; - std::string reload_commands_show; - std::string devtools_toggle; - - /** - * Search entity commands - */ - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list npcs", false, "NPC") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list players", false, "Players") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list corpses", false, "Corpses") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list doors", false, "Doors") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list objects", false, "Objects") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#fz", false, "Zones") + "] "; - menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#fi", false, "Items") + "] "; - - /** - * Show - */ - menu_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#showzonepoints", false, "Zone Points") + "] "; - menu_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#showzonegloballoot", false, "Zone Global Loot") + "] "; - - /** - * Reload - */ - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#rq", false, "Quests") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadmerchants", false, "Merchants") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadallrules", false, "Rules Globally") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadstatic", false, "Ground Spawns") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadstatic", false, "Alternate Currencies") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadstatic", false, "DB Emotes") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadstatic", false, "Doors") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadtraps", false, "Traps") + "] "; - reload_commands_show += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#reloadzps", false, "Zone Points") + "] "; - - /** - * Show window status - */ - devtools_toggle = "Disabled [" + EQ::SayLinkEngine::GenerateQuestSaylink("#devtools enable", false, "Enable") + "] "; - if (IsDevToolsEnabled()) { - devtools_toggle = "Enabled [" + EQ::SayLinkEngine::GenerateQuestSaylink("#devtools disable", false, "Disable") + "] "; - } - - /** - * Print menu - */ - SendChatLineBreak(); - Message( - Chat::White, "| [Devtools] %s Show this menu with %s | Current expansion [%s]", - devtools_toggle.c_str(), - EQ::SayLinkEngine::GenerateQuestSaylink("#dev", false, "#dev").c_str(), - content_service.GetCurrentExpansionName().c_str() - ); - Message(Chat::White, "| [Devtools] Search %s", menu_commands_search.c_str()); - Message(Chat::White, "| [Devtools] Show %s", menu_commands_show.c_str()); - Message(Chat::White, "| [Devtools] Reload %s", reload_commands_show.c_str()); - Message(Chat::White, "| [Devtools] Search commands with #help "); - SendChatLineBreak(); -} - -void Client::SendChatLineBreak(uint16 color) { - Message(color, "------------------------------------------------"); -} - -void Client::SendCrossZoneMessage( - Client* client, const std::string& character_name, uint16_t chat_type, const std::string& message) -{ - // if client is null, falls back to sending a cross zone message by name - if (!client && !character_name.empty()) - { - client = entity_list.GetClientByName(character_name.c_str()); - } - - if (client) - { - client->Message(chat_type, message.c_str()); - } - else if (!character_name.empty() && !message.empty()) - { - uint32_t pack_size = sizeof(CZMessagePlayer_Struct); - auto pack = std::make_unique(ServerOP_CZMessagePlayer, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->type = chat_type; - strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name)); - strn0cpy(buf->message, message.c_str(), sizeof(buf->message)); - - worldserver.SendPacket(pack.get()); - } -} - -void Client::SendCrossZoneMessageString( - Client* client, const std::string& character_name, uint16_t chat_type, - uint32_t string_id, const std::initializer_list& arguments) -{ - // if client is null, falls back to sending a cross zone message by name - if (!client && !character_name.empty()) // double check client isn't in this zone - { - client = entity_list.GetClientByName(character_name.c_str()); - } - - if (!client && character_name.empty()) - { - return; - } - - SerializeBuffer argument_buffer; - for (const auto& argument : arguments) - { - argument_buffer.WriteString(argument); - } - - uint32_t args_size = static_cast(argument_buffer.size()); - uint32_t pack_size = sizeof(CZClientMessageString_Struct) + args_size; - auto pack = std::make_unique(ServerOP_CZClientMessageString, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->string_id = string_id; - buf->chat_type = chat_type; - strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name)); - buf->args_size = args_size; - memcpy(buf->args, argument_buffer.buffer(), argument_buffer.size()); - - if (client) - { - client->MessageString(buf); - } - else - { - worldserver.SendPacket(pack.get()); - } -} - -void Client::UpdateExpeditionInfoAndLockouts() -{ - // this is processed by client after entering a zone - SendDzCompassUpdate(); - - m_expedition_lockouts = ExpeditionDatabase::LoadCharacterLockouts(CharacterID()); - - auto expedition = GetExpedition(); - if (expedition) - { - expedition->SendClientExpeditionInfo(this); - - // live synchronizes lockouts obtained during the active expedition to - // members once they zone into the expedition's dynamic zone instance - if (expedition->GetDynamicZone().IsCurrentZoneDzInstance()) - { - expedition->SyncCharacterLockouts(CharacterID(), m_expedition_lockouts); - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::InDynamicZone); - } - else - { - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Online); - } - } - - SendExpeditionLockoutTimers(); - - // ask world for any pending invite we saved from a previous zone - RequestPendingExpeditionInvite(); -} - -Expedition* Client::CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request) -{ - return Expedition::TryCreate(this, dz_instance, request); -} - -Expedition* Client::CreateExpedition( - const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name, - uint32 min_players, uint32 max_players, bool disable_messages) -{ - DynamicZone dz_instance{ ZoneID(zone_name), version, duration, DynamicZoneType::Expedition }; - ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages }; - return Expedition::TryCreate(this, dz_instance, request); -} - -Expedition* Client::GetExpedition() const -{ - if (zone && m_expedition_id) - { - auto expedition_cache_iter = zone->expedition_cache.find(m_expedition_id); - if (expedition_cache_iter != zone->expedition_cache.end()) - { - return expedition_cache_iter->second.get(); - } - } - return nullptr; -} - -void Client::AddExpeditionLockout(const ExpeditionLockoutTimer& lockout, bool update_db) -{ - // todo: support for account based lockouts like live AoC expeditions - - // if client already has this lockout, we're replacing it with the new one - m_expedition_lockouts.erase(std::remove_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(), - [&](const ExpeditionLockoutTimer& existing_lockout) { - return existing_lockout.IsSameLockout(lockout); - } - ), m_expedition_lockouts.end()); - - m_expedition_lockouts.emplace_back(lockout); - - if (update_db) // for quest api - { - ExpeditionDatabase::InsertCharacterLockouts(CharacterID(), { lockout }); - } - - SendExpeditionLockoutTimers(); -} - -void Client::AddNewExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid) -{ - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid); - AddExpeditionLockout(lockout, true); -} - -void Client::AddExpeditionLockoutDuration( - const std::string& expedition_name, const std::string& event_name, int seconds, - const std::string& uuid, bool update_db) -{ - auto it = std::find_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(), - [&](const ExpeditionLockoutTimer& lockout) { - return lockout.IsSameLockout(expedition_name, event_name); - }); - - if (it != m_expedition_lockouts.end()) - { - it->AddLockoutTime(seconds); - - if (!uuid.empty()) - { - it->SetUUID(uuid); - } - - if (update_db) - { - ExpeditionDatabase::InsertCharacterLockouts(CharacterID(), { *it }); - } - - SendExpeditionLockoutTimers(); - } - else if (seconds > 0) // missing lockouts inserted for reductions would be instantly expired - { - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid); - AddExpeditionLockout(lockout, update_db); - } -} - -void Client::RemoveExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, bool update_db) -{ - m_expedition_lockouts.erase(std::remove_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(), - [&](const ExpeditionLockoutTimer& lockout) { - return lockout.IsSameLockout(expedition_name, event_name); - } - ), m_expedition_lockouts.end()); - - if (update_db) // for quest api - { - ExpeditionDatabase::DeleteCharacterLockout(CharacterID(), expedition_name, event_name); - } - - SendExpeditionLockoutTimers(); -} - -void Client::RemoveAllExpeditionLockouts(const std::string& expedition_name, bool update_db) -{ - if (expedition_name.empty()) - { - if (update_db) - { - ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID()); - } - m_expedition_lockouts.clear(); - } - else - { - if (update_db) - { - ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID(), expedition_name); - } - - m_expedition_lockouts.erase(std::remove_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(), - [&](const ExpeditionLockoutTimer& lockout) { - return lockout.GetExpeditionName() == expedition_name; - } - ), m_expedition_lockouts.end()); - } - - SendExpeditionLockoutTimers(); -} - -const ExpeditionLockoutTimer* Client::GetExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, bool include_expired) const -{ - for (const auto& expedition_lockout : m_expedition_lockouts) - { - if ((include_expired || !expedition_lockout.IsExpired()) && - expedition_lockout.IsSameLockout(expedition_name, event_name)) - { - return &expedition_lockout; - } - } - return nullptr; -} - -std::vector Client::GetExpeditionLockouts( - const std::string& expedition_name, bool include_expired) -{ - std::vector lockouts; - for (const auto& lockout : m_expedition_lockouts) - { - if ((include_expired || !lockout.IsExpired()) && - lockout.GetExpeditionName() == expedition_name) - { - lockouts.emplace_back(lockout); - } - } - return lockouts; -} - -bool Client::HasExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, bool include_expired) -{ - return (GetExpeditionLockout(expedition_name, event_name, include_expired) != nullptr); -} - -void Client::SendExpeditionLockoutTimers() -{ - std::vector lockout_entries; - - // client displays lockouts rounded down to nearest minute, send lockouts - // with 60s offset added to compensate (live does this too) - constexpr uint32_t rounding_seconds = 60; - - // erases expired lockouts while building lockout timer list - for (auto it = m_expedition_lockouts.begin(); it != m_expedition_lockouts.end();) - { - uint32_t seconds_remaining = it->GetSecondsRemaining(); - if (seconds_remaining == 0) - { - it = m_expedition_lockouts.erase(it); - } - else - { - ExpeditionLockoutTimerEntry_Struct lockout; - strn0cpy(lockout.expedition_name, it->GetExpeditionName().c_str(), sizeof(lockout.expedition_name)); - lockout.seconds_remaining = seconds_remaining + rounding_seconds; - lockout.event_type = it->IsReplayTimer() ? Expedition::REPLAY_TIMER_ID : Expedition::EVENT_TIMER_ID; - strn0cpy(lockout.event_name, it->GetEventName().c_str(), sizeof(lockout.event_name)); - - lockout_entries.emplace_back(lockout); - ++it; - } - } - - uint32_t lockout_count = static_cast(lockout_entries.size()); - uint32_t lockout_entries_size = sizeof(ExpeditionLockoutTimerEntry_Struct) * lockout_count; - uint32_t outsize = sizeof(ExpeditionLockoutTimers_Struct) + lockout_entries_size; - auto outapp = std::make_unique(OP_DzExpeditionLockoutTimers, outsize); - auto outbuf = reinterpret_cast(outapp->pBuffer); - outbuf->count = lockout_count; - if (!lockout_entries.empty()) - { - memcpy(outbuf->timers, lockout_entries.data(), lockout_entries_size); - } - QueuePacket(outapp.get()); -} - -void Client::RequestPendingExpeditionInvite() -{ - uint32_t packsize = sizeof(ServerExpeditionCharacterID_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionRequestInvite, packsize); - auto packbuf = reinterpret_cast(pack->pBuffer); - packbuf->character_id = CharacterID(); - worldserver.SendPacket(pack.get()); -} - -void Client::DzListTimers() -{ - // only lists player's current replay timer lockouts, not all event lockouts - bool found = false; - for (const auto& lockout : m_expedition_lockouts) - { - if (lockout.IsReplayTimer()) - { - found = true; - auto time_remaining = lockout.GetDaysHoursMinutesRemaining(); - MessageString( - Chat::Yellow, DZLIST_REPLAY_TIMER, - time_remaining.days.c_str(), - time_remaining.hours.c_str(), - time_remaining.mins.c_str(), - lockout.GetExpeditionName().c_str() - ); - } - } - - if (!found) - { - MessageString(Chat::Yellow, EXPEDITION_NO_TIMERS); - } -} - -void Client::SetDzRemovalTimer(bool enable_timer) -{ - uint32_t timer_ms = RuleI(DynamicZone, ClientRemovalDelayMS); - - LogDynamicZones( - "Character [{}] instance [{}] removal timer enabled: [{}] delay (ms): [{}]", - CharacterID(), zone ? zone->GetInstanceID() : 0, enable_timer, timer_ms - ); - - if (enable_timer) - { - dynamiczone_removal_timer.Start(timer_ms); - } - else - { - dynamiczone_removal_timer.Disable(); - } -} - -void Client::SendDzCompassUpdate() -{ - // client may be associated with multiple dynamic zone compasses in this zone - std::vector compass_entries; - - for (const auto& client_dz : GetDynamicZones()) - { - auto compass = client_dz->GetCompassLocation(); - if (zone && zone->IsZone(compass.zone_id, 0)) - { - DynamicZoneCompassEntry_Struct entry; - entry.dz_zone_id = client_dz->GetZoneID(); - entry.dz_instance_id = client_dz->GetInstanceID(); - entry.dz_type = static_cast(client_dz->GetType()); - entry.x = compass.x; - entry.y = compass.y; - entry.z = compass.z; - - compass_entries.emplace_back(entry); - } - } - - // compass set via MarkSingleCompassLocation() - if (m_has_quest_compass) - { - DynamicZoneCompassEntry_Struct entry; - entry.dz_zone_id = 0; - entry.dz_instance_id = 0; - entry.dz_type = 0; - entry.x = m_quest_compass.x; - entry.y = m_quest_compass.y; - entry.z = m_quest_compass.z; - - compass_entries.emplace_back(entry); - } - - QueuePacket(CreateCompassPacket(compass_entries).get()); -} - -std::unique_ptr Client::CreateCompassPacket( - const std::vector& compass_entries) -{ - uint32 count = static_cast(compass_entries.size()); - uint32 entries_size = sizeof(DynamicZoneCompassEntry_Struct) * count; - uint32 outsize = sizeof(DynamicZoneCompass_Struct) + entries_size; - auto outapp = std::make_unique(OP_DzCompass, outsize); - auto outbuf = reinterpret_cast(outapp->pBuffer); - outbuf->count = count; - memcpy(outbuf->entries, compass_entries.data(), entries_size); - - return outapp; -} - -void Client::GoToDzSafeReturnOrBind(const DynamicZone* dynamic_zone) -{ - if (dynamic_zone) - { - auto safereturn = dynamic_zone->GetSafeReturnLocation(); - if (safereturn.zone_id != 0) - { - LogDynamicZonesDetail("Sending [{}] to safereturn zone [{}]", CharacterID(), safereturn.zone_id); - MovePC(safereturn.zone_id, 0, safereturn.x, safereturn.y, safereturn.z, safereturn.heading); - return; - } - } - - GoToBind(); -} - -std::vector Client::GetDynamicZones(uint32_t zone_id, int zone_version) -{ - std::vector client_dzs; - - // check client systems for any associated dynamic zones optionally filtered by zone - Expedition* expedition = GetExpedition(); - if (expedition && - (zone_id == 0 || expedition->GetDynamicZone().GetZoneID() == zone_id) && - (zone_version < 0 || expedition->GetDynamicZone().GetZoneVersion() == zone_version)) - { - client_dzs.emplace_back(&expedition->GetDynamicZone()); - } - - // todo: tasks, missions (shared tasks), and quests with an associated dz to zone_id - - return client_dzs; -} - -void Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_invalid) -{ - if (zone_id == 0) - { - return; - } - - auto client_dzs = GetDynamicZones(zone_id, zone_version); - - if (client_dzs.empty()) - { - if (msg_if_invalid) - { - MessageString(Chat::Red, DYNAMICZONE_WAY_IS_BLOCKED); // unconfirmed message - } - } - else if (client_dzs.size() == 1) - { - auto dz = client_dzs.front(); - DynamicZoneLocation zonein = dz->GetZoneInLocation(); - ZoneMode zone_mode = dz->HasZoneInLocation() ? ZoneMode::ZoneSolicited : ZoneMode::ZoneToSafeCoords; - MovePC(zone_id, dz->GetInstanceID(), zonein.x, zonein.y, zonein.z, zonein.heading, 0, zone_mode); - } - else - { - LogDynamicZonesDetail("Sending DzSwitchListWnd to [{}] for zone [{}] with [{}] dynamic zone(s)", - CharacterID(), zone_id, client_dzs.size()); - - // client has more than one dz for this zone, send out the switchlist window - QueuePacket(CreateDzSwitchListPacket(client_dzs).get()); - } -} - -std::unique_ptr Client::CreateDzSwitchListPacket( - const std::vector& client_dzs) -{ - uint32 count = static_cast(client_dzs.size()); - uint32 entries_size = sizeof(DynamicZoneChooseZoneEntry_Struct) * count; - uint32 outsize = sizeof(DynamicZoneChooseZone_Struct) + entries_size; - auto outapp = std::make_unique(OP_DzChooseZone, outsize); - auto outbuf = reinterpret_cast(outapp->pBuffer); - outbuf->count = count; - for (int i = 0; i < client_dzs.size(); ++i) - { - outbuf->choices[i].dz_zone_id = client_dzs[i]->GetZoneID(); - outbuf->choices[i].dz_instance_id = client_dzs[i]->GetInstanceID(); - outbuf->choices[i].dz_type = static_cast(client_dzs[i]->GetType()); - strn0cpy(outbuf->choices[i].description, client_dzs[i]->GetName().c_str(), sizeof(outbuf->choices[i].description)); - strn0cpy(outbuf->choices[i].leader_name, client_dzs[i]->GetLeaderName().c_str(), sizeof(outbuf->choices[i].leader_name)); - } - return outapp; -} - -void Client::MovePCDynamicZone(const std::string& zone_name, int zone_version, bool msg_if_invalid) -{ - auto zone_id = ZoneID(zone_name.c_str()); - MovePCDynamicZone(zone_id, zone_version, msg_if_invalid); -} - -void Client::Fling(float value, float target_x, float target_y, float target_z, bool ignore_los, bool clipping) { - BuffFadeByEffect(SE_Levitate); - if (CheckLosFN(target_x, target_y, target_z, 6.0f) || ignore_los) { - auto outapp_fling = new EQApplicationPacket(OP_Fling, sizeof(fling_struct)); - fling_struct* flingTo = (fling_struct*)outapp_fling->pBuffer; - if(clipping) - flingTo->collision = 0; - else - flingTo->collision = -1; - - flingTo->travel_time = -1; - flingTo->unk3 = 1; - flingTo->disable_fall_damage = 1; - flingTo->speed_z = value; - flingTo->new_y = target_y; - flingTo->new_x = target_x; - flingTo->new_z = target_z; - outapp_fling->priority = 6; - FastQueuePacket(&outapp_fling); - } -} - -std::vector Client::GetLearnableDisciplines(uint8 min_level, uint8 max_level) { - bool SpellGlobalRule = RuleB(Spells, EnableSpellGlobals); - bool SpellBucketRule = RuleB(Spells, EnableSpellBuckets); - bool SpellGlobalCheckResult = false; - bool SpellBucketCheckResult = false; - std::vector learnable_disciplines; - for (int spell_id = 0; spell_id < SPDAT_RECORDS; ++spell_id) { - bool learnable = false; - if (!IsValidSpell(spell_id)) - continue; - if (!IsDiscipline(spell_id)) - continue; - if (spells[spell_id].classes[WARRIOR] == 0) - continue; - if (max_level > 0 && spells[spell_id].classes[m_pp.class_ - 1] > max_level) - continue; - if (min_level > 1 && spells[spell_id].classes[m_pp.class_ - 1] < min_level) - continue; - if (spells[spell_id].skill == 52) - continue; - if (RuleB(Spells, UseCHAScribeHack) && spells[spell_id].effectid[EFFECT_COUNT - 1] == 10) - continue; - if (HasDisciplineLearned(spell_id)) - continue; - - if (SpellGlobalRule) { - SpellGlobalCheckResult = SpellGlobalCheck(spell_id, CharacterID()); - if (SpellGlobalCheckResult) { - learnable = true; - } - } else if (SpellBucketRule) { - SpellBucketCheckResult = SpellBucketCheck(spell_id, CharacterID()); - if (SpellBucketCheckResult) { - learnable = true; - } - } else { - learnable = true; - } - - if (learnable) { - learnable_disciplines.push_back(spell_id); - } - } - return learnable_disciplines; -} - -std::vector Client::GetLearnedDisciplines() { - std::vector learned_disciplines; - for (int index = 0; index < MAX_PP_DISCIPLINES; index++) { - if (IsValidSpell(m_pp.disciplines.values[index])) { - learned_disciplines.push_back(m_pp.disciplines.values[index]); - } - } - return learned_disciplines; -} - -std::vector Client::GetMemmedSpells() { - std::vector memmed_spells; - for (int index = 0; index < EQ::spells::SPELL_GEM_COUNT; index++) { - if (IsValidSpell(m_pp.mem_spells[index])) { - memmed_spells.push_back(m_pp.mem_spells[index]); - } - } - return memmed_spells; -} - -std::vector Client::GetScribeableSpells(uint8 min_level, uint8 max_level) { - bool SpellGlobalRule = RuleB(Spells, EnableSpellGlobals); - bool SpellBucketRule = RuleB(Spells, EnableSpellBuckets); - bool SpellGlobalCheckResult = false; - bool SpellBucketCheckResult = false; - std::vector scribeable_spells; - for (int spell_id = 0; spell_id < SPDAT_RECORDS; ++spell_id) { - bool scribeable = false; - if (!IsValidSpell(spell_id)) - continue; - if (IsDiscipline(spell_id)) - continue; - if (spells[spell_id].classes[WARRIOR] == 0) - continue; - if (max_level > 0 && spells[spell_id].classes[m_pp.class_ - 1] > max_level) - continue; - if (min_level > 1 && spells[spell_id].classes[m_pp.class_ - 1] < min_level) - continue; - if (spells[spell_id].skill == 52) - continue; - if (RuleB(Spells, UseCHAScribeHack) && spells[spell_id].effectid[EFFECT_COUNT - 1] == 10) - continue; - if (HasSpellScribed(spell_id)) - continue; - - if (SpellGlobalRule) { - SpellGlobalCheckResult = SpellGlobalCheck(spell_id, CharacterID()); - if (SpellGlobalCheckResult) { - scribeable = true; - } - } else if (SpellBucketRule) { - SpellBucketCheckResult = SpellBucketCheck(spell_id, CharacterID()); - if (SpellBucketCheckResult) { - scribeable = true; - } - } else { - scribeable = true; - } - - if (scribeable) { - scribeable_spells.push_back(spell_id); - } - } - return scribeable_spells; -} - -std::vector Client::GetScribedSpells() { - std::vector scribed_spells; - for(int index = 0; index < EQ::spells::SPELLBOOK_SIZE; index++) { - if (IsValidSpell(m_pp.spell_book[index])) { - scribed_spells.push_back(m_pp.spell_book[index]); - } - } - return scribed_spells; -} - -void Client::SetAnon(uint8 anon_flag) { - m_pp.anon = anon_flag; - auto outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct)); - SpawnAppearance_Struct* spawn_appearance = (SpawnAppearance_Struct*)outapp->pBuffer; - spawn_appearance->spawn_id = this->GetID(); - spawn_appearance->type = AT_Anon; - spawn_appearance->parameter = anon_flag; - entity_list.QueueClients(this, outapp); - Save(); - UpdateWho(); - safe_delete(outapp); -} - -void Client::SetAFK(uint8 afk_flag) { - AFK = afk_flag; - auto outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct)); - SpawnAppearance_Struct* spawn_appearance = (SpawnAppearance_Struct*)outapp->pBuffer; - spawn_appearance->spawn_id = this->GetID(); - spawn_appearance->type = AT_AFK; - spawn_appearance->parameter = afk_flag; - entity_list.QueueClients(this, outapp); - safe_delete(outapp); -} diff --git a/zone/client.h b/zone/client.h index 6e2840217..036f03baa 100644 --- a/zone/client.h +++ b/zone/client.h @@ -21,17 +21,12 @@ class Client; class EQApplicationPacket; class EQStream; -class DynamicZone; -class Expedition; -class ExpeditionLockoutTimer; -class ExpeditionRequest; class Group; class NPC; class Object; class Raid; class Seperator; class ServerPacket; -struct DynamicZoneLocation; enum WaterRegionType : int; namespace EQ @@ -64,8 +59,6 @@ namespace EQ #include "zone.h" #include "zonedb.h" #include "zone_store.h" -#include "task_manager.h" -#include "task_client_state.h" #ifdef _WINDOWS // since windows defines these within windef.h (which windows.h include) @@ -87,7 +80,7 @@ namespace EQ #define XTARGET_HARDCAP 20 extern Zone* zone; -extern TaskManager *task_manager; +extern TaskManager *taskmanager; class CLIENTPACKET { @@ -239,14 +232,12 @@ public: void SetDisplayMobInfoWindow(bool display_mob_info_window); bool GetDisplayMobInfoWindow() const; - bool IsDevToolsEnabled() const; - void SetDevToolsEnabled(bool in_dev_tools_enabled); + bool IsDevToolsWindowEnabled() const; + void SetDevToolsWindowEnabled(bool dev_tools_window_enabled); void SetPrimaryWeaponOrnamentation(uint32 model_id); void SetSecondaryWeaponOrnamentation(uint32 model_id); - void SendChatLineBreak(uint16 color = Chat::White); - bool GotoPlayer(std::string player_name); //abstract virtual function implementations required by base abstract class @@ -290,7 +281,6 @@ public: uint8 SlotConvert(uint8 slot,bool bracer=false); void MessageString(uint32 type, uint32 string_id, uint32 distance = 0); void MessageString(uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0); - void MessageString(const CZClientMessageString_Struct* msg); bool FilteredMessageCheck(Mob *sender, eqFilterType filter); void FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter, uint32 string_id); void FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter, @@ -370,9 +360,6 @@ public: void Kick(const std::string &reason); void WorldKick(); inline uint8 GetAnon() const { return m_pp.anon; } - inline uint8 GetAFK() const { return AFK; } - void SetAnon(uint8 anon_flag); - void SetAFK(uint8 afk_flag); inline PlayerProfile_Struct& GetPP() { return m_pp; } inline ExtendedProfile_Struct& GetEPP() { return m_epp; } inline EQ::InventoryProfile& GetInv() { return m_inv; } @@ -426,7 +413,7 @@ public: inline const float GetBindY(uint32 index = 0) const { return m_pp.binds[index].y; } inline const float GetBindZ(uint32 index = 0) const { return m_pp.binds[index].z; } inline const float GetBindHeading(uint32 index = 0) const { return m_pp.binds[index].heading; } - inline uint32 GetBindZoneID(uint32 index = 0) const { return m_pp.binds[index].zone_id; } + inline uint32 GetBindZoneID(uint32 index = 0) const { return m_pp.binds[index].zoneId; } inline uint32 GetBindInstanceID(uint32 index = 0) const { return m_pp.binds[index].instance_id; } int32 CalcMaxMana(); int32 CalcBaseMana(); @@ -459,8 +446,6 @@ public: inline float ProximityZ() const { return m_Proximity.z; } inline void ClearAllProximities() { entity_list.ProcessMove(this, glm::vec3(FLT_MAX, FLT_MAX, FLT_MAX)); m_Proximity = glm::vec3(FLT_MAX,FLT_MAX,FLT_MAX); } - void CheckVirtualZoneLines(); - /* Begin client modifiers */ @@ -600,19 +585,14 @@ public: inline uint32 GetEXP() const { return m_pp.exp; } - inline double GetAAEXPModifier(uint32 zone_id) const { return database.GetAAEXPModifier(CharacterID(), zone_id); }; - inline double GetEXPModifier(uint32 zone_id) const { return database.GetEXPModifier(CharacterID(), zone_id); }; - inline void SetAAEXPModifier(uint32 zone_id, double aa_modifier) { database.SetAAEXPModifier(CharacterID(), zone_id, aa_modifier); }; - inline void SetEXPModifier(uint32 zone_id, double exp_modifier) { database.SetEXPModifier(CharacterID(), zone_id, exp_modifier); }; - bool UpdateLDoNPoints(int32 points, uint32 theme); void SetPVPPoints(uint32 Points) { m_pp.PVPCurrentPoints = Points; } uint32 GetPVPPoints() { return m_pp.PVPCurrentPoints; } void AddPVPPoints(uint32 Points); uint32 GetRadiantCrystals() { return m_pp.currentRadCrystals; } - void SetRadiantCrystals(uint32 value); + void SetRadiantCrystals(uint32 Crystals) { m_pp.currentRadCrystals = Crystals; } uint32 GetEbonCrystals() { return m_pp.currentEbonCrystals; } - void SetEbonCrystals(uint32 value); + void SetEbonCrystals(uint32 Crystals) { m_pp.currentEbonCrystals = Crystals; } void AddCrystals(uint32 Radiant, uint32 Ebon); void SendCrystalCounts(); @@ -649,8 +629,7 @@ public: void GoToSafeCoords(uint16 zone_id, uint16 instance_id); void Gate(uint8 bindnum = 0); void SetBindPoint(int bind_num = 0, int to_zone = -1, int to_instance = 0, const glm::vec3& location = glm::vec3()); - void SetBindPoint2(int bind_num = 0, int to_zone = -1, int to_instance = 0, const glm::vec4& location = glm::vec4()); - void SetStartZone(uint32 zoneid, float x = 0.0f, float y =0.0f, float z = 0.0f, float heading = 0.0f); + void SetStartZone(uint32 zoneid, float x = 0.0f, float y =0.0f, float z = 0.0f); uint32 GetStartZone(void); void MovePC(const char* zonename, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited); void MovePC(uint32 zoneID, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited); @@ -794,11 +773,6 @@ public: void UnmemSpellAll(bool update_client = true); uint16 FindMemmedSpellBySlot(int slot); int MemmedCount(); - std::vector GetLearnableDisciplines(uint8 min_level = 1, uint8 max_level = 0); - std::vector GetLearnedDisciplines(); - std::vector GetMemmedSpells(); - std::vector GetScribeableSpells(uint8 min_level = 1, uint8 max_level = 0); - std::vector GetScribedSpells(); void ScribeSpell(uint16 spell_id, int slot, bool update_client = true); void UnscribeSpell(int slot, bool update_client = true); void UnscribeSpellAll(bool update_client = true); @@ -809,8 +783,6 @@ public: uint32 GetCharMaxLevelFromQGlobal(); uint32 GetCharMaxLevelFromBucket(); - void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los = false, bool clipping = false); - inline bool IsStanding() const {return (playeraction == 0);} inline bool IsSitting() const {return (playeraction == 1);} inline bool IsCrouching() const {return (playeraction == 2);} @@ -990,7 +962,6 @@ public: void SendDisciplineUpdate(); void SendDisciplineTimer(uint32 timer_id, uint32 duration); bool UseDiscipline(uint32 spell_id, uint32 target); - bool HasDisciplineLearned(uint16 spell_id); void SetLinkedSpellReuseTimer(uint32 timer_id, uint32 duration); bool IsLinkedSpellReuseTimerReady(uint32 timer_id); @@ -1013,10 +984,9 @@ public: void ProcessInspectRequest(Client* requestee, Client* requester); bool ClientFinishedLoading() { return (conn_state == ClientConnectFinished); } int FindSpellBookSlotBySpellID(uint16 spellid); - uint32 GetSpellIDByBookSlot(int book_slot); int GetNextAvailableSpellBookSlot(int starting_slot = 0); inline uint32 GetSpellByBookSlot(int book_slot) { return m_pp.spell_book[book_slot]; } - inline bool HasSpellScribed(int spellid) { return FindSpellBookSlotBySpellID(spellid) != -1; } + inline bool HasSpellScribed(int spellid) { return (FindSpellBookSlotBySpellID(spellid) != -1 ? true : false); } uint16 GetMaxSkillAfterSpecializationRules(EQ::skills::SkillType skillid, uint16 maxSkill); void SendPopupToClient(const char *Title, const char *Text, uint32 PopupID = 0, uint32 Buttons = 0, uint32 Duration = 0); void SendFullPopup(const char *Title, const char *Text, uint32 PopupID = 0, uint32 NegativeID = 0, uint32 Buttons = 0, uint32 Duration = 0, const char *ButtonName0 = 0, const char *ButtonName1 = 0, uint32 SoundControls = 0); @@ -1031,241 +1001,48 @@ public: // Task System Methods void LoadClientTaskState(); void RemoveClientTaskState(); - void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1); - void SendTaskFailed(int task_id, int task_index, TaskType task_type); - void SendTaskComplete(int task_index); - inline ClientTaskState *GetTaskState() const { return task_state; } - inline void CancelTask(int task_index, TaskType task_type) - { - if (task_state) { - task_state->CancelTask( - this, - task_index, - task_type - ); - } - } - inline bool SaveTaskState() - { - return task_manager != nullptr && task_manager->SaveClientState(this, task_state); - } - inline bool IsTaskStateLoaded() { return task_state != nullptr; } - inline bool IsTaskActive(int task_id) { return task_state != nullptr && task_state->IsTaskActive(task_id); } - inline bool IsTaskActivityActive(int task_id, int activity_id) - { - return task_state != nullptr && - task_state->IsTaskActivityActive( - task_id, - activity_id - ); - } - inline ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id) - { - return (task_state ? task_state->GetTaskActivityState(task_type, index, activity_id) : ActivityHidden); - } - inline void UpdateTaskActivity( - int task_id, - int activity_id, - int count, - bool ignore_quest_update = false - ) - { - if (task_state) { - task_state->UpdateTaskActivity(this, task_id, activity_id, count, ignore_quest_update); - } - } - inline void RemoveTaskByTaskID(uint32 task_id) { - if (task_state) { - task_state->RemoveTaskByTaskID(this, task_id); - } - } - inline void ResetTaskActivity(int task_id, int activity_id) - { - if (task_state) { - task_state->ResetTaskActivity( - this, - task_id, - activity_id - ); - } - } - inline void UpdateTasksOnKill(int npc_type_id) - { - if (task_state) { - task_state->UpdateTasksOnKill( - this, - npc_type_id - ); - } - } - inline void UpdateTasksForItem( - ActivityType activity_type, - int item_id, - int count = 1 - ) - { - if (task_state) { - task_state->UpdateTasksForItem(this, activity_type, item_id, count); - } - } - inline void UpdateTasksOnExplore(int explore_id) - { - if (task_state) { - task_state->UpdateTasksOnExplore( - this, - explore_id - ); - } - } - inline bool UpdateTasksOnSpeakWith(int npc_type_id) - { - if (task_state) { - return task_state->UpdateTasksOnSpeakWith( - this, - npc_type_id - ); - } - else { return false; } - } - inline bool UpdateTasksOnDeliver( - std::list &items, - int cash, - int npc_type_id - ) - { - if (task_state) { - return task_state->UpdateTasksOnDeliver( - this, - items, - cash, - npc_type_id - ); - } - else { return false; } - } - inline void TaskSetSelector(Mob *mob, int task_set_id) - { - if (task_manager) { - task_manager->TaskSetSelector( - this, - task_state, - mob, - task_set_id - ); - } - } - inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks) - { - if (task_manager) { - task_manager->TaskQuestSetSelector( - this, - task_state, - mob, - count, - tasks - ); - } - } - inline void EnableTask(int task_count, int *task_list) - { - if (task_state) { - task_state->EnableTask( - CharacterID(), - task_count, - task_list - ); - } - } - inline void DisableTask(int task_count, int *task_list) - { - if (task_state) { - task_state->DisableTask( - CharacterID(), - task_count, - task_list - ); - } - } - inline bool IsTaskEnabled(int task_id) { - return task_state != nullptr && task_state->IsTaskEnabled(task_id); - } - inline void ProcessTaskProximities(float x, float y, float z) - { - if (task_state) { - task_state->ProcessTaskProximities( - this, - x, - y, - z - ); - } - } - inline void AssignTask( - int task_id, - int npc_id, - bool enforce_level_requirement = false - ) { - if (task_state) { - task_state->AcceptNewTask(this, task_id, npc_id, enforce_level_requirement); - } - } - inline int ActiveSpeakTask(int npc_type_id) - { - if (task_state) { - return task_state->ActiveSpeakTask(npc_type_id); - } - else { - return 0; - } - } - inline int ActiveSpeakActivity(int npc_type_id, int task_id) - { - if (task_state) { - return task_state->ActiveSpeakActivity( - npc_type_id, - task_id - ); - } - else { return 0; } - } - inline void FailTask(int task_id) { if (task_state) { task_state->FailTask(this, task_id); }} - inline int TaskTimeLeft(int task_id) { return (task_state ? task_state->TaskTimeLeft(task_id) : 0); } - inline int EnabledTaskCount(int task_set_id) - { - return (task_state ? task_state->EnabledTaskCount(task_set_id) : -1); - } - inline int IsTaskCompleted(int task_id) { return (task_state ? task_state->IsTaskCompleted(task_id) : -1); } - inline void ShowClientTasks(Client *client) { if (task_state) { task_state->ShowClientTasks(client); }} - inline void CancelAllTasks() { if (task_state) { task_state->CancelAllTasks(this); }} - inline int GetActiveTaskCount() { return (task_state ? task_state->GetActiveTaskCount() : 0); } - inline int GetActiveTaskID(int index) { return (task_state ? task_state->GetActiveTaskID(index) : -1); } - inline int GetTaskStartTime(TaskType task_type, int index) - { - return (task_state ? task_state->GetTaskStartTime( - task_type, - index - ) : -1); - } - inline bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id) - { - return task_state != nullptr && task_state->IsTaskActivityCompleted(task_type, index, activity_id); - } - inline int GetTaskActivityDoneCount(TaskType task_type, int client_task_index, int activity_id) - { - return (task_state ? task_state->GetTaskActivityDoneCount(task_type, client_task_index, activity_id) : 0); - } - inline int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id) - { - return (task_state ? task_state->GetTaskActivityDoneCountFromTaskID(task_id, activity_id) : 0); - } - inline int ActiveTasksInSet(int task_set_id) - { - return (task_state ? task_state->ActiveTasksInSet(task_set_id) : 0); - } - inline int CompletedTasksInSet(int task_set_id) - { - return (task_state ? task_state->CompletedTasksInSet(task_set_id) : 0); - } + void SendTaskActivityComplete(int TaskID, int ActivityID, int TaskIndex, TaskType type, int TaskIncomplete=1); + void SendTaskFailed(int TaskID, int TaskIndex, TaskType type); + void SendTaskComplete(int TaskIndex); + inline ClientTaskState *GetTaskState() const { return taskstate; } + + inline void CancelTask(int TaskIndex, TaskType type) { if(taskstate) taskstate->CancelTask(this, TaskIndex, type); } + inline bool SaveTaskState() { return (taskmanager ? taskmanager->SaveClientState(this, taskstate) : false); } + inline bool IsTaskStateLoaded() { return taskstate != nullptr; } + inline bool IsTaskActive(int TaskID) { return (taskstate ? taskstate->IsTaskActive(TaskID) : false); } + inline bool IsTaskActivityActive(int TaskID, int ActivityID) { return (taskstate ? taskstate->IsTaskActivityActive(TaskID, ActivityID) : false); } + inline ActivityState GetTaskActivityState(TaskType type, int index, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityState(type, index, ActivityID) : ActivityHidden); } + inline void UpdateTaskActivity(int TaskID, int ActivityID, int Count, bool ignore_quest_update = false) { if (taskstate) taskstate->UpdateTaskActivity(this, TaskID, ActivityID, Count, ignore_quest_update); } + inline void RemoveTaskByTaskID(uint32 task_id) { if (taskstate) taskstate->RemoveTaskByTaskID(this, task_id); } + inline void ResetTaskActivity(int TaskID, int ActivityID) { if(taskstate) taskstate->ResetTaskActivity(this, TaskID, ActivityID); } + inline void UpdateTasksOnKill(int NPCTypeID) { if(taskstate) taskstate->UpdateTasksOnKill(this, NPCTypeID); } + inline void UpdateTasksForItem(ActivityType Type, int ItemID, int Count=1) { if(taskstate) taskstate->UpdateTasksForItem(this, Type, ItemID, Count); } + inline void UpdateTasksOnExplore(int ExploreID) { if(taskstate) taskstate->UpdateTasksOnExplore(this, ExploreID); } + inline bool UpdateTasksOnSpeakWith(int NPCTypeID) { if(taskstate) return taskstate->UpdateTasksOnSpeakWith(this, NPCTypeID); else return false; } + inline bool UpdateTasksOnDeliver(std::list& Items, int Cash, int NPCTypeID) { if (taskstate) return taskstate->UpdateTasksOnDeliver(this, Items, Cash, NPCTypeID); else return false; } + inline void TaskSetSelector(Mob *mob, int TaskSetID) { if(taskmanager) taskmanager->TaskSetSelector(this, taskstate, mob, TaskSetID); } + inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks) { if(taskmanager) taskmanager->TaskQuestSetSelector(this, taskstate, mob, count, tasks); } + inline void EnableTask(int TaskCount, int *TaskList) { if(taskstate) taskstate->EnableTask(CharacterID(), TaskCount, TaskList); } + inline void DisableTask(int TaskCount, int *TaskList) { if(taskstate) taskstate->DisableTask(CharacterID(), TaskCount, TaskList); } + inline bool IsTaskEnabled(int TaskID) { return (taskstate ? taskstate->IsTaskEnabled(TaskID) : false); } + inline void ProcessTaskProximities(float X, float Y, float Z) { if(taskstate) taskstate->ProcessTaskProximities(this, X, Y, Z); } + inline void AssignTask(int TaskID, int NPCID, bool enforce_level_requirement = false) { if (taskstate) taskstate->AcceptNewTask(this, TaskID, NPCID, enforce_level_requirement); } + inline int ActiveSpeakTask(int NPCID) { if(taskstate) return taskstate->ActiveSpeakTask(NPCID); else return 0; } + inline int ActiveSpeakActivity(int NPCID, int TaskID) { if(taskstate) return taskstate->ActiveSpeakActivity(NPCID, TaskID); else return 0; } + inline void FailTask(int TaskID) { if(taskstate) taskstate->FailTask(this, TaskID); } + inline int TaskTimeLeft(int TaskID) { return (taskstate ? taskstate->TaskTimeLeft(TaskID) : 0); } + inline int EnabledTaskCount(int TaskSetID) { return (taskstate ? taskstate->EnabledTaskCount(TaskSetID) : -1); } + inline int IsTaskCompleted(int TaskID) { return (taskstate ? taskstate->IsTaskCompleted(TaskID) : -1); } + inline void ShowClientTasks() { if(taskstate) taskstate->ShowClientTasks(this); } + inline void CancelAllTasks() { if(taskstate) taskstate->CancelAllTasks(this); } + inline int GetActiveTaskCount() { return (taskstate ? taskstate->GetActiveTaskCount() : 0); } + inline int GetActiveTaskID(int index) { return (taskstate ? taskstate->GetActiveTaskID(index) : -1); } + inline int GetTaskStartTime(TaskType type, int index) { return (taskstate ? taskstate->GetTaskStartTime(type, index) : -1); } + inline bool IsTaskActivityCompleted(TaskType type, int index, int ActivityID) { return (taskstate ? taskstate->IsTaskActivityCompleted(type, index, ActivityID) : false); } + inline int GetTaskActivityDoneCount(TaskType type, int ClientTaskIndex, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityDoneCount(type, ClientTaskIndex, ActivityID) :0); } + inline int GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityDoneCountFromTaskID(TaskID, ActivityID) :0); } + inline int ActiveTasksInSet(int TaskSet) { return (taskstate ? taskstate->ActiveTasksInSet(TaskSet) :0); } + inline int CompletedTasksInSet(int TaskSet) { return (taskstate ? taskstate->CompletedTasksInSet(TaskSet) :0); } inline const EQ::versions::ClientVersion ClientVersion() const { return m_ClientVersion; } inline const uint32 ClientVersionBit() const { return m_ClientVersionBit; } @@ -1322,49 +1099,6 @@ public: void MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count=1); - // cross zone client messaging helpers (null client argument will fallback to messaging by name) - static void SendCrossZoneMessage( - Client* client, const std::string& client_name, uint16_t chat_type, const std::string& message); - static void SendCrossZoneMessageString( - Client* client, const std::string& client_name, uint16_t chat_type, - uint32_t string_id, const std::initializer_list& arguments = {}); - - void AddExpeditionLockout(const ExpeditionLockoutTimer& lockout, bool update_db = false); - void AddExpeditionLockoutDuration(const std::string& expedition_name, - const std::string& event_Name, int seconds, const std::string& uuid = {}, bool update_db = false); - void AddNewExpeditionLockout(const std::string& expedition_name, - const std::string& event_name, uint32_t duration, std::string uuid = {}); - Expedition* CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request); - Expedition* CreateExpedition( - const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name, - uint32 min_players, uint32 max_players, bool disable_messages = false); - Expedition* GetExpedition() const; - uint32 GetExpeditionID() const { return m_expedition_id; } - const ExpeditionLockoutTimer* GetExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, bool include_expired = false) const; - const std::vector& GetExpeditionLockouts() const { return m_expedition_lockouts; }; - std::vector GetExpeditionLockouts(const std::string& expedition_name, bool include_expired = false); - uint32 GetPendingExpeditionInviteID() const { return m_pending_expedition_invite.expedition_id; } - bool HasExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool include_expired = false); - bool IsInExpedition() const { return m_expedition_id != 0; } - void RemoveAllExpeditionLockouts(const std::string& expedition_name, bool update_db = false); - void RemoveExpeditionLockout(const std::string& expedition_name, - const std::string& event_name, bool update_db = false); - void RequestPendingExpeditionInvite(); - void SendExpeditionLockoutTimers(); - void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; }; - void SetPendingExpeditionInvite(ExpeditionInvite&& invite) { m_pending_expedition_invite = invite; } - void UpdateExpeditionInfoAndLockouts(); - void DzListTimers(); - void SetDzRemovalTimer(bool enable_timer); - void SendDzCompassUpdate(); - void GoToDzSafeReturnOrBind(const DynamicZone* dynamic_zone); - void MovePCDynamicZone(uint32 zone_id, int zone_version = -1, bool msg_if_invalid = true); - void MovePCDynamicZone(const std::string& zone_name, int zone_version = -1, bool msg_if_invalid = true); - std::vector GetDynamicZones(uint32_t zone_id = 0, int zone_version = -1); - std::unique_ptr CreateDzSwitchListPacket(const std::vector& dzs); - std::unique_ptr CreateCompassPacket(const std::vector& entries); - void CalcItemScale(); bool CalcItemScale(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1 void DoItemEnterZone(); @@ -1583,8 +1317,6 @@ public: Raid *p_raid_instance; - void ShowDevToolsMenu(); - protected: friend class Mob; void CalcItemBonuses(StatBonuses* newbon); @@ -1738,7 +1470,7 @@ private: uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004 bool display_mob_info_window; - bool dev_tools_enabled; + bool dev_tools_window_enabled; int32 max_end; int32 current_endurance; @@ -1771,7 +1503,7 @@ private: void ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm); void ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited); - glm::vec4 m_ZoneSummonLocation; + glm::vec3 m_ZoneSummonLocation; uint16 zonesummon_id; uint8 zonesummon_ignorerestrictions; ZoneMode zone_mode; @@ -1818,7 +1550,6 @@ private: Timer hp_other_update_throttle_timer; /* This is to keep clients from DOSing the server with macros that change client targets constantly */ Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */ Timer consent_throttle_timer; - Timer dynamiczone_removal_timer; glm::vec3 m_Proximity; glm::vec4 last_position_before_bulk_update; @@ -1850,7 +1581,7 @@ private: std::set zone_flags; - ClientTaskState *task_state; + ClientTaskState *taskstate; int TotalSecondsPlayed; //Anti Spam Stuff @@ -1920,12 +1651,6 @@ private: int client_max_level; - uint32 m_expedition_id = 0; - ExpeditionInvite m_pending_expedition_invite { 0 }; - std::vector m_expedition_lockouts; - glm::vec3 m_quest_compass; - bool m_has_quest_compass = false; - #ifdef BOTS public: diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 0a67550f6..b88105aaf 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -49,8 +49,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../common/zone_numbers.h" #include "data_bucket.h" #include "event_codes.h" -#include "expedition.h" -#include "expedition_database.h" #include "guild_mgr.h" #include "merc.h" #include "petitions.h" @@ -193,15 +191,6 @@ void MapOpcodes() ConnectedOpcodes[OP_DuelResponse2] = &Client::Handle_OP_DuelResponse2; ConnectedOpcodes[OP_DumpName] = &Client::Handle_OP_DumpName; ConnectedOpcodes[OP_Dye] = &Client::Handle_OP_Dye; - ConnectedOpcodes[OP_DzAddPlayer] = &Client::Handle_OP_DzAddPlayer; - ConnectedOpcodes[OP_DzChooseZoneReply] = &Client::Handle_OP_DzChooseZoneReply; - ConnectedOpcodes[OP_DzExpeditionInviteResponse] = &Client::Handle_OP_DzExpeditionInviteResponse; - ConnectedOpcodes[OP_DzListTimers] = &Client::Handle_OP_DzListTimers; - ConnectedOpcodes[OP_DzMakeLeader] = &Client::Handle_OP_DzMakeLeader; - ConnectedOpcodes[OP_DzPlayerList] = &Client::Handle_OP_DzPlayerList; - ConnectedOpcodes[OP_DzRemovePlayer] = &Client::Handle_OP_DzRemovePlayer; - ConnectedOpcodes[OP_DzSwapPlayer] = &Client::Handle_OP_DzSwapPlayer; - ConnectedOpcodes[OP_DzQuit] = &Client::Handle_OP_DzQuit; ConnectedOpcodes[OP_Emote] = &Client::Handle_OP_Emote; ConnectedOpcodes[OP_EndLootRequest] = &Client::Handle_OP_EndLootRequest; ConnectedOpcodes[OP_EnvDamage] = &Client::Handle_OP_EnvDamage; @@ -277,7 +266,6 @@ void MapOpcodes() ConnectedOpcodes[OP_ItemViewUnknown] = &Client::Handle_OP_Ignore; ConnectedOpcodes[OP_Jump] = &Client::Handle_OP_Jump; ConnectedOpcodes[OP_KeyRing] = &Client::Handle_OP_KeyRing; - ConnectedOpcodes[OP_KickPlayers] = &Client::Handle_OP_KickPlayers; ConnectedOpcodes[OP_LDoNButton] = &Client::Handle_OP_LDoNButton; ConnectedOpcodes[OP_LDoNDisarmTraps] = &Client::Handle_OP_LDoNDisarmTraps; ConnectedOpcodes[OP_LDoNInspect] = &Client::Handle_OP_LDoNInspect; @@ -561,9 +549,8 @@ void Client::CompleteConnect() entity_list.AddRaid(raid, raidid); raid->LoadLeadership(); // Recreating raid in new zone, get leadership from DB } - else { - safe_delete(raid); - } + else + raid = nullptr; } if (raid) { SetRaidGrouped(true); @@ -898,8 +885,6 @@ void Client::CompleteConnect() guild_mgr.RequestOnlineGuildMembers(this->CharacterID(), this->GuildID()); } - UpdateExpeditionInfoAndLockouts(); - /** Request adventure info **/ auto pack = new ServerPacket(ServerOP_AdventureDataRequest, 64); strcpy((char*)pack->pBuffer, GetName()); @@ -919,8 +904,7 @@ void Client::CompleteConnect() SetPetCommandState(PET_BUTTON_REGROUP, 0); SetPetCommandState(PET_BUTTON_FOLLOW, 1); SetPetCommandState(PET_BUTTON_GUARD, 0); - // Taunt saved on client side for logging on with pet - // In our db for when we zone. + SetPetCommandState(PET_BUTTON_TAUNT, 1); SetPetCommandState(PET_BUTTON_HOLD, 0); SetPetCommandState(PET_BUTTON_GHOLD, 0); SetPetCommandState(PET_BUTTON_FOCUS, 0); @@ -934,11 +918,6 @@ void Client::CompleteConnect() worldserver.RequestTellQueue(GetName()); entity_list.ScanCloseMobs(close_mobs, this, true); - - if (GetGM() && IsDevToolsEnabled()) { - ShowDevToolsMenu(); - } - } // connecting opcode handlers @@ -1332,11 +1311,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) strcpy(lastname, m_pp.last_name); /* If PP is set to weird coordinates */ if ((m_pp.x == -1 && m_pp.y == -1 && m_pp.z == -1) || (m_pp.x == -2 && m_pp.y == -2 && m_pp.z == -2)) { - auto zone_safe_point = zone->GetSafePoint(); - m_pp.x = zone_safe_point.x; - m_pp.y = zone_safe_point.y; - m_pp.z = zone_safe_point.z; - m_pp.heading = zone_safe_point.w; + auto safePoint = zone->GetSafePoint(); + m_pp.x = safePoint.x; + m_pp.y = safePoint.y; + m_pp.z = safePoint.z; } /* If too far below ground, then fix */ // float ground_z = GetGroundZ(m_pp.x, m_pp.y, m_pp.z); @@ -1533,7 +1511,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) int mentor_percent; GroupLeadershipAA_Struct GLAA; memset(ln, 0, 64); - database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA); + strcpy(ln, database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA)); Client *c = entity_list.GetClientByName(ln); if (c) group->SetLeader(c); @@ -1648,13 +1626,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) pet->CalcBonuses(); pet->SetHP(m_petinfo.HP); pet->SetMana(m_petinfo.Mana); - - // Taunt persists when zoning on newer clients, overwrite default. - if (m_ClientVersionBit & EQ::versions::maskUFAndLater) { - if (!firstlogon) { - pet->SetTaunting(m_petinfo.taunting); - } - } } m_petinfo.SpellID = 0; } @@ -1717,15 +1688,13 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) /* Task Packets */ LoadClientTaskState(); - m_expedition_id = ExpeditionDatabase::GetExpeditionIDFromCharacterID(CharacterID()); - /** * DevTools Load Settings */ if (Admin() >= EQ::DevTools::GM_ACCOUNT_STATUS_LEVEL) { - std::string dev_tools_window_key = StringFormat("%i-dev-tools-disabled", AccountID()); + std::string dev_tools_window_key = StringFormat("%i-dev-tools-window-disabled", AccountID()); if (DataBucket::GetData(dev_tools_window_key) == "true") { - dev_tools_enabled = false; + dev_tools_window_enabled = false; } } @@ -1823,8 +1792,8 @@ void Client::Handle_OP_AcceptNewTask(const EQApplicationPacket *app) } AcceptNewTask_Struct *ant = (AcceptNewTask_Struct*)app->pBuffer; - if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state) - task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id); + if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && taskstate) + taskstate->AcceptNewTask(this, ant->task_id, ant->task_master_id); } void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app) @@ -2043,10 +2012,12 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) else if (aps->Type == NorrathsKeepersMerchant) { SetRadiantCrystals(GetRadiantCrystals() - (int32)item->LDoNPrice); + SendCrystalCounts(); } else if (aps->Type == DarkReignMerchant) { SetEbonCrystals(GetEbonCrystals() - (int32)item->LDoNPrice); + SendCrystalCounts(); } int16 charges = 1; if (item->MaxCharges != 0) @@ -3384,10 +3355,11 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app) if (!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = fmt::format( - "Player tried to make use of a banker(money) but {} is non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(money) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } @@ -4005,8 +3977,8 @@ void Client::Handle_OP_CancelTask(const EQApplicationPacket *app) } CancelTask_Struct *cts = (CancelTask_Struct*)app->pBuffer; - if (RuleB(TaskSystem, EnableTaskSystem) && task_state) - task_state->CancelTask(this, cts->SequenceNumber, static_cast(cts->type)); + if (RuleB(TaskSystem, EnableTaskSystem) && taskstate) + taskstate->CancelTask(this, cts->SequenceNumber, static_cast(cts->type)); } void Client::Handle_OP_CancelTrade(const EQApplicationPacket *app) @@ -4412,27 +4384,27 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { PlayerPositionUpdateClient_Struct *ppu = (PlayerPositionUpdateClient_Struct *) app->pBuffer; - /* Non PC handling like boats and eye of zomm */ - if (ppu->spawn_id && ppu->spawn_id != GetID()) { - Mob *cmob = entity_list.GetMob(ppu->spawn_id); + /* Boat handling */ + if (ppu->spawn_id != GetID()) { + /* If player is controlling boat */ + if (ppu->spawn_id && ppu->spawn_id == controlling_boat_id) { + Mob *boat = entity_list.GetMob(controlling_boat_id); + if (boat == 0) { + controlling_boat_id = 0; + return; + } - if (!cmob) { - return; - } - - if (cmob->IsControllableBoat()) { - // Controllable boats auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading)); - cmob->SetDelta(boat_delta); + boat->SetDelta(boat_delta); auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct *ppus = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer; - cmob->MakeSpawnUpdate(ppus); - entity_list.QueueCloseClients(cmob, outapp, true, 300, this, false); + boat->MakeSpawnUpdate(ppus); + entity_list.QueueCloseClients(boat, outapp, true, 300, this, false); safe_delete(outapp); /* Update the boat's position on the server, without sending an update */ - cmob->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading), false); + boat->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading), false); return; } else { @@ -4440,13 +4412,16 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { // so that other clients see it. I could add a check here for eye of zomm // race, to limit this code, but this should handle any client controlled // mob that gets updates from OP_ClientUpdate - if (!cmob->IsControllableBoat() && ppu->spawn_id == controlled_mob_id) { - cmob->SetPosition(ppu->x_pos, ppu->y_pos, ppu->z_pos); - cmob->SetHeading(EQ12toFloat(ppu->heading)); - mMovementManager->SendCommandToClients(cmob, 0.0, 0.0, 0.0, - 0.0, 0, ClientRangeAny, nullptr, this); - cmob->CastToNPC()->SaveGuardSpot(glm::vec4(ppu->x_pos, - ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading))); + if (ppu->spawn_id == controlled_mob_id) { + Mob *cmob = entity_list.GetMob(ppu->spawn_id); + if (cmob != nullptr) { + cmob->SetPosition(ppu->x_pos, ppu->y_pos, ppu->z_pos); + cmob->SetHeading(EQ12toFloat(ppu->heading)); + mMovementManager->SendCommandToClients(cmob, 0.0, 0.0, 0.0, + 0.0, 0, ClientRangeAny, nullptr, this); + cmob->CastToNPC()->SaveGuardSpot(glm::vec4(ppu->x_pos, + ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading))); + } } } return; @@ -4474,25 +4449,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { LogError("Can't find boat for client position offset."); } else { - if (boat->turning) return; - - // Calculate angle from boat heading to EQ heading - double theta = std::fmod(((boat->GetHeading() * 360.0) / 512.0),360.0); - double thetar = (theta * M_PI) / 180.0; - - // Boat cx is inverted (positive to left) - // Boat cy is normal (positive toward heading) - double cosine = std::cos(thetar); - double sine = std::sin(thetar); - - double normalizedx, normalizedy; - normalizedx = cx * cosine - -cy * sine; - normalizedy = -cx * sine + cy * cosine; - - cx = boat->GetX() + normalizedx; - cy = boat->GetY() + normalizedy; + cx += boat->GetX(); + cy += boat->GetY(); cz += boat->GetZ(); - new_heading += boat->GetHeading(); } } @@ -4561,63 +4520,23 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { rewind_timer.Start(30000, true); } - - is_client_moving = !(cy == m_Position.y && cx == m_Position.x); - - - /** - * Client aggro scanning - */ - const uint16 client_scan_npc_aggro_timer_idle = RuleI(Aggro, ClientAggroCheckIdleInterval); - const uint16 client_scan_npc_aggro_timer_moving = RuleI(Aggro, ClientAggroCheckMovingInterval); - - LogAggroDetail( - "ClientUpdate [{}] {}moving, scan timer [{}]", - GetCleanName(), - is_client_moving ? "" : "NOT ", - client_scan_npc_aggro_timer.GetRemainingTime() - ); + /* Handle client aggro scanning timers NPCs */ + is_client_moving = (cy == m_Position.y && cx == m_Position.x) ? false : true; if (is_client_moving) { - if (client_scan_npc_aggro_timer.GetRemainingTime() > client_scan_npc_aggro_timer_moving) { - LogAggroDetail("Client [{}] Restarting with moving timer", GetCleanName()); + LogDebug("ClientUpdate: Client is moving - scan timer is: [{}]", client_scan_npc_aggro_timer.GetDuration()); + if (client_scan_npc_aggro_timer.GetDuration() > 1000) { client_scan_npc_aggro_timer.Disable(); - client_scan_npc_aggro_timer.Start(client_scan_npc_aggro_timer_moving); - client_scan_npc_aggro_timer.Trigger(); + client_scan_npc_aggro_timer.Start(500); } } - else if (client_scan_npc_aggro_timer.GetDuration() == client_scan_npc_aggro_timer_moving) { - LogAggroDetail("Client [{}] Restarting with idle timer", GetCleanName()); - client_scan_npc_aggro_timer.Disable(); - client_scan_npc_aggro_timer.Start(client_scan_npc_aggro_timer_idle); - } - - /** - * Client mob close list cache scan timer - */ - const uint16 client_mob_close_scan_timer_moving = 6000; - const uint16 client_mob_close_scan_timer_idle = 60000; - - LogAIScanCloseDetail( - "Client [{}] {}moving, scan timer [{}]", - GetCleanName(), - is_client_moving ? "" : "NOT ", - mob_close_scan_timer.GetRemainingTime() - ); - - if (is_client_moving) { - if (mob_close_scan_timer.GetRemainingTime() > client_mob_close_scan_timer_moving) { - LogAIScanCloseDetail("Client [{}] Restarting with moving timer", GetCleanName()); - mob_close_scan_timer.Disable(); - mob_close_scan_timer.Start(client_mob_close_scan_timer_moving); - mob_close_scan_timer.Trigger(); + else { + LogDebug("ClientUpdate: Client is NOT moving - scan timer is: [{}]", client_scan_npc_aggro_timer.GetDuration()); + if (client_scan_npc_aggro_timer.GetDuration() < 1000) { + client_scan_npc_aggro_timer.Disable(); + client_scan_npc_aggro_timer.Start(3000); } } - else if (mob_close_scan_timer.GetDuration() == client_mob_close_scan_timer_moving) { - LogAIScanCloseDetail("Client [{}] Restarting with idle timer", GetCleanName()); - mob_close_scan_timer.Disable(); - mob_close_scan_timer.Start(client_mob_close_scan_timer_idle); - } /** * On a normal basis we limit mob movement updates based on distance @@ -4721,9 +4640,6 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { } CheckRegionTypeChanges(); } - - CheckVirtualZoneLines(); - } void Client::Handle_OP_CombatAbility(const EQApplicationPacket *app) @@ -5031,8 +4947,10 @@ void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app) if (!boat->IsNPC() || !boat->IsControllableBoat()) { - auto hacked_string = fmt::format("OP_Control Boat was sent against {} which is of race {}", boat->GetName(), boat->GetRace()); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "OP_Control Boat was sent against %s which is of race %u", boat->GetName(), boat->GetRace()); database.SetMQDetectionFlag(this->AccountName(), this->GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } @@ -5352,8 +5270,10 @@ void Client::Handle_OP_Disarm(const EQApplicationPacket *app) { return; if (pmob->GetID() != GetID()) { // Client sent a disarm request with an originator ID not matching their own ID. - auto hack_str = fmt::format("Player {} ({}) sent OP_Disarm with source ID of: {}", GetCleanName(), GetID(), pmob->GetID()); + char *hack_str = NULL; + MakeAnyLenString(&hack_str, "Player %s (%d) sent OP_Disarm with source ID of: %d", GetCleanName(), GetID(), pmob->GetID()); database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName()); + safe_delete_array(hack_str); return; } // No disarm on corpses @@ -5630,112 +5550,6 @@ void Client::Handle_OP_Dye(const EQApplicationPacket *app) return; } -void Client::Handle_OP_DzAddPlayer(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) - { - auto dzcmd = reinterpret_cast(app->pBuffer); - expedition->DzAddPlayer(this, dzcmd->name); - } - else - { - // the only /dz command that sends an error message if no active expedition - Message(Chat::System, DZ_YOU_NOT_ASSIGNED); - } -} - -void Client::Handle_OP_DzChooseZoneReply(const EQApplicationPacket *app) -{ - auto dzmsg = reinterpret_cast(app->pBuffer); - - LogDynamicZones("Character [{}] chose DynamicZone [{}]:[{}] type: [{}] with system id: [{}]", - CharacterID(), dzmsg->dz_zone_id, dzmsg->dz_instance_id, dzmsg->dz_type, dzmsg->unknown_id2); - - if (!dzmsg->dz_instance_id || !database.VerifyInstanceAlive(dzmsg->dz_instance_id, CharacterID())) - { - // live just no-ops this without a message - LogDynamicZones("Character [{}] chose invalid DynamicZone [{}]:[{}] or is no longer a member", - CharacterID(), dzmsg->dz_zone_id, dzmsg->dz_instance_id); - return; - } - - auto client_dzs = GetDynamicZones(); - auto it = std::find_if(client_dzs.begin(), client_dzs.end(), [&](const DynamicZone* dz) { - return dz->IsSameDz(dzmsg->dz_zone_id, dzmsg->dz_instance_id); }); - - if (it != client_dzs.end()) - { - DynamicZoneLocation loc = (*it)->GetZoneInLocation(); - ZoneMode zone_mode = (*it)->HasZoneInLocation() ? ZoneMode::ZoneSolicited : ZoneMode::ZoneToSafeCoords; - MovePC(dzmsg->dz_zone_id, dzmsg->dz_instance_id, loc.x, loc.y, loc.z, loc.heading, 0, zone_mode); - } -} - -void Client::Handle_OP_DzExpeditionInviteResponse(const EQApplicationPacket *app) -{ - auto expedition = Expedition::FindCachedExpeditionByID(m_pending_expedition_invite.expedition_id); - std::string swap_remove_name = m_pending_expedition_invite.swap_remove_name; - m_pending_expedition_invite = { 0 }; // clear before re-validating - - if (expedition) - { - auto dzmsg = reinterpret_cast(app->pBuffer); - expedition->DzInviteResponse(this, dzmsg->accepted, swap_remove_name); - } -} - -void Client::Handle_OP_DzListTimers(const EQApplicationPacket *app) -{ - DzListTimers(); -} - -void Client::Handle_OP_DzMakeLeader(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) - { - auto dzcmd = reinterpret_cast(app->pBuffer); - expedition->DzMakeLeader(this, dzcmd->name); - } -} - -void Client::Handle_OP_DzPlayerList(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) { - expedition->DzPlayerList(this); - } -} - -void Client::Handle_OP_DzRemovePlayer(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) - { - auto dzcmd = reinterpret_cast(app->pBuffer); - expedition->DzRemovePlayer(this, dzcmd->name); - } -} - -void Client::Handle_OP_DzSwapPlayer(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) - { - auto dzcmd = reinterpret_cast(app->pBuffer); - expedition->DzSwapPlayer(this, dzcmd->rem_player_name, dzcmd->add_player_name); - } -} - -void Client::Handle_OP_DzQuit(const EQApplicationPacket *app) -{ - auto expedition = GetExpedition(); - if (expedition) { - expedition->DzQuit(this); - } -} - void Client::Handle_OP_Emote(const EQApplicationPacket *app) { if (app->size != sizeof(Emote_Struct)) { @@ -6597,45 +6411,34 @@ void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app) } GMZoneRequest_Struct* gmzr = (GMZoneRequest_Struct*)app->pBuffer; - float target_x = -1, target_y = -1, target_z = -1, target_heading; + float tarx = -1, tary = -1, tarz = -1; - int16 min_status = 0; - uint8 min_level = 0; - char target_zone[32]; - uint16 zone_id = gmzr->zone_id; + int16 minstatus = 0; + uint8 minlevel = 0; + char tarzone[32]; + uint16 zid = gmzr->zone_id; if (gmzr->zone_id == 0) - zone_id = zonesummon_id; - - const char* zone_short_name = ZoneName(zone_id); - if (zone_short_name == nullptr) - target_zone[0] = 0; + zid = zonesummon_id; + const char * zname = ZoneName(zid); + if (zname == nullptr) + tarzone[0] = 0; else - strcpy(target_zone, zone_short_name); + strcpy(tarzone, zname); // this both loads the safe points and does a sanity check on zone name - if (!content_db.GetSafePoints( - target_zone, - 0, - &target_x, - &target_y, - &target_z, - &target_heading, - &min_status, - &min_level - )) { - target_zone[0] = 0; + if (!content_db.GetSafePoints(tarzone, 0, &tarx, &tary, &tarz, &minstatus, &minlevel)) { + tarzone[0] = 0; } auto outapp = new EQApplicationPacket(OP_GMZoneRequest, sizeof(GMZoneRequest_Struct)); GMZoneRequest_Struct* gmzr2 = (GMZoneRequest_Struct*)outapp->pBuffer; strcpy(gmzr2->charname, this->GetName()); gmzr2->zone_id = gmzr->zone_id; - gmzr2->x = target_x; - gmzr2->y = target_y; - gmzr2->z = target_z; - gmzr2->heading = target_heading; + gmzr2->x = tarx; + gmzr2->y = tary; + gmzr2->z = tarz; // Next line stolen from ZoneChange as well... - This gives us a nicer message than the normal "zone is down" message... - if (target_zone[0] != 0 && admin >= min_status && GetLevel() >= min_level) + if (tarzone[0] != 0 && admin >= minstatus && GetLevel() >= minlevel) gmzr2->success = 1; else { std::cout << "GetZoneSafeCoords failed. zoneid = " << gmzr->zone_id << "; czone = " << zone->GetZoneID() << std::endl; @@ -9017,23 +8820,6 @@ void Client::Handle_OP_KeyRing(const EQApplicationPacket *app) KeyRingList(); } -void Client::Handle_OP_KickPlayers(const EQApplicationPacket *app) -{ - auto buf = reinterpret_cast(app->pBuffer); - if (buf->kick_expedition) - { - auto expedition = GetExpedition(); - if (expedition) - { - expedition->DzKickPlayers(this); - } - } - else if (buf->kick_task) - { - // todo: shared tasks - } -} - void Client::Handle_OP_LDoNButton(const EQApplicationPacket *app) { if (app->size < sizeof(bool)) @@ -9215,7 +9001,7 @@ void Client::Handle_OP_LFGCommand(const EQApplicationPacket *app) LFGFromLevel = lfg->FromLevel; LFGToLevel = lfg->ToLevel; LFGMatchFilter = lfg->MatchFilter; - strn0cpy(LFGComments, lfg->Comments, sizeof(LFGComments)); + strcpy(LFGComments, lfg->Comments); break; default: Message(0, "Error: unknown LFG value %i", lfg->value); @@ -10047,15 +9833,17 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) { if (mi->from_slot != mi->to_slot && (mi->from_slot <= EQ::invslot::GENERAL_END || mi->from_slot > 39) && IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot)) { + char *detect = nullptr; const EQ::ItemInstance *itm_from = GetInv().GetItem(mi->from_slot); const EQ::ItemInstance *itm_to = GetInv().GetItem(mi->to_slot); - auto detect = fmt::format("Player issued a move item from {}(item id {}) to {}(item id {}) while casting {}.", + MakeAnyLenString(&detect, "Player issued a move item from %u(item id %u) to %u(item id %u) while casting %u.", mi->from_slot, itm_from ? itm_from->GetID() : 0, mi->to_slot, itm_to ? itm_to->GetID() : 0, casting_spell_id); database.SetMQDetectionFlag(AccountName(), GetName(), detect, zone->GetShortName()); + safe_delete_array(detect); Kick("Inventory desync"); // Kick client to prevent client and server from getting out-of-sync inventory slots return; } @@ -10273,11 +10061,6 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetRegroup(false); SetPetCommandState(PET_BUTTON_REGROUP, 0); } - - // fix GUI sit button to be unpressed and stop sitting regen - SetPetCommandState(PET_BUTTON_SIT, 0); - mypet->SetAppearance(eaStanding); - zone->AddAggroMob(); // classic acts like qattack int hate = 1; @@ -10319,11 +10102,6 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetRegroup(false); SetPetCommandState(PET_BUTTON_REGROUP, 0); } - - // fix GUI sit button to be unpressed and stop sitting regen - SetPetCommandState(PET_BUTTON_SIT, 0); - mypet->SetAppearance(eaStanding); - zone->AddAggroMob(); mypet->AddToHateList(GetTarget(), 1, 0, true, false, false, SPELL_UNKNOWN, true); MessageString(Chat::PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName()); @@ -10384,11 +10162,6 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { if (mypet->IsNPC()) { - - // Set Sit button to unpressed - send stand anim/end hpregen - SetPetCommandState(PET_BUTTON_SIT, 0); - mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); - mypet->SayString(this, Chat::PetResponse, PET_GUARDINGLIFE); mypet->SetPetOrder(SPO_Guard); mypet->CastToNPC()->SaveGuardSpot(mypet->GetPosition()); @@ -10408,11 +10181,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_FOLLOWING); mypet->SetPetOrder(SPO_Follow); - - // fix GUI sit button to be unpressed - send stand anim/end hpregen - SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); - if (mypet->IsPetStop()) { mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); @@ -10455,11 +10224,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_GUARDME_STRING); mypet->SetPetOrder(SPO_Follow); - - // Set Sit button to unpressed - send stand anim/end hpregen - SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); - if (mypet->IsPetStop()) { mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); @@ -10494,7 +10259,6 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING); - SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SetPetOrder(SPO_Follow); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); } @@ -10505,7 +10269,6 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING); - SetPetCommandState(PET_BUTTON_SIT, 1); mypet->SetPetOrder(SPO_Sit); mypet->SetRunAnimSpeed(0); if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet @@ -11068,8 +10831,8 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) break; case EQ::popupresponse::MOB_INFO_DISMISS: - SetDisplayMobInfoWindow(false); - Message(Chat::Yellow, "[DevTools] Window snoozed in this zone..."); + this->SetDisplayMobInfoWindow(false); + this->Message(Chat::Yellow, "[DevTools] Window snoozed in this zone..."); break; default: break; @@ -12677,8 +12440,8 @@ void Client::Handle_OP_SetServerFilter(const EQApplicationPacket *app) void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) { // if the character has a start city, don't let them use the command - if (m_pp.binds[4].zone_id != 0 && m_pp.binds[4].zone_id != 189) { - Message(Chat::Yellow, "Your home city has already been set.", m_pp.binds[4].zone_id, ZoneName(m_pp.binds[4].zone_id)); + if (m_pp.binds[4].zoneId != 0 && m_pp.binds[4].zoneId != 189) { + Message(Chat::Yellow, "Your home city has already been set.", m_pp.binds[4].zoneId, ZoneName(m_pp.binds[4].zoneId)); return; } @@ -12688,22 +12451,13 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) return; } - float x = 0.0f, y = 0.0f, z = 0.0f, heading = 0.0f; - uint32 zone_id = 0; - uint32 start_city = (uint32)strtol((const char*)app->pBuffer, nullptr, 10); - std::string query = fmt::format( - SQL( - SELECT - `zone_id`, `bind_id`, `x`, `y`, `z`, `heading` - FROM - `start_zones` - WHERE - player_class = {} - AND - player_deity = {} - AND - player_race = {} {} - ), + float x(0), y(0), z(0); + uint32 zoneid = 0; + uint32 startCity = (uint32)strtol((const char*)app->pBuffer, nullptr, 10); + + std::string query = StringFormat( + "SELECT zone_id, bind_id, x, y, z FROM start_zones " + "WHERE player_class=%i AND player_deity=%i AND player_race=%i %s", m_pp.class_, m_pp.deity, m_pp.race, @@ -12715,46 +12469,31 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) return; } - bool valid_city = false; + bool validCity = false; for (auto row = results.begin(); row != results.end(); ++row) { if (atoi(row[1]) != 0) - zone_id = atoi(row[1]); + zoneid = atoi(row[1]); else - zone_id = atoi(row[0]); + zoneid = atoi(row[0]); - if (zone_id != start_city) + if (zoneid != startCity) continue; - valid_city = true; + validCity = true; x = atof(row[2]); y = atof(row[3]); z = atof(row[4]); - heading = atof(row[5]); } - if (valid_city) { + if (validCity) { Message(Chat::Yellow, "Your home city has been set"); - SetStartZone(start_city, x, y, z, heading); + SetStartZone(startCity, x, y, z); return; } - query = fmt::format( - SQL( - SELECT - `zone_id`, `bind_id` - FROM - `start_zones` - WHERE - player_class = {} - AND - player_deity = {} - AND - player_race = {} - ), - m_pp.class_, - m_pp.deity, - m_pp.race - ); + query = StringFormat("SELECT zone_id, bind_id FROM start_zones " + "WHERE player_class=%i AND player_deity=%i AND player_race=%i", + m_pp.class_, m_pp.deity, m_pp.race); results = content_db.QueryDatabase(query); if (!results.Success()) return; @@ -12763,12 +12502,13 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) for (auto row = results.begin(); row != results.end(); ++row) { if (atoi(row[1]) != 0) - zone_id = atoi(row[1]); + zoneid = atoi(row[1]); else - zone_id = atoi(row[0]); + zoneid = atoi(row[0]); - std::string zone_long_name = zone_store.GetZoneLongName(zone_id); - Message(Chat::Yellow, "%d - %s", zone_id, zone_long_name.c_str()); + char* name = nullptr; + content_db.GetZoneLongName(ZoneName(zoneid), &name); + Message(Chat::Yellow, "%d - %s", zoneid, name); } } @@ -13020,10 +12760,12 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) if (!TakeMoneyFromPP(mpo->price)) { - auto hacker_str = fmt::format("Vendor Cheat: attempted to buy {} of {}: {} that cost {} cp but only has {} pp {} gp {} sp {} cp", + char *hacker_str = nullptr; + MakeAnyLenString(&hacker_str, "Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n", mpo->quantity, item->ID, item->Name, mpo->price, m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper); database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName()); + safe_delete_array(hacker_str); safe_delete(outapp); safe_delete(inst); return; @@ -13505,8 +13247,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) { if (ClientVersion() < EQ::versions::ClientVersion::SoF) { - auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Invis: {}", sa->parameter); + char *hack_str = nullptr; + MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Invis: %i", sa->parameter); database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName()); + safe_delete_array(hack_str); } } return; @@ -13605,8 +13349,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) { if (!HasSkill(EQ::skills::SkillSneak)) { - auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Sneak: {}", sa->parameter); + char *hack_str = nullptr; + MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Sneak: %i", sa->parameter); database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName()); + safe_delete_array(hack_str); } return; } @@ -13615,8 +13361,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else if (sa->type == AT_Size) { - auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Size: {}", sa->parameter); + char *hack_str = nullptr; + MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Size: %i", sa->parameter); database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName()); + safe_delete_array(hack_str); } else if (sa->type == AT_Light) // client emitting light (lightstone, shiny shield) { @@ -13956,9 +13704,11 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) else if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special || GetTarget()->GetBodyType() == BT_NoTarget) { - auto hacker_str = fmt::format("{} attempting to target something untargetable, {} bodytype: {}", + char *hacker_str = nullptr; + MakeAnyLenString(&hacker_str, "%s attempting to target something untargetable, %s bodytype: %i\n", GetName(), GetTarget()->GetName(), (int)GetTarget()->GetBodyType()); database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName()); + safe_delete_array(hacker_str); SetTarget((Mob*)nullptr); return; } @@ -13978,15 +13728,13 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) { if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { - auto hacker_str = fmt::format( - "{} attempting to target something beyond the clip plane of {:.2f} " - "units, from ({:.2f}, {:.2f}, {:.2f}) to {} ({:.2f}, {:.2f}, " - "{:.2f})", - GetName(), - (zone->newzone_data.maxclip * zone->newzone_data.maxclip), GetX(), - GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), - GetTarget()->GetY(), GetTarget()->GetZ()); + char *hacker_str = nullptr; + MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units," + " from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(), + (zone->newzone_data.maxclip*zone->newzone_data.maxclip), + GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ()); database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName()); + safe_delete_array(hacker_str); SetTarget(nullptr); return; } @@ -13994,13 +13742,13 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } else if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { - auto hacker_str = - fmt::format("{} attempting to target something beyond the clip plane of {:.2f} " - "units, from ({:.2f}, {:.2f}, {:.2f}) to {} ({:.2f}, {:.2f}, {:.2f})", - GetName(), (zone->newzone_data.maxclip * zone->newzone_data.maxclip), - GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), - GetTarget()->GetY(), GetTarget()->GetZ()); + char *hacker_str = nullptr; + MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units," + " from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(), + (zone->newzone_data.maxclip*zone->newzone_data.maxclip), + GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ()); database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName()); + safe_delete_array(hacker_str); SetTarget(nullptr); return; } @@ -14026,8 +13774,8 @@ void Client::Handle_OP_TaskHistoryRequest(const EQApplicationPacket *app) } TaskHistoryRequest_Struct *ths = (TaskHistoryRequest_Struct*)app->pBuffer; - if (RuleB(TaskSystem, EnableTaskSystem) && task_state) - task_state->SendTaskHistory(this, ths->TaskIndex); + if (RuleB(TaskSystem, EnableTaskSystem) && taskstate) + taskstate->SendTaskHistory(this, ths->TaskIndex); } void Client::Handle_OP_Taunt(const EQApplicationPacket *app) @@ -14490,19 +14238,12 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) // Client requesting a trade session from an npc/client // Trade session not started until OP_TradeRequestAck is sent - TradeRequest_Struct* msg = (TradeRequest_Struct*)app->pBuffer; - Mob* tradee = entity_list.GetMob(msg->to_mob_id); - - // If the tradee is an untargettable mob - ignore - // Helps in cases where servers use invisible_man, body type 11 for quests - // and the client opens a trade by mistake. - if (tradee && (tradee->GetBodyType() == 11)) { - return; - } - CommonBreakInvisible(); // Pass trade request on to recipient + TradeRequest_Struct* msg = (TradeRequest_Struct*)app->pBuffer; + Mob* tradee = entity_list.GetMob(msg->to_mob_id); + if (tradee && tradee->IsClient()) { tradee->CastToClient()->QueuePacket(app); } diff --git a/zone/client_packet.h b/zone/client_packet.h index 3951a1761..9605dc8cf 100644 --- a/zone/client_packet.h +++ b/zone/client_packet.h @@ -101,15 +101,6 @@ void Handle_OP_DuelResponse2(const EQApplicationPacket *app); void Handle_OP_DumpName(const EQApplicationPacket *app); void Handle_OP_Dye(const EQApplicationPacket *app); - void Handle_OP_DzAddPlayer(const EQApplicationPacket *app); - void Handle_OP_DzChooseZoneReply(const EQApplicationPacket *app); - void Handle_OP_DzExpeditionInviteResponse(const EQApplicationPacket *app); - void Handle_OP_DzListTimers(const EQApplicationPacket *app); - void Handle_OP_DzMakeLeader(const EQApplicationPacket *app); - void Handle_OP_DzPlayerList(const EQApplicationPacket *app); - void Handle_OP_DzRemovePlayer(const EQApplicationPacket *app); - void Handle_OP_DzSwapPlayer(const EQApplicationPacket *app); - void Handle_OP_DzQuit(const EQApplicationPacket *app); void Handle_OP_Emote(const EQApplicationPacket *app); void Handle_OP_EndLootRequest(const EQApplicationPacket *app); void Handle_OP_EnvDamage(const EQApplicationPacket *app); @@ -183,7 +174,6 @@ void Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app); void Handle_OP_Jump(const EQApplicationPacket *app); void Handle_OP_KeyRing(const EQApplicationPacket *app); - void Handle_OP_KickPlayers(const EQApplicationPacket *app); void Handle_OP_LDoNButton(const EQApplicationPacket *app); void Handle_OP_LDoNDisarmTraps(const EQApplicationPacket *app); void Handle_OP_LDoNInspect(const EQApplicationPacket *app); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 9c2175b27..18ee9979f 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -44,7 +44,6 @@ #include "../common/spdat.h" #include "../common/string_util.h" #include "event_codes.h" -#include "expedition.h" #include "guild_mgr.h" #include "map.h" #include "petitions.h" @@ -131,9 +130,9 @@ bool Client::Process() { CheckManaEndUpdate(); if (dead && dead_timer.Check()) { - database.MoveCharacterToZone(GetName(), m_pp.binds[0].zone_id); + database.MoveCharacterToZone(GetName(), m_pp.binds[0].zoneId); - m_pp.zone_id = m_pp.binds[0].zone_id; + m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = m_pp.binds[0].instance_id; m_pp.x = m_pp.binds[0].x; m_pp.y = m_pp.binds[0].y; @@ -158,14 +157,8 @@ bool Client::Process() { CalcItemScale(); } - if (TaskPeriodic_Timer.Check() && task_state) - task_state->TaskPeriodicChecks(this); - - if (dynamiczone_removal_timer.Check() && zone && zone->GetInstanceID() != 0) - { - dynamiczone_removal_timer.Disable(); - GoToDzSafeReturnOrBind(zone->GetDynamicZone()); - } + if (TaskPeriodic_Timer.Check() && taskstate) + taskstate->TaskPeriodicChecks(this); if (linkdead_timer.Check()) { LeaveGroup(); @@ -179,13 +172,6 @@ bool Client::Process() { if (myraid) { myraid->MemberZoned(this); } - - Expedition* expedition = GetExpedition(); - if (expedition) - { - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline); - } - return false; //delete client } @@ -271,7 +257,7 @@ bool Client::Process() { * Used in aggro checks */ if (mob_close_scan_timer.Check()) { - entity_list.ScanCloseMobs(close_mobs, this, is_client_moving); + entity_list.ScanCloseMobs(close_mobs, this, true); } bool may_use_attacks = false; @@ -574,12 +560,6 @@ bool Client::Process() { client_state = CLIENT_LINKDEAD; AI_Start(CLIENT_LD_TIMEOUT); SendAppearancePacket(AT_Linkdead, 1); - - Expedition* expedition = GetExpedition(); - if (expedition) - { - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead); - } } } @@ -711,12 +691,6 @@ void Client::OnDisconnect(bool hard_disconnect) { } } - Expedition* expedition = GetExpedition(); - if (expedition && !bZoning) - { - expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline); - } - RemoveAllAuras(); Mob *Other = trade->With(); @@ -1262,10 +1236,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) NPC *banker = entity_list.GetClosestBanker(this, distance); if(!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = fmt::format("Player tried to make use of a banker(coin move) but " - "{} is non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(coin move) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } @@ -1293,11 +1268,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) NPC *banker = entity_list.GetClosestBanker(this, distance); if(!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = - fmt::format("Player tried to make use of a banker(shared coin move) but {} is " - "non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(shared coin move) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } if(mc->cointype1 == COINTYPE_PP) // there's only platinum here @@ -1349,10 +1324,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) NPC *banker = entity_list.GetClosestBanker(this, distance); if(!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = fmt::format("Player tried to make use of a banker(coin move) but " - "{} is non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(coin move) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } switch(mc->cointype2) @@ -1392,11 +1368,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) NPC *banker = entity_list.GetClosestBanker(this, distance); if(!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = - fmt::format("Player tried to make use of a banker(shared coin move) but {} is " - "non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(shared coin move) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); return; } if(mc->cointype2 == COINTYPE_PP) // there's only platinum here @@ -1996,7 +1972,7 @@ void Client::HandleRespawnFromHover(uint32 Option) BindStruct* b = &m_pp.binds[0]; default_to_bind = new RespawnOption; default_to_bind->name = "Bind Location"; - default_to_bind->zone_id = b->zone_id; + default_to_bind->zone_id = b->zoneId; default_to_bind->instance_id = b->instance_id; default_to_bind->x = b->x; default_to_bind->y = b->y; diff --git a/zone/command.cpp b/zone/command.cpp index 20cb4856f..8ee74854b 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -57,11 +57,9 @@ #include "../common/eqemu_logsys.h" #include "../common/profanity_manager.h" #include "../common/net/eqstream.h" -#include "../common/repositories/dynamic_zones_repository.h" #include "data_bucket.h" #include "command.h" -#include "expedition.h" #include "guild_mgr.h" #include "map.h" #include "qglobals.h" @@ -78,7 +76,7 @@ extern QueryServ* QServ; extern WorldServer worldserver; -extern TaskManager *task_manager; +extern TaskManager *taskmanager; extern FastMath g_Math; void CatchSignal(int sig_num); @@ -200,14 +198,11 @@ int command_init(void) command_add("disarmtrap", "Analog for ldon disarm trap for the newer clients since we still don't have it working.", 80, command_disarmtrap) || command_add("distance", "- Reports the distance between you and your target.", 80, command_distance) || command_add("doanim", "[animnum] [type] - Send an EmoteAnim for you or your target", 50, command_doanim) || - command_add("dz", "Manage expeditions and dynamic zone instances", 80, command_dz) || - command_add("dzkickplayers", "Removes all players from current expedition. (/kickplayers alternative for pre-RoF clients)", 0, command_dzkickplayers) || command_add("editmassrespawn", "[name-search] [second-value] - Mass (Zone wide) NPC respawn timer editing command", 100, command_editmassrespawn) || command_add("emote", "['name'/'world'/'zone'] [type] [message] - Send an emote message", 80, command_emote) || command_add("emotesearch", "Searches NPC Emotes", 80, command_emotesearch) || command_add("emoteview", "Lists all NPC Emotes", 80, command_emoteview) || command_add("enablerecipe", "[recipe_id] - Enables a recipe using the recipe id.", 80, command_enablerecipe) || - command_add("endurance", "Restores you or your target's endurance.", 50, command_endurance) || command_add("equipitem", "[slotid(0-21)] - Equip the item on your cursor into the specified slot", 50, command_equipitem) || command_add("face", "- Change the face of your target", 80, command_face) || command_add("faction", "[Find (criteria | all ) | Review (criteria | all) | Reset (id)] - Resets Player's Faction", 80, command_faction) || @@ -392,7 +387,6 @@ int command_init(void) command_add("showspellslist", "Shows spell list of targeted NPC", 100, command_showspellslist) || command_add("showstats", "- Show details about you or your target", 50, command_showstats) || command_add("showzonegloballoot", "Show GlobalLoot entires on this zone", 50, command_showzonegloballoot) || - command_add("showzonepoints", "Show zone points for current zone", 50, command_showzonepoints) || command_add("shutdown", "- Shut this zone process down", 150, command_shutdown) || command_add("size", "[size] - Change size of you or your target", 50, command_size) || command_add("spawn", "[name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid] - Spawn an NPC", 10, command_spawn) || @@ -440,7 +434,6 @@ int command_init(void) command_add("wp", "[add/delete] [grid_num] [pause] [wp_num] [-h] - Add/delete a waypoint to/from a wandering grid", 170, command_wp) || command_add("wpadd", "[pause] [-h] - Add your current location as a waypoint to your NPC target's AI path", 170, command_wpadd) || command_add("wpinfo", "- Show waypoint info about your NPC target", 170, command_wpinfo) || - command_add("worldwide", "Performs world-wide GM functions such as cast (can be extended for other commands). Use caution", 250, command_worldwide) || command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", 250, command_xtargets) || command_add("zclip", "[min] [max] - modifies and resends zhdr packet", 80, command_zclip) || command_add("zcolor", "[red] [green] [blue] - Change sky color", 80, command_zcolor) || @@ -740,42 +733,6 @@ void command_logcommand(Client *c, const char *message) /* * commands go below here */ -void command_worldwide(Client *c, const Seperator *sep) -{ - std::string sub_command; - if (sep->arg[1]) { - sub_command = sep->arg[1]; - } - - if (sub_command == "cast") { - if (sep->arg[2][0] && Seperator::IsNumber(sep->arg[2])) { - int spell_id = atoi(sep->arg[2]); - quest_manager.WorldWideCastSpell(spell_id, 0, 0); - worldserver.SendEmoteMessage(0, 0, 15, fmt::format(" A GM has cast [{}] world-wide!", GetSpellName(spell_id)).c_str()); - } - else { - c->Message(Chat::Yellow, "Usage: #worldwide cast [spellid]"); - } - } - - if (!sep->arg[1]) { - c->Message(Chat::White, "This command is used to perform world-wide tasks"); - c->Message(Chat::White, "Usage: #worldwide cast [spellid]"); - } -} -void command_endurance(Client *c, const Seperator *sep) -{ - Mob *t; - - t = c->GetTarget() ? c->GetTarget() : c; - - if (t->IsClient()) - t->CastToClient()->SetEndurance(t->CastToClient()->GetMaxEndurance()); - else - t->SetEndurance(t->GetMaxEndurance()); - - t->Message(Chat::White, "Your endurance has been refilled."); -} void command_setstat(Client* c, const Seperator* sep){ if(sep->arg[1][0] && sep->arg[2][0] && c->GetTarget()!=0 && c->GetTarget()->IsClient()){ c->GetTarget()->CastToClient()->SetStats(atoi(sep->arg[1]),atoi(sep->arg[2])); @@ -1610,7 +1567,7 @@ void command_list(Client *c, const Seperator *sep) "#goto %.0f %0.f %.0f", entity->GetX(), entity->GetY(), - entity->GetZ() + (entity->IsBoat() ? 50 : 0)); + entity->GetZ()); c->Message( 0, @@ -1805,7 +1762,7 @@ void command_list(Client *c, const Seperator *sep) else { c->Message(Chat::White, "Usage of #list"); c->Message(Chat::White, "- #list [npcs|players|corpses|doors|objects] [search]"); - c->Message(Chat::White, "- Example: #list npcs (Blank for all)"); + c->Message(Chat::White, "- Example: #list npc (Blank for all)"); } } @@ -2643,7 +2600,9 @@ void command_flymode(Client *c, const Seperator *sep) { Mob *t = c; - if (strlen(sep->arg[1]) == 1 && sep->IsNumber(1) && atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 5) { + if (strlen(sep->arg[1]) == 1 && !(sep->arg[1][0] == '0' || sep->arg[1][0] == '1' || sep->arg[1][0] == '2' || sep->arg[1][0] == '3' || sep->arg[1][0] == '4' || sep->arg[1][0] == '5')) + c->Message(Chat::White, "#flymode [0/1/2/3/4/5]"); + else { if (c->GetTarget()) { t = c->GetTarget(); } @@ -2670,12 +2629,9 @@ void command_flymode(Client *c, const Seperator *sep) else if (sep->arg[1][0] == '5') { c->Message(Chat::White, "Setting %s to Levitating While Running", t->GetName()); } - } else { - c->Message(Chat::White, "#flymode [0/1/2/3/4/5]"); } } - void command_showskills(Client *c, const Seperator *sep) { Client *t=c; @@ -4880,10 +4836,6 @@ void command_corpse(Client *c, const Seperator *sep) c->Message(Chat::White, "Insufficient status to depop player corpse."); } - else if (strcasecmp(sep->arg[1], "moveallgraveyard") == 0) { - int count = entity_list.MovePlayerCorpsesToGraveyard(true); - c->Message(Chat::White, "Moved [%d] player corpse(s) to zone graveyard", count); - } else if (sep->arg[1][0] == 0 || strcasecmp(sep->arg[1], "help") == 0) { c->Message(Chat::White, "#Corpse Sub-Commands:"); c->Message(Chat::White, " DeleteNPCCorpses"); @@ -4891,7 +4843,6 @@ void command_corpse(Client *c, const Seperator *sep) c->Message(Chat::White, " ListNPC"); c->Message(Chat::White, " ListPlayer"); c->Message(Chat::White, " Lock - GM locks the corpse - cannot be looted by non-GM"); - c->Message(Chat::White, " MoveAllGraveyard - move all player corpses to zone's graveyard or non-instance"); c->Message(Chat::White, " UnLock"); c->Message(Chat::White, " RemoveCash"); c->Message(Chat::White, " InspectLoot"); @@ -5199,7 +5150,7 @@ void command_gmzone(Client *c, const Seperator *sep) } if (instance_id > 0) { - float target_x = -1, target_y = -1, target_z = -1, target_heading = -1; + float target_x = -1, target_y = -1, target_z = -1; int16 min_status = 0; uint8 min_level = 0; @@ -5209,7 +5160,6 @@ void command_gmzone(Client *c, const Seperator *sep) &target_x, &target_y, &target_z, - &target_heading, &min_status, &min_level )) { @@ -5219,7 +5169,7 @@ void command_gmzone(Client *c, const Seperator *sep) c->Message(Chat::Yellow, "Zoning to private GM instance (%s) (%u)", zone_short_name, instance_id); c->AssignToInstance(instance_id); - c->MovePC(zone_id, instance_id, target_x, target_y, target_z, target_heading, 1); + c->MovePC(zone_id, instance_id, target_x, target_y, target_z, 0, 1); } } @@ -5414,6 +5364,7 @@ void command_memspell(Client *c, const Seperator *sep) } } } + void command_save(Client *c, const Seperator *sep) { if (c->GetTarget() == 0) @@ -5448,153 +5399,6 @@ void command_showzonegloballoot(Client *c, const Seperator *sep) zone->ShowZoneGlobalLoot(c); } -void command_showzonepoints(Client *c, const Seperator *sep) -{ - auto &mob_list = entity_list.GetMobList(); - for (auto itr : mob_list) { - Mob *mob = itr.second; - if (mob->IsNPC() && mob->GetRace() == 2254) { - mob->Depop(); - } - } - - int found_zone_points = 0; - - c->Message(Chat::White, "Listing zone points..."); - c->SendChatLineBreak(); - - for (auto &virtual_zone_point : zone->virtual_zone_point_list) { - std::string zone_long_name = zone_store.GetZoneLongName(virtual_zone_point.target_zone_id); - - c->Message( - Chat::White, - fmt::format( - "Virtual Zone Point x [{}] y [{}] z [{}] h [{}] width [{}] height [{}] | To [{}] ({}) x [{}] y [{}] z [{}] h [{}]", - virtual_zone_point.x, - virtual_zone_point.y, - virtual_zone_point.z, - virtual_zone_point.heading, - virtual_zone_point.width, - virtual_zone_point.height, - zone_long_name.c_str(), - virtual_zone_point.target_zone_id, - virtual_zone_point.target_x, - virtual_zone_point.target_y, - virtual_zone_point.target_z, - virtual_zone_point.target_heading - ).c_str() - ); - - std::string node_name = fmt::format("ZonePoint To [{}]", zone_long_name); - - float half_width = ((float) virtual_zone_point.width / 2); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x + half_width, - (float) virtual_zone_point.y + half_width, - virtual_zone_point.z, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x + half_width, - (float) virtual_zone_point.y - half_width, - virtual_zone_point.z, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x - half_width, - (float) virtual_zone_point.y - half_width, - virtual_zone_point.z, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x - half_width, - (float) virtual_zone_point.y + half_width, - virtual_zone_point.z, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x + half_width, - (float) virtual_zone_point.y + half_width, - (float) virtual_zone_point.z + (float) virtual_zone_point.height, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x + half_width, - (float) virtual_zone_point.y - half_width, - (float) virtual_zone_point.z + (float) virtual_zone_point.height, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x - half_width, - (float) virtual_zone_point.y - half_width, - (float) virtual_zone_point.z + (float) virtual_zone_point.height, - virtual_zone_point.heading - )); - - NPC::SpawnZonePointNodeNPC(node_name, glm::vec4( - (float) virtual_zone_point.x - half_width, - (float) virtual_zone_point.y + half_width, - (float) virtual_zone_point.z + (float) virtual_zone_point.height, - virtual_zone_point.heading - )); - - found_zone_points++; - } - - LinkedListIterator iterator(zone->zone_point_list); - iterator.Reset(); - while (iterator.MoreElements()) { - ZonePoint *zone_point = iterator.GetData(); - std::string zone_long_name = zone_store.GetZoneLongName(zone_point->target_zone_id); - std::string node_name = fmt::format("ZonePoint To [{}]", zone_long_name); - - NPC::SpawnZonePointNodeNPC( - node_name, glm::vec4( - zone_point->x, - zone_point->y, - zone_point->z, - zone_point->heading - ) - ); - - c->Message( - Chat::White, - fmt::format( - "Client Side Zone Point x [{}] y [{}] z [{}] h [{}] number [{}] | To [{}] ({}) x [{}] y [{}] z [{}] h [{}]", - zone_point->x, - zone_point->y, - zone_point->z, - zone_point->heading, - zone_point->number, - zone_long_name.c_str(), - zone_point->target_zone_id, - zone_point->target_x, - zone_point->target_y, - zone_point->target_z, - zone_point->target_heading - ).c_str() - ); - - iterator.Advance(); - - found_zone_points++; - } - - if (found_zone_points == 0) { - c->Message(Chat::White, "There were no zone points found..."); - } - - c->SendChatLineBreak(); - -} - void command_mystats(Client *c, const Seperator *sep) { if (c->GetTarget() && c->GetPet()) { @@ -5641,21 +5445,45 @@ void command_depopzone(Client *c, const Seperator *sep) void command_devtools(Client *c, const Seperator *sep) { - std::string dev_tools_key = StringFormat("%i-dev-tools-disabled", c->AccountID()); + std::string menu_commands_search; + std::string window_toggle_command; + + /** + * Search entity commands + */ + menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list npcs", false, "NPC") + "] "; + menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list players", false, "Players") + "] "; + menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list corpses", false, "Corpses") + "] "; + menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list doors", false, "Doors") + "] "; + menu_commands_search += "[" + EQ::SayLinkEngine::GenerateQuestSaylink("#list objects", false, "Objects") + "] "; + + std::string dev_tools_window_key = StringFormat("%i-dev-tools-window-disabled", c->AccountID()); /** * Handle window toggle */ - if (strcasecmp(sep->arg[1], "disable") == 0) { - DataBucket::SetData(dev_tools_key, "true"); - c->SetDevToolsEnabled(false); + if (strcasecmp(sep->arg[1], "disable_window") == 0) { + DataBucket::SetData(dev_tools_window_key, "true"); + c->SetDevToolsWindowEnabled(false); } - if (strcasecmp(sep->arg[1], "enable") == 0) { - DataBucket::DeleteData(dev_tools_key); - c->SetDevToolsEnabled(true); + if (strcasecmp(sep->arg[1], "enable_window") == 0) { + DataBucket::DeleteData(dev_tools_window_key); + c->SetDevToolsWindowEnabled(true); } - c->ShowDevToolsMenu(); + /** + * Show window status + */ + window_toggle_command = "Disabled [" + EQ::SayLinkEngine::GenerateQuestSaylink("#devtools enable_window", false, "Enable") + "] "; + if (c->IsDevToolsWindowEnabled()) { + window_toggle_command = "Enabled [" + EQ::SayLinkEngine::GenerateQuestSaylink("#devtools disable_window", false, "Disable") + "] "; + } + + /** + * Print menu + */ + c->Message(Chat::White, "| [Devtools] Window %s", window_toggle_command.c_str()); + c->Message(Chat::White, "| [Devtools] Search %s", menu_commands_search.c_str()); } void command_repop(Client *c, const Seperator *sep) @@ -6874,188 +6702,6 @@ void command_doanim(Client *c, const Seperator *sep) c->DoAnim(atoi(sep->arg[1]),atoi(sep->arg[2])); } -void command_dz(Client* c, const Seperator* sep) -{ - if (!c || !zone) { - return; - } - - if (strcasecmp(sep->arg[1], "expedition") == 0) - { - if (strcasecmp(sep->arg[2], "list") == 0) - { - std::vector expeditions; - for (const auto& expedition : zone->expedition_cache) - { - expeditions.emplace_back(expedition.second.get()); - } - - std::sort(expeditions.begin(), expeditions.end(), - [](const Expedition* lhs, const Expedition* rhs) { - return lhs->GetID() < rhs->GetID(); - }); - - c->Message(Chat::White, fmt::format("Total Active Expeditions: [{}]", expeditions.size()).c_str()); - for (const auto& expedition : expeditions) - { - auto leader_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format( - "#goto {}", expedition->GetLeaderName()), false, expedition->GetLeaderName()); - auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format( - "#zoneinstance {}", expedition->GetDynamicZone().GetInstanceID()), false, "zone"); - - auto seconds = expedition->GetDynamicZone().GetSecondsRemaining(); - - c->Message(Chat::White, fmt::format( - "expedition id: [{}] dz id: [{}] name: [{}] leader: [{}] {}: [{}]:[{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]", - expedition->GetID(), - expedition->GetDynamicZone().GetID(), - expedition->GetName(), - leader_saylink, - zone_saylink, - ZoneName(expedition->GetDynamicZone().GetZoneID()), - expedition->GetDynamicZone().GetZoneID(), - expedition->GetDynamicZone().GetInstanceID(), - expedition->GetDynamicZone().GetZoneVersion(), - expedition->GetMemberCount(), - seconds / 3600, // hours - (seconds / 60) % 60, // minutes - seconds % 60 // seconds - ).c_str()); - } - } - else if (strcasecmp(sep->arg[2], "reload") == 0) - { - Expedition::CacheAllFromDatabase(); - c->Message(Chat::White, fmt::format( - "Reloaded [{}] expeditions to cache from database.", zone->expedition_cache.size() - ).c_str()); - } - else if (strcasecmp(sep->arg[2], "destroy") == 0 && sep->IsNumber(3)) - { - auto expedition_id = std::strtoul(sep->arg[3], nullptr, 10); - auto expedition = Expedition::FindCachedExpeditionByID(expedition_id); - if (expedition) - { - c->Message(Chat::White, fmt::format("Destroying expedition [{}] ({})", - expedition_id, expedition->GetName()).c_str()); - expedition->RemoveAllMembers(); - } - else - { - c->Message(Chat::Red, fmt::format("Failed to destroy expedition [{}]", sep->arg[3]).c_str()); - } - } - else if (strcasecmp(sep->arg[2], "unlock") == 0 && sep->IsNumber(3)) - { - auto expedition_id = std::strtoul(sep->arg[3], nullptr, 10); - auto expedition = Expedition::FindCachedExpeditionByID(expedition_id); - if (expedition) - { - c->Message(Chat::White, fmt::format("Unlocking expedition [{}]", expedition_id).c_str()); - expedition->SetLocked(false, ExpeditionLockMessage::None, true); - } - else - { - c->Message(Chat::Red, fmt::format("Failed to find expedition [{}]", sep->arg[3]).c_str()); - } - } - } - else if (strcasecmp(sep->arg[1], "list") == 0) - { - auto dz_list = DynamicZonesRepository::AllDzInstancePlayerCounts(database); - c->Message(Chat::White, fmt::format("Total Dynamic Zones: [{}]", dz_list.size()).c_str()); - - auto now = std::chrono::system_clock::now(); - - for (const auto& dz : dz_list) - { - auto expire_time = std::chrono::system_clock::from_time_t(dz.start_time + dz.duration); - auto remaining = std::chrono::duration_cast(expire_time - now); - auto seconds = std::max(0, static_cast(remaining.count())); - bool is_expired = now > expire_time; - - if (!is_expired || strcasecmp(sep->arg[2], "all") == 0) - { - auto zone_saylink = is_expired ? "zone" : EQ::SayLinkEngine::GenerateQuestSaylink( - fmt::format("#zoneinstance {}", dz.instance), false, "zone"); - - c->Message(Chat::White, fmt::format( - "dz id: [{}] type: [{}] {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]", - dz.id, - dz.type, - zone_saylink, - dz.zone, - dz.instance, - dz.version, - dz.player_count, - seconds / 3600, // hours - (seconds / 60) % 60, // minutes - seconds % 60 // seconds - ).c_str()); - } - } - } - else if (strcasecmp(sep->arg[1], "lockouts") == 0) - { - if (strcasecmp(sep->arg[2], "remove") == 0 && sep->arg[3][0] != '\0') - { - if (sep->arg[5][0] == '\0') - { - c->Message(Chat::White, fmt::format( - "Removing [{}] lockouts on [{}].", sep->arg[4][0] ? sep->arg[4] : "all", sep->arg[3] - ).c_str()); - } - else - { - c->Message(Chat::White, fmt::format( - "Removing [{}]:[{}] lockout on [{}].", sep->arg[4], sep->arg[5], sep->arg[3] - ).c_str()); - } - Expedition::RemoveLockoutsByCharacterName(sep->arg[3], sep->arg[4], sep->arg[5]); - } - } - else if (strcasecmp(sep->arg[1], "makeleader") == 0 && sep->IsNumber(2) && sep->arg[3][0] != '\0') - { - auto expedition_id = std::strtoul(sep->arg[2], nullptr, 10); - auto expedition = Expedition::FindCachedExpeditionByID(expedition_id); - if (expedition) - { - auto char_name = FormatName(sep->arg[3]); - c->Message(Chat::White, fmt::format("Setting expedition [{}] leader to [{}]", expedition_id, char_name).c_str()); - expedition->SendWorldMakeLeaderRequest(c->CharacterID(), char_name); - } - else - { - c->Message(Chat::Red, fmt::format("Failed to find expedition [{}]", expedition_id).c_str()); - } - } - else - { - c->Message(Chat::White, "#dz usage:"); - c->Message(Chat::White, "#dz expedition list - list expeditions in current zone cache"); - c->Message(Chat::White, "#dz expedition reload - reload expedition zone cache from database"); - c->Message(Chat::White, "#dz expedition destroy - destroy expedition globally (must be in cache)"); - c->Message(Chat::White, "#dz expedition unlock - unlock expedition"); - c->Message(Chat::White, "#dz list [all] - list dynamic zone instances from database -- 'all' includes expired"); - c->Message(Chat::White, "#dz lockouts remove - delete all of character's expedition lockouts"); - c->Message(Chat::White, "#dz lockouts remove \"\" - delete lockouts by expedition"); - c->Message(Chat::White, "#dz lockouts remove \"\" \"\" - delete lockout by expedition event"); - c->Message(Chat::White, "#dz makeleader - set new expedition leader"); - } -} - -void command_dzkickplayers(Client* c, const Seperator* sep) -{ - if (c) - { - auto expedition = c->GetExpedition(); - if (expedition) - { - expedition->DzKickPlayers(c); - } - } -} - void command_editmassrespawn(Client* c, const Seperator* sep) { if (strcasecmp(sep->arg[1], "usage") == 0) { @@ -7110,7 +6756,7 @@ void command_editmassrespawn(Client* c, const Seperator* sep) int results_count = 0; - auto results = content_db.QueryDatabase(query); + auto results = database.QueryDatabase(query); if (results.Success() && results.RowCount()) { results_count = results.RowCount(); @@ -7137,7 +6783,7 @@ void command_editmassrespawn(Client* c, const Seperator* sep) if (change_apply) { - results = content_db.QueryDatabase( + results = database.QueryDatabase( fmt::format( SQL( UPDATE spawn2 @@ -7972,6 +7618,13 @@ void command_itemsearch(Client *c, const Seperator *sep) return; } + std::vector amounts = { + "1", + "10", + "100", + "1000" + }; + int count = 0; char sName[64]; char sCriteria[255]; @@ -7985,25 +7638,14 @@ void command_itemsearch(Client *c, const Seperator *sep) pdest = strstr(sName, sCriteria); if (pdest != nullptr) { linker.SetItemData(item); - std::string item_id = std::to_string(item->ID); - std::string saylink_commands = - "[" + - EQ::SayLinkEngine::GenerateQuestSaylink( - "#si " + item_id, + + std::string saylink_commands; + for (auto &amount : amounts) { + saylink_commands += EQ::SayLinkEngine::GenerateQuestSaylink( + "#si " + std::to_string(item->ID) + " " + amount, false, - "X" - ) + - "] "; - if (item->Stackable && item->StackSize > 1) { - std::string stack_size = std::to_string(item->StackSize); - saylink_commands += - "[" + - EQ::SayLinkEngine::GenerateQuestSaylink( - "#si " + item_id + " " + stack_size, - false, - stack_size - ) + - "]"; + "[" + amount + "] " + ); } c->Message( @@ -8011,8 +7653,8 @@ void command_itemsearch(Client *c, const Seperator *sep) fmt::format( " Summon {} [{}] [{}]", saylink_commands, - linker.GenerateLink(), - item->ID + item->ID, + linker.GenerateLink() ).c_str() ); @@ -8090,10 +7732,14 @@ void command_setcrystals(Client *c, const Seperator *sep) else if(!strcasecmp(sep->arg[1], "radiant")) { t->SetRadiantCrystals(atoi(sep->arg[2])); + t->SendCrystalCounts(); + t->SaveCurrency(); } else if(!strcasecmp(sep->arg[1], "ebon")) { t->SetEbonCrystals(atoi(sep->arg[2])); + t->SendCrystalCounts(); + t->SaveCurrency(); } else { @@ -8779,8 +8425,6 @@ void command_npcedit(Client *c, const Seperator *sep) c->Message(Chat::White, "#npcedit version - Set an NPC's version"); c->Message(Chat::White, "#npcedit slow_mitigation - Set an NPC's slow mitigation"); c->Message(Chat::White, "#npcedit flymode - Set an NPC's flymode [0 = ground, 1 = flying, 2 = levitate, 3 = water, 4 = floating]"); - c->Message(Chat::White, "#npcedit raidtarget - Set an NPCs raid_target field"); - c->Message(Chat::White, "#npcedit respawntime - Set an NPCs respawn timer in seconds"); } @@ -9379,24 +9023,6 @@ void command_npcedit(Client *c, const Seperator *sep) return; } - if (strcasecmp(sep->arg[1], "raidtarget") == 0) { - if (sep->arg[2][0] && sep->IsNumber(sep->arg[2]) && atoi(sep->arg[2]) >= 0) { - c->Message(Chat::Yellow, "NPCID %u is %s as a raid target.", npcTypeID, atoi(sep->arg[2]) == 0 ? "no longer designated" : "now designated"); - std::string query = StringFormat("UPDATE npc_types SET raid_target = %i WHERE id = %i", atoi(sep->arg[2]), npcTypeID); - content_db.QueryDatabase(query); - return; - } - } - - if (strcasecmp(sep->arg[1], "respawntime") == 0) { - if (sep->arg[2][0] && sep->IsNumber(sep->arg[2]) && atoi(sep->arg[2]) > 0) { - c->Message(Chat::Yellow, "NPCID %u (spawngroup %i) respawn time set to %i.", npcTypeID, c->GetTarget()->CastToNPC()->GetSpawnGroupId(), atoi(sep->arg[2])); - std::string query = StringFormat("UPDATE spawn2 SET respawntime = %i WHERE spawngroupID = %i AND version = %i", atoi(sep->arg[2]), c->GetTarget()->CastToNPC()->GetSpawnGroupId(), zone->GetInstanceVersion()); - content_db.QueryDatabase(query); - return; - } - } - if((sep->arg[1][0] == 0 || strcasecmp(sep->arg[1],"*")==0) || ((c->GetTarget()==0) || (c->GetTarget()->IsClient()))) c->Message(Chat::White, "Type #npcedit help for more info"); @@ -10150,135 +9776,76 @@ void command_rules(Client *c, const Seperator *sep) { void command_task(Client *c, const Seperator *sep) { //super-command for managing tasks if(sep->arg[1][0] == '\0' || !strcasecmp(sep->arg[1], "help")) { - c->Message(Chat::White, "Syntax: #task [subcommand]"); - c->Message(Chat::White, "------------------------------------------------"); - c->Message(Chat::White, "# Task System Commands"); - c->Message(Chat::White, "------------------------------------------------"); - c->Message( - Chat::White, - fmt::format( - "--- [{}] List active tasks for a client", - EQ::SayLinkEngine::GenerateQuestSaylink("#task show", false, "show") - ).c_str() - ); - c->Message(Chat::White, "--- update [count] | Updates task"); - c->Message(Chat::White, "--- assign | Assigns task to client"); - c->Message( - Chat::White, - fmt::format( - "--- [{}] Reload all Task information from the database", - EQ::SayLinkEngine::GenerateQuestSaylink("#task reloadall", false, "reloadall") - ).c_str() - ); - c->Message( - Chat::White, - fmt::format( - "--- [{}] Reload Task and Activity information for a single task", - EQ::SayLinkEngine::GenerateQuestSaylink("#task reload task", false, "reload task") - ).c_str() - ); - c->Message( - Chat::White, - fmt::format( - "--- [{}] Reload goal/reward list information", - EQ::SayLinkEngine::GenerateQuestSaylink("#task reload lists", false, "reload lists") - ).c_str() - ); - c->Message( - Chat::White, - fmt::format( - "--- [{}] Reload proximity information", - EQ::SayLinkEngine::GenerateQuestSaylink("#task reload prox", false, "reload prox") - ).c_str() - ); - c->Message( - Chat::White, - fmt::format( - "--- [{}] Reload task set information", - EQ::SayLinkEngine::GenerateQuestSaylink("#task reload sets", false, "reload sets") - ).c_str() - ); + c->Message(Chat::White, "Syntax: #task [subcommand]."); + c->Message(Chat::White, "-- Task System Commands --"); + c->Message(Chat::White, "...show - List active tasks for a client"); + c->Message(Chat::White, "...update [Count]"); + c->Message(Chat::White, "...reloadall - Reload all Task information from the database"); + c->Message(Chat::White, "...reload task - Reload Task and Activity informnation for a single task"); + c->Message(Chat::White, "...reload lists - Reload goal/reward list information"); + c->Message(Chat::White, "...reload prox - Reload proximity information"); + c->Message(Chat::White, "...reload sets - Reload task set information"); return; } - Client *client_target = c; - if (c->GetTarget() && c->GetTarget()->IsClient()) { - client_target = c->GetTarget()->CastToClient(); - } + if(!strcasecmp(sep->arg[1], "show")) { + if(c->GetTarget() && c->GetTarget()->IsClient()) + c->GetTarget()->CastToClient()->ShowClientTasks(); + else + c->ShowClientTasks(); - if (!strcasecmp(sep->arg[1], "show")) { - c->ShowClientTasks(client_target); return; } - if (!strcasecmp(sep->arg[1], "update")) { - if (sep->argnum >= 3) { - int task_id = atoi(sep->arg[2]); - int activity_id = atoi(sep->arg[3]); - int count = 1; + if(!strcasecmp(sep->arg[1], "update")) { + if(sep->argnum>=3) { + int TaskID = atoi(sep->arg[2]); + int ActivityID = atoi(sep->arg[3]); + int Count=1; - if (sep->argnum >= 4) { - count = atoi(sep->arg[4]); - if (count <= 0) { - count = 1; - } + if(sep->argnum>=4) { + Count = atoi(sep->arg[4]); + if(Count <= 0) + Count = 1; } - c->Message( - Chat::Yellow, - "Updating Task [%i] Activity [%i] Count [%i] for client [%s]", - task_id, - activity_id, - count, - client_target->GetCleanName() - ); - client_target->UpdateTaskActivity(task_id, activity_id, count); - c->ShowClientTasks(client_target); + c->Message(Chat::Yellow, "Updating Task %i, Activity %i, Count %i", TaskID, ActivityID, Count); + c->UpdateTaskActivity(TaskID, ActivityID, Count); } return; } - - if (!strcasecmp(sep->arg[1], "assign")) { - int task_id = atoi(sep->arg[2]); - if ((task_id > 0) && (task_id < MAXTASKS)) { - client_target->AssignTask(task_id, 0, false); - c->Message(Chat::Yellow, "Assigned task [%i] to [%s]", task_id, client_target->GetCleanName()); - } - return; - } - - if (!strcasecmp(sep->arg[1], "reloadall")) { + if(!strcasecmp(sep->arg[1], "reloadall")) { c->Message(Chat::Yellow, "Sending reloadtasks to world"); worldserver.SendReloadTasks(RELOADTASKS); c->Message(Chat::Yellow, "Back again"); return; } - if (!strcasecmp(sep->arg[1], "reload")) { - if (sep->arg[2][0] != '\0') { - if (!strcasecmp(sep->arg[2], "lists")) { + if(!strcasecmp(sep->arg[1], "reload")) { + if(sep->arg[2][0] != '\0') { + if(!strcasecmp(sep->arg[2], "lists")) { c->Message(Chat::Yellow, "Sending reload lists to world"); worldserver.SendReloadTasks(RELOADTASKGOALLISTS); - c->Message(Chat::Yellow, "Reloaded"); + c->Message(Chat::Yellow, "Back again"); return; } - if (!strcasecmp(sep->arg[2], "prox")) { + if(!strcasecmp(sep->arg[2], "prox")) { c->Message(Chat::Yellow, "Sending reload proximities to world"); worldserver.SendReloadTasks(RELOADTASKPROXIMITIES); - c->Message(Chat::Yellow, "Reloaded"); + c->Message(Chat::Yellow, "Back again"); return; } - if (!strcasecmp(sep->arg[2], "sets")) { + if(!strcasecmp(sep->arg[2], "sets")) { c->Message(Chat::Yellow, "Sending reload task sets to world"); worldserver.SendReloadTasks(RELOADTASKSETS); - c->Message(Chat::Yellow, "Reloaded"); + c->Message(Chat::Yellow, "Back again"); return; } - if (!strcasecmp(sep->arg[2], "task") && (sep->arg[3][0] != '\0')) { - int task_id = atoi(sep->arg[3]); - if ((task_id > 0) && (task_id < MAXTASKS)) { - c->Message(Chat::Yellow, "Sending reload task %i to world", task_id); - worldserver.SendReloadTasks(RELOADTASKS, task_id); - c->Message(Chat::Yellow, "Reloaded"); + if(!strcasecmp(sep->arg[2], "task") && (sep->arg[3][0] != '\0')) { + int TaskID = atoi(sep->arg[3]); + if((TaskID > 0) && (TaskID < MAXTASKS)) { + c->Message(Chat::Yellow, "Sending reload task %i to world"); + worldserver.SendReloadTasks(RELOADTASKS, TaskID); + c->Message(Chat::Yellow, "Back again"); return; } } @@ -12533,7 +12100,7 @@ void command_max_all_skills(Client *c, const Seperator *sep) } else { - int max_skill_level = content_db.GetSkillCap(c->GetClass(), (EQ::skills::SkillType)i, c->GetLevel()); + int max_skill_level = database.GetSkillCap(c->GetClass(), (EQ::skills::SkillType)i, c->GetLevel()); c->SetSkill((EQ::skills::SkillType)i, max_skill_level); } } diff --git a/zone/command.h b/zone/command.h index 303e0f132..36f84d934 100644 --- a/zone/command.h +++ b/zone/command.h @@ -92,14 +92,11 @@ void command_disablerecipe(Client *c, const Seperator *sep); void command_disarmtrap(Client *c, const Seperator *sep); void command_distance(Client *c, const Seperator *sep); void command_doanim(Client *c, const Seperator *sep); -void command_dz(Client *c, const Seperator *sep); -void command_dzkickplayers(Client *c, const Seperator *sep); void command_editmassrespawn(Client* c, const Seperator* sep); void command_emote(Client *c, const Seperator *sep); void command_emotesearch(Client* c, const Seperator *sep); void command_emoteview(Client* c, const Seperator *sep); void command_enablerecipe(Client *c, const Seperator *sep); -void command_endurance(Client *c, const Seperator *sep); void command_equipitem(Client *c, const Seperator *sep); void command_face(Client *c, const Seperator *sep); void command_faction(Client *c, const Seperator *sep); @@ -293,7 +290,6 @@ void command_showskills(Client *c, const Seperator *sep); void command_showspellslist(Client *c, const Seperator *sep); void command_showstats(Client *c, const Seperator *sep); void command_showzonegloballoot(Client *c, const Seperator *sep); -void command_showzonepoints(Client *c, const Seperator *sep); void command_shutdown(Client *c, const Seperator *sep); void command_size(Client *c, const Seperator *sep); void command_spawn(Client *c, const Seperator *sep); @@ -345,7 +341,6 @@ void command_worldshutdown(Client *c, const Seperator *sep); void command_wp(Client *c, const Seperator *sep); void command_wpadd(Client *c, const Seperator *sep); void command_wpinfo(Client *c, const Seperator *sep); -void command_worldwide(Client *c, const Seperator *sep); void command_xtargets(Client *c, const Seperator *sep); void command_zclip(Client *c, const Seperator *sep); void command_zcolor(Client *c, const Seperator *sep); diff --git a/zone/common.h b/zone/common.h index fd513bdde..19df1a576 100644 --- a/zone/common.h +++ b/zone/common.h @@ -195,11 +195,7 @@ enum { COUNTER_AVOID_DAMAGE = 44, PROX_AGGRO = 45, IMMUNE_RANGED_ATTACKS = 46, - IMMUNE_DAMAGE_CLIENT = 47, - IMMUNE_DAMAGE_NPC = 48, - IMMUNE_AGGRO_CLIENT = 49, - IMMUNE_AGGRO_NPC = 50, - MAX_SPECIAL_ATTACK = 51 + MAX_SPECIAL_ATTACK = 47 }; typedef enum { //fear states @@ -790,12 +786,5 @@ struct DamageHitInfo { EQ::skills::SkillType skill; }; -struct ExpeditionInvite -{ - uint32_t expedition_id; - std::string inviter_name; - std::string swap_remove_name; -}; - #endif diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 5113b6fdf..cfcfb0397 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -38,7 +38,6 @@ Child of the Mob class. #include "corpse.h" #include "entity.h" -#include "expedition.h" #include "groups.h" #include "mob.h" #include "raids.h" @@ -622,7 +621,7 @@ bool Corpse::Save() { end = itemlist.end(); for (; cur != end; ++cur) { ServerLootItem_Struct* item = *cur; - memcpy((char*)&dbpc->items[x++], (char*)item, sizeof(player_lootitem::ServerLootItem_Struct)); + memcpy((char*)&dbpc->items[x++], (char*)item, sizeof(ServerLootItem_Struct)); } /* Create New Corpse*/ @@ -826,7 +825,22 @@ bool Corpse::Process() { } if (corpse_graveyard_timer.Check()) { - MovePlayerCorpseToGraveyard(); + if (zone->HasGraveyard()) { + Save(); + player_corpse_depop = true; + database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), + (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, zone->GetGraveyardPoint()); + corpse_graveyard_timer.Disable(); + auto pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); + SpawnPlayerCorpse_Struct* spc = (SpawnPlayerCorpse_Struct*)pack->pBuffer; + spc->player_corpse_id = corpse_db_id; + spc->zone_id = zone->graveyard_zoneid(); + worldserver.SendPacket(pack); + safe_delete(pack); + LogDebug("Moved [{}] player corpse to the designated graveyard in zone [{}]", this->GetName(), ZoneName(zone->graveyard_zoneid())); + corpse_db_id = 0; + } + corpse_graveyard_timer.Disable(); return false; } @@ -1261,20 +1275,6 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app) return; } - if (zone && zone->GetInstanceID() != 0) - { - // expeditions may prevent looting based on client's lockouts - auto expedition = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID()); - if (expedition && !expedition->CanClientLootCorpse(client, GetNPCTypeID(), GetID())) - { - client->MessageString(Chat::Red, LOOT_NOT_ALLOWED, inst->GetItem()->Name); - client->QueuePacket(app); - SendEndLootErrorPacket(client); - ResetLooter(); - delete inst; - return; - } - } // do we want this to have a fail option too? parse->EventItem(EVENT_LOOT, client, inst, this, buf, 0); @@ -1573,10 +1573,10 @@ void Corpse::UpdateEquipmentLight() for (auto iter = itemlist.begin(); iter != itemlist.end(); ++iter) { if ((*iter)->equip_slot < EQ::invslot::EQUIPMENT_BEGIN || (*iter)->equip_slot > EQ::invslot::EQUIPMENT_END) { continue; } if ((*iter)->equip_slot == EQ::invslot::slotAmmo) { continue; } - + auto item = database.GetItem((*iter)->item_id); if (item == nullptr) { continue; } - + if (EQ::lightsource::IsLevelGreater(item->Light, m_Light.Type[EQ::lightsource::LightEquipment])) m_Light.Type[EQ::lightsource::LightEquipment] = item->Light; } @@ -1584,7 +1584,7 @@ void Corpse::UpdateEquipmentLight() uint8 general_light_type = 0; for (auto iter = itemlist.begin(); iter != itemlist.end(); ++iter) { if ((*iter)->equip_slot < EQ::invslot::GENERAL_BEGIN || (*iter)->equip_slot > EQ::invslot::GENERAL_END) { continue; } - + auto item = database.GetItem((*iter)->item_id); if (item == nullptr) { continue; } @@ -1628,53 +1628,3 @@ void Corpse::LoadPlayerCorpseDecayTime(uint32 corpse_db_id){ corpse_graveyard_timer.SetTimer(3000); } } - -void Corpse::SendWorldSpawnPlayerCorpseInZone(uint32_t zone_id) -{ - auto pack = std::make_unique(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); - SpawnPlayerCorpse_Struct* spc = reinterpret_cast(pack->pBuffer); - spc->player_corpse_id = corpse_db_id; - spc->zone_id = zone_id; - worldserver.SendPacket(pack.get()); -} - -bool Corpse::MovePlayerCorpseToGraveyard() -{ - if (IsPlayerCorpse() && zone && zone->HasGraveyard()) - { - Save(); - - uint16_t instance_id = (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0; - database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), instance_id, zone->GetGraveyardPoint()); - SendWorldSpawnPlayerCorpseInZone(zone->graveyard_zoneid()); - - corpse_db_id = 0; - player_corpse_depop = true; - corpse_graveyard_timer.Disable(); - - LogDebug("Moved [{}] player corpse to the designated graveyard in zone [{}]", GetName(), ZoneName(zone->graveyard_zoneid())); - return true; - } - - return false; -} - -bool Corpse::MovePlayerCorpseToNonInstance() -{ - if (IsPlayerCorpse() && zone && zone->GetInstanceID() != 0) - { - Save(); - - database.SendCharacterCorpseToNonInstance(corpse_db_id); - SendWorldSpawnPlayerCorpseInZone(zone->GetZoneID()); - - corpse_db_id = 0; - player_corpse_depop = true; - corpse_graveyard_timer.Disable(); - - LogDebug("Moved [{}] player corpse to non-instance version of zone [{}]", GetName(), ZoneName(zone->GetZoneID())); - return true; - } - - return false; -} diff --git a/zone/corpse.h b/zone/corpse.h index cd564e80d..300569f89 100644 --- a/zone/corpse.h +++ b/zone/corpse.h @@ -79,9 +79,6 @@ class Corpse : public Mob { void SetConsentGuildID(uint32 guild_id) { if (IsPlayerCorpse()) { consented_guild_id = guild_id; } } void AddConsentName(std::string consent_player_name); void RemoveConsentName(std::string consent_player_name); - void SendWorldSpawnPlayerCorpseInZone(uint32_t zone_id); - bool MovePlayerCorpseToGraveyard(); - bool MovePlayerCorpseToNonInstance(); void Delete(); void Bury(); diff --git a/zone/data_bucket.cpp b/zone/data_bucket.cpp index 13dccef66..b0d45080b 100644 --- a/zone/data_bucket.cpp +++ b/zone/data_bucket.cpp @@ -102,29 +102,6 @@ std::string DataBucket::GetDataExpires(std::string bucket_key) { return std::string(row[0]); } -std::string DataBucket::GetDataRemaining(std::string bucket_key) { - if (DataBucket::GetDataExpires(bucket_key).empty()) { - return "0"; - } - std::string query = fmt::format( - "SELECT (`expires` - UNIX_TIMESTAMP()) AS `remaining` from `data_buckets` WHERE `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1", - bucket_key.c_str(), - (long long) std::time(nullptr) - ); - - auto results = database.QueryDatabase(query); - if (!results.Success()) { - return std::string(); - } - - if (results.RowCount() != 1) - return std::string(); - - auto row = results.begin(); - - return std::string(row[0]); -} - /** * Checks for bucket existence by bucket_name key * @param bucket_key diff --git a/zone/data_bucket.h b/zone/data_bucket.h index 51d9c643b..88a344637 100644 --- a/zone/data_bucket.h +++ b/zone/data_bucket.h @@ -15,7 +15,6 @@ public: static bool DeleteData(std::string bucket_key); static std::string GetData(std::string bucket_key); static std::string GetDataExpires(std::string bucket_key); - static std::string GetDataRemaining(std::string bucket_key); private: static uint64 DoesBucketExist(std::string bucket_key); static uint32 ParseStringTimeToInt(std::string time_string); diff --git a/zone/doors.cpp b/zone/doors.cpp index ba3d36d21..ddaa5709e 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -207,8 +207,6 @@ void Doors::HandleClick(Client* sender, uint8 trigger) { } } - // todo: if IsDzDoor() call Client::MovePCDynamicZone(target_zone_id) (for systems that use dzs) - uint32 required_key_item = GetKeyItem(); uint8 disable_add_to_key_ring = GetNoKeyring(); uint32 player_has_key = 0; diff --git a/zone/dynamic_zone.cpp b/zone/dynamic_zone.cpp deleted file mode 100644 index 0b19e5ade..000000000 --- a/zone/dynamic_zone.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "dynamic_zone.h" -#include "client.h" -#include "expedition.h" -#include "worldserver.h" -#include "../common/eqemu_logsys.h" - -extern WorldServer worldserver; - -// message string 8312 added in September 08 2020 Test patch (used by both dz and shared tasks) -const char* const CREATE_NOT_ALL_ADDED = "Not all players in your {} were added to the {}. The {} can take a maximum of {} players, and your {} has {}."; - -DynamicZone::DynamicZone( - uint32_t zone_id, uint32_t version, uint32_t duration, DynamicZoneType type) -{ - m_zone_id = zone_id; - m_zone_version = version; - m_duration = std::chrono::seconds(duration); - m_type = type; -} - -Database& DynamicZone::GetDatabase() -{ - return database; -} - -uint16_t DynamicZone::GetCurrentInstanceID() -{ - return zone ? static_cast(zone->GetInstanceID()) : 0; -} - -uint16_t DynamicZone::GetCurrentZoneID() -{ - return zone ? static_cast(zone->GetZoneID()) : 0; -} - -DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id) -{ - auto expedition = Expedition::FindCachedExpeditionByDynamicZoneID(dz_id); - if (expedition) - { - return &expedition->GetDynamicZone(); - } - // todo: other system caches - return nullptr; -} - -void DynamicZone::StartAllClientRemovalTimers() -{ - for (const auto& client_iter : entity_list.GetClientList()) - { - if (client_iter.second) - { - client_iter.second->SetDzRemovalTimer(true); - } - } -} - -void DynamicZone::SendInstanceRemoveAllCharacters() -{ - // just remove all clients in bulk instead of only characters assigned to the instance - if (IsCurrentZoneDzInstance()) - { - DynamicZone::StartAllClientRemovalTimers(); - } - else if (GetInstanceID() != 0) - { - auto pack = CreateServerRemoveAllCharactersPacket(); - worldserver.SendPacket(pack.get()); - } -} - -void DynamicZone::SendInstanceAddRemoveCharacter(uint32_t character_id, bool removed) -{ - // if removing, sets removal timer on client inside the instance - if (IsCurrentZoneDzInstance()) - { - Client* client = entity_list.GetClientByCharID(character_id); - if (client) - { - client->SetDzRemovalTimer(removed); - } - } - else if (GetInstanceID() != 0) - { - auto pack = CreateServerAddRemoveCharacterPacket(character_id, removed); - worldserver.SendPacket(pack.get()); - } -} - -bool DynamicZone::IsCurrentZoneDzInstance() const -{ - return (zone && zone->GetInstanceID() != 0 && zone->GetInstanceID() == GetInstanceID()); -} - -void DynamicZone::SetSecondsRemaining(uint32_t seconds_remaining) -{ - // async - constexpr uint32_t pack_size = sizeof(ServerDzSetDuration_Struct); - auto pack = std::make_unique(ServerOP_DzSetSecondsRemaining, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->dz_id = GetID(); - buf->seconds = seconds_remaining; - worldserver.SendPacket(pack.get()); -} - -void DynamicZone::SetUpdatedDuration(uint32_t new_duration) -{ - // preserves original start time, just modifies duration and expire time - m_duration = std::chrono::seconds(new_duration); - m_expire_time = m_start_time + m_duration; - - LogDynamicZones("Updated zone [{}]:[{}] seconds remaining: [{}]", - m_zone_id, m_instance_id, GetSecondsRemaining()); - - if (zone && IsCurrentZoneDzInstance()) - { - zone->SetInstanceTimer(GetSecondsRemaining()); - } -} - -void DynamicZone::SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) -{ - auto pack = CreateServerDzLocationPacket(server_opcode, location); - worldserver.SendPacket(pack.get()); -} - -void DynamicZone::HandleWorldMessage(ServerPacket* pack) -{ - switch (pack->opcode) - { - case ServerOP_DzAddRemoveCharacter: - { - auto buf = reinterpret_cast(pack->pBuffer); - Client* client = entity_list.GetClientByCharID(buf->character_id); - if (client) - { - client->SetDzRemovalTimer(buf->remove); // instance kick timer - } - break; - } - case ServerOP_DzRemoveAllCharacters: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (buf->remove) - { - DynamicZone::StartAllClientRemovalTimers(); - } - break; - } - case ServerOP_DzDurationUpdate: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id); - if (dz) - { - dz->SetUpdatedDuration(buf->seconds); - } - break; - } - case ServerOP_DzSetCompass: - case ServerOP_DzSetSafeReturn: - case ServerOP_DzSetZoneIn: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id); - if (dz) - { - if (pack->opcode == ServerOP_DzSetCompass) - { - dz->SetCompass(buf->zone_id, buf->x, buf->y, buf->z, false); - } - else if (pack->opcode == ServerOP_DzSetSafeReturn) - { - dz->SetSafeReturn(buf->zone_id, buf->x, buf->y, buf->z, buf->heading, false); - } - else if (pack->opcode == ServerOP_DzSetZoneIn) - { - dz->SetZoneInLocation(buf->x, buf->y, buf->z, buf->heading, false); - } - } - } - break; - } - } -} - -void DynamicZone::ProcessCompassChange(const DynamicZoneLocation& location) -{ - DynamicZoneBase::ProcessCompassChange(location); - if (m_on_compass_change) - { - m_on_compass_change(); - } -} diff --git a/zone/dynamic_zone.h b/zone/dynamic_zone.h deleted file mode 100644 index 3b421330a..000000000 --- a/zone/dynamic_zone.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef DYNAMIC_ZONE_H -#define DYNAMIC_ZONE_H - -#include "../common/dynamic_zone_base.h" -#include -#include -#include -#include -#include - -class Database; -class ServerPacket; - -extern const char* const CREATE_NOT_ALL_ADDED; - -class DynamicZone : public DynamicZoneBase -{ -public: - using DynamicZoneBase::DynamicZoneBase; // inherit base constructors - - DynamicZone() = default; - DynamicZone(uint32_t zone_id, uint32_t version, uint32_t duration, DynamicZoneType type); - - static DynamicZone* FindDynamicZoneByID(uint32_t dz_id); - static void HandleWorldMessage(ServerPacket* pack); - - void SetSecondsRemaining(uint32_t seconds_remaining) override; - - bool IsCurrentZoneDzInstance() const; - void RegisterOnCompassChange(const std::function& on_change) { m_on_compass_change = on_change; } - void SetUpdatedDuration(uint32_t seconds); - -protected: - uint16_t GetCurrentInstanceID() override; - uint16_t GetCurrentZoneID() override; - Database& GetDatabase() override; - void ProcessCompassChange(const DynamicZoneLocation& location) override; - void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override; - void SendInstanceRemoveAllCharacters() override; - void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override; - -private: - static void StartAllClientRemovalTimers(); - - std::function m_on_compass_change; -}; - -#endif diff --git a/zone/effects.cpp b/zone/effects.cpp index b095c84a3..c2a20cf71 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -678,17 +678,6 @@ void Client::ResetDisciplineTimer(uint32 timer_id) { SendDisciplineTimer(timer_id, 0); } -bool Client::HasDisciplineLearned(uint16 spell_id) { - bool has_learned = false; - for (auto index = 0; index < MAX_PP_DISCIPLINES; ++index) { - if (GetPP().disciplines.values[index] == spell_id) { - has_learned = true; - break; - } - } - return has_learned; -} - void Client::SendDisciplineTimer(uint32 timer_id, uint32 duration) { if (timer_id < MAX_DISCIPLINE_TIMERS) @@ -917,9 +906,6 @@ void EntityList::AESpell( } } - current_mob->CalcSpellPowerDistanceMod(spell_id, distance_to_target); - caster_mob->SpellOnTarget(spell_id, current_mob, false, true, resist_adjust); - /** * Increment hit count if max targets */ @@ -929,6 +915,9 @@ void EntityList::AESpell( break; } } + + current_mob->CalcSpellPowerDistanceMod(spell_id, distance_to_target); + caster_mob->SpellOnTarget(spell_id, current_mob, false, true, resist_adjust); } LogAoeCast("Done iterating [{}]", caster_mob->GetCleanName()); diff --git a/zone/embparser.cpp b/zone/embparser.cpp index c19ac6671..671a26d9c 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -959,9 +959,6 @@ void PerlembParser::MapFunctions() "package Raid;" "&boot_Raid;" //load our Raid XS - "package Inventory;" - "&boot_Inventory;" // load inventory XS - "package QuestItem;" "&boot_QuestItem;" // load quest Item XS @@ -974,9 +971,6 @@ void PerlembParser::MapFunctions() "package Doors;" "&boot_Doors;" // load quest Doors XS - "package Expedition;" - "&boot_Expedition;" - #endif "package main;" "}" @@ -1270,11 +1264,12 @@ void PerlembParser::ExportItemVariables(std::string &package_name, Mob *mob) perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); for (int slot = EQ::invslot::EQUIPMENT_BEGIN; slot <= EQ::invslot::GENERAL_END; slot++) { + char *hi_decl = nullptr; int itemid = mob->CastToClient()->GetItemIDAt(slot); if (itemid != -1 && itemid != 0) { - // this is really ugly with fmtlib, I think I did it right - auto hi_decl = fmt::format("push (@{{${0}{{{1}}}}},{2});", hashname, itemid, slot); - perl->eval(hi_decl.c_str()); + MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);", hashname.c_str(), itemid, slot); + perl->eval(hi_decl); + safe_delete_array(hi_decl); } } } @@ -1282,11 +1277,12 @@ void PerlembParser::ExportItemVariables(std::string &package_name, Mob *mob) if (mob && mob->IsClient()) { std::string hashname = package_name + std::string("::oncursor"); perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); + char *hi_decl = nullptr; int itemid = mob->CastToClient()->GetItemIDAt(EQ::invslot::slotCursor); if (itemid != -1 && itemid != 0) { - // this is really ugly with fmtlib, I think I did it right - auto hi_decl = fmt::format("push (@{{${0}{{{1}}}}},{2});", hashname, itemid, EQ::invslot::slotCursor); - perl->eval(hi_decl.c_str()); + MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);", hashname.c_str(), itemid, EQ::invslot::slotCursor); + perl->eval(hi_decl); + safe_delete_array(hi_decl); } } } diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index f0ba69526..af7b5acf7 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -29,7 +29,6 @@ #include "embparser.h" #include "embxs.h" #include "entity.h" -#include "expedition.h" #include "queryserv.h" #include "questmgr.h" #include "zone.h" @@ -104,23 +103,6 @@ XS(XS_EntityList_new) { XSRETURN(1); } -//Any creation of new inventory gets the curreny inventory -XS(XS_Inventory_new); -XS(XS_Inventory_new) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: quest::Inventory::new()"); - - EQ::InventoryProfile* RETVAL; - - RETVAL = quest_manager.GetInventory(); - ST(0) = sv_newmortal(); - if (RETVAL) - sv_setref_pv(ST(0), "Inventory", (void *) RETVAL); - - XSRETURN(1); -} - //Any creation of new quest items gets the current quest item XS(XS_QuestItem_new); XS(XS_QuestItem_new) { @@ -899,27 +881,6 @@ XS(XS__getspellname) { XSRETURN(1); } -XS(XS__get_spell_level); -XS(XS__get_spell_level) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: quest::get_spell_level(uint16 spell_id, uint8 class_id)"); - - dXSTARG; - uint16 spell_id = (int)SvIV(ST(0)); - uint8 class_id = (int)SvIV(ST(1)); - uint8 spell_level = IsValidSpell(spell_id) ? GetSpellLevel(spell_id, class_id) : 0; - uint8 server_max_level = RuleI(Character, MaxLevel); - - if (spell_level && spell_level > server_max_level) - spell_level = 0; - - XSprePUSH; - PUSHu((UV)spell_level); - - XSRETURN(1); -} - XS(XS__getskillname); XS(XS__getskillname) { dXSARGS; @@ -1495,19 +1456,14 @@ XS(XS__ding) { XS(XS__rebind); XS(XS__rebind) { dXSARGS; - if (items < 4 || items > 5) - Perl_croak(aTHX_ "Usage: quest::rebind(int zone_id, float x, float y, float z, [float heading])"); + if (items != 4) + Perl_croak(aTHX_ "Usage: quest::rebind(int zone_id, float x, float y, float z)"); + + int zone_id = (int) SvIV(ST(0)); + auto location = glm::vec3((float) SvNV(ST(1)), (float) SvNV(ST(2)), (float) SvNV(ST(3))); + + quest_manager.rebind(zone_id, location); - int zone_id = (int) SvIV(ST(0)); - float target_x = (float) SvNV(ST(1)); - float target_y = (float) SvNV(ST(2)); - float target_z = (float) SvNV(ST(3)); - if (items > 4) { - float target_heading = (float) SvNV(ST(4)); - quest_manager.rebind(zone_id, glm::vec4(target_x, target_y, target_z, target_heading)); - } else { - quest_manager.rebind(zone_id, glm::vec3(target_x, target_y, target_z)); - } XSRETURN_EMPTY; } @@ -2115,19 +2071,6 @@ XS(XS__repopzone) { XSRETURN_EMPTY; } -XS(XS__processmobswhilezoneempty); -XS(XS__processmobswhilezoneempty) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: quest::processmobswhilezoneempty(bool on)"); - - bool ProcessingOn = ((int) SvIV(ST(0))) == 0 ? false : true; - - quest_manager.processmobswhilezoneempty(ProcessingOn); - - XSRETURN_EMPTY; -} - XS(XS__npcrace); XS(XS__npcrace) { dXSARGS; @@ -2836,29 +2779,6 @@ XS(XS__we) { XSRETURN_EMPTY; } -XS(XS__message); -XS(XS__message) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: quest::message(int color, string message)"); - - int color = (int) SvIV(ST(0)); - char *message = (char *) SvPV_nolen(ST(1)); - quest_manager.message(color, message); - XSRETURN_EMPTY; -} - -XS(XS__whisper); -XS(XS__whisper) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: quest::whisper(string message)"); - - char *message = (char *) SvPV_nolen(ST(0)); - quest_manager.whisper(message); - XSRETURN_EMPTY; -} - XS(XS__getlevel); XS(XS__getlevel) { dXSARGS; @@ -2958,7 +2878,7 @@ XS(XS__ModifyNPCStat); XS(XS__ModifyNPCStat) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: quest::modifynpcstat(string key, string value)"); + Perl_croak(aTHX_ "Usage: quest::ModifyNPCStat(string key, string value)"); quest_manager.ModifyNPCStat(SvPV_nolen(ST(0)), SvPV_nolen(ST(1))); @@ -2993,22 +2913,6 @@ XS(XS__countitem) { XSRETURN_IV(quantity); } -XS(XS__removeitem); -XS(XS__removeitem) { - dXSARGS; - if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: quest::removeitem(int item_id, [int quantity = 1])"); - - uint32 item_id = (int) SvIV(ST(0)); - uint32 quantity = 1; - if (items > 1) - quantity = (int) SvIV(ST(1)); - - quest_manager.removeitem(item_id, quantity); - - XSRETURN_EMPTY; -} - XS(XS__getitemname); XS(XS__getitemname) { dXSARGS; @@ -3033,9 +2937,9 @@ XS(XS__getnpcnamebyid) { dXSTARG; uint32 npc_id = (int) SvIV(ST(0)); - auto npc_name = quest_manager.getnpcnamebyid(npc_id); + const char *npc_name = quest_manager.getnpcnamebyid(npc_id); - sv_setpv(TARG, npc_name.c_str()); + sv_setpv(TARG, npc_name); XSprePUSH; PUSHTARG; XSRETURN(1); @@ -3423,9 +3327,8 @@ XS(XS__getcharnamebyid) { Const_char *RETVAL; uint32 char_id = (int) SvUV(ST(0)); - auto name = quest_manager.getcharnamebyid(char_id); - RETVAL = name.c_str(); + RETVAL = quest_manager.getcharnamebyid(char_id); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -3817,41 +3720,10 @@ XS(XS__GetZoneLongName) { if (items != 1) Perl_croak(aTHX_ "Usage: quest::GetZoneLongName(string zone)"); dXSTARG; + char *zone = (char *) SvPV_nolen(ST(0)); + Const_char *RETVAL = quest_manager.GetZoneLongName(zone); - std::string zone = (std::string) SvPV_nolen(ST(0)); - std::string RETVAL = quest_manager.GetZoneLongName(zone); - - sv_setpv(TARG, RETVAL.c_str()); - XSprePUSH; - PUSHTARG; - XSRETURN(1); -} - -XS(XS__GetZoneLongNameByID); -XS(XS__GetZoneLongNameByID) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: quest::GetZoneLongNameByID(uint32 zone_id)"); - - dXSTARG; - uint32 zone_id = (uint32) SvUV(ST(0)); - std::string zone_long_name = quest_manager.GetZoneLongNameByID(zone_id); - sv_setpv(TARG, zone_long_name.c_str()); - XSprePUSH; - PUSHTARG; - XSRETURN(1); -} - -XS(XS__GetZoneShortName); -XS(XS__GetZoneShortName) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: quest::GetZoneShortName(uint32 zone_id)"); - - dXSTARG; - uint32 zone_id = (uint32) SvUV(ST(0)); - std::string zone_short_name = quest_manager.GetZoneShortName(zone_id); - sv_setpv(TARG, zone_short_name.c_str()); + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; XSRETURN(1); @@ -3882,7 +3754,7 @@ XS(XS__crosszoneassigntaskbycharid) { if (items == 3) { enforce_level_requirement = (bool) SvTRUE(ST(2)); - } + } quest_manager.CrossZoneAssignTaskByCharID(character_id, task_id, enforce_level_requirement); } @@ -3916,13 +3788,13 @@ XS(XS__crosszoneassigntaskbyraidid) { int raid_id = (int) SvIV(ST(0)); uint32 task_id = (uint32) SvIV(ST(1)); bool enforce_level_requirement = false; - + if (items == 3) { enforce_level_requirement = (bool) SvTRUE(ST(2)); } quest_manager.CrossZoneAssignTaskByRaidID(raid_id, task_id, enforce_level_requirement); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneassigntaskbyguildid); @@ -3940,7 +3812,7 @@ XS(XS__crosszoneassigntaskbyguildid) { } quest_manager.CrossZoneAssignTaskByGuildID(guild_id, task_id, enforce_level_requirement); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonecastspellbycharid); @@ -3953,7 +3825,7 @@ XS(XS__crosszonecastspellbycharid) { uint32 spell_id = (uint32) SvIV(ST(1)); quest_manager.CrossZoneCastSpellByCharID(character_id, spell_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonecastspellbygroupid); @@ -3966,7 +3838,7 @@ XS(XS__crosszonecastspellbygroupid) { uint32 spell_id = (uint32) SvIV(ST(1)); quest_manager.CrossZoneCastSpellByGroupID(group_id, spell_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonecastspellbyraidid); @@ -3979,7 +3851,7 @@ XS(XS__crosszonecastspellbyraidid) { uint32 spell_id = (uint32) SvIV(ST(1)); quest_manager.CrossZoneCastSpellByRaidID(raid_id, spell_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonecastspellbyguildid); @@ -3992,7 +3864,7 @@ XS(XS__crosszonecastspellbyguildid) { uint32 spell_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneCastSpellByGuildID(guild_id, spell_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonedisabletaskbycharid); @@ -4005,7 +3877,7 @@ XS(XS__crosszonedisabletaskbycharid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneDisableTaskByCharID(char_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonedisabletaskbygroupid); @@ -4018,7 +3890,7 @@ XS(XS__crosszonedisabletaskbygroupid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneDisableTaskByGroupID(group_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonedisabletaskbyraidid); @@ -4031,7 +3903,7 @@ XS(XS__crosszonedisabletaskbyraidid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneDisableTaskByRaidID(raid_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonedisabletaskbyguildid); @@ -4044,7 +3916,7 @@ XS(XS__crosszonedisabletaskbyguildid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneDisableTaskByGuildID(guild_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneenabletaskbycharid); @@ -4057,7 +3929,7 @@ XS(XS__crosszoneenabletaskbycharid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneEnableTaskByCharID(char_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneenabletaskbygroupid); @@ -4070,7 +3942,7 @@ XS(XS__crosszoneenabletaskbygroupid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneEnableTaskByGroupID(group_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneenabletaskbyraidid); @@ -4083,7 +3955,7 @@ XS(XS__crosszoneenabletaskbyraidid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneEnableTaskByRaidID(raid_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneenabletaskbyguildid); @@ -4096,7 +3968,7 @@ XS(XS__crosszoneenabletaskbyguildid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneEnableTaskByGuildID(guild_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonefailtaskbycharid); @@ -4109,7 +3981,7 @@ XS(XS__crosszonefailtaskbycharid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneFailTaskByCharID(char_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonefailtaskbygroupid); @@ -4122,7 +3994,7 @@ XS(XS__crosszonefailtaskbygroupid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneFailTaskByGroupID(group_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonefailtaskbyraidid); @@ -4135,7 +4007,7 @@ XS(XS__crosszonefailtaskbyraidid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneFailTaskByRaidID(raid_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonefailtaskbyguildid); @@ -4148,7 +4020,7 @@ XS(XS__crosszonefailtaskbyguildid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneFailTaskByGuildID(guild_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonemarqueebycharid); @@ -4505,7 +4377,7 @@ XS(XS__crosszoneremovetaskbycharid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneRemoveTaskByCharID(char_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneremovetaskbygroupid); @@ -4518,7 +4390,7 @@ XS(XS__crosszoneremovetaskbygroupid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneRemoveTaskByGroupID(group_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneremovetaskbyraidid); @@ -4531,7 +4403,7 @@ XS(XS__crosszoneremovetaskbyraidid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneRemoveTaskByRaidID(raid_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneremovetaskbyguildid); @@ -4544,7 +4416,7 @@ XS(XS__crosszoneremovetaskbyguildid) { uint32 task_id = (uint32) SvUV(ST(1)); quest_manager.CrossZoneRemoveTaskByGuildID(guild_id, task_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneresetactivitybycharid); @@ -4558,7 +4430,7 @@ XS(XS__crosszoneresetactivitybycharid) { int activity_id = (int) SvIV(ST(2)); quest_manager.CrossZoneResetActivityByCharID(char_id, task_id, activity_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneresetactivitybygroupid); @@ -4572,7 +4444,7 @@ XS(XS__crosszoneresetactivitybygroupid) { int activity_id = (int) SvIV(ST(2)); quest_manager.CrossZoneResetActivityByGroupID(group_id, task_id, activity_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneresetactivitybyraidid); @@ -4586,7 +4458,7 @@ XS(XS__crosszoneresetactivitybyraidid) { int activity_id = (int) SvIV(ST(2)); quest_manager.CrossZoneResetActivityByRaidID(raid_id, task_id, activity_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneresetactivitybyguildid); @@ -4600,7 +4472,7 @@ XS(XS__crosszoneresetactivitybyguildid) { int activity_id = (int) SvIV(ST(2)); quest_manager.CrossZoneResetActivityByGuildID(guild_id, task_id, activity_id); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszonesetentityvariablebynpctypeid); @@ -4799,7 +4671,7 @@ XS(XS__crosszoneupdateactivitybycharid) { } quest_manager.CrossZoneUpdateActivityByCharID(char_id, task_id, activity_id, activity_count); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneupdateactivitybygroupid); @@ -4817,7 +4689,7 @@ XS(XS__crosszoneupdateactivitybygroupid) { } quest_manager.CrossZoneUpdateActivityByGroupID(group_id, task_id, activity_id, activity_count); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneupdateactivitybyraidid); @@ -4835,7 +4707,7 @@ XS(XS__crosszoneupdateactivitybyraidid) { } quest_manager.CrossZoneUpdateActivityByRaidID(raid_id, task_id, activity_id, activity_count); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__crosszoneupdateactivitybyguildid); @@ -4853,7 +4725,7 @@ XS(XS__crosszoneupdateactivitybyguildid) { } quest_manager.CrossZoneUpdateActivityByGuildID(guild_id, task_id, activity_id, activity_count); } - XSRETURN_EMPTY; + XSRETURN_EMPTY; } XS(XS__worldwideassigntask); @@ -4868,7 +4740,7 @@ XS(XS__worldwideassigntask) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -4890,7 +4762,7 @@ XS(XS__worldwidecastspell) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -4912,7 +4784,7 @@ XS(XS__worldwidedisabletask) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -4934,7 +4806,7 @@ XS(XS__worldwideenabletask) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -4956,7 +4828,7 @@ XS(XS__worldwidefailtask) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -4983,7 +4855,7 @@ XS(XS__worldwidemarquee) { if (items == 7) { min_status = (uint8) SvUV(ST(6)); } - + if (items == 8) { max_status = (uint8) SvUV(ST(7)); } @@ -5006,7 +4878,7 @@ XS(XS__worldwidemessage) { if (items == 3) { min_status = (uint8) SvUV(ST(2)); } - + if (items == 4) { max_status = (uint8) SvUV(ST(3)); } @@ -5029,7 +4901,7 @@ XS(XS__worldwidemove) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -5051,7 +4923,7 @@ XS(XS__worldwidemoveinstance) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -5073,7 +4945,7 @@ XS(XS__worldwideremovespell) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -5095,7 +4967,7 @@ XS(XS__worldwideremovetask) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(2)); } @@ -5118,7 +4990,7 @@ XS(XS__worldwideresetactivity) { if (items == 3) { min_status = (uint8) SvUV(ST(2)); } - + if (items == 4) { max_status = (uint8) SvUV(ST(3)); } @@ -5141,7 +5013,7 @@ XS(XS__worldwidesetentityvariableclient) { if (items == 3) { min_status = (uint8) SvUV(ST(2)); } - + if (items == 4) { max_status = (uint8) SvUV(ST(3)); } @@ -5190,7 +5062,7 @@ XS(XS__worldwidesignalclient) { if (items == 2) { min_status = (uint8) SvUV(ST(1)); } - + if (items == 3) { max_status = (uint8) SvUV(ST(1)); } @@ -5217,7 +5089,7 @@ XS(XS__worldwideupdateactivity) { if (items == 4) { min_status = (uint8) SvUV(ST(3)); } - + if (items == 5) { max_status = (uint8) SvUV(ST(4)); } @@ -6157,402 +6029,6 @@ XS(XS__SetContentFlag) XSRETURN_EMPTY; } -XS(XS__get_expedition); -XS(XS__get_expedition) { - dXSARGS; - if (items != 0) { - Perl_croak(aTHX_ "Usage: quest::get_expedition()"); - } - - Expedition* RETVAL = nullptr; - if (zone && zone->GetInstanceID() != 0) - { - RETVAL = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID()); - } - - EXTEND(sp, 1); // grow stack, function had 0 arguments - ST(0) = sv_newmortal(); // PUSHs(sv_newmortal()); - if (RETVAL) { - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - } - - XSRETURN(1); -} - -XS(XS__get_expedition_by_char_id); -XS(XS__get_expedition_by_char_id) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: quest::get_expedition_by_char_id(uint32 character_id)"); - } - - uint32 character_id = (int)SvUV(ST(0)); - - Expedition* RETVAL = Expedition::FindCachedExpeditionByCharacterID(character_id); - - ST(0) = sv_newmortal(); - if (RETVAL) { - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - } - - XSRETURN(1); -} - -XS(XS__get_expedition_by_dz_id); -XS(XS__get_expedition_by_dz_id) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: quest::get_expedition_by_dz_id(uint32 dynamic_zone_id)"); - } - - uint32 dz_id = (int)SvUV(ST(0)); - - Expedition* RETVAL = Expedition::FindCachedExpeditionByDynamicZoneID(dz_id); - - ST(0) = sv_newmortal(); - if (RETVAL) { - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - } - - XSRETURN(1); -} - -XS(XS__get_expedition_by_zone_instance); -XS(XS__get_expedition_by_zone_instance) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: quest::GetExpeditionByZoneInstance(uint16 zone_id, uint16 instance_id)"); - } - - uint16 zone_id = (uint16)SvUV(ST(0)); - uint16 instance_id = (uint16)SvUV(ST(1)); - - Expedition* RETVAL = Expedition::FindCachedExpeditionByZoneInstance(zone_id, instance_id); - - ST(0) = sv_newmortal(); - if (RETVAL) { - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - } - - XSRETURN(1); -} - -XS(XS__get_expedition_lockout_by_char_id); -XS(XS__get_expedition_lockout_by_char_id) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: quest::get_expedition_lockout_by_char_id(uint32 character_id, string expedition_name, string event_name)"); - } - - uint32_t character_id = static_cast(SvUV(ST(0))); - std::string expedition_name = SvPV_nolen(ST(1)); - std::string event_name = SvPV_nolen(ST(2)); - - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(character_id); - auto it = std::find_if(lockouts.begin(), lockouts.end(), [&](const ExpeditionLockoutTimer& lockout) { - return lockout.IsSameLockout(expedition_name, event_name); - }); - - // mortalize so its refcnt is auto decremented on function exit to avoid leak - HV* hash = (HV*)sv_2mortal((SV*)newHV()); // hash refcnt +1 (mortal -1) - - if (it != lockouts.end()) - { - hv_store(hash, "remaining", strlen("remaining"), newSVuv(it->GetSecondsRemaining()), 0); - hv_store(hash, "uuid", strlen("uuid"), newSVpv(it->GetExpeditionUUID().c_str(), 0), 0); - } - - ST(0) = sv_2mortal(newRV((SV*)hash)); // hash refcnt: 2 (-1 mortal), reference: 1 (-1 mortal) - XSRETURN(1); -} - -XS(XS__get_expedition_lockouts_by_char_id); -XS(XS__get_expedition_lockouts_by_char_id) { - dXSARGS; - if (items != 1 && items != 2) { - Perl_croak(aTHX_ "Usage: quest::get_expedition_lockouts_by_char_id(uint32 character_id, [string expedition_name])"); - } - - HV* hash = newHV(); // hash refcnt +1 (non-mortal, newRV_noinc to not inc) - SV* hash_ref = nullptr; // for expedition event hash if filtering on expedition - - uint32_t character_id = static_cast(SvUV(ST(0))); - std::string expedition_name; - if (items == 2) - { - expedition_name = SvPV_nolen(ST(1)); - } - - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(character_id); - - for (const auto& lockout : lockouts) - { - uint32_t name_len = static_cast(lockout.GetExpeditionName().size()); - uint32_t event_len = static_cast(lockout.GetEventName().size()); - - // hashes are stored through references inside other hashes/arrays. we need - // to wrap newHV in newRV references when inserting nested hash values. - // we use newRV_noinc to not increment the hash's ref count; rv will own it - - SV** entry = hv_fetch(hash, lockout.GetExpeditionName().c_str(), name_len, false); - if (!entry) - { - // create expedition entry in hash with its value as ref to event hash - SV* event_hash_ref = newRV_noinc((SV*)newHV()); // ref takes ownership - if (!expedition_name.empty() && lockout.GetExpeditionName() == expedition_name) - { - hash_ref = event_hash_ref; // save ref for filtered expedition return - } - entry = hv_store(hash, lockout.GetExpeditionName().c_str(), name_len, event_hash_ref, 0); - } - - // *entry is a reference to expedition's event hash (which it owns). the - // event entry in the hash will contain ref to a lockout detail hash - if (entry && SvROK(*entry) && SvTYPE(SvRV(*entry)) == SVt_PVHV) // is ref to hash type - { - HV* details_hash = newHV(); // refcnt +1, reference will take ownership - hv_store(details_hash, "remaining", strlen("remaining"), newSVuv(lockout.GetSecondsRemaining()), 0); - hv_store(details_hash, "uuid", strlen("uuid"), newSVpv(lockout.GetExpeditionUUID().c_str(), 0), 0); - - HV* event_hash = (HV*)SvRV(*entry); - hv_store(event_hash, lockout.GetEventName().c_str(), event_len, - (SV*)newRV_noinc((SV*)details_hash), 0); - } - } - - SV* rv = &PL_sv_undef; - - if (!expedition_name.empty()) - { - rv = hash_ref ? sv_2mortal(hash_ref) : &PL_sv_undef; // ref that owns event hash for expedition - } - else - { - rv = sv_2mortal(newRV_noinc((SV*)hash)); // takes ownership of expedition hash - } - - ST(0) = rv; - XSRETURN(1); -} - -XS(XS__add_expedition_lockout_all_clients); -XS(XS__add_expedition_lockout_all_clients) { - dXSARGS; - if (items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: quest::add_expedition_lockout_all_clients(string expedition_name, string event_name, uint32 seconds, [string uuid])"); - } - - std::string expedition_name = SvPV_nolen(ST(0)); - std::string event_name = SvPV_nolen(ST(1)); - uint32_t seconds = static_cast(SvUV(ST(2))); - std::string uuid; - - if (items == 4) - { - uuid = SvPV_nolen(ST(3)); - } - - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid); - Expedition::AddLockoutClients(lockout); - - XSRETURN_EMPTY; -} - -XS(XS__add_expedition_lockout_by_char_id); -XS(XS__add_expedition_lockout_by_char_id) { - dXSARGS; - if (items != 4 && items != 5) { - Perl_croak(aTHX_ "Usage: quest::add_expedition_lockout_by_char_id(uint32 character_id, string expedition_name, string event_name, uint32 seconds, [string uuid])"); - } - - std::string uuid; - if (items == 5) - { - uuid = SvPV_nolen(ST(4)); - } - - uint32_t character_id = static_cast(SvUV(ST(0))); - std::string expedition_name = SvPV_nolen(ST(1)); - std::string event_name = SvPV_nolen(ST(2)); - uint32_t seconds = static_cast(SvUV(ST(3))); - - Expedition::AddLockoutByCharacterID(character_id, expedition_name, event_name, seconds, uuid); - - XSRETURN_EMPTY; -} - -XS(XS__remove_expedition_lockout_by_char_id); -XS(XS__remove_expedition_lockout_by_char_id) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: quest::remove_expedition_lockout_by_char_id(uint32 character_id, string expedition_name, string event_name)"); - } - - uint32_t character_id = static_cast(SvUV(ST(0))); - std::string expedition_name = SvPV_nolen(ST(1)); - std::string event_name = SvPV_nolen(ST(2)); - - Expedition::RemoveLockoutsByCharacterID(character_id, expedition_name, event_name); - - XSRETURN_EMPTY; -} - -XS(XS__remove_all_expedition_lockouts_by_char_id); -XS(XS__remove_all_expedition_lockouts_by_char_id) { - dXSARGS; - if (items != 1 && items != 2) { - Perl_croak(aTHX_ "Usage: quest::remove_expedition_lockout_by_char_id(uint32 character_id, [string expedition_name])"); - } - - std::string expedition_name; - if (items == 2) - { - expedition_name = SvPV_nolen(ST(1)); - } - - uint32_t character_id = static_cast(SvUV(ST(0))); - Expedition::RemoveLockoutsByCharacterID(character_id, expedition_name); - - XSRETURN_EMPTY; -} - -XS(XS__createitem); -XS(XS__createitem) { - dXSARGS; - if (items < 1 || items > 9) { - Perl_croak(aTHX_ "Usage: quest::createitem(uint32 item_id, [int16 charges = 0, uint32 augment_one = 0, uint32 augment_two = 0, uint32 augment_three = 0, uint32 augment_four = 0, uint32 augment_five = 0, uint32 augment_six = 0, bool attuned = false])"); - } - - EQ::ItemInstance* RETVAL = nullptr; - uint32 item_id = (uint32)SvUV(ST(0)); - int16 charges = 0; - uint32 augment_one = 0; - uint32 augment_two = 0; - uint32 augment_three = 0; - uint32 augment_four = 0; - uint32 augment_five = 0; - uint32 augment_six = 0; - bool attuned = false; - if (items > 1) - charges = (int16)SvIV(ST(1)); - if (items > 2) - augment_one = (uint32)SvUV(ST(2)); - if (items > 3) - augment_two = (uint32)SvUV(ST(3)); - if (items > 4) - augment_three = (uint32)SvUV(ST(4)); - if (items > 5) - augment_four = (uint32)SvUV(ST(5)); - if (items > 6) - augment_five = (uint32)SvUV(ST(6)); - if (items > 7) - augment_six = (uint32)SvUV(ST(7)); - if (items > 8) - attuned = (bool)SvNV(ST(8)); - - if (database.GetItem(item_id)) { - RETVAL = database.CreateItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six, attuned); - } - - ST(0) = sv_newmortal(); - if (RETVAL) { - sv_setref_pv(ST(0), "QuestItem", (void*)RETVAL); - } - XSRETURN(1); -} - -XS(XS__secondstotime); -XS(XS__secondstotime) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: quest::secondstotime(int duration)"); - } - - dXSTARG; - std::string time_string; - int duration = (int) SvIV(ST(0)); - time_string = quest_manager.secondstotime(duration); - sv_setpv(TARG, time_string.c_str()); - XSprePUSH; - PUSHTARG; - XSRETURN(1); -} - -XS(XS__gethexcolorcode); -XS(XS__gethexcolorcode) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: quest::gethexcolorcode(std::string color_name)"); - } - - dXSTARG; - std::string hex_color_code; - std::string color_name = SvPV_nolen(ST(0)); - hex_color_code = quest_manager.gethexcolorcode(color_name); - sv_setpv(TARG, hex_color_code.c_str()); - XSprePUSH; - PUSHTARG; - XSRETURN(1); -} - -XS(XS__getaaexpmodifierbycharid); -XS(XS__getaaexpmodifierbycharid) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: quest::getaaexpmodifierbycharid(uint32 character_id, uint32 zone_id)"); - - dXSTARG; - double aa_modifier; - uint32 character_id = (uint32) SvUV(ST(0)); - uint32 zone_id = (uint32) SvUV(ST(1)); - aa_modifier = quest_manager.GetAAEXPModifierByCharID(character_id, zone_id); - XSprePUSH; - PUSHn((double) aa_modifier); - XSRETURN(1); -} - -XS(XS__getexpmodifierbycharid); -XS(XS__getexpmodifierbycharid) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: quest::getexpmodifierbycharid(uint32 character_id, uint32 zone_id)"); - - dXSTARG; - double exp_modifier; - uint32 character_id = (uint32) SvUV(ST(0)); - uint32 zone_id = (uint32) SvUV(ST(1)); - exp_modifier = quest_manager.GetEXPModifierByCharID(character_id, zone_id); - XSprePUSH; - PUSHn((double) exp_modifier); - XSRETURN(1); -} - -XS(XS__setaaexpmodifierbycharid); -XS(XS__setaaexpmodifierbycharid) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: quest::setaaexpmodifierbycharid(uint32 character_id, uint32 zone_id, float aa_modifier)"); - } - uint32 character_id = (uint32) SvUV(ST(0)); - uint32 zone_id = (uint32) SvUV(ST(1)); - double aa_modifier = (double) SvNV(ST(2)); - quest_manager.SetAAEXPModifierByCharID(character_id, zone_id, aa_modifier); - XSRETURN_EMPTY; -} - -XS(XS__setexpmodifierbycharid); -XS(XS__setexpmodifierbycharid) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: quest::setexpmodifierbycharid(uint32 character_id, uint32 zone_id, float exp_modifier)"); - } - uint32 character_id = (uint32) SvUV(ST(0)); - uint32 zone_id = (uint32) SvUV(ST(1)); - double exp_modifier = (double) SvNV(ST(2)); - quest_manager.SetEXPModifierByCharID(character_id, zone_id, exp_modifier); - XSRETURN_EMPTY; -} - /* This is the callback perl will look for to setup the quest package's XSUBs @@ -6601,8 +6077,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "GetTimeSeconds"), XS__GetTimeSeconds, file); newXS(strcpy(buf, "GetZoneID"), XS__GetZoneID, file); newXS(strcpy(buf, "GetZoneLongName"), XS__GetZoneLongName, file); - newXS(strcpy(buf, "GetZoneLongNameByID"), XS__GetZoneLongNameByID, file); - newXS(strcpy(buf, "GetZoneShortName"), XS__GetZoneShortName, file); newXS(strcpy(buf, "set_rule"), XS__set_rule, file); newXS(strcpy(buf, "get_rule"), XS__get_rule, file); newXS(strcpy(buf, "get_data"), XS__get_data, file); @@ -6625,8 +6099,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "activespeakactivity"), XS__activespeakactivity, file); newXS(strcpy(buf, "activespeaktask"), XS__activespeaktask, file); newXS(strcpy(buf, "activetasksinset"), XS__activetasksinset, file); - newXS(strcpy(buf, "add_expedition_lockout_all_clients"), XS__add_expedition_lockout_all_clients, file); - newXS(strcpy(buf, "add_expedition_lockout_by_char_id"), XS__add_expedition_lockout_by_char_id, file); newXS(strcpy(buf, "addldonloss"), XS__addldonpoints, file); newXS(strcpy(buf, "addldonpoints"), XS__addldonpoints, file); newXS(strcpy(buf, "addldonwin"), XS__addldonpoints, file); @@ -6651,7 +6123,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "creategroundobject"), XS__CreateGroundObject, file); newXS(strcpy(buf, "creategroundobjectfrommodel"), XS__CreateGroundObjectFromModel, file); newXS(strcpy(buf, "createguild"), XS__createguild, file); - newXS(strcpy(buf, "createitem"), XS__createitem, file); newXS(strcpy(buf, "crosszoneassigntaskbycharid"), XS__crosszoneassigntaskbycharid, file); newXS(strcpy(buf, "crosszoneassigntaskbygroupid"), XS__crosszoneassigntaskbygroupid, file); newXS(strcpy(buf, "crosszoneassigntaskbyraidid"), XS__crosszoneassigntaskbyraidid, file); @@ -6687,7 +6158,7 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "crosszonemoveinstancebycharid"), XS__crosszonemoveinstancebycharid, file); newXS(strcpy(buf, "crosszonemoveinstancebygroupid"), XS__crosszonemoveinstancebygroupid, file); newXS(strcpy(buf, "crosszonemoveinstancebyraidid"), XS__crosszonemoveinstancebyraidid, file); - newXS(strcpy(buf, "crosszonemoveinstancebyguildid"), XS__crosszonemoveinstancebyguildid, file); + newXS(strcpy(buf, "crosszonemoveinstancebyguildid"), XS__crosszonemoveinstancebyguildid, file); newXS(strcpy(buf, "crosszoneremovespellbycharid"), XS__crosszoneremovespellbycharid, file); newXS(strcpy(buf, "crosszoneremovespellbygroupid"), XS__crosszoneremovespellbygroupid, file); newXS(strcpy(buf, "crosszoneremovespellbyraidid"), XS__crosszoneremovespellbyraidid, file); @@ -6759,18 +6230,9 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "follow"), XS__follow, file); newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file); newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file); - newXS(strcpy(buf, "getaaexpmodifierbycharid"), XS__getaaexpmodifierbycharid, file); newXS(strcpy(buf, "getcharidbyname"), XS__getcharidbyname, file); newXS(strcpy(buf, "getclassname"), XS__getclassname, file); - newXS(strcpy(buf, "gethexcolorcode"), XS__gethexcolorcode, file); newXS(strcpy(buf, "getcurrencyid"), XS__getcurrencyid, file); - newXS(strcpy(buf, "getexpmodifierbycharid"), XS__getexpmodifierbycharid, file); - newXS(strcpy(buf, "get_expedition"), XS__get_expedition, file); - newXS(strcpy(buf, "get_expedition_by_char_id"), XS__get_expedition_by_char_id, file); - newXS(strcpy(buf, "get_expedition_by_dz_id"), XS__get_expedition_by_dz_id, file); - newXS(strcpy(buf, "get_expedition_by_zone_instance"), XS__get_expedition_by_zone_instance, file); - newXS(strcpy(buf, "get_expedition_lockout_by_char_id"), XS__get_expedition_lockout_by_char_id, file); - newXS(strcpy(buf, "get_expedition_lockouts_by_char_id"), XS__get_expedition_lockouts_by_char_id, file); newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file); newXS(strcpy(buf, "getitemname"), XS__getitemname, file); newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file); @@ -6784,7 +6246,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "getraididbycharid"), XS__getraididbycharid, file); newXS(strcpy(buf, "getracename"), XS__getracename, file); newXS(strcpy(buf, "getspellname"), XS__getspellname, file); - newXS(strcpy(buf, "get_spell_level"), XS__get_spell_level, file); newXS(strcpy(buf, "getskillname"), XS__getskillname, file); newXS(strcpy(buf, "getlevel"), XS__getlevel, file); newXS(strcpy(buf, "getplayerburiedcorpsecount"), XS__getplayerburiedcorpsecount, file); @@ -6810,7 +6271,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "log"), XS__log, file); newXS(strcpy(buf, "log_combat"), XS__log_combat, file); newXS(strcpy(buf, "me"), XS__me, file); - newXS(strcpy(buf, "message"), XS__message, file); newXS(strcpy(buf, "modifynpcstat"), XS__ModifyNPCStat, file); newXS(strcpy(buf, "movegrp"), XS__movegrp, file); newXS(strcpy(buf, "movepc"), XS__movepc, file); @@ -6831,16 +6291,12 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "playersize"), XS__playersize, file); newXS(strcpy(buf, "playertexture"), XS__playertexture, file); newXS(strcpy(buf, "popup"), XS__popup, file); - newXS(strcpy(buf, "processmobswhilezoneempty"), XS__processmobswhilezoneempty, file); newXS(strcpy(buf, "pvp"), XS__pvp, file); newXS(strcpy(buf, "qs_player_event"), XS__qs_player_event, file); newXS(strcpy(buf, "qs_send_query"), XS__qs_send_query, file); newXS(strcpy(buf, "rain"), XS__rain, file); newXS(strcpy(buf, "rebind"), XS__rebind, file); newXS(strcpy(buf, "reloadzonestaticdata"), XS__reloadzonestaticdata, file); - newXS(strcpy(buf, "remove_all_expedition_lockouts_by_char_id"), XS__remove_all_expedition_lockouts_by_char_id, file); - newXS(strcpy(buf, "remove_expedition_lockout_by_char_id"), XS__remove_expedition_lockout_by_char_id, file); - newXS(strcpy(buf, "removeitem"), XS__removeitem, file); newXS(strcpy(buf, "removetitle"), XS__removetitle, file); newXS(strcpy(buf, "repopzone"), XS__repopzone, file); newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file); @@ -6851,14 +6307,11 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "say"), XS__say, file); newXS(strcpy(buf, "saylink"), XS__saylink, file); newXS(strcpy(buf, "scribespells"), XS__scribespells, file); - newXS(strcpy(buf, "secondstotime"), XS__secondstotime, file); newXS(strcpy(buf, "selfcast"), XS__selfcast, file); - newXS(strcpy(buf, "setaaexpmodifierbycharid"), XS__setaaexpmodifierbycharid, file); newXS(strcpy(buf, "set_proximity"), XS__set_proximity, file); newXS(strcpy(buf, "set_zone_flag"), XS__set_zone_flag, file); newXS(strcpy(buf, "setallskill"), XS__setallskill, file); newXS(strcpy(buf, "setanim"), XS__setanim, file); - newXS(strcpy(buf, "setexpmodifierbycharid"), XS__setexpmodifierbycharid, file); newXS(strcpy(buf, "setglobal"), XS__setglobal, file); newXS(strcpy(buf, "setguild"), XS__setguild, file); newXS(strcpy(buf, "sethp"), XS__sethp, file); @@ -6910,7 +6363,6 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "voicetell"), XS__voicetell, file); newXS(strcpy(buf, "we"), XS__we, file); newXS(strcpy(buf, "wearchange"), XS__wearchange, file); - newXS(strcpy(buf, "whisper"), XS__whisper, file); newXS(strcpy(buf, "write"), XS__write, file); newXS(strcpy(buf, "ze"), XS__ze, file); newXS(strcpy(buf, "zone"), XS__zone, file); diff --git a/zone/embperl.cpp b/zone/embperl.cpp index b05a429a1..c7ebb8060 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -32,13 +32,11 @@ EXTERN_C XS(boot_Corpse); EXTERN_C XS(boot_EntityList); EXTERN_C XS(boot_Group); EXTERN_C XS(boot_Raid); -EXTERN_C XS(boot_Inventory); EXTERN_C XS(boot_QuestItem); EXTERN_C XS(boot_HateEntry); EXTERN_C XS(boot_Object); EXTERN_C XS(boot_Doors); EXTERN_C XS(boot_PerlPacket); -EXTERN_C XS(boot_Expedition); #endif #endif @@ -85,12 +83,10 @@ EXTERN_C void xs_init(pTHX) newXS(strcpy(buf, "PerlPacket::boot_PerlPacket"), boot_PerlPacket, file); newXS(strcpy(buf, "Group::boot_Group"), boot_Group, file); newXS(strcpy(buf, "Raid::boot_Raid"), boot_Raid, file); - newXS(strcpy(buf, "Inventory::boot_Inventory"), boot_Inventory, file); newXS(strcpy(buf, "QuestItem::boot_QuestItem"), boot_QuestItem, file); newXS(strcpy(buf, "HateEntry::boot_HateEntry"), boot_HateEntry, file); newXS(strcpy(buf, "Object::boot_Object"), boot_Object, file); newXS(strcpy(buf, "Doors::boot_Doors"), boot_Doors, file); - newXS(strcpy(buf, "Expedition::boot_Expedition"), boot_Expedition, file); ; #endif #endif diff --git a/zone/entity.cpp b/zone/entity.cpp index 5cc12dc72..2c8216101 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -32,8 +32,6 @@ #include "../common/features.h" #include "../common/guilds.h" -#include "entity.h" -#include "dynamic_zone.h" #include "guild_mgr.h" #include "petitions.h" #include "quest_parser_collection.h" @@ -517,15 +515,13 @@ void EntityList::MobProcess() mob_settle_timer->Disable(); } - Spawn2* s2 = mob->CastToNPC()->respawn2; - - // Perform normal mob processing if any of these are true: - // -- zone is not empty - // -- a quest has turned it on for this zone while zone is idle - // -- the entity's spawn2 point is marked as path_while_zone_idle - // -- the zone is newly empty and we're allowing mobs to settle - if (zone->process_mobs_while_empty || numclients > 0 || - (s2 && s2->PathWhenZoneIdle()) || mob_settle_timer->Enabled()) { + if (numclients > 0 || + mob->GetWanderType() == 4 || mob->GetWanderType() == 6 || + mob_settle_timer->Enabled()) { + // Normal processing, or assuring that spawns that should + // path and depop do that. Otherwise all of these type mobs + // will be up and at starting positions, or waiting at the zoneline + // if they chased the PCs when idle zone wakes up. mob_dead = !mob->Process(); } else { @@ -604,8 +600,6 @@ void EntityList::EncounterProcess() auto it = encounter_list.begin(); while (it != encounter_list.end()) { if (!it->second->Process()) { - // if Process is returning false here, we probably just got called from ReloadQuests .. oh well - parse->RemoveEncounter(it->second->GetEncounterName()); safe_delete(it->second); free_ids.push(it->first); it = encounter_list.erase(it); @@ -718,8 +712,6 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) npc_list.insert(std::pair(npc->GetID(), npc)); mob_list.insert(std::pair(npc->GetID(), npc)); - entity_list.ScanCloseMobs(npc->close_mobs, npc, true); - /* Zone controller process EVENT_SPAWN_ZONE */ if (RuleB(Zone, UseZoneController)) { if (entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID) && npc->GetNPCTypeID() != ZONE_CONTROLLER_NPC_ID){ @@ -1330,8 +1322,8 @@ void EntityList::SendZoneSpawnsBulk(Client *client) const glm::vec4 &client_position = client->GetPosition(); const float distance_max = (600.0 * 600.0); - for (auto & it : mob_list) { - spawn = it.second; + for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { + spawn = it->second; if (spawn && spawn->GetID() > 0 && spawn->Spawned()) { if (!spawn->ShouldISpawnFor(client)) { continue; @@ -2484,7 +2476,7 @@ void EntityList::RemoveAllGroups() while (group_list.size()) { auto group = group_list.front(); group_list.pop_front(); - safe_delete(group); + delete group; } #if EQDEBUG >= 5 CheckGroupList (__FILE__, __LINE__); @@ -2496,7 +2488,7 @@ void EntityList::RemoveAllRaids() while (raid_list.size()) { auto raid = raid_list.front(); raid_list.pop_front(); - safe_delete(raid); + delete raid; } } @@ -2516,7 +2508,7 @@ void EntityList::DespawnAllDoors() auto outapp = new EQApplicationPacket(OP_RemoveAllDoors, 0); for (auto it = client_list.begin(); it != client_list.end(); ++it) { if (it->second) { - it->second->QueuePacket(outapp, true, Client::CLIENT_CONNECTED); + it->second->QueuePacket(outapp); } } safe_delete(outapp); @@ -2529,7 +2521,7 @@ void EntityList::RespawnAllDoors() if (it->second) { auto outapp = new EQApplicationPacket(); MakeDoorSpawnPacket(outapp, it->second); - it->second->FastQueuePacket(&outapp, true, Client::CLIENT_CONNECTED); + it->second->FastQueuePacket(&outapp); } ++it; } @@ -2569,7 +2561,6 @@ void EntityList::RemoveAllEncounters() { auto it = encounter_list.begin(); while (it != encounter_list.end()) { - parse->RemoveEncounter(it->second->GetEncounterName()); safe_delete(it->second); free_ids.push(it->first); it = encounter_list.erase(it); @@ -2699,36 +2690,6 @@ void EntityList::RemoveAuraFromMobs(Mob *aura) } /** - * The purpose of this system is so that we cache relevant entities that are "close" - * - * In general; it becomes incredibly expensive to run zone-wide checks against every single mob in the zone when in reality - * we only care about entities closest to us - * - * A very simple example of where this is relevant is Aggro, the below example is skewed because the overall implementation - * of Aggro was also tweaked in conjunction with close lists. We also scan more aggressively when entities are moving (1-6 seconds) - * versus 60 seconds when idle. We also have entities that are moving add themselves to those closest to them so that their close - * lists remain always up to date - * - * Before: Aggro checks for NPC to Client aggro | (40 clients in zone) x (525 npcs) x 2 (times a second) = 2,520,000 checks a minute - * After: Aggro checks for NPC to Client aggro | (40 clients in zone) x (20-30 npcs) x 2 (times a second) = 144,000 checks a minute (This is actually far less today) - * - * Places in the code where this logic makes a huge impact - * - * Aggro checks (zone wide -> close) - * Aura processing (zone wide -> close) - * AE Taunt (zone wide -> close) - * AOE Spells (zone wide -> close) - * Bard Pulse AOE (zone wide -> close) - * Mass Group Buff (zone wide -> close) - * AE Attack (zone wide -> close) - * Packet QueueCloseClients (zone wide -> close) - * Check Close Beneficial Spells (Buffs; should I heal other npcs) (zone wide -> close) - * AI Yell for Help (NPC Assist other NPCs) (zone wide -> close) - * - * All of the above makes a tremendous impact on the bottom line of cpu cycle performance because we run an order of magnitude - * less checks by focusing our hot path logic down to a very small subset of relevant entities instead of looping an entire - * entity list (zone wide) - * * @param close_mobs * @param scanning_mob */ @@ -2876,7 +2837,7 @@ bool EntityList::RemoveGroup(uint32 delete_id) } auto group = *it; group_list.erase(it); - safe_delete(group); + delete group; return true; } @@ -2888,7 +2849,7 @@ bool EntityList::RemoveRaid(uint32 delete_id) return false; auto raid = *it; raid_list.erase(it); - safe_delete(raid); + delete raid; return true; } @@ -3004,7 +2965,7 @@ void EntityList::Depop(bool StartSpawnTimer) if (own && own->IsClient()) continue; - if (pnpc->IsHorse()) + if (pnpc->IsHorse) continue; if (pnpc->IsFindable()) @@ -3609,21 +3570,18 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 hate) void EntityList::OpenDoorsNear(Mob *who) { - if (!who->CanOpenDoors()) { - return; - } - for (auto &it : door_list) { - Doors *door = it.second; - if (!door || door->IsDoorOpen()) { + for (auto it = door_list.begin();it != door_list.end(); ++it) { + Doors *cdoor = it->second; + if (!cdoor || cdoor->IsDoorOpen()) continue; - } - auto diff = who->GetPosition() - door->GetPosition(); - float distance = diff.x * diff.x + diff.y * diff.y; - if (diff.z * diff.z < 10 && distance <= 100) { - door->Open(who); - } + auto diff = who->GetPosition() - cdoor->GetPosition(); + + float curdist = diff.x * diff.x + diff.y * diff.y; + + if (diff.z * diff.z < 10 && curdist <= 100) + cdoor->Open(who); } } @@ -3909,24 +3867,22 @@ void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 langu void EntityList::SaveAllClientsTaskState() { - if (!task_manager) { + if (!taskmanager) return; - } auto it = client_list.begin(); while (it != client_list.end()) { Client *client = it->second; - if (client->IsTaskStateLoaded()) { + if (client->IsTaskStateLoaded()) client->SaveTaskState(); - } ++it; } } -void EntityList::ReloadAllClientsTaskState(int task_id) +void EntityList::ReloadAllClientsTaskState(int TaskID) { - if (!task_manager) + if (!taskmanager) return; auto it = client_list.begin(); @@ -3935,11 +3891,11 @@ void EntityList::ReloadAllClientsTaskState(int task_id) if (client->IsTaskStateLoaded()) { // If we have been passed a TaskID, only reload the client state if they have // that Task active. - if ((!task_id) || (task_id && client->IsTaskActive(task_id))) { + if ((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) { Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName()); client->RemoveClientTaskState(); client->LoadClientTaskState(); - task_manager->SendActiveTasksToClient(client); + taskmanager->SendActiveTasksToClient(client); } } ++it; @@ -4146,13 +4102,8 @@ void EntityList::AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy) NPC* n = it->second; if (n->GetSwarmInfo()) { if (n->GetSwarmInfo()->owner_id == owner->GetID()) { - if ( - !n->GetSpecialAbility(IMMUNE_AGGRO) && - !(n->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && other->IsClient()) && - !(n->GetSpecialAbility(IMMUNE_AGGRO_NPC) && other->IsNPC()) - ) { + if (!n->GetSpecialAbility(IMMUNE_AGGRO)) n->hate_list.AddEntToHateList(other, 0, 0, bFrenzy); - } } } ++it; @@ -5236,8 +5187,6 @@ void EntityList::ReloadMerchants() { * If we have a distance requested that is greater than our scanning distance * then we return the full list * - * See comments @EntityList::ScanCloseMobs for system explanation - * * @param mob * @param distance * @return @@ -5251,56 +5200,3 @@ std::unordered_map &EntityList::GetCloseMobList(Mob *mob, float d return mob_list; } -void EntityList::GateAllClientsToSafeReturn() -{ - DynamicZone* dz = zone ? zone->GetDynamicZone() : nullptr; - - for (const auto& client_list_iter : client_list) - { - if (client_list_iter.second) - { - // falls back to gating clients to bind if dz invalid - client_list_iter.second->GoToDzSafeReturnOrBind(dz); - } - } -} - -int EntityList::MovePlayerCorpsesToGraveyard(bool force_move_from_instance) -{ - if (!zone) - { - return 0; - } - - int moved_count = 0; - - for (auto it = corpse_list.begin(); it != corpse_list.end();) - { - bool moved = false; - if (it->second && it->second->IsPlayerCorpse()) - { - if (zone->HasGraveyard()) - { - moved = it->second->MovePlayerCorpseToGraveyard(); - } - else if (force_move_from_instance && zone->GetInstanceID() != 0) - { - moved = it->second->MovePlayerCorpseToNonInstance(); - } - } - - if (moved) - { - safe_delete(it->second); - free_ids.push(it->first); - it = corpse_list.erase(it); - ++moved_count; - } - else - { - ++it; - } - } - - return moved_count; -} diff --git a/zone/entity.h b/zone/entity.h index b4855b42e..3815f3c50 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -49,7 +49,6 @@ class Raid; class Spawn2; class Trap; -struct DynamicZoneSafeReturn; struct GuildBankItemUpdate_Struct; struct NewSpawn_Struct; struct QGlobal; @@ -482,7 +481,7 @@ public: void SendGroupJoin(uint32 gid, const char *name); void SaveAllClientsTaskState(); - void ReloadAllClientsTaskState(int task_id=0); + void ReloadAllClientsTaskState(int TaskID=0); uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000); uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0); uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100); @@ -497,8 +496,6 @@ public: void UpdateFindableNPCState(NPC *n, bool Remove); void HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode); - void GateAllClientsToSafeReturn(); - uint16 GetClientCount(); void GetMobList(std::list &m_list); void GetNPCList(std::list &n_list); @@ -537,8 +534,6 @@ public: void UpdateAllTraps(bool respawn, bool repopnow = false); void ClearTrapPointers(); - int MovePlayerCorpsesToGraveyard(bool force_move_from_instance = false); - protected: friend class Zone; void Depop(bool StartSpawnTimer = false); diff --git a/zone/exp.cpp b/zone/exp.cpp index 9b4df5492..1a314b479 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -194,10 +194,6 @@ uint32 Client::CalcEXP(uint8 conlevel) { } } - if (RuleR(Character, FinalExpMultiplier) >= 0) { - in_add_exp *= RuleR(Character, FinalExpMultiplier); - } - return in_add_exp; } @@ -215,15 +211,7 @@ uint32 Client::GetExperienceForKill(Mob *against) if (against && against->IsNPC()) { uint32 level = (uint32)against->GetLevel(); - uint32 ret = EXP_FORMULA; - - auto mod = against->GetKillExpMod(); - if(mod >= 0) { - ret *= mod; - ret /= 100; - } - - return ret; + return EXP_FORMULA; } return 0; @@ -323,14 +311,6 @@ void Client::CalculateStandardAAExp(uint32 &add_aaxp, uint8 conlevel, bool resex } } - if (RuleR(Character, FinalExpMultiplier) >= 0) { - add_aaxp *= RuleR(Character, FinalExpMultiplier); - } - - if (RuleB(Character, EnableCharacterEXPMods)) { - add_aaxp *= GetAAEXPModifier(this->GetZoneID()); - } - add_aaxp = (uint32)(RuleR(Character, AAExpMultiplier) * add_aaxp * aatotalmod); } @@ -486,14 +466,6 @@ void Client::CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp, } } - if (RuleR(Character, FinalExpMultiplier) >= 0) { - add_exp *= RuleR(Character, FinalExpMultiplier); - } - - if (RuleB(Character, EnableCharacterEXPMods)) { - add_exp *= GetEXPModifier(this->GetZoneID()); - } - add_exp = GetEXP() + add_exp; } @@ -591,22 +563,22 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { } if (isrezzexp) { - if (RuleI(Character, ShowExpValues) > 0) + if (RuleI(Character, ShowExpValues) > 0) Message(Chat::Experience, "You regain %s experience from resurrection. %s", exp_amount_message.c_str(), exp_percent_message.c_str()); else MessageString(Chat::Experience, REZ_REGAIN); } else { if (membercount > 1) { - if (RuleI(Character, ShowExpValues) > 0) + if (RuleI(Character, ShowExpValues) > 0) Message(Chat::Experience, "You have gained %s party experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str()); else MessageString(Chat::Experience, GAIN_GROUPXP); } else if (IsRaidGrouped()) { - if (RuleI(Character, ShowExpValues) > 0) + if (RuleI(Character, ShowExpValues) > 0) Message(Chat::Experience, "You have gained %s raid experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str()); else MessageString(Chat::Experience, GAIN_RAIDEXP); - } + } else { - if (RuleI(Character, ShowExpValues) > 0) + if (RuleI(Character, ShowExpValues) > 0) Message(Chat::Experience, "You have gained %s experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str()); else MessageString(Chat::Experience, GAIN_XP); } @@ -680,22 +652,15 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { m_pp.aapoints += last_unspentAA; //figure out how many points were actually gained - uint32 gained = (m_pp.aapoints - last_unspentAA); + /*uint32 gained = m_pp.aapoints - last_unspentAA;*/ //unused //Message(Chat::Yellow, "You have gained %d skill points!!", m_pp.aapoints - last_unspentAA); - char val1[20] = { 0 }; - char val2[20] = { 0 }; - if (gained == 1 && m_pp.aapoints == 1) - MessageString(Chat::Experience, GAIN_SINGLE_AA_SINGLE_AA, ConvertArray(m_pp.aapoints, val1)); //You have gained an ability point! You now have %1 ability point. - else if (gained == 1 && m_pp.aapoints > 1) - MessageString(Chat::Experience, GAIN_SINGLE_AA_MULTI_AA, ConvertArray(m_pp.aapoints, val1)); //You have gained an ability point! You now have %1 ability points. - else - MessageString(Chat::Experience, GAIN_MULTI_AA_MULTI_AA, ConvertArray(gained, val1), ConvertArray(m_pp.aapoints, val2)); //You have gained %1 ability point(s)! You now have %2 ability point(s). - + char val1[20]={0}; + MessageString(Chat::Experience, GAIN_ABILITY_POINT, ConvertArray(m_pp.aapoints, val1),m_pp.aapoints == 1 ? "" : "(s)"); //You have gained an ability point! You now have %1 ability point%2. if (RuleB(AA, SoundForAAEarned)) { SendSound(); } - + /* QS: PlayerLogAARate */ if (RuleB(QueryServ, PlayerLogAARate)){ int add_points = (m_pp.aapoints - last_unspentAA); @@ -741,8 +706,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { else Message(Chat::Yellow, "Welcome to level %i!", check_level); - if (check_level == RuleI(Character, DeathItemLossLevel) && - m_ClientVersionBit & EQ::versions::maskUFAndEarlier) + if (check_level == RuleI(Character, DeathItemLossLevel)) MessageString(Chat::Yellow, CORPSE_ITEM_LOST); if (check_level == RuleI(Character, DeathExpLossLevel)) @@ -837,7 +801,7 @@ void Client::SetLevel(uint8 set_level, bool command) /* QS: PlayerLogLevels */ if (RuleB(QueryServ, PlayerLogLevels)){ std::string event_desc = StringFormat("Leveled UP :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID()); - QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc); + QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc); } } else if (set_level < m_pp.level){ @@ -875,7 +839,7 @@ void Client::SetLevel(uint8 set_level, bool command) SetHP(CalcMaxHP()); // Why not, lets give them a free heal } - if (RuleI(World, PVPMinLevel) > 0 && level >= RuleI(World, PVPMinLevel) && m_pp.pvp == 0) SetPVP(true); + if (RuleI(World, PVPMinLevel) > 0 && level >= RuleI(World, PVPMinLevel) && m_pp.pvp == 0) SetPVP(true); DoTributeUpdate(); SendHPUpdate(); @@ -979,34 +943,32 @@ uint32 Client::GetEXPForLevel(uint16 check_level) return finalxp; } -void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods) -{ +void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods) +{ uint32 award; uint32 xp_for_level; - if (exp_percentage > 100) - { - exp_percentage = 100; - } + if (exp_percentage > 100) + { + exp_percentage = 100; + } if (!max_level || GetLevel() < max_level) - { - max_level = GetLevel(); - } + { + max_level = GetLevel(); + } xp_for_level = GetEXPForLevel(max_level + 1) - GetEXPForLevel(max_level); - award = xp_for_level * exp_percentage / 100; + award = xp_for_level * exp_percentage / 100; - if (RuleB(Zone, LevelBasedEXPMods) && !ignore_mods) { - if (zone->level_exp_mod[GetLevel()].ExpMod) { + if(RuleB(Zone, LevelBasedEXPMods) && !ignore_mods) + { + if(zone->level_exp_mod[GetLevel()].ExpMod) + { award *= zone->level_exp_mod[GetLevel()].ExpMod; } } - if (RuleR(Character, FinalExpMultiplier) >= 0) { - award *= RuleR(Character, FinalExpMultiplier); - } - uint32 newexp = GetEXP() + award; SetEXP(newexp, GetAAXP()); } @@ -1164,7 +1126,7 @@ uint32 Client::GetCharMaxLevelFromQGlobal() { while(iter != globalMap.end()) { if((*iter).name.compare("CharMaxLevel") == 0){ return atoi((*iter).value.c_str()); - } + } ++iter; ++gcount; } diff --git a/zone/expedition.cpp b/zone/expedition.cpp deleted file mode 100644 index cb6fa4199..000000000 --- a/zone/expedition.cpp +++ /dev/null @@ -1,2037 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition.h" -#include "expedition_database.h" -#include "expedition_request.h" -#include "client.h" -#include "string_ids.h" -#include "worldserver.h" -#include "zonedb.h" -#include "../common/eqemu_logsys.h" -#include "../common/expedition_lockout_timer.h" -#include "../common/repositories/expedition_lockouts_repository.h" -#include "../common/repositories/expedition_members_repository.h" -#include "../common/util/uuid.h" - -extern WorldServer worldserver; -extern Zone* zone; - -// message string 8271 (not in emu clients) -const char* const DZ_YOU_NOT_ASSIGNED = "You could not use this command because you are not currently assigned to a dynamic zone."; -// message string 9265 (not in emu clients) -const char* const EXPEDITION_OTHER_BELONGS = "{} attempted to create an expedition but {} already belongs to one."; -// lockout warnings were added to live in March 11 2020 patch -const char* const DZADD_INVITE_WARNING = "Warning! You will be given replay timers for the following events if you enter %s:"; -const char* const DZADD_INVITE_WARNING_TIMER = "%s - %sD:%sH:%sM"; -// various expeditions re-use these strings when locking -constexpr char LOCK_CLOSE[] = "Your expedition is nearing its close. You cannot bring any additional people into your expedition at this time."; -constexpr char LOCK_BEGIN[] = "The trial has begun. You cannot bring any additional people into your expedition at this time."; - -const int32_t Expedition::REPLAY_TIMER_ID = -1; -const int32_t Expedition::EVENT_TIMER_ID = 1; - -Expedition::Expedition( - uint32_t id, const std::string& uuid, DynamicZone&& dz, const std::string& expedition_name, - const DynamicZoneMember& leader -) : ExpeditionBase(id, uuid, expedition_name, leader) -{ - SetDynamicZone(std::move(dz)); -} - -void Expedition::SetDynamicZone(DynamicZone&& dz) -{ - dz.SetName(GetName()); - dz.SetLeaderName(GetLeaderName()); - - m_dynamiczone = std::move(dz); - m_dynamiczone.RegisterOnCompassChange([this]() { SendCompassUpdateToZoneMembers(); }); -} - -Expedition* Expedition::TryCreate( - Client* requester, DynamicZone& dynamiczone, ExpeditionRequest& request) -{ - if (!requester || !zone) - { - return nullptr; - } - - // request parses leader, members list, and lockouts while validating - if (!request.Validate(requester)) - { - LogExpeditionsModerate("[{}] request by [{}] denied", request.GetExpeditionName(), requester->GetName()); - return nullptr; - } - - dynamiczone.SetMinPlayers(request.GetMinPlayers()); - dynamiczone.SetMaxPlayers(request.GetMaxPlayers()); - - auto dynamic_zone_id = dynamiczone.Create(); - if (dynamic_zone_id == 0) - { - // live uses this message when trying to enter an instance that isn't ready - // we can use it as the client error message if instance creation fails - requester->MessageString(Chat::Red, DZ_PREVENT_ENTERING); - LogExpeditions("Failed to create a dynamic zone instance for expedition"); - return nullptr; - } - - std::string expedition_uuid = EQ::Util::UUID::Generate().ToString(); - - // unique expedition ids are created from database via auto-increment column - auto expedition_id = ExpeditionDatabase::InsertExpedition( - expedition_uuid, - dynamiczone.GetID(), - request.GetExpeditionName(), - request.GetLeaderID(), - request.GetMinPlayers(), - request.GetMaxPlayers() - ); - - if (expedition_id) - { - auto expedition = std::make_unique( - expedition_id, - expedition_uuid, - std::move(dynamiczone), - request.GetExpeditionName(), - DynamicZoneMember{ request.GetLeaderID(), request.GetLeaderName() } - ); - - LogExpeditions( - "Created [{}] [{}] instance id: [{}] leader: [{}] minplayers: [{}] maxplayers: [{}]", - expedition->GetID(), - expedition->GetName(), - expedition->GetDynamicZone().GetInstanceID(), - expedition->GetLeaderName(), - expedition->GetDynamicZone().GetMinPlayers(), - expedition->GetDynamicZone().GetMaxPlayers() - ); - - expedition->SaveMembers(request); - expedition->SaveLockouts(request); - - auto inserted = zone->expedition_cache.emplace(expedition_id, std::move(expedition)); - - inserted.first->second->SendUpdatesToZoneMembers(); - inserted.first->second->SendWorldExpeditionUpdate(ServerOP_ExpeditionCreate); // cache in other zones - inserted.first->second->SendLeaderMessage(request.GetLeaderClient(), - Chat::System, EXPEDITION_AVAILABLE, { request.GetExpeditionName() }); - - if (!request.GetNotAllAddedMessage().empty()) - { - Client::SendCrossZoneMessage(request.GetLeaderClient(), request.GetLeaderName(), - Chat::System, request.GetNotAllAddedMessage()); - } - - return inserted.first->second.get(); - } - - return nullptr; -} - -void Expedition::CacheExpeditions( - std::vector&& expedition_entries) -{ - if (!zone) - { - return; - } - - // bulk load expedition dzs, members, and internal lockouts before caching - std::vector expedition_ids; - std::vector dynamic_zone_ids; - for (const auto& entry : expedition_entries) - { - expedition_ids.emplace_back(entry.id); - dynamic_zone_ids.emplace_back(entry.dynamic_zone_id); - } - - auto dynamic_zones = DynamicZonesRepository::GetWithInstance(database, dynamic_zone_ids); - auto expedition_members = ExpeditionMembersRepository::GetWithNames(database, expedition_ids); - auto expedition_lockouts = ExpeditionLockoutsRepository::GetWithTimestamp(database, expedition_ids); - - for (auto& entry : expedition_entries) - { - auto expedition = std::make_unique(); - expedition->LoadRepositoryResult(std::move(entry)); - - auto dz_entry_iter = std::find_if(dynamic_zones.begin(), dynamic_zones.end(), - [&](const DynamicZonesRepository::DynamicZoneInstance& dz_entry) { - return dz_entry.id == entry.dynamic_zone_id; - }); - - if (dz_entry_iter != dynamic_zones.end()) - { - expedition->SetDynamicZone(std::move(*dz_entry_iter)); - } - - for (auto& member : expedition_members) - { - if (member.expedition_id == expedition->GetID()) - { - expedition->AddMemberFromRepositoryResult(std::move(member)); - } - } - - for (auto& lockout_entry : expedition_lockouts) - { - if (lockout_entry.expedition_id == expedition->GetID()) - { - ExpeditionLockoutTimer lockout{ - std::move(lockout_entry.from_expedition_uuid), - expedition->GetName(), - std::move(lockout_entry.event_name), - static_cast(lockout_entry.expire_time), - static_cast(lockout_entry.duration) - }; - - std::string event_name = lockout.GetEventName(); // copy for key since we're moving it - expedition->m_lockouts.emplace(std::move(event_name), std::move(lockout)); - } - } - - // stored on expedition in db but on dz in memory cache - expedition->GetDynamicZone().SetMinPlayers(entry.min_players); - expedition->GetDynamicZone().SetMaxPlayers(entry.max_players); - - expedition->SendWorldExpeditionUpdate(ServerOP_ExpeditionGetMemberStatuses); - - auto inserted = zone->expedition_cache.emplace(entry.id, std::move(expedition)); - inserted.first->second->SendUpdatesToZoneMembers(); - } -} - -void Expedition::CacheFromDatabase(uint32_t expedition_id) -{ - if (zone && expedition_id != 0) - { - BenchTimer benchmark; - - auto expedition = ExpeditionsRepository::GetWithLeaderName(database, expedition_id); - CacheExpeditions({ std::move(expedition) }); - - LogExpeditions("Caching new expedition [{}] took [{}s]", expedition_id, benchmark.elapsed()); - } -} - -bool Expedition::CacheAllFromDatabase() -{ - if (!zone) - { - return false; - } - - BenchTimer benchmark; - - auto expeditions = ExpeditionsRepository::GetAllWithLeaderName(database); - zone->expedition_cache.clear(); - zone->expedition_cache.reserve(expeditions.size()); - - CacheExpeditions(std::move(expeditions)); - - LogExpeditions("Caching [{}] expedition(s) took [{}s]", zone->expedition_cache.size(), benchmark.elapsed()); - - return true; -} - -void Expedition::SaveLockouts(ExpeditionRequest& request) -{ - m_lockouts = request.GetLockouts(); - ExpeditionDatabase::InsertLockouts(m_id, m_lockouts); -} - -void Expedition::SaveMembers(ExpeditionRequest& request) -{ - m_members = request.GetMembers(); - - std::vector member_ids; - for (const auto& member : m_members) - { - member_ids.emplace_back(member.id); - } - - ExpeditionDatabase::InsertMembers(m_id, m_members); - m_dynamiczone.SaveInstanceMembersToDatabase(member_ids); -} - -Expedition* Expedition::FindCachedExpeditionByCharacterID(uint32_t character_id) -{ - if (zone) - { - for (const auto& expedition : zone->expedition_cache) - { - if (expedition.second->HasMember(character_id)) - { - return expedition.second.get(); - } - } - } - return nullptr; -} - -Expedition* Expedition::FindCachedExpeditionByCharacterName(const std::string& char_name) -{ - if (zone) - { - for (const auto& expedition : zone->expedition_cache) - { - if (expedition.second->HasMember(char_name)) - { - return expedition.second.get(); - } - } - } - return nullptr; -} - -Expedition* Expedition::FindCachedExpeditionByDynamicZoneID(uint32_t dz_id) -{ - if (zone && dz_id != 0) - { - for (const auto& cached_expedition : zone->expedition_cache) - { - if (cached_expedition.second->GetDynamicZone().GetID() == dz_id) - { - return cached_expedition.second.get(); - } - } - } - return nullptr; -} - -Expedition* Expedition::FindCachedExpeditionByID(uint32_t expedition_id) -{ - if (zone && expedition_id) - { - auto expedition_cache_iter = zone->expedition_cache.find(expedition_id); - if (expedition_cache_iter != zone->expedition_cache.end()) - { - return expedition_cache_iter->second.get(); - } - } - return nullptr; -} - -Expedition* Expedition::FindCachedExpeditionByZoneInstance(uint32_t zone_id, uint32_t instance_id) -{ - if (zone && zone_id != 0 && instance_id != 0) - { - for (const auto& cached_expedition : zone->expedition_cache) - { - if (cached_expedition.second->GetDynamicZone().GetZoneID() == zone_id && - cached_expedition.second->GetDynamicZone().GetInstanceID() == instance_id) - { - return cached_expedition.second.get(); - } - } - } - return nullptr; -} - -bool Expedition::HasLockout(const std::string& event_name) -{ - return (m_lockouts.find(event_name) != m_lockouts.end()); -} - -bool Expedition::HasReplayLockout() -{ - return HasLockout(DZ_REPLAY_TIMER_NAME); -} - -void Expedition::SetReplayLockoutOnMemberJoin(bool add_on_join, bool update_db) -{ - m_add_replay_on_join = add_on_join; - - if (update_db) - { - ExpeditionDatabase::UpdateReplayLockoutOnJoin(m_id, add_on_join); - SendWorldSettingChanged(ServerOP_ExpeditionReplayOnJoin, m_add_replay_on_join); - } -} - -void Expedition::AddReplayLockout(uint32_t seconds) -{ - AddLockout(DZ_REPLAY_TIMER_NAME, seconds); -} - -void Expedition::AddLockout(const std::string& event_name, uint32_t seconds) -{ - auto lockout = ExpeditionLockoutTimer::CreateLockout(m_expedition_name, event_name, seconds, m_uuid); - AddLockout(lockout); -} - -void Expedition::AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only) -{ - if (!members_only) - { - ExpeditionDatabase::InsertLockout(m_id, lockout); - } - ExpeditionDatabase::InsertMembersLockout(m_members, lockout); - - ProcessLockoutUpdate(lockout, false, members_only); - SendWorldLockoutUpdate(lockout, false, members_only); -} - -void Expedition::AddLockoutDuration(const std::string& event_name, int seconds, bool members_only) -{ - // lockout timers use unsigned durations to define intent but we may need - // to insert a new lockout while still supporting timer reductions - auto lockout = ExpeditionLockoutTimer::CreateLockout( - m_expedition_name, event_name, std::max(0, seconds), m_uuid); - - if (!members_only) - { - auto it = m_lockouts.find(event_name); - if (it != m_lockouts.end()) - { - it->second.AddLockoutTime(seconds); - ExpeditionDatabase::InsertLockout(m_id, it->second); // replaces current one - } - else - { - ExpeditionDatabase::InsertLockout(m_id, lockout); - } - } - - // processing lockout duration applies multiplier again in client methods, - // update database with modified value now but pass original on - int modified_seconds = static_cast(seconds * RuleR(Expedition, LockoutDurationMultiplier)); - ExpeditionDatabase::AddLockoutDuration(m_members, lockout, modified_seconds); - - ProcessLockoutDuration(lockout, seconds, members_only); - SendWorldLockoutDuration(lockout, seconds, members_only); -} - -void Expedition::AddReplayLockoutDuration(int seconds, bool members_only) -{ - AddLockoutDuration(DZ_REPLAY_TIMER_NAME, seconds, members_only); -} - -void Expedition::UpdateLockoutDuration( - const std::string& event_name, uint32_t seconds, bool members_only) -{ - // some live expeditions update existing lockout timers during progression - auto it = m_lockouts.find(event_name); - if (it != m_lockouts.end()) - { - seconds = static_cast(seconds * RuleR(Expedition, LockoutDurationMultiplier)); - - uint64_t expire_time = it->second.GetStartTime() + seconds; - AddLockout({ m_uuid, m_expedition_name, event_name, expire_time, seconds }, members_only); - } -} - -void Expedition::RemoveLockout(const std::string& event_name) -{ - ExpeditionDatabase::DeleteLockout(m_id, event_name); - ExpeditionDatabase::DeleteMembersLockout(m_members, m_expedition_name, event_name); - - ExpeditionLockoutTimer lockout{m_uuid, m_expedition_name, event_name, 0, 0}; - ProcessLockoutUpdate(lockout, true); - SendWorldLockoutUpdate(lockout, true); -} - -bool Expedition::AddMember(const std::string& add_char_name, uint32_t add_char_id) -{ - if (HasMember(add_char_id)) - { - return false; - } - - ExpeditionDatabase::InsertMember(m_id, add_char_id); - m_dynamiczone.AddCharacter(add_char_id); - - ProcessMemberAdded(add_char_name, add_char_id); - SendWorldMemberChanged(add_char_name, add_char_id, false); - - return true; -} - -void Expedition::RemoveAllMembers(bool enable_removal_timers) -{ - m_dynamiczone.RemoveAllCharacters(enable_removal_timers); - - ExpeditionDatabase::DeleteAllMembers(m_id); - - SendUpdatesToZoneMembers(true); - SendWorldExpeditionUpdate(ServerOP_ExpeditionMembersRemoved); - - m_members.clear(); -} - -bool Expedition::RemoveMember(const std::string& remove_char_name) -{ - auto member = GetMemberData(remove_char_name); - if (!member.IsValid()) - { - return false; - } - - ExpeditionDatabase::DeleteMember(m_id, member.id); - m_dynamiczone.RemoveCharacter(member.id); - - ProcessMemberRemoved(member.name, member.id); - SendWorldMemberChanged(member.name, member.id, true); - - return true; -} - -void Expedition::SwapMember(Client* add_client, const std::string& remove_char_name) -{ - if (!add_client || remove_char_name.empty()) - { - return; - } - - auto member = GetMemberData(remove_char_name); - if (!member.IsValid()) - { - return; - } - - // make remove and add atomic to avoid racing with separate world messages - ExpeditionDatabase::DeleteMember(m_id, member.id); - ExpeditionDatabase::InsertMember(m_id, add_client->CharacterID()); - m_dynamiczone.RemoveCharacter(member.id); - m_dynamiczone.AddCharacter(add_client->CharacterID()); - - ProcessMemberRemoved(member.name, member.id); - ProcessMemberAdded(add_client->GetName(), add_client->CharacterID()); - SendWorldMemberSwapped(member.name, member.id, add_client->GetName(), add_client->CharacterID()); -} - -void Expedition::SetMemberStatus(Client* client, DynamicZoneMemberStatus status) -{ - if (client) - { - SendMemberStatusToZoneMembers(client->CharacterID(), status); - SendWorldMemberStatus(client->CharacterID(), status); - } -} - -void Expedition::SendMemberStatusToZoneMembers(uint32_t update_member_id, DynamicZoneMemberStatus status) -{ - auto member_data = GetMemberData(update_member_id); - if (!member_data.IsValid()) - { - return; - } - - // if zone already had this member status cached avoid packet update to clients - bool changed = SetInternalMemberStatus(update_member_id, status); - if (changed) - { - member_data = GetMemberData(update_member_id); // rules may override status - auto outapp_member_status = CreateMemberListStatusPacket(member_data.name, member_data.status); - for (auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->QueuePacket(outapp_member_status.get()); - } - } - } -} - -void Expedition::SendClientExpeditionInvite( - Client* client, const std::string& inviter_name, const std::string& swap_remove_name) -{ - if (!client) - { - return; - } - - LogExpeditionsModerate( - "Sending expedition [{}] invite to player [{}] inviter [{}] swap name [{}]", - m_id, client->GetName(), inviter_name, swap_remove_name - ); - - client->SetPendingExpeditionInvite({ m_id, inviter_name, swap_remove_name }); - - client->MessageString(Chat::System, EXPEDITION_ASKED_TO_JOIN, - m_leader.name.c_str(), m_expedition_name.c_str()); - - // live (as of March 11 2020 patch) sends warnings for lockouts added - // during current expedition that client would receive on entering dz - bool warned = false; - for (const auto& lockout_iter : m_lockouts) - { - // live doesn't issue a warning for the dz's replay timer - const ExpeditionLockoutTimer& lockout = lockout_iter.second; - if (!lockout.IsReplayTimer() && !lockout.IsExpired() && lockout.IsFromExpedition(m_uuid) && - !client->HasExpeditionLockout(m_expedition_name, lockout.GetEventName())) - { - if (!warned) - { - client->Message(Chat::System, DZADD_INVITE_WARNING, m_expedition_name.c_str()); - warned = true; - } - - auto time_remaining = lockout.GetDaysHoursMinutesRemaining(); - client->Message( - Chat::System, DZADD_INVITE_WARNING_TIMER, - lockout.GetEventName().c_str(), - time_remaining.days.c_str(), - time_remaining.hours.c_str(), - time_remaining.mins.c_str() - ); - } - } - - auto outapp = CreateInvitePacket(inviter_name, swap_remove_name); - client->QueuePacket(outapp.get()); -} - -void Expedition::SendLeaderMessage( - Client* leader_client, uint16_t chat_type, uint32_t string_id, const std::initializer_list& args) -{ - Client::SendCrossZoneMessageString(leader_client, m_leader.name, chat_type, string_id, args); -} - -bool Expedition::ProcessAddConflicts(Client* leader_client, Client* add_client, bool swapping) -{ - if (!add_client) // a null leader_client is handled by SendLeaderMessage fallback - { - return true; - } - - bool has_conflict = false; - - if (m_dynamiczone.IsCurrentZoneDzInstance()) - { - SendLeaderMessage(leader_client, Chat::Red, DZADD_LEAVE_ZONE_FIRST, { add_client->GetName() }); - has_conflict = true; - } - - auto expedition_id = add_client->GetExpeditionID(); - if (expedition_id) - { - auto string_id = (expedition_id == GetID()) ? DZADD_ALREADY_PART : DZADD_ALREADY_ASSIGNED; - SendLeaderMessage(leader_client, Chat::Red, string_id, { add_client->GetName() }); - has_conflict = true; - } - - // check any extra event lockouts for this expedition that the client has and expedition doesn't - auto client_lockouts = add_client->GetExpeditionLockouts(m_expedition_name); - for (const auto& client_lockout : client_lockouts) - { - if (client_lockout.IsReplayTimer()) - { - // client with a replay lockout is allowed only if the replay timer was from this expedition - if (client_lockout.GetExpeditionUUID() != GetUUID()) - { - has_conflict = true; - - auto time_remaining = client_lockout.GetDaysHoursMinutesRemaining(); - SendLeaderMessage(leader_client, Chat::Red, DZADD_REPLAY_TIMER, { - add_client->GetName(), - time_remaining.days, - time_remaining.hours, - time_remaining.mins - }); - } - } - else - { - bool is_missing_lockout = (m_lockouts.find(client_lockout.GetEventName()) == m_lockouts.end()); - if (is_missing_lockout) - { - has_conflict = true; - - auto time_remaining = client_lockout.GetDaysHoursMinutesRemaining(); - SendLeaderMessage(leader_client, Chat::Red, DZADD_EVENT_TIMER, { - add_client->GetName(), - client_lockout.GetEventName(), - time_remaining.days, - time_remaining.hours, - time_remaining.mins, - client_lockout.GetEventName() - }); - } - } - } - - // member swapping integrity is handled by invite response - if (!swapping) - { - auto member_count = ExpeditionDatabase::GetMemberCount(m_id); - if (member_count == 0) - { - has_conflict = true; - } - else if (member_count >= GetDynamicZone().GetMaxPlayers()) - { - SendLeaderMessage(leader_client, Chat::Red, DZADD_EXCEED_MAX, { - fmt::format_int(GetDynamicZone().GetMaxPlayers()).str() }); - has_conflict = true; - } - } - - auto invite_id = add_client->GetPendingExpeditionInviteID(); - if (invite_id) - { - auto string_id = (invite_id == GetID()) ? DZADD_PENDING : DZADD_PENDING_OTHER; - SendLeaderMessage(leader_client, Chat::Red, string_id, { add_client->GetName() }); - has_conflict = true; - } - - return has_conflict; -} - -void Expedition::DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name) -{ - if (!add_client) - { - return; - } - - LogExpeditionsModerate( - "Invite response by [{}] accepted [{}] swap_name [{}]", - add_client->GetName(), accepted, swap_remove_name - ); - - // a null leader_client is handled by SendLeaderMessage fallbacks - // note current leader receives invite reply messages (if leader changed) - Client* leader_client = entity_list.GetClientByCharID(m_leader.id); - - if (!accepted) - { - SendLeaderMessage(leader_client, Chat::Red, EXPEDITION_INVITE_DECLINED, { add_client->GetName() }); - return; - } - - bool was_swap_invite = !swap_remove_name.empty(); - bool has_conflicts = m_is_locked; - - if (m_is_locked) - { - SendLeaderMessage(leader_client, Chat::Red, DZADD_NOT_ALLOWING); - } - else - { - has_conflicts = ProcessAddConflicts(leader_client, add_client, was_swap_invite); - } - - // error if swapping and character was already removed before the accept - if (was_swap_invite) - { - auto swap_member = GetMemberData(swap_remove_name); - if (!swap_member.IsValid() || !ExpeditionDatabase::HasMember(m_id, swap_member.id)) - { - has_conflicts = true; - } - } - - if (has_conflicts) - { - SendLeaderMessage(leader_client, Chat::Red, EXPEDITION_INVITE_ERROR, { add_client->GetName() }); - } - else - { - SendLeaderMessage(leader_client, Chat::Yellow, EXPEDITION_INVITE_ACCEPTED, { add_client->GetName() }); - - // replay timers are optionally added to new members on join with fresh expire time - if (m_add_replay_on_join) - { - auto replay_lockout = m_lockouts.find(DZ_REPLAY_TIMER_NAME); - if (replay_lockout != m_lockouts.end() && - replay_lockout->second.IsFromExpedition(m_uuid) && - !add_client->HasExpeditionLockout(m_expedition_name, DZ_REPLAY_TIMER_NAME)) - { - ExpeditionLockoutTimer replay_timer = replay_lockout->second; // copy - replay_timer.Reset(); - add_client->AddExpeditionLockout(replay_timer, true); - } - } - - if (was_swap_invite) - { - SwapMember(add_client, swap_remove_name); - } - else - { - AddMember(add_client->GetName(), add_client->CharacterID()); - } - } -} - -bool Expedition::ConfirmLeaderCommand(Client* requester) -{ - if (!requester) - { - return false; - } - - if (!m_leader.IsValid()) - { - requester->MessageString(Chat::Red, UNABLE_RETRIEVE_LEADER); // unconfirmed message - return false; - } - - if (m_leader.id != requester->CharacterID()) - { - requester->MessageString(Chat::System, EXPEDITION_NOT_LEADER, m_leader.name.c_str()); - return false; - } - - return true; -} - -void Expedition::TryAddClient( - Client* add_client, const std::string& inviter_name, const std::string& swap_remove_name, - Client* leader_client) -{ - if (!add_client) - { - return; - } - - LogExpeditionsModerate( - "Add player request for expedition [{}] by inviter [{}] add name [{}] swap name [{}]", - m_id, inviter_name, add_client->GetName(), swap_remove_name - ); - - // null leader client handled by ProcessAddConflicts/SendLeaderMessage fallbacks - if (!leader_client) - { - leader_client = entity_list.GetClientByName(inviter_name.c_str()); - } - - bool has_conflicts = ProcessAddConflicts(leader_client, add_client, !swap_remove_name.empty()); - if (!has_conflicts) - { - // live uses the original unsanitized input string in invite messages - uint32_t string_id = swap_remove_name.empty() ? DZADD_INVITE : DZSWAP_INVITE; - SendLeaderMessage(leader_client, Chat::Yellow, string_id, { add_client->GetName() }); - SendClientExpeditionInvite(add_client, inviter_name.c_str(), swap_remove_name); - } - else if (swap_remove_name.empty()) // swap command doesn't result in this message - { - SendLeaderMessage(leader_client, Chat::Red, DZADD_INVITE_FAIL, { add_client->GetName() }); - } -} - -void Expedition::DzAddPlayer( - Client* requester, const std::string& add_char_name, const std::string& swap_remove_name) -{ - if (!requester || !ConfirmLeaderCommand(requester)) - { - return; - } - - bool invite_failed = false; - - if (m_is_locked) - { - requester->MessageString(Chat::Red, DZADD_NOT_ALLOWING); - invite_failed = true; - } - else if (add_char_name.empty()) - { - requester->MessageString(Chat::Red, DZADD_NOT_ONLINE, add_char_name.c_str()); - invite_failed = true; - } - else - { - auto member_data = GetMemberData(add_char_name); - if (member_data.IsValid()) - { - // live prioritizes offline message before already a member message - if (member_data.status == DynamicZoneMemberStatus::Offline) - { - requester->MessageString(Chat::Red, DZADD_NOT_ONLINE, add_char_name.c_str()); - } - else - { - requester->MessageString(Chat::Red, DZADD_ALREADY_PART, add_char_name.c_str()); - } - invite_failed = true; - } - } - - if (invite_failed) - { - requester->MessageString(Chat::Red, DZADD_INVITE_FAIL, FormatName(add_char_name).c_str()); - return; - } - - Client* add_client = entity_list.GetClientByName(add_char_name.c_str()); - if (add_client) - { - // client is online in this zone - TryAddClient(add_client, requester->GetName(), swap_remove_name, requester); - } - else - { - // forward to world to check if client is online and perform cross-zone invite - SendWorldAddPlayerInvite(requester->GetName(), swap_remove_name, FormatName(add_char_name)); - } -} - -void Expedition::DzAddPlayerContinue( - std::string inviter_name, std::string add_name, std::string swap_remove_name) -{ - // continuing expedition invite from leader in another zone - Client* add_client = entity_list.GetClientByName(add_name.c_str()); - if (add_client) - { - TryAddClient(add_client, inviter_name, swap_remove_name); - } -} - -void Expedition::DzMakeLeader(Client* requester, std::string new_leader_name) -{ - if (!requester || !ConfirmLeaderCommand(requester)) - { - return; - } - - if (new_leader_name.empty()) - { - requester->MessageString(Chat::Red, DZMAKELEADER_NOT_ONLINE, new_leader_name.c_str()); - return; - } - - // leader can only be changed by world - SendWorldMakeLeaderRequest(requester->CharacterID(), FormatName(new_leader_name)); -} - -void Expedition::DzRemovePlayer(Client* requester, std::string char_name) -{ - if (!requester || !ConfirmLeaderCommand(requester)) - { - return; - } - - // live only seems to enforce min_players for requesting expeditions, no need to check here - bool removed = RemoveMember(char_name); - if (!removed) - { - requester->MessageString(Chat::Red, EXPEDITION_NOT_MEMBER, FormatName(char_name).c_str()); - } - else - { - requester->MessageString(Chat::Yellow, EXPEDITION_REMOVED, FormatName(char_name).c_str(), m_expedition_name.c_str()); - } -} - -void Expedition::DzQuit(Client* requester) -{ - if (requester) - { - RemoveMember(requester->GetName()); - } -} - -void Expedition::DzSwapPlayer( - Client* requester, std::string remove_char_name, std::string add_char_name) -{ - if (!requester || !ConfirmLeaderCommand(requester)) - { - return; - } - - if (remove_char_name.empty() || !HasMember(remove_char_name)) - { - requester->MessageString(Chat::Red, DZSWAP_CANNOT_REMOVE, FormatName(remove_char_name).c_str()); - return; - } - - DzAddPlayer(requester, add_char_name, remove_char_name); -} - -void Expedition::DzPlayerList(Client* requester) -{ - if (requester) - { - requester->MessageString(Chat::Yellow, EXPEDITION_LEADER, m_leader.name.c_str()); - - std::string member_names; - for (const auto& member : m_members) - { - fmt::format_to(std::back_inserter(member_names), "{}, ", member.name); - } - - if (member_names.size() > 1) - { - member_names.erase(member_names.length() - 2); // trailing comma and space - } - - requester->MessageString(Chat::Yellow, EXPEDITION_MEMBERS, member_names.c_str()); - } -} - -void Expedition::DzKickPlayers(Client* requester) -{ - if (!requester || !ConfirmLeaderCommand(requester)) - { - return; - } - - RemoveAllMembers(); - requester->MessageString(Chat::Red, EXPEDITION_REMOVED, "Everyone", m_expedition_name.c_str()); -} - -void Expedition::SetLocked( - bool lock_expedition, ExpeditionLockMessage lock_msg, bool update_db, uint32_t msg_color) -{ - m_is_locked = lock_expedition; - - if (m_is_locked && lock_msg != ExpeditionLockMessage::None && m_dynamiczone.IsCurrentZoneDzInstance()) - { - auto msg = (lock_msg == ExpeditionLockMessage::Close) ? LOCK_CLOSE : LOCK_BEGIN; - for (const auto& client_iter : entity_list.GetClientList()) - { - if (client_iter.second) - { - client_iter.second->Message(msg_color, msg); - } - } - } - - if (update_db) - { - ExpeditionDatabase::UpdateLockState(m_id, lock_expedition); - SendWorldSettingChanged(ServerOP_ExpeditionLockState, m_is_locked); - } -} - -void Expedition::ProcessLeaderChanged(uint32_t new_leader_id) -{ - auto new_leader = GetMemberData(new_leader_id); - if (!new_leader.IsValid()) - { - LogExpeditions("Processed invalid new leader id [{}] for expedition [{}]", new_leader_id, m_id); - return; - } - - LogExpeditionsModerate("Replaced [{}] leader [{}] with [{}]", m_id, m_leader.name, new_leader.name); - - m_leader = new_leader; - m_dynamiczone.SetLeaderName(m_leader.name); - - // update each client's expedition window in this zone - auto outapp_leader = CreateLeaderNamePacket(); - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->QueuePacket(outapp_leader.get()); - - if (member.id == new_leader_id && RuleB(Expedition, AlwaysNotifyNewLeaderOnChange)) - { - member_client->MessageString(Chat::Yellow, DZMAKELEADER_YOU); - } - } - } -} - -void Expedition::ProcessMakeLeader(Client* old_leader_client, Client* new_leader_client, - const std::string& new_leader_name, bool is_success, bool is_online) -{ - if (old_leader_client) - { - // success flag is set by world to indicate new leader set to an online member - if (is_success) - { - old_leader_client->MessageString(Chat::Yellow, DZMAKELEADER_NAME, new_leader_name.c_str()); - } - else if (!is_online) - { - old_leader_client->MessageString(Chat::Red, DZMAKELEADER_NOT_ONLINE, new_leader_name.c_str()); - } - else - { - old_leader_client->MessageString(Chat::Red, EXPEDITION_NOT_MEMBER, new_leader_name.c_str()); - } - } - - if (is_success && new_leader_client && !RuleB(Expedition, AlwaysNotifyNewLeaderOnChange)) - { - new_leader_client->MessageString(Chat::Yellow, DZMAKELEADER_YOU); - } -} - -void Expedition::ProcessMemberAdded(const std::string& char_name, uint32_t added_char_id) -{ - AddInternalMember({ added_char_id, char_name, DynamicZoneMemberStatus::Online }); - - // adds the member to this expedition and notifies both leader and new member - Client* leader_client = entity_list.GetClientByCharID(m_leader.id); - if (leader_client) - { - leader_client->MessageString(Chat::Yellow, EXPEDITION_MEMBER_ADDED, char_name.c_str(), m_expedition_name.c_str()); - } - - Client* member_client = entity_list.GetClientByCharID(added_char_id); - if (member_client) - { - member_client->SetExpeditionID(GetID()); - member_client->SendDzCompassUpdate(); - member_client->QueuePacket(CreateInfoPacket().get()); - member_client->MessageString(Chat::Yellow, EXPEDITION_MEMBER_ADDED, char_name.c_str(), m_expedition_name.c_str()); - } - - SendMemberListToZoneMembers(); -} - -void Expedition::ProcessMemberRemoved(const std::string& removed_char_name, uint32_t removed_char_id) -{ - if (m_members.empty()) - { - return; - } - - auto outapp_member_name = CreateMemberListNamePacket(removed_char_name, true); - - for (auto it = m_members.begin(); it != m_members.end();) - { - bool is_removed = (it->name == removed_char_name); - - Client* member_client = entity_list.GetClientByCharID(it->id); - if (member_client) - { - // all members receive the removed player name packet - member_client->QueuePacket(outapp_member_name.get()); - - if (is_removed) - { - // live doesn't clear expedition info on clients removed while inside dz. - // it instead let's the dz kick timer do it even if character zones out - // before it triggers. for simplicity we'll always clear immediately - member_client->SetExpeditionID(0); - member_client->SendDzCompassUpdate(); - member_client->QueuePacket(CreateInfoPacket(true).get()); - member_client->MessageString(Chat::Yellow, EXPEDITION_REMOVED, - it->name.c_str(), m_expedition_name.c_str()); - } - } - - it = is_removed ? m_members.erase(it) : it + 1; - } - - LogExpeditionsDetail( - "Processed member [{}] ({}) removal from [{}], cache member count: [{}]", - removed_char_name, removed_char_id, m_id, m_members.size() - ); -} - -void Expedition::ProcessLockoutDuration( - const ExpeditionLockoutTimer& lockout, int seconds, bool members_only) -{ - if (!members_only) - { - auto it = m_lockouts.find(lockout.GetEventName()); - if (it != m_lockouts.end()) - { - it->second.AddLockoutTime(seconds); - } - else - { - m_lockouts[lockout.GetEventName()] = lockout; - } - } - - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->AddExpeditionLockoutDuration(m_expedition_name, - lockout.GetEventName(), seconds, m_uuid); - } - } - - if (m_dynamiczone.IsCurrentZoneDzInstance()) - { - AddLockoutDurationClients(lockout, seconds, GetID()); - } -} - -void Expedition::AddLockoutDurationClients( - const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id) -{ - std::vector lockout_clients; - for (const auto& client_iter : entity_list.GetClientList()) - { - Client* client = client_iter.second; - if (client && (exclude_id == 0 || client->GetExpeditionID() != exclude_id)) - { - lockout_clients.emplace_back(client->CharacterID(), client->GetName()); - client->AddExpeditionLockoutDuration(m_expedition_name, - lockout.GetEventName(), seconds, m_uuid); - } - } - - if (!lockout_clients.empty()) - { - int modified_seconds = static_cast(seconds * RuleR(Expedition, LockoutDurationMultiplier)); - ExpeditionDatabase::AddLockoutDuration(lockout_clients, lockout, modified_seconds); - } -} - -void Expedition::ProcessLockoutUpdate( - const ExpeditionLockoutTimer& lockout, bool remove, bool members_only) -{ - if (!members_only) - { - if (!remove) - { - m_lockouts[lockout.GetEventName()] = lockout; - } - else - { - m_lockouts.erase(lockout.GetEventName()); - } - } - - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - if (!remove) - { - member_client->AddExpeditionLockout(lockout); - } - else - { - member_client->RemoveExpeditionLockout(m_expedition_name, lockout.GetEventName()); - } - } - } - - // if this is the expedition's dz instance, all clients inside the zone need - // to receive added lockouts. this is done on live to avoid exploits where - // members leave the expedition but haven't been kicked from zone yet - if (!remove && m_dynamiczone.IsCurrentZoneDzInstance()) - { - AddLockoutClients(lockout, GetID()); - } -} - -void Expedition::AddLockoutClients( - const ExpeditionLockoutTimer& lockout, uint32_t exclude_expedition_id) -{ - std::vector lockout_clients; - for (const auto& client_iter : entity_list.GetClientList()) - { - Client* client = client_iter.second; - if (client && (exclude_expedition_id == 0 || client->GetExpeditionID() != exclude_expedition_id)) - { - lockout_clients.emplace_back(client->CharacterID(), client->GetName()); - client->AddExpeditionLockout(lockout); - } - } - - if (!lockout_clients.empty()) - { - ExpeditionDatabase::InsertMembersLockout(lockout_clients, lockout); - } -} - -void Expedition::SendMemberListToZoneMembers() -{ - auto outapp_members = CreateMemberListPacket(false); - - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->QueuePacket(outapp_members.get()); - } - } -} - -void Expedition::SendUpdatesToZoneMembers(bool clear, bool message_on_clear) -{ - if (!m_members.empty()) - { - auto outapp_info = CreateInfoPacket(clear); - auto outapp_members = CreateMemberListPacket(clear); - - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->SetExpeditionID(clear ? 0 : GetID()); - member_client->SendDzCompassUpdate(); - member_client->QueuePacket(outapp_info.get()); - member_client->QueuePacket(outapp_members.get()); - member_client->SendExpeditionLockoutTimers(); - if (clear && message_on_clear) - { - member_client->MessageString(Chat::Yellow, EXPEDITION_REMOVED, - member_client->GetName(), m_expedition_name.c_str()); - } - } - } - } -} - -void Expedition::SendClientExpeditionInfo(Client* client) -{ - if (client) - { - client->QueuePacket(CreateInfoPacket().get()); - client->QueuePacket(CreateMemberListPacket().get()); - } -} - -void Expedition::SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name) -{ - LogExpeditions( - "Character [{}] saving pending invite from [{}] to expedition [{}] in world", - add_name, invite.inviter_name, invite.expedition_id - ); - - SendWorldAddPlayerInvite(invite.inviter_name, invite.swap_remove_name, add_name, true); -} - -std::unique_ptr Expedition::CreateExpireWarningPacket(uint32_t minutes_remaining) -{ - uint32_t outsize = sizeof(ExpeditionExpireWarning); - auto outapp = std::make_unique(OP_DzExpeditionEndsWarning, outsize); - auto buf = reinterpret_cast(outapp->pBuffer); - buf->minutes_remaining = minutes_remaining; - return outapp; -} - -std::unique_ptr Expedition::CreateInfoPacket(bool clear) -{ - uint32_t outsize = sizeof(DynamicZoneInfo_Struct); - auto outapp = std::make_unique(OP_DzExpeditionInfo, outsize); - auto info = reinterpret_cast(outapp->pBuffer); - if (!clear) - { - info->assigned = true; - strn0cpy(info->dz_name, m_expedition_name.c_str(), sizeof(info->dz_name)); - strn0cpy(info->leader_name, m_leader.name.c_str(), sizeof(info->leader_name)); - info->max_players = GetDynamicZone().GetMaxPlayers(); - } - return outapp; -} - -std::unique_ptr Expedition::CreateInvitePacket( - const std::string& inviter_name, const std::string& swap_remove_name) -{ - uint32_t outsize = sizeof(ExpeditionInvite_Struct); - auto outapp = std::make_unique(OP_DzExpeditionInvite, outsize); - auto outbuf = reinterpret_cast(outapp->pBuffer); - strn0cpy(outbuf->inviter_name, inviter_name.c_str(), sizeof(outbuf->inviter_name)); - strn0cpy(outbuf->expedition_name, m_expedition_name.c_str(), sizeof(outbuf->expedition_name)); - strn0cpy(outbuf->swap_name, swap_remove_name.c_str(), sizeof(outbuf->swap_name)); - outbuf->swapping = !swap_remove_name.empty(); - outbuf->dz_zone_id = m_dynamiczone.GetZoneID(); - outbuf->dz_instance_id = m_dynamiczone.GetInstanceID(); - return outapp; -} - -std::unique_ptr Expedition::CreateMemberListPacket(bool clear) -{ - uint32_t member_count = clear ? 0 : static_cast(m_members.size()); - uint32_t member_entries_size = sizeof(DynamicZoneMemberEntry_Struct) * member_count; - uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + member_entries_size; - auto outapp = std::make_unique(OP_DzMemberList, outsize); - auto buf = reinterpret_cast(outapp->pBuffer); - - buf->member_count = member_count; - - if (!clear) - { - for (auto i = 0; i < m_members.size(); ++i) - { - strn0cpy(buf->members[i].name, m_members[i].name.c_str(), sizeof(buf->members[i].name)); - buf->members[i].online_status = static_cast(m_members[i].status); - } - } - - return outapp; -} - -std::unique_ptr Expedition::CreateMemberListNamePacket( - const std::string& name, bool remove_name) -{ - uint32_t outsize = sizeof(DynamicZoneMemberListName_Struct); - auto outapp = std::make_unique(OP_DzMemberListName, outsize); - auto buf = reinterpret_cast(outapp->pBuffer); - buf->add_name = !remove_name; - strn0cpy(buf->name, name.c_str(), sizeof(buf->name)); - return outapp; -} - -std::unique_ptr Expedition::CreateMemberListStatusPacket( - const std::string& name, DynamicZoneMemberStatus status) -{ - // member list status uses member list struct with a single entry - uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + sizeof(DynamicZoneMemberEntry_Struct); - auto outapp = std::make_unique(OP_DzMemberListStatus, outsize); - auto buf = reinterpret_cast(outapp->pBuffer); - buf->member_count = 1; - - auto entry = static_cast(buf->members); - strn0cpy(entry->name, name.c_str(), sizeof(entry->name)); - entry->online_status = static_cast(status); - - return outapp; -} - -std::unique_ptr Expedition::CreateLeaderNamePacket() -{ - uint32_t outsize = sizeof(DynamicZoneLeaderName_Struct); - auto outapp = std::make_unique(OP_DzSetLeaderName, outsize); - auto buf = reinterpret_cast(outapp->pBuffer); - strn0cpy(buf->leader_name, m_leader.name.c_str(), sizeof(buf->leader_name)); - return outapp; -} - -void Expedition::SendWorldExpeditionUpdate(uint16_t server_opcode) -{ - uint32_t pack_size = sizeof(ServerExpeditionID_Struct); - auto pack = std::make_unique(server_opcode, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldAddPlayerInvite( - const std::string& inviter_name, const std::string& swap_remove_name, const std::string& add_name, bool pending) -{ - auto server_opcode = pending ? ServerOP_ExpeditionSaveInvite : ServerOP_ExpeditionDzAddPlayer; - uint32_t pack_size = sizeof(ServerDzCommand_Struct); - auto pack = std::make_unique(server_opcode, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->is_char_online = false; - strn0cpy(buf->requester_name, inviter_name.c_str(), sizeof(buf->requester_name)); - strn0cpy(buf->target_name, add_name.c_str(), sizeof(buf->target_name)); - strn0cpy(buf->remove_name, swap_remove_name.c_str(), sizeof(buf->remove_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldLockoutDuration( - const ExpeditionLockoutTimer& lockout, int seconds, bool members_only) -{ - uint32_t pack_size = sizeof(ServerExpeditionLockout_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionLockoutDuration, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->expire_time = lockout.GetExpireTime(); - buf->duration = lockout.GetDuration(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->members_only = members_only; - buf->seconds_adjust = seconds; - strn0cpy(buf->event_name, lockout.GetEventName().c_str(), sizeof(buf->event_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldLockoutUpdate( - const ExpeditionLockoutTimer& lockout, bool remove, bool members_only) -{ - uint32_t pack_size = sizeof(ServerExpeditionLockout_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionLockout, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->expire_time = lockout.GetExpireTime(); - buf->duration = lockout.GetDuration(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->remove = remove; - buf->members_only = members_only; - strn0cpy(buf->event_name, lockout.GetEventName().c_str(), sizeof(buf->event_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name) -{ - uint32_t pack_size = sizeof(ServerDzCommandMakeLeader_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionDzMakeLeader, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->requester_id = requester_id; - strn0cpy(buf->new_leader_name, new_leader_name.c_str(), sizeof(buf->new_leader_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldMemberChanged(const std::string& char_name, uint32_t char_id, bool remove) -{ - // notify other zones of added or removed member - uint32_t pack_size = sizeof(ServerExpeditionMemberChange_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionMemberChange, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->removed = remove; - buf->char_id = char_id; - strn0cpy(buf->char_name, char_name.c_str(), sizeof(buf->char_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status) -{ - uint32_t pack_size = sizeof(ServerExpeditionMemberStatus_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionMemberStatus, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->status = static_cast(status); - buf->character_id = character_id; - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldMemberSwapped( - const std::string& remove_char_name, uint32_t remove_char_id, const std::string& add_char_name, uint32_t add_char_id) -{ - uint32_t pack_size = sizeof(ServerExpeditionMemberSwap_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionMemberSwap, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->add_char_id = add_char_id; - buf->remove_char_id = remove_char_id; - strn0cpy(buf->add_char_name, add_char_name.c_str(), sizeof(buf->add_char_name)); - strn0cpy(buf->remove_char_name, remove_char_name.c_str(), sizeof(buf->remove_char_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldSettingChanged(uint16_t server_opcode, bool setting_value) -{ - uint32_t pack_size = sizeof(ServerExpeditionSetting_Struct); - auto pack = std::make_unique(server_opcode, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->expedition_id = GetID(); - buf->sender_zone_id = zone ? zone->GetZoneID() : 0; - buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; - buf->enabled = setting_value; - worldserver.SendPacket(pack.get()); -} - -void Expedition::SendWorldCharacterLockout( - uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove) -{ - uint32_t pack_size = sizeof(ServerExpeditionCharacterLockout_Struct); - auto pack = std::make_unique(ServerOP_ExpeditionCharacterLockout, pack_size); - auto buf = reinterpret_cast(pack->pBuffer); - buf->remove = remove; - buf->character_id = character_id; - buf->expire_time = lockout.GetExpireTime(); - buf->duration = lockout.GetDuration(); - strn0cpy(buf->uuid, lockout.GetExpeditionUUID().c_str(), sizeof(buf->uuid)); - strn0cpy(buf->expedition_name, lockout.GetExpeditionName().c_str(), sizeof(buf->expedition_name)); - strn0cpy(buf->event_name, lockout.GetEventName().c_str(), sizeof(buf->event_name)); - worldserver.SendPacket(pack.get()); -} - -void Expedition::AddLockoutByCharacterID( - uint32_t character_id, const std::string& expedition_name, const std::string& event_name, - uint32_t seconds, const std::string& uuid) -{ - if (character_id) - { - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid); - ExpeditionDatabase::InsertCharacterLockouts(character_id, { lockout }); - SendWorldCharacterLockout(character_id, lockout, false); - } -} - -void Expedition::AddLockoutByCharacterName( - const std::string& character_name, const std::string& expedition_name, const std::string& event_name, - uint32_t seconds, const std::string& uuid) -{ - if (!character_name.empty()) - { - uint32_t character_id = database.GetCharacterID(character_name.c_str()); - AddLockoutByCharacterID(character_id, expedition_name, event_name, seconds, uuid); - } -} - -bool Expedition::HasLockoutByCharacterID( - uint32_t character_id, const std::string& expedition_name, const std::string& event_name) -{ - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(character_id); - return std::any_of(lockouts.begin(), lockouts.end(), [&](const ExpeditionLockoutTimer& lockout) { - return lockout.IsSameLockout(expedition_name, event_name); - }); -} - -bool Expedition::HasLockoutByCharacterName( - const std::string& character_name, const std::string& expedition_name, const std::string& event_name) -{ - if (!character_name.empty()) - { - uint32_t character_id = database.GetCharacterID(character_name.c_str()); - return HasLockoutByCharacterID(character_id, expedition_name, event_name); - } - return false; -} - -void Expedition::RemoveLockoutsByCharacterID( - uint32_t character_id, const std::string& expedition_name, const std::string& event_name) -{ - if (character_id) - { - if (!event_name.empty()) - { - ExpeditionDatabase::DeleteCharacterLockout(character_id, expedition_name, event_name); - } - else if (!expedition_name.empty()) - { - ExpeditionDatabase::DeleteAllCharacterLockouts(character_id, expedition_name); - } - else - { - ExpeditionDatabase::DeleteAllCharacterLockouts(character_id); - } - - ExpeditionLockoutTimer lockout{{}, expedition_name, event_name, 0, 0}; - SendWorldCharacterLockout(character_id, lockout, true); - } -} - -void Expedition::RemoveLockoutsByCharacterName( - const std::string& character_name, const std::string& expedition_name, const std::string& event_name) -{ - if (!character_name.empty()) - { - uint32_t character_id = database.GetCharacterID(character_name.c_str()); - RemoveLockoutsByCharacterID(character_id, expedition_name, event_name); - } -} - -void Expedition::HandleWorldMessage(ServerPacket* pack) -{ - switch (pack->opcode) - { - case ServerOP_ExpeditionCreate: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - Expedition::CacheFromDatabase(buf->expedition_id); - } - break; - } - case ServerOP_ExpeditionDeleted: - { - // sent by world when it deletes expired or empty expeditions - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (zone && expedition) - { - expedition->SendUpdatesToZoneMembers(true, false); // any members silently removed - - LogExpeditionsModerate("Deleting expedition [{}] from zone cache", buf->expedition_id); - zone->expedition_cache.erase(buf->expedition_id); - } - break; - } - case ServerOP_ExpeditionMembersRemoved: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->SendUpdatesToZoneMembers(true); - expedition->m_members.clear(); - } - } - break; - } - case ServerOP_ExpeditionLeaderChanged: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->ProcessLeaderChanged(buf->leader_id); - } - break; - } - case ServerOP_ExpeditionLockout: - case ServerOP_ExpeditionLockoutDuration: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - ExpeditionLockoutTimer lockout{ expedition->GetUUID(), expedition->GetName(), - buf->event_name, buf->expire_time, buf->duration }; - - if (pack->opcode == ServerOP_ExpeditionLockout) - { - expedition->ProcessLockoutUpdate(lockout, buf->remove, buf->members_only); - } - else if (pack->opcode == ServerOP_ExpeditionLockoutDuration) - { - expedition->ProcessLockoutDuration(lockout, buf->seconds_adjust, buf->members_only); - } - } - } - break; - } - case ServerOP_ExpeditionMemberChange: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - if (buf->removed) - { - expedition->ProcessMemberRemoved(buf->char_name, buf->char_id); - } - else - { - expedition->ProcessMemberAdded(buf->char_name, buf->char_id); - } - } - } - break; - } - case ServerOP_ExpeditionMemberSwap: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->ProcessMemberRemoved(buf->remove_char_name, buf->remove_char_id); - expedition->ProcessMemberAdded(buf->add_char_name, buf->add_char_id); - } - } - break; - } - case ServerOP_ExpeditionMemberStatus: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - auto status = static_cast(buf->status); - expedition->SendMemberStatusToZoneMembers(buf->character_id, status); - } - } - break; - } - case ServerOP_ExpeditionLockState: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->SetLocked(buf->enabled, static_cast(buf->lock_msg)); - } - } - break; - } - case ServerOP_ExpeditionReplayOnJoin: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id)) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->SetReplayLockoutOnMemberJoin(buf->enabled); - } - } - break; - } - case ServerOP_ExpeditionGetMemberStatuses: - { - // reply from world for online member statuses request - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - for (uint32_t i = 0; i < buf->count; ++i) - { - auto status = static_cast(buf->entries[i].online_status); - expedition->SetInternalMemberStatus(buf->entries[i].character_id, status); - } - expedition->SendMemberListToZoneMembers(); - } - break; - } - case ServerOP_ExpeditionDzAddPlayer: - { - auto buf = reinterpret_cast(pack->pBuffer); - if (buf->is_char_online) - { - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->DzAddPlayerContinue(buf->requester_name, buf->target_name, buf->remove_name); - } - } - else - { - Client* leader = entity_list.GetClientByName(buf->requester_name); - if (leader) - { - std::string target_name = FormatName(buf->target_name); - leader->MessageString(Chat::Red, DZADD_NOT_ONLINE, target_name.c_str()); - leader->MessageString(Chat::Red, DZADD_INVITE_FAIL, target_name.c_str()); - } - } - break; - } - case ServerOP_ExpeditionDzMakeLeader: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - auto old_leader_client = entity_list.GetClientByCharID(buf->requester_id); - auto new_leader_client = entity_list.GetClientByName(buf->new_leader_name); - expedition->ProcessMakeLeader(old_leader_client, new_leader_client, - buf->new_leader_name, buf->is_success, buf->is_online); - } - break; - } - case ServerOP_ExpeditionCharacterLockout: - { - auto buf = reinterpret_cast(pack->pBuffer); - Client* client = entity_list.GetClientByCharID(buf->character_id); - if (client) - { - if (!buf->remove) - { - client->AddExpeditionLockout(ExpeditionLockoutTimer{ - buf->uuid, buf->expedition_name, buf->event_name, buf->expire_time, buf->duration - }); - } - else if (buf->event_name[0] != '\0') - { - client->RemoveExpeditionLockout(buf->expedition_name, buf->event_name); - } - else - { - client->RemoveAllExpeditionLockouts(buf->expedition_name); - } - } - break; - } - case ServerOP_ExpeditionExpireWarning: - { - auto buf = reinterpret_cast(pack->pBuffer); - auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id); - if (expedition) - { - expedition->SendMembersExpireWarning(buf->minutes_remaining); - } - break; - } - } -} - -void Expedition::SendCompassUpdateToZoneMembers() -{ - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->SendDzCompassUpdate(); - } - } -} - -bool Expedition::CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t spawn_id) -{ - if (client && m_dynamiczone.IsCurrentZoneDzInstance()) - { - // entity id takes priority, falls back to checking by npc type if not set - std::string event_name = GetLootEventBySpawnID(spawn_id); - if (event_name.empty()) - { - event_name = GetLootEventByNPCTypeID(npc_type_id); - } - - if (!event_name.empty()) - { - auto client_lockout = client->GetExpeditionLockout(GetName(), event_name); - if (!client_lockout || client_lockout->GetExpeditionUUID() != GetUUID()) - { - // client lockout not received in this expedition, prevent looting - LogExpeditions( - "Character [{}] denied looting npc [{}] spawn [{}] for lockout event [{}]", - client->CharacterID(), npc_type_id, spawn_id, event_name - ); - return false; - } - } - } - - return true; -} - -void Expedition::SetLootEventByNPCTypeID(uint32_t npc_type_id, const std::string& event_name) -{ - if (npc_type_id && m_dynamiczone.IsCurrentZoneDzInstance()) - { - LogExpeditions("Setting loot event [{}] for npc type id [{}]", event_name, npc_type_id); - m_npc_loot_events[npc_type_id] = event_name; - } -} - -void Expedition::SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name) -{ - if (spawn_id && m_dynamiczone.IsCurrentZoneDzInstance()) - { - LogExpeditions("Setting loot event [{}] for entity id [{}]", event_name, spawn_id); - m_spawn_loot_events[spawn_id] = event_name; - } -} - -std::string Expedition::GetLootEventByNPCTypeID(uint32_t npc_type_id) -{ - std::string event_name; - - if (npc_type_id && m_dynamiczone.IsCurrentZoneDzInstance()) - { - auto it = m_npc_loot_events.find(npc_type_id); - if (it != m_npc_loot_events.end()) - { - event_name = it->second; - } - } - - return event_name; -} - -std::string Expedition::GetLootEventBySpawnID(uint32_t spawn_id) -{ - std::string event_name; - - if (spawn_id && m_dynamiczone.IsCurrentZoneDzInstance()) - { - auto it = m_spawn_loot_events.find(spawn_id); - if (it != m_spawn_loot_events.end()) - { - event_name = it->second; - } - } - - return event_name; -} - -std::vector Expedition::GetExpeditionLockoutsByCharacterID(uint32_t character_id) -{ - std::vector lockouts; - if (character_id == 0) - { - return lockouts; - } - - auto client = entity_list.GetClientByCharID(character_id); - if (client) - { - lockouts = client->GetExpeditionLockouts(); - } - else - { - lockouts = ExpeditionDatabase::LoadCharacterLockouts(character_id); - } - - return lockouts; -} - -void Expedition::SendMembersExpireWarning(uint32_t minutes_remaining) -{ - // expeditions warn members in all zones not just the dz - auto outapp = CreateExpireWarningPacket(minutes_remaining); - for (const auto& member : m_members) - { - Client* member_client = entity_list.GetClientByCharID(member.id); - if (member_client) - { - member_client->QueuePacket(outapp.get()); - member_client->MessageString(Chat::Yellow, EXPEDITION_MIN_REMAIN, - fmt::format_int(minutes_remaining).c_str()); - } - } -} - -void Expedition::SyncCharacterLockouts( - uint32_t character_id, std::vector& client_lockouts) -{ - // adds missing event lockouts to client for this expedition and updates - // client timers that are both shorter and from another expedition - BenchTimer benchmark; - - bool modified = false; - - for (const auto& lockout_iter : m_lockouts) - { - const ExpeditionLockoutTimer& lockout = lockout_iter.second; - if (lockout.IsReplayTimer() || lockout.IsExpired() || lockout.GetExpeditionUUID() != m_uuid) - { - continue; - } - - auto client_lockout_iter = std::find_if(client_lockouts.begin(), client_lockouts.end(), - [&](const ExpeditionLockoutTimer& client_lockout) { - return client_lockout.IsSameLockout(lockout); - }); - - if (client_lockout_iter == client_lockouts.end()) - { - modified = true; - client_lockouts.emplace_back(lockout); // insert missing - } - else if (client_lockout_iter->GetSecondsRemaining() < lockout.GetSecondsRemaining() && - client_lockout_iter->GetExpeditionUUID() != m_uuid) - { - // only update lockout timer not uuid so loot event apis still work - modified = true; - client_lockout_iter->SetDuration(lockout.GetDuration()); - client_lockout_iter->SetExpireTime(lockout.GetExpireTime()); - } - } - - if (modified) - { - ExpeditionDatabase::InsertCharacterLockouts(character_id, client_lockouts); - } - - LogExpeditionsDetail("Syncing character lockouts with expedition took [{}] s", benchmark.elapsed()); -} diff --git a/zone/expedition.h b/zone/expedition.h deleted file mode 100644 index b3404d696..000000000 --- a/zone/expedition.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EXPEDITION_H -#define EXPEDITION_H - -#include "dynamic_zone.h" -#include "../common/expedition_base.h" -#include "../common/expedition_lockout_timer.h" -#include "../common/repositories/expeditions_repository.h" -#include -#include -#include -#include -#include - -class Client; -class EQApplicationPacket; -struct ExpeditionInvite; -class ExpeditionRequest; -class ServerPacket; - -extern const char* const DZ_YOU_NOT_ASSIGNED; -extern const char* const EXPEDITION_OTHER_BELONGS; - -enum class ExpeditionLockMessage : uint8_t -{ - None = 0, - Close, - Begin -}; - -class Expedition : public ExpeditionBase -{ -public: - Expedition() = default; - Expedition(uint32_t id, const std::string& uuid, DynamicZone&& dz, const std::string& expedition_name, - const DynamicZoneMember& leader); - - static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, ExpeditionRequest& request); - - static void CacheFromDatabase(uint32_t expedition_id); - static bool CacheAllFromDatabase(); - static Expedition* FindCachedExpeditionByCharacterID(uint32_t character_id); - static Expedition* FindCachedExpeditionByCharacterName(const std::string& char_name); - static Expedition* FindCachedExpeditionByDynamicZoneID(uint32_t dz_id); - static Expedition* FindCachedExpeditionByID(uint32_t expedition_id); - static Expedition* FindCachedExpeditionByZoneInstance(uint32_t zone_id, uint32_t instance_id); - static std::vector GetExpeditionLockoutsByCharacterID(uint32_t character_id); - static void HandleWorldMessage(ServerPacket* pack); - static void AddLockoutByCharacterID(uint32_t character_id, const std::string& expedition_name, - const std::string& event_name, uint32_t seconds, const std::string& uuid = {}); - static void AddLockoutByCharacterName(const std::string& character_name, const std::string& expedition_name, - const std::string& event_name, uint32_t seconds, const std::string& uuid = {}); - static bool HasLockoutByCharacterID(uint32_t character_id, - const std::string& expedition_name, const std::string& event_name); - static bool HasLockoutByCharacterName(const std::string& character_name, - const std::string& expedition_name, const std::string& event_name); - static void RemoveLockoutsByCharacterID(uint32_t character_id, - const std::string& expedition_name = {}, const std::string& event_name = {}); - static void RemoveLockoutsByCharacterName(const std::string& character_name, - const std::string& expedition_name = {}, const std::string& event_name = {}); - static void AddLockoutClients(const ExpeditionLockoutTimer& lockout, uint32_t exclude_id = 0); - - DynamicZone& GetDynamicZone() { return m_dynamiczone; } - const std::unordered_map& GetLockouts() const { return m_lockouts; } - - bool AddMember(const std::string& add_char_name, uint32_t add_char_id); - void RemoveAllMembers(bool enable_removal_timers = true); - bool RemoveMember(const std::string& remove_char_name); - void SetMemberStatus(Client* client, DynamicZoneMemberStatus status); - void SwapMember(Client* add_client, const std::string& remove_char_name); - - bool IsLocked() const { return m_is_locked; } - void SetLocked(bool lock_expedition, ExpeditionLockMessage lock_msg, - bool update_db = false, uint32_t msg_color = Chat::Yellow); - - void AddLockout(const std::string& event_name, uint32_t seconds); - void AddLockoutDuration(const std::string& event_name, int seconds, bool members_only = true); - void AddReplayLockout(uint32_t seconds); - void AddReplayLockoutDuration(int seconds, bool members_only = true); - bool HasLockout(const std::string& event_name); - bool HasReplayLockout(); - void RemoveLockout(const std::string& event_name); - void SetReplayLockoutOnMemberJoin(bool add_on_join, bool update_db = false); - void SyncCharacterLockouts(uint32_t character_id, std::vector& client_lockouts); - void UpdateLockoutDuration(const std::string& event_name, uint32_t seconds, bool members_only = true); - - bool CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t spawn_id); - std::string GetLootEventByNPCTypeID(uint32_t npc_id); - std::string GetLootEventBySpawnID(uint32_t spawn_id); - void SetLootEventByNPCTypeID(uint32_t npc_type_id, const std::string& event_name); - void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name); - - void SendClientExpeditionInfo(Client* client); - void SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name); - void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name); - - void DzAddPlayer(Client* requester, const std::string& add_char_name, const std::string& swap_remove_name = {}); - void DzAddPlayerContinue(std::string leader_name, std::string add_char_name, std::string swap_remove_name = {}); - void DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name); - void DzMakeLeader(Client* requester, std::string new_leader_name); - void DzPlayerList(Client* requester); - void DzRemovePlayer(Client* requester, std::string remove_char_name); - void DzSwapPlayer(Client* requester, std::string remove_char_name, std::string add_char_name); - void DzQuit(Client* requester); - void DzKickPlayers(Client* requester); - - static const int32_t REPLAY_TIMER_ID; - static const int32_t EVENT_TIMER_ID; - -private: - static void CacheExpeditions(std::vector&& expeditions); - static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove); - - void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false); - void AddLockoutDurationClients(const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id = 0); - bool ConfirmLeaderCommand(Client* requester); - bool ProcessAddConflicts(Client* leader_client, Client* add_client, bool swapping); - void ProcessLeaderChanged(uint32_t new_leader_id); - void ProcessLockoutDuration(const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false); - void ProcessLockoutUpdate(const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false); - void ProcessMakeLeader(Client* old_leader, Client* new_leader, - const std::string& new_leader_name, bool is_success, bool is_online); - void ProcessMemberAdded(const std::string& added_char_name, uint32_t added_char_id); - void ProcessMemberRemoved(const std::string& removed_char_name, uint32_t removed_char_id); - void SaveLockouts(ExpeditionRequest& request); - void SaveMembers(ExpeditionRequest& request); - void SendClientExpeditionInvite( - Client* client, const std::string& inviter_name, const std::string& swap_remove_name); - void SendLeaderMessage(Client* leader_client, uint16_t chat_type, uint32_t string_id, - const std::initializer_list& args = {}); - void SendMemberListToZoneMembers(); - void SendMemberStatusToZoneMembers(uint32_t update_character_id, DynamicZoneMemberStatus status); - void SendMembersExpireWarning(uint32_t minutes); - void SendUpdatesToZoneMembers(bool clear = false, bool message_on_clear = true); - void SendCompassUpdateToZoneMembers(); - void SendWorldExpeditionUpdate(uint16_t server_opcode); - void SendWorldAddPlayerInvite(const std::string& inviter_name, const std::string& swap_remove_name, - const std::string& add_name, bool pending = false); - void SendWorldLockoutDuration( - const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false); - void SendWorldLockoutUpdate( - const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false); - void SendWorldMemberChanged(const std::string& char_name, uint32_t char_id, bool remove); - void SendWorldMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status); - void SendWorldMemberSwapped(const std::string& remove_char_name, uint32_t remove_char_id, - const std::string& add_char_name, uint32_t add_char_id); - void SendWorldSettingChanged(uint16_t server_opcode, bool setting_value); - void SetDynamicZone(DynamicZone&& dz); - void TryAddClient(Client* add_client, const std::string& inviter_name, - const std::string& swap_remove_name, Client* leader_client = nullptr); - - std::unique_ptr CreateExpireWarningPacket(uint32_t minutes_remaining); - std::unique_ptr CreateInfoPacket(bool clear = false); - std::unique_ptr CreateInvitePacket(const std::string& inviter_name, const std::string& swap_remove_name); - std::unique_ptr CreateMemberListPacket(bool clear = false); - std::unique_ptr CreateMemberListNamePacket(const std::string& name, bool remove_name); - std::unique_ptr CreateMemberListStatusPacket(const std::string& name, DynamicZoneMemberStatus status); - std::unique_ptr CreateLeaderNamePacket(); - - DynamicZone m_dynamiczone { DynamicZoneType::Expedition }; - std::unordered_map m_lockouts; - std::unordered_map m_npc_loot_events; // only valid inside dz zone - std::unordered_map m_spawn_loot_events; // only valid inside dz zone -}; - -#endif diff --git a/zone/expedition_database.cpp b/zone/expedition_database.cpp deleted file mode 100644 index af6948f5f..000000000 --- a/zone/expedition_database.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition_database.h" -#include "expedition.h" -#include "zonedb.h" -#include "../common/database.h" -#include "../common/expedition_lockout_timer.h" -#include "../common/string_util.h" -#include - -uint32_t ExpeditionDatabase::InsertExpedition( - const std::string& uuid, uint32_t dz_id, const std::string& expedition_name, - uint32_t leader_id, uint32_t min_players, uint32_t max_players) -{ - LogExpeditionsDetail( - "Inserting new expedition [{}] leader [{}] uuid [{}]", expedition_name, leader_id, uuid - ); - - std::string query = fmt::format(SQL( - INSERT INTO expeditions - (uuid, dynamic_zone_id, expedition_name, leader_id, min_players, max_players) - VALUES - ('{}', {}, '{}', {}, {}, {}); - ), uuid, dz_id, EscapeString(expedition_name), leader_id, min_players, max_players); - - auto results = database.QueryDatabase(query); - if (!results.Success()) - { - LogExpeditions("Failed to obtain an expedition id for [{}]", expedition_name); - return 0; - } - - return results.LastInsertedID(); -} - -std::vector ExpeditionDatabase::LoadCharacterLockouts(uint32_t character_id) -{ - LogExpeditionsDetail("Loading character [{}] lockouts", character_id); - - std::vector lockouts; - - auto query = fmt::format(SQL( - SELECT - from_expedition_uuid, - expedition_name, - event_name, - UNIX_TIMESTAMP(expire_time), - duration - FROM character_expedition_lockouts - WHERE character_id = {} AND expire_time > NOW(); - ), character_id); - - auto results = database.QueryDatabase(query); - if (results.Success()) - { - for (auto row = results.begin(); row != results.end(); ++row) - { - lockouts.emplace_back( - row[0], // expedition_uuid - row[1], // expedition_name - row[2], // event_name - strtoull(row[3], nullptr, 10), // expire_time - static_cast(strtoul(row[4], nullptr, 10)) // duration - ); - } - } - - return lockouts; -} - -std::vector ExpeditionDatabase::LoadCharacterLockouts( - uint32_t character_id, const std::string& expedition_name) -{ - LogExpeditionsDetail("Loading character [{}] lockouts for [{}]", character_id, expedition_name); - - std::vector lockouts; - - auto query = fmt::format(SQL( - SELECT - from_expedition_uuid, - event_name, - UNIX_TIMESTAMP(expire_time), - duration - FROM character_expedition_lockouts - WHERE - character_id = {} - AND expire_time > NOW() - AND expedition_name = '{}'; - ), character_id, EscapeString(expedition_name)); - - auto results = database.QueryDatabase(query); - if (results.Success()) - { - for (auto row = results.begin(); row != results.end(); ++row) - { - lockouts.emplace_back( - row[0], // expedition_uuid - expedition_name, - row[1], // event_name - strtoull(row[2], nullptr, 10), // expire_time - static_cast(strtoul(row[3], nullptr, 10)) // duration - ); - } - } - - return lockouts; -} - -void ExpeditionDatabase::DeleteAllCharacterLockouts(uint32_t character_id) -{ - LogExpeditionsDetail("Deleting all character [{}] lockouts", character_id); - - if (character_id != 0) - { - std::string query = fmt::format(SQL( - DELETE FROM character_expedition_lockouts - WHERE character_id = {}; - ), character_id); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::DeleteAllCharacterLockouts( - uint32_t character_id, const std::string& expedition_name) -{ - LogExpeditionsDetail("Deleting all character [{}] lockouts for [{}]", character_id, expedition_name); - - if (character_id != 0 && !expedition_name.empty()) - { - std::string query = fmt::format(SQL( - DELETE FROM character_expedition_lockouts - WHERE character_id = {} AND expedition_name = '{}'; - ), character_id, EscapeString(expedition_name)); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::DeleteCharacterLockout( - uint32_t character_id, const std::string& expedition_name, const std::string& event_name) -{ - LogExpeditionsDetail( - "Deleting character [{}] lockout: [{}]:[{}]", character_id, expedition_name, event_name - ); - - auto query = fmt::format(SQL( - DELETE FROM character_expedition_lockouts - WHERE - character_id = {} - AND expedition_name = '{}' - AND event_name = '{}'; - ), character_id, EscapeString(expedition_name), EscapeString(event_name)); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::DeleteMembersLockout( - const std::vector& members, - const std::string& expedition_name, const std::string& event_name) -{ - LogExpeditionsDetail("Deleting members lockout: [{}]:[{}]", expedition_name, event_name); - - std::string query_character_ids; - for (const auto& member : members) - { - fmt::format_to(std::back_inserter(query_character_ids), "{},", member.id); - } - - if (!query_character_ids.empty()) - { - query_character_ids.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - DELETE FROM character_expedition_lockouts - WHERE character_id - IN ({}) - AND expedition_name = '{}' - AND event_name = '{}'; - ), query_character_ids, EscapeString(expedition_name), EscapeString(event_name)); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::DeleteLockout(uint32_t expedition_id, const std::string& event_name) -{ - LogExpeditionsDetail("Deleting expedition [{}] lockout event [{}]", expedition_id, event_name); - - auto query = fmt::format(SQL( - DELETE FROM expedition_lockouts - WHERE expedition_id = {} AND event_name = '{}'; - ), expedition_id, EscapeString(event_name)); - - database.QueryDatabase(query); -} - -uint32_t ExpeditionDatabase::GetExpeditionIDFromCharacterID(uint32_t character_id) -{ - LogExpeditionsDetail("Getting expedition id for character [{}]", character_id); - - uint32_t expedition_id = 0; - auto query = fmt::format(SQL( - SELECT expedition_id FROM expedition_members - WHERE character_id = {} AND is_current_member = TRUE; - ), character_id); - - auto results = database.QueryDatabase(query); - if (results.Success() && results.RowCount() > 0) - { - auto row = results.begin(); - expedition_id = strtoul(row[0], nullptr, 10); - } - return expedition_id; -} - -uint32_t ExpeditionDatabase::GetMemberCount(uint32_t expedition_id) -{ - LogExpeditionsDetail("Getting expedition [{}] member count from db", expedition_id); - - uint32_t member_count = 0; - if (expedition_id != 0) - { - auto query = fmt::format(SQL( - SELECT COUNT(*) - FROM expedition_members - WHERE expedition_id = {} AND is_current_member = TRUE; - ), expedition_id); - - auto results = database.QueryDatabase(query); - if (results.Success() && results.RowCount() > 0) - { - auto row = results.begin(); - member_count = strtoul(row[0], nullptr, 10); - } - } - return member_count; -} - -bool ExpeditionDatabase::HasMember(uint32_t expedition_id, uint32_t character_id) -{ - LogExpeditionsDetail("Checking db expedition [{}] for character [{}]", expedition_id, character_id); - - if (expedition_id == 0 || character_id == 0) - { - return false; - } - - auto query = fmt::format(SQL( - SELECT id - FROM expedition_members - WHERE expedition_id = {} AND character_id = {} AND is_current_member = TRUE; - ), expedition_id, character_id); - - auto results = database.QueryDatabase(query); - return (results.Success() && results.RowCount() > 0); -} - -void ExpeditionDatabase::InsertCharacterLockouts(uint32_t character_id, - const std::vector& lockouts) -{ - LogExpeditionsDetail("Inserting [{}] lockouts for character [{}]", lockouts.size(), character_id); - - std::string insert_values; - for (const auto& lockout : lockouts) - { - fmt::format_to(std::back_inserter(insert_values), - "({}, FROM_UNIXTIME({}), {}, '{}', '{}', '{}'),", - character_id, - lockout.GetExpireTime(), - lockout.GetDuration(), - lockout.GetExpeditionUUID(), - EscapeString(lockout.GetExpeditionName()), - EscapeString(lockout.GetEventName()) - ); - } - - if (!insert_values.empty()) - { - insert_values.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - INSERT INTO character_expedition_lockouts - (character_id, expire_time, duration, from_expedition_uuid, expedition_name, event_name) - VALUES {} - ON DUPLICATE KEY UPDATE - from_expedition_uuid = VALUES(from_expedition_uuid), - expire_time = VALUES(expire_time), - duration = VALUES(duration); - ), insert_values); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::InsertMembersLockout( - const std::vector& members, const ExpeditionLockoutTimer& lockout) -{ - LogExpeditionsDetail( - "Inserting members lockout [{}]:[{}] with expire time [{}]", - lockout.GetExpeditionName(), lockout.GetEventName(), lockout.GetExpireTime() - ); - - std::string insert_values; - for (const auto& member : members) - { - fmt::format_to(std::back_inserter(insert_values), - "({}, FROM_UNIXTIME({}), {}, '{}', '{}', '{}'),", - member.id, - lockout.GetExpireTime(), - lockout.GetDuration(), - lockout.GetExpeditionUUID(), - EscapeString(lockout.GetExpeditionName()), - EscapeString(lockout.GetEventName()) - ); - } - - if (!insert_values.empty()) - { - insert_values.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - INSERT INTO character_expedition_lockouts - (character_id, expire_time, duration, from_expedition_uuid, expedition_name, event_name) - VALUES {} - ON DUPLICATE KEY UPDATE - from_expedition_uuid = VALUES(from_expedition_uuid), - expire_time = VALUES(expire_time), - duration = VALUES(duration); - ), insert_values); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::InsertLockout( - uint32_t expedition_id, const ExpeditionLockoutTimer& lockout) -{ - LogExpeditionsDetail( - "Inserting expedition [{}] lockout: [{}]:[{}] expire time: [{}]", - expedition_id, lockout.GetExpeditionName(), lockout.GetEventName(), lockout.GetExpireTime() - ); - - auto query = fmt::format(SQL( - INSERT INTO expedition_lockouts - (expedition_id, from_expedition_uuid, event_name, expire_time, duration) - VALUES - ({}, '{}', '{}', FROM_UNIXTIME({}), {}) - ON DUPLICATE KEY UPDATE - from_expedition_uuid = VALUES(from_expedition_uuid), - expire_time = VALUES(expire_time), - duration = VALUES(duration); - ), - expedition_id, - lockout.GetExpeditionUUID(), - EscapeString(lockout.GetEventName()), - lockout.GetExpireTime(), - lockout.GetDuration() - ); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::InsertLockouts( - uint32_t expedition_id, const std::unordered_map& lockouts) -{ - LogExpeditionsDetail("Inserting expedition [{}] lockouts", expedition_id); - - std::string insert_values; - for (const auto& lockout : lockouts) - { - fmt::format_to(std::back_inserter(insert_values), - "({}, '{}', '{}', FROM_UNIXTIME({}), {}),", - expedition_id, - lockout.second.GetExpeditionUUID(), - EscapeString(lockout.second.GetEventName()), - lockout.second.GetExpireTime(), - lockout.second.GetDuration() - ); - } - - if (!insert_values.empty()) - { - insert_values.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - INSERT INTO expedition_lockouts - (expedition_id, from_expedition_uuid, event_name, expire_time, duration) - VALUES {} - ON DUPLICATE KEY UPDATE - from_expedition_uuid = VALUES(from_expedition_uuid), - expire_time = VALUES(expire_time), - duration = VALUES(duration); - ), insert_values); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::InsertMember(uint32_t expedition_id, uint32_t character_id) -{ - LogExpeditionsDetail("Inserting character [{}] into expedition [{}]", character_id, expedition_id); - - auto query = fmt::format(SQL( - INSERT INTO expedition_members - (expedition_id, character_id) - VALUES - ({}, {}) - ON DUPLICATE KEY UPDATE is_current_member = TRUE; - ), expedition_id, character_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::InsertMembers( - uint32_t expedition_id, const std::vector& members) -{ - LogExpeditionsDetail("Inserting characters into expedition [{}]", expedition_id); - - std::string insert_values; - for (const auto& member : members) - { - fmt::format_to(std::back_inserter(insert_values), - "({}, {}),", - expedition_id, member.id - ); - } - - if (!insert_values.empty()) - { - insert_values.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - INSERT INTO expedition_members - (expedition_id, character_id) - VALUES {} - ON DUPLICATE KEY UPDATE is_current_member = TRUE; - ), insert_values); - - database.QueryDatabase(query); - } -} - -void ExpeditionDatabase::UpdateLockState(uint32_t expedition_id, bool is_locked) -{ - LogExpeditionsDetail("Updating lock state [{}] for expedition [{}]", is_locked, expedition_id); - - auto query = fmt::format(SQL( - UPDATE expeditions SET is_locked = {} WHERE id = {}; - ), is_locked, expedition_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::DeleteMember(uint32_t expedition_id, uint32_t character_id) -{ - LogExpeditionsDetail("Removing member [{}] from expedition [{}]", character_id, expedition_id); - - auto query = fmt::format(SQL( - UPDATE expedition_members SET is_current_member = FALSE - WHERE expedition_id = {} AND character_id = {}; - ), expedition_id, character_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::DeleteAllMembers(uint32_t expedition_id) -{ - LogExpeditionsDetail("Removing all members of expedition [{}]", expedition_id); - - auto query = fmt::format(SQL( - UPDATE expedition_members SET is_current_member = FALSE WHERE expedition_id = {}; - ), expedition_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::UpdateReplayLockoutOnJoin(uint32_t expedition_id, bool add_on_join) -{ - LogExpeditionsDetail("Updating replay lockout on join [{}] for expedition [{}]", add_on_join, expedition_id); - - auto query = fmt::format(SQL( - UPDATE expeditions SET add_replay_on_join = {} WHERE id = {}; - ), add_on_join, expedition_id); - - database.QueryDatabase(query); -} - -void ExpeditionDatabase::AddLockoutDuration(const std::vector& members, - const ExpeditionLockoutTimer& lockout, int seconds) -{ - LogExpeditionsDetail( - "Adding duration [{}] seconds to members lockouts [{}]:[{}]", - seconds, lockout.GetExpeditionName(), lockout.GetEventName()); - - std::string insert_values; - for (const auto& member : members) - { - fmt::format_to(std::back_inserter(insert_values), - "({}, FROM_UNIXTIME({}), {}, '{}', '{}', '{}'),", - member.id, - lockout.GetExpireTime(), - lockout.GetDuration(), - lockout.GetExpeditionUUID(), - EscapeString(lockout.GetExpeditionName()), - EscapeString(lockout.GetEventName()) - ); - } - - if (!insert_values.empty()) - { - insert_values.pop_back(); // trailing comma - - auto query = fmt::format(SQL( - INSERT INTO character_expedition_lockouts - (character_id, expire_time, duration, from_expedition_uuid, expedition_name, event_name) - VALUES {} - ON DUPLICATE KEY UPDATE - from_expedition_uuid = VALUES(from_expedition_uuid), - expire_time = DATE_ADD(expire_time, INTERVAL {} SECOND), - duration = GREATEST(0, CAST(duration AS SIGNED) + {}); - ), insert_values, seconds, seconds); - - database.QueryDatabase(query); - } -} diff --git a/zone/expedition_database.h b/zone/expedition_database.h deleted file mode 100644 index cce81c0fc..000000000 --- a/zone/expedition_database.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EXPEDITION_DATABASE_H -#define EXPEDITION_DATABASE_H - -#include -#include -#include -#include -#include -#include - -class Expedition; -class ExpeditionLockoutTimer; -struct DynamicZoneMember; -class MySQLRequestResult; - -namespace ExpeditionDatabase -{ - uint32_t InsertExpedition( - const std::string& uuid, uint32_t instance_id, const std::string& expedition_name, - uint32_t leader_id, uint32_t min_players, uint32_t max_players); - std::vector LoadCharacterLockouts(uint32_t character_id); - std::vector LoadCharacterLockouts(uint32_t character_id, - const std::string& expedition_name); - void DeleteAllMembers(uint32_t expedition_id); - void DeleteMember(uint32_t expedition_id, uint32_t character_id); - void DeleteAllCharacterLockouts(uint32_t character_id); - void DeleteAllCharacterLockouts(uint32_t character_id, const std::string& expedition_name); - void DeleteCharacterLockout(uint32_t character_id, const std::string& expedition_name, - const std::string& event_name); - void DeleteLockout(uint32_t expedition_id, const std::string& event_name); - void DeleteMembersLockout(const std::vector& members, - const std::string& expedition_name, const std::string& event_name); - uint32_t GetExpeditionIDFromCharacterID(uint32_t character_id); - uint32_t GetMemberCount(uint32_t expedition_id); - bool HasMember(uint32_t expedition_id, uint32_t character_id); - void InsertCharacterLockouts(uint32_t character_id, - const std::vector& lockouts); - void InsertMembersLockout(const std::vector& members, - const ExpeditionLockoutTimer& lockout); - void InsertLockout(uint32_t expedition_id, const ExpeditionLockoutTimer& lockout); - void InsertLockouts(uint32_t expedition_id, - const std::unordered_map& lockouts); - void InsertMember(uint32_t expedition_id, uint32_t character_id); - void InsertMembers(uint32_t expedition_id, const std::vector& members); - void UpdateLockState(uint32_t expedition_id, bool is_locked); - void UpdateReplayLockoutOnJoin(uint32_t expedition_id, bool add_on_join); - void AddLockoutDuration(const std::vector& members, - const ExpeditionLockoutTimer& lockout, int seconds); -}; - -#endif diff --git a/zone/expedition_request.cpp b/zone/expedition_request.cpp deleted file mode 100644 index a1a2aa48e..000000000 --- a/zone/expedition_request.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "expedition_request.h" -#include "client.h" -#include "expedition.h" -#include "groups.h" -#include "raids.h" -#include "string_ids.h" -#include "../common/expedition_lockout_timer.h" -#include "../common/repositories/character_expedition_lockouts_repository.h" -#include "../common/repositories/expeditions_repository.h" - -constexpr char SystemName[] = "expedition"; - -ExpeditionRequest::ExpeditionRequest(std::string expedition_name, - uint32_t min_players, uint32_t max_players, bool disable_messages -) : - m_expedition_name(std::move(expedition_name)), - m_min_players(min_players), - m_max_players(max_players), - m_disable_messages(disable_messages) -{ -} - -bool ExpeditionRequest::Validate(Client* requester) -{ - m_requester = requester; - if (!m_requester) - { - return false; - } - - // a message is sent to leader for every member that fails a requirement - - BenchTimer benchmark; - - bool requirements_met = false; - - Raid* raid = m_requester->GetRaid(); - Group* group = m_requester->GetGroup(); - if (raid) - { - requirements_met = CanRaidRequest(raid); - } - else if (group) - { - requirements_met = CanGroupRequest(group); - } - else // solo request - { - m_leader = m_requester; - m_leader_id = m_requester->CharacterID(); - m_leader_name = m_requester->GetName(); - requirements_met = CanMembersJoin({m_leader_name}); - } - - auto elapsed = benchmark.elapsed(); - LogExpeditions("Create validation for [{}] members took [{}s]", m_members.size(), elapsed); - - return requirements_met; -} - -bool ExpeditionRequest::CanRaidRequest(Raid* raid) -{ - m_leader = raid->GetLeader(); - m_leader_name = raid->leadername; - m_leader_id = m_leader ? m_leader->CharacterID() : database.GetCharacterID(raid->leadername); - - // live (as of September 16, 2020) supports creation even if raid count exceeds - // expedition max. members are added up to the max ordered by group number. - auto raid_members = raid->GetMembers(); - - if (raid_members.size() > m_max_players) - { - // stable_sort not needed, order within a raid group may not be what is displayed - std::sort(raid_members.begin(), raid_members.end(), - [&](const RaidMember& lhs, const RaidMember& rhs) { - if (m_leader_name == lhs.membername) { // leader always added first - return true; - } else if (m_leader_name == rhs.membername) { - return false; - } - return lhs.GroupNumber < rhs.GroupNumber; - }); - - m_not_all_added_msg = fmt::format(CREATE_NOT_ALL_ADDED, "raid", SystemName, - SystemName, m_max_players, "raid", raid_members.size()); - } - - // live still performs conflict checks for all members even those beyond max - std::vector member_names; - for (int i = 0; i < raid_members.size(); ++i) - { - member_names.emplace_back(raid_members[i].membername); - } - - return CanMembersJoin(member_names); -} - -bool ExpeditionRequest::CanGroupRequest(Group* group) -{ - m_leader = nullptr; - if (group->GetLeader() && group->GetLeader()->IsClient()) - { - m_leader = group->GetLeader()->CastToClient(); - } - - // Group::GetLeaderName() is broken if group formed across zones, ask database instead - m_leader_name = m_leader ? m_leader->GetName() : GetGroupLeaderName(group->GetID()); // group->GetLeaderName(); - m_leader_id = m_leader ? m_leader->CharacterID() : database.GetCharacterID(m_leader_name.c_str()); - - std::vector member_names; - member_names.emplace_back(m_leader_name); // leader always added first - - for (int i = 0; i < MAX_GROUP_MEMBERS; ++i) - { - if (group->membername[i][0] && m_leader_name != group->membername[i]) - { - member_names.emplace_back(group->membername[i]); - } - } - - if (member_names.size() > m_max_players) - { - m_not_all_added_msg = fmt::format(CREATE_NOT_ALL_ADDED, "group", SystemName, - SystemName, m_max_players, "group", member_names.size()); - } - - return CanMembersJoin(member_names); -} - -std::string ExpeditionRequest::GetGroupLeaderName(uint32_t group_id) -{ - char leader_name_buffer[64] = { 0 }; - database.GetGroupLeadershipInfo(group_id, leader_name_buffer); - return std::string(leader_name_buffer); -} - -bool ExpeditionRequest::CanMembersJoin(const std::vector& member_names) -{ - if (member_names.empty()) - { - return false; - } - - bool requirements_met = true; - - if (CheckMembersForConflicts(member_names)) - { - requirements_met = false; - } - - // live only checks player count requirement after other expensive checks pass (?) - // maybe it's done intentionally as a way to preview lockout conflicts - if (requirements_met) - { - requirements_met = IsPlayerCountValidated(); - } - - return requirements_met; -} - -bool ExpeditionRequest::SaveLeaderLockouts(const std::vector& lockouts) -{ - bool has_replay_lockout = false; - - for (const auto& lockout : lockouts) - { - if (!lockout.IsExpired()) - { - m_lockouts[lockout.GetEventName()] = lockout; - - if (lockout.IsReplayTimer()) - { - has_replay_lockout = true; - } - } - } - - return has_replay_lockout; -} - -bool ExpeditionRequest::CheckMembersForConflicts(const std::vector& member_names) -{ - // order of member_names is preserved by queries for use with max member truncation - auto entries = ExpeditionsRepository::GetCharactersWithExpedition(database, member_names); - if (entries.empty()) - { - LogExpeditions("Failed to load members for expedition request"); - return true; - } - - bool is_solo = (member_names.size() == 1); - bool has_conflicts = false; - - std::vector character_ids; - for (const auto& character : entries) - { - if (is_solo && character.expedition_id != 0) - { - // live doesn't bother checking replay lockout here - SendLeaderMemberInExpedition(character.name, is_solo); - return true; - } - - m_members.emplace_back(character.id, character.name, DynamicZoneMemberStatus::Online); - character_ids.emplace_back(character.id); - } - - auto member_lockouts = CharacterExpeditionLockoutsRepository::GetManyCharacterLockoutTimers( - database, character_ids, m_expedition_name, DZ_REPLAY_TIMER_NAME); - - // on live if leader has a replay lockout it never checks for event conflicts - bool leader_has_replay_lockout = false; - auto lockout_iter = member_lockouts.find(m_leader_id); - if (lockout_iter != member_lockouts.end()) - { - leader_has_replay_lockout = SaveLeaderLockouts(lockout_iter->second); - } - - for (const auto& character : entries) - { - if (character.expedition_id != 0) - { - has_conflicts = true; - SendLeaderMemberInExpedition(character.name, is_solo); - } - - auto lockout_iter = member_lockouts.find(character.id); - if (lockout_iter != member_lockouts.end()) - { - for (const auto& lockout : lockout_iter->second) - { - if (!lockout.IsExpired()) - { - // replay timers were sorted by query so they show up before event conflicts - if (lockout.IsReplayTimer()) - { - has_conflicts = true; - SendLeaderMemberReplayLockout(character.name, lockout, is_solo); - } - else if (!leader_has_replay_lockout && character.id != m_leader_id && - m_lockouts.find(lockout.GetEventName()) == m_lockouts.end()) - { - // leader doesn't have this lockout - has_conflicts = true; - SendLeaderMemberEventLockout(character.name, lockout); - } - } - } - } - } - - return has_conflicts; -} - -void ExpeditionRequest::SendLeaderMessage( - uint16_t chat_type, uint32_t string_id, const std::initializer_list& args) -{ - if (!m_disable_messages) - { - Client::SendCrossZoneMessageString(m_leader, m_leader_name, chat_type, string_id, args); - } -} - -void ExpeditionRequest::SendLeaderMemberInExpedition(const std::string& member_name, bool is_solo) -{ - if (m_disable_messages) - { - return; - } - - if (is_solo) - { - SendLeaderMessage(Chat::Red, EXPEDITION_YOU_BELONG); - } - else if (m_requester) - { - std::string message = fmt::format(EXPEDITION_OTHER_BELONGS, m_requester->GetName(), member_name); - Client::SendCrossZoneMessage(m_leader, m_leader_name, Chat::Red, message); - } -} - -void ExpeditionRequest::SendLeaderMemberReplayLockout( - const std::string& member_name, const ExpeditionLockoutTimer& lockout, bool is_solo) -{ - if (m_disable_messages) - { - return; - } - - auto time_remaining = lockout.GetDaysHoursMinutesRemaining(); - if (is_solo) - { - SendLeaderMessage(Chat::Red, EXPEDITION_YOU_PLAYED_HERE, { - time_remaining.days, time_remaining.hours, time_remaining.mins - }); - } - else - { - SendLeaderMessage(Chat::Red, EXPEDITION_REPLAY_TIMER, { - member_name, time_remaining.days, time_remaining.hours, time_remaining.mins - }); - } -} - -void ExpeditionRequest::SendLeaderMemberEventLockout( - const std::string& member_name, const ExpeditionLockoutTimer& lockout) -{ - if (m_disable_messages) - { - return; - } - - auto time_remaining = lockout.GetDaysHoursMinutesRemaining(); - SendLeaderMessage(Chat::Red, EXPEDITION_EVENT_TIMER, { - member_name, - lockout.GetEventName(), - time_remaining.days, - time_remaining.hours, - time_remaining.mins, - lockout.GetEventName() - }); -} - -bool ExpeditionRequest::IsPlayerCountValidated() -{ - // note: offline group members count towards requirement but not added to expedition - bool requirements_met = true; - - auto bypass_status = RuleI(Expedition, MinStatusToBypassPlayerCountRequirements); - auto gm_bypass = (m_requester && m_requester->GetGM() && m_requester->Admin() >= bypass_status); - - if (m_members.size() > m_max_players) - { - // members were sorted at start, truncate after conflict checks to act like live - m_members.resize(m_max_players); - } - else if (!gm_bypass && m_members.size() < m_min_players) - { - requirements_met = false; - - SendLeaderMessage(Chat::System, REQUIRED_PLAYER_COUNT, { - fmt::format_int(m_members.size()).str(), - fmt::format_int(m_min_players).str(), - fmt::format_int(m_max_players).str() - }); - } - - return requirements_met; -} diff --git a/zone/expedition_request.h b/zone/expedition_request.h deleted file mode 100644 index 64c594d3c..000000000 --- a/zone/expedition_request.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EXPEDITION_REQUEST_H -#define EXPEDITION_REQUEST_H - -#include "expedition.h" -#include "../common/expedition_lockout_timer.h" -#include -#include -#include -#include - -class Client; -class Group; -class Raid; - -class ExpeditionRequest -{ -public: - ExpeditionRequest(std::string expedition_name, uint32_t min_players, - uint32_t max_players, bool disable_messages = false); - - bool Validate(Client* requester); - - const std::string& GetExpeditionName() const { return m_expedition_name; } - Client* GetLeaderClient() const { return m_leader; } - uint32_t GetLeaderID() const { return m_leader_id; } - const std::string& GetLeaderName() const { return m_leader_name; } - const std::string& GetNotAllAddedMessage() const { return m_not_all_added_msg; } - uint32_t GetMinPlayers() const { return m_min_players; } - uint32_t GetMaxPlayers() const { return m_max_players; } - std::vector GetMembers() const { return m_members; } - std::unordered_map GetLockouts() const { return m_lockouts; } - -private: - bool CanMembersJoin(const std::vector& member_names); - bool CanRaidRequest(Raid* raid); - bool CanGroupRequest(Group* group); - bool CheckMembersForConflicts(const std::vector& member_names); - std::string GetGroupLeaderName(uint32_t group_id); - bool IsPlayerCountValidated(); - bool SaveLeaderLockouts(const std::vector& leader_lockouts); - void SendLeaderMemberInExpedition(const std::string& member_name, bool is_solo); - void SendLeaderMemberReplayLockout(const std::string& member_name, const ExpeditionLockoutTimer& lockout, bool is_solo); - void SendLeaderMemberEventLockout(const std::string& member_name, const ExpeditionLockoutTimer& lockout); - void SendLeaderMessage(uint16_t chat_type, uint32_t string_id, const std::initializer_list& args = {}); - - Client* m_requester = nullptr; - Client* m_leader = nullptr; - uint32_t m_leader_id = 0; - uint32_t m_min_players = 0; - uint32_t m_max_players = 0; - bool m_disable_messages = false; - std::string m_expedition_name; - std::string m_leader_name; - std::string m_not_all_added_msg; - std::vector m_members; - std::unordered_map m_lockouts; -}; - -#endif diff --git a/zone/groups.cpp b/zone/groups.cpp index 13188dcb9..5734d4672 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -18,7 +18,6 @@ #include "../common/global_define.h" #include "../common/eqemu_logsys.h" -#include "expedition.h" #include "masterentity.h" #include "npc_ai.h" #include "../common/packet_functions.h" @@ -499,9 +498,6 @@ void Group::SendEndurancePacketFrom(Mob* member) //if the group was in the zone already bool Group::UpdatePlayer(Mob* update){ - if (!update) - return false; - bool updateSuccess = false; VerifyGroup(); @@ -1006,14 +1002,14 @@ void Group::DisbandGroup(bool joinraid) { database.ClearGroup(GetID()); } + entity_list.RemoveGroup(GetID()); + if(Leader && (Leader->IsLFP())) { Leader->UpdateLFP(); } - SetLeader(nullptr); safe_delete(outapp); - entity_list.RemoveGroup(GetID()); } void Group::GetMemberList(std::list& member_list, bool clear_list) @@ -2503,24 +2499,3 @@ void Group::QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_r } } } - -bool Group::DoesAnyMemberHaveExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, int max_check_count) -{ - if (max_check_count <= 0) - { - max_check_count = MAX_GROUP_MEMBERS; - } - - for (int i = 0; i < MAX_GROUP_MEMBERS && i < max_check_count; ++i) - { - if (membername[i][0]) - { - if (Expedition::HasLockoutByCharacterName(membername[i], expedition_name, event_name)) - { - return true; - } - } - } - return false; -} diff --git a/zone/groups.h b/zone/groups.h index 57dfdbfb6..0d39409e0 100644 --- a/zone/groups.h +++ b/zone/groups.h @@ -153,8 +153,6 @@ public: inline int GetMentorPercent() { return mentor_percent; } inline Client *GetMentoree() { return mentoree; } - bool DoesAnyMemberHaveExpeditionLockout(const std::string& expedition_name, const std::string& event_name, int max_check_count = 0); - Mob* members[MAX_GROUP_MEMBERS]; char membername[MAX_GROUP_MEMBERS][64]; uint8 MemberRoles[MAX_GROUP_MEMBERS]; diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index b4b6725bb..725918762 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -675,12 +675,10 @@ int HateList::AreaRampage(Mob *caster, Mob *target, int count, ExtraAttackOption std::vector id_list; for (auto &h : list) { if (h->entity_on_hatelist && h->entity_on_hatelist != caster && h->entity_on_hatelist != target && - caster->CombatRange(h->entity_on_hatelist, 1.0, true)) { + caster->CombatRange(h->entity_on_hatelist)) id_list.push_back(h->entity_on_hatelist->GetID()); - } - if (count != -1 && id_list.size() > count) { + if (count != -1 && id_list.size() > count) break; - } } for (auto &id : id_list) { @@ -690,6 +688,7 @@ int HateList::AreaRampage(Mob *caster, Mob *target, int count, ExtraAttackOption caster->ProcessAttackRounds(mob, opts); } } + return hit_count; } @@ -785,15 +784,3 @@ void HateList::RemoveStaleEntries(int time_ms, float dist) } } -std::list HateList::GetHateListByDistance(int distance) -{ - std::list hate_list; - int squared_distance = (distance * distance); - for (auto hate_iterator : list) { - auto hate_entry = hate_iterator->entity_on_hatelist; - if (distance == 0 || (distance > 0 && DistanceSquaredNoZ(hate_owner->GetPosition(), hate_entry->GetPosition()) <= squared_distance)) { - hate_list.push_back(hate_iterator); - } - } - return hate_list; -} diff --git a/zone/hate_list.h b/zone/hate_list.h index 71c1f31cf..44613bdea 100644 --- a/zone/hate_list.h +++ b/zone/hate_list.h @@ -60,7 +60,6 @@ public: int32 GetEntHateAmount(Mob *ent, bool in_damage = false); std::list& GetHateList() { return list; } - std::list GetHateListByDistance(int distance = 0); void AddEntToHateList(Mob *ent, int32 in_hate = 0, int32 in_damage = 0, bool in_is_frenzied = false, bool add_to_hate_list_if_not_exist = true); void DoFactionHits(int32 npc_faction_level_id); diff --git a/zone/horse.cpp b/zone/horse.cpp index a31c58901..0a23995ad 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -36,7 +36,7 @@ Horse::Horse(Client *_owner, uint16 spell_id, const glm::vec4& position) strn0cpy(name, _owner->GetCleanName(), 55); strcat(name,"`s_Mount00"); - is_horse = true; + IsHorse = true; owner = _owner; } diff --git a/zone/inventory.cpp b/zone/inventory.cpp index b3d3b6d2b..b047197d2 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -1154,34 +1154,9 @@ bool Client::AutoPutLootInInventory(EQ::ItemInstance& inst, bool try_worn, bool } } } - if( i == EQ::invslot::slotPrimary && m_inv[EQ::invslot::slotSecondary] ) { - uint8 instrument = m_inv[EQ::invslot::slotSecondary]->GetItem()->ItemType; - if( - instrument == EQ::item::ItemTypeWindInstrument || - instrument == EQ::item::ItemTypeStringedInstrument || - instrument == EQ::item::ItemTypeBrassInstrument || - instrument == EQ::item::ItemTypePercussionInstrument - ) { - LogInventory("Cannot equip a primary item with [{}] already in the secondary.", m_inv[EQ::invslot::slotSecondary]->GetItem()->Name); - continue; // Do not auto-equip Primary when instrument is in Secondary - } - } if (i == EQ::invslot::slotSecondary && m_inv[EQ::invslot::slotPrimary]) { // check to see if primary slot is a two hander - uint8 instrument = inst.GetItem()->ItemType; - if( - instrument == EQ::item::ItemTypeWindInstrument || - instrument == EQ::item::ItemTypeStringedInstrument || - instrument == EQ::item::ItemTypeBrassInstrument || - instrument == EQ::item::ItemTypePercussionInstrument - ) { - LogInventory("Cannot equip a secondary instrument with [{}] already in the primary.", m_inv[EQ::invslot::slotPrimary]->GetItem()->Name); - continue; // Do not auto-equip instrument in Secondary when Primary is equipped. - } - - uint8 use = m_inv[EQ::invslot::slotPrimary]->GetItem()->ItemType; - if(use == EQ::item::ItemType2HSlash || use == EQ::item::ItemType2HBlunt || use == EQ::item::ItemType2HPiercing) { + if (m_inv[EQ::invslot::slotPrimary]->GetItem()->IsType2HWeapon()) continue; - } } if (i == EQ::invslot::slotSecondary && inst.IsWeapon() && !CanThisClassDualWield()) { continue; @@ -1194,6 +1169,7 @@ bool Client::AutoPutLootInInventory(EQ::ItemInstance& inst, bool try_worn, bool if (worn_slot_material != EQ::textures::materialInvalid) { SendWearChange(worn_slot_material); } + parse->EventItem(EVENT_EQUIP_ITEM, this, &inst, nullptr, "", i); return true; } @@ -1355,7 +1331,6 @@ bool MakeItemLink(char* &ret_link, const ItemData *item, uint32 aug0, uint32 aug #endif int Client::GetItemLinkHash(const EQ::ItemInstance* inst) { -#if 0 //pre-Titanium: http://eqitems.13th-floor.org/phpBB2/viewtopic.php?t=70&postdays=0&postorder=asc //Titanium: http://eqitems.13th-floor.org/phpBB2/viewtopic.php?t=145 if (!inst) //have to have an item to make the hash @@ -1441,8 +1416,6 @@ int Client::GetItemLinkHash(const EQ::ItemInstance* inst) { safe_delete_array(hash_str); return hash; -#endif - return 0; } // This appears to still be in use... The core of this should be incorporated into class EQ::SayLinkEngine @@ -1629,10 +1602,11 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if(!banker || distance > USE_NPC_RANGE2) { - auto hacked_string = fmt::format("Player tried to make use of a banker(items) but {} is " - "non-existant or too far away ({} units).", - banker ? banker->GetName() : "UNKNOWN NPC", distance); + char *hacked_string = nullptr; + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(items) but %s is non-existant or too far away (%u units).", + banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); + safe_delete_array(hacked_string); Kick("Inventory desync"); // Kicking player to avoid item loss do to client and server inventories not being sync'd return false; } diff --git a/zone/loottables.cpp b/zone/loottables.cpp index b4e0f00f0..b3f46f649 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -277,22 +277,6 @@ bool NPC::MeetsLootDropLevelRequirements(LootDropEntries_Struct loot_drop) return true; } -LootDropEntries_Struct NPC::NewLootDropEntry() -{ - LootDropEntries_Struct loot_drop{}; - loot_drop.item_id = 0; - loot_drop.item_charges = 1; - loot_drop.equip_item = 1; - loot_drop.chance = 0; - loot_drop.trivial_min_level = 0; - loot_drop.trivial_max_level = 0; - loot_drop.npc_min_level = 0; - loot_drop.npc_max_level = 0; - loot_drop.multiplier = 0; - - return loot_drop; -} - //if itemlist is null, just send wear changes void NPC::AddLootDrop( const EQ::ItemData *item2, @@ -523,39 +507,17 @@ void NPC::AddLootDrop( } } -void NPC::AddItem(const EQ::ItemData *item, uint16 charges, bool equipitem) -{ +void NPC::AddItem(const EQ::ItemData* item, uint16 charges, bool equipitem) { //slot isnt needed, its determined from the item. - auto loot_drop_entry = NPC::NewLootDropEntry(); - loot_drop_entry.equip_item = static_cast(equipitem ? 1 : 0); - loot_drop_entry.item_charges = charges; - - AddLootDrop(item, &itemlist, loot_drop_entry, true); + AddLootDrop(item, &itemlist, LootDropEntries_Struct{ .equip_item = static_cast(equipitem ? 1 : 0) }, true); } -void NPC::AddItem( - uint32 itemid, - uint16 charges, - bool equipitem, - uint32 aug1, - uint32 aug2, - uint32 aug3, - uint32 aug4, - uint32 aug5, - uint32 aug6 -) -{ +void NPC::AddItem(uint32 itemid, uint16 charges, bool equipitem, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6) { //slot isnt needed, its determined from the item. - const EQ::ItemData *i = database.GetItem(itemid); - if (i == nullptr) { + const EQ::ItemData * i = database.GetItem(itemid); + if(i == nullptr) return; - } - - auto loot_drop_entry = NPC::NewLootDropEntry(); - loot_drop_entry.equip_item = static_cast(equipitem ? 1 : 0); - loot_drop_entry.item_charges = charges; - - AddLootDrop(i, &itemlist, loot_drop_entry, true, aug1, aug2, aug3, aug4, aug5, aug6); + AddLootDrop(i, &itemlist, LootDropEntries_Struct{ .equip_item = equipitem }, true, aug1, aug2, aug3, aug4, aug5, aug6); } void NPC::AddLootTable() { diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 6b6265ce5..a6145000d 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -4,10 +4,7 @@ #include #include "client.h" -#include "dynamic_zone.h" -#include "expedition_request.h" #include "lua_client.h" -#include "lua_expedition.h" #include "lua_npc.h" #include "lua_item.h" #include "lua_iteminst.h" @@ -15,7 +12,6 @@ #include "lua_group.h" #include "lua_raid.h" #include "lua_packet.h" -#include "../common/expedition_lockout_timer.h" struct InventoryWhere { }; @@ -69,24 +65,9 @@ void Lua_Client::WorldKick() { self->WorldKick(); } -int Lua_Client::GetAFK() { - Lua_Safe_Call_Int(); - return self->GetAFK(); -} - -void Lua_Client::SetAFK(uint8 afk_flag) { - Lua_Safe_Call_Void(); - self->SetAFK(afk_flag); -} - -int Lua_Client::GetAnon() { - Lua_Safe_Call_Int(); - return self->GetAnon(); -} - -void Lua_Client::SetAnon(uint8 anon_flag) { - Lua_Safe_Call_Void(); - self->SetAnon(anon_flag); +bool Lua_Client::GetAnon() { + Lua_Safe_Call_Bool(); + return self->GetAnon() != 0; } void Lua_Client::Duck() { @@ -149,16 +130,6 @@ void Lua_Client::SetBaseGender(int v) { self->SetBaseGender(v); } -int Lua_Client::GetClassBitmask() { - Lua_Safe_Call_Int(); - return GetPlayerClassBit(self->GetClass()); -} - -int Lua_Client::GetRaceBitmask() { - Lua_Safe_Call_Int(); - return GetPlayerRaceBit(self->GetBaseRace()); -} - int Lua_Client::GetBaseFace() { Lua_Safe_Call_Int(); return self->GetBaseFace(); @@ -169,6 +140,11 @@ int Lua_Client::GetLanguageSkill(int skill_id) { return self->GetLanguageSkill(skill_id); } +const char *Lua_Client::GetLastName() { + Lua_Safe_Call_String(); + return self->GetLastName(); +} + int Lua_Client::GetLDoNPointsTheme(int theme) { Lua_Safe_Call_Int(); return self->GetLDoNPointsTheme(theme); @@ -299,11 +275,6 @@ void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float n self->SetBindPoint(0, to_zone, to_instance, glm::vec3(new_x, new_y, new_z)); } -void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z, float new_heading) { - Lua_Safe_Call_Void(); - self->SetBindPoint2(0, to_zone, to_instance, glm::vec4(new_x, new_y, new_z, new_heading)); -} - float Lua_Client::GetBindX() { Lua_Safe_Call_Real(); return self->GetBindX(); @@ -354,21 +325,6 @@ uint32 Lua_Client::GetBindZoneID(int index) { return self->GetBindZoneID(index); } -float Lua_Client::GetTargetRingX() { - Lua_Safe_Call_Real(); - return self->GetTargetRingX(); -} - -float Lua_Client::GetTargetRingY() { - Lua_Safe_Call_Real(); - return self->GetTargetRingY(); -} - -float Lua_Client::GetTargetRingZ() { - Lua_Safe_Call_Real(); - return self->GetTargetRingZ(); -} - void Lua_Client::MovePC(int zone, float x, float y, float z, float heading) { Lua_Safe_Call_Void(); self->MovePC(zone, x, y, z, heading); @@ -649,132 +605,6 @@ int Lua_Client::MemmedCount() { return self->MemmedCount(); } -luabind::object Lua_Client::GetLearnableDisciplines(lua_State* L) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto learnable_disciplines = self->GetLearnableDisciplines(); - int index = 0; - for (auto spell_id : learnable_disciplines) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetLearnableDisciplines(lua_State* L, uint8 min_level) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto learnable_disciplines = self->GetLearnableDisciplines(min_level); - int index = 0; - for (auto spell_id : learnable_disciplines) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetLearnableDisciplines(lua_State* L, uint8 min_level, uint8 max_level) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto learnable_disciplines = self->GetLearnableDisciplines(min_level, max_level); - int index = 0; - for (auto spell_id : learnable_disciplines) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetLearnedDisciplines(lua_State* L) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto learned_disciplines = self->GetLearnedDisciplines(); - int index = 0; - for (auto spell_id : learned_disciplines) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetMemmedSpells(lua_State* L) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto memmed_spells = self->GetMemmedSpells(); - int index = 0; - for (auto spell_id : memmed_spells) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetScribeableSpells(lua_State* L) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto scribeable_spells = self->GetScribeableSpells(); - int index = 0; - for (auto spell_id : scribeable_spells) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetScribeableSpells(lua_State* L, uint8 min_level) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto scribeable_spells = self->GetScribeableSpells(min_level); - int index = 0; - for (auto spell_id : scribeable_spells) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetScribeableSpells(lua_State* L, uint8 min_level, uint8 max_level) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto scribeable_spells = self->GetScribeableSpells(min_level, max_level); - int index = 0; - for (auto spell_id : scribeable_spells) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - -luabind::object Lua_Client::GetScribedSpells(lua_State* L) { - auto lua_table = luabind::newtable(L); - if (d_) { - auto self = reinterpret_cast(d_); - auto scribed_spells = self->GetScribedSpells(); - int index = 0; - for (auto spell_id : scribed_spells) { - lua_table[index] = spell_id; - index++; - } - } - return lua_table; -} - void Lua_Client::ScribeSpell(int spell_id, int slot) { Lua_Safe_Call_Void(); self->ScribeSpell(spell_id, slot); @@ -1070,11 +900,6 @@ bool Lua_Client::UseDiscipline(int spell_id, int target_id) { return self->UseDiscipline(spell_id, target_id); } -bool Lua_Client::HasDisciplineLearned(uint16 spell_id) { - Lua_Safe_Call_Bool(); - return self->HasDisciplineLearned(spell_id); -} - int Lua_Client::GetCharacterFactionLevel(int faction_id) { Lua_Safe_Call_Int(); return self->GetCharacterFactionLevel(faction_id); @@ -1215,16 +1040,6 @@ void Lua_Client::AddCrystals(uint32 radiant, uint32 ebon) { self->AddCrystals(radiant, ebon); } -void Lua_Client::SetEbonCrystals(uint32 value) { - Lua_Safe_Call_Void(); - self->SetEbonCrystals(value); -} - -void Lua_Client::SetRadiantCrystals(uint32 value) { - Lua_Safe_Call_Void(); - self->SetRadiantCrystals(value); -} - uint32 Lua_Client::GetPVPPoints() { Lua_Safe_Call_Int(); return self->GetPVPPoints(); @@ -1345,11 +1160,6 @@ int Lua_Client::GetNextAvailableSpellBookSlot() { return self->GetNextAvailableSpellBookSlot(); } -uint32 Lua_Client::GetSpellIDByBookSlot(int slot_id) { - Lua_Safe_Call_Int(); - return self->GetSpellIDByBookSlot(slot_id); -} - int Lua_Client::GetNextAvailableSpellBookSlot(int start) { Lua_Safe_Call_Int(); return self->GetNextAvailableSpellBookSlot(start); @@ -1819,269 +1629,7 @@ int Lua_Client::GetClientMaxLevel() { return self->GetClientMaxLevel(); } -DynamicZoneLocation GetDynamicZoneLocationFromTable(const luabind::object& lua_table) -{ - DynamicZoneLocation zone_location; - if (luabind::type(lua_table) == LUA_TTABLE) - { - luabind::object lua_zone = lua_table["zone"]; - - // default invalid/missing args to 0 - uint32_t zone_id = 0; - if (luabind::type(lua_zone) == LUA_TSTRING) - { - zone_id = ZoneID(luabind::object_cast(lua_zone)); - } - else if (luabind::type(lua_zone) == LUA_TNUMBER) - { - zone_id = luabind::object_cast(lua_zone); - } - - float x = (luabind::type(lua_table["x"]) != LUA_TNIL) ? luabind::object_cast(lua_table["x"]) : 0.0f; - float y = (luabind::type(lua_table["y"]) != LUA_TNIL) ? luabind::object_cast(lua_table["y"]) : 0.0f; - float z = (luabind::type(lua_table["z"]) != LUA_TNIL) ? luabind::object_cast(lua_table["z"]) : 0.0f; - float h = (luabind::type(lua_table["h"]) != LUA_TNIL) ? luabind::object_cast(lua_table["h"]) : 0.0f; - - zone_location = { zone_id, x, y, z, h }; - } - - return zone_location; -} - -Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) { - Lua_Safe_Call_Class(Lua_Expedition); - - if (luabind::type(expedition_table) != LUA_TTABLE) - { - return nullptr; - } - - // luabind will catch thrown cast_failed exceptions for invalid/missing args - luabind::object instance_info = expedition_table["instance"]; - luabind::object zone = instance_info["zone"]; - - uint32_t zone_id = 0; - if (luabind::type(zone) == LUA_TSTRING) - { - zone_id = ZoneID(luabind::object_cast(zone)); - } - else if (luabind::type(zone) == LUA_TNUMBER) - { - zone_id = luabind::object_cast(zone); - } - - uint32_t zone_version = luabind::object_cast(instance_info["version"]); - uint32_t zone_duration = luabind::object_cast(instance_info["duration"]); - - DynamicZone dz{ zone_id, zone_version, zone_duration, DynamicZoneType::Expedition }; - - // the dz_info table supports optional hash entries for 'compass', 'safereturn', and 'zonein' data - if (luabind::type(expedition_table["compass"]) == LUA_TTABLE) - { - auto compass_loc = GetDynamicZoneLocationFromTable(expedition_table["compass"]); - dz.SetCompass(compass_loc); - } - - if (luabind::type(expedition_table["safereturn"]) == LUA_TTABLE) - { - auto safereturn_loc = GetDynamicZoneLocationFromTable(expedition_table["safereturn"]); - dz.SetSafeReturn(safereturn_loc); - } - - if (luabind::type(expedition_table["zonein"]) == LUA_TTABLE) - { - auto zonein_loc = GetDynamicZoneLocationFromTable(expedition_table["zonein"]); - dz.SetZoneInLocation(zonein_loc); - } - - luabind::object expedition_info = expedition_table["expedition"]; - - std::string expedition_name = luabind::object_cast(expedition_info["name"]); - uint32_t min_players = luabind::object_cast(expedition_info["min_players"]); - uint32_t max_players = luabind::object_cast(expedition_info["max_players"]); - bool disable_messages = false; - - if (luabind::type(expedition_info["disable_messages"]) == LUA_TBOOLEAN) - { - disable_messages = luabind::object_cast(expedition_info["disable_messages"]); - } - - ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages }; - - return self->CreateExpedition(dz, request); -} - -Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players) { - Lua_Safe_Call_Class(Lua_Expedition); - return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players); -} - -Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players, bool disable_messages) { - Lua_Safe_Call_Class(Lua_Expedition); - return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players, disable_messages); -} - -Lua_Expedition Lua_Client::GetExpedition() { - Lua_Safe_Call_Class(Lua_Expedition); - return self->GetExpedition(); -} - -luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L) -{ - auto lua_table = luabind::newtable(L); - if (d_) - { - auto self = reinterpret_cast(d_); - auto lockouts = self->GetExpeditionLockouts(); - - for (const auto& lockout : lockouts) - { - auto lockout_table = lua_table[lockout.GetExpeditionName()]; - if (luabind::type(lockout_table) != LUA_TTABLE) - { - lockout_table = luabind::newtable(L); - } - lockout_table[lockout.GetEventName()] = lockout.GetSecondsRemaining(); - } - } - return lua_table; -} - -luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L, std::string expedition_name) -{ - auto lua_table = luabind::newtable(L); - if (d_) - { - auto self = reinterpret_cast(d_); - auto lockouts = self->GetExpeditionLockouts(); - - for (const auto& lockout : lockouts) - { - if (lockout.GetExpeditionName() == expedition_name) - { - lua_table[lockout.GetEventName()] = lockout.GetSecondsRemaining(); - } - } - } - return lua_table; -} - -std::string Lua_Client::GetLockoutExpeditionUUID(std::string expedition_name, std::string event_name) { - Lua_Safe_Call_String(); - std::string uuid; - auto lockout = self->GetExpeditionLockout(expedition_name, event_name); - if (lockout) - { - uuid = lockout->GetExpeditionUUID(); - } - return uuid; -} - -void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds) { - Lua_Safe_Call_Void(); - self->AddNewExpeditionLockout(expedition_name, event_name, seconds); -} - -void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) { - Lua_Safe_Call_Void(); - self->AddNewExpeditionLockout(expedition_name, event_name, seconds, uuid); -} - -void Lua_Client::AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds) { - Lua_Safe_Call_Void(); - self->AddExpeditionLockoutDuration(expedition_name, event_name, seconds, {}, true); -} - -void Lua_Client::AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds, std::string uuid) { - Lua_Safe_Call_Void(); - self->AddExpeditionLockoutDuration(expedition_name, event_name, seconds, uuid, true); -} - -void Lua_Client::RemoveAllExpeditionLockouts() { - Lua_Safe_Call_Void(); - self->RemoveAllExpeditionLockouts({}, true); -} - -void Lua_Client::RemoveAllExpeditionLockouts(std::string expedition_name) { - Lua_Safe_Call_Void(); - self->RemoveAllExpeditionLockouts(expedition_name, true); -} - -void Lua_Client::RemoveExpeditionLockout(std::string expedition_name, std::string event_name) { - Lua_Safe_Call_Void(); - self->RemoveExpeditionLockout(expedition_name, event_name, true); -} - -bool Lua_Client::HasExpeditionLockout(std::string expedition_name, std::string event_name) { - Lua_Safe_Call_Bool(); - return self->HasExpeditionLockout(expedition_name, event_name); -} - -void Lua_Client::MovePCDynamicZone(uint32 zone_id) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_id); -} - -void Lua_Client::MovePCDynamicZone(uint32 zone_id, int zone_version) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_id, zone_version); -} - -void Lua_Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_invalid) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_id, zone_version, msg_if_invalid); -} - -void Lua_Client::MovePCDynamicZone(std::string zone_name) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_name); -} - -void Lua_Client::MovePCDynamicZone(std::string zone_name, int zone_version) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_name, zone_version); -} - -void Lua_Client::MovePCDynamicZone(std::string zone_name, int zone_version, bool msg_if_invalid) { - Lua_Safe_Call_Void(); - return self->MovePCDynamicZone(zone_name, zone_version, msg_if_invalid); -} - -void Lua_Client::Fling(float value, float target_x, float target_y, float target_z) { - Lua_Safe_Call_Void(); - self->Fling(value, target_x, target_y, target_z); -} - -void Lua_Client::Fling(float value, float target_x, float target_y, float target_z, bool ignore_los) { - Lua_Safe_Call_Void(); - self->Fling(value, target_x, target_y, target_z, ignore_los); -} - -void Lua_Client::Fling(float value, float target_x, float target_y, float target_z, bool ignore_los, bool clipping) { - Lua_Safe_Call_Void(); - self->Fling(value, target_x, target_y, target_z, ignore_los, clipping); -} - -double Lua_Client::GetAAEXPModifier(uint32 zone_id) { - Lua_Safe_Call_Real(); - return self->GetAAEXPModifier(zone_id); -} - -double Lua_Client::GetEXPModifier(uint32 zone_id) { - Lua_Safe_Call_Real(); - return self->GetEXPModifier(zone_id); -} - -void Lua_Client::SetAAEXPModifier(uint32 zone_id, double aa_modifier) { - Lua_Safe_Call_Void(); - self->SetAAEXPModifier(zone_id, aa_modifier); -} - -void Lua_Client::SetEXPModifier(uint32 zone_id, double exp_modifier) { - Lua_Safe_Call_Void(); - self->SetEXPModifier(zone_id, exp_modifier); -} luabind::scope lua_register_client() { return luabind::class_("Client") @@ -2097,10 +1645,7 @@ luabind::scope lua_register_client() { .def("IsLD", (bool(Lua_Client::*)(void))&Lua_Client::IsLD) .def("WorldKick", (void(Lua_Client::*)(void))&Lua_Client::WorldKick) .def("SendToGuildHall", (void(Lua_Client::*)(void))&Lua_Client::SendToGuildHall) - .def("GetAFK", (int(Lua_Client::*)(void))&Lua_Client::GetAFK) - .def("SetAFK", (void(Lua_Client::*)(uint8))&Lua_Client::SetAFK) - .def("GetAnon", (int(Lua_Client::*)(void))&Lua_Client::GetAnon) - .def("SetAnon", (void(Lua_Client::*)(uint8))&Lua_Client::SetAnon) + .def("GetAnon", (bool(Lua_Client::*)(void))&Lua_Client::GetAnon) .def("Duck", (void(Lua_Client::*)(void))&Lua_Client::Duck) .def("DyeArmorBySlot", (void(Lua_Client::*)(uint8,uint8,uint8,uint8))&Lua_Client::DyeArmorBySlot) .def("DyeArmorBySlot", (void(Lua_Client::*)(uint8,uint8,uint8,uint8,uint8))&Lua_Client::DyeArmorBySlot) @@ -2112,10 +1657,9 @@ luabind::scope lua_register_client() { .def("SetBaseClass", (void(Lua_Client::*)(int))&Lua_Client::SetBaseClass) .def("SetBaseRace", (void(Lua_Client::*)(int))&Lua_Client::SetBaseRace) .def("SetBaseGender", (void(Lua_Client::*)(int))&Lua_Client::SetBaseGender) - .def("GetClassBitmask", (int(Lua_Client::*)(void))&Lua_Client::GetClassBitmask) - .def("GetRaceBitmask", (int(Lua_Client::*)(void))&Lua_Client::GetRaceBitmask) .def("GetBaseFace", (int(Lua_Client::*)(void))&Lua_Client::GetBaseFace) .def("GetLanguageSkill", (int(Lua_Client::*)(int))&Lua_Client::GetLanguageSkill) + .def("GetLastName", (const char *(Lua_Client::*)(void))&Lua_Client::GetLastName) .def("GetLDoNPointsTheme", (int(Lua_Client::*)(int))&Lua_Client::GetLDoNPointsTheme) .def("GetBaseSTR", (int(Lua_Client::*)(void))&Lua_Client::GetBaseSTR) .def("GetBaseSTA", (int(Lua_Client::*)(void))&Lua_Client::GetBaseSTA) @@ -2141,8 +1685,7 @@ luabind::scope lua_register_client() { .def("SetBindPoint", (void(Lua_Client::*)(int,int))&Lua_Client::SetBindPoint) .def("SetBindPoint", (void(Lua_Client::*)(int,int,float))&Lua_Client::SetBindPoint) .def("SetBindPoint", (void(Lua_Client::*)(int,int,float,float))&Lua_Client::SetBindPoint) - .def("SetBindPoint", (void(Lua_Client::*)(int,int,float,float,float))&Lua_Client::SetBindPoint) - .def("SetBindPoint", (void(Lua_Client::*)(int,int,float,float,float,float))&Lua_Client::SetBindPoint) + .def("SetBindPoint", (void(Lua_Client::*)(int,int,float,float, float))&Lua_Client::SetBindPoint) .def("GetBindX", (float(Lua_Client::*)(void))&Lua_Client::GetBindX) .def("GetBindX", (float(Lua_Client::*)(int))&Lua_Client::GetBindX) .def("GetBindY", (float(Lua_Client::*)(void))&Lua_Client::GetBindY) @@ -2153,9 +1696,6 @@ luabind::scope lua_register_client() { .def("GetBindHeading", (float(Lua_Client::*)(int))&Lua_Client::GetBindHeading) .def("GetBindZoneID", (uint32(Lua_Client::*)(void))&Lua_Client::GetBindZoneID) .def("GetBindZoneID", (uint32(Lua_Client::*)(int))&Lua_Client::GetBindZoneID) - .def("GetTargetRingX", (float(Lua_Client::*)(void))&Lua_Client::GetTargetRingX) - .def("GetTargetRingY", (float(Lua_Client::*)(void))&Lua_Client::GetTargetRingY) - .def("GetTargetRingZ", (float(Lua_Client::*)(void))&Lua_Client::GetTargetRingZ) .def("SetPrimaryWeaponOrnamentation", (void(Lua_Client::*)(uint32))&Lua_Client::SetPrimaryWeaponOrnamentation) .def("SetSecondaryWeaponOrnamentation", (void(Lua_Client::*)(uint32))&Lua_Client::SetSecondaryWeaponOrnamentation) .def("MovePC", (void(Lua_Client::*)(int,float,float,float,float))&Lua_Client::MovePC) @@ -2214,15 +1754,6 @@ luabind::scope lua_register_client() { .def("UnmemSpellAll", (void(Lua_Client::*)(bool))&Lua_Client::UnmemSpellAll) .def("FindMemmedSpellBySlot", (uint16(Lua_Client::*)(int))&Lua_Client::FindMemmedSpellBySlot) .def("MemmedCount", (int(Lua_Client::*)(void))&Lua_Client::MemmedCount) - .def("GetLearnableDisciplines", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetLearnableDisciplines) - .def("GetLearnableDisciplines", (luabind::object(Lua_Client::*)(lua_State* L,uint8))&Lua_Client::GetLearnableDisciplines) - .def("GetLearnableDisciplines", (luabind::object(Lua_Client::*)(lua_State* L,uint8,uint8))&Lua_Client::GetLearnableDisciplines) - .def("GetLearnedDisciplines", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetLearnedDisciplines) - .def("GetMemmedSpells", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetMemmedSpells) - .def("GetScribedSpells", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetScribedSpells) - .def("GetScribeableSpells", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetScribeableSpells) - .def("GetScribeableSpells", (luabind::object(Lua_Client::*)(lua_State* L,uint8))&Lua_Client::GetScribeableSpells) - .def("GetScribeableSpells", (luabind::object(Lua_Client::*)(lua_State* L,uint8,uint8))&Lua_Client::GetScribeableSpells) .def("ScribeSpell", (void(Lua_Client::*)(int,int))&Lua_Client::ScribeSpell) .def("ScribeSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::ScribeSpell) .def("UnscribeSpell", (void(Lua_Client::*)(int))&Lua_Client::UnscribeSpell) @@ -2282,7 +1813,6 @@ luabind::scope lua_register_client() { .def("GetDisciplineTimer", (uint32(Lua_Client::*)(uint32))&Lua_Client::GetDisciplineTimer) .def("ResetDisciplineTimer", (void(Lua_Client::*)(uint32))&Lua_Client::ResetDisciplineTimer) .def("UseDiscipline", (bool(Lua_Client::*)(int,int))&Lua_Client::UseDiscipline) - .def("HasDisciplineLearned", (bool(Lua_Client::*)(uint16))&Lua_Client::HasDisciplineLearned) .def("GetCharacterFactionLevel", (int(Lua_Client::*)(int))&Lua_Client::GetCharacterFactionLevel) .def("SetZoneFlag", (void(Lua_Client::*)(int))&Lua_Client::SetZoneFlag) .def("ClearZoneFlag", (void(Lua_Client::*)(int))&Lua_Client::ClearZoneFlag) @@ -2311,8 +1841,6 @@ luabind::scope lua_register_client() { .def("KeyRingCheck", (bool(Lua_Client::*)(uint32))&Lua_Client::KeyRingCheck) .def("AddPVPPoints", (void(Lua_Client::*)(uint32))&Lua_Client::AddPVPPoints) .def("AddCrystals", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::AddCrystals) - .def("SetEbonCrystals", (void(Lua_Client::*)(uint32))&Lua_Client::SetEbonCrystals) - .def("SetRadiantCrystals", (void(Lua_Client::*)(uint32))&Lua_Client::SetRadiantCrystals) .def("GetPVPPoints", (uint32(Lua_Client::*)(void))&Lua_Client::GetPVPPoints) .def("GetRadiantCrystals", (uint32(Lua_Client::*)(void))&Lua_Client::GetRadiantCrystals) .def("GetEbonCrystals", (uint32(Lua_Client::*)(void))&Lua_Client::GetEbonCrystals) @@ -2338,7 +1866,6 @@ luabind::scope lua_register_client() { .def("ClearCompassMark",(void(Lua_Client::*)(void))&Lua_Client::ClearCompassMark) .def("GetNextAvailableSpellBookSlot", (int(Lua_Client::*)(void))&Lua_Client::GetNextAvailableSpellBookSlot) .def("GetNextAvailableSpellBookSlot", (int(Lua_Client::*)(int))&Lua_Client::GetNextAvailableSpellBookSlot) - .def("GetSpellIDByBookSlot", (uint32(Lua_Client::*)(int))& Lua_Client::GetSpellIDByBookSlot) .def("FindSpellBookSlotBySpellID", (int(Lua_Client::*)(int))&Lua_Client::FindSpellBookSlotBySpellID) .def("UpdateTaskActivity", (void(Lua_Client::*)(int,int,int))&Lua_Client::UpdateTaskActivity) .def("AssignTask", (void(Lua_Client::*)(int,int))&Lua_Client::AssignTask) @@ -2407,35 +1934,7 @@ luabind::scope lua_register_client() { .def("EnableAreaRegens", &Lua_Client::EnableAreaRegens) .def("DisableAreaRegens", &Lua_Client::DisableAreaRegens) .def("SetClientMaxLevel", (void(Lua_Client::*)(int))&Lua_Client::SetClientMaxLevel) - .def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel) - .def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(luabind::object))&Lua_Client::CreateExpedition) - .def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32, std::string, uint32, uint32))&Lua_Client::CreateExpedition) - .def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32, std::string, uint32, uint32, bool))&Lua_Client::CreateExpedition) - .def("GetExpedition", (Lua_Expedition(Lua_Client::*)(void))&Lua_Client::GetExpedition) - .def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetExpeditionLockouts) - .def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L, std::string))&Lua_Client::GetExpeditionLockouts) - .def("GetLockoutExpeditionUUID", (std::string(Lua_Client::*)(std::string, std::string))&Lua_Client::GetLockoutExpeditionUUID) - .def("AddExpeditionLockout", (void(Lua_Client::*)(std::string, std::string, uint32))&Lua_Client::AddExpeditionLockout) - .def("AddExpeditionLockout", (void(Lua_Client::*)(std::string, std::string, uint32, std::string))&Lua_Client::AddExpeditionLockout) - .def("AddExpeditionLockoutDuration", (void(Lua_Client::*)(std::string, std::string, int))&Lua_Client::AddExpeditionLockoutDuration) - .def("AddExpeditionLockoutDuration", (void(Lua_Client::*)(std::string, std::string, int, std::string))&Lua_Client::AddExpeditionLockoutDuration) - .def("RemoveAllExpeditionLockouts", (void(Lua_Client::*)(void))&Lua_Client::RemoveAllExpeditionLockouts) - .def("RemoveAllExpeditionLockouts", (void(Lua_Client::*)(std::string))&Lua_Client::RemoveAllExpeditionLockouts) - .def("RemoveExpeditionLockout", (void(Lua_Client::*)(std::string, std::string))&Lua_Client::RemoveExpeditionLockout) - .def("HasExpeditionLockout", (bool(Lua_Client::*)(std::string, std::string))&Lua_Client::HasExpeditionLockout) - .def("MovePCDynamicZone", (void(Lua_Client::*)(uint32))&Lua_Client::MovePCDynamicZone) - .def("MovePCDynamicZone", (void(Lua_Client::*)(uint32, int))&Lua_Client::MovePCDynamicZone) - .def("MovePCDynamicZone", (void(Lua_Client::*)(uint32, int, bool))&Lua_Client::MovePCDynamicZone) - .def("MovePCDynamicZone", (void(Lua_Client::*)(std::string))&Lua_Client::MovePCDynamicZone) - .def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int))&Lua_Client::MovePCDynamicZone) - .def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int, bool))&Lua_Client::MovePCDynamicZone) - .def("Fling", (void(Lua_Client::*)(float,float,float,float))&Lua_Client::Fling) - .def("Fling", (void(Lua_Client::*)(float,float,float,float,bool))&Lua_Client::Fling) - .def("Fling", (void(Lua_Client::*)(float,float,float,float,bool,bool))&Lua_Client::Fling) - .def("GetAAEXPModifier", (double(Lua_Client::*)(uint32))&Lua_Client::GetAAEXPModifier) - .def("GetEXPModifier", (double(Lua_Client::*)(uint32))&Lua_Client::GetEXPModifier) - .def("SetAAEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetAAEXPModifier) - .def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier); + .def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel); } luabind::scope lua_register_inventory_where() { diff --git a/zone/lua_client.h b/zone/lua_client.h index bfd0f6b84..5900930f0 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -5,7 +5,6 @@ #include "lua_mob.h" class Client; -class Lua_Expedition; class Lua_Group; class Lua_Raid; class Lua_Inventory; @@ -41,10 +40,7 @@ public: bool IsLD(); void WorldKick(); void SendToGuildHall(); - int GetAnon(); - void SetAnon(uint8 anon_flag); - int GetAFK(); - void SetAFK(uint8 afk_flag); + bool GetAnon(); void Duck(); void DyeArmorBySlot(uint8 slot, uint8 red, uint8 green, uint8 blue); void DyeArmorBySlot(uint8 slot, uint8 red, uint8 green, uint8 blue, uint8 use_tint); @@ -55,11 +51,10 @@ public: bool GetGM(); void SetBaseClass(int v); void SetBaseRace(int v); - void SetBaseGender(int v); - int GetClassBitmask(); - int GetRaceBitmask(); + void SetBaseGender(int v); int GetBaseFace(); int GetLanguageSkill(int skill_id); + const char *GetLastName(); int GetLDoNPointsTheme(int theme); int GetBaseSTR(); int GetBaseSTA(); @@ -70,10 +65,6 @@ public: int GetBaseWIS(); int GetWeight(); uint32 GetEXP(); - double GetEXPModifier(uint32 zone_id); - double GetAAEXPModifier(uint32 zone_id); - void SetAAEXPModifier(uint32 zone_id, double aa_modifier); - void SetEXPModifier(uint32 zone_id, double exp_modifier); uint32 GetAAExp(); uint32 GetAAPercent(); uint32 GetTotalSecondsPlayed(); @@ -90,7 +81,6 @@ public: void SetBindPoint(int to_zone, int to_instance, float new_x); void SetBindPoint(int to_zone, int to_instance, float new_x, float new_y); void SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z); - void SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z, float new_heading); float GetBindX(); float GetBindX(int index); float GetBindY(); @@ -101,9 +91,6 @@ public: float GetBindHeading(int index); uint32 GetBindZoneID(); uint32 GetBindZoneID(int index); - float GetTargetRingX(); - float GetTargetRingY(); - float GetTargetRingZ(); void MovePC(int zone, float x, float y, float z, float heading); void MovePCInstance(int zone, int instance, float x, float y, float z, float heading); void MoveZone(const char *zone_short_name); @@ -159,15 +146,6 @@ public: void UnmemSpellAll(bool update_client); uint16 FindMemmedSpellBySlot(int slot); int MemmedCount(); - luabind::object GetLearnableDisciplines(lua_State* L); - luabind::object GetLearnableDisciplines(lua_State* L, uint8 min_level); - luabind::object GetLearnableDisciplines(lua_State* L, uint8 min_level, uint8 max_level); - luabind::object GetLearnedDisciplines(lua_State* L); - luabind::object GetMemmedSpells(lua_State* L); - luabind::object GetScribedSpells(lua_State* L); - luabind::object GetScribeableSpells(lua_State* L); - luabind::object GetScribeableSpells(lua_State* L, uint8 min_level); - luabind::object GetScribeableSpells(lua_State* L, uint8 min_level, uint8 max_level); void ScribeSpell(int spell_id, int slot); void ScribeSpell(int spell_id, int slot, bool update_client); void UnscribeSpell(int slot); @@ -229,7 +207,6 @@ public: uint32 GetDisciplineTimer(uint32 timer_id); void ResetDisciplineTimer(uint32 timer_id); bool UseDiscipline(int spell_id, int target_id); - bool HasDisciplineLearned(uint16 spell_id); int GetCharacterFactionLevel(int faction_id); void SetZoneFlag(int zone_id); void ClearZoneFlag(int zone_id); @@ -254,13 +231,10 @@ public: void SetStartZone(int zone_id, float x); void SetStartZone(int zone_id, float x, float y); void SetStartZone(int zone_id, float x, float y, float z); - void SetStartZone(int zone_id, float x, float y, float z, float heading); void KeyRingAdd(uint32 item); bool KeyRingCheck(uint32 item); void AddPVPPoints(uint32 points); void AddCrystals(uint32 radiant, uint32 ebon); - void SetEbonCrystals(uint32 value); - void SetRadiantCrystals(uint32 value); uint32 GetPVPPoints(); uint32 GetRadiantCrystals(); uint32 GetEbonCrystals(); @@ -286,7 +260,6 @@ public: void ClearCompassMark(); int GetNextAvailableSpellBookSlot(); int GetNextAvailableSpellBookSlot(int start); - uint32 GetSpellIDByBookSlot(int book_slot); int FindSpellBookSlotBySpellID(int spell_id); void UpdateTaskActivity(int task, int activity, int count); void AssignTask(int task, int npc_id); @@ -356,36 +329,12 @@ public: void EnableAreaRegens(int value); void DisableAreaRegens(); + void SetPrimaryWeaponOrnamentation(uint32 model_id); void SetSecondaryWeaponOrnamentation(uint32 model_id); void SetClientMaxLevel(int value); int GetClientMaxLevel(); - - Lua_Expedition CreateExpedition(luabind::object expedition_info); - Lua_Expedition CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players); - Lua_Expedition CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players, bool disable_messages); - Lua_Expedition GetExpedition(); - luabind::object GetExpeditionLockouts(lua_State* L); - luabind::object GetExpeditionLockouts(lua_State* L, std::string expedition_name); - std::string GetLockoutExpeditionUUID(std::string expedition_name, std::string event_name); - void AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds); - void AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid); - void AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds); - void AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds, std::string uuid); - void RemoveAllExpeditionLockouts(); - void RemoveAllExpeditionLockouts(std::string expedition_name); - void RemoveExpeditionLockout(std::string expedition_name, std::string event_name); - bool HasExpeditionLockout(std::string expedition_name, std::string event_name); - void MovePCDynamicZone(uint32 zone_id); - void MovePCDynamicZone(uint32 zone_id, int zone_version); - void MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_invalid); - void MovePCDynamicZone(std::string zone_name); - void MovePCDynamicZone(std::string zone_name, int zone_version); - void MovePCDynamicZone(std::string zone_name, int zone_version, bool msg_if_invalid); - void Fling(float value, float target_x, float target_y, float target_z); - void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los); - void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los, bool clipping); }; #endif diff --git a/zone/lua_expedition.cpp b/zone/lua_expedition.cpp deleted file mode 100644 index f19e417ff..000000000 --- a/zone/lua_expedition.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef LUA_EQEMU - -#include "lua_expedition.h" -#include "expedition.h" -#include "zone_store.h" -#include "lua.hpp" -#include -#include - -void Lua_Expedition::AddLockout(std::string event_name, uint32_t seconds) { - Lua_Safe_Call_Void(); - self->AddLockout(event_name, seconds); -} - -void Lua_Expedition::AddLockoutDuration(std::string event_name, int seconds) { - Lua_Safe_Call_Void(); - self->AddLockoutDuration(event_name, seconds); -} - -void Lua_Expedition::AddLockoutDuration(std::string event_name, int seconds, bool members_only) { - Lua_Safe_Call_Void(); - self->AddLockoutDuration(event_name, seconds, members_only); -} - -void Lua_Expedition::AddReplayLockout(uint32_t seconds) { - Lua_Safe_Call_Void(); - self->AddReplayLockout(seconds); -} - -void Lua_Expedition::AddReplayLockoutDuration(int seconds) { - Lua_Safe_Call_Void(); - self->AddReplayLockoutDuration(seconds); -} - -void Lua_Expedition::AddReplayLockoutDuration(int seconds, bool members_only) { - Lua_Safe_Call_Void(); - self->AddReplayLockoutDuration(seconds, members_only); -} - -uint32_t Lua_Expedition::GetDynamicZoneID() { - Lua_Safe_Call_Int(); - return self->GetDynamicZone().GetID(); -} - -uint32_t Lua_Expedition::GetID() { - Lua_Safe_Call_Int(); - return self->GetID(); -} - -int Lua_Expedition::GetInstanceID() { - Lua_Safe_Call_Int(); - return self->GetDynamicZone().GetInstanceID(); -} - -std::string Lua_Expedition::GetLeaderName() { - Lua_Safe_Call_String(); - return self->GetLeaderName(); -} - -luabind::object Lua_Expedition::GetLockouts(lua_State* L) { - luabind::object lua_table = luabind::newtable(L); - - if (d_) - { - auto self = reinterpret_cast(d_); - auto lockouts = self->GetLockouts(); - for (const auto& lockout : lockouts) - { - lua_table[lockout.first] = lockout.second.GetSecondsRemaining(); - } - } - return lua_table; -} - -std::string Lua_Expedition::GetLootEventByNPCTypeID(uint32_t npc_type_id) { - Lua_Safe_Call_String(); - return self->GetLootEventByNPCTypeID(npc_type_id); -} - -std::string Lua_Expedition::GetLootEventBySpawnID(uint32_t spawn_id) { - Lua_Safe_Call_String(); - return self->GetLootEventBySpawnID(spawn_id); -} - -uint32_t Lua_Expedition::GetMemberCount() { - Lua_Safe_Call_Int(); - return self->GetMemberCount(); -} - -luabind::object Lua_Expedition::GetMembers(lua_State* L) { - luabind::object lua_table = luabind::newtable(L); - - if (d_) - { - auto self = reinterpret_cast(d_); - for (const auto& member : self->GetMembers()) - { - lua_table[member.name] = member.id; - } - } - return lua_table; -} - -std::string Lua_Expedition::GetName() { - Lua_Safe_Call_String(); - return self->GetName(); -} - -int Lua_Expedition::GetSecondsRemaining() { - Lua_Safe_Call_Int(); - return self->GetDynamicZone().GetSecondsRemaining(); -} - -std::string Lua_Expedition::GetUUID() { - Lua_Safe_Call_String(); - return self->GetUUID(); -} - -int Lua_Expedition::GetZoneID() { - Lua_Safe_Call_Int(); - return self->GetDynamicZone().GetZoneID(); -} - -std::string Lua_Expedition::GetZoneName() { - Lua_Safe_Call_String(); - return ZoneName(self->GetDynamicZone().GetZoneID()); -} - -int Lua_Expedition::GetZoneVersion() { - Lua_Safe_Call_Int(); - return self->GetDynamicZone().GetZoneVersion(); -} - -bool Lua_Expedition::HasLockout(std::string event_name) { - Lua_Safe_Call_Bool(); - return self->HasLockout(event_name); -} - -bool Lua_Expedition::HasReplayLockout() { - Lua_Safe_Call_Bool(); - return self->HasReplayLockout(); -} - -bool Lua_Expedition::IsLocked() { - Lua_Safe_Call_Bool(); - return self->IsLocked(); -} - -void Lua_Expedition::RemoveCompass() { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetCompass(0, 0, 0, 0, true); -} - -void Lua_Expedition::RemoveLockout(std::string event_name) { - Lua_Safe_Call_Void(); - self->RemoveLockout(event_name); -} - -void Lua_Expedition::SetCompass(uint32_t zone_id, float x, float y, float z) { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetCompass(zone_id, x, y, z, true); -} - -void Lua_Expedition::SetCompass(std::string zone_name, float x, float y, float z) { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetCompass(ZoneID(zone_name), x, y, z, true); -} - -void Lua_Expedition::SetLocked(bool lock_expedition) { - Lua_Safe_Call_Void(); - self->SetLocked(lock_expedition, ExpeditionLockMessage::None, true); -} - -void Lua_Expedition::SetLocked(bool lock_expedition, int lock_msg) { - Lua_Safe_Call_Void(); - self->SetLocked(lock_expedition, static_cast(lock_msg), true); -} - -void Lua_Expedition::SetLocked(bool lock_expedition, int lock_msg, uint32_t msg_color) { - Lua_Safe_Call_Void(); - self->SetLocked(lock_expedition, static_cast(lock_msg), true, msg_color); -} - -void Lua_Expedition::SetLootEventByNPCTypeID(uint32_t npc_type_id, std::string event_name) { - Lua_Safe_Call_Void(); - self->SetLootEventByNPCTypeID(npc_type_id, event_name); -} - -void Lua_Expedition::SetLootEventBySpawnID(uint32_t spawn_id, std::string event_name) { - Lua_Safe_Call_Void(); - self->SetLootEventBySpawnID(spawn_id, event_name); -} - -void Lua_Expedition::SetReplayLockoutOnMemberJoin(bool enable) { - Lua_Safe_Call_Void(); - self->SetReplayLockoutOnMemberJoin(enable, true); -} - -void Lua_Expedition::SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading) { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetSafeReturn(zone_id, x, y, z, heading, true); -} - -void Lua_Expedition::SetSafeReturn(std::string zone_name, float x, float y, float z, float heading) { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true); -} - -void Lua_Expedition::SetSecondsRemaining(uint32_t seconds_remaining) -{ - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetSecondsRemaining(seconds_remaining); -} - -void Lua_Expedition::SetZoneInLocation(float x, float y, float z, float heading) { - Lua_Safe_Call_Void(); - self->GetDynamicZone().SetZoneInLocation(x, y, z, heading, true); -} - -void Lua_Expedition::UpdateLockoutDuration(std::string event_name, uint32_t duration) { - Lua_Safe_Call_Void(); - self->UpdateLockoutDuration(event_name, duration); -} - -void Lua_Expedition::UpdateLockoutDuration(std::string event_name, uint32_t duration, bool members_only) { - Lua_Safe_Call_Void(); - self->UpdateLockoutDuration(event_name, duration, members_only); -} - -luabind::scope lua_register_expedition() { - return luabind::class_("Expedition") - .def(luabind::constructor<>()) - .property("null", &Lua_Expedition::Null) - .property("valid", &Lua_Expedition::Valid) - .def("AddLockout", (void(Lua_Expedition::*)(std::string, uint32_t))&Lua_Expedition::AddLockout) - .def("AddLockoutDuration", (void(Lua_Expedition::*)(std::string, int))&Lua_Expedition::AddLockoutDuration) - .def("AddLockoutDuration", (void(Lua_Expedition::*)(std::string, int, bool))&Lua_Expedition::AddLockoutDuration) - .def("AddReplayLockout", (void(Lua_Expedition::*)(uint32_t))&Lua_Expedition::AddReplayLockout) - .def("AddReplayLockoutDuration", (void(Lua_Expedition::*)(int))&Lua_Expedition::AddReplayLockoutDuration) - .def("AddReplayLockoutDuration", (void(Lua_Expedition::*)(int, bool))&Lua_Expedition::AddReplayLockoutDuration) - .def("GetDynamicZoneID", &Lua_Expedition::GetDynamicZoneID) - .def("GetID", (uint32_t(Lua_Expedition::*)(void))&Lua_Expedition::GetID) - .def("GetInstanceID", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetInstanceID) - .def("GetLeaderName", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetLeaderName) - .def("GetLockouts", &Lua_Expedition::GetLockouts) - .def("GetLootEventByNPCTypeID", (std::string(Lua_Expedition::*)(uint32_t))&Lua_Expedition::GetLootEventByNPCTypeID) - .def("GetLootEventBySpawnID", (std::string(Lua_Expedition::*)(uint32_t))&Lua_Expedition::GetLootEventBySpawnID) - .def("GetMemberCount", (uint32_t(Lua_Expedition::*)(void))&Lua_Expedition::GetMemberCount) - .def("GetMembers", &Lua_Expedition::GetMembers) - .def("GetName", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetName) - .def("GetSecondsRemaining", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetSecondsRemaining) - .def("GetUUID", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetUUID) - .def("GetZoneID", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetZoneID) - .def("GetZoneName", &Lua_Expedition::GetZoneName) - .def("GetZoneVersion", &Lua_Expedition::GetZoneVersion) - .def("HasLockout", (bool(Lua_Expedition::*)(std::string))&Lua_Expedition::HasLockout) - .def("HasReplayLockout", (bool(Lua_Expedition::*)(void))&Lua_Expedition::HasReplayLockout) - .def("IsLocked", &Lua_Expedition::IsLocked) - .def("RemoveCompass", (void(Lua_Expedition::*)(void))&Lua_Expedition::RemoveCompass) - .def("RemoveLockout", (void(Lua_Expedition::*)(std::string))&Lua_Expedition::RemoveLockout) - .def("SetCompass", (void(Lua_Expedition::*)(uint32_t, float, float, float))&Lua_Expedition::SetCompass) - .def("SetCompass", (void(Lua_Expedition::*)(std::string, float, float, float))&Lua_Expedition::SetCompass) - .def("SetLocked", (void(Lua_Expedition::*)(bool))&Lua_Expedition::SetLocked) - .def("SetLocked", (void(Lua_Expedition::*)(bool, int))&Lua_Expedition::SetLocked) - .def("SetLocked", (void(Lua_Expedition::*)(bool, int, uint32_t))&Lua_Expedition::SetLocked) - .def("SetLootEventByNPCTypeID", (void(Lua_Expedition::*)(uint32_t, std::string))&Lua_Expedition::SetLootEventByNPCTypeID) - .def("SetLootEventBySpawnID", (void(Lua_Expedition::*)(uint32_t, std::string))&Lua_Expedition::SetLootEventBySpawnID) - .def("SetReplayLockoutOnMemberJoin", (void(Lua_Expedition::*)(bool))&Lua_Expedition::SetReplayLockoutOnMemberJoin) - .def("SetSafeReturn", (void(Lua_Expedition::*)(uint32_t, float, float, float, float))&Lua_Expedition::SetSafeReturn) - .def("SetSafeReturn", (void(Lua_Expedition::*)(std::string, float, float, float, float))&Lua_Expedition::SetSafeReturn) - .def("SetSecondsRemaining", &Lua_Expedition::SetSecondsRemaining) - .def("SetZoneInLocation", (void(Lua_Expedition::*)(float, float, float, float))&Lua_Expedition::SetZoneInLocation) - .def("UpdateLockoutDuration", (void(Lua_Expedition::*)(std::string, uint32_t))&Lua_Expedition::UpdateLockoutDuration) - .def("UpdateLockoutDuration", (void(Lua_Expedition::*)(std::string, uint32_t, bool))&Lua_Expedition::UpdateLockoutDuration); -} - -luabind::scope lua_register_expedition_lock_messages() { - return luabind::class_("ExpeditionLockMessage") - .enum_("constants") - [ - luabind::value("None", static_cast(ExpeditionLockMessage::None)), - luabind::value("Close", static_cast(ExpeditionLockMessage::Close)), - luabind::value("Begin", static_cast(ExpeditionLockMessage::Begin)) - ]; -} - -#endif // LUA_EQEMU diff --git a/zone/lua_expedition.h b/zone/lua_expedition.h deleted file mode 100644 index d154f9323..000000000 --- a/zone/lua_expedition.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_LUA_EXPEDITION_H -#define EQEMU_LUA_EXPEDITION_H -#ifdef LUA_EQEMU - -#include "lua_ptr.h" -#include "../common/types.h" -#include - -class Expedition; -class Lua_Client; -struct lua_State; - -namespace luabind { - struct scope; - namespace adl { - class object; - } - using adl::object; -} - -luabind::scope lua_register_expedition(); -luabind::scope lua_register_expedition_lock_messages(); - -class Lua_Expedition : public Lua_Ptr -{ - typedef Expedition NativeType; -public: - Lua_Expedition() : Lua_Ptr(nullptr) { } - Lua_Expedition(Expedition *d) : Lua_Ptr(d) { } - virtual ~Lua_Expedition() { } - - operator Expedition*() { - return reinterpret_cast(GetLuaPtrData()); - } - - void AddLockout(std::string event_name, uint32_t seconds); - void AddLockoutDuration(std::string event_name, int seconds); - void AddLockoutDuration(std::string event_name, int seconds, bool members_only); - void AddReplayLockout(uint32_t seconds); - void AddReplayLockoutDuration(int seconds); - void AddReplayLockoutDuration(int seconds, bool members_only); - uint32_t GetDynamicZoneID(); - uint32_t GetID(); - int GetInstanceID(); - std::string GetLeaderName(); - luabind::object GetLockouts(lua_State* L); - std::string GetLootEventByNPCTypeID(uint32_t npc_type_id); - std::string GetLootEventBySpawnID(uint32_t spawn_id); - uint32_t GetMemberCount(); - luabind::object GetMembers(lua_State* L); - std::string GetName(); - int GetSecondsRemaining(); - std::string GetUUID(); - int GetZoneID(); - std::string GetZoneName(); - int GetZoneVersion(); - bool HasLockout(std::string event_name); - bool HasReplayLockout(); - bool IsLocked(); - void RemoveCompass(); - void RemoveLockout(std::string event_name); - void SetCompass(uint32_t zone_id, float x, float y, float z); - void SetCompass(std::string zone_name, float x, float y, float z); - void SetLocked(bool lock_expedition); - void SetLocked(bool lock_expedition, int lock_msg); - void SetLocked(bool lock_expedition, int lock_msg, uint32_t color); - void SetLootEventByNPCTypeID(uint32_t npc_type_id, std::string event_name); - void SetLootEventBySpawnID(uint32_t spawn_id, std::string event_name); - void SetReplayLockoutOnMemberJoin(bool enable); - void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading); - void SetSafeReturn(std::string zone_name, float x, float y, float z, float heading); - void SetSecondsRemaining(uint32_t seconds_remaining); - void SetZoneInLocation(float x, float y, float z, float heading); - void UpdateLockoutDuration(std::string event_name, uint32_t duration); - void UpdateLockoutDuration(std::string event_name, uint32_t duration, bool members_only); -}; - -#endif // LUA_EQEMU -#endif // EQEMU_LUA_EXPEDITION_H diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index e01e32549..6f678709e 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -18,14 +18,12 @@ #include "lua_client.h" #include "lua_npc.h" #include "lua_entity_list.h" -#include "lua_expedition.h" #include "quest_parser_collection.h" #include "questmgr.h" #include "qglobals.h" #include "encounter.h" #include "lua_encounter.h" #include "data_bucket.h" -#include "expedition.h" struct Events { }; struct Factions { }; @@ -392,10 +390,6 @@ void lua_repop_zone() { quest_manager.repopzone(); } -void lua_process_mobs_while_zone_empty(bool on) { - quest_manager.processmobswhilezoneempty(on); -} - bool lua_is_disc_tome(int item_id) { return quest_manager.isdisctome(item_id); } @@ -768,14 +762,6 @@ void lua_world_emote(int type, const char *str) { quest_manager.we(type, str); } -void lua_message(int color, const char *message) { - quest_manager.message(color, message); -} - -void lua_whisper(const char *message) { - quest_manager.whisper(message); -} - int lua_get_level(int type) { return quest_manager.getlevel(type); } @@ -816,14 +802,6 @@ int lua_count_item(uint32 item_id) { return quest_manager.countitem(item_id); } -void lua_remove_item(uint32 item_id) { - quest_manager.removeitem(item_id); -} - -void lua_remove_item(uint32 item_id, uint32 quantity) { - quest_manager.removeitem(item_id, quantity); -} - void lua_update_spawn_timer(uint32 id, uint32 new_time) { quest_manager.UpdateSpawnTimer(id, new_time); } @@ -901,7 +879,7 @@ bool lua_delete_data(std::string bucket_key) { return DataBucket::DeleteData(bucket_key); } -std::string lua_get_char_name_by_id(uint32 char_id) { +const char *lua_get_char_name_by_id(uint32 char_id) { return database.GetCharNameByID(char_id); } @@ -937,7 +915,7 @@ int lua_get_group_id_by_char_id(uint32 char_id) { return database.GetGroupIDByCharID(char_id); } -std::string lua_get_npc_name_by_id(uint32 npc_id) { +const char *lua_get_npc_name_by_id(uint32 npc_id) { return quest_manager.getnpcnamebyid(npc_id); } @@ -1608,10 +1586,6 @@ int lua_get_zone_id() { return zone->GetZoneID(); } -int lua_get_zone_id_by_name(const char* zone_name) { - return ZoneID(zone_name); -} - const char *lua_get_zone_long_name() { if(!zone) return ""; @@ -1619,16 +1593,6 @@ const char *lua_get_zone_long_name() { return zone->GetLongName(); } -const char *lua_get_zone_long_name_by_name(const char* zone_name) { - return ZoneLongName( - ZoneID(zone_name) - ); -} - -const char *lua_get_zone_long_name_by_id(uint32 zone_id) { - return ZoneLongName(zone_id); -} - const char *lua_get_zone_short_name() { if(!zone) return ""; @@ -1636,10 +1600,6 @@ const char *lua_get_zone_short_name() { return zone->GetShortName(); } -const char *lua_get_zone_short_name_by_id(uint32 zone_id) { - return ZoneName(zone_id); -} - int lua_get_zone_instance_id() { if(!zone) return 0; @@ -1732,7 +1692,6 @@ void lua_add_spawn_point(luabind::adl::object table) { uint32 variance; uint32 timeleft = 0; uint32 grid = 0; - bool path_when_zone_idle = false; int condition_id = 0; int condition_min_value = 0; bool enabled = true; @@ -1842,14 +1801,6 @@ void lua_add_spawn_point(luabind::adl::object table) { } } - cur = table["path_when_zone_idle"]; - if(luabind::type(cur) != LUA_TNIL) { - try { - path_when_zone_idle = luabind::object_cast(cur); - } catch(luabind::cast_failed &) { - } - } - cur = table["condition_id"]; if(luabind::type(cur) != LUA_TNIL) { try { @@ -1884,10 +1835,8 @@ void lua_add_spawn_point(luabind::adl::object table) { lua_remove_spawn_point(spawn2_id); - auto t = new Spawn2(spawn2_id, spawngroup_id, x, y, z, heading, respawn, - variance, timeleft, grid, path_when_zone_idle, condition_id, - condition_min_value, enabled, static_cast(animation)); - + auto t = new Spawn2(spawn2_id, spawngroup_id, x, y, z, heading, respawn, variance, timeleft, grid, + condition_id, condition_min_value, enabled, static_cast(animation)); zone->spawn2_list.Insert(t); } } @@ -2217,142 +2166,6 @@ void lua_set_content_flag(std::string flag_name, bool enabled){ ZoneStore::SetContentFlag(flag_name, enabled); } -Lua_Expedition lua_get_expedition() { - if (zone && zone->GetInstanceID() != 0) - { - return Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID()); - } - return nullptr; -} - -Lua_Expedition lua_get_expedition_by_char_id(uint32 char_id) { - return Expedition::FindCachedExpeditionByCharacterID(char_id); -} - -Lua_Expedition lua_get_expedition_by_dz_id(uint32 dz_id) { - return Expedition::FindCachedExpeditionByDynamicZoneID(dz_id); -} - -Lua_Expedition lua_get_expedition_by_zone_instance(uint32 zone_id, uint32 instance_id) { - return Expedition::FindCachedExpeditionByZoneInstance(zone_id, instance_id); -} - -luabind::object lua_get_expedition_lockout_by_char_id(lua_State* L, uint32 char_id, std::string expedition_name, std::string event_name) { - luabind::adl::object lua_table = luabind::newtable(L); - - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id); - - auto it = std::find_if(lockouts.begin(), lockouts.end(), [&](const ExpeditionLockoutTimer& lockout) { - return lockout.IsSameLockout(expedition_name, event_name); - }); - - if (it != lockouts.end()) - { - lua_table["remaining"] = it->GetSecondsRemaining(); - lua_table["uuid"] = it->GetExpeditionUUID(); - } - - return lua_table; -} - -luabind::object lua_get_expedition_lockouts_by_char_id(lua_State* L, uint32 char_id) { - luabind::adl::object lua_table = luabind::newtable(L); - - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id); - for (const auto& lockout : lockouts) - { - auto lockout_table = lua_table[lockout.GetExpeditionName()]; - if (luabind::type(lockout_table) != LUA_TTABLE) - { - lockout_table = luabind::newtable(L); - } - - auto event_table = lockout_table[lockout.GetEventName()]; - if (luabind::type(event_table) != LUA_TTABLE) - { - event_table = luabind::newtable(L); - } - - event_table["remaining"] = lockout.GetSecondsRemaining(); - event_table["uuid"] = lockout.GetExpeditionUUID(); - } - return lua_table; -} - -luabind::object lua_get_expedition_lockouts_by_char_id(lua_State* L, uint32 char_id, std::string expedition_name) { - luabind::adl::object lua_table = luabind::newtable(L); - - auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id); - for (const auto& lockout : lockouts) - { - if (lockout.GetExpeditionName() == expedition_name) - { - auto event_table = lua_table[lockout.GetEventName()]; - if (luabind::type(event_table) != LUA_TTABLE) - { - event_table = luabind::newtable(L); - } - event_table["remaining"] = lockout.GetSecondsRemaining(); - event_table["uuid"] = lockout.GetExpeditionUUID(); - } - } - return lua_table; -} - -void lua_add_expedition_lockout_all_clients(std::string expedition_name, std::string event_name, uint32 seconds) { - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds); - Expedition::AddLockoutClients(lockout); -} - -void lua_add_expedition_lockout_all_clients(std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) { - auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid); - Expedition::AddLockoutClients(lockout); -} - -void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds) { - Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds); -} - -void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) { - Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds, uuid); -} - -void lua_remove_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name) { - Expedition::RemoveLockoutsByCharacterID(char_id, expedition_name, event_name); -} - -void lua_remove_all_expedition_lockouts_by_char_id(uint32 char_id) { - Expedition::RemoveLockoutsByCharacterID(char_id); -} - -void lua_remove_all_expedition_lockouts_by_char_id(uint32 char_id, std::string expedition_name) { - Expedition::RemoveLockoutsByCharacterID(char_id, expedition_name); -} - -std::string lua_seconds_to_time(int duration) { - return quest_manager.secondstotime(duration); -} - -std::string lua_get_hex_color_code(std::string color_name) { - return quest_manager.gethexcolorcode(color_name); -} - -double lua_get_aa_exp_modifier_by_char_id(uint32 character_id, uint32 zone_id) { - return database.GetAAEXPModifier(character_id, zone_id); -} - -double lua_get_exp_modifier_by_char_id(uint32 character_id, uint32 zone_id) { - return database.GetEXPModifier(character_id, zone_id); -} - -void lua_set_aa_exp_modifier_by_char_id(uint32 character_id, uint32 zone_id, double aa_modifier) { - database.SetAAEXPModifier(character_id, zone_id, aa_modifier); -} - -void lua_set_exp_modifier_by_char_id(uint32 character_id, uint32 zone_id, double exp_modifier) { - database.SetEXPModifier(character_id, zone_id, exp_modifier); -} - #define LuaCreateNPCParse(name, c_type, default_value) do { \ cur = table[#name]; \ if(luabind::type(cur) != LUA_TNIL) { \ @@ -2583,7 +2396,6 @@ luabind::scope lua_register_general() { luabind::def("depop_all", (void(*)(int))&lua_depop_all), luabind::def("depop_zone", &lua_depop_zone), luabind::def("repop_zone", &lua_repop_zone), - luabind::def("process_mobs_while_zone_empty", &lua_process_mobs_while_zone_empty), luabind::def("is_disc_tome", &lua_is_disc_tome), luabind::def("get_race_name", (std::string(*)(uint16))&lua_get_race_name), luabind::def("get_spell_name", (std::string(*)(uint32))&lua_get_spell_name), @@ -2660,8 +2472,6 @@ luabind::scope lua_register_general() { luabind::def("clear_spawn_timers", &lua_clear_spawn_timers), luabind::def("zone_emote", &lua_zone_emote), luabind::def("world_emote", &lua_world_emote), - luabind::def("message", &lua_message), - luabind::def("whisper", &lua_whisper), luabind::def("get_level", &lua_get_level), luabind::def("create_ground_object", (void(*)(uint32,float,float,float,float))&lua_create_ground_object), luabind::def("create_ground_object", (void(*)(uint32,float,float,float,float,uint32))&lua_create_ground_object), @@ -2672,8 +2482,6 @@ luabind::scope lua_register_general() { luabind::def("modify_npc_stat", &lua_modify_npc_stat), luabind::def("collect_items", &lua_collect_items), luabind::def("count_item", &lua_count_item), - luabind::def("remove_item", (void(*)(uint32))&lua_remove_item), - luabind::def("remove_item", (void(*)(uint32,uint32))&lua_remove_item), luabind::def("update_spawn_timer", &lua_update_spawn_timer), luabind::def("merchant_set_item", (void(*)(uint32,uint32))&lua_merchant_set_item), luabind::def("merchant_set_item", (void(*)(uint32,uint32,uint32))&lua_merchant_set_item), @@ -2855,12 +2663,8 @@ luabind::scope lua_register_general() { luabind::def("zone_group", &lua_zone_group), luabind::def("zone_raid", &lua_zone_raid), luabind::def("get_zone_id", &lua_get_zone_id), - luabind::def("get_zone_id_by_name", &lua_get_zone_id_by_name), luabind::def("get_zone_long_name", &lua_get_zone_long_name), - luabind::def("get_zone_long_name_by_name", &lua_get_zone_long_name_by_name), - luabind::def("get_zone_long_name_by_id", &lua_get_zone_long_name_by_id), luabind::def("get_zone_short_name", &lua_get_zone_short_name), - luabind::def("get_zone_short_name_by_id", &lua_get_zone_short_name_by_id), luabind::def("get_zone_instance_id", &lua_get_zone_instance_id), luabind::def("get_zone_instance_version", &lua_get_zone_instance_version), luabind::def("get_zone_weather", &lua_get_zone_weather), @@ -2893,13 +2697,7 @@ luabind::scope lua_register_general() { luabind::def("debug", (void(*)(std::string))&lua_debug), luabind::def("debug", (void(*)(std::string, int))&lua_debug), luabind::def("log_combat", (void(*)(std::string))&lua_log_combat), - luabind::def("seconds_to_time", &lua_seconds_to_time), - luabind::def("get_hex_color_code", &lua_get_hex_color_code), - luabind::def("get_aa_exp_modifier_by_char_id", &lua_get_aa_exp_modifier_by_char_id), - luabind::def("get_exp_modifier_by_char_id", &lua_get_exp_modifier_by_char_id), - luabind::def("set_aa_exp_modifier_by_char_id", &lua_set_aa_exp_modifier_by_char_id), - luabind::def("set_exp_modifier_by_char_id", &lua_set_exp_modifier_by_char_id), - + /** * Expansions */ @@ -2962,22 +2760,7 @@ luabind::scope lua_register_general() { * Content flags */ luabind::def("is_content_flag_enabled", (bool(*)(std::string))&lua_is_content_flag_enabled), - luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag), - - luabind::def("get_expedition", &lua_get_expedition), - luabind::def("get_expedition_by_char_id", &lua_get_expedition_by_char_id), - luabind::def("get_expedition_by_dz_id", &lua_get_expedition_by_dz_id), - luabind::def("get_expedition_by_zone_instance", &lua_get_expedition_by_zone_instance), - luabind::def("get_expedition_lockout_by_char_id", &lua_get_expedition_lockout_by_char_id), - luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32))&lua_get_expedition_lockouts_by_char_id), - luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32, std::string))&lua_get_expedition_lockouts_by_char_id), - luabind::def("add_expedition_lockout_all_clients", (void(*)(std::string, std::string, uint32))&lua_add_expedition_lockout_all_clients), - luabind::def("add_expedition_lockout_all_clients", (void(*)(std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_all_clients), - luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32))&lua_add_expedition_lockout_by_char_id), - luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_by_char_id), - luabind::def("remove_expedition_lockout_by_char_id", &lua_remove_expedition_lockout_by_char_id), - luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32))&lua_remove_all_expedition_lockouts_by_char_id), - luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32, std::string))&lua_remove_all_expedition_lockouts_by_char_id) + luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag) ]; } @@ -3297,13 +3080,9 @@ luabind::scope lua_register_skills() { .enum_("constants") [ luabind::value("1HBlunt", EQ::skills::Skill1HBlunt), - luabind::value("Blunt1H", EQ::skills::Skill1HBlunt), luabind::value("1HSlashing", EQ::skills::Skill1HSlashing), - luabind::value("Slashing1H", EQ::skills::Skill1HSlashing), luabind::value("2HBlunt", EQ::skills::Skill2HBlunt), - luabind::value("Blunt2H", EQ::skills::Skill2HBlunt), luabind::value("2HSlashing", EQ::skills::Skill2HSlashing), - luabind::value("Slashing2H", EQ::skills::Skill2HSlashing), luabind::value("Abjuration", EQ::skills::SkillAbjuration), luabind::value("Alteration", EQ::skills::SkillAlteration), luabind::value("ApplyPoison", EQ::skills::SkillApplyPoison), @@ -3338,7 +3117,6 @@ luabind::scope lua_register_skills() { luabind::value("Parry", EQ::skills::SkillParry), luabind::value("PickLock", EQ::skills::SkillPickLock), luabind::value("1HPiercing", EQ::skills::Skill1HPiercing), - luabind::value("Piercing1H", EQ::skills::Skill1HPiercing), luabind::value("Riposte", EQ::skills::SkillRiposte), luabind::value("RoundKick", EQ::skills::SkillRoundKick), luabind::value("SafeFall", EQ::skills::SkillSafeFall), @@ -3380,7 +3158,6 @@ luabind::scope lua_register_skills() { luabind::value("RemoveTraps", EQ::skills::SkillRemoveTraps), luabind::value("TripleAttack", EQ::skills::SkillTripleAttack), luabind::value("2HPiercing", EQ::skills::Skill2HPiercing), - luabind::value("Piercing2H", EQ::skills::Skill2HPiercing), luabind::value("HIGHEST_SKILL", EQ::skills::HIGHEST_SKILL) ]; } @@ -3466,24 +3243,7 @@ luabind::scope lua_register_message_types() { return luabind::class_("MT") .enum_("constants") [ - luabind::value("White", Chat::White), - luabind::value("DimGray", Chat::DimGray), - luabind::value("Default", Chat::Default), - luabind::value("Green", Chat::Green), - luabind::value("BrightBlue", Chat::BrightBlue), - luabind::value("LightBlue", Chat::LightBlue), - luabind::value("Magenta", Chat::Magenta), - luabind::value("Gray", Chat::Gray), - luabind::value("LightGray", Chat::LightGray), luabind::value("NPCQuestSay", Chat::NPCQuestSay), - luabind::value("DarkGray", Chat::DarkGray), - luabind::value("Red", Chat::Red), - luabind::value("Lime", Chat::Lime), - luabind::value("Yellow", Chat::Yellow), - luabind::value("Blue", Chat::Blue), - luabind::value("LightNavy", Chat::LightNavy), - luabind::value("Cyan", Chat::Cyan), - luabind::value("Black", Chat::Black), luabind::value("Say", Chat::Say), luabind::value("Tell", Chat::Tell), luabind::value("Group", Chat::Group), diff --git a/zone/lua_group.cpp b/zone/lua_group.cpp index 2cac41418..f297d72f1 100644 --- a/zone/lua_group.cpp +++ b/zone/lua_group.cpp @@ -107,18 +107,6 @@ Lua_Mob Lua_Group::GetMember(int index) { return self->members[index]; } -bool Lua_Group::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name) -{ - Lua_Safe_Call_Bool(); - return self->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name); -} - -bool Lua_Group::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name, int max_check_count) -{ - Lua_Safe_Call_Bool(); - return self->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name, max_check_count); -} - luabind::scope lua_register_group() { return luabind::class_("Group") .def(luabind::constructor<>()) @@ -141,9 +129,7 @@ luabind::scope lua_register_group() { .def("GetLowestLevel", (int(Lua_Group::*)(void))&Lua_Group::GetLowestLevel) .def("TeleportGroup", (void(Lua_Group::*)(Lua_Mob,uint32,uint32,float,float,float,float))&Lua_Group::TeleportGroup) .def("GetID", (int(Lua_Group::*)(void))&Lua_Group::GetID) - .def("GetMember", (Lua_Mob(Lua_Group::*)(int))&Lua_Group::GetMember) - .def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Group::*)(std::string, std::string))&Lua_Group::DoesAnyMemberHaveExpeditionLockout) - .def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Group::*)(std::string, std::string, int))&Lua_Group::DoesAnyMemberHaveExpeditionLockout); + .def("GetMember", (Lua_Mob(Lua_Group::*)(int))&Lua_Group::GetMember); } #endif diff --git a/zone/lua_group.h b/zone/lua_group.h index 46bc48f50..e1aa2a11d 100644 --- a/zone/lua_group.h +++ b/zone/lua_group.h @@ -44,8 +44,6 @@ public: void TeleportGroup(Lua_Mob sender, uint32 zone_id, uint32 instance_id, float x, float y, float z, float h); int GetID(); Lua_Mob GetMember(int index); - bool DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name); - bool DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name, int max_check_count); }; #endif diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 2948c8c71..53658e63d 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -372,11 +372,6 @@ int Lua_Mob::GetRace() { return self->GetRace(); } -const char *Lua_Mob::GetRaceName() { - Lua_Safe_Call_String(); - return GetRaceIDName(self->GetRace()); -} - int Lua_Mob::GetGender() { Lua_Safe_Call_Int(); return self->GetGender(); @@ -447,11 +442,6 @@ int Lua_Mob::GetClass() { return self->GetClass(); } -const char *Lua_Mob::GetClassName() { - Lua_Safe_Call_String(); - return GetClassIDName(self->GetClass()); -} - int Lua_Mob::GetLevel() { Lua_Safe_Call_Int(); return self->GetLevel(); @@ -2267,86 +2257,6 @@ void Lua_Mob::CheckNumHitsRemaining(int type, int32 buff_slot, uint16 spell_id) self->CheckNumHitsRemaining((NumHit)type, buff_slot, spell_id); } -void Lua_Mob::DeleteBucket(std::string bucket_name) -{ - Lua_Safe_Call_Void(); - self->DeleteBucket(bucket_name); -} - -std::string Lua_Mob::GetBucket(std::string bucket_name) -{ - Lua_Safe_Call_String(); - return self->GetBucket(bucket_name); -} - -std::string Lua_Mob::GetBucketExpires(std::string bucket_name) -{ - Lua_Safe_Call_String(); - return self->GetBucketExpires(bucket_name); -} - -std::string Lua_Mob::GetBucketKey() -{ - Lua_Safe_Call_String(); - return self->GetBucketKey(); -} - -std::string Lua_Mob::GetBucketRemaining(std::string bucket_name) -{ - Lua_Safe_Call_String(); - return self->GetBucketRemaining(bucket_name); -} - -void Lua_Mob::SetBucket(std::string bucket_name, std::string bucket_value) -{ - Lua_Safe_Call_Void(); - self->SetBucket(bucket_name, bucket_value); -} - -void Lua_Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration) -{ - Lua_Safe_Call_Void(); - self->SetBucket(bucket_name, bucket_value, expiration); -} - -bool Lua_Mob::IsHorse() -{ - Lua_Safe_Call_Bool(); - return self->IsHorse(); -} - -Lua_Mob Lua_Mob::GetHateClosest() { - Lua_Safe_Call_Class(Lua_Mob); - return Lua_Mob(self->GetHateClosest()); -} - -Lua_HateList Lua_Mob::GetHateListByDistance() { - Lua_Safe_Call_Class(Lua_HateList); - Lua_HateList ret; - auto list = self->GetHateListByDistance(); - for (auto hate_entry : list) { - Lua_HateEntry entry(hate_entry); - ret.entries.push_back(entry); - } - return ret; -} - -Lua_HateList Lua_Mob::GetHateListByDistance(int distance) { - Lua_Safe_Call_Class(Lua_HateList); - Lua_HateList ret; - auto list = self->GetHateListByDistance(distance); - for (auto hate_entry : list) { - Lua_HateEntry entry(hate_entry); - ret.entries.push_back(entry); - } - return ret; -} - -const char *Lua_Mob::GetLastName() { - Lua_Safe_Call_String(); - return self->GetLastName(); -} - luabind::scope lua_register_mob() { return luabind::class_("Mob") .def(luabind::constructor<>()) @@ -2406,7 +2316,6 @@ luabind::scope lua_register_mob() { .def("GetBaseGender", &Lua_Mob::GetBaseGender) .def("GetDeity", &Lua_Mob::GetDeity) .def("GetRace", &Lua_Mob::GetRace) - .def("GetRaceName", &Lua_Mob::GetRaceName) .def("GetGender", &Lua_Mob::GetGender) .def("GetTexture", &Lua_Mob::GetTexture) .def("GetHelmTexture", &Lua_Mob::GetHelmTexture) @@ -2421,7 +2330,6 @@ luabind::scope lua_register_mob() { .def("GetDrakkinTattoo", &Lua_Mob::GetDrakkinTattoo) .def("GetDrakkinDetails", &Lua_Mob::GetDrakkinDetails) .def("GetClass", &Lua_Mob::GetClass) - .def("GetClassName", &Lua_Mob::GetClassName) .def("GetLevel", &Lua_Mob::GetLevel) .def("GetCleanName", &Lua_Mob::GetCleanName) .def("GetTarget", &Lua_Mob::GetTarget) @@ -2513,12 +2421,9 @@ luabind::scope lua_register_mob() { .def("GetPet", &Lua_Mob::GetPet) .def("GetOwner", &Lua_Mob::GetOwner) .def("GetHateList", &Lua_Mob::GetHateList) - .def("GetHateListByDistance", (Lua_HateList(Lua_Mob::*)(void))&Lua_Mob::GetHateListByDistance) - .def("GetHateListByDistance", (Lua_HateList(Lua_Mob::*)(int))&Lua_Mob::GetHateListByDistance) .def("GetHateTop", (Lua_Mob(Lua_Mob::*)(void))&Lua_Mob::GetHateTop) .def("GetHateDamageTop", (Lua_Mob(Lua_Mob::*)(Lua_Mob))&Lua_Mob::GetHateDamageTop) .def("GetHateRandom", (Lua_Mob(Lua_Mob::*)(void))&Lua_Mob::GetHateRandom) - .def("GetHateClosest", &Lua_Mob::GetHateClosest) .def("AddToHateList", (void(Lua_Mob::*)(Lua_Mob))&Lua_Mob::AddToHateList) .def("AddToHateList", (void(Lua_Mob::*)(Lua_Mob,int))&Lua_Mob::AddToHateList) .def("AddToHateList", (void(Lua_Mob::*)(Lua_Mob,int,int))&Lua_Mob::AddToHateList) @@ -2740,16 +2645,7 @@ luabind::scope lua_register_mob() { .def("TryFinishingBlow", &Lua_Mob::TryFinishingBlow) .def("GetBodyType", &Lua_Mob::GetBodyType) .def("GetOrigBodyType", &Lua_Mob::GetOrigBodyType) - .def("CheckNumHitsRemaining", &Lua_Mob::CheckNumHitsRemaining) - .def("DeleteBucket", (void(Lua_Mob::*)(std::string))&Lua_Mob::DeleteBucket) - .def("GetBucket", (std::string(Lua_Mob::*)(std::string))&Lua_Mob::GetBucket) - .def("GetBucketExpires", (std::string(Lua_Mob::*)(std::string))&Lua_Mob::GetBucketExpires) - .def("GetBucketKey", (std::string(Lua_Mob::*)(void))&Lua_Mob::GetBucketKey) - .def("GetBucketRemaining", (std::string(Lua_Mob::*)(std::string))&Lua_Mob::GetBucketRemaining) - .def("SetBucket", (void(Lua_Mob::*)(std::string,std::string))&Lua_Mob::SetBucket) - .def("SetBucket", (void(Lua_Mob::*)(std::string,std::string,std::string))&Lua_Mob::SetBucket) - .def("IsHorse", &Lua_Mob::IsHorse) - .def("GetLastName", &Lua_Mob::GetLastName); + .def("CheckNumHitsRemaining", &Lua_Mob::CheckNumHitsRemaining); } luabind::scope lua_register_special_abilities() { @@ -2800,11 +2696,7 @@ luabind::scope lua_register_special_abilities() { luabind::value("ignore_root_aggro_rules", static_cast(IGNORE_ROOT_AGGRO_RULES)), luabind::value("casting_resist_diff", static_cast(CASTING_RESIST_DIFF)), luabind::value("counter_avoid_damage", static_cast(COUNTER_AVOID_DAMAGE)), - luabind::value("immune_ranged_attacks", static_cast(IMMUNE_RANGED_ATTACKS)), - luabind::value("immune_damage_client", static_cast(IMMUNE_DAMAGE_CLIENT)), - luabind::value("immune_damage_npc", static_cast(IMMUNE_DAMAGE_NPC)), - luabind::value("immune_aggro_client", static_cast(IMMUNE_AGGRO_CLIENT)), - luabind::value("immune_aggro_npc", static_cast(IMMUNE_AGGRO_NPC)) + luabind::value("immune_ranged_attacks", static_cast(IMMUNE_RANGED_ATTACKS)) ]; } diff --git a/zone/lua_mob.h b/zone/lua_mob.h index dbb3c8110..e2dbf9e24 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -92,8 +92,6 @@ public: int GetBaseGender(); int GetDeity(); int GetRace(); - const char *GetClassName(); - const char *GetRaceName(); int GetGender(); int GetTexture(); int GetHelmTexture(); @@ -110,7 +108,6 @@ public: int GetClass(); int GetLevel(); const char *GetCleanName(); - const char *GetLastName(); Lua_Mob GetTarget(); void SetTarget(Lua_Mob t); double GetHPRatio(); @@ -199,12 +196,9 @@ public: Lua_Mob GetPet(); Lua_Mob GetOwner(); Lua_HateList GetHateList(); - Lua_HateList GetHateListByDistance(); - Lua_HateList GetHateListByDistance(int distance); Lua_Mob GetHateTop(); Lua_Mob GetHateDamageTop(Lua_Mob other); Lua_Mob GetHateRandom(); - Lua_Mob GetHateClosest(); void AddToHateList(Lua_Mob other); void AddToHateList(Lua_Mob other, int hate); void AddToHateList(Lua_Mob other, int hate, int damage); @@ -429,15 +423,6 @@ public: int GetBodyType(); int GetOrigBodyType(); void CheckNumHitsRemaining(int type, int32 buff_slot, uint16 spell_id); - - void DeleteBucket(std::string bucket_name); - std::string GetBucket(std::string bucket_name); - std::string GetBucketExpires(std::string bucket_name); - std::string GetBucketKey(); - std::string GetBucketRemaining(std::string bucket_name); - void SetBucket(std::string bucket_name, std::string bucket_value); - void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration); - bool IsHorse(); }; #endif diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index c47870653..23be1e3ee 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -558,18 +558,6 @@ void Lua_NPC::RecalculateSkills() self->RecalculateSkills(); } -void Lua_NPC::ScaleNPC(uint8 npc_level) -{ - Lua_Safe_Call_Void(); - self->ScaleNPC(npc_level); -} - -bool Lua_NPC::IsRaidTarget() -{ - Lua_Safe_Call_Bool(); - return self->IsRaidTarget(); -} - luabind::scope lua_register_npc() { return luabind::class_("NPC") .def(luabind::constructor<>()) @@ -682,9 +670,7 @@ luabind::scope lua_register_npc() { .def("MerchantCloseShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantCloseShop) .def("GetRawAC", (int(Lua_NPC::*)(void))&Lua_NPC::GetRawAC) .def("GetAvoidanceRating", &Lua_NPC::GetAvoidanceRating) - .def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills) - .def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC) - .def("IsRaidTarget", (bool(Lua_NPC::*)(void))&Lua_NPC::IsRaidTarget); + .def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills); } #endif diff --git a/zone/lua_npc.h b/zone/lua_npc.h index 00c4623cb..3b1714095 100644 --- a/zone/lua_npc.h +++ b/zone/lua_npc.h @@ -136,8 +136,6 @@ public: void SetSimpleRoamBox(float box_size, float move_distance); void SetSimpleRoamBox(float box_size, float move_distance, int move_delay); void RecalculateSkills(); - void ScaleNPC(uint8 npc_level); - bool IsRaidTarget(); }; #endif diff --git a/zone/lua_packet.cpp b/zone/lua_packet.cpp index 4936259e6..648d6fa87 100644 --- a/zone/lua_packet.cpp +++ b/zone/lua_packet.cpp @@ -788,18 +788,16 @@ luabind::scope lua_register_packet_opcodes() { luabind::value("DzRemovePlayer", static_cast(OP_DzRemovePlayer)), luabind::value("DzSwapPlayer", static_cast(OP_DzSwapPlayer)), luabind::value("DzMakeLeader", static_cast(OP_DzMakeLeader)), - luabind::value("DzExpeditionInvite", static_cast(OP_DzExpeditionInvite)), - luabind::value("DzExpeditionInviteResponse", static_cast(OP_DzExpeditionInviteResponse)), + luabind::value("DzJoinExpeditionConfirm", static_cast(OP_DzJoinExpeditionConfirm)), + luabind::value("DzJoinExpeditionReply", static_cast(OP_DzJoinExpeditionReply)), luabind::value("DzExpeditionInfo", static_cast(OP_DzExpeditionInfo)), - luabind::value("DzMemberListName", static_cast(OP_DzMemberListName)), - luabind::value("DzMemberListStatus", static_cast(OP_DzMemberListStatus)), - luabind::value("DzSetLeaderName", static_cast(OP_DzSetLeaderName)), + luabind::value("DzMemberStatus", static_cast(OP_DzMemberStatus)), + luabind::value("DzLeaderStatus", static_cast(OP_DzLeaderStatus)), luabind::value("DzExpeditionEndsWarning", static_cast(OP_DzExpeditionEndsWarning)), - luabind::value("DzExpeditionLockoutTimers", static_cast(OP_DzExpeditionLockoutTimers)), + luabind::value("DzExpeditionList", static_cast(OP_DzExpeditionList)), luabind::value("DzMemberList", static_cast(OP_DzMemberList)), luabind::value("DzCompass", static_cast(OP_DzCompass)), luabind::value("DzChooseZone", static_cast(OP_DzChooseZone)), - luabind::value("DzChooseZoneReply", static_cast(OP_DzChooseZoneReply)), luabind::value("BuffCreate", static_cast(OP_BuffCreate)), luabind::value("GuildStatus", static_cast(OP_GuildStatus)), luabind::value("BuffRemoveRequest", static_cast(OP_BuffRemoveRequest)), diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 59b10d4bf..ebe88f32a 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -19,7 +19,6 @@ #include "lua_parser.h" #include "lua_bit.h" #include "lua_entity.h" -#include "lua_expedition.h" #include "lua_item.h" #include "lua_iteminst.h" #include "lua_mob.h" @@ -988,16 +987,6 @@ void LuaParser::ReloadQuests() { } } -/* - * This function is intended only to clean up lua_encounters when the Encounter object is - * about to be destroyed. It won't clean up memory else where, since the caller of this - * function is responsible for that - */ -void LuaParser::RemoveEncounter(const std::string &name) -{ - lua_encounters.erase(name); -} - void LuaParser::LoadScript(std::string filename, std::string package_name) { auto iter = loaded_.find(package_name); if(iter != loaded_.end()) { @@ -1119,9 +1108,7 @@ void LuaParser::MapFunctions(lua_State *L) { lua_register_ruler(), lua_register_ruleb(), lua_register_journal_speakmode(), - lua_register_journal_mode(), - lua_register_expedition(), - lua_register_expedition_lock_messages() + lua_register_journal_mode() ]; } catch(std::exception &ex) { diff --git a/zone/lua_parser.h b/zone/lua_parser.h index d058daf13..8265a191f 100644 --- a/zone/lua_parser.h +++ b/zone/lua_parser.h @@ -71,7 +71,6 @@ public: virtual std::string GetVar(std::string name); virtual void Init(); virtual void ReloadQuests(); - virtual void RemoveEncounter(const std::string &name); virtual uint32 GetIdentifier() { return 0xb0712acc; } virtual int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, diff --git a/zone/lua_raid.cpp b/zone/lua_raid.cpp index 78f6bb1b6..c181b8bd2 100644 --- a/zone/lua_raid.cpp +++ b/zone/lua_raid.cpp @@ -4,6 +4,7 @@ #include #include +#include "raid.h" #include "masterentity.h" #include "lua_raid.h" #include "lua_entity.h" @@ -131,17 +132,6 @@ int Lua_Raid::GetGroupNumber(int index) { return self->members[index].GroupNumber; } -bool Lua_Raid::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name) -{ - Lua_Safe_Call_Bool(); - return self->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name); -} - -bool Lua_Raid::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name, int max_check_count) -{ - Lua_Safe_Call_Bool(); - return self->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name, max_check_count); -} luabind::scope lua_register_raid() { return luabind::class_("Raid") @@ -168,9 +158,7 @@ luabind::scope lua_register_raid() { .def("TeleportRaid", (int(Lua_Raid::*)(Lua_Mob,uint32,uint32,float,float,float,float))&Lua_Raid::TeleportRaid) .def("GetID", (int(Lua_Raid::*)(void))&Lua_Raid::GetID) .def("GetMember", (Lua_Client(Lua_Raid::*)(int))&Lua_Raid::GetMember) - .def("GetGroupNumber", (int(Lua_Raid::*)(int))&Lua_Raid::GetGroupNumber) - .def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Raid::*)(std::string, std::string))&Lua_Raid::DoesAnyMemberHaveExpeditionLockout) - .def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Raid::*)(std::string, std::string, int))&Lua_Raid::DoesAnyMemberHaveExpeditionLockout); + .def("GetGroupNumber", (int(Lua_Raid::*)(int))&Lua_Raid::GetGroupNumber); } #endif diff --git a/zone/lua_raid.h b/zone/lua_raid.h index 9eb100f59..bc10a729c 100644 --- a/zone/lua_raid.h +++ b/zone/lua_raid.h @@ -48,8 +48,6 @@ public: int GetID(); Lua_Client GetMember(int index); int GetGroupNumber(int index); - bool DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name); - bool DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name, int max_check_count); }; #endif diff --git a/zone/main.cpp b/zone/main.cpp index b81a41f5b..7b5fca736 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -22,18 +22,26 @@ #define PLATFORM_ZONE 1 #include "../common/global_define.h" +#include "../common/features.h" +#include "../common/queue.h" #include "../common/timer.h" #include "../common/eq_packet_structs.h" #include "../common/mutex.h" +#include "../common/version.h" +#include "../common/packet_dump_file.h" #include "../common/opcodemgr.h" #include "../common/guilds.h" #include "../common/eq_stream_ident.h" #include "../common/patches/patches.h" #include "../common/rulesys.h" #include "../common/profanity_manager.h" +#include "../common/misc_functions.h" #include "../common/string_util.h" +#include "../common/platform.h" #include "../common/crash.h" +#include "../common/ipc_mutex.h" #include "../common/memory_mapped_file.h" +#include "../common/eqemu_exception.h" #include "../common/spdat.h" #include "../common/eqemu_logsys.h" @@ -49,21 +57,32 @@ #endif #include "zonedb.h" #include "zone_store.h" +#include "zone_config.h" #include "titles.h" #include "guild_mgr.h" -#include "task_manager.h" +#include "tasks.h" #include "quest_parser_collection.h" #include "embparser.h" #include "lua_parser.h" #include "questmgr.h" #include "npc_scale_manager.h" +#include "../common/event/event_loop.h" +#include "../common/event/timer.h" #include "../common/net/eqstream.h" +#include "../common/net/servertalk_server.h" #include "../common/content/world_content_service.h" +#include "../common/repositories/content_flags_repository.h" +#include +#include +#include #include +#include #include #include +#include +#include #include #ifdef _CRTDBG_MAP_ALLOC @@ -78,7 +97,6 @@ #include #include "../common/unix.h" #include "zone_store.h" -#include "zone_event_scheduler.h" #endif @@ -97,13 +115,12 @@ char errorname[32]; extern Zone* zone; npcDecayTimes_Struct npcCorpseDecayTimes[100]; TitleManager title_manager; -QueryServ *QServ = 0; -TaskManager *task_manager = 0; +QueryServ *QServ = 0; +TaskManager *taskmanager = 0; NpcScaleManager *npc_scale_manager; QuestParserCollection *parse = 0; -EQEmuLogSys LogSys; -ZoneEventScheduler event_scheduler; -WorldContentService content_service; +EQEmuLogSys LogSys; +WorldContentService content_service; const SPDat_Spell_Struct* spells; int32 SPDAT_RECORDS = -1; const ZoneConfig *Config; @@ -262,6 +279,12 @@ int main(int argc, char** argv) { guild_mgr.SetDatabase(&database); GuildBanks = nullptr; + /** + * NPC Scale Manager + */ + npc_scale_manager = new NpcScaleManager; + npc_scale_manager->LoadScaleData(); + #ifdef _EQDEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif @@ -320,7 +343,7 @@ int main(int argc, char** argv) { return 1; } LogInfo("Loading skill caps"); - if (!content_db.LoadSkillCaps(std::string(hotfix_name))) { + if (!database.LoadSkillCaps(std::string(hotfix_name))) { LogError("Loading skill caps failed!"); return 1; } @@ -389,8 +412,6 @@ int main(int argc, char** argv) { ZoneStore::LoadContentFlags(); - event_scheduler.SetDatabase(&database)->LoadScheduledEvents(); - #ifdef BOTS LogInfo("Loading bot commands"); int botretval = bot_command_init(); @@ -404,15 +425,10 @@ int main(int argc, char** argv) { LogError("Bot spell casting chances loading failed"); #endif - /** - * NPC Scale Manager - */ - npc_scale_manager = new NpcScaleManager; - npc_scale_manager->LoadScaleData(); - if (RuleB(TaskSystem, EnableTaskSystem)) { - task_manager = new TaskManager; - task_manager->LoadTasks(); + Log(Logs::General, Logs::Tasks, "[INIT] Loading Tasks"); + taskmanager = new TaskManager; + taskmanager->LoadTasks(); } parse = new QuestParserCollection(); @@ -434,7 +450,6 @@ int main(int argc, char** argv) { parse->ReloadQuests(); worldserver.Connect(); - worldserver.SetScheduler(&event_scheduler); Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect #ifdef EQPROFILE @@ -489,7 +504,7 @@ int main(int argc, char** argv) { */ if (!websocker_server_opened && Config->ZonePort != 0) { LogInfo("Websocket Server listener started ([{}]:[{}])", Config->TelnetIP.c_str(), Config->ZonePort); - ws_server = std::make_unique(Config->TelnetIP, Config->ZonePort); + ws_server.reset(new EQ::Net::WebsocketServer(Config->TelnetIP, Config->ZonePort)); RegisterApiService(ws_server); websocker_server_opened = true; } @@ -506,7 +521,7 @@ int main(int argc, char** argv) { opts.daybreak_options.resend_delay_min = RuleI(Network, ResendDelayMinMS); opts.daybreak_options.resend_delay_max = RuleI(Network, ResendDelayMaxMS); opts.daybreak_options.outgoing_data_rate = RuleR(Network, ClientDataRate); - eqsm = std::make_unique(opts); + eqsm.reset(new EQ::Net::EQStreamManager(opts)); eqsf_open = true; eqsm->OnNewConnection([&stream_identifier](std::shared_ptr stream) { @@ -546,11 +561,11 @@ int main(int argc, char** argv) { entity_list.CorpseProcess(); entity_list.TrapProcess(); entity_list.RaidProcess(); + entity_list.Process(); entity_list.MobProcess(); entity_list.BeaconProcess(); entity_list.EncounterProcess(); - event_scheduler.Process(zone, &content_service); if (zone) { if (!zone->Process()) { @@ -592,8 +607,7 @@ int main(int argc, char** argv) { if (zone != 0) Zone::Shutdown(true); //Fix for Linux world server problem. - safe_delete(task_manager); - safe_delete(npc_scale_manager); + safe_delete(taskmanager); command_deinit(); #ifdef BOTS bot_command_deinit(); diff --git a/zone/merc.cpp b/zone/merc.cpp index 1da2cd1ae..bb7a47f68 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -74,7 +74,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = content_db.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, GetLevel()); + skills[r] = database.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, GetLevel()); } size = d->size; @@ -1180,12 +1180,12 @@ bool Merc::HasSkill(EQ::skills::SkillType skill_id) const { } bool Merc::CanHaveSkill(EQ::skills::SkillType skill_id) const { - return(content_db.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)) > 0); + return(database.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)) > 0); //if you don't have it by max level, then odds are you never will? } uint16 Merc::MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const { - return(content_db.GetSkillCap(class_, skillid, level)); + return(database.GetSkillCap(class_, skillid, level)); } void Merc::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { @@ -2154,9 +2154,16 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) { } if(castedSpell) { + char* gmsg = nullptr; + if(tar && tar != this) { // [tar] was implicitly valid at this point..this change is to catch any bad logic //we don't need spam of bots healing themselves - MercGroupSay(this, "Casting %s on %s.", spells[selectedMercSpell.spellid].name, tar->GetCleanName()); + MakeAnyLenString(&gmsg, "Casting %s on %s.", spells[selectedMercSpell.spellid].name, tar->GetCleanName()); + if(gmsg) + { + MercGroupSay(this, gmsg); + safe_delete_array(gmsg); + } } } @@ -4791,12 +4798,7 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, tmpsize = c->GetMercInfo().MercSize; } - std::string tmp_lastname = c->GetName(); - tmp_lastname += "'s Mercenary"; - - // not sure what to do if too long - if (tmp_lastname.length() < sizeof(npc_type->lastname)) - strn0cpy(npc_type->lastname, tmp_lastname.c_str(), sizeof(npc_type->lastname)); + sprintf(npc_type->lastname, "%s's Mercenary", c->GetName()); npc_type->gender = tmpgender; npc_type->size = tmpsize; npc_type->loottable_id = 0; // Loottable has to be 0, otherwise we'll be leavin' some corpses! diff --git a/zone/mob.cpp b/zone/mob.cpp index 0138bdbfd..63eb351cb 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -20,7 +20,6 @@ #include "../common/string_util.h" #include "../common/misc_functions.h" -#include "data_bucket.h" #include "quest_parser_collection.h" #include "string_ids.h" #include "worldserver.h" @@ -119,7 +118,7 @@ Mob::Mob( attack_anim_timer(500), position_update_melee_push_timer(500), hate_list_cleanup_timer(6000), - mob_close_scan_timer(6000), + mob_scan_close(6000), mob_check_moving_timer(1000) { mMovementManager = &MobMovementManager::Get(); @@ -131,7 +130,6 @@ Mob::Mob( AI_Init(); SetMoving(false); moved = false; - turning = false; m_RewindLocation = glm::vec3(); m_RelativePosition = glm::vec4(); @@ -256,7 +254,7 @@ Mob::Mob( INT = in_int; WIS = in_wis; CHA = in_cha; - MR = CR = FR = DR = PR = Corrup = PhR = 0; + MR = CR = FR = DR = PR = Corrup = 0; ExtraHaste = 0; bEnraged = false; shield_target = nullptr; @@ -314,7 +312,7 @@ Mob::Mob( isgrouped = false; israidgrouped = false; - is_horse = false; + IsHorse = false; entity_id_being_looted = 0; _appearance = eaStanding; @@ -465,9 +463,7 @@ Mob::Mob( m_manual_follow = false; #endif - mob_close_scan_timer.Trigger(); - - SetCanOpenDoors(true); + mob_scan_close.Trigger(); } Mob::~Mob() @@ -1201,27 +1197,24 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) else ns->spawn.flymode = flymode; + if(IsBoat()) { + ns->spawn.flymode = GravityBehavior::Floating; + } + ns->spawn.lastName[0] = '\0'; strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName)); //for (i = 0; i < _MaterialCount; i++) - for (i = 0; i < 9; i++) { + for (i = 0; i < 9; i++) + { // Only Player Races Wear Armor - if (Mob::IsPlayerRace(race) || i > 6) { - ns->spawn.equipment.Slot[i].Material = GetEquipmentMaterial(i); - ns->spawn.equipment.Slot[i].EliteModel = IsEliteMaterialItem(i); + if (Mob::IsPlayerRace(race) || i > 6) + { + ns->spawn.equipment.Slot[i].Material = GetEquipmentMaterial(i); + ns->spawn.equipment.Slot[i].EliteModel = IsEliteMaterialItem(i); ns->spawn.equipment.Slot[i].HerosForgeModel = GetHerosForgeModel(i); - ns->spawn.equipment_tint.Slot[i].Color = GetEquipmentColor(i); - } - } - - if (texture > 0) { - for (i = 0; i < 9; i++) { - if (i == EQ::textures::weaponPrimary || i == EQ::textures::weaponSecondary || texture == 255) { - continue; - } - ns->spawn.equipment.Slot[i].Material = texture; + ns->spawn.equipment_tint.Slot[i].Color = GetEquipmentColor(i); } } @@ -1738,7 +1731,6 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) { m_Position.x = x; m_Position.y = y; m_Position.z = z; - SetHeading(heading); mMovementManager->SendCommandToClients(this, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeAny); if (IsNPC()) { @@ -1765,69 +1757,78 @@ void Mob::SendIllusionPacket( float in_size ) { - uint8 new_texture = in_texture; - uint8 new_helmtexture = in_helmtexture; - uint8 new_haircolor; - uint8 new_beardcolor; - uint8 new_eyecolor1; - uint8 new_eyecolor2; - uint8 new_hairstyle; - uint8 new_luclinface; - uint8 new_beard; - uint8 new_aa_title; + uint8 new_texture = in_texture; + uint8 new_helmtexture = in_helmtexture; + uint8 new_haircolor; + uint8 new_beardcolor; + uint8 new_eyecolor1; + uint8 new_eyecolor2; + uint8 new_hairstyle; + uint8 new_luclinface; + uint8 new_beard; + uint8 new_aa_title; uint32 new_drakkin_heritage; uint32 new_drakkin_tattoo; uint32 new_drakkin_details; race = in_race; - if (race == 0) { + if (race == 0) + { race = (use_model) ? use_model : GetBaseRace(); - } + } - if (in_gender != 0xFF) { + if (in_gender != 0xFF) + { gender = in_gender; - } - else { + } + else + { gender = (in_race) ? GetDefaultGender(race, gender) : GetBaseGender(); - } + } - if (in_texture == 0xFF && !IsPlayerRace(in_race)) { + if (in_texture == 0xFF && !IsPlayerRace(in_race)) + { new_texture = GetTexture(); - } + } - if (in_helmtexture == 0xFF && !IsPlayerRace(in_race)) { + if (in_helmtexture == 0xFF && !IsPlayerRace(in_race)) + { new_helmtexture = GetHelmTexture(); - } + } - new_haircolor = (in_haircolor == 0xFF) ? GetHairColor() : in_haircolor; - new_beardcolor = (in_beardcolor == 0xFF) ? GetBeardColor() : in_beardcolor; - new_eyecolor1 = (in_eyecolor1 == 0xFF) ? GetEyeColor1() : in_eyecolor1; - new_eyecolor2 = (in_eyecolor2 == 0xFF) ? GetEyeColor2() : in_eyecolor2; - new_hairstyle = (in_hairstyle == 0xFF) ? GetHairStyle() : in_hairstyle; - new_luclinface = (in_luclinface == 0xFF) ? GetLuclinFace() : in_luclinface; - new_beard = (in_beard == 0xFF) ? GetBeard() : in_beard; - new_drakkin_heritage = (in_drakkin_heritage == 0xFFFFFFFF) ? GetDrakkinHeritage() : in_drakkin_heritage; - new_drakkin_tattoo = (in_drakkin_tattoo == 0xFFFFFFFF) ? GetDrakkinTattoo() : in_drakkin_tattoo; - new_drakkin_details = (in_drakkin_details == 0xFFFFFFFF) ? GetDrakkinDetails() : in_drakkin_details; - new_aa_title = in_aa_title; + new_haircolor = (in_haircolor == 0xFF) ? GetHairColor() : in_haircolor; + new_beardcolor = (in_beardcolor == 0xFF) ? GetBeardColor() : in_beardcolor; + new_eyecolor1 = (in_eyecolor1 == 0xFF) ? GetEyeColor1() : in_eyecolor1; + new_eyecolor2 = (in_eyecolor2 == 0xFF) ? GetEyeColor2() : in_eyecolor2; + new_hairstyle = (in_hairstyle == 0xFF) ? GetHairStyle() : in_hairstyle; + new_luclinface = (in_luclinface == 0xFF) ? GetLuclinFace() : in_luclinface; + new_beard = (in_beard == 0xFF) ? GetBeard() : in_beard; + new_drakkin_heritage = + (in_drakkin_heritage == 0xFFFFFFFF) ? GetDrakkinHeritage() : in_drakkin_heritage; + new_drakkin_tattoo = + (in_drakkin_tattoo == 0xFFFFFFFF) ? GetDrakkinTattoo() : in_drakkin_tattoo; + new_drakkin_details = + (in_drakkin_details == 0xFFFFFFFF) ? GetDrakkinDetails() : in_drakkin_details; + new_aa_title = in_aa_title; + size = (in_size <= 0.0f) ? GetSize() : in_size; // Reset features to Base from the Player Profile if (IsClient() && in_race == 0) { - race = CastToClient()->GetBaseRace(); - gender = CastToClient()->GetBaseGender(); - new_texture = texture = 0xFF; - new_helmtexture = helmtexture = 0xFF; - new_haircolor = haircolor = CastToClient()->GetBaseHairColor(); - new_beardcolor = beardcolor = CastToClient()->GetBaseBeardColor(); - new_eyecolor1 = eyecolor1 = CastToClient()->GetBaseEyeColor(); - new_eyecolor2 = eyecolor2 = CastToClient()->GetBaseEyeColor(); - new_hairstyle = hairstyle = CastToClient()->GetBaseHairStyle(); - new_luclinface = luclinface = CastToClient()->GetBaseFace(); - new_beard = beard = CastToClient()->GetBaseBeard(); - new_aa_title = aa_title = 0xFF; - new_drakkin_heritage = drakkin_heritage = CastToClient()->GetBaseHeritage(); - new_drakkin_tattoo = drakkin_tattoo = CastToClient()->GetBaseTattoo(); - new_drakkin_details = drakkin_details = CastToClient()->GetBaseDetails(); + race = CastToClient()->GetBaseRace(); + gender = CastToClient()->GetBaseGender(); + new_texture = texture = 0xFF; + new_helmtexture = helmtexture = 0xFF; + new_haircolor = haircolor = CastToClient()->GetBaseHairColor(); + new_beardcolor = beardcolor = CastToClient()->GetBaseBeardColor(); + new_eyecolor1 = eyecolor1 = CastToClient()->GetBaseEyeColor(); + new_eyecolor2 = eyecolor2 = CastToClient()->GetBaseEyeColor(); + new_hairstyle = hairstyle = CastToClient()->GetBaseHairStyle(); + new_luclinface = luclinface = CastToClient()->GetBaseFace(); + new_beard = beard = CastToClient()->GetBaseBeard(); + new_aa_title = aa_title = 0xFF; + new_drakkin_heritage = drakkin_heritage = CastToClient()->GetBaseHeritage(); + new_drakkin_tattoo = drakkin_tattoo = CastToClient()->GetBaseTattoo(); + new_drakkin_details = drakkin_details = CastToClient()->GetBaseDetails(); switch (race) { case OGRE: size = 9; @@ -1858,21 +1859,6 @@ void Mob::SendIllusionPacket( } } - // update internal values for mob - size = (in_size <= 0.0f) ? GetSize() : in_size; - texture = new_texture; - helmtexture = new_helmtexture; - haircolor = new_haircolor; - beardcolor = new_beardcolor; - eyecolor1 = new_eyecolor1; - eyecolor2 = new_eyecolor2; - hairstyle = new_hairstyle; - luclinface = new_luclinface; - beard = new_beard; - drakkin_heritage = new_drakkin_heritage; - drakkin_tattoo = new_drakkin_tattoo; - drakkin_details = new_drakkin_details; - auto outapp = new EQApplicationPacket(OP_Illusion, sizeof(Illusion_Struct)); Illusion_Struct *is = (Illusion_Struct *) outapp->pBuffer; is->spawnid = GetID(); @@ -1897,10 +1883,9 @@ void Mob::SendIllusionPacket( safe_delete(outapp); /* Refresh armor and tints after send illusion packet */ - SendArmorAppearance(); + this->SendArmorAppearance(); - LogSpells( - "Illusion: Race [{}] Gender [{}] Texture [{}] HelmTexture [{}] HairColor [{}] BeardColor [{}] EyeColor1 [{}] EyeColor2 [{}] HairStyle [{}] Face [{}] DrakkinHeritage [{}] DrakkinTattoo [{}] DrakkinDetails [{}] Size [{}]", + LogSpells("Illusion: Race = [{}], Gender = [{}], Texture = [{}], HelmTexture = [{}], HairColor = [{}], BeardColor = [{}], EyeColor1 = [{}], EyeColor2 = [{}], HairStyle = [{}], Face = [{}], DrakkinHeritage = [{}], DrakkinTattoo = [{}], DrakkinDetails = [{}], Size = [{}]", race, gender, new_texture, @@ -1914,8 +1899,7 @@ void Mob::SendIllusionPacket( new_drakkin_heritage, new_drakkin_tattoo, new_drakkin_details, - size - ); + size); } bool Mob::RandomizeFeatures(bool send_illusion, bool set_variables) @@ -2421,7 +2405,7 @@ void Mob::ChangeSize(float in_size = 0, bool bNoRestriction) { if (in_size > 255.0) in_size = 255.0; //End of Size Code - size = in_size; + this->size = in_size; SendAppearancePacket(AT_Size, (uint32) in_size); } @@ -2825,11 +2809,6 @@ bool Mob::HateSummon() { } void Mob::FaceTarget(Mob* mob_to_face /*= 0*/) { - - if (IsBoat()) { - return; - } - Mob* faced_mob = mob_to_face; if(!faced_mob) { if(!GetTarget()) { @@ -3142,12 +3121,6 @@ void Mob::ExecWeaponProc(const EQ::ItemInstance *inst, uint16 spell_id, Mob *on, return; } - if (on->GetSpecialAbility(IMMUNE_DAMAGE_CLIENT) && IsClient()) - return; - - if (on->GetSpecialAbility(IMMUNE_DAMAGE_NPC) && IsNPC()) - return; - if (IsNoCast()) return; @@ -4899,8 +4872,7 @@ bool Mob::IsBoat() const { race == RACE_SHIP_404 || race == RACE_MERCHANT_SHIP_550 || race == RACE_PIRATE_SHIP_551 || - race == RACE_GHOST_SHIP_552 || - race == RACE_BOAT_533 + race == RACE_GHOST_SHIP_552 ); } @@ -5964,61 +5936,3 @@ float Mob::HealRotationExtendedHealFrequency() return m_target_of_heal_rotation->ExtendedHealFrequency(this); } #endif - -bool Mob::CanOpenDoors() const -{ - return m_can_open_doors; -} - -void Mob::SetCanOpenDoors(bool can_open) -{ - m_can_open_doors = can_open; -} - -void Mob::DeleteBucket(std::string bucket_name) { - std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); - DataBucket::DeleteData(full_bucket_name); -} - -std::string Mob::GetBucket(std::string bucket_name) { - std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); - std::string bucket_value = DataBucket::GetData(full_bucket_name); - if (!bucket_value.empty()) { - return bucket_value; - } - return std::string(); -} - -std::string Mob::GetBucketExpires(std::string bucket_name) { - std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); - std::string bucket_expiration = DataBucket::GetDataExpires(full_bucket_name); - if (!bucket_expiration.empty()) { - return bucket_expiration; - } - return std::string(); -} - -std::string Mob::GetBucketKey() { - if (IsClient()) { - return fmt::format("character-{}", CastToClient()->CharacterID()); - } else if (IsNPC()) { - return fmt::format("npc-{}", GetNPCTypeID()); - } - return std::string(); -} - -std::string Mob::GetBucketRemaining(std::string bucket_name) { - std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); - std::string bucket_remaining = DataBucket::GetDataRemaining(full_bucket_name); - if (!bucket_remaining.empty() && atoi(bucket_remaining.c_str()) > 0) { - return bucket_remaining; - } else if (atoi(bucket_remaining.c_str()) == 0) { - return "0"; - } - return std::string(); -} - -void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration) { - std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); - DataBucket::SetData(full_bucket_name, bucket_value, expiration); -} diff --git a/zone/mob.h b/zone/mob.h index 791c5a3e7..b07f51ceb 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -172,8 +172,8 @@ public: void DisplayInfo(Mob *mob); std::unordered_map close_mobs; - Timer mob_close_scan_timer; - Timer mob_check_moving_timer; + Timer mob_scan_close; + Timer mob_check_moving_timer; //Somewhat sorted: needs documenting! @@ -222,7 +222,7 @@ public: inline int GetMitigationAC() { return mitigation_ac; } void MeleeMitigation(Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts = nullptr); double RollD20(int offense, int mitigation); // CALL THIS FROM THE DEFENDER - bool CombatRange(Mob* other, float fixed_size_mod = 1.0, bool aeRampage = false); + bool CombatRange(Mob* other); virtual inline bool IsBerserk() { return false; } // only clients void RogueEvade(Mob *other); void CommonOutgoingHitSuccess(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts = nullptr); @@ -642,7 +642,6 @@ public: Mob* GetHateDamageTop(Mob* other) { return hate_list.GetDamageTopOnHateList(other);} Mob* GetHateRandom() { return hate_list.GetRandomEntOnHateList();} Mob* GetHateMost() { return hate_list.GetEntWithMostHateOnList();} - Mob* GetHateClosest() { return hate_list.GetClosestEntOnHateList(this); } bool IsEngaged() { return(!hate_list.IsHateListEmpty()); } bool HasPrimaryAggro() { return PrimaryAggro; } bool HasAssistAggro() { return AssistAggro; } @@ -657,7 +656,6 @@ public: bool IsOnFeignMemory(Client *attacker) const; void PrintHateListToClient(Client *who) { hate_list.PrintHateListToClient(who); } std::list& GetHateList() { return hate_list.GetHateList(); } - std::list GetHateListByDistance(int distance = 0) { return hate_list.GetHateListByDistance(distance); } bool CheckLosFN(Mob* other); bool CheckLosFN(float posX, float posY, float posZ, float mobSize); static bool CheckLosFN(glm::vec3 posWatcher, float sizeWatcher, glm::vec3 posTarget, float sizeTarget); @@ -697,7 +695,6 @@ public: bool PlotPositionOnArcInFrontOfTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float distance, float min_deg = 5.0f, float max_deg = 150.0f); bool PlotPositionOnArcBehindTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float distance); bool PlotPositionBehindMeFacingTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float min_dist = 1.0f, float max_dist = 5.0f); - virtual int GetKillExpMod() const { return 100; } // aura functions void MakeAura(uint16 spell_id); @@ -903,7 +900,6 @@ public: inline void SetPetOwnerClient(bool value) { pet_owner_client = value; } inline bool IsTempPet() const { return _IsTempPet; } inline void SetTempPet(bool value) { _IsTempPet = value; } - inline bool IsHorse() { return is_horse; } inline const bodyType GetBodyType() const { return bodytype; } inline const bodyType GetOrigBodyType() const { return orig_bodytype; } @@ -1198,15 +1194,6 @@ public: int32 GetHPRegen() const; int32 GetManaRegen() const; - bool CanOpenDoors() const; - void SetCanOpenDoors(bool can_open); - - void DeleteBucket(std::string bucket_name); - std::string GetBucket(std::string bucket_name); - std::string GetBucketExpires(std::string bucket_name); - std::string GetBucketKey(); - std::string GetBucketRemaining(std::string bucket_name); - void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration = ""); #ifdef BOTS // Bots HealRotation methods @@ -1486,7 +1473,6 @@ public: bool GetWasSpawnedInWater() const; void SetSpawnedInWater(bool spawned_in_water); - bool turning; protected: @@ -1595,21 +1581,18 @@ protected: std::unordered_map> aa_ranks; Timer aa_timers[aaTimerMax]; - - bool is_horse; + + bool IsHorse; AuraMgr aura_mgr; AuraMgr trap_mgr; - bool m_can_open_doors; - MobMovementManager *mMovementManager; private: void _StopSong(); //this is not what you think it is Mob* target; - #ifdef BOTS std::shared_ptr m_target_of_heal_rotation; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 306c6dd64..df4a70e12 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -117,8 +117,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates ( (spells[AIspells[i].spellid].targettype == ST_HateList || spells[AIspells[i].spellid].targettype == ST_AETargetHateList) || ( - // note: I think this check is actually wrong and we should be checking range instead in all cases, BUT if range is 0, range check is skipped? Works for now - (spells[AIspells[i].spellid].targettype==ST_AECaster || spells[AIspells[i].spellid].targettype==ST_AEBard || spells[AIspells[i].spellid].targettype==ST_AEClientV1) + (spells[AIspells[i].spellid].targettype==ST_AECaster || spells[AIspells[i].spellid].targettype==ST_AEBard) && dist2 <= spells[AIspells[i].spellid].aoerange*spells[AIspells[i].spellid].aoerange ) || dist2 <= spells[AIspells[i].spellid].range*spells[AIspells[i].spellid].range @@ -435,27 +434,23 @@ void Mob::AI_Start(uint32 iMoveDelay) { time_until_can_move = 0; pAIControlled = true; - AI_think_timer = std::make_unique(AIthink_duration); + AI_think_timer = std::unique_ptr(new Timer(AIthink_duration)); AI_think_timer->Trigger(); - AI_walking_timer = std::make_unique(0); - AI_movement_timer = std::make_unique(AImovement_duration); - AI_target_check_timer = std::make_unique(AItarget_check_duration); - AI_feign_remember_timer = std::make_unique(AIfeignremember_delay); - AI_scan_door_open_timer = std::make_unique(AI_scan_door_open_interval); - - if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) { - SetCanOpenDoors(false); - } + AI_walking_timer = std::unique_ptr(new Timer(0)); + AI_movement_timer = std::unique_ptr(new Timer(AImovement_duration)); + AI_target_check_timer = std::unique_ptr(new Timer(AItarget_check_duration)); + AI_feign_remember_timer = std::unique_ptr(new Timer(AIfeignremember_delay)); + AI_scan_door_open_timer = std::unique_ptr(new Timer(AI_scan_door_open_interval)); if(!RuleB(Aggro, NPCAggroMaxDistanceEnabled)) { hate_list_cleanup_timer.Disable(); } if (CastToNPC()->WillAggroNPCs()) - AI_scan_area_timer = std::make_unique(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax))); - - AI_check_signal_timer = std::make_unique(AI_check_signal_timer_delay); + AI_scan_area_timer = std::unique_ptr(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax)))); + + AI_check_signal_timer = std::unique_ptr(new Timer(AI_check_signal_timer_delay)); if (GetAggroRange() == 0) @@ -488,10 +483,10 @@ void NPC::AI_Start(uint32 iMoveDelay) { return; if (AIspells.empty()) { - AIautocastspell_timer = std::make_unique(1000); + AIautocastspell_timer = std::unique_ptr(new Timer(1000)); AIautocastspell_timer->Disable(); } else { - AIautocastspell_timer = std::make_unique(500); + AIautocastspell_timer = std::unique_ptr(new Timer(500)); AIautocastspell_timer->Start(RandomTimer(0, 300), false); } @@ -888,49 +883,49 @@ void Mob::ProcessForcedMovement() if (AI_movement_timer->Check()) { bool bPassed = true; glm::vec3 normal; - + // no zone map = fucked if (zone->HasMap()) { // in front m_CollisionBox[0].x = m_Position.x + 3.0f * g_Math.FastSin(0.0f); m_CollisionBox[0].y = m_Position.y + 3.0f * g_Math.FastCos(0.0f); m_CollisionBox[0].z = m_Position.z; - + // 45 right front m_CollisionBox[1].x = m_Position.x + 3.0f * g_Math.FastSin(64.0f); m_CollisionBox[1].y = m_Position.y + 3.0f * g_Math.FastCos(64.0f); m_CollisionBox[1].z = m_Position.z; - + // to right m_CollisionBox[2].x = m_Position.x + 3.0f * g_Math.FastSin(128.0f); m_CollisionBox[2].y = m_Position.y + 3.0f * g_Math.FastCos(128.0f); m_CollisionBox[2].z = m_Position.z; - + // 45 right back m_CollisionBox[3].x = m_Position.x + 3.0f * g_Math.FastSin(192.0f); m_CollisionBox[3].y = m_Position.y + 3.0f * g_Math.FastCos(192.0f); m_CollisionBox[3].z = m_Position.z; - + // behind m_CollisionBox[4].x = m_Position.x + 3.0f * g_Math.FastSin(256.0f); m_CollisionBox[4].y = m_Position.y + 3.0f * g_Math.FastCos(256.0f); m_CollisionBox[4].z = m_Position.z; - + // 45 left back m_CollisionBox[5].x = m_Position.x + 3.0f * g_Math.FastSin(320.0f); m_CollisionBox[5].y = m_Position.y + 3.0f * g_Math.FastCos(320.0f); m_CollisionBox[5].z = m_Position.z; - + // to left m_CollisionBox[6].x = m_Position.x + 3.0f * g_Math.FastSin(384.0f); m_CollisionBox[6].y = m_Position.y + 3.0f * g_Math.FastCos(384.0f); m_CollisionBox[6].z = m_Position.z; - + // 45 left front m_CollisionBox[7].x = m_Position.x + 3.0f * g_Math.FastSin(448.0f); m_CollisionBox[7].y = m_Position.y + 3.0f * g_Math.FastCos(448.0f); m_CollisionBox[7].z = m_Position.z; - + // collision happened, need to move along the wall float distance = 0.0f, shortest = std::numeric_limits::infinity(); glm::vec3 tmp_nrm; @@ -944,7 +939,7 @@ void Mob::ProcessForcedMovement() } } } - + if (bPassed) { ForcedMovement = 0; Teleport(m_Position + m_Delta); @@ -982,25 +977,23 @@ void Mob::AI_Process() { engaged = false; } - if (moving && CanOpenDoors()) { + if (moving) { if (AI_scan_door_open_timer->Check()) { + auto &door_list = entity_list.GetDoorsList(); for (auto itr : door_list) { Doors *door = itr.second; - if (door->GetKeyItem()) { + if (door->GetKeyItem()) continue; - } - if (door->GetLockpick()) { + if (door->GetLockpick()) continue; - } - if (door->IsDoorOpen()) { + if (door->IsDoorOpen()) continue; - } - float distance = DistanceSquared(m_Position, door->GetPosition()); + float distance = DistanceSquared(this->m_Position, door->GetPosition()); float distance_scan_door_open = 20; if (distance <= (distance_scan_door_open * distance_scan_door_open)) { @@ -1009,9 +1002,8 @@ void Mob::AI_Process() { * Make sure we're opening a door within height relevance and not platforms * above or below */ - if (std::abs(this->m_Position.z - door->GetPosition().z) > 10) { + if (std::abs(this->m_Position.z - door->GetPosition().z) > 10) continue; - } door->ForceOpen(this); } @@ -1612,12 +1604,11 @@ void NPC::AI_DoMovement() { * if the roam box was sloppily configured */ if (!this->GetWasSpawnedInWater()) { - roambox_destination_z = GetGroundZ(roambox_destination_x, roambox_destination_y); if (zone->HasMap() && zone->HasWaterMap()) { auto position = glm::vec3( roambox_destination_x, roambox_destination_y, - roambox_destination_z + (m_Position.z - 15) ); /** @@ -1637,19 +1628,6 @@ void NPC::AI_DoMovement() { } } } - else { // Mob was in water, make sure new spot is in water also - roambox_destination_z = m_Position.z; - auto position = glm::vec3( - roambox_destination_x, - roambox_destination_y, - m_Position.z + 15 - ); - if (zone->HasWaterMap() && !zone->watermap->InLiquid(position)) { - roambox_destination_x = m_SpawnPoint.x; - roambox_destination_y = m_SpawnPoint.y; - roambox_destination_z = m_SpawnPoint.z; - } - } PathfinderOptions opts; opts.smooth_path = true; @@ -1664,7 +1642,7 @@ void NPC::AI_DoMovement() { glm::vec3( roambox_destination_x, roambox_destination_y, - roambox_destination_z + GetGroundZ(roambox_destination_x, roambox_destination_y) ), partial, stuck, @@ -1680,6 +1658,8 @@ void NPC::AI_DoMovement() { return; } + roambox_destination_z = 0; + Log( Logs::General, Logs::NPCRoamBox, @@ -1730,9 +1710,7 @@ void NPC::AI_DoMovement() { // reached our randomly selected destination; force a pause if (cur_wp_pause == 0) { - if (Waypoints.size() >= cur_wp && Waypoints[cur_wp].pause) - cur_wp_pause = Waypoints[cur_wp].pause; - else if (Waypoints.size() > 0 && Waypoints[0].pause) + if (Waypoints.size() > 0 && Waypoints[0].pause) cur_wp_pause = Waypoints[0].pause; else cur_wp_pause = 38; @@ -1750,7 +1728,7 @@ void NPC::AI_DoMovement() { if (cur_wp_pause > 0 && m_CurrentWayPoint.w >= 0.0) { RotateTo(m_CurrentWayPoint.w); } - + //kick off event_waypoint arrive char temp[16]; sprintf(temp, "%d", cur_wp); @@ -1764,7 +1742,7 @@ void NPC::AI_DoMovement() { if (cur_wp == EQ::WaypointStatus::QuestControlNoGrid) { AI_SetupNextWaypoint(); } - + // wipe feign memory since we reached our first waypoint if (cur_wp == 1) ClearFeignMemory(); @@ -1782,7 +1760,7 @@ void NPC::AI_DoMovement() { m_CurrentWayPoint.y, m_CurrentWayPoint.z ); - + } } } // endif (gridno > 0) @@ -1791,15 +1769,15 @@ void NPC::AI_DoMovement() { if (pause_timer_complete == true) { // time to pause has ended SetGrid(0 - GetGrid()); // revert to AI control LogPathing("Quest pathing is finished. Resuming on grid [{}]", GetGrid()); - + SetAppearance(eaStanding, false); - + CalculateNewWaypoint(); } } } - else if (IsGuarding()) { + else if (IsGuarding()) { bool at_gp = IsPositionEqualWithinCertainZ(m_Position, m_GuardPoint, 15.0f); if (at_gp) { @@ -1864,17 +1842,17 @@ void NPC::AI_SetupNextWaypoint() { roamer = false; cur_wp = 0; } - + SetAppearance(eaStanding, false); - + entity_list.OpenDoorsNear(this); - + if (!DistractedFromGrid) { //kick off event_waypoint depart char temp[16]; sprintf(temp, "%d", cur_wp); parse->EventNPC(EVENT_WAYPOINT_DEPART, CastToNPC(), nullptr, temp, 0); - + //setup our next waypoint, if we are still on our normal grid //remember that the quest event above could have done anything it wanted with our grid if (GetGrid() > 0) { @@ -1944,7 +1922,7 @@ void Mob::AI_Event_NoLongerEngaged() { time_until_can_move += minLastFightingDelayMoving; else time_until_can_move += zone->random.Int(minLastFightingDelayMoving, maxLastFightingDelayMoving); - + StopNavigation(); ClearRampage(); @@ -2489,7 +2467,7 @@ create table npc_spells_entries ( ); */ -bool IsSpellInList(DBnpcspells_Struct* spell_list, uint16 iSpellID); +bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID); bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base, int32 limit, int32 max); bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { @@ -2761,14 +2739,14 @@ bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSp return false; } -bool IsSpellInList(DBnpcspells_Struct* spell_list, uint16 iSpellID) { +bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID) { auto it = std::find_if(spell_list->entries.begin(), spell_list->entries.end(), [iSpellID](const DBnpcspells_entries_Struct &a) { return a.spellid == iSpellID; }); return it != spell_list->entries.end(); } // adds a spell to the list, taking into account priority and resorting list as needed. -void NPC::AddSpellToNPCList(int16 iPriority, uint16 iSpellID, uint32 iType, +void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType, int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp) { @@ -2795,7 +2773,7 @@ void NPC::AddSpellToNPCList(int16 iPriority, uint16 iSpellID, uint32 iType, AIautocastspell_timer->Start(RandomTimer(0, 300), false); } -void NPC::RemoveSpellFromNPCList(uint16 spell_id) +void NPC::RemoveSpellFromNPCList(int16 spell_id) { auto iter = AIspells.begin(); while(iter != AIspells.end()) diff --git a/zone/mob_info.cpp b/zone/mob_info.cpp index 5b7011f33..95f04edec 100644 --- a/zone/mob_info.cpp +++ b/zone/mob_info.cpp @@ -225,10 +225,6 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut return std::to_string(mob->GetMaxBuffSlots()); } - if (attribute == "can_open_doors") { - return std::to_string(mob->CanOpenDoors()); - } - if (attribute == "curbuffslots") { return std::to_string(mob->GetCurrentBuffSlots()); } @@ -557,7 +553,7 @@ inline std::string WriteDisplayInfoSection( * "total_to_hit" = "Total To Hit" */ if (attribute_name.find('_') != std::string::npos) { - auto split_string = SplitString(attribute_name, '_'); + std::vector split_string = split(attribute_name, '_'); std::string new_attribute_name; for (std::string &string_value : split_string) { new_attribute_name += ucfirst(string_value) + " "; @@ -644,7 +640,7 @@ void Mob::DisplayInfo(Mob *mob) Client *client = this->CastToClient(); - if (!client->IsDevToolsEnabled()) { + if (!client->IsDevToolsWindowEnabled()) { return; } @@ -774,7 +770,6 @@ void Mob::DisplayInfo(Mob *mob) "spells_id", "curbuffslots", "maxbuffslots", - "can_open_doors", }; window_text += WriteDisplayInfoSection(mob, "NPC Attributes", npc_attributes, 1, true); diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index c323a13c2..904bc5246 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -63,7 +63,6 @@ public: if (!m_started) { m_started = true; - mob->turning = true; mob->SetMoving(true); if (dist > 15.0f && rotate_to_speed > 0.0 && rotate_to_speed <= 25.0) { //send basic rotation @@ -85,7 +84,6 @@ public: mob->SetHeading(to); mob->SetMoving(false); mob_movement_manager->SendCommandToClients(mob, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium); - mob->turning = false; return true; } @@ -571,7 +569,6 @@ public: } mob_movement_manager->SendCommandToClients(mob, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium); } - return true; } @@ -607,7 +604,7 @@ public: mob->WipeHateList(); mob->Heal(); - return false; + return true; } virtual bool Started() const @@ -681,7 +678,7 @@ struct MobMovementManager::Implementation { MobMovementManager::MobMovementManager() { - _impl = std::make_unique(); + _impl.reset(new Implementation()); } MobMovementManager::~MobMovementManager() @@ -1091,17 +1088,6 @@ void MobMovementManager::UpdatePath(Mob *who, float x, float y, float z, MobMove PushFlyTo(ent.second, x, y, z, mob_movement_mode); PushStopMoving(ent.second); } - // Below for npcs that can traverse land or water so they don't sink - else if (who->GetFlyMode() == GravityBehavior::Water && - zone->watermap->InLiquid(who->GetPosition()) && - zone->watermap->InLiquid(glm::vec3(x, y, z)) && - zone->zonemap->CheckLoS(who->GetPosition(), glm::vec3(x, y, z))) { - auto iter = _impl->Entries.find(who); - auto &ent = (*iter); - - PushSwimTo(ent.second, x, y, z, mob_movement_mode); - PushStopMoving(ent.second); - } else { UpdatePathGround(who, x, y, z, mob_movement_mode); } @@ -1228,7 +1214,7 @@ void MobMovementManager::UpdatePathGround(Mob *who, float x, float y, float z, M ) ); } - else if(!next_node.teleport) { + else { if (zone->watermap->InLiquid(previous_pos)) { PushSwimTo(ent.second, next_node.pos.x, next_node.pos.y, next_node.pos.z, mode); } @@ -1348,7 +1334,7 @@ void MobMovementManager::UpdatePathUnderwater(Mob *who, float x, float y, float next_node.pos.y )); } - else if(!next_node.teleport) { + else { PushSwimTo(ent.second, next_node.pos.x, next_node.pos.y, next_node.pos.z, movement_mode); } } @@ -1372,9 +1358,7 @@ void MobMovementManager::UpdatePathBoat(Mob *who, float x, float y, float z, Mob { auto eiter = _impl->Entries.find(who); auto &ent = (*eiter); - float to = who->CalculateHeadingToTarget(x, y); - PushRotateTo(ent.second, who, to, mode); PushSwimTo(ent.second, x, y, z, mode); PushStopMoving(ent.second); } diff --git a/zone/mod_functions.cpp b/zone/mod_functions.cpp index b4951f76d..b0b335a4e 100644 --- a/zone/mod_functions.cpp +++ b/zone/mod_functions.cpp @@ -151,7 +151,7 @@ int32 Mob::mod_monk_special_damage(int32 ndamage, EQ::skills::SkillType skill_ty //ndamage - Backstab damage as calculated by default formulas int32 Mob::mod_backstab_damage(int32 ndamage) { return(ndamage); } -//Chance for 50+ archery bonus damage if Combat:UseArcheryBonusRoll is true. +//Chance for 50+ archery bonus damage if Combat:UseArcheryBonusRoll is true. Base is Combat:ArcheryBonusChance int Mob::mod_archery_bonus_chance(int bonuschance, const EQ::ItemInstance* RangeWeapon) { return(bonuschance); } //Archery bonus damage diff --git a/zone/mod_functions_base.cpp b/zone/mod_functions_base.cpp index 5323ca32a..477050534 100644 --- a/zone/mod_functions_base.cpp +++ b/zone/mod_functions_base.cpp @@ -152,7 +152,7 @@ int32 Mob::mod_monk_special_damage(int32 ndamage, SkillType skill_type) { return //ndamage - Backstab damage as calculated by default formulas int32 Mob::mod_backstab_damage(int32 ndamage) { return(ndamage); } -//Chance for 50+ archery bonus damage if Combat:UseArcheryBonusRoll is true. +//Chance for 50+ archery bonus damage if Combat:UseArcheryBonusRoll is true. Base is Combat:ArcheryBonusChance int Mob::mod_archery_bonus_chance(int bonuschance, const ItemInst* RangeWeapon) { return(bonuschance); } //Archery bonus damage diff --git a/zone/npc.cpp b/zone/npc.cpp index 9bea0ec67..b0b9e65f7 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -230,14 +230,9 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi adventure_template_id = npc_type_data->adventure_template; flymode = iflymode; - // If server has set a flymode in db honor it over all else. - // If server has not set a flymde in db, and this is a boat - force floating. if (npc_type_data->flymode >= 0) { flymode = static_cast(npc_type_data->flymode); } - else if (IsBoat()) { - flymode = GravityBehavior::Floating; - } guard_anim = eaStanding; roambox_distance = 0; @@ -284,19 +279,6 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi entity_list.MakeNameUnique(name); npc_aggro = npc_type_data->npc_aggro; - - AISpellVar.fail_recast = static_cast(RuleI(Spells, AI_SpellCastFinishedFailRecast)); - AISpellVar.engaged_no_sp_recast_min = static_cast(RuleI(Spells, AI_EngagedNoSpellMinRecast)); - AISpellVar.engaged_no_sp_recast_max = static_cast(RuleI(Spells, AI_EngagedNoSpellMaxRecast)); - AISpellVar.engaged_beneficial_self_chance = static_cast (RuleI(Spells, AI_EngagedBeneficialSelfChance)); - AISpellVar.engaged_beneficial_other_chance = static_cast (RuleI(Spells, AI_EngagedBeneficialOtherChance)); - AISpellVar.engaged_detrimental_chance = static_cast (RuleI(Spells, AI_EngagedDetrimentalChance)); - AISpellVar.pursue_no_sp_recast_min = static_cast(RuleI(Spells, AI_PursueNoSpellMinRecast)); - AISpellVar.pursue_no_sp_recast_max = static_cast(RuleI(Spells, AI_PursueNoSpellMaxRecast)); - AISpellVar.pursue_detrimental_chance = static_cast (RuleI(Spells, AI_PursueDetrimentalChance)); - AISpellVar.idle_no_sp_recast_min = static_cast(RuleI(Spells, AI_IdleNoSpellMinRecast)); - AISpellVar.idle_no_sp_recast_max = static_cast(RuleI(Spells, AI_IdleNoSpellMaxRecast)); - AISpellVar.idle_beneficial_chance = static_cast (RuleI(Spells, AI_IdleBeneficialChance)); AI_Init(); AI_Start(); @@ -322,7 +304,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi //give NPCs skill values... int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = content_db.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, moblevel); + skills[r] = database.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, moblevel); } // some overrides -- really we need to be able to set skills for mobs in the DB // There are some known low level SHM/BST pets that do not follow this, which supports @@ -410,10 +392,18 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi SetMana(GetMaxMana()); - if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) { - m_can_open_doors = false; - } - + AISpellVar.fail_recast = static_cast(RuleI(Spells, AI_SpellCastFinishedFailRecast)); + AISpellVar.engaged_no_sp_recast_min = static_cast(RuleI(Spells, AI_EngagedNoSpellMinRecast)); + AISpellVar.engaged_no_sp_recast_max = static_cast(RuleI(Spells, AI_EngagedNoSpellMaxRecast)); + AISpellVar.engaged_beneficial_self_chance = static_cast (RuleI(Spells, AI_EngagedBeneficialSelfChance)); + AISpellVar.engaged_beneficial_other_chance = static_cast (RuleI(Spells, AI_EngagedBeneficialOtherChance)); + AISpellVar.engaged_detrimental_chance = static_cast (RuleI(Spells, AI_EngagedDetrimentalChance)); + AISpellVar.pursue_no_sp_recast_min = static_cast(RuleI(Spells, AI_PursueNoSpellMinRecast)); + AISpellVar.pursue_no_sp_recast_max = static_cast(RuleI(Spells, AI_PursueNoSpellMaxRecast)); + AISpellVar.pursue_detrimental_chance = static_cast (RuleI(Spells, AI_PursueDetrimentalChance)); + AISpellVar.idle_no_sp_recast_min = static_cast(RuleI(Spells, AI_IdleNoSpellMinRecast)); + AISpellVar.idle_no_sp_recast_max = static_cast(RuleI(Spells, AI_IdleNoSpellMaxRecast)); + AISpellVar.idle_beneficial_chance = static_cast (RuleI(Spells, AI_IdleBeneficialChance)); } float NPC::GetRoamboxMaxX() const @@ -725,7 +715,7 @@ bool NPC::Process() } return false; } - + if (IsStunned() && stunned_timer.Check()) { Mob::UnStun(); this->spun_timer.Disable(); @@ -733,27 +723,22 @@ bool NPC::Process() SpellProcess(); - if (mob_close_scan_timer.Check()) { - entity_list.ScanCloseMobs(close_mobs, this, IsMoving()); + if (mob_scan_close.Check()) { + + entity_list.ScanCloseMobs(close_mobs, this); + + if (moving) { + mob_scan_close.Disable(); + mob_scan_close.Start(RandomTimer(3000, 6000)); + } + else { + mob_scan_close.Disable(); + mob_scan_close.Start(RandomTimer(6000, 60000)); + } } - const uint16 npc_mob_close_scan_timer_moving = 6000; - const uint16 npc_mob_close_scan_timer_idle = 60000; - - if (mob_check_moving_timer.Check()) { - if (moving) { - if (mob_close_scan_timer.GetRemainingTime() > npc_mob_close_scan_timer_moving) { - LogAIScanCloseDetail("NPC [{}] Restarting with moving timer", GetCleanName()); - mob_close_scan_timer.Disable(); - mob_close_scan_timer.Start(npc_mob_close_scan_timer_moving); - mob_close_scan_timer.Trigger(); - } - } - else if (mob_close_scan_timer.GetDuration() == npc_mob_close_scan_timer_moving) { - LogAIScanCloseDetail("NPC [{}] Restarting with idle timer", GetCleanName()); - mob_close_scan_timer.Disable(); - mob_close_scan_timer.Start(npc_mob_close_scan_timer_idle); - } + if (mob_check_moving_timer.Check() && moving) { + mob_scan_close.Trigger(); } if (tic_timer.Check()) { @@ -916,10 +901,6 @@ bool NPC::Process() if (assist_timer.Check() && IsEngaged() && !Charmed() && !HasAssistAggro() && NPCAssistCap() < RuleI(Combat, NPCAssistCap)) { - // Some cases like flash of light used for aggro haven't set target - if (!GetTarget()) { - SetTarget(hate_list.GetEntWithMostHateOnList(this)); - } AIYellForHelp(this, GetTarget()); if (NPCAssistCap() > 0 && !assist_cap_timer.Enabled()) assist_cap_timer.Start(RuleI(Combat, NPCAssistCapTimer)); @@ -982,12 +963,9 @@ void NPC::Depop(bool StartSpawnTimer) { if(emoteid != 0) this->DoNPCEmote(ONDESPAWN,emoteid); p_depop = true; - if (respawn2) - { - if (StartSpawnTimer) { + if (StartSpawnTimer) { + if (respawn2 != 0) { respawn2->DeathReset(); - } else { - respawn2->Depop(); } } } @@ -1140,44 +1118,6 @@ void NPC::SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_number, int32 z entity_list.AddNPC(npc); } -void NPC::SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position) -{ - auto npc_type = new NPCType; - memset(npc_type, 0, sizeof(NPCType)); - - char node_name[64]; - strn0cpy(node_name, name.c_str(), 64); - - strcpy(npc_type->name, entity_list.MakeNameUnique(node_name)); - - npc_type->current_hp = 4000000; - npc_type->max_hp = 4000000; - npc_type->race = 2254; - npc_type->gender = 2; - npc_type->class_ = 9; - npc_type->deity = 1; - npc_type->level = 200; - npc_type->npc_id = 0; - npc_type->loottable_id = 0; - npc_type->texture = 1; - npc_type->light = 1; - npc_type->size = 5; - npc_type->runspeed = 0; - npc_type->merchanttype = 1; - npc_type->bodytype = 1; - npc_type->show_name = true; - npc_type->findable = true; - - auto node_position = glm::vec4(position.x, position.y, position.z, position.w); - auto npc = new NPC(npc_type, nullptr, node_position, GravityBehavior::Flying); - - npc->name[strlen(npc->name)-3] = (char) NULL; - - npc->GiveNPCTypeData(npc_type); - - entity_list.AddNPC(npc); -} - NPC * NPC::SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position) { auto npc_type = new NPCType; memset(npc_type, 0, sizeof(NPCType)); @@ -1769,7 +1709,7 @@ void NPC::PickPocket(Client* thief) steal_item = false; break; } - + auto item_inst = database.CreateItem(loot_selection[random].first, loot_selection[random].second); if (item_inst == nullptr) { steal_item = false; @@ -1795,7 +1735,7 @@ void NPC::PickPocket(Client* thief) while (!steal_item && has_coin) { uint32 coin_amount = zone->random.Int(1, (steal_skill / 25) + 1); - + int coin_type = PickPocketPlatinum; while (coin_type <= PickPocketCopper) { if (money[coin_type]) { @@ -2258,12 +2198,8 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) if (RuleB(Pets, UnTargetableSwarmPet)) { ns->spawn.bodytype = 11; - if(!IsCharmed() && swarmOwner->IsClient()) { - std::string tmp_lastname = swarmOwner->GetName(); - tmp_lastname += "'s Pet"; - if (tmp_lastname.size() < sizeof(ns->spawn.lastName)) - strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName)); - } + if(!IsCharmed() && swarmOwner->IsClient()) + sprintf(ns->spawn.lastName, "%s's Pet", swarmOwner->GetName()); } } else if(GetOwnerID()) @@ -2275,10 +2211,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) if(client) { SetPetOwnerClient(true); - std::string tmp_lastname = client->GetName(); - tmp_lastname += "'s Pet"; - if (tmp_lastname.size() < sizeof(ns->spawn.lastName)) - strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName)); + sprintf(ns->spawn.lastName, "%s's Pet", client->GetName()); } } } @@ -2538,10 +2471,10 @@ void NPC::LevelScale() { max_hp += (random_level - level) * 100; base_hp += (random_level - level) * 100; } - + current_hp = max_hp; } - + // Don't add max_dmg to dynamically scaled NPCs since this will be calculated later if (max_dmg > 0 || skip_auto_scale) { @@ -2841,7 +2774,7 @@ FACTION_VALUE NPC::CheckNPCFactionAlly(int32 other_faction) { // I believe that the assumption is, barring no entry in npc_faction_entries // that two npcs on like faction con ally to each other. This catches cases - // where an npc is on a faction but has no hits (hence no entry in + // where an npc is on a faction but has no hits (hence no entry in // npc_faction_entries). if (GetPrimaryFaction() == other_faction) @@ -3221,11 +3154,6 @@ bool NPC::AICheckCloseBeneficialSpells( */ void NPC::AIYellForHelp(Mob *sender, Mob *attacker) { - LogAIYellForHelp("Mob[{}] Target[{}]", - (sender == nullptr ? "NULL MOB" : GetCleanName()), - (attacker == nullptr ? "NULL TARGET" : attacker->GetCleanName()) - ); - if (!sender || !attacker) { return; } @@ -3234,14 +3162,11 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker) * If we dont have a faction set, we're gonna be indiff to everybody */ if (sender->GetPrimaryFaction() == 0) { - LogAIYellForHelp("No Primary Faction"); return; } - if (sender->HasAssistAggro()) { - LogAIYellForHelp("I have assist aggro"); + if (sender->HasAssistAggro()) return; - } LogAIYellForHelp( "NPC [{}] ID [{}] is starting to scan", @@ -3258,19 +3183,6 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker) } float assist_range = (mob->GetAssistRange() * mob->GetAssistRange()); - - // Implement optional sneak-pull - if (RuleB(Combat, EnableSneakPull) && attacker->sneaking) { - assist_range = RuleI(Combat, SneakPullAssistRange); - if (attacker->IsClient()) { - float clientx = attacker->GetX(); - float clienty = attacker->GetY(); - if (attacker->CastToClient()->BehindMob(mob, clientx, clienty)) { - assist_range = 0; - } - } - } - if (distance > assist_range) { continue; } @@ -3306,16 +3218,17 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker) * then jump in if they are our friend */ if (mob->GetLevel() >= 50 || attacker->GetLevelCon(mob->GetLevel()) != CON_GRAY) { + bool use_primary_faction = false; if (mob->GetPrimaryFaction() == sender->CastToNPC()->GetPrimaryFaction()) { const NPCFactionList *cf = content_db.GetNPCFactionEntry(mob->CastToNPC()->GetNPCFactionID()); if (cf) { - if (cf->assistprimaryfaction == 0) { - continue; //Same faction and ignore primary assist + if (cf->assistprimaryfaction != 0) { + use_primary_faction = true; } } } - if (sender->GetReverseFactionCon(mob) <= FACTION_AMIABLE) { + if (use_primary_faction || sender->GetReverseFactionCon(mob) <= FACTION_AMIABLE) { //attacking someone on same faction, or a friend //Father Nitwit: make sure we can see them. if (mob->CheckLosFN(sender)) { @@ -3340,7 +3253,7 @@ void NPC::RecalculateSkills() { int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = content_db.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, level); + skills[r] = database.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, level); } // some overrides -- really we need to be able to set skills for mobs in the DB @@ -3360,11 +3273,3 @@ void NPC::RecalculateSkills() } } } - -void NPC::ScaleNPC(uint8 npc_level) { - if (GetLevel() != npc_level) { - SetLevel(npc_level); - } - npc_scale_manager->ResetNPCScaling(this); - npc_scale_manager->ScaleNPC(this); -} diff --git a/zone/npc.h b/zone/npc.h index b23d15568..f0b9871bd 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -115,7 +115,6 @@ public: static NPC *SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position); static void SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_number, int32 zoffset); - static void SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position); //abstract virtual function implementations requird by base abstract class virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, EQ::skills::SkillType attack_skill); @@ -178,8 +177,8 @@ public: FACTION_VALUE CheckNPCFactionAlly(int32 other_faction); virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther); - void GoToBind(uint8 bind_number = 0) { GMMove(m_SpawnPoint.x, m_SpawnPoint.y, m_SpawnPoint.z, m_SpawnPoint.w); } - void Gate(uint8 bind_number = 0); + void GoToBind(uint8 bindnum = 0) { GMMove(m_SpawnPoint.x, m_SpawnPoint.y, m_SpawnPoint.z, m_SpawnPoint.w); } + void Gate(uint8 bindnum = 0); void GetPetState(SpellBuff_Struct *buffs, uint32 *items, char *name); void SetPetState(SpellBuff_Struct *buffs, uint32 *items); @@ -422,12 +421,10 @@ public: void SetCombatEvent(bool b) { combat_event = b; } /* Only allows players that killed corpse to loot */ - const bool HasPrivateCorpse() const { return NPCTypedata_ours ? NPCTypedata_ours->private_corpse : NPCTypedata->private_corpse; } + const bool HasPrivateCorpse() const { return NPCTypedata->private_corpse; } - virtual const bool IsUnderwaterOnly() const { return NPCTypedata_ours ? NPCTypedata_ours->underwater : NPCTypedata->underwater; } - const char* GetRawNPCTypeName() const { return NPCTypedata_ours ? NPCTypedata_ours->name : NPCTypedata->name; } - - virtual int GetKillExpMod() const { return NPCTypedata_ours ? NPCTypedata_ours->exp_mod : NPCTypedata->exp_mod; } + virtual const bool IsUnderwaterOnly() const { return NPCTypedata->underwater; } + const char* GetRawNPCTypeName() const { return NPCTypedata->name; } void ChangeLastName(const char* in_lastname); void ClearLastName(); @@ -437,9 +434,9 @@ public: void NPCSlotTexture(uint8 slot, uint16 texture); // Sets new material values for slots uint32 GetAdventureTemplate() const { return adventure_template_id; } - void AddSpellToNPCList(int16 iPriority, uint16 iSpellID, uint32 iType, int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp); + void AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType, int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp); void AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base, int32 limit, int32 max); - void RemoveSpellFromNPCList(uint16 spell_id); + void RemoveSpellFromNPCList(int16 spell_id); Timer *GetRefaceTimer() const { return reface_timer; } const uint32 GetAltCurrencyType() const { return NPCTypedata->alt_currency_type; } @@ -496,11 +493,8 @@ public: inline bool IsSkipAutoScale() const { return skip_auto_scale; } - void ScaleNPC(uint8 npc_level); - void RecalculateSkills(); - static LootDropEntries_Struct NewLootDropEntry(); protected: const NPCType* NPCTypedata; @@ -643,10 +637,11 @@ protected: private: - uint32 loottable_id; - bool skip_global_loot; - bool skip_auto_scale; - bool p_depop; + uint32 loottable_id; + bool skip_global_loot; + bool skip_auto_scale; + bool p_depop; + }; #endif diff --git a/zone/npc_scale_manager.cpp b/zone/npc_scale_manager.cpp index 158ac299b..191d2540f 100644 --- a/zone/npc_scale_manager.cpp +++ b/zone/npc_scale_manager.cpp @@ -164,16 +164,6 @@ void NpcScaleManager::ScaleNPC(NPC *npc) } } -void NpcScaleManager::ResetNPCScaling(NPC *npc) { - for (const auto &scaling_stat : scaling_stats) { - std::string stat_name = fmt::format("modify_stat_{}", scaling_stat); - std::string reset_value = "0"; - if (npc->EntityVariableExists(stat_name.c_str())) { - npc->ModifyNPCStat(scaling_stat.c_str(), reset_value.c_str()); - } - } -} - bool NpcScaleManager::LoadScaleData() { auto results = content_db.QueryDatabase( diff --git a/zone/npc_scale_manager.h b/zone/npc_scale_manager.h index 2b52de1e4..1135ee8a2 100644 --- a/zone/npc_scale_manager.h +++ b/zone/npc_scale_manager.h @@ -87,7 +87,6 @@ public: }; void ScaleNPC(NPC * npc); - void ResetNPCScaling(NPC * npc); bool IsAutoScaled(NPC * npc); bool LoadScaleData(); diff --git a/zone/object.cpp b/zone/object.cpp index 88038bbe8..97fdcd69b 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -463,7 +463,7 @@ void Object::RandomSpawn(bool send_packet) { m_data.x = zone->random.Real(m_min_x, m_max_x); m_data.y = zone->random.Real(m_min_y, m_max_y); - if (m_data.z == BEST_Z_INVALID && zone->HasMap()) { + if(m_data.z == BEST_Z_INVALID) { glm::vec3 me; me.x = m_data.x; me.y = m_data.y; diff --git a/zone/pathfinder_nav_mesh.cpp b/zone/pathfinder_nav_mesh.cpp index c644a45e0..4af9fc0f6 100644 --- a/zone/pathfinder_nav_mesh.cpp +++ b/zone/pathfinder_nav_mesh.cpp @@ -20,7 +20,7 @@ struct PathfinderNavmesh::Implementation PathfinderNavmesh::PathfinderNavmesh(const std::string &path) { - m_impl = std::make_unique(); + m_impl.reset(new Implementation()); m_impl->nav_mesh = nullptr; m_impl->query = nullptr; Load(path); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 4d675d8fb..aabeaa77d 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -37,34 +37,28 @@ #endif #include "client.h" -#include "expedition.h" #include "titles.h" #ifdef THIS /* this macro seems to leak out on some systems */ #undef THIS #endif -#define VALIDATE_THIS_IS_CLIENT \ - do { \ - if (sv_derived_from(ST(0), "Client")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Client*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Client"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_Client_SendSound); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendSound) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::SendSound(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendSound(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendSound(); } XSRETURN_EMPTY; @@ -74,12 +68,20 @@ XS(XS_Client_Save); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Save) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::Save(THIS, uint8 commit_now)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Save(THIS, uint8 commit_now)"); { Client *THIS; bool RETVAL; uint8 iCommitNow = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Save(iCommitNow); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -91,10 +93,18 @@ XS(XS_Client_SaveBackup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SaveBackup) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::SaveBackup(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SaveBackup(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SaveBackup(); } XSRETURN_EMPTY; @@ -104,11 +114,19 @@ XS(XS_Client_Connected); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Connected) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Connected(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Connected(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Connected(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -120,11 +138,19 @@ XS(XS_Client_InZone); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_InZone) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::InZone(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::InZone(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->InZone(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -136,10 +162,18 @@ XS(XS_Client_Kick); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Kick) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Kick(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Kick(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Kick("Perl Quest"); } XSRETURN_EMPTY; @@ -149,10 +183,18 @@ XS(XS_Client_Disconnect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Disconnect) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Disconnect(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Disconnect(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Disconnect(); } XSRETURN_EMPTY; @@ -162,11 +204,19 @@ XS(XS_Client_IsLD); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsLD) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsLD(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsLD(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsLD(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -178,10 +228,18 @@ XS(XS_Client_WorldKick); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_WorldKick) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::WorldKick(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::WorldKick(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->WorldKick(); } XSRETURN_EMPTY; @@ -191,10 +249,18 @@ XS(XS_Client_SendToGuildHall); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendToGuildHall) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::SendToGuildHall(THIS)"); // @categories Script Utility, Guild + Perl_croak(aTHX_ "Usage: Client::SendToGuildHall(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendToGuildHall(); } XSRETURN_EMPTY; @@ -204,12 +270,20 @@ XS(XS_Client_GetAnon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAnon) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAnon(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetAnon(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAnon(); XSprePUSH; PUSHu((UV) RETVAL); @@ -217,59 +291,22 @@ XS(XS_Client_GetAnon) { XSRETURN(1); } -XS(XS_Client_SetAnon); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_SetAnon) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetAnon(THIS, uint8 anon_flag)"); // @categories Account and Character, Stats and Attributes - { - Client *THIS; - uint8 anon_flag = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetAnon(anon_flag); - } - XSRETURN_EMPTY; -} - -XS(XS_Client_GetAFK); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_GetAFK) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAFK(THIS)"); // @categories Account and Character, Stats and Attributes - { - Client *THIS; - uint8 RETVAL; - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - RETVAL = THIS->GetAFK(); - XSprePUSH; - PUSHu((UV) RETVAL); - } - XSRETURN(1); -} - -XS(XS_Client_SetAFK); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_SetAFK) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetAFK(THIS, uint8 afk_flag)"); // @categories Account and Character, Stats and Attributes - { - Client *THIS; - uint8 afk_flag = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetAFK(afk_flag); - } - XSRETURN_EMPTY; -} - XS(XS_Client_Duck); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Duck) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Duck(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::Duck(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Duck(); } XSRETURN_EMPTY; @@ -279,7 +316,7 @@ XS(XS_Client_DyeArmorBySlot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_DyeArmorBySlot) { dXSARGS; if (items != 5 && items != 6) - Perl_croak(aTHX_ "Usage: Client::DyeArmorBySlot(THIS, uint8 slot, uint8 red, uint8 green, uint8 blue, [uint8 use_tint = 0x00])"); // @categories Account and Character, Inventory and Items + Perl_croak(aTHX_ "Usage: Client::DyeArmorBySlot(THIS, uint8 slot, uint8 red, uint8 green, uint8 blue, [uint8 use_tint = 0x00])"); { Client *THIS; uint8 slot = (uint8) SvUV(ST(1)); @@ -290,7 +327,14 @@ XS(XS_Client_DyeArmorBySlot) { if (items == 6) { use_tint = (uint8) SvUV(ST(5)); } - VALIDATE_THIS_IS_CLIENT; + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->DyeArmorBySlot(slot, red, green, blue, use_tint); } XSRETURN_EMPTY; @@ -300,10 +344,18 @@ XS(XS_Client_Stand); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Stand) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Stand(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Stand(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Stand(); } XSRETURN_EMPTY; @@ -313,11 +365,19 @@ XS(XS_Client_SetGM); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetGM) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetGM(THIS, bool toggle)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::SetGM(THIS, bool toggle)"); { Client *THIS; bool toggle = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetGM(toggle); } XSRETURN_EMPTY; @@ -327,11 +387,19 @@ XS(XS_Client_SetPVP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetPVP) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetPVP(THIS, bool toggle)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::SetPVP(THIS, bool toggle)"); { Client *THIS; bool toggle = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPVP(toggle); } XSRETURN_EMPTY; @@ -341,11 +409,19 @@ XS(XS_Client_GetPVP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetPVP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetPVP(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetPVP(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPVP(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -357,11 +433,19 @@ XS(XS_Client_GetGM); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetGM) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetGM(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetGM(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGM(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -373,11 +457,19 @@ XS(XS_Client_SetBaseClass); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBaseClass) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetBaseClass(THIS, uint32 class_id)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetBaseClass(THIS, uint32 class_id)"); { Client *THIS; uint32 i = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetBaseClass(i); } XSRETURN_EMPTY; @@ -387,11 +479,19 @@ XS(XS_Client_SetBaseRace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBaseRace) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetBaseRace(THIS, uint32 race_id)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetBaseRace(THIS, uint32 race_id)"); { Client *THIS; uint32 i = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetBaseRace(i); } XSRETURN_EMPTY; @@ -401,11 +501,19 @@ XS(XS_Client_SetBaseGender); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBaseGender) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetBaseGender(THIS, uint32 gender_id)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetBaseGender(THIS, uint32 gender_id)"); { Client *THIS; uint32 i = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetBaseGender(i); } XSRETURN_EMPTY; @@ -415,12 +523,20 @@ XS(XS_Client_GetBaseFace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseFace) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseFace(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseFace(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseFace(); XSprePUSH; PUSHu((UV) RETVAL); @@ -432,13 +548,21 @@ XS(XS_Client_GetLanguageSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLanguageSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetLanguageSkill(THIS, uint16 lanuage_id)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetLanguageSkill(THIS, uint16 lanuage_id)"); { Client *THIS; uint8 RETVAL; dXSTARG; uint16 n = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLanguageSkill(n); XSprePUSH; PUSHu((UV) RETVAL); @@ -446,17 +570,51 @@ XS(XS_Client_GetLanguageSkill) { XSRETURN(1); } +XS(XS_Client_GetLastName); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Client_GetLastName) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Client::GetLastName(THIS)"); + { + Client *THIS; + Const_char *RETVAL; + dXSTARG; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetLastName(); + sv_setpv(TARG, RETVAL); + XSprePUSH; + PUSHTARG; + } + XSRETURN(1); +} + XS(XS_Client_GetLDoNPointsTheme); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLDoNPointsTheme) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetLDoNPointsTheme(THIS, int32 theme)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetLDoNPointsTheme(THIS, int32 theme)"); { Client *THIS; uint32 RETVAL; dXSTARG; int32 theme_out = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLDoNPointsTheme(theme_out); XSprePUSH; PUSHu((UV) RETVAL); @@ -468,12 +626,20 @@ XS(XS_Client_GetBaseSTR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseSTR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseSTR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseSTR(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseSTR(); XSprePUSH; PUSHu((UV) RETVAL); @@ -485,12 +651,20 @@ XS(XS_Client_GetBaseSTA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseSTA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseSTA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseSTA(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseSTA(); XSprePUSH; PUSHu((UV) RETVAL); @@ -502,12 +676,20 @@ XS(XS_Client_GetBaseCHA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseCHA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseCHA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseCHA(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseCHA(); XSprePUSH; PUSHu((UV) RETVAL); @@ -519,12 +701,20 @@ XS(XS_Client_GetBaseDEX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseDEX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseDEX(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseDEX(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseDEX(); XSprePUSH; PUSHu((UV) RETVAL); @@ -536,12 +726,20 @@ XS(XS_Client_GetBaseINT); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseINT) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseINT(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseINT(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseINT(); XSprePUSH; PUSHu((UV) RETVAL); @@ -553,12 +751,20 @@ XS(XS_Client_GetBaseAGI); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseAGI) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseAGI(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseAGI(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseAGI(); XSprePUSH; PUSHu((UV) RETVAL); @@ -570,12 +776,20 @@ XS(XS_Client_GetBaseWIS); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBaseWIS) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBaseWIS(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetBaseWIS(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseWIS(); XSprePUSH; PUSHu((UV) RETVAL); @@ -587,12 +801,20 @@ XS(XS_Client_GetWeight); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetWeight) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetWeight(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetWeight(THIS)"); { Client *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetWeight(); XSprePUSH; PUSHu((UV) RETVAL); @@ -604,12 +826,20 @@ XS(XS_Client_GetEXP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetEXP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetEXP(THIS)"); // @categories Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetEXP(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEXP(); XSprePUSH; PUSHu((UV) RETVAL); @@ -621,12 +851,20 @@ XS(XS_Client_GetAAExp); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAAExp) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAAExp(THIS)"); // @categories Alternative Advancement, Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetAAExp(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAAXP(); XSprePUSH; PUSHu((UV) RETVAL); @@ -638,12 +876,20 @@ XS(XS_Client_GetAAPercent); XS(XS_Client_GetAAPercent) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAAPercent(THIS)"); // @categories Alternative Advancement, Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetAAPercent(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAAPercent(); XSprePUSH; PUSHu((UV) RETVAL); @@ -655,12 +901,20 @@ XS(XS_Client_GetTotalSecondsPlayed); /* prototype to pass -Wmissing-prototypes * XS(XS_Client_GetTotalSecondsPlayed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetTotalSecondsPlayed(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetTotalSecondsPlayed(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTotalSecondsPlayed(); XSprePUSH; PUSHu((UV) RETVAL); @@ -672,13 +926,21 @@ XS(XS_Client_UpdateLDoNPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UpdateLDoNPoints) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::UpdateLDoNPoints(THIS, int32 points, uint32 theme)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::UpdateLDoNPoints(THIS, int32 points, uint32 theme)"); { Client *THIS; bool RETVAL; int32 points = (int32) SvIV(ST(1)); uint32 theme = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->UpdateLDoNPoints(points, theme); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -690,11 +952,19 @@ XS(XS_Client_SetDeity); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetDeity) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetDeity(THIS, uint32 deity_id)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetDeity(THIS, uint32 deity_id)"); { Client *THIS; uint32 i = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDeity(i); } XSRETURN_EMPTY; @@ -704,13 +974,21 @@ XS(XS_Client_AddEXP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AddEXP) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Client::AddEXP(THIS, uint32 experience_points)"); // @categories Experience and Level + Perl_croak(aTHX_ "Usage: Client::AddEXP(THIS, uint32 experience_points)"); { Client *THIS; uint32 add_exp = (uint32) SvUV(ST(1)); uint8 conlevel; bool resexp; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) conlevel = 0xFF; else { @@ -732,13 +1010,21 @@ XS(XS_Client_SetEXP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetEXP) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Client::SetEXP(THIS, uint32 experience_points, uint32 aa_experience_points, [bool resexp=false])"); // @categories Experience and Level + Perl_croak(aTHX_ "Usage: Client::SetEXP(THIS, uint32 experience_points, uint32 aa_experience_points, [bool resexp=false])"); { Client *THIS; uint32 set_exp = (uint32) SvUV(ST(1)); uint32 set_aaxp = (uint32) SvUV(ST(2)); bool resexp; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) resexp = false; else { @@ -753,28 +1039,55 @@ XS(XS_Client_SetEXP) { XS(XS_Client_SetBindPoint); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBindPoint) { dXSARGS; - if (items < 1 || items > 7) - Perl_croak(aTHX_ "Usage: Client::SetBindPoint(THIS, [int to_zone = -1, int to_instance = 0, float new_x = 0.0f, float new_y = 0.0f, float new_z = 0.0f, float new_heading = 0.0f])"); // @categories Account and Character, Stats and Attributes + if (items < 1 || items > 6) + Perl_croak(aTHX_ "Usage: Client::SetBindPoint(THIS, int to_zone = -1, int to_instance = 0, float new_x = 0.0f, float new_y = 0.0f, float new_z = 0.0f)"); { Client *THIS; - int to_zone = -1; - int to_instance = 0; - float new_x = 0.0f, new_y = 0.0f, new_z = 0.0f, new_heading = 0.0f; - VALIDATE_THIS_IS_CLIENT; - if (items > 1) - to_zone = (int) SvIV(ST(1)); - if (items > 2) - to_instance = (int) SvIV(ST(2)); - if (items > 3) - new_x = (float) SvNV(ST(3)); - if (items > 4) - new_y = (float) SvNV(ST(4)); - if (items > 5) - new_z = (float) SvNV(ST(5)); - if (items > 6) - new_heading = (float) SvNV(ST(6)); + int to_zone; + int to_instance; + float new_x; + float new_y; + float new_z; - THIS->SetBindPoint2(0, to_zone, to_instance, glm::vec4(new_x, new_y, new_z, new_heading)); + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + if (items < 2) + to_zone = -1; + else { + to_zone = (int) SvIV(ST(1)); + } + + if (items < 3) + to_instance = 0; + else { + to_instance = (int) SvIV(ST(2)); + } + + if (items < 4) + new_x = 0.0f; + else { + new_x = (float) SvNV(ST(3)); + } + + if (items < 5) + new_y = 0.0f; + else { + new_y = (float) SvNV(ST(4)); + } + + if (items < 6) + new_z = 0.0f; + else { + new_z = (float) SvNV(ST(5)); + } + + THIS->SetBindPoint(0, to_zone, to_instance, glm::vec3(new_x, new_y, new_z)); } XSRETURN_EMPTY; } @@ -783,13 +1096,21 @@ XS(XS_Client_GetBindX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBindX) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetBindX(int index = 0)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetBindX(int index = 0)"); { Client *THIS; int index = 0; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 1) index = 0; else if (items == 2) { @@ -807,13 +1128,21 @@ XS(XS_Client_GetBindY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBindY) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetBindY(int index = 0)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetBindY(int index = 0)"); { Client *THIS; int index = 0; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 1) index = 0; else if (items == 2) { @@ -831,13 +1160,21 @@ XS(XS_Client_GetBindZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBindZ) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetBindZ(int index = 0)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetBindZ(int index = 0)"); { Client *THIS; int index = 0; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 1) index = 0; else if (items == 2) { @@ -855,13 +1192,21 @@ XS(XS_Client_GetBindHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBindHeading) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetBindHeading(int index = 0)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetBindHeading(int index = 0)"); { Client *THIS; int index = 0; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 1) index = 0; else if (items == 2) { @@ -879,13 +1224,21 @@ XS(XS_Client_GetBindZoneID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBindZoneID) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetBindZoneID(int index = 0)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetBindZoneID(int index = 0)"); { Client *THIS; uint32 index = 0; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 1) index = 0; else if (items == 2) { @@ -904,7 +1257,7 @@ XS(XS_Client_MovePC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MovePC) { dXSARGS; if (items != 6) - Perl_croak(aTHX_ "Usage: Client::MovePC(THIS, uint32 zone_id, float x, float y, float z, float heading)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::MovePC(THIS, uint32 zone_id, float x, float y, float z, float heading)"); { Client *THIS; uint32 zoneID = (uint32) SvUV(ST(1)); @@ -912,7 +1265,15 @@ XS(XS_Client_MovePC) { float y = (float) SvNV(ST(3)); float z = (float) SvNV(ST(4)); float heading = (float) SvNV(ST(5)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MovePC(zoneID, x, y, z, heading); } else { @@ -942,7 +1303,7 @@ XS(XS_Client_MovePCInstance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MovePCInstance) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Client::MovePCInstance(THIS, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading)"); // @categories Adventures and Expeditions, Script Utility + Perl_croak(aTHX_ "Usage: Client::MovePCInstance(THIS, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading)"); { Client *THIS; uint32 zoneID = (uint32) SvUV(ST(1)); @@ -951,7 +1312,15 @@ XS(XS_Client_MovePCInstance) { float y = (float) SvNV(ST(4)); float z = (float) SvNV(ST(5)); float heading = (float) SvNV(ST(6)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MovePC(zoneID, instanceID, x, y, z, heading); } else { @@ -982,11 +1351,19 @@ XS(XS_Client_MoveZone); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MoveZone) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZone(THIS, string zone_short_name)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::MoveZone(THIS, string zone_short_name)"); { Client *THIS; const char *zone_short_name = (const char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZone(zone_short_name); } else { @@ -1016,11 +1393,19 @@ XS(XS_Client_MoveZoneGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MoveZoneGroup) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZoneGroup(THIS, string zone_short_name)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Client::MoveZoneGroup(THIS, string zone_short_name)"); { Client *THIS; const char *zone_short_name = (const char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZoneGroup(zone_short_name); } else { @@ -1050,11 +1435,19 @@ XS(XS_Client_MoveZoneRaid); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MoveZoneRaid) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZoneRaid(THIS, string zone_short_name)"); // @categories Script Utility, Raid + Perl_croak(aTHX_ "Usage: Client::MoveZoneRaid(THIS, string zone_short_name)"); { Client *THIS; const char *zone_short_name = (const char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZoneRaid(zone_short_name); } else { @@ -1084,11 +1477,19 @@ XS(XS_Client_MoveZoneInstance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MoveZoneInstance) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZoneInstance(THIS, uint16 instance_id)"); // @categories Adventures and Expeditions, Script Utility + Perl_croak(aTHX_ "Usage: Client::MoveZoneInstance(THIS, uint16 instance_id)"); { Client *THIS; uint16 instance_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZoneInstance(instance_id); } else { @@ -1118,11 +1519,19 @@ XS(XS_Client_MoveZoneInstanceGroup); /* prototype to pass -Wmissing-prototypes * XS(XS_Client_MoveZoneInstanceGroup) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceGroup(THIS, uint16 instance_id)"); // @categories Adventures and Expeditions, Script Utility, Group + Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceGroup(THIS, uint16 instance_id)"); { Client *THIS; uint16 instance_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZoneInstanceGroup(instance_id); } else { @@ -1152,11 +1561,19 @@ XS(XS_Client_MoveZoneInstanceRaid); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MoveZoneInstanceRaid) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceRaid(THIS, uint16 instance_id)"); // @categories Adventures and Expeditions, Script Utility, Raid + Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceRaid(THIS, uint16 instance_id)"); { Client *THIS; uint16 instance_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->IsClient()) { THIS->MoveZoneInstanceRaid(instance_id); } else { @@ -1186,11 +1603,19 @@ XS(XS_Client_ChangeLastName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ChangeLastName) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::ChangeLastName(THIS, string last_name)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::ChangeLastName(THIS, string last_name)"); { Client *THIS; char *in_lastname = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ChangeLastName(in_lastname); } XSRETURN_EMPTY; @@ -1200,7 +1625,7 @@ XS(XS_Client_GetFactionLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetFactionLevel) { dXSARGS; if (items != 8) - Perl_croak(aTHX_ "Usage: Client::GetFactionLevel(THIS, uint32 character_id, uint32 npc_id, uint32 player_race_id, uint32 player_class_id, uint32 player_deity_id, uint32 player_faction_id, Mob*)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Client::GetFactionLevel(THIS, uint32 character_id, uint32 npc_id, uint32 player_race_id, uint32 player_class_id, uint32 player_deity_id, uint32 player_faction_id, Mob*)"); { Client *THIS; FACTION_VALUE RETVAL; @@ -1212,7 +1637,15 @@ XS(XS_Client_GetFactionLevel) { uint32 p_deity = (uint32) SvUV(ST(5)); int32 pFaction = (int32) SvIV(ST(6)); Mob *tnpc; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(7), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(7))); tnpc = INT2PTR(Mob *, tmp); @@ -1232,7 +1665,7 @@ XS(XS_Client_SetFactionLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetFactionLevel) { dXSARGS; if (items != 6) - Perl_croak(aTHX_ "Usage: Client::SetFactionLevel(THIS, uint32 character_id, uint32 npc_id, uint8 character_class, uint8 character_race, uint8 character_deity)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Client::SetFactionLevel(THIS, uint32 character_id, uint32 npc_id, uint8 character_class, uint8 character_race, uint8 character_deity)"); { Client *THIS; uint32 char_id = (uint32) SvUV(ST(1)); @@ -1240,7 +1673,15 @@ XS(XS_Client_SetFactionLevel) { uint8 char_class = (uint8) SvUV(ST(3)); uint8 char_race = (uint8) SvUV(ST(4)); uint8 char_deity = (uint8) SvUV(ST(5)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFactionLevel(char_id, npc_id, char_class, char_race, char_deity); } XSRETURN_EMPTY; @@ -1250,7 +1691,7 @@ XS(XS_Client_SetFactionLevel2); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetFactionLevel2) { dXSARGS; if (items < 7 || items > 8) - Perl_croak(aTHX_ "Usage: Client::SetFactionLevel2(THIS, uint32 character_id, int32 faction_id, uint8 character_class, uint8 character_race, uint8 character_deity, int32 value, uint8 temp)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Client::SetFactionLevel2(THIS, uint32 character_id, int32 faction_id, uint8 character_class, uint8 character_race, uint8 character_deity, int32 value, uint8 temp)"); { Client *THIS; uint32 char_id = (uint32) SvUV(ST(1)); @@ -1260,7 +1701,15 @@ XS(XS_Client_SetFactionLevel2) { uint8 char_deity = (uint8) SvUV(ST(5)); int32 value = (int32) SvIV(ST(6)); uint8 temp; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 7) temp = 0; else { @@ -1276,12 +1725,20 @@ XS(XS_Client_GetRawItemAC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetRawItemAC) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetRawItemAC(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetRawItemAC(THIS)"); { Client *THIS; int16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRawItemAC(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1293,12 +1750,20 @@ XS(XS_Client_AccountID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AccountID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::AccountID(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::AccountID(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->AccountID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1310,12 +1775,20 @@ XS(XS_Client_AccountName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AccountName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::AccountName(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::AccountName(THIS)"); { Client *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->AccountName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -1328,12 +1801,20 @@ XS(XS_Client_Admin); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Admin) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Admin(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::Admin(THIS)"); { Client *THIS; int16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Admin(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1345,12 +1826,20 @@ XS(XS_Client_CharacterID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_CharacterID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::CharacterID(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::CharacterID(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CharacterID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1362,11 +1851,19 @@ XS(XS_Client_UpdateAdmin); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UpdateAdmin) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::UpdateAdmin(THIS, bool from_db = true)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::UpdateAdmin(THIS, bool from_db = true)"); { Client *THIS; bool iFromDB; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) iFromDB = true; else { @@ -1382,11 +1879,19 @@ XS(XS_Client_UpdateWho); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UpdateWho) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::UpdateWho(THIS, uint8 remove = 0)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::UpdateWho(THIS, uint8 remove = 0)"); { Client *THIS; uint8 remove; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) remove = 0; else { @@ -1402,12 +1907,20 @@ XS(XS_Client_GuildRank); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GuildRank) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GuildRank(THIS)"); // @categories Account and Character, Guild + Perl_croak(aTHX_ "Usage: Client::GuildRank(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GuildRank(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1419,12 +1932,20 @@ XS(XS_Client_GuildID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GuildID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GuildID(THIS)"); // @categories Account and Character, Guild + Perl_croak(aTHX_ "Usage: Client::GuildID(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GuildID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1436,12 +1957,20 @@ XS(XS_Client_GetFace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetFace) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetFace(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetFace(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFace(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1453,13 +1982,21 @@ XS(XS_Client_TakeMoneyFromPP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_TakeMoneyFromPP) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::TakeMoneyFromPP(THIS, uint32 copper, bool update_client = false)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::TakeMoneyFromPP(THIS, uint32 copper, bool update_client = false)"); { Client *THIS; bool RETVAL; bool updateclient = false; uint32 copper = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) updateclient = (bool) SvTRUE(ST(2)); @@ -1474,7 +2011,7 @@ XS(XS_Client_AddMoneyToPP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AddMoneyToPP) { dXSARGS; if (items != 6) - Perl_croak(aTHX_ "Usage: Client::AddMoneyToPP(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool update_client)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::AddMoneyToPP(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool update_client)"); { Client *THIS; uint32 copper = (uint32) SvUV(ST(1)); @@ -1482,7 +2019,15 @@ XS(XS_Client_AddMoneyToPP) { uint32 gold = (uint32) SvUV(ST(3)); uint32 platinum = (uint32) SvUV(ST(4)); bool updateclient = (bool) SvTRUE(ST(5)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddMoneyToPP(copper, silver, gold, platinum, updateclient); } XSRETURN_EMPTY; @@ -1492,11 +2037,19 @@ XS(XS_Client_TGB); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_TGB) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::TGB(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::TGB(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->TGB(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1508,12 +2061,20 @@ XS(XS_Client_GetSkillPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetSkillPoints) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetSkillPoints(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::GetSkillPoints(THIS)"); { Client *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSkillPoints(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1525,11 +2086,19 @@ XS(XS_Client_SetSkillPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetSkillPoints) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetSkillPoints(THIS, inp)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::SetSkillPoints(THIS, inp)"); { Client *THIS; int inp = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSkillPoints(inp); } XSRETURN_EMPTY; @@ -1539,12 +2108,20 @@ XS(XS_Client_IncreaseSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IncreaseSkill) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::IncreaseSkill(THIS, int skill_id, int value = 1)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::IncreaseSkill(THIS, int skill_id, int value = 1)"); { Client *THIS; int skill_id = (int) SvIV(ST(1)); int value; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) value = 1; else { @@ -1560,12 +2137,20 @@ XS(XS_Client_IncreaseLanguageSkill); /* prototype to pass -Wmissing-prototypes * XS(XS_Client_IncreaseLanguageSkill) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::IncreaseLanguageSkill(THIS, int skill_id, int value = 1)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::IncreaseLanguageSkill(THIS, int skill_id, int value = 1)"); { Client *THIS; int skill_id = (int) SvIV(ST(1)); int value; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) value = 1; else { @@ -1581,13 +2166,21 @@ XS(XS_Client_GetRawSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetRawSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetRawSkill(THIS, int skill_id)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::GetRawSkill(THIS, int skill_id)"); { Client *THIS; uint32 RETVAL; dXSTARG; EQ::skills::SkillType skill_id = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRawSkill(skill_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -1599,12 +2192,20 @@ XS(XS_Client_HasSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_HasSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::HasSkill(THIS, int skill_id)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::HasSkill(THIS, int skill_id)"); { Client *THIS; bool RETVAL; EQ::skills::SkillType skill_id = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasSkill(skill_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1616,12 +2217,20 @@ XS(XS_Client_CanHaveSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_CanHaveSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::CanHaveSkill(THIS, int skill_id)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::CanHaveSkill(THIS, int skill_id)"); { Client *THIS; bool RETVAL; EQ::skills::SkillType skill_id = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanHaveSkill(skill_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1633,12 +2242,20 @@ XS(XS_Client_SetSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetSkill) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetSkill(THIS, int skill_id, uint16 value)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::SetSkill(THIS, int skill_id, uint16 value)"); { Client *THIS; EQ::skills::SkillType skill_num = (EQ::skills::SkillType) SvUV(ST(1)); uint16 value = (uint16) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSkill(skill_num, value); } XSRETURN_EMPTY; @@ -1648,12 +2265,20 @@ XS(XS_Client_AddSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AddSkill) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::AddSkill(THIS, int skill_id, uint16 value)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::AddSkill(THIS, int skill_id, uint16 value)"); { Client *THIS; EQ::skills::SkillType skillid = (EQ::skills::SkillType) SvUV(ST(1)); uint16 value = (uint16) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddSkill(skillid, value); } XSRETURN_EMPTY; @@ -1663,11 +2288,19 @@ XS(XS_Client_CheckSpecializeIncrease); /* prototype to pass -Wmissing-prototypes XS(XS_Client_CheckSpecializeIncrease) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::CheckSpecializeIncrease(THIS, uint16 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::CheckSpecializeIncrease(THIS, uint16 spell_id)"); { Client *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->CheckSpecializeIncrease(spell_id); } XSRETURN_EMPTY; @@ -1677,13 +2310,21 @@ XS(XS_Client_CheckIncreaseSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_CheckIncreaseSkill) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::CheckIncreaseSkill(THIS, int skill_id, int chance_modifier = 0)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::CheckIncreaseSkill(THIS, int skill_id, int chance_modifier = 0)"); { Client *THIS; bool RETVAL; EQ::skills::SkillType skillid = (EQ::skills::SkillType) SvUV(ST(1)); int chancemodi; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) chancemodi = 0; else { @@ -1701,12 +2342,20 @@ XS(XS_Client_SetLanguageSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetLanguageSkill) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetLanguageSkill(THIS, int language_id, int value)"); // @categories Account and Character, Skills and Recipes, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetLanguageSkill(THIS, int language_id, int value)"); { Client *THIS; int langid = (int) SvIV(ST(1)); int value = (int) SvIV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetLanguageSkill(langid, value); } XSRETURN_EMPTY; @@ -1717,7 +2366,7 @@ XS(XS_Client_MaxSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MaxSkill) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Client::MaxSkill(THIS, uint16 skill_id, uint16 class_id, uint16 level)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::MaxSkill(THIS, uint16 skill_id, uint16 class_id, uint16 level)"); { Client *THIS; uint16 RETVAL; @@ -1725,7 +2374,15 @@ XS(XS_Client_MaxSkill) { uint16 class_ = 0; uint16 level = 0; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) class_ = (uint16) SvUV(ST(2)); else @@ -1747,10 +2404,18 @@ XS(XS_Client_GMKill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GMKill) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GMKill(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GMKill(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->GMKill(); } XSRETURN_EMPTY; @@ -1760,11 +2425,19 @@ XS(XS_Client_IsMedding); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsMedding) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsMedding(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsMedding(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMedding(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1776,12 +2449,20 @@ XS(XS_Client_GetDuelTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetDuelTarget) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetDuelTarget(THIS)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: Client::GetDuelTarget(THIS)"); { Client *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDuelTarget(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1793,11 +2474,19 @@ XS(XS_Client_IsDueling); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsDueling) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsDueling(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsDueling(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsDueling(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1809,11 +2498,19 @@ XS(XS_Client_SetDuelTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetDuelTarget) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetDuelTarget(THIS, set_id)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::SetDuelTarget(THIS, set_id)"); { Client *THIS; uint16 set_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDuelTarget(set_id); } XSRETURN_EMPTY; @@ -1823,11 +2520,19 @@ XS(XS_Client_SetDueling); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetDueling) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetDueling(THIS, duel)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: Client::SetDueling(THIS, duel)"); { Client *THIS; bool duel = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDueling(duel); } XSRETURN_EMPTY; @@ -1837,10 +2542,18 @@ XS(XS_Client_ResetAA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ResetAA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::ResetAA(THIS)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::ResetAA(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ResetAA(); } XSRETURN_EMPTY; @@ -1850,13 +2563,21 @@ XS(XS_Client_MemSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MemSpell) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Client::MemSpell(THIS, uint16 spell_id, int slot, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::MemSpell(THIS, uint16 spell_id, int slot, [bool update_client = true])"); { Client *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); int slot = (int) SvIV(ST(2)); bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) update_client = true; else { @@ -1872,12 +2593,20 @@ XS(XS_Client_UnmemSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UnmemSpell) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::UnmemSpell(THIS, int slot, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UnmemSpell(THIS, int slot, [bool update_client = true])"); { Client *THIS; int slot = (int) SvIV(ST(1)); bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) update_client = true; else { @@ -1893,11 +2622,19 @@ XS(XS_Client_UnmemSpellBySpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UnmemSpellBySpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::UnmemSpellBySpellID(THIS, int32 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UnmemSpellBySpellID(THIS, int32 spell_id)"); { Client *THIS; int32 spell_id = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->UnmemSpellBySpellID(spell_id); } XSRETURN_EMPTY; @@ -1907,11 +2644,19 @@ XS(XS_Client_UnmemSpellAll); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UnmemSpellAll) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::UnmemSpellAll(THIS, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UnmemSpellAll(THIS, [bool update_client = true])"); { Client *THIS; bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) update_client = true; else { @@ -1927,13 +2672,21 @@ XS(XS_Client_FindMemmedSpellBySlot); /* prototype to pass -Wmissing-prototypes * XS(XS_Client_FindMemmedSpellBySlot) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::FindMemmedSpellBySlot(THIS, int slot)"); // @categories Account and Character, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::FindMemmedSpellBySlot(THIS, int slot)"); { Client *THIS; uint16 RETVAL; dXSTARG; int slot = SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->FindMemmedSpellBySlot(slot); XSprePUSH; PUSHu((UV) RETVAL); @@ -1945,12 +2698,20 @@ XS(XS_Client_MemmedCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_MemmedCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::MemmedCount(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::MemmedCount(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->MemmedCount(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1962,13 +2723,21 @@ XS(XS_Client_ScribeSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ScribeSpell) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Client::ScribeSpell(THIS, uint16 spell_id, int slot, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::ScribeSpell(THIS, uint16 spell_id, int slot, [bool update_client = true])"); { Client *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); int slot = (int) SvIV(ST(2)); bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) update_client = true; else { @@ -1984,12 +2753,20 @@ XS(XS_Client_UnscribeSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UnscribeSpell) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::UnscribeSpell(THIS, int slot, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UnscribeSpell(THIS, int slot, [bool update_client = true])"); { Client *THIS; int slot = (int) SvIV(ST(1)); bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) update_client = true; else { @@ -2009,7 +2786,15 @@ XS(XS_Client_UnscribeSpellAll) { { Client *THIS; bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) update_client = true; else { @@ -2025,11 +2810,19 @@ XS(XS_Client_TrainDiscBySpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_TrainDiscBySpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::TrainDiscBySpellID(THIS, int32 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::TrainDiscBySpellID(THIS, int32 spell_id)"); { Client *THIS; int32 spell_id = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->TrainDiscBySpellID(spell_id); } XSRETURN_EMPTY; @@ -2039,13 +2832,21 @@ XS(XS_Client_GetDiscSlotBySpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetDiscSlotBySpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetDiscSlotBySpellID(THIS, int32 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::GetDiscSlotBySpellID(THIS, int32 spell_id)"); { Client *THIS; int RETVAL; int32 spell_id = (int32) SvIV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDiscSlotBySpellID(spell_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -2057,12 +2858,20 @@ XS(XS_Client_UntrainDisc); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UntrainDisc) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Client::UntrainDisc(THIS, int slot, [bool update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UntrainDisc(THIS, int slot, [bool update_client = true])"); { Client *THIS; int slot = (int) SvIV(ST(1)); bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) update_client = true; else { @@ -2078,11 +2887,19 @@ XS(XS_Client_UntrainDiscAll); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UntrainDiscAll) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::UntrainDiscAll(THIS, [update_client = true])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UntrainDiscAll(THIS, [update_client = true])"); { Client *THIS; bool update_client; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) update_client = true; else { @@ -2099,11 +2916,20 @@ XS(XS_Client_IsStanding) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsStanding(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsStanding(THIS)"); { Client * THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Client *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Client"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsStanding(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2115,11 +2941,19 @@ XS(XS_Client_IsSitting); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsSitting) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsSitting(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsSitting(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsSitting(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2132,11 +2966,20 @@ XS(XS_Client_IsCrouching) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsCrouching(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsCrouching(THIS)"); { Client * THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Client *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Client"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsCrouching(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2148,11 +2991,19 @@ XS(XS_Client_IsBecomeNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsBecomeNPC) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsBecomeNPC(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::IsBecomeNPC(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsBecomeNPC(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2164,12 +3015,20 @@ XS(XS_Client_GetBecomeNPCLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetBecomeNPCLevel) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetBecomeNPCLevel(THIS)"); // @categories Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetBecomeNPCLevel(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBecomeNPCLevel(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2181,11 +3040,19 @@ XS(XS_Client_SetBecomeNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBecomeNPC) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetBecomeNPC(THIS, flag)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetBecomeNPC(THIS, flag)"); { Client *THIS; bool flag = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetBecomeNPC(flag); } XSRETURN_EMPTY; @@ -2195,11 +3062,19 @@ XS(XS_Client_SetBecomeNPCLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetBecomeNPCLevel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetBecomeNPCLevel(THIS, level)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetBecomeNPCLevel(THIS, level)"); { Client *THIS; uint8 level = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetBecomeNPCLevel(level); } XSRETURN_EMPTY; @@ -2209,11 +3084,19 @@ XS(XS_Client_SetFeigned); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetFeigned) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetFeigned(THIS, in_feigned)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SetFeigned(THIS, in_feigned)"); { Client *THIS; bool in_feigned = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFeigned(in_feigned); } XSRETURN_EMPTY; @@ -2223,11 +3106,19 @@ XS(XS_Client_GetFeigned); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetFeigned) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetFeigned(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetFeigned(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFeigned(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2239,11 +3130,19 @@ XS(XS_Client_AutoSplitEnabled); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AutoSplitEnabled) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::AutoSplitEnabled(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::AutoSplitEnabled(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->AutoSplitEnabled(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2255,11 +3154,19 @@ XS(XS_Client_SetHorseId); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetHorseId) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetHorseId(THIS, horseid_in)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SetHorseId(THIS, horseid_in)"); { Client *THIS; uint16 horseid_in = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetHorseId(horseid_in); } XSRETURN_EMPTY; @@ -2269,12 +3176,20 @@ XS(XS_Client_GetHorseId); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetHorseId) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetHorseId(THIS)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: Client::GetHorseId(THIS)"); { Client *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHorseId(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2286,14 +3201,22 @@ XS(XS_Client_NukeItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_NukeItem) { dXSARGS; if (items != 3 && items != 2) - Perl_croak(aTHX_ "Usage: Client::NukeItem(THIS, uint32 item_id, [uint8 slot_to_check])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::NukeItem(THIS, uint32 item_id, [uint8 slot_to_check])"); { Client *THIS; uint32 RETVAL; dXSTARG; uint32 itemnum = (uint32) SvUV(ST(1)); uint8 where_to_check; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) { where_to_check = 0xFF; } @@ -2312,12 +3235,20 @@ XS(XS_Client_SetTint); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetTint) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetTint(THIS, int16 slot_id, uint32 color)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SetTint(THIS, int16 slot_id, uint32 color)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); uint32 color = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetTint(slot_id, color); } XSRETURN_EMPTY; @@ -2327,12 +3258,20 @@ XS(XS_Client_SetMaterial); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetMaterial) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetMaterial(THIS, int16 slot_id, uint32 item_id)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SetMaterial(THIS, int16 slot_id, uint32 item_id)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); uint32 item_id = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetMaterial(slot_id, item_id); } XSRETURN_EMPTY; @@ -2342,10 +3281,18 @@ XS(XS_Client_Undye); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Undye) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Undye(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Undye(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Undye(); } XSRETURN_EMPTY; @@ -2355,13 +3302,21 @@ XS(XS_Client_GetItemIDAt); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetItemIDAt) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetItemIDAt(THIS, int16 slot_id)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetItemIDAt(THIS, int16 slot_id)"); { Client *THIS; int32 RETVAL; dXSTARG; int16 slot_id = (int16) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItemIDAt(slot_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -2373,14 +3328,22 @@ XS(XS_Client_GetAugmentIDAt); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAugmentIDAt) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::GetAugmentIDAt(THIS, int16 slot_id, int16 aug_slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetAugmentIDAt(THIS, int16 slot_id, int16 aug_slot)"); { Client *THIS; int32 RETVAL; dXSTARG; int16 slot_id = (int16) SvIV(ST(1)); int16 augslot = (uint8) SvIV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAugmentIDAt(slot_id, augslot); XSprePUSH; PUSHi((IV) RETVAL); @@ -2392,13 +3355,21 @@ XS(XS_Client_DeleteItemInInventory); /* prototype to pass -Wmissing-prototypes * XS(XS_Client_DeleteItemInInventory) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Client::DeleteItemInInventory(THIS, int16 slot_id, [int8 quantity = 0], [bool client_update = false])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::DeleteItemInInventory(THIS, int16 slot_id, [int8 quantity = 0], [bool client_update = false])"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); int8 quantity; bool client_update; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) quantity = 0; else { @@ -2420,7 +3391,7 @@ XS(XS_Client_SummonItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SummonItem) { dXSARGS; if (items < 2 || items > 10) - Perl_croak(aTHX_ "Usage: Client::SummonItem(THIS, uint32 item_id, [int16 charges = -1], [bool attune = false], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint16 slot_id = cursor])"); // @categories Inventory and Items, Script Utility + Perl_croak(aTHX_ "Usage: Client::SummonItem(THIS, uint32 item_id, [int16 charges = -1], [bool attune = false], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint16 slot_id = cursor])"); { Client *THIS; uint32 item_id = (uint32) SvUV(ST(1)); @@ -2432,7 +3403,15 @@ XS(XS_Client_SummonItem) { uint32 aug4 = 0; uint32 aug5 = 0; uint16 slot_id = EQ::invslot::slotCursor; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) { charges = (int16) SvIV(ST(2)); } @@ -2467,12 +3446,20 @@ XS(XS_Client_SetStats); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetStats) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetStats(THIS, uint8 type, uint16 increase_val)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetStats(THIS, uint8 type, uint16 increase_val)"); { Client *THIS; uint8 type = (uint8) SvUV(ST(1)); int16 increase_val = (int16) SvIV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetStats(type, increase_val); } XSRETURN_EMPTY; @@ -2482,12 +3469,20 @@ XS(XS_Client_IncStats); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IncStats) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::IncStats(THIS, uint8 type, uint16 increase_val)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::IncStats(THIS, uint8 type, uint16 increase_val)"); { Client *THIS; uint8 type = (uint8) SvUV(ST(1)); int16 increase_val = (int16) SvIV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->IncStats(type, increase_val); } XSRETURN_EMPTY; @@ -2497,11 +3492,19 @@ XS(XS_Client_DropItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_DropItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::DropItem(THIS, int16 slot_id)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::DropItem(THIS, int16 slot_id)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->DropItem(slot_id); } XSRETURN_EMPTY; @@ -2511,10 +3514,18 @@ XS(XS_Client_BreakInvis); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_BreakInvis) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::BreakInvis(THIS)"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Client::BreakInvis(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->BreakInvis(); } XSRETURN_EMPTY; @@ -2524,11 +3535,19 @@ XS(XS_Client_GetGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetGroup) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetGroup(THIS)"); // @categories Account and Character, Group + Perl_croak(aTHX_ "Usage: Client::GetGroup(THIS)"); { Client *THIS; Group *RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroup(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Group", (void *) RETVAL); @@ -2540,10 +3559,18 @@ XS(XS_Client_LeaveGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_LeaveGroup) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::LeaveGroup(THIS)"); // @categories Account and Character, Group + Perl_croak(aTHX_ "Usage: Client::LeaveGroup(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->LeaveGroup(); } XSRETURN_EMPTY; @@ -2553,11 +3580,19 @@ XS(XS_Client_GetRaid); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetRaid) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetRaid(THIS)"); // @categories Account and Character, Raid + Perl_croak(aTHX_ "Usage: Client::GetRaid(THIS)"); { Client *THIS; Raid *RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRaid(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Raid", (void *) RETVAL); @@ -2569,11 +3604,19 @@ XS(XS_Client_IsGrouped); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsGrouped) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsGrouped(THIS)"); // @categories Account and Character, Group + Perl_croak(aTHX_ "Usage: Client::IsGrouped(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsGrouped(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2585,11 +3628,19 @@ XS(XS_Client_IsRaidGrouped); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsRaidGrouped) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::IsRaidGrouped(THIS)"); // @categories Account and Character, Group, Raid + Perl_croak(aTHX_ "Usage: Client::IsRaidGrouped(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRaidGrouped(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2601,11 +3652,19 @@ XS(XS_Client_Hungry); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Hungry) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Hungry(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::Hungry(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Hungry(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2617,11 +3676,19 @@ XS(XS_Client_Thirsty); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Thirsty) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Thirsty(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::Thirsty(THIS)"); { Client *THIS; bool RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Thirsty(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2633,13 +3700,21 @@ XS(XS_Client_GetInstrumentMod); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetInstrumentMod) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetInstrumentMod(THIS, uint16 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::GetInstrumentMod(THIS, uint16 spell_id)"); { Client *THIS; uint16 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetInstrumentMod(spell_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -2651,13 +3726,21 @@ XS(XS_Client_DecreaseByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_DecreaseByID) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::DecreaseByID(THIS, uint32 type, unit8 amount)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::DecreaseByID(THIS, uint32 type, unit8 amount)"); { Client *THIS; bool RETVAL; uint32 type = (uint32) SvUV(ST(1)); uint8 amt = (uint8) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DecreaseByID(type, amt); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2669,13 +3752,21 @@ XS(XS_Client_SlotConvert2); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SlotConvert2) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SlotConvert2(THIS, uint8 slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SlotConvert2(THIS, uint8 slot)"); { Client *THIS; uint8 RETVAL; dXSTARG; uint8 slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SlotConvert2(slot); XSprePUSH; PUSHu((UV) RETVAL); @@ -2687,10 +3778,18 @@ XS(XS_Client_Escape); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Escape) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::Escape(THIS)"); // @categories Account and Character, Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::Escape(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Escape(); } XSRETURN_EMPTY; @@ -2700,10 +3799,18 @@ XS(XS_Client_RemoveNoRent); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_RemoveNoRent) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::RemoveNoRent(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::RemoveNoRent(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveNoRent(); } XSRETURN_EMPTY; @@ -2713,10 +3820,18 @@ XS(XS_Client_GoFish); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GoFish) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GoFish(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::GoFish(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->GoFish(); } XSRETURN_EMPTY; @@ -2726,10 +3841,18 @@ XS(XS_Client_ForageItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ForageItem) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::ForageItem(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::ForageItem(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ForageItem(); } XSRETURN_EMPTY; @@ -2739,14 +3862,22 @@ XS(XS_Client_CalcPriceMod); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_CalcPriceMod) { dXSARGS; if (items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: Client::CalcPriceMod(THIS, Mob*, [bool reverse = false])"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::CalcPriceMod(THIS, Mob*, [bool reverse = false])"); { Client *THIS; float RETVAL; dXSTARG; Mob *other; bool reverse; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) other = 0; else { @@ -2776,10 +3907,18 @@ XS(XS_Client_ResetTrade); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ResetTrade) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::ResetTrade(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::ResetTrade(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ResetTrade(); } XSRETURN_EMPTY; @@ -2789,13 +3928,21 @@ XS(XS_Client_UseDiscipline); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UseDiscipline) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::UseDiscipline(THIS, int32 spell_id, int32 target)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::UseDiscipline(THIS, int32 spell_id, int32 target)"); { Client *THIS; bool RETVAL; uint32 spell_id = (uint32) SvUV(ST(1)); uint32 target = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->UseDiscipline(spell_id, target); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2807,13 +3954,21 @@ XS(XS_Client_GetDisciplineTimer); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetDisciplineTimer) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetDisciplineTimer(THIS, uint32 timer_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::GetDisciplineTimer(THIS, uint32 timer_id)"); { Client *THIS; uint32 RETVAL; dXSTARG; uint32 timer_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDisciplineTimer(timer_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -2825,11 +3980,19 @@ XS(XS_Client_ResetDisciplineTimer); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ResetDisciplineTimer) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::ResetDisciplineTimer(THIS, uint32 timer_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::ResetDisciplineTimer(THIS, uint32 timer_id)"); { Client *THIS; uint32 timer_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ResetDisciplineTimer(timer_id); } XSRETURN_EMPTY; @@ -2839,13 +4002,21 @@ XS(XS_Client_GetCharacterFactionLevel); /* prototype to pass -Wmissing-prototype XS(XS_Client_GetCharacterFactionLevel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetCharacterFactionLevel(THIS, int32 faction_id)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Client::GetCharacterFactionLevel(THIS, int32 faction_id)"); { Client *THIS; int32 RETVAL; dXSTARG; int32 faction_id = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCharacterFactionLevel(faction_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -2857,11 +4028,19 @@ XS(XS_Client_SetZoneFlag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetZoneFlag) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetZoneFlag(THIS, uint32 zone_id)"); // @categories Account and Character, Zones + Perl_croak(aTHX_ "Usage: Client::SetZoneFlag(THIS, uint32 zone_id)"); { Client *THIS; uint32 zone_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetZoneFlag(zone_id); } XSRETURN_EMPTY; @@ -2871,11 +4050,19 @@ XS(XS_Client_ClearZoneFlag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ClearZoneFlag) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::ClearZoneFlag(THIS, uint32 zone_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::ClearZoneFlag(THIS, uint32 zone_id)"); { Client *THIS; uint32 zone_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearZoneFlag(zone_id); } XSRETURN_EMPTY; @@ -2885,12 +4072,20 @@ XS(XS_Client_HasZoneFlag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_HasZoneFlag) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::HasZoneFlag(THIS, uint32 zone_id)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::HasZoneFlag(THIS, uint32 zone_id)"); { Client *THIS; bool RETVAL; uint32 zone_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasZoneFlag(zone_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2902,11 +4097,19 @@ XS(XS_Client_SendZoneFlagInfo); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendZoneFlagInfo) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SendZoneFlagInfo(THIS, Client* to)"); // @categories Account and Character, Zones + Perl_croak(aTHX_ "Usage: Client::SendZoneFlagInfo(THIS, Client* to)"); { Client *THIS; Client *to; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); to = INT2PTR(Client *, tmp); @@ -2924,10 +4127,18 @@ XS(XS_Client_LoadZoneFlags); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_LoadZoneFlags) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::LoadZoneFlags(THIS)"); // @categories Zones + Perl_croak(aTHX_ "Usage: Client::LoadZoneFlags(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->LoadZoneFlags(); } XSRETURN_EMPTY; @@ -2937,12 +4148,20 @@ XS(XS_Client_SetAATitle); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetAATitle) { dXSARGS; if ((items < 2) || (items > 3)) - Perl_croak(aTHX_ "Usage: Client::SetAATitle(THIS, string text, [bool save = false])"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::SetAATitle(THIS, string text, [bool save = false])"); { Client *THIS; char *txt = (char *) SvPV_nolen(ST(1)); bool SaveTitle = false; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (strlen(txt) > 31) Perl_croak(aTHX_ "Title must be 31 characters or less"); @@ -2961,12 +4180,20 @@ XS(XS_Client_GetClientVersion); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetClientVersion) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetClientVersion(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetClientVersion(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = static_cast(THIS->ClientVersion()); XSprePUSH; PUSHu((UV) RETVAL); @@ -2978,12 +4205,20 @@ XS(XS_Client_GetClientVersionBit); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetClientVersionBit) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetClientVersionBit(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetClientVersionBit(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->ClientVersionBit(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2995,12 +4230,20 @@ XS(XS_Client_SetTitleSuffix); XS(XS_Client_SetTitleSuffix) { dXSARGS; if ((items < 2) || (items > 3)) - Perl_croak(aTHX_ "Usage: Client::SetTitleSuffix(THIS, string text, [bool save = false])"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::SetTitleSuffix(THIS, string text, [bool save = false])"); { Client *THIS; char *txt = (char *) SvPV_nolen(ST(1)); bool SaveSuffix = false; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (strlen(txt) > 31) Perl_croak(aTHX_ "Title must be 31 characters or less"); @@ -3019,11 +4262,19 @@ XS(XS_Client_SetAAPoints); XS(XS_Client_SetAAPoints) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetAAPoints(THIS, uint32 points)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::SetAAPoints(THIS, uint32 points)"); { Client *THIS; uint32 points = SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetAAPoints(points); } XSRETURN_EMPTY; @@ -3033,12 +4284,20 @@ XS(XS_Client_GetAAPoints); XS(XS_Client_GetAAPoints) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAAPoints(THIS)"); // @categories Alternative Advancement, Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetAAPoints(THIS)"); dXSTARG; { Client *THIS; uint32 RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAAPoints(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3050,12 +4309,20 @@ XS(XS_Client_GetSpentAA); XS(XS_Client_GetSpentAA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetSpentAA(THIS)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::GetSpentAA(THIS)"); dXSTARG; { Client *THIS; uint32 RETVAL; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpentAA(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3067,11 +4334,19 @@ XS(XS_Client_AddAAPoints); XS(XS_Client_AddAAPoints) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::AddAAPoints(THIS, uint32 points)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::AddAAPoints(THIS, uint32 points)"); { Client *THIS; uint32 points = SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddAAPoints(points); } XSRETURN_EMPTY; @@ -3081,10 +4356,18 @@ XS(XS_Client_RefundAA); XS(XS_Client_RefundAA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::RefundAA(THIS)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::RefundAA(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RefundAA(); } XSRETURN_EMPTY; @@ -3094,13 +4377,21 @@ XS(XS_Client_GetModCharacterFactionLevel); /* prototype to pass -Wmissing-protot XS(XS_Client_GetModCharacterFactionLevel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetModCharacterFactionLevel(THIS, int32 faction_id)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Client::GetModCharacterFactionLevel(THIS, int32 faction_id)"); { Client *THIS; int32 RETVAL; dXSTARG; int32 faction_id = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetModCharacterFactionLevel(faction_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -3112,12 +4403,20 @@ XS(XS_Client_GetLDoNWins); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLDoNWins) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetLDoNWins(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetLDoNWins(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLDoNWins(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3129,12 +4428,20 @@ XS(XS_Client_GetLDoNLosses); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLDoNLosses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetLDoNLosses(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetLDoNLosses(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLDoNLosses(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3146,13 +4453,21 @@ XS(XS_Client_GetLDoNWinsTheme); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLDoNWinsTheme) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetLDoNWinsTheme(THIS, int32 theme)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetLDoNWinsTheme(THIS, int32 theme)"); { Client *THIS; uint32 RETVAL; dXSTARG; int32 theme_out = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLDoNWinsTheme(theme_out); XSprePUSH; PUSHu((UV) RETVAL); @@ -3164,13 +4479,21 @@ XS(XS_Client_GetLDoNLossesTheme); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetLDoNLossesTheme) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetLDoNLossesTheme(THIS, int32 theme)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetLDoNLossesTheme(THIS, int32 theme)"); { Client *THIS; uint32 RETVAL; dXSTARG; int32 theme_out = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLDoNLossesTheme(theme_out); XSprePUSH; PUSHu((UV) RETVAL); @@ -3182,12 +4505,20 @@ XS(XS_Client_GetItemAt); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetItemAt) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetItemAt(THIS, uint32 slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetItemAt(THIS, uint32 slot)"); { Client *THIS; EQ::ItemInstance *RETVAL; uint32 slot = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetInv().GetItem(slot); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "QuestItem", (void *) RETVAL); @@ -3199,13 +4530,21 @@ XS(XS_Client_GetAugmentAt); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAugmentAt) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::GetAugmentAt(THIS, uint32 slot, uint32 aug_slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetAugmentAt(THIS, uint32 slot, uint32 aug_slot)"); { Client *THIS; EQ::ItemInstance *RETVAL; uint32 slot = (int32) SvIV(ST(1)); uint32 aug_slot = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + EQ::ItemInstance *inst = THIS->GetInv().GetItem(slot); if (inst) { RETVAL = inst->GetAugment(aug_slot); @@ -3223,12 +4562,20 @@ XS(XS_Client_GetStartZone); XS(XS_Client_GetStartZone) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetStartZone(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetStartZone(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetStartZone(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3239,22 +4586,31 @@ XS(XS_Client_GetStartZone) { XS(XS_Client_SetStartZone); XS(XS_Client_SetStartZone) { dXSARGS; - if (items != 2 && items != 5 && items != 6) - Perl_croak(aTHX_ "Usage: Client::SetStartZone(THIS, uint32 zone_id, [float x = 0, float y = 0, float z = 0, [float heading = 0]])"); + if (items != 2 && items != 5) + Perl_croak(aTHX_ + "Usage: Client::SetStartZone(THIS, uint32 zone_id, [float x = 0], [float y = 0], [float z = 0])"); { Client *THIS; uint32 zoneid = (uint32) SvUV(ST(1)); - float x = 0.0f, y = 0.0f, z = 0.0f, heading = 0.0f; - VALIDATE_THIS_IS_CLIENT; - if (items == 5) { - x = (float) SvNV(ST(2)); - y = (float) SvNV(ST(3)); - z = (float) SvNV(ST(4)); - } - if (items == 6) - heading = (float) SvNV(ST(5)); + float x = 0; + float y = 0; + float z = 0; - THIS->SetStartZone(zoneid, x, y, z, heading); + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + if (items == 5) { + x = SvNV(ST(2)); + y = SvNV(ST(3)); + z = SvNV(ST(4)); + } + + THIS->SetStartZone(zoneid, x, y, z); } XSRETURN_EMPTY; } @@ -3263,11 +4619,19 @@ XS(XS_Client_KeyRingAdd); XS(XS_Client_KeyRingAdd) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::KeyRingAdd(THIS, uint32 item_id)"); // @categories Account and Character, Inventory and Items + Perl_croak(aTHX_ "Usage: Client::KeyRingAdd(THIS, uint32 item_id)"); { Client *THIS; uint32 item_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->KeyRingAdd(item_id);; } XSRETURN_EMPTY; @@ -3277,12 +4641,20 @@ XS(XS_Client_KeyRingCheck); XS(XS_Client_KeyRingCheck) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::KeyRingCheck(THIS, uint32 item_id)"); // @categories Account and Character, Inventory and Items + Perl_croak(aTHX_ "Usage: Client::KeyRingCheck(THIS, uint32 item_id)"); { Client *THIS; bool RETVAL; uint32 item_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->KeyRingCheck(item_id);; ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3294,11 +4666,19 @@ XS(XS_Client_AddPVPPoints); XS(XS_Client_AddPVPPoints) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::AddPVPPoints(THIS, uint32 points)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::AddPVPPoints(THIS, uint32 points)"); { Client *THIS; uint32 Points = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddPVPPoints(Points); } XSRETURN_EMPTY; @@ -3308,55 +4688,43 @@ XS(XS_Client_AddCrystals); XS(XS_Client_AddCrystals) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::AddCrystals(THIS, uint32 radiant_count, uint32 ebon_count)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::AddCrystals(THIS, uint32 radiant_count, uint32 ebon_count)"); { Client *THIS; uint32 Radiant = (uint32) SvUV(ST(1)); uint32 Ebon = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddCrystals(Radiant, Ebon); } XSRETURN_EMPTY; } -XS(XS_Client_SetEbonCrystals); -XS(XS_Client_SetEbonCrystals) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetEbonCrystals(THIS, uint32 value)"); - { - Client *THIS; - uint32 value = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetEbonCrystals(value); - } - XSRETURN_EMPTY; -} - -XS(XS_Client_SetRadiantCrystals); -XS(XS_Client_SetRadiantCrystals) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetRadiantCrystals(THIS, uint32 value)"); - { - Client *THIS; - uint32 value = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetRadiantCrystals(value); - } - XSRETURN_EMPTY; -} - XS(XS_Client_GetPVPPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetPVPPoints) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetPVPPoints(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetPVPPoints(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPVPPoints(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3368,12 +4736,20 @@ XS(XS_Client_GetRadiantCrystals); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetRadiantCrystals) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetRadiantCrystals(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetRadiantCrystals(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRadiantCrystals(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3385,12 +4761,20 @@ XS(XS_Client_GetEbonCrystals); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetEbonCrystals) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetEbonCrystals(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetEbonCrystals(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEbonCrystals(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3402,12 +4786,20 @@ XS(XS_Client_ReadBook); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ReadBook) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::ReadBook(THIS, char* book_test, uint8 type)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::ReadBook(THIS, char* book_test, uint8 type)"); { Client *THIS; char *in_txt = (char *) SvPV_nolen(ST(1)); uint8 type = (uint8) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->QuestReadBook(in_txt, type); } XSRETURN_EMPTY; @@ -3417,12 +4809,20 @@ XS(XS_Client_UpdateGroupAAs); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UpdateGroupAAs) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::UpdateGroupAAs(THIS, int32 points, uint32 type)"); // @categories Alternative Advancement, Group + Perl_croak(aTHX_ "Usage: Client::UpdateGroupAAs(THIS, int32 points, uint32 type)"); { Client *THIS; int32 points = (int32) SvIV(ST(1)); uint32 type = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->UpdateGroupAAs(points, type); } XSRETURN(1); @@ -3432,12 +4832,20 @@ XS(XS_Client_GetGroupPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetGroupPoints) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetGroupPoints(THIS)"); // @categories Account and Character, Group + Perl_croak(aTHX_ "Usage: Client::GetGroupPoints(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroupPoints(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3449,12 +4857,20 @@ XS(XS_Client_GetRaidPoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetRaidPoints) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetRaidPoints(THIS)"); // @categories Account and Character, Raid + Perl_croak(aTHX_ "Usage: Client::GetRaidPoints(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRaidPoints(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3466,11 +4882,19 @@ XS(XS_Client_LearnRecipe); XS(XS_Client_LearnRecipe) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::LearnRecipe(THIS, uint32 recipe_id)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Client::LearnRecipe(THIS, uint32 recipe_id)"); { Client *THIS; uint32 recipe_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->LearnRecipe(recipe_id);; } XSRETURN_EMPTY; @@ -3480,12 +4904,20 @@ XS(XS_Client_GetEndurance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetEndurance) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetEndurance(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetEndurance(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEndurance(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3497,12 +4929,20 @@ XS(XS_Client_GetMaxEndurance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetMaxEndurance) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetMaxEndurance(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetMaxEndurance(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxEndurance(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3514,12 +4954,20 @@ XS(XS_Client_GetEnduranceRatio); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetEnduranceRatio) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetEnduranceRatio(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetEnduranceRatio(THIS)"); { Client *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEndurancePercent(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3531,11 +4979,19 @@ XS(XS_Client_SetEndurance); XS(XS_Client_SetEndurance) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetEndurance(THIS, Endurance)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetEndurance(THIS, Endurance)"); { Client *THIS; int32 Endurance = (int32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetEndurance(Endurance); } XSRETURN_EMPTY; @@ -3545,12 +5001,20 @@ XS(XS_Client_SendOPTranslocateConfirm); XS(XS_Client_SendOPTranslocateConfirm) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SendOPTranslocateConfirm(THIS, Mob* caster, int32 spell_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendOPTranslocateConfirm(THIS, Mob* caster, int32 spell_id)"); { Client *THIS; Mob *caster = nullptr; int32 spell_id = (int32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); caster = INT2PTR(Mob *, tmp); @@ -3568,13 +5032,21 @@ XS(XS_Client_NPCSpawn); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_NPCSpawn) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Client::NPCSpawn(THIS, NPC*, string option, uint32 respawn_time=1200)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: Client::NPCSpawn(THIS, NPC*, string option, uint32 respawn_time=1200)"); { Client *THIS; NPC *target_npc = nullptr; Const_char *option = (Const_char *) SvPV_nolen(ST(2)); uint32 respawntime = 1200; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "NPC")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target_npc = INT2PTR(NPC *, tmp); @@ -3595,12 +5067,20 @@ XS(XS_Client_GetIP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetIP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetIP(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetIP(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetIP(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3612,13 +5092,21 @@ XS(XS_Client_AddLevelBasedExp); XS(XS_Client_AddLevelBasedExp) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Client::AddLevelBasedExp(THIS, uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false)"); // @categories Experience and Level + Perl_croak(aTHX_ "Usage: Client::AddLevelBasedExp(THIS, uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false)"); { Client *THIS; uint8 exp_percentage = (uint8) SvUV(ST(1)); uint8 max_level = 0; bool ignore_mods = false; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) max_level = (uint8) SvUV(ST(2)); @@ -3634,11 +5122,19 @@ XS(XS_Client_IncrementAA); XS(XS_Client_IncrementAA) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::IncrementAA(THIS, uint32 aa_skill_id)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::IncrementAA(THIS, uint32 aa_skill_id)"); { Client *THIS; uint32 aaskillid = SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->IncrementAlternateAdvancementRank(aaskillid); } XSRETURN_EMPTY; @@ -3648,14 +5144,22 @@ XS(XS_Client_GrantAlternateAdvancementAbility); /* prototype to pass -Wmissing-p XS(XS_Client_GrantAlternateAdvancementAbility) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Client::GrantAlternateAdvancementAbility(THIS, int aa_id, int points, [bool ignore_cost = false])"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Client::GrantAlternateAdvancementAbility(THIS, int aa_id, int points, [bool ignore_cost = false])"); { Client *THIS; bool RETVAL; int aa_id = (int) SvIV(ST(1)); int points = (int) SvIV(ST(2)); bool ignore_cost = false; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 3) { ignore_cost = (bool) SvTRUE(ST(3)); } @@ -3671,13 +5175,21 @@ XS(XS_Client_GetAALevel); XS(XS_Client_GetAALevel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetAALevel(THIS, uint32 aa_skill_id)"); // @categories Alternative Advancement, Experience and Level + Perl_croak(aTHX_ "Usage: Client::GetAALevel(THIS, uint32 aa_skill_id)"); { Client *THIS; uint32 RETVAL; dXSTARG; uint32 aaskillid = SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAA(aaskillid); XSprePUSH; PUSHu((UV) RETVAL); @@ -3689,13 +5201,21 @@ XS(XS_Client_MarkCompassLoc); XS(XS_Client_MarkCompassLoc) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Client::MarkCompassLoc(THIS, float x, float y, float z)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::MarkCompassLoc(THIS, float x, float y, float z)"); { Client *THIS; float x = SvNV(ST(1)); float y = SvNV(ST(2)); float z = SvNV(ST(3)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->MarkSingleCompassLoc(x, y, z); } XSRETURN_EMPTY; @@ -3705,10 +5225,18 @@ XS(XS_Client_ClearCompassMark); XS(XS_Client_ClearCompassMark) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::ClearCompassMark(THIS)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::ClearCompassMark(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->MarkSingleCompassLoc(0, 0, 0, 0); } XSRETURN_EMPTY; @@ -3718,13 +5246,21 @@ XS(XS_Client_GetFreeSpellBookSlot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetFreeSpellBookSlot) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::GetFreeSpellBookSlot(THIS, uint32 start_slot = 0)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::GetFreeSpellBookSlot(THIS, uint32 start_slot = 0)"); { Client *THIS; int RETVAL; uint32 start_slot = 0; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) start_slot = SvUV(ST(1)); @@ -3739,13 +5275,21 @@ XS(XS_Client_GetSpellBookSlotBySpellID); /* prototype to pass -Wmissing-prototyp XS(XS_Client_GetSpellBookSlotBySpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetSpellBookSlotBySpellID(THIS, uint32 spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::GetSpellBookSlotBySpellID(THIS, uint32 spell_id)"); { Client *THIS; int RETVAL; uint32 spell_id = SvUV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->FindSpellBookSlotBySpellID(spell_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -3753,29 +5297,11 @@ XS(XS_Client_GetSpellBookSlotBySpellID) { XSRETURN(1); } -XS(XS_Client_GetSpellIDByBookSlot); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_GetSpellIDByBookSlot) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetSpellIDByBookSlot(THIS, int slot_id)"); - { - Client* THIS; - int RETVAL; - int slot_id = SvUV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - RETVAL = THIS->GetSpellIDByBookSlot(slot_id); - XSprePUSH; - PUSHi((IV)RETVAL); - } - XSRETURN(1); -} - XS(XS_Client_UpdateTaskActivity); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_UpdateTaskActivity) { dXSARGS; if (items < 4) - Perl_croak(aTHX_ "Usage: Client::UpdateTaskActivity(THIS, int task_id, int activity_id, int count, [bool ignore_quest_update = false])"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::UpdateTaskActivity(THIS, int task_id, int activity_id, int count, [bool ignore_quest_update = false])"); { bool ignore_quest_update = false; @@ -3788,7 +5314,15 @@ XS(XS_Client_UpdateTaskActivity) { if (items == 5) { ignore_quest_update = (bool) SvTRUE(ST(4)); } - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->UpdateTaskActivity(TaskID, ActivityID, Count, ignore_quest_update); } XSRETURN_EMPTY; @@ -3798,14 +5332,22 @@ XS(XS_Client_GetTaskActivityDoneCount); /* prototype to pass -Wmissing-prototype XS(XS_Client_GetTaskActivityDoneCount) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::GetTaskActivityDoneCount(THIS, int task_id, int activity_id)"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::GetTaskActivityDoneCount(THIS, int task_id, int activity_id)"); { Client *THIS; int RETVAL; int TaskID = (int) SvIV(ST(1)); int ActivityID = (int) SvIV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTaskActivityDoneCountFromTaskID(TaskID, ActivityID); XSprePUSH; @@ -3818,7 +5360,7 @@ XS(XS_Client_AssignTask); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AssignTask) { dXSARGS; if (items != 3 && items != 4) - Perl_croak(aTHX_ "Usage: Client::AssignTask(THIS, int task_id, int npc_id, [bool enforce_level_requirement = false])"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::AssignTask(THIS, int task_id, int npc_id, [bool enforce_level_requirement = false])"); { Client *THIS; int TaskID = (int) SvIV(ST(1)); @@ -3829,7 +5371,14 @@ XS(XS_Client_AssignTask) { enforce_level_requirement = true; } } - VALIDATE_THIS_IS_CLIENT; + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AssignTask(TaskID, NPCID, enforce_level_requirement); } XSRETURN_EMPTY; @@ -3839,11 +5388,19 @@ XS(XS_Client_FailTask); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_FailTask) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::FailTask(THIS, int task_id)"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::FailTask(THIS, int task_id)"); { Client *THIS; int TaskID = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->FailTask(TaskID); } XSRETURN_EMPTY; @@ -3853,12 +5410,20 @@ XS(XS_Client_IsTaskCompleted); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsTaskCompleted) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::IsTaskCompleted(THIS, int task_id)"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::IsTaskCompleted(THIS, int task_id)"); { Client *THIS; int RETVAL; int TaskID = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTaskCompleted(TaskID); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3870,12 +5435,20 @@ XS(XS_Client_IsTaskActive); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsTaskActive) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::IsTaskActive(THIS, int task_id)"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::IsTaskActive(THIS, int task_id)"); { Client *THIS; bool RETVAL; int TaskID = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTaskActive(TaskID); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3887,13 +5460,21 @@ XS(XS_Client_IsTaskActivityActive); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_IsTaskActivityActive) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::IsTaskActivityActive(THIS, int task_id, int activity_id)"); // @categories Tasks and Activities + Perl_croak(aTHX_ "Usage: Client::IsTaskActivityActive(THIS, int task_id, int activity_id)"); { Client *THIS; bool RETVAL; int TaskID = (int) SvIV(ST(1)); int ActivityID = (int) SvIV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTaskActivityActive(TaskID, ActivityID); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3905,12 +5486,20 @@ XS(XS_Client_GetCorpseCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetCorpseCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetCorpseCount(THIS)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Client::GetCorpseCount(THIS)"); { Client *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseCount(); XSprePUSH; PUSHi((IV) RETVAL); @@ -3922,13 +5511,21 @@ XS(XS_Client_GetCorpseID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetCorpseID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetCorpseID(THIS, uint8 corpse)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Client::GetCorpseID(THIS, uint8 corpse)"); { Client *THIS; uint8 corpse = (uint8) SvIV(ST(1)); uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseID(corpse); XSprePUSH; PUSHi((IV) RETVAL); @@ -3940,14 +5537,22 @@ XS(XS_Client_GetCorpseItemAt); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetCorpseItemAt) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::GetCorpseItemAt(THIS, uint32 corpse_id, uint16 slot_id)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Client::GetCorpseItemAt(THIS, uint32 corpse_id, uint16 slot_id)"); { Client *THIS; uint32 corpse_id = (uint32) SvIV(ST(1)); uint16 slotid = (uint16) SvIV(ST(2)); uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseItemAt(corpse_id, slotid); XSprePUSH; PUSHi((IV) RETVAL); @@ -3959,11 +5564,19 @@ XS(XS_Client_AssignToInstance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_AssignToInstance) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::AssignToInstance(THIS, uint16 instance_id)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::AssignToInstance(THIS, uint16 instance_id)"); { Client *THIS; uint16 instance_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AssignToInstance(instance_id); } XSRETURN_EMPTY; @@ -3973,11 +5586,19 @@ XS(XS_Client_RemoveFromInstance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_RemoveFromInstance) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::RemoveFromInstance(THIS, uint16 instance_id)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::RemoveFromInstance(THIS, uint16 instance_id)"); { Client *THIS; uint16 instance_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveFromInstance(instance_id); } XSRETURN_EMPTY; @@ -3990,7 +5611,15 @@ XS(XS_Client_Freeze) { Perl_croak(aTHX_ "Usage: Client:Freeze(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendAppearancePacket(AT_Anim, ANIM_FREEZE); } XSRETURN_EMPTY; @@ -4003,7 +5632,15 @@ XS(XS_Client_UnFreeze) { Perl_croak(aTHX_ "Usage: Client:UnFreeze(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendAppearancePacket(AT_Anim, ANIM_STAND); } XSRETURN_EMPTY; @@ -4014,12 +5651,20 @@ XS(XS_Client_GetAggroCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAggroCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAggroCount(THIS)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: Client::GetAggroCount(THIS)"); { Client *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAggroCount(); XSprePUSH; PUSHi((IV) RETVAL); @@ -4032,12 +5677,20 @@ XS(XS_Client_GetCarriedMoney); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetCarriedMoney) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetCarriedMoney(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetCarriedMoney(THIS)"); { Client *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCarriedMoney(); XSprePUSH; PUSHi((IV) RETVAL); @@ -4050,12 +5703,20 @@ XS(XS_Client_GetAllMoney); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAllMoney) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetAllMoney(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetAllMoney(THIS)"); { Client *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAllMoney(); XSprePUSH; PUSHi((IV) RETVAL); @@ -4068,12 +5729,20 @@ XS(XS_Client_GetItemInInventory); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetItemInInventory) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetItemInInventory(THIS, int16 slot_id)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::GetItemInInventory(THIS, int16 slot_id)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); EQ::ItemInstance *RETVAL = nullptr; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetInv().GetItem(slot_id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "QuestItem", (void *) RETVAL); @@ -4085,13 +5754,21 @@ XS(XS_Client_SetCustomItemData); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetCustomItemData) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Client::SetCustomItemData(THIS, int16 slot_id, string identifier, string value)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SetCustomItemData(THIS, int16 slot_id, string identifier, string value)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); Const_char *identifier = SvPV_nolen(ST(2)); Const_char *value = SvPV_nolen(ST(3)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->GetInv().SetCustomItemData(THIS->CharacterID(), slot_id, std::string(identifier), std::string(value)); } XSRETURN_EMPTY; @@ -4101,14 +5778,22 @@ XS(XS_Client_GetCustomItemData); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetCustomItemData) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::GetCustomItemData(THIS, int16 slot_id, string identifier)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Client::GetCustomItemData(THIS, int16 slot_id, string identifier)"); { Client *THIS; int16 slot_id = (int16) SvIV(ST(1)); Const_char *identifier = SvPV_nolen(ST(2)); Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::string ret_val = THIS->GetInv().GetCustomItemData(slot_id, std::string(identifier)); RETVAL = ret_val.c_str(); sv_setpv(TARG, RETVAL); @@ -4122,10 +5807,18 @@ XS(XS_Client_OpenLFGuildWindow); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_OpenLFGuildWindow) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::OpenLFGuildWindow(THIS)"); // @categories Script Utility, Guild + Perl_croak(aTHX_ "Usage: Client::OpenLFGuildWindow(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->OpenLFGuildWindow(); } XSRETURN_EMPTY; @@ -4135,10 +5828,18 @@ XS(XS_Client_NotifyNewTitlesAvailable); /* prototype to pass -Wmissing-prototype XS(XS_Client_NotifyNewTitlesAvailable) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::NotifyNewTitlesAvailable(THIS)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::NotifyNewTitlesAvailable(THIS)"); { Client *THIS; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->NotifyNewTitlesAvailable(); } XSRETURN_EMPTY; @@ -4148,12 +5849,20 @@ XS(XS_Client_AddAlternateCurrencyValue); /* prototype to pass -Wmissing-prototyp XS(XS_Client_AddAlternateCurrencyValue) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::AddAlternateCurrencyValue(THIS, uint32 currency_id, int32 amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::AddAlternateCurrencyValue(THIS, uint32 currency_id, int32 amount)"); { Client *THIS; uint32 currency_id = (uint32) SvUV(ST(1)); int32 amount = (int32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddAlternateCurrencyValue(currency_id, amount); } XSRETURN_EMPTY; @@ -4163,12 +5872,20 @@ XS(XS_Client_SetAlternateCurrencyValue); /* prototype to pass -Wmissing-prototyp XS(XS_Client_SetAlternateCurrencyValue) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetAlternateCurrencyValue(THIS, uint32 currency_id, int32 amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::SetAlternateCurrencyValue(THIS, uint32 currency_id, int32 amount)"); { Client *THIS; uint32 currency_id = (uint32) SvUV(ST(1)); int32 amount = (int32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetAlternateCurrencyValue(currency_id, amount); } XSRETURN_EMPTY; @@ -4178,13 +5895,21 @@ XS(XS_Client_GetAlternateCurrencyValue); /* prototype to pass -Wmissing-prototyp XS(XS_Client_GetAlternateCurrencyValue) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetAlternateCurrencyValue(THIS, uint32 currency_id)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: Client::GetAlternateCurrencyValue(THIS, uint32 currency_id)"); { Client *THIS; uint32 currency_id = (uint32) SvUV(ST(1)); int32 RETVAL = 0; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAlternateCurrencyValue(currency_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -4196,11 +5921,19 @@ XS(XS_Client_SendWebLink); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendWebLink) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::SendWebLink(THIS, string website_url)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendWebLink(THIS, string website_url)"); { Client *THIS; char *website = nullptr; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { website = (char *) SvPV_nolen(ST(1)); } THIS->SendWebLink(website); @@ -4212,12 +5945,20 @@ XS(XS_Client_GetInstanceID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetInstanceID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetInstanceID(THIS)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::GetInstanceID(THIS)"); { Client *THIS; int8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetInstanceID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4229,12 +5970,20 @@ XS(XS_Client_HasSpellScribed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_HasSpellScribed) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::HasSpellScribed(THIS, int spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Client::HasSpellScribed(THIS, int spell_id)"); { Client *THIS; bool RETVAL; int spell_id = (int) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + RETVAL = THIS->HasSpellScribed(spell_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4246,7 +5995,7 @@ XS(XS_Client_SetAccountFlag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetAccountFlag) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetAccountFlag(THIS, string flag, string value)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::SetAccountFlag(THIS, string flag, string value)"); { Client *THIS; //char* flag = (char *)SvPV_nolen(ST(1)); @@ -4254,7 +6003,15 @@ XS(XS_Client_SetAccountFlag) { std::string flag((char *) SvPV_nolen(ST(1))); std::string value((char *) SvTRUE(ST(2))); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->SetAccountFlag(flag, value); } XSRETURN_EMPTY; @@ -4264,7 +6021,7 @@ XS(XS_Client_GetAccountFlag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetAccountFlag) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetAccountFlag(THIS, string flag)"); // @categories Account and Character + Perl_croak(aTHX_ "Usage: Client::GetAccountFlag(THIS, string flag)"); { Client *THIS; //char* flag = (char *)SvPV_nolen(ST(1)); @@ -4272,7 +6029,15 @@ XS(XS_Client_GetAccountFlag) { std::string flag((char *) SvPV_nolen(ST(1))); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + std::string value = THIS->GetAccountFlag(flag); sv_setpv(TARG, value.c_str()); @@ -4286,12 +6051,20 @@ XS(XS_Client_GetHunger); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetHunger) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetHunger(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetHunger(THIS)"); { Client *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHunger(); XSprePUSH; PUSHi((IV) RETVAL); @@ -4303,12 +6076,20 @@ XS(XS_Client_GetThirst); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetThirst) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetThirst(THIS)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::GetThirst(THIS)"); { Client *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetThirst(); XSprePUSH; PUSHi((IV) RETVAL); @@ -4320,11 +6101,19 @@ XS(XS_Client_SetHunger); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetHunger) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetHunger(THIS, in_hunger)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetHunger(THIS, in_hunger)"); { Client *THIS; int32 in_hunger = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetHunger(in_hunger); } XSRETURN_EMPTY; @@ -4334,11 +6123,19 @@ XS(XS_Client_SetThirst); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetThirst) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SetThirst(THIS, int32 in_thirst)"); // @categories Account and Character, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetThirst(THIS, int32 in_thirst)"); { Client *THIS; int32 in_thirst = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetThirst(in_thirst); } XSRETURN_EMPTY; @@ -4348,11 +6145,19 @@ XS(XS_Client_SendTargetCommand); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendTargetCommand) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SendTargetCommand(THIS, int32 entity_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendTargetCommand(THIS, int32 entity_id)"); { Client *THIS; int32 in_entid = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendTargetCommand(in_entid); } XSRETURN_EMPTY; @@ -4362,12 +6167,20 @@ XS(XS_Client_SetConsumption); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SetConsumption) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetHunger(THIS, int32 hunger_amount, int32 thirst_amount)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Client::SetHunger(THIS, int32 hunger_amount, int32 thirst_amount)"); { Client *THIS; int32 in_hunger = (uint32) SvUV(ST(1)); int32 in_thirst = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetConsumption(in_hunger, in_thirst); } XSRETURN_EMPTY; @@ -4377,11 +6190,18 @@ XS(XS_Client_SilentMessage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SilentMessage) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Client::SilentMessage(THIS, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SilentMessage(THIS, string message)"); { Client *THIS; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); if (THIS->GetTarget() != NULL) { if (THIS->GetTarget()->IsNPC()) { if (DistanceSquaredNoZ(THIS->GetPosition(), THIS->GetTarget()->GetPosition()) <= 200) { @@ -4400,11 +6220,19 @@ XS(XS_Client_PlayMP3); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_PlayMP3) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Client::PlayMP3(THIS, string file_name)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::PlayMP3(THIS, string file_name)"); { Client *THIS; char *fname = nullptr; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { fname = (char *) SvPV_nolen(ST(1)); } THIS->PlayMP3(fname); @@ -4416,13 +6244,21 @@ XS(XS_Client_ExpeditionMessage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ExpeditionMessage) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::ExpeditionMessage(THIS, int expedition_id, string message)"); // @categories Adventures and Expeditions + Perl_croak(aTHX_ "Usage: Client::ExpeditionMessage(THIS, int expedition_id, string message)"); { Client *THIS; int ExpdID = (int) SvUV(ST(1)); const char *Message = (const char *) SvPV_nolen(ST(2)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->ExpeditionSay(Message, ExpdID); } XSRETURN_EMPTY; @@ -4434,7 +6270,7 @@ XS(XS_Client_SendMarqueeMessage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendMarqueeMessage) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Client::SendMarqueeMessage(THIS, uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, string msg)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendMarqueeMessage(THIS, uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, string msg)"); { Client *THIS; uint32 type = (uint32) SvUV(ST(1)); @@ -4444,7 +6280,15 @@ XS(XS_Client_SendMarqueeMessage) { uint32 duration = (uint32) SvUV(ST(5)); std::string msg = (std::string) SvPV_nolen(ST(6)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->SendMarqueeMessage(type, priority, fade_in, fade_out, duration, msg); } XSRETURN_EMPTY; @@ -4454,13 +6298,21 @@ XS(XS_Client_SendColoredText); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_SendColoredText) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SendColoredText(uint32 color, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendColoredText(uint32 color, string message)"); { Client *THIS; uint32 color = (uint32) SvUV(ST(1)); std::string msg = (std::string) SvPV_nolen(ST(2)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->SendColoredText(color, msg); } XSRETURN_EMPTY; @@ -4476,7 +6328,15 @@ XS(XS_Client_SendSpellAnim) { uint16 targetid = (uint16) SvUV(ST(1)); uint16 spell_id = (uint16) SvUV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->SendSpellAnim(targetid, spell_id); } XSRETURN_EMPTY; @@ -4486,12 +6346,20 @@ XS(XS_Client_GetTargetRingX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetTargetRingX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetTargetRingX(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetTargetRingX(THIS)"); { Client *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTargetRingX(); XSprePUSH; PUSHn((double) RETVAL); @@ -4503,12 +6371,20 @@ XS(XS_Client_GetTargetRingY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetTargetRingY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetTargetRingY(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetTargetRingY(THIS)"); { Client *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTargetRingY(); XSprePUSH; PUSHn((double) RETVAL); @@ -4520,12 +6396,20 @@ XS(XS_Client_GetTargetRingZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetTargetRingZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetTargetRingZ(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::GetTargetRingZ(THIS)"); { Client *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTargetRingZ(); XSprePUSH; PUSHn((double) RETVAL); @@ -4545,7 +6429,15 @@ XS(XS_Client_CalcEXP) { if (items == 2) conlevel = (uint16) SvUV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + RETVAL = THIS->CalcEXP(conlevel); XSprePUSH; PUSHi((IV) RETVAL); @@ -4557,7 +6449,7 @@ XS(XS_Client_QuestReward); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_QuestReward) { dXSARGS; if (items < 1 || items > 9) - Perl_croak(aTHX_ "Usage: Client::QuestReward(THIS, int32 mob, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int32 exp, [bool faction = false])"); // @categories Currency and Points, Experience and Level, Inventory and Items, Faction + Perl_croak(aTHX_ "Usage: Client::QuestReward(THIS, int32 mob, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int32 exp, [bool faction = false])"); { Client *THIS; Mob *mob = nullptr; @@ -4610,7 +6502,16 @@ XS(XS_Client_GetMoney) { uint8 type = (uint8) SvUV(ST(1)); uint8 subtype = (uint8) SvUV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMoney(type, subtype); XSprePUSH; PUSHn((uint32) RETVAL); @@ -4627,7 +6528,16 @@ XS(XS_Client_GetAccountAge) { Client *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAccountAge(); XSprePUSH; PUSHn((int) RETVAL); @@ -4639,7 +6549,7 @@ XS(XS_Client_Popup2); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_Popup2) { dXSARGS; if (items < 3 || items > 10) - Perl_croak(aTHX_ "Usage: Client::Popup2(THIS, string title, string text, uint32 popup_id, uint32 negative_id, uint32 buttons, uint32 duration, string button_name_0, string button_name_1, uint32 sound_controls)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Client::SendFullPopup(THIS, string title, string text, uint32 popup_id, uint32 negative_id, uint32 buttons, uint32 duration, string button_name_0, string button_name_1, uint32 sound_controls)"); { Client *THIS; char *Title = (char *) SvPV_nolen(ST(1)); @@ -4651,7 +6561,15 @@ XS(XS_Client_Popup2) { char *ButtonName0 = 0; char *ButtonName1 = 0; uint32 SoundControls = 0; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 3) { PopupID = (uint32) SvUV(ST(3)); } if (items > 4) { NegativeID = (uint32) SvUV(ST(4)); } if (items > 5) { Buttons = (uint32) SvUV(ST(5)); } @@ -4672,12 +6590,23 @@ XS(XS_Client_SetPrimaryWeaponOrnamentation) { dXSARGS; if (items != 2) { - Perl_croak(aTHX_ "Usage: Client::SetPrimaryWeaponOrnamentation(THIS, model_id)"); // @categories Account and Character, Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SetPrimaryWeaponOrnamentation(THIS, model_id)"); } { Client *THIS; uint32 model_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } + else { + Perl_croak(aTHX_ "THIS is not of type Client"); + } + if (THIS == nullptr) { + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + } + THIS->SetPrimaryWeaponOrnamentation(model_id); } XSRETURN_EMPTY; @@ -4688,12 +6617,23 @@ XS(XS_Client_SetSecondaryWeaponOrnamentation) { dXSARGS; if (items != 2) { - Perl_croak(aTHX_ "Usage: Client::SetSecondaryWeaponOrnamentation(THIS, model_id)"); // @categories Account and Character, Inventory and Items + Perl_croak(aTHX_ "Usage: Client::SetSecondaryWeaponOrnamentation(THIS, model_id)"); } { Client *THIS; uint32 model_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } + else { + Perl_croak(aTHX_ "THIS is not of type Client"); + } + if (THIS == nullptr) { + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + } + THIS->SetSecondaryWeaponOrnamentation(model_id); } XSRETURN_EMPTY; @@ -4707,7 +6647,16 @@ XS(XS_Client_SetClientMaxLevel) { { Client* THIS; int in_level = (int)SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Client*, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetClientMaxLevel(in_level); } XSRETURN_EMPTY; @@ -4722,7 +6671,16 @@ XS(XS_Client_GetClientMaxLevel) { Client* THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_CLIENT; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Client*, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientMaxLevel(); XSprePUSH; PUSHu((UV)RETVAL); @@ -4730,565 +6688,6 @@ XS(XS_Client_GetClientMaxLevel) { XSRETURN(1); } -XS(XS_Client_CreateExpedition); -XS(XS_Client_CreateExpedition) { - dXSARGS; - if (items != 7 && items != 8) { - Perl_croak(aTHX_ "Usage: Client::CreateExpedition(THIS, string zone_name, uint32 zone_version, uint32 duration, string expedition_name, uint32 min_players, uint32 max_players, [bool disable_messages = false])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string zone_name(SvPV_nolen(ST(1))); - uint32 zone_version = (uint32)SvUV(ST(2)); - uint32 duration = (uint32)SvUV(ST(3)); - std::string expedition_name(SvPV_nolen(ST(4))); - uint32 min_players = (uint32)SvUV(ST(5)); - uint32 max_players = (uint32)SvUV(ST(6)); - bool disable_messages = (items > 7) ? (bool)SvTRUE(ST(7)) : false; - - Expedition* RETVAL = THIS->CreateExpedition(zone_name, zone_version, duration, - expedition_name, min_players, max_players, disable_messages); - - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - - XSRETURN(1); -} - -XS(XS_Client_GetExpedition); -XS(XS_Client_GetExpedition) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Client::GetExpedition(THIS)"); - } - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - Expedition* RETVAL = THIS->GetExpedition(); - - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "Expedition", (void*)RETVAL); - - XSRETURN(1); -} - -XS(XS_Client_GetExpeditionLockouts); -XS(XS_Client_GetExpeditionLockouts) { - dXSARGS; - if (items != 1 && items != 2) { - Perl_croak(aTHX_ "Usage: Client::GetExpeditionLockouts(THIS, [string expedition_name])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - HV* hash = newHV(); - SV* hash_ref = nullptr; // for expedition event hash if filtering on expedition - - std::string expedition_name; - if (items == 2) - { - expedition_name = SvPV_nolen(ST(1)); - } - - auto lockouts = THIS->GetExpeditionLockouts(); - - for (const auto& lockout : lockouts) - { - uint32_t name_len = static_cast(lockout.GetExpeditionName().size()); - uint32_t event_len = static_cast(lockout.GetEventName().size()); - - SV** entry = hv_fetch(hash, lockout.GetExpeditionName().c_str(), name_len, false); - if (!entry) - { - SV* event_hash_ref = newRV_noinc((SV*)newHV()); // takes ownership of hash - if (!expedition_name.empty() && lockout.GetExpeditionName() == expedition_name) - { - hash_ref = event_hash_ref; // save ref to event hash for return - } - entry = hv_store(hash, lockout.GetExpeditionName().c_str(), name_len, event_hash_ref, 0); - } - - if (entry && SvROK(*entry) && SvTYPE(SvRV(*entry)) == SVt_PVHV) - { - HV* event_hash = (HV*)SvRV(*entry); - hv_store(event_hash, lockout.GetEventName().c_str(), event_len, - newSVuv(lockout.GetSecondsRemaining()), 0); - } - } - - SV* rv = &PL_sv_undef; - - if (!expedition_name.empty()) - { - rv = hash_ref ? sv_2mortal(hash_ref) : &PL_sv_undef; // ref that owns event hash for expedition - } - else - { - rv = sv_2mortal(newRV_noinc((SV*)hash)); // owns expedition hash - } - - ST(0) = rv; - XSRETURN(1); -} - -XS(XS_Client_GetLockoutExpeditionUUID); -XS(XS_Client_GetLockoutExpeditionUUID) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Client::GetLockoutExpeditionUUID(THIS, string expedition_name, string event_name)"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name = SvPV_nolen(ST(1)); - std::string event_name = SvPV_nolen(ST(2)); - - auto lockout = THIS->GetExpeditionLockout(expedition_name, event_name); - if (lockout) - { - XSRETURN_PV(lockout->GetExpeditionUUID().c_str()); - } - - XSRETURN_UNDEF; -} - -XS(XS_Client_AddExpeditionLockout); -XS(XS_Client_AddExpeditionLockout) { - dXSARGS; - if (items != 4 && items != 5) { - Perl_croak(aTHX_ "Usage: Client::AddExpeditionLockout(THIS, string expedition_name, string event_name, uint32 seconds, [string uuid])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - uint32 seconds = (uint32)SvUV(ST(3)); - std::string uuid; - - if (items == 5) - { - uuid = SvPV_nolen(ST(4)); - } - - THIS->AddNewExpeditionLockout(expedition_name, event_name, seconds, uuid); - - XSRETURN_EMPTY; -} - -XS(XS_Client_AddExpeditionLockoutDuration); -XS(XS_Client_AddExpeditionLockoutDuration) { - dXSARGS; - if (items != 4 && items != 5) { - Perl_croak(aTHX_ "Usage: Client::AddExpeditionLockoutDuration(THIS, string expedition_name, string event_name, int seconds, [string uuid])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - int seconds = static_cast(SvUV(ST(3))); - std::string uuid; - - if (items == 5) - { - uuid = SvPV_nolen(ST(4)); - } - - THIS->AddExpeditionLockoutDuration(expedition_name, event_name, seconds, uuid, true); - - XSRETURN_EMPTY; -} - -XS(XS_Client_RemoveAllExpeditionLockouts); -XS(XS_Client_RemoveAllExpeditionLockouts) { - dXSARGS; - if (items != 1 && items != 2) { - Perl_croak(aTHX_ "Usage: Client::RemoveAllExpeditionLockouts(THIS, [string expedition_name])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name; - if (items == 2) - { - expedition_name = SvPV_nolen(ST(1)); - } - - THIS->RemoveAllExpeditionLockouts(expedition_name, true); - - XSRETURN_EMPTY; -} - -XS(XS_Client_RemoveExpeditionLockout); -XS(XS_Client_RemoveExpeditionLockout) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Client::RemoveExpeditionLockout(THIS, string expedition_name, string event_name)"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - - THIS->RemoveExpeditionLockout(expedition_name, event_name, true); - - XSRETURN_EMPTY; -} - -XS(XS_Client_HasExpeditionLockout); -XS(XS_Client_HasExpeditionLockout) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Client::HasExpeditionLockout(THIS, string expedition_name, string event_name)"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - - bool result = THIS->HasExpeditionLockout(expedition_name, event_name); - ST(0) = boolSV(result); - - XSRETURN(1); -} - -XS(XS_Client_MovePCDynamicZone); -XS(XS_Client_MovePCDynamicZone) { - dXSARGS; - if (items != 2 && items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Client::MovePCDynamicZone(THIS, uint32 zone_id | string zone_name, [int zone_version = -1], [bool message_if_invalid = true])"); - } - - Client* THIS = nullptr; - VALIDATE_THIS_IS_CLIENT; - - if (SvTYPE(ST(1)) == SVt_PV) - { - std::string zone_name(SvPV_nolen(ST(1))); - int zone_version = (items >= 3) ? static_cast(SvIV(ST(2))) : -1; - if (items == 4) - { - THIS->MovePCDynamicZone(zone_name, zone_version, (bool)SvTRUE(ST(3))); - } - else - { - THIS->MovePCDynamicZone(zone_name, zone_version); - } - } - else if (SvTYPE(ST(1)) == SVt_IV) - { - uint32 zone_id = (uint32)SvUV(ST(1)); - int zone_version = (items >= 3) ? static_cast(SvIV(ST(2))) : -1; - if (items == 3) - { - THIS->MovePCDynamicZone(zone_id, zone_version, (bool)SvTRUE(ST(2))); - } - else - { - THIS->MovePCDynamicZone(zone_id, zone_version); - } - } - else - { - Perl_croak(aTHX_ "Client::MovePCDynamicZone expected an integer or string"); - } - - XSRETURN_EMPTY; -} - -XS(XS_Client_Fling); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_Fling) { - dXSARGS; - if (items < 5 || items > 7) - Perl_croak(aTHX_ "Usage: Client::Fling(THIS, value, target_x, target_y, target_z, ignore_los, clipping)"); - { - Client* THIS; - float value = (float) SvNV(ST(1)); - float target_x = (float) SvNV(ST(2)); - float target_y = (float) SvNV(ST(3)); - float target_z = (float) SvNV(ST(4)); - bool ignore_los = false; - bool clipping = false; - VALIDATE_THIS_IS_CLIENT; - if (items > 5) - ignore_los = (bool) SvTRUE(ST(5)); - - if (items > 6) - clipping = (bool) SvTRUE(ST(6)); - - THIS->Fling(value, target_x, target_y, target_z, ignore_los, clipping); - } - XSRETURN_EMPTY; -} - -XS(XS_Client_HasDisciplineLearned); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Client_HasDisciplineLearned) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::HasDisciplineLearned(THIS, uint16 spell_id)"); - { - Client *THIS; - bool has_learned; - uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CLIENT; - has_learned = THIS->HasDisciplineLearned(spell_id); - ST(0) = boolSV(has_learned); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Client_GetClassBitmask); -XS(XS_Client_GetClassBitmask) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetClassBitmask(THIS)"); - { - Client* THIS; - int client_bitmask = 0; - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - client_bitmask = GetPlayerClassBit(THIS->GetClass()); - XSprePUSH; - PUSHu((UV) client_bitmask); - } - XSRETURN(1); -} - -XS(XS_Client_GetRaceBitmask); -XS(XS_Client_GetRaceBitmask) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetRaceBitmask(THIS)"); // @categories Stats and Attributes - { - Client* THIS; - int client_bitmask = 0; - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - client_bitmask = GetPlayerRaceBit(THIS->GetBaseRace()); - XSprePUSH; - PUSHu((UV) client_bitmask); - } - XSRETURN(1); -} - -XS(XS_Client_GetLearnableDisciplines); -XS(XS_Client_GetLearnableDisciplines) { - dXSARGS; - if (items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: Client::GetLearnableDisciplines(THIS, [uint8 min_level, uint8 max_level])"); - - uint8 min_level = 1; - uint8 max_level = 0; - if (items > 1) - min_level = (uint8)SvUV(ST(1)); - if (items > 2) - max_level = (uint8)SvUV(ST(2)); - - Client* THIS; - VALIDATE_THIS_IS_CLIENT; - auto learnable_disciplines = THIS->GetLearnableDisciplines(min_level, max_level); - auto learnable_size = learnable_disciplines.size(); - if (learnable_size > 0) { - EXTEND(sp, learnable_size); - for (int index = 0; index < learnable_size; ++index) { - ST(index) = sv_2mortal(newSVuv(learnable_disciplines[index])); - } - XSRETURN(learnable_size); - } - SV* return_value = &PL_sv_undef; - ST(0) = return_value; - XSRETURN(1); -} - -XS(XS_Client_GetLearnedDisciplines); -XS(XS_Client_GetLearnedDisciplines) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetLearnedDisciplines(THIS)"); - - Client* THIS; - VALIDATE_THIS_IS_CLIENT; - auto learned_disciplines = THIS->GetLearnedDisciplines(); - auto learned_size = learned_disciplines.size(); - if (learned_size > 0) { - EXTEND(sp, learned_size); - for (int index = 0; index < learned_size; ++index) { - ST(index) = sv_2mortal(newSVuv(learned_disciplines[index])); - } - XSRETURN(learned_size); - } - SV* return_value = &PL_sv_undef; - ST(0) = return_value; - XSRETURN(1); -} - -XS(XS_Client_GetMemmedSpells); -XS(XS_Client_GetMemmedSpells) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetMemmedSpells(THIS)"); - - Client* THIS; - VALIDATE_THIS_IS_CLIENT; - auto memmed_spells = THIS->GetMemmedSpells(); - auto memmed_size = memmed_spells.size(); - if (memmed_size > 0) { - EXTEND(sp, memmed_size); - for (int index = 0; index < memmed_size; ++index) { - ST(index) = sv_2mortal(newSVuv(memmed_spells[index])); - } - XSRETURN(memmed_size); - } - SV* return_value = &PL_sv_undef; - ST(0) = return_value; - XSRETURN(1); -} - -XS(XS_Client_GetScribeableSpells); -XS(XS_Client_GetScribeableSpells) { - dXSARGS; - if (items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: Client::GetScribeableSpells(THIS, [uint8 min_level, uint8 max_level])"); - - uint8 min_level = 1; - uint8 max_level = 0; - if (items > 1) - min_level = (uint8)SvUV(ST(1)); - if (items > 2) - max_level = (uint8)SvUV(ST(2)); - - Client* THIS; - VALIDATE_THIS_IS_CLIENT; - auto scribeable_spells = THIS->GetScribeableSpells(min_level, max_level); - auto scribeable_size = scribeable_spells.size(); - if (scribeable_size > 0) { - EXTEND(sp, scribeable_size); - for (int index = 0; index < scribeable_size; ++index) { - ST(index) = sv_2mortal(newSVuv(scribeable_spells[index])); - } - XSRETURN(scribeable_size); - } - SV* return_value = &PL_sv_undef; - ST(0) = return_value; - XSRETURN(1); -} - -XS(XS_Client_GetScribedSpells); -XS(XS_Client_GetScribedSpells) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetScribedSpells(THIS)"); - - Client* THIS; - VALIDATE_THIS_IS_CLIENT; - auto scribed_spells = THIS->GetScribedSpells(); - auto scribed_size = scribed_spells.size(); - if (scribed_size > 0) { - EXTEND(sp, scribed_size); - for (int index = 0; index < scribed_size; ++index) { - ST(index) = sv_2mortal(newSVuv(scribed_spells[index])); - } - XSRETURN(scribed_size); - } - SV* return_value = &PL_sv_undef; - ST(0) = return_value; - XSRETURN(1); -} - -XS(XS_Client_GetInventory); -XS(XS_Client_GetInventory) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Client::GetInventory(THIS)"); - { - Client* THIS; - EQ::InventoryProfile* RETVAL; - VALIDATE_THIS_IS_CLIENT; - RETVAL = &THIS->GetInv(); - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "Inventory", (void *) RETVAL); - } - XSRETURN(1); -} - -XS(XS_Client_GetAAEXPModifier); -XS(XS_Client_GetAAEXPModifier) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetAAEXPModifier(THIS, uint32 zone_id)"); - { - Client* THIS; - double aa_modifier = 1.0f; - uint32 zone_id = (uint32)SvUV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - aa_modifier = THIS->GetAAEXPModifier(zone_id); - XSprePUSH; - PUSHn((double) aa_modifier); - } - XSRETURN(1); -} - -XS(XS_Client_GetEXPModifier); -XS(XS_Client_GetEXPModifier) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Client::GetEXPModifier(THIS, uint32 zone_id)"); - { - Client* THIS; - double exp_modifier = 1.0f; - uint32 zone_id = (uint32)SvUV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_CLIENT; - exp_modifier = THIS->GetEXPModifier(zone_id); - XSprePUSH; - PUSHn((double) exp_modifier); - } - XSRETURN(1); -} - -XS(XS_Client_SetAAEXPModifier); -XS(XS_Client_SetAAEXPModifier) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetAAEXPModifier(THIS, uint32 zone_id, float aa_modifier)"); - { - Client* THIS; - uint32 zone_id = (uint32)SvUV(ST(1)); - double aa_modifier = (double) SvNV(ST(2)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetAAEXPModifier(zone_id, aa_modifier); - } - XSRETURN_EMPTY; -} - -XS(XS_Client_SetEXPModifier); -XS(XS_Client_SetEXPModifier) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Client::SetEXPModifier(THIS, uint32 zone_id, float exp_modifier)"); - { - Client* THIS; - uint32 zone_id = (uint32)SvUV(ST(1)); - double exp_modifier = (double) SvNV(ST(2)); - VALIDATE_THIS_IS_CLIENT; - THIS->SetEXPModifier(zone_id, exp_modifier); - } - XSRETURN_EMPTY; -} #ifdef __cplusplus extern "C" @@ -5316,8 +6715,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "AddAlternateCurrencyValue"), XS_Client_AddAlternateCurrencyValue, file, "$$$"); newXSproto(strcpy(buf, "AddCrystals"), XS_Client_AddCrystals, file, "$$"); newXSproto(strcpy(buf, "AddEXP"), XS_Client_AddEXP, file, "$$;$$"); - newXSproto(strcpy(buf, "AddExpeditionLockout"), XS_Client_AddExpeditionLockout, file, "$$$$;$"); - newXSproto(strcpy(buf, "AddExpeditionLockoutDuration"), XS_Client_AddExpeditionLockoutDuration, file, "$$$$;$"); newXSproto(strcpy(buf, "AddLevelBasedExp"), XS_Client_AddLevelBasedExp, file, "$$;$$"); newXSproto(strcpy(buf, "AddMoneyToPP"), XS_Client_AddMoneyToPP, file, "$$$$$$"); newXSproto(strcpy(buf, "AddPVPPoints"), XS_Client_AddPVPPoints, file, "$$"); @@ -5336,7 +6733,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "CheckSpecializeIncrease"), XS_Client_CheckSpecializeIncrease, file, "$$"); newXSproto(strcpy(buf, "ClearCompassMark"), XS_Client_ClearCompassMark, file, "$"); newXSproto(strcpy(buf, "ClearZoneFlag"), XS_Client_ClearZoneFlag, file, "$$"); - newXSproto(strcpy(buf, "CreateExpedition"), XS_Client_CreateExpedition, file, "$$$$$$$;$"); newXSproto(strcpy(buf, "Connected"), XS_Client_Connected, file, "$"); newXSproto(strcpy(buf, "DecreaseByID"), XS_Client_DecreaseByID, file, "$$$"); newXSproto(strcpy(buf, "DeleteItemInInventory"), XS_Client_DeleteItemInInventory, file, "$$;$$"); @@ -5347,17 +6743,14 @@ XS(boot_Client) { newXSproto(strcpy(buf, "Escape"), XS_Client_Escape, file, "$"); newXSproto(strcpy(buf, "ExpeditionMessage"), XS_Client_ExpeditionMessage, file, "$$$"); newXSproto(strcpy(buf, "FailTask"), XS_Client_FailTask, file, "$$"); - newXSproto(strcpy(buf, "Fling"), XS_Client_Fling, file, "$$$$$;$$"); newXSproto(strcpy(buf, "ForageItem"), XS_Client_ForageItem, file, "$"); newXSproto(strcpy(buf, "Freeze"), XS_Client_Freeze, file, "$"); newXSproto(strcpy(buf, "GetAAExp"), XS_Client_GetAAExp, file, "$"); - newXSproto(strcpy(buf, "GetAAEXPModifier"), XS_Client_GetAAEXPModifier, file, "$$"); newXSproto(strcpy(buf, "GetAALevel"), XS_Client_GetAALevel, file, "$$"); newXSproto(strcpy(buf, "GetAAPercent"), XS_Client_GetAAPercent, file, "$"); newXSproto(strcpy(buf, "GetAAPoints"), XS_Client_GetAAPoints, file, "$$"); newXSproto(strcpy(buf, "GetAccountAge"), XS_Client_GetAccountAge, file, "$"); newXSproto(strcpy(buf, "GetAccountFlag"), XS_Client_GetAccountFlag, file, "$$"); - newXSproto(strcpy(buf, "GetAFK"), XS_Client_GetAFK, file, "$"); newXSproto(strcpy(buf, "GetAggroCount"), XS_Client_GetAggroCount, file, "$"); newXSproto(strcpy(buf, "GetAllMoney"), XS_Client_GetAllMoney, file, "$"); newXSproto(strcpy(buf, "GetAlternateCurrencyValue"), XS_Client_GetAlternateCurrencyValue, file, "$$"); @@ -5380,7 +6773,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "GetBindZoneID"), XS_Client_GetBindZoneID, file, "$$"); newXSproto(strcpy(buf, "GetCarriedMoney"), XS_Client_GetCarriedMoney, file, "$"); newXSproto(strcpy(buf, "GetCharacterFactionLevel"), XS_Client_GetCharacterFactionLevel, file, "$$"); - newXSproto(strcpy(buf, "GetClassBitmask"), XS_Client_GetClassBitmask, file, "$"); newXSproto(strcpy(buf, "GetClientMaxLevel"), XS_Client_GetClientMaxLevel, file, "$"); newXSproto(strcpy(buf, "GetClientVersion"), XS_Client_GetClientVersion, file, "$"); newXSproto(strcpy(buf, "GetClientVersionBit"), XS_Client_GetClientVersionBit, file, "$"); @@ -5395,9 +6787,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "GetEndurance"), XS_Client_GetEndurance, file, "$"); newXSproto(strcpy(buf, "GetEnduranceRatio"), XS_Client_GetEnduranceRatio, file, "$"); newXSproto(strcpy(buf, "GetEXP"), XS_Client_GetEXP, file, "$"); - newXSproto(strcpy(buf, "GetEXPModifier"), XS_Client_GetEXPModifier, file, "$$"); - newXSproto(strcpy(buf, "GetExpedition"), XS_Client_GetExpedition, file, "$"); - newXSproto(strcpy(buf, "GetExpeditionLockouts"), XS_Client_GetExpeditionLockouts, file, "$;$"); newXSproto(strcpy(buf, "GetFace"), XS_Client_GetFace, file, "$"); newXSproto(strcpy(buf, "GetFactionLevel"), XS_Client_GetFactionLevel, file, "$$$$$$$$"); newXSproto(strcpy(buf, "GetFeigned"), XS_Client_GetFeigned, file, "$"); @@ -5409,42 +6798,34 @@ XS(boot_Client) { newXSproto(strcpy(buf, "GetHunger"), XS_Client_GetHunger, file, "$$"); newXSproto(strcpy(buf, "GetInstanceID"), XS_Client_GetInstanceID, file, "$$"); newXSproto(strcpy(buf, "GetInstrumentMod"), XS_Client_GetInstrumentMod, file, "$$"); - newXSproto(strcpy(buf, "GetInventory"), XS_Client_GetInventory, file, "$"); newXSproto(strcpy(buf, "GetIP"), XS_Client_GetIP, file, "$"); newXSproto(strcpy(buf, "GetItemAt"), XS_Client_GetItemAt, file, "$$"); newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$"); newXSproto(strcpy(buf, "GetItemInInventory"), XS_Client_GetItemInInventory, file, "$$"); newXSproto(strcpy(buf, "GetLanguageSkill"), XS_Client_GetLanguageSkill, file, "$$"); + newXSproto(strcpy(buf, "GetLastName"), XS_Client_GetLastName, file, "$"); newXSproto(strcpy(buf, "GetLDoNLosses"), XS_Client_GetLDoNLosses, file, "$"); newXSproto(strcpy(buf, "GetLDoNLossesTheme"), XS_Client_GetLDoNLossesTheme, file, "$$"); newXSproto(strcpy(buf, "GetLDoNPointsTheme"), XS_Client_GetLDoNPointsTheme, file, "$"); newXSproto(strcpy(buf, "GetLDoNWins"), XS_Client_GetLDoNWins, file, "$"); newXSproto(strcpy(buf, "GetLDoNWinsTheme"), XS_Client_GetLDoNWinsTheme, file, "$$"); - newXSproto(strcpy(buf, "GetLearnableDisciplines"), XS_Client_GetLearnableDisciplines, file, "$;$$"); - newXSproto(strcpy(buf, "GetLearnedDisciplines"), XS_Client_GetLearnedDisciplines, file, "$"); - newXSproto(strcpy(buf, "GetLockoutExpeditionUUID"), XS_Client_GetLockoutExpeditionUUID, file, "$$$"); newXSproto(strcpy(buf, "GetMaxEndurance"), XS_Client_GetMaxEndurance, file, "$"); - newXSproto(strcpy(buf, "GetMemmedSpells"), XS_Client_GetMemmedSpells, file, "$"); newXSproto(strcpy(buf, "GetModCharacterFactionLevel"), XS_Client_GetModCharacterFactionLevel, file, "$$"); newXSproto(strcpy(buf, "GetMoney"), XS_Client_GetMoney, file, "$$$"); newXSproto(strcpy(buf, "GetPVP"), XS_Client_GetPVP, file, "$"); newXSproto(strcpy(buf, "GetPVPPoints"), XS_Client_GetPVPPoints, file, "$"); - newXSproto(strcpy(buf, "GetRaceBitmask"), XS_Client_GetRaceBitmask, file, "$"); newXSproto(strcpy(buf, "GetRadiantCrystals"), XS_Client_GetRadiantCrystals, file, "$"); newXSproto(strcpy(buf, "GetRaid"), XS_Client_GetRaid, file, "$"); newXSproto(strcpy(buf, "GetRaidPoints"), XS_Client_GetRaidPoints, file, "$"); newXSproto(strcpy(buf, "GetRawItemAC"), XS_Client_GetRawItemAC, file, "$"); newXSproto(strcpy(buf, "GetRawSkill"), XS_Client_GetRawSkill, file, "$$"); - newXSproto(strcpy(buf, "GetScribeableSpells"), XS_Client_GetScribeableSpells, file, "$;$$"); - newXSproto(strcpy(buf, "GetScribedSpells"), XS_Client_GetScribedSpells, file, "$"); newXSproto(strcpy(buf, "GetSkillPoints"), XS_Client_GetSkillPoints, file, "$"); newXSproto(strcpy(buf, "GetSpellBookSlotBySpellID"), XS_Client_GetSpellBookSlotBySpellID, file, "$$"); - newXSproto(strcpy(buf, "GetSpellIDByBookSlot"), XS_Client_GetSpellIDByBookSlot, file, "$$"); newXSproto(strcpy(buf, "GetSpentAA"), XS_Client_GetSpentAA, file, "$$"); newXSproto(strcpy(buf, "GetStartZone"), XS_Client_GetStartZone, file, "$"); - newXSproto(strcpy(buf, "GetTargetRingX"), XS_Client_GetTargetRingX, file, "$"); - newXSproto(strcpy(buf, "GetTargetRingY"), XS_Client_GetTargetRingY, file, "$"); - newXSproto(strcpy(buf, "GetTargetRingZ"), XS_Client_GetTargetRingZ, file, "$"); + newXSproto(strcpy(buf, "GetTargetRingX"), XS_Client_GetTargetRingX, file, "$$"); + newXSproto(strcpy(buf, "GetTargetRingY"), XS_Client_GetTargetRingY, file, "$$"); + newXSproto(strcpy(buf, "GetTargetRingZ"), XS_Client_GetTargetRingZ, file, "$$"); newXSproto(strcpy(buf, "GetTaskActivityDoneCount"), XS_Client_GetTaskActivityDoneCount, file, "$$$"); newXSproto(strcpy(buf, "GetThirst"), XS_Client_GetThirst, file, "$$"); newXSproto(strcpy(buf, "GetTotalSecondsPlayed"), XS_Client_GetTotalSecondsPlayed, file, "$"); @@ -5454,8 +6835,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "GrantAlternateAdvancementAbility"), XS_Client_GrantAlternateAdvancementAbility, file, "$$$;$"); newXSproto(strcpy(buf, "GuildID"), XS_Client_GuildID, file, "$"); newXSproto(strcpy(buf, "GuildRank"), XS_Client_GuildRank, file, "$"); - newXSproto(strcpy(buf, "HasDisciplineLearned"), XS_Client_HasDisciplineLearned, file, "$$"); - newXSproto(strcpy(buf, "HasExpeditionLockout"), XS_Client_HasExpeditionLockout, file, "$$$"); newXSproto(strcpy(buf, "HasSkill"), XS_Client_HasSkill, file, "$$"); newXSproto(strcpy(buf, "HasSpellScribed"), XS_Client_HasSkill, file, "$$"); newXSproto(strcpy(buf, "HasZoneFlag"), XS_Client_HasZoneFlag, file, "$$"); @@ -5487,7 +6866,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "MaxSkill"), XS_Client_MaxSkill, file, "$$;$$"); newXSproto(strcpy(buf, "MemSpell"), XS_Client_MemSpell, file, "$$$;$"); newXSproto(strcpy(buf, "MovePC"), XS_Client_MovePC, file, "$$$$$$"); - newXSproto(strcpy(buf, "MovePCDynamicZone"), XS_Client_MovePCDynamicZone, file, "$$;$$"); newXSproto(strcpy(buf, "MovePCInstance"), XS_Client_MovePCInstance, file, "$$$$$$$"); newXSproto(strcpy(buf, "MoveZone"), XS_Client_MoveZone, file, "$$"); newXSproto(strcpy(buf, "MoveZoneGroup"), XS_Client_MoveZoneGroup, file, "$$"); @@ -5504,8 +6882,6 @@ XS(boot_Client) { newXSproto(strcpy(buf, "QuestReward"), XS_Client_QuestReward, file, "$$;$$$$$$$"); newXSproto(strcpy(buf, "ReadBook"), XS_Client_ReadBook, file, "$$$"); newXSproto(strcpy(buf, "RefundAA"), XS_Client_RefundAA, file, "$$"); - newXSproto(strcpy(buf, "RemoveAllExpeditionLockouts"), XS_Client_RemoveAllExpeditionLockouts, file, "$;$"); - newXSproto(strcpy(buf, "RemoveExpeditionLockout"), XS_Client_RemoveExpeditionLockout, file, "$$$"); newXSproto(strcpy(buf, "RemoveNoRent"), XS_Client_RemoveNoRent, file, "$"); newXSproto(strcpy(buf, "ResetAA"), XS_Client_ResetAA, file, "$"); newXSproto(strcpy(buf, "ResetDisciplineTimer"), XS_Client_ResetDisciplineTimer, file, "$$"); @@ -5522,29 +6898,24 @@ XS(boot_Client) { newXSproto(strcpy(buf, "SendToGuildHall"), XS_Client_SendToGuildHall, file, "$"); newXSproto(strcpy(buf, "SendWebLink"), XS_Client_SendWebLink, file, "$:$"); newXSproto(strcpy(buf, "SendZoneFlagInfo"), XS_Client_SendZoneFlagInfo, file, "$$"); - newXSproto(strcpy(buf, "SetAAEXPModifier"), XS_Client_SetAAEXPModifier, file, "$$$"); newXSproto(strcpy(buf, "SetAAPoints"), XS_Client_SetAAPoints, file, "$$"); newXSproto(strcpy(buf, "SetAATitle"), XS_Client_SetAATitle, file, "$$;$"); newXSproto(strcpy(buf, "SetAccountFlag"), XS_Client_SetAccountFlag, file, "$$"); - newXSproto(strcpy(buf, "SetAFK"), XS_Client_SetAFK, file, "$$"); - newXSproto(strcpy(buf, "SetAnon"), XS_Client_SetAnon, file, "$$"); newXSproto(strcpy(buf, "SetAlternateCurrencyValue"), XS_Client_SetAlternateCurrencyValue, file, "$$$"); newXSproto(strcpy(buf, "SetBaseClass"), XS_Client_SetBaseClass, file, "$$"); newXSproto(strcpy(buf, "SetBaseGender"), XS_Client_SetBaseGender, file, "$$"); newXSproto(strcpy(buf, "SetBaseRace"), XS_Client_SetBaseRace, file, "$$"); newXSproto(strcpy(buf, "SetBecomeNPC"), XS_Client_SetBecomeNPC, file, "$$"); newXSproto(strcpy(buf, "SetBecomeNPCLevel"), XS_Client_SetBecomeNPCLevel, file, "$$"); - newXSproto(strcpy(buf, "SetBindPoint"), XS_Client_SetBindPoint, file, "$;$$$$$$"); + newXSproto(strcpy(buf, "SetBindPoint"), XS_Client_SetBindPoint, file, "$;$$$$$"); newXSproto(strcpy(buf, "SetConsumption"), XS_Client_SetConsumption, file, "$$$"); newXSproto(strcpy(buf, "SetClientMaxLevel"), XS_Client_SetClientMaxLevel, file, "$$"); newXSproto(strcpy(buf, "SetCustomItemData"), XS_Client_SetCustomItemData, file, "$$$$"); newXSproto(strcpy(buf, "SetDeity"), XS_Client_SetDeity, file, "$$"); newXSproto(strcpy(buf, "SetDueling"), XS_Client_SetDueling, file, "$$"); newXSproto(strcpy(buf, "SetDuelTarget"), XS_Client_SetDuelTarget, file, "$$"); - newXSproto(strcpy(buf, "SetEbonCrystals"), XS_Client_SetEbonCrystals, file, "$$"); newXSproto(strcpy(buf, "SetEndurance"), XS_Client_SetEndurance, file, "$$"); newXSproto(strcpy(buf, "SetEXP"), XS_Client_SetEXP, file, "$$$;$"); - newXSproto(strcpy(buf, "SetEXPModifier"), XS_Client_SetEXPModifier, file, "$$$"); newXSproto(strcpy(buf, "SetFactionLevel"), XS_Client_SetFactionLevel, file, "$$$$$$"); newXSproto(strcpy(buf, "SetFactionLevel2"), XS_Client_SetFactionLevel2, file, "$$$$$$$"); newXSproto(strcpy(buf, "SetFeigned"), XS_Client_SetFeigned, file, "$$"); @@ -5555,11 +6926,10 @@ XS(boot_Client) { newXSproto(strcpy(buf, "SetMaterial"), XS_Client_SetMaterial, file, "$$$"); newXSproto(strcpy(buf, "SetPrimaryWeaponOrnamentation"), XS_Client_SetPrimaryWeaponOrnamentation, file, "$$"); newXSproto(strcpy(buf, "SetPVP"), XS_Client_SetPVP, file, "$$"); - newXSproto(strcpy(buf, "SetRadiantCrystals"), XS_Client_SetRadiantCrystals, file, "$$"); newXSproto(strcpy(buf, "SetSecondaryWeaponOrnamentation"), XS_Client_SetSecondaryWeaponOrnamentation, file, "$$"); newXSproto(strcpy(buf, "SetSkill"), XS_Client_SetSkill, file, "$$$"); newXSproto(strcpy(buf, "SetSkillPoints"), XS_Client_SetSkillPoints, file, "$$"); - newXSproto(strcpy(buf, "SetStartZone"), XS_Client_SetStartZone, file, "$$;$$$$"); + newXSproto(strcpy(buf, "SetStartZone"), XS_Client_SetStartZone, file, "$$"); newXSproto(strcpy(buf, "SetStats"), XS_Client_SetStats, file, "$$$"); newXSproto(strcpy(buf, "SetThirst"), XS_Client_SetThirst, file, "$$"); newXSproto(strcpy(buf, "SetTint"), XS_Client_SetTint, file, "$$$"); diff --git a/zone/perl_doors.cpp b/zone/perl_doors.cpp index b922b5091..8c4f4ea98 100644 --- a/zone/perl_doors.cpp +++ b/zone/perl_doors.cpp @@ -42,29 +42,24 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_DOOR \ - do { \ - if (sv_derived_from(ST(0), "Doors")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Doors*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Doors"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_Doors_GetDoorDBID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetDoorDBID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetDoorDBID(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetDoorDBID(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorDBID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -76,12 +71,20 @@ XS(XS_Doors_GetDoorID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetDoorID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetDoorID(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetDoorID(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -93,12 +96,20 @@ XS(XS_Doors_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetID(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetID(THIS)"); { Doors *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEntityID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -110,12 +121,20 @@ XS(XS_Doors_GetX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetX(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetX(THIS)"); { Doors *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPosition().x; XSprePUSH; PUSHn((double) RETVAL); @@ -127,12 +146,20 @@ XS(XS_Doors_GetY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetY(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetY(THIS)"); { Doors *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPosition().y; XSprePUSH; PUSHn((double) RETVAL); @@ -144,12 +171,20 @@ XS(XS_Doors_GetZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetZ(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetZ(THIS)"); { Doors *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPosition().z; XSprePUSH; PUSHn((double) RETVAL); @@ -161,12 +196,20 @@ XS(XS_Doors_GetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetHeading) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetHeading(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetHeading(THIS)"); { Doors *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPosition().w; XSprePUSH; PUSHn((double) RETVAL); @@ -178,12 +221,20 @@ XS(XS_Doors_GetOpenType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetOpenType) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetOpenType(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetOpenType(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetOpenType(); XSprePUSH; PUSHu((UV) RETVAL); @@ -195,12 +246,20 @@ XS(XS_Doors_GetLockpick); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetLockpick) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetLockpick(THIS)"); // @categories Doors, Skills and Recipes + Perl_croak(aTHX_ "Usage: Doors::GetLockpick(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLockpick(); XSprePUSH; PUSHu((UV) RETVAL); @@ -212,12 +271,20 @@ XS(XS_Doors_GetKeyItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetKeyItem) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetKeyItem(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetKeyItem(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetKeyItem(); XSprePUSH; PUSHu((UV) RETVAL); @@ -229,11 +296,19 @@ XS(XS_Doors_GetNoKeyring); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetNoKeyring) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::GetNoKeyring(THIS, uint8 type)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetNoKeyring(THIS, uint8 type)"); { Doors *THIS; uint8 type = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->GetNoKeyring(); } XSRETURN_EMPTY; @@ -243,12 +318,20 @@ XS(XS_Doors_GetIncline); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetIncline) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetIncline(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetIncline(THIS)"); { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetIncline(); XSprePUSH; PUSHu((UV) RETVAL); @@ -265,7 +348,15 @@ XS(XS_Doors_GetSize) { Doors *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSize(); XSprePUSH; PUSHu((UV) RETVAL); @@ -278,11 +369,19 @@ XS(XS_Doors_SetOpenType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetOpenType) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetOpenType(THIS, uint32 open_type)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetOpenType(THIS, uint32 open_type)"); { Doors *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetOpenType(type); } XSRETURN_EMPTY; @@ -292,11 +391,19 @@ XS(XS_Doors_SetLockpick); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetLockpick) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetLockpick(THIS, uint32 lockpick_type)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetLockpick(THIS, uint32 lockpick_type)"); { Doors *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetLockpick(type); } XSRETURN_EMPTY; @@ -306,11 +413,19 @@ XS(XS_Doors_SetKeyItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetKeyItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetKeyItem(THIS, uint32 key_item_id)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetKeyItem(THIS, uint32 key_item_id)"); { Doors *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetKeyItem(type); } XSRETURN_EMPTY; @@ -320,11 +435,19 @@ XS(XS_Doors_SetNoKeyring); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetNoKeyring) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetNoKeyring(THIS, uint8 no_key_ring)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetNoKeyring(THIS, uint8 no_key_ring)"); { Doors *THIS; uint8 type = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetNoKeyring(type); } XSRETURN_EMPTY; @@ -334,11 +457,19 @@ XS(XS_Doors_SetIncline); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetIncline) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetIncline(THIS, uint32 incline)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetIncline(THIS, uint32 incline)"); { Doors *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetIncline(type); } XSRETURN_EMPTY; @@ -348,11 +479,19 @@ XS(XS_Doors_SetSize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetSize) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetSize(THIS, uint32 size)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetSize(THIS, uint32 size)"); { Doors *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSize(type); } XSRETURN_EMPTY; @@ -362,13 +501,21 @@ XS(XS_Doors_SetLocation); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetLocation) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Doors::SetLocation(THIS, float x, float y, float z)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetLocation(THIS, float x, float y, float z)"); { Doors *THIS; float x = (float) SvNV(ST(1)); float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetLocation(x, y, z); } XSRETURN_EMPTY; @@ -378,11 +525,18 @@ XS(XS_Doors_SetX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetX) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetX(THIS, float x)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetX(THIS, float x)"); { Doors *THIS; float x = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); auto position = THIS->GetPosition(); position.x = x; THIS->SetPosition(position); @@ -394,11 +548,19 @@ XS(XS_Doors_SetY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetY) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetY(THIS, float y)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetY(THIS, float y)"); { Doors *THIS; float y = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + auto position = THIS->GetPosition(); position.y = y; THIS->SetPosition(position); @@ -410,11 +572,19 @@ XS(XS_Doors_SetZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetZ) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetZ(THIS, float z)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetZ(THIS, float z)"); { Doors *THIS; float z = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + auto position = THIS->GetPosition(); position.z = z; THIS->SetPosition(position); @@ -426,11 +596,19 @@ XS(XS_Doors_SetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetHeading) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Doors::SetHeading(THIS, float heading)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetHeading(THIS, float heading)"); { Doors *THIS; float heading = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + auto position = THIS->GetPosition(); position.w = heading; THIS->SetPosition(position); @@ -442,11 +620,19 @@ XS(XS_Doors_SetModelName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_SetModelName) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Doors::SetModelName(THIS, string name)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::SetModelName(THIS, string name)"); { Doors *THIS; char *name = nullptr; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { name = (char *) SvPV_nolen(ST(1)); } THIS->SetDoorName(name); @@ -457,12 +643,20 @@ XS(XS_Doors_GetModelName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_GetModelName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::GetModelName(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::GetModelName(THIS)"); { Doors *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -475,10 +669,18 @@ XS(XS_Doors_CreateDatabaseEntry); /* prototype to pass -Wmissing-prototypes */ XS(XS_Doors_CreateDatabaseEntry) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Doors::InsertDoor(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: Doors::InsertDoor(THIS)"); { Doors *THIS; - VALIDATE_THIS_IS_DOOR; + + if (sv_derived_from(ST(0), "Doors")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Doors *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Doors"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->CreateDatabaseEntry(); } XSRETURN_EMPTY; diff --git a/zone/perl_entity.cpp b/zone/perl_entity.cpp index c2b3d6a32..3280d0a56 100644 --- a/zone/perl_entity.cpp +++ b/zone/perl_entity.cpp @@ -43,29 +43,25 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_ENTITY \ - do { \ - if (sv_derived_from(ST(0), "EntityList")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(EntityList*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type EntityList"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_EntityList_GetMobID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetMobID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetMobID(THIS, id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetMobID(THIS, id)"); { EntityList *THIS; Mob *RETVAL; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMobID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -82,7 +78,15 @@ XS(XS_EntityList_GetMob) { EntityList *THIS; Mob *RETVAL; char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMob(name); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -94,12 +98,20 @@ XS(XS_EntityList_GetMobByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetMobByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetMobByID(THIS, id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetMobByID(THIS, id)"); { EntityList *THIS; Mob *RETVAL; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMob(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -111,12 +123,20 @@ XS(XS_EntityList_GetMobByNpcTypeID); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_GetMobByNpcTypeID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetMobByNpcTypeID(THIS, get_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetMobByNpcTypeID(THIS, get_id)"); { EntityList *THIS; Mob *RETVAL; uint32 get_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMobByNpcTypeID(get_id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -128,12 +148,20 @@ XS(XS_EntityList_IsMobSpawnedByNpcTypeID); /* prototype pass -Wmissing-prototype XS(XS_EntityList_IsMobSpawnedByNpcTypeID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::ValidMobByNpcTypeID(THIS, get_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::ValidMobByNpcTypeID(THIS, get_id)"); { EntityList *THIS; bool RETVAL; uint32 get_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMobSpawnedByNpcTypeID(get_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -145,12 +173,20 @@ XS(XS_EntityList_GetNPCByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetNPCByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetNPCByID(THIS, id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetNPCByID(THIS, id)"); { EntityList *THIS; NPC *RETVAL; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNPCByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "NPC", (void *) RETVAL); @@ -162,12 +198,20 @@ XS(XS_EntityList_GetNPCByNPCTypeID); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_GetNPCByNPCTypeID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetNPCByNPCTypeID(THIS, npc_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetNPCByNPCTypeID(THIS, npc_id)"); { EntityList *THIS; NPC *RETVAL; uint32 npc_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNPCByNPCTypeID(npc_id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "NPC", (void *) RETVAL); @@ -179,12 +223,23 @@ XS(XS_EntityList_GetNPCBySpawnID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetNPCBySpawnID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetNPCBySpawnID(THIS, spawn_id)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: EntityList::GetNPCBySpawnID(THIS, spawn_id)"); { EntityList *THIS; NPC *RETVAL; uint32 spawn_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else { + Perl_croak(aTHX_ "THIS is not of type EntityList"); + } + + if (THIS == nullptr) { + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + } + RETVAL = THIS->GetNPCBySpawnID(spawn_id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "NPC", (void *) RETVAL); @@ -196,12 +251,20 @@ XS(XS_EntityList_GetClientByName); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetClientByName) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetClientByName(THIS, name)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientByName(THIS, name)"); { EntityList *THIS; Client *RETVAL; char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByName(name); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -213,12 +276,20 @@ XS(XS_EntityList_GetClientByAccID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetClientByAccID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetClientByAccID(THIS, uint32 account_id)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientByAccID(THIS, uint32 account_id)"); { EntityList *THIS; Client *RETVAL; uint32 accid = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByAccID(accid); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -230,12 +301,20 @@ XS(XS_EntityList_GetClientByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetClientByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetClientByID(THIS, uint16 client_id)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientByID(THIS, uint16 client_id)"); { EntityList *THIS; Client *RETVAL; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -247,12 +326,20 @@ XS(XS_EntityList_GetClientByCharID); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_GetClientByCharID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetClientByCharID(THIS, uint32 character_id)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientByCharID(THIS, uint32 character_id)"); { EntityList *THIS; Client *RETVAL; uint32 iCharID = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByCharID(iCharID); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -264,12 +351,20 @@ XS(XS_EntityList_GetClientByWID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetClientByWID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetClientByWID(THIS, uint32 wid)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientByWID(THIS, uint32 wid)"); { EntityList *THIS; Client *RETVAL; uint32 iWID = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByWID(iWID); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -281,12 +376,20 @@ XS(XS_EntityList_GetObjectByDBID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetObjectByDBID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetObjectByDBID(THIS, uint32 database_id)"); // @categories Script Utility, Objects + Perl_croak(aTHX_ "Usage: EntityList::GetObjectByDBID(THIS, uint32 database_id)"); { EntityList *THIS; Object *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetObjectByDBID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Object", (void *) RETVAL); @@ -298,12 +401,20 @@ XS(XS_EntityList_GetObjectByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetObjectByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetObjectByID(THIS, uint32 entity_id)"); // @categories Script Utility, Objects + Perl_croak(aTHX_ "Usage: EntityList::GetObjectByID(THIS, uint32 entity_id)"); { EntityList *THIS; Object *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetObjectByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Object", (void *) RETVAL); @@ -315,12 +426,20 @@ XS(XS_EntityList_GetDoorsByDBID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetDoorsByDBID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByDBID(THIS, uint32 database_id)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByDBID(THIS, uint32 database_id)"); { EntityList *THIS; Doors *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorsByDBID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Doors", (void *) RETVAL); @@ -332,12 +451,20 @@ XS(XS_EntityList_GetDoorsByDoorID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetDoorsByDoorID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByDoorID(THIS, uint32 door_id)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByDoorID(THIS, uint32 door_id)"); { EntityList *THIS; Doors *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorsByDoorID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Doors", (void *) RETVAL); @@ -349,12 +476,20 @@ XS(XS_EntityList_GetDoorsByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetDoorsByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByID(THIS, uint32 entity_id)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::GetDoorsByID(THIS, uint32 entity_id)"); { EntityList *THIS; Doors *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDoorsByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Doors", (void *) RETVAL); @@ -366,12 +501,20 @@ XS(XS_EntityList_FindDoor); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_FindDoor) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::FindDoor(THIS, uint32 door_id)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::FindDoor(THIS, uint32 door_id)"); { EntityList *THIS; Doors *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->FindDoor(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Doors", (void *) RETVAL); @@ -383,12 +526,20 @@ XS(XS_EntityList_GetGroupByMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetGroupByMob) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetGroupByMob(THIS, Mob* mob)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::GetGroupByMob(THIS, Mob* mob)"); { EntityList *THIS; Group *RETVAL; Mob *mob; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -408,12 +559,20 @@ XS(XS_EntityList_GetGroupByClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetGroupByClient) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetGroupByClient(THIS, Client* client)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::GetGroupByClient(THIS, Client* client)"); { EntityList *THIS; Group *RETVAL; Client *client; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Client *, tmp); @@ -433,12 +592,20 @@ XS(XS_EntityList_GetGroupByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetGroupByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetGroupByID(THIS, id)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::GetGroupByID(THIS, id)"); { EntityList *THIS; Group *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroupByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Group", (void *) RETVAL); @@ -450,12 +617,20 @@ XS(XS_EntityList_GetGroupByLeaderName); /* prototype to pass -Wmissing-prototype XS(XS_EntityList_GetGroupByLeaderName) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetGroupByLeaderName(THIS, leader)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::GetGroupByLeaderName(THIS, leader)"); { EntityList *THIS; Group *RETVAL; char *leader = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroupByLeaderName(leader); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Group", (void *) RETVAL); @@ -467,12 +642,20 @@ XS(XS_EntityList_GetRaidByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetRaidByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetRaidByID(THIS, id)"); // @categories Script Utility, Raid + Perl_croak(aTHX_ "Usage: EntityList::GetRaidByID(THIS, id)"); { EntityList *THIS; Raid *RETVAL; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRaidByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Raid", (void *) RETVAL); @@ -484,12 +667,20 @@ XS(XS_EntityList_GetRaidByClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetRaidByClient) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetRaidByClient(THIS, client)"); // @categories Account and Character, Script Utility, Raid + Perl_croak(aTHX_ "Usage: EntityList::GetRaidByClient(THIS, client)"); { EntityList *THIS; Raid *RETVAL; Client *client; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Client *, tmp); @@ -509,12 +700,20 @@ XS(XS_EntityList_GetCorpseByOwner); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetCorpseByOwner) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByOwner(THIS, client)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByOwner(THIS, client)"); { EntityList *THIS; Corpse *RETVAL; Client *client; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Client *, tmp); @@ -534,12 +733,20 @@ XS(XS_EntityList_GetCorpseByID); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetCorpseByID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByID(THIS, id)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByID(THIS, id)"); { EntityList *THIS; Corpse *RETVAL; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseByID(id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Corpse", (void *) RETVAL); @@ -551,12 +758,20 @@ XS(XS_EntityList_GetCorpseByName); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetCorpseByName) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByName(THIS, name)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: EntityList::GetCorpseByName(THIS, name)"); { EntityList *THIS; Corpse *RETVAL; char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseByName(name); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Corpse", (void *) RETVAL); @@ -568,10 +783,18 @@ XS(XS_EntityList_ClearClientPetitionQueue); /* prototype to pass -Wmissing-proto XS(XS_EntityList_ClearClientPetitionQueue) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::ClearClientPetitionQueue(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::ClearClientPetitionQueue(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearClientPetitionQueue(); } XSRETURN_EMPTY; @@ -581,12 +804,20 @@ XS(XS_EntityList_CanAddHateForMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_CanAddHateForMob) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::CanAddHateForMob(THIS, Mob* target)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: EntityList::CanAddHateForMob(THIS, Mob* target)"); { EntityList *THIS; bool RETVAL; Mob *p; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); p = INT2PTR(Mob *, tmp); @@ -606,10 +837,18 @@ XS(XS_EntityList_Clear); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_Clear) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::Clear(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::Clear(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Clear(); } XSRETURN_EMPTY; @@ -619,12 +858,20 @@ XS(XS_EntityList_RemoveMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveMob) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveMob(THIS, delete_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveMob(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveMob(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -636,12 +883,20 @@ XS(XS_EntityList_RemoveClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveClient) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveClient(THIS, delete_id)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveClient(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveClient(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -653,12 +908,20 @@ XS(XS_EntityList_RemoveNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveNPC) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveNPC(THIS, delete_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveNPC(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveNPC(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -670,12 +933,20 @@ XS(XS_EntityList_RemoveGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveGroup) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveGroup(THIS, delete_id)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::RemoveGroup(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint32 delete_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveGroup(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -687,12 +958,20 @@ XS(XS_EntityList_RemoveCorpse); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveCorpse) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveCorpse(THIS, delete_id)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: EntityList::RemoveCorpse(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveCorpse(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -704,12 +983,20 @@ XS(XS_EntityList_RemoveDoor); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveDoor) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveDoor(THIS, delete_id)"); // @categories Doors + Perl_croak(aTHX_ "Usage: EntityList::RemoveDoor(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveDoor(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -721,12 +1008,20 @@ XS(XS_EntityList_RemoveTrap); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveTrap) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveTrap(THIS, delete_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveTrap(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveTrap(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -738,12 +1033,20 @@ XS(XS_EntityList_RemoveObject); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveObject) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveObject(THIS, delete_id)"); // @categories Script Utility, Objects + Perl_croak(aTHX_ "Usage: EntityList::RemoveObject(THIS, delete_id)"); { EntityList *THIS; bool RETVAL; uint16 delete_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RemoveObject(delete_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -755,10 +1058,18 @@ XS(XS_EntityList_RemoveAllMobs); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllMobs) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllMobs(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllMobs(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllMobs(); } XSRETURN_EMPTY; @@ -768,10 +1079,18 @@ XS(XS_EntityList_RemoveAllClients); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllClients) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllClients(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllClients(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllClients(); } XSRETURN_EMPTY; @@ -781,10 +1100,18 @@ XS(XS_EntityList_RemoveAllNPCs); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllNPCs) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllNPCs(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllNPCs(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllNPCs(); } XSRETURN_EMPTY; @@ -794,10 +1121,18 @@ XS(XS_EntityList_RemoveAllGroups); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllGroups) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllGroups(THIS)"); // @categories Group + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllGroups(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllGroups(); } XSRETURN_EMPTY; @@ -807,10 +1142,18 @@ XS(XS_EntityList_RemoveAllCorpses); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllCorpses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllCorpses(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllCorpses(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllCorpses(); } XSRETURN_EMPTY; @@ -820,10 +1163,18 @@ XS(XS_EntityList_RemoveAllDoors); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllDoors) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllDoors(THIS)"); // @categories Doors + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllDoors(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllDoors(); } XSRETURN_EMPTY; @@ -833,10 +1184,18 @@ XS(XS_EntityList_RemoveAllTraps); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllTraps) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllTraps(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllTraps(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllTraps(); } XSRETURN_EMPTY; @@ -846,10 +1205,18 @@ XS(XS_EntityList_RemoveAllObjects); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveAllObjects) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::RemoveAllObjects(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: EntityList::RemoveAllObjects(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveAllObjects(); } XSRETURN_EMPTY; @@ -859,13 +1226,21 @@ XS(XS_EntityList_Message); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_Message) { dXSARGS; if (items < 4) - Perl_croak(aTHX_ "Usage: EntityList::Message(THIS, uint32 guild_id, uint32 emote_color_type, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::Message(THIS, uint32 guild_id, uint32 emote_color_type, string message)"); { EntityList *THIS; uint32 to_guilddbid = (uint32) SvUV(ST(1)); uint32 type = (uint32) SvUV(ST(2)); char *message = (char *) SvPV_nolen(ST(3)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Message(to_guilddbid, type, message); } XSRETURN_EMPTY; @@ -875,14 +1250,22 @@ XS(XS_EntityList_MessageStatus); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_MessageStatus) { dXSARGS; if (items < 5) - Perl_croak(aTHX_ "Usage: EntityList::MessageStatus(THIS, uint32 guild_id, uint32 emote_color_type, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::MessageStatus(THIS, uint32 guild_id, uint32 emote_color_type, string message)"); { EntityList *THIS; uint32 to_guilddbid = (uint32) SvUV(ST(1)); int to_minstatus = (int) SvIV(ST(2)); uint32 type = (uint32) SvUV(ST(3)); char *message = (char *) SvPV_nolen(ST(4)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->MessageStatus(to_guilddbid, to_minstatus, type, message); } XSRETURN_EMPTY; @@ -900,7 +1283,15 @@ XS(XS_EntityList_MessageClose) { float dist = (float) SvNV(ST(3)); uint32 type = (uint32) SvUV(ST(4)); char *message = (char *) SvPV_nolen(ST(5)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -918,11 +1309,19 @@ XS(XS_EntityList_RemoveFromTargets); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_RemoveFromTargets) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveFromTargets(THIS, Mob* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveFromTargets(THIS, Mob* target)"); { EntityList *THIS; Mob *mob; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -940,12 +1339,20 @@ XS(XS_EntityList_ReplaceWithTarget); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_ReplaceWithTarget) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: EntityList::ReplaceWithTarget(THIS, Mob* old_mob, Mob* new_target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::ReplaceWithTarget(THIS, Mob* old_mob, Mob* new_target)"); { EntityList *THIS; Mob *pOldMob; Mob *pNewTarget; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); pOldMob = INT2PTR(Mob *, tmp); @@ -971,11 +1378,19 @@ XS(XS_EntityList_OpenDoorsNear); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_OpenDoorsNear) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::OpenDoorsNear(THIS, NPC* opener)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::OpenDoorsNear(THIS, NPC* opener)"); { EntityList *THIS; Mob *opener; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); opener = INT2PTR(Mob *, tmp); @@ -993,13 +1408,21 @@ XS(XS_EntityList_MakeNameUnique); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_MakeNameUnique) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::MakeNameUnique(THIS, string name)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::MakeNameUnique(THIS, string name)"); { EntityList *THIS; char *RETVAL; dXSTARG; char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->MakeNameUnique(name); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -1030,12 +1453,20 @@ XS(XS_EntityList_SignalMobsByNPCID); /* prototype to pass -Wmissing-prototypes * XS(XS_EntityList_SignalMobsByNPCID) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: EntityList::SignalMobsByNPCID(THIS, uint32 npc_type_id, int signal_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::SignalMobsByNPCID(THIS, uint32 npc_type_id, int signal_id)"); { EntityList *THIS; uint32 npc_type = (uint32) SvUV(ST(1)); int signal_id = (int) SvIV(ST(2)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SignalMobsByNPCID(npc_type, signal_id); } XSRETURN_EMPTY; @@ -1045,11 +1476,19 @@ XS(XS_EntityList_RemoveEntity); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_RemoveEntity) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::RemoveEntity(THIS, uint16 id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::RemoveEntity(THIS, uint16 id)"); { EntityList *THIS; uint16 id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveEntity(id); } XSRETURN_EMPTY; @@ -1059,12 +1498,20 @@ XS(XS_EntityList_DeleteNPCCorpses); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_DeleteNPCCorpses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::DeleteNPCCorpses(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: EntityList::DeleteNPCCorpses(THIS)"); { EntityList *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DeleteNPCCorpses(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1076,12 +1523,20 @@ XS(XS_EntityList_DeletePlayerCorpses); /* prototype to pass -Wmissing-prototypes XS(XS_EntityList_DeletePlayerCorpses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::DeletePlayerCorpses(THIS)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: EntityList::DeletePlayerCorpses(THIS)"); { EntityList *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DeletePlayerCorpses(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1093,11 +1548,19 @@ XS(XS_EntityList_HalveAggro); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_HalveAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::HalveAggro(THIS, Mob* target)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: EntityList::HalveAggro(THIS, Mob* target)"); { EntityList *THIS; Mob *who; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); who = INT2PTR(Mob *, tmp); @@ -1115,11 +1578,19 @@ XS(XS_EntityList_DoubleAggro); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_DoubleAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::DoubleAggro(THIS, *Mob target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::DoubleAggro(THIS, *Mob target)"); { EntityList *THIS; Mob *who; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); who = INT2PTR(Mob *, tmp); @@ -1137,11 +1608,19 @@ XS(XS_EntityList_ClearFeignAggro); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_ClearFeignAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::ClearFeignAggro(THIS, Mob* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::ClearFeignAggro(THIS, Mob* target)"); { EntityList *THIS; Mob *targ; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); targ = INT2PTR(Mob *, tmp); @@ -1159,12 +1638,20 @@ XS(XS_EntityList_Fighting); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_Fighting) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::Fighting(THIS, Mob* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::Fighting(THIS, Mob* target)"); { EntityList *THIS; bool RETVAL; Mob *targ; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); targ = INT2PTR(Mob *, tmp); @@ -1184,12 +1671,20 @@ XS(XS_EntityList_RemoveFromHateLists); /* prototype to pass -Wmissing-prototypes XS(XS_EntityList_RemoveFromHateLists) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: EntityList::RemoveFromHateLists(THIS, Mob* mob, [bool set_to_one = false])"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: EntityList::RemoveFromHateLists(THIS, Mob* mob, [bool set_to_one = false])"); { EntityList *THIS; Mob *mob; bool settoone; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -1213,14 +1708,22 @@ XS(XS_EntityList_MessageGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_MessageGroup) { dXSARGS; if (items < 5) - Perl_croak(aTHX_ "Usage: EntityList::MessageGroup(THIS, Mob* sender, bool skip_close, uint32 emote_color_type, string message)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: EntityList::MessageGroup(THIS, Mob* sender, bool skip_close, uint32 emote_color_type, string message)"); { EntityList *THIS; Mob *sender; bool skipclose = (bool) SvTRUE(ST(2)); uint32 type = (uint32) SvUV(ST(3)); char *message = (char *) SvPV_nolen(ST(4)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -1238,7 +1741,7 @@ XS(XS_EntityList_GetRandomClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_GetRandomClient) { dXSARGS; if ((items < 5) || (items > 6)) - Perl_croak(aTHX_ "Usage: EntityList::GetRandomClient(THIS, float x, float y, float z, float distance, [Client* exclude_client = nullptr])"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetRandomClient(THIS, float x, float y, float z, float distance, [Client* exclude_client = nullptr])"); { EntityList *THIS; Client *RETVAL, *c = nullptr; @@ -1246,7 +1749,16 @@ XS(XS_EntityList_GetRandomClient) { float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); float d = (float) SvNV(ST(4)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 6) { if (sv_derived_from(ST(5), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(5))); @@ -1265,10 +1777,19 @@ XS(XS_EntityList_GetMobList) { dXSARGS; int num_mobs = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetMobList(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetMobList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list mob_list; entity_list.GetMobList(mob_list); auto iter = mob_list.begin(); @@ -1290,10 +1811,19 @@ XS(XS_EntityList_GetClientList) { dXSARGS; int num_clients = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetClientList(THIS)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetClientList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list client_list; entity_list.GetClientList(client_list); auto iter = client_list.begin(); @@ -1315,10 +1845,19 @@ XS(XS_EntityList_GetNPCList) { dXSARGS; int num_npcs = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetNPCList(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::GetNPCList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list npc_list; entity_list.GetNPCList(npc_list); auto iter = npc_list.begin(); @@ -1340,10 +1879,19 @@ XS(XS_EntityList_GetCorpseList) { dXSARGS; int num_corpses = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetCorpseList(THIS)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: EntityList::GetCorpseList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list corpse_list; entity_list.GetCorpseList(corpse_list); auto iter = corpse_list.begin(); @@ -1365,10 +1913,19 @@ XS(XS_EntityList_GetObjectList) { dXSARGS; int num_objects = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetObjectList(THIS)"); // @categories Script Utility, Objects + Perl_croak(aTHX_ "Usage: EntityList::GetObjectList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list object_list; entity_list.GetObjectList(object_list); auto iter = object_list.begin(); @@ -1390,10 +1947,19 @@ XS(XS_EntityList_GetDoorsList) { dXSARGS; int num_objects = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: EntityList::GetDoorsList(THIS)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: EntityList::GetDoorsList(THIS)"); { EntityList *THIS; - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + std::list door_list; entity_list.GetDoorsList(door_list); auto iter = door_list.begin(); @@ -1414,11 +1980,20 @@ XS(XS_EntityList_SignalAllClients); /* prototype to pass -Wmissing-prototypes */ XS(XS_EntityList_SignalAllClients) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: EntityList::SignalAllClients(THIS, uint32 data)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: EntityList::SignalAllClients(THIS, uint32 data)"); { EntityList *THIS; uint32 data = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_ENTITY; + + if (sv_derived_from(ST(0), "EntityList")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EntityList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EntityList"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + entity_list.SignalAllClients(data); } XSRETURN_EMPTY; diff --git a/zone/perl_expedition.cpp b/zone/perl_expedition.cpp deleted file mode 100644 index c0c483cfb..000000000 --- a/zone/perl_expedition.cpp +++ /dev/null @@ -1,691 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "../common/features.h" - -#ifdef EMBPERL_XS_CLASSES - -#include "expedition.h" -#include "zone_store.h" -#include "embperl.h" -#include "../common/global_define.h" - -#ifdef seed -#undef seed -#endif - -#ifdef THIS /* this macro seems to leak out on some systems */ -#undef THIS -#endif - -#define VALIDATE_THIS_IS_EXPEDITION \ - do { \ - if (sv_derived_from(ST(0), "Expedition")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Expedition*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Expedition"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - -XS(XS_Expedition_AddLockout); -XS(XS_Expedition_AddLockout) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Expedition::AddLockout(THIS, string event_name, uint32 seconds)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - std::string event_name(SvPV_nolen(ST(1))); - uint32_t seconds = static_cast(SvUV(ST(2))); - - THIS->AddLockout(event_name, seconds); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_AddLockoutDuration); -XS(XS_Expedition_AddLockoutDuration) { - dXSARGS; - if (items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Expedition::AddLockout(THIS, string event_name, int seconds, [bool members_only = true])"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - std::string event_name(SvPV_nolen(ST(1))); - int seconds = static_cast(SvUV(ST(2))); - if (items == 4) - { - bool members_only = (bool)SvTRUE(ST(3)); - THIS->AddLockoutDuration(event_name, seconds, members_only); - } - else - { - THIS->AddLockoutDuration(event_name, seconds); - } - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_AddReplayLockout); -XS(XS_Expedition_AddReplayLockout) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::AddReplayLockout(THIS, uint32 seconds)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t seconds = static_cast(SvUV(ST(1))); - - THIS->AddReplayLockout(seconds); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_AddReplayLockoutDuration); -XS(XS_Expedition_AddReplayLockoutDuration) { - dXSARGS; - if (items != 2 && items != 3) { - Perl_croak(aTHX_ "Usage: Expedition::AddReplayLockoutDuration(THIS, int seconds, [bool members_only = true])"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - int seconds = static_cast(SvUV(ST(1))); - if (items == 3) - { - bool members_only = (bool)SvTRUE(ST(2)); - THIS->AddReplayLockoutDuration(seconds, members_only); - } - else - { - THIS->AddReplayLockoutDuration(seconds); - } - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_GetDynamicZoneID); -XS(XS_Expedition_GetDynamicZoneID) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetDynamicZoneID(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetDynamicZone().GetID()); -} - -XS(XS_Expedition_GetID); -XS(XS_Expedition_GetID) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetID(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetID()); -} - -XS(XS_Expedition_GetInstanceID); -XS(XS_Expedition_GetInstanceID) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetInstanceID(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetDynamicZone().GetInstanceID()); -} - -XS(XS_Expedition_GetLeaderName); -XS(XS_Expedition_GetLeaderName) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetLeaderName(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_PV(THIS->GetLeaderName().c_str()); -} - -XS(XS_Expedition_GetLockouts); -XS(XS_Expedition_GetLockouts) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetLockouts(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - HV* hash = newHV(); - - auto lockouts = THIS->GetLockouts(); - for (const auto& lockout : lockouts) - { - hv_store(hash, lockout.first.c_str(), static_cast(lockout.first.size()), - newSVuv(lockout.second.GetSecondsRemaining()), 0); - } - - ST(0) = sv_2mortal(newRV_noinc((SV*)hash)); // take ownership of hash (refcnt remains 1) - XSRETURN(1); -} - -XS(XS_Expedition_GetLootEventByNPCTypeID); -XS(XS_Expedition_GetLootEventByNPCTypeID) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::GetLootEventByNPCTypeID(THIS, uint32 npc_type_id)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t npc_type_id = static_cast(SvUV(ST(1))); - - XSRETURN_PV(THIS->GetLootEventByNPCTypeID(npc_type_id).c_str()); -} - -XS(XS_Expedition_GetLootEventBySpawnID); -XS(XS_Expedition_GetLootEventBySpawnID) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::GetLootEventBySpawnID(THIS, uint32 spawn_id)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t spawn_id = static_cast(SvUV(ST(1))); - - XSRETURN_PV(THIS->GetLootEventBySpawnID(spawn_id).c_str()); -} - -XS(XS_Expedition_GetMemberCount); -XS(XS_Expedition_GetMemberCount) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetMemberCount(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetMemberCount()); -} - -XS(XS_Expedition_GetMembers); -XS(XS_Expedition_GetMembers) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetMembers(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - HV* hash = newHV(); - - auto members = THIS->GetMembers(); - for (const auto& member : members) - { - hv_store(hash, member.name.c_str(), static_cast(member.name.size()), - newSVuv(member.id), 0); - } - - ST(0) = sv_2mortal(newRV_noinc((SV*)hash)); - XSRETURN(1); -} - -XS(XS_Expedition_GetName); -XS(XS_Expedition_GetName) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetName(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_PV(THIS->GetName().c_str()); -} - -XS(XS_Expedition_GetSecondsRemaining); -XS(XS_Expedition_GetSecondsRemaining) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetSecondsRemaining(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetDynamicZone().GetSecondsRemaining()); -} - -XS(XS_Expedition_GetUUID); -XS(XS_Expedition_GetUUID) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetUUID(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_PV(THIS->GetUUID().c_str()); -} - -XS(XS_Expedition_GetZoneID); -XS(XS_Expedition_GetZoneID) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetZoneID(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetDynamicZone().GetZoneID()); -} - -XS(XS_Expedition_GetZoneName); -XS(XS_Expedition_GetZoneName) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetZoneName(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_PV(ZoneName(THIS->GetDynamicZone().GetZoneID())); -} - -XS(XS_Expedition_GetZoneVersion); -XS(XS_Expedition_GetZoneVersion) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::GetZoneVersion(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - XSRETURN_UV(THIS->GetDynamicZone().GetZoneVersion()); -} - -XS(XS_Expedition_HasLockout); -XS(XS_Expedition_HasLockout) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::HasLockout(THIS, string event_name)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - std::string event_name(SvPV_nolen(ST(1))); - - bool result = THIS->HasLockout(event_name); - ST(0) = boolSV(result); - XSRETURN(1); -} - -XS(XS_Expedition_HasReplayLockout); -XS(XS_Expedition_HasReplayLockout) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::HasReplayLockout(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - bool result = THIS->HasReplayLockout(); - ST(0) = boolSV(result); - XSRETURN(1); -} - -XS(XS_Expedition_IsLocked); -XS(XS_Expedition_IsLocked) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::IsLocked(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - ST(0) = boolSV(THIS->IsLocked()); - XSRETURN(1); -} - -XS(XS_Expedition_RemoveCompass); -XS(XS_Expedition_RemoveCompass) { - dXSARGS; - if (items != 1) { - Perl_croak(aTHX_ "Usage: Expedition::RemoveCompass(THIS)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - THIS->GetDynamicZone().SetCompass(0, 0, 0, 0, true); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_RemoveLockout); -XS(XS_Expedition_RemoveLockout) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::RemoveLockout(THIS, string event_name)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - std::string event_name(SvPV_nolen(ST(1))); - - THIS->RemoveLockout(event_name); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetCompass); -XS(XS_Expedition_SetCompass) { - dXSARGS; - if (items != 5) { - Perl_croak(aTHX_ "Usage: Expedition::SetCompass(THIS, uint32 zone_id | string zone_name, float x, float y, float z)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - float x = static_cast(SvNV(ST(2))); - float y = static_cast(SvNV(ST(3))); - float z = static_cast(SvNV(ST(4))); - - if (SvTYPE(ST(1)) == SVt_PV) - { - std::string zone_name(SvPV_nolen(ST(1))); - THIS->GetDynamicZone().SetCompass(ZoneID(zone_name), x, y, z, true); - } - else if (SvTYPE(ST(1)) == SVt_IV) - { - uint32_t zone_id = static_cast(SvUV(ST(1))); - THIS->GetDynamicZone().SetCompass(zone_id, x, y, z, true); - } - else - { - Perl_croak(aTHX_ "Expedition::SetCompass expected an integer or string"); - } - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetLocked); -XS(XS_Expedition_SetLocked) { - dXSARGS; - if (items != 2 && items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Expedition::SetLocked(THIS, bool locked, [int lock_msg = 0], [uint32 color = 15])"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - bool locked = (bool)SvTRUE(ST(1)); - int lock_msg = (items == 3) ? static_cast(SvIV(ST(2))) : 0; - if (items == 4) - { - THIS->SetLocked(locked, static_cast(lock_msg), true, (uint32)SvUV(ST(3))); - } - else - { - THIS->SetLocked(locked, static_cast(lock_msg), true); - } - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetLootEventByNPCTypeID); -XS(XS_Expedition_SetLootEventByNPCTypeID) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Expedition::SetLootEventByNPCTypeID(THIS, uint32 npc_type_id, string event_name)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t npc_type_id = static_cast(SvUV(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - - THIS->SetLootEventByNPCTypeID(npc_type_id, event_name); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetLootEventBySpawnID); -XS(XS_Expedition_SetLootEventBySpawnID) { - dXSARGS; - if (items != 3) { - Perl_croak(aTHX_ "Usage: Expedition::SetLootEventBySpawnID(THIS, uint32 spawn_id, string event_name)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t spawn_id = static_cast(SvUV(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - - THIS->SetLootEventBySpawnID(spawn_id, event_name); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetReplayLockoutOnMemberJoin); -XS(XS_Expedition_SetReplayLockoutOnMemberJoin) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::SetReplayLockoutOnMemberJoin(THIS, bool enable)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - bool enable = (bool)SvTRUE(ST(1)); - - THIS->SetReplayLockoutOnMemberJoin(enable, true); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetSafeReturn); -XS(XS_Expedition_SetSafeReturn) { - dXSARGS; - if (items != 6) { - Perl_croak(aTHX_ "Usage: Expedition::SetSafeReturn(THIS, uint32 zone_id | string zone_name, float x, float y, float z, float heading)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - float x = static_cast(SvNV(ST(2))); - float y = static_cast(SvNV(ST(3))); - float z = static_cast(SvNV(ST(4))); - float heading = static_cast(SvNV(ST(5))); - - if (SvTYPE(ST(1)) == SVt_PV) - { - std::string zone_name(SvPV_nolen(ST(1))); - THIS->GetDynamicZone().SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true); - } - else if (SvTYPE(ST(1)) == SVt_IV) - { - uint32_t zone_id = static_cast(SvUV(ST(1))); - THIS->GetDynamicZone().SetSafeReturn(zone_id, x, y, z, heading, true); - } - else - { - Perl_croak(aTHX_ "Expedition::SetSafeReturn expected an integer or string"); - } - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetSecondsRemaining); -XS(XS_Expedition_SetSecondsRemaining) { - dXSARGS; - if (items != 2) { - Perl_croak(aTHX_ "Usage: Expedition::SetSecondsRemaining(THIS, uint32 seconds_remaining)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - uint32_t seconds_remaining = static_cast(SvUV(ST(1))); - THIS->GetDynamicZone().SetSecondsRemaining(seconds_remaining); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_SetZoneInLocation); -XS(XS_Expedition_SetZoneInLocation) { - dXSARGS; - if (items != 5) { - Perl_croak(aTHX_ "Usage: Expedition::SetZoneInLocation(THIS, float x, float y, float z, float heading)"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - float x = static_cast(SvNV(ST(1))); - float y = static_cast(SvNV(ST(2))); - float z = static_cast(SvNV(ST(3))); - float heading = static_cast(SvNV(ST(4))); - - THIS->GetDynamicZone().SetZoneInLocation(x, y, z, heading, true); - - XSRETURN_EMPTY; -} - -XS(XS_Expedition_UpdateLockoutDuration); -XS(XS_Expedition_UpdateLockoutDuration) { - dXSARGS; - if (items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Expedition::UpdateLockoutDuration(THIS, string event_name, uint32 seconds, [bool members_only = true])"); - } - - Expedition* THIS = nullptr; - VALIDATE_THIS_IS_EXPEDITION; - - std::string event_name(SvPV_nolen(ST(1))); - uint32_t seconds = static_cast(SvUV(ST(2))); - - if (items == 4) - { - bool members_only = (bool)SvTRUE(ST(3)); - THIS->UpdateLockoutDuration(event_name, seconds, members_only); - } - else - { - THIS->UpdateLockoutDuration(event_name, seconds); - } - - XSRETURN_EMPTY; -} - -XS(boot_Expedition); -XS(boot_Expedition) { - dXSARGS; - char file[256]; - strncpy(file, __FILE__, 256); - file[255] = 0; - - if (items != 1) { - fprintf(stderr, "boot_Expedition does not take any arguments."); - } - char buf[128]; - - XS_VERSION_BOOTCHECK; - newXSproto(strcpy(buf, "AddLockout"), XS_Expedition_AddLockout, file, "$$$"); - newXSproto(strcpy(buf, "AddLockoutDuration"), XS_Expedition_AddLockoutDuration, file, "$$$;$"); - newXSproto(strcpy(buf, "AddReplayLockout"), XS_Expedition_AddReplayLockout, file, "$$"); - newXSproto(strcpy(buf, "AddReplayLockoutDuration"), XS_Expedition_AddReplayLockoutDuration, file, "$$;$"); - newXSproto(strcpy(buf, "GetDynamicZoneID"), XS_Expedition_GetDynamicZoneID, file, "$"); - newXSproto(strcpy(buf, "GetID"), XS_Expedition_GetID, file, "$"); - newXSproto(strcpy(buf, "GetInstanceID"), XS_Expedition_GetInstanceID, file, "$"); - newXSproto(strcpy(buf, "GetLeaderName"), XS_Expedition_GetLeaderName, file, "$"); - newXSproto(strcpy(buf, "GetLockouts"), XS_Expedition_GetLockouts, file, "$"); - newXSproto(strcpy(buf, "GetLootEventByNPCTypeID"), XS_Expedition_GetLootEventByNPCTypeID, file, "$$"); - newXSproto(strcpy(buf, "GetLootEventBySpawnID"), XS_Expedition_GetLootEventBySpawnID, file, "$$"); - newXSproto(strcpy(buf, "GetMemberCount"), XS_Expedition_GetMemberCount, file, "$"); - newXSproto(strcpy(buf, "GetMembers"), XS_Expedition_GetMembers, file, "$"); - newXSproto(strcpy(buf, "GetName"), XS_Expedition_GetName, file, "$"); - newXSproto(strcpy(buf, "GetSecondsRemaining"), XS_Expedition_GetSecondsRemaining, file, "$"); - newXSproto(strcpy(buf, "GetUUID"), XS_Expedition_GetUUID, file, "$"); - newXSproto(strcpy(buf, "GetZoneID"), XS_Expedition_GetZoneID, file, "$"); - newXSproto(strcpy(buf, "GetZoneName"), XS_Expedition_GetZoneName, file, "$"); - newXSproto(strcpy(buf, "GetZoneVersion"), XS_Expedition_GetZoneVersion, file, "$"); - newXSproto(strcpy(buf, "HasLockout"), XS_Expedition_HasLockout, file, "$$"); - newXSproto(strcpy(buf, "HasReplayLockout"), XS_Expedition_HasReplayLockout, file, "$"); - newXSproto(strcpy(buf, "IsLocked"), XS_Expedition_IsLocked, file, "$"); - newXSproto(strcpy(buf, "RemoveCompass"), XS_Expedition_RemoveCompass, file, "$"); - newXSproto(strcpy(buf, "RemoveLockout"), XS_Expedition_RemoveLockout, file, "$$"); - newXSproto(strcpy(buf, "SetCompass"), XS_Expedition_SetCompass, file, "$$$$$"); - newXSproto(strcpy(buf, "SetLocked"), XS_Expedition_SetLocked, file, "$$;$$"); - newXSproto(strcpy(buf, "SetLootEventByNPCTypeID"), XS_Expedition_SetLootEventByNPCTypeID, file, "$$$"); - newXSproto(strcpy(buf, "SetLootEventBySpawnID"), XS_Expedition_SetLootEventBySpawnID, file, "$$$"); - newXSproto(strcpy(buf, "SetReplayLockoutOnMemberJoin"), XS_Expedition_SetReplayLockoutOnMemberJoin, file, "$$"); - newXSproto(strcpy(buf, "SetSafeReturn"), XS_Expedition_SetSafeReturn, file, "$$$$$$"); - newXSproto(strcpy(buf, "SetSecondsRemaining"), XS_Expedition_SetSecondsRemaining, file, "$$"); - newXSproto(strcpy(buf, "SetZoneInLocation"), XS_Expedition_SetZoneInLocation, file, "$$$$$"); - newXSproto(strcpy(buf, "UpdateLockoutDuration"), XS_Expedition_UpdateLockoutDuration, file, "$$$;$"); - - HV* stash = gv_stashpvs("ExpeditionLockMessage", GV_ADD); - newCONSTSUB(stash, "None", newSViv(static_cast(ExpeditionLockMessage::None))); - newCONSTSUB(stash, "Close", newSViv(static_cast(ExpeditionLockMessage::Close))); - newCONSTSUB(stash, "Begin", newSViv(static_cast(ExpeditionLockMessage::Begin))); - - XSRETURN_YES; -} - -#endif //EMBPERL_XS_CLASSES diff --git a/zone/perl_groups.cpp b/zone/perl_groups.cpp index 70c321a21..c23246b4a 100644 --- a/zone/perl_groups.cpp +++ b/zone/perl_groups.cpp @@ -42,27 +42,23 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_GROUP \ - do { \ - if (sv_derived_from(ST(0), "Group")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Group*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Group"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_Group_DisbandGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_DisbandGroup) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::DisbandGroup(THIS)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::DisbandGroup(THIS)"); { Group *THIS; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->DisbandGroup(); } XSRETURN_EMPTY; @@ -72,12 +68,20 @@ XS(XS_Group_IsGroupMember); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_IsGroupMember) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::IsGroupMember(THIS, client)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::IsGroupMember(THIS, client)"); { Group *THIS; bool RETVAL; Mob *client; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Mob *, tmp); @@ -97,12 +101,20 @@ XS(XS_Group_CastGroupSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_CastGroupSpell) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Group::CastGroupSpell(THIS, Mob* caster, uint16 spell_id)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::CastGroupSpell(THIS, Mob* caster, uint16 spell_id)"); { Group *THIS; Mob *caster; uint16 spellid = (uint16) SvUV(ST(2)); - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); caster = INT2PTR(Mob *, tmp); @@ -120,12 +132,20 @@ XS(XS_Group_SplitExp); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_SplitExp) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Group::SplitExp(THIS, uint32 exp, Mob* other)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::SplitExp(THIS, uint32 exp, Mob* other)"); { Group *THIS; uint32 exp = (uint32) SvUV(ST(1)); Mob *other; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(2), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(2))); other = INT2PTR(Mob *, tmp); @@ -143,13 +163,21 @@ XS(XS_Group_GroupMessage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GroupMessage) { dXSARGS; if ((items != 3) && (items != 4)) // the 3 item version is kept for backwards compatability - Perl_croak(aTHX_ "Usage: Group::GroupMessage(THIS, Mob* sender, uint8 language, string message)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GroupMessage(THIS, Mob* sender, uint8 language, string message)"); { Group *THIS; Mob *sender; uint8 language; char *message; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -176,13 +204,21 @@ XS(XS_Group_GetTotalGroupDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GetTotalGroupDamage) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::GetTotalGroupDamage(THIS, Mob* other)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetTotalGroupDamage(THIS, Mob* other)"); { Group *THIS; uint32 RETVAL; dXSTARG; Mob *other; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -202,14 +238,22 @@ XS(XS_Group_SplitMoney); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_SplitMoney) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: Group::SplitMoney(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum)"); // @categories Currency and Points, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::SplitMoney(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum)"); { Group *THIS; uint32 copper = (uint32) SvUV(ST(1)); uint32 silver = (uint32) SvUV(ST(2)); uint32 gold = (uint32) SvUV(ST(3)); uint32 platinum = (uint32) SvUV(ST(4)); - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SplitMoney(copper, silver, gold, platinum); } XSRETURN_EMPTY; @@ -219,11 +263,19 @@ XS(XS_Group_SetLeader); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_SetLeader) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::SetLeader(THIS, Mob* new_leader)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::SetLeader(THIS, Mob* new_leader)"); { Group *THIS; Mob *newleader; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); newleader = INT2PTR(Mob *, tmp); @@ -241,11 +293,19 @@ XS(XS_Group_GetLeader); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GetLeader) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::GetLeader(THIS)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetLeader(THIS)"); { Group *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLeader(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -257,12 +317,20 @@ XS(XS_Group_GetLeaderName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GetLeaderName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::GetLeaderName(THIS)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetLeaderName(THIS)"); { Group *THIS; const char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLeaderName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -275,11 +343,19 @@ XS(XS_Group_SendHPPacketsTo); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_SendHPPacketsTo) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::SendHPPacketsTo(THIS, Mob* new_member)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::SendHPPacketsTo(THIS, Mob* new_member)"); { Group *THIS; Mob *newmember; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); newmember = INT2PTR(Mob *, tmp); @@ -297,11 +373,19 @@ XS(XS_Group_SendHPPacketsFrom); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_SendHPPacketsFrom) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::SendHPPacketsFrom(THIS, Mob* new_member)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::SendHPPacketsFrom(THIS, Mob* new_member)"); { Group *THIS; Mob *newmember; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); newmember = INT2PTR(Mob *, tmp); @@ -319,12 +403,20 @@ XS(XS_Group_IsLeader); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_IsLeader) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::IsLeader(THIS, Mob* target)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::IsLeader(THIS, Mob* target)"); { Group *THIS; bool RETVAL; Mob *leadertest; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); leadertest = INT2PTR(Mob *, tmp); @@ -344,12 +436,20 @@ XS(XS_Group_GroupCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GroupCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::GroupCount(THIS)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GroupCount(THIS)"); { Group *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GroupCount(); XSprePUSH; PUSHu((UV) RETVAL); @@ -361,12 +461,20 @@ XS(XS_Group_GetHighestLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GetHighestLevel) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::GetHighestLevel(THIS)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetHighestLevel(THIS)"); { Group *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHighestLevel(); XSprePUSH; PUSHu((UV) RETVAL); @@ -378,7 +486,7 @@ XS(XS_Group_TeleportGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_TeleportGroup) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Group::TeleportGroup(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::TeleportGroup(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading)"); { Group *THIS; Mob *sender; @@ -387,7 +495,15 @@ XS(XS_Group_TeleportGroup) { float y = (float) SvNV(ST(4)); float z = (float) SvNV(ST(5)); float heading = (float) SvNV(ST(6)); - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -405,12 +521,20 @@ XS(XS_Group_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Group_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Group::GetID(THIS)"); // @categories Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetID(THIS)"); { Group *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -422,13 +546,21 @@ XS(XS_Group_GetMember); XS(XS_Group_GetMember) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Group::GetMember(THIS, int group_index)"); // @categories Account and Character, Script Utility, Group + Perl_croak(aTHX_ "Usage: Group::GetMember(THIS, int group_index)"); { Group *THIS; Mob *member; Client *RETVAL = nullptr; dXSTARG; - VALIDATE_THIS_IS_GROUP; + + if (sv_derived_from(ST(0), "Group")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Group *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Group"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + int index = (int) SvUV(ST(1)); if (index < 0 || index > 5) RETVAL = nullptr; @@ -444,24 +576,6 @@ XS(XS_Group_GetMember) { XSRETURN(1); } -XS(XS_Group_DoesAnyMemberHaveExpeditionLockout); -XS(XS_Group_DoesAnyMemberHaveExpeditionLockout) { - dXSARGS; - if (items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Group::DoesAnyMemberHaveExpeditionLockout(THIS, string expedition_name, string event_name, [int max_check_count = 0])"); - } - - Group* THIS = nullptr; - VALIDATE_THIS_IS_GROUP; - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - int max_check_count = (items == 4) ? static_cast(SvIV(ST(3))) : 0; - - bool result = THIS->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name, max_check_count); - ST(0) = boolSV(result); - XSRETURN(1); -} - #ifdef __cplusplus extern "C" #endif @@ -498,7 +612,6 @@ XS(boot_Group) { newXSproto(strcpy(buf, "TeleportGroup"), XS_Group_TeleportGroup, file, "$$$$$$$"); newXSproto(strcpy(buf, "GetID"), XS_Group_GetID, file, "$"); newXSproto(strcpy(buf, "GetMember"), XS_Group_GetMember, file, "$$"); - newXSproto(strcpy(buf, "DoesAnyMemberHaveExpeditionLockout"), XS_Group_DoesAnyMemberHaveExpeditionLockout, file, "$$$;$"); XSRETURN_YES; } diff --git a/zone/perl_hateentry.cpp b/zone/perl_hateentry.cpp index cd98648fa..85b5d67dd 100644 --- a/zone/perl_hateentry.cpp +++ b/zone/perl_hateentry.cpp @@ -35,28 +35,23 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_HATE \ - do { \ - if (sv_derived_from(ST(0), "HateEntry")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(struct_HateList*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type HateEntry"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_HateEntry_GetEnt); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetEnt) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: HateEntry::GetData(THIS)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: HateEntry::GetData(THIS)"); { struct_HateList *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_HATE; + + if (sv_derived_from(ST(0), "HateEntry")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(struct_HateList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type tHateEntry"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->entity_on_hatelist; ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -68,12 +63,20 @@ XS(XS_HateEntry_GetHate); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetHate) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: HateEntry::GetHate(THIS)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: HateEntry::GetHate(THIS)"); { struct_HateList *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_HATE; + + if (sv_derived_from(ST(0), "HateEntry")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(struct_HateList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type tHateEntry"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->stored_hate_amount; XSprePUSH; PUSHi((IV) RETVAL); @@ -85,12 +88,20 @@ XS(XS_HateEntry_GetDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetDamage) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: HateEntry::GetDamage(THIS)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: HateEntry::GetDamage(THIS)"); { struct_HateList *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_HATE; + + if (sv_derived_from(ST(0), "HateEntry")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(struct_HateList *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type tHateEntry"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->hatelist_damage; XSprePUSH; PUSHi((IV) RETVAL); diff --git a/zone/perl_inventory.cpp b/zone/perl_inventory.cpp deleted file mode 100644 index 56452873c..000000000 --- a/zone/perl_inventory.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/* -* This file was generated automatically by xsubpp version 1.9508 from the -* contents of tmp. Do not edit this file, edit tmp instead. -* -* ANY CHANGES MADE HERE WILL BE LOST! -* -*/ - - -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "../common/features.h" -#include "client.h" - -#ifdef EMBPERL_XS_CLASSES - -#include "../common/global_define.h" -#include "embperl.h" - -#ifdef seed -#undef seed -#endif - -#include "../common/inventory_profile.h" - -#ifdef THIS /* this macro seems to leak out on some systems */ -#undef THIS -#endif - -#define VALIDATE_THIS_IS_INVENTORY \ - do { \ - if (sv_derived_from(ST(0), "Inventory")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(EQ::InventoryProfile*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type EQ::InventoryProfile"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - -XS(XS_Inventory_CanItemFitInContainer); -XS(XS_Inventory_CanItemFitInContainer) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Inventory::CanItemFitInContainer(THIS, ItemInstance item_to_check, ItemInstance container_to_check)"); - { - EQ::InventoryProfile* THIS; - bool can_fit = false; - EQ::ItemInstance* item_to_check = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(1))); - EQ::ItemInstance* container_to_check = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(2))); - const EQ::ItemData* item_data = item_to_check->GetItem(); - const EQ::ItemData* container_data = container_to_check->GetItem(); - VALIDATE_THIS_IS_INVENTORY; - can_fit = THIS->CanItemFitInContainer(item_data, container_data); - ST(0) = boolSV(can_fit); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_CheckNoDrop); -XS(XS_Inventory_CheckNoDrop) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::CheckNoDrop(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - bool no_drop = false; - int16 slot_id = (int16)SvIV(ST(1)); - VALIDATE_THIS_IS_INVENTORY; - no_drop = THIS->CheckNoDrop(slot_id); - ST(0) = boolSV(no_drop); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_DeleteItem); -XS(XS_Inventory_DeleteItem) { - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Inventory::DeleteItem(THIS, int16 slot_id, [uint8 quantity = 0])"); - { - EQ::InventoryProfile* THIS; - bool item_deleted = false; - int16 slot_id = (int16)SvIV(ST(1)); - uint8 quantity = 0; - VALIDATE_THIS_IS_INVENTORY; - if (items > 2) - quantity = (uint8)SvUV(ST(2)); - - item_deleted = THIS->DeleteItem(slot_id, quantity); - ST(0) = boolSV(item_deleted); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_FindFreeSlot); -XS(XS_Inventory_FindFreeSlot) { - dXSARGS; - if (items < 3 || items > 5) - Perl_croak(aTHX_ "Usage: Inventory::FindFreeSlot(THIS, bool is_for_bag, bool try_cursor, [uint8 min_size = 0, bool is_arrow = false])"); - { - EQ::InventoryProfile* THIS; - int16 free_slot; - bool is_for_bag = (bool)SvNV(ST(1)); - bool try_cursor = (bool)SvNV(ST(2)); - uint8 min_size = 0; - bool is_arrow = false; - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (items > 3) - min_size = (uint8)SvUV(ST(3)); - if (items > 4) - is_arrow = (bool)SvNV(ST(4)); - - free_slot = THIS->FindFreeSlot(is_for_bag, try_cursor, min_size, is_arrow); - XSprePUSH; - PUSHi((IV)free_slot); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetBagIndex); -XS(XS_Inventory_GetBagIndex) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::GetBagIndex(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - uint8 bag_index; - int16 slot_id = (int16)SvIV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - bag_index = THIS->CalcBagIdx(slot_id); - XSprePUSH; - PUSHu((UV)bag_index); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetItem); -XS(XS_Inventory_GetItem) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::GetItem(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - EQ::ItemInstance* item; - int16 slot_id = (int16)SvIV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - item = THIS->GetItem(slot_id); - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "QuestItem", (void*)item); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetMaterialFromSlot); -XS(XS_Inventory_GetMaterialFromSlot) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::GetMaterialFromSlot(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - uint8 material; - int16 slot_id = (int16)SvIV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - material = THIS->CalcMaterialFromSlot(slot_id); - XSprePUSH; - PUSHu((UV)material); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetSlotByItemInst); -XS(XS_Inventory_GetSlotByItemInst) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::GetSlotByItemInst(THIS, ItemInstance item)"); - { - EQ::InventoryProfile* THIS; - int slot_id; - EQ::ItemInstance* item = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(1))); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - slot_id = THIS->GetSlotByItemInst(item); - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetSlotFromMaterial); -XS(XS_Inventory_GetSlotFromMaterial) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::GetSlotFromMaterial(THIS, uint8 material)"); - { - EQ::InventoryProfile* THIS; - int16 slot_id; - uint8 material = (uint8)SvUV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - slot_id = THIS->CalcSlotFromMaterial(material); - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_GetSlotID); -XS(XS_Inventory_GetSlotID) { - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Inventory::GetSlotID(THIS, int16 slot_id, [uint8 bag_index])"); - { - EQ::InventoryProfile* THIS; - int16 slot_id = (int16)SvIV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (items == 2) - slot_id = THIS->CalcSlotId(slot_id); - - if (items == 3) { - uint8 bag_index = (uint8)SvUV(ST(2)); - slot_id = THIS->CalcSlotId(slot_id, bag_index); - } - - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_HasItem); -XS(XS_Inventory_HasItem) { - dXSARGS; - if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Inventory::HasItem(THIS, uint32 item_id, [uint8 quantity, uint8 where])"); - { - EQ::InventoryProfile* THIS; - int16 slot_id; - uint32 item_id = (uint32)SvUV(ST(1)); - uint8 quantity = 0; - uint8 where_to_look = 0xFF; - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (items > 2) - quantity = (uint8)SvUV(ST(2)); - if (items > 3) - where_to_look = (uint8)SvUV(ST(3)); - - slot_id = THIS->HasItem(item_id, quantity, where_to_look); - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_HasItemByLoreGroup); -XS(XS_Inventory_HasItemByLoreGroup) { - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Inventory::HasItemByLoreGroup(THIS, uint32 loregroup, [uint8 where])"); - { - EQ::InventoryProfile* THIS; - int16 slot_id; - uint32 loregroup = (uint32)SvUV(ST(1)); - uint8 where_to_look = 0xFF; - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (items > 2) - where_to_look = (uint8)SvUV(ST(2)); - - slot_id = THIS->HasItemByLoreGroup(loregroup, where_to_look); - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_HasItemByUse); -XS(XS_Inventory_HasItemByUse) { - dXSARGS; - if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Inventory::HasItemByUse(THIS, uint8 use, uint8 quantity, [uint8 where])"); - { - EQ::InventoryProfile* THIS; - int16 slot_id; - uint8 item_use = (uint8)SvUV(ST(1)); - uint8 quantity = (uint8)SvUV(ST(2)); - uint8 where_to_look = 0xFF; - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (items > 3) - where_to_look = (uint8)SvUV(ST(3)); - - slot_id = THIS->HasItemByUse(item_use, quantity, where_to_look); - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_HasSpaceForItem); -XS(XS_Inventory_HasSpaceForItem) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Inventory::HasSpaceForItem(THIS, ItemInstance item_to_check, uint8 quantity)"); - { - EQ::InventoryProfile* THIS; - bool has_space = false; - EQ::ItemInstance* item_to_check = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(1))); - uint8 quantity = (uint8)SvUV(ST(2)); - const EQ::ItemData* item_data = item_to_check->GetItem(); - VALIDATE_THIS_IS_INVENTORY; - has_space = THIS->HasSpaceForItem(item_data, quantity); - ST(0) = boolSV(has_space); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_PopItem); -XS(XS_Inventory_PopItem) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::PopItem(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - EQ::ItemInstance* item; - int16 slot_id = (int16)SvIV(ST(1)); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - item = THIS->PopItem(slot_id); - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "QuestItem", (void*)item); - } - XSRETURN(1); -} - -XS(XS_Inventory_SupportsContainers); -XS(XS_Inventory_SupportsContainers) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::SupportsContainers(THIS, int16 slot_id)"); - { - EQ::InventoryProfile* THIS; - bool supports_containers = false; - int16 slot_id = (int16)SvIV(ST(1)); - VALIDATE_THIS_IS_INVENTORY; - supports_containers = THIS->SupportsContainers(slot_id); - ST(0) = boolSV(supports_containers); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_SwapItem); -XS(XS_Inventory_SwapItem) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Inventory::SwapItem(THIS, int16 source_slot_id, int16 destination_slot_id)"); - { - EQ::InventoryProfile* THIS; - bool item_swapped = false; - int16 source_slot_id = (int16)SvIV(ST(1)); - int16 destination_slot_id = (int16)SvIV(ST(2)); - EQ::InventoryProfile::SwapItemFailState fail_state = EQ::InventoryProfile::swapInvalid; - VALIDATE_THIS_IS_INVENTORY; - item_swapped = THIS->SwapItem(source_slot_id, destination_slot_id, fail_state); - ST(0) = boolSV(item_swapped); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Inventory_PushCursor); -XS(XS_Inventory_PushCursor) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Inventory::PushCursor(THIS, ItemInstance item)"); - { - EQ::InventoryProfile* THIS; - int16 slot_id; - EQ::ItemInstance* item = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(1))); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (item) - slot_id = THIS->PushCursor(*item); - else - slot_id = 0; - - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -XS(XS_Inventory_PutItem); -XS(XS_Inventory_PutItem) { - dXSARGS; - if (items != 3) - Perl_croak(aTHX_ "Usage: Inventory::PutItem(THIS, int16 slot_id, ItemInstance item)"); - { - EQ::InventoryProfile* THIS; - int16 slot_id = (int16)SvUV(ST(1)); - EQ::ItemInstance* item = (EQ::ItemInstance*)SvIV((SV*)SvRV(ST(2))); - dXSTARG; - VALIDATE_THIS_IS_INVENTORY; - if (item) - slot_id = THIS->PutItem(slot_id, *item); - else - slot_id = 0; - - XSprePUSH; - PUSHi((IV)slot_id); - } - XSRETURN(1); -} - -#ifdef __cplusplus -extern "C" -#endif - -XS(boot_Inventory); -XS(boot_Inventory) { - dXSARGS; - char file[256]; - strncpy(file, __FILE__, 256); - file[255] = 0; - if (items != 1) - fprintf(stderr, "boot_quest does not take any arguments."); - - char buf[128]; - XS_VERSION_BOOTCHECK; - newXSproto(strcpy(buf, "CanItemFitInContainer"), XS_Inventory_CanItemFitInContainer, file, "$$$"); - newXSproto(strcpy(buf, "CheckNoDrop"), XS_Inventory_CheckNoDrop, file, "$$"); - newXSproto(strcpy(buf, "DeleteItem"), XS_Inventory_DeleteItem, file, "$$;$"); - newXSproto(strcpy(buf, "FindFreeSlot"), XS_Inventory_FindFreeSlot, file, "$$$;$$"); - newXSproto(strcpy(buf, "GetBagIndex"), XS_Inventory_GetBagIndex, file, "$$"); - newXSproto(strcpy(buf, "GetItem"), XS_Inventory_GetItem, file, "$$;$"); - newXSproto(strcpy(buf, "GetMaterialFromSlot"), XS_Inventory_GetMaterialFromSlot, file, "$$"); - newXSproto(strcpy(buf, "GetSlotByItemInst"), XS_Inventory_GetSlotByItemInst, file, "$$"); - newXSproto(strcpy(buf, "GetSlotFromMaterial"), XS_Inventory_GetSlotFromMaterial, file, "$$"); - newXSproto(strcpy(buf, "GetSlotID"), XS_Inventory_GetSlotID, file, "$$;$"); - newXSproto(strcpy(buf, "HasItem"), XS_Inventory_HasItem, file, "$$;$$"); - newXSproto(strcpy(buf, "HasItemByLoreGroup"), XS_Inventory_HasItemByLoreGroup, file, "$$;$"); - newXSproto(strcpy(buf, "HasItemByUse"), XS_Inventory_HasItemByUse, file, "$$;$$"); - newXSproto(strcpy(buf, "HasSpaceForItem"), XS_Inventory_HasSpaceForItem, file, "$$$"); - newXSproto(strcpy(buf, "PopItem"), XS_Inventory_PopItem, file, "$$"); - newXSproto(strcpy(buf, "PushCursor"), XS_Inventory_PushCursor, file, "$$"); - newXSproto(strcpy(buf, "PutItem"), XS_Inventory_PutItem, file, "$$$"); - newXSproto(strcpy(buf, "SupportsContainers"), XS_Inventory_SupportsContainers, file, "$$"); - newXSproto(strcpy(buf, "SwapItem"), XS_Inventory_SwapItem, file, "$$$"); - XSRETURN_YES; -} - -#endif //EMBPERL_XS_CLASSES diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index fb4606d27..f90435887 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -46,28 +46,24 @@ typedef const char Const_char; #undef THIS #endif -#define VALIDATE_THIS_IS_MOB \ - do { \ - if (sv_derived_from(ST(0), "Mob")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Mob*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Mob"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_Mob_IsClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsClient) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsClient(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsClient(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsClient(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -79,11 +75,19 @@ XS(XS_Mob_IsNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsNPC) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsNPC(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsNPC(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsNPC(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -95,11 +99,20 @@ XS(XS_Mob_IsBot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsBot) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsBot(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsBot(THIS)"); { Mob* THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsBot(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -111,11 +124,19 @@ XS(XS_Mob_IsMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsMob) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsMob(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsMob(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMob(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -127,11 +148,19 @@ XS(XS_Mob_IsCorpse); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsCorpse) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsCorpse(THIS)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: Mob::IsCorpse(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsCorpse(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -143,11 +172,19 @@ XS(XS_Mob_IsPlayerCorpse); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsPlayerCorpse) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsPlayerCorpse(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Mob::IsPlayerCorpse(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsPlayerCorpse(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -159,11 +196,19 @@ XS(XS_Mob_IsNPCCorpse); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsNPCCorpse) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsNPCCorpse(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Mob::IsNPCCorpse(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsNPCCorpse(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -175,11 +220,19 @@ XS(XS_Mob_IsObject); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsObject) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsObject(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Mob::IsObject(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsObject(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -191,11 +244,19 @@ XS(XS_Mob_IsDoor); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsDoor) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsDoor(THIS)"); // @categories Script Utility, Doors + Perl_croak(aTHX_ "Usage: Mob::IsDoor(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsDoor(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -207,11 +268,19 @@ XS(XS_Mob_IsTrap); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsTrap) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsTrap(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsTrap(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTrap(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -223,11 +292,19 @@ XS(XS_Mob_IsBeacon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsBeacon) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsBeacon(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsBeacon(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsBeacon(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -239,11 +316,19 @@ XS(XS_Mob_CastToClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastToClient) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CastToClient(THIS)"); // @categories Account and Character, Script Utility + Perl_croak(aTHX_ "Usage: Mob::CastToClient(THIS)"); { Mob *THIS; Client *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CastToClient(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -255,11 +340,19 @@ XS(XS_Mob_CastToNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastToNPC) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CastToNPC(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CastToNPC(THIS)"); { Mob *THIS; NPC *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CastToNPC(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "NPC", (void *) RETVAL); @@ -271,11 +364,19 @@ XS(XS_Mob_CastToMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastToMob) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CastToMob(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CastToMob(THIS)"); { Mob *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CastToMob(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -287,11 +388,19 @@ XS(XS_Mob_CastToCorpse); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastToCorpse) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CastToCorpse(THIS)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: Mob::CastToCorpse(THIS)"); { Mob *THIS; Corpse *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CastToCorpse(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Corpse", (void *) RETVAL); @@ -303,12 +412,20 @@ XS(XS_Mob_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetID(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetID(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -320,12 +437,20 @@ XS(XS_Mob_GetName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetName(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetName(THIS)"); { Mob *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -338,11 +463,19 @@ XS(XS_Mob_Depop); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Depop) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Mob::Depop(THIS, StartSpawnTimer = true)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: Mob::Depop(THIS, StartSpawnTimer = true)"); { Mob *THIS; bool StartSpawnTimer; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) StartSpawnTimer = true; else { @@ -358,11 +491,19 @@ XS(XS_Mob_RogueAssassinate); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RogueAssassinate) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::RogueAssassinate(THIS, other)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::RogueAssassinate(THIS, other)"); { Mob *THIS; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -380,14 +521,22 @@ XS(XS_Mob_BehindMob); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BehindMob) { dXSARGS; if (items < 1 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::BehindMob(THIS, Mob* other = 0, [float x = 0.0f], [float y= 0.0f])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::BehindMob(THIS, Mob* other = 0, [float x = 0.0f], [float y= 0.0f])"); { Mob *THIS; bool RETVAL; Mob *other; float playerx; float playery; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) other = 0; else { @@ -423,12 +572,20 @@ XS(XS_Mob_SetLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetLevel) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::SetLevel(THIS, uint8 in_level, [bool command = false])"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetLevel(THIS, uint8 in_level, [bool command = false])"); { Mob *THIS; uint8 in_level = (uint8) SvUV(ST(1)); bool command; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) command = false; else { @@ -444,13 +601,21 @@ XS(XS_Mob_GetSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetSkill(THIS, int skill_id)"); // @categories Skills and Recipes, Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetSkill(THIS, int skill_id)"); { Mob *THIS; uint32 RETVAL; dXSTARG; EQ::skills::SkillType skill_num = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSkill(skill_num); XSprePUSH; PUSHu((UV) RETVAL); @@ -462,11 +627,19 @@ XS(XS_Mob_SendWearChange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SendWearChange) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SendWearChange(THIS, uint8 material_slot)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SendWearChange(THIS, uint8 material_slot)"); { Mob *THIS; uint8 material_slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendWearChange(material_slot); } XSRETURN_EMPTY; @@ -476,13 +649,21 @@ XS(XS_Mob_GetEquipment); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEquipment) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetEquipment(THIS, uint8 material_slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Mob::GetEquipment(THIS, uint8 material_slot)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint8 material_slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEquippedItemFromTextureSlot(material_slot); XSprePUSH; PUSHi((IV) RETVAL); @@ -494,13 +675,21 @@ XS(XS_Mob_GetEquipmentMaterial); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEquipmentMaterial) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetEquipmentMaterial(THIS, uint8 material_slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Mob::GetEquipmentMaterial(THIS, uint8 material_slot)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint8 material_slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEquipmentMaterial(material_slot); XSprePUSH; PUSHi((IV) RETVAL); @@ -512,13 +701,21 @@ XS(XS_Mob_GetEquipmentColor); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEquipmentColor) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetEquipmentColor(THIS, uint8 material_slot)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: Mob::GetEquipmentColor(THIS, uint8 material_slot)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint8 material_slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEquipmentColor(material_slot); XSprePUSH; PUSHi((IV) RETVAL); @@ -530,13 +727,21 @@ XS(XS_Mob_GetArmorTint); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetArmorTint) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetArmorTint(THIS, uint8 material_slot)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetArmorTint(THIS, uint8 material_slot)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint8 material_slot = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetArmorTint(material_slot); XSprePUSH; PUSHi((IV) RETVAL); @@ -548,11 +753,19 @@ XS(XS_Mob_IsMoving); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsMoving) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsMoving(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsMoving(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMoving(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -564,10 +777,18 @@ XS(XS_Mob_GoToBind); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GoToBind) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GoToBind(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GoToBind(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->GoToBind(); } XSRETURN_EMPTY; @@ -577,10 +798,18 @@ XS(XS_Mob_Gate); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Gate) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Gate(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::Gate(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Gate(); } XSRETURN_EMPTY; @@ -590,14 +819,22 @@ XS(XS_Mob_Attack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Attack) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::Attack(THIS, Mob* other, [int hand = 13 [prim|sec]], [bool from_riposte = false])"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::Attack(THIS, Mob* other, [int hand = 13 [prim|sec]], [bool from_riposte = false])"); { Mob *THIS; bool RETVAL; Mob *other; int Hand; bool FromRiposte; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -629,7 +866,7 @@ XS(XS_Mob_Damage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Damage) { dXSARGS; if (items < 5 || items > 8) - Perl_croak(aTHX_ "Usage: Mob::Damage(THIS, Mob* from, int32 damage, uint16 spell_id, int attack_skill, [bool avoidable = true], [int8 buffslot = -1], [bool buff_tic = false])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Damage(THIS, Mob* from, int32 damage, uint16 spell_id, int attack_skill, [bool avoidable = true], [int8 buffslot = -1], [bool buff_tic = false])"); { Mob *THIS; Mob *from; @@ -639,7 +876,15 @@ XS(XS_Mob_Damage) { bool avoidable; int8 buffslot; bool iBuffTic; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); from = INT2PTR(Mob *, tmp); @@ -675,11 +920,19 @@ XS(XS_Mob_RangedAttack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RangedAttack) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::RangedAttack(THIS, Mob* other)"); // @categories Skills and Recipes, Script Utility + Perl_croak(aTHX_ "Usage: Mob::RangedAttack(THIS, Mob* other)"); { Mob *THIS; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -697,11 +950,19 @@ XS(XS_Mob_ThrowingAttack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ThrowingAttack) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::ThrowingAttack(THIS, Mob* other)"); // @categories Skills and Recipes, Script Utility + Perl_croak(aTHX_ "Usage: Mob::ThrowingAttack(THIS, Mob* other)"); { Mob *THIS; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -719,10 +980,18 @@ XS(XS_Mob_Heal); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Heal) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Heal(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Heal(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Heal(); } XSRETURN_EMPTY; @@ -733,12 +1002,20 @@ XS(XS_Mob_HealDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_HealDamage) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::HealDamage(THIS, int32 amount, [Mob* caster = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::HealDamage(THIS, int32 amount, [Mob* caster = 0])"); { Mob *THIS; int32 heal_amt = (int32) SvIV(ST(1)); Mob *caster = nullptr; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 3) { if (sv_derived_from(ST(2), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(2))); @@ -758,10 +1035,18 @@ XS(XS_Mob_SetMaxHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetMaxHP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::SetMaxHP(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetMaxHP(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetMaxHP(); } XSRETURN_EMPTY; @@ -771,13 +1056,21 @@ XS(XS_Mob_GetLevelCon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetLevelCon) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetLevelCon(THIS, uint8 other_level)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetLevelCon(THIS, uint8 other_level)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint8 iOtherLevel = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLevelCon(iOtherLevel); XSprePUSH; PUSHu((UV) RETVAL); @@ -789,11 +1082,19 @@ XS(XS_Mob_SetHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetHP) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetHP(THIS, int32 hp)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetHP(THIS, int32 hp)"); { Mob *THIS; int32 hp = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetHP(hp); } XSRETURN_EMPTY; @@ -803,12 +1104,20 @@ XS(XS_Mob_DoAnim); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoAnim) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::DoAnim(THIS, int animation_number, [int type = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DoAnim(THIS, int animation_number, [int type = 0])"); { Mob *THIS; int animnum = (int) SvIV(ST(1)); int type; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) type = 0; else { @@ -824,12 +1133,20 @@ XS(XS_Mob_ChangeSize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ChangeSize) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::ChangeSize(THIS, float in_size, [bool no_restriction = false])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::ChangeSize(THIS, float in_size, [bool no_restriction = false])"); { Mob *THIS; float in_size = (float) SvNV(ST(1)); bool bNoRestriction; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) bNoRestriction = false; else { @@ -843,31 +1160,47 @@ XS(XS_Mob_ChangeSize) { XS(XS_Mob_RandomizeFeatures); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RandomizeFeatures) { - dXSARGS; - if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::RandomizeFeatures(THIS, bool send_illusion, set_variables)"); // @categories Script Utility - { - Mob *THIS; - bool send_illusion = (bool) SvNV(ST(1)); - bool set_variables = (bool) SvNV(ST(2)); - VALIDATE_THIS_IS_MOB; - THIS->RandomizeFeatures(send_illusion, set_variables); - } - XSRETURN_EMPTY; + dXSARGS; + if (items < 2 || items > 3) + Perl_croak(aTHX_ "Usage: Mob::RandomizeFeatures(THIS, bool send_illusion, set_variables)"); + { + Mob *THIS; + bool send_illusion = (bool) SvNV(ST(1)); + bool set_variables = (bool) SvNV(ST(2)); + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->RandomizeFeatures(send_illusion, set_variables); + } + XSRETURN_EMPTY; } XS(XS_Mob_GMMove); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GMMove) { dXSARGS; if (items < 4 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::GMMove(THIS, float x, float y, float z, [float heading = 0.01])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GMMove(THIS, float x, float y, float z, [float heading = 0.01])"); { Mob *THIS; float x = (float) SvNV(ST(1)); float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); float heading; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 5) heading = 0.01; else { @@ -883,11 +1216,19 @@ XS(XS_Mob_HasProcs); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_HasProcs) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasProcs(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::HasProcs(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasProcs(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -899,12 +1240,20 @@ XS(XS_Mob_IsInvisible); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsInvisible) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Mob::IsInvisible(THIS, [Mob* other = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsInvisible(THIS, [Mob* other = 0])"); { Mob *THIS; bool RETVAL; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) other = 0; else { @@ -928,11 +1277,19 @@ XS(XS_Mob_SetInvisible); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetInvisible) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetInvisible(THIS, uint8 state)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetInvisible(THIS, uint8 state)"); { Mob *THIS; uint8 state = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetInvisible(state); } XSRETURN_EMPTY; @@ -942,12 +1299,20 @@ XS(XS_Mob_FindBuff); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_FindBuff) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::FindBuff(THIS, uint16 spell_id)"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Mob::FindBuff(THIS, uint16 spell_id)"); { Mob *THIS; bool RETVAL; uint16 spellid = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->FindBuff(spellid); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -959,13 +1324,21 @@ XS(XS_Mob_FindBuffBySlot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_FindBuffBySlot) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::FindBuffBySlot(THIS, int slot)"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Mob::FindBuffBySlot(THIS, int slot)"); { Mob *THIS; uint16 RETVAL; dXSTARG; int slot = SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->FindBuffBySlot(slot); XSprePUSH; PUSHu((UV) RETVAL); @@ -977,12 +1350,20 @@ XS(XS_Mob_BuffCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BuffCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::BuffCount(THIS)"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::BuffCount(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->BuffCount(); XSprePUSH; PUSHu((UV) RETVAL); @@ -994,14 +1375,22 @@ XS(XS_Mob_FindType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_FindType) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::FindType(THIS, uint8 type, [bool offensive = false], [uint16 threshold = 100])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::FindType(THIS, uint8 type, [bool offensive = false], [uint16 threshold = 100])"); { Mob *THIS; bool RETVAL; uint8 type = (uint8) SvUV(ST(1)); bool bOffensive; uint16 threshold; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) bOffensive = false; else { @@ -1025,13 +1414,21 @@ XS(XS_Mob_GetBuffSlotFromType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBuffSlotFromType) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetBuffSlotFromType(THIS, uint16 type)"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetBuffSlotFromType(THIS, uint16 type)"); { Mob *THIS; int8 RETVAL; dXSTARG; uint16 type = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBuffSlotFromType(type); XSprePUSH; PUSHi((IV) RETVAL); @@ -1043,13 +1440,21 @@ XS(XS_Mob_MakePet); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_MakePet) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::MakePet(THIS, uint16 spell_id, string pet_type, [string name = nullptr])"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::MakePet(THIS, uint16 spell_id, string pet_type, [string name = nullptr])"); { Mob *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); char *pettype = (char *) SvPV_nolen(ST(2)); char *name; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) name = nullptr; else { @@ -1065,7 +1470,7 @@ XS(XS_Mob_MakeTempPet); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_MakeTempPet) { dXSARGS; if (items < 2 || items > 6) - Perl_croak(aTHX_ "Usage: Mob::MakeTempPet(THIS, uint16 spell_id, [string name = nullptr], [uint32 duration = 0], [Mob* target = nullptr], [bool sticktarg = 0])"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::MakeTempPet(THIS, uint16 spell_id, [string name = nullptr], [uint32 duration = 0], [Mob* target = nullptr], [bool sticktarg = 0])"); { Mob *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); @@ -1073,7 +1478,15 @@ XS(XS_Mob_MakeTempPet) { uint32 duration; Mob *target; bool sticktarg; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) name = nullptr; else @@ -1107,7 +1520,7 @@ XS(XS_Mob_TypesTempPet); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_TypesTempPet) { dXSARGS; if (items < 2 || items > 7) - Perl_croak(aTHX_ "Usage: Mob::TypesTempPet(THIS, uint32 type_id, [string name = nullptr], [uint32 duration = 0], [bool follow = 0], [Mob* target = nullptr], [bool stick_targ = 0])"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::TypesTempPet(THIS, uint32 type_id, [string name = nullptr], [uint32 duration = 0], [bool follow = 0], [Mob* target = nullptr], [bool stick_targ = 0])"); { Mob *THIS; uint32 typesid = (uint32) SvUV(ST(1)); @@ -1116,7 +1529,15 @@ XS(XS_Mob_TypesTempPet) { bool follow; Mob *target; bool sticktarg; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) name = nullptr; else @@ -1157,12 +1578,20 @@ XS(XS_Mob_GetBaseRace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBaseRace) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBaseRace(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBaseRace(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseRace(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1174,12 +1603,20 @@ XS(XS_Mob_GetBaseGender); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBaseGender) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBaseGender(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBaseGender(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseGender(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1191,12 +1628,20 @@ XS(XS_Mob_GetDeity); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDeity) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDeity(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDeity(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDeity(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1208,12 +1653,20 @@ XS(XS_Mob_GetRace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetRace) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetRace(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetRace(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRace(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1225,12 +1678,20 @@ XS(XS_Mob_GetGender); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetGender) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetGender(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetGender(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGender(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1242,12 +1703,20 @@ XS(XS_Mob_GetTexture); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetTexture) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetTexture(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetTexture(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTexture(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1259,12 +1728,20 @@ XS(XS_Mob_GetHelmTexture); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHelmTexture) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHelmTexture(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHelmTexture(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHelmTexture(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1276,12 +1753,20 @@ XS(XS_Mob_GetHairColor); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHairColor) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHairColor(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHairColor(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHairColor(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1293,12 +1778,20 @@ XS(XS_Mob_GetBeardColor); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBeardColor) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBeardColor(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBeardColor(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBeardColor(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1310,12 +1803,20 @@ XS(XS_Mob_GetEyeColor1); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEyeColor1) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetEyeColor1(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetEyeColor1(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEyeColor1(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1327,12 +1828,20 @@ XS(XS_Mob_GetEyeColor2); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEyeColor2) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetEyeColor2(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetEyeColor2(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEyeColor2(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1344,12 +1853,20 @@ XS(XS_Mob_GetHairStyle); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHairStyle) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHairStyle(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHairStyle(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHairStyle(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1361,12 +1878,20 @@ XS(XS_Mob_GetLuclinFace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetLuclinFace) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetLuclinFace(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetLuclinFace(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLuclinFace(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1378,12 +1903,20 @@ XS(XS_Mob_GetBeard); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBeard) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBeard(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBeard(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBeard(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1395,12 +1928,20 @@ XS(XS_Mob_GetDrakkinHeritage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDrakkinHeritage) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDrakkinHeritage(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDrakkinHeritage(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDrakkinHeritage(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1412,12 +1953,20 @@ XS(XS_Mob_GetDrakkinTattoo); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDrakkinTattoo) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDrakkinTattoo(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDrakkinTattoo(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDrakkinTattoo(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1429,12 +1978,20 @@ XS(XS_Mob_GetDrakkinDetails); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDrakkinDetails) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDrakkinDetails(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDrakkinDetails(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDrakkinDetails(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1446,12 +2003,20 @@ XS(XS_Mob_GetClass); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetClass) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetClass(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetClass(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClass(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1463,12 +2028,20 @@ XS(XS_Mob_GetLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetLevel) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetLevel(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetLevel(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLevel(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1480,12 +2053,20 @@ XS(XS_Mob_GetCleanName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetCleanName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetCleanName(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetCleanName(THIS)"); { Mob *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCleanName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -1498,11 +2079,19 @@ XS(XS_Mob_GetTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetTarget) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetTarget(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetTarget(THIS)"); { Mob *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTarget(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -1514,11 +2103,19 @@ XS(XS_Mob_SetTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetTarget) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetTarget(THIS, mob)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetTarget(THIS, mob)"); { Mob *THIS; Mob *mob; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -1536,12 +2133,20 @@ XS(XS_Mob_GetHPRatio); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHPRatio) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHPRatio(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHPRatio(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHPRatio(); XSprePUSH; PUSHn((double) RETVAL); @@ -1553,11 +2158,19 @@ XS(XS_Mob_IsWarriorClass); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsWarriorClass) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsWarriorClass(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsWarriorClass(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsWarriorClass(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1569,12 +2182,20 @@ XS(XS_Mob_GetHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHP(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHP(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHP(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1586,12 +2207,20 @@ XS(XS_Mob_GetMaxHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxHP) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxHP(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxHP(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxHP(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1603,12 +2232,20 @@ XS(XS_Mob_GetItemHPBonuses); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetItemHPBonuses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetItemHPBonuses(THIS)"); // @categories Inventory and Items, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetItemHPBonuses(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItemHPBonuses(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1620,12 +2257,20 @@ XS(XS_Mob_GetSpellHPBonuses); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpellHPBonuses) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetSpellHPBonuses(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetSpellHPBonuses(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpellHPBonuses(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1637,13 +2282,21 @@ XS(XS_Mob_GetSpellIDFromSlot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpellIDFromSlot) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetSpellIDFromSlot(THIS, slot)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetSpellIDFromSlot(THIS, slot)"); { Mob *THIS; int RETVAL; dXSTARG; uint8 slot = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (slot > THIS->GetMaxBuffSlots()) RETVAL = -1; else @@ -1659,12 +2312,20 @@ XS(XS_Mob_GetWalkspeed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWalkspeed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWalkspeed(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetWalkspeed(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetWalkspeed(); XSprePUSH; PUSHn((double) RETVAL); @@ -1676,12 +2337,20 @@ XS(XS_Mob_GetRunspeed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetRunspeed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetRunspeed(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetRunspeed(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRunspeed(); XSprePUSH; PUSHn((double) RETVAL); @@ -1693,13 +2362,21 @@ XS(XS_Mob_GetCasterLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetCasterLevel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetCasterLevel(THIS, spell_id)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetCasterLevel(THIS, spell_id)"); { Mob *THIS; int RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCasterLevel(spell_id); XSprePUSH; PUSHi((IV) RETVAL); @@ -1711,12 +2388,20 @@ XS(XS_Mob_GetMaxMana); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxMana) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxMana(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxMana(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxMana(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1728,12 +2413,20 @@ XS(XS_Mob_GetMana); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMana) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMana(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMana(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMana(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1745,11 +2438,19 @@ XS(XS_Mob_SetMana); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetMana) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetMana(THIS, amount)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetMana(THIS, amount)"); { Mob *THIS; int32 amount = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetMana(amount); } XSRETURN_EMPTY; @@ -1759,12 +2460,20 @@ XS(XS_Mob_GetManaRatio); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetManaRatio) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetManaRatio(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetManaRatio(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetManaRatio(); XSprePUSH; PUSHn((double) RETVAL); @@ -1776,12 +2485,20 @@ XS(XS_Mob_GetAC); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAC) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAC(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetAC(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAC(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1798,7 +2515,15 @@ XS(XS_Mob_GetDisplayAC) { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDisplayAC(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1810,12 +2535,20 @@ XS(XS_Mob_GetATK); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetATK) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetATK(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetATK(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetATK(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1827,12 +2560,20 @@ XS(XS_Mob_GetSTR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSTR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetSTR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetSTR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSTR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1844,12 +2585,20 @@ XS(XS_Mob_GetSTA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSTA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetSTA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetSTA(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSTA(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1861,12 +2610,20 @@ XS(XS_Mob_GetDEX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDEX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDEX(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDEX(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDEX(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1878,12 +2635,20 @@ XS(XS_Mob_GetAGI); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAGI) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAGI(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetAGI(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAGI(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1895,12 +2660,20 @@ XS(XS_Mob_GetINT); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetINT) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetINT(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetINT(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetINT(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1912,12 +2685,20 @@ XS(XS_Mob_GetWIS); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWIS) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWIS(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetWIS(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetWIS(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1929,12 +2710,20 @@ XS(XS_Mob_GetCHA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetCHA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetCHA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetCHA(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCHA(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1946,12 +2735,20 @@ XS(XS_Mob_GetMR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1963,12 +2760,20 @@ XS(XS_Mob_GetFR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetFR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetFR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetFR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1980,12 +2785,20 @@ XS(XS_Mob_GetDR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetDR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -1997,12 +2810,20 @@ XS(XS_Mob_GetPR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetPR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetPR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetPR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2014,12 +2835,20 @@ XS(XS_Mob_GetCR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetCR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetCR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetCR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2031,12 +2860,20 @@ XS(XS_Mob_GetCorruption); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetCorruption) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetCorruption(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetCorruption(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorrup(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2048,12 +2885,20 @@ XS(XS_Mob_GetPhR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetPhR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetPhR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetPhR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPhR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2065,12 +2910,20 @@ XS(XS_Mob_GetMaxSTR); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxSTR) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxSTR(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxSTR(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxSTR(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2082,12 +2935,20 @@ XS(XS_Mob_GetMaxSTA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxSTA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxSTA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxSTA(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxSTA(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2099,12 +2960,20 @@ XS(XS_Mob_GetMaxDEX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxDEX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxDEX(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxDEX(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxDEX(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2116,12 +2985,20 @@ XS(XS_Mob_GetMaxAGI); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxAGI) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxAGI(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxAGI(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxAGI(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2133,12 +3010,20 @@ XS(XS_Mob_GetMaxINT); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxINT) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxINT(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxINT(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxINT(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2150,12 +3035,20 @@ XS(XS_Mob_GetMaxWIS); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxWIS) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxWIS(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxWIS(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxWIS(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2167,12 +3060,20 @@ XS(XS_Mob_GetMaxCHA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetMaxCHA) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMaxCHA(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMaxCHA(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxCHA(); XSprePUSH; PUSHi((IV) RETVAL); @@ -2184,14 +3085,22 @@ XS(XS_Mob_GetActSpellRange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellRange) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellRange(THIS, uint16 spell_id, float range)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellRange(THIS, uint16 spell_id, float range)"); { Mob *THIS; float RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); float range = (float) SvNV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellRange(spell_id, range); XSprePUSH; PUSHn((double) RETVAL); @@ -2203,14 +3112,22 @@ XS(XS_Mob_GetActSpellDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellDamage) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellDamage(THIS, uint16 spell_id, int32 value)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellDamage(THIS, uint16 spell_id, int32 value)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); int32 value = (int32) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellDamage(spell_id, value); XSprePUSH; PUSHi((IV) RETVAL); @@ -2222,14 +3139,22 @@ XS(XS_Mob_GetActSpellHealing); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellHealing) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellHealing(THIS, uint16 spell_id, int32 value)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellHealing(THIS, uint16 spell_id, int32 value)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); int32 value = (int32) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellHealing(spell_id, value); XSprePUSH; PUSHi((IV) RETVAL); @@ -2241,14 +3166,22 @@ XS(XS_Mob_GetActSpellCost); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellCost) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellCost(THIS, uint16 spell_id, int32 cost)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellCost(THIS, uint16 spell_id, int32 cost)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); int32 cost = (int32) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellCost(spell_id, cost); XSprePUSH; PUSHi((IV) RETVAL); @@ -2260,14 +3193,22 @@ XS(XS_Mob_GetActSpellDuration); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellDuration) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellDuration(THIS, uint16 spell_id, int32 duration)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellDuration(THIS, uint16 spell_id, int32 duration)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); int32 duration = (int32) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellDuration(spell_id, duration); XSprePUSH; PUSHi((IV) RETVAL); @@ -2279,14 +3220,22 @@ XS(XS_Mob_GetActSpellCasttime); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetActSpellCasttime) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetActSpellCasttime(THIS, uint16 spell_id, uint32 cast_time)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetActSpellCasttime(THIS, uint16 spell_id, uint32 cast_time)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); int32 casttime = (int32) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetActSpellCasttime(spell_id, casttime); XSprePUSH; PUSHi((IV) RETVAL); @@ -2298,7 +3247,7 @@ XS(XS_Mob_ResistSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ResistSpell) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::ResistSpell(THIS, uint8 resist_type, uint16 spell_id, [Mob* caster = nullptr])"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Mob::ResistSpell(THIS, uint8 resist_type, uint16 spell_id, [Mob* caster = nullptr])"); { Mob *THIS; double RETVAL; @@ -2306,7 +3255,15 @@ XS(XS_Mob_ResistSpell) { uint8 ressit_type = (uint8) SvUV(ST(1)); uint16 spell_id = (uint16) SvUV(ST(2)); Mob *caster; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(3), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(3))); caster = INT2PTR(Mob *, tmp); @@ -2326,13 +3283,21 @@ XS(XS_Mob_GetSpecializeSkillValue); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpecializeSkillValue) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetSpecializeSkillValue(THIS, uint16 spell_id)"); // @categories Skills and Recipes, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetSpecializeSkillValue(THIS, uint16 spell_id)"); { Mob *THIS; uint16 RETVAL; dXSTARG; uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpecializeSkillValue(spell_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -2344,12 +3309,20 @@ XS(XS_Mob_GetNPCTypeID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetNPCTypeID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetNPCTypeID(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetNPCTypeID(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNPCTypeID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2361,11 +3334,19 @@ XS(XS_Mob_IsTargeted); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsTargeted) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsTargeted(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsTargeted(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTargeted(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2377,12 +3358,20 @@ XS(XS_Mob_GetX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetX(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetX(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetX(); XSprePUSH; PUSHn((double) RETVAL); @@ -2394,12 +3383,20 @@ XS(XS_Mob_GetY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetY(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetY(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetY(); XSprePUSH; PUSHn((double) RETVAL); @@ -2411,12 +3408,20 @@ XS(XS_Mob_GetZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetZ(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetZ(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetZ(); XSprePUSH; PUSHn((double) RETVAL); @@ -2428,12 +3433,20 @@ XS(XS_Mob_GetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHeading) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHeading(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetHeading(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHeading(); XSprePUSH; PUSHn((double) RETVAL); @@ -2446,12 +3459,20 @@ XS(XS_Mob_GetWaypointX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointX(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointX(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCurrentWayPoint().x; XSprePUSH; PUSHn((double) RETVAL); @@ -2463,12 +3484,20 @@ XS(XS_Mob_GetWaypointY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointY(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointY(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCurrentWayPoint().y; XSprePUSH; PUSHn((double) RETVAL); @@ -2480,12 +3509,20 @@ XS(XS_Mob_GetWaypointZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointZ(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointZ(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCurrentWayPoint().z; XSprePUSH; PUSHn((double) RETVAL); @@ -2497,12 +3534,20 @@ XS(XS_Mob_GetWaypointH); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointH) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointH(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointH(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCurrentWayPoint().w; XSprePUSH; PUSHn((double) RETVAL); @@ -2514,12 +3559,20 @@ XS(XS_Mob_GetWaypointPause); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointPause) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointPause(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointPause(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCWPP(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2531,12 +3584,20 @@ XS(XS_Mob_GetWaypointID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetWaypointID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetWaypointID(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetWaypointID(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCWP(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2548,11 +3609,19 @@ XS(XS_Mob_SetCurrentWP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetCurrentWP) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetCurrentWP(THIS, waypoint)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetCurrentWP(THIS, waypoint)"); { Mob *THIS; uint16 waypoint = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetCurrentWP(waypoint); } XSRETURN_EMPTY; @@ -2562,12 +3631,20 @@ XS(XS_Mob_GetSize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSize) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetSize(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetSize(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSize(); XSprePUSH; PUSHn((double) RETVAL); @@ -2579,11 +3656,19 @@ XS(XS_Mob_SetFollowID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetFollowID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetFollowID(THIS, id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetFollowID(THIS, id)"); { Mob *THIS; uint32 id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFollowID(id); } XSRETURN_EMPTY; @@ -2593,12 +3678,20 @@ XS(XS_Mob_GetFollowID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetFollowID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetFollowID(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetFollowID(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFollowID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2610,12 +3703,20 @@ XS(XS_Mob_Message); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Message) { dXSARGS; if (items < 3) - Perl_croak(aTHX_ "Usage: Mob::Message(THIS, uint32 emote_color_type, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Message(THIS, uint32 emote_color_type, string message)"); { Mob *THIS; uint32 type = (uint32) SvUV(ST(1)); char *message = (char *) SvPV_nolen(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Message(type, message); } XSRETURN_EMPTY; @@ -2625,13 +3726,21 @@ XS(XS_Mob_Message_StringID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Message_StringID) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::Message_StringID(THIS, uint32 emote_color_type, uint32 string_id, [uint32 distance = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Message_StringID(THIS, uint32 emote_color_type, uint32 string_id, [uint32 distance = 0])"); { Mob *THIS; uint32 type = (uint32) SvUV(ST(1)); uint32 string_id = (uint32) SvUV(ST(2)); uint32 distance; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) distance = 0; else { @@ -2647,11 +3756,19 @@ XS(XS_Mob_Say); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Say) { dXSARGS; if (items < 2) - Perl_croak(aTHX_ "Usage: Mob::Say(THIS, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Say(THIS, string message)"); { Mob *THIS; char *format = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Say(format); } XSRETURN_EMPTY; @@ -2661,11 +3778,19 @@ XS(XS_Mob_Shout); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Shout) { dXSARGS; if (items < 2) - Perl_croak(aTHX_ "Usage: Mob::Shout(THIS, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Shout(THIS, string message)"); { Mob *THIS; char *format = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Shout(format); } XSRETURN_EMPTY; @@ -2675,11 +3800,19 @@ XS(XS_Mob_Emote); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Emote) { dXSARGS; if (items < 2) - Perl_croak(aTHX_ "Usage: Mob::Emote(THIS, string message)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Emote(THIS, string message)"); { Mob *THIS; char *format = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Emote(format); } XSRETURN_EMPTY; @@ -2689,11 +3822,19 @@ XS(XS_Mob_InterruptSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_InterruptSpell) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Mob::InterruptSpell(THIS, [uint16 spell_id = 0xFFFF])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::InterruptSpell(THIS, [uint16 spell_id = 0xFFFF])"); { Mob *THIS; uint16 spellid; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) spellid = 0xFFFF; else { @@ -2709,7 +3850,7 @@ XS(XS_Mob_CastSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastSpell) { dXSARGS; if (items < 3 || items > 7) - Perl_croak(aTHX_ "Usage: Mob::CastSpell(THIS, uint16 spell_id, uint16 target_id, [int slot = 22], [int32 cast_time = -1], [int32 mana_cost = -1], [int16 resist_adjust = 0])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::CastSpell(THIS, uint16 spell_id, uint16 target_id, [int slot = 22], [int32 cast_time = -1], [int32 mana_cost = -1], [int16 resist_adjust = 0])"); { Mob *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); @@ -2718,7 +3859,15 @@ XS(XS_Mob_CastSpell) { int32 casttime; int32 mana_cost; int16 resist_adjust; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) slot = EQ::spells::CastingSlot::Item; else { @@ -2757,14 +3906,22 @@ XS(XS_Mob_SpellFinished); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SpellFinished) { dXSARGS; if (items < 2 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::SpellFinished(uint16 spell_id, [Mob* spell_target = this], [uint16 mana_cost = 0], [uint16 resist_diff = 0])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::SpellFinished(uint16 spell_id, [Mob* spell_target = this], [uint16 mana_cost = 0], [uint16 resist_diff = 0])"); { Mob *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); Mob *spell_target; uint16 mana_cost = 0; int16 resist_diff; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + spell_target = THIS; if (items > 2) { @@ -2796,13 +3953,21 @@ XS(XS_Mob_IsImmuneToSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsImmuneToSpell) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::IsImmuneToSpell(THIS, uint16 spell_id, [Mob* caster = nullptr])"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsImmuneToSpell(THIS, uint16 spell_id, [Mob* caster = nullptr])"); { Mob *THIS; bool RETVAL; uint16 spell_id = (uint16) SvUV(ST(1)); Mob *caster; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(2), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(2))); caster = INT2PTR(Mob *, tmp); @@ -2822,11 +3987,19 @@ XS(XS_Mob_BuffFadeBySpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BuffFadeBySpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::BuffFadeBySpellID(THIS, uint16 spell_id)"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::BuffFadeBySpellID(THIS, uint16 spell_id)"); { Mob *THIS; uint16 spell_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->BuffFadeBySpellID(spell_id); } XSRETURN_EMPTY; @@ -2836,12 +4009,20 @@ XS(XS_Mob_BuffFadeByEffect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BuffFadeByEffect) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::BuffFadeByEffect(THIS, int effect_id, int skip_slot = -1)"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::BuffFadeByEffect(THIS, int effect_id, int skip_slot = -1)"); { Mob *THIS; int effectid = (int) SvIV(ST(1)); int skipslot; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) skipslot = -1; else { @@ -2857,10 +4038,18 @@ XS(XS_Mob_BuffFadeAll); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BuffFadeAll) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::BuffFadeAll(THIS)"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::BuffFadeAll(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->BuffFadeAll(); } XSRETURN_EMPTY; @@ -2870,12 +4059,20 @@ XS(XS_Mob_BuffFadeBySlot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_BuffFadeBySlot) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::BuffFadeBySlot(THIS, int slot, bool recalc_bonuses = true)"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::BuffFadeBySlot(THIS, int slot, bool recalc_bonuses = true)"); { Mob *THIS; int slot = (int) SvIV(ST(1)); bool iRecalcBonuses; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) iRecalcBonuses = true; else { @@ -2891,7 +4088,7 @@ XS(XS_Mob_CanBuffStack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanBuffStack) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::CanBuffStack(THIS, uint16 spell_id, uint8 caster_level, [bool fail_if_overwritten = false])"); // @categories Script Utility, Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::CanBuffStack(THIS, uint16 spell_id, uint8 caster_level, [bool fail_if_overwritten = false])"); { Mob *THIS; int RETVAL; @@ -2899,7 +4096,15 @@ XS(XS_Mob_CanBuffStack) { uint16 spellid = (uint16) SvUV(ST(1)); uint8 caster_level = (uint8) SvUV(ST(2)); bool iFailIfOverwrite; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) iFailIfOverwrite = false; else { @@ -2917,11 +4122,19 @@ XS(XS_Mob_IsCasting); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsCasting) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsCasting(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsCasting(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsCasting(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -2933,12 +4146,20 @@ XS(XS_Mob_CastingSpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CastingSpellID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CastingSpellID(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::CastingSpellID(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CastingSpellID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2950,12 +4171,20 @@ XS(XS_Mob_SetAppearance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetAppearance) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::SetAppearance(THIS, int appearance [0|1|2|3|4], [ignore_self = true])"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetAppearance(THIS, int appearance [0|1|2|3|4], [ignore_self = true])"); { Mob *THIS; EmuAppearance app = (EmuAppearance) SvUV(ST(1)); bool iIgnoreSelf; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) iIgnoreSelf = true; else { @@ -2971,12 +4200,20 @@ XS(XS_Mob_GetAppearance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAppearance) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAppearance(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetAppearance(THIS)"); { Mob *THIS; EmuAppearance RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAppearance(); XSprePUSH; PUSHu((UV) RETVAL); @@ -2988,12 +4225,20 @@ XS(XS_Mob_GetRunAnimSpeed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetRunAnimSpeed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetRunAnimSpeed(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetRunAnimSpeed(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetRunAnimSpeed(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3005,11 +4250,19 @@ XS(XS_Mob_SetRunAnimSpeed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetRunAnimSpeed) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetRunAnimSpeed(THIS, int8 speed)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetRunAnimSpeed(THIS, int8 speed)"); { Mob *THIS; int8 in = (int8) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetRunAnimSpeed(in); } XSRETURN_EMPTY; @@ -3019,11 +4272,19 @@ XS(XS_Mob_SetPetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetPetID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetPetID(THIS, uint16 new_pet_id)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::SetPetID(THIS, uint16 new_pet_id)"); { Mob *THIS; uint16 NewPetID = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPetID(NewPetID); } XSRETURN_EMPTY; @@ -3033,12 +4294,20 @@ XS(XS_Mob_GetPetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetPetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetPetID(THIS)"); // @categories Script Utility, Pet + Perl_croak(aTHX_ "Usage: Mob::GetPetID(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPetID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3050,11 +4319,19 @@ XS(XS_Mob_SetOwnerID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetOwnerID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetOwnerID(THIS, uint16 new_owner_id)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::SetOwnerID(THIS, uint16 new_owner_id)"); { Mob *THIS; uint16 NewOwnerID = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetOwnerID(NewOwnerID); } XSRETURN_EMPTY; @@ -3064,12 +4341,20 @@ XS(XS_Mob_GetOwnerID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetOwnerID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetOwnerID(THIS)"); // @categories Script Utility, Pet + Perl_croak(aTHX_ "Usage: Mob::GetOwnerID(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetOwnerID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3081,12 +4366,20 @@ XS(XS_Mob_GetPetType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetPetType) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetPetType(THIS)"); // @categories Script Utility, Pet + Perl_croak(aTHX_ "Usage: Mob::GetPetType(THIS)"); { Mob *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPetType(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3098,12 +4391,20 @@ XS(XS_Mob_GetBodyType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetBodyType) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBodyType(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBodyType(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBodyType(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3119,7 +4420,15 @@ XS(XS_Mob_Stun) { { Mob *THIS; int duration = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Stun(duration); } XSRETURN_EMPTY; @@ -3129,10 +4438,18 @@ XS(XS_Mob_Spin); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Spin) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Spin(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Spin(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Spin(); } XSRETURN_EMPTY; @@ -3142,10 +4459,18 @@ XS(XS_Mob_Kill); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Kill) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Kill(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Kill(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Kill(); } XSRETURN_EMPTY; @@ -3155,11 +4480,19 @@ XS(XS_Mob_SetInvul); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetInvul) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetInvul(THIS, bool set_invulnerable)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetInvul(THIS, bool set_invulnerable)"); { Mob *THIS; bool invul = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetInvul(invul); } XSRETURN_EMPTY; @@ -3169,11 +4502,19 @@ XS(XS_Mob_GetInvul); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetInvul) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetInvul(THIS)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetInvul(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetInvul(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3185,11 +4526,19 @@ XS(XS_Mob_SetExtraHaste); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetExtraHaste) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetExtraHaste(THIS, int haste)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetExtraHaste(THIS, int haste)"); { Mob *THIS; int Haste = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetExtraHaste(Haste); } XSRETURN_EMPTY; @@ -3199,12 +4548,20 @@ XS(XS_Mob_GetHaste); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHaste) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHaste(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHaste(THIS)"); { Mob *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHaste(); XSprePUSH; PUSHi((IV) RETVAL); @@ -3216,12 +4573,20 @@ XS(XS_Mob_GetHandToHandDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHandToHandDamage) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHandToHandDamage(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHandToHandDamage(THIS)"); { Mob *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHandToHandDamage(); XSprePUSH; PUSHi((IV) RETVAL); @@ -3233,11 +4598,19 @@ XS(XS_Mob_CanThisClassDoubleAttack); /* prototype to pass -Wmissing-prototypes * XS(XS_Mob_CanThisClassDoubleAttack) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CanThisClassDoubleAttack(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Mob::CanThisClassDoubleAttack(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanThisClassDoubleAttack(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3249,11 +4622,19 @@ XS(XS_Mob_CanThisClassDualWield); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanThisClassDualWield) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CanThisClassDualWield(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Mob::CanThisClassDualWield(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanThisClassDualWield(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3265,11 +4646,19 @@ XS(XS_Mob_CanThisClassRiposte); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanThisClassRiposte) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CanThisClassRiposte(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Mob::CanThisClassRiposte(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanThisClassRiposte(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3281,11 +4670,19 @@ XS(XS_Mob_CanThisClassDodge); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanThisClassDodge) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CanThisClassDodge(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Mob::CanThisClassDodge(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanThisClassDodge(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3297,11 +4694,19 @@ XS(XS_Mob_CanThisClassParry); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanThisClassParry) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::CanThisClassParry(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: Mob::CanThisClassParry(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanThisClassParry(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3313,12 +4718,20 @@ XS(XS_Mob_GetHandToHandDelay); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHandToHandDelay) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHandToHandDelay(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHandToHandDelay(THIS)"); { Mob *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHandToHandDelay(); XSprePUSH; PUSHi((IV) RETVAL); @@ -3330,12 +4743,20 @@ XS(XS_Mob_GetClassLevelFactor); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetClassLevelFactor) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetClassLevelFactor(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetClassLevelFactor(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClassLevelFactor(); XSprePUSH; PUSHu((UV) RETVAL); @@ -3347,10 +4768,18 @@ XS(XS_Mob_Mesmerize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Mesmerize) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Mesmerize(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Mesmerize(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Mesmerize(); } XSRETURN_EMPTY; @@ -3360,11 +4789,19 @@ XS(XS_Mob_IsMezzed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsMezzed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsMezzed(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsMezzed(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMezzed(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3376,11 +4813,19 @@ XS(XS_Mob_IsStunned); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsStunned) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsStunned(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsStunned(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsStunned(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3393,10 +4838,18 @@ XS(XS_Mob_StartEnrage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_StartEnrage) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::StartEnrage(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::StartEnrage(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->StartEnrage(); } XSRETURN_EMPTY; @@ -3406,11 +4859,19 @@ XS(XS_Mob_IsEnraged); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsEnraged) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsEnraged(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsEnraged(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsEnraged(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3422,13 +4883,21 @@ XS(XS_Mob_GetReverseFactionCon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetReverseFactionCon) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetReverseFactionCon(THIS, iOther)"); // @categories Faction + Perl_croak(aTHX_ "Usage: Mob::GetReverseFactionCon(THIS, iOther)"); { Mob *THIS; FACTION_VALUE RETVAL; dXSTARG; Mob *iOther; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); iOther = INT2PTR(Mob *, tmp); @@ -3448,11 +4917,19 @@ XS(XS_Mob_IsAIControlled); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsAIControlled) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsAIControlled(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsAIControlled(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsAIControlled(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3464,12 +4941,20 @@ XS(XS_Mob_GetAggroRange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAggroRange) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAggroRange(THIS)"); // @categories Stats and Attributes, Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetAggroRange(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAggroRange(); XSprePUSH; PUSHn((double) RETVAL); @@ -3481,12 +4966,20 @@ XS(XS_Mob_GetAssistRange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAssistRange) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAssistRange(THIS)"); // @categories Stats and Attributes, Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetAssistRange(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAssistRange(); XSprePUSH; PUSHn((double) RETVAL); @@ -3498,11 +4991,19 @@ XS(XS_Mob_SetPetOrder); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetPetOrder) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetPetOrder(THIS, i)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::SetPetOrder(THIS, i)"); { Mob *THIS; Mob::eStandingPetOrder i = (Mob::eStandingPetOrder) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPetOrder(i); } XSRETURN_EMPTY; @@ -3512,12 +5013,20 @@ XS(XS_Mob_GetPetOrder); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetPetOrder) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetPetOrder(THIS)"); // @categories Script Utility, Pet + Perl_croak(aTHX_ "Usage: Mob::GetPetOrder(THIS)"); { Mob *THIS; Mob::eStandingPetOrder RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPetOrder(); XSprePUSH; PUSHi((IV) RETVAL); @@ -3529,11 +5038,19 @@ XS(XS_Mob_IsRoamer); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsRoamer) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsRoamer(THIS)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: Mob::IsRoamer(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRoamer(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3545,11 +5062,19 @@ XS(XS_Mob_IsRooted); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsRooted) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsRooted(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsRooted(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRooted(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3561,7 +5086,7 @@ XS(XS_Mob_AddToHateList); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_AddToHateList) { dXSARGS; if (items < 2 || items > 7) - Perl_croak(aTHX_ "Usage: Mob::AddToHateList(THIS, Mob* other, [int32 hate = 0], [int32 damage = 0], [bool yell_for_help = true], [bool frenzy = false], [bool buff_tic = false])"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::AddToHateList(THIS, Mob* other, [int32 hate = 0], [int32 damage = 0], [bool yell_for_help = true], [bool frenzy = false], [bool buff_tic = false])"); { Mob *THIS; Mob *other; @@ -3570,7 +5095,15 @@ XS(XS_Mob_AddToHateList) { bool iYellForHelp; bool bFrenzy; bool iBuffTic; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3618,13 +5151,21 @@ XS(XS_Mob_SetHate); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetHate) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::SetHate(THIS, Mob* other, [int32 hate = 0], [int32 damage = 0])"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::SetHate(THIS, Mob* other, [int32 hate = 0], [int32 damage = 0])"); { Mob *THIS; Mob *other; int32 hate; int32 damage; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3654,11 +5195,19 @@ XS(XS_Mob_HalveAggro); XS(XS_Mob_HalveAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::HalveAggro(THIS, Mob* other)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::HalveAggro(THIS, Mob* other)"); { Mob *THIS; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3676,11 +5225,19 @@ XS(XS_Mob_DoubleAggro); XS(XS_Mob_DoubleAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::DoubleAggro(THIS, Mob* other)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::DoubleAggro(THIS, Mob* other)"); { Mob *THIS; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3698,14 +5255,22 @@ XS(XS_Mob_GetHateAmount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHateAmount) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::GetHateAmount(THIS, Mob* mob, [bool is_damage = false])"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetHateAmount(THIS, Mob* mob, [bool is_damage = false])"); { Mob *THIS; uint32 RETVAL; dXSTARG; Mob *tmob; bool is_dam; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); tmob = INT2PTR(Mob *, tmp); @@ -3731,13 +5296,21 @@ XS(XS_Mob_GetDamageAmount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetDamageAmount) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetDamageAmount(THIS, Mob* target_mob)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetDamageAmount(THIS, Mob* target_mob)"); { Mob *THIS; uint32 RETVAL; dXSTARG; Mob *tmob; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); tmob = INT2PTR(Mob *, tmp); @@ -3757,11 +5330,19 @@ XS(XS_Mob_GetHateTop); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHateTop) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHateTop(THIS)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetHateTop(THIS)"); { Mob *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHateTop(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -3773,12 +5354,20 @@ XS(XS_Mob_GetHateDamageTop); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHateDamageTop) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetHateDamageTop(THIS, Mob* other)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetHateDamageTop(THIS, Mob* other)"); { Mob *THIS; Mob *RETVAL; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3798,11 +5387,19 @@ XS(XS_Mob_GetHateRandom); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetHateRandom) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHateRandom(THIS)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetHateRandom(THIS)"); { Mob *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHateRandom(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -3814,11 +5411,19 @@ XS(XS_Mob_IsEngaged); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsEngaged) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsEngaged(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsEngaged(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsEngaged(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3830,11 +5435,19 @@ XS(XS_Mob_HateSummon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_HateSummon) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HateSummon(THIS)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::HateSummon(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HateSummon(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -3846,11 +5459,19 @@ XS(XS_Mob_FaceTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_FaceTarget) { dXSARGS; if (items < 1 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::FaceTarget(THIS, [Mob* target = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::FaceTarget(THIS, [Mob* target = 0])"); { Mob *THIS; Mob *MobToFace; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) MobToFace = 0; else { @@ -3872,11 +5493,19 @@ XS(XS_Mob_SetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetHeading) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetHeading(THIS, float heading)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetHeading(THIS, float heading)"); { Mob *THIS; float iHeading = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetHeading(iHeading); } XSRETURN_EMPTY; @@ -3886,10 +5515,18 @@ XS(XS_Mob_WipeHateList); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_WipeHateList) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::WipeHateList(THIS)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::WipeHateList(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->WipeHateList(); } XSRETURN_EMPTY; @@ -3899,12 +5536,20 @@ XS(XS_Mob_CheckAggro); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CheckAggro) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::CheckAggro(THIS, Mob* other)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::CheckAggro(THIS, Mob* other)"); { Mob *THIS; bool RETVAL; Mob *other; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -3924,14 +5569,22 @@ XS(XS_Mob_CalculateHeadingToTarget); /* prototype to pass -Wmissing-prototypes * XS(XS_Mob_CalculateHeadingToTarget) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::CalculateHeadingToTarget(THIS, float x, float y)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CalculateHeadingToTarget(THIS, float x, float y)"); { Mob *THIS; int8 RETVAL; dXSTARG; float in_x = (float) SvNV(ST(1)); float in_y = (float) SvNV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CalculateHeadingToTarget(in_x, in_y); XSprePUSH; PUSHi((IV) RETVAL); @@ -3950,7 +5603,17 @@ XS(XS_Mob_RunTo) { float x = (float)SvNV(ST(1)); float y = (float)SvNV(ST(2)); float z = (float)SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *)SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->RunTo(x, y, z); } XSRETURN_EMPTY; @@ -3967,7 +5630,17 @@ XS(XS_Mob_WalkTo) { float x = (float)SvNV(ST(1)); float y = (float)SvNV(ST(2)); float z = (float)SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *)SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->WalkTo(x, y, z); } XSRETURN_EMPTY; @@ -3977,13 +5650,22 @@ XS(XS_Mob_NavigateTo); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_NavigateTo) { dXSARGS; if (items < 4 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::NavigateTo(THIS, float x, float y, float z)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::NavigateTo(THIS, float x, float y, float z)"); { Mob *THIS; float x = (float) SvNV(ST(1)); float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->NavigateTo(x, y, z); } XSRETURN_EMPTY; @@ -3997,7 +5679,17 @@ XS(XS_Mob_StopNavigation) { "Usage: Mob::StopNavigation(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *)SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->StopNavigation(); } XSRETURN_EMPTY; @@ -4007,7 +5699,7 @@ XS(XS_Mob_CalculateDistance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CalculateDistance) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::CalculateDistance(THIS, float x, float y, float z)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CalculateDistance(THIS, float x, float y, float z)"); { Mob *THIS; float RETVAL; @@ -4015,7 +5707,15 @@ XS(XS_Mob_CalculateDistance) { float x = (float) SvNV(ST(1)); float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CalculateDistance(x, y, z); XSprePUSH; PUSHn((double) RETVAL); @@ -4027,13 +5727,21 @@ XS(XS_Mob_SendTo); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SendTo) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::SendTo(THIS, float new_x, float new_y, float new_z)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SendTo(THIS, float new_x, float new_y, float new_z)"); { Mob *THIS; float new_x = (float) SvNV(ST(1)); float new_y = (float) SvNV(ST(2)); float new_z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendTo(new_x, new_y, new_z); } XSRETURN_EMPTY; @@ -4043,13 +5751,21 @@ XS(XS_Mob_SendToFixZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SendToFixZ) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::SendToFixZ(THIS, float new_x, float new_y, float new_z)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SendToFixZ(THIS, float new_x, float new_y, float new_z)"); { Mob *THIS; float new_x = (float) SvNV(ST(1)); float new_y = (float) SvNV(ST(2)); float new_z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendToFixZ(new_x, new_y, new_z); } XSRETURN_EMPTY; @@ -4059,14 +5775,22 @@ XS(XS_Mob_NPCSpecialAttacks); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_NPCSpecialAttacks) { dXSARGS; if (items < 3 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::NPCSpecialAttacks(THIS, string abilities_string, int perm_tag, [bool reset = true], [bool remove = true])"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::NPCSpecialAttacks(THIS, string abilities_string, int perm_tag, [bool reset = true], [bool remove = true])"); { Mob *THIS; char *parse = (char *) SvPV_nolen(ST(1)); int permtag = (int) SvIV(ST(2)); bool reset = items == 4 ? (bool) SvTRUE(ST(3)) : true; bool remove = items == 5 ? (bool) SvTRUE(ST(4)) : false; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->NPCSpecialAttacks(parse, permtag, reset, remove); } XSRETURN_EMPTY; @@ -4076,12 +5800,20 @@ XS(XS_Mob_DontHealMeBefore); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DontHealMeBefore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DontHealMeBefore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DontHealMeBefore(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DontHealMeBefore(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4093,12 +5825,20 @@ XS(XS_Mob_DontBuffMeBefore); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DontBuffMeBefore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DontBuffMeBefore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DontBuffMeBefore(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DontBuffMeBefore(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4110,12 +5850,20 @@ XS(XS_Mob_DontDotMeBefore); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DontDotMeBefore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DontDotMeBefore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DontDotMeBefore(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DontDotMeBefore(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4127,12 +5875,20 @@ XS(XS_Mob_DontRootMeBefore); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DontRootMeBefore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DontRootMeBefore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DontRootMeBefore(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DontRootMeBefore(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4144,12 +5900,20 @@ XS(XS_Mob_DontSnareMeBefore); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DontSnareMeBefore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DontSnareMeBefore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DontSnareMeBefore(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DontSnareMeBefore(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4161,13 +5925,21 @@ XS(XS_Mob_GetResist); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetResist) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetResist(THIS, type)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetResist(THIS, type)"); { Mob *THIS; int16 RETVAL; dXSTARG; uint8 type = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetResist(type); XSprePUSH; PUSHi((IV) RETVAL); @@ -4179,11 +5951,19 @@ XS(XS_Mob_GetShieldTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetShieldTarget) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetShieldTarget(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetShieldTarget(THIS)"); { Mob *THIS; Mob *RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetShieldTarget(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Mob", (void *) RETVAL); @@ -4195,11 +5975,19 @@ XS(XS_Mob_SetShieldTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetShieldTarget) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetShieldTarget(THIS, mob)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetShieldTarget(THIS, mob)"); { Mob *THIS; Mob *mob; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -4217,11 +6005,19 @@ XS(XS_Mob_Charmed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_Charmed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::Charmed(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::Charmed(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Charmed(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4233,13 +6029,21 @@ XS(XS_Mob_GetLevelHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetLevelHP) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetLevelHP(THIS, uint8 level)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetLevelHP(THIS, uint8 level)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint8 tlevel = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLevelHP(tlevel); XSprePUSH; PUSHu((UV) RETVAL); @@ -4251,12 +6055,20 @@ XS(XS_Mob_GetZoneID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetZoneID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetZoneID(THIS)"); // @categories Zones + Perl_croak(aTHX_ "Usage: Mob::GetZoneID(THIS)"); { Mob *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetZoneID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -4268,13 +6080,21 @@ XS(XS_Mob_CheckAggroAmount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CheckAggroAmount) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::CheckAggroAmount(THIS, uint16 spell_id)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::CheckAggroAmount(THIS, uint16 spell_id)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint16 spellid = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CheckAggroAmount(spellid, nullptr); XSprePUSH; PUSHu((UV) RETVAL); @@ -4286,14 +6106,22 @@ XS(XS_Mob_CheckHealAggroAmount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CheckHealAggroAmount) { dXSARGS; if (items != 2 && items != 3) - Perl_croak(aTHX_ "Usage: Mob::CheckHealAggroAmount(THIS, uint16 spell_id, uint32 possible_heal_amt)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::CheckHealAggroAmount(THIS, uint16 spell_id, uint32 possible_heal_amt)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint16 spellid = (uint16) SvUV(ST(1)); uint32 possible = 0; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 3) { possible = (uint32) SvUV(ST(2)); } @@ -4309,13 +6137,21 @@ XS(XS_Mob_GetAA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAA) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetAA(THIS, uint32 rank_id)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Mob::GetAA(THIS, uint32 rank_id)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint32 rank_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAA(rank_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -4327,13 +6163,21 @@ XS(XS_Mob_GetAAByAAID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAAByAAID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetAAByAAID(THIS, uint32 aa_id)"); // @categories Alternative Advancement + Perl_croak(aTHX_ "Usage: Mob::GetAAByAAID(THIS, uint32 aa_id)"); { Mob *THIS; uint32 RETVAL; dXSTARG; uint32 aa_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAAByAAID(aa_id); XSprePUSH; PUSHu((UV) RETVAL); @@ -4345,14 +6189,22 @@ XS(XS_Mob_SetAA); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetAA) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::SetAA(THIS, int aa_id, int points, [int charges = 0])"); // @categories Alternative Advancement, Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetAA(THIS, int aa_id, int points, [int charges = 0])"); { Mob *THIS; bool RETVAL; int aa_id = (int) SvIV(ST(1)); int points = (int) SvIV(ST(2)); int charges = (items == 4) ? (int) SvIV(ST(3)) : 0; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SetAA(aa_id, points, charges); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4364,11 +6216,19 @@ XS(XS_Mob_DivineAura); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DivineAura) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::DivineAura(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::DivineAura(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->DivineAura(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4380,11 +6240,19 @@ XS(XS_Mob_AddFeignMemory); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_AddFeignMemory) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::AddFeignMemory(THIS, Client* attacker)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::AddFeignMemory(THIS, Client* attacker)"); { Mob *THIS; Client *attacker; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); attacker = INT2PTR(Client *, tmp); @@ -4402,11 +6270,19 @@ XS(XS_Mob_RemoveFromFeignMemory); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RemoveFromFeignMemory) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::RemoveFromFeignMemory(THIS, Client* attacker)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::RemoveFromFeignMemory(THIS, Client* attacker)"); { Mob *THIS; Client *attacker; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); attacker = INT2PTR(Client *, tmp); @@ -4424,10 +6300,18 @@ XS(XS_Mob_ClearFeignMemory); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ClearFeignMemory) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::ClearFeignMemory(THIS)"); // @categories Script Utility, Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::ClearFeignMemory(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearFeignMemory(); } XSRETURN_EMPTY; @@ -4437,11 +6321,19 @@ XS(XS_Mob_SetOOCRegen); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetOOCRegen) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetOOCRegen(THIS, int32 new_ooc_regen)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetOOCRegen(THIS, int32 new_ooc_regen)"); { Mob *THIS; int32 newoocregen = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetOOCRegen(newoocregen); } XSRETURN_EMPTY; @@ -4451,13 +6343,21 @@ XS(XS_Mob_GetEntityVariable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetEntityVariable) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetEntityVariable(THIS, string id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetEntityVariable(THIS, string id)"); { Mob *THIS; Const_char *id = SvPV_nolen(ST(1)); Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEntityVariable(id); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -4475,7 +6375,15 @@ XS(XS_Mob_EntityVariableExists) { Mob *THIS; Const_char *id = SvPV_nolen(ST(1)); bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->EntityVariableExists(id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4487,12 +6395,20 @@ XS(XS_Mob_SetEntityVariable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetEntityVariable) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::SetEntityVariable(THIS, string id, string var)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetEntityVariable(THIS, string id, string var)"); { Mob *THIS; Const_char *id = SvPV_nolen(ST(1)); const char *var = (const char *) SvPV_nolen(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetEntityVariable(id, var); } XSRETURN_EMPTY; @@ -4503,10 +6419,19 @@ XS(XS_Mob_GetHateList) { dXSARGS; int num_entries = 0; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHateList(THIS)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: Mob::GetHateList(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + auto hate_list = THIS->GetHateList(); auto iter = hate_list.begin(); @@ -4526,12 +6451,20 @@ XS(XS_Mob_SignalClient); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SignalClient) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::SignalClient(THIS, Client* client, uint32 data)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SignalClient(THIS, Client* client, uint32 data)"); { Mob *THIS; Client *client = nullptr; uint32 data = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Client *, tmp); @@ -4549,12 +6482,20 @@ XS(XS_Mob_CombatRange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CombatRange) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::CombatRange(THIS, Mob* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CombatRange(THIS, Mob* target)"); { Mob *THIS; Mob *target = nullptr; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -4574,7 +6515,7 @@ XS(XS_Mob_DoSpecialAttackDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoSpecialAttackDamage) { dXSARGS; if (items < 4 || items > 6) - Perl_croak(aTHX_ "Usage: Mob::DoSpecialAttackDamage(THIS, Mob* target, int skill, int32 max_damage, [int32 min_damage = 1], [int32 hate_override = -11])"); // @categories Script Utility, Skills and Attributes + Perl_croak(aTHX_ "Usage: Mob::DoSpecialAttackDamage(THIS, Mob* target, int skill, int32 max_damage, [int32 min_damage = 1], [int32 hate_override = -11])"); { Mob *THIS; Mob *target; @@ -4582,7 +6523,15 @@ XS(XS_Mob_DoSpecialAttackDamage) { int32 max_damage = (int32) SvIV(ST(3)); int32 min_damage = 1; int32 hate_override = -11; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -4608,12 +6557,20 @@ XS(XS_Mob_CheckLoS); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CheckLoS) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::CheckLoS(THIS, Mob*)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CheckLoS(THIS, Mob*)"); { Mob *THIS; Mob *mob; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -4633,7 +6590,7 @@ XS(XS_Mob_CheckLoSToLoc); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CheckLoSToLoc) { dXSARGS; if (items != 4 && items != 5) - Perl_croak(aTHX_ "Usage: Mob::CheckLoSToLoc(THIS, float x, float y, float z, float mob_size)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CheckLoSToLoc(THIS, float x, float y, float z, float mob_size)"); { Mob *THIS; float loc_x = (float) SvNV(ST(1)); @@ -4647,7 +6604,15 @@ XS(XS_Mob_CheckLoSToLoc) { } else { mob_size = 6; } - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CheckLosFN(loc_x, loc_y, loc_z, mob_size); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4659,7 +6624,7 @@ XS(XS_Mob_FindGroundZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_FindGroundZ) { dXSARGS; if (items != 3 && items != 4) - Perl_croak(aTHX_ "Usage: Mob::FindGroundZ(THIS, float x, float y, float z_offset)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::FindGroundZ(THIS, float x, float y, float z_offset)"); { Mob *THIS; float new_x = (float) SvNV(ST(1)); @@ -4673,7 +6638,15 @@ XS(XS_Mob_FindGroundZ) { } else { z_offset = 10; } - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroundZ(new_x, new_y, z_offset); XSprePUSH; PUSHn((double) RETVAL); @@ -4685,7 +6658,7 @@ XS(XS_Mob_ProjectileAnim); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ProjectileAnim) { dXSARGS; if (items < 3 || items > 9) - Perl_croak(aTHX_ "Usage: Mob::ProjectileAnim(THIS, Mob* mob, int item_id, [bool is_arrow = false], [float speed = 0], [float angle = 0], [float tilt = 0], [float arc = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::ProjectileAnim(THIS, Mob* mob, int item_id, [bool is_arrow = false], [float speed = 0], [float angle = 0], [float tilt = 0], [float arc = 0])"); { Mob *THIS; @@ -4697,7 +6670,15 @@ XS(XS_Mob_ProjectileAnim) { float tilt = 0; float arc = 0; char *IDFile = nullptr; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); mob = INT2PTR(Mob *, tmp); @@ -4734,12 +6715,20 @@ XS(XS_Mob_HasNPCSpecialAtk); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_HasNPCSpecialAtk) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::HasNPCSpecialAtk(THIS, string ability_string)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::HasNPCSpecialAtk(THIS, string ability_string)"); { Mob *THIS; char *parse = (char *) SvPV_nolen(ST(1)); bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasNPCSpecialAtk(parse); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -4751,7 +6740,7 @@ XS(XS_Mob_SendAppearanceEffect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SendAppearanceEffect) { dXSARGS; if (items < 2 || items > 7) - Perl_croak(aTHX_ "Usage: Mob::SendAppearanceEffect(THIS, int32 param_1, [int32 param_2 = 0], [int32 param_3 = 0], [int32 param_4 = 0], [int32 param_5 = 0], [Client* single_client_to_send_to = null])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SendAppearanceEffect(THIS, int32 param_1, [int32 param_2 = 0], [int32 param_3 = 0], [int32 param_4 = 0], [int32 param_5 = 0], [Client* single_client_to_send_to = null])"); { Mob *THIS; int32 parm1 = (int32) SvIV(ST(1)); @@ -4760,7 +6749,15 @@ XS(XS_Mob_SendAppearanceEffect) { int32 parm4 = 0; int32 parm5 = 0; Client *client = nullptr; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) { parm2 = (int32) SvIV(ST(2)); } if (items > 3) { parm3 = (int32) SvIV(ST(3)); } if (items > 4) { parm4 = (int32) SvIV(ST(4)); } @@ -4784,11 +6781,19 @@ XS(XS_Mob_SetFlyMode); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetFlyMode) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetFlyMode(THIS, uint8 flymode[0|1|2|3|4|5])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetFlyMode(THIS, uint8 flymode[0|1|2|3|4|5])"); { Mob *THIS; GravityBehavior flymode = (GravityBehavior) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFlyMode(flymode); } XSRETURN_EMPTY; @@ -4798,11 +6803,19 @@ XS(XS_Mob_SetTexture); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetTexture) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetTexture(THIS, int32 texture)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetTexture(THIS, int32 texture)"); { Mob *THIS; int32 texture = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendIllusionPacket(THIS->GetRace(), 0xFF, texture); } XSRETURN_EMPTY; @@ -4812,11 +6825,19 @@ XS(XS_Mob_SetRace); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetRace) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetRace(THIS, int32 race)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetRace(THIS, int32 race)"); { Mob *THIS; int32 race = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendIllusionPacket(race); } XSRETURN_EMPTY; @@ -4826,11 +6847,19 @@ XS(XS_Mob_SetGender); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetGender) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetGender(THIS, int32 gender)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetGender(THIS, int32 gender)"); { Mob *THIS; int32 gender = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendIllusionPacket(THIS->GetRace(), gender); } XSRETURN_EMPTY; @@ -4840,7 +6869,7 @@ XS(XS_Mob_SendIllusion); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SendIllusion) { dXSARGS; if (items < 2 || items > 14) - Perl_croak(aTHX_ "Usage: Mob::SendIllusion(THIS, uint16 race, [uint8 gender = 0xFF], [uint8 texture face = 0xFF], [uint8 hairstyle = 0xFF], [uint8 hair_color = 0xFF], [uint8 beard = 0xFF], [uint8 beard_color =FF], [uint32 drakkin_tattoo = 0xFFFFFFFF], [uint32 drakkin_details = 0xFFFFFFFF], [float size = -1])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SendIllusion(THIS, uint16 race, [uint8 gender = 0xFF], [uint8 texture face = 0xFF], [uint8 hairstyle = 0xFF], [uint8 hair_color = 0xFF], [uint8 beard = 0xFF], [uint8 beard_color =FF], [uint32 drakkin_tattoo = 0xFFFFFFFF], [uint32 drakkin_details = 0xFFFFFFFF], [float size = -1])"); { Mob *THIS; uint16 race = (uint16) SvIV(ST(1)); @@ -4856,7 +6885,15 @@ XS(XS_Mob_SendIllusion) { uint32 drakkin_tattoo = 0xFFFFFFFF; uint32 drakkin_details = 0xFFFFFFFF; float size = -1.0f; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) { gender = (uint8) SvIV(ST(2)); } if (items > 3) { texture = (uint8) SvIV(ST(3)); } if (items > 4) { helmtexture = (uint8) SvIV(ST(4)); } @@ -4880,7 +6917,7 @@ XS(XS_Mob_CameraEffect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CameraEffect) { dXSARGS; if (items < 2 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::CameraEffect(THIS, uint32 duration, [uint32 intensity = 0], [Client* single_client = nullptr], [bool is_world_wide = false])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::CameraEffect(THIS, uint32 duration, [uint32 intensity = 0], [Client* single_client = nullptr], [bool is_world_wide = false])"); { Mob *THIS; uint32 duration = (uint32) SvUV(ST(1)); @@ -4888,7 +6925,15 @@ XS(XS_Mob_CameraEffect) { Client *client = nullptr; bool global = false; bool nullcli = false; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) { intensity = (uint32) SvUV(ST(2)); } if (items > 3) { if (sv_derived_from(ST(3), "Client")) { @@ -4914,7 +6959,7 @@ XS(XS_Mob_SpellEffect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SpellEffect) { dXSARGS; if (items < 2 || items > 8) - Perl_croak(aTHX_ "Usage: Mob::SpellEffect(THIS, uint32 effect, [uint32 duration = 5000], [uint32 finish_delay = 0], [bool zone_wide = false], [uint32 unk20 = 3000], [bool perm_effect = false], [Client* single_client])"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::SpellEffect(THIS, uint32 effect, [uint32 duration = 5000], [uint32 finish_delay = 0], [bool zone_wide = false], [uint32 unk20 = 3000], [bool perm_effect = false], [Client* single_client])"); { Mob *THIS; uint32 effect = (uint32) SvUV(ST(1)); @@ -4924,7 +6969,16 @@ XS(XS_Mob_SpellEffect) { uint32 unk20 = 3000; bool perm_effect = false; Client *client = nullptr; - VALIDATE_THIS_IS_MOB; + + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) { duration = (uint32) SvUV(ST(2)); } if (items > 3) { finish_delay = (uint32) SvUV(ST(3)); } if (items > 4) { zone_wide = (bool) SvTRUE(ST(4)); } @@ -4951,11 +7005,19 @@ XS(XS_Mob_TempName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_TempName) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Mob::TempName(THIS, string name)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::TempName(THIS, string name)"); { Mob *THIS; char *name = nullptr; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { name = (char *) SvPV_nolen(ST(1)); } THIS->TempName(name); @@ -4967,14 +7029,22 @@ XS(XS_Mob_GetItemStat); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetItemStat) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetItemStat(THIS, uint32 item_id, string stat)"); // @categories Inventory and Items, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetItemStat(THIS, uint32 item_id, string stat)"); { Mob *THIS; int32 RETVAL; uint32 itemid = (uint32) SvUV(ST(1)); Const_char *stat = (Const_char *) SvPV_nolen(ST(2)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItemStat(itemid, stat); XSprePUSH; PUSHi((IV) RETVAL); @@ -4993,7 +7063,15 @@ XS(XS_Mob_GetGlobal) { std::string ret_val = "Undefined"; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (THIS->GetGlobal(varname) != "Undefined") ret_val = THIS->GetGlobal(varname); @@ -5017,7 +7095,15 @@ XS(XS_Mob_SetGlobal) { int options = (int) SvIV(ST(3)); char *duration = (char *) SvPV_nolen(ST(4)); Mob *other = nullptr; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 5) { if (sv_derived_from(ST(5), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(5))); @@ -5046,7 +7132,15 @@ XS(XS_Mob_TarGlobal) { int npcid = (int) SvIV(ST(4)); int charid = (int) SvIV(ST(5)); int zoneid = (int) SvIV(ST(6)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->TarGlobal(varname, value, duration, npcid, charid, zoneid); } XSRETURN_EMPTY; @@ -5060,7 +7154,15 @@ XS(XS_Mob_DelGlobal) { { Mob *THIS; char *varname = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->DelGlobal(varname); } XSRETURN_EMPTY; @@ -5070,14 +7172,22 @@ XS(XS_Mob_SetSlotTint); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetSlotTint) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: Mob::SetSlotTint(THIS, uint8 material_slot, uint8 red_tint, uint8 green_tint, uint8 blue_tint)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetSlotTint(THIS, uint8 material_slot, uint8 red_tint, uint8 green_tint, uint8 blue_tint)"); { Mob *THIS; uint8 material_slot = (uint8) SvIV(ST(1)); uint8 red_tint = (uint8) SvIV(ST(2)); uint8 green_tint = (uint8) SvIV(ST(3)); uint8 blue_tint = (uint8) SvIV(ST(4)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSlotTint(material_slot, red_tint, green_tint, blue_tint); } XSRETURN_EMPTY; @@ -5087,14 +7197,22 @@ XS(XS_Mob_WearChange); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_WearChange) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::WearChange(THIS, uint8 material_slot, uint16 texture, [uint32 color = 0, uint32 hero_forge_model = 0])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::WearChange(THIS, uint8 material_slot, uint16 texture, [uint32 color = 0, uint32 hero_forge_model = 0])"); { Mob *THIS; uint8 material_slot = (uint8) SvIV(ST(1)); uint16 texture = (uint16) SvUV(ST(2)); uint32 color = 0; uint32 hero_forge_model = 0; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 3) { color = (uint32) SvUV(ST(3)); } @@ -5111,13 +7229,21 @@ XS(XS_Mob_DoKnockback); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoKnockback) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::DoKnockback(THIS, Mob* caster, uint32 push_back_amount, uint32 push_up_amount)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::DoKnockback(THIS, Mob* caster, uint32 push_back_amount, uint32 push_up_amount)"); { Mob *THIS; Mob *caster; uint32 pushback = (uint16) SvUV(ST(2)); uint32 pushup = (uint16) SvUV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); caster = INT2PTR(Mob *, tmp); @@ -5135,11 +7261,19 @@ XS(XS_Mob_RemoveNimbusEffect); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_RemoveNimbusEffect) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::RemoveNimbusEffect(THIS, int32 effect_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::RemoveNimbusEffect(THIS, int32 effect_id)"); { Mob *THIS; int32 effectid = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveNimbusEffect(effectid); } XSRETURN_EMPTY; @@ -5149,11 +7283,19 @@ XS(XS_Mob_SetRunning); XS(XS_Mob_SetRunning) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetRunning(THIS, bool value)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetRunning(THIS, bool value)"); { Mob *THIS; bool value = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetRunning(value); } XSRETURN_EMPTY; @@ -5163,12 +7305,20 @@ XS(XS_Mob_IsRunning); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsRunning) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsRunning(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsRunning(THIS)"); { Mob *THIS; bool RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRunning(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5180,12 +7330,20 @@ XS(XS_Mob_SetBodyType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetBodyType) { dXSARGS; if (items < 2 || items > 3) - Perl_croak(aTHX_ "Usage: Mob::SetBodyType(THIS, int32 type, [bool overwrite_orig = false])"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetBodyType(THIS, int32 type, [bool overwrite_orig = false])"); { Mob *THIS; int32 type = (int32) SvIV(ST(1)); bool overwrite_orig = false; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 3) { overwrite_orig = (bool) SvTRUE(ST(2)); } @@ -5199,11 +7357,19 @@ XS(XS_Mob_SetDeltas); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetDeltas) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: Mob::SetDeltas(THIS, float delta_x, float delta_y, float delta_z, float delta_h)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetDeltas(THIS, float delta_x, float delta_y, float delta_z, float delta_h)"); { Mob *THIS; auto delta = glm::vec4((float) SvNV(ST(1)), (float) SvNV(ST(2)), (float) SvNV(ST(3)), (float) SvNV(ST(4))); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDelta(delta); } XSRETURN_EMPTY; @@ -5213,11 +7379,19 @@ XS(XS_Mob_SetLD); XS(XS_Mob_SetLD) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetLD(THIS, bool value)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::SetLD(THIS, bool value)"); { Mob *THIS; bool value = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendAppearancePacket(AT_Linkdead, value); } XSRETURN_EMPTY; @@ -5227,11 +7401,19 @@ XS(XS_Mob_SetTargetable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetTargetable) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetTargetable(THIS, bool targetable)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetTargetable(THIS, bool targetable)"); { Mob *THIS; bool on = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetTargetable(on); } XSRETURN_EMPTY; @@ -5241,12 +7423,20 @@ XS(XS_Mob_ModSkillDmgTaken); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ModSkillDmgTaken) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::ModSkillDmgTaken(THIS, int skill, int16 value)"); // @categories Skills and Recipes, Script Utility + Perl_croak(aTHX_ "Usage: Mob::ModSkillDmgTaken(THIS, int skill, int16 value)"); { Mob *THIS; EQ::skills::SkillType skill_num = (EQ::skills::SkillType) SvUV(ST(1)); int16 value = (int16) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ModSkillDmgTaken(skill_num, value); } XSRETURN_EMPTY; @@ -5256,13 +7446,21 @@ XS(XS_Mob_GetModSkillDmgTaken); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetModSkillDmgTaken) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetModSkillDmgTaken(THIS, int skill_id)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetModSkillDmgTaken(THIS, int skill_id)"); { Mob *THIS; int16 RETVAL; dXSTARG; EQ::skills::SkillType skill_num = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetModSkillDmgTaken(skill_num); XSprePUSH; PUSHi((IV) RETVAL); @@ -5274,13 +7472,21 @@ XS(XS_Mob_GetSkillDmgTaken); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSkillDmgTaken) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetSkillDmgTaken(THIS, int skill_id)"); // @categories Skills and Recipes, Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetSkillDmgTaken(THIS, int skill_id)"); { Mob *THIS; int32 RETVAL; dXSTARG; EQ::skills::SkillType skill_num = (EQ::skills::SkillType) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSkillDmgTaken(skill_num); XSprePUSH; PUSHu((UV) RETVAL); @@ -5292,11 +7498,19 @@ XS(XS_Mob_SetAllowBeneficial); XS(XS_Mob_SetAllowBeneficial) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetAllowBeneficial(THIS, bool value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetAllowBeneficial(THIS, bool value)"); { Mob *THIS; bool value = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetAllowBeneficial(value); } XSRETURN_EMPTY; @@ -5306,11 +7520,19 @@ XS(XS_Mob_GetAllowBeneficial); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetAllowBeneficial) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetAllowBeneficial(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetAllowBeneficial(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAllowBeneficial(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5322,13 +7544,21 @@ XS(XS_Mob_IsBeneficialAllowed); XS(XS_Mob_IsBeneficialAllowed) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::IsBeneficialAllowed(THIS, Mob* target)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::IsBeneficialAllowed(THIS, Mob* target)"); { dXSTARG; Mob *THIS; Mob *target; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -5348,12 +7578,20 @@ XS(XS_Mob_ModVulnerability); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ModVulnerability) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::ModVulnerability(THIS, uint8 resist, int16 value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::ModVulnerability(THIS, uint8 resist, int16 value)"); { Mob *THIS; uint8 resist = (uint8) SvIV(ST(1)); int16 value = (int16) SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ModVulnerability(resist, value); } XSRETURN_EMPTY; @@ -5363,13 +7601,21 @@ XS(XS_Mob_GetModVulnerability); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetModVulnerability) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetModVulnerability(THIS, uint8 resist)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetModVulnerability(THIS, uint8 resist)"); { Mob *THIS; int32 RETVAL; dXSTARG; uint8 resist = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetModVulnerability(resist); XSprePUSH; PUSHi((IV) RETVAL); @@ -5381,7 +7627,7 @@ XS(XS_Mob_DoMeleeSkillAttackDmg); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoMeleeSkillAttackDmg) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Mob::DoMeleeSkillAttackDmg(THIS, Mob* target, uint16 weapon_damage, int skill, int16 chance_mod, int16 focus, uint8 can_riposte)"); // @categories Script Utility, Skills and Attributes + Perl_croak(aTHX_ "Usage: Mob::DoMeleeSkillAttackDmg(THIS, Mob* target, uint16 weapon_damage, int skill, int16 chance_mod, int16 focus, uint8 can_riposte)"); { Mob *THIS; Mob *target; @@ -5390,7 +7636,15 @@ XS(XS_Mob_DoMeleeSkillAttackDmg) { int16 chance_mod = (int16) SvIV(ST(4)); int16 focus = (int16) SvIV(ST(5)); uint8 CanRiposte = (uint8) SvIV(ST(6)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -5408,7 +7662,7 @@ XS(XS_Mob_DoArcheryAttackDmg); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoArcheryAttackDmg) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Mob::DoArcheryAttackDmg(THIS, Mob* target, [range_weapon_item_instance = nullptr], [ammo_item_instance = nullptr], uint16 weapon_damage, int16 chance_mod, int16 focus)"); // @categories Script Utility, Skills and Attributes + Perl_croak(aTHX_ "Usage: Mob::DoArcheryAttackDmg(THIS, Mob* target, [range_weapon_item_instance = nullptr], [ammo_item_instance = nullptr], uint16 weapon_damage, int16 chance_mod, int16 focus)"); { Mob *THIS; Mob *target; @@ -5417,7 +7671,15 @@ XS(XS_Mob_DoArcheryAttackDmg) { uint16 weapon_damage = (uint16) SvIV(ST(4)); int16 chance_mod = (int16) SvIV(ST(5)); int16 focus = (int16) SvIV(ST(6)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -5435,7 +7697,7 @@ XS(XS_Mob_DoThrowingAttackDmg); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DoThrowingAttackDmg) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Mob::DoThrowingAttackDmg(THIS, Mob* target, [range_weapon_item_instance = nullptr], [ammo_item_instance = nullptr], uint16 weapon_damage, int16 chance_mod, int16 focus)"); // @categories Script Utility, Skills and Attributes + Perl_croak(aTHX_ "Usage: Mob::DoThrowingAttackDmg(THIS, Mob* target, [range_weapon_item_instance = nullptr], [ammo_item_instance = nullptr], uint16 weapon_damage, int16 chance_mod, int16 focus)"); { Mob *THIS; Mob *target; @@ -5444,7 +7706,15 @@ XS(XS_Mob_DoThrowingAttackDmg) { uint16 weapon_damage = (uint16) SvIV(ST(4)); int16 chance_mod = (int16) SvIV(ST(5)); int16 focus = (int16) SvIV(ST(6)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -5462,11 +7732,19 @@ XS(XS_Mob_SetDisableMelee); XS(XS_Mob_SetDisableMelee) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetDisableMelee(THIS, bool value)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetDisableMelee(THIS, bool value)"); { Mob *THIS; bool value = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDisableMelee(value); } XSRETURN_EMPTY; @@ -5476,11 +7754,19 @@ XS(XS_Mob_IsMeleeDisabled); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_IsMeleeDisabled) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsMeleeDisabled(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::IsMeleeDisabled(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsMeleeDisabled(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5492,11 +7778,19 @@ XS(XS_Mob_SetFlurryChance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetFlurryChance) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::SetFlurryChance(THIS, uint8 value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetFlurryChance(THIS, uint8 value)"); { Mob *THIS; uint8 value = (uint8) SvIV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFlurryChance(value); } XSRETURN_EMPTY; @@ -5506,12 +7800,20 @@ XS(XS_Mob_GetFlurryChance); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetFlurryChance) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetFlurryChance(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetFlurryChance(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFlurryChance(); XSprePUSH; PUSHu((UV) RETVAL); @@ -5523,7 +7825,7 @@ XS(XS_Mob_GetSpellStat); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpellStat) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::GetSpellStat(THIS, uint32 spell_id, string stat, uint8 slot)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: Mob::GetSpellStat(THIS, uint32 spell_id, string stat, uint8 slot)"); { Mob *THIS; int32 RETVAL; @@ -5531,7 +7833,15 @@ XS(XS_Mob_GetSpellStat) { Const_char *stat = (Const_char *) SvPV_nolen(ST(2)); uint8 slot = (uint8) SvUV(ST(3)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 4) { slot = 0; } @@ -5546,13 +7856,21 @@ XS(XS_Mob_GetSpecialAbility); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpecialAbility) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetSpecialAbility(THIS, int special_ability)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetSpecialAbility(THIS, int special_ability)"); { int RETVAL; Mob *THIS; int ability = SvIV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpecialAbility(ability); XSprePUSH; PUSHi((IV) RETVAL); @@ -5564,14 +7882,22 @@ XS(XS_Mob_GetSpecialAbilityParam); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_GetSpecialAbilityParam) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::GetSpecialAbilityParam(THIS, int special_ability, int param)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetSpecialAbilityParam(THIS, int special_ability, int param)"); { int RETVAL; Mob *THIS; int ability = SvIV(ST(1)); int param = SvIV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpecialAbilityParam(ability, param); XSprePUSH; PUSHi((IV) RETVAL); @@ -5583,12 +7909,20 @@ XS(XS_Mob_SetSpecialAbility); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetSpecialAbility) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Mob::SetSpecialAbility(THIS, int ability, int value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetSpecialAbility(THIS, int ability, int value)"); { Mob *THIS; int ability = SvIV(ST(1)); int value = SvIV(ST(2)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSpecialAbility(ability, value); } XSRETURN_EMPTY; @@ -5598,13 +7932,21 @@ XS(XS_Mob_SetSpecialAbilityParam); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetSpecialAbilityParam) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Mob::SetSpecialAbilityParam(THIS, int ability, int param, int value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SetSpecialAbilityParam(THIS, int ability, int param, int value)"); { Mob *THIS; int ability = SvIV(ST(1)); int param = SvIV(ST(2)); int value = SvIV(ST(3)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSpecialAbilityParam(ability, param, value); } XSRETURN_EMPTY; @@ -5614,10 +7956,18 @@ XS(XS_Mob_ClearSpecialAbilities); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ClearSpecialAbilities) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::ClearSpecialAbilities(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::ClearSpecialAbilities(THIS)"); { Mob *THIS; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearSpecialAbilities(); } XSRETURN_EMPTY; @@ -5627,11 +7977,19 @@ XS(XS_Mob_ProcessSpecialAbilities); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_ProcessSpecialAbilities) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::ProcessSpecialAbilities(THIS, string str)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::ProcessSpecialAbilities(THIS, string str)"); { Mob *THIS; const char *str = (const char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ProcessSpecialAbilities(str); } XSRETURN_EMPTY; @@ -5641,12 +7999,20 @@ XS(XS_Mob_CanClassEquipItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_CanClassEquipItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::CanClassEquipItem(THIS, uint32 item_id)"); // @categories Inventory and Items, Script Utility + Perl_croak(aTHX_ "Usage: Mob::CanClassEquipItem(THIS, uint32 item_id)"); { Mob *THIS; bool RETVAL; uint32 item_id = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanClassEquipItem(item_id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5658,11 +8024,19 @@ XS(XS_Mob_IsFeared); XS(XS_Mob_IsFeared) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsFeared(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsFeared(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsFeared(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5674,11 +8048,19 @@ XS(XS_Mob_IsBlind); XS(XS_Mob_IsBlind) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsBlind(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsBlind(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsBlind(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5690,12 +8072,21 @@ XS(XS_Mob_SeeInvisible); XS(XS_Mob_SeeInvisible) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::SeeInvisible(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SeeInvisible(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SeeInvisible(); XSprePUSH; PUSHu((UV) RETVAL); @@ -5707,11 +8098,19 @@ XS(XS_Mob_SeeInvisibleUndead); XS(XS_Mob_SeeInvisibleUndead) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::SeeInvisibleUndead(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SeeInvisibleUndead(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SeeInvisibleUndead(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5723,11 +8122,19 @@ XS(XS_Mob_SeeHide); XS(XS_Mob_SeeHide) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::SeeHide(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SeeHide(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SeeHide(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5739,11 +8146,19 @@ XS(XS_Mob_SeeImprovedHide); XS(XS_Mob_SeeImprovedHide) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::SeeImprovedHide(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::SeeImprovedHide(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SeeImprovedHide(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5755,12 +8170,21 @@ XS(XS_Mob_GetNimbusEffect1); XS(XS_Mob_GetNimbusEffect1) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect1(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect1(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNimbusEffect1(); XSprePUSH; PUSHu((UV) RETVAL); @@ -5772,12 +8196,21 @@ XS(XS_Mob_GetNimbusEffect2); XS(XS_Mob_GetNimbusEffect2) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect2(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect2(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNimbusEffect2(); XSprePUSH; PUSHu((UV) RETVAL); @@ -5789,12 +8222,21 @@ XS(XS_Mob_GetNimbusEffect3); XS(XS_Mob_GetNimbusEffect3) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect3(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::GetNimbusEffect3(THIS)"); { Mob *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNimbusEffect3(); XSprePUSH; PUSHu((UV) RETVAL); @@ -5806,11 +8248,19 @@ XS(XS_Mob_IsTargetable); XS(XS_Mob_IsTargetable) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsTargetable(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::IsTargetable(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTargetable(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5822,11 +8272,19 @@ XS(XS_Mob_HasShieldEquiped); XS(XS_Mob_HasShieldEquiped) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasShieldEquiped(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::HasShieldEquiped(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasShieldEquiped(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5838,11 +8296,19 @@ XS(XS_Mob_HasTwoHandBluntEquiped); XS(XS_Mob_HasTwoHandBluntEquiped) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasTwoHandBluntEquiped(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::HasTwoHandBluntEquiped(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasTwoHandBluntEquiped(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5854,11 +8320,19 @@ XS(XS_Mob_HasTwoHanderEquipped); XS(XS_Mob_HasTwoHanderEquipped) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasTwoHanderEquipped(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::HasTwoHanderEquipped(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasTwoHanderEquipped(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5870,13 +8344,22 @@ XS(XS_Mob_GetHerosForgeModel); XS(XS_Mob_GetHerosForgeModel) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetHerosForgeModel(THIS, uint8 material_slot)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetHerosForgeModel(THIS, uint8 material_slot)"); { Mob *THIS; int32 RETVAL; uint8 material_slot = (uint8) SvUV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHerosForgeModel(material_slot); XSprePUSH; PUSHi((IV) RETVAL); @@ -5888,13 +8371,22 @@ XS(XS_Mob_IsEliteMaterialItem); XS(XS_Mob_IsEliteMaterialItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::IsEliteMaterialItem(THIS, uint8 material_slot)"); // @categories Script Utility, Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::IsEliteMaterialItem(THIS, uint8 material_slot)"); { Mob *THIS; uint32 RETVAL; uint8 material_slot = (uint8) SvUV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsEliteMaterialItem(material_slot); XSprePUSH; PUSHu((UV) RETVAL); @@ -5906,12 +8398,21 @@ XS(XS_Mob_GetBaseSize); XS(XS_Mob_GetBaseSize) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBaseSize(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetBaseSize(THIS)"); { Mob *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetBaseSize(); XSprePUSH; PUSHn((double) RETVAL); @@ -5923,11 +8424,19 @@ XS(XS_Mob_HasOwner); XS(XS_Mob_HasOwner) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasOwner(THIS)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::HasOwner(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasOwner(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5939,11 +8448,19 @@ XS(XS_Mob_IsPet); XS(XS_Mob_IsPet) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsPet(THIS)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::IsPet(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsPet(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5955,11 +8472,19 @@ XS(XS_Mob_HasPet); XS(XS_Mob_HasPet) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::HasPet(THIS)"); // @categories Pet + Perl_croak(aTHX_ "Usage: Mob::HasPet(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->HasPet(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5971,11 +8496,19 @@ XS(XS_Mob_IsSilenced); XS(XS_Mob_IsSilenced) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsSilenced(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsSilenced(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsSilenced(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -5987,11 +8520,19 @@ XS(XS_Mob_IsAmnesiad); XS(XS_Mob_IsAmnesiad) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsAmnesiad(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::IsAmnesiad(THIS)"); { Mob *THIS; bool RETVAL; - VALIDATE_THIS_IS_MOB; + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsAmnesiad(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -6003,12 +8544,21 @@ XS(XS_Mob_GetMeleeMitigation); XS(XS_Mob_GetMeleeMitigation) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetMeleeMitigation(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: Mob::GetMeleeMitigation(THIS)"); { Mob *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMeleeMitigation(); XSprePUSH; PUSHi((IV) RETVAL); @@ -6020,13 +8570,22 @@ XS(XS_Mob_TryMoveAlong); XS(XS_Mob_TryMoveAlong) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::TryMoveAlong(THIS, float distance, float angle, bool send)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: Mob::TryMoveAlong(THIS, float distance, float angle, bool send)"); { Mob *THIS; float distance = (float) SvNV(ST(1)); float angle = (float) SvNV(ST(2)); bool send = true; - VALIDATE_THIS_IS_MOB; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Mob *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items == 4) send = (bool) SvTRUE(ST(3)); @@ -6035,224 +8594,6 @@ XS(XS_Mob_TryMoveAlong) { XSRETURN_EMPTY; } -XS(XS_Mob_GetClassName); -XS(XS_Mob_GetClassName) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetClassName(THIS)"); - { - Mob* THIS; - Const_char *class_name; - dXSTARG; - VALIDATE_THIS_IS_MOB; - class_name = GetClassIDName(THIS->GetClass()); - sv_setpv(TARG, class_name); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_GetRaceName); -XS(XS_Mob_GetRaceName) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetRaceName(THIS)"); - { - Mob* THIS; - Const_char *race_name; - dXSTARG; - VALIDATE_THIS_IS_MOB; - race_name = GetRaceIDName(THIS->GetRace()); - sv_setpv(TARG, race_name); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_DeleteBucket); -XS(XS_Mob_DeleteBucket) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::DeleteBucket(THIS, std::string bucket_name)"); // @categories Script Utility - { - Mob* THIS; - std::string bucket_name = (std::string) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_MOB; - THIS->DeleteBucket(bucket_name); - } - XSRETURN_EMPTY; -} - -XS(XS_Mob_GetBucket); -XS(XS_Mob_GetBucket) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetBucket(THIS, std::string bucket_name)"); // @categories Script Utility - { - Mob* THIS; - dXSTARG; - std::string bucket_name = (std::string) SvPV_nolen(ST(1)); - std::string bucket_value; - VALIDATE_THIS_IS_MOB; - bucket_value = THIS->GetBucket(bucket_name); - sv_setpv(TARG, bucket_value.c_str()); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_GetBucketExpires); -XS(XS_Mob_GetBucketExpires) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetBucketExpires(THIS, std::string bucket_name)"); // @categories Script Utility - { - Mob* THIS; - dXSTARG; - std::string bucket_name = (std::string) SvPV_nolen(ST(1)); - std::string bucket_expiration; - VALIDATE_THIS_IS_MOB; - bucket_expiration = THIS->GetBucketExpires(bucket_name); - sv_setpv(TARG, bucket_expiration.c_str()); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_GetBucketKey); -XS(XS_Mob_GetBucketKey) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetBucketKey(THIS)"); // @categories Script Utility - { - Mob* THIS; - dXSTARG; - std::string bucket_key; - VALIDATE_THIS_IS_MOB; - bucket_key = THIS->GetBucketKey(); - sv_setpv(TARG, bucket_key.c_str()); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_GetBucketRemaining); -XS(XS_Mob_GetBucketRemaining) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: Mob::GetBucketRemaining(THIS, std::string bucket_name)"); // @categories Script Utility - { - Mob* THIS; - dXSTARG; - std::string bucket_name = (std::string) SvPV_nolen(ST(1)); - std::string bucket_remaining; - VALIDATE_THIS_IS_MOB; - bucket_remaining = THIS->GetBucketRemaining(bucket_name); - sv_setpv(TARG, bucket_remaining.c_str()); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - -XS(XS_Mob_SetBucket); -XS(XS_Mob_SetBucket) { - dXSARGS; - if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Mob::SetBucket(THIS, std::string bucket_name, std::string bucket_value, [std::string expiration])"); // @categories Script Utility - { - Mob* THIS; - std::string key = (std::string) SvPV_nolen(ST(1)); - std::string value = (std::string) SvPV_nolen(ST(2)); - std::string expiration; - VALIDATE_THIS_IS_MOB; - if (items == 4) - expiration = (std::string) SvPV_nolen(ST(3)); - - THIS->SetBucket(key, value, expiration); - } - XSRETURN_EMPTY; -} - -XS(XS_Mob_IsHorse); -XS(XS_Mob_IsHorse) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::IsHorse(THIS)"); // @categories Script Utility - { - Mob *THIS; - bool RETVAL; - VALIDATE_THIS_IS_MOB; - RETVAL = THIS->IsHorse(); - ST(0) = boolSV(RETVAL); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - -XS(XS_Mob_GetHateListByDistance); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Mob_GetHateListByDistance) { - dXSARGS; - int num_entries = 0; - if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Mob::GetHateListByDistance(THIS, int distance)"); // @categories Hate and Aggro - { - Mob *THIS; - int distance = 0; - VALIDATE_THIS_IS_MOB; - if (items == 2) - distance = (int) SvIV(ST(1)); - - auto list = THIS->GetHateListByDistance(distance); - for (auto hate_entry : list) { - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "HateEntry", (void *) hate_entry); - XPUSHs(ST(0)); - num_entries++; - } - } - XSRETURN(num_entries); -} - -XS(XS_Mob_GetHateClosest); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Mob_GetHateClosest) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetHateClosest(THIS)"); // @categories Hate and Aggro - { - Mob *THIS; - Mob *closest_mob; - VALIDATE_THIS_IS_MOB; - closest_mob = THIS->GetHateClosest(); - ST(0) = sv_newmortal(); - sv_setref_pv(ST(0), "Mob", (void *) closest_mob); - } - XSRETURN(1); -} - -XS(XS_Mob_GetLastName); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Mob_GetLastName) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: Mob::GetLastName(THIS)"); // @categories Script Utility - { - Mob *THIS; - Const_char *last_name; - dXSTARG; - VALIDATE_THIS_IS_MOB; - last_name = THIS->GetLastName(); - sv_setpv(TARG, last_name); - XSprePUSH; - PUSHTARG; - } - XSRETURN(1); -} - #ifdef __cplusplus extern "C" #endif @@ -6282,7 +8623,6 @@ XS(boot_Mob) { newXSproto(strcpy(buf, "IsDoor"), XS_Mob_IsDoor, file, "$"); newXSproto(strcpy(buf, "IsTrap"), XS_Mob_IsTrap, file, "$"); newXSproto(strcpy(buf, "IsBeacon"), XS_Mob_IsBeacon, file, "$"); - newXSproto(strcpy(buf, "IsHorse"), XS_Mob_IsHorse, file, "$"); newXSproto(strcpy(buf, "CastToClient"), XS_Mob_CastToClient, file, "$"); newXSproto(strcpy(buf, "CastToNPC"), XS_Mob_CastToNPC, file, "$"); newXSproto(strcpy(buf, "CastToMob"), XS_Mob_CastToMob, file, "$"); @@ -6328,7 +8668,6 @@ XS(boot_Mob) { newXSproto(strcpy(buf, "GetBaseGender"), XS_Mob_GetBaseGender, file, "$"); newXSproto(strcpy(buf, "GetDeity"), XS_Mob_GetDeity, file, "$"); newXSproto(strcpy(buf, "GetRace"), XS_Mob_GetRace, file, "$"); - newXSproto(strcpy(buf, "GetRaceName"), XS_Mob_GetRaceName, file, "$"); newXSproto(strcpy(buf, "GetGender"), XS_Mob_GetGender, file, "$"); newXSproto(strcpy(buf, "GetTexture"), XS_Mob_GetTexture, file, "$"); newXSproto(strcpy(buf, "GetHelmTexture"), XS_Mob_GetHelmTexture, file, "$"); @@ -6343,7 +8682,6 @@ XS(boot_Mob) { newXSproto(strcpy(buf, "GetDrakkinTattoo"), XS_Mob_GetDrakkinTattoo, file, "$"); newXSproto(strcpy(buf, "GetDrakkinDetails"), XS_Mob_GetDrakkinDetails, file, "$"); newXSproto(strcpy(buf, "GetClass"), XS_Mob_GetClass, file, "$"); - newXSproto(strcpy(buf, "GetClassName"), XS_Mob_GetClassName, file, "$"); newXSproto(strcpy(buf, "GetLevel"), XS_Mob_GetLevel, file, "$"); newXSproto(strcpy(buf, "GetCleanName"), XS_Mob_GetCleanName, file, "$"); newXSproto(strcpy(buf, "GetTarget"), XS_Mob_GetTarget, file, "$"); @@ -6593,15 +8931,6 @@ XS(boot_Mob) { newXSproto(strcpy(buf, "IsAmnesiad"), XS_Mob_IsAmnesiad, file, "$"); newXSproto(strcpy(buf, "GetMeleeMitigation"), XS_Mob_GetMeleeMitigation, file, "$"); newXSproto(strcpy(buf, "TryMoveAlong"), XS_Mob_TryMoveAlong, file, "$$$;$"); - newXSproto(strcpy(buf, "DeleteBucket"), XS_Mob_DeleteBucket, file, "$$"); - newXSproto(strcpy(buf, "GetBucket"), XS_Mob_GetBucket, file, "$$"); - newXSproto(strcpy(buf, "GetBucketExpires"), XS_Mob_GetBucketExpires, file, "$$"); - newXSproto(strcpy(buf, "GetBucketKey"), XS_Mob_GetBucketKey, file, "$"); - newXSproto(strcpy(buf, "GetBucketRemaining"), XS_Mob_GetBucketRemaining, file, "$$"); - newXSproto(strcpy(buf, "SetBucket"), XS_Mob_SetBucket, file, "$$$;$"); - newXSproto(strcpy(buf, "GetHateClosest"), XS_Mob_GetHateClosest, file, "$"); - newXSproto(strcpy(buf, "GetHateListByDistance"), XS_Mob_GetHateListByDistance, file, "$;$"); - newXSproto(strcpy(buf, "GetLastName"), XS_Mob_GetLastName, file, "$"); XSRETURN_YES; } diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index 99cd83b86..59a55e49f 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -44,28 +44,24 @@ typedef const char Const_char; #undef THIS #endif -#define VALIDATE_THIS_IS_NPC \ - do { \ - if (sv_derived_from(ST(0), "NPC")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(NPC*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type NPC"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_NPC_SignalNPC); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SignalNPC) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SignalNPC(THIS, int signal_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SignalNPC(THIS, int signal_id)"); { NPC *THIS; int _signal_id = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SignalNPC(_signal_id); } XSRETURN_EMPTY; @@ -75,13 +71,21 @@ XS(XS_NPC_CheckNPCFactionAlly); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_CheckNPCFactionAlly) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::CheckNPCFactionAlly(THIS, int32 faction_id)"); // @categories Faction + Perl_croak(aTHX_ "Usage: NPC::CheckNPCFactionAlly(THIS, int32 faction_id)"); { NPC *THIS; FACTION_VALUE RETVAL; dXSTARG; int32 other_faction = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CheckNPCFactionAlly(other_faction); XSprePUSH; PUSHi((IV) RETVAL); @@ -93,7 +97,7 @@ XS(XS_NPC_AddItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AddItem) { dXSARGS; if (items < 2 || items > 10) - Perl_croak(aTHX_ "Usage: NPC::AddItem(THIS, uint32 item_id, [uint16 charges = 0], [bool equip_item = true], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint32 aug6 = 0])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: NPC::AddItem(THIS, uint32 item_id, [uint16 charges = 0], [bool equip_item = true], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint32 aug6 = 0])"); { NPC *THIS; uint32 itemid = (uint32) SvUV(ST(1)); @@ -105,7 +109,15 @@ XS(XS_NPC_AddItem) { uint32 aug4 = 0; uint32 aug5 = 0; uint32 aug6 = 0; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 2) charges = (uint16) SvUV(ST(2)); if (items > 3) @@ -132,10 +144,18 @@ XS(XS_NPC_AddLootTable); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AddLootTable) { dXSARGS; if (items < 1) - Perl_croak(aTHX_ "Usage: NPC::AddLootTable(THIS, [uint32 loottable_id])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: NPC::AddLootTable(THIS, [uint32 loottable_id])"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + uint32 loottable_id = 0; if (items > 1) { @@ -152,13 +172,21 @@ XS(XS_NPC_RemoveItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_RemoveItem) { dXSARGS; if (items < 2 || items > 4) - Perl_croak(aTHX_ "Usage: NPC::RemoveItem(THIS, uint32 item_id, [uint16 quantity = 0], [uint16 slot_id = 0])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: NPC::RemoveItem(THIS, uint32 item_id, [uint16 quantity = 0], [uint16 slot_id = 0])"); { NPC *THIS; uint32 item_id = (uint32) SvUV(ST(1)); uint16 quantity; uint16 slot; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 3) quantity = 0; else { @@ -180,10 +208,18 @@ XS(XS_NPC_ClearItemList); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_ClearItemList) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::ClearItemList(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: NPC::ClearItemList(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearItemList(); } XSRETURN_EMPTY; @@ -193,14 +229,22 @@ XS(XS_NPC_AddCash); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AddCash) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: NPC::AddCash(THIS, uint16 copper, uint16 silver, uint16 gold, uint16 platinum)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::AddCash(THIS, uint16 copper, uint16 silver, uint16 gold, uint16 platinum)"); { NPC *THIS; uint16 in_copper = (uint16) SvUV(ST(1)); uint16 in_silver = (uint16) SvUV(ST(2)); uint16 in_gold = (uint16) SvUV(ST(3)); uint16 in_platinum = (uint16) SvUV(ST(4)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddCash(in_copper, in_silver, in_gold, in_platinum); } XSRETURN_EMPTY; @@ -210,10 +254,18 @@ XS(XS_NPC_RemoveCash); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_RemoveCash) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::RemoveCash(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::RemoveCash(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveCash(); } XSRETURN_EMPTY; @@ -223,12 +275,20 @@ XS(XS_NPC_CountLoot); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_CountLoot) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::CountLoot(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: NPC::CountLoot(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CountLoot(); XSprePUSH; PUSHu((UV) RETVAL); @@ -240,12 +300,20 @@ XS(XS_NPC_GetLoottableID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetLoottableID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetLoottableID(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetLoottableID(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLoottableID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -257,12 +325,20 @@ XS(XS_NPC_GetCopper); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetCopper) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetCopper(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::GetCopper(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCopper(); XSprePUSH; PUSHu((UV) RETVAL); @@ -274,12 +350,20 @@ XS(XS_NPC_GetSilver); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSilver) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSilver(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::GetSilver(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSilver(); XSprePUSH; PUSHu((UV) RETVAL); @@ -291,12 +375,20 @@ XS(XS_NPC_GetGold); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetGold) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetGold(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::GetGold(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGold(); XSprePUSH; PUSHu((UV) RETVAL); @@ -308,12 +400,20 @@ XS(XS_NPC_GetPlatinum); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetPlatinum) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetPlatinum(THIS)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::GetPlatinum(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPlatinum(); XSprePUSH; PUSHu((UV) RETVAL); @@ -325,11 +425,19 @@ XS(XS_NPC_SetCopper); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetCopper) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetCopper(THIS, uint32 copper_amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::SetCopper(THIS, uint32 copper_amount)"); { NPC *THIS; uint32 amt = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetCopper(amt); } XSRETURN_EMPTY; @@ -339,11 +447,19 @@ XS(XS_NPC_SetSilver); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSilver) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSilver(THIS, uint32 silver_amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::SetSilver(THIS, uint32 silver_amount)"); { NPC *THIS; uint32 amt = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSilver(amt); } XSRETURN_EMPTY; @@ -353,11 +469,19 @@ XS(XS_NPC_SetGold); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetGold) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetGold(THIS, uint32 gold_amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::SetGold(THIS, uint32 gold_amount)"); { NPC *THIS; uint32 amt = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetGold(amt); } XSRETURN_EMPTY; @@ -367,11 +491,19 @@ XS(XS_NPC_SetPlatinum); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetPlatinum) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetPlatinum(THIS, uint32 platinum_amount)"); // @categories Currency and Points + Perl_croak(aTHX_ "Usage: NPC::SetPlatinum(THIS, uint32 platinum_amount)"); { NPC *THIS; uint32 amt = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPlatinum(amt); } XSRETURN_EMPTY; @@ -381,11 +513,19 @@ XS(XS_NPC_SetGrid); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetGrid) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetGrid(THIS, int32 grid_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SetGrid(THIS, int32 grid_id)"); { NPC *THIS; int32 grid_ = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetGrid(grid_); } XSRETURN_EMPTY; @@ -395,11 +535,19 @@ XS(XS_NPC_SetSaveWaypoint); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSaveWaypoint) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSaveWaypoint(THIS, uint16 waypoint)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SetSaveWaypoint(THIS, uint16 waypoint)"); { NPC *THIS; uint16 waypoint = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSaveWaypoint(waypoint); } XSRETURN_EMPTY; @@ -409,11 +557,19 @@ XS(XS_NPC_SetSp2); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSp2) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSp2(THIS, uint32 set_spawn_group_id)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::SetSp2(THIS, uint32 set_spawn_group_id)"); { NPC *THIS; uint32 sg2 = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSpawnGroupId(sg2); } XSRETURN_EMPTY; @@ -423,12 +579,20 @@ XS(XS_NPC_GetWaypointMax); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetWaypointMax) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetWaypointMax(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::GetWaypointMax(THIS)"); { NPC *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetWaypointMax(); XSprePUSH; PUSHu((UV) RETVAL); @@ -440,12 +604,20 @@ XS(XS_NPC_GetGrid); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetGrid) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetGrid(THIS)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: NPC::GetGrid(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGrid(); XSprePUSH; PUSHi((IV) RETVAL); @@ -457,12 +629,20 @@ XS(XS_NPC_GetSp2); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSp2) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSp2(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSp2(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpawnGroupId(); XSprePUSH; PUSHu((UV) RETVAL); @@ -474,12 +654,20 @@ XS(XS_NPC_GetNPCFactionID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetNPCFactionID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetNPCFactionID(THIS)"); // @categories Faction, Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetNPCFactionID(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNPCFactionID(); XSprePUSH; PUSHi((IV) RETVAL); @@ -491,12 +679,20 @@ XS(XS_NPC_GetPrimaryFaction); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetPrimaryFaction) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetPrimaryFaction(THIS)"); // @categories Faction, Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetPrimaryFaction(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPrimaryFaction(); XSprePUSH; PUSHi((IV) RETVAL); @@ -508,13 +704,21 @@ XS(XS_NPC_GetNPCHate); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetNPCHate) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::GetNPCHate(THIS, Mob* entity)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: NPC::GetNPCHate(THIS, Mob* entity)"); { NPC *THIS; int32 RETVAL; dXSTARG; Mob *in_ent; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); in_ent = INT2PTR(Mob *, tmp); @@ -534,12 +738,20 @@ XS(XS_NPC_IsOnHatelist); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_IsOnHatelist) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::IsOnHatelist(THIS, Mob* target)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: NPC::IsOnHatelist(THIS, Mob* target)"); { NPC *THIS; bool RETVAL; Mob *p; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); p = INT2PTR(Mob *, tmp); @@ -559,11 +771,19 @@ XS(XS_NPC_RemoveFromHateList); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_RemoveFromHateList) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::RemoveFromHateList(THIS, Mob* target)"); // @categories Hate and Aggro + Perl_croak(aTHX_ "Usage: NPC::RemoveFromHateList(THIS, Mob* target)"); { NPC *THIS; Mob *ent; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); ent = INT2PTR(Mob *, tmp); @@ -583,11 +803,19 @@ XS(XS_NPC_SetNPCFactionID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetNPCFactionID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetNPCFactionID(THIS, int32 faction_id)"); // @categories Faction + Perl_croak(aTHX_ "Usage: NPC::SetNPCFactionID(THIS, int32 faction_id)"); { NPC *THIS; int32 in = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetNPCFactionID(in); } XSRETURN_EMPTY; @@ -597,12 +825,20 @@ XS(XS_NPC_GetMaxDMG); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetMaxDMG) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetMaxDMG(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetMaxDMG(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxDMG(); XSprePUSH; PUSHu((UV) RETVAL); @@ -619,7 +855,15 @@ XS(XS_NPC_GetMinDMG) { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMinDMG(); XSprePUSH; PUSHu((UV) RETVAL); @@ -632,11 +876,19 @@ XS(XS_NPC_IsAnimal); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_IsAnimal) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::IsAnimal(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::IsAnimal(THIS)"); { NPC *THIS; bool RETVAL; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsAnimal(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -648,12 +900,20 @@ XS(XS_NPC_GetPetSpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetPetSpellID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetPetSpellID(THIS)"); // @categories Stats and Attributes, Pet + Perl_croak(aTHX_ "Usage: NPC::GetPetSpellID(THIS)"); { NPC *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPetSpellID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -665,11 +925,19 @@ XS(XS_NPC_SetPetSpellID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetPetSpellID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetPetSpellID(THIS, uint16 amount)"); // @categories Pet + Perl_croak(aTHX_ "Usage: NPC::SetPetSpellID(THIS, uint16 amount)"); { NPC *THIS; uint16 amt = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPetSpellID(amt); } XSRETURN_EMPTY; @@ -679,13 +947,21 @@ XS(XS_NPC_GetMaxDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetMaxDamage) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::GetMaxDamage(THIS, uint8 target_level)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetMaxDamage(THIS, uint8 target_level)"); { NPC *THIS; uint32 RETVAL; dXSTARG; uint8 tlevel = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxDamage(tlevel); XSprePUSH; PUSHu((UV) RETVAL); @@ -697,11 +973,19 @@ XS(XS_NPC_SetTaunting); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetTaunting) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetTaunting(THIS, bool toggle)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SetTaunting(THIS, bool toggle)"); { NPC *THIS; bool toggle = (bool) SvTRUE(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetTaunting(toggle); } XSRETURN_EMPTY; @@ -715,7 +999,15 @@ XS(XS_NPC_IsTaunting) { { NPC *THIS; bool RETVAL; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsTaunting(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -727,11 +1019,19 @@ XS(XS_NPC_PickPocket); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_PickPocket) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::PickPocket(THIS, Client* thief)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: NPC::PickPocket(THIS, Client* thief)"); { NPC *THIS; Client *thief; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); thief = INT2PTR(Client *, tmp); @@ -749,11 +1049,19 @@ XS(XS_NPC_StartSwarmTimer); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_StartSwarmTimer) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::StartSwarmTimer(THIS, uint32 duration)"); // @categories Script Utility, Pet + Perl_croak(aTHX_ "Usage: NPC::StartSwarmTimer(THIS, uint32 duration)"); { NPC *THIS; uint32 duration = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->StartSwarmTimer(duration); } XSRETURN_EMPTY; @@ -763,11 +1071,19 @@ XS(XS_NPC_DoClassAttacks); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_DoClassAttacks) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::DoClassAttacks(THIS, Mob* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::DoClassAttacks(THIS, Mob* target)"); { NPC *THIS; Mob *target; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); target = INT2PTR(Mob *, tmp); @@ -790,7 +1106,15 @@ XS(XS_NPC_GetMaxWp) { NPC *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetMaxWp(); XSprePUSH; PUSHi((IV) RETVAL); @@ -802,11 +1126,19 @@ XS(XS_NPC_DisplayWaypointInfo); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_DisplayWaypointInfo) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::DisplayWaypointInfo(THIS, Client* target)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::DisplayWaypointInfo(THIS, Client* target)"); { NPC *THIS; Client *to; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); to = INT2PTR(Client *, tmp); @@ -824,10 +1156,18 @@ XS(XS_NPC_CalculateNewWaypoint); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_CalculateNewWaypoint) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::CalculateNewWaypoint(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::CalculateNewWaypoint(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->CalculateNewWaypoint(); } XSRETURN_EMPTY; @@ -837,11 +1177,19 @@ XS(XS_NPC_AssignWaypoints); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AssignWaypoints) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::AssignWaypoints(THIS, uint32 grid_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::AssignWaypoints(THIS, uint32 grid_id)"); { NPC *THIS; uint32 grid = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AssignWaypoints(grid); } XSRETURN_EMPTY; @@ -851,10 +1199,18 @@ XS(XS_NPC_SetWaypointPause); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetWaypointPause) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::SetWaypointPause(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SetWaypointPause(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetWaypointPause(); } XSRETURN_EMPTY; @@ -864,11 +1220,19 @@ XS(XS_NPC_UpdateWaypoint); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_UpdateWaypoint) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::UpdateWaypoint(THIS, int wp_index)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::UpdateWaypoint(THIS, int wp_index)"); { NPC *THIS; int wp_index = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->UpdateWaypoint(wp_index); } XSRETURN_EMPTY; @@ -878,10 +1242,18 @@ XS(XS_NPC_StopWandering); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_StopWandering) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::StopWandering(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::StopWandering(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->StopWandering(); } XSRETURN_EMPTY; @@ -891,10 +1263,18 @@ XS(XS_NPC_ResumeWandering); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_ResumeWandering) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::ResumeWandering(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::ResumeWandering(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ResumeWandering(); } XSRETURN_EMPTY; @@ -904,11 +1284,19 @@ XS(XS_NPC_PauseWandering); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_PauseWandering) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::PauseWandering(THIS, int pause_time)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::PauseWandering(THIS, int pause_time)"); { NPC *THIS; int pausetime = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->PauseWandering(pausetime); } XSRETURN_EMPTY; @@ -918,19 +1306,33 @@ XS(XS_NPC_MoveTo); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_MoveTo) { dXSARGS; if (items != 4 && items != 5 && items != 6) - Perl_croak(aTHX_ "Usage: NPC::MoveTo(THIS, float x, float y, float z, [float heading], [bool save_guard_location = false])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::MoveTo(THIS, float x, float y, float z, [float heading], [bool save_guard_location = false])"); { NPC *THIS; float mtx = (float) SvNV(ST(1)); float mty = (float) SvNV(ST(2)); float mtz = (float) SvNV(ST(3)); - float mth = 0; - bool saveguard = false; - VALIDATE_THIS_IS_NPC; + float mth; + bool saveguard; + if (items > 4) mth = (float) SvNV(ST(4)); + else + mth = 0; + if (items > 5) saveguard = (bool) SvTRUE(ST(5)); + else + saveguard = false; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + auto position = glm::vec4(mtx, mty, mtz, mth); THIS->MoveTo(position, saveguard); } @@ -941,10 +1343,18 @@ XS(XS_NPC_NextGuardPosition); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_NextGuardPosition) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::NextGuardPosition(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::NextGuardPosition(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->NextGuardPosition(); } XSRETURN_EMPTY; @@ -954,14 +1364,22 @@ XS(XS_NPC_SaveGuardSpot); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SaveGuardSpot) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: NPC::SaveGuardSpot(THIS, x, y, z, heading)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SaveGuardSpot(THIS, x, y, z, heading)"); { NPC *THIS; float x = (float)SvNV(ST(1)); float y = (float)SvNV(ST(2)); float z = (float)SvNV(ST(3)); float heading = (float)SvNV(ST(4)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SaveGuardSpot(glm::vec4(x, y, z, heading)); } XSRETURN_EMPTY; @@ -971,11 +1389,19 @@ XS(XS_NPC_IsGuarding); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_IsGuarding) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::IsGuarding(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::IsGuarding(THIS)"); { NPC *THIS; bool RETVAL; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsGuarding(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -987,7 +1413,7 @@ XS(XS_NPC_AI_SetRoambox); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AI_SetRoambox) { dXSARGS; if (items < 6 || items > 8) - Perl_croak(aTHX_ "Usage: NPC::AI_SetRoambox(THIS, float distance, float max_x, float min_x, float max_y, float min_y, [uint32 max_delay = 2500], [uint32 min_delay = 2500])"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::AI_SetRoambox(THIS, float distance, float max_x, float min_x, float max_y, float min_y, [uint32 max_delay = 2500], [uint32 min_delay = 2500])"); { NPC *THIS; float iDist = (float) SvNV(ST(1)); @@ -997,7 +1423,15 @@ XS(XS_NPC_AI_SetRoambox) { float iMinY = (float) SvNV(ST(5)); uint32 iDelay; uint32 iMinDelay; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 7) { iMinDelay = 2500; iDelay = 2500; @@ -1018,12 +1452,20 @@ XS(XS_NPC_GetNPCSpellsID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetNPCSpellsID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetNPCSpellsID(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetNPCSpellsID(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetNPCSpellsID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1035,12 +1477,20 @@ XS(XS_NPC_GetSpawnPointID); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnPointID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointID(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointID(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpawnPointID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1052,12 +1502,21 @@ XS(XS_NPC_GetSpawnPointX); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnPointX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointX(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointX(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetSpawnPoint().x; XSprePUSH; PUSHn((double) RETVAL); @@ -1069,12 +1528,21 @@ XS(XS_NPC_GetSpawnPointY); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnPointY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointY(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointY(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetSpawnPoint().y; XSprePUSH; PUSHn((double) RETVAL); @@ -1086,12 +1554,21 @@ XS(XS_NPC_GetSpawnPointZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnPointZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointZ(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointZ(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetSpawnPoint().z; XSprePUSH; PUSHn((double) RETVAL); @@ -1103,12 +1580,21 @@ XS(XS_NPC_GetSpawnPointH); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnPointH) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointH(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnPointH(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetSpawnPoint().w; XSprePUSH; PUSHn((double) RETVAL); @@ -1120,12 +1606,21 @@ XS(XS_NPC_GetGuardPointX); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetGuardPointX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetGuardPointX(THIS)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: NPC::GetGuardPointX(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetGuardPoint().x; XSprePUSH; PUSHn((double) RETVAL); @@ -1137,12 +1632,21 @@ XS(XS_NPC_GetGuardPointY); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetGuardPointY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetGuardPointY(THIS)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: NPC::GetGuardPointY(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetGuardPoint().y; XSprePUSH; PUSHn((double) RETVAL); @@ -1154,12 +1658,21 @@ XS(XS_NPC_GetGuardPointZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetGuardPointZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetGuardPointZ(THIS)"); // @categories Script Utility, Spawns + Perl_croak(aTHX_ "Usage: NPC::GetGuardPointZ(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetGuardPoint().z; XSprePUSH; PUSHn((double) RETVAL); @@ -1171,11 +1684,19 @@ XS(XS_NPC_SetPrimSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetPrimSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetPrimSkill(THIS, int skill_id)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::SetPrimSkill(THIS, int skill_id)"); { NPC *THIS; int skill_id = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetPrimSkill(skill_id); } XSRETURN_EMPTY; @@ -1185,11 +1706,19 @@ XS(XS_NPC_SetSecSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSecSkill) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSecSkill(THIS, int skill_id)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::SetSecSkill(THIS, int skill_id)"); { NPC *THIS; int skill_id = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSecSkill(skill_id); } XSRETURN_EMPTY; @@ -1199,12 +1728,20 @@ XS(XS_NPC_GetPrimSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetPrimSkill) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetPrimSkill(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetPrimSkill(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPrimSkill(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1216,12 +1753,20 @@ XS(XS_NPC_GetSecSkill); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSecSkill) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSecSkill(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetSecSkill(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSecSkill(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1233,12 +1778,20 @@ XS(XS_NPC_GetSwarmOwner); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSwarmOwner) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSwarmOwner(THIS)"); // @categories Pet + Perl_croak(aTHX_ "Usage: NPC::GetSwarmOwner(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSwarmOwner(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1250,12 +1803,20 @@ XS(XS_NPC_GetSwarmTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSwarmTarget) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSwarmTarget(THIS)"); // @categories Pet + Perl_croak(aTHX_ "Usage: NPC::GetSwarmTarget(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSwarmTarget(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1267,11 +1828,19 @@ XS(XS_NPC_SetSwarmTarget); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSwarmTarget) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSwarmTarget(THIS, int target_id)"); // @categories Pet + Perl_croak(aTHX_ "Usage: NPC::SetSwarmTarget(THIS, int target_id)"); { NPC *THIS; int target_id = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSwarmTarget(target_id); } XSRETURN_EMPTY; @@ -1281,12 +1850,20 @@ XS(XS_NPC_ModifyNPCStat); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_ModifyNPCStat) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: NPC::ModifyNPCStat(THIS, string key, string value)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::ModifyNPCStat(THIS, string key, string value)"); { NPC *THIS; Const_char *identifier = (Const_char *) SvPV_nolen(ST(1)); Const_char *newValue = (Const_char *) SvPV_nolen(ST(2)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ModifyNPCStat(identifier, newValue); } XSRETURN_EMPTY; @@ -1296,7 +1873,7 @@ XS(XS_NPC_AddSpellToNPCList); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_AddSpellToNPCList) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: NPC::AddAISpell(THIS, int priority, int spell_id, int type, int mana_cost, int recast_delay, int resist_adjust)"); // @categories Spells and Disciplines, Script Utility + Perl_croak(aTHX_ "Usage: NPC::AddAISpell(THIS, int priority, int spell_id, int type, int mana_cost, int recast_delay, int resist_adjust)"); { NPC *THIS; int priority = (int) SvIV(ST(1)); @@ -1305,7 +1882,15 @@ XS(XS_NPC_AddSpellToNPCList) { int mana_cost = (int) SvIV(ST(4)); int recast_delay = (int) SvIV(ST(5)); int resist_adjust = (int) SvIV(ST(6)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->AddSpellToNPCList(priority, spell_id, type, mana_cost, recast_delay, resist_adjust, 0, 0); } XSRETURN_EMPTY; @@ -1315,11 +1900,19 @@ XS(XS_NPC_RemoveSpellFromNPCList); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_RemoveSpellFromNPCList) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::RemoveAISpell(THIS, int spell_id)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: NPC::RemoveAISpell(THIS, int spell_id)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveSpellFromNPCList(spell_id); } XSRETURN_EMPTY; @@ -1329,11 +1922,19 @@ XS(XS_NPC_SetSpellFocusDMG); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSpellFocusDMG) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSpellFocusDMG(THIS, int new_spell_focus_dmg)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::SetSpellFocusDMG(THIS, int new_spell_focus_dmg)"); { NPC *THIS; int32 NewSpellFocusDMG = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSpellFocusDMG(NewSpellFocusDMG); } XSRETURN_EMPTY; @@ -1343,12 +1944,20 @@ XS(XS_NPC_GetSpellFocusDMG); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpellFocusDMG) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusDMG(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusDMG(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpellFocusDMG(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1360,11 +1969,19 @@ XS(XS_NPC_SetSpellFocusHeal); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSpellFocusHeal) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::SetSpellFocusHeal(THIS, int32 new_spell_focus_heal)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::SetSpellFocusHeal(THIS, int32 new_spell_focus_heal)"); { NPC *THIS; int32 NewSpellFocusHeal = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSpellFocusHeal(NewSpellFocusHeal); } XSRETURN_EMPTY; @@ -1374,12 +1991,20 @@ XS(XS_NPC_GetSpellFocusHeal); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpellFocusHeal) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusHeal(THIS)"); // @categories Spells and Disciplines + Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusHeal(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSpellFocusHeal(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1391,12 +2016,20 @@ XS(XS_NPC_GetSlowMitigation); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSlowMitigation) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSlowMitigation(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetSlowMitigation(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSlowMitigation(); XSprePUSH; PUSHn((double) RETVAL); @@ -1408,12 +2041,20 @@ XS(XS_NPC_GetAttackSpeed); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetAttackSpeed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetAttackSpeed(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetAttackSpeed(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAttackSpeed(); XSprePUSH; PUSHn((double) RETVAL); @@ -1425,12 +2066,20 @@ XS(XS_NPC_GetAttackDelay); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetAttackDelay) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetAttackDelay(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetAttackDelay(THIS)"); { NPC *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAttackDelay(); XSprePUSH; PUSHn((double) RETVAL); @@ -1442,12 +2091,20 @@ XS(XS_NPC_GetAccuracyRating); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetAccuracyRating) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetAccuracyRating(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetAccuracyRating(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAccuracyRating(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1459,12 +2116,20 @@ XS(XS_NPC_GetAvoidanceRating); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetAvoidanceRating) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetAvoidanceRating(THIS)"); // @categories Stats and Attributes + Perl_croak(aTHX_ "Usage: NPC::GetAvoidanceyRating(THIS)"); { NPC *THIS; int32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAvoidanceRating(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1476,12 +2141,20 @@ XS(XS_NPC_GetSpawnKillCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSpawnKillCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetSpawnKillCount(THIS)"); // @categories Spawns + Perl_croak(aTHX_ "Usage: NPC::GetSpawnKillCount(THIS)"); { NPC *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + RETVAL = THIS->GetSpawnKillCount(); XSprePUSH; PUSHu((UV) RETVAL); @@ -1493,12 +2166,20 @@ XS(XS_NPC_GetScore); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetScore) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetScore(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::GetScore(THIS)"); { NPC *THIS; int RETVAL; dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + RETVAL = THIS->GetScore(); XSprePUSH; PUSHi((UV) RETVAL); @@ -1510,11 +2191,18 @@ XS(XS_NPC_MerchantOpenShop); XS(XS_NPC_MerchantOpenShop) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::MerchantOpenShop(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::MerchantOpenShop(THIS)"); { NPC *THIS; dXSTARG; - VALIDATE_THIS_IS_NPC; + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->MerchantOpenShop(); } XSRETURN_EMPTY; @@ -1524,11 +2212,18 @@ XS(XS_NPC_MerchantCloseShop); XS(XS_NPC_MerchantCloseShop) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::MerchantCloseShop(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::MerchantCloseShop(THIS)"); { NPC *THIS; dXSTARG; - VALIDATE_THIS_IS_NPC; + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->MerchantCloseShop(); } XSRETURN_EMPTY; @@ -1538,13 +2233,21 @@ XS(XS_NPC_AddMeleeProc); XS(XS_NPC_AddMeleeProc) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: NPC::AddMeleeProc(THIS, int spell_id, int chance)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::AddMeleeProc(THIS, int spell_id, int chance)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); int chance = (int) SvIV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->AddProcToWeapon(spell_id, true, chance); } XSRETURN_EMPTY; @@ -1554,13 +2257,21 @@ XS(XS_NPC_AddRangedProc); XS(XS_NPC_AddRangedProc) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: NPC::AddRangedProc(THIS, int spell_id, int chance)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::AddRangedProc(THIS, int spell_id, int chance)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); int chance = (int) SvIV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->AddRangedProc(spell_id, chance); } XSRETURN_EMPTY; @@ -1570,13 +2281,21 @@ XS(XS_NPC_AddDefensiveProc); XS(XS_NPC_AddDefensiveProc) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: NPC::AddDefensiveProc(THIS, int spell_id, int chance)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::AddDefensiveProc(THIS, int spell_id, int chance)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); int chance = (int) SvIV(ST(2)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->AddDefensiveProc(spell_id, chance); } XSRETURN_EMPTY; @@ -1586,12 +2305,20 @@ XS(XS_NPC_RemoveMeleeProc); XS(XS_NPC_RemoveMeleeProc) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::RemoveMeleeProc(THIS, int spell_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::RemoveMeleeProc(THIS, int spell_id)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->RemoveProcFromWeapon(spell_id, false); } XSRETURN_EMPTY; @@ -1601,12 +2328,20 @@ XS(XS_NPC_RemoveRangedProc); XS(XS_NPC_RemoveRangedProc) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::RemoveRangedProc(THIS, int spell_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::RemoveRangedProc(THIS, int spell_id)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->RemoveRangedProc(spell_id, false); } XSRETURN_EMPTY; @@ -1616,12 +2351,20 @@ XS(XS_NPC_RemoveDefensiveProc); XS(XS_NPC_RemoveDefensiveProc) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::RemoveDefensiveProc(THIS, int spell_id)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::RemoveDefensiveProc(THIS, int spell_id)"); { NPC *THIS; int spell_id = (int) SvIV(ST(1)); dXSTARG; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + THIS->RemoveDefensiveProc(spell_id, false); } XSRETURN_EMPTY; @@ -1631,11 +2374,19 @@ XS(XS_NPC_ChangeLastName); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_ChangeLastName) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: NPC::ChangeLastName(THIS, string name)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::ChangeLastName(THIS, string name)"); { NPC *THIS; char *name = nullptr; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { name = (char *) SvPV_nolen(ST(1)); } THIS->ChangeLastName(name); @@ -1647,10 +2398,18 @@ XS(XS_NPC_ClearLastName); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_ClearLastName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::ClearLastName(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::ClearLastName(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearLastName(); } XSRETURN_EMPTY; @@ -1660,11 +2419,19 @@ XS(XS_NPC_GetCombatState); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetCombatState) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::GetCombatState(THIS)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::GetCombatState(THIS)"); { NPC *THIS; bool RETVAL; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCombatEvent(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -1676,7 +2443,7 @@ XS(XS_NPC_SetSimpleRoamBox); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSimpleRoamBox) { dXSARGS; if (items < 2) - Perl_croak(aTHX_ "Usage: NPC::SetSimpleRoamBox(THIS, box_size, move_distance, move_delay)"); // @categories Script Utility + Perl_croak(aTHX_ "Usage: NPC::SetSimpleRoamBox(THIS, box_size, move_distance, move_delay)"); { NPC *THIS; @@ -1691,7 +2458,18 @@ XS(XS_NPC_SetSimpleRoamBox) { if (items >= 4) { move_delay = (int) SvIV(ST(3)); } - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } + else { + Perl_croak(aTHX_ "THIS is not of type NPC"); + } + if (THIS == nullptr) { + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + } + THIS->SetSimpleRoamBox(box_size, move_distance, move_delay); } XSRETURN_EMPTY; @@ -1702,45 +2480,23 @@ XS(XS_NPC_RecalculateSkills); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_RecalculateSkills) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::RecalculateSkills(THIS)"); // @categories Skills and Recipes + Perl_croak(aTHX_ "Usage: NPC::RecalculateSkills(THIS)"); { NPC *THIS; - VALIDATE_THIS_IS_NPC; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(NPC *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RecalculateSkills(); } XSRETURN_EMPTY; } -XS(XS_NPC_ScaleNPC); /* prototype to pass -Wmissing-prototypes */ -XS(XS_NPC_ScaleNPC) { - dXSARGS; - if (items != 2) - Perl_croak(aTHX_ "Usage: NPC::ScaleNPC(THIS, uint8 npc_level)"); - { - NPC *THIS; - uint8 npc_level = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_NPC; - THIS->ScaleNPC(npc_level); - } - XSRETURN_EMPTY; -} - -XS(XS_NPC_IsRaidTarget); /* prototype to pass -Wmissing-prototypes */ -XS(XS_NPC_IsRaidTarget) { - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: NPC::IsRaidTarget(THIS)"); // @categories Stats and Attributes - { - NPC *THIS; - bool is_raid_target; - VALIDATE_THIS_IS_NPC; - is_raid_target = THIS->IsRaidTarget(); - ST(0) = boolSV(is_raid_target); - sv_2mortal(ST(0)); - } - XSRETURN(1); -} - #ifdef __cplusplus extern "C" #endif @@ -1857,8 +2613,6 @@ XS(boot_NPC) { newXSproto(strcpy(buf, "GetCombatState"), XS_NPC_GetCombatState, file, "$"); newXSproto(strcpy(buf, "SetSimpleRoamBox"), XS_NPC_SetSimpleRoamBox, file, "$$;$$"); newXSproto(strcpy(buf, "RecalculateSkills"), XS_NPC_RecalculateSkills, file, "$"); - newXSproto(strcpy(buf, "ScaleNPC"), XS_NPC_ScaleNPC, file, "$$"); - newXSproto(strcpy(buf, "IsRaidTarget"), XS_NPC_IsRaidTarget, file, "$"); XSRETURN_YES; } diff --git a/zone/perl_object.cpp b/zone/perl_object.cpp index c1e5d76db..df2589de4 100644 --- a/zone/perl_object.cpp +++ b/zone/perl_object.cpp @@ -42,28 +42,23 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_OBJECT \ - do { \ - if (sv_derived_from(ST(0), "Object")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Object*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Object"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_Object_IsGroundSpawn); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_IsGroundSpawn) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::IsGroundSpawn(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::IsGroundSpawn(THIS)"); { Object *THIS; bool RETVAL; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsGroundSpawn(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -76,10 +71,18 @@ XS(XS_Object_Close); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_Close) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::Close(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::Close(THIS)"); { Object *THIS; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Close(); } XSRETURN_EMPTY; @@ -90,11 +93,19 @@ XS(XS_Object_Delete); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_Delete) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Object::Delete(THIS, [bool reset_state = false])"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::Delete(THIS, [bool reset_state = false])"); { Object *THIS; bool reset_state; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 2) reset_state = false; else { @@ -109,10 +120,18 @@ XS(XS_Object_StartDecay); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_StartDecay) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::StartDecay(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::StartDecay(THIS)"); { Object *THIS; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->StartDecay(); } XSRETURN_EMPTY; @@ -123,11 +142,19 @@ XS(XS_Object_DeleteItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_DeleteItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::DeleteItem(THIS, uint8 index)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::DeleteItem(THIS, uint8 index)"); { Object *THIS; uint8 index = (uint8) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->DeleteItem(index); } XSRETURN_EMPTY; @@ -137,11 +164,19 @@ XS(XS_Object_IsObject); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_IsObject) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::IsObject(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::IsObject(THIS)"); { Object *THIS; bool RETVAL; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsObject(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -154,11 +189,19 @@ XS(XS_Object_Save); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_Save) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::Save(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::Save(THIS)"); { Object *THIS; bool RETVAL; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->Save(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -171,11 +214,19 @@ XS(XS_Object_SetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetID(THIS, uint16 id)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetID(THIS, uint16 id)"); { Object *THIS; uint16 set_id = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetID(set_id); } XSRETURN_EMPTY; @@ -186,10 +237,18 @@ XS(XS_Object_ClearUser); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_ClearUser) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::ClearUser(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::ClearUser(THIS)"); { Object *THIS; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ClearUser(); } XSRETURN_EMPTY; @@ -200,12 +259,20 @@ XS(XS_Object_GetDBID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetDBID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetDBID(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetDBID(THIS)"); { Object *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDBID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -217,12 +284,20 @@ XS(XS_Object_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetID(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetID(THIS)"); { Object *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -234,12 +309,20 @@ XS(XS_Object_GetX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetX) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetX(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetX(THIS)"); { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetX(); XSprePUSH; PUSHn((double) RETVAL); @@ -251,12 +334,20 @@ XS(XS_Object_GetY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetY) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetY(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetY(THIS)"); { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetY(); XSprePUSH; PUSHn((double) RETVAL); @@ -268,12 +359,20 @@ XS(XS_Object_GetZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetZ) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetZ(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetZ(THIS)"); { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetZ(); XSprePUSH; PUSHn((double) RETVAL); @@ -285,12 +384,20 @@ XS(XS_Object_GetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetHeading) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetHeading(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetHeading(THIS)"); { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHeadingData(); XSprePUSH; PUSHn((double) RETVAL); @@ -302,12 +409,20 @@ XS(XS_Object_VarSave); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_VarSave) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::VarSave(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::VarSave(THIS)"); { Object *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->VarSave(); XSprePUSH; PUSHu((UV) RETVAL); @@ -320,12 +435,20 @@ XS(XS_Object_GetType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetType) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetType(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetType(THIS)"); { Object *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetType(); XSprePUSH; PUSHu((UV) RETVAL); @@ -338,11 +461,19 @@ XS(XS_Object_SetType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetType) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetType(THIS, uint32 type)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetType(THIS, uint32 type)"); { Object *THIS; uint32 type = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetType(type); } XSRETURN_EMPTY; @@ -353,12 +484,20 @@ XS(XS_Object_GetIcon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetIcon) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetIcon(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetIcon(THIS)"); { Object *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetIcon(); XSprePUSH; PUSHu((UV) RETVAL); @@ -371,11 +510,19 @@ XS(XS_Object_SetIcon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetIcon) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetIcon(THIS, uint32 icon)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetIcon(THIS, uint32 icon)"); { Object *THIS; uint32 icon = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetIcon(icon); } XSRETURN_EMPTY; @@ -386,12 +533,20 @@ XS(XS_Object_GetItemID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetItemID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetItemID(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetItemID(THIS)"); { Object *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItemID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -404,11 +559,19 @@ XS(XS_Object_SetItemID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetItemID) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetItemID(THIS, uint32 item_id)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetItemID(THIS, uint32 item_id)"); { Object *THIS; uint32 itemid = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetItemID(itemid); } XSRETURN_EMPTY; @@ -418,13 +581,21 @@ XS(XS_Object_SetLocation); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetLocation) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Object::SetLocation(THIS, float x, float y, float z)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetLocation(THIS, float x, float y, float z)"); { Object *THIS; float x = (float) SvNV(ST(1)); float y = (float) SvNV(ST(2)); float z = (float) SvNV(ST(3)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetLocation(x, y, z); } XSRETURN_EMPTY; @@ -434,11 +605,19 @@ XS(XS_Object_SetX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetX) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetX(THIS, float x)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetX(THIS, float x)"); { Object *THIS; float pos = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetX(pos); } XSRETURN_EMPTY; @@ -448,11 +627,19 @@ XS(XS_Object_SetY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetY) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetY(THIS, float y)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetY(THIS, float y)"); { Object *THIS; float pos = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetY(pos); } XSRETURN_EMPTY; @@ -462,11 +649,19 @@ XS(XS_Object_SetZ); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetZ) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetZ(THIS, float z)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetZ(THIS, float z)"); { Object *THIS; float pos = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetZ(pos); } XSRETURN_EMPTY; @@ -476,11 +671,19 @@ XS(XS_Object_SetHeading); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetHeading) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetHeading(THIS, float heading)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetHeading(THIS, float heading)"); { Object *THIS; float heading = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetHeading(heading); } XSRETURN_EMPTY; @@ -490,11 +693,19 @@ XS(XS_Object_SetModelName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetModelName) { dXSARGS; if (items < 1 || items > 2) - Perl_croak(aTHX_ "Usage: Object::SetModelName(THIS, string name)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetModelName(THIS, string name)"); { Object *THIS; char *name = nullptr; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items > 1) { name = (char *) SvPV_nolen(ST(1)); } THIS->SetModelName(name); @@ -505,12 +716,20 @@ XS(XS_Object_GetModelName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetModelName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetModelName(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetModelName(THIS)"); { Object *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetModelName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -523,11 +742,19 @@ XS(XS_Object_Repop); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_Repop) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::Repop(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::Repop(THIS)"); { Object *THIS; dXSTARG; - VALIDATE_THIS_IS_OBJECT; THIS->Repop(); + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Repop(); } XSRETURN_EMPTY; } @@ -536,11 +763,19 @@ XS(XS_Object_Depop); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_Depop) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::Depop(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::Depop(THIS)"); { Object *THIS; dXSTARG; - VALIDATE_THIS_IS_OBJECT; THIS->Depop(); + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Depop(); } XSRETURN_EMPTY; } @@ -550,13 +785,21 @@ XS(XS_Object_GetEntityVariable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetEntityVariable) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::GetEntityVariable(THIS, string key)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetEntityVariable(THIS, string key)"); { Object *THIS; Const_char *id = SvPV_nolen(ST(1)); Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetEntityVariable(id); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -569,12 +812,20 @@ XS(XS_Object_EntityVariableExists); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_EntityVariableExists) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::EntityVariableExists(THIS, string key)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::EntityVariableExists(THIS, string key)"); { Object *THIS; Const_char *id = SvPV_nolen(ST(1)); bool RETVAL; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->EntityVariableExists(id); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -586,12 +837,20 @@ XS(XS_Object_SetEntityVariable); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetEntityVariable) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Object::SetEntityVariable(THIS, string key, string var)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetEntityVariable(THIS, string key, string var)"); { Object *THIS; Const_char *id = SvPV_nolen(ST(1)); const char *var = (const char *) SvPV_nolen(ST(2)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetEntityVariable(id, var); } XSRETURN_EMPTY; @@ -601,12 +860,20 @@ XS(XS_Object_GetSolidType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetSolidType) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetSolidType(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetSolidType(THIS)"); { Object *THIS; uint16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSolidType(); XSprePUSH; PUSHu((UV) RETVAL); @@ -619,11 +886,19 @@ XS(XS_Object_SetSolidType); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetSolidType) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetSolidType(THIS, uint16 type)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetSolidType(THIS, uint16 type)"); { Object *THIS; uint16 type = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSolidType(type); } XSRETURN_EMPTY; @@ -633,12 +908,20 @@ XS(XS_Object_GetSize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_GetSize) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Object::GetSize(THIS)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::GetSize(THIS)"); { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSize(); XSprePUSH; PUSHn((double) RETVAL); @@ -651,11 +934,19 @@ XS(XS_Object_SetSize); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetSize) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetSize(THIS, float size)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetSize(THIS, float size)"); { Object *THIS; float size = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetSize(size); } XSRETURN_EMPTY; @@ -665,11 +956,19 @@ XS(XS_Object_SetTiltX); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetTiltX) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetTiltX(THIS, float tilt_x)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetTiltX(THIS, float tilt_x)"); { Object *THIS; float pos = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetTiltX(pos); } XSRETURN_EMPTY; @@ -679,11 +978,19 @@ XS(XS_Object_SetTiltY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Object_SetTiltY) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Object::SetTiltY(THIS, float tilt_y)"); // @categories Objects + Perl_croak(aTHX_ "Usage: Object::SetTiltY(THIS, float tilt_y)"); { Object *THIS; float pos = (float) SvNV(ST(1)); - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetTiltY(pos); } XSRETURN_EMPTY; @@ -698,7 +1005,15 @@ XS(XS_Object_GetTiltX) { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTiltX(); XSprePUSH; PUSHn((double) RETVAL); @@ -715,7 +1030,15 @@ XS(XS_Object_GetTiltY) { Object *THIS; float RETVAL; dXSTARG; - VALIDATE_THIS_IS_OBJECT; + + if (sv_derived_from(ST(0), "Object")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Object *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Object"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetTiltY(); XSprePUSH; PUSHn((double) RETVAL); diff --git a/zone/perl_perlpacket.cpp b/zone/perl_perlpacket.cpp index 36fb97440..f23cf36d7 100644 --- a/zone/perl_perlpacket.cpp +++ b/zone/perl_perlpacket.cpp @@ -41,19 +41,6 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_PACKET \ - do { \ - if (sv_derived_from(ST(0), "PerlPacket")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(PerlPacket*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type PerlPacket"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_PerlPacket_new); /* prototype to pass -Wmissing-prototypes */ XS(XS_PerlPacket_new) { @@ -93,7 +80,16 @@ XS(XS_PerlPacket_DESTROY) Perl_croak(aTHX_ "Usage: PerlPacket::DESTROY(THIS)"); { PerlPacket * THIS; - VALIDATE_THIS_IS_PACKET; + + if (SvROK(ST(0))) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not a reference"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + delete THIS; } XSRETURN_EMPTY; @@ -109,7 +105,16 @@ XS(XS_PerlPacket_SetOpcode) PerlPacket * THIS; bool RETVAL; char * opcode = (char *)SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->SetOpcode(opcode); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -126,7 +131,16 @@ XS(XS_PerlPacket_Resize) { PerlPacket * THIS; uint32 len = (uint32)SvUV(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Resize(len); } XSRETURN_EMPTY; @@ -141,7 +155,16 @@ XS(XS_PerlPacket_SendTo) { PerlPacket * THIS; Client * who; - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV*)SvRV(ST(1))); who = INT2PTR(Client *,tmp); @@ -164,7 +187,16 @@ XS(XS_PerlPacket_SendToAll) Perl_croak(aTHX_ "Usage: PerlPacket::SendToAll(THIS)"); { PerlPacket * THIS; - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SendToAll(); } XSRETURN_EMPTY; @@ -178,7 +210,16 @@ XS(XS_PerlPacket_Zero) Perl_croak(aTHX_ "Usage: PerlPacket::Zero(THIS)"); { PerlPacket * THIS; - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Zero(); } XSRETURN_EMPTY; @@ -194,7 +235,16 @@ XS(XS_PerlPacket_FromArray) PerlPacket * THIS; int * numbers; uint32 length = (uint32)SvUV(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + AV *av_numbers; if (SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVAV) av_numbers = (AV*)SvRV(ST(1)); @@ -227,7 +277,16 @@ XS(XS_PerlPacket_SetByte) PerlPacket * THIS; uint32 pos = (uint32)SvUV(ST(1)); uint8 val = (uint8)SvUV(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetByte(pos, val); } XSRETURN_EMPTY; @@ -243,7 +302,16 @@ XS(XS_PerlPacket_SetShort) PerlPacket * THIS; uint32 pos = (uint32)SvUV(ST(1)); uint16 val = (uint16)SvUV(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetShort(pos, val); } XSRETURN_EMPTY; @@ -259,7 +327,16 @@ XS(XS_PerlPacket_SetLong) PerlPacket * THIS; uint32 pos = (uint32)SvUV(ST(1)); uint32 val = (uint32)SvUV(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetLong(pos, val); } XSRETURN_EMPTY; @@ -275,7 +352,16 @@ XS(XS_PerlPacket_SetFloat) PerlPacket * THIS; uint32 pos = (uint32)SvUV(ST(1)); float val = (float)SvNV(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetFloat(pos, val); } XSRETURN_EMPTY; @@ -291,7 +377,16 @@ XS(XS_PerlPacket_SetString) PerlPacket * THIS; uint32 pos = (uint32)SvUV(ST(1)); char * str = (char *)SvPV_nolen(ST(2)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetString(pos, str); } XSRETURN_EMPTY; @@ -308,7 +403,16 @@ XS(XS_PerlPacket_SetEQ1319) uint32 pos = (uint32)SvUV(ST(1)); float part13 = (float)SvNV(ST(2)); float part19 = (float)SvNV(ST(3)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetEQ1319(pos, part13, part19); } XSRETURN_EMPTY; @@ -325,7 +429,16 @@ XS(XS_PerlPacket_SetEQ1913) uint32 pos = (uint32)SvUV(ST(1)); float part19 = (float)SvNV(ST(2)); float part13 = (float)SvNV(ST(3)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetEQ1913(pos, part19, part13); } XSRETURN_EMPTY; @@ -342,7 +455,16 @@ XS(XS_PerlPacket_GetByte) uint8 RETVAL; dXSTARG; uint32 pos = (uint32)SvUV(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetByte(pos); XSprePUSH; PUSHu((UV)RETVAL); } @@ -360,7 +482,16 @@ XS(XS_PerlPacket_GetShort) uint16 RETVAL; dXSTARG; uint32 pos = (uint32)SvUV(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetShort(pos); XSprePUSH; PUSHu((UV)RETVAL); } @@ -378,7 +509,16 @@ XS(XS_PerlPacket_GetLong) uint32 RETVAL; dXSTARG; uint32 pos = (uint32)SvUV(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLong(pos); XSprePUSH; PUSHu((UV)RETVAL); } @@ -396,7 +536,16 @@ XS(XS_PerlPacket_GetFloat) float RETVAL; dXSTARG; uint32 pos = (uint32)SvUV(ST(1)); - VALIDATE_THIS_IS_PACKET; + + if (sv_derived_from(ST(0), "PerlPacket")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(PerlPacket *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type PerlPacket"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetFloat(pos); XSprePUSH; PUSHn((double)RETVAL); } diff --git a/zone/perl_player_corpse.cpp b/zone/perl_player_corpse.cpp index 8979d2102..69be0f48c 100644 --- a/zone/perl_player_corpse.cpp +++ b/zone/perl_player_corpse.cpp @@ -42,29 +42,25 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_CORPSE \ - do { \ - if (sv_derived_from(ST(0), "Corpse")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Corpse*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Corpse"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_Corpse_GetCharID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetCharID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetCharID(THIS)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetCharID(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCharID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -76,12 +72,20 @@ XS(XS_Corpse_GetDecayTime); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetDecayTime) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetDecayTime(THIS)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetDecayTime(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetDecayTime(); XSprePUSH; PUSHu((UV) RETVAL); @@ -93,10 +97,18 @@ XS(XS_Corpse_Lock); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_Lock) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::Lock(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::Lock(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Lock(); } XSRETURN_EMPTY; @@ -106,10 +118,18 @@ XS(XS_Corpse_UnLock); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_UnLock) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::UnLock(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::UnLock(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->UnLock(); } XSRETURN_EMPTY; @@ -119,11 +139,19 @@ XS(XS_Corpse_IsLocked); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_IsLocked) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::IsLocked(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::IsLocked(THIS)"); { Corpse *THIS; bool RETVAL; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsLocked(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -135,10 +163,18 @@ XS(XS_Corpse_ResetLooter); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_ResetLooter) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::ResetLooter(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::ResetLooter(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->ResetLooter(); } XSRETURN_EMPTY; @@ -148,12 +184,20 @@ XS(XS_Corpse_GetDBID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetDBID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetDBID(THIS)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetDBID(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCorpseDBID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -165,12 +209,20 @@ XS(XS_Corpse_GetOwnerName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetOwnerName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetOwnerName(THIS)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetOwnerName(THIS)"); { Corpse *THIS; char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetOwnerName(); sv_setpv(TARG, RETVAL); XSprePUSH; @@ -183,11 +235,19 @@ XS(XS_Corpse_SetDecayTimer); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_SetDecayTimer) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Corpse::SetDecayTimer(THIS, uint32 decay_time)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::SetDecayTimer(THIS, uint32 decay_time)"); { Corpse *THIS; uint32 decaytime = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetDecayTimer(decaytime); } XSRETURN_EMPTY; @@ -197,11 +257,19 @@ XS(XS_Corpse_IsEmpty); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_IsEmpty) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::IsEmpty(THIS)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Corpse::IsEmpty(THIS)"); { Corpse *THIS; bool RETVAL; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsEmpty(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -213,13 +281,21 @@ XS(XS_Corpse_AddItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_AddItem) { dXSARGS; if (items < 3 || items > 4) - Perl_croak(aTHX_ "Usage: Corpse::AddItem(THIS, uint32 item_id, uint16 charges, [unt16 slot = 0])"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Corpse::AddItem(THIS, uint32 item_id, uint16 charges, [unt16 slot = 0])"); { Corpse *THIS; uint32 itemnum = (uint32) SvUV(ST(1)); uint16 charges = (uint16) SvUV(ST(2)); int16 slot; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (items < 4) slot = 0; else { @@ -235,13 +311,21 @@ XS(XS_Corpse_GetWornItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetWornItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Corpse::GetWornItem(THIS, equipSlot)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetWornItem(THIS, equipSlot)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; int16 equipSlot = (int16) SvIV(ST(1)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetWornItem(equipSlot); XSprePUSH; PUSHu((UV) RETVAL); @@ -253,11 +337,19 @@ XS(XS_Corpse_RemoveItem); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_RemoveItem) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Corpse::RemoveItem(THIS, uint16 loot_slot)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Corpse::RemoveItem(THIS, uint16 loot_slot)"); { Corpse *THIS; uint16 lootslot = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveItem(lootslot); } XSRETURN_EMPTY; @@ -267,14 +359,22 @@ XS(XS_Corpse_SetCash); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_SetCash) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: Corpse::SetCash(THIS, uint16 copper, uint16 silver, uint16 gold, uint16 platinum)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::SetCash(THIS, uint16 copper, uint16 silver, uint16 gold, uint16 platinum)"); { Corpse *THIS; uint16 in_copper = (uint16) SvUV(ST(1)); uint16 in_silver = (uint16) SvUV(ST(2)); uint16 in_gold = (uint16) SvUV(ST(3)); uint16 in_platinum = (uint16) SvUV(ST(4)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SetCash(in_copper, in_silver, in_gold, in_platinum); } XSRETURN_EMPTY; @@ -284,10 +384,18 @@ XS(XS_Corpse_RemoveCash); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_RemoveCash) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::RemoveCash(THIS)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::RemoveCash(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->RemoveCash(); } XSRETURN_EMPTY; @@ -297,12 +405,20 @@ XS(XS_Corpse_CountItems); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_CountItems) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::CountItems(THIS)"); // @categories Inventory and Items, Corpse + Perl_croak(aTHX_ "Usage: Corpse::CountItems(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CountItems(); XSprePUSH; PUSHu((UV) RETVAL); @@ -314,10 +430,18 @@ XS(XS_Corpse_Delete); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_Delete) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::Delete(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::Delete(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->Delete(); } XSRETURN_EMPTY; @@ -327,12 +451,20 @@ XS(XS_Corpse_GetCopper); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetCopper) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetCopper(THIS)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetCopper(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCopper(); XSprePUSH; PUSHu((UV) RETVAL); @@ -344,12 +476,20 @@ XS(XS_Corpse_GetSilver); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetSilver) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetSilver(THIS)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetSilver(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetSilver(); XSprePUSH; PUSHu((UV) RETVAL); @@ -361,12 +501,20 @@ XS(XS_Corpse_GetGold); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetGold) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetGold(THIS)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetGold(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGold(); XSprePUSH; PUSHu((UV) RETVAL); @@ -378,12 +526,20 @@ XS(XS_Corpse_GetPlatinum); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_GetPlatinum) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::GetPlatinum(THIS)"); // @categories Currency and Points, Corpse + Perl_croak(aTHX_ "Usage: Corpse::GetPlatinum(THIS)"); { Corpse *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetPlatinum(); XSprePUSH; PUSHu((UV) RETVAL); @@ -395,12 +551,20 @@ XS(XS_Corpse_Summon); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_Summon) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Corpse::Summon(THIS, Client* client, bool is_spell)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::Summon(THIS, Client* client, bool is_spell)"); { Corpse *THIS; Client *client; bool spell = (bool) SvTRUE(ST(2)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Client")) { IV tmp = SvIV((SV *) SvRV(ST(1))); client = INT2PTR(Client *, tmp); @@ -418,12 +582,20 @@ XS(XS_Corpse_CastRezz); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_CastRezz) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Corpse::CastRezz(THIS, uint16 spell_id, [Mob* caster = nullptr])"); // @categories Spells and Disciplines, Corpse + Perl_croak(aTHX_ "Usage: Corpse::CastRezz(THIS, uint16 spell_id, [Mob* caster = nullptr])"); { Corpse *THIS; uint16 spellid = (uint16) SvUV(ST(1)); Mob *Caster; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(2), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(2))); Caster = INT2PTR(Mob *, tmp); @@ -441,10 +613,18 @@ XS(XS_Corpse_CompleteRezz); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_CompleteRezz) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::CompleteRezz(THIS)"); // @categories Spells and Disciplines, Corpse + Perl_croak(aTHX_ "Usage: Corpse::CompleteRezz(THIS)"); { Corpse *THIS; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->CompleteResurrection(); } XSRETURN_EMPTY; @@ -454,12 +634,20 @@ XS(XS_Corpse_CanMobLoot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_CanMobLoot) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Corpse::CanMobLoot(THIS, int character_id)"); // @categories Script Utility, Corpse + Perl_croak(aTHX_ "Usage: Corpse::CanMobLoot(THIS, int character_id)"); { Corpse *THIS; bool RETVAL; int charid = (int) SvIV(ST(1)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->CanPlayerLoot(charid); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -471,12 +659,20 @@ XS(XS_Corpse_AllowMobLoot); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_AllowMobLoot) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Corpse::AllowMobLoot(THIS, Mob* them, uint8 slot)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Corpse::AllowMobLoot(THIS, Mob* them, uint8 slot)"); { Corpse *THIS; Mob *them; uint8 slot = (uint8) SvUV(ST(2)); - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); them = INT2PTR(Mob *, tmp); @@ -494,11 +690,19 @@ XS(XS_Corpse_AddLooter); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_AddLooter) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Corpse::AddLooter(THIS, Mob* who)"); // @categories Account and Character, Corpse + Perl_croak(aTHX_ "Usage: Corpse::AddLooter(THIS, Mob* who)"); { Corpse *THIS; Mob *who; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); who = INT2PTR(Mob *, tmp); @@ -516,11 +720,19 @@ XS(XS_Corpse_IsRezzed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Corpse_IsRezzed) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Corpse::IsRezzed(THIS)"); // @categories Corpse + Perl_croak(aTHX_ "Usage: Corpse::IsRezzed(THIS)"); { Corpse *THIS; bool RETVAL; - VALIDATE_THIS_IS_CORPSE; + + if (sv_derived_from(ST(0), "Corpse")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Corpse *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Corpse"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRezzed(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); diff --git a/zone/perl_questitem.cpp b/zone/perl_questitem.cpp index e1029b33a..f30728147 100644 --- a/zone/perl_questitem.cpp +++ b/zone/perl_questitem.cpp @@ -34,29 +34,24 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_ITEM \ - do { \ - if (sv_derived_from(ST(0), "QuestItem")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(EQ::ItemInstance*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); - XS(XS_QuestItem_GetName); XS(XS_QuestItem_GetName) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: QuestItem::GetName(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::GetName(THIS)"); { EQ::ItemInstance *THIS; Const_char *RETVAL; dXSTARG; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItem()->Name; sv_setpv(TARG, RETVAL); XSprePUSH; @@ -69,11 +64,19 @@ XS(XS_QuestItem_SetScale); XS(XS_QuestItem_SetScale) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, float scale_multiplier)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, float scale_multiplier)"); { EQ::ItemInstance *THIS; float Mult; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + Mult = (float) SvNV(ST(1)); if (THIS->IsScaling()) { @@ -87,12 +90,20 @@ XS(XS_QuestItem_ItemSay); XS(XS_QuestItem_ItemSay) { dXSARGS; if (items != 2 && items != 3) - Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, string text [int language_id])"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, string text [int language_id])"); { EQ::ItemInstance *THIS; Const_char *text; int lang = 0; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + text = SvPV_nolen(ST(1)); if (items == 3) lang = (int) SvUV(ST(2)); @@ -106,12 +117,20 @@ XS(XS_QuestItem_IsType); /* prototype to pass -Wmissing-prototypes */ XS(XS_QuestItem_IsType) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: QuestItem::IsType(THIS, type)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::IsType(THIS, type)"); { EQ::ItemInstance *THIS; bool RETVAL; uint32 type = (int32) SvIV(ST(1)); - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsType((EQ::item::ItemClass) type); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -123,11 +142,19 @@ XS(XS_QuestItem_IsAttuned); /* prototype to pass -Wmissing-prototypes */ XS(XS_QuestItem_IsAttuned) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: QuestItem::IsAttuned(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::IsAttuned(THIS)"); { EQ::ItemInstance *THIS; bool RETVAL; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsAttuned(); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -139,12 +166,20 @@ XS(XS_QuestItem_GetCharges); /* prototype to pass -Wmissing-prototypes */ XS(XS_QuestItem_GetCharges) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: QuestItem::GetCharges(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::GetCharges(THIS)"); { EQ::ItemInstance *THIS; int16 RETVAL; dXSTARG; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetCharges(); XSprePUSH; PUSHi((IV) RETVAL); @@ -156,12 +191,20 @@ XS(XS_QuestItem_GetAugment); /* prototype to pass -Wmissing-prototypes */ XS(XS_QuestItem_GetAugment) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: QuestItem::GetAugment(THIS, int16 slot_id)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::GetAugment(THIS, int16 slot_id)"); { EQ::ItemInstance *THIS; int16 slot_id = (int16) SvIV(ST(1)); EQ::ItemInstance *RETVAL; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetAugment(slot_id); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "QuestItem", (void *) RETVAL); @@ -173,12 +216,20 @@ XS(XS_QuestItem_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_QuestItem_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: QuestItem::GetID(THIS)"); // @categories Inventory and Items + Perl_croak(aTHX_ "Usage: QuestItem::GetID(THIS)"); { EQ::ItemInstance *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_ITEM; + + if (sv_derived_from(ST(0), "QuestItem")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(EQ::ItemInstance *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type EQ::ItemInstance"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetItem()->ID; XSprePUSH; PUSHi((IV) RETVAL); diff --git a/zone/perl_raids.cpp b/zone/perl_raids.cpp index 452741be6..670d445e5 100644 --- a/zone/perl_raids.cpp +++ b/zone/perl_raids.cpp @@ -43,29 +43,25 @@ #undef THIS #endif -#define VALIDATE_THIS_IS_RAID \ - do { \ - if (sv_derived_from(ST(0), "Raid")) { \ - IV tmp = SvIV((SV*)SvRV(ST(0))); \ - THIS = INT2PTR(Raid*, tmp); \ - } else { \ - Perl_croak(aTHX_ "THIS is not of type Raid"); \ - } \ - if (THIS == nullptr) { \ - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); \ - } \ - } while (0); XS(XS_Raid_IsRaidMember); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_IsRaidMember) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::IsRaidMember(THIS, string name)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::IsRaidMember(THIS, string name)"); { Raid *THIS; bool RETVAL; const char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsRaidMember(name); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -77,13 +73,21 @@ XS(XS_Raid_CastGroupSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_CastGroupSpell) { dXSARGS; if (items != 4) - Perl_croak(aTHX_ "Usage: Raid::CastGroupSpell(THIS, Mob* caster, uint16 spell_id, uint32 group_id)"); // @categories Group, Raid + Perl_croak(aTHX_ "Usage: Raid::CastGroupSpell(THIS, Mob* caster, uint16 spell_id, uint32 group_id)"); { Raid *THIS; Mob *caster; uint16 spellid = (uint16) SvUV(ST(2)); uint32 gid = (uint32) SvUV(ST(3)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); caster = INT2PTR(Mob *, tmp); @@ -101,13 +105,21 @@ XS(XS_Raid_GroupCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GroupCount) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::GroupCount(THIS, uint32 group_id)"); // @categories Group, Raid + Perl_croak(aTHX_ "Usage: Raid::GroupCount(THIS, uint32 group_id)"); { Raid *THIS; uint8 RETVAL; dXSTARG; uint32 gid = (uint32) SvUV(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GroupCount(gid); XSprePUSH; PUSHu((UV) RETVAL); @@ -119,12 +131,20 @@ XS(XS_Raid_RaidCount); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_RaidCount) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Raid::RaidCount(THIS)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::RaidCount(THIS)"); { Raid *THIS; uint8 RETVAL; dXSTARG; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->RaidCount(); XSprePUSH; PUSHu((UV) RETVAL); @@ -136,13 +156,21 @@ XS(XS_Raid_GetGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetGroup) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::GetGroup(THIS, string name)"); // @categories Group, Raid + Perl_croak(aTHX_ "Usage: Raid::GetGroup(THIS, string name)"); { Raid *THIS; uint32 RETVAL; dXSTARG; const char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetGroup(name); XSprePUSH; PUSHu((UV) RETVAL); @@ -154,12 +182,20 @@ XS(XS_Raid_SplitExp); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_SplitExp) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Raid::SplitExp(THIS, uint32 experience, [Mob* other = nullptr])"); // @categories Experience and Level, Raid + Perl_croak(aTHX_ "Usage: Raid::SplitExp(THIS, uint32 experience, [Mob* other = nullptr])"); { Raid *THIS; uint32 exp = (uint32) SvUV(ST(1)); Mob *other; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(2), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(2))); other = INT2PTR(Mob *, tmp); @@ -177,13 +213,21 @@ XS(XS_Raid_GetTotalRaidDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetTotalRaidDamage) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::GetTotalRaidDamage(THIS, [Mob* other = nullptr])"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetTotalRaidDamage(THIS, [Mob* other = nullptr])"); { Raid *THIS; uint32 RETVAL; dXSTARG; Mob *other; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); other = INT2PTR(Mob *, tmp); @@ -203,7 +247,7 @@ XS(XS_Raid_SplitMoney); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_SplitMoney) { dXSARGS; if (items != 5) - Perl_croak(aTHX_ "Usage: Raid::SplitMoney(THIS, uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum)"); // @categories Currency and Points, Raid + Perl_croak(aTHX_ "Usage: Raid::SplitMoney(THIS, uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum)"); { Raid *THIS; uint32 gid = (uint32) SvUV(ST(1)); @@ -211,7 +255,15 @@ XS(XS_Raid_SplitMoney) { uint32 silver = (uint32) SvUV(ST(3)); uint32 gold = (uint32) SvUV(ST(4)); uint32 platinum = (uint32) SvUV(ST(5)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->SplitMoney(gid, copper, silver, gold, platinum); } XSRETURN_EMPTY; @@ -221,12 +273,20 @@ XS(XS_Raid_BalanceHP); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_BalanceHP) { dXSARGS; if (items != 3) - Perl_croak(aTHX_ "Usage: Raid::BalanceHP(THIS, int32 penalty, uint32 group_id)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::BalanceHP(THIS, int32 penalty, uint32 group_id)"); { Raid *THIS; int32 penalty = (int32) SvUV(ST(1)); uint32 gid = (uint32) SvUV(ST(2)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + THIS->BalanceHP(penalty, gid); } XSRETURN_EMPTY; @@ -236,12 +296,20 @@ XS(XS_Raid_IsLeader); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_IsLeader) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::IsLeader(THIS, string name)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::IsLeader(THIS, string name)"); { Raid *THIS; bool RETVAL; const char *name = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsLeader(name); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -253,12 +321,20 @@ XS(XS_Raid_IsGroupLeader); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_IsGroupLeader) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::IsGroupLeader(THIS, string name)"); // @categories Group, Raid + Perl_croak(aTHX_ "Usage: Raid::IsGroupLeader(THIS, string name)"); { Raid *THIS; bool RETVAL; const char *who = (char *) SvPV_nolen(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->IsGroupLeader(who); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); @@ -270,12 +346,20 @@ XS(XS_Raid_GetHighestLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetHighestLevel) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Raid::GetHighestLevel(THIS)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetHighestLevel(THIS)"); { Raid *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetHighestLevel(); XSprePUSH; PUSHu((UV) RETVAL); @@ -287,12 +371,20 @@ XS(XS_Raid_GetLowestLevel); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetLowestLevel) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Raid::GetLowestLevel(THIS)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetLowestLevel(THIS)"); { Raid *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetLowestLevel(); XSprePUSH; PUSHu((UV) RETVAL); @@ -304,12 +396,20 @@ XS(XS_Raid_GetClientByIndex); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetClientByIndex) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::GetClientByIndex(THIS, uint16 raid_indez)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetClientByIndex(THIS, uint16 raid_indez)"); { Raid *THIS; Client *RETVAL; uint16 index = (uint16) SvUV(ST(1)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetClientByIndex(index); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void *) RETVAL); @@ -321,7 +421,7 @@ XS(XS_Raid_TeleportGroup); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_TeleportGroup) { dXSARGS; if (items != 8) - Perl_croak(aTHX_ "Usage: Raid::TeleportGroup(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading, uint32 group_id)"); // @categories Group, Raid + Perl_croak(aTHX_ "Usage: Raid::TeleportGroup(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading, uint32 group_id)"); { Raid *THIS; Mob *sender; @@ -331,7 +431,15 @@ XS(XS_Raid_TeleportGroup) { float z = (float) SvNV(ST(5)); float heading = (float) SvNV(ST(6)); uint32 gid = (uint32) SvUV(ST(7)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -349,7 +457,7 @@ XS(XS_Raid_TeleportRaid); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_TeleportRaid) { dXSARGS; if (items != 7) - Perl_croak(aTHX_ "Usage: Raid::TeleportRaid(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::TeleportRaid(THIS, Mob* sender, uint32 zone_id, float x, float y, float z, float heading)"); { Raid *THIS; Mob *sender; @@ -358,7 +466,15 @@ XS(XS_Raid_TeleportRaid) { float y = (float) SvNV(ST(4)); float z = (float) SvNV(ST(5)); float heading = (float) SvNV(ST(6)); - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + if (sv_derived_from(ST(1), "Mob")) { IV tmp = SvIV((SV *) SvRV(ST(1))); sender = INT2PTR(Mob *, tmp); @@ -376,12 +492,20 @@ XS(XS_Raid_GetID); /* prototype to pass -Wmissing-prototypes */ XS(XS_Raid_GetID) { dXSARGS; if (items != 1) - Perl_croak(aTHX_ "Usage: Raid::GetID(THIS)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetID(THIS)"); { Raid *THIS; uint32 RETVAL; dXSTARG; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + RETVAL = THIS->GetID(); XSprePUSH; PUSHu((UV) RETVAL); @@ -393,12 +517,20 @@ XS(XS_Raid_GetMember); XS(XS_Raid_GetMember) { dXSARGS; if (items != 2) - Perl_croak(aTHX_ "Usage: Raid::GetMember(THIS, int raid_index)"); // @categories Raid + Perl_croak(aTHX_ "Usage: Raid::GetMember(THIS, int raid_index)"); { Raid *THIS; Client *RETVAL = nullptr; dXSTARG; - VALIDATE_THIS_IS_RAID; + + if (sv_derived_from(ST(0), "Raid")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Raid *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Raid"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + int index = (int) SvUV(ST(1)); if (index < 0 || index > 71) RETVAL = nullptr; @@ -413,24 +545,6 @@ XS(XS_Raid_GetMember) { XSRETURN(1); } -XS(XS_Raid_DoesAnyMemberHaveExpeditionLockout); -XS(XS_Raid_DoesAnyMemberHaveExpeditionLockout) { - dXSARGS; - if (items != 3 && items != 4) { - Perl_croak(aTHX_ "Usage: Raid::DoesAnyMemberHaveExpeditionLockout(THIS, string expedition_name, string event_name, [int max_check_count = 0])"); - } - - Raid* THIS = nullptr; - VALIDATE_THIS_IS_RAID; - std::string expedition_name(SvPV_nolen(ST(1))); - std::string event_name(SvPV_nolen(ST(2))); - int max_check_count = (items == 4) ? static_cast(SvIV(ST(3))) : 0; - - bool result = THIS->DoesAnyMemberHaveExpeditionLockout(expedition_name, event_name, max_check_count); - ST(0) = boolSV(result); - XSRETURN(1); -} - #ifdef __cplusplus extern "C" #endif @@ -467,7 +581,6 @@ XS(boot_Raid) { newXSproto(strcpy(buf, "TeleportRaid"), XS_Raid_TeleportRaid, file, "$$$$$$$"); newXSproto(strcpy(buf, "GetID"), XS_Raid_GetID, file, "$"); newXSproto(strcpy(buf, "GetMember"), XS_Raid_GetMember, file, "$$"); - newXSproto(strcpy(buf, "DoesAnyMemberHaveExpeditionLockout"), XS_Raid_DoesAnyMemberHaveExpeditionLockout, file, "$$$;$"); XSRETURN_YES; } diff --git a/zone/pets.cpp b/zone/pets.cpp index e88f0f246..5d4359d64 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -394,7 +394,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, for (int i = EQ::invslot::EQUIPMENT_BEGIN; i <= EQ::invslot::EQUIPMENT_END; i++) if (petinv[i]) { item = database.GetItem(petinv[i]); - npc->AddLootDrop(item, &npc->itemlist, NPC::NewLootDropEntry(), true); + npc->AddLootDrop(item, &npc->itemlist, LootDropEntries_Struct{ .equip_item = 1 }, true); } } @@ -433,21 +433,7 @@ Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 po petpower = power; SetOwnerID(owner->GetID()); SetPetSpellID(spell_id); - - // All pets start at false on newer clients. The client - // turns it on and tracks the state. - taunting=false; - - // Older clients didn't track state, and default taunting is on (per @mackal) - // Familiar and animation pets don't get taunt until an AA. - if (owner && owner->IsClient()) { - if (!(owner->CastToClient()->ClientVersionBit() & EQ::versions::maskUFAndLater)) { - if ((typeofpet != petFamiliar && typeofpet != petAnimation) || - aabonuses.PetCommands[PET_TAUNT]) { - taunting=true; - } - } - } + taunting = true; // Class should use npc constructor to set light properties } @@ -639,7 +625,7 @@ void NPC::SetPetState(SpellBuff_Struct *pet_buffs, uint32 *items) { bool petCanHaveNoDrop = (RuleB(Pets, CanTakeNoDrop) && _CLIENTPET(this) && GetPetType() <= petOther); if (!noDrop || petCanHaveNoDrop) { - AddLootDrop(item2, &itemlist, NPC::NewLootDropEntry(), true); + AddLootDrop(item2, &itemlist, LootDropEntries_Struct{.equip_item = 1}, true); } } } diff --git a/zone/quest.cpp b/zone/quest.cpp new file mode 100644 index 000000000..fb2d9f851 --- /dev/null +++ b/zone/quest.cpp @@ -0,0 +1,101 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "../common/debug.h" +#include +#include +#include +#include + +// Disgrace: for windows compile +#ifdef WIN32 + #include + #define snprintf _snprintf +#else + #include "../common/unix.h" +#endif + +#include "quest.h" + +pquest_entry Quest::m_pQuests; +int Quest::m_nQuests; + +Quest::Quest() +{ + m_pQuests = NULL; + m_nQuests = 0; +} + +Quest::~Quest() +{ + for( int i=0;i &err) { diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index 625425839..a4d9a5e21 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -89,14 +89,6 @@ void QuestParserCollection::ReloadQuests(bool reset_timers) { } } -void QuestParserCollection::RemoveEncounter(const std::string name) { - auto iter = _load_precedence.begin(); - while(iter != _load_precedence.end()) { - (*iter)->RemoveEncounter(name); - ++iter; - } -} - bool QuestParserCollection::HasQuestSub(uint32 npcid, QuestEventID evt) { return HasQuestSubLocal(npcid, evt) || HasQuestSubGlobal(evt); } diff --git a/zone/quest_parser_collection.h b/zone/quest_parser_collection.h index 082b5b6f4..a5dc07a95 100644 --- a/zone/quest_parser_collection.h +++ b/zone/quest_parser_collection.h @@ -65,7 +65,6 @@ public: void AddVar(std::string name, std::string val); void Init(); void ReloadQuests(bool reset_timers = true); - void RemoveEncounter(const std::string name); bool HasQuestSub(uint32 npcid, QuestEventID evt); bool PlayerHasQuestSub(QuestEventID evt); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 561f3eb3a..59fd887e2 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -857,15 +857,6 @@ void QuestManager::repopzone() { } } -void QuestManager::processmobswhilezoneempty(bool on) { - if(zone) { - zone->process_mobs_while_empty = on; - } - else { - LogQuests("QuestManager::processmobswhilezoneempty called with nullptr zone. Probably syntax error in quest file"); - } -} - void QuestManager::settarget(const char *type, int target_id) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) @@ -1088,64 +1079,174 @@ void QuestManager::permagender(int gender_id) { uint16 QuestManager::scribespells(uint8 max_level, uint8 min_level) { QuestManagerCurrentQuestVars(); int book_slot = initiator->GetNextAvailableSpellBookSlot(); - std::vector spell_ids = initiator->GetScribeableSpells(min_level, max_level); - int spell_count = spell_ids.size(); - int spells_learned = 0; - if (spell_count > 0) { - for (auto spell_id : spell_ids) { - if (book_slot == -1) { - initiator->Message( - Chat::Red, - "Unable to scribe spell %s (%i) to Spell Book: Spell Book is Full.", spells[spell_id].name, spell_id - ); - break; - } - - if (initiator->HasSpellScribed(spell_id)) - continue; - - initiator->ScribeSpell(spell_id, book_slot); - book_slot = initiator->GetNextAvailableSpellBookSlot(book_slot); - spells_learned++; + int spell_id = 0; + int count = 0; + + uint32 char_id = initiator->CharacterID(); + bool SpellGlobalRule = RuleB(Spells, EnableSpellGlobals); + bool SpellBucketRule = RuleB(Spells, EnableSpellBuckets); + bool SpellGlobalCheckResult = false; + bool SpellBucketCheckResult = false; + + for ( ; spell_id < SPDAT_RECORDS && book_slot < EQ::spells::SPELLBOOK_SIZE; ++spell_id) { + if (book_slot == -1) { + initiator->Message( + 13, + "Unable to scribe spell %s (%i) to spellbook: no more spell book slots available.", + ((spell_id >= 0 && spell_id < SPDAT_RECORDS) ? spells[spell_id].name : "Out-of-range"), + spell_id + ); + + break; } + if (spell_id < 0 || spell_id >= SPDAT_RECORDS) { + initiator->Message(Chat::Red, "FATAL ERROR: Spell id out-of-range (id: %i, min: 0, max: %i)", spell_id, SPDAT_RECORDS); + return count; + } + if (book_slot < 0 || book_slot >= EQ::spells::SPELLBOOK_SIZE) { + initiator->Message(Chat::Red, "FATAL ERROR: Book slot out-of-range (slot: %i, min: 0, max: %i)", book_slot, EQ::spells::SPELLBOOK_SIZE); + return count; + } + + while (true) { + if (spells[spell_id].classes[WARRIOR] == 0) // check if spell exists + break; + if (spells[spell_id].classes[initiator->GetPP().class_ - 1] > max_level) // maximum level + break; + if (spells[spell_id].classes[initiator->GetPP().class_ - 1] < min_level) // minimum level + break; + if (spells[spell_id].skill == 52) + break; + if (spells[spell_id].effectid[EFFECT_COUNT - 1] == 10) + break; + + uint16 spell_id_ = (uint16)spell_id; + if ((spell_id_ != spell_id) || (spell_id != spell_id_)) { + initiator->Message(Chat::Red, "FATAL ERROR: Type conversion data loss with spell_id (%i != %u)", spell_id, spell_id_); + return count; + } + + if (!IsDiscipline(spell_id_) && !initiator->HasSpellScribed(spell_id)) { // isn't a discipline & we don't already have it scribed + if (SpellGlobalRule) { + // bool to see if the character has the required QGlobal to scribe it if one exists in the Spell_Globals table + SpellGlobalCheckResult = initiator->SpellGlobalCheck(spell_id_, char_id); + if (SpellGlobalCheckResult) { + initiator->ScribeSpell(spell_id_, book_slot); + ++count; + } + } + else if (SpellBucketRule) { + // bool to see if the character has the required bucket to train it if one exists in the spell_buckets table + SpellBucketCheckResult = initiator->SpellBucketCheck(spell_id_, char_id); + if (SpellBucketCheckResult) { + initiator->ScribeSpell(spell_id_, book_slot); + ++count; + } + } + else { + initiator->ScribeSpell(spell_id_, book_slot); + ++count; + } + } + + break; + } + + book_slot = initiator->GetNextAvailableSpellBookSlot(book_slot); } - if (spells_learned > 0) { - std::string spell_message = (spells_learned == 1 ? "a new spell" : fmt::format("{} new spells", spells_learned)); - initiator->Message(Chat::White, fmt::format("You have learned {}!", spell_message).c_str()); - } - return spells_learned; + return count; // how many spells were scribed successfully } uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) { QuestManagerCurrentQuestVars(); - int character_id = initiator->CharacterID(); - std::vector spell_ids = initiator->GetLearnableDisciplines(min_level, max_level); - int discipline_count = spell_ids.size(); - int disciplines_learned = 0; - if (discipline_count > 0) { - for (auto spell_id : spell_ids) { - if (initiator->HasDisciplineLearned(spell_id)) - continue; + int spell_id = 0; + int count = 0; - for (uint32 index = 0; index < MAX_PP_DISCIPLINES; index++) { - if (initiator->GetPP().disciplines.values[index] == 0) { - initiator->GetPP().disciplines.values[index] = spell_id; - database.SaveCharacterDisc(character_id, index, spell_id); - disciplines_learned++; - break; + uint32 char_id = initiator->CharacterID(); + bool SpellGlobalRule = RuleB(Spells, EnableSpellGlobals); + bool SpellBucketRule = RuleB(Spells, EnableSpellBuckets); + bool SpellGlobalCheckResult = false; + bool SpellBucketCheckResult = false; + + bool change = false; + + for( ; spell_id < SPDAT_RECORDS; ++spell_id) { + if (spell_id < 0 || spell_id >= SPDAT_RECORDS) { + initiator->Message(Chat::Red, "FATAL ERROR: Spell id out-of-range (id: %i, min: 0, max: %i)", spell_id, SPDAT_RECORDS); + return count; + } + + while (true) { + if (spells[spell_id].classes[WARRIOR] == 0) // check if spell exists + break; + if (spells[spell_id].classes[initiator->GetPP().class_ - 1] > max_level) // maximum level + break; + if (spells[spell_id].classes[initiator->GetPP().class_ - 1] < min_level) // minimum level + break; + if (spells[spell_id].skill == 52) + break; + if (RuleB(Spells, UseCHAScribeHack) && spells[spell_id].effectid[EFFECT_COUNT - 1] == 10) + break; + + uint16 spell_id_ = (uint16)spell_id; + if ((spell_id_ != spell_id) || (spell_id != spell_id_)) { + initiator->Message(Chat::Red, "FATAL ERROR: Type conversion data loss with spell_id (%i != %u)", spell_id, spell_id_); + return count; + } + + if (!IsDiscipline(spell_id_)) + break; + + for (uint32 r = 0; r < MAX_PP_DISCIPLINES; r++) { + if (initiator->GetPP().disciplines.values[r] == spell_id_) { + initiator->Message(Chat::Red, "You already know this discipline."); + break; // continue the 1st loop + } + else if (initiator->GetPP().disciplines.values[r] == 0) { + if (SpellGlobalRule) { + // bool to see if the character has the required QGlobal to train it if one exists in the Spell_Globals table + SpellGlobalCheckResult = initiator->SpellGlobalCheck(spell_id_, char_id); + if (SpellGlobalCheckResult) { + initiator->GetPP().disciplines.values[r] = spell_id_; + database.SaveCharacterDisc(char_id, r, spell_id_); + change = true; + initiator->Message(Chat::White, "You have learned a new discipline!"); + ++count; // success counter + } + break; // continue the 1st loop + } + else if (SpellBucketRule) { + // bool to see if the character has the required bucket to train it if one exists in the spell_buckets table + SpellBucketCheckResult = initiator->SpellBucketCheck(spell_id_, char_id); + if (SpellBucketCheckResult) { + initiator->GetPP().disciplines.values[r] = spell_id_; + database.SaveCharacterDisc(char_id, r, spell_id_); + change = true; + initiator->Message(Chat::White, "You have learned a new discipline!"); + ++count; + } + break; + } + else { + initiator->GetPP().disciplines.values[r] = spell_id_; + database.SaveCharacterDisc(char_id, r, spell_id_); + change = true;; + initiator->Message(Chat::White, "You have learned a new discipline!"); + ++count; // success counter + break; // continue the 1st loop + } } } + + break; } } - if (disciplines_learned > 0) { - std::string discipline_message = (disciplines_learned == 1 ? "a new discipline" : fmt::format("{} new disciplines", disciplines_learned)); + if (change) initiator->SendDisciplineUpdate(); - initiator->Message(Chat::White, fmt::format("You have learned {}!", discipline_message).c_str()); - } - return disciplines_learned; + return count; // how many disciplines were learned successfully } void QuestManager::unscribespells() { @@ -1673,17 +1774,10 @@ void QuestManager::ding() { } -void QuestManager::rebind(int zone_id, const glm::vec3& location) { +void QuestManager::rebind(int zoneid, const glm::vec3& location) { QuestManagerCurrentQuestVars(); if(initiator && initiator->IsClient()) { - initiator->SetBindPoint(0, zone_id, 0, location); - } -} - -void QuestManager::rebind(int zone_id, const glm::vec4& location) { - QuestManagerCurrentQuestVars(); - if(initiator && initiator->IsClient()) { - initiator->SetBindPoint2(0, zone_id, 0, location); + initiator->SetBindPoint(0, zoneid, 0, location); } } @@ -2247,27 +2341,27 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level void QuestManager::taskselector(int taskcount, int *tasks) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && taskmanager) initiator->TaskQuestSetSelector(owner, taskcount, tasks); } void QuestManager::enabletask(int taskcount, int *tasks) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager) initiator->EnableTask(taskcount, tasks); } void QuestManager::disabletask(int taskcount, int *tasks) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager) initiator->DisableTask(taskcount, tasks); } bool QuestManager::istaskenabled(int taskid) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager) return initiator->IsTaskEnabled(taskid); return false; @@ -2276,7 +2370,7 @@ bool QuestManager::istaskenabled(int taskid) { void QuestManager::tasksetselector(int tasksetid) { QuestManagerCurrentQuestVars(); Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && taskmanager) initiator->TaskSetSelector(owner, tasksetid); } @@ -2365,8 +2459,8 @@ int QuestManager::enabledtaskcount(int taskset) { int QuestManager::firsttaskinset(int taskset) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->FirstTaskInSet(taskset); + if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager) + return taskmanager->FirstTaskInSet(taskset); return -1; } @@ -2374,8 +2468,8 @@ int QuestManager::firsttaskinset(int taskset) { int QuestManager::lasttaskinset(int taskset) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->LastTaskInSet(taskset); + if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager) + return taskmanager->LastTaskInSet(taskset); return -1; } @@ -2383,8 +2477,8 @@ int QuestManager::lasttaskinset(int taskset) { int QuestManager::nexttaskinset(int taskset, int taskid) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->NextTaskInSet(taskset, taskid); + if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager) + return taskmanager->NextTaskInSet(taskset, taskid); return -1; } @@ -2436,8 +2530,8 @@ int QuestManager::completedtasksinset(int taskset) { bool QuestManager::istaskappropriate(int task) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) - return task_manager->ValidateLevel(task, initiator->GetLevel()); + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager) + return taskmanager->AppropriateLevel(task, initiator->GetLevel()); return false; } @@ -2446,7 +2540,7 @@ std::string QuestManager::gettaskname(uint32 task_id) { QuestManagerCurrentQuestVars(); if (RuleB(TaskSystem, EnableTaskSystem)) { - return task_manager->GetTaskName(task_id); + return taskmanager->GetTaskName(task_id); } return std::string(); @@ -2477,24 +2571,6 @@ void QuestManager::we(int type, const char *str) { worldserver.SendEmoteMessage(0, 0, type, str); } -void QuestManager::message(int color, const char *message) { - QuestManagerCurrentQuestVars(); - if (!initiator) - return; - - initiator->Message(color, message); -} - -void QuestManager::whisper(const char *message) { - QuestManagerCurrentQuestVars(); - if (!initiator || !owner) - return; - - std::string mob_name = owner->GetCleanName(); - std::string new_message = fmt::format("{} whispers, '{}'", mob_name, message); - initiator->Message(315, new_message.c_str()); -} - int QuestManager::getlevel(uint8 type) { QuestManagerCurrentQuestVars(); @@ -2644,43 +2720,6 @@ int QuestManager::countitem(uint32 item_id) { return quantity; } -void QuestManager::removeitem(uint32 item_id, uint32 quantity) { - QuestManagerCurrentQuestVars(); - EQ::ItemInstance *item = nullptr; - static const int16 slots[][2] = { - { EQ::invslot::POSSESSIONS_BEGIN, EQ::invslot::POSSESSIONS_END }, - { EQ::invbag::GENERAL_BAGS_BEGIN, EQ::invbag::GENERAL_BAGS_END }, - { EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END}, - { EQ::invslot::BANK_BEGIN, EQ::invslot::BANK_END }, - { EQ::invbag::BANK_BAGS_BEGIN, EQ::invbag::BANK_BAGS_END }, - { EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END }, - { EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END }, - }; - int removed_count = 0; - const size_t size = sizeof(slots) / sizeof(slots[0]); - for (int slot_index = 0; slot_index < size; ++slot_index) { - for (int slot_id = slots[slot_index][0]; slot_id <= slots[slot_index][1]; ++slot_id) { - if (removed_count == quantity) - break; - - item = initiator->GetInv().GetItem(slot_id); - if (item && item->GetID() == item_id) { - int stack_size = item->IsStackable() ? item->GetCharges() : 1; - if ((removed_count + stack_size) <= quantity) { - removed_count += stack_size; - initiator->DeleteItemInInventory(slot_id, stack_size, true); - } else { - int amount_left = (quantity - removed_count); - if (amount_left > 0 && stack_size >= amount_left) { - removed_count += amount_left; - initiator->DeleteItemInInventory(slot_id, amount_left, true); - } - } - } - } - } -} - void QuestManager::UpdateSpawnTimer(uint32 id, uint32 newTime) { bool found = false; @@ -2781,12 +2820,11 @@ std::string QuestManager::getitemname(uint32 item_id) { return item_name; } -std::string QuestManager::getnpcnamebyid(uint32 npc_id) { - std::string res; +const char *QuestManager::getnpcnamebyid(uint32 npc_id) { if (npc_id > 0) { - res = database.GetNPCNameByID(npc_id); + return database.GetNPCNameByID(npc_id); } - return res; + return ""; } uint16 QuestManager::CreateInstance(const char *zone, int16 version, uint32 duration) @@ -2992,12 +3030,11 @@ std::string QuestManager::saylink(char *saylink_text, bool silent, const char *l return EQ::SayLinkEngine::GenerateQuestSaylink(saylink_text, silent, link_name); } -std::string QuestManager::getcharnamebyid(uint32 char_id) { - std::string res; +const char* QuestManager::getcharnamebyid(uint32 char_id) { if (char_id > 0) { - res = database.GetCharNameByID(char_id); + return database.GetCharNameByID(char_id); } - return res; + return ""; } uint32 QuestManager::getcharidbyname(const char* name) { @@ -3226,17 +3263,13 @@ int32 QuestManager::GetZoneID(const char *zone) { return static_cast(ZoneID(zone)); } -std::string QuestManager::GetZoneLongName(std::string zone_short_name) -{ - return ZoneLongName(ZoneID(zone_short_name)); -} +const char* QuestManager::GetZoneLongName(const char *zone) { + char *long_name; + content_db.GetZoneLongName(zone, &long_name); + std::string ln = long_name; + safe_delete_array(long_name); -std::string QuestManager::GetZoneLongNameByID(uint32 zone_id) { - return ZoneLongName(zone_id); -} - -std::string QuestManager::GetZoneShortName(uint32 zone_id) { - return ZoneName(zone_id); + return ln.c_str(); } void QuestManager::CrossZoneAssignTaskByCharID(int character_id, uint32 task_id, bool enforce_level_requirement) { @@ -3916,7 +3949,7 @@ void QuestManager::CrossZoneUpdateActivityByGuildID(int guild_id, uint32 task_id } } -void QuestManager::WorldWideAssignTask(uint32 task_id, bool enforce_level_requirement, uint8 min_status, uint8 max_status) { +void QuestManager::WorldWideAssignTask(uint32 task_id, bool enforce_level_requirement, uint8 min_status, uint8 max_status) { QuestManagerCurrentQuestVars(); if (initiator && owner) { auto pack = new ServerPacket(ServerOP_WWAssignTask, sizeof(WWAssignTask_Struct)); @@ -4161,15 +4194,6 @@ Mob *QuestManager::GetOwner() const { return nullptr; } -EQ::InventoryProfile *QuestManager::GetInventory() const { - if(!quests_running_.empty()) { - running_quest e = quests_running_.top(); - return &e.initiator->GetInv(); - } - - return nullptr; -} - EQ::ItemInstance *QuestManager::GetQuestItem() const { if(!quests_running_.empty()) { running_quest e = quests_running_.top(); @@ -4259,376 +4283,3 @@ void QuestManager::UpdateZoneHeader(std::string type, std::string value) { entity_list.QueueClients(0, outapp); safe_delete(outapp); } - -EQ::ItemInstance *QuestManager::CreateItem(uint32 item_id, int16 charges, uint32 augment_one, uint32 augment_two, uint32 augment_three, uint32 augment_four, uint32 augment_five, uint32 augment_six, bool attuned) const { - if (database.GetItem(item_id)) { - return database.CreateItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six, attuned); - } - return nullptr; -} - -std::string QuestManager::secondstotime(int duration) { - int timer_length = duration; - int hours = int(timer_length / 3600); - timer_length %= 3600; - int minutes = int(timer_length / 60); - timer_length %= 60; - int seconds = timer_length; - std::string time_string = "Unknown"; - std::string hour_string = (hours == 1 ? "Hour" : "Hours"); - std::string minute_string = (minutes == 1 ? "Minute" : "Minutes"); - std::string second_string = (seconds == 1 ? "Second" : "Seconds"); - if (hours > 0 && minutes > 0 && seconds > 0) { - time_string = fmt::format("{} {}, {} {}, and {} {}", hours, hour_string, minutes, minute_string, seconds, second_string); - } else if (hours > 0 && minutes > 0 && seconds == 0) { - time_string = fmt::format("{} {} and {} {}", hours, hour_string, minutes, minute_string); - } else if (hours > 0 && minutes == 0 && seconds > 0) { - time_string = fmt::format("{} {} and {} {}", hours, hour_string, seconds, second_string); - } else if (hours > 0 && minutes == 0 && seconds == 0) { - time_string = fmt::format("{} {}", hours, hour_string); - } else if (hours == 0 && minutes > 0 && seconds > 0) { - time_string = fmt::format("{} {} and {} {}", minutes, minute_string, seconds, second_string); - } else if (hours == 0 && minutes > 0 && seconds == 0) { - time_string = fmt::format("{} {}", minutes, minute_string); - } else if (hours == 0 && minutes == 0 && seconds > 0) { - time_string = fmt::format("{} {}", seconds, second_string); - } - return time_string; -} - -std::string QuestManager::gethexcolorcode(std::string color_name) { - static const std::map colors = { - { "Black", "#000000" }, - { "Brown", "#804000" }, - { "Burgundy", "#800000" }, - { "Cadet Blue", "#77BFC7" }, - { "Cadet Blue1", "#4C787E" }, - { "Chartreuse", "#8AFB17" }, - { "Chartreuse1", "#7FE817" }, - { "Chartreuse2", "#6CC417" }, - { "Chartreuse3", "#437C17" }, - { "Chocolate", "#C85A17" }, - { "Coral", "#F76541" }, - { "Coral1", "#E55B3C" }, - { "Coral2", "#C34A2C" }, - { "Cornflower Blue", "#151B8D" }, - { "Cyan", "#00FFFF" }, - { "Cyan1", "#57FEFF" }, - { "Cyan2", "#50EBEC" }, - { "Cyan3", "#46C7C7" }, - { "Cyan4", "#307D7E" }, - { "Dark Blue", "#0000A0" }, - { "Dark Goldenrod", "#AF7817" }, - { "Dark Goldenrod1", "#FBB117" }, - { "Dark Goldenrod2", "#E8A317" }, - { "Dark Goldenrod3", "#C58917" }, - { "Dark Goldenrod4", "#7F5217" }, - { "Dark Green", "#254117" }, - { "Dark Grey", "#808080" }, - { "Dark Olive Green", "#CCFB5D" }, - { "Dark Olive Green2", "#BCE954" }, - { "Dark Olive Green3", "#A0C544" }, - { "Dark Olive Green4", "#667C26" }, - { "Dark Orange", "#F88017" }, - { "Dark Orange1", "#F87217" }, - { "Dark Orange2", "#E56717" }, - { "Dark Orange3", "#7E3117" }, - { "Dark Orange3", "#C35617" }, - { "Dark Orchid", "#7D1B7E" }, - { "Dark Orchid1", "#B041FF" }, - { "Dark Orchid2", "#A23BEC" }, - { "Dark Orchid3", "#8B31C7" }, - { "Dark Orchid4", "#571B7e" }, - { "Dark Purple", "#800080" }, - { "Dark Salmon", "#E18B6B" }, - { "Dark Sea Green", "#8BB381" }, - { "Dark Sea Green1", "#C3FDB8" }, - { "Dark Sea Green2", "#B5EAAA" }, - { "Dark Sea Green3", "#99C68E" }, - { "Dark Sea Green4", "#617C58" }, - { "Dark Slate Blue", "#2B3856" }, - { "Dark Slate Gray", "#25383C" }, - { "Dark Slate Gray1", "#9AFEFF" }, - { "Dark Slate Gray2", "#8EEBEC" }, - { "Dark Slate Gray3", "#78c7c7" }, - { "Dark Slate Gray4", "#4C7D7E" }, - { "Dark Turquoise", "#3B9C9C" }, - { "Dark Violet", "#842DCE" }, - { "Deep Pink", "#F52887" }, - { "Deep Pink1", "#E4287C" }, - { "Deep Pink2", "#C12267" }, - { "Deep Pink3", "#7D053F" }, - { "Deep Sky Blue", "#3BB9FF" }, - { "Deep Sky Blue1", "#38ACEC" }, - { "Deep Sky Blue2", "#3090C7" }, - { "Deep Sky Blue3", "#25587E" }, - { "Dim Gray", "#463E41" }, - { "Dodger Blue", "#1589FF" }, - { "Dodger Blue1", "#157DEC" }, - { "Dodger Blue2", "#1569C7" }, - { "Dodger Blue3", "#153E7E" }, - { "Firebrick", "#800517" }, - { "Firebrick1", "#F62817" }, - { "Firebrick2", "#E42217" }, - { "Firebrick3", "#C11B17" }, - { "Forest Green", "#4E9258" }, - { "Forest Green1", "#808000" }, - { "Gold", "#D4A017" }, - { "Gold1", "#FDD017" }, - { "Gold2", "#EAC117" }, - { "Gold3", "#C7A317" }, - { "Gold4", "#806517" }, - { "Goldenrod", "#EDDA74" }, - { "Goldenrod1", "#FBB917" }, - { "Goldenrod2", "#E9AB17" }, - { "Goldenrod3", "#C68E17" }, - { "Goldenrod4", "#805817" }, - { "Grass Green", "#408080" }, - { "Gray", "#736F6E" }, - { "Gray1", "#150517" }, - { "Gray2", "#250517" }, - { "Gray3", "#2B1B17" }, - { "Gray4", "#302217" }, - { "Gray5", "#302226" }, - { "Gray6", "#342826" }, - { "Gray7", "#34282C" }, - { "Gray8", "#382D2C" }, - { "Gray9", "#3b3131" }, - { "Gray10", "#3E3535" }, - { "Gray11", "#413839" }, - { "Gray12", "#41383C" }, - { "Gray13", "#463E3F" }, - { "Gray14", "#4A4344" }, - { "Gray15", "#4C4646" }, - { "Gray16", "#4E4848" }, - { "Gray17", "#504A4B" }, - { "Gray18", "#544E4F" }, - { "Gray19", "#565051" }, - { "Gray19", "#595454" }, - { "Gray20", "#5C5858" }, - { "Gray21", "#5F5A59" }, - { "Gray22", "#625D5D" }, - { "Gray23", "#646060" }, - { "Gray24", "#666362" }, - { "Gray25", "#696565" }, - { "Gray26", "#6D6968" }, - { "Gray27", "#6E6A6B" }, - { "Gray28", "#726E6D" }, - { "Gray29", "#747170" }, - { "Green", "#00FF00" }, - { "Green1", "#5FFB17" }, - { "Green2", "#59E817" }, - { "Green3", "#4CC417" }, - { "Green4", "#347C17" }, - { "Green Yellow", "#B1FB17" }, - { "Hot Pink", "#F660AB" }, - { "Hot Pink1", "#F665AB" }, - { "Hot Pink2", "#E45E9D" }, - { "Hot Pink3", "#C25283" }, - { "Hot Pink4", "#7D2252" }, - { "Indian Red", "#F75D59" }, - { "Indian Red2", "#E55451" }, - { "Indian Red3", "#C24641" }, - { "Indian Red4", "#7E2217" }, - { "Khaki", "#ADA96E" }, - { "Khaki1", "#FFF380" }, - { "Khaki2", "#EDE275" }, - { "Khaki3", "#C9BE62" }, - { "Khaki4", "#827839" }, - { "Lavender", "#E3E4FA" }, - { "Lavender Blush", "#FDEEF4" }, - { "Lavender Blush1", "#EBDDE2" }, - { "Lavender Blush2", "#C8BBBE" }, - { "Lavender Blush3", "#817679" }, - { "Lawn Green", "#87F717" }, - { "Lemon Chiffon", "#FFF8C6" }, - { "Lemon Chiffon1", "#ECE5B6" }, - { "Lemon Chiffon2", "#C9C299" }, - { "Lemon Chiffon3", "#827B60" }, - { "Light Blue", "#0000FF" }, - { "Light Blue1", "#ADDFFF" }, - { "Light Blue2", "#BDEDFF" }, - { "Light Blue3", "#AFDCEC" }, - { "Light Blue4", "#95B9C7" }, - { "Light Blue5", "#5E767E" }, - { "Light Coral", "#E77471" }, - { "Light Cyan", "#E0FFFF" }, - { "Light Cyan1", "#CFECEC" }, - { "Light Cyan2", "#AFC7C7" }, - { "Light Cyan3", "#717D7D" }, - { "Light Golden", "#ECD672" }, - { "Light Goldenrod", "#ECD872" }, - { "Light Goldenrod1", "#FFE87C" }, - { "Light Goldenrod2", "#C8B560" }, - { "Light Goldenrod3", "#817339" }, - { "Light Goldenrod Yellow", "#FAF8CC" }, - { "Light Grey", "#C0C0C0" }, - { "Light Pink", "#FAAFBA" }, - { "Light Pink1", "#F9A7B0" }, - { "Light Pink2", "#E799A3" }, - { "Light Pink3", "#C48189" }, - { "Light Pink4", "#7F4E52" }, - { "Light Purple", "#FF0080" }, - { "Light Salmon", "#F9966B" }, - { "Light Salmon1", "#E78A61" }, - { "Light Salmon2", "#C47451" }, - { "Light Salmon3", "#7F462C" }, - { "Light Sea Green", "#3EA99F" }, - { "Light Sky Blue", "#82CAFA" }, - { "Light Sky Blue1", "#A0CFEC" }, - { "Light Sky Blue2", "#87AFC7" }, - { "Light Sky Blue3", "#566D7E" }, - { "Light Slate Blue", "#736AFF" }, - { "Light Slate Gray", "#6D7B8D" }, - { "Light Steel Blue", "#728FCE" }, - { "Light Steel Blue1", "#C6DEFF" }, - { "Light Steel Blue2", "#B7CEEC" }, - { "Light Steel Blue3", "#646D7E" }, - { "Lime Green", "#41A317" }, - { "Magenta", "#FF00FF" }, - { "Magenta1", "#F433FF" }, - { "Magenta2", "#E238EC" }, - { "Magenta3", "#C031C7" }, - { "Maroon", "#810541" }, - { "Maroon1", "#F535AA" }, - { "Maroon2", "#E3319D" }, - { "Maroon3", "#C12283" }, - { "Maroon4", "#7D0552" }, - { "Medium Aquamarine", "#348781" }, - { "Medium Forest Green", "#347235" }, - { "Medium Orchid", "#B048B5" }, - { "Medium Orchid1", "#D462FF" }, - { "Medium Orchid2", "#C45AEC" }, - { "Medium Orchid3", "#A74AC7" }, - { "Medium Orchid4", "#6A287E" }, - { "Medium Purple", "#8467D7" }, - { "Medium Purple1", "#9E7BFF" }, - { "Medium Purple2", "#9172EC" }, - { "Medium Purple3", "#7A5DC7" }, - { "Medium Purple4", "#4E387E" }, - { "Medium Sea Green", "#306754" }, - { "Medium Slate Blue", "#5E5A80" }, - { "Medium Spring Green", "#348017" }, - { "Medium Turquoise", "#48CCCD" }, - { "Medium Violet Red", "#CA226B" }, - { "Midnight Blue", "#151B54" }, - { "Orange", "#FF8040" }, - { "Pale Turquoise", "#92C7C7" }, - { "Pale Turquoise1", "#5E7D7E" }, - { "Pale Violet Red", "#D16587" }, - { "Pale Violet Red1", "#F778A1" }, - { "Pale Violet Red2", "#E56E94" }, - { "Pale Violet Red3", "#C25A7C" }, - { "Pale Violet Red4", "#7E354D" }, - { "Pastel Green", "#00FF00" }, - { "Pink", "#FAAFBE" }, - { "Pink1", "#FF00FF" }, - { "Pink2", "#E7A1B0" }, - { "Pink3", "#C48793" }, - { "Pink4", "#7F525D" }, - { "Plum", "#B93B8F" }, - { "Plum1", "#F9B7FF" }, - { "Plum2", "#E6A9EC" }, - { "Plum3", "#C38EC7" }, - { "Plum4", "#7E587E" }, - { "Purple", "#8E35EF" }, - { "Purple1", "#893BFF" }, - { "Purple2", "#7F38EC" }, - { "Purple3", "#6C2DC7" }, - { "Purple4", "#461B7E" }, - { "Red", "#FF0000" }, - { "Red1", "#F62217" }, - { "Red2", "#E41B17" }, - { "Rosy Brown", "#B38481" }, - { "Rosy Brown1", "#FBBBB9" }, - { "Rosy Brown2", "#E8ADAA" }, - { "Rosy Brown3", "#C5908E" }, - { "Rosy Brown4", "#7F5A58" }, - { "Royal Blue", "#2B60DE" }, - { "Royal Blue1", "#306EFF" }, - { "Royal Blue2", "#2B65EC" }, - { "Royal Blue3", "#2554C7" }, - { "Royal Blue4", "#15317E" }, - { "Salmon1", "#F88158" }, - { "Salmon2", "#E67451" }, - { "Salmon3", "#C36241" }, - { "Salmon4", "#7E3817" }, - { "Sandy Brown", "#EE9A4D" }, - { "Sea Green", "#4E8975" }, - { "Sea Green1", "#6AFB92" }, - { "Sea Green2", "#64E986" }, - { "Sea Green3", "#54C571" }, - { "Sea Green4", "#387C44" }, - { "Sienna", "#8A4117" }, - { "Sienna1", "#F87431" }, - { "Sienna2", "#E66C2C" }, - { "Sienna3", "#C35817" }, - { "Sienna4", "#7E3517" }, - { "Sky Blue", "#82CAFF" }, - { "Sky Blue1", "#6698FF" }, - { "Sky Blue2", "#79BAEC" }, - { "Sky Blue3", "#659EC7" }, - { "Sky Blue4", "#41627E" }, - { "Slate Blue", "#357EC7" }, - { "Slate Blue1", "#737CA1" }, - { "Slate Blue2", "#6960EC" }, - { "Slate Blue3", "#342D7E" }, - { "Slate Gray", "#657383" }, - { "Slate Gray1", "#C2DFFF" }, - { "Slate Gray2", "#B4CFEC" }, - { "Slate Gray3", "#98AFC7" }, - { "Slate Gray4", "#616D7E" }, - { "Spring Green", "#4AA02C" }, - { "Spring Green1", "#5EFB6E" }, - { "Spring Green2", "#57E964" }, - { "Spring Green3", "#4CC552" }, - { "Spring Green4", "#347C2C" }, - { "Steel Blue", "#4863A0" }, - { "Steel Blue1", "#5CB3FF" }, - { "Steel Blue2", "#56A5EC" }, - { "Steel Blue3", "#488AC7" }, - { "Steel Blue4", "#2B547E" }, - { "Thistle", "#D2B9D3" }, - { "Thistle1", "#FCDFFF" }, - { "Thistle2", "#E9CFEC" }, - { "Thistle3", "#C6AEC7" }, - { "Thistle4", "#806D7E" }, - { "Turquoise", "#00FFFF" }, - { "Turquoise1", "#43C6DB" }, - { "Turquoise2", "#52F3FF" }, - { "Turquoise3", "#4EE2EC" }, - { "Turquoise4", "#43BFC7" }, - { "Violet", "#8D38C9" }, - { "Violet Red", "#F6358A" }, - { "Violet Red1", "#F6358A" }, - { "Violet Red2", "#E4317F" }, - { "Violet Red3", "#C12869" }, - { "Violet Red4", "#7D0541" }, - { "White", "#FFFFFF" }, - { "Yellow", "#FFFF00" }, - { "Yellow1", "#FFFC17" }, - { "Yellow Green", "#52D017" } - }; - for (auto color : colors) { - if (!strcasecmp(color.first.c_str(), color_name.c_str())) { - return color.second; - } - } - - return std::string(); -} - -double QuestManager::GetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id) const { - return database.GetAAEXPModifier(character_id, zone_id); -} -double QuestManager::GetEXPModifierByCharID(uint32 character_id, uint32 zone_id) const { - return database.GetEXPModifier(character_id, zone_id); -} - -void QuestManager::SetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, double aa_modifier) { - database.SetAAEXPModifier(character_id, zone_id, aa_modifier); -} - -void QuestManager::SetEXPModifierByCharID(uint32 character_id, uint32 zone_id, double exp_modifier) { - database.SetEXPModifier(character_id, zone_id, exp_modifier); -} diff --git a/zone/questmgr.h b/zone/questmgr.h index 95166886f..8e9d84cf9 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -65,7 +65,6 @@ public: void say(const char *str, Journal::Options &opts); void me(const char *str); void summonitem(uint32 itemid, int16 charges = -1); - EQ::ItemInstance* CreateItem(uint32 item_id, int16 charges = 0, uint32 augment_one = 0, uint32 augment_two = 0, uint32 augment_three = 0, uint32 augment_four = 0, uint32 augment_five = 0, uint32 augment_six = 0, bool attuned = false) const; void write(const char *file, const char *str); Mob* spawn2(int npc_type, int grid, int unused, const glm::vec4& position); Mob* unique_spawn(int npc_type, int grid, int unused, const glm::vec4& position); @@ -102,7 +101,6 @@ public: void depopall(int npc_type = 0); void depopzone(bool StartSpawnTimer = true); void repopzone(); - void processmobswhilezoneempty(bool on); void settarget(const char *type, int target_id); void follow(int entity_id, int distance); void sfollow(); @@ -151,8 +149,7 @@ public: void targlobal(const char *varname, const char *value, const char *duration, int npcid, int charid, int zoneid); void delglobal(const char *varname); void ding(); - void rebind(int zone_id, const glm::vec3& location); - void rebind(int zone_id, const glm::vec4& location); + void rebind(int zoneid, const glm::vec3& location); void start(int wp); void stop(); void pause(int duration); @@ -225,13 +222,10 @@ public: void clearspawntimers(); void ze(int type, const char *str); void we(int type, const char *str); - void message(int color, const char *message); - void whisper(const char *message); int getlevel(uint8 type); int collectitems(uint32 item_id, bool remove); int collectitems_processSlot(int16 slot_id, uint32 item_id, bool remove); int countitem(uint32 item_id); - void removeitem(uint32 item_id, uint32 quantity = 1); std::string getitemname(uint32 item_id); void enabletitle(int titleset); bool checktitle(int titlecheck); @@ -265,7 +259,7 @@ public: void FlagInstanceByRaidLeader(uint32 zone, int16 version); const char* varlink(char* perltext, int item_id); std::string saylink(char *saylink_text, bool silent, const char *link_name); - std::string getcharnamebyid(uint32 char_id); + const char* getcharnamebyid(uint32 char_id); uint32 getcharidbyname(const char* name); std::string getclassname(uint8 class_id, uint8 level = 0); int getcurrencyid(uint32 item_id); @@ -273,7 +267,7 @@ public: const char* getguildnamebyid(int guild_id); int getguildidbycharid(uint32 char_id); int getgroupidbycharid(uint32 char_id); - std::string getnpcnamebyid(uint32 npc_id); + const char* getnpcnamebyid(uint32 npc_id); int getraididbycharid(uint32 char_id); void SetRunning(bool val); bool IsRunning(); @@ -285,9 +279,7 @@ public: void SendMail(const char *to, const char *from, const char *subject, const char *message); uint16 CreateDoor( const char* model, float x, float y, float z, float heading, uint8 opentype, uint16 size); int32 GetZoneID(const char *zone); - static std::string GetZoneLongName(std::string zone_short_name); - static std::string GetZoneLongNameByID(uint32 zone_id); - static std::string GetZoneShortName(uint32 zone_id); + const char *GetZoneLongName(const char *zone); void CrossZoneAssignTaskByCharID(int character_id, uint32 task_id, bool enforce_level_requirement = false); void CrossZoneAssignTaskByGroupID(int group_id, uint32 task_id, bool enforce_level_requirement = false); void CrossZoneAssignTaskByRaidID(int raid_id, uint32 task_id, bool enforce_level_requirement = false); @@ -372,17 +364,10 @@ public: bool DisableRecipe(uint32 recipe_id); void ClearNPCTypeCache(int npctype_id); void ReloadZoneStaticData(); - std::string secondstotime(int duration); - std::string gethexcolorcode(std::string color_name); - double GetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id) const; - double GetEXPModifierByCharID(uint32 character_id, uint32 zone_id) const; - void SetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, double aa_modifier); - void SetEXPModifierByCharID(uint32 character_id, uint32 zone_id, double exp_modifier); Client *GetInitiator() const; NPC *GetNPC() const; Mob *GetOwner() const; - EQ::InventoryProfile* GetInventory() const; EQ::ItemInstance *GetQuestItem() const; std::string GetEncounter() const; inline bool ProximitySayInUse() { return HaveProximitySays; } diff --git a/zone/raid.h b/zone/raid.h new file mode 100644 index 000000000..fad4b9fa2 --- /dev/null +++ b/zone/raid.h @@ -0,0 +1,161 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* Parser needs these defines always, even if USE_RAID is not defined */ +#define RAID_TYPE_0 1 /* Striping */ +#define RAID_TYPE_x 2 /* Some new modes */ +#define RAID_TYPE_y 3 + +#define RAID_DEFAULT_CHUNKS 4 +#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */ + +extern const char *raid_type_string[]; + +#ifdef __cplusplus +extern "C" { +#endif +const char *my_raid_type(int raid_type); +#ifdef __cplusplus +} +#endif + +#if defined(USE_RAID) && !defined(DONT_USE_RAID) + +#ifdef __GNUC__ +#pragma interface /* gcc class implementation */ +#endif +#include "my_dir.h" + +/* Trap all occurences of my_...() in source and use our wrapper around this function */ + +#ifdef MAP_TO_USE_RAID +#define my_read(A,B,C,D) my_raid_read(A,B,C,D) +#define my_write(A,B,C,D) my_raid_write(A,B,C,D) +#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E) +#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E) +#define my_chsize(A,B,C) my_raid_chsize(A,B,C) +#define my_close(A,B) my_raid_close(A,B) +#define my_tell(A,B) my_raid_tell(A,B) +#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D) +#define my_lock(A,B,C,D,E) my_raid_lock(A,B,C,D,E) +#define my_fstat(A,B,C) my_raid_fstat(A,B,C) +#endif /* MAP_TO_USE_RAID */ + +#ifdef __cplusplus +extern "C" { +#endif + +void init_raid(void); +void end_raid(void); + +bool is_raid(File fd); +File my_raid_create(const char *FileName, int CreateFlags, int access_flags, + uint raid_type, uint raid_chunks, ulong raid_chunksize, + myf MyFlags); +File my_raid_open(const char *FileName, int Flags, + uint raid_type, uint raid_chunks, ulong raid_chunksize, + myf MyFlags); +int my_raid_rename(const char *from, const char *to, uint raid_chunks, + myf MyFlags); +int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags); +int my_raid_redel(const char *old_name, const char *new_name, + uint raid_chunks, myf MyFlags); + +my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags); +my_off_t my_raid_tell(File fd, myf MyFlags); + +uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags); +uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags); + +uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, + myf MyFlags); +uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count, + my_off_t offset, myf MyFlags); + +int my_raid_lock(File,int locktype, my_off_t start, my_off_t length, + myf MyFlags); +int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags); +int my_raid_close(File, myf MyFlags); +int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags); + +#ifdef __cplusplus +} + +class RaidName { + public: + RaidName(const char *FileName); + ~RaidName(); + bool IsRaid(); + int Rename(const char * from, const char * to, myf MyFlags); + private: + uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ + uint _raid_chunks; /* 1..n */ + ulong _raid_chunksize; /* 1..n in bytes */ +}; + +class RaidFd { + public: + RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize); + ~RaidFd(); + File Create(const char *FileName, int CreateFlags, int access_flags, + myf MyFlags); + File Open(const char *FileName, int Flags, myf MyFlags); + my_off_t Seek(my_off_t pos,int whence,myf MyFlags); + my_off_t Tell(myf MyFlags); + int Write(const byte *Buffer, uint Count, myf MyFlags); + int Read(const byte *Buffer, uint Count, myf MyFlags); + int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags); + int Chsize(File fd, my_off_t newlength, myf MyFlags); + int Fstat(int fd, MY_STAT *stat_area, myf MyFlags ); + int Close(myf MyFlags); + static bool IsRaid(File fd); + static DYNAMIC_ARRAY _raid_map; /* Map of RaidFD* */ + private: + + uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ + uint _raid_chunks; /* 1..n */ + ulong _raid_chunksize; /* 1..n in bytes */ + + ulong _total_block; /* We are operating with block no x (can be 0..many). */ + uint _this_block; /* can be 0.._raid_chunks */ + uint _remaining_bytes; /* Maximum bytes that can be written in this block */ + + my_off_t _position; + my_off_t _size; /* Cached file size for faster seek(SEEK_END) */ + File _fd; + File *_fd_vector; /* Array of File */ + off_t *_seek_vector; /* Array of cached seek positions */ + + inline void Calculate() + { + DBUG_ENTER("RaidFd::_Calculate"); + DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu", + (ulong) _position, _raid_chunksize, (ulong) _size)); + + _total_block = (ulong) (_position / _raid_chunksize); + _this_block = _total_block % _raid_chunks; /* can be 0.._raid_chunks */ + _remaining_bytes = (uint) (_raid_chunksize - (_position - _total_block * _raid_chunksize)); + DBUG_PRINT("info", + ("_total_block: %d this_block: %d _remaining_bytes:%d", + _total_block, _this_block, _remaining_bytes)); + DBUG_VOID_RETURN; + } +}; + +#endif /* __cplusplus */ +#endif /* USE_RAID */ + diff --git a/zone/raids.cpp b/zone/raids.cpp index 55e6d9e55..2dc892a9a 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -20,7 +20,6 @@ #include "client.h" #include "entity.h" -#include "expedition.h" #include "groups.h" #include "mob.h" #include "raids.h" @@ -280,8 +279,6 @@ void Raid::SetRaidLeader(const char *wasLead, const char *name) Client *c = entity_list.GetClientByName(name); if(c) SetLeader(c); - else - SetLeader(nullptr); //sanity check, should never get hit but we want to prefer to NOT crash if we do VerifyRaid and leader never gets set there (raid without a leader?) LearnMembers(); VerifyRaid(); @@ -1552,11 +1549,6 @@ void Raid::VerifyRaid() SetLeader(members[x].member); strn0cpy(leadername, members[x].membername, 64); } - else - { - //should never happen, but maybe it is? - SetLeader(nullptr); - } } } } @@ -1566,11 +1558,6 @@ void Raid::MemberZoned(Client *c) if(!c) return; - if (leader == c) - { - leader = nullptr; - } - // Raid::GetGroup() goes over the members as well, this way we go over once uint32 gid = RAID_GROUPLESS; for(int x = 0; x < MAX_RAID_MEMBERS; x++) @@ -1850,42 +1837,3 @@ void Raid::QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_re } } } - -std::vector Raid::GetMembers() const -{ - std::vector raid_members; - for (int i = 0; i < MAX_RAID_MEMBERS; ++i) - { - if (members[i].membername[0]) - { - raid_members.emplace_back(members[i]); - } - } - return raid_members; -} - -bool Raid::DoesAnyMemberHaveExpeditionLockout( - const std::string& expedition_name, const std::string& event_name, int max_check_count) -{ - auto raid_members = GetMembers(); - - if (max_check_count > 0) - { - // priority is leader, group number, then ungrouped members - std::sort(raid_members.begin(), raid_members.end(), - [&](const RaidMember& lhs, const RaidMember& rhs) { - if (lhs.IsRaidLeader) { - return true; - } else if (rhs.IsRaidLeader) { - return false; - } - return lhs.GroupNumber < rhs.GroupNumber; - }); - - raid_members.resize(max_check_count); - } - - return std::any_of(raid_members.begin(), raid_members.end(), [&](const RaidMember& raid_member) { - return Expedition::HasLockoutByCharacterName(raid_member.membername, expedition_name, event_name); - }); -} diff --git a/zone/raids.h b/zone/raids.h index a04d1eb54..26ba90a02 100644 --- a/zone/raids.h +++ b/zone/raids.h @@ -239,10 +239,6 @@ public: void QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_required = true, bool ignore_sender = true, float distance = 0, bool group_only = true); - bool DoesAnyMemberHaveExpeditionLockout(const std::string& expedition_name, const std::string& event_name, int max_check_count = 0); - - std::vector GetMembers() const; - RaidMember members[MAX_RAID_MEMBERS]; char leadername[64]; protected: diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index b6689d715..37b8cc943 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -70,8 +70,7 @@ CREATE TABLE spawn_events ( Spawn2::Spawn2(uint32 in_spawn2_id, uint32 spawngroup_id, float in_x, float in_y, float in_z, float in_heading, uint32 respawn, uint32 variance, uint32 timeleft, uint32 grid, - bool in_path_when_zone_idle, uint16 in_cond_id, int16 in_min_value, - bool in_enabled, EmuAppearance anim) + uint16 in_cond_id, int16 in_min_value, bool in_enabled, EmuAppearance anim) : timer(100000), killcount(0) { spawn2_id = in_spawn2_id; @@ -83,7 +82,6 @@ Spawn2::Spawn2(uint32 in_spawn2_id, uint32 spawngroup_id, respawn_ = respawn; variance_ = variance; grid_ = grid; - path_when_zone_idle = in_path_when_zone_idle; condition_id = in_cond_id; condition_min_value = in_min_value; npcthis = nullptr; @@ -476,7 +474,6 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList "respawntime, " "variance, " "pathgrid, " - "path_when_zone_idle, " "_condition, " "cond_value, " "enabled, " @@ -497,7 +494,7 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList uint32 spawn_time_left = 0; Spawn2* new_spawn = 0; - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = atoi(row[11]) == 1 ? true : false; if (spawn_times.count(atoi(row[0])) != 0) spawn_time_left = spawn_times[atoi(row[0])]; @@ -511,22 +508,21 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList if (mob_distance > repop_distance) continue; - new_spawn = new Spawn2( - atoi(row[0]), // uint32 in_spawn2_id - atoi(row[1]), // uint32 spawngroup_id - atof(row[2]), // float in_x - atof(row[3]), // float in_y - atof(row[4]), // float in_z - atof(row[5]), // float in_heading - atoi(row[6]), // uint32 respawn - atoi(row[7]), // uint32 variance - spawn_time_left, // uint32 timeleft - atoi(row[8]), // uint32 grid - (bool)atoi(row[9]), // bool path_when_zone_idle - atoi(row[10]), // uint16 in_cond_id - atoi(row[11]), // int16 in_min_value - perl_enabled, // bool in_enabled - (EmuAppearance)atoi(row[13]) // EmuAppearance anim + new_spawn = new Spawn2( // + atoi(row[0]), // uint32 in_spawn2_id + atoi(row[1]), // uint32 spawngroup_id + atof(row[2]), // float in_x + atof(row[3]), // float in_y + atof(row[4]), // float in_z + atof(row[5]), // float in_heading + atoi(row[6]), // uint32 respawn + atoi(row[7]), // uint32 variance + spawn_time_left, // uint32 timeleft + atoi(row[8]), // uint32 grid + atoi(row[9]), // uint16 in_cond_id + atoi(row[10]), // int16 in_min_value + perl_enabled, // bool in_enabled + (EmuAppearance)atoi(row[12]) // EmuAppearance anim ); spawn2_list.Insert(new_spawn); @@ -582,7 +578,6 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa "respawntime, " "variance, " "pathgrid, " - "path_when_zone_idle, " "_condition, " "cond_value, " "enabled, " @@ -603,27 +598,26 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa uint32 spawn_time_left = 0; Spawn2* new_spawn = 0; - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = atoi(row[11]) == 1 ? true : false; if (spawn_times.count(atoi(row[0])) != 0) spawn_time_left = spawn_times[atoi(row[0])]; - new_spawn = new Spawn2( - atoi(row[0]), // uint32 in_spawn2_id - atoi(row[1]), // uint32 spawngroup_id - atof(row[2]), // float in_x - atof(row[3]), // float in_y - atof(row[4]), // float in_z - atof(row[5]), // float in_heading - atoi(row[6]), // uint32 respawn - atoi(row[7]), // uint32 variance - spawn_time_left, // uint32 timeleft - atoi(row[8]), // uint32 grid - (bool)atoi(row[9]), // bool path_when_zone_idle - atoi(row[10]), // uint16 in_cond_id - atoi(row[11]), // int16 in_min_value - perl_enabled, // bool in_enabled - (EmuAppearance)atoi(row[13]) // EmuAppearance anim + new_spawn = new Spawn2( // + atoi(row[0]), // uint32 in_spawn2_id + atoi(row[1]), // uint32 spawngroup_id + atof(row[2]), // float in_x + atof(row[3]), // float in_y + atof(row[4]), // float in_z + atof(row[5]), // float in_heading + atoi(row[6]), // uint32 respawn + atoi(row[7]), // uint32 variance + spawn_time_left, // uint32 timeleft + atoi(row[8]), // uint32 grid + atoi(row[9]), // uint16 in_cond_id + atoi(row[10]), // int16 in_min_value + perl_enabled, // bool in_enabled + (EmuAppearance)atoi(row[12]) // EmuAppearance anim ); spawn2_list.Insert(new_spawn); @@ -638,10 +632,9 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2id, uint32 timeleft) { std::string query = StringFormat("SELECT id, spawngroupID, x, y, z, heading, " - "respawntime, variance, pathgrid, " - "path_when_zone_idle, _condition, " - "cond_value, enabled, animation FROM spawn2 " - "WHERE id = %i", spawn2id); + "respawntime, variance, pathgrid, _condition, " + "cond_value, enabled, animation FROM spawn2 " + "WHERE id = %i", spawn2id); auto results = QueryDatabase(query); if (!results.Success()) { return nullptr; @@ -653,12 +646,11 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2 auto row = results.begin(); - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = atoi(row[11]) == 1 ? true : false; - auto newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), - atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), - timeleft, atoi(row[8]), (bool) atoi(row[9]), atoi(row[10]), - atoi(row[11]), perl_enabled, (EmuAppearance)atoi(row[13])); + auto newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), + atoi(row[6]), atoi(row[7]), timeleft, atoi(row[8]), atoi(row[9]), atoi(row[10]), + perl_enabled, (EmuAppearance)atoi(row[12])); spawn2_list.Insert(newSpawn); diff --git a/zone/spawn2.h b/zone/spawn2.h index 3f8b2e8ee..bf6530876 100644 --- a/zone/spawn2.h +++ b/zone/spawn2.h @@ -32,7 +32,7 @@ public: Spawn2(uint32 spawn2_id, uint32 spawngroup_id, float x, float y, float z, float heading, uint32 respawn, uint32 variance, - uint32 timeleft = 0, uint32 grid = 0, bool in_path_when_zone_idle=false, + uint32 timeleft = 0, uint32 grid = 0, uint16 cond_id = SC_AlwaysEnabled, int16 min_value = 0, bool in_enabled = true, EmuAppearance anim = eaStanding); ~Spawn2(); @@ -54,7 +54,6 @@ public: float GetY() { return y; } float GetZ() { return z; } float GetHeading() { return heading; } - bool PathWhenZoneIdle() { return path_when_zone_idle; } void SetRespawnTimer(uint32 newrespawntime) { respawn_ = newrespawntime; }; void SetVariance(uint32 newvariance) { variance_ = newvariance; } const uint32 GetVariance() const { return variance_; } @@ -87,7 +86,6 @@ private: float heading; uint32 variance_; uint32 grid_; - bool path_when_zone_idle; uint16 condition_id; int16 condition_min_value; bool enabled; diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index c337bfac0..97f3dab9a 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -78,9 +78,12 @@ uint32 SpawnGroup::GetNPCType(uint16 in_filter) return (0); } - std::list possible; - for (auto &it : list_) { - auto se = it.get(); + std::list::iterator cur, end; + std::list possible; + cur = list_.begin(); + end = list_.end(); + for (; cur != end; ++cur) { + SpawnEntry *se = *cur; if (!entity_list.LimitCheckType(se->NPCType, se->npc_spawn_limit)) { continue; @@ -92,7 +95,6 @@ uint32 SpawnGroup::GetNPCType(uint16 in_filter) totalchance += se->chance; possible.push_back(se); } - if (totalchance == 0) { return 0; } @@ -100,7 +102,10 @@ uint32 SpawnGroup::GetNPCType(uint16 in_filter) int32 roll = 0; roll = zone->random.Int(0, totalchance - 1); - for (auto se : possible) { + cur = possible.begin(); + end = possible.end(); + for (; cur != end; ++cur) { + SpawnEntry *se = *cur; if (roll < se->chance) { npcType = se->NPCType; break; @@ -112,28 +117,42 @@ uint32 SpawnGroup::GetNPCType(uint16 in_filter) return npcType; } -void SpawnGroup::AddSpawnEntry(std::unique_ptr &newEntry) +void SpawnGroup::AddSpawnEntry(SpawnEntry *newEntry) { - list_.push_back(std::move(newEntry)); + list_.push_back(newEntry); } SpawnGroup::~SpawnGroup() { + std::list::iterator cur, end; + cur = list_.begin(); + end = list_.end(); + for (; cur != end; ++cur) { + SpawnEntry *tmp = *cur; + safe_delete(tmp); + } list_.clear(); } SpawnGroupList::~SpawnGroupList() { + std::map::iterator cur, end; + cur = m_spawn_groups.begin(); + end = m_spawn_groups.end(); + for (; cur != end; ++cur) { + SpawnGroup *tmp = cur->second; + safe_delete(tmp); + } m_spawn_groups.clear(); } -void SpawnGroupList::AddSpawnGroup(std::unique_ptr &new_group) +void SpawnGroupList::AddSpawnGroup(SpawnGroup *new_group) { if (new_group == nullptr) { return; } - m_spawn_groups[new_group->id] = std::move(new_group); + m_spawn_groups[new_group->id] = new_group; } SpawnGroup *SpawnGroupList::GetSpawnGroup(uint32 in_id) @@ -142,7 +161,7 @@ SpawnGroup *SpawnGroupList::GetSpawnGroup(uint32 in_id) return nullptr; } - return (m_spawn_groups[in_id].get()); + return (m_spawn_groups[in_id]); } bool SpawnGroupList::RemoveSpawnGroup(uint32 in_id) @@ -191,8 +210,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG WHERE spawn2.spawngroupID = spawngroup.ID AND - (spawn2.version = {} OR version = -1) - AND zone = '{}' + spawn2.version = {} and zone = '{}' {} ), version, @@ -206,7 +224,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG } for (auto row = results.begin(); row != results.end(); ++row) { - auto new_spawn_group = std::make_unique( + auto new_spawn_group = new SpawnGroup( atoi(row[0]), row[1], atoi(row[2]), @@ -254,7 +272,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG } for (auto row = results.begin(); row != results.end(); ++row) { - auto new_spawn_entry = std::make_unique( + auto new_spawn_entry = new SpawnEntry( atoi(row[1]), atoi(row[2]), atoi(row[3]), @@ -264,6 +282,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); if (!spawn_group) { + safe_delete(new_spawn_entry); continue; } @@ -318,7 +337,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn row[3] ); - auto new_spawn_group = std::make_unique( + auto new_spawn_group = new SpawnGroup( atoi(row[0]), row[1], atoi(row[2]), @@ -361,7 +380,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn } for (auto row = results.begin(); row != results.end(); ++row) { - auto new_spawn_entry = std::make_unique( + auto new_spawn_entry = new SpawnEntry( atoi(row[1]), atoi(row[2]), atoi(row[3]), @@ -379,6 +398,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); if (!spawn_group) { + safe_delete(new_spawn_entry); continue; } diff --git a/zone/spawngroup.h b/zone/spawngroup.h index 20b84b734..a1068cea0 100644 --- a/zone/spawngroup.h +++ b/zone/spawngroup.h @@ -22,7 +22,6 @@ #include #include -#include class SpawnEntry { public: @@ -56,7 +55,7 @@ public: ~SpawnGroup(); uint32 GetNPCType(uint16 condition_value_filter=1); - void AddSpawnEntry(std::unique_ptr &newEntry); + void AddSpawnEntry(SpawnEntry *newEntry); uint32 id; bool wp_spawns; // if true, spawn NPCs at a random waypoint location (if spawnpoint has a grid) instead of the spawnpoint's loc float roamdist; @@ -67,7 +66,7 @@ public: uint32 despawn_timer; private: char name_[120]; - std::list> list_; + std::list list_; uint8 group_spawn_limit; //max # of this entry which can be spawned by this group }; @@ -76,13 +75,14 @@ public: SpawnGroupList() {} ~SpawnGroupList(); - void AddSpawnGroup(std::unique_ptr &new_group); + void AddSpawnGroup(SpawnGroup *new_group); SpawnGroup *GetSpawnGroup(uint32 id); bool RemoveSpawnGroup(uint32 in_id); void ClearSpawnGroups(); void ReloadSpawnGroups(); private: - std::map> m_spawn_groups; + //LinkedList list_; + std::map m_spawn_groups; }; #endif diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index b6c2f9cf8..2eb17eb29 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -774,13 +774,6 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove caster->SetPet(this); SetOwnerID(caster->GetID()); SetPetOrder(SPO_Follow); - SetAppearance(eaStanding); - // Client has saved previous pet sit/stand - make all new pets - // stand on charm. - if (caster->IsClient()) { - caster->CastToClient()->SetPetCommandState(PET_BUTTON_SIT,0); - } - SetPetType(petCharmed); if(caster->IsClient()){ @@ -1252,8 +1245,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove MakePet(spell_id, spell.teleport_zone); // TODO: we need to sync the states for these clients ... // Will fix buttons for now - Mob *pet=GetPet(); - if (IsClient() && pet) { + if (IsClient()) { auto c = CastToClient(); if (c->ClientVersionBit() & EQ::versions::maskUFAndLater) { c->SetPetCommandState(PET_BUTTON_SIT, 0); @@ -1261,9 +1253,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove c->SetPetCommandState(PET_BUTTON_REGROUP, 0); c->SetPetCommandState(PET_BUTTON_FOLLOW, 1); c->SetPetCommandState(PET_BUTTON_GUARD, 0); - // Creating pet from spell - taunt always false - // If suspended pet - that will be restore there - // If logging in, client will send toggle + c->SetPetCommandState(PET_BUTTON_TAUNT, 1); c->SetPetCommandState(PET_BUTTON_HOLD, 0); c->SetPetCommandState(PET_BUTTON_GHOLD, 0); c->SetPetCommandState(PET_BUTTON_FOCUS, 0); diff --git a/zone/spells.cpp b/zone/spells.cpp index 13c7ff1cf..8e70df06d 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -101,7 +101,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #endif #include "mob_movement_manager.h" -#include "client.h" extern Zone* zone; @@ -1038,10 +1037,8 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo // So long recast bard songs need special bard logic, although the effects don't repulse like other songs // This is basically a hack to get that effect // You can hold down the long recast spells, but you only get the effects once - // Songs with mana cost also do not repulse - // AAs that use SE_TemporaryPets or SE_Familiar also do not repulse // TODO fuck bards. - if (spells[spell_id].recast_time == 0 && spells[spell_id].mana == 0 && !IsEffectInSpell(spell_id, SE_TemporaryPets) && !IsEffectInSpell(spell_id, SE_Familiar)) { + if (spells[spell_id].recast_time == 0) { bardsong = spell_id; bardsong_slot = slot; //NOTE: theres a lot more target types than this to think about... @@ -2355,7 +2352,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui SpellOnTarget(spell_id, spell_target); #ifdef GROUP_BUFF_PETS //pet too - if (spells[spell_id].targettype != ST_GroupNoPets && spell_target->GetPet() && spell_target->HasPetAffinity() && !spell_target->GetPet()->IsCharmed()) + if (spells[spell_id].targettype != ST_GroupNoPets && spell_target->GetPet() && HasPetAffinity() && !spell_target->GetPet()->IsCharmed()) SpellOnTarget(spell_id, spell_target->GetPet()); #endif } @@ -2391,6 +2388,8 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui } } + DoAnim(spells[spell_id].CastingAnim, 0, true, IsClient() ? FilterPCSpells : FilterNPCSpells); + // Set and send the nimbus effect if this spell has one int NimbusEffect = GetNimbusEffect(spell_id); if(NimbusEffect) { @@ -2640,6 +2639,8 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo } } + //do we need to do this??? + DoAnim(spells[spell_id].CastingAnim, 0, true, IsClient() ? FilterPCSpells : FilterNPCSpells); if(IsClient()) CastToClient()->CheckSongSkillIncrease(spell_id); @@ -2647,12 +2648,6 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo } void Mob::BardPulse(uint16 spell_id, Mob *caster) { - // so for Solon's Song of the Sirens (725) if we're repulsing, we need to skip - // other charms have mana and don't repulse - // This is probably not the ideal place for this, but it will work - if (IsCharmed() && GetOwner() == caster && IsEffectInSpell(spell_id, SE_Charm)) { - return; - } int buffs_i; int buff_count = GetMaxTotalSlots(); for (buffs_i = 0; buffs_i < buff_count; buffs_i++) { @@ -4531,7 +4526,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use // JULY 24, 2002 changes int level = GetLevel(); - if (RuleB(Spells,July242002PetResists) && IsPetOwnerClient() && caster->IsNPC() && !caster->IsPetOwnerClient()) { + if (IsPetOwnerClient() && caster->IsNPC() && !caster->IsPetOwnerClient()) { auto owner = GetOwner(); if (owner != nullptr) { target_resist = std::max(target_resist, owner->GetResist(resist_type)); @@ -4924,13 +4919,11 @@ void Mob::Stun(int duration) if(stunned && stunned_timer.GetRemainingTime() > uint32(duration)) return; - auto spell_id = bardsong ? bardsong : casting_spell_id; - - if(IsValidSpell(spell_id) && !spells[spell_id].uninterruptable) { + if(IsValidSpell(casting_spell_id) && !spells[casting_spell_id].uninterruptable) { int persistent_casting = spellbonuses.PersistantCasting + itembonuses.PersistantCasting + aabonuses.PersistantCasting; if(zone->random.Int(0,99) > persistent_casting) - InterruptSpell(spell_id); + InterruptSpell(); } if(duration > 0) @@ -4986,11 +4979,9 @@ void Mob::Mesmerize() { mezzed = true; - auto spell_id = bardsong ? bardsong : casting_spell_id; + if (casting_spell_id) + InterruptSpell(); - if (spell_id) - InterruptSpell(spell_id); - StopNavigation(); } @@ -5098,13 +5089,6 @@ void Client::UnmemSpellAll(bool update_client) UnmemSpell(i, update_client); } -uint32 Client::GetSpellIDByBookSlot(int book_slot) { - if (book_slot <= EQ::spells::SPELLBOOK_SIZE) { - return GetSpellByBookSlot(book_slot); - } - return -1; //default -} - uint16 Client::FindMemmedSpellBySlot(int slot) { if (m_pp.mem_spells[slot] != 0xFFFFFFFF) return m_pp.mem_spells[slot]; @@ -6020,4 +6004,3 @@ bool Client::IsLinkedSpellReuseTimerReady(uint32 timer_id) return GetPTimers().Expired(&database, pTimerLinkedSpellReuseStart + timer_id, false); } - diff --git a/zone/string_ids.h b/zone/string_ids.h index 25c62d6b2..b7ee5ddd4 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -293,47 +293,8 @@ #define TRADESKILL_MISSING_ITEM 3455 //You are missing a %1. #define TRADESKILL_MISSING_COMPONENTS 3456 //Sorry, but you don't have everything you need for this recipe in your general inventory. #define TRADESKILL_LEARN_RECIPE 3457 //You have learned the recipe %1! -#define EXPEDITION_YOU_BELONG 3500 //You cannot create this expedition since you already belong to another. -#define EXPEDITION_YOU_PLAYED_HERE 3501 //You cannot create this expedition for another %1d:%2h:%3m since you have recently played here. -#define REQUIRED_PLAYER_COUNT 3503 //You do not meet the player count requirement. You have %1 players. You must have at least %2 and no more than %3. -#define EXPEDITION_REPLAY_TIMER 3504 //%1 cannot be added to this expedition for another %2D:%3H:%4M since they have recently played in this area. -#define EXPEDITION_AVAILABLE 3507 //%1 is now available to you. -#define DZADD_INVITE 3508 //Sending an invitation to: %1. -#define DZ_PREVENT_ENTERING 3510 //A strange magical presence prevents you from entering. It's too dangerous to enter at the moment. -#define DZADD_INVITE_FAIL 3511 //%1 could not be invited to join you. -#define UNABLE_RETRIEVE_LEADER 3512 //Unable to retrieve information on the leader to check permissions. -#define EXPEDITION_NOT_LEADER 3513 //You are not the expedition leader, only %1 can issue this command. -#define EXPEDITION_NOT_MEMBER 3514 //%1 is not a member of this expedition. -#define EXPEDITION_REMOVED 3516 //%1 has been removed from %2. -#define DZSWAP_INVITE 3517 //Sending an invitation to: %1. They must accept in order to swap party members. -#define DZMAKELEADER_NOT_ONLINE 3518 //%1 is not currently online. You can only transfer leadership to an online member of the expedition you are in. -#define DZLIST_REPLAY_TIMER 3519 //You have %1d:%2h:%3m remaining until you may enter %4. -#define DZMAKELEADER_NAME 3520 //%1 has been made the leader for this expedition. -#define DZMAKELEADER_YOU 3521 //You have been made the leader of this expedition. -#define EXPEDITION_INVITE_ACCEPTED 3522 //%1 has accepted your offer to join your expedition. -#define EXPEDITION_MEMBER_ADDED 3523 //%1 has been added to %2. -#define EXPEDITION_INVITE_ERROR 3524 //%1 accepted your offer to join your expedition but could not due to error(s). -#define EXPEDITION_INVITE_DECLINED 3525 //%1 has declined your offer to join your expedition. -#define EXPEDITION_ASKED_TO_JOIN 3527 //%1 has asked you to join the expedition: %2. Would you like to join? -#define DYNAMICZONE_WAY_IS_BLOCKED 3528 //The way is blocked to you. Perhaps you would be able to enter if there was a reason to come here. -#define EXPEDITION_NO_TIMERS 3529 //You have no outstanding timers. -#define EXPEDITION_MIN_REMAIN 3551 //You only have %1 minutes remaining before this expedition comes to an end. -#define EXPEDITION_LEADER 3552 //Expedition Leader: %1 -#define EXPEDITION_MEMBERS 3553 //Expedition Members: %1 -#define EXPEDITION_EVENT_TIMER 3561 //%1 cannot be added to this expedition since they have recently experienced %2. They must wait another %3D:%4H:%5M until they can experience it again. They may be added to the expedition later, once %2 has been completed. +#define EXPEDITION_MIN_REMAIN 3551 //You only have %1 minutes remaining before this expedition comes to an end. #define LOOT_NOT_ALLOWED 3562 //You are not allowed to loot the item: %1. -#define DZ_UNABLE_RETRIEVE_LEADER 3583 //Unable to retrieve dynamic zone leader to check permissions. -#define DZADD_NOT_ALLOWING 3585 //The expedition is not allowing players to be added. -#define DZADD_NOT_ONLINE 3586 //%1 is not currently online. A player needs to be online to be added to a Dynamic Zone -#define DZADD_EXCEED_MAX 3587 //You can not add another player since you currently have the maximum number of players allowed (%1) in this zone. -#define DZADD_ALREADY_PART 3588 //You can not add %1 since they are already part of this zone. -#define DZADD_LEAVE_ZONE_FIRST 3589 //You can not add %1 since they first need to leave the zone before being allowed back in. -#define DZADD_ALREADY_ASSIGNED 3590 //%1 can not be added to this dynamic zone since they are already assigned to another dynamic zone. -#define DZADD_REPLAY_TIMER 3591 //%1 can not be added to this dynamic zone for another %2D:%3H:%4M since they have recently played this zone. -#define DZADD_EVENT_TIMER 3592 //%1 can not be added to this dynamic zone since they have recently experienced %2. They must wait for another %3D:%4H:%5M, or until event %2 has occurred. -#define DZADD_PENDING 3593 //%1 currently has an outstanding invitation to join this Dynamic Zone. -#define DZADD_PENDING_OTHER 3594 //%1 currently has an outstanding invitation to join another Dynamic Zone. Players may only have one invitation outstanding. -#define DZSWAP_CANNOT_REMOVE 3595 //%1 can not be removed from this dynamic zone since they are not assigned to it. #define NOT_YOUR_TRAP 3671 //You cannot remove this, you are only allowed to remove traps you have set. #define NO_CAST_ON_PET 4045 //You cannot cast this spell on your pet. #define REWIND_WAIT 4059 //You must wait a bit longer before using the rewind command again. @@ -403,9 +364,6 @@ #define LDON_NO_LOCKPICK 7564 //You must have a lock pick in your inventory to do this. #define LDON_WAS_NOT_LOCKED 7565 //%1 was not locked. #define LDON_WAS_NOT_TRAPPED 7566 //%1 was not trapped -#define GAIN_SINGLE_AA_SINGLE_AA 8019 //You have gained an ability point! You now have %1 ability point. -#define GAIN_SINGLE_AA_MULTI_AA 8020 //You have gained an ability point! You now have %1 ability points. -#define GAIN_MULTI_AA_MULTI_AA 8021 //You have gained %1 ability point(s)! You now have %2 ability point(s). #define GAIN_GROUP_LEADERSHIP_POINT 8585 // #define GAIN_RAID_LEADERSHIP_POINT 8589 // #define MAX_GROUP_LEADERSHIP_POINTS 8584 // diff --git a/zone/task_client_state.cpp b/zone/task_client_state.cpp deleted file mode 100644 index 3ded9eb27..000000000 --- a/zone/task_client_state.cpp +++ /dev/null @@ -1,2177 +0,0 @@ -#include "../common/global_define.h" -#include "../common/misc_functions.h" -#include "../common/repositories/character_activities_repository.h" -#include "../common/repositories/character_tasks_repository.h" -#include "../common/repositories/completed_tasks_repository.h" -#include "../common/rulesys.h" -#include "client.h" -#include "queryserv.h" -#include "quest_parser_collection.h" -#include "task_client_state.h" -#include "zonedb.h" - -extern QueryServ *QServ; - -ClientTaskState::ClientTaskState() -{ - m_active_task_count = 0; - m_last_completed_task_loaded = 0; - m_checked_touch_activities = false; - - for (int i = 0; i < MAXACTIVEQUESTS; i++) { - m_active_quests[i].slot = i; - m_active_quests[i].task_id = TASKSLOTEMPTY; - } - - m_active_task.slot = 0; - m_active_task.task_id = TASKSLOTEMPTY; - // TODO: shared task -} - -ClientTaskState::~ClientTaskState() -{ -} - -void ClientTaskState::SendTaskHistory(Client *client, int task_index) -{ - - LogTasks("[SendTaskHistory] Task history requested for completed task index [{}]", task_index); - - // We only sent the most recent 50 completed tasks, so we need to offset the Index the client sent to us. - - int adjusted_task_index = task_index; - if (m_completed_tasks.size() > 50) { - adjusted_task_index += (m_completed_tasks.size() - 50); - } - - if ((adjusted_task_index < 0) || (adjusted_task_index >= (int) m_completed_tasks.size())) { - return; - } - - int task_id = m_completed_tasks[adjusted_task_index].task_id; - if ((task_id < 0) || (task_id > MAXTASKS)) { - return; - } - - TaskInformation *p_task_data = task_manager->m_task_data[task_id]; - - if (p_task_data == nullptr) { - return; - } - - TaskHistoryReplyHeader_Struct *task_history_reply; - TaskHistoryReplyData1_Struct *task_history_reply_data_1; - TaskHistoryReplyData2_Struct *task_history_reply_data_2; - - char *reply; - - int completed_activity_count = 0; - int packet_length = sizeof(TaskHistoryReplyHeader_Struct); - - for (int i = 0; i < p_task_data->activity_count; i++) { - if (m_completed_tasks[adjusted_task_index].activity_done[i]) { - completed_activity_count++; - packet_length = packet_length + sizeof(TaskHistoryReplyData1_Struct) + - p_task_data->activity_information[i].target_name.size() + 1 + - p_task_data->activity_information[i].item_list.size() + 1 + - sizeof(TaskHistoryReplyData2_Struct) + - p_task_data->activity_information[i].description_override.size() + 1; - } - } - - auto outapp = new EQApplicationPacket(OP_TaskHistoryReply, packet_length); - - task_history_reply = (TaskHistoryReplyHeader_Struct *) outapp->pBuffer; - - // We use the TaskIndex the client sent in the request - task_history_reply->TaskID = task_index; - task_history_reply->ActivityCount = completed_activity_count; - - reply = (char *) task_history_reply + sizeof(TaskHistoryReplyHeader_Struct); - - for (int i = 0; i < p_task_data->activity_count; i++) { - if (m_completed_tasks[adjusted_task_index].activity_done[i]) { - task_history_reply_data_1 = (TaskHistoryReplyData1_Struct *) reply; - task_history_reply_data_1->ActivityType = p_task_data->activity_information[i].activity_type; - reply = (char *) task_history_reply_data_1 + sizeof(TaskHistoryReplyData1_Struct); - VARSTRUCT_ENCODE_STRING(reply, p_task_data->activity_information[i].target_name.c_str()); - VARSTRUCT_ENCODE_STRING(reply, p_task_data->activity_information[i].item_list.c_str()); - task_history_reply_data_2 = (TaskHistoryReplyData2_Struct *) reply; - task_history_reply_data_2->GoalCount = p_task_data->activity_information[i].goal_count; - task_history_reply_data_2->unknown04 = 0xffffffff; - task_history_reply_data_2->unknown08 = 0xffffffff; - task_history_reply_data_2->ZoneID = p_task_data->activity_information[i].zone_ids.empty() ? 0 - : p_task_data->activity_information[i].zone_ids.front(); - task_history_reply_data_2->unknown16 = 0x00000000; - reply = (char *) task_history_reply_data_2 + sizeof(TaskHistoryReplyData2_Struct); - VARSTRUCT_ENCODE_STRING(reply, p_task_data->activity_information[i].description_override.c_str()); - } - } - - client->QueuePacket(outapp); - safe_delete(outapp); -} - -void ClientTaskState::EnableTask(int character_id, int task_count, int *task_list) -{ - // Check if the Task is already enabled for this client - std::vector tasks_enabled; - - for (int i = 0; i < task_count; i++) { - auto iterator = m_enabled_tasks.begin(); - bool add_task = true; - - while (iterator != m_enabled_tasks.end()) { - // If this task is already enabled, stop looking - if ((*iterator) == task_list[i]) { - add_task = false; - break; - } - // Our list of enabled tasks is sorted, so we can quit if we find a taskid higher than - // the one we are looking for. - if ((*iterator) > task_list[i]) { - break; - } - ++iterator; - } - - if (add_task) { - m_enabled_tasks.insert(iterator, task_list[i]); - // Make a note of the task we enabled, for later SQL generation - tasks_enabled.push_back(task_list[i]); - } - } - - LogTasksDetail("[EnableTask] New enabled task list"); - for (int enabled_task : m_enabled_tasks) { - LogTasksDetail("[EnableTask] enabled [{}] character_id [{}]", enabled_task, character_id); - } - - if (tasks_enabled.empty()) { - return; - } - - std::stringstream query_stream; - query_stream << "REPLACE INTO character_enabledtasks (charid, taskid) VALUES "; - for (unsigned int i = 0; i < tasks_enabled.size(); i++) { - query_stream << (i ? ", " : "") << StringFormat("(%i, %i)", character_id, tasks_enabled[i]); - } - - std::string query = query_stream.str(); - if (!tasks_enabled.empty()) { - database.QueryDatabase(query); - } - else { - LogTasks("[EnableTask] Called for character_id [{}] but, no tasks exist", character_id); - } -} - -void ClientTaskState::DisableTask(int character_id, int task_count, int *task_list) -{ - - // Check if the Task is enabled for this client - std::vector tasks_disabled; - - for (int task_id = 0; task_id < task_count; task_id++) { - auto iterator = m_enabled_tasks.begin(); - bool removeTask = false; - - while (iterator != m_enabled_tasks.end()) { - if ((*iterator) == task_list[task_id]) { - removeTask = true; - break; - } - - if ((*iterator) > task_list[task_id]) { - break; - } - - ++iterator; - } - - if (removeTask) { - m_enabled_tasks.erase(iterator); - tasks_disabled.push_back(task_list[task_id]); - } - } - - LogTasks("[DisableTask] New enabled task list "); - for (int enabled_task : m_enabled_tasks) { - LogTasks("[DisableTask] enabled_tasks [{}]", enabled_task); - } - - if (tasks_disabled.empty()) { - return; - } - - std::stringstream queryStream; - queryStream << StringFormat("DELETE FROM character_enabledtasks WHERE charid = %i AND (", character_id); - - for (unsigned int i = 0; i < tasks_disabled.size(); i++) - queryStream - << (i ? StringFormat("taskid = %i ", tasks_disabled[i]) : StringFormat( - "OR taskid = %i ", - tasks_disabled[i] - )); - - queryStream << ")"; - - std::string query = queryStream.str(); - - if (tasks_disabled.size()) { - database.QueryDatabase(query); - } - else { - LogTasks( - "[DisableTask] DisableTask called for character_id [{}] ... but, no tasks exist", - character_id - ); - } -} - -bool ClientTaskState::IsTaskEnabled(int task_id) -{ - std::vector::iterator iterator; - - iterator = m_enabled_tasks.begin(); - - while (iterator != m_enabled_tasks.end()) { - if ((*iterator) == task_id) { return true; } - if ((*iterator) > task_id) { break; } - ++iterator; - } - - return false; -} - -int ClientTaskState::EnabledTaskCount(int task_set_id) -{ - - // Return the number of tasks in TaskSet that this character is enabled for. - - unsigned int enabled_task_index = 0; - unsigned int task_set_index = 0; - int enabled_task_count = 0; - - if ((task_set_id <= 0) || (task_set_id >= MAXTASKSETS)) { return -1; } - - while ((enabled_task_index < m_enabled_tasks.size()) && - (task_set_index < task_manager->m_task_sets[task_set_id].size())) { - - if (m_enabled_tasks[enabled_task_index] == task_manager->m_task_sets[task_set_id][task_set_index]) { - enabled_task_count++; - enabled_task_index++; - task_set_index++; - continue; - } - - if (m_enabled_tasks[enabled_task_index] < task_manager->m_task_sets[task_set_id][task_set_index]) { - enabled_task_index++; - } - else { - task_set_index++; - } - - } - - return enabled_task_count; -} - -int ClientTaskState::ActiveTasksInSet(int task_set_id) -{ - if ((task_set_id <= 0) || (task_set_id >= MAXTASKSETS)) { - return -1; - } - - int active_task_in_set_count = 0; - - for (int task_id : task_manager->m_task_sets[task_set_id]) { - if (IsTaskActive(task_id)) { - active_task_in_set_count++; - } - } - - return active_task_in_set_count; -} - -int ClientTaskState::CompletedTasksInSet(int task_set_id) -{ - if ((task_set_id <= 0) || (task_set_id >= MAXTASKSETS)) { - return -1; - } - - int completed_tasks_count = 0; - - for (int i : task_manager->m_task_sets[task_set_id]) { - if (IsTaskCompleted(i)) { - completed_tasks_count++; - } - } - - return completed_tasks_count; -} - -bool ClientTaskState::HasSlotForTask(TaskInformation *task) -{ - if (task == nullptr) { - return false; - } - - switch (task->type) { - case TaskType::Task: - return m_active_task.task_id == TASKSLOTEMPTY; - case TaskType::Shared: - return false; // todo - case TaskType::Quest: - for (auto &active_quest : m_active_quests) { - if (active_quest.task_id == TASKSLOTEMPTY) { - return true; - } - } - case TaskType::E: - return false; // removed on live - } - - return false; -} - -int ClientTaskState::GetActiveTaskID(int index) -{ - // Return the task_id from the client's specified Active Task slot. - if ((index < 0) || (index >= MAXACTIVEQUESTS)) { - return 0; - } - - return m_active_quests[index].task_id; -} - -static void DeleteCompletedTaskFromDatabase(int character_id, int task_id) -{ - LogTasks("[DeleteCompletedTasksFromDatabase] character_id [{}], task_id [{}]", character_id, task_id); - - CompletedTasksRepository::DeleteWhere( - database, - fmt::format("charid = {} and taskid = {}", character_id, task_id) - ); -} - -bool ClientTaskState::UnlockActivities(int character_id, ClientTaskInformation &task_info) -{ - bool all_activities_complete = true; - - TaskInformation *p_task_data = task_manager->m_task_data[task_info.task_id]; - if (p_task_data == nullptr) { - return true; - } - - // On loading the client state, all activities that are not completed, are - // marked as hidden. For Sequential (non-stepped) mode, we mark the first - // activity_information as active if not complete. - LogTasks( - "character_id [{}] task_id [{}] sequence_mode [{}]", - character_id, - task_info.task_id, - p_task_data->sequence_mode - ); - - if (p_task_data->sequence_mode == ActivitiesSequential) { - if (task_info.activity[0].activity_state != ActivityCompleted) { - task_info.activity[0].activity_state = ActivityActive; - } - - // Enable the next Hidden task. - for (int i = 0; i < p_task_data->activity_count; i++) { - if ((task_info.activity[i].activity_state == ActivityActive) && - (!p_task_data->activity_information[i].optional)) { - all_activities_complete = false; - break; - } - - if (task_info.activity[i].activity_state == ActivityHidden) { - task_info.activity[i].activity_state = ActivityActive; - all_activities_complete = false; - break; - } - } - - if (all_activities_complete && RuleB(TaskSystem, RecordCompletedTasks)) { - if (RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { - LogTasks("KeepOneRecord enabled"); - auto iterator = m_completed_tasks.begin(); - int erased_elements = 0; - while (iterator != m_completed_tasks.end()) { - int task_id = (*iterator).task_id; - if (task_id == task_info.task_id) { - iterator = m_completed_tasks.erase(iterator); - erased_elements++; - } - else { - ++iterator; - } - } - - LogTasks("Erased Element count is [{}]", erased_elements); - - if (erased_elements) { - m_last_completed_task_loaded -= erased_elements; - DeleteCompletedTaskFromDatabase(character_id, task_info.task_id); - } - } - - CompletedTaskInformation completed_task_information{}; - completed_task_information.task_id = task_info.task_id; - completed_task_information.completed_time = time(nullptr); - - for (int i = 0; i < p_task_data->activity_count; i++) { - completed_task_information.activity_done[i] = (task_info.activity[i].activity_state == ActivityCompleted); - } - - m_completed_tasks.push_back(completed_task_information); - } - - LogTasks("Returning sequential task, AllActivitiesComplete is [{}]", all_activities_complete); - - return all_activities_complete; - } - - // Stepped Mode - // TODO: This code is probably more complex than it needs to be - - bool current_step_complete = true; - - LogTasks( - "[UnlockActivities] Current step [{}] last_step [{}]", - task_info.current_step, - p_task_data->last_step - ); - - // If current_step is -1, this is the first call to this method since loading the - // client state. Unlock all activities with a step number of 0 - - if (task_info.current_step == -1) { - for (int i = 0; i < p_task_data->activity_count; i++) { - - if (p_task_data->activity_information[i].step_number == 0 && - task_info.activity[i].activity_state == ActivityHidden) { - task_info.activity[i].activity_state = ActivityActive; - // task_info.activity_information[i].updated=true; - } - } - task_info.current_step = 0; - } - - for (int current_step = task_info.current_step; current_step <= p_task_data->last_step; current_step++) { - for (int activity = 0; activity < p_task_data->activity_count; activity++) { - if (p_task_data->activity_information[activity].step_number == (int) task_info.current_step) { - if ((task_info.activity[activity].activity_state != ActivityCompleted) && - (!p_task_data->activity_information[activity].optional)) { - current_step_complete = false; - all_activities_complete = false; - break; - } - } - } - if (!current_step_complete) { - break; - } - task_info.current_step++; - } - - if (all_activities_complete) { - if (RuleB(TaskSystem, RecordCompletedTasks)) { - // If we are only keeping one completed record per task, and the player has done - // the same task again, erase the previous completed entry for this task. - if (RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { - LogTasksDetail("[UnlockActivities] KeepOneRecord enabled"); - auto iterator = m_completed_tasks.begin(); - int erased_elements = 0; - - while (iterator != m_completed_tasks.end()) { - int task_id = (*iterator).task_id; - if (task_id == task_info.task_id) { - iterator = m_completed_tasks.erase(iterator); - erased_elements++; - } - else { - ++iterator; - } - } - - LogTasksDetail("[UnlockActivities] Erased Element count is [{}]", erased_elements); - - if (erased_elements) { - m_last_completed_task_loaded -= erased_elements; - DeleteCompletedTaskFromDatabase(character_id, task_info.task_id); - } - } - - CompletedTaskInformation completed_task_information{}; - completed_task_information.task_id = task_info.task_id; - completed_task_information.completed_time = time(nullptr); - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - completed_task_information.activity_done[activity_id] = - (task_info.activity[activity_id].activity_state == ActivityCompleted); - } - - m_completed_tasks.push_back(completed_task_information); - } - return true; - } - - // Mark all non-completed tasks in the current step as active - for (int activity = 0; activity < p_task_data->activity_count; activity++) { - if ((p_task_data->activity_information[activity].step_number == (int) task_info.current_step) && - (task_info.activity[activity].activity_state == ActivityHidden)) { - task_info.activity[activity].activity_state = ActivityActive; - task_info.activity[activity].updated = true; - } - } - - return false; -} - -void ClientTaskState::UpdateTasksOnKill(Client *client, int npc_type_id) -{ - UpdateTasksByNPC(client, ActivityKill, npc_type_id); -} - -bool ClientTaskState::UpdateTasksOnSpeakWith(Client *client, int npc_type_id) -{ - return UpdateTasksByNPC(client, ActivitySpeakWith, npc_type_id); -} - -bool ClientTaskState::UpdateTasksByNPC(Client *client, int activity_type, int npc_type_id) -{ - - int is_updating = false; - - // If the client has no tasks, there is nothing further to check. - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return false; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - // Check if there are any active kill activities for this p_task_data - auto p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - return false; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - // We are only interested in Kill activities - if (activity_info->activity_type != activity_type) { - continue; - } - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - LogTasks( - "[UPDATE] character [{}] task_id [{}] activity_id [{}] activity_type [{}] for NPC [{}] failed zone check", - client->GetName(), - current_task->task_id, - activity_id, - activity_type, - npc_type_id - ); - continue; - } - // Is the activity_information to kill this type of NPC ? - switch (activity_info->goal_method) { - case METHODSINGLEID: - if (activity_info->goal_id != npc_type_id) { - continue; - } - break; - - case METHODLIST: - if (!task_manager->m_goal_list_manager.IsInList( - activity_info->goal_id, - npc_type_id - )) { - continue; - } - break; - - default: - // If METHODQUEST, don't updated the activity_information here - continue; - } - // We found an active p_task_data to kill this type of NPC, so increment the done count - LogTasksDetail("Calling increment done count ByNPC"); - IncrementDoneCount(client, p_task_data, current_task->slot, activity_id); - is_updating = true; - } - } - - return is_updating; -} - -int ClientTaskState::ActiveSpeakTask(int npc_type_id) -{ - - // This method is to be used from Perl quests only and returns the task_id of the first - // active task found which has an active SpeakWith activity_information for this NPC. - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return 0; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - TaskInformation *p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - continue; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - if (activity_info->activity_type != ActivitySpeakWith) { - continue; - } - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - continue; - } - // Is the activity_information to speak with this type of NPC ? - if (activity_info->goal_method == METHODQUEST && activity_info->goal_id == npc_type_id) { - return current_task->task_id; - } - } - } - - return 0; -} - -int ClientTaskState::ActiveSpeakActivity(int npc_type_id, int task_id) -{ - - // This method is to be used from Perl quests only and returns the activity_id of the first - // active activity_information found in the specified task which is to SpeakWith this NPC. - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return -1; - } - if (task_id <= 0 || task_id >= MAXTASKS) { - return -1; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id != task_id) { - continue; - } - - TaskInformation *p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - continue; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - if (activity_info->activity_type != ActivitySpeakWith) { - continue; - } - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - continue; - } - - // Is the activity_information to speak with this type of NPC ? - if (activity_info->goal_method == METHODQUEST && activity_info->goal_id == npc_type_id) { - return activity_id; - } - } - return 0; - } - return 0; -} - -void ClientTaskState::UpdateTasksForItem(Client *client, ActivityType activity_type, int item_id, int count) -{ - - // This method updates the client's task activities of the specified type which relate - // to the specified item. - // - // Type should be one of ActivityLoot, ActivityTradeSkill, ActivityFish or ActivityForage - - // If the client has no tasks, there is nothing further to check. - - LogTasks( - "[UpdateTasksForItem] activity_type [{}] item_id [{}]", - activity_type, - item_id - ); - - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - // Check if there are any active loot activities for this task - - TaskInformation *p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - return; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - // We are only interested in the ActivityType we were called with - if (activity_info->activity_type != (int) activity_type) { - continue; - } - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - LogTasks( - "[UpdateTasksForItem] Error: Character [{}] activity_information type [{}] for Item [{}] failed zone check", - client->GetName(), - activity_type, - item_id - ); - continue; - } - // Is the activity_information related to this item ? - // - switch (activity_info->goal_method) { - - case METHODSINGLEID: - if (activity_info->goal_id != item_id) { continue; } - break; - - case METHODLIST: - if (!task_manager->m_goal_list_manager.IsInList( - activity_info->goal_id, - item_id - )) { continue; } - break; - - default: - // If METHODQUEST, don't updated the activity_information here - continue; - } - // We found an active task related to this item, so increment the done count - LogTasksDetail("[UpdateTasksForItem] Calling increment done count ForItem"); - IncrementDoneCount(client, p_task_data, current_task->slot, activity_id, count); - } - } -} - -void ClientTaskState::UpdateTasksOnExplore(Client *client, int explore_id) -{ - LogTasks("[UpdateTasksOnExplore] explore_id [{}]", explore_id); - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - // Check if there are any active explore activities for this task - - TaskInformation *task_data = task_manager->m_task_data[current_task->task_id]; - if (task_data == nullptr) { - return; - } - - for (int activity_id = 0; activity_id < task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - // We are only interested in explore activities - if (activity_info->activity_type != ActivityExplore) { - continue; - } - if (!activity_info->CheckZone(zone->GetZoneID())) { - LogTasks( - "[UpdateTasksOnExplore] character [{}] explore_id [{}] failed zone check", - client->GetName(), - explore_id - ); - continue; - } - // Is the activity_information to explore this area id ? - switch (activity_info->goal_method) { - - case METHODSINGLEID: - if (activity_info->goal_id != explore_id) { - continue; - } - break; - - case METHODLIST: - if (!task_manager->m_goal_list_manager.IsInList( - activity_info->goal_id, - explore_id - )) { - continue; - } - break; - - default: - // If METHODQUEST, don't updated the activity_information here - continue; - } - - // We found an active task to explore this area, so set done count to goal count - // (Only a goal count of 1 makes sense for explore activities?) - LogTasks( - "[UpdateTasksOnExplore] character [{}] explore_id [{}] increment on explore", - client->GetName(), - explore_id - ); - - IncrementDoneCount( - client, - task_data, - current_task->slot, - activity_id, - activity_info->goal_count - current_task->activity[activity_id].done_count - ); - } - } -} - -bool ClientTaskState::UpdateTasksOnDeliver( - Client *client, - std::list &items, - int cash, - int npc_type_id -) -{ - bool is_updated = false; - - LogTasks("[UpdateTasksOnDeliver] [{}]", npc_type_id); - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return false; - } - - // loop over the union of tasks and quests - for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { - auto current_task = &m_active_tasks[i]; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - // Check if there are any active deliver activities for this task - TaskInformation *p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - return false; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - - // We are only interested in Deliver activities - if (activity_info->activity_type != ActivityDeliver && - activity_info->activity_type != ActivityGiveCash) { - continue; - } - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - Log( - Logs::General, Logs::Tasks, - "[UPDATE] Char: %s Deliver activity_information failed zone check (current zone %i, need zone " - "%s", - client->GetName(), zone->GetZoneID(), activity_info->zones.c_str()); - continue; - } - // Is the activity_information to deliver to this NPCTypeID ? - if (activity_info->deliver_to_npc != npc_type_id) { - continue; - } - // Is the activity_information related to these items ? - // - if ((activity_info->activity_type == ActivityGiveCash) && cash) { - LogTasks("[UpdateTasksOnDeliver] Increment on GiveCash"); - IncrementDoneCount(client, p_task_data, i, activity_id, cash); - is_updated = true; - } - else { - for (auto &item : items) { - switch (activity_info->goal_method) { - case METHODSINGLEID: - if (activity_info->goal_id != item->GetID()) { - continue; - } - break; - - case METHODLIST: - if (!task_manager->m_goal_list_manager.IsInList( - activity_info->goal_id, - item->GetID())) { - continue; - } - break; - - default: - // If METHODQUEST, don't updated the activity_information here - continue; - } - // We found an active task related to this item, so increment the done count - LogTasks("[UpdateTasksOnDeliver] Increment on GiveItem"); - IncrementDoneCount( - client, - p_task_data, - current_task->slot, - activity_id, - item->GetCharges() <= 0 ? 1 : item->GetCharges() - ); - is_updated = true; - } - } - } - } - - return is_updated; -} - -void ClientTaskState::UpdateTasksOnTouch(Client *client, int zone_id) -{ - // If the client has no tasks, there is nothing further to check. - - LogTasks("[UpdateTasksOnTouch] [{}] ", zone_id); - if (!task_manager || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { // could be better ... - return; - } - - // loop over the union of tasks and quests - for (auto &active_task : m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { - continue; - } - - // Check if there are any active explore activities for this task - TaskInformation *p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - return; - } - - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (current_task->activity[activity_id].activity_state != ActivityActive) { - continue; - } - // We are only interested in touch activities - if (activity_info->activity_type != ActivityTouch) { - continue; - } - if (activity_info->goal_method != METHODSINGLEID) { - continue; - } - if (!activity_info->CheckZone(zone_id)) { - LogTasks( - "[UpdateTasksOnTouch] character [{}] Touch activity_information failed zone check", - client->GetName() - ); - continue; - } - - // We found an active task to zone into this zone, so set done count to goal count - // (Only a goal count of 1 makes sense for touch activities?) - LogTasks("[UpdateTasksOnTouch] Increment on Touch"); - IncrementDoneCount( - client, - p_task_data, - current_task->slot, - activity_id, - activity_info->goal_count - current_task->activity[activity_id].done_count - ); - } - } -} - -void ClientTaskState::IncrementDoneCount( - Client *client, - TaskInformation *task_information, - int task_index, - int activity_id, - int count, - bool ignore_quest_update -) -{ - Log(Logs::General, Logs::Tasks, "[UPDATE] IncrementDoneCount"); - - auto info = GetClientTaskInfo(task_information->type, task_index); - if (info == nullptr) { - return; - } - - info->activity[activity_id].done_count += count; - - if (info->activity[activity_id].done_count > task_information->activity_information[activity_id].goal_count) { - info->activity[activity_id].done_count = task_information->activity_information[activity_id].goal_count; - } - - if (!ignore_quest_update) { - char buf[24]; - snprintf( - buf, - 23, - "%d %d %d", - info->activity[activity_id].done_count, - info->activity[activity_id].activity_id, - info->task_id - ); - buf[23] = '\0'; - parse->EventPlayer(EVENT_TASK_UPDATE, client, buf, 0); - } - - info->activity[activity_id].updated = true; - // Have we reached the goal count for this activity_information ? - if (info->activity[activity_id].done_count >= task_information->activity_information[activity_id].goal_count) { - Log( - Logs::General, Logs::Tasks, "[UPDATE] Done (%i) = Goal (%i) for activity_information %i", - info->activity[activity_id].done_count, - task_information->activity_information[activity_id].goal_count, - activity_id - ); - - // Flag the activity_information as complete - info->activity[activity_id].activity_state = ActivityCompleted; - // Unlock subsequent activities for this task - bool task_complete = UnlockActivities(client->CharacterID(), *info); - Log(Logs::General, Logs::Tasks, "[UPDATE] TaskCompleted is %i", task_complete); - // and by the 'Task Stage Completed' message - client->SendTaskActivityComplete(info->task_id, activity_id, task_index, task_information->type); - // Send the updated task/activity_information list to the client - task_manager->SendSingleActiveTaskToClient(client, *info, task_complete, false); - // Inform the client the task has been updated, both by a chat message - client->Message(Chat::White, "Your task '%s' has been updated.", task_information->title.c_str()); - - if (task_information->activity_information[activity_id].goal_method != METHODQUEST) { - if (!ignore_quest_update) { - char buf[24]; - snprintf(buf, 23, "%d %d", info->task_id, info->activity[activity_id].activity_id); - buf[23] = '\0'; - parse->EventPlayer(EVENT_TASK_STAGE_COMPLETE, client, buf, 0); - } - /* QS: PlayerLogTaskUpdates :: Update */ - if (RuleB(QueryServ, PlayerLogTaskUpdates)) { - std::string event_desc = StringFormat( - "Task Stage Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", - info->task_id, - info->activity[activity_id].activity_id, - info->activity[activity_id].done_count, - client->GetZoneID(), - client->GetInstanceID()); - QServ->PlayerLogEvent(Player_Log_Task_Updates, client->CharacterID(), event_desc); - } - } - - // If this task is now complete, the Completed tasks will have been - // updated in UnlockActivities. Send the completed task list to the - // client. This is the same sequence the packets are sent on live. - if (task_complete) { - char buf[24]; - snprintf( - buf, - 23, - "%d %d %d", - info->activity[activity_id].done_count, - info->activity[activity_id].activity_id, - info->task_id - ); - buf[23] = '\0'; - parse->EventPlayer(EVENT_TASK_COMPLETE, client, buf, 0); - - /* QS: PlayerLogTaskUpdates :: Complete */ - if (RuleB(QueryServ, PlayerLogTaskUpdates)) { - std::string event_desc = StringFormat( - "Task Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", - info->task_id, - info->activity[activity_id].activity_id, - info->activity[activity_id].done_count, - client->GetZoneID(), - client->GetInstanceID()); - QServ->PlayerLogEvent(Player_Log_Task_Updates, client->CharacterID(), event_desc); - } - - task_manager->SendCompletedTasksToClient(client, this); - client->SendTaskActivityComplete(info->task_id, 0, task_index, task_information->type, 0); - task_manager->SaveClientState(client, this); - //c->SendTaskComplete(TaskIndex); - client->CancelTask(task_index, task_information->type); - //if(Task->reward_method != METHODQUEST) RewardTask(c, Task); - // If Experience and/or cash rewards are set, reward them from the task even if reward_method is METHODQUEST - RewardTask(client, task_information); - //RemoveTask(c, TaskIndex); - - } - - } - else { - // Send an updated packet for this single activity_information - task_manager->SendTaskActivityLong( - client, - info->task_id, - activity_id, - task_index, - task_information->activity_information[activity_id].optional - ); - task_manager->SaveClientState(client, this); - } -} - -void ClientTaskState::RewardTask(Client *client, TaskInformation *task_information) -{ - - if (!task_information || !client) { - return; - } - - const EQ::ItemData *item_data; - std::vector reward_list; - - switch (task_information->reward_method) { - case METHODSINGLEID: { - if (task_information->reward_id) { - client->SummonItem(task_information->reward_id); - item_data = database.GetItem(task_information->reward_id); - if (item_data) { - client->Message(Chat::Yellow, "You receive %s as a reward.", item_data->Name); - } - } - break; - } - case METHODLIST: { - reward_list = task_manager->m_goal_list_manager.GetListContents(task_information->reward_id); - for (int item_id : reward_list) { - client->SummonItem(item_id); - item_data = database.GetItem(item_id); - if (item_data) { - client->Message(Chat::Yellow, "You receive %s as a reward.", item_data->Name); - } - } - break; - } - default: { - // Nothing special done for METHODQUEST - break; - } - } - - if (!task_information->completion_emote.empty()) { - client->SendColoredText( - Chat::Yellow, - task_information->completion_emote - ); - } // unsure if they use this packet or color, should work - - // just use normal NPC faction ID stuff - if (task_information->faction_reward) { - client->SetFactionLevel( - client->CharacterID(), - task_information->faction_reward, - client->GetBaseClass(), - client->GetBaseRace(), - client->GetDeity() - ); - } - - if (task_information->cash_reward) { - int platinum, gold, silver, copper; - - copper = task_information->cash_reward; - client->AddMoneyToPP(copper, true); - - platinum = copper / 1000; - copper = copper - (platinum * 1000); - gold = copper / 100; - copper = copper - (gold * 100); - silver = copper / 10; - copper = copper - (silver * 10); - - std::string cash_message; - - if (platinum > 0) { - cash_message = "You receive "; - cash_message += itoa(platinum); - cash_message += " platinum"; - } - if (gold > 0) { - if (cash_message.length() == 0) { - cash_message = "You receive "; - } - else { - cash_message += ","; - } - cash_message += itoa(gold); - cash_message += " gold"; - } - if (silver > 0) { - if (cash_message.length() == 0) { - cash_message = "You receive "; - } - else { - cash_message += ","; - } - cash_message += itoa(silver); - cash_message += " silver"; - } - if (copper > 0) { - if (cash_message.length() == 0) { - cash_message = "You receive "; - } - else { - cash_message += ","; - } - cash_message += itoa(copper); - cash_message += " copper"; - } - cash_message += " pieces."; - client->Message(Chat::Yellow, cash_message.c_str()); - } - int32 experience_reward = task_information->experience_reward; - if (experience_reward > 0) { - client->AddEXP(experience_reward); - } - if (experience_reward < 0) { - uint32 pos_reward = experience_reward * -1; - // Minimal Level Based Exp reward Setting is 101 (1% exp at level 1) - if (pos_reward > 100 && pos_reward < 25700) { - uint8 max_level = pos_reward / 100; - uint8 exp_percent = pos_reward - (max_level * 100); - client->AddLevelBasedExp(exp_percent, max_level); - } - } - - client->SendSound(); -} - -bool ClientTaskState::IsTaskActive(int task_id) -{ - if (m_active_task.task_id == task_id) { - return true; - } - - if (m_active_task_count == 0 || task_id == 0) { - return false; - } - - for (auto &active_quest : m_active_quests) { - if (active_quest.task_id == task_id) { - return true; - } - } - - return false; -} - -void ClientTaskState::FailTask(Client *client, int task_id) -{ - LogTasks( - "[FailTask] Failing task for character [{}] task_id [{}] task_count [{}]", - client->GetCleanName(), - task_id, - m_active_task_count - ); - - if (m_active_task.task_id == task_id) { - client->SendTaskFailed(task_id, 0, TaskType::Task); - // Remove the task from the client - client->CancelTask(0, TaskType::Task); - return; - } - - // TODO: shared tasks - - if (m_active_task_count == 0) { - return; - } - - for (int i = 0; i < MAXACTIVEQUESTS; i++) { - if (m_active_quests[i].task_id == task_id) { - client->SendTaskFailed(m_active_quests[i].task_id, i, TaskType::Quest); - // Remove the task from the client - client->CancelTask(i, TaskType::Quest); - return; - } - } -} - -// TODO: Shared tasks -bool ClientTaskState::IsTaskActivityActive(int task_id, int activity_id) -{ - LogTasks("[IsTaskActivityActive] task_id [{}] activity_id [{}]", task_id, activity_id); - - // Quick sanity check - if (activity_id < 0) { - return false; - } - if (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY) { - return false; - } - - int active_task_index = -1; - auto task_type = TaskType::Task; - - if (m_active_task.task_id == task_id) { - active_task_index = 0; - } - - if (active_task_index == -1) { - for (int i = 0; i < MAXACTIVEQUESTS; i++) { - if (m_active_quests[i].task_id == task_id) { - active_task_index = i; - task_type = TaskType::Quest; - break; - } - } - } - - // The client does not have this task - if (active_task_index == -1) { - return false; - } - - auto info = GetClientTaskInfo(task_type, active_task_index); - - if (info == nullptr) { - return false; - } - - TaskInformation *p_task_data = task_manager->m_task_data[info->task_id]; - - // The task is invalid - if (p_task_data == nullptr) { - return false; - } - - // The activity_id is out of range - if (activity_id >= p_task_data->activity_count) { - return false; - } - - LogTasks( - "[IsTaskActivityActive] (Update) task_id [{}] activity_id [{}] activity_state [{}]", - task_id, - activity_id, - info->activity[activity_id].activity_state - ); - - return (info->activity[activity_id].activity_state == ActivityActive); -} - -void ClientTaskState::UpdateTaskActivity( - Client *client, - int task_id, - int activity_id, - int count, - bool ignore_quest_update /*= false*/) -{ - LogTasks( - "[UpdateTaskActivity] Increment done count (pre) on UpdateTaskActivity task_id [{}] activity_id [{}] count [{}]", - task_id, - activity_id, - count - ); - - // Quick sanity check - if (activity_id < 0 || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { - return; - } - - int active_task_index = -1; - auto type = TaskType::Task; - - if (m_active_task.task_id == task_id) { - active_task_index = 0; - } - - if (active_task_index == -1) { - for (int i = 0; i < MAXACTIVEQUESTS; i++) { - if (m_active_quests[i].task_id == task_id) { - active_task_index = i; - type = TaskType::Quest; - break; - } - } - } - - // The client does not have this task - if (active_task_index == -1) { - return; - } - - auto info = GetClientTaskInfo(type, active_task_index); - if (info == nullptr) { - return; - } - - TaskInformation *p_task_data = task_manager->m_task_data[info->task_id]; - - // The task is invalid - if (p_task_data == nullptr) { - return; - } - - // The activity_id is out of range - if (activity_id >= p_task_data->activity_count) { - return; - } - - // The activity_information is not currently active - if (info->activity[activity_id].activity_state == ActivityHidden) { - return; - } - - LogTasks( - "[UpdateTaskActivity] Increment done count (done) on UpdateTaskActivity task_id [{}] activity_id [{}] count [{}]", - task_id, - activity_id, - count - ); - - IncrementDoneCount(client, p_task_data, active_task_index, activity_id, count, ignore_quest_update); -} - -void ClientTaskState::ResetTaskActivity(Client *client, int task_id, int activity_id) -{ - LogTasks( - "[ResetTaskActivity] (pre) client [{}] task_id [{}] activity_id [{}]", - client->GetCleanName(), - task_id, - activity_id - ); - - // Quick sanity check - if (activity_id < 0 || (m_active_task_count == 0 && m_active_task.task_id == TASKSLOTEMPTY)) { - return; - } - - int active_task_index = -1; - auto type = TaskType::Task; - if (m_active_task.task_id == task_id) { - active_task_index = 0; - } - - if (active_task_index == -1) { - for (int i = 0; i < MAXACTIVEQUESTS; i++) { - if (m_active_quests[i].task_id == task_id) { - active_task_index = i; - type = TaskType::Quest; - break; - } - } - } - - // The client does not have this task - if (active_task_index == -1) { - return; - } - - auto info = GetClientTaskInfo(type, active_task_index); - if (info == nullptr) { - return; - } - - TaskInformation *p_task_data = task_manager->m_task_data[info->task_id]; - if (p_task_data == nullptr) { - return; - } - - // The activity_id is out of range - if (activity_id >= p_task_data->activity_count) { - return; - } - - // The activity_information is not currently active - if (info->activity[activity_id].activity_state == ActivityHidden) { - return; - } - - LogTasks( - "[ResetTaskActivity] (IncrementDoneCount) client [{}] task_id [{}] activity_id [{}]", - client->GetCleanName(), - task_id, - activity_id - ); - - IncrementDoneCount( - client, - p_task_data, - active_task_index, - activity_id, - (info->activity[activity_id].done_count * -1), - false - ); -} - -void ClientTaskState::ShowClientTasks(Client *client) -{ - client->Message(Chat::White, "------------------------------------------------"); - client->Message(Chat::White, "# Task Information | Client [%s]", client->GetCleanName()); -// client->Message(Chat::White, "------------------------------------------------"); - if (m_active_task.task_id != TASKSLOTEMPTY) { - client->Message( - Chat::White, - "Task: %i %s", - m_active_task.task_id, - task_manager->m_task_data[m_active_task.task_id]->title.c_str() - ); - client->Message( - Chat::White, - " description: [%s]\n", - task_manager->m_task_data[m_active_task.task_id]->description.c_str() - ); - for (int activity_id = 0; activity_id < task_manager->GetActivityCount(m_active_task.task_id); activity_id++) { - client->Message( - Chat::White, - " activity_information: %2d, done_count: %2d, Status: %d (0=Hidden, 1=Active, 2=Complete)", - m_active_task.activity[activity_id].activity_id, - m_active_task.activity[activity_id].done_count, - m_active_task.activity[activity_id].activity_state - ); - } - } - - for (auto &active_quest : m_active_quests) { - if (active_quest.task_id == TASKSLOTEMPTY) { - continue; - } - - client->Message(Chat::White, "------------------------------------------------"); - client->Message( - Chat::White, "# Quest | task_id [%i] title [%s]", - active_quest.task_id, - task_manager->m_task_data[active_quest.task_id]->title.c_str() - ); - client->Message(Chat::White, "------------------------------------------------"); - - client->Message( - Chat::White, - " -- Description [%s]\n", - task_manager->m_task_data[active_quest.task_id]->description.c_str() - ); - - for (int activity_id = 0; activity_id < task_manager->GetActivityCount(active_quest.task_id); activity_id++) { - std::vector update_increments = {"1", "5", "50"}; - std::string update_saylinks; - - for (auto &increment: update_increments) { - auto task_update_saylink = EQ::SayLinkEngine::GenerateQuestSaylink( - fmt::format( - "#task update {} {} {}", - active_quest.task_id, - active_quest.activity[activity_id].activity_id, - increment - ), - false, - increment - ); - - update_saylinks += "[" + task_update_saylink + "] "; - } - - client->Message( - Chat::White, - " --- activity_id [%i] done_count [%i] state [%d] (0=hidden 1=active 2=complete) | Update %s", - active_quest.activity[activity_id].activity_id, - active_quest.activity[activity_id].done_count, - active_quest.activity[activity_id].activity_state, - update_saylinks.c_str() - ); - } - } - - client->Message(Chat::White, "------------------------------------------------"); -} - -// TODO: Shared Task -int ClientTaskState::TaskTimeLeft(int task_id) -{ - if (m_active_task.task_id == task_id) { - int time_now = time(nullptr); - - TaskInformation *p_task_data = task_manager->m_task_data[task_id]; - if (p_task_data == nullptr) { - return -1; - } - - if (!p_task_data->duration) { - return -1; - } - - int time_left = (m_active_task.accepted_time + p_task_data->duration - time_now); - - return (time_left > 0 ? time_left : 0); - } - - if (m_active_task_count == 0) { - return -1; - } - - for (auto &active_quest : m_active_quests) { - if (active_quest.task_id != task_id) { - continue; - } - - int time_now = time(nullptr); - - TaskInformation *p_task_data = task_manager->m_task_data[active_quest.task_id]; - if (p_task_data == nullptr) { - return -1; - } - - if (!p_task_data->duration) { - return -1; - } - - int time_left = (active_quest.accepted_time + p_task_data->duration - time_now); - - // If Timeleft is negative, return 0, else return the number of seconds left - - return (time_left > 0 ? time_left : 0); - } - - return -1; -} - -int ClientTaskState::IsTaskCompleted(int task_id) -{ - - // Returns: -1 if RecordCompletedTasks is not true - // +1 if the task has been completed - // 0 if the task has not been completed - - if (!(RuleB(TaskSystem, RecordCompletedTasks))) { - return -1; - } - - for (auto &completed_task : m_completed_tasks) { - LogTasks("[IsTaskCompleted] Comparing compelted task [{}] with [{}]", completed_task.task_id, task_id); - if (completed_task.task_id == task_id) { - return 1; - } - } - - return 0; -} - -bool ClientTaskState::TaskOutOfTime(TaskType task_type, int index) -{ - // Returns true if the Task in the specified slot has a time limit that has been exceeded. - auto info = GetClientTaskInfo(task_type, index); - if (info == nullptr) { - return false; - } - - // make sure the task_id is at least maybe in our array - if (info->task_id <= 0 || info->task_id >= MAXTASKS) { - return false; - } - - int time_now = time(nullptr); - TaskInformation *task_data = task_manager->m_task_data[info->task_id]; - if (task_data == nullptr) { - return false; - } - - return (task_data->duration && (info->accepted_time + task_data->duration <= time_now)); -} - -void ClientTaskState::TaskPeriodicChecks(Client *client) -{ - if (m_active_task.task_id != TASKSLOTEMPTY) { - if (TaskOutOfTime(TaskType::Task, 0)) { - // Send Red Task Failed Message - client->SendTaskFailed(m_active_task.task_id, 0, TaskType::Task); - // Remove the task from the client - client->CancelTask(0, TaskType::Task); - // It is a conscious decision to only fail one task per call to this method, - // otherwise the player will not see all the failed messages where multiple - // tasks fail at the same time. - return; - } - } - - // TODO: shared tasks -- although that will probably be manager in world checking and telling zones to fail us - - if (m_active_task_count == 0) { - return; - } - - // Check for tasks that have failed because they have not been completed in the specified time - // - for (int task_index = 0; task_index < MAXACTIVEQUESTS; task_index++) { - if (m_active_quests[task_index].task_id == TASKSLOTEMPTY) { - continue; - } - - if (TaskOutOfTime(TaskType::Quest, task_index)) { - // Send Red Task Failed Message - client->SendTaskFailed(m_active_quests[task_index].task_id, task_index, TaskType::Quest); - // Remove the task from the client - client->CancelTask(task_index, TaskType::Quest); - // It is a conscious decision to only fail one task per call to this method, - // otherwise the player will not see all the failed messages where multiple - // tasks fail at the same time. - break; - } - } - - // Check for activities that require zoning into a specific zone. - // This is done in this method because it gives an extra few seconds for the client screen to display - // the zone before we send the 'Task activity_information Completed' message. - // - if (!m_checked_touch_activities) { - UpdateTasksOnTouch(client, zone->GetZoneID()); - m_checked_touch_activities = true; - } -} - -bool ClientTaskState::IsTaskActivityCompleted(TaskType task_type, int index, int activity_id) -{ - switch (task_type) { - case TaskType::Task: - if (index != 0) { - return false; - } - return m_active_task.activity[activity_id].activity_state == ActivityCompleted; - case TaskType::Shared: - return false; // TODO: shared tasks - case TaskType::Quest: - if (index < MAXACTIVEQUESTS) { - return m_active_quests[index].activity[activity_id].activity_state == ActivityCompleted; - } - default: - return false; - } - -} - -// should we be defaulting to hidden? -ActivityState ClientTaskState::GetTaskActivityState(TaskType task_type, int index, int activity_id) -{ - switch (task_type) { - case TaskType::Task: - if (index != 0) { - return ActivityHidden; - } - return m_active_task.activity[activity_id].activity_state; - case TaskType::Shared: - return ActivityHidden; // TODO: shared tasks - case TaskType::Quest: - if (index < MAXACTIVEQUESTS) { - return m_active_quests[index].activity[activity_id].activity_state; - } - default: - return ActivityHidden; - } -} - -int ClientTaskState::GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id) -{ - switch (task_type) { - case TaskType::Task: - if (index != 0) { - return 0; - } - return m_active_task.activity[activity_id].done_count; - case TaskType::Shared: - return 0; // TODO: shared tasks - case TaskType::Quest: - if (index < MAXACTIVEQUESTS) { - return m_active_quests[index].activity[activity_id].done_count; - } - default: - return 0; - } -} - -int ClientTaskState::GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id) -{ - if (m_active_task.task_id == task_id) { - return m_active_task.activity[activity_id].done_count; - } - - // TODO: shared tasks - - int active_task_index = -1; - - for (int task_index = 0; task_index < MAXACTIVEQUESTS; task_index++) { - if (m_active_quests[task_index].task_id == task_id) { - active_task_index = task_index; - break; - } - } - - if (active_task_index == -1) { - return 0; - } - - if (m_active_quests[active_task_index].activity[activity_id].done_count) { - return m_active_quests[active_task_index].activity[activity_id].done_count; - } - else { - return 0; - } -} - -int ClientTaskState::GetTaskStartTime(TaskType task_type, int index) -{ - switch (task_type) { - case TaskType::Task: - return m_active_task.accepted_time; - case TaskType::Quest: - return m_active_quests[index].accepted_time; - case TaskType::Shared: // TODO - default: - return -1; - } -} - -void ClientTaskState::CancelAllTasks(Client *client) -{ - - // This method exists solely to be called during #task reloadall - // It removes tasks from the in-game client state ready for them to be - // resent to the client, in case an updated task fails to load - - CancelTask(client, 0, TaskType::Task, false); - m_active_task.task_id = TASKSLOTEMPTY; - - for (int task_index = 0; task_index < MAXACTIVEQUESTS; task_index++) - if (m_active_quests[task_index].task_id != TASKSLOTEMPTY) { - CancelTask(client, task_index, TaskType::Quest, false); - m_active_quests[task_index].task_id = TASKSLOTEMPTY; - } - - // TODO: shared -} - -void ClientTaskState::CancelTask(Client *client, int sequence_number, TaskType task_type, bool remove_from_db) -{ - auto outapp = new EQApplicationPacket(OP_CancelTask, sizeof(CancelTask_Struct)); - - CancelTask_Struct *cts = (CancelTask_Struct *) outapp->pBuffer; - cts->SequenceNumber = sequence_number; - cts->type = static_cast(task_type); - - Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask"); - - client->QueuePacket(outapp); - safe_delete(outapp); - - if (remove_from_db) { - RemoveTask(client, sequence_number, task_type); - } -} - -void ClientTaskState::RemoveTask(Client *client, int sequence_number, TaskType task_type) -{ - int character_id = client->CharacterID(); - Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState Cancel Task %i ", sequence_number); - - int task_id = -1; - switch (task_type) { - case TaskType::Task: - if (sequence_number == 0) { - task_id = m_active_task.task_id; - } - break; - case TaskType::Quest: - if (sequence_number < MAXACTIVEQUESTS) { - task_id = m_active_quests[sequence_number].task_id; - } - break; - case TaskType::Shared: // TODO: - default: - break; - } - - CharacterActivitiesRepository::DeleteWhere( - database, - fmt::format("charid = {} AND taskid = {}", character_id, task_id) - ); - - CharacterTasksRepository::DeleteWhere( - database, - fmt::format("charid = {} AND taskid = {} AND type = {}", character_id, task_id, static_cast(task_type)) - ); - - switch (task_type) { - case TaskType::Task: - m_active_task.task_id = TASKSLOTEMPTY; - break; - case TaskType::Shared: - break; // TODO: shared tasks - case TaskType::Quest: - m_active_quests[sequence_number].task_id = TASKSLOTEMPTY; - m_active_task_count--; - break; - default: - break; - } -} - -void ClientTaskState::RemoveTaskByTaskID(Client *client, uint32 task_id) -{ - auto task_type = task_manager->GetTaskType(task_id); - int character_id = client->CharacterID(); - - CharacterActivitiesRepository::DeleteWhere( - database, - fmt::format("charid = {} AND taskid = {}", character_id, task_id) - ); - - CharacterTasksRepository::DeleteWhere( - database, - fmt::format("charid = {} AND taskid = {} AND type = {}", character_id, task_id, (int) task_type) - ); - - switch (task_type) { - case TaskType::Task: { - if (m_active_task.task_id == task_id) { - auto outapp = new EQApplicationPacket(OP_CancelTask, sizeof(CancelTask_Struct)); - CancelTask_Struct *cts = (CancelTask_Struct *) outapp->pBuffer; - cts->SequenceNumber = 0; - cts->type = static_cast(task_type); - LogTasks("[UPDATE] RemoveTaskByTaskID found Task [{}]", task_id); - client->QueuePacket(outapp); - safe_delete(outapp); - m_active_task.task_id = TASKSLOTEMPTY; - } - break; - } - case TaskType::Shared: { - break; // TODO: shared tasks - } - case TaskType::Quest: { - for (int active_quest = 0; active_quest < MAXACTIVEQUESTS; active_quest++) { - if (m_active_quests[active_quest].task_id == task_id) { - auto outapp = new EQApplicationPacket(OP_CancelTask, sizeof(CancelTask_Struct)); - CancelTask_Struct *cts = (CancelTask_Struct *) outapp->pBuffer; - cts->SequenceNumber = active_quest; - cts->type = static_cast(task_type); - LogTasks("[UPDATE] RemoveTaskByTaskID found Quest [{}] at index [{}]", task_id, active_quest); - m_active_quests[active_quest].task_id = TASKSLOTEMPTY; - m_active_task_count--; - client->QueuePacket(outapp); - safe_delete(outapp); - } - } - } - default: { - break; - } - } -} - -void ClientTaskState::AcceptNewTask(Client *client, int task_id, int npc_type_id, bool enforce_level_requirement) -{ - if (!task_manager || task_id < 0 || task_id >= MAXTASKS) { - client->Message(Chat::Red, "Task system not functioning, or task_id %i out of range.", task_id); - return; - } - - auto task = task_manager->m_task_data[task_id]; - - if (task == nullptr) { - client->Message(Chat::Red, "Invalid task_id %i", task_id); - return; - } - - bool max_tasks = false; - - switch (task->type) { - case TaskType::Task: - if (m_active_task.task_id != TASKSLOTEMPTY) { - max_tasks = true; - } - break; - case TaskType::Shared: // TODO: shared tasks - // if (something) - max_tasks = true; - break; - case TaskType::Quest: - if (m_active_task_count == MAXACTIVEQUESTS) { - max_tasks = true; - } - break; - default: - break; - } - - if (max_tasks) { - client->Message( - Chat::Red, - "You already have the maximum allowable number of active tasks (%i)", - MAXACTIVEQUESTS - ); - return; - } - - // only Quests can have more than one, so don't need to check others - if (task->type == TaskType::Quest) { - for (auto &active_quest : m_active_quests) { - if (active_quest.task_id == task_id) { - client->Message(Chat::Red, "You have already been assigned this task."); - return; - } - } - } - - if (enforce_level_requirement && !task_manager->ValidateLevel(task_id, client->GetLevel())) { - client->Message(Chat::Red, "You are outside the level range of this task."); - return; - } - - if (!task_manager->IsTaskRepeatable(task_id) && IsTaskCompleted(task_id)) { - return; - } - - // We do it this way, because when the Client cancels a task, it retains the sequence number of the remaining - // tasks in it's window, until something causes the TaskDescription packets to be sent again. We could just - // resend all the active task data to the client when it cancels a task, but that could be construed as a - // waste of bandwidth. - // - ClientTaskInformation *active_slot = nullptr; - switch (task->type) { - case TaskType::Task: - active_slot = &m_active_task; - break; - case TaskType::Shared: // TODO: shared - active_slot = nullptr; - break; - case TaskType::Quest: - for (int task_index = 0; task_index < MAXACTIVEQUESTS; task_index++) { - Log(Logs::General, Logs::Tasks, - "[UPDATE] ClientTaskState Looking for free slot in slot %i, found task_id of %i", task_index, - m_active_quests[task_index].task_id); - if (m_active_quests[task_index].task_id == 0) { - active_slot = &m_active_quests[task_index]; - break; - } - } - break; - default: - break; - } - - // This shouldn't happen unless there is a bug in the handling of ActiveTaskCount somewhere - if (active_slot == nullptr) { - client->Message( - Chat::Red, - "You already have the maximum allowable number of active tasks (%i)", - MAXACTIVEQUESTS - ); - return; - } - - active_slot->task_id = task_id; - active_slot->accepted_time = time(nullptr); - active_slot->updated = true; - active_slot->current_step = -1; - - for (int activity_id = 0; activity_id < task_manager->m_task_data[task_id]->activity_count; activity_id++) { - active_slot->activity[activity_id].activity_id = activity_id; - active_slot->activity[activity_id].done_count = 0; - active_slot->activity[activity_id].activity_state = ActivityHidden; - active_slot->activity[activity_id].updated = true; - } - - UnlockActivities(client->CharacterID(), *active_slot); - - if (task->type == TaskType::Quest) { - m_active_task_count++; - } - - task_manager->SendSingleActiveTaskToClient(client, *active_slot, false, true); - client->Message( - Chat::White, - "You have been assigned the task '%s'.", - task_manager->m_task_data[task_id]->title.c_str() - ); - task_manager->SaveClientState(client, this); - std::string buf = std::to_string(task_id); - - NPC *npc = entity_list.GetID(npc_type_id)->CastToNPC(); - if (npc) { - parse->EventNPC(EVENT_TASK_ACCEPTED, npc, client, buf.c_str(), 0); - } -} - -void ClientTaskState::ProcessTaskProximities(Client *client, float x, float y, float z) -{ - float last_x = client->ProximityX(); - float last_y = client->ProximityY(); - float last_z = client->ProximityZ(); - - if ((last_x == x) && (last_y == y) && (last_z == z)) { - return; - } - - LogTasksDetail("[ProcessTaskProximities] Checking proximities for Position x[{}] y[{}] z[{}]", x, y, z); - int explore_id = task_manager->m_proximity_manager.CheckProximities(x, y, z); - if (explore_id > 0) { - LogTasksDetail( - "[ProcessTaskProximities] Position x[{}] y[{}] z[{}] is within proximity explore_id [{}]", - x, - y, - z, - explore_id - ); - - UpdateTasksOnExplore(client, explore_id); - } -} diff --git a/zone/task_client_state.h b/zone/task_client_state.h deleted file mode 100644 index 6812e99c6..000000000 --- a/zone/task_client_state.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef EQEMU_TASK_CLIENT_STATE_H -#define EQEMU_TASK_CLIENT_STATE_H - -#include "tasks.h" -#include "../common/types.h" -#include -#include -#include -#include - -class ClientTaskState { - -public: - ClientTaskState(); - ~ClientTaskState(); - void ShowClientTasks(Client *client); - inline int GetActiveTaskCount() { return m_active_task_count; } - int GetActiveTaskID(int index); - bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id); - int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id); - int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id); - int GetTaskStartTime(TaskType task_type, int index); - void AcceptNewTask(Client *client, int task_id, int npc_type_id, bool enforce_level_requirement = false); - void FailTask(Client *client, int task_id); - int TaskTimeLeft(int task_id); - int IsTaskCompleted(int task_id); - bool IsTaskActive(int task_id); - bool IsTaskActivityActive(int task_id, int activity_id); - ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id); - void UpdateTaskActivity(Client *client, int task_id, int activity_id, int count, bool ignore_quest_update = false); - void ResetTaskActivity(Client *client, int task_id, int activity_id); - void CancelTask(Client *client, int sequence_number, TaskType task_type, bool remove_from_db = true); - void CancelAllTasks(Client *client); - void RemoveTask(Client *client, int sequence_number, TaskType task_type); - void RemoveTaskByTaskID(Client *client, uint32 task_id); - bool UpdateTasksByNPC(Client *client, int activity_type, int npc_type_id); - void UpdateTasksOnKill(Client *client, int npc_type_id); - void UpdateTasksForItem(Client *client, ActivityType activity_type, int item_id, int count = 1); - void UpdateTasksOnExplore(Client *client, int explore_id); - bool UpdateTasksOnSpeakWith(Client *client, int npc_type_id); - bool UpdateTasksOnDeliver(Client *client, std::list &items, int cash, int npc_type_id); - void UpdateTasksOnTouch(Client *client, int zone_id); - void ProcessTaskProximities(Client *client, float x, float y, float z); - bool TaskOutOfTime(TaskType task_type, int index); - void TaskPeriodicChecks(Client *client); - void SendTaskHistory(Client *client, int task_index); - void RewardTask(Client *client, TaskInformation *task_information); - void EnableTask(int character_id, int task_count, int *task_list); - void DisableTask(int character_id, int task_count, int *task_list); - bool IsTaskEnabled(int task_id); - int EnabledTaskCount(int task_set_id); - int ActiveSpeakTask(int npc_type_id); - int ActiveSpeakActivity(int npc_type_id, int task_id); - int ActiveTasksInSet(int task_set_id); - int CompletedTasksInSet(int task_set_id); - bool HasSlotForTask(TaskInformation *task); - - inline bool HasFreeTaskSlot() { return m_active_task.task_id == TASKSLOTEMPTY; } - - friend class TaskManager; - -private: - bool UnlockActivities(int character_id, ClientTaskInformation &task_info); - void IncrementDoneCount( - Client *client, - TaskInformation *task_information, - int task_index, - int activity_id, - int count = 1, - bool ignore_quest_update = false - ); - - inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index) - { - ClientTaskInformation *info = nullptr; - switch (task_type) { - case TaskType::Task: - if (index == 0) { - info = &m_active_task; - } - break; - case TaskType::Shared: - break; - case TaskType::Quest: - if (index < MAXACTIVEQUESTS) { - info = &m_active_quests[index]; - } - break; - default: - break; - } - return info; - } - - union { // easier to loop over - struct { - ClientTaskInformation m_active_task; // only one - ClientTaskInformation m_active_quests[MAXACTIVEQUESTS]; - }; - ClientTaskInformation m_active_tasks[MAXACTIVEQUESTS + 1]; - }; - // Shared tasks should be limited to 1 as well - int m_active_task_count; - std::vector m_enabled_tasks; - std::vector m_completed_tasks; - int m_last_completed_task_loaded; - bool m_checked_touch_activities; -}; - - -#endif //EQEMU_TASK_CLIENT_STATE_H diff --git a/zone/task_goal_list_manager.cpp b/zone/task_goal_list_manager.cpp deleted file mode 100644 index 9a641c6eb..000000000 --- a/zone/task_goal_list_manager.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "../common/global_define.h" -#include "../common/misc_functions.h" -#include "../common/repositories/goallists_repository.h" -#include "../common/rulesys.h" -#include "client.h" -#include "mob.h" -#include "quest_parser_collection.h" -#include "task_goal_list_manager.h" -#include "tasks.h" -#include "zonedb.h" - -TaskGoalListManager::TaskGoalListManager() -{ - m_goal_lists_count = 0; -} - -TaskGoalListManager::~TaskGoalListManager() {} - -bool TaskGoalListManager::LoadLists() -{ - m_task_goal_lists.clear(); - m_goal_lists_count = 0; - - std::string query = "SELECT `listid`, COUNT(`entry`) FROM `goallists` GROUP by `listid` ORDER BY `listid`"; - auto results = content_db.QueryDatabase(query); - if (!results.Success()) { - return false; - } - - m_goal_lists_count = results.RowCount(); - LogTasks("Loaded [{}] GoalLists", m_goal_lists_count); - - m_task_goal_lists.reserve(m_goal_lists_count); - - int list_index = 0; - for (auto row = results.begin(); row != results.end(); ++row) { - int list_id = atoi(row[0]); - int list_size = atoi(row[1]); - - m_task_goal_lists.push_back({list_id, 0, 0}); - - m_task_goal_lists[list_index].GoalItemEntries.reserve(list_size); - - list_index++; - } - - auto goal_lists = GoallistsRepository::GetWhere(content_db, "TRUE ORDER BY listid, entry ASC"); - for (list_index = 0; list_index < m_goal_lists_count; list_index++) { - - int list_id = m_task_goal_lists[list_index].ListID; - - for (auto &entry: goal_lists) { - if (entry.listid == list_id) { - if (entry.entry < m_task_goal_lists[list_index].Min) { - m_task_goal_lists[list_index].Min = entry.entry; - } - - if (entry.entry > m_task_goal_lists[list_index].Max) { - m_task_goal_lists[list_index].Max = entry.entry; - } - - m_task_goal_lists[list_index].GoalItemEntries.push_back(entry.entry); - - LogTasksDetail( - "Goal list index [{}] loading list [{}] entry [{}]", - list_index, - list_id, - entry.entry - ); - } - } - } - - return true; - -} - -int TaskGoalListManager::GetListByID(int list_id) -{ - - // Find the list with the specified ListID and return the index - auto it = std::find_if( - m_task_goal_lists.begin(), - m_task_goal_lists.end(), - [list_id](const TaskGoalList_Struct &t) { return t.ListID == list_id; } - ); - - if (it == m_task_goal_lists.end()) { - return -1; - } - - return std::distance(m_task_goal_lists.begin(), it); -} - -int TaskGoalListManager::GetFirstEntry(int list_id) -{ - int list_by_id = GetListByID(list_id); - - if ((list_by_id < 0) || (list_by_id >= m_goal_lists_count)) { - return -1; - } - - if (m_task_goal_lists[list_by_id].GoalItemEntries.empty()) { - return -1; - } - - return m_task_goal_lists[list_by_id].GoalItemEntries[0]; -} - -std::vector TaskGoalListManager::GetListContents(int list_index) -{ - std::vector list_contents; - int list_by_id = GetListByID(list_index); - - if ((list_by_id < 0) || (list_by_id >= m_goal_lists_count)) { - return list_contents; - } - - list_contents = m_task_goal_lists[list_by_id].GoalItemEntries; - - return list_contents; -} - -bool TaskGoalListManager::IsInList(int list_id, int entry) -{ - Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", list_id, entry); - - int list_index = GetListByID(list_id); - - if ((list_index < 0) || (list_index >= m_goal_lists_count)) { - return false; - } - - if ((entry < m_task_goal_lists[list_index].Min) || (entry > m_task_goal_lists[list_index].Max)) { - return false; - } - - int first_entry = 0; - auto &task = m_task_goal_lists[list_index]; - auto it = std::find(task.GoalItemEntries.begin(), task.GoalItemEntries.end(), entry); - - if (it == task.GoalItemEntries.end()) { - return false; - } - - Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", list_index, entry); - - return true; -} diff --git a/zone/task_goal_list_manager.h b/zone/task_goal_list_manager.h deleted file mode 100644 index 11146f6e3..000000000 --- a/zone/task_goal_list_manager.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef EQEMU_TASK_GOAL_LIST_MANAGER_H -#define EQEMU_TASK_GOAL_LIST_MANAGER_H - -#include "tasks.h" -#include "../common/types.h" -#include -#include -#include -#include - -struct TaskGoalList_Struct { - int ListID; - int Min, Max; - std::vector GoalItemEntries; -}; - -// This is used for handling lists, loading them from the database, searching them. -// Used for lists of NPCs to kill, items to loot, etc, as well as lists of items to -// reward the player with on completion of the task. -class TaskGoalListManager { - -public: - TaskGoalListManager(); - ~TaskGoalListManager(); - bool LoadLists(); - int GetListByID(int list_id); - bool IsInList(int list_id, int entry); - int GetFirstEntry(int list_id); - std::vector GetListContents(int list_index); - -private: - std::vector m_task_goal_lists; - int m_goal_lists_count; -}; - - -#endif //EQEMU_TASK_GOAL_LIST_MANAGER_H diff --git a/zone/task_manager.cpp b/zone/task_manager.cpp deleted file mode 100644 index b16d95a4e..000000000 --- a/zone/task_manager.cpp +++ /dev/null @@ -1,1656 +0,0 @@ -#include "../common/global_define.h" -#include "../common/misc_functions.h" -#include "../common/repositories/character_activities_repository.h" -#include "../common/repositories/character_tasks_repository.h" -#include "../common/repositories/completed_tasks_repository.h" -#include "../common/repositories/task_activities_repository.h" -#include "../common/repositories/tasks_repository.h" -#include "../common/repositories/tasksets_repository.h" -#include "client.h" -#include "string_ids.h" -#include "task_manager.h" - -TaskManager::TaskManager() -{ - for (auto &task : m_task_data) { - task = nullptr; - } -} - -TaskManager::~TaskManager() -{ - for (auto &task : m_task_data) { - if (task != nullptr) { - safe_delete(task); - } - } -} - -bool TaskManager::LoadTaskSets() -{ - // Clear all task sets in memory. Done so we can reload them on the fly if required by just calling - // this method again. - for (auto &task_set : m_task_sets) { - task_set.clear(); - } - - auto rows = TasksetsRepository::GetWhere( - content_db, - fmt::format( - "`id` > 0 AND `id` < {} AND `taskid` >= 0 AND `taskid` < {} ORDER BY `id`, `taskid` ASC", - MAXTASKSETS, - MAXTASKS - ) - ); - - for (auto &task_set: rows) { - m_task_sets[task_set.id].push_back(task_set.taskid); - LogTasksDetail("[LoadTaskSets] Adding task_id [{}] to task_set [{}]", task_set.taskid, task_set.id); - } - - return true; -} - -void TaskManager::ReloadGoalLists() -{ - if (!m_goal_list_manager.LoadLists()) { - Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadLists failed"); - } -} - -bool TaskManager::LoadTasks(int single_task) -{ - std::string task_query_filter = fmt::format("id = {}", single_task); - std::string query; - if (single_task == 0) { - if (!m_goal_list_manager.LoadLists()) { - LogTasks("[TaskManager::LoadTasks] LoadLists failed"); - } - - if (!LoadTaskSets()) { - LogTasks("[TaskManager::LoadTasks] LoadTaskSets failed"); - } - - task_query_filter = fmt::format("id < {}", MAXTASKS); - } - - // load task level data - auto repo_tasks = TasksRepository::GetWhere(content_db, task_query_filter); - - for (auto &task: repo_tasks) { - int task_id = task.id; - - if ((task_id <= 0) || (task_id >= MAXTASKS)) { - // This shouldn't happen, as the SELECT is bounded by MAXTASKS - LogError("[TASKS]Task ID [{}] out of range while loading tasks from database", task_id); - continue; - } - - // load task data - m_task_data[task_id] = new TaskInformation; - m_task_data[task_id]->type = static_cast(task.type); - m_task_data[task_id]->duration = task.duration; - m_task_data[task_id]->duration_code = static_cast(task.duration_code); - m_task_data[task_id]->title = task.title; - m_task_data[task_id]->description = task.description; - m_task_data[task_id]->reward = task.reward; - m_task_data[task_id]->reward_id = task.rewardid; - m_task_data[task_id]->cash_reward = task.cashreward; - m_task_data[task_id]->experience_reward = task.xpreward; - m_task_data[task_id]->reward_method = (TaskMethodType) task.rewardmethod; - m_task_data[task_id]->faction_reward = task.faction_reward; - m_task_data[task_id]->min_level = task.minlevel; - m_task_data[task_id]->max_level = task.maxlevel; - m_task_data[task_id]->repeatable = task.repeatable; - m_task_data[task_id]->completion_emote = task.completion_emote; - m_task_data[task_id]->activity_count = 0; - m_task_data[task_id]->sequence_mode = ActivitiesSequential; - m_task_data[task_id]->last_step = 0; - - LogTasksDetail( - "[LoadTasks] (Task) task_id [{}] type [{}] duration [{}] duration_code [{}] title [{}] description [{}] " - " reward [{}] rewardid [{}] cashreward [{}] xpreward [{}] rewardmethod [{}] faction_reward [{}] minlevel [{}] " - " maxlevel [{}] repeatable [{}] completion_emote [{}] ", - task.id, - task.type, - task.duration, - task.duration_code, - task.title, - task.description, - task.reward, - task.rewardid, - task.cashreward, - task.xpreward, - task.rewardmethod, - task.faction_reward, - task.minlevel, - task.maxlevel, - task.repeatable, - task.completion_emote - ); - } - - LogTasks("Loaded [{}] Tasks", repo_tasks.size()); - - std::string activities_query_filter = fmt::format( - "taskid = {} and activityid < {} ORDER BY taskid, activityid ASC", - single_task, - MAXACTIVITIESPERTASK - ); - - // if loading only a single task - if (single_task == 0) { - activities_query_filter = fmt::format( - "taskid < {} and activityid < {} ORDER BY taskid, activityid ASC", - MAXTASKS, - MAXACTIVITIESPERTASK - ); - } - - // load activity data - auto task_activities = TaskActivitiesRepository::GetWhere(content_db, activities_query_filter); - for (auto &task_activity: task_activities) { - int task_id = task_activity.taskid; - int step = task_activity.step; - int activity_id = task_activity.activityid; - - if ((task_id <= 0) || (task_id >= MAXTASKS) || (activity_id < 0) || (activity_id >= MAXACTIVITIESPERTASK)) { - - // This shouldn't happen, as the SELECT is bounded by MAXTASKS - LogTasks( - "[LoadTasks] Error: Task or activity_information ID ([{}], [{}]) out of range while loading activities from database", - task_id, - activity_id - ); - continue; - } - - if (m_task_data[task_id] == nullptr) { - LogTasks( - "[LoadTasks] Error: activity_information for non-existent task ([{}], [{}]) while loading activities from database", - task_id, - activity_id - ); - continue; - } - - // create pointer to activity data since declarations get unruly long - int activity_index = m_task_data[task_id]->activity_count; - ActivityInformation *activity_data = &m_task_data[task_id]->activity_information[activity_index]; - - m_task_data[task_id]->activity_information[m_task_data[task_id]->activity_count].step_number = step; - - if (step != 0) { - m_task_data[task_id]->sequence_mode = ActivitiesStepped; - } - - if (step > m_task_data[task_id]->last_step) { - m_task_data[task_id]->last_step = step; - } - - // Task Activities MUST be numbered sequentially from 0. If not, log an error - // and set the task to nullptr. Subsequent activities for this task will raise - // ERR_NOTASK errors. - // Change to (activityID != (Tasks[taskID]->activity_count + 1)) to index from 1 - if (activity_id != m_task_data[task_id]->activity_count) { - LogTasks( - "[LoadTasks] Error: Activities for Task [{}] (activity_id [{}]) are not sequential starting at 0. Not loading task ", - task_id, - activity_id - ); - m_task_data[task_id] = nullptr; - continue; - } - - // set activity data - activity_data->activity_type = task_activity.activitytype; - activity_data->target_name = task_activity.target_name; - activity_data->item_list = task_activity.item_list; - activity_data->skill_list = task_activity.skill_list; - activity_data->skill_id = std::stoi(task_activity.skill_list); // for older clients - activity_data->spell_list = task_activity.spell_list; - activity_data->spell_id = std::stoi(task_activity.spell_list); // for older clients - activity_data->description_override = task_activity.description_override; - activity_data->goal_id = task_activity.goalid; - activity_data->goal_method = (TaskMethodType) task_activity.goalmethod; - activity_data->goal_count = task_activity.goalcount; - activity_data->deliver_to_npc = task_activity.delivertonpc; - - // zones - activity_data->zones = task_activity.zones; - auto zones = SplitString( - task_activity.zones, - ';' - ); - - for (auto &&e : zones) { - activity_data->zone_ids.push_back(std::stoi(e)); - } - - activity_data->optional = task_activity.optional; - - LogTasksDetail( - "[LoadTasks] (Activity) task_id [{}] activity_id [{}] slot [{}] activity_type [{}] goal_id [{}] goal_method [{}] goal_count [{}] zones [{}]" - " target_name [{}] item_list [{}] skill_list [{}] spell_list [{}] description_override [{}]", - task_id, - activity_id, - m_task_data[task_id]->activity_count, - activity_data->activity_type, - activity_data->goal_id, - activity_data->goal_method, - activity_data->goal_count, - activity_data->zones.c_str(), - activity_data->target_name.c_str(), - activity_data->item_list.c_str(), - activity_data->skill_list.c_str(), - activity_data->spell_list.c_str(), - activity_data->description_override.c_str() - ); - - m_task_data[task_id]->activity_count++; - } - - LogTasks("Loaded [{}] Task Activities", task_activities.size()); - - return true; -} - -bool TaskManager::SaveClientState(Client *client, ClientTaskState *client_task_state) -{ - // I am saving the slot in the ActiveTasks table, because unless a Task is cancelled/completed, the client - // doesn't seem to like tasks moving slots between zoning and you can end up with 'bogus' activities if the task - // previously in that slot had more activities than the one now occupying it. Hopefully retaining the slot - // number for the duration of a session will overcome this. - if (!client || !client_task_state) { - return false; - } - - const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::SaveClientState %s"; - - int character_id = client->CharacterID(); - - LogTasks("[SaveClientState] character_id [{}]", character_id); - - if (client_task_state->m_active_task_count > 0 || - client_task_state->m_active_task.task_id != TASKSLOTEMPTY) { // TODO: tasks - for (auto &active_task : client_task_state->m_active_tasks) { - int task_id = active_task.task_id; - if (task_id == TASKSLOTEMPTY) { - continue; - } - - int slot = active_task.slot; - if (active_task.updated) { - - LogTasks( - "[SaveClientState] character_id [{}] updating task_index [{}] task_id [{}]", - character_id, - slot, - task_id - ); - - std::string query = StringFormat( - "REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime) " - "VALUES (%i, %i, %i, %i, %i)", - character_id, - task_id, - slot, - static_cast(m_task_data[task_id]->type), - active_task.accepted_time - ); - - auto results = database.QueryDatabase(query); - if (!results.Success()) { - LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); - } - else { - active_task.updated = false; - } - } - - std::string query = - "REPLACE INTO character_activities (charid, taskid, activityid, donecount, completed) " - "VALUES "; - - int updated_activity_count = 0; - - for (int activity_index = 0; activity_index < m_task_data[task_id]->activity_count; ++activity_index) { - if (!active_task.activity[activity_index].updated) { - continue; - } - - LogTasks( - "[SaveClientState] Updating activity character_id [{}] updating task_index [{}] task_id [{}] activity_index [{}]", - character_id, - slot, - task_id, - activity_index - ); - - if (updated_activity_count == 0) { - query += - StringFormat( - "(%i, %i, %i, %i, %i)", character_id, task_id, activity_index, - active_task.activity[activity_index].done_count, - active_task.activity[activity_index].activity_state == - ActivityCompleted - ); - } - else { - query += - StringFormat( - ", (%i, %i, %i, %i, %i)", character_id, task_id, activity_index, - active_task.activity[activity_index].done_count, - active_task.activity[activity_index].activity_state == - ActivityCompleted - ); - } - - updated_activity_count++; - } - - if (updated_activity_count == 0) { - continue; - } - - auto results = database.QueryDatabase(query); - - if (!results.Success()) { - LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); - continue; - } - - active_task.updated = false; - for (int activity_index = 0; - activity_index < m_task_data[task_id]->activity_count; - ++activity_index) - active_task.activity[activity_index].updated = false; - } - } - - if (!RuleB(TaskSystem, RecordCompletedTasks) || - (client_task_state->m_completed_tasks.size() <= (unsigned int) client_task_state->m_last_completed_task_loaded)) { - client_task_state->m_last_completed_task_loaded = client_task_state->m_completed_tasks.size(); - return true; - } - - const char *completed_task_query = "REPLACE INTO completed_tasks (charid, completedtime, taskid, activityid) " - "VALUES (%i, %i, %i, %i)"; - - for (unsigned int task_index = client_task_state->m_last_completed_task_loaded; - task_index < client_task_state->m_completed_tasks.size(); - task_index++) { - - int task_id = client_task_state->m_completed_tasks[task_index].task_id; - - if ((task_id <= 0) || (task_id >= MAXTASKS) || (m_task_data[task_id] == nullptr)) { - continue; - } - - // First we save a record with an activity_id of -1. - // This indicates this task was completed at the given time. We infer that all - // none optional activities were completed. - // - std::string query = StringFormat( - completed_task_query, - character_id, - client_task_state->m_completed_tasks[task_index].completed_time, - task_id, - -1 - ); - - auto results = database.QueryDatabase(query); - if (!results.Success()) { - LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); - continue; - } - - // If the Rule to record non-optional task completion is not enabled, don't save it - if (!RuleB(TaskSystem, RecordCompletedOptionalActivities)) { - continue; - } - - // Insert one record for each completed optional task. - for (int activity_id = 0; activity_id < m_task_data[task_id]->activity_count; activity_id++) { - if (!m_task_data[task_id]->activity_information[activity_id].optional || - !client_task_state->m_completed_tasks[task_index].activity_done[activity_id]) { - continue; - } - - query = StringFormat( - completed_task_query, - character_id, - client_task_state->m_completed_tasks[task_index].completed_time, - task_id, activity_id - ); - - results = database.QueryDatabase(query); - if (!results.Success()) { - LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); - } - } - } - - client_task_state->m_last_completed_task_loaded = client_task_state->m_completed_tasks.size(); - return true; -} - -int TaskManager::FirstTaskInSet(int task_set) -{ - if ((task_set <= 0) || (task_set >= MAXTASKSETS)) { - return 0; - } - - if (m_task_sets[task_set].empty()) { - return 0; - } - - auto iterator = m_task_sets[task_set].begin(); - while (iterator != m_task_sets[task_set].end()) { - if ((*iterator) > 0) { - return (*iterator); - } - ++iterator; - } - - return 0; -} - -int TaskManager::LastTaskInSet(int task_set) -{ - if ((task_set <= 0) || (task_set >= MAXTASKSETS)) { - return 0; - } - - if (m_task_sets[task_set].empty()) { - return 0; - } - - return m_task_sets[task_set][m_task_sets[task_set].size() - 1]; -} - -int TaskManager::NextTaskInSet(int task_set, int task_id) -{ - if ((task_set <= 0) || (task_set >= MAXTASKSETS)) { - return 0; - } - - if (m_task_sets[task_set].empty()) { - return 0; - } - - for (int i : m_task_sets[task_set]) { - if (i > task_id) { - return i; - } - } - - return 0; -} - -bool TaskManager::ValidateLevel(int task_id, int player_level) -{ - if (m_task_data[task_id] == nullptr) { - return false; - } - - if (m_task_data[task_id]->min_level && (player_level < m_task_data[task_id]->min_level)) { - return false; - } - - if (m_task_data[task_id]->max_level && (player_level > m_task_data[task_id]->max_level)) { - return false; - } - - return true; -} - -std::string TaskManager::GetTaskName(uint32 task_id) -{ - if (task_id > 0 && task_id < MAXTASKS) { - if (m_task_data[task_id] != nullptr) { - return m_task_data[task_id]->title; - } - } - - return std::string(); -} - -TaskType TaskManager::GetTaskType(uint32 task_id) -{ - if (task_id > 0 && task_id < MAXTASKS) { - if (m_task_data[task_id] != nullptr) { - return m_task_data[task_id]->type; - } - } - return TaskType::Task; -} - -void TaskManager::TaskSetSelector(Client *client, ClientTaskState *client_task_state, Mob *mob, int task_set_id) -{ - int task_list[MAXCHOOSERENTRIES]; - int task_list_index = 0; - int player_level = client->GetLevel(); - - LogTasks( - "TaskSetSelector called for task_set_id [{}] EnableTaskSize is [{}]", - task_set_id, - client_task_state->m_enabled_tasks.size() - ); - - if (task_set_id <= 0 || task_set_id >= MAXTASKSETS) { - return; - } - - if (m_task_sets[task_set_id].empty()) { - // I think this is suppose to be yellow - mob->SayString( - client, - Chat::Yellow, - MAX_ACTIVE_TASKS, - client->GetName() - ); - return; - } - - bool all_enabled = false; - - // A task_id of 0 in a TaskSet indicates that all Tasks in the set are enabled for all players. - if (m_task_sets[task_set_id][0] == 0) { - LogTasks("[TaskSetSelector] TaskSets[{}][0] == 0. All Tasks in Set enabled.", task_set_id); - all_enabled = true; - } - - auto iterator = m_task_sets[task_set_id].begin(); - if (all_enabled) { - ++iterator; - } // skip first when all enabled since it's useless data - - while (iterator != m_task_sets[task_set_id].end() && task_list_index < MAXCHOOSERENTRIES) { - auto task = *iterator; - // verify level, we're not currently on it, repeatable status, if it's a (shared) task - // we aren't currently on another, and if it's enabled if not all_enabled - if ((all_enabled || client_task_state->IsTaskEnabled(task)) && ValidateLevel(task, player_level) && - !client_task_state->IsTaskActive(task) && client_task_state->HasSlotForTask(m_task_data[task]) && - // this slot checking is a bit silly, but we allow mixing of task types ... - (IsTaskRepeatable(task) || !client_task_state->IsTaskCompleted(task))) { - task_list[task_list_index++] = task; - } - - ++iterator; - } - - if (task_list_index > 0) { - SendTaskSelector(client, mob, task_list_index, task_list); - } - else { - // TODO: check color, I think this might be only for (Shared) Tasks, w/e -- think should be yellow - mob->SayString( - client, - Chat::Yellow, - MAX_ACTIVE_TASKS, - client->GetName() - ); - } -} - -// unlike the non-Quest version of this function, it does not check enabled, that is assumed the responsibility of the quest to handle -// we do however still want it to check the other stuff like level, active, room, etc -void TaskManager::TaskQuestSetSelector( - Client *client, - ClientTaskState *client_task_state, - Mob *mob, - int count, - int *tasks -) -{ - int task_list[MAXCHOOSERENTRIES]; - int task_list_index = 0; - int player_level = client->GetLevel(); - - LogTasks("[UPDATE] TaskQuestSetSelector called for array size [{}]", count); - - if (count <= 0) { - return; - } - - for (int i = 0; i < count; ++i) { - auto task = tasks[i]; - // verify level, we're not currently on it, repeatable status, if it's a (shared) task - // we aren't currently on another, and if it's enabled if not all_enabled - if (ValidateLevel(task, player_level) && !client_task_state->IsTaskActive(task) && - client_task_state->HasSlotForTask(m_task_data[task]) && - // this slot checking is a bit silly, but we allow mixing of task types ... - (IsTaskRepeatable(task) || !client_task_state->IsTaskCompleted(task))) { - task_list[task_list_index++] = task; - } - } - - if (task_list_index > 0) { - SendTaskSelector(client, mob, task_list_index, task_list); - } - else { - // TODO: check color, I think this might be only for (Shared) Tasks, w/e -- think should be yellow - mob->SayString( - client, - Chat::Yellow, - MAX_ACTIVE_TASKS, - client->GetName() - ); - } -} - -// sends task selector to client -void TaskManager::SendTaskSelector(Client *client, Mob *mob, int task_count, int *task_list) -{ - if (client->ClientVersion() >= EQ::versions::ClientVersion::RoF) { - SendTaskSelectorNew(client, mob, task_count, task_list); - return; - } - // Titanium OpCode: 0x5e7c - LogTasks("TaskSelector for [{}] Tasks", task_count); - int player_level = client->GetLevel(); - - // Check if any of the tasks exist - for (int i = 0; i < task_count; i++) { - if (m_task_data[task_list[i]] != nullptr) { - break; - } - } - - int valid_task_count = 0; - - for (int i = 0; i < task_count; i++) { - if (!ValidateLevel(task_list[i], player_level)) { - continue; - } - if (client->IsTaskActive(task_list[i])) { - continue; - } - if (!IsTaskRepeatable(task_list[i]) && client->IsTaskCompleted(task_list[i])) { - continue; - } - - valid_task_count++; - } - - if (valid_task_count == 0) { - return; - } - - SerializeBuffer buf(50 * valid_task_count); - - buf.WriteUInt32(valid_task_count); - buf.WriteUInt32(2); // task type, live doesn't let you send more than one type, but we do? - buf.WriteUInt32(mob->GetID()); - - for (int task_index = 0; task_index < task_count; task_index++) { - if (!ValidateLevel(task_list[task_index], player_level)) { - continue; - } - if (client->IsTaskActive(task_list[task_index])) { - continue; - } - if (!IsTaskRepeatable(task_list[task_index]) && client->IsTaskCompleted(task_list[task_index])) { - continue; - } - - buf.WriteUInt32(task_list[task_index]); // task_id - - // affects color, difficulty? - if (client->ClientVersion() != EQ::versions::ClientVersion::Titanium) { - buf.WriteFloat(1.0f); - } - buf.WriteUInt32(m_task_data[task_list[task_index]]->duration); - buf.WriteUInt32(static_cast(m_task_data[task_list[task_index]]->duration_code)); - - buf.WriteString(m_task_data[task_list[task_index]]->title); // max 64 with null - buf.WriteString(m_task_data[task_list[task_index]]->description); // max 4000 with null - - // Has reward set flag - if (client->ClientVersion() != EQ::versions::ClientVersion::Titanium) { - buf.WriteUInt8(0); - } - - buf.WriteUInt32(m_task_data[task_list[task_index]]->activity_count); - - for (int activity_index = 0; - activity_index < m_task_data[task_list[task_index]]->activity_count; - ++activity_index) { - buf.WriteUInt32(activity_index); // ActivityNumber - auto &activity = m_task_data[task_list[task_index]]->activity_information[activity_index]; - buf.WriteUInt32(activity.activity_type); - buf.WriteUInt32(0); // solo, group, raid? - buf.WriteString(activity.target_name); // max length 64, "target name" so like loot x foo from bar (this is bar) - buf.WriteString(activity.item_list); // max length 64 in these clients - buf.WriteUInt32(activity.goal_count); - buf.WriteInt32(activity.skill_id); - buf.WriteInt32(activity.spell_id); - buf.WriteInt32(activity.zone_ids.empty() ? 0 : activity.zone_ids.front()); - buf.WriteString(activity.description_override); - } - } - - auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf); - - client->QueuePacket(outapp); - safe_delete(outapp); -} - -void TaskManager::SendTaskSelectorNew(Client *client, Mob *mob, int task_count, int *task_list) -{ - LogTasks("SendTaskSelectorNew for [{}] Tasks", task_count); - - int player_level = client->GetLevel(); - - // Check if any of the tasks exist - for (int i = 0; i < task_count; i++) { - if (m_task_data[task_list[i]] != nullptr) { - break; - } - } - - int valid_tasks_count = 0; - for (int task_index = 0; task_index < task_count; task_index++) { - if (!ValidateLevel(task_list[task_index], player_level)) { - continue; - } - if (client->IsTaskActive(task_list[task_index])) { - continue; - } - if (!IsTaskRepeatable(task_list[task_index]) && client->IsTaskCompleted(task_list[task_index])) { - continue; - } - - valid_tasks_count++; - } - - if (valid_tasks_count == 0) { - return; - } - - SerializeBuffer buf(50 * valid_tasks_count); - - buf.WriteUInt32(valid_tasks_count); // TaskCount - buf.WriteUInt32(2); // Type, valid values: 0-3. 0 = Task, 1 = Shared Task, 2 = Quest, 3 = ??? -- should fix maybe some day, but we let more than 1 type through :P - // so I guess an NPC can only offer one type of quests or we can only open a selection with one type :P (so quest call can tell us I guess) - // this is also sent in OP_TaskDescription - buf.WriteUInt32(mob->GetID()); // TaskGiver - - for (int i = 0; i < task_count; i++) { // max 40 - if (!ValidateLevel(task_list[i], player_level)) { - continue; - } - if (client->IsTaskActive(task_list[i])) { - continue; - } - if (!IsTaskRepeatable(task_list[i]) && client->IsTaskCompleted(task_list[i])) { - continue; - } - - buf.WriteUInt32(task_list[i]); // task_id - buf.WriteFloat(1.0f); // affects color, difficulty? - buf.WriteUInt32(m_task_data[task_list[i]]->duration); - buf.WriteUInt32(static_cast(m_task_data[task_list[i]]->duration_code)); // 1 = Short, 2 = Medium, 3 = Long, anything else Unlimited - - buf.WriteString(m_task_data[task_list[i]]->title); // max 64 with null - buf.WriteString(m_task_data[task_list[i]]->description); // max 4000 with null - - buf.WriteUInt8(0); // Has reward set flag - buf.WriteUInt32(m_task_data[task_list[i]]->activity_count); // activity_count - - for (int j = 0; j < m_task_data[task_list[i]]->activity_count; ++j) { - buf.WriteUInt32(j); // ActivityNumber - auto &activity = m_task_data[task_list[i]]->activity_information[j]; - buf.WriteUInt32(activity.activity_type); // ActivityType - buf.WriteUInt32(0); // solo, group, raid? - buf.WriteString(activity.target_name); // max length 64, "target name" so like loot x foo from bar (this is bar) - - // this string is item names - buf.WriteLengthString(activity.item_list); - - buf.WriteUInt32(activity.goal_count); // GoalCount - - // this string is skill IDs? probably one of the "use on" tasks - buf.WriteLengthString(activity.skill_list); - - // this string is spell IDs? probably one of the "use on" tasks - buf.WriteLengthString(activity.spell_list); - - //buf.WriteString(itoa(Tasks[TaskList[i]]->activity_information[activity_id].ZoneID)); - buf.WriteString(activity.zones); // Zone number in ascii max length 64, can be multiple with separated by ; - buf.WriteString(activity.description_override); // max length 128 -- overrides the automatic descriptions - // this doesn't appear to be shown to the client at all and isn't the same as zones ... defaults to '0' though - buf.WriteString(activity.zones); // Zone number in ascii max length 64, probably can be separated by ; too, haven't found it used - } - } - - auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf); - - client->QueuePacket(outapp); - safe_delete(outapp); -} - -int TaskManager::GetActivityCount(int task_id) -{ - if ((task_id > 0) && (task_id < MAXTASKS)) { - if (m_task_data[task_id]) { return m_task_data[task_id]->activity_count; } - } - - return 0; -} - -void TaskManager::ExplainTask(Client *client, int task_id) -{ - - // TODO: This method is not finished (hardly started). It was intended to - // explain in English, what each activity_information did, conditions for step unlocking, etc. - // - return; - - if (!client) { return; } - - if ((task_id <= 0) || (task_id >= MAXTASKS)) { - client->Message(Chat::White, "task_id out-of-range."); - return; - } - - if (m_task_data[task_id] == nullptr) { - client->Message(Chat::White, "Task does not exist."); - return; - } - - char explanation[1000], *ptr; - client->Message(Chat::White, "Task %4i: title: %s", task_id, m_task_data[task_id]->description.c_str()); - client->Message(Chat::White, "%3i Activities", m_task_data[task_id]->activity_count); - ptr = explanation; - for (int i = 0; i < m_task_data[task_id]->activity_count; i++) { - - sprintf(ptr, "Act: %3i: ", i); - ptr = ptr + strlen(ptr); - switch (m_task_data[task_id]->activity_information[i].activity_type) { - case ActivityDeliver: - sprintf(ptr, "Deliver"); - break; - } - - } -} - -bool TaskManager::IsTaskRepeatable(int task_id) -{ - if ((task_id <= 0) || (task_id >= MAXTASKS)) { - return false; - } - - TaskInformation *task_data = task_manager->m_task_data[task_id]; - if (task_data == nullptr) { - return false; - } - - return task_data->repeatable; -} - -void TaskManager::SendCompletedTasksToClient(Client *c, ClientTaskState *client_task_state) -{ - int packet_length = 4; - - //vector::const_iterator iterator; - // The client only display the first 50 Completed Tasks send, so send the 50 most recent - int first_task_to_send = 0; - int last_task_to_send = client_task_state->m_completed_tasks.size(); - - if (client_task_state->m_completed_tasks.size() > 50) { - first_task_to_send = client_task_state->m_completed_tasks.size() - 50; - } - - LogTasks( - "[SendCompletedTasksToClient] completed task count [{}] first tank to send is [{}] last is [{}]", - client_task_state->m_completed_tasks.size(), - first_task_to_send, - last_task_to_send - ); - - /* - for(iterator=activity_state->CompletedTasks.begin(); iterator!=activity_state->CompletedTasks.end(); iterator++) { - int task_id = (*iterator).task_id; - if(Tasks[task_id] == nullptr) continue; - PacketLength = PacketLength + 8 + strlen(Tasks[task_id]->title) + 1; - } - */ - for (int i = first_task_to_send; i < last_task_to_send; i++) { - int TaskID = client_task_state->m_completed_tasks[i].task_id; - if (m_task_data[TaskID] == nullptr) { continue; } - packet_length = packet_length + 8 + m_task_data[TaskID]->title.size() + 1; - } - - auto outapp = new EQApplicationPacket(OP_CompletedTasks, packet_length); - char *buf = (char *) outapp->pBuffer; - - //*(uint32 *)buf = activity_state->CompletedTasks.size(); - *(uint32 *) buf = last_task_to_send - first_task_to_send; - buf = buf + 4; - //for(iterator=activity_state->CompletedTasks.begin(); iterator!=activity_state->CompletedTasks.end(); iterator++) { - // int task_id = (*iterator).task_id; - for (int i = first_task_to_send; i < last_task_to_send; i++) { - int task_id = client_task_state->m_completed_tasks[i].task_id; - if (m_task_data[task_id] == nullptr) { continue; } - *(uint32 *) buf = task_id; - buf = buf + 4; - - sprintf(buf, "%s", m_task_data[task_id]->title.c_str()); - buf = buf + strlen(buf) + 1; - //*(uint32 *)buf = (*iterator).CompletedTime; - *(uint32 *) buf = client_task_state->m_completed_tasks[i].completed_time; - buf = buf + 4; - } - - c->QueuePacket(outapp); - safe_delete(outapp); -} - -void TaskManager::SendTaskActivityShort(Client *client, int task_id, int activity_id, int client_task_index) -{ - // This activity_information Packet is sent for activities that have not yet been unlocked and appear as ??? - // in the client. - - TaskActivityShort_Struct *task_activity_short; - if (client->ClientVersionBit() & EQ::versions::maskRoFAndLater) { - auto outapp = new EQApplicationPacket(OP_TaskActivity, 25); - outapp->WriteUInt32(client_task_index); - outapp->WriteUInt32(static_cast(m_task_data[task_id]->type)); - outapp->WriteUInt32(task_id); - outapp->WriteUInt32(activity_id); - outapp->WriteUInt32(0); - outapp->WriteUInt32(0xffffffff); - outapp->WriteUInt8(0); - client->FastQueuePacket(&outapp); - - return; - } - - auto outapp = new EQApplicationPacket(OP_TaskActivity, sizeof(TaskActivityShort_Struct)); - - task_activity_short = (TaskActivityShort_Struct *) outapp->pBuffer; - task_activity_short->TaskSequenceNumber = client_task_index; - task_activity_short->unknown2 = static_cast(m_task_data[task_id]->type); - task_activity_short->TaskID = task_id; - task_activity_short->ActivityID = activity_id; - task_activity_short->unknown3 = 0x000000; - task_activity_short->ActivityType = 0xffffffff; - task_activity_short->unknown4 = 0x00000000; - - client->QueuePacket(outapp); - safe_delete(outapp); -} - -void TaskManager::SendTaskActivityLong( - Client *client, - int task_id, - int activity_id, - int client_task_index, - bool optional, - bool task_complete -) -{ - - if (client->ClientVersion() >= EQ::versions::ClientVersion::RoF) { - SendTaskActivityNew(client, task_id, activity_id, client_task_index, optional, task_complete); - return; - } - - SerializeBuffer buf(100); - - buf.WriteUInt32(client_task_index); - buf.WriteUInt32(static_cast(m_task_data[task_id]->type)); - buf.WriteUInt32(task_id); - buf.WriteUInt32(activity_id); - buf.WriteUInt32(0); // unknown3 - - // We send our 'internal' types as ActivityCastOn. text3 should be set to the activity_information description, so it makes - // no difference to the client. All activity_information updates will be done based on our interal activity_information types. - if ((m_task_data[task_id]->activity_information[activity_id].activity_type > 0) && - m_task_data[task_id]->activity_information[activity_id].activity_type < 100) { - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].activity_type); - } - else { - buf.WriteUInt32(ActivityCastOn); - } // w/e! - - buf.WriteUInt32(optional); - buf.WriteUInt32(0); // solo, group, raid - - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].target_name); // target name string - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].item_list); // item name list - - if (m_task_data[task_id]->activity_information[activity_id].activity_type != ActivityGiveCash) { - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].goal_count); - } - else { - // For our internal type GiveCash, where the goal count has the amount of cash that must be given, - // we don't want the donecount and goalcount fields cluttered up with potentially large numbers, so we just - // send a goalcount of 1, and a bit further down, a donecount of 1 if the activity_information is complete, 0 otherwise. - // The text3 field should decribe the exact activity_information goal, e.g. give 3500gp to Hasten Bootstrutter. - buf.WriteUInt32(1); - } - - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].skill_id); - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].spell_id); - buf.WriteUInt32( - m_task_data[task_id]->activity_information[activity_id].zone_ids.empty() ? 0 - : m_task_data[task_id]->activity_information[activity_id].zone_ids.front()); - buf.WriteUInt32(0); - - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].description_override); - - if (m_task_data[task_id]->activity_information[activity_id].activity_type != ActivityGiveCash) { - buf.WriteUInt32(client->GetTaskActivityDoneCount(m_task_data[task_id]->type, client_task_index, activity_id)); - } - else { - // For internal activity_information types, done_count is either 1 if the activity_information is complete, 0 otherwise. - buf.WriteUInt32((client->GetTaskActivityDoneCount(m_task_data[task_id]->type, client_task_index, activity_id) >= - m_task_data[task_id]->activity_information[activity_id].goal_count)); - } - - buf.WriteUInt32(1); // unknown - - auto outapp = new EQApplicationPacket(OP_TaskActivity, buf); - - client->QueuePacket(outapp); - safe_delete(outapp); - -} - -// Used only by RoF+ Clients -void TaskManager::SendTaskActivityNew( - Client *client, - int task_id, - int activity_id, - int client_task_index, - bool optional, - bool task_complete -) -{ - SerializeBuffer buf(100); - - buf.WriteUInt32(client_task_index); // TaskSequenceNumber - buf.WriteUInt32(static_cast(m_task_data[task_id]->type)); // task type - buf.WriteUInt32(task_id); - buf.WriteUInt32(activity_id); - buf.WriteUInt32(0); // unknown3 - - // We send our 'internal' types as ActivityCastOn. text3 should be set to the activity_information description, so it makes - // no difference to the client. All activity_information updates will be done based on our interal activity_information types. - if ((m_task_data[task_id]->activity_information[activity_id].activity_type > 0) && - m_task_data[task_id]->activity_information[activity_id].activity_type < 100) { - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].activity_type); - } - else { - buf.WriteUInt32(ActivityCastOn); - } // w/e! - - buf.WriteUInt8(optional); - buf.WriteUInt32(0); // solo, group, raid - - // One of these unknown fields maybe related to the 'Use On' activity_information types - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].target_name); // target name string - - buf.WriteLengthString(m_task_data[task_id]->activity_information[activity_id].item_list); // item name list - - // Goal Count - if (m_task_data[task_id]->activity_information[activity_id].activity_type != ActivityGiveCash) { - buf.WriteUInt32(m_task_data[task_id]->activity_information[activity_id].goal_count); - } - else { - buf.WriteUInt32(1); - } // GoalCount - - // skill ID list ; separated - buf.WriteLengthString(m_task_data[task_id]->activity_information[activity_id].skill_list); - - // spelll ID list ; separated -- unsure wtf we're doing here - buf.WriteLengthString(m_task_data[task_id]->activity_information[activity_id].spell_list); - - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].zones); - buf.WriteUInt32(0); // unknown7 - - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].description_override); // description override - - if (m_task_data[task_id]->activity_information[activity_id].activity_type != ActivityGiveCash) { - buf.WriteUInt32( - client->GetTaskActivityDoneCount( - m_task_data[task_id]->type, - client_task_index, - activity_id - )); // done_count - } - else { - // For internal activity_information types, done_count is either 1 if the activity_information is complete, 0 otherwise. - buf.WriteUInt32((client->GetTaskActivityDoneCount(m_task_data[task_id]->type, client_task_index, activity_id) >= - m_task_data[task_id]->activity_information[activity_id].goal_count)); - } - - buf.WriteUInt8(1); // unknown9 - - buf.WriteString(m_task_data[task_id]->activity_information[activity_id].zones); - - auto outapp = new EQApplicationPacket(OP_TaskActivity, buf); - - client->QueuePacket(outapp); - safe_delete(outapp); - -} - -void TaskManager::SendActiveTasksToClient(Client *client, bool task_complete) -{ - auto state = client->GetTaskState(); - if (!state) { - return; - } - - for (int task_index = 0; task_index < MAXACTIVEQUESTS + 1; task_index++) { - int task_id = state->m_active_tasks[task_index].task_id; - if ((task_id == 0) || (m_task_data[task_id] == 0)) { - continue; - } - int start_time = state->m_active_tasks[task_index].accepted_time; - - SendActiveTaskDescription( - client, task_id, state->m_active_tasks[task_index], start_time, m_task_data[task_id]->duration, - false - ); - LogTasks("[SendActiveTasksToClient] task_id [{}] activity_count [{}]", task_id, GetActivityCount(task_id)); - - int sequence = 0; - int fixed_index = m_task_data[task_id]->type == TaskType::Task ? 0 : task_index - 1; // hmmm fuck - for (int activity_id = 0; activity_id < GetActivityCount(task_id); activity_id++) { - if (client->GetTaskActivityState(m_task_data[task_id]->type, fixed_index, activity_id) != ActivityHidden) { - LogTasks( - "[SendActiveTasksToClient] (Long Update) task_id [{}] activity_id [{}] fixed_index [{}] task_complete [{}]", - task_id, - activity_id, - fixed_index, - task_complete ? "true" : "false" - ); - - if (activity_id == GetActivityCount(task_id) - 1) { - SendTaskActivityLong( - client, - task_id, - activity_id, - fixed_index, - m_task_data[task_id]->activity_information[activity_id].optional, - task_complete - ); - } - else { - SendTaskActivityLong( - client, - task_id, - activity_id, - fixed_index, - m_task_data[task_id]->activity_information[activity_id].optional, - 0 - ); - } - } - else { - LogTasks( - "[SendActiveTasksToClient] (Short Update) task_id [{}] activity_id [{}] fixed_index [{}]", - task_id, - activity_id, - fixed_index - ); - - SendTaskActivityShort(client, task_id, activity_id, fixed_index); - } - sequence++; - } - } -} - -void TaskManager::SendSingleActiveTaskToClient( - Client *client, ClientTaskInformation &task_info, bool task_complete, - bool bring_up_task_journal -) -{ - int task_id = task_info.task_id; - if (task_id == 0 || m_task_data[task_id] == nullptr) { - return; - } - - int start_time = task_info.accepted_time; - SendActiveTaskDescription( - client, - task_id, - task_info, - start_time, - m_task_data[task_id]->duration, - bring_up_task_journal - ); - Log(Logs::General, - Logs::Tasks, - "[UPDATE] SendSingleActiveTasksToClient: Task %i, Activities: %i", - task_id, - GetActivityCount(task_id)); - - for (int activity_id = 0; activity_id < GetActivityCount(task_id); activity_id++) { - if (task_info.activity[activity_id].activity_state != ActivityHidden) { - LogTasks("[SendSingleActiveTaskToClient] Long [{}] [{}] complete [{}]", - task_id, - activity_id, - task_complete); - if (activity_id == GetActivityCount(task_id) - 1) { - SendTaskActivityLong( - client, task_id, activity_id, task_info.slot, - m_task_data[task_id]->activity_information[activity_id].optional, task_complete - ); - } - else { - SendTaskActivityLong( - client, task_id, activity_id, task_info.slot, - m_task_data[task_id]->activity_information[activity_id].optional, 0 - ); - } - } - else { - LogTasks("[SendSingleActiveTaskToClient] Short [{}] [{}]", task_id, activity_id); - SendTaskActivityShort(client, task_id, activity_id, task_info.slot); - } - } -} - -void TaskManager::SendActiveTaskDescription( - Client *client, - int task_id, - ClientTaskInformation &task_info, - int start_time, - int duration, - bool bring_up_task_journal -) -{ - if ((task_id < 1) || (task_id >= MAXTASKS) || !m_task_data[task_id]) { - return; - } - - int packet_length = sizeof(TaskDescriptionHeader_Struct) + m_task_data[task_id]->title.length() + 1 - + sizeof(TaskDescriptionData1_Struct) + m_task_data[task_id]->description.length() + 1 - + sizeof(TaskDescriptionData2_Struct) + 1 + sizeof(TaskDescriptionTrailer_Struct); - - // If there is an item make the reward text into a link to the item (only the first item if a list - // is specified). I have been unable to get multiple item links to work. - // - if (m_task_data[task_id]->reward_id && m_task_data[task_id]->item_link.empty()) { - int item_id = 0; - // If the reward is a list of items, and the first entry on the list is valid - if (m_task_data[task_id]->reward_method == METHODSINGLEID) { - item_id = m_task_data[task_id]->reward_id; - } - else if (m_task_data[task_id]->reward_method == METHODLIST) { - item_id = m_goal_list_manager.GetFirstEntry(m_task_data[task_id]->reward_id); - if (item_id < 0) { - item_id = 0; - } - } - - if (item_id) { - const EQ::ItemData *reward_item = database.GetItem(item_id); - - EQ::SayLinkEngine linker; - linker.SetLinkType(EQ::saylink::SayLinkItemData); - linker.SetItemData(reward_item); - linker.SetTaskUse(); - m_task_data[task_id]->item_link = linker.GenerateLink(); - } - } - - packet_length += m_task_data[task_id]->reward.length() + 1 + m_task_data[task_id]->item_link.length() + 1; - - char *Ptr; - TaskDescriptionHeader_Struct *task_description_header; - TaskDescriptionData1_Struct *tdd1; - TaskDescriptionData2_Struct *tdd2; - TaskDescriptionTrailer_Struct *tdt; - - auto outapp = new EQApplicationPacket(OP_TaskDescription, packet_length); - - task_description_header = (TaskDescriptionHeader_Struct *) outapp->pBuffer; - - task_description_header->SequenceNumber = task_info.slot; - task_description_header->TaskID = task_id; - task_description_header->open_window = bring_up_task_journal; - task_description_header->task_type = static_cast(m_task_data[task_id]->type); - task_description_header->reward_type = 0; // TODO: 4 says Radiant Crystals else Ebon Crystals when shared task - - Ptr = (char *) task_description_header + sizeof(TaskDescriptionHeader_Struct); - - sprintf(Ptr, "%s", m_task_data[task_id]->title.c_str()); - Ptr += m_task_data[task_id]->title.length() + 1; - - tdd1 = (TaskDescriptionData1_Struct *) Ptr; - - tdd1->Duration = duration; - tdd1->dur_code = static_cast(m_task_data[task_id]->duration_code); - - tdd1->StartTime = start_time; - - Ptr = (char *) tdd1 + sizeof(TaskDescriptionData1_Struct); - - sprintf(Ptr, "%s", m_task_data[task_id]->description.c_str()); - Ptr += m_task_data[task_id]->description.length() + 1; - - tdd2 = (TaskDescriptionData2_Struct *) Ptr; - - // we have this reward stuff! - // if we ever don't hardcode this, TaskDescriptionTrailer_Struct will need to be fixed since - // "has_reward_selection" is after this bool! Smaller packet when this is 0 - tdd2->has_rewards = 1; - - tdd2->coin_reward = m_task_data[task_id]->cash_reward; - tdd2->xp_reward = m_task_data[task_id]->experience_reward ? 1 : 0; // just booled - tdd2->faction_reward = m_task_data[task_id]->faction_reward ? 1 : 0; // faction booled - - Ptr = (char *) tdd2 + sizeof(TaskDescriptionData2_Struct); - - // we actually have 2 strings here. One is max length 96 and not parsed for item links - // We actually skipped past that string incorrectly before, so TODO: fix item link string - sprintf(Ptr, "%s", m_task_data[task_id]->reward.c_str()); - Ptr += m_task_data[task_id]->reward.length() + 1; - - // second string is parsed for item links - sprintf(Ptr, "%s", m_task_data[task_id]->item_link.c_str()); - Ptr += m_task_data[task_id]->item_link.length() + 1; - - tdt = (TaskDescriptionTrailer_Struct *) Ptr; - tdt->Points = 0x00000000; // Points Count TODO: this does have a visible affect on the client ... - tdt->has_reward_selection = 0; // TODO: new rewards window - - client->QueuePacket(outapp); - safe_delete(outapp); -} - -bool TaskManager::LoadClientState(Client *client, ClientTaskState *client_task_state) -{ - if (!client || !client_task_state) { - return false; - } - - int character_id = client->CharacterID(); - - client_task_state->m_active_task_count = 0; - - LogTasks("[LoadClientState] for character_id [{}]", character_id); - - auto character_tasks = CharacterTasksRepository::GetWhere( - database, - fmt::format("charid = {} ORDER BY acceptedtime", character_id) - ); - - for (auto &character_task: character_tasks) { - int task_id = character_task.taskid; - int slot = character_task.slot; - auto type = static_cast(character_task.type); - - if ((task_id < 0) || (task_id >= MAXTASKS)) { - LogTasks( - "[LoadClientState] Error: task_id [{}] out of range while loading character tasks from database", - task_id - ); - continue; - } - - // client data bucket pointer - auto task_info = client_task_state->GetClientTaskInfo(type, slot); - if (task_info == nullptr) { - LogTasks( - "[LoadClientState] Error: slot [{}] out of range while loading character tasks from database", - slot - ); - continue; - } - - if (task_info->task_id != TASKSLOTEMPTY) { - LogTasks("[LoadClientState] Error: slot [{}] for task [{}] is already occupied", slot, task_id); - continue; - } - - task_info->task_id = task_id; - task_info->current_step = -1; - task_info->accepted_time = character_task.acceptedtime; - task_info->updated = false; - - for (auto &i : task_info->activity) { - i.activity_id = -1; - } - - if (type == TaskType::Quest) { - ++client_task_state->m_active_task_count; - } - - LogTasks( - "[LoadClientState] character_id [{}] task_id [{}] accepted_time [{}]", - character_id, - task_id, - character_task.acceptedtime - ); - } - - // Load Activities - LogTasks("[LoadClientState] Loading activities for character_id [{}]", character_id); - - auto character_activities = CharacterActivitiesRepository::GetWhere( - database, - fmt::format("charid = {} ORDER BY `taskid` ASC, `activityid` ASC", character_id) - ); - - for (auto &character_activity: character_activities) { - int task_id = character_activity.taskid; - if ((task_id < 0) || (task_id >= MAXTASKS)) { - LogTasks( - "[LoadClientState] Error: task_id [{}] out of range while loading character activities from database character_id [{}]", - task_id, - character_id - ); - continue; - } - - int activity_id = character_activity.activityid; - if ((activity_id < 0) || (activity_id >= MAXACTIVITIESPERTASK)) { - LogTasks( - "[LoadClientState] Error: activity_id [{}] out of range while loading character activities from database character_id [{}]", - activity_id, - character_id - ); - - continue; - } - - ClientTaskInformation *task_info = nullptr; - if (client_task_state->m_active_task.task_id == task_id) { - task_info = &client_task_state->m_active_task; - } - - // wasn't task - if (task_info == nullptr) { - for (auto &active_quest : client_task_state->m_active_quests) { - if (active_quest.task_id == task_id) { - task_info = &active_quest; - } - } - } - - if (task_info == nullptr) { - LogTasks( - "[LoadClientState] Error: activity_id [{}] found for task_id [{}] which client does not have character_id [{}]", - activity_id, - task_id, - character_id - ); - - continue; - } - - task_info->activity[activity_id].activity_id = activity_id; - task_info->activity[activity_id].done_count = character_activity.donecount; - if (character_activity.completed) { - task_info->activity[activity_id].activity_state = ActivityCompleted; - } - else { - task_info->activity[activity_id].activity_state = ActivityHidden; - } - - task_info->activity[activity_id].updated = false; - - LogTasks( - "[LoadClientState] character_id [{}] task_id [{}] activity_id [{}] done_count [{}] completed [{}]", - character_id, - task_id, - activity_id, - character_activity.donecount, - character_activity.completed - ); - } - - if (RuleB(TaskSystem, RecordCompletedTasks)) { - CompletedTaskInformation completed_task_information{}; - - for (bool &i : completed_task_information.activity_done) { - i = false; - } - - int previous_task_id = -1; - int previous_completed_time = -1; - - auto character_completed_tasks = CompletedTasksRepository::GetWhere( - database, - fmt::format("charid = {} ORDER BY completedtime, taskid, activityid", character_id) - ); - - for (auto &character_completed_task: character_completed_tasks) { - int task_id = character_completed_task.taskid; - if ((task_id <= 0) || (task_id >= MAXTASKS)) { - LogError("[TASKS]Task ID [{}] out of range while loading completed tasks from database", task_id); - continue; - } - - // An activity_id of -1 means mark all the none optional activities in the - // task as complete. If the Rule to record optional activities is enabled, - // subsequent records for this task will flag any optional tasks that were - // completed. - int activity_id = character_completed_task.activityid; - if ((activity_id < -1) || (activity_id >= MAXACTIVITIESPERTASK)) { - LogError("[TASKS]activity_information ID [{}] out of range while loading completed tasks from database", - activity_id); - continue; - } - - int completed_time = character_completed_task.completedtime; - if ((previous_task_id != -1) && - ((task_id != previous_task_id) || (completed_time != previous_completed_time))) { - client_task_state->m_completed_tasks.push_back(completed_task_information); - for (bool &activity_done : completed_task_information.activity_done) { - activity_done = false; - } - } - - completed_task_information.task_id = previous_task_id = task_id; - completed_task_information.completed_time = previous_completed_time = completed_time; - - // If activity_id is -1, Mark all the non-optional tasks as completed. - if (activity_id < 0) { - TaskInformation *task = m_task_data[task_id]; - if (task == nullptr) { - continue; - } - - for (int i = 0; i < task->activity_count; i++) { - if (!task->activity_information[i].optional) { - completed_task_information.activity_done[i] = true; - } - } - } - else { - completed_task_information.activity_done[activity_id] = true; - } - } - - if (previous_task_id != -1) { - client_task_state->m_completed_tasks.push_back(completed_task_information); - } - - client_task_state->m_last_completed_task_loaded = client_task_state->m_completed_tasks.size(); - } - - std::string query = StringFormat( - "SELECT `taskid` FROM character_enabledtasks " - "WHERE `charid` = %i AND `taskid` >0 AND `taskid` < %i " - "ORDER BY `taskid` ASC", - character_id, MAXTASKS - ); - - auto results = database.QueryDatabase(query); - if (results.Success()) { - for (auto row = results.begin(); row != results.end(); ++row) { - int task_id = atoi(row[0]); - client_task_state->m_enabled_tasks.push_back(task_id); - LogTasksDetail("[LoadClientState] Adding task_id [{}] to enabled tasks", task_id); - } - } - - // Check that there is an entry in the client task state for every activity_information in each task - // This should only break if a ServerOP adds or deletes activites for a task that players already - // have active, or due to a bug. - for (int task_index = 0; task_index < MAXACTIVEQUESTS + 1; task_index++) { - int task_id = client_task_state->m_active_tasks[task_index].task_id; - if (task_id == TASKSLOTEMPTY) { - continue; - } - if (!m_task_data[task_id]) { - client->Message( - Chat::Red, - "Active Task Slot %i, references a task (%i), that does not exist. " - "Removing from memory. Contact a GM to resolve this.", - task_index, - task_id - ); - - LogError("[LoadClientState] Character [{}] has task [{}] which does not exist", character_id, task_id); - client_task_state->m_active_tasks[task_index].task_id = TASKSLOTEMPTY; - continue; - } - for (int activity_index = 0; activity_index < m_task_data[task_id]->activity_count; activity_index++) { - if (client_task_state->m_active_tasks[task_index].activity[activity_index].activity_id != activity_index) { - client->Message( - Chat::Red, - "Active Task %i, %s. activity_information count does not match expected value." - "Removing from memory. Contact a GM to resolve this.", - task_id, m_task_data[task_id]->title.c_str() - ); - - LogTasks( - "[LoadClientState] Fatal error in character [{}] task state. activity_information [{}] for Task [{}] either missing from client state or from task", - character_id, - activity_index, - task_id - ); - client_task_state->m_active_tasks[task_index].task_id = TASKSLOTEMPTY; - break; - } - } - } - - if (client_task_state->m_active_task.task_id != TASKSLOTEMPTY) { - client_task_state->UnlockActivities(character_id, client_task_state->m_active_task); - } - - // TODO: shared - for (auto &active_quest : client_task_state->m_active_quests) { - if (active_quest.task_id != TASKSLOTEMPTY) { - client_task_state->UnlockActivities(character_id, active_quest); - } - } - - LogTasks("[LoadClientState] for Character ID [{}] DONE!", character_id); - - return true; -} diff --git a/zone/task_manager.h b/zone/task_manager.h deleted file mode 100644 index f1fe41bd9..000000000 --- a/zone/task_manager.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef EQEMU_TASK_MANAGER_H -#define EQEMU_TASK_MANAGER_H - -#include "tasks.h" -#include "task_client_state.h" -#include "task_proximity_manager.h" -#include "task_goal_list_manager.h" -#include "../common/types.h" -#include -#include -#include -#include - -class Client; - -class Mob; - -class TaskManager { - -public: - TaskManager(); - ~TaskManager(); - int GetActivityCount(int task_id); - bool LoadTasks(int single_task = 0); - void ReloadGoalLists(); - inline void LoadProximities(int zone_id) - { - m_proximity_manager.LoadProximities(zone_id); - } - bool LoadTaskSets(); - bool LoadClientState(Client *client, ClientTaskState *client_task_state); - bool SaveClientState(Client *client, ClientTaskState *client_task_state); - void SendTaskSelector(Client *client, Mob *mob, int task_count, int *task_list); - void SendTaskSelectorNew(Client *client, Mob *mob, int task_count, int *task_list); - bool ValidateLevel(int task_id, int player_level); - std::string GetTaskName(uint32 task_id); - TaskType GetTaskType(uint32 task_id); - void TaskSetSelector(Client *client, ClientTaskState *client_task_state, Mob *mob, int task_set_id); - // task list provided by QuestManager (perl/lua) - void TaskQuestSetSelector( - Client *client, - ClientTaskState *client_task_state, - Mob *mob, - int count, - int *tasks - ); - void SendActiveTasksToClient(Client *client, bool task_complete = false); - void SendSingleActiveTaskToClient( - Client *client, - ClientTaskInformation &task_info, - bool task_complete, - bool bring_up_task_journal = false - ); - void SendTaskActivityShort(Client *client, int task_id, int activity_id, int client_task_index); - void SendTaskActivityLong( - Client *client, - int task_id, - int activity_id, - int client_task_index, - bool optional, - bool task_complete = false - ); - void SendTaskActivityNew( - Client *client, - int task_id, - int activity_id, - int client_task_index, - bool optional, - bool task_complete = false - ); - void SendCompletedTasksToClient(Client *c, ClientTaskState *client_task_state); - void ExplainTask(Client *client, int task_id); - int FirstTaskInSet(int task_set); - int LastTaskInSet(int task_set); - int NextTaskInSet(int task_set, int task_id); - bool IsTaskRepeatable(int task_id); - - friend class ClientTaskState; - - -private: - TaskGoalListManager m_goal_list_manager; - TaskProximityManager m_proximity_manager; - TaskInformation *m_task_data[MAXTASKS]{}; - std::vector m_task_sets[MAXTASKSETS]; - void SendActiveTaskDescription( - Client *client, - int task_id, - ClientTaskInformation &task_info, - int start_time, - int duration, - bool bring_up_task_journal = false - ); - -}; - - -#endif //EQEMU_TASK_MANAGER_H diff --git a/zone/task_proximity_manager.cpp b/zone/task_proximity_manager.cpp deleted file mode 100644 index ee46acbcb..000000000 --- a/zone/task_proximity_manager.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "../common/global_define.h" -#include "../common/repositories/proximities_repository.h" -#include "../common/rulesys.h" -#include "client.h" -#include "mob.h" -#include "quest_parser_collection.h" -#include "task_proximity_manager.h" -#include "tasks.h" -#include "zonedb.h" - -TaskProximityManager::TaskProximityManager() -{ - - -} - -TaskProximityManager::~TaskProximityManager() -{ - - -} - -bool TaskProximityManager::LoadProximities(int zone_id) -{ - TaskProximity proximity{}; - m_task_proximities.clear(); - - auto proximities = ProximitiesRepository::GetWhere( - content_db, - fmt::format("zoneid = {} ORDER BY `zoneid` ASC", zone_id) - ); - - for (auto &row: proximities) { - proximity.explore_id = row.exploreid; - proximity.min_x = row.minx; - proximity.max_x = row.maxx; - proximity.min_y = row.miny; - proximity.max_y = row.maxy; - proximity.min_z = row.minz; - proximity.max_z = row.maxz; - - m_task_proximities.push_back(proximity); - } - - LogTasks("Loaded [{}] Task Proximities", proximities.size()); - - return true; -} - -int TaskProximityManager::CheckProximities(float x, float y, float z) -{ - for (auto &task_proximity : m_task_proximities) { - - TaskProximity *p_proximity = &task_proximity; - - Log( - Logs::General, - Logs::Tasks, - "[Proximity] Checking %8.3f, %8.3f, %8.3f against %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f", - x, - y, - z, - p_proximity->min_x, - p_proximity->max_x, - p_proximity->min_y, - p_proximity->max_y, - p_proximity->min_z, - p_proximity->max_z - ); - - if (x < p_proximity->min_x || x > p_proximity->max_x || y < p_proximity->min_y || y > p_proximity->max_y || - z < p_proximity->min_z || z > p_proximity->max_z) { - continue; - } - - return p_proximity->explore_id; - } - - return 0; -} diff --git a/zone/task_proximity_manager.h b/zone/task_proximity_manager.h deleted file mode 100644 index a3fe44c07..000000000 --- a/zone/task_proximity_manager.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef EQEMU_TASK_PROXIMITY_MANAGER_H -#define EQEMU_TASK_PROXIMITY_MANAGER_H - -struct TaskProximity { - int explore_id; - float min_x; - float max_x; - float min_y; - float max_y; - float min_z; - float max_z; -}; - -// This class is used for managing proximities so that Quest NPC proximities don't need to be used. -class TaskProximityManager { - -public: - TaskProximityManager(); - ~TaskProximityManager(); - bool LoadProximities(int zone_id); - int CheckProximities(float x, float y, float z); - -private: - std::vector m_task_proximities; -}; - -#endif //EQEMU_TASK_PROXIMITY_MANAGER_H diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 4f240bab5..4972658df 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -1,38 +1,2483 @@ + +/* EQEMu: Everquest Server Emulator +Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + #include "../common/global_define.h" +#include "tasks.h" + +#include + +#ifdef _WINDOWS +#define strcasecmp _stricmp +#endif + #include "../common/misc_functions.h" #include "../common/rulesys.h" #include "../common/string_util.h" +#include "../common/say_link.h" +#include "zonedb.h" +#include "zone_store.h" +#include "../common/repositories/goallists_repository.h" #include "client.h" +#include "entity.h" +#include "mob.h" +#include "string_ids.h" + #include "queryserv.h" #include "quest_parser_collection.h" -#include "tasks.h" -#include "zonedb.h" -extern QueryServ *QServ; +extern QueryServ* QServ; -void Client::LoadClientTaskState() -{ - if (RuleB(TaskSystem, EnableTaskSystem) && task_manager) { - if (task_state) { - safe_delete(task_state); - } +TaskManager::TaskManager() { + for(int i=0; iLoadClientState(this, task_state)) { - safe_delete(task_state); - } - else { - task_manager->SendActiveTasksToClient(this); - task_manager->SendCompletedTasksToClient(this, task_state); +TaskManager::~TaskManager() { + for(int i=0; iCancelAllTasks(this); - safe_delete(task_state); + + // Clear all task sets in memory. Done so we can reload them on the fly if required by just calling + // this method again. + for (int i = 0; i < MAXTASKSETS; i++) + TaskSets[i].clear(); + + std::string query = StringFormat( + "SELECT `id`, `taskid` from `tasksets` " + "WHERE `id` > 0 AND `id` < %i " + "AND `taskid` >= 0 AND `taskid` < %i " + "ORDER BY `id`, `taskid` ASC", + MAXTASKSETS, MAXTASKS + ); + auto results = content_db.QueryDatabase(query); + if (!results.Success()) { + LogError("Error in TaskManager::LoadTaskSets: [{}]", results.ErrorMessage().c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + int taskSet = atoi(row[0]); + int taskID = atoi(row[1]); + + TaskSets[taskSet].push_back(taskID); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding TaskID %4i to TaskSet %4i", taskID, taskSet); + } + + return true; +} + +bool TaskManager::LoadSingleTask(int TaskID) { + + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadSingleTask(%i)", TaskID); + + if((TaskID <= 0) || (TaskID >= MAXTASKS)) return false; + + // If this task already exists in memory, free all the dynamically allocated strings. + if(Tasks[TaskID]) { + safe_delete(Tasks[TaskID]); + } + + return LoadTasks(TaskID); +} + +void TaskManager::ReloadGoalLists() { + + if(!GoalListManager.LoadLists()) + Log(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadLists failed"); +} + +bool TaskManager::LoadTasks(int singleTask) +{ + // If TaskID !=0, then just load the task specified. + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadTasks Called"); + + std::string query; + if (singleTask == 0) { + if (!GoalListManager.LoadLists()) + Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadLists failed"); + + if (!LoadTaskSets()) + Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadTaskSets failed"); + + query = StringFormat("SELECT `id`, `type`, `duration`, `duration_code`, `title`, `description`, " + "`reward`, `rewardid`, `cashreward`, `xpreward`, `rewardmethod`, `faction_reward`," + "`minlevel`, `maxlevel`, `repeatable`, `completion_emote` FROM `tasks` WHERE `id` < %i", + MAXTASKS); + } else + query = StringFormat("SELECT `id`, `type`, `duration`, `duration_code`, `title`, `description`, " + "`reward`, `rewardid`, `cashreward`, `xpreward`, `rewardmethod`, `faction_reward`," + "`minlevel`, `maxlevel`, `repeatable`, `completion_emote` FROM `tasks` WHERE `id` = %i", + singleTask); + + const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTasks: %s"; + + auto results = content_db.QueryDatabase(query); + if (!results.Success()) { + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + int taskID = atoi(row[0]); + + if ((taskID <= 0) || (taskID >= MAXTASKS)) { + // This shouldn't happen, as the SELECT is bounded by MAXTASKS + LogError("[TASKS]Task ID [{}] out of range while loading tasks from database", taskID); + continue; + } + + Tasks[taskID] = new TaskInformation; + Tasks[taskID]->type = static_cast(atoi(row[1])); + Tasks[taskID]->Duration = atoi(row[2]); + Tasks[taskID]->dur_code = static_cast(atoi(row[3])); + Tasks[taskID]->Title = row[4]; + Tasks[taskID]->Description = row[5]; + Tasks[taskID]->Reward = row[6]; + Tasks[taskID]->RewardID = atoi(row[7]); + Tasks[taskID]->CashReward = atoi(row[8]); + Tasks[taskID]->XPReward = atoi(row[9]); + Tasks[taskID]->RewardMethod = (TaskMethodType)atoi(row[10]); + Tasks[taskID]->faction_reward = atoi(row[11]); + Tasks[taskID]->MinLevel = atoi(row[12]); + Tasks[taskID]->MaxLevel = atoi(row[13]); + Tasks[taskID]->Repeatable = atoi(row[14]); + Tasks[taskID]->completion_emote = row[15]; + Tasks[taskID]->ActivityCount = 0; + Tasks[taskID]->SequenceMode = ActivitiesSequential; + Tasks[taskID]->LastStep = 0; + + Log(Logs::General, Logs::Tasks, + "[GLOBALLOAD] TaskID: %5i, Duration: %8i, Reward: %s MinLevel %i MaxLevel %i " + "Repeatable: %s", + taskID, Tasks[taskID]->Duration, Tasks[taskID]->Reward.c_str(), + Tasks[taskID]->MinLevel, Tasks[taskID]->MaxLevel, Tasks[taskID]->Repeatable ? "Yes" : "No"); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Title: %s", Tasks[taskID]->Title.c_str()); + } + + if (singleTask == 0) + query = + StringFormat("SELECT `taskid`, `step`, `activityid`, `activitytype`, `target_name`, `item_list`, " + "`skill_list`, `spell_list`, `description_override`, `goalid`, `goalmethod`, " + "`goalcount`, `delivertonpc`, `zones`, `optional` FROM `task_activities` WHERE `taskid` < " + "%i AND `activityid` < %i ORDER BY taskid, activityid ASC", + MAXTASKS, MAXACTIVITIESPERTASK); + else + query = + StringFormat("SELECT `taskid`, `step`, `activityid`, `activitytype`, `target_name`, `item_list`, " + "`skill_list`, `spell_list`, `description_override`, `goalid`, `goalmethod`, " + "`goalcount`, `delivertonpc`, `zones`, `optional` FROM `task_activities` WHERE `taskid` = " + "%i AND `activityid` < %i ORDER BY taskid, activityid ASC", + singleTask, MAXACTIVITIESPERTASK); + results = content_db.QueryDatabase(query); + if (!results.Success()) { + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + int taskID = atoi(row[0]); + int step = atoi(row[1]); + + int activityID = atoi(row[2]); + + if ((taskID <= 0) || (taskID >= MAXTASKS) || (activityID < 0) || (activityID >= MAXACTIVITIESPERTASK)) { + // This shouldn't happen, as the SELECT is bounded by MAXTASKS + LogError("[TASKS]Task or Activity ID ([{}], [{}]) out of range while loading activities from database", taskID, activityID); + continue; + } + + if (Tasks[taskID] == nullptr) { + LogError("[TASKS]Activity for non-existent task ([{}], [{}]) while loading activities from database", + taskID, activityID); + continue; + } + + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].StepNumber = step; + + if (step != 0) + Tasks[taskID]->SequenceMode = ActivitiesStepped; + + if (step > Tasks[taskID]->LastStep) + Tasks[taskID]->LastStep = step; + + // Task Activities MUST be numbered sequentially from 0. If not, log an error + // and set the task to nullptr. Subsequent activities for this task will raise + // ERR_NOTASK errors. + // Change to (activityID != (Tasks[taskID]->ActivityCount + 1)) to index from 1 + if (activityID != Tasks[taskID]->ActivityCount) { + LogError("[TASKS]Activities for Task [{}] are not sequential starting at 0. Not loading task", taskID, + activityID); + Tasks[taskID] = nullptr; + continue; + } + + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Type = atoi(row[3]); + + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].target_name = row[4]; + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].item_list = row[5]; + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].skill_list = row[6]; + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].skill_id = atoi(row[6]); // for older clients + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].spell_list = row[7]; + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].spell_id = atoi(row[7]); // for older clients + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].desc_override = row[8]; + + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalID = atoi(row[9]); + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalMethod = (TaskMethodType)atoi(row[10]); + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalCount = atoi(row[11]); + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].DeliverToNPC = atoi(row[12]); + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].zones = row[13]; + auto zones = SplitString(Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].zones, ';'); + for (auto && e : zones) + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].ZoneIDs.push_back(std::stoi(e)); + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Optional = atoi(row[14]); + + Log(Logs::General, Logs::Tasks, + "[GLOBALLOAD] Activity Slot %2i: ID %i for Task %5i. Type: %3i, GoalID: %8i, " + "GoalMethod: %i, GoalCount: %3i, Zones:%s", + Tasks[taskID]->ActivityCount, activityID, taskID, + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Type, + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalID, + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalMethod, + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalCount, + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].zones.c_str()); + + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] target_name: %s", + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].target_name.c_str()); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] item_list: %s", + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].item_list.c_str()); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] skill_list: %s", + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].skill_list.c_str()); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] spell_list: %s", + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].spell_list.c_str()); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] description_override: %s", + Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].desc_override.c_str()); + + Tasks[taskID]->ActivityCount++; + } + + return true; +} + +bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) +{ + // I am saving the slot in the ActiveTasks table, because unless a Task is cancelled/completed, the client + // doesn't seem to like tasks moving slots between zoning and you can end up with 'bogus' activities if the task + // previously in that slot had more activities than the one now occupying it. Hopefully retaining the slot + // number for the duration of a session will overcome this. + if (!c || !state) + return false; + + const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::SaveClientState %s"; + + int characterID = c->CharacterID(); + + Log(Logs::Detail, Logs::Tasks, "TaskManager::SaveClientState for character ID %d", characterID); + + if (state->ActiveTaskCount > 0 || state->ActiveTask.TaskID != TASKSLOTEMPTY) { // TODO: tasks + for (int task = 0; task < MAXACTIVEQUESTS + 1; task++) { + int taskID = state->ActiveTasks[task].TaskID; + if (taskID == TASKSLOTEMPTY) + continue; + + int slot = state->ActiveTasks[task].slot; + + if (state->ActiveTasks[task].Updated) { + + Log(Logs::General, Logs::Tasks, + "[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex " + "%i TaskID %i", + characterID, slot, taskID); + + std::string query = StringFormat( + "REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime) " + "VALUES (%i, %i, %i, %i, %i)", + characterID, taskID, slot, static_cast(Tasks[taskID]->type), + state->ActiveTasks[task].AcceptedTime); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + } else { + state->ActiveTasks[task].Updated = false; + } + } + + std::string query = + "REPLACE INTO character_activities (charid, taskid, activityid, donecount, completed) " + "VALUES "; + + int updatedActivityCount = 0; + for (int activityIndex = 0; activityIndex < Tasks[taskID]->ActivityCount; ++activityIndex) { + + if (!state->ActiveTasks[task].Activity[activityIndex].Updated) + continue; + + Log(Logs::General, Logs::Tasks, + "[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity " + "%i, %i", + characterID, slot, activityIndex); + + if (updatedActivityCount == 0) + query += + StringFormat("(%i, %i, %i, %i, %i)", characterID, taskID, activityIndex, + state->ActiveTasks[task].Activity[activityIndex].DoneCount, + state->ActiveTasks[task].Activity[activityIndex].State == + ActivityCompleted); + else + query += + StringFormat(", (%i, %i, %i, %i, %i)", characterID, taskID, activityIndex, + state->ActiveTasks[task].Activity[activityIndex].DoneCount, + state->ActiveTasks[task].Activity[activityIndex].State == + ActivityCompleted); + + updatedActivityCount++; + } + + if (updatedActivityCount == 0) + continue; + + Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] Executing query %s", query.c_str()); + auto results = database.QueryDatabase(query); + + if (!results.Success()) { + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + continue; + } + + state->ActiveTasks[task].Updated = false; + for (int activityIndex = 0; activityIndex < Tasks[taskID]->ActivityCount; ++activityIndex) + state->ActiveTasks[task].Activity[activityIndex].Updated = false; + } + } + + if (!RuleB(TaskSystem, RecordCompletedTasks) || + (state->CompletedTasks.size() <= (unsigned int)state->LastCompletedTaskLoaded)) { + state->LastCompletedTaskLoaded = state->CompletedTasks.size(); + return true; + } + + const char *completedTaskQuery = "REPLACE INTO completed_tasks (charid, completedtime, taskid, activityid) " + "VALUES (%i, %i, %i, %i)"; + + for (unsigned int i = state->LastCompletedTaskLoaded; i < state->CompletedTasks.size(); i++) { + + Log(Logs::General, Logs::Tasks, + "[CLIENTSAVE] TaskManager::SaveClientState Saving Completed Task at slot %i", i); + int taskID = state->CompletedTasks[i].TaskID; + + if ((taskID <= 0) || (taskID >= MAXTASKS) || (Tasks[taskID] == nullptr)) + continue; + + // First we save a record with an ActivityID of -1. + // This indicates this task was completed at the given time. We infer that all + // none optional activities were completed. + // + std::string query = + StringFormat(completedTaskQuery, characterID, state->CompletedTasks[i].CompletedTime, taskID, -1); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + continue; + } + + // If the Rule to record non-optional task completion is not enabled, don't save it + if (!RuleB(TaskSystem, RecordCompletedOptionalActivities)) + continue; + + // Insert one record for each completed optional task. + + for (int j = 0; j < Tasks[taskID]->ActivityCount; j++) { + if (!Tasks[taskID]->Activity[j].Optional || !state->CompletedTasks[i].ActivityDone[j]) + continue; + + query = StringFormat(completedTaskQuery, characterID, state->CompletedTasks[i].CompletedTime, + taskID, j); + results = database.QueryDatabase(query); + if (!results.Success()) + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); + } + } + + state->LastCompletedTaskLoaded = state->CompletedTasks.size(); + return true; +} + +void Client::LoadClientTaskState() { + + if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager) { + if(taskstate) + safe_delete(taskstate); + + taskstate = new ClientTaskState; + if(!taskmanager->LoadClientState(this, taskstate)) { + safe_delete(taskstate); + } + else { + taskmanager->SendActiveTasksToClient(this); + taskmanager->SendCompletedTasksToClient(this, taskstate); + } + } + +} + +void Client::RemoveClientTaskState() { + + if(taskstate) { + taskstate->CancelAllTasks(this); + safe_delete(taskstate); + } +} + +bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) +{ + if (!c || !state) + return false; + + int characterID = c->CharacterID(); + + state->ActiveTaskCount = 0; + + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState for character ID %d", characterID); + + std::string query = StringFormat("SELECT `taskid`, `slot`,`type`, `acceptedtime` " + "FROM `character_tasks` " + "WHERE `charid` = %i ORDER BY acceptedtime", + characterID); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS]Error in TaskManager::LoadClientState load Tasks: [{}]", + results.ErrorMessage().c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + int taskID = atoi(row[0]); + int slot = atoi(row[1]); + TaskType type = static_cast(atoi(row[2])); + + if ((taskID < 0) || (taskID >= MAXTASKS)) { + LogError("[TASKS]Task ID [{}] out of range while loading character tasks from database", taskID); + continue; + } + + auto task_info = state->GetClientTaskInfo(type, slot); + + if (task_info == nullptr) { + LogError("[TASKS] Slot [{}] out of range while loading character tasks from database", slot); + continue; + } + + if (task_info->TaskID != TASKSLOTEMPTY) { + LogError("[TASKS] Slot [{}] for Task [{}]s is already occupied", slot, + taskID); + continue; + } + + int acceptedtime = atoi(row[3]); + + task_info->TaskID = taskID; + task_info->CurrentStep = -1; + task_info->AcceptedTime = acceptedtime; + task_info->Updated = false; + + for (int i = 0; i < MAXACTIVITIESPERTASK; i++) + task_info->Activity[i].ActivityID = -1; + + if (type == TaskType::Quest) + ++state->ActiveTaskCount; + + Log(Logs::General, Logs::Tasks, + "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, Accepted Time: %8X", characterID, + taskID, acceptedtime); + } + + // Load Activities + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState. Loading activities for character ID %d", + characterID); + + query = StringFormat("SELECT `taskid`, `activityid`, `donecount`, `completed` " + "FROM `character_activities` " + "WHERE `charid` = %i " + "ORDER BY `taskid` ASC, `activityid` ASC", + characterID); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS]Error in TaskManager::LoadClientState load Activities: [{}]", + results.ErrorMessage().c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + int taskID = atoi(row[0]); + if ((taskID < 0) || (taskID >= MAXTASKS)) { + LogError("[TASKS]Task ID [{}] out of range while loading character activities from database", taskID); + continue; + } + + int activityID = atoi(row[1]); + if ((activityID < 0) || (activityID >= MAXACTIVITIESPERTASK)) { + LogError("[TASKS]Activity ID [{}] out of range while loading character activities from database", + activityID); + continue; + } + + ClientTaskInformation *task_info = nullptr; + + if (state->ActiveTask.TaskID == taskID) + task_info = &state->ActiveTask; + + // wasn't task + if (task_info == nullptr) + for (int i = 0; i < MAXACTIVEQUESTS; i++) + if (state->ActiveQuests[i].TaskID == taskID) + task_info = &state->ActiveQuests[i]; + + if (task_info == nullptr) { + LogError("[TASKS]Activity [{}] found for task [{}] which client does not have", activityID, taskID); + continue; + } + + int doneCount = atoi(row[2]); + bool completed = atoi(row[3]); + task_info->Activity[activityID].ActivityID = activityID; + task_info->Activity[activityID].DoneCount = doneCount; + if (completed) + task_info->Activity[activityID].State = ActivityCompleted; + else + task_info->Activity[activityID].State = ActivityHidden; + + task_info->Activity[activityID].Updated = false; + + Log(Logs::General, Logs::Tasks, + "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, ActivityID: %i, DoneCount: %i, " + "Completed: %i", + characterID, taskID, activityID, doneCount, completed); + } + + if (RuleB(TaskSystem, RecordCompletedTasks)) { + query = StringFormat("SELECT `taskid`, `activityid`, `completedtime` " + "FROM `completed_tasks` " + "WHERE `charid` = %i ORDER BY completedtime, taskid, activityid", + characterID); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS]Error in TaskManager::LoadClientState load completed tasks: [{}]", + results.ErrorMessage().c_str()); + return false; + } + + CompletedTaskInformation cti; + + for (int i = 0; i < MAXACTIVITIESPERTASK; i++) + cti.ActivityDone[i] = false; + + int previousTaskID = -1; + int previousCompletedTime = -1; + + for (auto row = results.begin(); row != results.end(); ++row) { + + int taskID = atoi(row[0]); + if ((taskID <= 0) || (taskID >= MAXTASKS)) { + LogError("[TASKS]Task ID [{}] out of range while loading completed tasks from database", + taskID); + continue; + } + + // An ActivityID of -1 means mark all the none optional activities in the + // task as complete. If the Rule to record optional activities is enabled, + // subsequent records for this task will flag any optional tasks that were + // completed. + int activityID = atoi(row[1]); + if ((activityID < -1) || (activityID >= MAXACTIVITIESPERTASK)) { + LogError("[TASKS]Activity ID [{}] out of range while loading completed tasks from database", + activityID); + continue; + } + + int completedTime = atoi(row[2]); + if ((previousTaskID != -1) && + ((taskID != previousTaskID) || (completedTime != previousCompletedTime))) { + state->CompletedTasks.push_back(cti); + for (int i = 0; i < MAXACTIVITIESPERTASK; i++) + cti.ActivityDone[i] = false; + } + + cti.TaskID = previousTaskID = taskID; + cti.CompletedTime = previousCompletedTime = completedTime; + + // If ActivityID is -1, Mark all the non-optional tasks as completed. + if (activityID < 0) { + TaskInformation *task = Tasks[taskID]; + if (task == nullptr) + continue; + + for (int i = 0; i < task->ActivityCount; i++) + if (!task->Activity[i].Optional) + cti.ActivityDone[i] = true; + } else + cti.ActivityDone[activityID] = true; + } + + if (previousTaskID != -1) + state->CompletedTasks.push_back(cti); + + state->LastCompletedTaskLoaded = state->CompletedTasks.size(); + } + + query = StringFormat("SELECT `taskid` FROM character_enabledtasks " + "WHERE `charid` = %i AND `taskid` >0 AND `taskid` < %i " + "ORDER BY `taskid` ASC", + characterID, MAXTASKS); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS]Error in TaskManager::LoadClientState load enabled tasks: [{}]", + results.ErrorMessage().c_str()); + } else { + for (auto row = results.begin(); row != results.end(); ++row) { + int taskID = atoi(row[0]); + state->EnabledTasks.push_back(taskID); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Adding TaskID %i to enabled tasks", taskID); + } + } + + // Check that there is an entry in the client task state for every activity in each task + // This should only break if a ServerOP adds or deletes activites for a task that players already + // have active, or due to a bug. + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + int taskID = state->ActiveTasks[i].TaskID; + if (taskID == TASKSLOTEMPTY) + continue; + if (!Tasks[taskID]) { + c->Message(Chat::Red, + "Active Task Slot %i, references a task (%i), that does not exist. " + "Removing from memory. Contact a GM to resolve this.", + i, taskID); + + LogError("[TASKS]Character [{}] has task [{}] which does not exist", + characterID, taskID); + state->ActiveTasks[i].TaskID = TASKSLOTEMPTY; + continue; + } + for (int j = 0; j < Tasks[taskID]->ActivityCount; j++) { + + if (state->ActiveTasks[i].Activity[j].ActivityID != j) { + c->Message(Chat::Red, + "Active Task %i, %s. Activity count does not match expected value." + "Removing from memory. Contact a GM to resolve this.", + taskID, Tasks[taskID]->Title.c_str()); + + LogError("[TASKS]Fatal error in character [{}] task state. Activity [{}] for Task [{}] either missing from client state or from task", + characterID, j, taskID); + state->ActiveTasks[i].TaskID = TASKSLOTEMPTY; + break; + } + } + } + + if (state->ActiveTask.TaskID != TASKSLOTEMPTY) + state->UnlockActivities(characterID, state->ActiveTask); + // TODO: shared + for (int i = 0; i < MAXACTIVEQUESTS; i++) + if (state->ActiveQuests[i].TaskID != TASKSLOTEMPTY) + state->UnlockActivities(characterID, state->ActiveQuests[i]); + + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState for Character ID %d DONE!", characterID); + return true; +} + +void ClientTaskState::EnableTask(int characterID, int taskCount, int *tasks) { + + // Check if the Task is already enabled for this client + // + std::vector tasksEnabled; + + for(int i=0; i tasks[i]) + break; + ++iterator; + } + + if(addTask) { + EnabledTasks.insert(iterator, tasks[i]); + // Make a note of the task we enabled, for later SQL generation + tasksEnabled.push_back(tasks[i]); + } + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] New enabled task list "); + for(unsigned int i=0; i tasksDisabled; + + for(int i=0; i taskList[i]) + break; + + ++iterator; + } + + if(removeTask) { + EnabledTasks.erase(iterator); + tasksDisabled.push_back(taskList[i]); + } + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] New enabled task list "); + for(unsigned int i=0; i::iterator Iterator; + + Iterator = EnabledTasks.begin(); + + while(Iterator != EnabledTasks.end()) { + if((*Iterator) == TaskID) return true; + if((*Iterator) > TaskID) break; + ++Iterator; + } + + return false; +} + +int ClientTaskState::EnabledTaskCount(int TaskSetID) { + + // Return the number of tasks in TaskSet that this character is enabled for. + + unsigned int EnabledTaskIndex = 0; + unsigned int TaskSetIndex = 0; + int EnabledTaskCount = 0; + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return -1; + + while((EnabledTaskIndex < EnabledTasks.size()) && (TaskSetIndex < taskmanager->TaskSets[TaskSetID].size())) { + + if(EnabledTasks[EnabledTaskIndex] == taskmanager->TaskSets[TaskSetID][TaskSetIndex]) { + + EnabledTaskCount++; + EnabledTaskIndex++; + TaskSetIndex++; + continue; + } + + if(EnabledTasks[EnabledTaskIndex] < taskmanager->TaskSets[TaskSetID][TaskSetIndex]) + EnabledTaskIndex++; + else + TaskSetIndex++; + + } + + return EnabledTaskCount; +} +int ClientTaskState::ActiveTasksInSet(int TaskSetID) { + + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return -1; + + int Count = 0; + + for(unsigned int i=0; iTaskSets[TaskSetID].size(); i++) + if(IsTaskActive(taskmanager->TaskSets[TaskSetID][i])) + Count++; + + return Count; +} + +int ClientTaskState::CompletedTasksInSet(int TaskSetID) { + + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return -1; + + int Count = 0; + + for(unsigned int i=0; iTaskSets[TaskSetID].size(); i++) + if(IsTaskCompleted(taskmanager->TaskSets[TaskSetID][i])) + Count++; + + return Count; +} + +bool ClientTaskState::HasSlotForTask(TaskInformation *task) +{ + if (task == nullptr) + return false; + + switch (task->type) { + case TaskType::Task: + return ActiveTask.TaskID == TASKSLOTEMPTY; + case TaskType::Shared: + return false; // todo + case TaskType::Quest: + for (int i = 0; i < MAXACTIVEQUESTS; ++i) + if (ActiveQuests[i].TaskID == TASKSLOTEMPTY) + return true; + case TaskType::E: + return false; // removed on live + } + + return false; +} + +int TaskManager::FirstTaskInSet(int TaskSetID) { + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0; + + if(TaskSets[TaskSetID].empty()) return 0; + + auto Iterator = TaskSets[TaskSetID].begin(); + + while(Iterator != TaskSets[TaskSetID].end()) { + if((*Iterator) > 0) + return (*Iterator); + ++Iterator; + } + + return 0; +} + +int TaskManager::LastTaskInSet(int TaskSetID) { + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0; + + if(TaskSets[TaskSetID].empty()) return 0; + + return TaskSets[TaskSetID][TaskSets[TaskSetID].size()-1]; +} + +int TaskManager::NextTaskInSet(int TaskSetID, int TaskID) { + + if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0; + + if(TaskSets[TaskSetID].empty()) return 0; + + for(unsigned int i=0; i TaskID) return TaskSets[TaskSetID][i]; + } + + return 0; +} + +bool TaskManager::AppropriateLevel(int TaskID, int PlayerLevel) { + + if(Tasks[TaskID] == nullptr) return false; + + if(Tasks[TaskID]->MinLevel && (PlayerLevel < Tasks[TaskID]->MinLevel)) return false; + + if(Tasks[TaskID]->MaxLevel && (PlayerLevel > Tasks[TaskID]->MaxLevel)) return false; + + return true; + +} + +std::string TaskManager::GetTaskName(uint32 task_id) +{ + if (task_id > 0 && task_id < MAXTASKS) { + if (Tasks[task_id] != nullptr) { + return Tasks[task_id]->Title; + } + } + + return std::string(); +} + +TaskType TaskManager::GetTaskType(uint32 task_id) +{ + if (task_id > 0 && task_id < MAXTASKS) { + if (Tasks[task_id] != nullptr) { + return Tasks[task_id]->type; + } + } + return TaskType::Task; +} + +int TaskManager::GetTaskMinLevel(int TaskID) +{ + if (Tasks[TaskID]->MinLevel) + { + return Tasks[TaskID]->MinLevel; + } + + return -1; +} + +int TaskManager::GetTaskMaxLevel(int TaskID) +{ + if (Tasks[TaskID]->MaxLevel) + { + return Tasks[TaskID]->MaxLevel; + } + + return -1; +} + +void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, int TaskSetID) +{ + int TaskList[MAXCHOOSERENTRIES]; + int TaskListIndex = 0; + int PlayerLevel = c->GetLevel(); + + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for taskset %i. EnableTaskSize is %i", + TaskSetID, state->EnabledTasks.size()); + + if (TaskSetID <= 0 || TaskSetID >= MAXTASKSETS) + return; + + if (TaskSets[TaskSetID].empty()) { + mob->SayString(c, Chat::Yellow, MAX_ACTIVE_TASKS, c->GetName()); // I think this is suppose to be yellow + return; + } + + bool all_enabled = false; + + // A TaskID of 0 in a TaskSet indicates that all Tasks in the set are enabled for all players. + if (TaskSets[TaskSetID][0] == 0) { + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSets[%i][0] == 0. All Tasks in Set enabled.", TaskSetID); + all_enabled = true; + } + + auto Iterator = TaskSets[TaskSetID].begin(); + + if (all_enabled) + ++Iterator; // skip first when all enabled since it's useless data + + while (Iterator != TaskSets[TaskSetID].end() && TaskListIndex < MAXCHOOSERENTRIES) { + auto task = *Iterator; + // verify level, we're not currently on it, repeatable status, if it's a (shared) task + // we aren't currently on another, and if it's enabled if not all_enabled + if ((all_enabled || state->IsTaskEnabled(task)) && AppropriateLevel(task, PlayerLevel) && + !state->IsTaskActive(task) && state->HasSlotForTask(Tasks[task]) && // this slot checking is a bit silly, but we allow mixing of task types ... + (IsTaskRepeatable(task) || !state->IsTaskCompleted(task))) + TaskList[TaskListIndex++] = task; + + ++Iterator; + } + + if (TaskListIndex > 0) { + SendTaskSelector(c, mob, TaskListIndex, TaskList); + } else { + mob->SayString(c, Chat::Yellow, MAX_ACTIVE_TASKS, c->GetName()); // check color, I think this might be only for (Shared) Tasks, w/e -- think should be yellow + } + + return; +} + +// unlike the non-Quest version of this function, it does not check enabled, that is assumed the responsibility of the quest to handle +// we do however still want it to check the other stuff like level, active, room, etc +void TaskManager::TaskQuestSetSelector(Client *c, ClientTaskState *state, Mob *mob, int count, int *tasks) +{ + int TaskList[MAXCHOOSERENTRIES]; + int TaskListIndex = 0; + int PlayerLevel = c->GetLevel(); + + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskQuestSetSelector called for array size %d", count); + + if (count <= 0) + return; + + for (int i = 0; i < count; ++i) { + auto task = tasks[i]; + // verify level, we're not currently on it, repeatable status, if it's a (shared) task + // we aren't currently on another, and if it's enabled if not all_enabled + if (AppropriateLevel(task, PlayerLevel) && + !state->IsTaskActive(task) && state->HasSlotForTask(Tasks[task]) && // this slot checking is a bit silly, but we allow mixing of task types ... + (IsTaskRepeatable(task) || !state->IsTaskCompleted(task))) + TaskList[TaskListIndex++] = task; + } + + if (TaskListIndex > 0) { + SendTaskSelector(c, mob, TaskListIndex, TaskList); + } else { + mob->SayString(c, Chat::Yellow, MAX_ACTIVE_TASKS, c->GetName()); // check color, I think this might be only for (Shared) Tasks, w/e -- think should be yellow + } + + return; +} + +void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *TaskList) { + + if (c->ClientVersion() >= EQ::versions::ClientVersion::RoF) + { + SendTaskSelectorNew(c, mob, TaskCount, TaskList); + return; + } + // Titanium OpCode: 0x5e7c + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); + int PlayerLevel = c->GetLevel(); + + // Check if any of the tasks exist + for (int i = 0; i < TaskCount; i++) { + if (Tasks[TaskList[i]] != nullptr) + break; + } + + int ValidTasks = 0; + + for (int i = 0; i < TaskCount; i++) { + if (!AppropriateLevel(TaskList[i], PlayerLevel)) + continue; + if (c->IsTaskActive(TaskList[i])) + continue; + if (!IsTaskRepeatable(TaskList[i]) && c->IsTaskCompleted(TaskList[i])) + continue; + + ValidTasks++; + } + + if (ValidTasks == 0) + return; + + SerializeBuffer buf(50 * ValidTasks); + + + buf.WriteUInt32(ValidTasks); + buf.WriteUInt32(2); // task type, live doesn't let you send more than one type, but we do? + buf.WriteUInt32(mob->GetID()); + + for (int i = 0; i < TaskCount; i++) { + if (!AppropriateLevel(TaskList[i], PlayerLevel)) + continue; + if (c->IsTaskActive(TaskList[i])) + continue; + if (!IsTaskRepeatable(TaskList[i]) && c->IsTaskCompleted(TaskList[i])) + continue; + + buf.WriteUInt32(TaskList[i]); // TaskID + if (c->ClientVersion() != EQ::versions::ClientVersion::Titanium) + buf.WriteFloat(1.0f); // affects color, difficulty? + buf.WriteUInt32(Tasks[TaskList[i]]->Duration); + buf.WriteUInt32(static_cast(Tasks[TaskList[i]]->dur_code)); + + buf.WriteString(Tasks[TaskList[i]]->Title); // max 64 with null + buf.WriteString(Tasks[TaskList[i]]->Description); // max 4000 with null + + if (c->ClientVersion() != EQ::versions::ClientVersion::Titanium) + buf.WriteUInt8(0); // Has reward set flag + + buf.WriteUInt32(Tasks[TaskList[i]]->ActivityCount); + + for (int j = 0; j < Tasks[TaskList[i]]->ActivityCount; ++j) { + buf.WriteUInt32(j); // ActivityNumber + auto &activity = Tasks[TaskList[i]]->Activity[j]; + buf.WriteUInt32(activity.Type); + buf.WriteUInt32(0); // solo, group, raid? + buf.WriteString(activity.target_name); // max length 64, "target name" so like loot x foo from bar (this is bar) + + buf.WriteString(activity.item_list); // max length 64 in these clients + + buf.WriteUInt32(activity.GoalCount); + + buf.WriteInt32(activity.skill_id); + buf.WriteInt32(activity.spell_id); + buf.WriteInt32(activity.ZoneIDs.empty() ? 0 : activity.ZoneIDs.front()); + buf.WriteString(activity.desc_override); + } + } + + auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf); + + c->QueuePacket(outapp); + safe_delete(outapp); + +} + +void TaskManager::SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *TaskList) +{ + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); + + int PlayerLevel = c->GetLevel(); + + // Check if any of the tasks exist + for (int i = 0; i < TaskCount; i++) + if (Tasks[TaskList[i]] != nullptr) + break; + + int ValidTasks = 0; + + for (int i = 0; i < TaskCount; i++) { + if (!AppropriateLevel(TaskList[i], PlayerLevel)) + continue; + if (c->IsTaskActive(TaskList[i])) + continue; + if (!IsTaskRepeatable(TaskList[i]) && c->IsTaskCompleted(TaskList[i])) + continue; + + ValidTasks++; + } + + if (ValidTasks == 0) + return; + + SerializeBuffer buf(50 * ValidTasks); + + buf.WriteUInt32(ValidTasks); // TaskCount + buf.WriteUInt32(2); // Type, valid values: 0-3. 0 = Task, 1 = Shared Task, 2 = Quest, 3 = ??? -- should fix maybe some day, but we let more than 1 type through :P + // so I guess an NPC can only offer one type of quests or we can only open a selection with one type :P (so quest call can tell us I guess) + // this is also sent in OP_TaskDescription + buf.WriteUInt32(mob->GetID()); // TaskGiver + + for (int i = 0; i < TaskCount; i++) { // max 40 + if (!AppropriateLevel(TaskList[i], PlayerLevel)) + continue; + if (c->IsTaskActive(TaskList[i])) + continue; + if (!IsTaskRepeatable(TaskList[i]) && c->IsTaskCompleted(TaskList[i])) + continue; + + buf.WriteUInt32(TaskList[i]); // TaskID + buf.WriteFloat(1.0f); // affects color, difficulty? + buf.WriteUInt32(Tasks[TaskList[i]]->Duration); + buf.WriteUInt32(static_cast(Tasks[TaskList[i]]->dur_code)); // 1 = Short, 2 = Medium, 3 = Long, anything else Unlimited + + buf.WriteString(Tasks[TaskList[i]]->Title); // max 64 with null + buf.WriteString(Tasks[TaskList[i]]->Description); // max 4000 with null + + buf.WriteUInt8(0); // Has reward set flag + buf.WriteUInt32(Tasks[TaskList[i]]->ActivityCount); // ActivityCount + + for (int j = 0; j < Tasks[TaskList[i]]->ActivityCount; ++j) { + buf.WriteUInt32(j); // ActivityNumber + auto &activity = Tasks[TaskList[i]]->Activity[j]; + buf.WriteUInt32(activity.Type); // ActivityType + buf.WriteUInt32(0); // solo, group, raid? + buf.WriteString(activity.target_name); // max length 64, "target name" so like loot x foo from bar (this is bar) + + // this string is item names + buf.WriteLengthString(activity.item_list); + + buf.WriteUInt32(activity.GoalCount); // GoalCount + + // this string is skill IDs? probably one of the "use on" tasks + buf.WriteLengthString(activity.skill_list); + + // this string is spell IDs? probably one of the "use on" tasks + buf.WriteLengthString(activity.spell_list); + + //buf.WriteString(itoa(Tasks[TaskList[i]]->Activity[ActivityID].ZoneID)); + buf.WriteString(activity.zones); // Zone number in ascii max length 64, can be multiple with separated by ; + buf.WriteString(activity.desc_override); // max length 128 -- overrides the automatic descriptions + // this doesn't appear to be shown to the client at all and isn't the same as zones ... defaults to '0' though + buf.WriteString(activity.zones); // Zone number in ascii max length 64, probably can be separated by ; too, haven't found it used + } + } + + auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf); + + c->QueuePacket(outapp); + safe_delete(outapp); + +} + +int TaskManager::GetActivityCount(int TaskID) { + + // Return the total number of activities in a particular task. + + if((TaskID>0) && (TaskIDActivityCount; + + return 0; + +} + +void TaskManager::ExplainTask(Client*c, int TaskID) { + + // TODO: This method is not finished (hardly started). It was intended to + // explain in English, what each activity did, conditions for step unlocking, etc. + // + return; + + if(!c) return; + + if((TaskID<=0) || (TaskID>=MAXTASKS)) { + c->Message(Chat::White, "TaskID out-of-range."); + return; + } + + if(Tasks[TaskID] == nullptr) { + c->Message(Chat::White, "Task does not exist."); + return; + } + + char Explanation[1000], *ptr; + c->Message(Chat::White, "Task %4i: Title: %s", TaskID, Tasks[TaskID]->Description.c_str()); + c->Message(Chat::White, "%3i Activities", Tasks[TaskID]->ActivityCount); + ptr = Explanation; + for(int i=0; iActivityCount; i++) { + + sprintf(ptr, "Act: %3i: ", i); ptr = ptr + strlen(ptr); + switch(Tasks[TaskID]->Activity[i].Type) { + case ActivityDeliver: + sprintf(ptr, "Deliver"); + break; + } + + } +} + +ClientTaskState::ClientTaskState() { + + ActiveTaskCount = 0; + LastCompletedTaskLoaded = 0; + CheckedTouchActivities = false; + + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + ActiveQuests[i].slot = i; + ActiveQuests[i].TaskID = TASKSLOTEMPTY; + } + + ActiveTask.slot = 0; + ActiveTask.TaskID = TASKSLOTEMPTY; + // TODO: shared task +} + +ClientTaskState::~ClientTaskState() { +} + + +int ClientTaskState::GetActiveTaskID(int index) { + + // Return the TaskID from the client's specified Active Task slot. + + if((index<0) || (index>=MAXACTIVEQUESTS)) return 0; + + return ActiveQuests[index].TaskID; +} + +static void DeleteCompletedTaskFromDatabase(int charID, int taskID) { + + Log(Logs::General, Logs::Tasks, "[UPDATE] DeleteCompletedTasksFromDatabase. CharID = %i, TaskID = %i", charID, taskID); + + const std::string query = StringFormat("DELETE FROM completed_tasks WHERE charid=%i AND taskid = %i", charID, taskID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + return; + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] Delete query %s", query.c_str()); +} + +bool ClientTaskState::UnlockActivities(int CharID, ClientTaskInformation &task_info) +{ + bool AllActivitiesComplete = true; + + TaskInformation* Task = taskmanager->Tasks[task_info.TaskID]; + + if (Task == nullptr) + return true; + + // On loading the client state, all activities that are not completed, are + // marked as hidden. For Sequential (non-stepped) mode, we mark the first + // activity as active if not complete. + Log(Logs::General, Logs::Tasks, "[UPDATE] CharID: %i Task: %i Sequence mode is %i", + CharID, task_info.TaskID, Task->SequenceMode); + + if (Task->SequenceMode == ActivitiesSequential) { + if (task_info.Activity[0].State != ActivityCompleted) + task_info.Activity[0].State = ActivityActive; + + // Enable the next Hidden task. + for (int i = 0; i < Task->ActivityCount; i++) { + if ((task_info.Activity[i].State == ActivityActive) && + (!Task->Activity[i].Optional)) { + AllActivitiesComplete = false; + break; + } + + if (task_info.Activity[i].State == ActivityHidden) { + task_info.Activity[i].State = ActivityActive; + AllActivitiesComplete = false; + break; + } + } + + if (AllActivitiesComplete && RuleB(TaskSystem, RecordCompletedTasks)) { + if (RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { + Log(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); + auto Iterator = CompletedTasks.begin(); + int ErasedElements = 0; + while (Iterator != CompletedTasks.end()) { + int TaskID = (*Iterator).TaskID; + if (TaskID == task_info.TaskID) { + Iterator = CompletedTasks.erase(Iterator); + ErasedElements++; + } else + ++Iterator; + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); + + if (ErasedElements) { + LastCompletedTaskLoaded -= ErasedElements; + DeleteCompletedTaskFromDatabase(CharID, task_info.TaskID); + } + } + + CompletedTaskInformation cti; + cti.TaskID = task_info.TaskID; + cti.CompletedTime = time(nullptr); + + for (int i = 0; i < Task->ActivityCount; i++) + cti.ActivityDone[i] = (task_info.Activity[i].State == ActivityCompleted); + + CompletedTasks.push_back(cti); + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] Returning sequential task, AllActivitiesComplete is %i", + AllActivitiesComplete); + + return AllActivitiesComplete; + } + + // Stepped Mode + // TODO: This code is probably more complex than it needs to be + + bool CurrentStepComplete = true; + + Log(Logs::General, Logs::Tasks, "[UPDATE] Current Step is %i, Last Step is %i", task_info.CurrentStep, + Task->LastStep); + // If CurrentStep is -1, this is the first call to this method since loading the + // client state. Unlock all activities with a step number of 0 + + if (task_info.CurrentStep == -1) { + for (int i = 0; i < Task->ActivityCount; i++) { + if (Task->Activity[i].StepNumber == 0 && task_info.Activity[i].State == ActivityHidden) { + task_info.Activity[i].State = ActivityActive; + // task_info.Activity[i].Updated=true; + } + } + task_info.CurrentStep = 0; + } + + for (int Step = task_info.CurrentStep; Step <= Task->LastStep; Step++) { + for (int Activity = 0; Activity < Task->ActivityCount; Activity++) { + if (Task->Activity[Activity].StepNumber == (int)task_info.CurrentStep) { + if ((task_info.Activity[Activity].State != ActivityCompleted) && + (!Task->Activity[Activity].Optional)) { + CurrentStepComplete = false; + AllActivitiesComplete = false; + break; + } + } + } + if (!CurrentStepComplete) + break; + task_info.CurrentStep++; + } + + if (AllActivitiesComplete) { + if (RuleB(TaskSystem, RecordCompletedTasks)) { + // If we are only keeping one completed record per task, and the player has done + // the same task again, erase the previous completed entry for this task. + if (RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { + Log(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); + auto Iterator = CompletedTasks.begin(); + int ErasedElements = 0; + + while (Iterator != CompletedTasks.end()) { + int TaskID = (*Iterator).TaskID; + if (TaskID == task_info.TaskID) { + Iterator = CompletedTasks.erase(Iterator); + ErasedElements++; + } else + ++Iterator; + } + + Log(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); + + if (ErasedElements) { + LastCompletedTaskLoaded -= ErasedElements; + DeleteCompletedTaskFromDatabase(CharID, task_info.TaskID); + } + } + + CompletedTaskInformation cti; + cti.TaskID = task_info.TaskID; + cti.CompletedTime = time(nullptr); + + for (int i = 0; i < Task->ActivityCount; i++) + cti.ActivityDone[i] = (task_info.Activity[i].State == ActivityCompleted); + + CompletedTasks.push_back(cti); + } + return true; + } + + // Mark all non-completed tasks in the current step as active + // + for (int Activity = 0; Activity < Task->ActivityCount; Activity++) { + if ((Task->Activity[Activity].StepNumber == (int)task_info.CurrentStep) && + (task_info.Activity[Activity].State == ActivityHidden)) { + task_info.Activity[Activity].State = ActivityActive; + task_info.Activity[Activity].Updated = true; + } + } + + return false; +} + +void ClientTaskState::UpdateTasksOnKill(Client *c, int NPCTypeID) { + + UpdateTasksByNPC(c, ActivityKill, NPCTypeID); + +} + +bool ClientTaskState::UpdateTasksOnSpeakWith(Client *c, int NPCTypeID) { + + return UpdateTasksByNPC(c, ActivitySpeakWith, NPCTypeID); + +} + +bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeID) { + + int Ret = false; + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasks for NPCTypeID: %d", NPCTypeID); + + // If the client has no tasks, there is nothing further to check. + + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return false; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + // Check if there are any active kill activities for this task + + auto Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + return false; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + // We are only interested in Kill activities + if (Task->Activity[j].Type != ActivityType) + continue; + // Is there a zone restriction on the activity ? + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) { + Log(Logs::General, Logs::Tasks, + "[UPDATE] Char: %s Task: %i, Activity %i, Activity type %i for NPC %i failed zone " + "check", + c->GetName(), cur_task->TaskID, j, ActivityType, NPCTypeID); + continue; + } + // Is the activity to kill this type of NPC ? + switch (Task->Activity[j].GoalMethod) { + + case METHODSINGLEID: + if (Task->Activity[j].GoalID != NPCTypeID) + continue; + break; + + case METHODLIST: + if (!taskmanager->GoalListManager.IsInList(Task->Activity[j].GoalID, NPCTypeID)) + continue; + break; + + default: + // If METHODQUEST, don't update the activity here + continue; + } + // We found an active task to kill this type of NPC, so increment the done count + Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ByNPC"); + IncrementDoneCount(c, Task, cur_task->slot, j); + Ret = true; + } + } + + return Ret; +} + +int ClientTaskState::ActiveSpeakTask(int NPCTypeID) { + + // This method is to be used from Perl quests only and returns the TaskID of the first + // active task found which has an active SpeakWith activity for this NPC. + + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return 0; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + TaskInformation* Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + continue; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + if (Task->Activity[j].Type != ActivitySpeakWith) + continue; + // Is there a zone restriction on the activity ? + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) + continue; + // Is the activity to speak with this type of NPC ? + if (Task->Activity[j].GoalMethod == METHODQUEST && Task->Activity[j].GoalID == NPCTypeID) + return cur_task->TaskID; + } + } + return 0; +} + +int ClientTaskState::ActiveSpeakActivity(int NPCTypeID, int TaskID) { + + // This method is to be used from Perl quests only and returns the ActivityID of the first + // active activity found in the specified task which is to SpeakWith this NPC. + + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return -1; + if (TaskID <= 0 || TaskID >= MAXTASKS) + return -1; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID != TaskID) + continue; + + TaskInformation* Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + continue; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + if (Task->Activity[j].Type != ActivitySpeakWith) + continue; + // Is there a zone restriction on the activity ? + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) + continue; + // Is the activity to speak with this type of NPC ? + if (Task->Activity[j].GoalMethod == METHODQUEST && Task->Activity[j].GoalID == NPCTypeID) + return j; + } + return 0; + } + return 0; +} + +void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemID, int Count) { + + // This method updates the client's task activities of the specified type which relate + // to the specified item. + // + // Type should be one of ActivityLoot, ActivityTradeSkill, ActivityFish or ActivityForage + + // If the client has no tasks, there is nothing further to check. + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksForItem(%d,%d)", Type, ItemID); + + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + // Check if there are any active loot activities for this task + + TaskInformation* Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + return; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + // We are only interested in the ActivityType we were called with + if (Task->Activity[j].Type != (int)Type) + continue; + // Is there a zone restriction on the activity ? + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Activity type %i for Item %i failed zone check", + c->GetName(), Type, ItemID); + continue; + } + // Is the activity related to this item ? + // + switch(Task->Activity[j].GoalMethod) { + + case METHODSINGLEID: + if(Task->Activity[j].GoalID != ItemID) continue; + break; + + case METHODLIST: + if(!taskmanager->GoalListManager.IsInList(Task->Activity[j].GoalID, ItemID)) continue; + break; + + default: + // If METHODQUEST, don't update the activity here + continue; + } + // We found an active task related to this item, so increment the done count + Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ForItem"); + IncrementDoneCount(c, Task, cur_task->slot, j, Count); + } + } + + return; +} + +void ClientTaskState::UpdateTasksOnExplore(Client *c, int ExploreID) +{ + + // If the client has no tasks, there is nothing further to check. + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnExplore(%i)", ExploreID); + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + // Check if there are any active explore activities for this task + + TaskInformation *Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + return; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + // We are only interested in explore activities + if (Task->Activity[j].Type != ActivityExplore) + continue; + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) { + Log(Logs::General, Logs::Tasks, + "[UPDATE] Char: %s Explore exploreid %i failed zone check", c->GetName(), + ExploreID); + continue; + } + // Is the activity to explore this area id ? + switch (Task->Activity[j].GoalMethod) { + + case METHODSINGLEID: + if (Task->Activity[j].GoalID != ExploreID) + continue; + break; + + case METHODLIST: + if (!taskmanager->GoalListManager.IsInList(Task->Activity[j].GoalID, ExploreID)) + continue; + break; + + default: + // If METHODQUEST, don't update the activity here + continue; + } + // We found an active task to explore this area, so set done count to goal count + // (Only a goal count of 1 makes sense for explore activities?) + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on explore"); + IncrementDoneCount(c, Task, cur_task->slot, j, + Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount); + } + } + + return; +} + +bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::list &Items, int Cash, int NPCTypeID) +{ + bool Ret = false; + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksForOnDeliver(%d)", NPCTypeID); + + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return false; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + // Check if there are any active deliver activities for this task + + TaskInformation *Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + return false; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + // We are only interested in Deliver activities + if (Task->Activity[j].Type != ActivityDeliver && Task->Activity[j].Type != ActivityGiveCash) + continue; + // Is there a zone restriction on the activity ? + if (!Task->Activity[j].CheckZone(zone->GetZoneID())) { + Log(Logs::General, Logs::Tasks, + "[UPDATE] Char: %s Deliver activity failed zone check (current zone %i, need zone " + "%s", + c->GetName(), zone->GetZoneID(), Task->Activity[j].zones.c_str()); + continue; + } + // Is the activity to deliver to this NPCTypeID ? + if (Task->Activity[j].DeliverToNPC != NPCTypeID) + continue; + // Is the activity related to these items ? + // + if ((Task->Activity[j].Type == ActivityGiveCash) && Cash) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveCash"); + IncrementDoneCount(c, Task, i, j, Cash); + Ret = true; + } else { + for (auto &k : Items) { + switch (Task->Activity[j].GoalMethod) { + + case METHODSINGLEID: + if (Task->Activity[j].GoalID != k->GetID()) + continue; + break; + + case METHODLIST: + if (!taskmanager->GoalListManager.IsInList(Task->Activity[j].GoalID, + k->GetID())) + continue; + break; + + default: + // If METHODQUEST, don't update the activity here + continue; + } + // We found an active task related to this item, so increment the done count + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveItem"); + IncrementDoneCount(c, Task, cur_task->slot, j, k->GetCharges() <= 0 ? 1 : k->GetCharges()); + Ret = true; + } + } + } + } + + return Ret; +} + +void ClientTaskState::UpdateTasksOnTouch(Client *c, int ZoneID) +{ + // If the client has no tasks, there is nothing further to check. + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnTouch(%i)", ZoneID); + if (!taskmanager || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) // could be better ... + return; + + // loop over the union of tasks and quests + for (int i = 0; i < MAXACTIVEQUESTS + 1; i++) { + auto cur_task = &ActiveTasks[i]; + if (cur_task->TaskID == TASKSLOTEMPTY) + continue; + + // Check if there are any active explore activities for this task + + TaskInformation *Task = taskmanager->Tasks[cur_task->TaskID]; + + if (Task == nullptr) + return; + + for (int j = 0; j < Task->ActivityCount; j++) { + // We are not interested in completed or hidden activities + if (cur_task->Activity[j].State != ActivityActive) + continue; + // We are only interested in touch activities + if (Task->Activity[j].Type != ActivityTouch) + continue; + if (Task->Activity[j].GoalMethod != METHODSINGLEID) + continue; + if (!Task->Activity[j].CheckZone(ZoneID)) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Touch activity failed zone check", + c->GetName()); + continue; + } + // We found an active task to zone into this zone, so set done count to goal count + // (Only a goal count of 1 makes sense for touch activities?) + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on Touch"); + IncrementDoneCount(c, Task, cur_task->slot, j, + Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount); + } + } + + return; +} + +void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation *Task, int TaskIndex, int ActivityID, int Count, + bool ignore_quest_update) +{ + Log(Logs::General, Logs::Tasks, "[UPDATE] IncrementDoneCount"); + + auto info = GetClientTaskInfo(Task->type, TaskIndex); + + if (info == nullptr) + return; + + info->Activity[ActivityID].DoneCount += Count; + + if(info->Activity[ActivityID].DoneCount > Task->Activity[ActivityID].GoalCount) + info->Activity[ActivityID].DoneCount = Task->Activity[ActivityID].GoalCount; + + if (!ignore_quest_update){ + char buf[24]; + snprintf(buf, 23, "%d %d %d", info->Activity[ActivityID].DoneCount, info->Activity[ActivityID].ActivityID, info->TaskID); + buf[23] = '\0'; + parse->EventPlayer(EVENT_TASK_UPDATE, c, buf, 0); + } + + info->Activity[ActivityID].Updated=true; + // Have we reached the goal count for this activity ? + if(info->Activity[ActivityID].DoneCount >= Task->Activity[ActivityID].GoalCount) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Done (%i) = Goal (%i) for Activity %i", + info->Activity[ActivityID].DoneCount, + Task->Activity[ActivityID].GoalCount, + ActivityID); + + // Flag the activity as complete + info->Activity[ActivityID].State = ActivityCompleted; + // Unlock subsequent activities for this task + bool TaskComplete = UnlockActivities(c->CharacterID(), *info); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskCompleted is %i", TaskComplete); + // and by the 'Task Stage Completed' message + c->SendTaskActivityComplete(info->TaskID, ActivityID, TaskIndex, Task->type); + // Send the updated task/activity list to the client + taskmanager->SendSingleActiveTaskToClient(c, *info, TaskComplete, false); + // Inform the client the task has been updated, both by a chat message + c->Message(Chat::White, "Your task '%s' has been updated.", Task->Title.c_str()); + + if(Task->Activity[ActivityID].GoalMethod != METHODQUEST) { + if (!ignore_quest_update){ + char buf[24]; + snprintf(buf, 23, "%d %d", info->TaskID, info->Activity[ActivityID].ActivityID); + buf[23] = '\0'; + parse->EventPlayer(EVENT_TASK_STAGE_COMPLETE, c, buf, 0); + } + /* QS: PlayerLogTaskUpdates :: Update */ + if (RuleB(QueryServ, PlayerLogTaskUpdates)){ + std::string event_desc = StringFormat("Task Stage Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", info->TaskID, info->Activity[ActivityID].ActivityID, info->Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc); + } + } + + // If this task is now complete, the Completed tasks will have been + // updated in UnlockActivities. Send the completed task list to the + // client. This is the same sequence the packets are sent on live. + if(TaskComplete) { + char buf[24]; + snprintf(buf, 23, "%d %d %d", info->Activity[ActivityID].DoneCount, info->Activity[ActivityID].ActivityID, info->TaskID); + buf[23] = '\0'; + parse->EventPlayer(EVENT_TASK_COMPLETE, c, buf, 0); + + /* QS: PlayerLogTaskUpdates :: Complete */ + if (RuleB(QueryServ, PlayerLogTaskUpdates)){ + std::string event_desc = StringFormat("Task Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", info->TaskID, info->Activity[ActivityID].ActivityID, info->Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc); + } + + taskmanager->SendCompletedTasksToClient(c, this); + c->SendTaskActivityComplete(info->TaskID, 0, TaskIndex, Task->type, 0); + taskmanager->SaveClientState(c, this); + //c->SendTaskComplete(TaskIndex); + c->CancelTask(TaskIndex, Task->type); + //if(Task->RewardMethod != METHODQUEST) RewardTask(c, Task); + // If Experience and/or cash rewards are set, reward them from the task even if RewardMethod is METHODQUEST + RewardTask(c, Task); + //RemoveTask(c, TaskIndex); + + } + + } else { + // Send an update packet for this single activity + taskmanager->SendTaskActivityLong(c, info->TaskID, ActivityID, TaskIndex, + Task->Activity[ActivityID].Optional); + taskmanager->SaveClientState(c, this); + } +} + +void ClientTaskState::RewardTask(Client *c, TaskInformation *Task) { + + if(!Task || !c) return; + + const EQ::ItemData* Item; + std::vector RewardList; + + switch(Task->RewardMethod) { + + case METHODSINGLEID: + { + if(Task->RewardID) { + c->SummonItem(Task->RewardID); + Item = database.GetItem(Task->RewardID); + if(Item) + c->Message(Chat::Yellow, "You receive %s as a reward.", Item->Name); + } + break; + } + case METHODLIST: + { + RewardList = taskmanager->GoalListManager.GetListContents(Task->RewardID); + for(unsigned int i=0; iSummonItem(RewardList[i]); + Item = database.GetItem(RewardList[i]); + if(Item) + c->Message(Chat::Yellow, "You receive %s as a reward.", Item->Name); + } + break; + } + default: + { + // Nothing special done for METHODQUEST + break; + } + } + + if (!Task->completion_emote.empty()) + c->SendColoredText(Chat::Yellow, Task->completion_emote); // unsure if they use this packet or color, should work + + // just use normal NPC faction ID stuff + if (Task->faction_reward) + c->SetFactionLevel(c->CharacterID(), Task->faction_reward, c->GetBaseClass(), c->GetBaseRace(), c->GetDeity()); + + if(Task->CashReward) { + int Plat, Gold, Silver, Copper; + + Copper = Task->CashReward; + c->AddMoneyToPP(Copper, true); + + Plat = Copper / 1000; + Copper = Copper - (Plat * 1000); + Gold = Copper / 100; + Copper = Copper - (Gold * 100); + Silver = Copper / 10; + Copper = Copper - (Silver * 10); + + std::string CashMessage; + + if (Plat>0){ + CashMessage = "You receive "; + CashMessage += itoa(Plat); + CashMessage += " platinum"; + } + if (Gold>0){ + if (CashMessage.length()==0){ + CashMessage = "You receive "; + } + else{ + CashMessage += ","; + } + CashMessage += itoa(Gold); + CashMessage += " gold"; + } + if(Silver>0){ + if (CashMessage.length()==0){ + CashMessage = "You receive "; + } + else{ + CashMessage += ","; + } + CashMessage += itoa(Silver); + CashMessage += " silver"; + } + if(Copper>0){ + if (CashMessage.length()==0){ + CashMessage = "You receive "; + } + else{ + CashMessage += ","; + } + CashMessage += itoa(Copper); + CashMessage += " copper"; + } + CashMessage += " pieces."; + c->Message(Chat::Yellow,CashMessage.c_str()); + } + int32 EXPReward = Task->XPReward; + if(EXPReward > 0) { + c->AddEXP(EXPReward); + } + if(EXPReward < 0) { + uint32 PosReward = EXPReward * -1; + // Minimal Level Based Exp Reward Setting is 101 (1% exp at level 1) + if (PosReward > 100 && PosReward < 25700) { + uint8 MaxLevel = PosReward / 100; + uint8 ExpPercent = PosReward - (MaxLevel * 100); + c->AddLevelBasedExp(ExpPercent, MaxLevel); + } + } + + c->SendSound(); +} + +bool ClientTaskState::IsTaskActive(int TaskID) +{ + if (ActiveTask.TaskID == TaskID) + return true; + + if (ActiveTaskCount == 0 || TaskID == 0) + return false; + + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) + return true; + } + + return false; +} + +void ClientTaskState::FailTask(Client *c, int TaskID) +{ + Log(Logs::General, Logs::Tasks, "[UPDATE] FailTask %i, ActiveTaskCount is %i", TaskID, ActiveTaskCount); + + if (ActiveTask.TaskID == TaskID) { + c->SendTaskFailed(TaskID, 0, TaskType::Task); + // Remove the task from the client + c->CancelTask(0, TaskType::Task); + return; + } + + // TODO: shared tasks + + if (ActiveTaskCount == 0) + return; + + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) { + c->SendTaskFailed(ActiveQuests[i].TaskID, i, TaskType::Quest); + // Remove the task from the client + c->CancelTask(i, TaskType::Quest); + return; + } + } +} + +// TODO: Shared tasks +bool ClientTaskState::IsTaskActivityActive(int TaskID, int ActivityID) +{ + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState IsTaskActivityActive(%i, %i).", TaskID, ActivityID); + // Quick sanity check + if (ActivityID < 0) + return false; + if (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY) + return false; + + int ActiveTaskIndex = -1; + auto type = TaskType::Task; + + if (ActiveTask.TaskID == TaskID) + ActiveTaskIndex = 0; + + if (ActiveTaskIndex == -1) { + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) { + ActiveTaskIndex = i; + type = TaskType::Quest; + break; + } + } + } + + // The client does not have this task + if (ActiveTaskIndex == -1) + return false; + + auto info = GetClientTaskInfo(type, ActiveTaskIndex); + + if (info == nullptr) + return false; + + TaskInformation *Task = taskmanager->Tasks[info->TaskID]; + + // The task is invalid + if (Task == nullptr) + return false; + + // The ActivityID is out of range + if (ActivityID >= Task->ActivityCount) + return false; + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState IsTaskActivityActive(%i, %i). State is %i ", TaskID, + ActivityID, info->Activity[ActivityID].State); + + return (info->Activity[ActivityID].State == ActivityActive); +} + +void ClientTaskState::UpdateTaskActivity(Client *c, int TaskID, int ActivityID, int Count, bool ignore_quest_update /*= false*/) +{ + + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState UpdateTaskActivity(%i, %i, %i).", TaskID, ActivityID, + Count); + + // Quick sanity check + if (ActivityID < 0 || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) + return; + + int ActiveTaskIndex = -1; + auto type = TaskType::Task; + + if (ActiveTask.TaskID == TaskID) + ActiveTaskIndex = 0; + + if (ActiveTaskIndex == -1) { + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) { + ActiveTaskIndex = i; + type = TaskType::Quest; + break; + } + } + } + + // The client does not have this task + if (ActiveTaskIndex == -1) + return; + + auto info = GetClientTaskInfo(type, ActiveTaskIndex); + + if (info == nullptr) + return; + + TaskInformation *Task = taskmanager->Tasks[info->TaskID]; + + // The task is invalid + if (Task == nullptr) + return; + + // The ActivityID is out of range + if (ActivityID >= Task->ActivityCount) + return; + + // The Activity is not currently active + if (info->Activity[ActivityID].State == ActivityHidden) + return; + + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment done count on UpdateTaskActivity %d %d", ActivityID, Count); + IncrementDoneCount(c, Task, ActiveTaskIndex, ActivityID, Count, ignore_quest_update); +} + +void ClientTaskState::ResetTaskActivity(Client *c, int TaskID, int ActivityID) +{ + Log(Logs::General, Logs::Tasks, "[RESET] ClientTaskState ResetTaskActivity(%i, %i).", TaskID, ActivityID); + + // Quick sanity check + if (ActivityID < 0 || (ActiveTaskCount == 0 && ActiveTask.TaskID == TASKSLOTEMPTY)) + return; + + int ActiveTaskIndex = -1; + auto type = TaskType::Task; + + if (ActiveTask.TaskID == TaskID) + ActiveTaskIndex = 0; + + if (ActiveTaskIndex == -1) { + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) { + ActiveTaskIndex = i; + type = TaskType::Quest; + break; + } + } + } + + // The client does not have this task + if (ActiveTaskIndex == -1) + return; + + auto info = GetClientTaskInfo(type, ActiveTaskIndex); + + if (info == nullptr) + return; + + TaskInformation *Task = taskmanager->Tasks[info->TaskID]; + + // The task is invalid + if (Task == nullptr) + return; + + // The ActivityID is out of range + if (ActivityID >= Task->ActivityCount) + return; + + // The Activity is not currently active + if (info->Activity[ActivityID].State == ActivityHidden) + return; + + Log(Logs::General, Logs::Tasks, "[RESET] Increment done count on ResetTaskActivity"); + IncrementDoneCount(c, Task, ActiveTaskIndex, ActivityID, (info->Activity[ActivityID].DoneCount * -1), false); +} + +void ClientTaskState::ShowClientTasks(Client *c) +{ + c->Message(Chat::White, "Task Information:"); + if (ActiveTask.TaskID != TASKSLOTEMPTY) { + c->Message(Chat::White, "Task: %i %s", ActiveTask.TaskID, taskmanager->Tasks[ActiveTask.TaskID]->Title.c_str()); + c->Message(Chat::White, " Description: [%s]\n", taskmanager->Tasks[ActiveTask.TaskID]->Description.c_str()); + for (int j = 0; j < taskmanager->GetActivityCount(ActiveTask.TaskID); j++) { + c->Message(Chat::White, " Activity: %2d, DoneCount: %2d, Status: %d (0=Hidden, 1=Active, 2=Complete)", + ActiveTask.Activity[j].ActivityID, ActiveTask.Activity[j].DoneCount, + ActiveTask.Activity[j].State); + } + } + + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TASKSLOTEMPTY) + continue; + + c->Message(Chat::White, "Quest: %i %s", ActiveQuests[i].TaskID, + taskmanager->Tasks[ActiveQuests[i].TaskID]->Title.c_str()); + c->Message(Chat::White, " Description: [%s]\n", taskmanager->Tasks[ActiveQuests[i].TaskID]->Description.c_str()); + for (int j = 0; j < taskmanager->GetActivityCount(ActiveQuests[i].TaskID); j++) { + c->Message(Chat::White, " Activity: %2d, DoneCount: %2d, Status: %d (0=Hidden, 1=Active, 2=Complete)", + ActiveQuests[i].Activity[j].ActivityID, ActiveQuests[i].Activity[j].DoneCount, + ActiveQuests[i].Activity[j].State); + } + } +} + +// TODO: Shared Task +int ClientTaskState::TaskTimeLeft(int TaskID) +{ + if (ActiveTask.TaskID == TaskID) { + int Now = time(nullptr); + + TaskInformation *Task = taskmanager->Tasks[TaskID]; + + if (Task == nullptr) + return -1; + + if (!Task->Duration) + return -1; + + int TimeLeft = (ActiveTask.AcceptedTime + Task->Duration - Now); + + return (TimeLeft > 0 ? TimeLeft : 0); + } + + if (ActiveTaskCount == 0) + return -1; + + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + + if (ActiveQuests[i].TaskID != TaskID) + continue; + + int Now = time(nullptr); + + TaskInformation *Task = taskmanager->Tasks[ActiveQuests[i].TaskID]; + + if (Task == nullptr) + return -1; + + if (!Task->Duration) + return -1; + + int TimeLeft = (ActiveQuests[i].AcceptedTime + Task->Duration - Now); + + // If Timeleft is negative, return 0, else return the number of seconds left + + return (TimeLeft > 0 ? TimeLeft : 0); + } + + return -1; +} + +int ClientTaskState::IsTaskCompleted(int TaskID) { + + // Returns: -1 if RecordCompletedTasks is not true + // +1 if the task has been completed + // 0 if the task has not been completed + + if(!(RuleB(TaskSystem, RecordCompletedTasks))) return -1; + + for(unsigned int i=0; i= MAXTASKS)) return false; + + TaskInformation* Task = taskmanager->Tasks[TaskID]; + + if(Task == nullptr) return false; + + return Task->Repeatable; +} + +bool ClientTaskState::TaskOutOfTime(TaskType type, int Index) +{ + // Returns true if the Task in the specified slot has a time limit that has been exceeded. + auto info = GetClientTaskInfo(type, Index); + + if (info == nullptr) + return false; + + // make sure the TaskID is at least maybe in our array + if (info->TaskID <= 0 || info->TaskID >= MAXTASKS) + return false; + + int Now = time(nullptr); + + TaskInformation *Task = taskmanager->Tasks[info->TaskID]; + + if (Task == nullptr) + return false; + + return (Task->Duration && (info->AcceptedTime + Task->Duration <= Now)); +} + +void ClientTaskState::TaskPeriodicChecks(Client *c) +{ + if (ActiveTask.TaskID != TASKSLOTEMPTY) { + if (TaskOutOfTime(TaskType::Task, 0)) { + // Send Red Task Failed Message + c->SendTaskFailed(ActiveTask.TaskID, 0, TaskType::Task); + // Remove the task from the client + c->CancelTask(0, TaskType::Task); + // It is a conscious decision to only fail one task per call to this method, + // otherwise the player will not see all the failed messages where multiple + // tasks fail at the same time. + return; + } + } + + // TODO: shared tasks -- although that will probably be manager in world checking and telling zones to fail us + + if (ActiveTaskCount == 0) + return; + + // Check for tasks that have failed because they have not been completed in the specified time + // + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TASKSLOTEMPTY) + continue; + + if (TaskOutOfTime(TaskType::Quest, i)) { + // Send Red Task Failed Message + c->SendTaskFailed(ActiveQuests[i].TaskID, i, TaskType::Quest); + // Remove the task from the client + c->CancelTask(i, TaskType::Quest); + // It is a conscious decision to only fail one task per call to this method, + // otherwise the player will not see all the failed messages where multiple + // tasks fail at the same time. + break; + } + } + + // Check for activities that require zoning into a specific zone. + // This is done in this method because it gives an extra few seconds for the client screen to display + // the zone before we send the 'Task Activity Completed' message. + // + if (!CheckedTouchActivities) { + UpdateTasksOnTouch(c, zone->GetZoneID()); + CheckedTouchActivities = true; } } @@ -48,7 +2493,7 @@ void Client::SendTaskComplete(int TaskIndex) { tcs = (TaskComplete_Struct*)outapp->pBuffer; // I have seen unknown0 as non-zero. It always seems to match the value in the first word of the - // Task activity_information Complete packet sent immediately prior to it. + // Task Activity Complete packet sent immediately prior to it. //tcs->unknown00 = 0x00000000; tcs->unknown00 = TaskIndex; // I have only seen 0x00000002 in the next field. This is a common 'unknown' value in the task packets. @@ -66,58 +2511,1093 @@ void Client::SendTaskComplete(int TaskIndex) { } #endif -void Client::SendTaskActivityComplete( - int task_id, - int activity_id, - int task_index, - TaskType task_type, - int task_incomplete -) +void ClientTaskState::SendTaskHistory(Client *c, int TaskIndex) { + + Log(Logs::General, Logs::Tasks, "[UPDATE] Task History Requested for Completed Task Index %i", TaskIndex); + + // We only sent the most recent 50 completed tasks, so we need to offset the Index the client sent to us. + + int AdjustedTaskIndex = TaskIndex; + + if(CompletedTasks.size() > 50) + AdjustedTaskIndex += (CompletedTasks.size() - 50); + + if((AdjustedTaskIndex < 0) || (AdjustedTaskIndex >= (int)CompletedTasks.size())) return; + + int TaskID = CompletedTasks[AdjustedTaskIndex].TaskID; + + if((TaskID < 0) || (TaskID > MAXTASKS)) return; + + TaskInformation* Task = taskmanager->Tasks[TaskID]; + + if(Task == nullptr) return; + + TaskHistoryReplyHeader_Struct* ths; + TaskHistoryReplyData1_Struct* thd1; + TaskHistoryReplyData2_Struct* thd2; + + char *Ptr; + + int CompletedActivityCount = 0;; + + int PacketLength = sizeof(TaskHistoryReplyHeader_Struct); + + for(int i=0; iActivityCount; i++) { + if(CompletedTasks[AdjustedTaskIndex].ActivityDone[i]) { + CompletedActivityCount++; + PacketLength = PacketLength + sizeof(TaskHistoryReplyData1_Struct) + + Task->Activity[i].target_name.size() + 1 + + Task->Activity[i].item_list.size() + 1 + + sizeof(TaskHistoryReplyData2_Struct) + + Task->Activity[i].desc_override.size() + 1; + } + } + + auto outapp = new EQApplicationPacket(OP_TaskHistoryReply, PacketLength); + + ths = (TaskHistoryReplyHeader_Struct*)outapp->pBuffer; + + // We use the TaskIndex the client sent in the request + ths->TaskID = TaskIndex; + + ths->ActivityCount = CompletedActivityCount; + + Ptr = (char *) ths + sizeof(TaskHistoryReplyHeader_Struct); + + for(int i=0; iActivityCount; i++) { + if(CompletedTasks[AdjustedTaskIndex].ActivityDone[i]) { + thd1 = (TaskHistoryReplyData1_Struct*)Ptr; + thd1->ActivityType = Task->Activity[i].Type; + Ptr = (char *)thd1 + sizeof(TaskHistoryReplyData1_Struct); + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].target_name.c_str()); + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].item_list.c_str()); + thd2 = (TaskHistoryReplyData2_Struct*)Ptr; + thd2->GoalCount = Task->Activity[i].GoalCount; + thd2->unknown04 = 0xffffffff; + thd2->unknown08 = 0xffffffff; + thd2->ZoneID = Task->Activity[i].ZoneIDs.empty() ? 0 : Task->Activity[i].ZoneIDs.front(); + thd2->unknown16 = 0x00000000; + Ptr = (char *)thd2 + sizeof(TaskHistoryReplyData2_Struct); + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].desc_override.c_str()); + } + } + + + c->QueuePacket(outapp); + safe_delete(outapp); + + + +} + +void Client::SendTaskActivityComplete(int TaskID, int ActivityID, int TaskIndex, TaskType type, int TaskIncomplete) { - TaskActivityComplete_Struct *task_activity_complete; + // 0x54eb + + TaskActivityComplete_Struct* tac; auto outapp = new EQApplicationPacket(OP_TaskActivityComplete, sizeof(TaskActivityComplete_Struct)); - task_activity_complete = (TaskActivityComplete_Struct *) outapp->pBuffer; + tac = (TaskActivityComplete_Struct*)outapp->pBuffer; + + tac->TaskIndex = TaskIndex; + tac->TaskType = static_cast(type); + tac->TaskID = TaskID; + tac->ActivityID = ActivityID; + tac->task_completed = 0x00000001; + tac->stage_complete = TaskIncomplete; - task_activity_complete->TaskIndex = task_index; - task_activity_complete->TaskType = static_cast(task_type); - task_activity_complete->TaskID = task_id; - task_activity_complete->ActivityID = activity_id; - task_activity_complete->task_completed = 0x00000001; - task_activity_complete->stage_complete = task_incomplete; QueuePacket(outapp); safe_delete(outapp); } -void Client::SendTaskFailed(int task_id, int task_index, TaskType task_type) +void Client::SendTaskFailed(int TaskID, int TaskIndex, TaskType type) { // 0x54eb char buf[24]; - snprintf(buf, 23, "%d", task_id); + snprintf(buf, 23, "%d", TaskID); buf[23] = '\0'; parse->EventPlayer(EVENT_TASK_FAIL, this, buf, 0); - TaskActivityComplete_Struct *task_activity_complete; + TaskActivityComplete_Struct* tac; auto outapp = new EQApplicationPacket(OP_TaskActivityComplete, sizeof(TaskActivityComplete_Struct)); - task_activity_complete = (TaskActivityComplete_Struct *) outapp->pBuffer; - task_activity_complete->TaskIndex = task_index; - task_activity_complete->TaskType = static_cast(task_type); - task_activity_complete->TaskID = task_id; - task_activity_complete->ActivityID = 0; - task_activity_complete->task_completed = 0; //Fail - task_activity_complete->stage_complete = 0; // 0 for task complete or failed. + tac = (TaskActivityComplete_Struct*)outapp->pBuffer; - LogTasks("[SendTaskFailed] Sending failure to client [{}]", GetCleanName()); + tac->TaskIndex = TaskIndex; + tac->TaskType = static_cast(type); + tac->TaskID = TaskID; + tac->ActivityID = 0; + tac->task_completed = 0; //Fail + tac->stage_complete = 0; // 0 for task complete or failed. + + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskFailed"); QueuePacket(outapp); safe_delete(outapp); } +void TaskManager::SendCompletedTasksToClient(Client *c, ClientTaskState *State) { + + int PacketLength = 4; + //vector::const_iterator iterator; + + // The client only display the first 50 Completed Tasks send, so send the 50 most recent + int FirstTaskToSend = 0; + int LastTaskToSend = State->CompletedTasks.size(); + + if(State->CompletedTasks.size() > 50) + FirstTaskToSend = State->CompletedTasks.size() - 50; + + Log(Logs::General, Logs::Tasks, "[UPDATE] Completed Task Count: %i, First Task to send is %i, Last is %i", + State->CompletedTasks.size(), FirstTaskToSend, LastTaskToSend); + /* + for(iterator=State->CompletedTasks.begin(); iterator!=State->CompletedTasks.end(); iterator++) { + int TaskID = (*iterator).TaskID; + if(Tasks[TaskID] == nullptr) continue; + PacketLength = PacketLength + 8 + strlen(Tasks[TaskID]->Title) + 1; + } + */ + for(int i = FirstTaskToSend; iCompletedTasks[i].TaskID; + if(Tasks[TaskID] == nullptr) continue; + PacketLength = PacketLength + 8 + Tasks[TaskID]->Title.size() + 1; + } + + auto outapp = new EQApplicationPacket(OP_CompletedTasks, PacketLength); + char *buf = (char*)outapp->pBuffer; + + //*(uint32 *)buf = State->CompletedTasks.size(); + *(uint32 *)buf = LastTaskToSend - FirstTaskToSend; + buf = buf + 4; + //for(iterator=State->CompletedTasks.begin(); iterator!=State->CompletedTasks.end(); iterator++) { + // int TaskID = (*iterator).TaskID; + for(int i = FirstTaskToSend; iCompletedTasks[i].TaskID; + if(Tasks[TaskID] == nullptr) continue; + *(uint32 *)buf = TaskID; + buf = buf + 4; + + sprintf(buf, "%s", Tasks[TaskID]->Title.c_str()); + buf = buf + strlen(buf) + 1; + //*(uint32 *)buf = (*iterator).CompletedTime; + *(uint32 *)buf = State->CompletedTasks[i].CompletedTime; + buf = buf + 4; + } + + + c->QueuePacket(outapp); + safe_delete(outapp); +} + + + +void TaskManager::SendTaskActivityShort(Client *c, int TaskID, int ActivityID, int ClientTaskIndex) +{ + // This Activity Packet is sent for activities that have not yet been unlocked and appear as ??? + // in the client. + + TaskActivityShort_Struct* tass; + + if (c->ClientVersionBit() & EQ::versions::maskRoFAndLater) + { + auto outapp = new EQApplicationPacket(OP_TaskActivity, 25); + outapp->WriteUInt32(ClientTaskIndex); + outapp->WriteUInt32(static_cast(Tasks[TaskID]->type)); + outapp->WriteUInt32(TaskID); + outapp->WriteUInt32(ActivityID); + outapp->WriteUInt32(0); + outapp->WriteUInt32(0xffffffff); + outapp->WriteUInt8(0); + c->FastQueuePacket(&outapp); + + return; + } + + auto outapp = new EQApplicationPacket(OP_TaskActivity, sizeof(TaskActivityShort_Struct)); + + tass = (TaskActivityShort_Struct*)outapp->pBuffer; + + tass->TaskSequenceNumber = ClientTaskIndex; + tass->unknown2 = static_cast(Tasks[TaskID]->type); + tass->TaskID = TaskID; + tass->ActivityID = ActivityID; + tass->unknown3 = 0x000000; + tass->ActivityType = 0xffffffff; + tass->unknown4 = 0x00000000; + + + c->QueuePacket(outapp); + safe_delete(outapp); +} + + + +void TaskManager::SendTaskActivityLong(Client *c, int TaskID, int ActivityID, int ClientTaskIndex, bool Optional, bool TaskComplete) { + + if (c->ClientVersion() >= EQ::versions::ClientVersion::RoF) + { + SendTaskActivityNew(c, TaskID, ActivityID, ClientTaskIndex, Optional, TaskComplete); + return; + } + + SerializeBuffer buf(100); + + buf.WriteUInt32(ClientTaskIndex); + buf.WriteUInt32(static_cast(Tasks[TaskID]->type)); + buf.WriteUInt32(TaskID); + buf.WriteUInt32(ActivityID); + buf.WriteUInt32(0); // unknown3 + + // We send our 'internal' types as ActivityCastOn. text3 should be set to the activity description, so it makes + // no difference to the client. All activity updates will be done based on our interal activity types. + if((Tasks[TaskID]->Activity[ActivityID].Type > 0) && Tasks[TaskID]->Activity[ActivityID].Type < 100) + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].Type); + else + buf.WriteUInt32(ActivityCastOn); // w/e! + + buf.WriteUInt32(Optional); + buf.WriteUInt32(0); // solo, group, raid + + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].target_name); // target name string + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].item_list); // item name list + + if(Tasks[TaskID]->Activity[ActivityID].Type != ActivityGiveCash) + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].GoalCount); + else + // For our internal type GiveCash, where the goal count has the amount of cash that must be given, + // we don't want the donecount and goalcount fields cluttered up with potentially large numbers, so we just + // send a goalcount of 1, and a bit further down, a donecount of 1 if the activity is complete, 0 otherwise. + // The text3 field should decribe the exact activity goal, e.g. give 3500gp to Hasten Bootstrutter. + buf.WriteUInt32(1); + + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].skill_id); + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].spell_id); + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].ZoneIDs.empty() ? 0 : Tasks[TaskID]->Activity[ActivityID].ZoneIDs.front()); + buf.WriteUInt32(0); + + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].desc_override); + + if(Tasks[TaskID]->Activity[ActivityID].Type != ActivityGiveCash) + buf.WriteUInt32(c->GetTaskActivityDoneCount(Tasks[TaskID]->type, ClientTaskIndex, ActivityID)); + else + // For internal activity types, DoneCount is either 1 if the activity is complete, 0 otherwise. + buf.WriteUInt32((c->GetTaskActivityDoneCount(Tasks[TaskID]->type, ClientTaskIndex, ActivityID) >= Tasks[TaskID]->Activity[ActivityID].GoalCount)); + + buf.WriteUInt32(1); // unknown + + auto outapp = new EQApplicationPacket(OP_TaskActivity, buf); + + c->QueuePacket(outapp); + safe_delete(outapp); + +} + +// Used only by RoF+ Clients +void TaskManager::SendTaskActivityNew(Client *c, int TaskID, int ActivityID, int ClientTaskIndex, bool Optional, bool TaskComplete) +{ + SerializeBuffer buf(100); + + buf.WriteUInt32(ClientTaskIndex); // TaskSequenceNumber + buf.WriteUInt32(static_cast(Tasks[TaskID]->type)); // task type + buf.WriteUInt32(TaskID); + buf.WriteUInt32(ActivityID); + buf.WriteUInt32(0); // unknown3 + + // We send our 'internal' types as ActivityCastOn. text3 should be set to the activity description, so it makes + // no difference to the client. All activity updates will be done based on our interal activity types. + if((Tasks[TaskID]->Activity[ActivityID].Type > 0) && Tasks[TaskID]->Activity[ActivityID].Type < 100) + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].Type); + else + buf.WriteUInt32(ActivityCastOn); // w/e! + + buf.WriteUInt8(Optional); + buf.WriteUInt32(0); // solo, group, raid + + // One of these unknown fields maybe related to the 'Use On' activity types + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].target_name); // target name string + + buf.WriteLengthString(Tasks[TaskID]->Activity[ActivityID].item_list); // item name list + + // Goal Count + if(Tasks[TaskID]->Activity[ActivityID].Type != ActivityGiveCash) + buf.WriteUInt32(Tasks[TaskID]->Activity[ActivityID].GoalCount); + else + buf.WriteUInt32(1); // GoalCount + + // skill ID list ; separated + buf.WriteLengthString(Tasks[TaskID]->Activity[ActivityID].skill_list); + + // spelll ID list ; separated -- unsure wtf we're doing here + buf.WriteLengthString(Tasks[TaskID]->Activity[ActivityID].spell_list); + + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].zones); + buf.WriteUInt32(0); // unknown7 + + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].desc_override); // description override + + if(Tasks[TaskID]->Activity[ActivityID].Type != ActivityGiveCash) + buf.WriteUInt32(c->GetTaskActivityDoneCount(Tasks[TaskID]->type, ClientTaskIndex, ActivityID)); // DoneCount + else + // For internal activity types, DoneCount is either 1 if the activity is complete, 0 otherwise. + buf.WriteUInt32((c->GetTaskActivityDoneCount(Tasks[TaskID]->type, ClientTaskIndex, ActivityID) >= Tasks[TaskID]->Activity[ActivityID].GoalCount)); + + buf.WriteUInt8(1); // unknown9 + + buf.WriteString(Tasks[TaskID]->Activity[ActivityID].zones); + + auto outapp = new EQApplicationPacket(OP_TaskActivity, buf); + + c->QueuePacket(outapp); + safe_delete(outapp); + +} + +void TaskManager::SendActiveTasksToClient(Client *c, bool TaskComplete) +{ + auto state = c->GetTaskState(); + if (!state) + return; + + for (int TaskIndex = 0; TaskIndex < MAXACTIVEQUESTS + 1; TaskIndex++) { + int TaskID = state->ActiveTasks[TaskIndex].TaskID; + if ((TaskID == 0) || (Tasks[TaskID] == 0)) + continue; + int StartTime = state->ActiveTasks[TaskIndex].AcceptedTime; + + SendActiveTaskDescription(c, TaskID, state->ActiveTasks[TaskIndex], StartTime, Tasks[TaskID]->Duration, + false); + Log(Logs::General, Logs::Tasks, "[UPDATE] SendActiveTasksToClient: Task %i, Activities: %i", TaskID, + GetActivityCount(TaskID)); + + int Sequence = 0; + int fixed_index = Tasks[TaskID]->type == TaskType::Task ? 0 : TaskIndex - 1; // hmmm fuck + for (int Activity = 0; Activity < GetActivityCount(TaskID); Activity++) { + if (c->GetTaskActivityState(Tasks[TaskID]->type, fixed_index, Activity) != ActivityHidden) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, + Activity, fixed_index, TaskComplete); + if (Activity == GetActivityCount(TaskID) - 1) + SendTaskActivityLong(c, TaskID, Activity, fixed_index, + Tasks[TaskID]->Activity[Activity].Optional, TaskComplete); + else + SendTaskActivityLong(c, TaskID, Activity, fixed_index, + Tasks[TaskID]->Activity[Activity].Optional, 0); + } else { + Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, + fixed_index); + SendTaskActivityShort(c, TaskID, Activity, fixed_index); + } + Sequence++; + } + } +} + +void TaskManager::SendSingleActiveTaskToClient(Client *c, ClientTaskInformation &task_info, bool TaskComplete, + bool BringUpTaskJournal) +{ + int TaskID = task_info.TaskID; + + if (TaskID == 0 || Tasks[TaskID] == nullptr) + return; + + int StartTime = task_info.AcceptedTime; + SendActiveTaskDescription(c, TaskID, task_info, StartTime, Tasks[TaskID]->Duration, BringUpTaskJournal); + Log(Logs::General, Logs::Tasks, "[UPDATE] SendSingleActiveTasksToClient: Task %i, Activities: %i", TaskID, GetActivityCount(TaskID)); + + for (int Activity = 0; Activity < GetActivityCount(TaskID); Activity++) { + if(task_info.Activity[Activity].State != ActivityHidden) { + Log(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i Complete=%i", TaskID, Activity, TaskComplete); + if (Activity == GetActivityCount(TaskID) - 1) + SendTaskActivityLong(c, TaskID, Activity, task_info.slot, + Tasks[TaskID]->Activity[Activity].Optional, TaskComplete); + else + SendTaskActivityLong(c, TaskID, Activity, task_info.slot, + Tasks[TaskID]->Activity[Activity].Optional, 0); + } else { + Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i", TaskID, Activity); + SendTaskActivityShort(c, TaskID, Activity, task_info.slot); + } + } +} + +void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, ClientTaskInformation &task_info, int StartTime, int Duration, bool BringUpTaskJournal) +{ + if ((TaskID < 1) || (TaskID >= MAXTASKS) || !Tasks[TaskID]) + return; + + int PacketLength = sizeof(TaskDescriptionHeader_Struct) + Tasks[TaskID]->Title.length() + 1 + + sizeof(TaskDescriptionData1_Struct) + Tasks[TaskID]->Description.length() + 1 + + sizeof(TaskDescriptionData2_Struct) + 1 + sizeof(TaskDescriptionTrailer_Struct); + + // If there is an item make the Reward text into a link to the item (only the first item if a list + // is specified). I have been unable to get multiple item links to work. + // + if(Tasks[TaskID]->RewardID && Tasks[TaskID]->item_link.empty()) { + int ItemID = 0; + // If the reward is a list of items, and the first entry on the list is valid + if (Tasks[TaskID]->RewardMethod == METHODSINGLEID) { + ItemID = Tasks[TaskID]->RewardID; + } else if (Tasks[TaskID]->RewardMethod == METHODLIST) { + ItemID = GoalListManager.GetFirstEntry(Tasks[TaskID]->RewardID); + if (ItemID < 0) + ItemID = 0; + } + + if(ItemID) { + const EQ::ItemData* reward_item = database.GetItem(ItemID); + + EQ::SayLinkEngine linker; + linker.SetLinkType(EQ::saylink::SayLinkItemData); + linker.SetItemData(reward_item); + linker.SetTaskUse(); + Tasks[TaskID]->item_link = linker.GenerateLink(); + } + } + + PacketLength += Tasks[TaskID]->Reward.length() + 1 + Tasks[TaskID]->item_link.length() + 1; + + char *Ptr; + TaskDescriptionHeader_Struct* tdh; + TaskDescriptionData1_Struct* tdd1; + TaskDescriptionData2_Struct* tdd2; + TaskDescriptionTrailer_Struct* tdt; + + auto outapp = new EQApplicationPacket(OP_TaskDescription, PacketLength); + + tdh = (TaskDescriptionHeader_Struct*)outapp->pBuffer; + + tdh->SequenceNumber = task_info.slot; + tdh->TaskID = TaskID; + tdh->open_window = BringUpTaskJournal; + tdh->task_type = static_cast(Tasks[TaskID]->type); + tdh->reward_type = 0; // TODO: 4 says Radiant Crystals else Ebon Crystals when shared task + + Ptr = (char *) tdh + sizeof(TaskDescriptionHeader_Struct); + + sprintf(Ptr, "%s", Tasks[TaskID]->Title.c_str()); + Ptr += Tasks[TaskID]->Title.length() + 1; + + tdd1 = (TaskDescriptionData1_Struct*)Ptr; + + tdd1->Duration = Duration; + tdd1->dur_code = static_cast(Tasks[TaskID]->dur_code); + + tdd1->StartTime = StartTime; + + Ptr = (char *) tdd1 + sizeof(TaskDescriptionData1_Struct); + + sprintf(Ptr, "%s", Tasks[TaskID]->Description.c_str()); + Ptr += Tasks[TaskID]->Description.length() + 1; + + tdd2 = (TaskDescriptionData2_Struct*)Ptr; + + // we have this reward stuff! + // if we ever don't hardcode this, TaskDescriptionTrailer_Struct will need to be fixed since + // "has_reward_selection" is after this bool! Smaller packet when this is 0 + tdd2->has_rewards = 1; + + tdd2->coin_reward = Tasks[TaskID]->CashReward; + tdd2->xp_reward = Tasks[TaskID]->XPReward ? 1 : 0; // just booled + tdd2->faction_reward = Tasks[TaskID]->faction_reward ? 1 : 0; // faction booled + + Ptr = (char *) tdd2 + sizeof(TaskDescriptionData2_Struct); + + // we actually have 2 strings here. One is max length 96 and not parsed for item links + // We actually skipped past that string incorrectly before, so TODO: fix item link string + sprintf(Ptr, "%s", Tasks[TaskID]->Reward.c_str()); + Ptr += Tasks[TaskID]->Reward.length() + 1; + + // second string is parsed for item links + sprintf(Ptr, "%s", Tasks[TaskID]->item_link.c_str()); + Ptr += Tasks[TaskID]->item_link.length() + 1; + + tdt = (TaskDescriptionTrailer_Struct*)Ptr; + tdt->Points = 0x00000000; // Points Count TODO: this does have a visible affect on the client ... + tdt->has_reward_selection = 0; // TODO: new rewards window + + c->QueuePacket(outapp); + safe_delete(outapp); +} + +bool ClientTaskState::IsTaskActivityCompleted(TaskType type, int index, int ActivityID) +{ + switch (type) { + case TaskType::Task: + if (index != 0) + return false; + return ActiveTask.Activity[ActivityID].State == ActivityCompleted; + case TaskType::Shared: + return false; // TODO: shared tasks + case TaskType::Quest: + if (index < MAXACTIVEQUESTS) + return ActiveQuests[index].Activity[ActivityID].State == ActivityCompleted; + default: + return false; + } + +} + +// should we be defaulting to hidden? +ActivityState ClientTaskState::GetTaskActivityState(TaskType type, int index, int ActivityID) +{ + switch (type) { + case TaskType::Task: + if (index != 0) + return ActivityHidden; + return ActiveTask.Activity[ActivityID].State; + case TaskType::Shared: + return ActivityHidden; // TODO: shared tasks + case TaskType::Quest: + if (index < MAXACTIVEQUESTS) + return ActiveQuests[index].Activity[ActivityID].State; + default: + return ActivityHidden; + } +} + +int ClientTaskState::GetTaskActivityDoneCount(TaskType type, int index, int ActivityID) +{ + switch (type) { + case TaskType::Task: + if (index != 0) + return 0; + return ActiveTask.Activity[ActivityID].DoneCount; + case TaskType::Shared: + return 0; // TODO: shared tasks + case TaskType::Quest: + if (index < MAXACTIVEQUESTS) + return ActiveQuests[index].Activity[ActivityID].DoneCount; + default: + return 0; + } +} + +int ClientTaskState::GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID) +{ + if (ActiveTask.TaskID == TaskID) + return ActiveTask.Activity[ActivityID].DoneCount; + + // TODO: shared tasks + + int ActiveTaskIndex = -1; + for(int i=0; ipBuffer; + cts->SequenceNumber = SequenceNumber; + cts->type = static_cast(type); + + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask"); + + c->QueuePacket(outapp); + safe_delete(outapp); + + if(RemoveFromDB) + RemoveTask(c, SequenceNumber, type); +} + +void ClientTaskState::RemoveTask(Client *c, int sequenceNumber, TaskType type) +{ + int characterID = c->CharacterID(); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState Cancel Task %i ", sequenceNumber); + + int task_id = -1; + switch (type) { + case TaskType::Task: + if (sequenceNumber == 0) + task_id = ActiveTask.TaskID; + break; + case TaskType::Quest: + if (sequenceNumber < MAXACTIVEQUESTS) + task_id = ActiveQuests[sequenceNumber].TaskID; + break; + case TaskType::Shared: // TODO: + default: + break; + } + + std::string query = StringFormat("DELETE FROM character_activities WHERE charid=%i AND taskid = %i", + characterID, task_id); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS] Error in CientTaskState::CancelTask [{}]", + results.ErrorMessage().c_str()); + return; + } + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); + + query = StringFormat("DELETE FROM character_tasks WHERE charid=%i AND taskid = %i AND type=%i", characterID, + task_id, static_cast(type)); + results = database.QueryDatabase(query); + if (!results.Success()) + LogError("[TASKS] Error in CientTaskState::CancelTask [{}]", + results.ErrorMessage().c_str()); + + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); + + switch (type) { + case TaskType::Task: + ActiveTask.TaskID = TASKSLOTEMPTY; + break; + case TaskType::Shared: + break; // TODO: shared tasks + case TaskType::Quest: + ActiveQuests[sequenceNumber].TaskID = TASKSLOTEMPTY; + ActiveTaskCount--; + break; + default: + break; + } +} + +void ClientTaskState::RemoveTaskByTaskID(Client *c, uint32 task_id) +{ + auto task_type = taskmanager->GetTaskType(task_id); + int character_id = c->CharacterID(); + Log(Logs::General, Logs::Tasks, "[UPDATE] RemoveTaskByTaskID: %d", task_id); + std::string query = fmt::format("DELETE FROM character_activities WHERE charid = {} AND taskid = {}", character_id, task_id); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS] Error in CientTaskState::RemoveTaskByTaskID [{}]", results.ErrorMessage().c_str()); + return; + } + LogTasks("[UPDATE] RemoveTaskByTaskID: {}", query.c_str()); + + query = fmt::format("DELETE FROM character_tasks WHERE charid = {} AND taskid = {} AND type = {}", character_id, task_id, (int) task_type); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("[TASKS] Error in ClientTaskState::RemoveTaskByTaskID [{}]", results.ErrorMessage().c_str()); + } + + LogTasks("[UPDATE] RemoveTaskByTaskID: {}", query.c_str()); + + switch (task_type) { + case TaskType::Task: + { + if (ActiveTask.TaskID == task_id) { + auto outapp = new EQApplicationPacket(OP_CancelTask, sizeof(CancelTask_Struct)); + CancelTask_Struct* cts = (CancelTask_Struct*)outapp->pBuffer; + cts->SequenceNumber = 0; + cts->type = static_cast(task_type); + LogTasks("[UPDATE] RemoveTaskByTaskID found Task [{}]", task_id); + c->QueuePacket(outapp); + safe_delete(outapp); + ActiveTask.TaskID = TASKSLOTEMPTY; + } + break; + } + case TaskType::Shared: + { + break; // TODO: shared tasks + } + case TaskType::Quest: + { + for (int active_quest = 0; active_quest < MAXACTIVEQUESTS; active_quest++) { + if (ActiveQuests[active_quest].TaskID == task_id) { + auto outapp = new EQApplicationPacket(OP_CancelTask, sizeof(CancelTask_Struct)); + CancelTask_Struct* cts = (CancelTask_Struct*)outapp->pBuffer; + cts->SequenceNumber = active_quest; + cts->type = static_cast(task_type); + LogTasks("[UPDATE] RemoveTaskByTaskID found Quest [{}] at index [{}]", task_id, active_quest); + ActiveQuests[active_quest].TaskID = TASKSLOTEMPTY; + ActiveTaskCount--; + c->QueuePacket(outapp); + safe_delete(outapp); + } + } + } + default: { + break; + } + } +} + +void ClientTaskState::AcceptNewTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement) +{ + if (!taskmanager || TaskID < 0 || TaskID >= MAXTASKS) { + c->Message(Chat::Red, "Task system not functioning, or TaskID %i out of range.", TaskID); + return; + } + + auto task = taskmanager->Tasks[TaskID]; + + if (task == nullptr) { + c->Message(Chat::Red, "Invalid TaskID %i", TaskID); + return; + } + + bool max_tasks = false; + + switch (task->type) { + case TaskType::Task: + if (ActiveTask.TaskID != TASKSLOTEMPTY) + max_tasks = true; + break; + case TaskType::Shared: // TODO: shared tasks + // if (something) + max_tasks = true; + break; + case TaskType::Quest: + if (ActiveTaskCount == MAXACTIVEQUESTS) + max_tasks = true; + break; + default: + break; + } + + if (max_tasks) { + c->Message(Chat::Red, "You already have the maximum allowable number of active tasks (%i)", MAXACTIVEQUESTS); + return; + } + + // only Quests can have more than one, so don't need to check others + if (task->type == TaskType::Quest) { + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + if (ActiveQuests[i].TaskID == TaskID) { + c->Message(Chat::Red, "You have already been assigned this task."); + return; + } + } + } + + if (enforce_level_requirement && !taskmanager->AppropriateLevel(TaskID, c->GetLevel())) { + c->Message(Chat::Red, "You are outside the level range of this task."); + return; + } + + if (!taskmanager->IsTaskRepeatable(TaskID) && IsTaskCompleted(TaskID)) + return; + + // We do it this way, because when the Client cancels a task, it retains the sequence number of the remaining + // tasks in it's window, until something causes the TaskDescription packets to be sent again. We could just + // resend all the active task data to the client when it cancels a task, but that could be construed as a + // waste of bandwidth. + // + ClientTaskInformation *active_slot = nullptr; + switch (task->type) { + case TaskType::Task: + active_slot = &ActiveTask; + break; + case TaskType::Shared: // TODO: shared + active_slot = nullptr; + break; + case TaskType::Quest: + for (int i = 0; i < MAXACTIVEQUESTS; i++) { + Log(Logs::General, Logs::Tasks, + "[UPDATE] ClientTaskState Looking for free slot in slot %i, found TaskID of %i", i, + ActiveQuests[i].TaskID); + if (ActiveQuests[i].TaskID == 0) { + active_slot = &ActiveQuests[i]; + break; + } + } + break; + default: + break; + } + + // This shouldn't happen unless there is a bug in the handling of ActiveTaskCount somewhere + if (active_slot == nullptr) { + c->Message(Chat::Red, "You already have the maximum allowable number of active tasks (%i)", MAXACTIVEQUESTS); + return; + } + + active_slot->TaskID = TaskID; + active_slot->AcceptedTime = time(nullptr); + active_slot->Updated = true; + active_slot->CurrentStep = -1; + + for (int i = 0; i < taskmanager->Tasks[TaskID]->ActivityCount; i++) { + active_slot->Activity[i].ActivityID = i; + active_slot->Activity[i].DoneCount = 0; + active_slot->Activity[i].State = ActivityHidden; + active_slot->Activity[i].Updated = true; + } + + UnlockActivities(c->CharacterID(), *active_slot); + + if (task->type == TaskType::Quest) + ActiveTaskCount++; + + taskmanager->SendSingleActiveTaskToClient(c, *active_slot, false, true); + c->Message(Chat::White, "You have been assigned the task '%s'.", taskmanager->Tasks[TaskID]->Title.c_str()); + taskmanager->SaveClientState(c, this); + std::string buf = std::to_string(TaskID); + + NPC *npc = entity_list.GetID(NPCID)->CastToNPC(); + if(npc) { + parse->EventNPC(EVENT_TASK_ACCEPTED, npc, c, buf.c_str(), 0); + } +} + +void ClientTaskState::ProcessTaskProximities(Client *c, float X, float Y, float Z) { + + float LastX = c->ProximityX(); + float LastY = c->ProximityY(); + float LastZ = c->ProximityZ(); + + if((LastX==X) && (LastY==Y) && (LastZ==Z)) return; + + Log(Logs::General, Logs::Tasks, "[PROXIMITY] Checking proximities for Position %8.3f, %8.3f, %8.3f", X, Y, Z); + int ExploreID = taskmanager->ProximityManager.CheckProximities(X, Y, Z); + + if(ExploreID > 0) { + Log(Logs::General, Logs::Tasks, "[PROXIMITY] Position %8.3f, %8.3f, %8.3f is within proximity %i", X, Y, Z, ExploreID); + UpdateTasksOnExplore(c, ExploreID); + } +} + +TaskGoalListManager::TaskGoalListManager() +{ + NumberOfLists = 0; +} + +TaskGoalListManager::~TaskGoalListManager() {} + +bool TaskGoalListManager::LoadLists() +{ + + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskGoalListManager::LoadLists Called"); + + TaskGoalLists.clear(); + + const char *ERR_MYSQLERROR = "Error in TaskGoalListManager::LoadLists: %s %s"; + + NumberOfLists = 0; + + std::string query = "SELECT `listid`, COUNT(`entry`) " + "FROM `goallists` GROUP by `listid` " + "ORDER BY `listid`"; + auto results = content_db.QueryDatabase(query); + if (!results.Success()) { + return false; + } + + NumberOfLists = results.RowCount(); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Database returned a count of %i lists", NumberOfLists); + + TaskGoalLists.reserve(NumberOfLists); + + int list_index = 0; + + for (auto row = results.begin(); row != results.end(); ++row) { + int listID = atoi(row[0]); + int listSize = atoi(row[1]); + + TaskGoalLists.push_back({listID, 0, 0}); + + TaskGoalLists[list_index].GoalItemEntries.reserve(listSize); + + list_index++; + } + + auto goal_lists = GoallistsRepository::GetWhere("TRUE ORDER BY listid, entry ASC"); + + for (list_index = 0; list_index < NumberOfLists; list_index++) { + + int list_id = TaskGoalLists[list_index].ListID; + + for (auto &entry: goal_lists) { + if (entry.listid == list_id) { + if (entry.entry < TaskGoalLists[list_index].Min) { + TaskGoalLists[list_index].Min = entry.entry; + } + + if (entry.entry > TaskGoalLists[list_index].Max) { + TaskGoalLists[list_index].Max = entry.entry; + } + + TaskGoalLists[list_index].GoalItemEntries.push_back(entry.entry); + + LogTasksDetail( + "Goal list index [{}] loading list [{}] entry [{}]", + list_index, + list_id, + entry.entry + ); + } + } + } + + return true; + +} + +int TaskGoalListManager::GetListByID(int ListID) { + + // Find the list with the specified ListID and return the index + auto it = std::find_if(TaskGoalLists.begin(), TaskGoalLists.end(), + [ListID](const TaskGoalList_Struct &t) { return t.ListID == ListID; }); + + if (it == TaskGoalLists.end()) + return -1; + + return std::distance(TaskGoalLists.begin(), it); +} + +int TaskGoalListManager::GetFirstEntry(int ListID) { + + int ListIndex = GetListByID(ListID); + + if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return -1; + + if(TaskGoalLists[ListIndex].GoalItemEntries.empty()) return -1; + + return TaskGoalLists[ListIndex].GoalItemEntries[0]; +} + +std::vector TaskGoalListManager::GetListContents(int ListID) { + + std::vector ListContents; + + int ListIndex = GetListByID(ListID); + + if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return ListContents; + + ListContents = TaskGoalLists[ListIndex].GoalItemEntries; + + return ListContents; + +} + +bool TaskGoalListManager::IsInList(int ListID, int Entry) +{ + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", ListID, Entry); + + int ListIndex = GetListByID(ListID); + + if ((ListIndex < 0) || (ListIndex >= NumberOfLists)) + return false; + + if ((Entry < TaskGoalLists[ListIndex].Min) || (Entry > TaskGoalLists[ListIndex].Max)) + return false; + + int FirstEntry = 0; + auto &task = TaskGoalLists[ListIndex]; + + auto it = std::find(task.GoalItemEntries.begin(), task.GoalItemEntries.end(), Entry); + + if (it == task.GoalItemEntries.end()) + return false; + + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", ListIndex, + Entry); + return true; +} + +TaskProximityManager::TaskProximityManager() { + + +} + +TaskProximityManager::~TaskProximityManager() { + + +} + +bool TaskProximityManager::LoadProximities(int zoneID) { + TaskProximity proximity; + + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskProximityManager::LoadProximities Called for zone %i", zoneID); + TaskProximities.clear(); + + std::string query = StringFormat("SELECT `exploreid`, `minx`, `maxx`, " + "`miny`, `maxy`, `minz`, `maxz` " + "FROM `proximities` WHERE `zoneid` = %i " + "ORDER BY `zoneid` ASC", zoneID); + auto results = content_db.QueryDatabase(query); + if (!results.Success()) { + return false; + } + + for( auto row = results.begin(); row != results.end(); ++row) { + proximity.ExploreID = atoi(row[0]); + proximity.MinX = atof(row[1]); + proximity.MaxX = atof(row[2]); + proximity.MinY = atof(row[3]); + proximity.MaxY = atof(row[4]); + proximity.MinZ = atof(row[5]); + proximity.MaxZ = atof(row[6]); + + TaskProximities.push_back(proximity); + } + + return true; + +} + +int TaskProximityManager::CheckProximities(float X, float Y, float Z) { + + for(unsigned int i=0; iMinX, P->MaxX, P->MinY, P->MaxY, P->MinZ, P->MaxZ); + + if(X < P->MinX || X > P->MaxX || Y < P->MinY || Y > P->MaxY || + Z < P->MinZ || Z > P->MaxZ) continue; + + return P->ExploreID; + + } + + return 0; +} + diff --git a/zone/tasks.h b/zone/tasks.h index d3fed2c09..cb4cd63c1 100644 --- a/zone/tasks.h +++ b/zone/tasks.h @@ -1,7 +1,27 @@ +/* EQEMu: Everquest Server Emulator +Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + #ifndef TASKS_H #define TASKS_H #include "../common/types.h" + #include #include #include @@ -9,141 +29,304 @@ #define MAXTASKS 10000 #define MAXTASKSETS 1000 -#define MAXACTIVEQUESTS 19 // The Client has a hard cap of 19 active quests, 29 in SoD+ -#define MAXCHOOSERENTRIES 40 // The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client. -#define MAXACTIVITIESPERTASK 20 // The Client has a hard cap of 20 activities per task. -#define TASKSLOTEMPTY 0 // This is used to determine if a client's active task slot is empty. +// The Client has a hard cap of 19 active quests, 29 in SoD+ +#define MAXACTIVEQUESTS 19 +// The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client. +#define MAXCHOOSERENTRIES 40 +// The Client has a hard cap of 20 activities per task. +#define MAXACTIVITIESPERTASK 20 +// This is used to determine if a client's active task slot is empty. +#define TASKSLOTEMPTY 0 // Command Codes for worldserver ServerOP_ReloadTasks -#define RELOADTASKS 0 -#define RELOADTASKGOALLISTS 1 -#define RELOADTASKPROXIMITIES 2 -#define RELOADTASKSETS 3 +// +#define RELOADTASKS 0 +#define RELOADTASKGOALLISTS 1 +#define RELOADTASKPROXIMITIES 2 +#define RELOADTASKSETS 3 class Client; class Mob; -namespace EQ { +namespace EQ +{ class ItemInstance; } -typedef enum { - METHODSINGLEID = 0, - METHODLIST = 1, - METHODQUEST = 2 -} TaskMethodType; +struct TaskGoalList_Struct { + int ListID; + int Min, Max; + std::vector GoalItemEntries; +}; + +// This is used for handling lists, loading them from the database, searching them. +// Used for lists of NPCs to kill, items to loot, etc, as well as lists of items to +// reward the player with on completion of the task. +// +class TaskGoalListManager { + +public: + TaskGoalListManager(); + ~TaskGoalListManager(); + bool LoadLists(); + int GetListByID(int ListID); + bool IsInList(int ListID, int Entry); + int GetFirstEntry(int ListID); + std::vector GetListContents(int ListIndex); + +private: + + std::vector TaskGoalLists; + int NumberOfLists; +}; + +typedef struct { + int ExploreID; + float MinX, MaxX, MinY, MaxY, MinZ, MaxZ; +} TaskProximity; + +// This class is used for managing proximities so that Quest NPC proximities don't need to be used. +class TaskProximityManager { + +public: + TaskProximityManager(); + ~TaskProximityManager(); + bool LoadProximities(int ZoneID); + int CheckProximities(float X, float Y, float Z); + +private: + std::vector TaskProximities; +}; + +typedef enum { METHODSINGLEID = 0, METHODLIST = 1, METHODQUEST = 2 } TaskMethodType; struct ActivityInformation { - int step_number; - int activity_type; - std::string target_name; // name mob, location -- default empty - std::string item_list; // likely defaults to empty - std::string skill_list; // IDs ; separated -- default -1 - std::string spell_list; // IDs ; separated -- default 0 - std::string description_override; // overrides auto generated description -- default empty - int skill_id; // older clients, first id from above - int spell_id; // older clients, first id from above - int goal_id; - TaskMethodType goal_method; - int goal_count; - int deliver_to_npc; - std::vector zone_ids; - std::string zones; // IDs ; searated, ZoneID is the first in this list for older clients -- default empty string - bool optional; + int StepNumber; + int Type; + std::string target_name; // name mob, location -- default empty + std::string item_list; // likely defaults to empty + std::string skill_list; // IDs ; separated -- default -1 + std::string spell_list; // IDs ; separated -- default 0 + std::string desc_override; // overrides auto generated description -- default empty + int skill_id; // older clients, first id from above + int spell_id; // older clients, first id from above + int GoalID; + TaskMethodType GoalMethod; + int GoalCount; + int DeliverToNPC; + std::vector ZoneIDs; + std::string zones; // IDs ; searated, ZoneID is the first in this list for older clients -- default empty string + bool Optional; - inline bool CheckZone(int zone_id) - { - if (zone_ids.empty()) { + inline bool CheckZone(int zone_id) { + if (ZoneIDs.empty()) return true; - } - return std::find(zone_ids.begin(), zone_ids.end(), zone_id) != zone_ids.end(); + return std::find(ZoneIDs.begin(), ZoneIDs.end(), zone_id) != ZoneIDs.end(); } }; -typedef enum { - ActivitiesSequential = 0, - ActivitiesStepped = 1 -} SequenceType; +typedef enum { ActivitiesSequential = 0, ActivitiesStepped = 1 } SequenceType; enum class TaskType { - Task = 0, // can have at max 1 - Shared = 1, // can have at max 1 - Quest = 2, // can have at max 19 or 29 depending on client - E = 3 // can have at max 19 or 29 depending on client, not present in live anymore + Task = 0, // can have at max 1 + Shared = 1, // can have at max 1 + Quest = 2, // can have at max 19 or 29 depending on client + E = 3 // can have at max 19 or 29 depending on client, not present in live anymore }; enum class DurationCode { - None = 0, - Short = 1, + None = 0, + Short = 1, Medium = 2, - Long = 3 + Long = 3 }; struct TaskInformation { - TaskType type; - int duration; - DurationCode duration_code; // description for time investment for when duration == 0 - std::string title; // max length 64 - std::string description; // max length 4000, 2048 on Tit - std::string reward; - std::string item_link; // max length 128 older clients, item link gets own string - std::string completion_emote; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now! - int reward_id; - int cash_reward; // Expressed in copper - int experience_reward; - int faction_reward; // just a npc_faction_id - TaskMethodType reward_method; - int activity_count; - SequenceType sequence_mode; - int last_step; - short min_level; - short max_level; - bool repeatable; - ActivityInformation activity_information[MAXACTIVITIESPERTASK]; + TaskType type; + int Duration; + DurationCode dur_code; // description for time investment for when Duration == 0 + std::string Title; // max length 64 + std::string Description; // max length 4000, 2048 on Tit + std::string Reward; + std::string item_link; // max length 128 older clients, item link gets own string + std::string completion_emote; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now! + int RewardID; + int CashReward; // Expressed in copper + int XPReward; + int faction_reward; // just a npc_faction_id + TaskMethodType RewardMethod; + int ActivityCount; + SequenceType SequenceMode; + int LastStep; + short MinLevel; + short MaxLevel; + bool Repeatable; + ActivityInformation Activity[MAXACTIVITIESPERTASK]; }; -typedef enum { - ActivityHidden = 0, - ActivityActive = 1, - ActivityCompleted = 2 -} ActivityState; +typedef enum { ActivityHidden = 0, ActivityActive = 1, ActivityCompleted = 2 } ActivityState; + +typedef enum { ActivityDeliver = 1, ActivityKill = 2, ActivityLoot = 3, ActivitySpeakWith = 4, ActivityExplore = 5, + ActivityTradeSkill = 6, ActivityFish = 7, ActivityForage = 8, ActivityCastOn = 9, ActivitySkillOn = 10, + ActivityTouch = 11, ActivityCollect = 13, ActivityGiveCash = 100 } ActivityType; -typedef enum { - ActivityDeliver = 1, - ActivityKill = 2, - ActivityLoot = 3, - ActivitySpeakWith = 4, - ActivityExplore = 5, - ActivityTradeSkill = 6, - ActivityFish = 7, - ActivityForage = 8, - ActivityCastOn = 9, - ActivitySkillOn = 10, - ActivityTouch = 11, - ActivityCollect = 13, - ActivityGiveCash = 100 -} ActivityType; struct ClientActivityInformation { - int activity_id; - int done_count; - ActivityState activity_state; - bool updated; // Flag so we know if we need to updated the database + int ActivityID; + int DoneCount; + ActivityState State; + bool Updated; // Flag so we know if we need to update the database }; struct ClientTaskInformation { - int slot; // intrusive, but makes things easier :P - int task_id; - int current_step; - int accepted_time; - bool updated; - ClientActivityInformation activity[MAXACTIVITIESPERTASK]; + int slot; // intrusive, but makes things easier :P + int TaskID; + int CurrentStep; + int AcceptedTime; + bool Updated; + ClientActivityInformation Activity[MAXACTIVITIESPERTASK]; }; struct CompletedTaskInformation { - int task_id; - int completed_time; - bool activity_done[MAXACTIVITIESPERTASK]; + int TaskID; + int CompletedTime; + bool ActivityDone[MAXACTIVITIESPERTASK]; +}; + +class ClientTaskState { + +public: + ClientTaskState(); + ~ClientTaskState(); + void ShowClientTasks(Client *c); + inline int GetActiveTaskCount() { return ActiveTaskCount; } + int GetActiveTaskID(int index); + bool IsTaskActivityCompleted(TaskType type, int index, int ActivityID); + int GetTaskActivityDoneCount(TaskType type, int index, int ActivityID); + int GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID); + int GetTaskStartTime(TaskType type, int index); + void AcceptNewTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement = false); + void FailTask(Client *c, int TaskID); + int TaskTimeLeft(int TaskID); + int IsTaskCompleted(int TaskID); + bool IsTaskActive(int TaskID); + bool IsTaskActivityActive(int TaskID, int ActivityID); + ActivityState GetTaskActivityState(TaskType type, int index, int ActivityID); + void UpdateTaskActivity(Client *c, int TaskID, int ActivityID, int Count, bool ignore_quest_update = false); + void ResetTaskActivity(Client *c, int TaskID, int ActivityID); + void CancelTask(Client *c, int SequenceNumber, TaskType type, bool RemoveFromDB = true); + void CancelAllTasks(Client *c); + void RemoveTask(Client *c, int SequenceNumber, TaskType type); + void RemoveTaskByTaskID(Client *c, uint32 task_id); + bool UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeID); + void UpdateTasksOnKill(Client *c, int NPCTypeID); + void UpdateTasksForItem(Client *c, ActivityType Type, int ItemID, int Count=1); + void UpdateTasksOnExplore(Client *c, int ExploreID); + bool UpdateTasksOnSpeakWith(Client *c, int NPCTypeID); + bool UpdateTasksOnDeliver(Client *c, std::list& Items, int Cash, int NPCTypeID); + void UpdateTasksOnTouch(Client *c, int ZoneID); + void ProcessTaskProximities(Client *c, float X, float Y, float Z); + bool TaskOutOfTime(TaskType type, int Index); + void TaskPeriodicChecks(Client *c); + void SendTaskHistory(Client *c, int TaskIndex); + void RewardTask(Client *c, TaskInformation *Task); + void EnableTask(int CharID, int TaskCount, int *TaskList); + void DisableTask(int CharID, int TaskCount, int *TaskList); + bool IsTaskEnabled(int TaskID); + int EnabledTaskCount(int TaskSetID); + int ActiveSpeakTask(int NPCID); + int ActiveSpeakActivity(int NPCID, int TaskID); + int ActiveTasksInSet(int TaskSetID); + int CompletedTasksInSet(int TaskSetID); + bool HasSlotForTask(TaskInformation *task); + + inline bool HasFreeTaskSlot() { return ActiveTask.TaskID == TASKSLOTEMPTY; } + + friend class TaskManager; + +private: + bool UnlockActivities(int CharID, ClientTaskInformation &task_info); + void IncrementDoneCount(Client *c, TaskInformation *Task, int TaskIndex, int ActivityID, int Count = 1, bool ignore_quest_update = false); + inline ClientTaskInformation *GetClientTaskInfo(TaskType type, int index) + { + ClientTaskInformation *info = nullptr; + switch (type) { + case TaskType::Task: + if (index == 0) + info = &ActiveTask; + break; + case TaskType::Shared: + break; + case TaskType::Quest: + if (index < MAXACTIVEQUESTS) + info = &ActiveQuests[index]; + break; + default: + break; + } + return info; + } + int ActiveTaskCount; + union { // easier to loop over + struct { + ClientTaskInformation ActiveTask; // only one + ClientTaskInformation ActiveQuests[MAXACTIVEQUESTS]; + }; + ClientTaskInformation ActiveTasks[MAXACTIVEQUESTS + 1]; + }; + // Shared tasks should be limited to 1 as well + std::vector EnabledTasks; + std::vector CompletedTasks; + int LastCompletedTaskLoaded; + bool CheckedTouchActivities; +}; + + +class TaskManager { + +public: + TaskManager(); + ~TaskManager(); + int GetActivityCount(int TaskID); + bool LoadSingleTask(int TaskID); + bool LoadTasks(int SingleTask=0); + void ReloadGoalLists(); + inline void LoadProximities(int ZoneID) { ProximityManager.LoadProximities(ZoneID); } + bool LoadTaskSets(); + bool LoadClientState(Client *c, ClientTaskState *state); + bool SaveClientState(Client *c, ClientTaskState *state); + void SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *TaskList); + void SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *TaskList); + bool AppropriateLevel(int TaskID, int PlayerLevel); + int GetTaskMinLevel(int TaskID); + int GetTaskMaxLevel(int TaskID); + std::string GetTaskName(uint32 task_id); + TaskType GetTaskType(uint32 task_id); + void TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, int TaskSetID); + void TaskQuestSetSelector(Client *c, ClientTaskState *state, Mob *mob, int count, int *tasks); // task list provided by QuestManager (perl/lua) + void SendActiveTasksToClient(Client *c, bool TaskComplete=false); + void SendSingleActiveTaskToClient(Client *c, ClientTaskInformation &task_info, bool TaskComplete, bool BringUpTaskJournal = false); + void SendTaskActivityShort(Client *c, int TaskID, int ActivityID, int ClientTaskIndex); + void SendTaskActivityLong(Client *c, int TaskID, int ActivityID, int ClientTaskIndex, + bool Optional, bool TaskComplete=false); + void SendTaskActivityNew(Client *c, int TaskID, int ActivityID, int ClientTaskIndex, + bool Optional, bool TaskComplete=false); + void SendCompletedTasksToClient(Client *c, ClientTaskState *state); + void ExplainTask(Client *c, int TaskID); + int FirstTaskInSet(int TaskSet); + int LastTaskInSet(int TaskSet); + int NextTaskInSet(int TaskSet, int TaskID); + bool IsTaskRepeatable(int TaskID); + friend class ClientTaskState; + + +private: + TaskGoalListManager GoalListManager; + TaskProximityManager ProximityManager; + TaskInformation* Tasks[MAXTASKS]; + std::vector TaskSets[MAXTASKSETS]; + void SendActiveTaskDescription(Client *c, int TaskID, ClientTaskInformation &task_info, int StartTime, int Duration, bool BringUpTaskJournal=false); + }; #endif diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 52423b368..eb365b8a9 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -1582,7 +1582,7 @@ void Client::LearnRecipe(uint32 recipe_id) return; } - auto tradeskill_recipe = TradeskillRecipeRepository::FindOne(content_db, recipe_id); + auto tradeskill_recipe = TradeskillRecipeRepository::FindOne(recipe_id); if (tradeskill_recipe.id == 0) { LogError("Invalid recipe [{}]", recipe_id); return; diff --git a/zone/trading.cpp b/zone/trading.cpp index 1d75bd941..9a58d46a6 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -899,15 +899,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st if (baginst) { const EQ::ItemData* bagitem = baginst->GetItem(); if (bagitem && (GetGM() || (bagitem->NoDrop != 0 && baginst->IsAttuned() == false))) { - - auto loot_drop_entry = NPC::NewLootDropEntry(); - loot_drop_entry.equip_item = 1; - loot_drop_entry.item_charges = static_cast(baginst->GetCharges()); - tradingWith->CastToNPC()->AddLootDrop( bagitem, &tradingWith->CastToNPC()->itemlist, - loot_drop_entry, + LootDropEntries_Struct{.item_charges = static_cast(baginst->GetCharges()), .equip_item = 1 }, true ); } @@ -918,14 +913,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st } } - auto new_loot_drop_entry = NPC::NewLootDropEntry(); - new_loot_drop_entry.equip_item = 1; - new_loot_drop_entry.item_charges = static_cast(inst->GetCharges()); - tradingWith->CastToNPC()->AddLootDrop( item, &tradingWith->CastToNPC()->itemlist, - new_loot_drop_entry, + LootDropEntries_Struct{.item_charges = static_cast(inst->GetCharges()), .equip_item = 1 }, true ); } @@ -2648,11 +2639,6 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { return; } - if(item->IsClassBag()) { - Message(Chat::Red, "That item is a Bag."); - return; - } - if(!item->Stackable) { for(uint32 i = 0; i < Quantity; i++) { @@ -3006,27 +2992,29 @@ void Client::UpdateBuyLine(const EQApplicationPacket *app) { LogTrading("UpdateBuyLine: Char: [{}] BuySlot: [{}] ItemID [{}] [{}] Quantity [{}] Toggle: [{}] Price [{}] ItemCount [{}] LoreConflict [{}]", GetName(), BuySlot, ItemID, item->Name, Quantity, ToggleOnOff, Price, ItemCount, LoreConflict); - if((item->NoDrop != 0) && (!item->IsClassBag())&& !LoreConflict && (Quantity > 0) && HasMoney(Quantity * Price) && ToggleOnOff && (ItemCount == 0)) { + if((item->NoDrop != 0) && !LoreConflict && (Quantity > 0) && HasMoney(Quantity * Price) && ToggleOnOff && (ItemCount == 0)) { LogTrading("Adding to database"); database.AddBuyLine(CharacterID(), BuySlot, ItemID, ItemName, Quantity, Price); QueuePacket(app); } else { - if(ItemCount > 0) { + if(ItemCount > 0) Message(Chat::Red, "Buy line %s disabled as Item Compensation is not currently supported.", ItemName); - } else if(Quantity <= 0) { + + else if(Quantity <= 0) Message(Chat::Red, "Buy line %s disabled as the quantity is invalid.", ItemName); - } else if(LoreConflict) { + + else if(LoreConflict) Message(Chat::Red, "Buy line %s disabled as the item is LORE and you have one already.", ItemName); - } else if(item->NoDrop == 0) { + + else if(item->NoDrop == 0) Message(Chat::Red, "Buy line %s disabled as the item is NODROP.", ItemName); - } else if(item->IsClassBag()) { - Message(Chat::Red, "Buy line %s disabled as the item is a Bag.", ItemName); - } else if(ToggleOnOff) { + + else if(ToggleOnOff) Message(Chat::Red, "Buy line %s disabled due to insufficient funds.", ItemName); - } else { + + else database.RemoveBuyLine(CharacterID(), BuySlot); - } auto outapp = new EQApplicationPacket(OP_Barter, 936); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 90fc25d1e..1beca2c01 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -308,12 +308,13 @@ void NPC::CalculateNewWaypoint() { bool on_center = Waypoints[cur_wp].centerpoint; std::vector random_waypoints; - for (auto &wpl : Waypoints) + for (auto &w : Waypoints) { + wplist wpl = w; if (wpl.index != cur_wp && ((on_center && !wpl.centerpoint) || (!on_center && wpl.centerpoint))) { - random_waypoints.push_back(wpl); + random_waypoints.push_back(w); } } @@ -384,47 +385,8 @@ void NPC::CalculateNewWaypoint() { if (cur_wp == patrol) // reutilizing patrol member instead of making new member for this wander type; here we use it to save a random waypoint { - if (!Waypoints[cur_wp].centerpoint) - { - // if we have arrived at a waypoint that is NOT a centerpoint, then check for the existence of any centerpoint waypoint - // if any exists then randomly go to it otherwise go to one that exist. - std::vector random_centerpoints; - for (auto& wpl : Waypoints) - { - if (wpl.index != cur_wp && wpl.centerpoint) - { - random_centerpoints.push_back(wpl); - } - } - - if (random_centerpoints.size() == 1) - { - patrol = random_centerpoints[0].index; - break; - } - else if (random_centerpoints.size() > 1) - { - int windex = zone->random.Roll0(random_centerpoints.size()); - patrol = random_centerpoints[windex].index; - break; - } - } - while (patrol == cur_wp) - { - // Setting a negative number in pause of the select waypoints will NOT be included in the group of waypoints to be random. - // This will cause the NPC to not stop and pause in any of the waypoints that is not part of random waypoints. - std::vector random_waypoints; - for (auto& wpl : Waypoints) - { - if (wpl.index != cur_wp && wpl.pause >= 0 && !wpl.centerpoint) - { - random_waypoints.push_back(wpl); - } - } - int windex = zone->random.Roll0(random_waypoints.size()); - patrol = random_waypoints[windex].index; - } + patrol = zone->random.Int(0, Waypoints.size() - 1); } if (patrol > cur_wp) cur_wp = cur_wp + 1; @@ -1029,7 +991,7 @@ void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type return; } - std::string query = StringFormat("DELETE FROM grid where id=%i and zoneid=%i", id, zoneid); + std::string query = StringFormat("DELETE FROM grid where id=%i", id); auto results = QueryDatabase(query); query = StringFormat("DELETE FROM grid_entries WHERE zoneid = %i AND gridid = %i", zoneid, id); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 545625d0d..d4fa5e572 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "client.h" #include "corpse.h" #include "entity.h" -#include "expedition.h" #include "quest_parser_collection.h" #include "guild_mgr.h" #include "mob.h" @@ -55,6 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "zone_config.h" #include "zone_reload.h" + extern EntityList entity_list; extern Zone* zone; extern volatile bool is_zone_loaded; @@ -79,14 +79,14 @@ WorldServer::~WorldServer() { void WorldServer::Connect() { - m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey); + m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey)); m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) { OnConnected(); }); m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_keepalive = std::make_unique(2500, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1)); + m_keepalive.reset(new EQ::Timer(2500, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); } bool WorldServer::SendPacket(ServerPacket *pack) @@ -472,16 +472,20 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_Motd: { - if (pack->size != sizeof(ServerMotd_Struct)) - break; + ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer; + EQApplicationPacket *outapp; + outapp = new EQApplicationPacket(OP_MOTD); + char tmp[500] = { 0 }; + sprintf(tmp, "%s", smotd->motd); - ServerMotd_Struct *smotd = (ServerMotd_Struct *)pack->pBuffer; - SerializeBuffer buf(100); - buf.WriteString(smotd->motd); + outapp->size = strlen(tmp) + 1; + outapp->pBuffer = new uchar[outapp->size]; + memset(outapp->pBuffer, 0, outapp->size); + strcpy((char*)outapp->pBuffer, tmp); - auto outapp = std::make_unique(OP_MOTD, buf); + entity_list.QueueClients(0, outapp); + safe_delete(outapp); - entity_list.QueueClients(0, outapp.get()); break; } case ServerOP_ShutdownAll: { @@ -1011,7 +1015,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) if (group->GetID() != 0) entity_list.AddGroup(group, groupid); else - safe_delete(group); + group = nullptr; } if (group) @@ -1047,7 +1051,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) int mentor_percent; GroupLeadershipAA_Struct GLAA; memset(ln, 0, 64); - database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA); + strcpy(ln, database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA)); Client *lc = entity_list.GetClientByName(ln); if (lc) group->SetLeader(lc); @@ -2439,7 +2443,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) CZTaskDisablePlayer_Struct* CZUA = (CZTaskDisablePlayer_Struct*) pack->pBuffer; auto client = entity_list.GetClientByCharID(CZUA->character_id); if (client) { - client->DisableTask(1, reinterpret_cast(CZUA->task_id)); + client->DisableTask(1, (int*) CZUA->task_id); } break; } @@ -2451,7 +2455,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { auto group_member = client_group->members[member_index]->CastToClient(); - group_member->DisableTask(1, reinterpret_cast(CZUA->task_id)); + group_member->DisableTask(1, (int*) CZUA->task_id); } } } @@ -2465,7 +2469,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { auto raid_member = client_raid->members[member_index].member->CastToClient(); - raid_member->DisableTask(1, reinterpret_cast(CZUA->task_id)); + raid_member->DisableTask(1, (int*) CZUA->task_id); } } } @@ -2476,7 +2480,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) CZTaskDisableGuild_Struct* CZUA = (CZTaskDisableGuild_Struct*) pack->pBuffer; for (auto &client : entity_list.GetClientList()) { if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) { - client.second->DisableTask(1, reinterpret_cast(CZUA->task_id)); + client.second->DisableTask(1, (int*) CZUA->task_id); } } break; @@ -2486,7 +2490,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) CZTaskEnablePlayer_Struct* CZUA = (CZTaskEnablePlayer_Struct*) pack->pBuffer; auto client = entity_list.GetClientByCharID(CZUA->character_id); if (client) { - client->EnableTask(1, reinterpret_cast(CZUA->task_id)); + client->EnableTask(1, (int*) CZUA->task_id); } break; } @@ -2498,7 +2502,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) { if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) { auto group_member = client_group->members[member_index]->CastToClient(); - group_member->EnableTask(1, reinterpret_cast(CZUA->task_id)); + group_member->EnableTask(1, (int*) CZUA->task_id); } } } @@ -2512,7 +2516,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) { if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) { auto raid_member = client_raid->members[member_index].member->CastToClient(); - raid_member->EnableTask(1, reinterpret_cast(CZUA->task_id)); + raid_member->EnableTask(1, (int*) CZUA->task_id); } } } @@ -2523,7 +2527,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) CZTaskEnableGuild_Struct* CZUA = (CZTaskEnableGuild_Struct*) pack->pBuffer; for (auto &client : entity_list.GetClientList()) { if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) { - client.second->EnableTask(1, reinterpret_cast(CZUA->task_id)); + client.second->EnableTask(1, (int*) CZUA->task_id); } } break; @@ -2650,7 +2654,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (auto &client : entity_list.GetClientList()) { auto client_status = client.second->Admin(); if (client_status >= WWDT->min_status && (client_status <= WWDT->max_status || WWDT->max_status == 0)) { - client.second->DisableTask(1, reinterpret_cast(WWDT->task_id)); + client.second->DisableTask(1, (int *) WWDT->task_id); } } break; @@ -2661,7 +2665,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) for (auto &client : entity_list.GetClientList()) { auto client_status = client.second->Admin(); if (client_status >= WWET->min_status && (client_status <= WWET->max_status || WWET->max_status == 0)) { - client.second->EnableTask(1, reinterpret_cast(WWET->task_id)); + client.second->EnableTask(1, (int *) WWET->task_id); } } break; @@ -2814,15 +2818,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_UpdateSchedulerEvents: { - LogScheduler("Received signal from world to update"); - if (m_zone_scheduler) { - m_zone_scheduler->LoadScheduledEvents(); - } - - break; - } - case ServerOP_HotReloadQuests: { if (!zone) { @@ -2851,6 +2846,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } + case ServerOP_ChangeSharedMem: { std::string hotfix_name = std::string((char*)pack->pBuffer); @@ -2885,45 +2881,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_CZClientMessageString: - { - auto buf = reinterpret_cast(pack->pBuffer); - Client* client = entity_list.GetClientByName(buf->character_name); - if (client) { - client->MessageString(buf); - } - break; - } - case ServerOP_ExpeditionCreate: - case ServerOP_ExpeditionDeleted: - case ServerOP_ExpeditionLeaderChanged: - case ServerOP_ExpeditionLockout: - case ServerOP_ExpeditionLockoutDuration: - case ServerOP_ExpeditionLockState: - case ServerOP_ExpeditionMemberChange: - case ServerOP_ExpeditionMemberSwap: - case ServerOP_ExpeditionMemberStatus: - case ServerOP_ExpeditionMembersRemoved: - case ServerOP_ExpeditionReplayOnJoin: - case ServerOP_ExpeditionGetMemberStatuses: - case ServerOP_ExpeditionDzAddPlayer: - case ServerOP_ExpeditionDzMakeLeader: - case ServerOP_ExpeditionCharacterLockout: - case ServerOP_ExpeditionExpireWarning: - { - Expedition::HandleWorldMessage(pack); - break; - } - case ServerOP_DzAddRemoveCharacter: - case ServerOP_DzRemoveAllCharacters: - case ServerOP_DzDurationUpdate: - case ServerOP_DzSetCompass: - case ServerOP_DzSetSafeReturn: - case ServerOP_DzSetZoneIn: - { - DynamicZone::HandleWorldMessage(pack); - break; - } default: { std::cout << " Unknown ZSopcode:" << (int)pack->opcode; std::cout << " size:" << pack->size << std::endl; @@ -3093,16 +3050,16 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack) if (rts->Parameter == 0) { Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks"); - safe_delete(task_manager); - task_manager = new TaskManager; - task_manager->LoadTasks(); + safe_delete(taskmanager); + taskmanager = new TaskManager; + taskmanager->LoadTasks(); if (zone) - task_manager->LoadProximities(zone->GetZoneID()); + taskmanager->LoadProximities(zone->GetZoneID()); entity_list.ReloadAllClientsTaskState(); } else { Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter); - task_manager->LoadTasks(rts->Parameter); + taskmanager->LoadTasks(rts->Parameter); entity_list.ReloadAllClientsTaskState(rts->Parameter); } @@ -3111,18 +3068,18 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack) case RELOADTASKPROXIMITIES: if (zone) { Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities"); - task_manager->LoadProximities(zone->GetZoneID()); + taskmanager->LoadProximities(zone->GetZoneID()); } break; case RELOADTASKGOALLISTS: Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists"); - task_manager->ReloadGoalLists(); + taskmanager->ReloadGoalLists(); break; case RELOADTASKSETS: Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets"); - task_manager->LoadTaskSets(); + taskmanager->LoadTaskSets(); break; default: @@ -3180,8 +3137,8 @@ void WorldServer::UpdateLFP(uint32 LeaderID, GroupLFPMemberEntry *LFPMembers) { void WorldServer::StopLFP(uint32 LeaderID) { - GroupLFPMemberEntry LFPMembers[MAX_GROUP_MEMBERS]; - UpdateLFP(LeaderID, LFPOff, 0, 0, 0, 0, "", LFPMembers); + GroupLFPMemberEntry LFPMembers; + UpdateLFP(LeaderID, LFPOff, 0, 0, 0, 0, "", &LFPMembers); } void WorldServer::HandleLFGMatches(ServerPacket *pack) { @@ -3308,14 +3265,4 @@ void WorldServer::OnKeepAlive(EQ::Timer *t) { ServerPacket pack(ServerOP_KeepAlive, 0); SendPacket(&pack); -} - -ZoneEventScheduler *WorldServer::GetScheduler() const -{ - return m_zone_scheduler; -} - -void WorldServer::SetScheduler(ZoneEventScheduler *scheduler) -{ - WorldServer::m_zone_scheduler = scheduler; -} +} \ No newline at end of file diff --git a/zone/worldserver.h b/zone/worldserver.h index bcccb67b7..1eee0b948 100644 --- a/zone/worldserver.h +++ b/zone/worldserver.h @@ -20,7 +20,6 @@ #include "../common/eq_packet_structs.h" #include "../common/net/servertalk_client_connection.h" -#include "zone_event_scheduler.h" class ServerPacket; class EQApplicationPacket; @@ -77,11 +76,6 @@ private: std::unique_ptr m_connection; std::unique_ptr m_keepalive; - - ZoneEventScheduler *m_zone_scheduler; -public: - ZoneEventScheduler *GetScheduler() const; - void SetScheduler(ZoneEventScheduler *scheduler); }; #endif diff --git a/zone/zone.cpp b/zone/zone.cpp index 2f974c35a..01850dc93 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -37,7 +37,6 @@ #include "../common/string_util.h" #include "../common/eqemu_logsys.h" -#include "expedition.h" #include "guild_mgr.h" #include "map.h" #include "npc.h" @@ -59,7 +58,6 @@ #include "zone_reload.h" #include "../common/repositories/criteria/content_filter_criteria.h" #include "../common/repositories/content_flags_repository.h" -#include "../common/repositories/zone_points_repository.h" #include #include @@ -275,9 +273,7 @@ bool Zone::LoadZoneObjects() position.y = data.y; position.z = data.z; - if (zone->HasMap()) { - data.z = zone->zonemap->FindBestZ(position, nullptr); - } + data.z = zone->zonemap->FindBestZ(position, nullptr); EQ::ItemInstance *inst = nullptr; // FatherNitwit: this dosent seem to work... @@ -860,14 +856,12 @@ void Zone::Shutdown(bool quiet) while (!zone->npctable.empty()) { itr = zone->npctable.begin(); delete itr->second; - itr->second = nullptr; zone->npctable.erase(itr); } while (!zone->merctable.empty()) { itr = zone->merctable.begin(); delete itr->second; - itr->second = nullptr; zone->merctable.erase(itr); } @@ -877,7 +871,6 @@ void Zone::Shutdown(bool quiet) while (!zone->ldon_trap_list.empty()) { itr4 = zone->ldon_trap_list.begin(); delete itr4->second; - itr4->second = nullptr; zone->ldon_trap_list.erase(itr4); } zone->ldon_trap_entry_list.clear(); @@ -941,7 +934,8 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) spawn2_timer(1000), hot_reload_timer(1000), qglobal_purge_timer(30000), - m_SafePoint(0.0f,0.0f,0.0f,0.0f), + hotzone_timer(120000), + m_SafePoint(0.0f,0.0f,0.0f), m_Graveyard(0.0f,0.0f,0.0f,0.0f) { zoneid = in_zoneid; @@ -955,7 +949,6 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) default_ruleset = 0; is_zone_time_localized = false; - process_mobs_while_empty = false; loglevelvar = 0; merchantvar = 0; @@ -963,7 +956,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) lootvar = 0; if(RuleB(TaskSystem, EnableTaskSystem)) { - task_manager->LoadProximities(zoneid); + taskmanager->LoadProximities(zoneid); } short_name = strcpy(new char[strlen(in_short_name)+1], in_short_name); @@ -1185,9 +1178,6 @@ bool Zone::Init(bool iStaticZone) { petition_list.ClearPetitions(); petition_list.ReadDatabase(); - LogInfo("Loading active Expeditions"); - Expedition::CacheAllFromDatabase(); - LogInfo("Loading timezone data"); zone->zone_time.setEQTimeZone(content_db.GetZoneTZ(zoneid, GetInstanceVersion())); @@ -1492,17 +1482,7 @@ bool Zone::Process() { { if(Instance_Timer->Check()) { - // if this is a dynamic zone instance notify system associated with it - auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID()); - if (expedition) - { - expedition->RemoveAllMembers(false); // entity list will teleport clients out immediately - } - - // instance shutting down, move corpses to graveyard or non-instanced zone at same coords - entity_list.MovePlayerCorpsesToGraveyard(true); - - entity_list.GateAllClientsToSafeReturn(); + entity_list.GateAllClients(); database.DeleteInstance(GetInstanceID()); Instance_Shutdown_Timer = new Timer(20000); //20 seconds } @@ -1512,29 +1492,20 @@ bool Zone::Process() { if(Instance_Warning_timer == nullptr) { uint32 rem_time = Instance_Timer->GetRemainingTime(); - uint32_t minutes_warning = 0; if(rem_time < 60000 && rem_time > 55000) { - minutes_warning = 1; + entity_list.ExpeditionWarning(1); + Instance_Warning_timer = new Timer(10000); } else if(rem_time < 300000 && rem_time > 295000) { - minutes_warning = 5; + entity_list.ExpeditionWarning(5); + Instance_Warning_timer = new Timer(10000); } else if(rem_time < 900000 && rem_time > 895000) { - minutes_warning = 15; - } - - if (minutes_warning > 0) - { - // expedition expire warnings are handled by world - auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID()); - if (!expedition) - { - entity_list.ExpeditionWarning(minutes_warning); - Instance_Warning_timer = new Timer(10000); - } + entity_list.ExpeditionWarning(15); + Instance_Warning_timer = new Timer(10000); } } else if(Instance_Warning_timer->Check()) @@ -1581,6 +1552,8 @@ bool Zone::Process() { } } + if(hotzone_timer.Check()) { UpdateHotzone(); } + mMovementManager->Process(); return true; @@ -1733,7 +1706,6 @@ bool Zone::Depop(bool StartSpawnTimer) { while(!npctable.empty()) { itr = npctable.begin(); delete itr->second; - itr->second = nullptr; npctable.erase(itr); } @@ -1750,7 +1722,6 @@ void Zone::ClearNPCTypeCache(int id) { auto iter = npctable.begin(); while (iter != npctable.end()) { delete iter->second; - iter->second = nullptr; ++iter; } npctable.clear(); @@ -1760,7 +1731,6 @@ void Zone::ClearNPCTypeCache(int id) { while (iter != npctable.end()) { if (iter->first == (uint32)id) { delete iter->second; - iter->second = nullptr; npctable.erase(iter); return; } @@ -1974,60 +1944,41 @@ bool ZoneDatabase::LoadStaticZonePoints(LinkedList *zone_point_list { zone_point_list->Clear(); zone->numzonepoints = 0; - zone->virtual_zone_point_list.clear(); - auto zone_points = ZonePointsRepository::GetWhere(content_db, - fmt::format( - "zone = '{}' AND (version = {} OR version = -1) {} ORDER BY number", - zonename, - version, - ContentFilterCriteria::apply() - ) + std::string query = StringFormat( + "SELECT x, y, z, target_x, target_y, " + "target_z, target_zone_id, heading, target_heading, " + "number, target_instance, client_version_mask " + "FROM zone_points WHERE zone='%s' AND (version=%i OR version=-1) %s" + "ORDER BY number", + zonename, + version, + ContentFilterCriteria::apply().c_str() ); - for (auto &zone_point : zone_points) { + auto results = QueryDatabase(query); + if (!results.Success()) { + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { auto zp = new ZonePoint; - zp->x = zone_point.x; - zp->y = zone_point.y; - zp->z = zone_point.z; - zp->target_x = zone_point.target_x; - zp->target_y = zone_point.target_y; - zp->target_z = zone_point.target_z; - zp->target_zone_id = zone_point.target_zone_id; - zp->heading = zone_point.heading; - zp->target_heading = zone_point.target_heading; - zp->number = zone_point.number; - zp->target_zone_instance = zone_point.target_instance; - zp->client_version_mask = zone_point.client_version_mask; - zp->is_virtual = zone_point.is_virtual > 0; - zp->height = zone_point.height; - zp->width = zone_point.width; - - LogZonePoints( - "Loading ZP x [{}] y [{}] z [{}] heading [{}] target x y z zone_id instance_id [{}] [{}] [{}] [{}] [{}] number [{}] is_virtual [{}] height [{}] width [{}]", - zp->x, - zp->y, - zp->z, - zp->heading, - zp->target_x, - zp->target_y, - zp->target_z, - zp->target_zone_id, - zp->target_zone_instance, - zp->number, - zp->is_virtual ? "true" : "false", - zp->height, - zp->width - ); - - if (zone_point.is_virtual) { - zone->virtual_zone_point_list.emplace_back(zone_point); - safe_delete(zp); - continue; - } + zp->x = atof(row[0]); + zp->y = atof(row[1]); + zp->z = atof(row[2]); + zp->target_x = atof(row[3]); + zp->target_y = atof(row[4]); + zp->target_z = atof(row[5]); + zp->target_zone_id = atoi(row[6]); + zp->heading = atof(row[7]); + zp->target_heading = atof(row[8]); + zp->number = atoi(row[9]); + zp->target_zone_instance = atoi(row[10]); + zp->client_version_mask = (uint32)strtoul(row[11], nullptr, 0); zone_point_list->Insert(zp); + zone->numzonepoints++; } @@ -2599,9 +2550,19 @@ uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) { return 0; } -void Zone::SetIsHotzone(bool is_hotzone) +void Zone::UpdateHotzone() { - Zone::is_hotzone = is_hotzone; + std::string query = StringFormat("SELECT hotzone FROM zone WHERE short_name = '%s'", GetShortName()); + auto results = content_db.QueryDatabase(query); + if (!results.Success()) + return; + + if (results.RowCount() == 0) + return; + + auto row = results.begin(); + + is_hotzone = atoi(row[0]) == 0 ? false: true; } void Zone::RequestUCSServerStatus() { @@ -2710,26 +2671,3 @@ void Zone::SetInstanceTimeRemaining(uint32 instance_time_remaining) { Zone::instance_time_remaining = instance_time_remaining; } - -bool Zone::IsZone(uint32 zone_id, uint16 instance_id) const -{ - return (zoneid == zone_id && instanceid == instance_id); -} - -DynamicZone* Zone::GetDynamicZone() -{ - if (GetInstanceID() == 0) - { - return nullptr; - } - - auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID()); - if (expedition) - { - return &expedition->GetDynamicZone(); - } - - // todo: tasks, missions, and quests with an associated dz for this instance id - - return nullptr; -} diff --git a/zone/zone.h b/zone/zone.h index c7c6daf12..75fd9d4cb 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -28,7 +28,6 @@ #include "zone_store.h" #include "../common/repositories/grid_repository.h" #include "../common/repositories/grid_entries_repository.h" -#include "../common/repositories/zone_points_repository.h" #include "qglobals.h" #include "spawn2.h" #include "spawngroup.h" @@ -36,8 +35,6 @@ #include "pathfinder_interface.h" #include "global_loot_manager.h" -class DynamicZone; - struct ZonePoint { float x; float y; @@ -51,9 +48,6 @@ struct ZonePoint { uint16 target_zone_id; int32 target_zone_instance; uint32 client_version_mask; - bool is_virtual; - int height; - int width; }; struct ZoneClientAuth_Struct { @@ -83,7 +77,6 @@ struct item_tick_struct { }; class Client; -class Expedition; class Map; class Mob; class WaterMap; @@ -104,7 +97,6 @@ public: AA::Ability *GetAlternateAdvancementAbilityByRank(int rank_id); AA::Rank *GetAlternateAdvancementRank(int rank_id); bool is_zone_time_localized; - bool process_mobs_while_empty; bool AggroLimitReached() { return (aggroedmobs > 10) ? true : false; } bool AllowMercs() const { return (allow_mercs); } bool CanBind() const { return (can_bind); } @@ -132,7 +124,6 @@ public: bool IsPVPZone() { return pvpzone; } bool IsSpellBlocked(uint32 spell_id, const glm::vec3 &location); bool IsUCSServerAvailable() { return m_ucss_available; } - bool IsZone(uint32 zone_id, uint16 instance_id) const; bool LoadGroundSpawns(); bool LoadZoneCFG(const char *filename, uint16 instance_id); bool LoadZoneObjects(); @@ -167,7 +158,7 @@ public: inline const uint32 &graveyard_zoneid() { return pgraveyard_zoneid; } inline const uint32 GetInstanceID() const { return instanceid; } inline const uint32 GetZoneID() const { return zoneid; } - inline glm::vec4 GetSafePoint() { return m_SafePoint; } + inline glm::vec3 GetSafePoint() { return m_SafePoint; } inline glm::vec4 GetGraveyardPoint() { return m_Graveyard; } inline std::vector GetGlobalLootTables(NPC *mob) const { return m_global_loot.GetGlobalLootTables(mob); } inline Timer *GetInstanceTimer() { return Instance_Timer; } @@ -179,14 +170,11 @@ public: void DumpMerchantList(uint32 npcid); int SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charges, bool sold = false); int32 MobsAggroCount() { return aggroedmobs; } - DynamicZone* GetDynamicZone(); - - IPathfinder *pathing; - LinkedList NPCEmoteList; - LinkedList spawn2_list; - LinkedList zone_point_list; - std::vector virtual_zone_point_list; + IPathfinder *pathing; + LinkedList NPCEmoteList; + LinkedList spawn2_list; + LinkedList zone_point_list; Map *zonemap; MercTemplate *GetMercTemplate(uint32 template_id); NewZone_Struct newzone_data; @@ -222,8 +210,6 @@ public: std::vector zone_grids; std::vector zone_grid_entries; - std::unordered_map> expedition_cache; - time_t weather_timer; Timer spawn2_timer; Timer hot_reload_timer; @@ -289,6 +275,7 @@ public: void SpawnConditionChanged(const SpawnCondition &c, int16 old_value); void SpawnStatus(Mob *client); void StartShutdownTimer(uint32 set_time = (RuleI(Zone, AutoShutdownDelay))); + void UpdateHotzone(); void UpdateQGlobal(uint32 qid, QGlobal newGlobal); void weatherSend(Client *client = nullptr); @@ -355,7 +342,6 @@ public: */ void mod_init(); void mod_repop(); - void SetIsHotzone(bool is_hotzone); private: bool allow_mercs; @@ -376,7 +362,7 @@ private: char *map_name; char *short_name; char file_name[16]; - glm::vec4 m_SafePoint; + glm::vec3 m_SafePoint; glm::vec4 m_Graveyard; int default_ruleset; int zone_total_blocked_spells; @@ -401,6 +387,7 @@ private: Timer *Weather_Timer; Timer autoshutdown_timer; Timer clientauth_timer; + Timer hotzone_timer; Timer initgrids_timer; Timer qglobal_purge_timer; ZoneSpellsBlocked *blocked_spells; @@ -408,3 +395,4 @@ private: }; #endif + diff --git a/zone/zone_event_scheduler.cpp b/zone/zone_event_scheduler.cpp deleted file mode 100644 index 4bdb2cd6f..000000000 --- a/zone/zone_event_scheduler.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "zone_event_scheduler.h" -#include "../common/rulesys.h" -#include - -void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_service) -{ - std::time_t time = std::time(nullptr); - std::tm *now = std::localtime(&time); - - // once a minute polling - if (m_last_polled_minute != now->tm_min) { - int month = (now->tm_mon + 1); - int year = (now->tm_year + 1900); - - LogSchedulerDetail( - "Polling year [{}] month [{}] day [{}] hour [{}] minute [{}]", - year, - month, - now->tm_mday, - now->tm_hour, - now->tm_min - ); - - // because stored active events could have a reference of time that has been changed since - // the time has been updated, we need to make sure we update internal fields so that - // the scheduler can properly end events if we set a new end date - SyncEventDataWithActiveEvents(); - - // active events - for (auto &e: m_active_events) { - LogSchedulerDetail("Looping active event [{}]", e.description); - - // if event becomes no longer active - if (!ValidateEventReadyToActivate(e)) { - LogSchedulerDetail("Looping active event validated [{}]", e.event_type); - if (e.event_type == ServerEvents::EVENT_TYPE_HOT_ZONE_ACTIVE) { - LogScheduler("Deactivating event [{}] disabling hotzone status", e.description); - if (search_deliminated_string(e.event_data, zone->GetShortName()) != std::string::npos) { - zone->SetIsHotzone(false); - } - RemoveActiveEvent(e); - } - - if (e.event_type == ServerEvents::EVENT_TYPE_RULE_CHANGE) { - LogScheduler("Deactivating event [{}] resetting rules to normal", e.description); - RuleManager::Instance()->LoadRules(m_database, RuleManager::Instance()->GetActiveRuleset(), true); - - // force active events clear and reapply all active events because we reset the entire state - // ideally if we could revert only the state of which was originally set we would only remove one active event - m_active_events.clear(); - } - - if (e.event_type == ServerEvents::EVENT_TYPE_CONTENT_FLAG_CHANGE) { - auto flag_name = e.event_data; - if (!flag_name.empty()) { - LogScheduler("Deactivating event [{}] resetting content flags", e.description); - content_service->ReloadContentFlags(*m_database); - } - - // force active events clear and reapply all active events because we reset the entire state - // ideally if we could revert only the state of which was originally set we would only remove one active event - m_active_events.clear(); - } - } - } - - // check for active - for (auto &e: m_events) { - - // discard uninteresting events as its less work to calculate time on events we don't care about - // different processes are interested in different events - if ( - e.event_type != ServerEvents::EVENT_TYPE_HOT_ZONE_ACTIVE && - e.event_type != ServerEvents::EVENT_TYPE_CONTENT_FLAG_CHANGE && - e.event_type != ServerEvents::EVENT_TYPE_RULE_CHANGE - ) { - continue; - } - - // the scheduler as of today manipulates events in memory and is preferred to be that way - // the scheduler changes temporary "state" in the server for a period of time for things such as - // hotzone activation, content flag activation, rule value activation - // when these events expire, the events become untoggled in memory - // there can be support for one-time events that are more suitable to run from worlds scheduler - // such as broadcasts, reloads - if (ValidateEventReadyToActivate(e) && !IsEventActive(e)) { - if (e.event_type == ServerEvents::EVENT_TYPE_HOT_ZONE_ACTIVE) { - if (search_deliminated_string(e.event_data, zone->GetShortName()) != std::string::npos) { - zone->SetIsHotzone(true); - LogScheduler("Activating Event [{}] Enabling zone as hotzone", e.description); - } - m_active_events.push_back(e); - } - - if (e.event_type == ServerEvents::EVENT_TYPE_RULE_CHANGE) { - auto params = SplitString(e.event_data, '='); - auto rule_key = params[0]; - auto rule_value = params[1]; - if (!rule_key.empty() && !rule_value.empty()) { - LogScheduler( - "Activating Event [{}] scheduled rule change, setting rule [{}] to [{}]", - e.description, - rule_key, - rule_value - ); - RuleManager::Instance()->SetRule(rule_key.c_str(), rule_value.c_str(), nullptr, false, true); - } - m_active_events.push_back(e); - } - - if (e.event_type == ServerEvents::EVENT_TYPE_CONTENT_FLAG_CHANGE) { - auto flag_name = e.event_data; - if (!flag_name.empty()) { - LogScheduler( - "Activating Event [{}] scheduled content flag change, setting flag [{}] to enabled", - e.description, - flag_name - ); - - auto flags = content_service->GetContentFlags(); - flags.push_back(flag_name); - content_service->SetContentFlags(flags); - m_active_events.push_back(e); - } - } - } - } - - m_last_polled_minute = now->tm_min; - } -} - -// because stored active events could have a reference of time that has been changed since -// the time has been updated, we need to make sure we update internal fields so that -// the scheduler can properly end events if we set a new end date -void ZoneEventScheduler::SyncEventDataWithActiveEvents() -{ - for (auto &a: m_active_events) { - for (auto &e: m_events) { - if (e.id == a.id) { - a.description = e.description; - a.event_type = e.event_type; - a.event_data = e.event_data; - a.minute_start = e.minute_start; - a.hour_start = e.hour_start; - a.day_start = e.day_start; - a.month_start = e.month_start; - a.year_start = e.year_start; - a.minute_end = e.minute_end; - a.hour_end = e.hour_end; - a.day_end = e.day_end; - a.month_end = e.month_end; - a.year_end = e.year_end; - a.cron_expression = e.cron_expression; - a.created_at = e.created_at; - a.deleted_at = e.deleted_at; - } - } - } -} diff --git a/zone/zone_event_scheduler.h b/zone/zone_event_scheduler.h deleted file mode 100644 index a2e6c67ad..000000000 --- a/zone/zone_event_scheduler.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EQEMU_ZONE_EVENT_SCHEDULER_H -#define EQEMU_ZONE_EVENT_SCHEDULER_H - -#include "../common/server_event_scheduler.h" -#include "zone.h" -#include "../common/content/world_content_service.h" - -class ZoneEventScheduler : public ServerEventScheduler { -public: - void Process(Zone *zone, WorldContentService *content_service); - void SyncEventDataWithActiveEvents(); -}; - -#endif //EQEMU_ZONE_EVENT_SCHEDULER_H diff --git a/zone/zone_store.cpp b/zone/zone_store.cpp index 467c3af25..e06737be2 100644 --- a/zone/zone_store.cpp +++ b/zone/zone_store.cpp @@ -27,7 +27,7 @@ ZoneStore::~ZoneStore() = default; void ZoneStore::LoadZones() { - zones = ZoneRepository::All(content_db); + zones = ZoneRepository::All(); } /** @@ -146,7 +146,20 @@ ZoneRepository::Zone ZoneStore::GetZone(const char *in_zone_name) */ void ZoneStore::LoadContentFlags() { - content_service.ReloadContentFlags(database); + std::vector set_content_flags; + auto content_flags = ContentFlagsRepository::GetWhere("enabled = 1"); + + set_content_flags.reserve(content_flags.size()); + for (auto &flags: content_flags) { + set_content_flags.push_back(flags.flag_name); + } + + LogInfo( + "Enabled content flags [{}]", + implode(", ", set_content_flags) + ); + + content_service.SetContentFlags(set_content_flags); } /** @@ -157,7 +170,7 @@ void ZoneStore::LoadContentFlags() */ void ZoneStore::SetContentFlag(const std::string &content_flag_name, bool enabled) { - auto content_flags = ContentFlagsRepository::GetWhere(database, + auto content_flags = ContentFlagsRepository::GetWhere( fmt::format("flag_name = '{}'", content_flag_name) ); @@ -170,10 +183,10 @@ void ZoneStore::SetContentFlag(const std::string &content_flag_name, bool enable content_flag.flag_name = content_flag_name; if (!content_flags.empty()) { - ContentFlagsRepository::UpdateOne(database, content_flag); + ContentFlagsRepository::UpdateOne(content_flag); } else { - ContentFlagsRepository::InsertOne(database, content_flag); + ContentFlagsRepository::InsertOne(content_flag); } LoadContentFlags(); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 327e43058..ad29b10dc 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -105,69 +105,68 @@ bool ZoneDatabase::GetZoneCFG( std::string query = StringFormat( "SELECT " - "ztype, " // 0 - "fog_red, " // 1 - "fog_green, " // 2 - "fog_blue, " // 3 - "fog_minclip, " // 4 - "fog_maxclip, " // 5 - "fog_red2, " // 6 - "fog_green2, " // 7 - "fog_blue2, " // 8 - "fog_minclip2, " // 9 - "fog_maxclip2, " // 10 - "fog_red3, " // 11 - "fog_green3, " // 12 - "fog_blue3, " // 13 - "fog_minclip3, " // 14 - "fog_maxclip3, " // 15 - "fog_red4, " // 16 - "fog_green4, " // 17 - "fog_blue4, " // 18 - "fog_minclip4, " // 19 - "fog_maxclip4, " // 20 - "fog_density, " // 21 - "sky, " // 22 - "zone_exp_multiplier, " // 23 - "safe_x, " // 24 - "safe_y, " // 25 - "safe_z, " // 26 - "underworld, " // 27 - "minclip, " // 28 - "maxclip, " // 29 - "time_type, " // 30 - "canbind, " // 31 - "cancombat, " // 32 - "canlevitate, " // 33 - "castoutdoor, " // 34 - "hotzone, " // 35 - "ruleset, " // 36 - "suspendbuffs, " // 37 - "map_file_name, " // 38 - "short_name, " // 39 - "rain_chance1, " // 40 - "rain_chance2, " // 41 - "rain_chance3, " // 42 - "rain_chance4, " // 43 - "rain_duration1, " // 44 - "rain_duration2, " // 45 - "rain_duration3, " // 46 - "rain_duration4, " // 47 - "snow_chance1, " // 48 - "snow_chance2, " // 49 - "snow_chance3, " // 50 - "snow_chance4, " // 51 - "snow_duration1, " // 52 - "snow_duration2, " // 53 - "snow_duration3, " // 54 - "snow_duration4, " // 55 - "gravity, " // 56 - "fast_regen_hp, " // 57 - "fast_regen_mana, " // 58 - "fast_regen_endurance, " // 59 - "npc_max_aggro_dist, " // 60 - "max_movement_update_range, " // 61 - "underworld_teleport_index " // 62 + "ztype, " // 0 + "fog_red, " // 1 + "fog_green, " // 2 + "fog_blue, " // 3 + "fog_minclip, " // 4 + "fog_maxclip, " // 5 + "fog_red2, " // 6 + "fog_green2, " // 7 + "fog_blue2, " // 8 + "fog_minclip2, " // 9 + "fog_maxclip2, " // 10 + "fog_red3, " // 11 + "fog_green3, " // 12 + "fog_blue3, " // 13 + "fog_minclip3, " // 14 + "fog_maxclip3, " // 15 + "fog_red4, " // 16 + "fog_green4, " // 17 + "fog_blue4, " // 18 + "fog_minclip4, " // 19 + "fog_maxclip4, " // 20 + "fog_density, " // 21 + "sky, " // 22 + "zone_exp_multiplier, " // 23 + "safe_x, " // 24 + "safe_y, " // 25 + "safe_z, " // 26 + "underworld, " // 27 + "minclip, " // 28 + "maxclip, " // 29 + "time_type, " // 30 + "canbind, " // 31 + "cancombat, " // 32 + "canlevitate, " // 33 + "castoutdoor, " // 34 + "hotzone, " // 35 + "ruleset, " // 36 + "suspendbuffs, " // 37 + "map_file_name, " // 38 + "short_name, " // 39 + "rain_chance1, " // 40 + "rain_chance2, " // 41 + "rain_chance3, " // 42 + "rain_chance4, " // 43 + "rain_duration1, " // 44 + "rain_duration2, " // 45 + "rain_duration3, " // 46 + "rain_duration4, " // 47 + "snow_chance1, " // 48 + "snow_chance2, " // 49 + "snow_chance3, " // 50 + "snow_chance4, " // 51 + "snow_duration1, " // 52 + "snow_duration2, " // 53 + "snow_duration3, " // 54 + "snow_duration4, " // 55 + "gravity, " // 56 + "fast_regen_hp, " // 57 + "fast_regen_mana, " // 58 + "fast_regen_endurance, " // 59 + "npc_max_aggro_dist, " // 60 + "max_movement_update_range " // 61 "FROM zone WHERE zoneidnumber = %i AND version = %i %s", zoneid, instance_id, @@ -219,7 +218,6 @@ bool ZoneDatabase::GetZoneCFG( zone_data->FastRegenMana = atoi(row[58]); zone_data->FastRegenEndurance = atoi(row[59]); zone_data->NPCAggroMaxDist = atoi(row[60]); - zone_data->underworld_teleport_index = atoi(row[62]); int bindable = 0; bindable = atoi(row[31]); @@ -639,6 +637,53 @@ void ZoneDatabase::SetDoorPlace(uint8 value,uint8 door_id,const char* zone_name) door_isopen_array[door_id] = value; } +void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id,uint8 eventid,char* detail,char* timestamp, CharacterEventLog_Struct* cel) +{ + char modifications[200]; + if(strlen(name) != 0) + sprintf(modifications,"charname=\'%s\'",name); + else if(account_id != 0) + sprintf(modifications,"accountid=%i",account_id); + + if(strlen(target) != 0) + sprintf(modifications,"%s AND target LIKE \'%%%s%%\'",modifications,target); + + if(strlen(detail) != 0) + sprintf(modifications,"%s AND description LIKE \'%%%s%%\'",modifications,detail); + + if(strlen(timestamp) != 0) + sprintf(modifications,"%s AND time LIKE \'%%%s%%\'",modifications,timestamp); + + if(eventid == 0) + eventid =1; + sprintf(modifications,"%s AND event_nid=%i",modifications,eventid); + + std::string query = StringFormat("SELECT id, accountname, accountid, status, charname, target, " + "time, descriptiontype, description FROM eventlog WHERE %s", modifications); + auto results = QueryDatabase(query); + if (!results.Success()) + return; + + int index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + if(index == 255) + break; + + cel->eld[index].id = atoi(row[0]); + strn0cpy(cel->eld[index].accountname,row[1],64); + cel->eld[index].account_id = atoi(row[2]); + cel->eld[index].status = atoi(row[3]); + strn0cpy(cel->eld[index].charactername,row[4],64); + strn0cpy(cel->eld[index].targetname,row[5],64); + sprintf(cel->eld[index].timestamp,"%s",row[6]); + strn0cpy(cel->eld[index].descriptiontype,row[7],64); + strn0cpy(cel->eld[index].details,row[8],128); + cel->eventid = eventid; + cel->count = index + 1; + } + +} + // Load child objects for a world container (i.e., forge, bag dropped to ground, etc) void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQ::ItemInstance* container) { @@ -1470,7 +1515,7 @@ bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Str if (index < 0 || index > 4) continue; - pp->binds[index].zone_id = atoi(row[1]); + pp->binds[index].zoneId = atoi(row[1]); pp->binds[index].instance_id = atoi(row[2]); pp->binds[index].x = atoi(row[3]); pp->binds[index].y = atoi(row[4]); @@ -1493,10 +1538,10 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, const BindStruct std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot) VALUES (%u, " "%u, %u, %f, %f, %f, %f, %i)", - character_id, bind.zone_id, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); + character_id, bind.zoneId, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); LogDebug("ZoneDatabase::SaveCharacterBindPoint for character ID: [{}] zone_id: [{}] instance_id: [{}] position: [{}] [{}] [{}] [{}] bind_num: [{}]", - character_id, bind.zone_id, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); + character_id, bind.zoneId, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); auto results = QueryDatabase(query); if (!results.RowsAffected()) @@ -2478,8 +2523,7 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load "npc_types.stuck_behavior, " "npc_types.model, " "npc_types.flymode, " - "npc_types.always_aggro, " - "npc_types.exp_mod " + "npc_types.always_aggro " "FROM npc_types %s", where_condition.c_str() ); @@ -2682,7 +2726,6 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load temp_npctype_data->use_model = atoi(row[110]); temp_npctype_data->flymode = atoi(row[111]); temp_npctype_data->always_aggro = atoi(row[112]); - temp_npctype_data->exp_mod = atoi(row[113]); temp_npctype_data->skip_auto_scale = false; // hardcoded here for now @@ -3745,14 +3788,13 @@ void ZoneDatabase::SavePetInfo(Client *client) continue; query = StringFormat("INSERT INTO `character_pet_info` " - "(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`, `taunting`) " - "VALUES (%u, %u, '%s', %i, %u, %u, %u, %f, %u) " + "(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) " + "VALUES (%u, %u, '%s', %i, %u, %u, %u, %f) " "ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, " - "`hp` = %u, `mana` = %u, `size` = %f, `taunting` = %u", + "`hp` = %u, `mana` = %u, `size` = %f", client->CharacterID(), pet, petinfo->Name, petinfo->petpower, petinfo->SpellID, - petinfo->HP, petinfo->Mana, petinfo->size, (petinfo->taunting) ? 1 : 0, - // and now the ON DUPLICATE ENTRIES - petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size, (petinfo->taunting) ? 1 : 0); + petinfo->HP, petinfo->Mana, petinfo->size, // and now the ON DUPLICATE ENTRIES + petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size); results = database.QueryDatabase(query); if (!results.Success()) return; @@ -3824,7 +3866,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) memset(suspended, 0, sizeof(PetInfo)); std::string query = StringFormat("SELECT `pet`, `petname`, `petpower`, `spell_id`, " - "`hp`, `mana`, `size` , `taunting` FROM `character_pet_info` " + "`hp`, `mana`, `size` FROM `character_pet_info` " "WHERE `char_id` = %u", client->CharacterID()); auto results = database.QueryDatabase(query); @@ -3849,7 +3891,6 @@ void ZoneDatabase::LoadPetInfo(Client *client) pi->HP = atoul(row[4]); pi->Mana = atoul(row[5]); pi->size = atof(row[6]); - pi->taunting = (bool) atoi(row[7]); } query = StringFormat("SELECT `pet`, `slot`, `spell_id`, `caster_level`, `castername`, " @@ -4255,18 +4296,6 @@ uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, return dbid; } -void ZoneDatabase::SendCharacterCorpseToNonInstance(uint32 corpse_db_id) -{ - if (corpse_db_id != 0) - { - auto query = fmt::format(SQL( - UPDATE character_corpses SET instance_id = 0 WHERE id = {}; - ), corpse_db_id); - - QueryDatabase(query); - } -} - uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){ std::string query = StringFormat("SELECT(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) FROM `character_corpses` WHERE `id` = %d AND NOT `time_of_death` = 0", corpse_db_id); auto results = QueryDatabase(query); @@ -4893,85 +4922,3 @@ uint32 ZoneDatabase::SaveSaylinkID(const char* saylink_text) return results.LastInsertedID(); } - -double ZoneDatabase::GetAAEXPModifier(uint32 character_id, uint32 zone_id) const { - std::string query = fmt::format( - SQL( - SELECT - `aa_modifier` - FROM - `character_exp_modifiers` - WHERE - `character_id` = {} - AND - (`zone_id` = {} OR `zone_id` = 0) - ORDER BY `zone_id` DESC - LIMIT 1 - ), - character_id, - zone_id - ); - auto results = database.QueryDatabase(query); - for (auto row = results.begin(); row != results.end(); ++row) { - return atof(row[0]); - } - return 1.0f; -} - -double ZoneDatabase::GetEXPModifier(uint32 character_id, uint32 zone_id) const { - std::string query = fmt::format( - SQL( - SELECT - `exp_modifier` - FROM - `character_exp_modifiers` - WHERE - `character_id` = {} - AND - (`zone_id` = {} OR `zone_id` = 0) - ORDER BY `zone_id` DESC - LIMIT 1 - ), - character_id, - zone_id - ); - auto results = database.QueryDatabase(query); - for (auto row = results.begin(); row != results.end(); ++row) { - return atof(row[0]); - } - return 1.0f; -} - -void ZoneDatabase::SetAAEXPModifier(uint32 character_id, uint32 zone_id, double aa_modifier) { - float exp_modifier = GetEXPModifier(character_id, zone_id); - std::string query = fmt::format( - SQL( - REPLACE INTO - `character_exp_modifiers` - VALUES - ({}, {}, {}, {}) - ), - character_id, - zone_id, - aa_modifier, - exp_modifier - ); - database.QueryDatabase(query); -} - -void ZoneDatabase::SetEXPModifier(uint32 character_id, uint32 zone_id, double exp_modifier) { - float aa_modifier = GetAAEXPModifier(character_id, zone_id); - std::string query = fmt::format( - SQL( - REPLACE INTO - `character_exp_modifiers` - VALUES - ({}, {}, {}, {}) - ), - character_id, - zone_id, - aa_modifier, - exp_modifier - ); - database.QueryDatabase(query); -} diff --git a/zone/zonedb.h b/zone/zonedb.h index d7e41ecb0..f3766c05c 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -23,6 +23,7 @@ class Petition; class Spawn2; class SpawnGroupList; class Trap; +struct CharacterEventLog_Struct; struct Door; struct ExtendedProfile_Struct; struct NPCType; @@ -51,7 +52,7 @@ struct wplist { #pragma pack(1) struct DBnpcspells_entries_Struct { - uint16 spellid; + int16 spellid; uint8 minlevel; uint8 maxlevel; uint32 type; @@ -154,7 +155,6 @@ struct PetInfo { SpellBuff_Struct Buffs[PET_BUFF_COUNT]; uint32 Items[EQ::invslot::EQUIPMENT_COUNT]; char Name[64]; - bool taunting; }; struct ZoneSpellsBlocked { @@ -319,7 +319,7 @@ public: bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level, uint32 charges); bool SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name); - bool SaveCharacterBindPoint(uint32 character_id, const BindStruct &bind, uint32 bind_number); + bool SaveCharacterBindPoint(uint32 character_id, const BindStruct &bind, uint32 bind_num); bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp); bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp); bool SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id); @@ -331,11 +331,6 @@ public: bool SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value); bool SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id); bool SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp); - - double GetAAEXPModifier(uint32 character_id, uint32 zone_id) const; - double GetEXPModifier(uint32 character_id, uint32 zone_id) const; - void SetAAEXPModifier(uint32 character_id, uint32 zone_id, double aa_modifier); - void SetEXPModifier(uint32 character_id, uint32 zone_id, double exp_modifier); /* Character Inventory */ bool NoRentExpired(const char* name); @@ -380,7 +375,6 @@ public: uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse); uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slotid); uint32 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type); - void SendCharacterCorpseToNonInstance(uint32 corpse_db_id); /* Faction */ bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0); @@ -555,6 +549,7 @@ public: * REALLY HAS NO BETTER SECTION */ bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid); + void GetEventLogs(const char* name,char* target,uint32 account_id=0,uint8 eventid=0,char* detail=0,char* timestamp=0, CharacterEventLog_Struct* cel=0); uint32 GetKarma(uint32 acct_id); void UpdateKarma(uint32 acct_id, uint32 amount); diff --git a/zone/zonedump.h b/zone/zonedump.h index 09f11b65b..a30ec9f5f 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -148,7 +148,6 @@ struct NPCType uint16 use_model; int8 flymode; bool always_aggro; - int exp_mod; }; namespace player_lootitem { diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 0d088aadf..2e0b46d78 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -21,7 +21,6 @@ #include "../common/rulesys.h" #include "../common/string_util.h" -#include "expedition.h" #include "queryserv.h" #include "quest_parser_collection.h" #include "string_ids.h" @@ -78,11 +77,11 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { target_zone_id = zonesummon_id; break; case GateToBindPoint: - target_zone_id = m_pp.binds[0].zone_id; + target_zone_id = m_pp.binds[0].zoneId; target_instance_id = m_pp.binds[0].instance_id; break; case ZoneToBindPoint: - target_zone_id = m_pp.binds[0].zone_id; + target_zone_id = m_pp.binds[0].zoneId; target_instance_id = m_pp.binds[0].instance_id; break; case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going. @@ -170,21 +169,11 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { } /* Load up the Safe Coordinates, restrictions and verify the zone name*/ - float safe_x, safe_y, safe_z, safe_heading; - int16 min_status = 0; - uint8 min_level = 0; + float safe_x, safe_y, safe_z; + int16 minstatus = 0; + uint8 minlevel = 0; char flag_needed[128]; - if(!content_db.GetSafePoints( - target_zone_name, - database.GetInstanceVersion(target_instance_id), - &safe_x, - &safe_y, - &safe_z, - &safe_heading, - &min_status, - &min_level, - flag_needed - )) { + if(!content_db.GetSafePoints(target_zone_name, database.GetInstanceVersion(target_instance_id), &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_needed)) { //invalid zone... Message(Chat::Red, "Invalid target zone while getting safe points."); LogError("Zoning [{}]: Unable to get safe coordinates for zone [{}]", GetName(), target_zone_name); @@ -199,54 +188,41 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //handle circumvention of zone restrictions //we need the value when creating the outgoing packet as well. - uint8 ignore_restrictions = zonesummon_ignorerestrictions; + uint8 ignorerestrictions = zonesummon_ignorerestrictions; zonesummon_ignorerestrictions = 0; - float target_x = 0, target_y = 0, target_z = 0, target_heading = 0; + float dest_x=0, dest_y=0, dest_z=0, dest_h; + dest_h = GetHeading(); switch(zone_mode) { case EvacToSafeCoords: case ZoneToSafeCoords: - LogDebug( - "Zoning [{}] to safe coords ([{}], [{}], [{}], [{}]) in [{}] ([{}])", - GetName(), - safe_x, - safe_y, - safe_z, - safe_heading, - target_zone_name, - target_zone_id - ); - target_x = safe_x; - target_y = safe_y; - target_z = safe_z; - target_heading = safe_heading; + LogDebug("Zoning [{}] to safe coords ([{}],[{}],[{}]) in [{}] ([{}])", GetName(), safe_x, safe_y, safe_z, target_zone_name, target_zone_id); + dest_x = safe_x; + dest_y = safe_y; + dest_z = safe_z; break; case GMSummon: - target_x = m_ZoneSummonLocation.x; - target_y = m_ZoneSummonLocation.y; - target_z = m_ZoneSummonLocation.z; - target_heading = m_ZoneSummonLocation.w; - ignore_restrictions = 1; + dest_x = m_ZoneSummonLocation.x; + dest_y = m_ZoneSummonLocation.y; + dest_z = m_ZoneSummonLocation.z; + ignorerestrictions = 1; break; case GateToBindPoint: - target_x = m_pp.binds[0].x; - target_y = m_pp.binds[0].y; - target_z = m_pp.binds[0].z; - target_heading = m_pp.binds[0].heading; + dest_x = m_pp.binds[0].x; + dest_y = m_pp.binds[0].y; + dest_z = m_pp.binds[0].z; break; case ZoneToBindPoint: - target_x = m_pp.binds[0].x; - target_y = m_pp.binds[0].y; - target_z = m_pp.binds[0].z; - target_heading = m_pp.binds[0].heading; - ignore_restrictions = 1; //can always get to our bind point? seems exploitable + dest_x = m_pp.binds[0].x; + dest_y = m_pp.binds[0].y; + dest_z = m_pp.binds[0].z; + ignorerestrictions = 1; //can always get to our bind point? seems exploitable break; case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going. //recycle zonesummon variables - target_x = m_ZoneSummonLocation.x; - target_y = m_ZoneSummonLocation.y; - target_z = m_ZoneSummonLocation.z; - target_heading = m_ZoneSummonLocation.w; + dest_x = m_ZoneSummonLocation.x; + dest_y = m_ZoneSummonLocation.y; + dest_z = m_ZoneSummonLocation.z; break; case ZoneUnsolicited: //client came up with this on its own. //client requested a zoning... what are the cases when this could happen? @@ -257,24 +233,21 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //999999 is a placeholder for 'same as where they were from' if(zone_point->target_x == 999999) - target_x = GetX(); + dest_x = GetX(); else - target_x = zone_point->target_x; - + dest_x = zone_point->target_x; if(zone_point->target_y == 999999) - target_y = GetY(); + dest_y = GetY(); else - target_y = zone_point->target_y; - + dest_y = zone_point->target_y; if(zone_point->target_z == 999999) - target_z = GetZ(); + dest_z=GetZ(); else - target_z = zone_point->target_z; - + dest_z = zone_point->target_z; if(zone_point->target_heading == 999) - target_heading = GetHeading(); + dest_h = GetHeading(); else - target_heading = zone_point->target_heading; + dest_h = zone_point->target_heading; break; } @@ -298,12 +271,12 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //not sure when we would use ZONE_ERROR_NOTREADY //enforce min status and level - if (!ignore_restrictions && (Admin() < min_status || GetLevel() < min_level)) + if (!ignorerestrictions && (Admin() < minstatus || GetLevel() < minlevel)) { myerror = ZONE_ERROR_NOEXPERIENCE; } - if(!ignore_restrictions && flag_needed[0] != '\0') { + if(!ignorerestrictions && flag_needed[0] != '\0') { //the flag needed string is not empty, meaning a flag is required. if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(target_zone_id)) { @@ -339,7 +312,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { * In 99% of cases we would never get here and this would be fallback */ if (!found_zone) { - auto zones = ZoneRepository::GetWhere(content_db, + auto zones = ZoneRepository::GetWhere( fmt::format( "expansion <= {} AND short_name = '{}' and version = 0", (content_service.GetCurrentExpansion() + 1), @@ -363,13 +336,9 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { } } - if (content_service.GetCurrentExpansion() >= Expansion::Classic && GetGM()) { - LogInfo("[{}] Bypassing Expansion zone checks because GM status is set", GetCleanName()); - } - if(myerror == 1) { //we have successfully zoned - DoZoneSuccess(zc, target_zone_id, target_instance_id, target_x, target_y, target_z, target_heading, ignore_restrictions); + DoZoneSuccess(zc, target_zone_id, target_instance_id, dest_x, dest_y, dest_z, dest_h, ignorerestrictions); } else { LogError("Zoning [{}]: Rules prevent this char from zoning into [{}]", GetName(), target_zone_name); SendZoneError(zc, myerror); @@ -431,16 +400,6 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc if(this->GetPet()) entity_list.RemoveFromHateLists(this->GetPet()); - if (GetPendingExpeditionInviteID() != 0) - { - // live re-invites if client zoned with a pending invite, save pending invite info in world - auto expedition = Expedition::FindCachedExpeditionByID(GetPendingExpeditionInviteID()); - if (expedition) - { - expedition->SendWorldPendingInvite(m_pending_expedition_invite, GetName()); - } - } - LogInfo("Zoning [{}] to: [{}] ([{}]) - ([{}]) x [{}] y [{}] z [{}]", m_pp.name, ZoneName(zone_id), zone_id, instance_id, dest_x, dest_y, dest_z); //set the player's coordinates in the new zone so they have them @@ -489,7 +448,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc //reset to unsolicited. zone_mode = ZoneUnsolicited; - m_ZoneSummonLocation = glm::vec4(); + m_ZoneSummonLocation = glm::vec3(); zonesummon_id = 0; zonesummon_ignorerestrictions = 0; } @@ -616,7 +575,7 @@ void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, return; } - if(zm != SummonPC && GetPetID() != 0) { + if(GetPetID() != 0) { //if they have a pet and they are staying in zone, move with them Mob *p = GetPet(); if(p != nullptr){ @@ -673,24 +632,29 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z return; } iZoneNameLength = strlen(pZoneName); - glm::vec4 zone_safe_point; + glm::vec3 safePoint; + switch(zm) { case EvacToSafeCoords: case ZoneToSafeCoords: - zone_safe_point = zone->GetSafePoint(); - x = zone_safe_point.x; - y = zone_safe_point.y; - z = zone_safe_point.z; - heading = zone_safe_point.w; + safePoint = zone->GetSafePoint(); + x = safePoint.x; + y = safePoint.y; + z = safePoint.z; + SetHeading(heading); break; case GMSummon: m_Position = glm::vec4(x, y, z, heading); - m_ZoneSummonLocation = m_Position; + m_ZoneSummonLocation = glm::vec3(m_Position); + SetHeading(heading); + zonesummon_id = zoneID; zonesummon_ignorerestrictions = 1; break; case ZoneSolicited: - m_ZoneSummonLocation = glm::vec4(x, y, z, heading); + m_ZoneSummonLocation = glm::vec3(x,y,z); + SetHeading(heading); + zonesummon_id = zoneID; zonesummon_ignorerestrictions = ignorerestrictions; break; @@ -705,20 +669,23 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z y = m_Position.y = m_pp.binds[0].y; z = m_Position.z = m_pp.binds[0].z; heading = m_pp.binds[0].heading; + zonesummon_ignorerestrictions = 1; LogDebug("Player [{}] has died and will be zoned to bind point in zone: [{}] at LOC x=[{}], y=[{}], z=[{}], heading=[{}]", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading); break; case SummonPC: - m_ZoneSummonLocation = glm::vec4(x, y, z, heading); - m_Position = m_ZoneSummonLocation; + m_ZoneSummonLocation = glm::vec3(x, y, z); + m_Position = glm::vec4(m_ZoneSummonLocation, 0.0f); + SetHeading(heading); break; case Rewind: LogDebug("[{}] has requested a /rewind from [{}], [{}], [{}], to [{}], [{}], [{}] in [{}]", GetName(), m_Position.x, m_Position.y, m_Position.z, m_RewindLocation.x, m_RewindLocation.y, m_RewindLocation.z, zone->GetShortName()); - m_ZoneSummonLocation = glm::vec4(x, y, z, heading); - m_Position = m_ZoneSummonLocation; + m_ZoneSummonLocation = glm::vec3(x, y, z); + m_Position = glm::vec4(m_ZoneSummonLocation, 0.0f); + SetHeading(heading); break; default: LogError("Client::ZonePC() received a reguest to perform an unsupported client zone operation"); @@ -865,7 +832,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z { if(zm != EvacToSafeCoords && zm != ZoneToSafeCoords && zm != ZoneToBindPoint) { - m_ZoneSummonLocation = glm::vec4(); + m_ZoneSummonLocation = glm::vec3(); zonesummon_id = 0; zonesummon_ignorerestrictions = 0; zone_mode = ZoneUnsolicited; @@ -884,100 +851,61 @@ void Client::GoToSafeCoords(uint16 zone_id, uint16 instance_id) { } -void Mob::Gate(uint8 bind_number) { - GoToBind(bind_number); +void Mob::Gate(uint8 bindnum) { + GoToBind(bindnum); if (RuleB(NPC, NPCHealOnGate) && this->IsNPC() && this->GetHPRatio() <= RuleR(NPC, NPCHealOnGateAmount)) { auto HealAmount = (RuleR(NPC, NPCHealOnGateAmount) / 100); SetHP(int(this->GetMaxHP() * HealAmount)); } } -void Client::Gate(uint8 bind_number) { - Mob::Gate(bind_number); +void Client::Gate(uint8 bindnum) { + Mob::Gate(bindnum); } -void NPC::Gate(uint8 bind_number) { +void NPC::Gate(uint8 bindnum) { entity_list.MessageCloseString(this, true, RuleI(Range, SpellMessages), Chat::Spells, GATES, GetCleanName()); - Mob::Gate(bind_number); + Mob::Gate(bindnum); } -void Client::SetBindPoint(int bind_number, int to_zone, int to_instance, const glm::vec3 &location) +void Client::SetBindPoint(int bind_num, int to_zone, int to_instance, const glm::vec3 &location) { - if (bind_number < 0 || bind_number >= 4) - bind_number = 0; + if (bind_num < 0 || bind_num >= 4) + bind_num = 0; if (to_zone == -1) { - m_pp.binds[bind_number].zone_id = zone->GetZoneID(); - m_pp.binds[bind_number].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; - m_pp.binds[bind_number].x = m_Position.x; - m_pp.binds[bind_number].y = m_Position.y; - m_pp.binds[bind_number].z = m_Position.z; + m_pp.binds[bind_num].zoneId = zone->GetZoneID(); + m_pp.binds[bind_num].instance_id = + (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; + m_pp.binds[bind_num].x = m_Position.x; + m_pp.binds[bind_num].y = m_Position.y; + m_pp.binds[bind_num].z = m_Position.z; } else { - m_pp.binds[bind_number].zone_id = to_zone; - m_pp.binds[bind_number].instance_id = to_instance; - m_pp.binds[bind_number].x = location.x; - m_pp.binds[bind_number].y = location.y; - m_pp.binds[bind_number].z = location.z; + m_pp.binds[bind_num].zoneId = to_zone; + m_pp.binds[bind_num].instance_id = to_instance; + m_pp.binds[bind_num].x = location.x; + m_pp.binds[bind_num].y = location.y; + m_pp.binds[bind_num].z = location.z; } - database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[bind_number], bind_number); + database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[bind_num], bind_num); } -void Client::SetBindPoint2(int bind_number, int to_zone, int to_instance, const glm::vec4 &location) -{ - if (bind_number < 0 || bind_number >= 4) - bind_number = 0; - - if (to_zone == -1) { - m_pp.binds[bind_number].zone_id = zone->GetZoneID(); - m_pp.binds[bind_number].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; - m_pp.binds[bind_number].x = m_Position.x; - m_pp.binds[bind_number].y = m_Position.y; - m_pp.binds[bind_number].z = m_Position.z; - m_pp.binds[bind_number].heading = m_Position.w; - } else { - m_pp.binds[bind_number].zone_id = to_zone; - m_pp.binds[bind_number].instance_id = to_instance; - m_pp.binds[bind_number].x = location.x; - m_pp.binds[bind_number].y = location.y; - m_pp.binds[bind_number].z = location.z; - m_pp.binds[bind_number].heading = location.w; - } - database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[bind_number], bind_number); -} - -void Client::GoToBind(uint8 bind_number) { +void Client::GoToBind(uint8 bindnum) { // if the bind number is invalid, use the primary bind - if(bind_number > 4) - bind_number = 0; + if(bindnum > 4) + bindnum = 0; // move the client, which will zone them if needed. // ignore restrictions on the zone request..? - if(bind_number == 0) - MovePC( - m_pp.binds[0].zone_id, - m_pp.binds[0].instance_id, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1, - GateToBindPoint - ); + if(bindnum == 0) + MovePC(m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, 0.0f, 0.0f, 0.0f, 0.0f, 1, GateToBindPoint); else - MovePC( - m_pp.binds[bind_number].zone_id, - m_pp.binds[bind_number].instance_id, - m_pp.binds[bind_number].x, - m_pp.binds[bind_number].y, - m_pp.binds[bind_number].z, - m_pp.binds[bind_number].heading, - 1 - ); + MovePC(m_pp.binds[bindnum].zoneId, m_pp.binds[bindnum].instance_id, m_pp.binds[bindnum].x, m_pp.binds[bindnum].y, m_pp.binds[bindnum].z, m_pp.binds[bindnum].heading, 1); } void Client::GoToDeath() { - MovePC(m_pp.binds[0].zone_id, m_pp.binds[0].instance_id, 0.0f, 0.0f, 0.0f, 0.0f, 1, ZoneToBindPoint); + MovePC(m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, 0.0f, 0.0f, 0.0f, 0.0f, 1, ZoneToBindPoint); } void Client::SetZoneFlag(uint32 zone_id) { @@ -1039,28 +967,26 @@ void Client::SendZoneFlagInfo(Client *to) const { to->Message(Chat::White, "Flags for %s:", GetName()); for(; cur != end; ++cur) { - uint32 zone_id = *cur; - const char* zone_short_name = ZoneName(zone_id); - std::string zone_long_name = zone_store.GetZoneLongName(zone_id); - float safe_x, safe_y, safe_z, safe_heading; - int16 min_status = 0; - uint8 min_level = 0; + uint32 zoneid = *cur; + + const char *short_name = ZoneName(zoneid); + + char *long_name = nullptr; + content_db.GetZoneLongName(short_name, &long_name); + if(long_name == nullptr) + long_name = empty; + + float safe_x, safe_y, safe_z; + int16 minstatus = 0; + uint8 minlevel = 0; char flag_name[128]; - if(!content_db.GetSafePoints( - zone_short_name, - 0, - &safe_x, - &safe_y, - &safe_z, - &safe_heading, - &min_status, - &min_level, - flag_name - )) { + if(!content_db.GetSafePoints(short_name, 0, &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_name)) { strcpy(flag_name, "(ERROR GETTING NAME)"); } - to->Message(Chat::White, "Has Flag %s for zone %s (%d,%s)", flag_name, zone_long_name.c_str(), zone_id, zone_short_name); + to->Message(Chat::White, "Has Flag %s for zone %s (%d,%s)", flag_name, long_name, zoneid, short_name); + if(long_name != empty) + delete[] long_name; } } @@ -1072,32 +998,22 @@ bool Client::CanBeInZone() { if(Admin() >= RuleI(GM, MinStatusToZoneAnywhere)) return(true); - float safe_x, safe_y, safe_z, safe_heading; - int16 min_status = 0; - uint8 min_level = 0; + float safe_x, safe_y, safe_z; + int16 minstatus = 0; + uint8 minlevel = 0; char flag_needed[128]; - if(!content_db.GetSafePoints( - zone->GetShortName(), - zone->GetInstanceVersion(), - &safe_x, - &safe_y, - &safe_z, - &safe_heading, - &min_status, - &min_level, - flag_needed - )) { + if(!content_db.GetSafePoints(zone->GetShortName(), zone->GetInstanceVersion(), &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_needed)) { //this should not happen... LogDebug("[CLIENT] Unable to query zone info for ourself [{}]", zone->GetShortName()); return(false); } - if(GetLevel() < min_level) { - LogDebug("[CLIENT] Character does not meet min level requirement ([{}] < [{}])!", GetLevel(), min_level); + if(GetLevel() < minlevel) { + LogDebug("[CLIENT] Character does not meet min level requirement ([{}] < [{}])!", GetLevel(), minlevel); return(false); } - if(Admin() < min_status) { - LogDebug("[CLIENT] Character does not meet min status requirement ([{}] < [{}])!", Admin(), min_status); + if(Admin() < minstatus) { + LogDebug("[CLIENT] Character does not meet min status requirement ([{}] < [{}])!", Admin(), minstatus); return(false); }