mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-24 05:52:28 +00:00
Compare commits
162 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6792db2cdd | |||
| 871657c68b | |||
| 8f21b01b7e | |||
| 591fa003c6 | |||
| f3e09abf22 | |||
| 18e6e5e5e2 | |||
| 698a814fc3 | |||
| fb820f4fec | |||
| 0d84a73e9f | |||
| b92d6c57a1 | |||
| 8c6fefa33e | |||
| e03a90b05d | |||
| c030e1ce8d | |||
| 7e49a21b3b | |||
| 9e824876ba | |||
| 891fa0411c | |||
| a4fda2a951 | |||
| ffdc933ce0 | |||
| e3f15de1f8 | |||
| 6cef5c6beb | |||
| da08a622f1 | |||
| 50a67c76e7 | |||
| 0a4ccb11aa | |||
| 30157a37a2 | |||
| f5827174ee | |||
| 1d19bd11d0 | |||
| 6a2be94282 | |||
| 630ea0d3c6 | |||
| 55e78cd8e9 | |||
| a13e32498a | |||
| 18693998b9 | |||
| 908a7061cf | |||
| 648078d76c | |||
| 06279b18a3 | |||
| f53b95d141 | |||
| e680a0f704 | |||
| 019586abbd | |||
| 8f5ba05e75 | |||
| 427fb08561 | |||
| 343c23cc6c | |||
| ac0332c020 | |||
| c1fbfc0f44 | |||
| d305d67279 | |||
| 3cc7d0db63 | |||
| 1b1d8700ae | |||
| 6994157184 | |||
| bf25c65868 | |||
| 6311d82095 | |||
| 491cabfe8b | |||
| fddb6f67ab | |||
| 26985496d1 | |||
| ab0f883191 | |||
| 538ff873ee | |||
| d0e6bb6e07 | |||
| 6cbb4bcf47 | |||
| d99df2540d | |||
| f5a0b994dc | |||
| 246f770e8f | |||
| 95efc3a66c | |||
| baf9336617 | |||
| 0ab0c5c117 | |||
| c482738d79 | |||
| a4c9fa6a65 | |||
| bb8fc17189 | |||
| b61c7d0b14 | |||
| 0d9af27a03 | |||
| 3e50491619 | |||
| de92c277e0 | |||
| ffbc913b9d | |||
| 286bfa7af6 | |||
| b5e324af83 | |||
| d9e0708331 | |||
| a121675161 | |||
| bbd2796ea4 | |||
| 5a08e0ffd9 | |||
| 3dec02881a | |||
| 04c8fe7d2c | |||
| e8d80a436e | |||
| 3447c86562 | |||
| 71e641c882 | |||
| cb1d0a0bef | |||
| 34ffb5b908 | |||
| e7e379c71b | |||
| b3842ba72a | |||
| a3c16ecdbe | |||
| 72e7465e16 | |||
| 4af996e359 | |||
| 462dea67e1 | |||
| e23fd269d5 | |||
| 06e2f76c05 | |||
| b1f97712f1 | |||
| cbe53951f8 | |||
| 66f253553a | |||
| 7f4ce3faf5 | |||
| a29177de9e | |||
| a15df2ec2c | |||
| cbb7090615 | |||
| b9fefc95e8 | |||
| 60406ebcc1 | |||
| a6f5571750 | |||
| aabf7b9b5a | |||
| aa56e8aac4 | |||
| db7f0cc977 | |||
| 95064947b6 | |||
| 714464481f | |||
| 6abed18eb9 | |||
| 752821f22b | |||
| 409bad8108 | |||
| 97999a63b7 | |||
| fe968f83a3 | |||
| 9545684883 | |||
| 6e0cba566f | |||
| 16fa32e65b | |||
| e3e20a947b | |||
| d1f7448b25 | |||
| d62ceaefcc | |||
| ec548874cc | |||
| 9a225bc396 | |||
| 101002d635 | |||
| 04f4fd652b | |||
| 1cb79c8c1f | |||
| 195bc03645 | |||
| 3438247904 | |||
| 9f01d14c64 | |||
| 7071b27183 | |||
| bfd07b1010 | |||
| 8b5dd58e96 | |||
| decaadfe7d | |||
| e29ec16759 | |||
| 16642b7c4c | |||
| 2188be24e4 | |||
| 70b9ff384c | |||
| 56babc1801 | |||
| 3ba199e052 | |||
| 8496bf16ff | |||
| e86fca3aff | |||
| 46cbd147b5 | |||
| 05ed623056 | |||
| c90a436db3 | |||
| 1e865a5246 | |||
| 343c41bb18 | |||
| a5b19d0c0d | |||
| c263c4ef07 | |||
| 7b5ea9e99c | |||
| 013f7cfd21 | |||
| 379ef7eed3 | |||
| 329c9c8d98 | |||
| 4fa8c89e5c | |||
| 19b6a96063 | |||
| 6079b34a2a | |||
| 4cb7d9a352 | |||
| b04844aa94 | |||
| b15ada974f | |||
| e2587b78f5 | |||
| 06dfba3c81 | |||
| 8aa942cd27 | |||
| a9070b1327 | |||
| 745510ea75 | |||
| f6d721dd72 | |||
| 0503e85fd3 | |||
| 0232f4f672 | |||
| 56d355935b |
@@ -35,3 +35,8 @@ Build_64/
|
||||
build_64/
|
||||
log/
|
||||
logs/
|
||||
|
||||
submodules/
|
||||
.idea/
|
||||
cmake-build-debug
|
||||
EQEmu.cbp
|
||||
+5
-10
@@ -323,8 +323,7 @@ IF(EQEMU_BUILD_LUA)
|
||||
SET(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/boost")
|
||||
|
||||
FIND_PACKAGE(Boost REQUIRED)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}" "luabind")
|
||||
|
||||
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
||||
IF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
@@ -332,18 +331,14 @@ IF(EQEMU_BUILD_LUA)
|
||||
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/common/glm")
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${MySQL_INCLUDE_DIR}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/common/glm")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/cereal")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/libuv/include" )
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/libuv/src")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/format")
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_SUBDIRECTORY(luabind)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(libs)
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||
IF(EQEMU_BUILD_SERVER)
|
||||
ADD_SUBDIRECTORY(shared_memory)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# EQEmulator Core Server
|
||||
|Travis CI (Linux)|Appveyor (Windows) |
|
||||
|:---:|:---:|
|
||||
|:---:|:---:|
|
||||
|[](https://travis-ci.org/EQEmu/Server) |[](https://ci.appveyor.com/project/KimLS/server/branch/master) |
|
||||
|
||||
***
|
||||
|
||||
+238
-134
@@ -1,5 +1,109 @@
|
||||
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
||||
-------------------------------------------------------
|
||||
== 12/03/2016 ==
|
||||
Uleat: Added hack detection to trade code
|
||||
- If illegal items are found in trade slots when the 'trade' button is clicked, the trade is cancelled and a message is sent to the offending player
|
||||
- Future revisions will, at a minimum, log the player as a hacker once the quirks have been worked out
|
||||
|
||||
== 12/01/2016 ==
|
||||
Uleat: Disabled RoF+ clients from augmenting items not in their possessions slots (0-29, 9999, 251-330) to abate an exploit in the current code
|
||||
|
||||
== 10/17/2016 ==
|
||||
Uleat: Moved namespace ItemField from item_instance.h to shareddb.cpp - the only place it is used
|
||||
Uleat: Separated class Inventory from item_instance files into inventory_profile files
|
||||
Uleat: Renamed class Inventory to EQEmu::InventoryProfile
|
||||
Uleat: Renamed enum class InventoryVersion to MobVersion
|
||||
|
||||
== 10/16/2016 ==
|
||||
Uleat: Renamed struct EQEmu::ItemBase to EQEmu::ItemData and class ItemInst to EQEmu::ItemInstance
|
||||
Uleat: Added class EQEmu::InventorySlot. Re-attached pertinent inventory token references to EQDictionary
|
||||
|
||||
== 10/15/2016 ==
|
||||
Uleat: Changed filenames to facilitate future inventory naming conventions
|
||||
|
||||
== 10/09/2016 ==
|
||||
Noudess: Rogue usage of merchants while utilizing sneak was limited to
|
||||
temporary items, as the code that checked faction per item sold did not
|
||||
take into account that rogue was sneaking. Now sneaking rogues can see full
|
||||
inventory on merchants (well, unless an item requires a + faction value).
|
||||
|
||||
== 09/12/2016 ==
|
||||
Akkadius: Massive overhaul of the update system and EQEmu Server management utility framework
|
||||
(known as eqemu_update.pl) now known as eqemu_server.pl
|
||||
- eqemu_server.pl is now a general EQEmu Server management utiltiy framework that can be used
|
||||
to extend to many purposes. It's main purpose is to simplify server management
|
||||
- eqemu_server.pl changes:
|
||||
- Menu has been completely changed, instead of a number based (enter number and hit enter)
|
||||
you now type commands within the menu (Ex: 'database')
|
||||
- Handles last mile installation for Windows Servers (See Github Readme)
|
||||
- Handles last mile installation for Linux Servers (See Github Readme)
|
||||
- Ubuntu
|
||||
- Debian
|
||||
- Fedora
|
||||
- CentOS
|
||||
- Now checks for Internet connection before performing web requests
|
||||
- Database:
|
||||
- Regular schema updates now happen automatically, if new binaries present updated
|
||||
database schema changes, script will backup first, auto update database, and continue
|
||||
world bootup
|
||||
- Regular bots database schema changes now happen automatically similarily to the above
|
||||
- Database checks can also be ran manually via the script menu
|
||||
- CLI Arguments
|
||||
- Arguments passed to eqemu_server.pl can execute the same name-based operations that
|
||||
are present in the interactive menu
|
||||
- Example: "perl eqemu_server.pl opcodes" will download opcodes
|
||||
- Example: "perl eqemu_server.pl backup_player_tables" will backup and export player tables
|
||||
- Bots
|
||||
- Bots can now be automatically setup in Linux or Windows via the 'setup_bots' command
|
||||
- Windows will auto download binaries and install, along with installing bots db schema
|
||||
- Linxu will auto compile binaries and install, along with installings bots db schema
|
||||
- Utility scripts
|
||||
- Linux now has the following utility scripts for download, available via menu 'utility_scripts'
|
||||
and via Linux default install:
|
||||
- server_launcher.pl
|
||||
- server_start_dev.sh
|
||||
- server_start.sh
|
||||
- server_status.sh
|
||||
- server_stop.sh
|
||||
- Usage analytics
|
||||
- eqemu_server.pl now collects usage analytics, this is very helpful for our developers
|
||||
- Example: We can see how many installs have been performed:
|
||||
https://github.com/EQEmu/Server#server-installs
|
||||
- This helps us see how often certain utilities are used as well
|
||||
- Console Messages
|
||||
- All script messages have been prefixed with a bracket action Ex: [Update] [Database] [Info]
|
||||
to be more consistent with our log conventions
|
||||
- 'New Server' Utility
|
||||
- Running 'new_server' from the main menu or 'perl eqemu_server.pl new_server' while in
|
||||
a completely new folder with just the script present, will allow a server operator
|
||||
to initiate a full clean PEQ install in that folder. Pulling down all assets and
|
||||
installing a PEQ database with the name the server operator gives the prompts in the
|
||||
script
|
||||
|
||||
== 09/10/2016 ==
|
||||
noudess: Task system experience based on a % of a level did not take into
|
||||
account the hell levels rule. Now it does.
|
||||
|
||||
== 09/04/2016 (Changes over past few months) ==
|
||||
Akkadius: Fixed an issue where clients would crash with health marquee's
|
||||
Akkadius: Fixed issues with NPC's "ghosting" when they path
|
||||
Akkadius: Overhauled worldserver logging
|
||||
Akkadius: Pets now don't actually spawn until the player has fully entered the zone (Live-like)
|
||||
demonstar/KLS: Adjusted some background workings on how spell buff tics are synced with the client
|
||||
Uleat: Optimizations to map loading and zone times
|
||||
Uleat/Akkadius: Fixed bandolier exploit where you could equip a 2H and Shield
|
||||
mackal: Re-worked spell re-use timer logic
|
||||
mackal: Source optimizations all over, crash fixes
|
||||
mackal: Fixed some issues with illusions on zoning
|
||||
mackal: Fixed some client DOT stacking bugs
|
||||
mackal: Invis will now break on AA spell casts and item cast
|
||||
mackal: Changed how Loot response code works
|
||||
mackal: Implemented 3 additional spell gems with (Mnemonic Retention)
|
||||
mackal: Instant spells now have instrument mods
|
||||
mackal: Rate limit character saves
|
||||
mackal: Made it so items no longer do TGB (Live-like) Rule implemented to disable
|
||||
mackal: Set pet buffs limit to 30
|
||||
|
||||
== 09/03/2016 ==
|
||||
Uleat: Changed 'Bind Wound' behavior to match the best references that I could find for post-2004 era.
|
||||
Note: If you wish to retain the old method, source in the optional '2016_09_03_old_bind_wound_rule.sql' script file.
|
||||
@@ -412,10 +516,10 @@ mackal: Reworked the activated avoidace skills (riposte, dodge, etc) based on de
|
||||
Also riposte immunity from the increase riposte chance spell effect.
|
||||
|
||||
== 7/2/2015 ==
|
||||
KLS/Demonstar55: AA system has been rewritten fixing a ton of bugs and extending functionality while making it easier to create new AA points.
|
||||
KLS/Demonstar55: New tables are needed and so older data will need to be migrated to the new system.
|
||||
KLS/Demonstar55: The SQL saves the old aa points spent/avail/character_alt_abilities data if any server ops want to do something different than PEQ did with it.
|
||||
KLS/Demonstar55: Will try to get a wiki entry written up next week some time explaining the system but it's really not hard to follow the db tables in the meantime.
|
||||
KLS/mackal: AA system has been rewritten fixing a ton of bugs and extending functionality while making it easier to create new AA points.
|
||||
KLS/mackal: New tables are needed and so older data will need to be migrated to the new system.
|
||||
KLS/mackal: The SQL saves the old aa points spent/avail/character_alt_abilities data if any server ops want to do something different than PEQ did with it.
|
||||
KLS/mackal: Will try to get a wiki entry written up next week some time explaining the system but it's really not hard to follow the db tables in the meantime.
|
||||
|
||||
== 7/1/2015 ==
|
||||
Akkadius: Fix an issue where emote messages would overflow the buffer of 256 by increasing the size and changing some of the initialization
|
||||
@@ -445,7 +549,7 @@ Akkadius: Added DB ver 9082 with update to add npc_types texture columns if tabl
|
||||
Uleat: Added null-term declaration for character names in ENCODE(OP_CharInfo) - where appropriate
|
||||
|
||||
== 05/20/2015 ==
|
||||
demonstar55: Bard instrument mods should be more consistent with live. Zoning will keep instrument mod for long duration buffs (selo's)
|
||||
mackal: Bard instrument mods should be more consistent with live. Zoning will keep instrument mod for long duration buffs (selo's)
|
||||
Still need to have procs/doom effects to inherit the instrument mods from their source buff/whatever
|
||||
|
||||
== 05/18/2015 ==
|
||||
@@ -455,7 +559,7 @@ KLS: Changed how fishing locates water to hopefully be a bit more accurate at th
|
||||
Uleat: Added check to EntityList::CheckSpawnQueue() to bypass dereference if returned iterator is npc_list.end() - should fix the debug assertion failure crash
|
||||
|
||||
== 04/30/2015 ==
|
||||
demonstar55: Implement mob and client melee push
|
||||
mackal: Implement mob and client melee push
|
||||
You can set Combat:MeleePush to false to turn off or change Combat:MeleePushChance to increase the chance an NPC can be pushed
|
||||
PCs are always pushed, need to do more testing to verify.
|
||||
|
||||
@@ -509,7 +613,7 @@ Uleat: Fix for RoF+ clients showing active 'Return Home' button when action is n
|
||||
Noudess: Starting erudites that were supposed to start in paineel were landing in erudin on Titanium. Fixed to be paineel.
|
||||
|
||||
== 02/20/2015 ==
|
||||
demonstar55: Implement claims for RoF/RoF2 (should no longer crash the client!)
|
||||
mackal: Implement claims for RoF/RoF2 (should no longer crash the client!)
|
||||
- fixed bugs related to claims for the rest of the clients (woo infinite loops)
|
||||
|
||||
== 02/18/2015 ==
|
||||
@@ -528,7 +632,7 @@ Notes:
|
||||
|
||||
== 02/16/2015 ==
|
||||
Trevius: (RoF2) Bazaar Trading (Buying/Selling) is now fully functional. Bazaar (/bazaar) search is not yet functional.
|
||||
demonstar55: (RoF2) Send the bard focus effects, note custom servers will need to fix their items, server side we still use the old system, but RoF2 wasn't showing anything with not sending focus, so send them
|
||||
mackal: (RoF2) Send the bard focus effects, note custom servers will need to fix their items, server side we still use the old system, but RoF2 wasn't showing anything with not sending focus, so send them
|
||||
|
||||
== 02/14/2015 ==
|
||||
Trevius: (RoF2) Bazaar is now partially functional. RoF2 clients can start/end trader mode and other clients can purchase from them. No other functionality yet.
|
||||
@@ -578,7 +682,7 @@ Akkadius: Implement Packet logs with dumps
|
||||
See: http://wiki.eqemulator.org/p?Logging_System_Overhaul#packet-logging-levels
|
||||
|
||||
== 02/01/2015 ==
|
||||
demonstar55: Add quest debugging to lua
|
||||
mackal: Add quest debugging to lua
|
||||
eq.debug("Test debug level implicit 1")
|
||||
eq.debug("Test debug level explicit 1", 1)
|
||||
eq.debug("Test debug level explicit 2", 2)
|
||||
@@ -771,7 +875,7 @@ Trevius: Finished lining up the RoF2 Player Profile Struct. Zone times are now
|
||||
Trevius: Fixed zoning after death for RoF2.
|
||||
|
||||
== 12/17/2014 ==
|
||||
demonstar55: Use vectors for route stuff, should be more CPU cache friendly so faster
|
||||
mackal: Use vectors for route stuff, should be more CPU cache friendly so faster
|
||||
Secrets: EQStream changes as recommended by a community member in private.
|
||||
|
||||
== 12/15/2014 ==
|
||||
@@ -781,7 +885,7 @@ Trevius: Player Corpses now saved attuned settings for Items.
|
||||
Required SQL: utils/sql/git/required/2014_12_15_multiple_table_updates.sql
|
||||
|
||||
== 12/13/2014 ==
|
||||
demonstar55: Fix guild rank spam on zone (needed to be in OP_PP).
|
||||
mackal: Fix guild rank spam on zone (needed to be in OP_PP).
|
||||
Trevius: (RoF+) Implemented Armor Ornamentation using Hero's Forge Armor Models. To use, create an ornamentation augment and set the herosforgemodel field in the items table.
|
||||
Trevius: (RoF+) Added command #heromodel (#hm for short) - Usage: #heromodel [hero forge model] [ [slot] ] (example: #heromodel 63)
|
||||
|
||||
@@ -789,11 +893,11 @@ Be sure to run this or there will be item loss:
|
||||
Required SQL: utils/sql/git/required/2014_12_13_inventory_table_update.sql
|
||||
|
||||
== 12/12/2014 ==
|
||||
demonstar55: Add special attack 42, Ignore Root Aggro Rules. This allows you to root a mob and have them still use the normal aggro rules (so they will attack the one with most hate, not closest)
|
||||
mackal: Add special attack 42, Ignore Root Aggro Rules. This allows you to root a mob and have them still use the normal aggro rules (so they will attack the one with most hate, not closest)
|
||||
|
||||
== 12/09/2014 ==
|
||||
Trevius: (RoF+) Implemented Hero's Forge Armor Models for Items. To use, set herosforgemodel field in the item table to a model number such as 63 (for example).
|
||||
demonstar55: SoF+ swarm pets will no longer be F8able (without a hack!)
|
||||
mackal: SoF+ swarm pets will no longer be F8able (without a hack!)
|
||||
|
||||
== 12/08/2014 ==
|
||||
Secrets: Added a feature that allows an EQ client to log in directly to World without having to enter the LoginServer, provided the 'password' field is set in WorldServer.
|
||||
@@ -839,10 +943,10 @@ Trevius: Mercenaries now Dismiss, Suspend, Unsuspend, and Die correctly.
|
||||
Trevius: Mercenaries can now zone once again.
|
||||
|
||||
== 11/17/2014 ==
|
||||
demonstar55: Correct OP_AugmentInfo reply. This fixes RoF display issue with Adventurer's Stone. Still issues with UF/SoF/SoD though.
|
||||
mackal: Correct OP_AugmentInfo reply. This fixes RoF display issue with Adventurer's Stone. Still issues with UF/SoF/SoD though.
|
||||
|
||||
== 11/16/2014 ==
|
||||
demonstar55: fix size issue with ControlBoat_Struct and exploit fix in OP_BoardBoat
|
||||
mackal: fix size issue with ControlBoat_Struct and exploit fix in OP_BoardBoat
|
||||
|
||||
Akkadius: Implemented Automatic Database update and versioning system
|
||||
Akkadius: Created database revision define, this is located in version.h in common #define CURRENT_BINARY_DATABASE_VERSION 9057
|
||||
@@ -919,12 +1023,12 @@ Optional SQL: utils/sql/git/optional/2014_11_15_SwarmPetTargetLock.sql
|
||||
|
||||
== 11/14/2014 ==
|
||||
Secrets: Identified object size and solidtype as flags. Exported them as functions to Perl.
|
||||
demonstar55: Don't use the hack for charms that doesn't work on RoF
|
||||
demonstar55: UF too
|
||||
demonstar55: Tit
|
||||
demonstar55: SoF
|
||||
demonstar55: SoD
|
||||
demonstar55: 62 (untested)
|
||||
mackal: Don't use the hack for charms that doesn't work on RoF
|
||||
mackal: UF too
|
||||
mackal: Tit
|
||||
mackal: SoF
|
||||
mackal: SoD
|
||||
mackal: 62 (untested)
|
||||
|
||||
== 11/13/2014 ==
|
||||
Kayen: Implemented target type (44) 'Beams' (which projects an AE infront of caster with a specified length and width).
|
||||
@@ -950,7 +1054,7 @@ JJ: Implement new Live-like faction adjustment message using rule Client:UseLive
|
||||
Optional SQL: utils/sql/git/optional/2014_11_09_LiveFactionMessages.sql
|
||||
|
||||
== 11/06/2014 ==
|
||||
demonstar55: Tracking default sort will now be correct order
|
||||
mackal: Tracking default sort will now be correct order
|
||||
Trevius: Fixed dynamic merchant list loading. Allows any merchant to be used in any zone.
|
||||
|
||||
== 11/03/2014 ==
|
||||
@@ -974,17 +1078,17 @@ Uleat: Added Client::InterrogateInventory(). Can be invoked by #interrogateinv a
|
||||
Uleat: Fix for stacking items in a world object..added a new command option: #peekinv world - will show world container contents, if one is in use by target.
|
||||
|
||||
== 10/20/2014 ==
|
||||
demonstar55: Inspect Buffs rank 1 will now show NPC buffs in target window (SoD+)
|
||||
mackal: Inspect Buffs rank 1 will now show NPC buffs in target window (SoD+)
|
||||
|
||||
== 10/19/2014 ==
|
||||
Uleat: Updated command #peekinv to display item links properly in RoF clients
|
||||
demonstar55: Group Mentoring in raids
|
||||
demonstar55: Inspect Buffs (text only version) works in raid groups
|
||||
demonstar55: Make use of the Inspect Buffs op/packet. 62 SOL until someone finds its op
|
||||
mackal: Group Mentoring in raids
|
||||
mackal: Inspect Buffs (text only version) works in raid groups
|
||||
mackal: Make use of the Inspect Buffs op/packet. 62 SOL until someone finds its op
|
||||
|
||||
== 10/18/2014==
|
||||
demonstar55: Implement group mentor, sharing leadership exp (SoF+ only)
|
||||
demonstar55: Add gaining of group leadership while in raids
|
||||
mackal: Implement group mentor, sharing leadership exp (SoF+ only)
|
||||
mackal: Add gaining of group leadership while in raids
|
||||
|
||||
== 10/16/2014 ==
|
||||
Uleat: Fixed the auto-conversion view naming error and renamed the views in the script files. Added a fix sql for databases that auto-converted.
|
||||
@@ -997,7 +1101,7 @@ Notes: I modifed the behavior of both load and drop bots to fail on the first op
|
||||
a few altered tables back to their original state - as of the date in the file.
|
||||
|
||||
== 10/13/2014 ==
|
||||
demonstar55: Partially implement leadership and raids
|
||||
mackal: Partially implement leadership and raids
|
||||
Currently working: client side only effects and stat bonuses.
|
||||
Not working: Mark NPC, and other stuff that need extra server side support
|
||||
Currently only UF tested (Tit and 62 may just work, others need packet work)
|
||||
@@ -1006,7 +1110,7 @@ demonstar55: Partially implement leadership and raids
|
||||
Akkadius: Fix for LDON Character Stat load
|
||||
|
||||
== 10/11/2014 ==
|
||||
demonstar55: Implement Raid MOTD for UF
|
||||
mackal: Implement Raid MOTD for UF
|
||||
Don't forget 2014_10_11_RaidMOTD.sql!
|
||||
|
||||
== 10/09/2014 ==
|
||||
@@ -1019,7 +1123,7 @@ previously and/or manually changed code, or just have a need for it to re-run, c
|
||||
** This will only work if you haven't deleted your `character_old` table **
|
||||
|
||||
== 10/07/2014 ==
|
||||
demonstar55: Identified tutorial flag in all charcreate packets, reworked logic to correctly set homes binds
|
||||
mackal: Identified tutorial flag in all charcreate packets, reworked logic to correctly set homes binds
|
||||
|
||||
== 10/05/2014 ==
|
||||
Uleat: Added Server<->Corpse slot translators needed for re-enumeration (inactive until phased in)
|
||||
@@ -1037,13 +1141,13 @@ Uleat: First round of Ti/6.2 translators added - needed for re-enumeration
|
||||
|
||||
== 10/01/2014 ==
|
||||
Kayen: Exported to PERL $client->SendColoredText(color, msg)
|
||||
demonstar55: Exported SendColoredText to lua
|
||||
mackal: Exported SendColoredText to lua
|
||||
|
||||
== 09/30/2014 ==
|
||||
Uleat: Implemented click-casting from bag slots for clients that natively support it (RoF)
|
||||
|
||||
== 09/28/2014 ==
|
||||
demonstar55: Add support for post June 18, 2014 Hundred Hands Effect spells (they changed the formula and stuff)
|
||||
mackal: Add support for post June 18, 2014 Hundred Hands Effect spells (they changed the formula and stuff)
|
||||
set Spells:Jun182014HundredHandsRevamp to true if you're using a spell file from June 18, 2014+
|
||||
|
||||
== 09/27/2014 ==
|
||||
@@ -1052,15 +1156,15 @@ Note: identifier is the stat field in spells_new, slot is used for certain effec
|
||||
Example $mob->GetSpellStat(121, "range"); //Returns spell range
|
||||
Example $mob->GetSpellStat(121, "effectid", 1); //Returns the the value of effectid1
|
||||
This will allow you to pull almost all the data for any spell in quest files.
|
||||
demonstar55: Move the client's SetAttackTimer to the end of Client::CalcBonuses to keep the haste in sync
|
||||
demonstar55: Correct haste/slow "stacking" rules
|
||||
demonstar55: Correct SE_AttackSpeed4 to respect unslowable
|
||||
demonstar55: Make the haste be between 1-225 like the client (<100 = slow, >100 = haste) to ...
|
||||
demonstar55: Correct Hundred Hands effect and use formula provided by devs
|
||||
mackal: Move the client's SetAttackTimer to the end of Client::CalcBonuses to keep the haste in sync
|
||||
mackal: Correct haste/slow "stacking" rules
|
||||
mackal: Correct SE_AttackSpeed4 to respect unslowable
|
||||
mackal: Make the haste be between 1-225 like the client (<100 = slow, >100 = haste) to ...
|
||||
mackal: Correct Hundred Hands effect and use formula provided by devs
|
||||
|
||||
== 09/24/2014 ==
|
||||
Uleat: Re-ordered server opcodes and handlers to give them some predictability of location (I need this for the inventory re-enumeration.)
|
||||
demonstar55: Added helper function bool EQEmu::IsTradeskill(uint32 skill)
|
||||
mackal: Added helper function bool EQEmu::IsTradeskill(uint32 skill)
|
||||
|
||||
== 09/23/2014 ==
|
||||
Kayen: Spell recourse effects will now be applied AFTER the base spells effects have been applied (consistent with live).
|
||||
@@ -1169,46 +1273,46 @@ Akkadius: Player Profile Blob to Database Conversion
|
||||
ORDER BY DATA DESC;
|
||||
|
||||
== 09/20/2014 ==
|
||||
demonstar55: Fix crash in SendEnterWorld on illegally long names
|
||||
demonstar55: The client only lets you enter 15 characters for your name (UF at least)
|
||||
demonstar55: Add rule Spells:SHDProcIDOffByOne for pre-UF spell file, set to true, UF+ set to false
|
||||
mackal: Fix crash in SendEnterWorld on illegally long names
|
||||
mackal: The client only lets you enter 15 characters for your name (UF at least)
|
||||
mackal: Add rule Spells:SHDProcIDOffByOne for pre-UF spell file, set to true, UF+ set to false
|
||||
KLS: #suspend and #ban now have required messages to record the reason for the ban/suspension.
|
||||
|
||||
== 09/19/2014 ==
|
||||
demonstar55: Added Client::Tell_StringID (used in tell queue messages)
|
||||
demonstar55: Tell queues (and offline) messages now show correctly
|
||||
demonstar55: Fix starting with capital check
|
||||
mackal: Added Client::Tell_StringID (used in tell queue messages)
|
||||
mackal: Tell queues (and offline) messages now show correctly
|
||||
mackal: Fix starting with capital check
|
||||
|
||||
== 09/18/2014==
|
||||
demonstar55: Implement tell queues
|
||||
mackal: Implement tell queues
|
||||
Currently set to a limit of 20 by default (World:TellQueueSize) I was unable to hit the limit on live though (100+)
|
||||
The required SQL nukes the old tell queue table, which may or may not be in your DB
|
||||
Optional SQL adds the rule to the DB to allow easy of change
|
||||
Note: this does not play well with multiple sessions with the same name on (crash and relog and have multiple sessions) but normal tells don't play well either
|
||||
|
||||
== 09/16/2014 ==
|
||||
demonstar55: Implement spell formula 137 (BER AA Desperation)
|
||||
mackal: Implement spell formula 137 (BER AA Desperation)
|
||||
Uleat (NateDog): Fix for LoadBuffs() crash when a spell with a non-persistent Illusion effect was loaded.
|
||||
demonstar55: Fix some effect calcs + implement more (derived from the client)
|
||||
mackal: Fix some effect calcs + implement more (derived from the client)
|
||||
|
||||
== 09/15/2014 ==
|
||||
Kayen: Nimbus effects will now be reapplied after zoning and will be removed when associated buff fades.
|
||||
|
||||
== 09/13/2014 ==
|
||||
demonstar55: Fix rogues not having Thieves' Cant
|
||||
mackal: Fix rogues not having Thieves' Cant
|
||||
|
||||
== 09/09/2014 ==
|
||||
demonstar55: Incrase Mob kick/bash timer by 3
|
||||
mackal: Incrase Mob kick/bash timer by 3
|
||||
see: http://www.eqemulator.org/forums/showthread.php?t=38734
|
||||
demonstar55: Fix slow effect on NPC special attack reuse timers
|
||||
mackal: Fix slow effect on NPC special attack reuse timers
|
||||
see: http://www.eqemulator.org/forums/showthread.php?t=38734
|
||||
demonstar55: Slow fixes to bots!
|
||||
demonstar55: Revamped how NPC attack rate is set
|
||||
mackal: Slow fixes to bots!
|
||||
mackal: Revamped how NPC attack rate is set
|
||||
SQL: 2014_09_09_attack_delay.sql
|
||||
demonstar55: Added attackdelay to #npcedit
|
||||
mackal: Added attackdelay to #npcedit
|
||||
|
||||
== 09/08/2014 ==
|
||||
demonstar55: Fix slow calc
|
||||
mackal: Fix slow calc
|
||||
see: http://www.eqemulator.org/forums/showthread.php?t=38734
|
||||
|
||||
== 09/07/2014 ==
|
||||
@@ -1219,18 +1323,18 @@ Uleat: Tweaked 'Smart' trading code to return main slots before sub slots in sta
|
||||
|
||||
== 09/05/2014 ==
|
||||
Uleat: Fix for cursor item loss when zoning. (Thanks to the other devs who traced and fixed the 'macro' issue!)
|
||||
demonstar55: Fix size getting nuked with lua's SendIllusionPacket
|
||||
mackal: Fix size getting nuked with lua's SendIllusionPacket
|
||||
|
||||
== 09/03/2014 ==
|
||||
Secrets: Identified the routines needed to augment items in RoF. Currently, only Insert and Remove are supported. Swap and Destroy do not work due to missing functions related to the cursor.
|
||||
demonstar55: Added work around command to show numhits on your buffs (#shownumhits)
|
||||
mackal: Added work around command to show numhits on your buffs (#shownumhits)
|
||||
Uleat: Fix for timer issue introduced by Zone::ShutDown() fix.
|
||||
|
||||
== 09/02/2014 ==
|
||||
Secrets: Identified OP_GuildPromote for RoF clients.
|
||||
Secrets: Fixed promotion, demotion, transferring a leader and displaying of client ranks in the Rain of Fear client. The rain of fear client, as such, will only have 3 ranks like the other clients, but supports a theoretical 8 ranks later.
|
||||
Secrets/Akkadius: Fixed an issue involving character name lookup in the new DB code.
|
||||
demonstar55: crash fix checking DivineAura in hate_list.cpp
|
||||
mackal: crash fix checking DivineAura in hate_list.cpp
|
||||
Secrets: Reverted some code that got in the main branch that shouldn't have gotten there.
|
||||
Uleat: Changed #loc to report the same precision as /loc for Cartesians
|
||||
|
||||
@@ -1241,7 +1345,7 @@ KLS: Fixed a few quest related inconsistencies.
|
||||
KLS: Added Lua EntityList::ChannelMessage(from, type, msg, language)
|
||||
|
||||
== 08/30/2014 ==
|
||||
demonstar55: (noudess) Merchants should be more descriptive of why they don't sell to you
|
||||
mackal: (noudess) Merchants should be more descriptive of why they don't sell to you
|
||||
|
||||
== 08/26/2014 ==
|
||||
Uleat: Implemented 'Smart' Player Trade transfers. Trades are processed by containers, stackables and then all remaining. QueryServ logs have been updated to match these transactions.
|
||||
@@ -1619,7 +1723,7 @@ Optional SQL: utils/sql/git/optional/2014_04_03_SpellProjectileRules.sql
|
||||
Note: The rules in this SQL are for setting the item id for the graphic used by the projectile on different clients.
|
||||
|
||||
== 04/01/2014 ==
|
||||
demonstar55: Implemented ability for a merchant to open and close shop.
|
||||
mackal: Implemented ability for a merchant to open and close shop.
|
||||
Lua quest functions: e.self:MerchantOpenShop() and e.self:MerchantCloseShop()
|
||||
GM Commands: #merchant_open_shop (short: #open_shop) and #merchant_close_shop (short: #close_shop)
|
||||
default to status 100, just in case you need to force the merchants status
|
||||
@@ -1685,7 +1789,7 @@ Kayen: Revision to lull/harmony/pacification code to be consistent with live bas
|
||||
which if 'resisted' will cause the caster to gain aggro.
|
||||
|
||||
== 03/05/2014 ==
|
||||
demonstar55: Corrected rogue's evade to be single target
|
||||
mackal: Corrected rogue's evade to be single target
|
||||
sorvani: fixed crash issue 119
|
||||
|
||||
== 03/04/2014 ==
|
||||
@@ -1700,7 +1804,7 @@ Kayen: Revision to root code to be consistent with live based on extensive perso
|
||||
Optional SQL: utils/sql/git/optional/2014_03_04_RootRule.sql
|
||||
|
||||
== 03/03/2014 ==
|
||||
demonstar55: Implemented deadly strikes and gave rogues higher innate throwing crit chance
|
||||
mackal: Implemented deadly strikes and gave rogues higher innate throwing crit chance
|
||||
|
||||
New rules: Combat:RogueCritThrowingChance, Combat:RogueDeadlyStrikeChance, Combat:RogueDeadlyStrikeMod
|
||||
Defaults should give fairly close to live results
|
||||
@@ -1712,7 +1816,7 @@ Kayen: Revision to charm code to be consistent with live based on extensive pers
|
||||
|
||||
Optional SQL: utils/sql/git/optional/2014_03_02_CharmRules.sql
|
||||
|
||||
demonstar55: Melee Crits, HoTs, DoTs messages should now be filtered correctly on all clients.
|
||||
mackal: Melee Crits, HoTs, DoTs messages should now be filtered correctly on all clients.
|
||||
Clients that also support seeing others DoTs will now see them if they don't filter them
|
||||
note: some newer clients have a 'mine only' option for HoTs but it functions the same as show
|
||||
|
||||
@@ -1764,7 +1868,7 @@ Sorvani: Renamed the instance_lockout and instance_lockout_player tables to inst
|
||||
Required SQL: utils/sql/git/2014_02_13_Rename_instance_lockout_tables.sql
|
||||
|
||||
== 02/10/2014 ==
|
||||
demonstar55 (Secrets): Re-wrote the entity list to be a std::map. This should be used for direct entityID lookups and is noticably faster performance-wise. Also should result in less nil pointers potentially.
|
||||
mackal (Secrets): Re-wrote the entity list to be a std::map. This should be used for direct entityID lookups and is noticably faster performance-wise. Also should result in less nil pointers potentially.
|
||||
Secrets: Fixed a crash issue that could occur on #repop related to quest timers.
|
||||
Kayen: Divine Arbiration and other similar spell effects will now utilize a spell range check.
|
||||
Kayen: Revised how heal amount is calculated to properly incorporate all current focus effects/bonuses.
|
||||
@@ -1795,14 +1899,14 @@ Kayen: Implemented SE_FfLimitUseType (focus limit to numhits type)
|
||||
|
||||
== 01/20/2014 ==
|
||||
cavedude: Live-Like weather system (Thanks to robregen for figuring it out!)
|
||||
demonstar55: Implemented not_extendable spell flag
|
||||
demonstar55: Moved Spell Casting Reinforcement to DB
|
||||
demonstar55: Moved Mez Mastery to DB
|
||||
mackal: Implemented not_extendable spell flag
|
||||
mackal: Moved Spell Casting Reinforcement to DB
|
||||
mackal: Moved Mez Mastery to DB
|
||||
Kayen: Complete revision of the numhits systems to utilize 'numhits type' field in spell file.
|
||||
|
||||
== 01/18/2014 ==
|
||||
sorvani: Implemented for Lua eq.get_characters_in_instance(uint16 instance_id), return a Lua HashTable
|
||||
demonstar55: NPCs will now cast their charms.
|
||||
mackal: NPCs will now cast their charms.
|
||||
|
||||
== 01/13/2014 ==
|
||||
Kayen: Numerous minor fixes to spell effects.
|
||||
@@ -1822,19 +1926,19 @@ Kayen: Implemented SE_LimitRace (Limits to spells cast by a certain race)
|
||||
Kayen: Implemented SE_FcMute (silences casting of spells that contain specific spell effects) ie silence only heals
|
||||
|
||||
== 01/09/2014 ==
|
||||
demonstar55: Add pet size preservation like live (zone, camp, etc)
|
||||
mackal: Add pet size preservation like live (zone, camp, etc)
|
||||
|
||||
== 01/07/2014 ==
|
||||
demonstar55: Moved pet can attack check to before it tries to attack, which is more live like.
|
||||
mackal: Moved pet can attack check to before it tries to attack, which is more live like.
|
||||
|
||||
== 01/03/2014 ==
|
||||
demonstar55: Crash prevention for emote.
|
||||
mackal: Crash prevention for emote.
|
||||
|
||||
== 01/02/2014 ==
|
||||
demonstar55: Stuns from beneficial spells (Harvest) ignore immunity
|
||||
mackal: Stuns from beneficial spells (Harvest) ignore immunity
|
||||
|
||||
== 12/26/2013 ==
|
||||
demonstar55: Added classes_required to merchantlist (same bitmask as items)
|
||||
mackal: Added classes_required to merchantlist (same bitmask as items)
|
||||
|
||||
== 12/24/2013 ==
|
||||
Secrets (Akkadius): Perl $client->SilentMessage("Message"); addition, this is a pre-req for a Perl plugin I've shared with EQEmu. This function essentially mimics a player speaking with an NPC - which is used in popup window responses
|
||||
@@ -1855,14 +1959,14 @@ Kayen: Implemented SE_TriggerOnAmountValue (Trigger spell if HP/Mana/End bellow
|
||||
Kayen: Fix to SE_BlockNextSpellFocus to make it functional again.
|
||||
|
||||
== 12/15/2013 ==
|
||||
demonstar55: Moved the blocked buff check down so we get spell effects like on live
|
||||
mackal: Moved the blocked buff check down so we get spell effects like on live
|
||||
Kayen: Implemented SE_ReduceHealing (Reduces amount of healing on target by X amount)
|
||||
Kayen: Implemented SE_CastonFocusEffect (Triggers spell as part of a focus, when that focus effect is used)
|
||||
Kayen: Implemented SE_IncreaseHitDmgTaken (Effect is triggered when X amount of damage is taken)
|
||||
Kayen: More fixes for various spell triggers/procs to now properly use their resist modifier.
|
||||
|
||||
== 12/14/2013 ==
|
||||
demonstar55: Blocked buffs shouldn't fail, they should just not be applied.
|
||||
mackal: Blocked buffs shouldn't fail, they should just not be applied.
|
||||
JJ: Changed enable/disable recipe to confirm change made.
|
||||
|
||||
== 12/13/2013 ==
|
||||
@@ -1873,52 +1977,52 @@ Kayen: Fix for various spell triggers/procs to now properly use their resist mod
|
||||
Kayen: Fix to mob->ModSkillDmgTaken(skill_num, value), setting value to -1 will now properly effect all skills.
|
||||
|
||||
== 12/11/2013 ==
|
||||
demonstar55: Fixed issue with crippling blow from berserker frenzy not actually doing anything
|
||||
demonstar55: Fix haste caps
|
||||
mackal: Fixed issue with crippling blow from berserker frenzy not actually doing anything
|
||||
mackal: Fix haste caps
|
||||
|
||||
== 12/04/2013 ==
|
||||
demonstar55: Fixed SpellType_Charm case in AICastSpell
|
||||
mackal: Fixed SpellType_Charm case in AICastSpell
|
||||
|
||||
== 12/03/2013 ==
|
||||
demonstar55: Added #showspellslist to view a mobs spell list
|
||||
demonstar55: Fix procing off of unattackable things
|
||||
mackal: Added #showspellslist to view a mobs spell list
|
||||
mackal: Fix procing off of unattackable things
|
||||
|
||||
== 12/02/2013 ==
|
||||
JJ: Bandaid fix to CopyCharacter function.
|
||||
|
||||
== 11/29/2013 ==
|
||||
demonstar55: Stacking issues should be resolved now, probably could be optimized more, but went from 3 loops that do stuff to 3 where only 2 really does stuff and one breaks early in most cases, so slightly better
|
||||
mackal: Stacking issues should be resolved now, probably could be optimized more, but went from 3 loops that do stuff to 3 where only 2 really does stuff and one breaks early in most cases, so slightly better
|
||||
|
||||
== 11/23/2013 ==
|
||||
Secrets: Fixed an issue related to a zone crash where the count of the abilities in an AA was 0, leading to a size 0 buffer issue.
|
||||
|
||||
== 11/19/2013 ==
|
||||
Secrets: Fixed an issue with two zone crashes reported on PEQ related to the buff restrictions code and AAs.
|
||||
demonstar55: Partially make use of dot_stacking_exempt (case when it's 1 is implemented, -1 case isn't)
|
||||
mackal: Partially make use of dot_stacking_exempt (case when it's 1 is implemented, -1 case isn't)
|
||||
|
||||
== 11/18/2013 ==
|
||||
demonstar55: Added assistradius to npc_types, defaults to aggroradius if set to 0 (old behaviour)
|
||||
mackal: Added assistradius to npc_types, defaults to aggroradius if set to 0 (old behaviour)
|
||||
|
||||
== 11/17/2013 ==
|
||||
Sorvani: fixed leash and tether special abilities to use the specified range correctly.
|
||||
demonstar55: Rewrote the Mob::_GetMovementSpeed fix an issue that arose from the change on 11/11
|
||||
mackal: Rewrote the Mob::_GetMovementSpeed fix an issue that arose from the change on 11/11
|
||||
- Added the rule Character:BaseRunSpeedCap (default 158) so people can customize what their runspeed cap is. Hardcapped to 225 so stuff doesn't get too crazy.
|
||||
|
||||
== 11/16/2013 ==
|
||||
Leere: Fixed the drinking message for auto-consume, it will again correctly show up for forced consumption instead.
|
||||
demonstar55: Added Mob::DoCastingChecks() which will check for various fail conditions while the casting bar is up. This is called after Mob::DoCastSpell() starts the casting and before it returns.
|
||||
mackal: Added Mob::DoCastingChecks() which will check for various fail conditions while the casting bar is up. This is called after Mob::DoCastSpell() starts the casting and before it returns.
|
||||
|
||||
== 11/15/2013 ==
|
||||
demonstar55: Fixed Mob::CalcFocusEffect()'s SE_LimitEffect
|
||||
mackal: Fixed Mob::CalcFocusEffect()'s SE_LimitEffect
|
||||
Leere: Fixed a stacking issue for SE_StackingCommand_Block
|
||||
|
||||
== 11/13/2013 ==
|
||||
demonstar55: Implemented bard song effect cap. You can set the base cap with the rule Character:BaseInstrumentSoftCap, defaults to 36 or "3.6" as it is sometimes referred to.
|
||||
demonstar55: Fix Echo of Taelosia and Ayonae's Tutelage to increase the mod cap instead of further improving the instrument mod
|
||||
demonstar55: Implemented Singing/Instrument Mastery as an AA bonus.
|
||||
mackal: Implemented bard song effect cap. You can set the base cap with the rule Character:BaseInstrumentSoftCap, defaults to 36 or "3.6" as it is sometimes referred to.
|
||||
mackal: Fix Echo of Taelosia and Ayonae's Tutelage to increase the mod cap instead of further improving the instrument mod
|
||||
mackal: Implemented Singing/Instrument Mastery as an AA bonus.
|
||||
|
||||
== 11/11/2013 ==
|
||||
demonstar55: Changed the way walk speed is calculated to allow mobs to have their walk speed equal a 100% movement reduction
|
||||
mackal: Changed the way walk speed is calculated to allow mobs to have their walk speed equal a 100% movement reduction
|
||||
|
||||
== 11/09/2013 ==
|
||||
Leere: Fixed Bard mana regen, they now only are affected by items and AA.
|
||||
@@ -1968,50 +2072,50 @@ Uleat: Converted SkillType typedef enumeration to SkillUseTypes enumeration - So
|
||||
Uleat: Prepped the client patch files for larger skill buffer size (not active)
|
||||
|
||||
== 10/24/2013 ==
|
||||
demonstar55: Fix some memory leaks in Mob::SpellOnTarget
|
||||
mackal: Fix some memory leaks in Mob::SpellOnTarget
|
||||
|
||||
== 10/21/2013 ==
|
||||
demonstar55: Changed GetMinLevel return 0 for more cases that EQ uses for some reason ...
|
||||
demonstar55: Added buff level restrictions, set the Spells:BuffLevelRestrictions to false to have the old behavior.
|
||||
mackal: Changed GetMinLevel return 0 for more cases that EQ uses for some reason ...
|
||||
mackal: Added buff level restrictions, set the Spells:BuffLevelRestrictions to false to have the old behavior.
|
||||
|
||||
== 10/18/2013 ==
|
||||
Uleat: Expanded the 'Bag Type' enumeration to include all known values. Also, set in place additional 'Bag Type' to 'Skill Type' conversions. Some of these will need to be verified before activation.
|
||||
Uleat: Cleaned up some unused enumerations to show a move towards standardization. More to come...
|
||||
|
||||
== 10/12/2013 ==
|
||||
demonstar55: Allow Titanium and lower clients to enter Tutorial zone from character select
|
||||
mackal: Allow Titanium and lower clients to enter Tutorial zone from character select
|
||||
Bad_Captain: Fixed merc crash issue by updating special_abilities & vwMercNpcTypes (Sorvani).
|
||||
Bad_Captain: Bots- added out of combat bard songs & #bot bardoutofcombat on|off command to turn them on/off.
|
||||
|
||||
== 10/11/2013 ==
|
||||
JJ: (demonstar55) Allow use of Go Home button when Tutorial still selected in RoF.
|
||||
JJ: (mackal) Allow use of Go Home button when Tutorial still selected in RoF.
|
||||
|
||||
== 10/10/2013 ==
|
||||
Secrets: Fixed zone shutdown (or #reloadqst) reinitalization of Perl. This should allow for Perl 5.14 and later to work on Windows under the new quest system.
|
||||
demonstar55: Beneficial single target buffs shouldn't have their mana/timers set if they fail to cast after the Mob::SpellOnTarget call in Mob::SpellFinished
|
||||
mackal: Beneficial single target buffs shouldn't have their mana/timers set if they fail to cast after the Mob::SpellOnTarget call in Mob::SpellFinished
|
||||
JJ: Revert change to EnterWorldPacket introduced on 22 April 2013 to fix inability to enter Tutorial or Go Home from character select screen.
|
||||
|
||||
== 10/09/2013 ==
|
||||
demonstar55: Fixed some more instances of the AA timer being eaten
|
||||
mackal: Fixed some more instances of the AA timer being eaten
|
||||
|
||||
== 10/08/2013 ==
|
||||
demonstar55: Added IsBuffSpell(spell_id) that will return true if the spell has a duration, so would end up in effects/song/discs etc windows on the client
|
||||
demonstar55: Replaced instances of using CalcBuffDuration to determine if a spell was a buff with IsBuffSpell
|
||||
demonstar55: Removed Mob::HasBuffIcon since it was doing what IsBuffSpell does in a more convoluted way with a rather misleading name
|
||||
demonstar55: Fixed issues that arose from the 10/03/2013 change
|
||||
mackal: Added IsBuffSpell(spell_id) that will return true if the spell has a duration, so would end up in effects/song/discs etc windows on the client
|
||||
mackal: Replaced instances of using CalcBuffDuration to determine if a spell was a buff with IsBuffSpell
|
||||
mackal: Removed Mob::HasBuffIcon since it was doing what IsBuffSpell does in a more convoluted way with a rather misleading name
|
||||
mackal: Fixed issues that arose from the 10/03/2013 change
|
||||
|
||||
== 10/05/2013 ==
|
||||
Sorvani: fixed issue with stackable items being created with 0 charges cause by fix to SummonItems
|
||||
|
||||
== 10/03/2013 ==
|
||||
demonstar55: Fix when the random +1 tick is added to nerf extension focus effects to where they should be
|
||||
mackal: Fix when the random +1 tick is added to nerf extension focus effects to where they should be
|
||||
|
||||
== 09/30/2013 ==
|
||||
Sorvani: Changed SummonItem to only summon an item with max charges when said default value is present and not on zero charges
|
||||
demonstar55: Fixed issue with #showstats showing your level for a bunch of values
|
||||
mackal: Fixed issue with #showstats showing your level for a bunch of values
|
||||
|
||||
== 09/13/2013 ==
|
||||
demonstar55: Add support for /pet hold on and /pet hold off (UF and RoF)
|
||||
mackal: Add support for /pet hold on and /pet hold off (UF and RoF)
|
||||
|
||||
== 08/29/2013 ==
|
||||
KLS: Removed Common Profiler and Zone Profiler. They're well past outdated status and are just code bloat.
|
||||
@@ -2157,8 +2261,8 @@ KLS: Perl now will (like lua) keep track of the values you return from EVENT_*.
|
||||
KLS: Exported eq.follow(entity_id, [distance]) and eq.stop_follow() to lua.
|
||||
|
||||
== 07/01/2013 ==
|
||||
demonstar55: Fix Monster Summoning related to giants/cyclops
|
||||
demonstar55: Prevent Monster Summoning from summoning a portal in bothunder
|
||||
mackal: Fix Monster Summoning related to giants/cyclops
|
||||
mackal: Prevent Monster Summoning from summoning a portal in bothunder
|
||||
KLS: Merge of lua branch to master
|
||||
See: http://www.eqemulator.org/forums/showthread.php?t=37008 for more detailed information on what is added.
|
||||
Upgrade notes:
|
||||
@@ -2226,35 +2330,35 @@ JJ: Fixed rare case where heals from buffs could go negative.
|
||||
Derision: Moved entity_list.Clear() prior to destruction of Perl objects in zone shutdown as I was seeing a segfault due to attempts to call EVENT_HATE_LIST as mobs were being destroyed.
|
||||
|
||||
== 04/09/2013 ==
|
||||
demonstar55: Realized I was an idiot, changed salvage script to be better
|
||||
mackal: Realized I was an idiot, changed salvage script to be better
|
||||
optional SQL: 2013_04_09_SalvageCleanOld.sql - run if ran old script
|
||||
|
||||
== 04/08/2013 ==
|
||||
demonstar55: Implemented Salvage AA
|
||||
mackal: Implemented Salvage AA
|
||||
required SQL: 2013_04_08_Salvage.sql
|
||||
script: generate_salvage.py - will generate the entries for some exceptions for salvage returns.
|
||||
|
||||
== 04/04/2013 ==
|
||||
demonstar55: Implemented SE_ForageAdditionalItems as a bonus
|
||||
mackal: Implemented SE_ForageAdditionalItems as a bonus
|
||||
required SQL: 2013_04_04_NaturesBounty.sql
|
||||
|
||||
== 04/03/2013 ==
|
||||
demonstar55: Overloaded Mob::Say_StringID with the option to provide a message type
|
||||
demonstar55: Switched rest of the Pet Messages to MT_PetResponse (Leader commands intentionally left the old way)
|
||||
mackal: Overloaded Mob::Say_StringID with the option to provide a message type
|
||||
mackal: Switched rest of the Pet Messages to MT_PetResponse (Leader commands intentionally left the old way)
|
||||
|
||||
== 04/2/2013 ==
|
||||
Bad_Captain: Fixed Merc lack of use of heal over time spells (causing excessive healing).
|
||||
Bad_Captain: Fixed pet mitigation/AC issues.
|
||||
|
||||
== 04/01/2013 ==
|
||||
demonstar55: AA reuse timers now start when you hit the button and are reset upon failure
|
||||
demonstar55: Instant Cast bard AAs can now be used while singing a song
|
||||
mackal: AA reuse timers now start when you hit the button and are reset upon failure
|
||||
mackal: Instant Cast bard AAs can now be used while singing a song
|
||||
|
||||
== 03/30/2013 ==
|
||||
demonstar55: Fixed most of the pet talking, all use StringIDs now. Pet now informs you when it taunts.
|
||||
mackal: Fixed most of the pet talking, all use StringIDs now. Pet now informs you when it taunts.
|
||||
|
||||
== 03/23/2013 ==
|
||||
demonstar55: Fix issues with escape not always working and fixed SE_FadingMemories to have the message since the message isn't part of the spell data.
|
||||
mackal: Fix issues with escape not always working and fixed SE_FadingMemories to have the message since the message isn't part of the spell data.
|
||||
Escape now uses just the spell and not the AA Actoin
|
||||
Fading Memories now only uses the AA Action to eat mana
|
||||
|
||||
@@ -2264,7 +2368,7 @@ Bad_Captain: Added checks before dismissing merc to prevent possible bugged merc
|
||||
Bad_Captain: Merged in Secret's merc memory leak fixes.
|
||||
|
||||
== 03/20/2013 ==
|
||||
demonstar55: Fixed stacking issues with SE_Limit* (ex. Unholy Aura Discipline and Aura of Reverence)
|
||||
mackal: Fixed stacking issues with SE_Limit* (ex. Unholy Aura Discipline and Aura of Reverence)
|
||||
|
||||
== 03/18/2013 ==
|
||||
Bad_Captain: Fixed zone crash due to merc focus effects & tribute.
|
||||
@@ -2327,7 +2431,7 @@ KLS: Changed how shared memory works:
|
||||
af4t: Add Touch of the Wicked AA redux to SK Improved Harm Touch and Leech Touch.
|
||||
|
||||
== 02/22/2013 ==
|
||||
demonstar55: Mobs will now be removed from XTargets when they get back to their way point, should be last instance of XTarget mobs not clearing when they are not aggroed anymore
|
||||
mackal: Mobs will now be removed from XTargets when they get back to their way point, should be last instance of XTarget mobs not clearing when they are not aggroed anymore
|
||||
|
||||
== 02/19/2013 ==
|
||||
Derision: World should no longer crash if the start_zone query fails at character creation.
|
||||
@@ -2336,7 +2440,7 @@ Derision: World should no longer crash if the start_zone query fails at characte
|
||||
Bad_Captain: Moved merc save to merc table, save merc buffs, added cure and rez spells to healer merc.
|
||||
JJ: Chat garbled for drunk characters.
|
||||
Derision: Charmed pets should no longer be targettable with F8. Charmed pets no longer get a surname of Soandso's Pet.
|
||||
demonstar55: Added potionbelt tool tip
|
||||
mackal: Added potionbelt tool tip
|
||||
KLS: Added EVENT_DEATH to Player Quests
|
||||
|
||||
REQUIRED SQL: 2013_02_18_Merc_Rules_and_Tables.sql
|
||||
@@ -2348,8 +2452,8 @@ Derision: Client version is now returned by the stream proxy as a number.
|
||||
Derision: Fixed bug where BecomeTrader packets were only being sent to the Trader, not all other clients in the bazaar.
|
||||
|
||||
== 02/16/2013 ==
|
||||
demonstar55: Fix AA reuse timer calc
|
||||
demonstar55: Remove old filters and change all remaining old to new (Also fix Auction filtering out OOC as well due to incorrect define)
|
||||
mackal: Fix AA reuse timer calc
|
||||
mackal: Remove old filters and change all remaining old to new (Also fix Auction filtering out OOC as well due to incorrect define)
|
||||
|
||||
== 02/12/2013 ==
|
||||
Kayen: AA fix
|
||||
@@ -2360,7 +2464,7 @@ REQUIRED SQL: utils/sql/svn/2504_required_aa_updates.sql
|
||||
Derision: RoF: Added ENCODE for OP_BeginCast (fixes no sound during spell casting). Corrected OP_DeleteSpell.
|
||||
|
||||
== 02/10/2013 ==
|
||||
JJ: (demonstar55) Language skill up should use proper function.
|
||||
JJ: (mackal) Language skill up should use proper function.
|
||||
JJ: SetLanguageSkill now updates client immediately. Both functions do proper limit checks.
|
||||
Added two missing languages. Skill level 0 in a spoken language now shows 'in an unknown tongue'.
|
||||
JJ: Initial implementation of a GarbleMessage function and implemented for languages. Can be shared with drunk speaking.
|
||||
@@ -2396,7 +2500,7 @@ Trevius: RoF: Turning on Trader mode in bazaar now works, but no further trader
|
||||
Akkadius: Fixed an issue where global_npc.pl was not initializing (initially)
|
||||
|
||||
== 01/31/2013 ==
|
||||
cavedude00: (demonstar55) Rune aggro fix
|
||||
cavedude00: (mackal) Rune aggro fix
|
||||
cavedude00: (Drajor) Tradeskill skillneeded fix.
|
||||
|
||||
== 01/30/2013 ==
|
||||
@@ -2430,7 +2534,7 @@ Bad_Captain: Mercs - Initial spell casting AI committed.
|
||||
KLS: Added crash logging for Windows builds.
|
||||
Trevius: Mercenaries now despawn when a player camps out or disconnects in any way.
|
||||
Trevius: Players with a Mercenary spawned can now be invited to and join another group with their mercenary.
|
||||
Sorvani: (Demonstar55): Moved stunproc rule implmentation to catch all cases
|
||||
Sorvani: (mackal): Moved stunproc rule implmentation to catch all cases
|
||||
|
||||
OPTIONAL SQL: utils/sql/svn/mercs.sql -- rerun for updated merc stats & merc spell lists
|
||||
|
||||
@@ -2881,9 +2985,9 @@ references:
|
||||
http://www.eqemulator.org/forums/showthread.php?t=35629 - CSD Bugged Corpse Patch
|
||||
http://www.eqemulator.org/forums/showthread.php?t=35699 - CSD Bandolier Patch
|
||||
|
||||
cavedude: (demonstar55) Damage shields by default will no longer count towards EXP gain. (Rule also added to change this behaviour.)
|
||||
cavedude: (demonstar55) Extended targets should now clear when aggro is lost using skills.
|
||||
cavedude: (demonstar55) AAs with shorter reuse timers should now reset if the cast failed (interrupted.)
|
||||
cavedude: (mackal) Damage shields by default will no longer count towards EXP gain. (Rule also added to change this behaviour.)
|
||||
cavedude: (mackal) Extended targets should now clear when aggro is lost using skills.
|
||||
cavedude: (mackal) AAs with shorter reuse timers should now reset if the cast failed (interrupted.)
|
||||
KLS: Fixed a cause of raids disbanding on zoning.
|
||||
|
||||
OPTIONAL SQL: INSERT INTO `rule_values` VALUES (1, 'Combat:EXPFromDmgShield', 'false', 'Determine if damage from a damage shield counts for EXP gain.');
|
||||
@@ -3260,7 +3364,7 @@ Kayen: Implemented Perl Mob Quest Object GetModVulnerability(resist type) - Retu
|
||||
Optional SQL: utils/sql/svn/2154_optional_rule_spell_procs_resists_falloff.sql
|
||||
|
||||
==06/22/2012==
|
||||
Secrets: (demonstar55) Spells now display to all clients and can be filtered as such.
|
||||
Secrets: (mackal) Spells now display to all clients and can be filtered as such.
|
||||
Secrets: Damage Shields now go to the proper filter, and do not show the non-melee damage to everyone.
|
||||
|
||||
==06/03/2012==
|
||||
@@ -5415,10 +5519,10 @@ WildcardX: *BOTS* Bots can now be invited and disbanded from your group by simpl
|
||||
WildcardX: *BOTS* Tweak to the bots total play time calculation to make it more accurate.
|
||||
KLS: Added #path meshtest simple to do a faster search on errant path nodes.
|
||||
KLS: Modified the accurate hazard code to make automatic path maps with more accurate info that requires less manual editing afterward.
|
||||
cavedude: (demonstar55) Pets will now be amiable to their owners, indifferent to all else.
|
||||
cavedude: (demonstar55) Added $client->KeyRingCheck() and $client->KeyRingAdd() to allow Perl to manipulate the keyring.
|
||||
cavedude: (demonstar55) Casting an invis spell on a player that already has a similar type invis spell will no longer drop the existing buff.
|
||||
cavedude: (demonstar55) Corrected message string for heal spells.
|
||||
cavedude: (mackal) Pets will now be amiable to their owners, indifferent to all else.
|
||||
cavedude: (mackal) Added $client->KeyRingCheck() and $client->KeyRingAdd() to allow Perl to manipulate the keyring.
|
||||
cavedude: (mackal) Casting an invis spell on a player that already has a similar type invis spell will no longer drop the existing buff.
|
||||
cavedude: (mackal) Corrected message string for heal spells.
|
||||
cavedude: Added rule to determine at what HP a fleeing NPC will halt due to being snared.
|
||||
|
||||
==08/07/2009==
|
||||
@@ -6054,7 +6158,7 @@ KLS: Fixed the /bug structure and updated the table to be more useful.
|
||||
Required SQL: .\utils\sql\svn\503_bugs.sql
|
||||
|
||||
==05/11/2009==
|
||||
demonstar55: Added a function to allow Perl to check augments within items.
|
||||
mackal: Added a function to allow Perl to check augments within items.
|
||||
cavedude: Increased bind wound skill up speed some.
|
||||
KLS: Fix for potentially dangerous typo in spawn conditions code.
|
||||
KLS: Removed some non-functioning but still taking up database resources database code.
|
||||
@@ -6355,7 +6459,7 @@ cavedude: Removed the USE_RACE_CLASS_XP_MODS define as it was outdated and horri
|
||||
cavedude: Added group XP bonus. The larger the group, the higher the XP gain.
|
||||
cavedude: Added XP bonus for Warrior, Rogue, and Halfling.
|
||||
cavedude: Corrected ZEM for AAs.
|
||||
cavedude: (Thanks to demonstar55) Pet Affinity will no longer effect charmed pets.
|
||||
cavedude: (Thanks to mackal) Pet Affinity will no longer effect charmed pets.
|
||||
cavedude: (realityincarnate) Bard songs that require instruments will now require them.
|
||||
|
||||
Please note: XP gain has pretty much been overhauled. You may need tweak the multiplier rules for your server.
|
||||
@@ -6489,7 +6593,7 @@ AndMetal: Augments are now visible when linking items.
|
||||
Trevius: SoF - Adjusted the new Item Structure to align more fields
|
||||
Trevius: SoF - Added OP_Consume and OP_LootRequest opcodes
|
||||
cavedude00: (AndMetal) AAs now use skill_id instead of index for prereqs.
|
||||
cavedude00: (demonstar55) Implemented Improved Instrument Mastery, Improved Singing Mastery, and Echo of Taelosia AAs.
|
||||
cavedude00: (mackal) Implemented Improved Instrument Mastery, Improved Singing Mastery, and Echo of Taelosia AAs.
|
||||
cavedude00: Created Combat:ChanceToHitDivideBy rule and increased default value to 1250.
|
||||
Required and Optional SQL: utils/sql/svn/326_aas.sql
|
||||
KLS: SoF - Fix for item slots in bags.
|
||||
|
||||
@@ -9,7 +9,7 @@ SET(export_headers
|
||||
|
||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
||||
|
||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
TARGET_LINK_LIBRARIES(export_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||
|
||||
@@ -30,6 +30,7 @@ IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "pthread")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@@ -9,7 +9,7 @@ SET(import_headers
|
||||
|
||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
||||
|
||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
TARGET_LINK_LIBRARIES(import_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||
|
||||
@@ -30,6 +30,7 @@ IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "pthread")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
+9
-76
@@ -35,9 +35,11 @@ SET(common_sources
|
||||
faction.cpp
|
||||
guild_base.cpp
|
||||
guilds.cpp
|
||||
inventory_profile.cpp
|
||||
inventory_slot.cpp
|
||||
ipc_mutex.cpp
|
||||
item.cpp
|
||||
item_base.cpp
|
||||
item_data.cpp
|
||||
item_instance.cpp
|
||||
light_source.cpp
|
||||
md5.cpp
|
||||
memory_buffer.cpp
|
||||
@@ -75,14 +77,6 @@ SET(common_sources
|
||||
worldconn.cpp
|
||||
xml_parser.cpp
|
||||
platform.cpp
|
||||
net/crc32.cpp
|
||||
net/daybreak_connection.cpp
|
||||
net/eqstream.cpp
|
||||
net/packet.cpp
|
||||
patch/chat.cpp
|
||||
patch/login_sod.cpp
|
||||
patch/login_titanium.cpp
|
||||
patch/patch.cpp
|
||||
patches/patches.cpp
|
||||
patches/sod.cpp
|
||||
patches/sod_limits.cpp
|
||||
@@ -163,10 +157,12 @@ SET(common_headers
|
||||
global_define.h
|
||||
guild_base.h
|
||||
guilds.h
|
||||
inventory_profile.h
|
||||
inventory_slot.h
|
||||
ipc_mutex.h
|
||||
item.h
|
||||
item_base.h
|
||||
item_data.h
|
||||
item_fieldlist.h
|
||||
item_instance.h
|
||||
languages.h
|
||||
light_source.h
|
||||
linked_list.h
|
||||
@@ -218,52 +214,31 @@ SET(common_headers
|
||||
worldconn.h
|
||||
xml_parser.h
|
||||
zone_numbers.h
|
||||
event/background_task.h
|
||||
event/event_loop.h
|
||||
event/timer.h
|
||||
net/crc32.h
|
||||
net/daybreak_connection.h
|
||||
net/daybreak_structs.h
|
||||
net/endian.h
|
||||
net/eqstream.h
|
||||
net/packet.h
|
||||
patch/chat.h
|
||||
patch/login_sod.h
|
||||
patch/login_titanium.h
|
||||
patch/patch.h
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
# patches/sod_itemfields.h
|
||||
patches/sod_limits.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
# patches/sof_itemfields.h
|
||||
patches/sof_limits.h
|
||||
# patches/sof_opcode_list.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
# patches/rof_itemfields.h
|
||||
patches/rof_limits.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_structs.h
|
||||
patches/rof2.h
|
||||
# patches/rof2_itemfields.h
|
||||
patches/rof2_limits.h
|
||||
patches/rof2_ops.h
|
||||
patches/rof2_structs.h
|
||||
patches/titanium.h
|
||||
# patches/titanium_itemfields_a.h
|
||||
# patches/titanium_itemfields_b.h
|
||||
patches/titanium_limits.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_structs.h
|
||||
patches/uf.h
|
||||
# patches/uf_itemfields.h
|
||||
patches/uf_limits.h
|
||||
patches/uf_ops.h
|
||||
patches/uf_structs.h
|
||||
@@ -282,73 +257,34 @@ SET(common_headers
|
||||
StackWalker/StackWalker.h
|
||||
tinyxml/tinystr.h
|
||||
tinyxml/tinyxml.h
|
||||
util/memory_stream.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Event FILES
|
||||
event/background_task.h
|
||||
event/event_loop.h
|
||||
event/timer.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Net FILES
|
||||
net/crc32.cpp
|
||||
net/crc32.h
|
||||
net/daybreak_connection.cpp
|
||||
net/daybreak_connection.h
|
||||
net/daybreak_structs.h
|
||||
net/endian.h
|
||||
net/eqstream.h
|
||||
net/eqstream.cpp
|
||||
net/packet.cpp
|
||||
net/packet.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Patch FILES
|
||||
patch/chat.cpp
|
||||
patch/chat.h
|
||||
patch/login_sod.cpp
|
||||
patch/login_sod.h
|
||||
patch/login_titanium.cpp
|
||||
patch/login_titanium.h
|
||||
patch/patch.cpp
|
||||
patch/patch.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Patches FILES
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
# patches/sod_itemfields.h
|
||||
patches/sod_limits.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
# patches/sof_itemfields.h
|
||||
patches/sof_limits.h
|
||||
# patches/sof_opcode_list.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
# patches/rof_itemfields.h
|
||||
patches/rof_limits.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_structs.h
|
||||
patches/rof2.h
|
||||
# patches/rof2_itemfields.h
|
||||
patches/rof2_limits.h
|
||||
patches/rof2_ops.h
|
||||
patches/rof2_structs.h
|
||||
patches/titanium.h
|
||||
# patches/titanium_itemfields_a.h
|
||||
# patches/titanium_itemfields_b.h
|
||||
patches/titanium_limits.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_structs.h
|
||||
patches/uf.h
|
||||
# patches/uf_itemfields.h
|
||||
patches/uf_limits.h
|
||||
patches/uf_ops.h
|
||||
patches/uf_structs.h
|
||||
@@ -407,15 +343,12 @@ SOURCE_GROUP(TinyXML FILES
|
||||
tinyxml/tinyxmlparser.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Util FILES
|
||||
util/memory_stream.h
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
|
||||
|
||||
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
||||
|
||||
IF(UNIX)
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
||||
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||
ENDIF(UNIX)
|
||||
|
||||
+23
-4
@@ -638,6 +638,13 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
||||
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 */
|
||||
if(RuleB(Character, GrantHoTTOnCreate))
|
||||
{
|
||||
query = StringFormat("INSERT INTO `character_leadership_abilities` (id, slot, rank) VALUES (%u, %i, %i)", character_id, 14, 1);
|
||||
results = QueryDatabase(query);
|
||||
}
|
||||
|
||||
/* Save Skills */
|
||||
int firstquery = 0;
|
||||
for (int i = 0; i < MAX_PP_SKILL; i++){
|
||||
@@ -672,7 +679,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
||||
}
|
||||
|
||||
/* This only for new Character creation storing */
|
||||
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv) {
|
||||
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv) {
|
||||
uint32 charid = 0;
|
||||
char zone[50];
|
||||
float x, y, z;
|
||||
@@ -701,7 +708,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
|
||||
/* Insert starting inventory... */
|
||||
std::string invquery;
|
||||
for (int16 i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::BANK_BAGS_END;) {
|
||||
const ItemInst* newinv = inv->GetItem(i);
|
||||
const EQEmu::ItemInstance* newinv = inv->GetItem(i);
|
||||
if (newinv) {
|
||||
invquery = StringFormat("INSERT INTO `inventory` (charid, slotid, itemid, charges, color) VALUES (%u, %i, %u, %i, %u)",
|
||||
charid, i, newinv->GetItem()->ID, newinv->GetCharges(), newinv->GetColor());
|
||||
@@ -709,7 +716,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
|
||||
auto results = QueryDatabase(invquery);
|
||||
}
|
||||
|
||||
if (i == EQEmu::legacy::SlotCursor) {
|
||||
if (i == EQEmu::inventory::slotCursor) {
|
||||
i = EQEmu::legacy::GENERAL_BAGS_BEGIN;
|
||||
continue;
|
||||
}
|
||||
@@ -2147,4 +2154,16 @@ int Database::GetIPExemption(std::string account_ip) {
|
||||
}
|
||||
|
||||
return RuleI(World, MaxClientsPerIP);
|
||||
}
|
||||
}
|
||||
|
||||
int Database::GetInstanceID(uint32 char_id, uint32 zone_id) {
|
||||
std::string query = StringFormat("SELECT instance_list.id FROM instance_list INNER JOIN instance_list_player ON instance_list.id = instance_list_player.id WHERE instance_list.zone = '%i' AND instance_list_player.charid = '%i'", zone_id, char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (results.Success() && results.RowCount() > 0) {
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+19
-2
@@ -37,10 +37,14 @@
|
||||
//atoi is not uint32 or uint32 safe!!!!
|
||||
#define atoul(str) strtoul(str, nullptr, 10)
|
||||
|
||||
class Inventory;
|
||||
class MySQLRequestResult;
|
||||
class Client;
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
class InventoryProfile;
|
||||
}
|
||||
|
||||
struct EventLogDetails_Struct {
|
||||
uint32 id;
|
||||
char accountname[64];
|
||||
@@ -79,6 +83,17 @@ struct VarCache_Struct {
|
||||
|
||||
class PTimerList;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#if _MSC_VER > 1700 // greater than 2012 (2013+)
|
||||
# define _ISNAN_(a) std::isnan(a)
|
||||
#else
|
||||
# include <float.h>
|
||||
# define _ISNAN_(a) _isnan(a)
|
||||
#endif
|
||||
#else
|
||||
# define _ISNAN_(a) std::isnan(a)
|
||||
#endif
|
||||
|
||||
class Database : public DBcore {
|
||||
public:
|
||||
Database();
|
||||
@@ -98,7 +113,7 @@ 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 StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv);
|
||||
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv);
|
||||
bool UpdateName(const char* oldname, const char* newname);
|
||||
|
||||
/* General Information Queries */
|
||||
@@ -178,6 +193,8 @@ public:
|
||||
|
||||
int GetIPExemption(std::string account_ip);
|
||||
|
||||
int GetInstanceID(uint32 char_id, uint32 zone_id);
|
||||
|
||||
|
||||
/* Groups */
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Convert {
|
||||
/*002*/ uint32 HP;
|
||||
/*006*/ uint32 Mana;
|
||||
/*010*/ Convert::SpellBuff_Struct Buffs[BUFF_COUNT];
|
||||
/*510*/ uint32 Items[EQEmu::textures::TextureCount];
|
||||
/*510*/ uint32 Items[EQEmu::textures::materialCount];
|
||||
/*546*/ char Name[64];
|
||||
/*610*/
|
||||
};
|
||||
@@ -227,9 +227,9 @@ namespace Convert {
|
||||
/*0304*/ uint8 ability_time_minutes;
|
||||
/*0305*/ uint8 ability_time_hours; //place holder
|
||||
/*0306*/ uint8 unknown0306[6]; // @bp Spacer/Flag?
|
||||
/*0312*/ uint32 item_material[EQEmu::textures::TextureCount]; // Item texture/material of worn/held items
|
||||
/*0312*/ uint32 item_material[EQEmu::textures::materialCount]; // Item texture/material of worn/held items
|
||||
/*0348*/ uint8 unknown0348[44];
|
||||
/*0392*/ Convert::Color_Struct item_tint[EQEmu::textures::TextureCount];
|
||||
/*0392*/ Convert::Color_Struct item_tint[EQEmu::textures::materialCount];
|
||||
/*0428*/ Convert::AA_Array aa_array[MAX_PP_AA_ARRAY];
|
||||
/*2348*/ float unknown2384; //seen ~128, ~47
|
||||
/*2352*/ char servername[32]; // length probably not right
|
||||
@@ -1327,7 +1327,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){
|
||||
if (rquery != ""){ results = QueryDatabase(rquery); }
|
||||
|
||||
/* Run Bind Home Convert */
|
||||
if (pp->binds[4].zoneId < 999 && !std::isnan(pp->binds[4].x) && !std::isnan(pp->binds[4].y) && !std::isnan(pp->binds[4].z) && !std::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].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading);
|
||||
@@ -1335,7 +1335,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){
|
||||
}
|
||||
|
||||
/* Run Bind Convert */
|
||||
if (pp->binds[0].zoneId < 999 && !std::isnan(pp->binds[0].x) && !std::isnan(pp->binds[0].y) && !std::isnan(pp->binds[0].z) && !std::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].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading);
|
||||
@@ -1403,7 +1403,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){
|
||||
if (rquery != ""){ results = QueryDatabase(rquery); }
|
||||
/* Run Material Color Convert */
|
||||
first_entry = 0; rquery = "";
|
||||
for (i = 0; i < EQEmu::textures::TextureCount; i++){
|
||||
for (i = EQEmu::textures::textureBegin; i < EQEmu::textures::materialCount; i++){
|
||||
if (pp->item_tint[i].color > 0){
|
||||
if (first_entry != 1){
|
||||
rquery = StringFormat("REPLACE INTO `character_material` (id, slot, blue, green, red, use_tint, color) VALUES (%u, %u, %u, %u, %u, %u, %u)", character_id, i, pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint, pp->item_tint[i].color);
|
||||
|
||||
@@ -35,6 +35,79 @@ namespace EQEmu
|
||||
//using namespace RoF2::invbag;
|
||||
//using namespace RoF2::invaug;
|
||||
|
||||
enum : int16 { typeInvalid = -1, slotInvalid = -1, containerInvalid = -1, socketInvalid = -1 }; // temporary
|
||||
enum : int16 { typeBegin = 0, slotBegin = 0, containerBegin = 0, socketBegin = 0 }; // temporary
|
||||
|
||||
enum PossessionsSlots : int16 { // temporary
|
||||
slotCharm = 0,
|
||||
slotEar1,
|
||||
slotHead,
|
||||
slotFace,
|
||||
slotEar2,
|
||||
slotNeck, // 5
|
||||
slotShoulders,
|
||||
slotArms,
|
||||
slotBack,
|
||||
slotWrist1,
|
||||
slotWrist2, // 10
|
||||
slotRange,
|
||||
slotHands,
|
||||
slotPrimary,
|
||||
slotSecondary,
|
||||
slotFinger1, // 15
|
||||
slotFinger2,
|
||||
slotChest,
|
||||
slotLegs,
|
||||
slotFeet,
|
||||
slotWaist, // 20
|
||||
slotPowerSource = 9999,
|
||||
slotAmmo = 21,
|
||||
slotGeneral1,
|
||||
slotGeneral2,
|
||||
slotGeneral3,
|
||||
slotGeneral4, // 25
|
||||
slotGeneral5,
|
||||
slotGeneral6,
|
||||
slotGeneral7,
|
||||
slotGeneral8,
|
||||
slotCursor, // 30
|
||||
slotCount
|
||||
};
|
||||
|
||||
enum InventoryTypes : int16 { // temporary
|
||||
typePossessions = 0,
|
||||
typeBank,
|
||||
typeSharedBank,
|
||||
typeTrade,
|
||||
typeWorld,
|
||||
typeLimbo, // 5
|
||||
typeTribute,
|
||||
typeTrophyTribute,
|
||||
typeGuildTribute,
|
||||
typeMerchant,
|
||||
typeDeleted, // 10
|
||||
typeCorpse,
|
||||
typeBazaar,
|
||||
typeInspect,
|
||||
typeRealEstate,
|
||||
typeViewMODPC, // 15
|
||||
typeViewMODBank,
|
||||
typeViewMODSharedBank,
|
||||
typeViewMODLimbo,
|
||||
typeAltStorage,
|
||||
typeArchived, // 20
|
||||
typeMail,
|
||||
typeGuildTrophyTribute,
|
||||
typeKrono,
|
||||
typeOther,
|
||||
typeCount
|
||||
};
|
||||
|
||||
static int16 SlotCount(int16 type_index) { return 0; } // temporary
|
||||
|
||||
const int16 ContainerCount = 10; // temporary
|
||||
const int16 SocketCount = 6; // temporary
|
||||
|
||||
} /*inventory*/
|
||||
|
||||
namespace constants {
|
||||
@@ -43,7 +116,16 @@ namespace EQEmu
|
||||
|
||||
const size_t SayLinkBodySize = RoF2::constants::SayLinkBodySize;
|
||||
|
||||
const int LongBuffs = RoF2::constants::LongBuffs;
|
||||
const int ShortBuffs = RoF2::constants::ShortBuffs;
|
||||
const int DiscBuffs = RoF2::constants::DiscBuffs;
|
||||
const int TotalBuffs = RoF2::constants::TotalBuffs;
|
||||
const int NPCBuffs = RoF2::constants::NPCBuffs;
|
||||
const int PetBuffs = RoF2::constants::PetBuffs;
|
||||
const int MercBuffs = RoF2::constants::MercBuffs;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
enum class CastingSlot : uint32 {
|
||||
Gem1 = 0,
|
||||
Gem2 = 1,
|
||||
@@ -68,3 +150,9 @@ namespace EQEmu
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /*COMMON_EMU_CONSTANTS_H*/
|
||||
|
||||
/* hack list to prevent circular references
|
||||
|
||||
eq_limits.h:EQEmu::inventory::LookupEntry::InventoryTypeSize[n];
|
||||
|
||||
*/
|
||||
|
||||
+15
-89
@@ -61,8 +61,6 @@ namespace EQEmu
|
||||
SLOT_GENERAL_6 = 27,
|
||||
SLOT_GENERAL_7 = 28,
|
||||
SLOT_GENERAL_8 = 29,
|
||||
//SLOT_GENERAL_9 = not supported
|
||||
//SLOT_GENERAL_10 = not supported
|
||||
SLOT_CURSOR = 30,
|
||||
SLOT_CURSOR_END = (int16)0xFFFE, // I hope no one is using this...
|
||||
SLOT_TRADESKILL = 1000,
|
||||
@@ -96,75 +94,8 @@ namespace EQEmu
|
||||
SLOT_WORLD_END = 4009
|
||||
};
|
||||
|
||||
enum InventoryTypes : int16 {
|
||||
TypePossessions = 0,
|
||||
TypeBank,
|
||||
TypeSharedBank,
|
||||
TypeTrade,
|
||||
TypeWorld,
|
||||
TypeLimbo, // 5
|
||||
TypeTribute,
|
||||
TypeTrophyTribute,
|
||||
TypeGuildTribute,
|
||||
TypeMerchant,
|
||||
TypeDeleted, // 10
|
||||
TypeCorpse,
|
||||
TypeBazaar,
|
||||
TypeInspect,
|
||||
TypeRealEstate,
|
||||
TypeViewMODPC, // 15
|
||||
TypeViewMODBank,
|
||||
TypeViewMODSharedBank,
|
||||
TypeViewMODLimbo,
|
||||
TypeAltStorage,
|
||||
TypeArchived, // 20
|
||||
TypeMail,
|
||||
TypeGuildTrophyTribute,
|
||||
TypeKrono,
|
||||
TypeOther,
|
||||
TypeCount
|
||||
};
|
||||
|
||||
enum PossessionsSlots : int16 {
|
||||
SlotCharm = 0,
|
||||
SlotEar1,
|
||||
SlotHead,
|
||||
SlotFace,
|
||||
SlotEar2,
|
||||
SlotNeck, // 5
|
||||
SlotShoulders,
|
||||
SlotArms,
|
||||
SlotBack,
|
||||
SlotWrist1,
|
||||
SlotWrist2, // 10
|
||||
SlotRange,
|
||||
SlotHands,
|
||||
SlotPrimary,
|
||||
SlotSecondary,
|
||||
SlotFinger1, // 15
|
||||
SlotFinger2,
|
||||
SlotChest,
|
||||
SlotLegs,
|
||||
SlotFeet,
|
||||
SlotWaist, // 20
|
||||
SlotPowerSource = 9999, // temp
|
||||
SlotAmmo = 21, // temp
|
||||
SlotGeneral1,
|
||||
SlotGeneral2,
|
||||
SlotGeneral3,
|
||||
SlotGeneral4, // 25
|
||||
SlotGeneral5,
|
||||
SlotGeneral6,
|
||||
SlotGeneral7,
|
||||
SlotGeneral8,
|
||||
//SlotGeneral9,
|
||||
//SlotGeneral10,
|
||||
SlotCursor, // 30
|
||||
SlotCount
|
||||
};
|
||||
|
||||
// these are currently hard-coded for existing inventory system..do not use in place of special client version handlers until ready
|
||||
static const uint16 TYPE_POSSESSIONS_SIZE = SlotCount;
|
||||
static const uint16 TYPE_POSSESSIONS_SIZE = 31;
|
||||
static const uint16 TYPE_BANK_SIZE = 24;
|
||||
static const uint16 TYPE_SHARED_BANK_SIZE = 2;
|
||||
static const uint16 TYPE_TRADE_SIZE = 8;
|
||||
@@ -175,14 +106,14 @@ namespace EQEmu
|
||||
static const uint16 TYPE_GUILD_TRIBUTE_SIZE = 0;
|
||||
static const uint16 TYPE_MERCHANT_SIZE = 0;
|
||||
static const uint16 TYPE_DELETED_SIZE = 0;
|
||||
static const uint16 TYPE_CORPSE_SIZE = SlotCount; // no bitmask use..limits to size of client corpse window (see EQLimits::InventoryMapSize(MapCorpse, <EQClientVersion))
|
||||
static const uint16 TYPE_CORPSE_SIZE = 31; // no bitmask use..limits to size of client corpse window (see EQLimits::InventoryMapSize(MapCorpse, <EQClientVersion))
|
||||
static const uint16 TYPE_BAZAAR_SIZE = 80;
|
||||
static const uint16 TYPE_INSPECT_SIZE = 22;
|
||||
static const uint16 TYPE_REAL_ESTATE_SIZE = 0;
|
||||
static const uint16 TYPE_VIEW_MOD_PC_SIZE = 0;//NOT_USED;
|
||||
static const uint16 TYPE_VIEW_MOD_BANK_SIZE = 0;//NOT_USED;
|
||||
static const uint16 TYPE_VIEW_MOD_SHARED_BANK_SIZE = 0;//NOT_USED;
|
||||
static const uint16 TYPE_VIEW_MOD_LIMBO_SIZE = 0;//NOT_USED;
|
||||
static const uint16 TYPE_VIEW_MOD_PC_SIZE = 0;
|
||||
static const uint16 TYPE_VIEW_MOD_BANK_SIZE = 0;
|
||||
static const uint16 TYPE_VIEW_MOD_SHARED_BANK_SIZE = 0;
|
||||
static const uint16 TYPE_VIEW_MOD_LIMBO_SIZE = 0;
|
||||
static const uint16 TYPE_ALT_STORAGE_SIZE = 0;
|
||||
static const uint16 TYPE_ARCHIVED_SIZE = 0;
|
||||
static const uint16 TYPE_MAIL_SIZE = 0;
|
||||
@@ -192,12 +123,12 @@ namespace EQEmu
|
||||
|
||||
// most of these definitions will go away with the structure-based system..this maintains compatibility for now
|
||||
// (these are mainly to assign specific values to constants used in conversions and to identify per-client ranges/offsets)
|
||||
static const int16 EQUIPMENT_BEGIN = SlotCharm;
|
||||
static const int16 EQUIPMENT_END = SlotAmmo;
|
||||
static const int16 EQUIPMENT_BEGIN = 0;
|
||||
static const int16 EQUIPMENT_END = 21;
|
||||
static const uint16 EQUIPMENT_SIZE = 22; // does not account for 'Power Source' - used mainly for npc equipment arrays
|
||||
|
||||
static const int16 GENERAL_BEGIN = SlotGeneral1;
|
||||
static const int16 GENERAL_END = SlotGeneral8;
|
||||
static const int16 GENERAL_BEGIN = 22;
|
||||
static const int16 GENERAL_END = 29;
|
||||
static const uint16 GENERAL_SIZE = 8;
|
||||
static const int16 GENERAL_BAGS_BEGIN = 251;
|
||||
static const int16 GENERAL_BAGS_END_OFFSET = 79;
|
||||
@@ -235,22 +166,17 @@ namespace EQEmu
|
||||
static const int16 TRIBUTE_SIZE = TYPE_TRIBUTE_SIZE;
|
||||
|
||||
static const int16 CORPSE_BEGIN = 22;
|
||||
//static const int16 CORPSE_END = RoF::consts::CORPSE_END; // not ready for use
|
||||
|
||||
// items
|
||||
// common and container sizes will not increase until the new 'location' struct is implemented
|
||||
static const uint16 ITEM_COMMON_SIZE = 6;//RoF::consts::ITEM_COMMON_SIZE;
|
||||
static const uint16 ITEM_CONTAINER_SIZE = 10;//Titanium::consts::ITEM_CONTAINER_SIZE;
|
||||
|
||||
// BANDOLIERS_SIZE sets maximum limit..active limit will need to be handled by the appropriate AA or spell (or item?)
|
||||
static const size_t BANDOLIERS_SIZE = 20;//RoF2::consts::BANDOLIERS_SIZE; // number of bandolier instances
|
||||
static const size_t BANDOLIER_ITEM_COUNT = 4;//RoF2::consts::BANDOLIER_ITEM_COUNT; // number of equipment slots in bandolier instance
|
||||
static const size_t BANDOLIERS_SIZE = 20; // number of bandolier instances
|
||||
static const size_t BANDOLIER_ITEM_COUNT = 4; // number of equipment slots in bandolier instance
|
||||
|
||||
// POTION_BELT_SIZE sets maximum limit..active limit will need to be handled by the appropriate AA or spell (or item?)
|
||||
static const size_t POTION_BELT_ITEM_COUNT = 5;//RoF2::consts::POTION_BELT_ITEM_COUNT;
|
||||
static const size_t POTION_BELT_ITEM_COUNT = 5;
|
||||
|
||||
static const size_t TEXT_LINK_BODY_LENGTH = 56;//RoF2::consts::TEXT_LINK_BODY_LENGTH;
|
||||
static const size_t TEXT_LINK_BODY_LENGTH = 56;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* COMMON_EMU_LEGACY_H */
|
||||
|
||||
+113
-113
@@ -127,244 +127,244 @@ uint32 EQEmu::versions::ConvertClientVersionToExpansion(ClientVersion client_ver
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidInventoryVersion(InventoryVersion inventory_version)
|
||||
bool EQEmu::versions::IsValidMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= InventoryVersion::Unknown || inventory_version > LastInventoryVersion)
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidPCInventoryVersion(InventoryVersion inventory_version)
|
||||
bool EQEmu::versions::IsValidPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= InventoryVersion::Unknown || inventory_version > LastPCInventoryVersion)
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastPCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidNonPCInventoryVersion(InventoryVersion inventory_version)
|
||||
bool EQEmu::versions::IsValidNonPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= LastPCInventoryVersion || inventory_version > LastNonPCInventoryVersion)
|
||||
if (mob_version <= LastPCMobVersion || mob_version > LastNonPCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidOfflinePCInventoryVersion(InventoryVersion inventory_version)
|
||||
bool EQEmu::versions::IsValidOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= LastNonPCInventoryVersion || inventory_version > LastOfflinePCInventoryVersion)
|
||||
if (mob_version <= LastNonPCMobVersion || mob_version > LastOfflinePCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ValidateInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= InventoryVersion::Unknown || inventory_version > LastInventoryVersion)
|
||||
return InventoryVersion::Unknown;
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return inventory_version;
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ValidatePCInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidatePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= InventoryVersion::Unknown || inventory_version > LastPCInventoryVersion)
|
||||
return InventoryVersion::Unknown;
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastPCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return inventory_version;
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ValidateNonPCInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateNonPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= LastPCInventoryVersion || inventory_version > LastNonPCInventoryVersion)
|
||||
return InventoryVersion::Unknown;
|
||||
if (mob_version <= LastPCMobVersion || mob_version > LastNonPCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return inventory_version;
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ValidateOfflinePCInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (inventory_version <= LastNonPCInventoryVersion || inventory_version > LastOfflinePCInventoryVersion)
|
||||
return InventoryVersion::Unknown;
|
||||
if (mob_version <= LastNonPCMobVersion || mob_version > LastOfflinePCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return inventory_version;
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
const char* EQEmu::versions::InventoryVersionName(InventoryVersion inventory_version)
|
||||
const char* EQEmu::versions::MobVersionName(MobVersion mob_version)
|
||||
{
|
||||
switch (inventory_version) {
|
||||
case InventoryVersion::Unknown:
|
||||
switch (mob_version) {
|
||||
case MobVersion::Unknown:
|
||||
return "Unknown Version";
|
||||
case InventoryVersion::Client62:
|
||||
case MobVersion::Client62:
|
||||
return "Client 6.2";
|
||||
case InventoryVersion::Titanium:
|
||||
case MobVersion::Titanium:
|
||||
return "Titanium";
|
||||
case InventoryVersion::SoF:
|
||||
case MobVersion::SoF:
|
||||
return "SoF";
|
||||
case InventoryVersion::SoD:
|
||||
case MobVersion::SoD:
|
||||
return "SoD";
|
||||
case InventoryVersion::UF:
|
||||
case MobVersion::UF:
|
||||
return "UF";
|
||||
case InventoryVersion::RoF:
|
||||
case MobVersion::RoF:
|
||||
return "RoF";
|
||||
case InventoryVersion::RoF2:
|
||||
case MobVersion::RoF2:
|
||||
return "RoF2";
|
||||
case InventoryVersion::NPC:
|
||||
case MobVersion::NPC:
|
||||
return "NPC";
|
||||
case InventoryVersion::NPCMerchant:
|
||||
case MobVersion::NPCMerchant:
|
||||
return "NPC Merchant";
|
||||
case InventoryVersion::Merc:
|
||||
case MobVersion::Merc:
|
||||
return "Merc";
|
||||
case InventoryVersion::Bot:
|
||||
case MobVersion::Bot:
|
||||
return "Bot";
|
||||
case InventoryVersion::ClientPet:
|
||||
case MobVersion::ClientPet:
|
||||
return "Client Pet";
|
||||
case InventoryVersion::NPCPet:
|
||||
case MobVersion::NPCPet:
|
||||
return "NPC Pet";
|
||||
case InventoryVersion::MercPet:
|
||||
case MobVersion::MercPet:
|
||||
return "Merc Pet";
|
||||
case InventoryVersion::BotPet:
|
||||
case MobVersion::BotPet:
|
||||
return "Bot Pet";
|
||||
case InventoryVersion::OfflineTitanium:
|
||||
case MobVersion::OfflineTitanium:
|
||||
return "Offline Titanium";
|
||||
case InventoryVersion::OfflineSoF:
|
||||
case MobVersion::OfflineSoF:
|
||||
return "Offline SoF";
|
||||
case InventoryVersion::OfflineSoD:
|
||||
case MobVersion::OfflineSoD:
|
||||
return "Offline SoD";
|
||||
case InventoryVersion::OfflineUF:
|
||||
case MobVersion::OfflineUF:
|
||||
return "Offline UF";
|
||||
case InventoryVersion::OfflineRoF:
|
||||
case MobVersion::OfflineRoF:
|
||||
return "Offline RoF";
|
||||
case InventoryVersion::OfflineRoF2:
|
||||
case MobVersion::OfflineRoF2:
|
||||
return "Offline RoF2";
|
||||
default:
|
||||
return "Invalid Version";
|
||||
};
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertInventoryVersionToClientVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertMobVersionToClientVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (inventory_version) {
|
||||
case InventoryVersion::Unknown:
|
||||
case InventoryVersion::Client62:
|
||||
switch (mob_version) {
|
||||
case MobVersion::Unknown:
|
||||
case MobVersion::Client62:
|
||||
return ClientVersion::Unknown;
|
||||
case InventoryVersion::Titanium:
|
||||
case MobVersion::Titanium:
|
||||
return ClientVersion::Titanium;
|
||||
case InventoryVersion::SoF:
|
||||
case MobVersion::SoF:
|
||||
return ClientVersion::SoF;
|
||||
case InventoryVersion::SoD:
|
||||
case MobVersion::SoD:
|
||||
return ClientVersion::SoD;
|
||||
case InventoryVersion::UF:
|
||||
case MobVersion::UF:
|
||||
return ClientVersion::UF;
|
||||
case InventoryVersion::RoF:
|
||||
case MobVersion::RoF:
|
||||
return ClientVersion::RoF;
|
||||
case InventoryVersion::RoF2:
|
||||
case MobVersion::RoF2:
|
||||
return ClientVersion::RoF2;
|
||||
default:
|
||||
return ClientVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ConvertClientVersionToInventoryVersion(ClientVersion client_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertClientVersionToMobVersion(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Unknown:
|
||||
case ClientVersion::Client62:
|
||||
return InventoryVersion::Unknown;
|
||||
return MobVersion::Unknown;
|
||||
case ClientVersion::Titanium:
|
||||
return InventoryVersion::Titanium;
|
||||
return MobVersion::Titanium;
|
||||
case ClientVersion::SoF:
|
||||
return InventoryVersion::SoF;
|
||||
return MobVersion::SoF;
|
||||
case ClientVersion::SoD:
|
||||
return InventoryVersion::SoD;
|
||||
return MobVersion::SoD;
|
||||
case ClientVersion::UF:
|
||||
return InventoryVersion::UF;
|
||||
return MobVersion::UF;
|
||||
case ClientVersion::RoF:
|
||||
return InventoryVersion::RoF;
|
||||
return MobVersion::RoF;
|
||||
case ClientVersion::RoF2:
|
||||
return InventoryVersion::RoF2;
|
||||
return MobVersion::RoF2;
|
||||
default:
|
||||
return InventoryVersion::Unknown;
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ConvertPCInventoryVersionToOfflinePCInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertPCMobVersionToOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (inventory_version) {
|
||||
case InventoryVersion::Titanium:
|
||||
return InventoryVersion::OfflineTitanium;
|
||||
case InventoryVersion::SoF:
|
||||
return InventoryVersion::OfflineSoF;
|
||||
case InventoryVersion::SoD:
|
||||
return InventoryVersion::OfflineSoD;
|
||||
case InventoryVersion::UF:
|
||||
return InventoryVersion::OfflineUF;
|
||||
case InventoryVersion::RoF:
|
||||
return InventoryVersion::OfflineRoF;
|
||||
case InventoryVersion::RoF2:
|
||||
return InventoryVersion::OfflineRoF2;
|
||||
switch (mob_version) {
|
||||
case MobVersion::Titanium:
|
||||
return MobVersion::OfflineTitanium;
|
||||
case MobVersion::SoF:
|
||||
return MobVersion::OfflineSoF;
|
||||
case MobVersion::SoD:
|
||||
return MobVersion::OfflineSoD;
|
||||
case MobVersion::UF:
|
||||
return MobVersion::OfflineUF;
|
||||
case MobVersion::RoF:
|
||||
return MobVersion::OfflineRoF;
|
||||
case MobVersion::RoF2:
|
||||
return MobVersion::OfflineRoF2;
|
||||
default:
|
||||
return InventoryVersion::Unknown;
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ConvertOfflinePCInventoryVersionToPCInventoryVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertOfflinePCMobVersionToPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (inventory_version) {
|
||||
case InventoryVersion::OfflineTitanium:
|
||||
return InventoryVersion::Titanium;
|
||||
case InventoryVersion::OfflineSoF:
|
||||
return InventoryVersion::SoF;
|
||||
case InventoryVersion::OfflineSoD:
|
||||
return InventoryVersion::SoD;
|
||||
case InventoryVersion::OfflineUF:
|
||||
return InventoryVersion::UF;
|
||||
case InventoryVersion::OfflineRoF:
|
||||
return InventoryVersion::RoF;
|
||||
case InventoryVersion::OfflineRoF2:
|
||||
return InventoryVersion::RoF2;
|
||||
switch (mob_version) {
|
||||
case MobVersion::OfflineTitanium:
|
||||
return MobVersion::Titanium;
|
||||
case MobVersion::OfflineSoF:
|
||||
return MobVersion::SoF;
|
||||
case MobVersion::OfflineSoD:
|
||||
return MobVersion::SoD;
|
||||
case MobVersion::OfflineUF:
|
||||
return MobVersion::UF;
|
||||
case MobVersion::OfflineRoF:
|
||||
return MobVersion::RoF;
|
||||
case MobVersion::OfflineRoF2:
|
||||
return MobVersion::RoF2;
|
||||
default:
|
||||
return InventoryVersion::Unknown;
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertOfflinePCInventoryVersionToClientVersion(InventoryVersion inventory_version)
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertOfflinePCMobVersionToClientVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (inventory_version) {
|
||||
case InventoryVersion::OfflineTitanium:
|
||||
switch (mob_version) {
|
||||
case MobVersion::OfflineTitanium:
|
||||
return ClientVersion::Titanium;
|
||||
case InventoryVersion::OfflineSoF:
|
||||
case MobVersion::OfflineSoF:
|
||||
return ClientVersion::SoF;
|
||||
case InventoryVersion::OfflineSoD:
|
||||
case MobVersion::OfflineSoD:
|
||||
return ClientVersion::SoD;
|
||||
case InventoryVersion::OfflineUF:
|
||||
case MobVersion::OfflineUF:
|
||||
return ClientVersion::UF;
|
||||
case InventoryVersion::OfflineRoF:
|
||||
case MobVersion::OfflineRoF:
|
||||
return ClientVersion::RoF;
|
||||
case InventoryVersion::OfflineRoF2:
|
||||
case MobVersion::OfflineRoF2:
|
||||
return ClientVersion::RoF2;
|
||||
default:
|
||||
return ClientVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::InventoryVersion EQEmu::versions::ConvertClientVersionToOfflinePCInventoryVersion(ClientVersion client_version)
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertClientVersionToOfflinePCMobVersion(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Titanium:
|
||||
return InventoryVersion::OfflineTitanium;
|
||||
return MobVersion::OfflineTitanium;
|
||||
case ClientVersion::SoF:
|
||||
return InventoryVersion::OfflineSoF;
|
||||
return MobVersion::OfflineSoF;
|
||||
case ClientVersion::SoD:
|
||||
return InventoryVersion::OfflineSoD;
|
||||
return MobVersion::OfflineSoD;
|
||||
case ClientVersion::UF:
|
||||
return InventoryVersion::OfflineUF;
|
||||
return MobVersion::OfflineUF;
|
||||
case ClientVersion::RoF:
|
||||
return InventoryVersion::OfflineRoF;
|
||||
return MobVersion::OfflineRoF;
|
||||
case ClientVersion::RoF2:
|
||||
return InventoryVersion::OfflineRoF2;
|
||||
return MobVersion::OfflineRoF2;
|
||||
default:
|
||||
return InventoryVersion::Unknown;
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-29
@@ -64,17 +64,15 @@ namespace EQEmu
|
||||
const ClientVersion LastClientVersion = ClientVersion::RoF2;
|
||||
const size_t ClientVersionCount = (static_cast<size_t>(LastClientVersion) + 1);
|
||||
|
||||
extern bool IsValidClientVersion(ClientVersion client_version);
|
||||
extern ClientVersion ValidateClientVersion(ClientVersion client_version);
|
||||
extern const char* ClientVersionName(ClientVersion client_version);
|
||||
extern uint32 ConvertClientVersionToClientVersionBit(ClientVersion client_version);
|
||||
extern ClientVersion ConvertClientVersionBitToClientVersion(uint32 client_version_bit);
|
||||
extern uint32 ConvertClientVersionToExpansion(ClientVersion client_version);
|
||||
bool IsValidClientVersion(ClientVersion client_version);
|
||||
ClientVersion ValidateClientVersion(ClientVersion client_version);
|
||||
const char* ClientVersionName(ClientVersion client_version);
|
||||
uint32 ConvertClientVersionToClientVersionBit(ClientVersion client_version);
|
||||
ClientVersion ConvertClientVersionBitToClientVersion(uint32 client_version_bit);
|
||||
uint32 ConvertClientVersionToExpansion(ClientVersion client_version);
|
||||
|
||||
} /*versions*/
|
||||
|
||||
namespace versions {
|
||||
enum class InventoryVersion {
|
||||
enum class MobVersion {
|
||||
Unknown = 0,
|
||||
Client62,
|
||||
Titanium,
|
||||
@@ -99,29 +97,29 @@ namespace EQEmu
|
||||
OfflineRoF2
|
||||
};
|
||||
|
||||
const InventoryVersion LastInventoryVersion = InventoryVersion::OfflineRoF2;
|
||||
const InventoryVersion LastPCInventoryVersion = InventoryVersion::RoF2;
|
||||
const InventoryVersion LastNonPCInventoryVersion = InventoryVersion::BotPet;
|
||||
const InventoryVersion LastOfflinePCInventoryVersion = InventoryVersion::OfflineRoF2;
|
||||
const size_t InventoryVersionCount = (static_cast<size_t>(LastInventoryVersion) + 1);
|
||||
const MobVersion LastMobVersion = MobVersion::OfflineRoF2;
|
||||
const MobVersion LastPCMobVersion = MobVersion::RoF2;
|
||||
const MobVersion LastNonPCMobVersion = MobVersion::BotPet;
|
||||
const MobVersion LastOfflinePCMobVersion = MobVersion::OfflineRoF2;
|
||||
const size_t MobVersionCount = (static_cast<size_t>(LastMobVersion) + 1);
|
||||
|
||||
extern bool IsValidInventoryVersion(InventoryVersion inventory_version);
|
||||
extern bool IsValidPCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern bool IsValidNonPCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern bool IsValidOfflinePCInventoryVersion(InventoryVersion inventory_version);
|
||||
bool IsValidMobVersion(MobVersion mob_version);
|
||||
bool IsValidPCMobVersion(MobVersion mob_version);
|
||||
bool IsValidNonPCMobVersion(MobVersion mob_version);
|
||||
bool IsValidOfflinePCMobVersion(MobVersion mob_version);
|
||||
|
||||
extern InventoryVersion ValidateInventoryVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ValidatePCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ValidateNonPCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ValidateOfflinePCInventoryVersion(InventoryVersion inventory_version);
|
||||
MobVersion ValidateMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidatePCMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidateNonPCMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidateOfflinePCMobVersion(MobVersion mob_version);
|
||||
|
||||
extern const char* InventoryVersionName(InventoryVersion inventory_version);
|
||||
extern ClientVersion ConvertInventoryVersionToClientVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ConvertClientVersionToInventoryVersion(ClientVersion client_version);
|
||||
extern InventoryVersion ConvertPCInventoryVersionToOfflinePCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ConvertOfflinePCInventoryVersionToPCInventoryVersion(InventoryVersion inventory_version);
|
||||
extern ClientVersion ConvertOfflinePCInventoryVersionToClientVersion(InventoryVersion inventory_version);
|
||||
extern InventoryVersion ConvertClientVersionToOfflinePCInventoryVersion(ClientVersion client_version);
|
||||
const char* MobVersionName(MobVersion mob_version);
|
||||
ClientVersion ConvertMobVersionToClientVersion(MobVersion mob_version);
|
||||
MobVersion ConvertClientVersionToMobVersion(ClientVersion client_version);
|
||||
MobVersion ConvertPCMobVersionToOfflinePCMobVersion(MobVersion mob_version);
|
||||
MobVersion ConvertOfflinePCMobVersionToPCMobVersion(MobVersion mob_version);
|
||||
ClientVersion ConvertOfflinePCMobVersionToClientVersion(MobVersion mob_version);
|
||||
MobVersion ConvertClientVersionToOfflinePCMobVersion(ClientVersion client_version);
|
||||
|
||||
} /*versions*/
|
||||
|
||||
|
||||
@@ -516,14 +516,6 @@ static const uint8 SkillDamageTypes[EQEmu::skills::HIGHEST_SKILL + 1] = // chang
|
||||
*/
|
||||
|
||||
#define INVALID_INDEX -1
|
||||
#define NO_ITEM 0
|
||||
|
||||
// yes..these are redundant... but, they help to identify and define what is actually being performed
|
||||
// plus, since they're pre-op's, they don't affect the actual binary size
|
||||
#define TYPE_BEGIN 0
|
||||
#define SLOT_BEGIN 0
|
||||
#define SUB_INDEX_BEGIN 0
|
||||
#define AUG_INDEX_BEGIN 0
|
||||
|
||||
static const uint32 MAX_SPELL_DB_ID_VAL = 65535;
|
||||
|
||||
|
||||
+791
-189
File diff suppressed because it is too large
Load Diff
+10
-3
@@ -38,6 +38,13 @@ namespace EQEmu
|
||||
class LookupEntry {
|
||||
public:
|
||||
size_t CharacterCreationLimit;
|
||||
int LongBuffs;
|
||||
int ShortBuffs;
|
||||
int DiscBuffs;
|
||||
int TotalBuffs;
|
||||
int NPCBuffs;
|
||||
int PetBuffs;
|
||||
int MercBuffs;
|
||||
};
|
||||
|
||||
const LookupEntry* Lookup(versions::ClientVersion client_version);
|
||||
@@ -47,7 +54,7 @@ namespace EQEmu
|
||||
namespace inventory {
|
||||
class LookupEntry {
|
||||
public:
|
||||
size_t InventoryTypeSize[legacy::TypeCount];
|
||||
size_t InventoryTypeSize[25]; // should reflect EQEmu::inventory::typeCount referenced in emu_constants.h
|
||||
|
||||
uint64 PossessionsBitmask;
|
||||
size_t ItemBagSize;
|
||||
@@ -59,7 +66,7 @@ namespace EQEmu
|
||||
bool AllowOverLevelEquipment;
|
||||
};
|
||||
|
||||
const LookupEntry* Lookup(versions::InventoryVersion inventory_version);
|
||||
const LookupEntry* Lookup(versions::MobVersion mob_version);
|
||||
|
||||
} /*inventory*/
|
||||
|
||||
@@ -69,7 +76,7 @@ namespace EQEmu
|
||||
bool CoinHasWeight;
|
||||
};
|
||||
|
||||
const LookupEntry* Lookup(versions::InventoryVersion inventory_version);
|
||||
const LookupEntry* Lookup(versions::MobVersion mob_version);
|
||||
|
||||
} /*behavior*/
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ struct LDoNTrapTemplate
|
||||
|
||||
// All clients translate the character select information to some degree
|
||||
|
||||
struct CharSelectEquip : EQEmu::Texture_Struct, EQEmu::Tint_Struct {};
|
||||
struct CharSelectEquip : EQEmu::textures::Texture_Struct, EQEmu::textures::Tint_Struct {};
|
||||
|
||||
// RoF2-based hybrid struct
|
||||
struct CharacterSelectEntry_Struct
|
||||
@@ -142,7 +142,7 @@ struct CharacterSelectEntry_Struct
|
||||
uint16 Instance;
|
||||
uint8 Gender;
|
||||
uint8 Face;
|
||||
CharSelectEquip Equip[EQEmu::textures::TextureCount];
|
||||
CharSelectEquip Equip[EQEmu::textures::materialCount];
|
||||
uint8 Unknown15; // Seen FF
|
||||
uint8 Unknown19; // Seen FF
|
||||
uint32 DrakkinTattoo;
|
||||
@@ -834,7 +834,7 @@ struct SuspendedMinion_Struct
|
||||
/*002*/ uint32 HP;
|
||||
/*006*/ uint32 Mana;
|
||||
/*010*/ SpellBuff_Struct Buffs[BUFF_COUNT];
|
||||
/*510*/ EQEmu::TextureShortProfile Items;
|
||||
/*510*/ EQEmu::TextureMaterialProfile Items;
|
||||
/*546*/ char Name[64];
|
||||
/*610*/
|
||||
};
|
||||
@@ -942,7 +942,7 @@ struct PlayerProfile_Struct
|
||||
/*0304*/ uint8 ability_time_minutes;
|
||||
/*0305*/ uint8 ability_time_hours; //place holder
|
||||
/*0306*/ uint8 unknown0306[6]; // @bp Spacer/Flag?
|
||||
/*0312*/ EQEmu::TextureShortProfile item_material; // Item texture/material of worn/held items
|
||||
/*0312*/ EQEmu::TextureMaterialProfile item_material; // Item texture/material of worn/held items
|
||||
/*0348*/ uint8 unknown0348[44];
|
||||
/*0392*/ EQEmu::TintProfile item_tint;
|
||||
/*0428*/ AA_Array aa_array[MAX_PP_AA_ARRAY];
|
||||
@@ -1179,7 +1179,7 @@ struct WearChange_Struct{
|
||||
/*010*/ uint32 elite_material; // 1 for Drakkin Elite Material
|
||||
/*014*/ uint32 hero_forge_model; // New to VoA
|
||||
/*018*/ uint32 unknown18; // New to RoF
|
||||
/*022*/ EQEmu::Tint_Struct color;
|
||||
/*022*/ EQEmu::textures::Tint_Struct color;
|
||||
/*026*/ uint8 wear_slot_id;
|
||||
/*027*/
|
||||
};
|
||||
@@ -1643,7 +1643,7 @@ struct LootingItem_Struct {
|
||||
/*002*/ uint32 looter;
|
||||
/*004*/ uint16 slot_id;
|
||||
/*006*/ uint8 unknown3[2];
|
||||
/*008*/ uint32 auto_loot;
|
||||
/*008*/ int32 auto_loot;
|
||||
};
|
||||
|
||||
struct GuildManageStatus_Struct{
|
||||
@@ -2071,7 +2071,7 @@ struct AdventureLeaderboard_Struct
|
||||
/*struct Item_Shop_Struct {
|
||||
uint16 merchantid;
|
||||
uint8 itemtype;
|
||||
EQEmu::ItemBase item;
|
||||
EQEmu::ItemData item;
|
||||
uint8 iss_unknown001[6];
|
||||
};*/
|
||||
|
||||
@@ -3517,6 +3517,20 @@ struct RecipeAutoCombine_Struct {
|
||||
// f5 ff ff ff in 'you dont have all the stuff' reply
|
||||
};
|
||||
|
||||
// this is the "value#a" data
|
||||
enum EParticlePoint {
|
||||
eDefault,
|
||||
eChest,
|
||||
eHead,
|
||||
eLeftHand,
|
||||
eRigthHand,
|
||||
eLeftFoot,
|
||||
eRightFood,
|
||||
eLeftEye,
|
||||
eRightEye,
|
||||
eMouth
|
||||
};
|
||||
|
||||
struct LevelAppearance_Struct { //Sends a little graphic on level up
|
||||
uint32 spawn_id;
|
||||
uint32 parm1;
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
#ifndef EQEMU_LOGSYS_H
|
||||
#define EQEMU_LOGSYS_H
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <functional>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace Logs {
|
||||
@@ -158,13 +158,6 @@ public:
|
||||
void SetCurrentTimeStamp(char* time_stamp); /* Used in file logs to prepend a timestamp entry for logs */
|
||||
void StartFileLogs(const std::string &log_name = ""); /* Used to declare the processes file log and to keep it open for later use */
|
||||
|
||||
template <typename... Args>
|
||||
void OutF(Logs::DebugLevel debug_level, uint16 log_category, const char *fmt, const Args&... args)
|
||||
{
|
||||
std::string log_str = fmt::format(fmt, args...);
|
||||
Out(debug_level, log_category, log_str);
|
||||
}
|
||||
|
||||
/*
|
||||
LogSettings Struct
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include "event_loop.h"
|
||||
|
||||
namespace EQ {
|
||||
class BackgroundTask
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(void)> BackgroundTaskFunction;
|
||||
struct BackgroundTaskBaton
|
||||
{
|
||||
BackgroundTaskFunction fn;
|
||||
BackgroundTaskFunction on_finish;
|
||||
};
|
||||
|
||||
BackgroundTask(BackgroundTaskFunction fn, BackgroundTaskFunction on_finish) {
|
||||
uv_work_t *m_work = new uv_work_t;
|
||||
memset(m_work, 0, sizeof(uv_work_t));
|
||||
BackgroundTaskBaton *baton = new BackgroundTaskBaton();
|
||||
baton->fn = fn;
|
||||
baton->on_finish = on_finish;
|
||||
|
||||
m_work->data = baton;
|
||||
uv_queue_work(EventLoop::Get().Handle(), m_work, [](uv_work_t* req) {
|
||||
BackgroundTaskBaton *baton = (BackgroundTaskBaton*)req->data;
|
||||
baton->fn();
|
||||
}, [](uv_work_t* req, int status) {
|
||||
BackgroundTaskBaton *baton = (BackgroundTaskBaton*)req->data;
|
||||
baton->on_finish();
|
||||
delete baton;
|
||||
delete req;
|
||||
});
|
||||
}
|
||||
|
||||
~BackgroundTask() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <uv.h>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
class EventLoop
|
||||
{
|
||||
public:
|
||||
static EventLoop &Get() {
|
||||
static EventLoop inst;
|
||||
return inst;
|
||||
}
|
||||
|
||||
~EventLoop() {
|
||||
uv_loop_close(&m_loop);
|
||||
}
|
||||
|
||||
void Process() {
|
||||
uv_run(&m_loop, UV_RUN_NOWAIT);
|
||||
}
|
||||
|
||||
uv_loop_t* Handle() { return &m_loop; }
|
||||
|
||||
private:
|
||||
EventLoop() {
|
||||
memset(&m_loop, 0, sizeof(uv_loop_t));
|
||||
uv_loop_init(&m_loop);
|
||||
}
|
||||
|
||||
EventLoop(const EventLoop&);
|
||||
EventLoop& operator=(const EventLoop&);
|
||||
|
||||
uv_loop_t m_loop;
|
||||
};
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include "event_loop.h"
|
||||
|
||||
namespace EQ {
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
Timer(uint64_t duration_ms, bool repeats, std::function<void(void)> cb)
|
||||
{
|
||||
memset(&m_timer, 0, sizeof(uv_timer_t));
|
||||
m_cb = cb;
|
||||
m_duration_ms = duration_ms;
|
||||
m_repeats = repeats;
|
||||
m_attached = nullptr;
|
||||
Attach(EventLoop::Get().Handle());
|
||||
}
|
||||
|
||||
~Timer()
|
||||
{
|
||||
Detach();
|
||||
}
|
||||
private:
|
||||
void Execute() {
|
||||
m_cb();
|
||||
}
|
||||
|
||||
virtual void Attach(uv_loop_t *loop) {
|
||||
if (!m_attached) {
|
||||
uv_timer_init(loop, &m_timer);
|
||||
m_timer.data = this;
|
||||
|
||||
if (m_repeats) {
|
||||
uv_timer_start(&m_timer, [](uv_timer_t *handle) {
|
||||
Timer *t = (Timer*)handle->data;
|
||||
t->Execute();
|
||||
}, m_duration_ms, m_duration_ms);
|
||||
}
|
||||
else {
|
||||
uv_timer_start(&m_timer, [](uv_timer_t *handle) {
|
||||
Timer *t = (Timer*)handle->data;
|
||||
t->Execute();
|
||||
}, m_duration_ms, 0);
|
||||
}
|
||||
|
||||
m_attached = loop;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Detach() {
|
||||
if (m_attached) {
|
||||
uv_timer_stop(&m_timer);
|
||||
m_attached = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
uv_timer_t m_timer;
|
||||
std::function<void(void)> m_cb;
|
||||
uint64_t m_duration_ms;
|
||||
bool m_repeats;
|
||||
uv_loop_t *m_attached;
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
#define EXTENDED_PROFILE_H
|
||||
|
||||
#include "eq_packet_structs.h"
|
||||
#include "item.h"
|
||||
#include "inventory_profile.h"
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
@@ -40,7 +40,7 @@ struct ExtendedProfile_Struct {
|
||||
uint16 old_pet_hp; /* Not Used */
|
||||
uint16 old_pet_mana; /* Not Used */
|
||||
SpellBuff_Struct pet_buffs[BUFF_COUNT]; /* Not Used */
|
||||
EQEmu::TextureShortProfile pet_items; /* Not Used */
|
||||
EQEmu::TextureMaterialProfile pet_items; /* Not Used */
|
||||
char merc_name[64]; /* Used */
|
||||
|
||||
uint32 aa_effects; /* Used */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,230 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 04111-1307 USA
|
||||
*/
|
||||
|
||||
// @merth notes:
|
||||
// These classes could be optimized with database reads/writes by storing
|
||||
// a status flag indicating how object needs to interact with database
|
||||
|
||||
#ifndef COMMON_INVENTORY_PROFILE_H
|
||||
#define COMMON_INVENTORY_PROFILE_H
|
||||
|
||||
|
||||
#include "item_instance.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
//FatherNitwit: location bits for searching specific
|
||||
//places with HasItem() and HasItemByUse()
|
||||
enum {
|
||||
invWhereWorn = 0x01,
|
||||
invWherePersonal = 0x02, //in the character's inventory
|
||||
invWhereBank = 0x04,
|
||||
invWhereSharedBank = 0x08,
|
||||
invWhereTrading = 0x10,
|
||||
invWhereCursor = 0x20
|
||||
};
|
||||
|
||||
// ########################################
|
||||
// Class: Queue
|
||||
// Queue that allows a read-only iterator
|
||||
class ItemInstQueue
|
||||
{
|
||||
public:
|
||||
~ItemInstQueue();
|
||||
/////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////
|
||||
|
||||
inline std::list<EQEmu::ItemInstance*>::const_iterator cbegin() { return m_list.cbegin(); }
|
||||
inline std::list<EQEmu::ItemInstance*>::const_iterator cend() { return m_list.cend(); }
|
||||
|
||||
inline int size() { return static_cast<int>(m_list.size()); } // TODO: change to size_t
|
||||
inline bool empty() { return m_list.empty(); }
|
||||
|
||||
void push(EQEmu::ItemInstance* inst);
|
||||
void push_front(EQEmu::ItemInstance* inst);
|
||||
EQEmu::ItemInstance* pop();
|
||||
EQEmu::ItemInstance* pop_back();
|
||||
EQEmu::ItemInstance* peek_front() const;
|
||||
|
||||
protected:
|
||||
/////////////////////////
|
||||
// Protected Members
|
||||
/////////////////////////
|
||||
|
||||
std::list<EQEmu::ItemInstance*> m_list;
|
||||
};
|
||||
|
||||
// ########################################
|
||||
// Class: EQEmu::InventoryProfile
|
||||
// Character inventory
|
||||
namespace EQEmu
|
||||
{
|
||||
class InventoryProfile
|
||||
{
|
||||
friend class ItemInstance;
|
||||
public:
|
||||
///////////////////////////////
|
||||
// Public Methods
|
||||
///////////////////////////////
|
||||
|
||||
InventoryProfile() { m_mob_version = versions::MobVersion::Unknown; m_mob_version_set = false; }
|
||||
~InventoryProfile();
|
||||
|
||||
bool SetInventoryVersion(versions::MobVersion inventory_version) {
|
||||
if (!m_mob_version_set) {
|
||||
m_mob_version = versions::ValidateMobVersion(inventory_version);
|
||||
return (m_mob_version_set = true);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool SetInventoryVersion(versions::ClientVersion client_version) { return SetInventoryVersion(versions::ConvertClientVersionToMobVersion(client_version)); }
|
||||
|
||||
versions::MobVersion InventoryVersion() { return m_mob_version; }
|
||||
|
||||
static void CleanDirty();
|
||||
static void MarkDirty(ItemInstance *inst);
|
||||
|
||||
// Retrieve a writeable item at specified slot
|
||||
ItemInstance* GetItem(int16 slot_id) const;
|
||||
ItemInstance* GetItem(int16 slot_id, uint8 bagidx) const;
|
||||
|
||||
inline std::list<ItemInstance*>::const_iterator cursor_cbegin() { return m_cursor.cbegin(); }
|
||||
inline std::list<ItemInstance*>::const_iterator cursor_cend() { return m_cursor.cend(); }
|
||||
|
||||
inline int CursorSize() { return m_cursor.size(); }
|
||||
inline bool CursorEmpty() { return m_cursor.empty(); }
|
||||
|
||||
// Retrieve a read-only item from inventory
|
||||
inline const ItemInstance* operator[](int16 slot_id) const { return GetItem(slot_id); }
|
||||
|
||||
// Add item to inventory
|
||||
int16 PutItem(int16 slot_id, const ItemInstance& inst);
|
||||
|
||||
// Add item to cursor queue
|
||||
int16 PushCursor(const ItemInstance& inst);
|
||||
|
||||
// Get cursor item in front of queue
|
||||
ItemInstance* GetCursorItem();
|
||||
|
||||
// Swap items in inventory
|
||||
bool SwapItem(int16 slot_a, int16 slot_b);
|
||||
|
||||
// Remove item from inventory
|
||||
bool DeleteItem(int16 slot_id, uint8 quantity = 0);
|
||||
|
||||
// Checks All items in a bag for No Drop
|
||||
bool CheckNoDrop(int16 slot_id, bool recurse = true);
|
||||
|
||||
// Remove item from inventory (and take control of memory)
|
||||
ItemInstance* PopItem(int16 slot_id);
|
||||
|
||||
// Check whether there is space for the specified number of the specified item.
|
||||
bool HasSpaceForItem(const ItemData *ItemToTry, int16 Quantity);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItem(uint32 item_id, uint8 quantity = 0, uint8 where = 0xFF);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByUse(uint8 use, uint8 quantity = 0, uint8 where = 0xFF);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where = 0xFF);
|
||||
|
||||
// Locate an available inventory slot
|
||||
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
||||
int16 FindFreeSlotForTradeItem(const ItemInstance* inst);
|
||||
|
||||
// Calculate slot_id for an item within a bag
|
||||
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
|
||||
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag
|
||||
static uint8 CalcBagIdx(int16 slot_id); // Calc bagidx for slot_id
|
||||
static int16 CalcSlotFromMaterial(uint8 material);
|
||||
static uint8 CalcMaterialFromSlot(int16 equipslot);
|
||||
|
||||
static bool CanItemFitInContainer(const ItemData *ItemToTry, const ItemData *Container);
|
||||
|
||||
// Test for valid inventory casting slot
|
||||
bool SupportsClickCasting(int16 slot_id);
|
||||
bool SupportsPotionBeltCasting(int16 slot_id);
|
||||
|
||||
// Test whether a given slot can support a container item
|
||||
static bool SupportsContainers(int16 slot_id);
|
||||
|
||||
int GetSlotByItemInst(ItemInstance *inst);
|
||||
|
||||
uint8 FindBrightestLightType();
|
||||
|
||||
void dumpEntireInventory();
|
||||
void dumpWornItems();
|
||||
void dumpInventory();
|
||||
void dumpBankItems();
|
||||
void dumpSharedBankItems();
|
||||
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
|
||||
std::string GetCustomItemData(int16 slot_id, std::string identifier);
|
||||
protected:
|
||||
///////////////////////////////
|
||||
// Protected Methods
|
||||
///////////////////////////////
|
||||
|
||||
int GetSlotByItemInstCollection(const std::map<int16, ItemInstance*> &collection, ItemInstance *inst);
|
||||
void dumpItemCollection(const std::map<int16, ItemInstance*> &collection);
|
||||
void dumpBagContents(ItemInstance *inst, std::map<int16, ItemInstance*>::const_iterator *it);
|
||||
|
||||
// Retrieves item within an inventory bucket
|
||||
ItemInstance* _GetItem(const std::map<int16, ItemInstance*>& bucket, int16 slot_id) const;
|
||||
|
||||
// Private "put" item into bucket, without regard for what is currently in bucket
|
||||
int16 _PutItem(int16 slot_id, ItemInstance* inst);
|
||||
|
||||
// Checks an inventory bucket for a particular item
|
||||
int16 _HasItem(std::map<int16, ItemInstance*>& bucket, uint32 item_id, uint8 quantity);
|
||||
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
|
||||
int16 _HasItemByUse(std::map<int16, ItemInstance*>& bucket, uint8 use, uint8 quantity);
|
||||
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
||||
int16 _HasItemByLoreGroup(std::map<int16, ItemInstance*>& bucket, uint32 loregroup);
|
||||
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
||||
|
||||
|
||||
// Player inventory
|
||||
std::map<int16, ItemInstance*> m_worn; // Items worn by character
|
||||
std::map<int16, ItemInstance*> m_inv; // Items in character personal inventory
|
||||
std::map<int16, ItemInstance*> m_bank; // Items in character bank
|
||||
std::map<int16, ItemInstance*> m_shbank; // Items in character shared bank
|
||||
std::map<int16, ItemInstance*> m_trade; // Items in a trade session
|
||||
::ItemInstQueue m_cursor; // Items on cursor: FIFO
|
||||
|
||||
private:
|
||||
// Active mob version
|
||||
versions::MobVersion m_mob_version;
|
||||
bool m_mob_version_set;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /*COMMON_INVENTORY_PROFILE_H*/
|
||||
@@ -0,0 +1,397 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 "inventory_slot.h"
|
||||
#include "textures.h"
|
||||
#include "string_util.h"
|
||||
|
||||
|
||||
int8 EQEmu::inventory::ConvertEquipmentIndexToTextureIndex(int16 slot_index)
|
||||
{
|
||||
switch (slot_index) {
|
||||
case slotHead:
|
||||
return textures::armorHead;
|
||||
case slotChest:
|
||||
return textures::armorChest;
|
||||
case slotArms:
|
||||
return textures::armorArms;
|
||||
case slotWrist1:
|
||||
return textures::armorWrist;
|
||||
case slotHands:
|
||||
return textures::armorHands;
|
||||
case slotLegs:
|
||||
return textures::armorLegs;
|
||||
case slotFeet:
|
||||
return textures::armorFeet;
|
||||
case slotPrimary:
|
||||
return textures::weaponPrimary;
|
||||
case slotSecondary:
|
||||
return textures::weaponSecondary;
|
||||
default:
|
||||
return textures::textureInvalid;
|
||||
}
|
||||
}
|
||||
|
||||
int8 EQEmu::inventory::ConvertEquipmentSlotToTextureIndex(const InventorySlot& inventory_slot)
|
||||
{
|
||||
if ((!inventory_slot.Typeless() && !inventory_slot.IsTypeIndex(typePossessions)) || !inventory_slot.IsContainerIndex(containerInvalid) || !inventory_slot.IsSocketIndex(socketInvalid))
|
||||
return textures::textureInvalid;
|
||||
|
||||
return ConvertEquipmentIndexToTextureIndex(inventory_slot.SlotIndex());
|
||||
}
|
||||
|
||||
int16 EQEmu::inventory::ConvertTextureIndexToEquipmentIndex(int8 texture_index)
|
||||
{
|
||||
switch (texture_index) {
|
||||
case textures::armorHead:
|
||||
return slotHead;
|
||||
case textures::armorChest:
|
||||
return slotChest;
|
||||
case textures::armorArms:
|
||||
return slotArms;
|
||||
case textures::armorWrist:
|
||||
return slotWrist1;
|
||||
case textures::armorHands:
|
||||
return slotHands;
|
||||
case textures::armorLegs:
|
||||
return slotLegs;
|
||||
case textures::armorFeet:
|
||||
return slotFeet;
|
||||
case textures::weaponPrimary:
|
||||
return slotPrimary;
|
||||
case textures::weaponSecondary:
|
||||
return slotSecondary;
|
||||
default:
|
||||
return slotInvalid;
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsValidSlot() const
|
||||
{
|
||||
if (_typeless)
|
||||
return false;
|
||||
|
||||
int16 slot_count = inventory::SlotCount(_type_index);
|
||||
if (!slot_count || _slot_index < inventory::slotBegin || _slot_index >= slot_count)
|
||||
return false;
|
||||
|
||||
if (_container_index < inventory::containerInvalid || _container_index >= inventory::ContainerCount)
|
||||
return false;
|
||||
|
||||
if (_socket_index < inventory::socketInvalid || _socket_index >= inventory::SocketCount)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsDeleteSlot() const
|
||||
{
|
||||
if (_typeless)
|
||||
return (_slot_index == inventory::slotInvalid && _container_index == inventory::containerInvalid && _socket_index == inventory::socketInvalid);
|
||||
else
|
||||
return (_type_index == inventory::typeInvalid && _slot_index == inventory::slotInvalid && _container_index == inventory::containerInvalid && _socket_index == inventory::socketInvalid);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsEquipmentIndex(int16 slot_index)
|
||||
{
|
||||
/*if (slot_index < inventory::EquipmentBegin || slot_index > inventory::EquipmentEnd)
|
||||
return false;*/
|
||||
if ((slot_index < legacy::EQUIPMENT_BEGIN || slot_index > legacy::EQUIPMENT_END) && slot_index != legacy::SLOT_POWER_SOURCE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsGeneralIndex(int16 slot_index)
|
||||
{
|
||||
/*if (slot_index < inventory::GeneralBegin || slot_index > inventory::GeneralEnd)
|
||||
return false;*/
|
||||
if (slot_index < legacy::GENERAL_BEGIN || slot_index > legacy::GENERAL_END)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsCursorIndex(int16 slot_index)
|
||||
{
|
||||
/*if (slot_index != inventory::slotCursor)
|
||||
return false;*/
|
||||
if (slot_index != legacy::SLOT_CURSOR)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsWeaponIndex(int16 slot_index)
|
||||
{
|
||||
/*if ((slot_index != inventory::slotRange) && (slot_index != inventory::slotPrimary) && (slot_index != inventory::slotSecondary))
|
||||
return false;*/
|
||||
if ((slot_index != legacy::SLOT_RANGE) && (slot_index != legacy::SLOT_PRIMARY) && (slot_index != legacy::SLOT_SECONDARY))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsTextureIndex(int16 slot_index)
|
||||
{
|
||||
switch (slot_index) {
|
||||
case inventory::slotHead:
|
||||
case inventory::slotChest:
|
||||
case inventory::slotArms:
|
||||
case inventory::slotWrist1:
|
||||
case inventory::slotHands:
|
||||
case inventory::slotLegs:
|
||||
case inventory::slotFeet:
|
||||
case inventory::slotPrimary:
|
||||
case inventory::slotSecondary:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsTintableIndex(int16 slot_index)
|
||||
{
|
||||
switch (slot_index) {
|
||||
case inventory::slotHead:
|
||||
case inventory::slotChest:
|
||||
case inventory::slotArms:
|
||||
case inventory::slotWrist1:
|
||||
case inventory::slotHands:
|
||||
case inventory::slotLegs:
|
||||
case inventory::slotFeet:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsEquipmentSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsEquipmentIndex(_slot_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsGeneralSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsGeneralIndex(_socket_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsCursorSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsCursorIndex(_slot_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsWeaponSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsWeaponIndex(_slot_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsTextureSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsTextureIndex(_slot_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsTintableSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index != inventory::typePossessions))
|
||||
return false;
|
||||
|
||||
if ((_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
return false;
|
||||
|
||||
return IsTintableIndex(_slot_index);
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsSlot() const
|
||||
{
|
||||
if (!_typeless && (_type_index == inventory::typeInvalid))
|
||||
return false;
|
||||
if (_slot_index == inventory::slotInvalid)
|
||||
return false;
|
||||
if (_container_index != inventory::containerInvalid)
|
||||
return false;
|
||||
if (_socket_index != inventory::socketInvalid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsSlotSocket() const
|
||||
{
|
||||
if (!_typeless && (_type_index == inventory::typeInvalid))
|
||||
return false;
|
||||
if (_slot_index == inventory::slotInvalid)
|
||||
return false;
|
||||
if (_container_index != inventory::containerInvalid)
|
||||
return false;
|
||||
if (_socket_index == inventory::socketInvalid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsContainer() const
|
||||
{
|
||||
if (!_typeless && (_type_index == inventory::typeInvalid))
|
||||
return false;
|
||||
if (_slot_index == inventory::slotInvalid)
|
||||
return false;
|
||||
if (_container_index == inventory::containerInvalid)
|
||||
return false;
|
||||
if (_socket_index != inventory::socketInvalid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::IsContainerSocket() const
|
||||
{
|
||||
if (!_typeless && (_type_index == inventory::typeInvalid))
|
||||
return false;
|
||||
if (_slot_index == inventory::slotInvalid)
|
||||
return false;
|
||||
if (_container_index == inventory::containerInvalid)
|
||||
return false;
|
||||
if (_socket_index == inventory::socketInvalid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EQEmu::InventorySlot EQEmu::InventorySlot::ToTopOwner() const
|
||||
{
|
||||
return InventorySlot(_type_index, _slot_index);
|
||||
}
|
||||
|
||||
EQEmu::InventorySlot EQEmu::InventorySlot::ToOwner() const
|
||||
{
|
||||
if (IsSlot() || IsSlotSocket() || IsContainer())
|
||||
return InventorySlot(_type_index, _slot_index);
|
||||
|
||||
if (IsContainerSocket())
|
||||
return InventorySlot(_type_index, _slot_index, _container_index);
|
||||
|
||||
return InventorySlot();
|
||||
}
|
||||
|
||||
const std::string EQEmu::InventorySlot::ToString() const
|
||||
{
|
||||
return StringFormat("(%i%s, %i, %i, %i)", _type_index, (_typeless ? " [typeless]" : ""), _slot_index, _container_index, _socket_index);
|
||||
}
|
||||
|
||||
const std::string EQEmu::InventorySlot::ToName() const
|
||||
{
|
||||
return StringFormat("InventorySlot - _type_index: %i%s, _slot_index: %i, _container_index: %i, _socket_index: %i", _type_index, (_typeless ? " [typeless]" : ""), _slot_index, _container_index, _socket_index);
|
||||
}
|
||||
|
||||
void EQEmu::InventorySlot::SetInvalidSlot()
|
||||
{
|
||||
_type_index = inventory::typeInvalid;
|
||||
_slot_index = inventory::slotInvalid;
|
||||
_container_index = inventory::containerInvalid;
|
||||
_socket_index = inventory::socketInvalid;
|
||||
}
|
||||
|
||||
//bool EQEmu::InventorySlot::IsBonusIndex(int16 slot_index)
|
||||
//{
|
||||
// if ((slot_index >= inventory::EquipmentBegin) && (slot_index <= inventory::EquipmentEnd) && (slot_index != inventory::slotAmmo))
|
||||
// return true;
|
||||
//
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//bool EQEmu::InventorySlot::IsBonusSlot() const
|
||||
//{
|
||||
// if ((_type_index != inventory::typePossessions) || (_container_index != inventory::containerInvalid) || (_socket_index != inventory::socketInvalid))
|
||||
// return false;
|
||||
//
|
||||
// return IsBonusIndex(_slot_index);
|
||||
//}
|
||||
|
||||
bool inventory_slot_typeless_lessthan(const EQEmu::InventorySlot& lhs, const EQEmu::InventorySlot& rhs)
|
||||
{
|
||||
if (lhs.SlotIndex() < rhs.SlotIndex())
|
||||
return true;
|
||||
|
||||
if ((lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() < rhs.ContainerIndex()))
|
||||
return true;
|
||||
|
||||
if ((lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() == rhs.ContainerIndex()) && (lhs.SocketIndex() < rhs.SocketIndex()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EQEmu::InventorySlot::operator<(const InventorySlot& rhs) const
|
||||
{
|
||||
if (Typeless() || rhs.Typeless())
|
||||
return inventory_slot_typeless_lessthan(*this, rhs);
|
||||
|
||||
if (TypeIndex() < rhs.TypeIndex())
|
||||
return true;
|
||||
|
||||
if ((TypeIndex() == rhs.TypeIndex()) && (SlotIndex() < rhs.SlotIndex()))
|
||||
return true;
|
||||
|
||||
if ((TypeIndex() == rhs.TypeIndex()) && (SlotIndex() == rhs.SlotIndex()) && (ContainerIndex() < rhs.ContainerIndex()))
|
||||
return true;
|
||||
|
||||
if ((TypeIndex() == rhs.TypeIndex()) && (SlotIndex() == rhs.SlotIndex()) && (ContainerIndex() == rhs.ContainerIndex()) && (SocketIndex() < rhs.SocketIndex()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EQEmu::operator==(const InventorySlot& lhs, const InventorySlot& rhs)
|
||||
{
|
||||
if (lhs.Typeless() || rhs.Typeless())
|
||||
return ((lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() == rhs.ContainerIndex()) && (lhs.SocketIndex() == rhs.SocketIndex()));
|
||||
|
||||
return ((lhs.TypeIndex() == rhs.TypeIndex()) && (lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() == rhs.ContainerIndex()) && (lhs.SocketIndex() == rhs.SocketIndex()));
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 COMMON_INVENTORY_SLOT
|
||||
#define COMMON_INVENTORY_SLOT
|
||||
|
||||
#include "emu_constants.h"
|
||||
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
class InventorySlot;
|
||||
|
||||
namespace inventory {
|
||||
int8 ConvertEquipmentIndexToTextureIndex(int16 slot_index);
|
||||
int8 ConvertEquipmentSlotToTextureIndex(const InventorySlot& inventory_slot);
|
||||
int16 ConvertTextureIndexToEquipmentIndex(int8 texture_index);
|
||||
}
|
||||
|
||||
class InventorySlot {
|
||||
public:
|
||||
InventorySlot() : _type_index(inventory::typeInvalid), _slot_index(inventory::slotInvalid), _container_index(inventory::containerInvalid), _socket_index(inventory::socketInvalid), _typeless(false) { }
|
||||
InventorySlot(int16 type_index) : _type_index(type_index), _slot_index(inventory::slotInvalid), _container_index(inventory::containerInvalid), _socket_index(inventory::socketInvalid), _typeless(false) { }
|
||||
InventorySlot(int16 type_index, int16 parent_index) : _type_index(type_index), _slot_index(parent_index), _container_index(inventory::containerInvalid), _socket_index(inventory::socketInvalid), _typeless(false) { }
|
||||
InventorySlot(int16 type_index, int16 parent_index, int16 bag_index) : _type_index(type_index), _slot_index(parent_index), _container_index(bag_index), _socket_index(inventory::socketInvalid), _typeless(false) { }
|
||||
InventorySlot(int16 type_index, int16 parent_index, int16 bag_index, int16 aug_index) : _type_index(type_index), _slot_index(parent_index), _container_index(bag_index), _socket_index(aug_index), _typeless(false) { }
|
||||
InventorySlot(const InventorySlot& r) : _type_index(r._type_index), _slot_index(r._slot_index), _container_index(r._container_index), _socket_index(r._socket_index), _typeless(r._typeless) { }
|
||||
InventorySlot(int16 type_index, const InventorySlot& r) : _type_index(type_index), _slot_index(r._slot_index), _container_index(r._container_index), _socket_index(r._socket_index), _typeless(false) { }
|
||||
|
||||
inline int16 TypeIndex() const { return _type_index; }
|
||||
inline int16 SlotIndex() const { return _slot_index; }
|
||||
inline int16 ContainerIndex() const { return _container_index; }
|
||||
inline int16 SocketIndex() const { return _socket_index; }
|
||||
|
||||
bool Typeless() const { return _typeless; }
|
||||
|
||||
bool IsValidSlot() const;
|
||||
bool IsDeleteSlot() const;
|
||||
|
||||
static bool IsEquipmentIndex(int16 slot_index);
|
||||
static bool IsGeneralIndex(int16 slot_index);
|
||||
static bool IsCursorIndex(int16 slot_index);
|
||||
static bool IsWeaponIndex(int16 slot_index);
|
||||
static bool IsTextureIndex(int16 slot_index);
|
||||
static bool IsTintableIndex(int16 slot_index);
|
||||
|
||||
bool IsEquipmentSlot() const;
|
||||
bool IsGeneralSlot() const;
|
||||
bool IsCursorSlot() const;
|
||||
bool IsWeaponSlot() const;
|
||||
bool IsTextureSlot() const;
|
||||
bool IsTintableSlot() const;
|
||||
|
||||
bool IsSlot() const;
|
||||
bool IsSlotSocket() const;
|
||||
bool IsContainer() const;
|
||||
bool IsContainerSocket() const;
|
||||
|
||||
InventorySlot ToTopOwner() const;
|
||||
InventorySlot ToOwner() const;
|
||||
|
||||
const std::string ToString() const;
|
||||
const std::string ToName() const;
|
||||
|
||||
bool IsTypeIndex(int16 type_index) const { return (_type_index == type_index); }
|
||||
bool IsSlotIndex(int16 slot_index) const { return (_slot_index == slot_index); }
|
||||
bool IsContainerIndex(int16 container_index) const { return (_container_index == container_index); }
|
||||
bool IsSocketIndex(int16 socket_index) const { return (_socket_index == socket_index); }
|
||||
|
||||
void SetType(int16 type_index) { _type_index = type_index; }
|
||||
void SetSlot(int16 slot_index) { _slot_index = slot_index; }
|
||||
void SetContainer(int16 container_index) { _container_index = container_index; }
|
||||
void SetSocket(int16 socket_index) { _socket_index = socket_index; }
|
||||
|
||||
void SetInvalidSlot();
|
||||
|
||||
void SetTypeInvalid() { _type_index = inventory::typeInvalid; }
|
||||
void SetSlotInvalid() { _slot_index = inventory::slotInvalid; }
|
||||
void SetContainerInvalid() { _container_index = inventory::containerInvalid; }
|
||||
void SetSocketInvalid() { _socket_index = inventory::socketInvalid; }
|
||||
|
||||
void SetTypeBegin() { _type_index = inventory::typeBegin; }
|
||||
void SetSlotBegin() { _slot_index = inventory::slotBegin; }
|
||||
void SetContainerBegin() { _container_index = inventory::containerBegin; }
|
||||
void SetSocketBegin() { _socket_index = inventory::socketBegin; }
|
||||
|
||||
void IncrementType() { ++_type_index; }
|
||||
void IncrementSlot() { ++_slot_index; }
|
||||
void IncrementContainer() { ++_container_index; }
|
||||
void IncrementSocket() { ++_socket_index; }
|
||||
|
||||
void SetTypeless() { _typeless = true; }
|
||||
void ClearTypeless() { _typeless = false; }
|
||||
|
||||
// these two methods should really check for all bonus-valid slots..currently checks for equipment only (rework needed)
|
||||
//static bool IsBonusIndex(int16 slot_index);
|
||||
//bool IsBonusSlot() const;
|
||||
|
||||
bool operator<(const InventorySlot& rhs) const;
|
||||
|
||||
private:
|
||||
int16 _type_index;
|
||||
//int16 _unknown2; // not implemented
|
||||
int16 _slot_index;
|
||||
int16 _container_index;
|
||||
int16 _socket_index;
|
||||
//int16 _unknown1; // not implemented
|
||||
|
||||
bool _typeless;
|
||||
};
|
||||
|
||||
bool operator==(const InventorySlot& lhs, const InventorySlot& rhs);
|
||||
bool operator!=(const InventorySlot& lhs, const InventorySlot& rhs) { return (!(lhs == rhs)); }
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /*COMMON_INVENTORY_SLOT*/
|
||||
-3073
File diff suppressed because it is too large
Load Diff
-544
@@ -1,544 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 04111-1307 USA
|
||||
*/
|
||||
|
||||
// @merth notes:
|
||||
// These classes could be optimized with database reads/writes by storing
|
||||
// a status flag indicating how object needs to interact with database
|
||||
|
||||
#ifndef COMMON_ITEM_H
|
||||
#define COMMON_ITEM_H
|
||||
|
||||
|
||||
class ItemParse; // Parses item packets
|
||||
class EvolveInfo; // Stores information about an evolving item family
|
||||
|
||||
#include "../common/eq_constants.h"
|
||||
#include "../common/item_base.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/bodytypes.h"
|
||||
#include "../common/deity.h"
|
||||
#include "../common/memory_buffer.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace ItemField
|
||||
{
|
||||
enum
|
||||
{
|
||||
source = 0,
|
||||
#define F(x) x,
|
||||
#include "item_fieldlist.h"
|
||||
#undef F
|
||||
updated
|
||||
};
|
||||
};
|
||||
|
||||
// Specifies usage type for item inside ItemInst
|
||||
enum ItemInstTypes
|
||||
{
|
||||
ItemInstNormal = 0,
|
||||
ItemInstWorldContainer
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
byFlagIgnore, //do not consider this flag
|
||||
byFlagSet, //apply action if the flag is set
|
||||
byFlagNotSet //apply action if the flag is NOT set
|
||||
} byFlagSetting;
|
||||
|
||||
|
||||
//FatherNitwit: location bits for searching specific
|
||||
//places with HasItem() and HasItemByUse()
|
||||
enum {
|
||||
invWhereWorn = 0x01,
|
||||
invWherePersonal = 0x02, //in the character's inventory
|
||||
invWhereBank = 0x04,
|
||||
invWhereSharedBank = 0x08,
|
||||
invWhereTrading = 0x10,
|
||||
invWhereCursor = 0x20
|
||||
};
|
||||
|
||||
class ItemInst;
|
||||
|
||||
// ########################################
|
||||
// Class: Queue
|
||||
// Queue that allows a read-only iterator
|
||||
class ItemInstQueue
|
||||
{
|
||||
public:
|
||||
~ItemInstQueue();
|
||||
/////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////
|
||||
|
||||
inline std::list<ItemInst*>::const_iterator cbegin() { return m_list.cbegin(); }
|
||||
inline std::list<ItemInst*>::const_iterator cend() { return m_list.cend(); }
|
||||
|
||||
inline int size() { return static_cast<int>(m_list.size()); } // TODO: change to size_t
|
||||
inline bool empty() { return m_list.empty(); }
|
||||
|
||||
void push(ItemInst* inst);
|
||||
void push_front(ItemInst* inst);
|
||||
ItemInst* pop();
|
||||
ItemInst* pop_back();
|
||||
ItemInst* peek_front() const;
|
||||
|
||||
protected:
|
||||
/////////////////////////
|
||||
// Protected Members
|
||||
/////////////////////////
|
||||
|
||||
std::list<ItemInst*> m_list;
|
||||
};
|
||||
|
||||
// ########################################
|
||||
// Class: Inventory
|
||||
// Character inventory
|
||||
class Inventory
|
||||
{
|
||||
friend class ItemInst;
|
||||
public:
|
||||
///////////////////////////////
|
||||
// Public Methods
|
||||
///////////////////////////////
|
||||
|
||||
Inventory() { m_inventory_version = EQEmu::versions::InventoryVersion::Unknown; m_inventory_version_set = false; }
|
||||
~Inventory();
|
||||
|
||||
// inv2 creep
|
||||
bool SetInventoryVersion(EQEmu::versions::InventoryVersion inventory_version) {
|
||||
if (!m_inventory_version_set) {
|
||||
m_inventory_version = EQEmu::versions::ValidateInventoryVersion(inventory_version);
|
||||
return (m_inventory_version_set = true);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool SetInventoryVersion(EQEmu::versions::ClientVersion client_version) { return SetInventoryVersion(EQEmu::versions::ConvertClientVersionToInventoryVersion(client_version)); }
|
||||
|
||||
EQEmu::versions::InventoryVersion InventoryVersion() { return m_inventory_version; }
|
||||
|
||||
static void CleanDirty();
|
||||
static void MarkDirty(ItemInst *inst);
|
||||
|
||||
// Retrieve a writeable item at specified slot
|
||||
ItemInst* GetItem(int16 slot_id) const;
|
||||
ItemInst* GetItem(int16 slot_id, uint8 bagidx) const;
|
||||
|
||||
inline std::list<ItemInst*>::const_iterator cursor_cbegin() { return m_cursor.cbegin(); }
|
||||
inline std::list<ItemInst*>::const_iterator cursor_cend() { return m_cursor.cend(); }
|
||||
|
||||
inline int CursorSize() { return m_cursor.size(); }
|
||||
inline bool CursorEmpty() { return m_cursor.empty(); }
|
||||
|
||||
// Retrieve a read-only item from inventory
|
||||
inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); }
|
||||
|
||||
// Add item to inventory
|
||||
int16 PutItem(int16 slot_id, const ItemInst& inst);
|
||||
|
||||
// Add item to cursor queue
|
||||
int16 PushCursor(const ItemInst& inst);
|
||||
|
||||
// Get cursor item in front of queue
|
||||
ItemInst* GetCursorItem();
|
||||
|
||||
// Swap items in inventory
|
||||
bool SwapItem(int16 slot_a, int16 slot_b);
|
||||
|
||||
// Remove item from inventory
|
||||
bool DeleteItem(int16 slot_id, uint8 quantity=0);
|
||||
|
||||
// Checks All items in a bag for No Drop
|
||||
bool CheckNoDrop(int16 slot_id);
|
||||
|
||||
// Remove item from inventory (and take control of memory)
|
||||
ItemInst* PopItem(int16 slot_id);
|
||||
|
||||
// Check whether there is space for the specified number of the specified item.
|
||||
bool HasSpaceForItem(const EQEmu::ItemBase *ItemToTry, int16 Quantity);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItem(uint32 item_id, uint8 quantity = 0, uint8 where = 0xFF);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF);
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF);
|
||||
|
||||
// Locate an available inventory slot
|
||||
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
||||
int16 FindFreeSlotForTradeItem(const ItemInst* inst);
|
||||
|
||||
// Calculate slot_id for an item within a bag
|
||||
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
|
||||
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag
|
||||
static uint8 CalcBagIdx(int16 slot_id); // Calc bagidx for slot_id
|
||||
static int16 CalcSlotFromMaterial(uint8 material);
|
||||
static uint8 CalcMaterialFromSlot(int16 equipslot);
|
||||
|
||||
static bool CanItemFitInContainer(const EQEmu::ItemBase *ItemToTry, const EQEmu::ItemBase *Container);
|
||||
|
||||
// Test for valid inventory casting slot
|
||||
bool SupportsClickCasting(int16 slot_id);
|
||||
bool SupportsPotionBeltCasting(int16 slot_id);
|
||||
|
||||
// Test whether a given slot can support a container item
|
||||
static bool SupportsContainers(int16 slot_id);
|
||||
|
||||
int GetSlotByItemInst(ItemInst *inst);
|
||||
|
||||
uint8 FindBrightestLightType();
|
||||
|
||||
void dumpEntireInventory();
|
||||
void dumpWornItems();
|
||||
void dumpInventory();
|
||||
void dumpBankItems();
|
||||
void dumpSharedBankItems();
|
||||
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
|
||||
std::string GetCustomItemData(int16 slot_id, std::string identifier);
|
||||
protected:
|
||||
///////////////////////////////
|
||||
// Protected Methods
|
||||
///////////////////////////////
|
||||
|
||||
int GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst);
|
||||
void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
|
||||
void dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::const_iterator *it);
|
||||
|
||||
// Retrieves item within an inventory bucket
|
||||
ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const;
|
||||
|
||||
// Private "put" item into bucket, without regard for what is currently in bucket
|
||||
int16 _PutItem(int16 slot_id, ItemInst* inst);
|
||||
|
||||
// Checks an inventory bucket for a particular item
|
||||
int16 _HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
|
||||
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
|
||||
int16 _HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
|
||||
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
||||
int16 _HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup);
|
||||
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
||||
|
||||
|
||||
// Player inventory
|
||||
std::map<int16, ItemInst*> m_worn; // Items worn by character
|
||||
std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
|
||||
std::map<int16, ItemInst*> m_bank; // Items in character bank
|
||||
std::map<int16, ItemInst*> m_shbank; // Items in character shared bank
|
||||
std::map<int16, ItemInst*> m_trade; // Items in a trade session
|
||||
ItemInstQueue m_cursor; // Items on cursor: FIFO
|
||||
|
||||
private:
|
||||
// Active inventory version
|
||||
EQEmu::versions::InventoryVersion m_inventory_version;
|
||||
bool m_inventory_version_set;
|
||||
};
|
||||
|
||||
class SharedDatabase;
|
||||
|
||||
// ########################################
|
||||
// Class: ItemInst
|
||||
// Base class for an instance of an item
|
||||
// An item instance encapsulates item data + data specific
|
||||
// to an item instance (includes dye, augments, charges, etc)
|
||||
class ItemInst
|
||||
{
|
||||
public:
|
||||
/////////////////////////
|
||||
// Methods
|
||||
/////////////////////////
|
||||
|
||||
// Constructors/Destructor
|
||||
ItemInst(const EQEmu::ItemBase* item = nullptr, int16 charges = 0);
|
||||
|
||||
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
|
||||
|
||||
ItemInst(ItemInstTypes use_type);
|
||||
|
||||
ItemInst(const ItemInst& copy);
|
||||
|
||||
~ItemInst();
|
||||
|
||||
// Query item type
|
||||
bool IsType(EQEmu::item::ItemClass item_class) const;
|
||||
|
||||
bool IsClassCommon();
|
||||
bool IsClassBag();
|
||||
bool IsClassBook();
|
||||
|
||||
bool IsClassCommon() const { return const_cast<ItemInst*>(this)->IsClassCommon(); }
|
||||
bool IsClassBag() const { return const_cast<ItemInst*>(this)->IsClassBag(); }
|
||||
bool IsClassBook() const { return const_cast<ItemInst*>(this)->IsClassBook(); }
|
||||
|
||||
// Can item be stacked?
|
||||
bool IsStackable() const;
|
||||
bool IsCharged() const;
|
||||
|
||||
// Can item be equipped by/at?
|
||||
bool IsEquipable(uint16 race, uint16 class_) const;
|
||||
bool IsEquipable(int16 slot_id) const;
|
||||
|
||||
//
|
||||
// Augments
|
||||
//
|
||||
bool IsAugmentable() const;
|
||||
bool AvailableWearSlot(uint32 aug_wear_slots) const;
|
||||
int8 AvailableAugmentSlot(int32 augtype) const;
|
||||
bool IsAugmentSlotAvailable(int32 augtype, uint8 slot) const;
|
||||
inline int32 GetAugmentType() const { return ((m_item) ? m_item->AugType : NO_ITEM); }
|
||||
|
||||
inline bool IsExpendable() const { return ((m_item) ? ((m_item->Click.Type == EQEmu::item::ItemEffectExpendable) || (m_item->ItemType == EQEmu::item::ItemTypePotion)) : false); }
|
||||
|
||||
//
|
||||
// Contents
|
||||
//
|
||||
ItemInst* GetItem(uint8 slot) const;
|
||||
uint32 GetItemID(uint8 slot) const;
|
||||
inline const ItemInst* operator[](uint8 slot) const { return GetItem(slot); }
|
||||
void PutItem(uint8 slot, const ItemInst& inst);
|
||||
void PutItem(SharedDatabase *db, uint8 slot, uint32 item_id) { return; } // not defined anywhere...
|
||||
void DeleteItem(uint8 slot);
|
||||
ItemInst* PopItem(uint8 index);
|
||||
void Clear();
|
||||
void ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent);
|
||||
uint8 FirstOpenSlot() const;
|
||||
uint8 GetTotalItemCount() const;
|
||||
bool IsNoneEmptyContainer();
|
||||
std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
|
||||
|
||||
//
|
||||
// Augments
|
||||
//
|
||||
ItemInst* GetAugment(uint8 slot) const;
|
||||
uint32 GetAugmentItemID(uint8 slot) const;
|
||||
void PutAugment(uint8 slot, const ItemInst& inst);
|
||||
void PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id);
|
||||
void DeleteAugment(uint8 slot);
|
||||
ItemInst* RemoveAugment(uint8 index);
|
||||
bool IsAugmented();
|
||||
ItemInst* GetOrnamentationAug(int32 ornamentationAugtype) const;
|
||||
bool UpdateOrnamentationInfo();
|
||||
static bool CanTransform(const EQEmu::ItemBase *ItemToTry, const EQEmu::ItemBase *Container, bool AllowAll = false);
|
||||
|
||||
// Has attack/delay?
|
||||
bool IsWeapon() const;
|
||||
bool IsAmmo() const;
|
||||
|
||||
// Accessors
|
||||
const uint32 GetID() const { return ((m_item) ? m_item->ID : NO_ITEM); }
|
||||
const uint32 GetItemScriptID() const { return ((m_item) ? m_item->ScriptFileID : NO_ITEM); }
|
||||
const EQEmu::ItemBase* GetItem() const;
|
||||
const EQEmu::ItemBase* GetUnscaledItem() const;
|
||||
|
||||
int16 GetCharges() const { return m_charges; }
|
||||
void SetCharges(int16 charges) { m_charges = charges; }
|
||||
|
||||
uint32 GetPrice() const { return m_price; }
|
||||
void SetPrice(uint32 price) { m_price = price; }
|
||||
|
||||
void SetColor(uint32 color) { m_color = color; }
|
||||
uint32 GetColor() const { return m_color; }
|
||||
|
||||
uint32 GetMerchantSlot() const { return m_merchantslot; }
|
||||
void SetMerchantSlot(uint32 slot) { m_merchantslot = slot; }
|
||||
|
||||
int32 GetMerchantCount() const { return m_merchantcount; }
|
||||
void SetMerchantCount(int32 count) { m_merchantcount = count; }
|
||||
|
||||
int16 GetCurrentSlot() const { return m_currentslot; }
|
||||
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
|
||||
|
||||
// Is this item already attuned?
|
||||
bool IsAttuned() const { return m_attuned; }
|
||||
void SetAttuned(bool flag) { m_attuned=flag; }
|
||||
|
||||
std::string GetCustomDataString() const;
|
||||
std::string GetCustomData(std::string identifier);
|
||||
void SetCustomData(std::string identifier, std::string value);
|
||||
void SetCustomData(std::string identifier, int value);
|
||||
void SetCustomData(std::string identifier, float value);
|
||||
void SetCustomData(std::string identifier, bool value);
|
||||
void DeleteCustomData(std::string identifier);
|
||||
|
||||
// Allows treatment of this object as though it were a pointer to m_item
|
||||
operator bool() const { return (m_item != nullptr); }
|
||||
|
||||
// Compare inner Item_Struct of two ItemInst objects
|
||||
bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); }
|
||||
bool operator!=(const ItemInst& right) const { return (this->m_item != right.m_item); }
|
||||
|
||||
// Clone current item
|
||||
ItemInst* Clone() const;
|
||||
|
||||
bool IsSlotAllowed(int16 slot_id) const;
|
||||
|
||||
bool IsScaling() const { return m_scaling; }
|
||||
bool IsEvolving() const { return (m_evolveLvl >= 1); }
|
||||
uint32 GetExp() const { return m_exp; }
|
||||
void SetExp(uint32 exp) { m_exp = exp; }
|
||||
void AddExp(uint32 exp) { m_exp += exp; }
|
||||
bool IsActivated() { return m_activated; }
|
||||
void SetActivated(bool activated) { m_activated = activated; }
|
||||
int8 GetEvolveLvl() const { return m_evolveLvl; }
|
||||
void SetScaling(bool v) { m_scaling = v; }
|
||||
uint32 GetOrnamentationIcon() const { return m_ornamenticon; }
|
||||
void SetOrnamentIcon(uint32 ornament_icon) { m_ornamenticon = ornament_icon; }
|
||||
uint32 GetOrnamentationIDFile() const { return m_ornamentidfile; }
|
||||
void SetOrnamentationIDFile(uint32 ornament_idfile) { m_ornamentidfile = ornament_idfile; }
|
||||
uint32 GetOrnamentHeroModel(int32 material_slot = -1) const;
|
||||
void SetOrnamentHeroModel(uint32 ornament_hero_model) { m_ornament_hero_model = ornament_hero_model; }
|
||||
uint32 GetRecastTimestamp() const { return m_recast_timestamp; }
|
||||
void SetRecastTimestamp(uint32 in) { m_recast_timestamp = in; }
|
||||
|
||||
void Initialize(SharedDatabase *db = nullptr);
|
||||
void ScaleItem();
|
||||
bool EvolveOnAllKills() const;
|
||||
int8 GetMaxEvolveLvl() const;
|
||||
uint32 GetKillsNeeded(uint8 currentlevel);
|
||||
|
||||
std::string Serialize(int16 slot_id) const { EQEmu::InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(EQEmu::InternalSerializedItem_Struct)); return ser; }
|
||||
void Serialize(EQEmu::OutBuffer& ob, int16 slot_id) const { EQEmu::InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); }
|
||||
|
||||
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
||||
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
||||
|
||||
std::map<std::string, Timer>& GetTimers() { return m_timers; }
|
||||
void SetTimer(std::string name, uint32 time);
|
||||
void StopTimer(std::string name);
|
||||
void ClearTimers();
|
||||
|
||||
// Get a total of a stat, including augs
|
||||
// These functions should be used in place of other code manually totaling
|
||||
// to centralize where it is done to make future changes easier (ex. whenever powersources come around)
|
||||
// and to minimize errors. CalcItemBonuses however doesn't use these in interest of performance
|
||||
// by default these do not recurse into augs
|
||||
int GetItemArmorClass(bool augments = false) const;
|
||||
int GetItemElementalDamage(int &magic, int &fire, int &cold, int &poison, int &disease, int &chromatic, int &prismatic, int &physical, int &corruption, bool augments = false) const;
|
||||
// These two differ in the fact that they're quick checks (they are checked BEFORE the one above
|
||||
int GetItemElementalFlag(bool augments = false) const;
|
||||
int GetItemElementalDamage(bool augments = false) const;
|
||||
int GetItemRecommendedLevel(bool augments = false) const;
|
||||
int GetItemRequiredLevel(bool augments = false) const;
|
||||
int GetItemWeaponDamage(bool augments = false) const;
|
||||
int GetItemBackstabDamage(bool augments = false) const;
|
||||
// these two are just quick checks
|
||||
int GetItemBaneDamageBody(bool augments = false) const;
|
||||
int GetItemBaneDamageRace(bool augments = false) const;
|
||||
int GetItemBaneDamageBody(bodyType against, bool augments = false) const;
|
||||
int GetItemBaneDamageRace(uint16 against, bool augments = false) const;
|
||||
int GetItemMagical(bool augments = false) const;
|
||||
int GetItemHP(bool augments = false) const;
|
||||
int GetItemMana(bool augments = false) const;
|
||||
int GetItemEndur(bool augments = false) const;
|
||||
int GetItemAttack(bool augments = false) const;
|
||||
int GetItemStr(bool augments = false) const;
|
||||
int GetItemSta(bool augments = false) const;
|
||||
int GetItemDex(bool augments = false) const;
|
||||
int GetItemAgi(bool augments = false) const;
|
||||
int GetItemInt(bool augments = false) const;
|
||||
int GetItemWis(bool augments = false) const;
|
||||
int GetItemCha(bool augments = false) const;
|
||||
int GetItemMR(bool augments = false) const;
|
||||
int GetItemFR(bool augments = false) const;
|
||||
int GetItemCR(bool augments = false) const;
|
||||
int GetItemPR(bool augments = false) const;
|
||||
int GetItemDR(bool augments = false) const;
|
||||
int GetItemCorrup(bool augments = false) const;
|
||||
int GetItemHeroicStr(bool augments = false) const;
|
||||
int GetItemHeroicSta(bool augments = false) const;
|
||||
int GetItemHeroicDex(bool augments = false) const;
|
||||
int GetItemHeroicAgi(bool augments = false) const;
|
||||
int GetItemHeroicInt(bool augments = false) const;
|
||||
int GetItemHeroicWis(bool augments = false) const;
|
||||
int GetItemHeroicCha(bool augments = false) const;
|
||||
int GetItemHeroicMR(bool augments = false) const;
|
||||
int GetItemHeroicFR(bool augments = false) const;
|
||||
int GetItemHeroicCR(bool augments = false) const;
|
||||
int GetItemHeroicPR(bool augments = false) const;
|
||||
int GetItemHeroicDR(bool augments = false) const;
|
||||
int GetItemHeroicCorrup(bool augments = false) const;
|
||||
int GetItemHaste(bool augments = false) const;
|
||||
|
||||
protected:
|
||||
//////////////////////////
|
||||
// Protected Members
|
||||
//////////////////////////
|
||||
std::map<uint8, ItemInst*>::const_iterator _cbegin() { return m_contents.cbegin(); }
|
||||
std::map<uint8, ItemInst*>::const_iterator _cend() { return m_contents.cend(); }
|
||||
|
||||
friend class Inventory;
|
||||
|
||||
|
||||
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
|
||||
|
||||
ItemInstTypes m_use_type; // Usage type for item
|
||||
const EQEmu::ItemBase* m_item; // Ptr to item data
|
||||
int16 m_charges; // # of charges for chargeable items
|
||||
uint32 m_price; // Bazaar /trader price
|
||||
uint32 m_color;
|
||||
uint32 m_merchantslot;
|
||||
int16 m_currentslot;
|
||||
bool m_attuned;
|
||||
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
|
||||
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
|
||||
uint32 m_exp;
|
||||
int8 m_evolveLvl;
|
||||
bool m_activated;
|
||||
EQEmu::ItemBase* m_scaledItem;
|
||||
EvolveInfo* m_evolveInfo;
|
||||
bool m_scaling;
|
||||
uint32 m_ornamenticon;
|
||||
uint32 m_ornamentidfile;
|
||||
uint32 m_ornament_hero_model;
|
||||
uint32 m_recast_timestamp;
|
||||
|
||||
//
|
||||
// Items inside of this item (augs or contents);
|
||||
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
|
||||
std::map<std::string, std::string> m_custom_data;
|
||||
std::map<std::string, Timer> m_timers;
|
||||
};
|
||||
|
||||
class EvolveInfo {
|
||||
public:
|
||||
friend class ItemInst;
|
||||
//temporary
|
||||
uint16 LvlKills[9];
|
||||
uint32 FirstItem;
|
||||
uint8 MaxLvl;
|
||||
bool AllKills;
|
||||
|
||||
EvolveInfo();
|
||||
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
|
||||
~EvolveInfo();
|
||||
};
|
||||
|
||||
#endif /*COMMON_ITEM_H*/
|
||||
@@ -17,7 +17,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "item_base.h"
|
||||
#include "item_data.h"
|
||||
#include "classes.h"
|
||||
#include "races.h"
|
||||
//#include "deity.h"
|
||||
@@ -167,7 +167,7 @@ uint8 EQEmu::item::ConvertAugTypeBitToAugType(uint32 aug_type_bit)
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsEquipable(uint16 race_id, uint16 class_id)
|
||||
bool EQEmu::ItemData::IsEquipable(uint16 race_id, uint16 class_id) const
|
||||
{
|
||||
if (!(Races & GetPlayerRaceBit(race_id)))
|
||||
return false;
|
||||
@@ -178,32 +178,32 @@ bool EQEmu::ItemBase::IsEquipable(uint16 race_id, uint16 class_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsClassCommon()
|
||||
bool EQEmu::ItemData::IsClassCommon() const
|
||||
{
|
||||
return (ItemClass == item::ItemClassCommon);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsClassBag()
|
||||
bool EQEmu::ItemData::IsClassBag() const
|
||||
{
|
||||
return (ItemClass == item::ItemClassBag);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsClassBook()
|
||||
bool EQEmu::ItemData::IsClassBook() const
|
||||
{
|
||||
return (ItemClass == item::ItemClassBook);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsType1HWeapon()
|
||||
bool EQEmu::ItemData::IsType1HWeapon() const
|
||||
{
|
||||
return ((ItemType == item::ItemType1HBlunt) || (ItemType == item::ItemType1HSlash) || (ItemType == item::ItemType1HPiercing));
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsType2HWeapon()
|
||||
bool EQEmu::ItemData::IsType2HWeapon() const
|
||||
{
|
||||
return ((ItemType == item::ItemType2HBlunt) || (ItemType == item::ItemType2HSlash) || (ItemType == item::ItemType2HPiercing));
|
||||
}
|
||||
|
||||
bool EQEmu::ItemBase::IsTypeShield()
|
||||
bool EQEmu::ItemData::IsTypeShield() const
|
||||
{
|
||||
return (ItemType == item::ItemTypeShield);
|
||||
}
|
||||
@@ -17,8 +17,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMON_ITEM_BASE_H
|
||||
#define COMMON_ITEM_BASE_H
|
||||
#ifndef COMMON_ITEM_DATA_H
|
||||
#define COMMON_ITEM_DATA_H
|
||||
|
||||
|
||||
/*
|
||||
@@ -50,17 +50,6 @@
|
||||
namespace EQEmu
|
||||
{
|
||||
namespace item {
|
||||
enum ItemAttributeBit : uint32 {
|
||||
bit_ItemAttributeNone = 0x00000000,
|
||||
bit_ItemAttributeLore = 0x00000001,
|
||||
bit_ItemAttributeArtifact = 0x00000002,
|
||||
bit_ItemAttributeSummoned = 0x00000004,
|
||||
bit_ItemAttributeMagic = 0x00000008,
|
||||
bit_ItemAttributeAugment = 0x00000010,
|
||||
bit_ItemAttributePendingLore = 0x00000020,
|
||||
bit_ItemAttributeUnknown = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
enum ItemClass {
|
||||
ItemClassCommon = 0,
|
||||
ItemClassBag,
|
||||
@@ -354,8 +343,8 @@ namespace EQEmu
|
||||
//ProcRate
|
||||
};
|
||||
|
||||
extern uint32 ConvertAugTypeToAugTypeBit(uint8 aug_type);
|
||||
extern uint8 ConvertAugTypeBitToAugType(uint32 aug_type_bit);
|
||||
uint32 ConvertAugTypeToAugTypeBit(uint8 aug_type);
|
||||
uint8 ConvertAugTypeBitToAugType(uint32 aug_type_bit);
|
||||
|
||||
} /*item*/
|
||||
|
||||
@@ -364,10 +353,9 @@ namespace EQEmu
|
||||
const void * inst;
|
||||
};
|
||||
|
||||
struct ItemBase {
|
||||
struct ItemData {
|
||||
// Non packet based fields
|
||||
uint8 MinStatus;
|
||||
uint8 ItemDataType; // memset to item::ItemDataBase ('0') during mmf load
|
||||
|
||||
// Packet based fields
|
||||
uint8 ItemClass; // Item Type: 0=common, 1=container, 2=book
|
||||
@@ -476,9 +464,9 @@ namespace EQEmu
|
||||
int32 FactionAmt4; // Faction Amt 4
|
||||
char CharmFile[32]; // ?
|
||||
uint32 AugType;
|
||||
uint8 AugSlotType[EQEmu::legacy::ITEM_COMMON_SIZE]; // RoF: Augment Slot 1-6 Type
|
||||
uint8 AugSlotVisible[EQEmu::legacy::ITEM_COMMON_SIZE]; // RoF: Augment Slot 1-6 Visible
|
||||
uint8 AugSlotUnk2[EQEmu::legacy::ITEM_COMMON_SIZE]; // RoF: Augment Slot 1-6 Unknown Most likely Powersource related
|
||||
uint8 AugSlotType[inventory::SocketCount]; // RoF: Augment Slot 1-6 Type
|
||||
uint8 AugSlotVisible[inventory::SocketCount]; // RoF: Augment Slot 1-6 Visible
|
||||
uint8 AugSlotUnk2[inventory::SocketCount]; // RoF: Augment Slot 1-6 Unknown Most likely Powersource related
|
||||
uint32 LDoNTheme;
|
||||
uint32 LDoNPrice;
|
||||
uint32 LDoNSold;
|
||||
@@ -543,23 +531,15 @@ namespace EQEmu
|
||||
char ScrollName[65];
|
||||
//BardName
|
||||
|
||||
bool IsEquipable(uint16 Race, uint16 Class);
|
||||
bool IsClassCommon();
|
||||
bool IsClassBag();
|
||||
bool IsClassBook();
|
||||
bool IsType1HWeapon();
|
||||
bool IsType2HWeapon();
|
||||
bool IsTypeShield();
|
||||
|
||||
bool IsEquipable(uint16 Race, uint16 Class) const { return const_cast<ItemBase*>(this)->IsEquipable(Race, Class); }
|
||||
bool IsClassCommon() const { return const_cast<ItemBase*>(this)->IsClassCommon(); }
|
||||
bool IsClassBag() const { return const_cast<ItemBase*>(this)->IsClassBag(); }
|
||||
bool IsClassBook() const { return const_cast<ItemBase*>(this)->IsClassBook(); }
|
||||
bool IsType1HWeapon() const { return const_cast<ItemBase*>(this)->IsType1HWeapon(); }
|
||||
bool IsType2HWeapon() const { return const_cast<ItemBase*>(this)->IsType2HWeapon(); }
|
||||
bool IsTypeShield() const { return const_cast<ItemBase*>(this)->IsTypeShield(); }
|
||||
bool IsEquipable(uint16 Race, uint16 Class) const;
|
||||
bool IsClassCommon() const;
|
||||
bool IsClassBag() const;
|
||||
bool IsClassBook() const;
|
||||
bool IsType1HWeapon() const;
|
||||
bool IsType2HWeapon() const;
|
||||
bool IsTypeShield() const;
|
||||
};
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /*COMMON_ITEM_BASE_H*/
|
||||
#endif /*COMMON_ITEM_DATA_H*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,334 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 04111-1307 USA
|
||||
*/
|
||||
|
||||
// @merth notes:
|
||||
// These classes could be optimized with database reads/writes by storing
|
||||
// a status flag indicating how object needs to interact with database
|
||||
|
||||
#ifndef COMMON_ITEM_INSTANCE_H
|
||||
#define COMMON_ITEM_INSTANCE_H
|
||||
|
||||
|
||||
class ItemParse; // Parses item packets
|
||||
class EvolveInfo; // Stores information about an evolving item family
|
||||
|
||||
#include "../common/eq_constants.h"
|
||||
#include "../common/item_data.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/bodytypes.h"
|
||||
#include "../common/deity.h"
|
||||
#include "../common/memory_buffer.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
// Specifies usage type for item inside EQEmu::ItemInstance
|
||||
enum ItemInstTypes
|
||||
{
|
||||
ItemInstNormal = 0,
|
||||
ItemInstWorldContainer
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
byFlagIgnore, //do not consider this flag
|
||||
byFlagSet, //apply action if the flag is set
|
||||
byFlagNotSet //apply action if the flag is NOT set
|
||||
} byFlagSetting;
|
||||
|
||||
class SharedDatabase;
|
||||
|
||||
// ########################################
|
||||
// Class: EQEmu::ItemInstance
|
||||
// Base class for an instance of an item
|
||||
// An item instance encapsulates item data + data specific
|
||||
// to an item instance (includes dye, augments, charges, etc)
|
||||
namespace EQEmu
|
||||
{
|
||||
class InventoryProfile;
|
||||
|
||||
class ItemInstance {
|
||||
public:
|
||||
/////////////////////////
|
||||
// Methods
|
||||
/////////////////////////
|
||||
|
||||
// Constructors/Destructor
|
||||
ItemInstance(const ItemData* item = nullptr, int16 charges = 0);
|
||||
|
||||
ItemInstance(SharedDatabase *db, uint32 item_id, int16 charges = 0);
|
||||
|
||||
ItemInstance(ItemInstTypes use_type);
|
||||
|
||||
ItemInstance(const ItemInstance& copy);
|
||||
|
||||
~ItemInstance();
|
||||
|
||||
// Query item type
|
||||
bool IsType(item::ItemClass item_class) const;
|
||||
|
||||
bool IsClassCommon() const;
|
||||
bool IsClassBag() const;
|
||||
bool IsClassBook() const;
|
||||
|
||||
// Can item be stacked?
|
||||
bool IsStackable() const;
|
||||
bool IsCharged() const;
|
||||
|
||||
// Can item be equipped by/at?
|
||||
bool IsEquipable(uint16 race, uint16 class_) const;
|
||||
bool IsEquipable(int16 slot_id) const;
|
||||
|
||||
//
|
||||
// Augments
|
||||
//
|
||||
bool IsAugmentable() const;
|
||||
bool AvailableWearSlot(uint32 aug_wear_slots) const;
|
||||
int8 AvailableAugmentSlot(int32 augtype) const;
|
||||
bool IsAugmentSlotAvailable(int32 augtype, uint8 slot) const;
|
||||
inline int32 GetAugmentType() const { return ((m_item) ? m_item->AugType : 0); }
|
||||
|
||||
inline bool IsExpendable() const { return ((m_item) ? ((m_item->Click.Type == item::ItemEffectExpendable) || (m_item->ItemType == item::ItemTypePotion)) : false); }
|
||||
|
||||
//
|
||||
// Contents
|
||||
//
|
||||
ItemInstance* GetItem(uint8 slot) const;
|
||||
uint32 GetItemID(uint8 slot) const;
|
||||
inline const ItemInstance* operator[](uint8 slot) const { return GetItem(slot); }
|
||||
void PutItem(uint8 slot, const ItemInstance& inst);
|
||||
void PutItem(SharedDatabase *db, uint8 slot, uint32 item_id) { return; } // not defined anywhere...
|
||||
void DeleteItem(uint8 slot);
|
||||
ItemInstance* PopItem(uint8 index);
|
||||
void Clear();
|
||||
void ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent);
|
||||
uint8 FirstOpenSlot() const;
|
||||
uint8 GetTotalItemCount() const;
|
||||
bool IsNoneEmptyContainer();
|
||||
std::map<uint8, ItemInstance*>* GetContents() { return &m_contents; }
|
||||
|
||||
//
|
||||
// Augments
|
||||
//
|
||||
ItemInstance* GetAugment(uint8 slot) const;
|
||||
uint32 GetAugmentItemID(uint8 slot) const;
|
||||
void PutAugment(uint8 slot, const ItemInstance& inst);
|
||||
void PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id);
|
||||
void DeleteAugment(uint8 slot);
|
||||
ItemInstance* RemoveAugment(uint8 index);
|
||||
bool IsAugmented();
|
||||
ItemInstance* GetOrnamentationAug(int32 ornamentationAugtype) const;
|
||||
bool UpdateOrnamentationInfo();
|
||||
static bool CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll = false);
|
||||
|
||||
// Has attack/delay?
|
||||
bool IsWeapon() const;
|
||||
bool IsAmmo() const;
|
||||
|
||||
// Accessors
|
||||
const uint32 GetID() const { return ((m_item) ? m_item->ID : 0); }
|
||||
const uint32 GetItemScriptID() const { return ((m_item) ? m_item->ScriptFileID : 0); }
|
||||
const ItemData* GetItem() const;
|
||||
const ItemData* GetUnscaledItem() const;
|
||||
|
||||
int16 GetCharges() const { return m_charges; }
|
||||
void SetCharges(int16 charges) { m_charges = charges; }
|
||||
|
||||
uint32 GetPrice() const { return m_price; }
|
||||
void SetPrice(uint32 price) { m_price = price; }
|
||||
|
||||
void SetColor(uint32 color) { m_color = color; }
|
||||
uint32 GetColor() const { return m_color; }
|
||||
|
||||
uint32 GetMerchantSlot() const { return m_merchantslot; }
|
||||
void SetMerchantSlot(uint32 slot) { m_merchantslot = slot; }
|
||||
|
||||
int32 GetMerchantCount() const { return m_merchantcount; }
|
||||
void SetMerchantCount(int32 count) { m_merchantcount = count; }
|
||||
|
||||
int16 GetCurrentSlot() const { return m_currentslot; }
|
||||
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
|
||||
|
||||
// Is this item already attuned?
|
||||
bool IsAttuned() const { return m_attuned; }
|
||||
void SetAttuned(bool flag) { m_attuned = flag; }
|
||||
|
||||
std::string GetCustomDataString() const;
|
||||
std::string GetCustomData(std::string identifier);
|
||||
void SetCustomData(std::string identifier, std::string value);
|
||||
void SetCustomData(std::string identifier, int value);
|
||||
void SetCustomData(std::string identifier, float value);
|
||||
void SetCustomData(std::string identifier, bool value);
|
||||
void DeleteCustomData(std::string identifier);
|
||||
|
||||
// Allows treatment of this object as though it were a pointer to m_item
|
||||
operator bool() const { return (m_item != nullptr); }
|
||||
|
||||
// Compare inner Item_Struct of two ItemInstance objects
|
||||
bool operator==(const ItemInstance& right) const { return (this->m_item == right.m_item); }
|
||||
bool operator!=(const ItemInstance& right) const { return (this->m_item != right.m_item); }
|
||||
|
||||
// Clone current item
|
||||
ItemInstance* Clone() const;
|
||||
|
||||
bool IsSlotAllowed(int16 slot_id) const;
|
||||
|
||||
bool IsDroppable(bool recurse = true) const;
|
||||
|
||||
bool IsScaling() const { return m_scaling; }
|
||||
bool IsEvolving() const { return (m_evolveLvl >= 1); }
|
||||
uint32 GetExp() const { return m_exp; }
|
||||
void SetExp(uint32 exp) { m_exp = exp; }
|
||||
void AddExp(uint32 exp) { m_exp += exp; }
|
||||
bool IsActivated() { return m_activated; }
|
||||
void SetActivated(bool activated) { m_activated = activated; }
|
||||
int8 GetEvolveLvl() const { return m_evolveLvl; }
|
||||
void SetScaling(bool v) { m_scaling = v; }
|
||||
uint32 GetOrnamentationIcon() const { return m_ornamenticon; }
|
||||
void SetOrnamentIcon(uint32 ornament_icon) { m_ornamenticon = ornament_icon; }
|
||||
uint32 GetOrnamentationIDFile() const { return m_ornamentidfile; }
|
||||
void SetOrnamentationIDFile(uint32 ornament_idfile) { m_ornamentidfile = ornament_idfile; }
|
||||
uint32 GetOrnamentHeroModel(int32 material_slot = -1) const;
|
||||
void SetOrnamentHeroModel(uint32 ornament_hero_model) { m_ornament_hero_model = ornament_hero_model; }
|
||||
uint32 GetRecastTimestamp() const { return m_recast_timestamp; }
|
||||
void SetRecastTimestamp(uint32 in) { m_recast_timestamp = in; }
|
||||
|
||||
void Initialize(SharedDatabase *db = nullptr);
|
||||
void ScaleItem();
|
||||
bool EvolveOnAllKills() const;
|
||||
int8 GetMaxEvolveLvl() const;
|
||||
uint32 GetKillsNeeded(uint8 currentlevel);
|
||||
|
||||
std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(InternalSerializedItem_Struct)); return ser; }
|
||||
void Serialize(OutBuffer& ob, int16 slot_id) const { InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); }
|
||||
|
||||
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
||||
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
||||
|
||||
std::map<std::string, Timer>& GetTimers() { return m_timers; }
|
||||
void SetTimer(std::string name, uint32 time);
|
||||
void StopTimer(std::string name);
|
||||
void ClearTimers();
|
||||
|
||||
// Get a total of a stat, including augs
|
||||
// These functions should be used in place of other code manually totaling
|
||||
// to centralize where it is done to make future changes easier (ex. whenever powersources come around)
|
||||
// and to minimize errors. CalcItemBonuses however doesn't use these in interest of performance
|
||||
// by default these do not recurse into augs
|
||||
int GetItemArmorClass(bool augments = false) const;
|
||||
int GetItemElementalDamage(int &magic, int &fire, int &cold, int &poison, int &disease, int &chromatic, int &prismatic, int &physical, int &corruption, bool augments = false) const;
|
||||
// These two differ in the fact that they're quick checks (they are checked BEFORE the one above
|
||||
int GetItemElementalFlag(bool augments = false) const;
|
||||
int GetItemElementalDamage(bool augments = false) const;
|
||||
int GetItemRecommendedLevel(bool augments = false) const;
|
||||
int GetItemRequiredLevel(bool augments = false) const;
|
||||
int GetItemWeaponDamage(bool augments = false) const;
|
||||
int GetItemBackstabDamage(bool augments = false) const;
|
||||
// these two are just quick checks
|
||||
int GetItemBaneDamageBody(bool augments = false) const;
|
||||
int GetItemBaneDamageRace(bool augments = false) const;
|
||||
int GetItemBaneDamageBody(bodyType against, bool augments = false) const;
|
||||
int GetItemBaneDamageRace(uint16 against, bool augments = false) const;
|
||||
int GetItemMagical(bool augments = false) const;
|
||||
int GetItemHP(bool augments = false) const;
|
||||
int GetItemMana(bool augments = false) const;
|
||||
int GetItemEndur(bool augments = false) const;
|
||||
int GetItemAttack(bool augments = false) const;
|
||||
int GetItemStr(bool augments = false) const;
|
||||
int GetItemSta(bool augments = false) const;
|
||||
int GetItemDex(bool augments = false) const;
|
||||
int GetItemAgi(bool augments = false) const;
|
||||
int GetItemInt(bool augments = false) const;
|
||||
int GetItemWis(bool augments = false) const;
|
||||
int GetItemCha(bool augments = false) const;
|
||||
int GetItemMR(bool augments = false) const;
|
||||
int GetItemFR(bool augments = false) const;
|
||||
int GetItemCR(bool augments = false) const;
|
||||
int GetItemPR(bool augments = false) const;
|
||||
int GetItemDR(bool augments = false) const;
|
||||
int GetItemCorrup(bool augments = false) const;
|
||||
int GetItemHeroicStr(bool augments = false) const;
|
||||
int GetItemHeroicSta(bool augments = false) const;
|
||||
int GetItemHeroicDex(bool augments = false) const;
|
||||
int GetItemHeroicAgi(bool augments = false) const;
|
||||
int GetItemHeroicInt(bool augments = false) const;
|
||||
int GetItemHeroicWis(bool augments = false) const;
|
||||
int GetItemHeroicCha(bool augments = false) const;
|
||||
int GetItemHeroicMR(bool augments = false) const;
|
||||
int GetItemHeroicFR(bool augments = false) const;
|
||||
int GetItemHeroicCR(bool augments = false) const;
|
||||
int GetItemHeroicPR(bool augments = false) const;
|
||||
int GetItemHeroicDR(bool augments = false) const;
|
||||
int GetItemHeroicCorrup(bool augments = false) const;
|
||||
int GetItemHaste(bool augments = false) const;
|
||||
|
||||
protected:
|
||||
//////////////////////////
|
||||
// Protected Members
|
||||
//////////////////////////
|
||||
friend class InventoryProfile;
|
||||
|
||||
std::map<uint8, ItemInstance*>::const_iterator _cbegin() { return m_contents.cbegin(); }
|
||||
std::map<uint8, ItemInstance*>::const_iterator _cend() { return m_contents.cend(); }
|
||||
|
||||
void _PutItem(uint8 index, ItemInstance* inst) { m_contents[index] = inst; }
|
||||
|
||||
ItemInstTypes m_use_type; // Usage type for item
|
||||
const ItemData* m_item; // Ptr to item data
|
||||
int16 m_charges; // # of charges for chargeable items
|
||||
uint32 m_price; // Bazaar /trader price
|
||||
uint32 m_color;
|
||||
uint32 m_merchantslot;
|
||||
int16 m_currentslot;
|
||||
bool m_attuned;
|
||||
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
|
||||
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
|
||||
uint32 m_exp;
|
||||
int8 m_evolveLvl;
|
||||
bool m_activated;
|
||||
ItemData* m_scaledItem;
|
||||
::EvolveInfo* m_evolveInfo;
|
||||
bool m_scaling;
|
||||
uint32 m_ornamenticon;
|
||||
uint32 m_ornamentidfile;
|
||||
uint32 m_ornament_hero_model;
|
||||
uint32 m_recast_timestamp;
|
||||
|
||||
//
|
||||
// Items inside of this item (augs or contents);
|
||||
std::map<uint8, ItemInstance*> m_contents; // Zero-based index: min=0, max=9
|
||||
std::map<std::string, std::string> m_custom_data;
|
||||
std::map<std::string, Timer> m_timers;
|
||||
};
|
||||
}
|
||||
|
||||
class EvolveInfo {
|
||||
public:
|
||||
friend class EQEmu::ItemInstance;
|
||||
//temporary
|
||||
uint16 LvlKills[9];
|
||||
uint32 FirstItem;
|
||||
uint8 MaxLvl;
|
||||
bool AllKills;
|
||||
|
||||
EvolveInfo();
|
||||
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
|
||||
~EvolveInfo();
|
||||
};
|
||||
|
||||
#endif /*COMMON_ITEM_INSTANCE_H*/
|
||||
@@ -1,96 +0,0 @@
|
||||
#include "crc32.h"
|
||||
#include <memory.h>
|
||||
|
||||
unsigned int CRC32EncodeTable[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
int EQ::Crc32(const void * data, int size)
|
||||
{
|
||||
int crc = 0xffffffff;
|
||||
auto buffer = (const uint8_t *)data;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
crc = ((crc >> 8) & 0x00FFFFFFL) ^ CRC32EncodeTable[(crc ^ *&buffer[i]) & 0x000000FFL];
|
||||
}
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
int EQ::Crc32(const void * data, int size, int key)
|
||||
{
|
||||
int crc = 0xffffffff;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
crc = ((crc >> 8) & 0x00FFFFFFL) ^ CRC32EncodeTable[(crc ^ ((key >> (i * 8)) & 0xff)) & 0x000000FFL];
|
||||
}
|
||||
|
||||
auto buffer = (const uint8_t *)data;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
crc = ((crc >> 8) & 0x00FFFFFFL) ^ CRC32EncodeTable[(crc ^ *&buffer[i]) & 0x000000FFL];
|
||||
}
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
int Crc32(const void *data, int size);
|
||||
int Crc32(const void *data, int size, int key);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,271 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../random.h"
|
||||
#include "packet.h"
|
||||
#include "daybreak_structs.h"
|
||||
#include <uv.h>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <list>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Net
|
||||
{
|
||||
enum DaybreakProtocolOpcode
|
||||
{
|
||||
OP_Padding = 0x00,
|
||||
OP_SessionRequest = 0x01,
|
||||
OP_SessionResponse = 0x02,
|
||||
OP_Combined = 0x03,
|
||||
OP_SessionDisconnect = 0x05,
|
||||
OP_KeepAlive = 0x06,
|
||||
OP_SessionStatRequest = 0x07,
|
||||
OP_SessionStatResponse = 0x08,
|
||||
OP_Packet = 0x09,
|
||||
OP_Packet2 = 0x0a,
|
||||
OP_Packet3 = 0x0b,
|
||||
OP_Packet4 = 0x0c,
|
||||
OP_Fragment = 0x0d,
|
||||
OP_Fragment2 = 0x0e,
|
||||
OP_Fragment3 = 0x0f,
|
||||
OP_Fragment4 = 0x10,
|
||||
OP_OutOfOrderAck = 0x11,
|
||||
OP_OutOfOrderAck2 = 0x12,
|
||||
OP_OutOfOrderAck3 = 0x13,
|
||||
OP_OutOfOrderAck4 = 0x14,
|
||||
OP_Ack = 0x15,
|
||||
OP_Ack2 = 0x16,
|
||||
OP_Ack3 = 0x17,
|
||||
OP_Ack4 = 0x18,
|
||||
OP_AppCombined = 0x19,
|
||||
OP_OutboundPing = 0x1c,
|
||||
OP_OutOfSession = 0x1d
|
||||
};
|
||||
|
||||
enum DbProtocolStatus
|
||||
{
|
||||
StatusConnecting,
|
||||
StatusConnected,
|
||||
StatusDisconnecting,
|
||||
StatusDisconnected
|
||||
};
|
||||
|
||||
enum DaybreakEncodeType
|
||||
{
|
||||
EncodeNone = 0,
|
||||
EncodeCompression = 1,
|
||||
EncodeXOR = 4,
|
||||
};
|
||||
|
||||
enum SequenceOrder
|
||||
{
|
||||
SequenceCurrent,
|
||||
SequenceFuture,
|
||||
SequencePast
|
||||
};
|
||||
|
||||
typedef std::chrono::system_clock::time_point Timestamp;
|
||||
typedef std::chrono::system_clock Clock;
|
||||
|
||||
struct DaybreakConnectionStats
|
||||
{
|
||||
DaybreakConnectionStats() {
|
||||
recv_bytes = 0;
|
||||
sent_bytes = 0;
|
||||
recv_packets = 0;
|
||||
sent_packets = 0;
|
||||
total_ping = 0;
|
||||
total_acks = 0;
|
||||
min_ping = 0xFFFFFFFFFFFFFFFFUL;
|
||||
max_ping = 0;
|
||||
created = Clock::now();
|
||||
}
|
||||
|
||||
uint64_t recv_bytes;
|
||||
uint64_t sent_bytes;
|
||||
uint64_t recv_packets;
|
||||
uint64_t sent_packets;
|
||||
uint64_t total_ping;
|
||||
uint64_t total_acks;
|
||||
uint64_t min_ping;
|
||||
uint64_t max_ping;
|
||||
Timestamp created;
|
||||
};
|
||||
|
||||
class DaybreakConnectionManager;
|
||||
class DaybreakConnection;
|
||||
class DaybreakConnection
|
||||
{
|
||||
public:
|
||||
DaybreakConnection(DaybreakConnectionManager *owner, const DaybreakConnect &connect, const std::string &endpoint, int port);
|
||||
DaybreakConnection(DaybreakConnectionManager *owner, const std::string &endpoint, int port);
|
||||
~DaybreakConnection();
|
||||
|
||||
const std::string& RemoteEndpoint() const { return m_endpoint; }
|
||||
int RemotePort() const { return m_port; }
|
||||
|
||||
void QueuePacket(Packet &p);
|
||||
void QueuePacket(Packet &p, int stream);
|
||||
void QueuePacket(Packet &p, int stream, bool reliable);
|
||||
const DaybreakConnectionStats& GetStats() const { return m_stats; }
|
||||
void ResetStats();
|
||||
size_t GetRollingPing() const { return m_rolling_ping; }
|
||||
private:
|
||||
DaybreakConnectionManager *m_owner;
|
||||
std::string m_endpoint;
|
||||
int m_port;
|
||||
uint32_t m_connect_code;
|
||||
uint32_t m_encode_key;
|
||||
uint32_t m_max_packet_size;
|
||||
uint32_t m_crc_bytes;
|
||||
DaybreakEncodeType m_encode_passes[2];
|
||||
|
||||
Timestamp m_last_send;
|
||||
Timestamp m_last_recv;
|
||||
DbProtocolStatus m_status;
|
||||
Timestamp m_hold_time;
|
||||
std::list<WritablePacket> m_buffered_packets;
|
||||
size_t m_buffered_packets_length;
|
||||
Timestamp m_last_stats;
|
||||
DaybreakConnectionStats m_stats;
|
||||
Timestamp m_last_session_stats;
|
||||
uint64_t m_last_session_stats_ping;
|
||||
size_t m_resend_delay;
|
||||
size_t m_rolling_ping;
|
||||
|
||||
struct DaybreakSentPacket
|
||||
{
|
||||
WritablePacket packet;
|
||||
Timestamp last_sent;
|
||||
Timestamp first_sent;
|
||||
size_t times_resent;
|
||||
};
|
||||
|
||||
struct DaybreakStream
|
||||
{
|
||||
DaybreakStream() {
|
||||
sequence_in = 0;
|
||||
sequence_out = 0;
|
||||
fragment_current_bytes = 0;
|
||||
fragment_total_bytes = 0;
|
||||
}
|
||||
|
||||
uint16_t sequence_in;
|
||||
uint16_t sequence_out;
|
||||
std::map<uint16_t, Packet*> packet_queue;
|
||||
|
||||
WritablePacket fragment_packet;
|
||||
uint32_t fragment_current_bytes;
|
||||
uint32_t fragment_total_bytes;
|
||||
|
||||
std::map<uint16_t, DaybreakSentPacket> sent_packets;
|
||||
};
|
||||
|
||||
DaybreakStream m_streams[4];
|
||||
std::weak_ptr<DaybreakConnection> m_self;
|
||||
|
||||
void Process();
|
||||
void ProcessPacket(Packet &p);
|
||||
void ProcessQueue();
|
||||
void RemoveFromQueue(int stream, uint16_t seq);
|
||||
void AddToQueue(int stream, uint16_t seq, const Packet &p);
|
||||
void ProcessDecodedPacket(const Packet &p);
|
||||
void ChangeStatus(DbProtocolStatus new_status);
|
||||
bool ValidateCRC(Packet &p);
|
||||
void AppendCRC(Packet &p);
|
||||
bool PacketCanBeEncoded(Packet &p) const;
|
||||
void Decode(Packet &p, size_t offset, size_t length);
|
||||
void Encode(Packet &p, size_t offset, size_t length);
|
||||
void Decompress(Packet &p, size_t offset, size_t length);
|
||||
void Compress(Packet &p, size_t offset, size_t length);
|
||||
void ProcessResend();
|
||||
void ProcessResend(int stream);
|
||||
void Ack(int stream, uint16_t seq);
|
||||
void OutOfOrderAck(int stream, uint16_t seq);
|
||||
|
||||
void SendConnect();
|
||||
void SendKeepAlive();
|
||||
void SendAck(int stream, uint16_t seq);
|
||||
void SendOutOfOrderAck(int stream, uint16_t seq);
|
||||
void SendStatSync();
|
||||
void InternalBufferedSend(Packet &p);
|
||||
void InternalSend(Packet &p);
|
||||
void InternalQueuePacket(Packet &p, int stream_id, bool reliable);
|
||||
void FlushBuffer();
|
||||
SequenceOrder CompareSequence(uint16_t expected, uint16_t actual) const;
|
||||
|
||||
friend class DaybreakConnectionManager;
|
||||
};
|
||||
|
||||
struct DaybreakConnectionManagerOptions
|
||||
{
|
||||
DaybreakConnectionManagerOptions() {
|
||||
max_connection_count = 0;
|
||||
keepalive_delay_ms = 0;
|
||||
resend_delay_ms = 1000;
|
||||
stats_delay_ms = 10000;
|
||||
connect_delay_ms = 1000;
|
||||
stale_connection_ms = 60000;
|
||||
crc_length = 2;
|
||||
max_packet_size = 512;
|
||||
encode_passes[0] = DaybreakEncodeType::EncodeNone;
|
||||
encode_passes[1] = DaybreakEncodeType::EncodeNone;
|
||||
port = 0;
|
||||
hold_size = 384;
|
||||
hold_length_ms = 50;
|
||||
}
|
||||
|
||||
size_t max_packet_size;
|
||||
size_t max_connection_count;
|
||||
size_t keepalive_delay_ms;
|
||||
size_t resend_delay_ms;
|
||||
size_t stats_delay_ms;
|
||||
size_t connect_delay_ms;
|
||||
size_t stale_connection_ms;
|
||||
size_t crc_length;
|
||||
size_t hold_size;
|
||||
size_t hold_length_ms;
|
||||
DaybreakEncodeType encode_passes[2];
|
||||
int port;
|
||||
};
|
||||
|
||||
class DaybreakConnectionManager
|
||||
{
|
||||
public:
|
||||
DaybreakConnectionManager();
|
||||
DaybreakConnectionManager(const DaybreakConnectionManagerOptions &opts);
|
||||
~DaybreakConnectionManager();
|
||||
|
||||
void Connect(const std::string &addr, int port);
|
||||
void Process();
|
||||
void ProcessResend();
|
||||
void OnNewConnection(std::function<void(std::shared_ptr<DaybreakConnection>)> func) { m_on_new_connection = func; }
|
||||
void OnConnectionStateChange(std::function<void(std::shared_ptr<DaybreakConnection>, DbProtocolStatus, DbProtocolStatus)> func) { m_on_connection_state_change = func; }
|
||||
void OnPacketRecv(std::function<void(std::shared_ptr<DaybreakConnection>, const Packet &)> func) { m_on_packet_recv = func; }
|
||||
private:
|
||||
void Attach(uv_loop_t *loop);
|
||||
void Detach();
|
||||
|
||||
EQEmu::Random m_rand;
|
||||
uv_timer_t m_timer;
|
||||
uv_timer_t m_resend_timer;
|
||||
uv_udp_t m_socket;
|
||||
uv_loop_t *m_attached;
|
||||
DaybreakConnectionManagerOptions m_options;
|
||||
std::function<void(std::shared_ptr<DaybreakConnection>)> m_on_new_connection;
|
||||
std::function<void(std::shared_ptr<DaybreakConnection>, DbProtocolStatus, DbProtocolStatus)> m_on_connection_state_change;
|
||||
std::function<void(std::shared_ptr<DaybreakConnection>, const Packet&)> m_on_packet_recv;
|
||||
std::map<std::pair<std::string, int>, std::shared_ptr<DaybreakConnection>> m_connections;
|
||||
|
||||
void ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size);
|
||||
std::shared_ptr<DaybreakConnection> FindConnectionByEndpoint(std::string addr, int port);
|
||||
void SendSessionLost(const std::string &addr, int port);
|
||||
|
||||
friend class DaybreakConnection;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cstdint>
|
||||
#include "endian.h"
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Net
|
||||
{
|
||||
struct DaybreakHeader
|
||||
{
|
||||
static size_t size() { return 2; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakConnect
|
||||
{
|
||||
static size_t size() { return 14; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint32_t protocol_version;
|
||||
uint32_t connect_code;
|
||||
uint32_t max_packet_size;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(protocol_version),
|
||||
CEREAL_NVP(connect_code),
|
||||
CEREAL_NVP(max_packet_size));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakConnectReply
|
||||
{
|
||||
static size_t size() { return 17; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint32_t connect_code;
|
||||
uint32_t encode_key;
|
||||
uint8_t crc_bytes;
|
||||
uint8_t encode_pass1;
|
||||
uint8_t encode_pass2;
|
||||
uint32_t max_packet_size;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(connect_code),
|
||||
CEREAL_NVP(encode_key),
|
||||
CEREAL_NVP(crc_bytes),
|
||||
CEREAL_NVP(encode_pass1),
|
||||
CEREAL_NVP(encode_pass2),
|
||||
CEREAL_NVP(max_packet_size));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakDisconnect
|
||||
{
|
||||
static size_t size() { return 8; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint32_t connect_code;
|
||||
uint16_t disconnect_code;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(connect_code),
|
||||
CEREAL_NVP(disconnect_code));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakReliableHeader
|
||||
{
|
||||
static size_t size() { return 4; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint16_t sequence;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(sequence));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakReliableFragmentHeader
|
||||
{
|
||||
static size_t size() { return 4 + DaybreakReliableHeader::size(); }
|
||||
DaybreakReliableHeader reliable;
|
||||
uint32_t total_size;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(reliable),
|
||||
CEREAL_NVP(total_size));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakSessionStatRequestHeader
|
||||
{
|
||||
static size_t size() { return 40; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint16_t timestamp;
|
||||
uint32_t stat_ping;
|
||||
uint32_t avg_ping;
|
||||
uint32_t min_ping;
|
||||
uint32_t max_ping;
|
||||
uint32_t last_ping;
|
||||
uint64_t packets_sent;
|
||||
uint64_t packets_recv;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(timestamp),
|
||||
CEREAL_NVP(stat_ping),
|
||||
CEREAL_NVP(avg_ping),
|
||||
CEREAL_NVP(min_ping),
|
||||
CEREAL_NVP(max_ping),
|
||||
CEREAL_NVP(last_ping),
|
||||
CEREAL_NVP(packets_sent),
|
||||
CEREAL_NVP(packets_recv));
|
||||
}
|
||||
};
|
||||
|
||||
struct DaybreakSessionStatResponseHeader
|
||||
{
|
||||
static size_t size() { return 40; }
|
||||
uint8_t zero;
|
||||
uint8_t opcode;
|
||||
uint16_t timestamp;
|
||||
uint32_t our_timestamp;
|
||||
uint64_t client_sent;
|
||||
uint64_t client_recv;
|
||||
uint64_t server_sent;
|
||||
uint64_t server_recv;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(timestamp),
|
||||
CEREAL_NVP(our_timestamp),
|
||||
CEREAL_NVP(client_sent),
|
||||
CEREAL_NVP(client_recv),
|
||||
CEREAL_NVP(server_sent),
|
||||
CEREAL_NVP(server_recv));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Net
|
||||
{
|
||||
inline bool IsLittleEndian() {
|
||||
static int32_t v = 1;
|
||||
return 1 == *(int8_t*)&v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T ByteSwap(T in) {
|
||||
static_assert(std::is_integral<T>::value, "Byte swap only works on integer types.");
|
||||
T ret;
|
||||
|
||||
char *first = (char*)∈
|
||||
char *last = (char*)&in + sizeof(in);
|
||||
char *d_first = (char*)&ret;
|
||||
while (first != last) {
|
||||
*(d_first++) = *(--last);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T HostToNetwork(T in) {
|
||||
if (IsLittleEndian()) {
|
||||
return ByteSwap(in);
|
||||
}
|
||||
else {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NetworkToHost(T in) {
|
||||
if (IsLittleEndian()) {
|
||||
return ByteSwap(in);
|
||||
}
|
||||
else {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
#include "eqstream.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
|
||||
EQ::Net::EQStreamManager::EQStreamManager(EQStreamManagerOptions &options) : m_daybreak(options.daybreak_options)
|
||||
{
|
||||
m_options = options;
|
||||
|
||||
m_daybreak.OnNewConnection(std::bind(&EQStreamManager::DaybreakNewConnection, this, std::placeholders::_1));
|
||||
m_daybreak.OnConnectionStateChange(std::bind(&EQStreamManager::DaybreakConnectionStateChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_daybreak.OnPacketRecv(std::bind(&EQStreamManager::DaybreakPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
EQ::Net::EQStreamManager::~EQStreamManager()
|
||||
{
|
||||
}
|
||||
|
||||
void EQ::Net::EQStreamManager::DaybreakNewConnection(std::shared_ptr<DaybreakConnection> connection)
|
||||
{
|
||||
std::shared_ptr<EQStream> stream(new EQStream(this, connection));
|
||||
m_streams.insert(std::make_pair(connection, stream));
|
||||
if (m_on_new_connection) {
|
||||
m_on_new_connection(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::Net::EQStreamManager::DaybreakConnectionStateChange(std::shared_ptr<DaybreakConnection> connection, DbProtocolStatus from, DbProtocolStatus to)
|
||||
{
|
||||
auto iter = m_streams.find(connection);
|
||||
if (iter != m_streams.end()) {
|
||||
if (m_on_connection_state_change) {
|
||||
m_on_connection_state_change(iter->second, from, to);
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
m_streams.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnection> connection, const Packet &p)
|
||||
{
|
||||
auto iter = m_streams.find(connection);
|
||||
if (iter != m_streams.end()) {
|
||||
auto patch = iter->second->GetRegisteredPatch();
|
||||
if (patch == nullptr && m_possible_patches.size() > 0) {
|
||||
for (auto &pt : m_possible_patches) {
|
||||
auto match = pt->TryIdentityMatch(p);
|
||||
if (match == EQ::Patches::IdentityMatchSuccess) {
|
||||
iter->second->RegisterPatch(pt.get());
|
||||
patch = pt.get();
|
||||
Log.OutF(Logs::General, Logs::Debug, "Identified patch with name {0}", pt->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (patch) {
|
||||
EmuOpcode opcode;
|
||||
EQ::Net::WritablePacket out;
|
||||
patch->Decode(&p, opcode, out);
|
||||
|
||||
if (opcode == OP_Unknown) {
|
||||
Log.OutF(Logs::General, Logs::Netcode, "Incoming packet was not handled because the opcode was not found.\n{0}", p.ToString());
|
||||
}
|
||||
else {
|
||||
if (m_on_packet_recv) {
|
||||
m_on_packet_recv(iter->second, opcode, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.OutF(Logs::General, Logs::Netcode, "Incoming packet was not handled because we don't have a patch set.\n{0}", p.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EQ::Net::EQStream::EQStream(EQStreamManager *owner, std::shared_ptr<DaybreakConnection> connection)
|
||||
{
|
||||
m_owner = owner;
|
||||
m_connection = connection;
|
||||
m_patch = nullptr;
|
||||
}
|
||||
|
||||
EQ::Net::EQStream::~EQStream()
|
||||
{
|
||||
}
|
||||
|
||||
void EQ::Net::EQStream::QueuePacket(EmuOpcode type, const Packet &p)
|
||||
{
|
||||
if (m_patch) {
|
||||
EQ::Net::WritablePacket trans;
|
||||
m_patch->Encode(m_connection, type, &p);
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::Net::EQStream::ResetStats()
|
||||
{
|
||||
m_connection->ResetStats();
|
||||
}
|
||||
|
||||
void EQ::Net::EQStream::Close()
|
||||
{
|
||||
}
|
||||
|
||||
void EQ::Net::EQStream::QueuePacket(const EQApplicationPacket *p)
|
||||
{
|
||||
EQ::Net::ReadOnlyPacket out(p->pBuffer, p->size);
|
||||
QueuePacket(p->GetOpcode(), out);
|
||||
|
||||
}
|
||||
|
||||
void EQ::Net::EQStream::FastQueuePacket(const EQApplicationPacket **p)
|
||||
{
|
||||
QueuePacket(*p);
|
||||
delete *p;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../patch/patch.h"
|
||||
#include "../eq_packet.h"
|
||||
#include "daybreak_connection.h"
|
||||
#include <vector>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Net
|
||||
{
|
||||
struct EQStreamManagerOptions
|
||||
{
|
||||
EQStreamManagerOptions() {
|
||||
|
||||
}
|
||||
|
||||
EQStreamManagerOptions(bool encoded, bool compressed) {
|
||||
if (encoded) {
|
||||
daybreak_options.encode_passes[0] = EncodeXOR;
|
||||
|
||||
if (compressed) {
|
||||
daybreak_options.encode_passes[1] = EncodeCompression;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (compressed) {
|
||||
daybreak_options.encode_passes[0] = EncodeCompression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DaybreakConnectionManagerOptions daybreak_options;
|
||||
};
|
||||
|
||||
class EQStream;
|
||||
class EQStreamManager
|
||||
{
|
||||
public:
|
||||
EQStreamManager(EQStreamManagerOptions &options);
|
||||
~EQStreamManager();
|
||||
|
||||
void OnNewConnection(std::function<void(std::shared_ptr<EQStream>)> func) { m_on_new_connection = func; }
|
||||
void OnConnectionStateChange(std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> func) { m_on_connection_state_change = func; }
|
||||
void OnPacketRecv(std::function<void(std::shared_ptr<EQStream>, EmuOpcode, const Packet &)> func) { m_on_packet_recv = func; }
|
||||
|
||||
void RegisterPotentialPatch(EQ::Patches::BasePatch *patch) { m_possible_patches.push_back(std::unique_ptr<EQ::Patches::BasePatch>(patch)); }
|
||||
private:
|
||||
EQStreamManagerOptions m_options;
|
||||
DaybreakConnectionManager m_daybreak;
|
||||
std::function<void(std::shared_ptr<EQStream>)> m_on_new_connection;
|
||||
std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> m_on_connection_state_change;
|
||||
std::function<void(std::shared_ptr<EQStream>, EmuOpcode, const Packet &)> m_on_packet_recv;
|
||||
std::map<std::shared_ptr<DaybreakConnection>, std::shared_ptr<EQStream>> m_streams;
|
||||
std::vector<std::unique_ptr<EQ::Patches::BasePatch>> m_possible_patches;
|
||||
|
||||
void DaybreakNewConnection(std::shared_ptr<DaybreakConnection> connection);
|
||||
void DaybreakConnectionStateChange(std::shared_ptr<DaybreakConnection> connection, DbProtocolStatus from, DbProtocolStatus to);
|
||||
void DaybreakPacketRecv(std::shared_ptr<DaybreakConnection> connection, const Packet &p);
|
||||
friend class EQStream;
|
||||
};
|
||||
|
||||
class EQStream
|
||||
{
|
||||
public:
|
||||
EQStream(EQStreamManager *parent, std::shared_ptr<DaybreakConnection> connection);
|
||||
~EQStream();
|
||||
|
||||
const std::string& RemoteEndpoint() const { return m_connection->RemoteEndpoint(); }
|
||||
int RemotePort() const { return m_connection->RemotePort(); }
|
||||
|
||||
void QueuePacket(EmuOpcode type, const Packet &p);
|
||||
const DaybreakConnectionStats& GetStats() const { return m_connection->GetStats(); }
|
||||
void ResetStats();
|
||||
size_t GetRollingPing() const { return m_connection->GetRollingPing(); }
|
||||
void Close();
|
||||
void QueuePacket(const EQApplicationPacket *p);
|
||||
void FastQueuePacket(const EQApplicationPacket **p);
|
||||
|
||||
void RegisterPatch(EQ::Patches::BasePatch *p) { m_patch = p; }
|
||||
EQ::Patches::BasePatch *GetRegisteredPatch() { return m_patch; }
|
||||
private:
|
||||
EQStreamManager *m_owner;
|
||||
std::shared_ptr<DaybreakConnection> m_connection;
|
||||
EQ::Patches::BasePatch *m_patch;
|
||||
friend class EQStreamManager;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
#include "packet.h"
|
||||
#include "endian.h"
|
||||
#include <fmt/format.h>
|
||||
#include <cctype>
|
||||
|
||||
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
||||
{
|
||||
if (Length() < offset + 1) {
|
||||
if (!Resize(offset + 1)) {
|
||||
throw std::out_of_range("Packet::PutInt8(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(int8_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutInt16(size_t offset, int16_t value)
|
||||
{
|
||||
if (Length() < offset + 2) {
|
||||
if (!Resize(offset + 2)) {
|
||||
throw std::out_of_range("Packet::PutInt16(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(int16_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutInt32(size_t offset, int32_t value)
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
if (!Resize(offset + 4)) {
|
||||
throw std::out_of_range("Packet::PutInt32(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(int32_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutInt64(size_t offset, int64_t value)
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
if (!Resize(offset + 8)) {
|
||||
throw std::out_of_range("Packet::PutInt64(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(int64_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutUInt8(size_t offset, uint8_t value)
|
||||
{
|
||||
if (Length() < offset + 1) {
|
||||
if (!Resize(offset + 1)) {
|
||||
throw std::out_of_range("Packet::PutUInt8(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(uint8_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutUInt16(size_t offset, uint16_t value)
|
||||
{
|
||||
if (Length() < offset + 2) {
|
||||
if (!Resize(offset + 2)) {
|
||||
throw std::out_of_range("Packet::PutUInt16(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(uint16_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutUInt32(size_t offset, uint32_t value)
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
if (!Resize(offset + 4)) {
|
||||
throw std::out_of_range("Packet::PutUInt32(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(uint32_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutUInt64(size_t offset, uint64_t value)
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
if (!Resize(offset + 8)) {
|
||||
throw std::out_of_range("Packet::PutUInt64(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(uint64_t*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutFloat(size_t offset, float value)
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
if (!Resize(offset + 4)) {
|
||||
throw std::out_of_range("Packet::PutFloat(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(float*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutDouble(size_t offset, double value)
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
if (!Resize(offset + 8)) {
|
||||
throw std::out_of_range("Packet::PutDouble(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
*(double*)((char*)Data() + offset) = value;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutString(size_t offset, const std::string &str)
|
||||
{
|
||||
if (Length() < offset + str.length()) {
|
||||
if (!Resize(offset + str.length())) {
|
||||
throw std::out_of_range("Packet::PutString(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(((char*)Data() + offset), str.c_str(), str.length());
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutCString(size_t offset, const char *str)
|
||||
{
|
||||
size_t sz = strlen(str);
|
||||
if (Length() < offset + sz + 1) {
|
||||
if (!Resize(offset + sz + 1)) {
|
||||
throw std::out_of_range("Packet::PutCString(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(((char*)Data() + offset), str, sz);
|
||||
*((char*)Data() + offset + sz) = 0;
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutPacket(size_t offset, const Packet &p)
|
||||
{
|
||||
if (Length() < offset + p.Length()) {
|
||||
if (!Resize(offset + p.Length())) {
|
||||
throw std::out_of_range("Packet::PutPacket(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(((char*)Data() + offset), p.Data(), p.Length());
|
||||
}
|
||||
|
||||
void EQ::Net::Packet::PutData(size_t offset, void *data, size_t length)
|
||||
{
|
||||
if (Length() < offset + length) {
|
||||
if (!Resize(offset + length)) {
|
||||
throw std::out_of_range("Packet::PutData(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(((char*)Data() + offset), data, length);
|
||||
}
|
||||
|
||||
int8_t EQ::Net::Packet::GetInt8(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 1) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(int8_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
int16_t EQ::Net::Packet::GetInt16(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 2) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(int16_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
int32_t EQ::Net::Packet::GetInt32(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(int32_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
int64_t EQ::Net::Packet::GetInt64(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(int64_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
uint8_t EQ::Net::Packet::GetUInt8(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 1) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(uint8_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
uint16_t EQ::Net::Packet::GetUInt16(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 2) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(uint16_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
uint32_t EQ::Net::Packet::GetUInt32(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(uint32_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
uint64_t EQ::Net::Packet::GetUInt64(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(uint64_t*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
float EQ::Net::Packet::GetFloat(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 4) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(float*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
double EQ::Net::Packet::GetDouble(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 8) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return *(double*)((char*)Data() + offset);
|
||||
}
|
||||
|
||||
std::string EQ::Net::Packet::GetString(size_t offset, size_t length) const
|
||||
{
|
||||
if (Length() < offset + length) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
return std::string((char*)Data(), (char*)Data() + length);
|
||||
}
|
||||
|
||||
std::string EQ::Net::Packet::GetCString(size_t offset) const
|
||||
{
|
||||
if (Length() < offset + 1) {
|
||||
throw std::out_of_range("Packet read out of range.");
|
||||
}
|
||||
|
||||
char *str = ((char*)Data() + offset);
|
||||
return std::string(str);
|
||||
}
|
||||
|
||||
char ToSafePrint(unsigned char in) {
|
||||
if (std::isprint(in)) {
|
||||
return in;
|
||||
}
|
||||
|
||||
return '.';
|
||||
}
|
||||
|
||||
std::string EQ::Net::Packet::ToString() const
|
||||
{
|
||||
return ToString(16);
|
||||
}
|
||||
|
||||
std::string EQ::Net::Packet::ToString(size_t line_length) const
|
||||
{
|
||||
std::string ret;
|
||||
size_t lines = Length() / line_length;
|
||||
size_t i;
|
||||
|
||||
char *data = (char*)Data();
|
||||
|
||||
for (i = 0; i < lines; ++i) {
|
||||
ret += fmt::format("{:0>5x} |", i * line_length);
|
||||
std::string hex;
|
||||
std::string ascii;
|
||||
for (size_t j = 0; j < line_length; ++j) {
|
||||
hex += fmt::format(" {:0>2x}", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += fmt::format("{}", ToSafePrint(data[(i * line_length) + j]));
|
||||
}
|
||||
|
||||
ret += hex;
|
||||
ret += " | ";
|
||||
ret += ascii;
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
if (Length() % line_length > 0) {
|
||||
ret += fmt::format("{:0>5x} |", i * line_length);
|
||||
|
||||
size_t non_blank_count = Length() % line_length;
|
||||
size_t blank_count = line_length - non_blank_count;
|
||||
std::string hex;
|
||||
std::string ascii;
|
||||
|
||||
for (size_t j = 0; j < non_blank_count; ++j) {
|
||||
hex += fmt::format(" {:0>2x}", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += fmt::format("{}", ToSafePrint(data[(i * line_length) + j]));
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < blank_count; ++j) {
|
||||
hex += " ";
|
||||
ascii += " ";
|
||||
}
|
||||
|
||||
ret += hex;
|
||||
ret += " | ";
|
||||
ret += ascii;
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include "../util/memory_stream.h"
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/archives/binary.hpp>
|
||||
|
||||
namespace EQ {
|
||||
namespace Net {
|
||||
class Packet
|
||||
{
|
||||
public:
|
||||
Packet() { }
|
||||
virtual ~Packet() { }
|
||||
|
||||
virtual const void *Data() const = 0;
|
||||
virtual void *Data() = 0;
|
||||
virtual size_t Length() const = 0;
|
||||
virtual size_t Length() = 0;
|
||||
virtual bool Clear() = 0;
|
||||
virtual bool Resize(size_t new_size) = 0;
|
||||
virtual void Reserve(size_t new_size) = 0;
|
||||
|
||||
template<typename T>
|
||||
T GetSerialize(size_t offset) const
|
||||
{
|
||||
if (T::size() > (Length() - offset)) {
|
||||
throw std::out_of_range("Packet::GetSerialize(), packet not large enough to cast to type.");
|
||||
}
|
||||
|
||||
T ret;
|
||||
Util::MemoryStreamReader reader(((char*)Data() + offset), Length());
|
||||
cereal::BinaryInputArchive input(reader);
|
||||
input(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void PutSerialize(size_t offset, const T &value) {
|
||||
std::stringstream buffer(std::ios::in | std::ios::out | std::ios::binary);
|
||||
cereal::BinaryOutputArchive output(buffer);
|
||||
output(value);
|
||||
|
||||
auto str = buffer.str();
|
||||
if (Length() < offset + str.length()) {
|
||||
if (!Resize(offset + str.length())) {
|
||||
throw std::out_of_range("Packet::PutSerialize(), could not resize packet and would of written past the end.");
|
||||
}
|
||||
}
|
||||
|
||||
memcpy((char*)Data() + offset, &str[0], str.length());
|
||||
}
|
||||
|
||||
void PutInt8(size_t offset, int8_t value);
|
||||
void PutInt16(size_t offset, int16_t value);
|
||||
void PutInt32(size_t offset, int32_t value);
|
||||
void PutInt64(size_t offset, int64_t value);
|
||||
void PutUInt8(size_t offset, uint8_t value);
|
||||
void PutUInt16(size_t offset, uint16_t value);
|
||||
void PutUInt32(size_t offset, uint32_t value);
|
||||
void PutUInt64(size_t offset, uint64_t value);
|
||||
void PutFloat(size_t offset, float value);
|
||||
void PutDouble(size_t offset, double value);
|
||||
void PutString(size_t offset, const std::string &str);
|
||||
void PutCString(size_t offset, const char *str);
|
||||
void PutPacket(size_t offset, const Packet &p);
|
||||
void PutData(size_t offset, void *data, size_t length);
|
||||
|
||||
int8_t GetInt8(size_t offset) const;
|
||||
int16_t GetInt16(size_t offset) const;
|
||||
int32_t GetInt32(size_t offset) const;
|
||||
int64_t GetInt64(size_t offset) const;
|
||||
uint8_t GetUInt8(size_t offset) const;
|
||||
uint16_t GetUInt16(size_t offset) const;
|
||||
uint32_t GetUInt32(size_t offset) const;
|
||||
uint64_t GetUInt64(size_t offset) const;
|
||||
float GetFloat(size_t offset) const;
|
||||
double GetDouble(size_t offset) const;
|
||||
std::string GetString(size_t offset, size_t length) const;
|
||||
std::string GetCString(size_t offset) const;
|
||||
|
||||
std::string ToString() const;
|
||||
std::string ToString(size_t line_length) const;
|
||||
};
|
||||
|
||||
class ReadOnlyPacket : public Packet
|
||||
{
|
||||
public:
|
||||
ReadOnlyPacket(void *data, size_t size) { m_data = data; m_data_length = size; }
|
||||
virtual ~ReadOnlyPacket() { }
|
||||
ReadOnlyPacket(const ReadOnlyPacket &o) { m_data = o.m_data; m_data_length = o.m_data_length; }
|
||||
ReadOnlyPacket& operator=(const ReadOnlyPacket &o) { m_data = o.m_data; m_data_length = o.m_data_length; return *this; }
|
||||
ReadOnlyPacket(ReadOnlyPacket &&o) { m_data = o.m_data; m_data_length = o.m_data_length; }
|
||||
|
||||
virtual const void *Data() const { return m_data; }
|
||||
virtual void *Data() { return m_data; }
|
||||
virtual size_t Length() const { return m_data_length; }
|
||||
virtual size_t Length() { return m_data_length; }
|
||||
virtual bool Clear() { return false; }
|
||||
virtual bool Resize(size_t new_size) { return false; }
|
||||
virtual void Reserve(size_t new_size) { }
|
||||
|
||||
protected:
|
||||
void *m_data;
|
||||
size_t m_data_length;
|
||||
};
|
||||
|
||||
class WritablePacket : public Packet
|
||||
{
|
||||
public:
|
||||
WritablePacket() { }
|
||||
virtual ~WritablePacket() { }
|
||||
WritablePacket(WritablePacket &&o) { m_data = std::move(o.m_data); }
|
||||
WritablePacket(const WritablePacket &o) { m_data = o.m_data; }
|
||||
WritablePacket& operator=(const WritablePacket &o) { m_data = o.m_data; return *this; }
|
||||
|
||||
virtual const void *Data() const { return &m_data[0]; }
|
||||
virtual void *Data() { return &m_data[0]; }
|
||||
virtual size_t Length() const { return m_data.size(); }
|
||||
virtual size_t Length() { return m_data.size(); }
|
||||
virtual bool Clear() { m_data.clear(); return true; }
|
||||
virtual bool Resize(size_t new_size) { m_data.resize(new_size); return true; }
|
||||
virtual void Reserve(size_t new_size) { m_data.reserve(new_size); }
|
||||
protected:
|
||||
std::vector<char> m_data;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "chat.h"
|
||||
|
||||
EQ::Patches::ChatPatch::ChatPatch()
|
||||
{
|
||||
m_opcode_manager.reset(new RegularOpcodeManager());
|
||||
if (!m_opcode_manager->LoadOpcodes("mail_opcodes.conf")) {
|
||||
m_opcode_manager.release();
|
||||
}
|
||||
|
||||
m_signature.match_message_opcode = 0x0;
|
||||
m_signature.match_message_size = 0;
|
||||
m_message_size = 1;
|
||||
}
|
||||
|
||||
EQ::Patches::ChatPatch::~ChatPatch()
|
||||
{
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "../patch/patch.h"
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Patches
|
||||
{
|
||||
class ChatPatch : public BasePatch
|
||||
{
|
||||
public:
|
||||
ChatPatch();
|
||||
virtual ~ChatPatch();
|
||||
virtual std::string GetName() const { return "Chat"; }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "login_sod.h"
|
||||
|
||||
EQ::Patches::LoginSoDPatch::LoginSoDPatch()
|
||||
{
|
||||
m_opcode_manager.reset(new RegularOpcodeManager());
|
||||
if (!m_opcode_manager->LoadOpcodes("login_opcodes_sod.conf")) {
|
||||
m_opcode_manager.release();
|
||||
}
|
||||
|
||||
m_signature.match_message_opcode = 0x01;
|
||||
m_signature.match_message_size = 0;
|
||||
m_message_size = 2;
|
||||
}
|
||||
|
||||
EQ::Patches::LoginSoDPatch::~LoginSoDPatch()
|
||||
{
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "../patch/patch.h"
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Patches
|
||||
{
|
||||
class LoginSoDPatch : public BasePatch
|
||||
{
|
||||
public:
|
||||
LoginSoDPatch();
|
||||
virtual ~LoginSoDPatch();
|
||||
virtual std::string GetName() const { return "Login SoD+"; }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "login_titanium.h"
|
||||
|
||||
EQ::Patches::LoginTitaniumPatch::LoginTitaniumPatch()
|
||||
{
|
||||
m_opcode_manager.reset(new RegularOpcodeManager());
|
||||
if (!m_opcode_manager->LoadOpcodes("login_opcodes.conf")) {
|
||||
m_opcode_manager.release();
|
||||
}
|
||||
|
||||
m_signature.match_message_opcode = 0x01;
|
||||
m_signature.match_message_size = 0;
|
||||
m_message_size = 2;
|
||||
}
|
||||
|
||||
EQ::Patches::LoginTitaniumPatch::~LoginTitaniumPatch()
|
||||
{
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "../patch/patch.h"
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Patches
|
||||
{
|
||||
class LoginTitaniumPatch : public BasePatch
|
||||
{
|
||||
public:
|
||||
LoginTitaniumPatch();
|
||||
virtual ~LoginTitaniumPatch();
|
||||
virtual std::string GetName() const { return "Login Titanium"; }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
#include "patch.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
|
||||
EQ::Patches::IdentityMatchStatus EQ::Patches::BasePatch::TryIdentityMatch(const EQ::Net::Packet &p) const
|
||||
{
|
||||
if (p.Length() < m_message_size) {
|
||||
return IdentityMatchFailure;
|
||||
}
|
||||
|
||||
int raw_opcode = 0;
|
||||
switch (m_message_size) {
|
||||
case 1:
|
||||
raw_opcode = *(uint8_t*)p.Data();
|
||||
break;
|
||||
case 2:
|
||||
raw_opcode = *(uint16_t*)p.Data();
|
||||
break;
|
||||
default:
|
||||
return IdentityMatchFailure;
|
||||
}
|
||||
|
||||
if (m_signature.match_message_opcode != 0 && m_signature.match_message_opcode != raw_opcode) {
|
||||
return IdentityMatchFailure;
|
||||
}
|
||||
|
||||
if (m_signature.match_message_size > 0 && m_signature.match_message_size != p.Length() - m_message_size) {
|
||||
return IdentityMatchFailure;
|
||||
}
|
||||
|
||||
return IdentityMatchSuccess;
|
||||
}
|
||||
|
||||
void EQ::Patches::BasePatch::Decode(const EQ::Net::Packet *in, EmuOpcode &opcode, EQ::Net::WritablePacket &out)
|
||||
{
|
||||
int raw_opcode = 0;
|
||||
switch (m_message_size) {
|
||||
case 1:
|
||||
raw_opcode = *(uint8_t*)in->Data();
|
||||
break;
|
||||
case 2:
|
||||
raw_opcode = *(uint16_t*)in->Data();
|
||||
break;
|
||||
default:
|
||||
opcode = OP_Unknown;
|
||||
return;
|
||||
}
|
||||
|
||||
opcode = m_opcode_manager->EQToEmu(raw_opcode);
|
||||
if (opcode == OP_Unknown) {
|
||||
out.PutData(0, (uint8_t*)in->Data() + m_message_size, in->Length() - m_message_size);
|
||||
return;
|
||||
}
|
||||
|
||||
auto decode_iter = m_decode.find(opcode);
|
||||
if (decode_iter != m_decode.end()) {
|
||||
EQ::Net::ReadOnlyPacket p((uint8_t*)in->Data() + m_message_size, in->Length() - m_message_size);
|
||||
decode_iter->second(&p, opcode, out);
|
||||
}
|
||||
else {
|
||||
out.PutData(0, (uint8_t*)in->Data() + m_message_size, in->Length() - m_message_size);
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::Patches::BasePatch::Encode(std::shared_ptr<EQ::Net::DaybreakConnection> connection, EmuOpcode opcode, const EQ::Net::Packet *in)
|
||||
{
|
||||
auto encode_iter = m_encode.find(opcode);
|
||||
if (encode_iter != m_encode.end()) {
|
||||
encode_iter->second(connection, opcode, in);
|
||||
}
|
||||
else {
|
||||
SendPacket(connection, opcode, in);
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::Patches::BasePatch::RegisterDecode(int protocol_number, DecodeStructFunction f)
|
||||
{
|
||||
m_decode.insert(std::make_pair(protocol_number, f));
|
||||
}
|
||||
|
||||
void EQ::Patches::BasePatch::RegisterEncode(EmuOpcode opcode, EncodeStructFunction f)
|
||||
{
|
||||
m_encode.insert(std::make_pair(opcode, f));
|
||||
}
|
||||
|
||||
void EQ::Patches::BasePatch::SendPacket(std::shared_ptr<EQ::Net::DaybreakConnection> connection, EmuOpcode opcode, const EQ::Net::Packet *p)
|
||||
{
|
||||
if (!m_opcode_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto raw_opcode = m_opcode_manager->EmuToEQ(opcode);
|
||||
EQ::Net::WritablePacket out;
|
||||
switch (m_message_size) {
|
||||
case 1:
|
||||
out.PutUInt8(0, (uint8_t)raw_opcode);
|
||||
out.PutPacket(1, *p);
|
||||
break;
|
||||
case 2:
|
||||
out.PutUInt16(0, raw_opcode);
|
||||
out.PutPacket(2, *p);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
connection->QueuePacket(out);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../opcodemgr.h"
|
||||
#include "../net/packet.h"
|
||||
#include "../net/daybreak_connection.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Patches
|
||||
{
|
||||
enum IdentityMatchStatus
|
||||
{
|
||||
IdentityMatchFailure,
|
||||
IdentityMatchSuccess
|
||||
};
|
||||
|
||||
struct Signature
|
||||
{
|
||||
int match_message_opcode;
|
||||
size_t match_message_size;
|
||||
};
|
||||
|
||||
class BasePatch
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(const EQ::Net::Packet*, EmuOpcode, EQ::Net::WritablePacket&)> DecodeStructFunction;
|
||||
typedef std::function<void(std::shared_ptr<EQ::Net::DaybreakConnection>, EmuOpcode, const EQ::Net::Packet*)> EncodeStructFunction;
|
||||
|
||||
BasePatch() { }
|
||||
virtual ~BasePatch() { }
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
IdentityMatchStatus TryIdentityMatch(const EQ::Net::Packet &p) const;
|
||||
|
||||
void Decode(const EQ::Net::Packet *in, EmuOpcode& opcode, EQ::Net::WritablePacket& out);
|
||||
void Encode(std::shared_ptr<EQ::Net::DaybreakConnection> connection, EmuOpcode opcode, const EQ::Net::Packet *in);
|
||||
|
||||
void RegisterDecode(int protocol_number, DecodeStructFunction f);
|
||||
void RegisterEncode(EmuOpcode opcode, EncodeStructFunction f);
|
||||
protected:
|
||||
void SendPacket(std::shared_ptr<EQ::Net::DaybreakConnection> connection, EmuOpcode opcode, const EQ::Net::Packet *p);
|
||||
|
||||
std::unique_ptr<OpcodeManager> m_opcode_manager;
|
||||
std::map<int, DecodeStructFunction> m_decode;
|
||||
std::map<EmuOpcode, EncodeStructFunction> m_encode;
|
||||
Signature m_signature;
|
||||
int m_message_size;
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+98
-94
@@ -29,7 +29,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../inventory_profile.h"
|
||||
#include "rof_structs.h"
|
||||
#include "../rulesys.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace RoF
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id, uint8 depth);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline structs::InventorySlot_Struct ServerToRoFSlot(uint32 serverSlot);
|
||||
@@ -66,6 +66,9 @@ namespace RoF
|
||||
static inline CastingSlot ServerToRoFCastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot RoFToServerCastingSlot(CastingSlot slot);
|
||||
|
||||
static inline int ServerToRoFBuffSlot(int index);
|
||||
static inline int RoFToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
//create our opcode manager if we havent already
|
||||
@@ -423,15 +426,8 @@ namespace RoF
|
||||
OUT(buff.y);
|
||||
OUT(buff.x);
|
||||
OUT(buff.z);
|
||||
uint16 buffslot = emu->slotid;
|
||||
// Not sure if this is needs amending for RoF yet.
|
||||
if (buffslot >= 25)
|
||||
{
|
||||
buffslot += 17;
|
||||
}
|
||||
|
||||
// TODO: implement slot_data stuff
|
||||
eq->slotid = buffslot;
|
||||
eq->slotid = ServerToRoFBuffSlot(emu->slotid);
|
||||
|
||||
if (emu->bufffade == 1)
|
||||
eq->bufffade = 1;
|
||||
@@ -447,10 +443,10 @@ namespace RoF
|
||||
outapp->WriteUInt32(0); // tic timer
|
||||
outapp->WriteUInt8(0); // Type of OP_BuffCreate packet ?
|
||||
outapp->WriteUInt16(1); // 1 buff in this packet
|
||||
outapp->WriteUInt32(buffslot);
|
||||
outapp->WriteUInt32(eq->slotid);
|
||||
outapp->WriteUInt32(0xffffffff); // SpellID (0xffff to remove)
|
||||
outapp->WriteUInt32(0); // Duration
|
||||
outapp->WriteUInt32(0); // ?
|
||||
outapp->WriteUInt32(0); // numhits
|
||||
outapp->WriteUInt8(0); // Caster name
|
||||
outapp->WriteUInt8(0); // Type
|
||||
}
|
||||
@@ -474,17 +470,9 @@ namespace RoF
|
||||
__packet->WriteUInt8(emu->all_buffs); // 1 indicates all buffs on the player (0 to add or remove a single buff)
|
||||
__packet->WriteUInt16(emu->count);
|
||||
|
||||
for (uint16 i = 0; i < emu->count; ++i)
|
||||
for (int i = 0; i < emu->count; ++i)
|
||||
{
|
||||
uint16 buffslot = emu->entries[i].buff_slot;
|
||||
if (emu->type == 0) { // only correct for self packets
|
||||
if (emu->entries[i].buff_slot >= 25)
|
||||
buffslot += 17;
|
||||
if (buffslot == 54)
|
||||
buffslot = 62;
|
||||
}
|
||||
|
||||
__packet->WriteUInt32(buffslot);
|
||||
__packet->WriteUInt32(emu->type == 0 ? ServerToRoFBuffSlot(emu->entries[i].buff_slot) : emu->entries[i].buff_slot);
|
||||
__packet->WriteUInt32(emu->entries[i].spell_id);
|
||||
__packet->WriteUInt32(emu->entries[i].tics_remaining);
|
||||
__packet->WriteUInt32(emu->entries[i].num_hits); // Unknown
|
||||
@@ -596,7 +584,7 @@ namespace RoF
|
||||
ob.write((const char*)&item_count, sizeof(uint32));
|
||||
|
||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -1504,17 +1492,6 @@ namespace RoF
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
ENCODE(OP_InterruptCast)
|
||||
{
|
||||
ENCODE_LENGTH_EXACT(InterruptCast_Struct);
|
||||
SETUP_DIRECT_ENCODE(InterruptCast_Struct, structs::InterruptCast_Struct);
|
||||
|
||||
OUT(spawnid);
|
||||
OUT(messageid);
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
|
||||
|
||||
ENCODE(OP_ItemPacket)
|
||||
@@ -1533,7 +1510,7 @@ namespace RoF
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -2079,7 +2056,7 @@ namespace RoF
|
||||
|
||||
outapp->WriteUInt32(22); // Equipment count
|
||||
|
||||
for (int r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++)
|
||||
for (int r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++)
|
||||
{
|
||||
outapp->WriteUInt32(emu->item_material.Slot[r].Material);
|
||||
outapp->WriteUInt32(0);
|
||||
@@ -2099,9 +2076,9 @@ namespace RoF
|
||||
outapp->WriteUInt32(0);
|
||||
}
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Equipment2 count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Equipment2 count
|
||||
|
||||
for (int r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++)
|
||||
for (int r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++)
|
||||
{
|
||||
outapp->WriteUInt32(0);
|
||||
outapp->WriteUInt32(0);
|
||||
@@ -2110,7 +2087,7 @@ namespace RoF
|
||||
outapp->WriteUInt32(0);
|
||||
}
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Tint Count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Tint Count
|
||||
|
||||
for (int r = 0; r < 7; r++)
|
||||
{
|
||||
@@ -2120,7 +2097,7 @@ namespace RoF
|
||||
outapp->WriteUInt32(0);
|
||||
outapp->WriteUInt32(0);
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Tint2 Count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Tint2 Count
|
||||
|
||||
for (int r = 0; r < 7; r++)
|
||||
{
|
||||
@@ -3059,12 +3036,12 @@ namespace RoF
|
||||
eq_cse->Gender = emu_cse->Gender;
|
||||
eq_cse->Face = emu_cse->Face;
|
||||
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::TextureCount; equip_index++) {
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::materialCount; equip_index++) {
|
||||
eq_cse->Equip[equip_index].Material = emu_cse->Equip[equip_index].Material;
|
||||
eq_cse->Equip[equip_index].Unknown1 = emu_cse->Equip[equip_index].Unknown1;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteMaterial;
|
||||
eq_cse->Equip[equip_index].HeroForgeModel = emu_cse->Equip[equip_index].HeroForgeModel;
|
||||
eq_cse->Equip[equip_index].Material2 = emu_cse->Equip[equip_index].Material2;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteModel;
|
||||
eq_cse->Equip[equip_index].HeroForgeModel = emu_cse->Equip[equip_index].HerosForgeModel;
|
||||
eq_cse->Equip[equip_index].Material2 = emu_cse->Equip[equip_index].Unknown2;
|
||||
eq_cse->Equip[equip_index].Color = emu_cse->Equip[equip_index].Color;
|
||||
}
|
||||
|
||||
@@ -4096,7 +4073,7 @@ namespace RoF
|
||||
|
||||
if ((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522))
|
||||
{
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; ++k)
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; ++k)
|
||||
{
|
||||
{
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->equipment_tint.Slot[k].Color);
|
||||
@@ -4105,15 +4082,15 @@ namespace RoF
|
||||
|
||||
structs::Texture_Struct *Equipment = (structs::Texture_Struct *)Buffer;
|
||||
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
Equipment[k].Material = emu->equipment.Slot[k].Material;
|
||||
Equipment[k].Unknown1 = emu->equipment.Slot[k].Unknown1;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteMaterial;
|
||||
Equipment[k].HeroForgeModel = emu->equipment.Slot[k].HeroForgeModel;
|
||||
Equipment[k].Material2 = emu->equipment.Slot[k].Material2;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteModel;
|
||||
Equipment[k].HeroForgeModel = emu->equipment.Slot[k].HerosForgeModel;
|
||||
Equipment[k].Material2 = emu->equipment.Slot[k].Unknown2;
|
||||
}
|
||||
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4312,7 +4289,7 @@ namespace RoF
|
||||
IN(buff.unknown003);
|
||||
IN(buff.spellid);
|
||||
IN(buff.duration);
|
||||
IN(slotid);
|
||||
emu->slotid = RoFToServerBuffSlot(eq->slotid);
|
||||
IN(bufffade);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -4325,7 +4302,7 @@ namespace RoF
|
||||
DECODE_LENGTH_EXACT(structs::BuffRemoveRequest_Struct);
|
||||
SETUP_DIRECT_DECODE(BuffRemoveRequest_Struct, structs::BuffRemoveRequest_Struct);
|
||||
|
||||
emu->SlotID = (eq->SlotID < 42) ? eq->SlotID : (eq->SlotID - 17);
|
||||
emu->SlotID = RoFToServerBuffSlot(eq->SlotID);
|
||||
|
||||
IN(EntityID);
|
||||
|
||||
@@ -4829,10 +4806,9 @@ namespace RoF
|
||||
|
||||
IN(item_id);
|
||||
int r;
|
||||
for (r = 0; r < EQEmu::legacy::ITEM_COMMON_SIZE; r++) {
|
||||
for (r = EQEmu::inventory::socketBegin; r < EQEmu::inventory::SocketCount; r++) {
|
||||
IN(augments[r]);
|
||||
}
|
||||
// Max Augs is now 6, but no code to support that many yet
|
||||
IN(link_hash);
|
||||
IN(icon);
|
||||
|
||||
@@ -5209,9 +5185,9 @@ namespace RoF
|
||||
return NextItemInstSerialNumber;
|
||||
}
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
|
||||
{
|
||||
const EQEmu::ItemBase *item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData *item = inst->GetUnscaledItem();
|
||||
|
||||
RoF::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@@ -5265,7 +5241,7 @@ namespace RoF
|
||||
|
||||
if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) {
|
||||
ornaIcon = inst->GetOrnamentationIcon();
|
||||
heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in));
|
||||
heroModel = inst->GetOrnamentHeroModel(EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id_in));
|
||||
|
||||
char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile());
|
||||
|
||||
@@ -5622,18 +5598,18 @@ namespace RoF
|
||||
|
||||
ob.write((const char*)&subitem_count, sizeof(uint32));
|
||||
|
||||
for (uint32 index = SUB_INDEX_BEGIN; index < EQEmu::legacy::ITEM_CONTAINER_SIZE; ++index) {
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
for (uint32 index = EQEmu::inventory::containerBegin; index < EQEmu::inventory::ContainerCount; ++index) {
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
int SubSlotNumber = INVALID_INDEX;
|
||||
if (slot_id_in >= EQEmu::legacy::GENERAL_BEGIN && slot_id_in <= EQEmu::legacy::GENERAL_END)
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + index + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::inventory::ContainerCount) + index + 1);
|
||||
else if (slot_id_in >= EQEmu::legacy::BANK_BEGIN && slot_id_in <= EQEmu::legacy::BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
else if (slot_id_in >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::legacy::SHARED_BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
else
|
||||
SubSlotNumber = slot_id_in;
|
||||
|
||||
@@ -5659,17 +5635,17 @@ namespace RoF
|
||||
|
||||
uint32 TempSlot = 0;
|
||||
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::legacy::SlotPowerSource) { // Main Inventory and Cursor
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::inventory::slotPowerSource) { // Main Inventory and Cursor
|
||||
RoFSlot.Type = invtype::InvTypePossessions;
|
||||
RoFSlot.Slot = serverSlot;
|
||||
|
||||
if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
RoFSlot.Slot = invslot::PossessionsPowerSource;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotCursor) // Cursor and Extended Corpse Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotCursor) // Cursor and Extended Corpse Inventory
|
||||
RoFSlot.Slot += 3;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotAmmo) // (> 20)
|
||||
else if (serverSlot >= EQEmu::inventory::slotAmmo) // (> 20)
|
||||
RoFSlot.Slot += 1;
|
||||
}
|
||||
|
||||
@@ -5681,8 +5657,8 @@ namespace RoF
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END) { // (> 250 && < 341)
|
||||
RoFSlot.Type = invtype::InvTypePossessions;
|
||||
TempSlot = serverSlot - 1;
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 2;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 2;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::inventory::ContainerCount);
|
||||
|
||||
if (RoFSlot.Slot >= invslot::PossessionsGeneral9) // (> 30)
|
||||
RoFSlot.Slot = invslot::PossessionsCursor;
|
||||
@@ -5699,8 +5675,8 @@ namespace RoF
|
||||
RoFSlot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) { // (> 30)
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5710,8 +5686,8 @@ namespace RoF
|
||||
RoFSlot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) { // (> 30)
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5721,8 +5697,8 @@ namespace RoF
|
||||
RoFSlot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) {
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5760,16 +5736,16 @@ namespace RoF
|
||||
|
||||
uint32 TempSlot = 0;
|
||||
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::legacy::SlotPowerSource) { // (< 52)
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::inventory::slotPowerSource) { // (< 52)
|
||||
RoFSlot.Slot = serverSlot;
|
||||
|
||||
if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
RoFSlot.Slot = invslot::PossessionsPowerSource;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotCursor) // Cursor and Extended Corpse Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotCursor) // Cursor and Extended Corpse Inventory
|
||||
RoFSlot.Slot += 3;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotAmmo) // Ammo and Personl Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotAmmo) // Ammo and Personl Inventory
|
||||
RoFSlot.Slot += 1;
|
||||
|
||||
/*else if (ServerSlot >= MainCursor) { // Cursor
|
||||
@@ -5782,8 +5758,8 @@ namespace RoF
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END) {
|
||||
TempSlot = serverSlot - 1;
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 2;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoFSlot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 2;
|
||||
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01);
|
||||
@@ -5803,7 +5779,7 @@ namespace RoF
|
||||
|
||||
if (rofSlot.Type == invtype::InvTypePossessions && rofSlot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 51)
|
||||
if (rofSlot.Slot == invslot::PossessionsPowerSource)
|
||||
TempSlot = EQEmu::legacy::SlotPowerSource;
|
||||
TempSlot = EQEmu::inventory::slotPowerSource;
|
||||
|
||||
else if (rofSlot.Slot >= invslot::PossessionsCursor) // Cursor and Extended Corpse Inventory
|
||||
TempSlot = rofSlot.Slot - 3;
|
||||
@@ -5825,8 +5801,8 @@ namespace RoF
|
||||
else // Worn Slots
|
||||
TempSlot = rofSlot.Slot;
|
||||
|
||||
if (rofSlot.SubIndex >= SUB_INDEX_BEGIN) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rofSlot.SubIndex + 1;
|
||||
if (rofSlot.SubIndex >= EQEmu::inventory::containerBegin) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::inventory::ContainerCount) + rofSlot.SubIndex + 1;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
@@ -5834,8 +5810,8 @@ namespace RoF
|
||||
else if (rofSlot.Type == invtype::InvTypeBank) {
|
||||
TempSlot = EQEmu::legacy::BANK_BEGIN;
|
||||
|
||||
if (rofSlot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rofSlot.SubIndex + 1;
|
||||
if (rofSlot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::inventory::ContainerCount) + rofSlot.SubIndex + 1;
|
||||
|
||||
else
|
||||
TempSlot += rofSlot.Slot;
|
||||
@@ -5846,8 +5822,8 @@ namespace RoF
|
||||
else if (rofSlot.Type == invtype::InvTypeSharedBank) {
|
||||
TempSlot = EQEmu::legacy::SHARED_BANK_BEGIN;
|
||||
|
||||
if (rofSlot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rofSlot.SubIndex + 1;
|
||||
if (rofSlot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::inventory::ContainerCount) + rofSlot.SubIndex + 1;
|
||||
|
||||
else
|
||||
TempSlot += rofSlot.Slot;
|
||||
@@ -5858,10 +5834,10 @@ namespace RoF
|
||||
else if (rofSlot.Type == invtype::InvTypeTrade) {
|
||||
TempSlot = EQEmu::legacy::TRADE_BEGIN;
|
||||
|
||||
if (rofSlot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rofSlot.SubIndex + 1;
|
||||
if (rofSlot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rofSlot.Slot + 3) * EQEmu::inventory::ContainerCount) + rofSlot.SubIndex + 1;
|
||||
// OLD CODE:
|
||||
//TempSlot += 100 + (RoFSlot.MainSlot * EQEmu::legacy::ITEM_CONTAINER_SIZE) + RoFSlot.SubSlot;
|
||||
//TempSlot += 100 + (RoFSlot.MainSlot * EQEmu::inventory::ContainerCount) + RoFSlot.SubSlot;
|
||||
|
||||
else
|
||||
TempSlot += rofSlot.Slot;
|
||||
@@ -5872,7 +5848,7 @@ namespace RoF
|
||||
else if (rofSlot.Type == invtype::InvTypeWorld) {
|
||||
TempSlot = EQEmu::legacy::WORLD_BEGIN;
|
||||
|
||||
if (rofSlot.Slot >= SUB_INDEX_BEGIN)
|
||||
if (rofSlot.Slot >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += rofSlot.Slot;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
@@ -5903,7 +5879,7 @@ namespace RoF
|
||||
|
||||
if (rofSlot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 33)
|
||||
if (rofSlot.Slot == invslot::PossessionsPowerSource)
|
||||
TempSlot = EQEmu::legacy::SlotPowerSource;
|
||||
TempSlot = EQEmu::inventory::slotPowerSource;
|
||||
|
||||
else if (rofSlot.Slot >= invslot::PossessionsCursor) // Cursor and Extended Corpse Inventory
|
||||
TempSlot = rofSlot.Slot - 3;
|
||||
@@ -5920,8 +5896,8 @@ namespace RoF
|
||||
else
|
||||
TempSlot = rofSlot.Slot;
|
||||
|
||||
if (rofSlot.SubIndex >= SUB_INDEX_BEGIN) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rofSlot.SubIndex + 1;
|
||||
if (rofSlot.SubIndex >= EQEmu::inventory::containerBegin) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::inventory::ContainerCount) + rofSlot.SubIndex + 1;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
@@ -6085,4 +6061,32 @@ namespace RoF
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
// these should be optimized out for RoF since they should all boil down to return index :P
|
||||
// but lets leave it here for future proofing
|
||||
static inline int ServerToRoFBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int RoFToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*RoF*/
|
||||
|
||||
+97
-99
@@ -29,7 +29,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../inventory_profile.h"
|
||||
#include "rof2_structs.h"
|
||||
#include "../rulesys.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace RoF2
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id, uint8 depth, ItemPacketType packet_type);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth, ItemPacketType packet_type);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline structs::InventorySlot_Struct ServerToRoF2Slot(uint32 serverSlot, ItemPacketType PacketType = ItemPacketInvalid);
|
||||
@@ -66,6 +66,9 @@ namespace RoF2
|
||||
static inline CastingSlot ServerToRoF2CastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot RoF2ToServerCastingSlot(CastingSlot slot);
|
||||
|
||||
static inline int ServerToRoF2BuffSlot(int index);
|
||||
static inline int RoF2ToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
//create our opcode manager if we havent already
|
||||
@@ -492,18 +495,7 @@ namespace RoF2
|
||||
OUT(buff.y);
|
||||
OUT(buff.x);
|
||||
OUT(buff.z);
|
||||
uint16 buffslot = emu->slotid;
|
||||
// Not sure if this is needs amending for RoF2 yet.
|
||||
if (buffslot >= 25)
|
||||
{
|
||||
buffslot += 17;
|
||||
}
|
||||
// TODO: We should really just deal with these "server side"
|
||||
// so we can have clients not limited to other clients.
|
||||
// This fixes discs, songs were changed to 20
|
||||
if (buffslot == 54)
|
||||
buffslot = 62;
|
||||
eq->slotid = buffslot;
|
||||
eq->slotid = ServerToRoF2BuffSlot(emu->slotid);
|
||||
// TODO: implement slot_data stuff
|
||||
if (emu->bufffade == 1)
|
||||
eq->bufffade = 1;
|
||||
@@ -519,10 +511,10 @@ namespace RoF2
|
||||
outapp->WriteUInt32(0); // tic timer
|
||||
outapp->WriteUInt8(0); // Type of OP_BuffCreate packet ?
|
||||
outapp->WriteUInt16(1); // 1 buff in this packet
|
||||
outapp->WriteUInt32(buffslot);
|
||||
outapp->WriteUInt32(eq->slotid);
|
||||
outapp->WriteUInt32(0xffffffff); // SpellID (0xffff to remove)
|
||||
outapp->WriteUInt32(0); // Duration
|
||||
outapp->WriteUInt32(0); // ?
|
||||
outapp->WriteUInt32(0); // numhits
|
||||
outapp->WriteUInt8(0); // Caster name
|
||||
outapp->WriteUInt8(0); // Type
|
||||
}
|
||||
@@ -546,20 +538,9 @@ namespace RoF2
|
||||
__packet->WriteUInt8(emu->all_buffs); // 1 indicates all buffs on the player (0 to add or remove a single buff)
|
||||
__packet->WriteUInt16(emu->count);
|
||||
|
||||
for (uint16 i = 0; i < emu->count; ++i)
|
||||
for (int i = 0; i < emu->count; ++i)
|
||||
{
|
||||
uint16 buffslot = emu->entries[i].buff_slot;
|
||||
if (emu->type == 0) { // only correct for self packets
|
||||
if (emu->entries[i].buff_slot >= 25)
|
||||
buffslot += 17;
|
||||
// TODO: We should really just deal with these "server side"
|
||||
// so we can have clients not limited to other clients.
|
||||
// This fixes discs, songs were changed to 20
|
||||
if (buffslot == 54)
|
||||
buffslot = 62;
|
||||
}
|
||||
|
||||
__packet->WriteUInt32(buffslot);
|
||||
__packet->WriteUInt32(emu->type == 0 ? ServerToRoF2BuffSlot(emu->entries[i].buff_slot) : emu->entries[i].buff_slot);
|
||||
__packet->WriteUInt32(emu->entries[i].spell_id);
|
||||
__packet->WriteUInt32(emu->entries[i].tics_remaining);
|
||||
__packet->WriteUInt32(emu->entries[i].num_hits); // Unknown
|
||||
@@ -671,7 +652,7 @@ namespace RoF2
|
||||
ob.write((const char*)&item_count, sizeof(uint32));
|
||||
|
||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -1579,17 +1560,6 @@ namespace RoF2
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
ENCODE(OP_InterruptCast)
|
||||
{
|
||||
ENCODE_LENGTH_EXACT(InterruptCast_Struct);
|
||||
SETUP_DIRECT_ENCODE(InterruptCast_Struct, structs::InterruptCast_Struct);
|
||||
|
||||
OUT(spawnid);
|
||||
OUT(messageid);
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
|
||||
|
||||
ENCODE(OP_ItemPacket)
|
||||
@@ -1609,7 +1579,7 @@ namespace RoF2
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -2164,7 +2134,7 @@ namespace RoF2
|
||||
|
||||
outapp->WriteUInt32(22); // Equipment count
|
||||
|
||||
for (int r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++)
|
||||
for (int r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++)
|
||||
{
|
||||
outapp->WriteUInt32(emu->item_material.Slot[r].Material);
|
||||
outapp->WriteUInt32(0);
|
||||
@@ -2184,9 +2154,9 @@ namespace RoF2
|
||||
outapp->WriteUInt32(0);
|
||||
}
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Equipment2 count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Equipment2 count
|
||||
|
||||
for (int r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++)
|
||||
for (int r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++)
|
||||
{
|
||||
outapp->WriteUInt32(0);
|
||||
outapp->WriteUInt32(0);
|
||||
@@ -2195,7 +2165,7 @@ namespace RoF2
|
||||
outapp->WriteUInt32(0);
|
||||
}
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Tint Count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Tint Count
|
||||
|
||||
for (int r = 0; r < 7; r++)
|
||||
{
|
||||
@@ -2205,7 +2175,7 @@ namespace RoF2
|
||||
outapp->WriteUInt32(0);
|
||||
outapp->WriteUInt32(0);
|
||||
|
||||
outapp->WriteUInt32(EQEmu::textures::TextureCount); // Tint2 Count
|
||||
outapp->WriteUInt32(EQEmu::textures::materialCount); // Tint2 Count
|
||||
|
||||
for (int r = 0; r < 7; r++)
|
||||
{
|
||||
@@ -3154,12 +3124,12 @@ namespace RoF2
|
||||
eq_cse->Gender = emu_cse->Gender;
|
||||
eq_cse->Face = emu_cse->Face;
|
||||
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::TextureCount; equip_index++) {
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::materialCount; equip_index++) {
|
||||
eq_cse->Equip[equip_index].Material = emu_cse->Equip[equip_index].Material;
|
||||
eq_cse->Equip[equip_index].Unknown1 = emu_cse->Equip[equip_index].Unknown1;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteMaterial;
|
||||
eq_cse->Equip[equip_index].HeroForgeModel = emu_cse->Equip[equip_index].HeroForgeModel;
|
||||
eq_cse->Equip[equip_index].Material2 = emu_cse->Equip[equip_index].Material2;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteModel;
|
||||
eq_cse->Equip[equip_index].HeroForgeModel = emu_cse->Equip[equip_index].HerosForgeModel;
|
||||
eq_cse->Equip[equip_index].Material2 = emu_cse->Equip[equip_index].Unknown2;
|
||||
eq_cse->Equip[equip_index].Color = emu_cse->Equip[equip_index].Color;
|
||||
}
|
||||
|
||||
@@ -4321,7 +4291,7 @@ namespace RoF2
|
||||
|
||||
if ((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522))
|
||||
{
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; ++k)
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; ++k)
|
||||
{
|
||||
{
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->equipment_tint.Slot[k].Color);
|
||||
@@ -4330,15 +4300,15 @@ namespace RoF2
|
||||
|
||||
structs::Texture_Struct *Equipment = (structs::Texture_Struct *)Buffer;
|
||||
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
Equipment[k].Material = emu->equipment.Slot[k].Material;
|
||||
Equipment[k].Unknown1 = emu->equipment.Slot[k].Unknown1;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteMaterial;
|
||||
Equipment[k].HeroForgeModel = emu->equipment.Slot[k].HeroForgeModel;
|
||||
Equipment[k].Material2 = emu->equipment.Slot[k].Material2;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteModel;
|
||||
Equipment[k].HeroForgeModel = emu->equipment.Slot[k].HerosForgeModel;
|
||||
Equipment[k].Material2 = emu->equipment.Slot[k].Unknown2;
|
||||
}
|
||||
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4550,7 +4520,7 @@ namespace RoF2
|
||||
IN(buff.unknown003);
|
||||
IN(buff.spellid);
|
||||
IN(buff.duration);
|
||||
IN(slotid);
|
||||
emu->slotid = RoF2ToServerBuffSlot(eq->slotid);
|
||||
IN(bufffade);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -4563,7 +4533,7 @@ namespace RoF2
|
||||
DECODE_LENGTH_EXACT(structs::BuffRemoveRequest_Struct);
|
||||
SETUP_DIRECT_DECODE(BuffRemoveRequest_Struct, structs::BuffRemoveRequest_Struct);
|
||||
|
||||
emu->SlotID = (eq->SlotID < 42) ? eq->SlotID : (eq->SlotID - 17);
|
||||
emu->SlotID = RoF2ToServerBuffSlot(eq->SlotID);
|
||||
|
||||
IN(EntityID);
|
||||
|
||||
@@ -5066,7 +5036,7 @@ namespace RoF2
|
||||
|
||||
IN(item_id);
|
||||
int r;
|
||||
for (r = 0; r < EQEmu::legacy::ITEM_COMMON_SIZE; r++) {
|
||||
for (r = EQEmu::inventory::socketBegin; r < EQEmu::inventory::SocketCount; r++) {
|
||||
IN(augments[r]);
|
||||
}
|
||||
IN(link_hash);
|
||||
@@ -5499,9 +5469,9 @@ namespace RoF2
|
||||
return NextItemInstSerialNumber;
|
||||
}
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth, ItemPacketType packet_type)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth, ItemPacketType packet_type)
|
||||
{
|
||||
const EQEmu::ItemBase *item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData *item = inst->GetUnscaledItem();
|
||||
|
||||
RoF2::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@@ -5555,7 +5525,7 @@ namespace RoF2
|
||||
|
||||
if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) {
|
||||
ornaIcon = inst->GetOrnamentationIcon();
|
||||
heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in));
|
||||
heroModel = inst->GetOrnamentHeroModel(EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id_in));
|
||||
|
||||
char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile());
|
||||
|
||||
@@ -5922,18 +5892,18 @@ namespace RoF2
|
||||
|
||||
ob.write((const char*)&subitem_count, sizeof(uint32));
|
||||
|
||||
for (uint32 index = SUB_INDEX_BEGIN; index < EQEmu::legacy::ITEM_CONTAINER_SIZE; ++index) {
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
for (uint32 index = EQEmu::inventory::containerBegin; index < EQEmu::inventory::ContainerCount; ++index) {
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
int SubSlotNumber = INVALID_INDEX;
|
||||
if (slot_id_in >= EQEmu::legacy::GENERAL_BEGIN && slot_id_in <= EQEmu::legacy::GENERAL_END)
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + index + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::inventory::ContainerCount) + index + 1);
|
||||
else if (slot_id_in >= EQEmu::legacy::BANK_BEGIN && slot_id_in <= EQEmu::legacy::BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
else if (slot_id_in >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::legacy::SHARED_BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
else
|
||||
SubSlotNumber = slot_id_in;
|
||||
|
||||
@@ -5959,7 +5929,7 @@ namespace RoF2
|
||||
|
||||
uint32 TempSlot = 0;
|
||||
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::legacy::SlotPowerSource) { // Main Inventory and Cursor
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::inventory::slotPowerSource) { // Main Inventory and Cursor
|
||||
if (PacketType == ItemPacketLoot)
|
||||
{
|
||||
RoF2Slot.Type = invtype::InvTypeCorpse;
|
||||
@@ -5971,13 +5941,13 @@ namespace RoF2
|
||||
RoF2Slot.Slot = serverSlot;
|
||||
}
|
||||
|
||||
if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
RoF2Slot.Slot = invslot::PossessionsPowerSource;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotCursor && PacketType != ItemPacketLoot) // Cursor and Extended Corpse Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotCursor && PacketType != ItemPacketLoot) // Cursor and Extended Corpse Inventory
|
||||
RoF2Slot.Slot += 3;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotAmmo) // (> 20)
|
||||
else if (serverSlot >= EQEmu::inventory::slotAmmo) // (> 20)
|
||||
RoF2Slot.Slot += 1;
|
||||
}
|
||||
|
||||
@@ -5989,8 +5959,8 @@ namespace RoF2
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END) { // (> 250 && < 341)
|
||||
RoF2Slot.Type = invtype::InvTypePossessions;
|
||||
TempSlot = serverSlot - 1;
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 2;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 2;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::inventory::ContainerCount);
|
||||
|
||||
if (RoF2Slot.Slot >= invslot::PossessionsGeneral9) // (> 30)
|
||||
RoF2Slot.Slot = invslot::PossessionsCursor;
|
||||
@@ -6007,8 +5977,8 @@ namespace RoF2
|
||||
RoF2Slot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) { // (> 30)
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6018,8 +5988,8 @@ namespace RoF2
|
||||
RoF2Slot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) { // (> 30)
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6029,8 +5999,8 @@ namespace RoF2
|
||||
RoF2Slot.Slot = TempSlot;
|
||||
|
||||
if (TempSlot > 30) {
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 3;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6068,16 +6038,16 @@ namespace RoF2
|
||||
|
||||
uint32 TempSlot = 0;
|
||||
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::legacy::SlotPowerSource) { // (< 52)
|
||||
if (serverSlot < 56 || serverSlot == EQEmu::inventory::slotPowerSource) { // (< 52)
|
||||
RoF2Slot.Slot = serverSlot;
|
||||
|
||||
if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
RoF2Slot.Slot = invslot::PossessionsPowerSource;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotCursor) // Cursor and Extended Corpse Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotCursor) // Cursor and Extended Corpse Inventory
|
||||
RoF2Slot.Slot += 3;
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::SlotAmmo) // Ammo and Personl Inventory
|
||||
else if (serverSlot >= EQEmu::inventory::slotAmmo) // Ammo and Personl Inventory
|
||||
RoF2Slot.Slot += 1;
|
||||
|
||||
/*else if (ServerSlot >= MainCursor) { // Cursor
|
||||
@@ -6090,8 +6060,8 @@ namespace RoF2
|
||||
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END) {
|
||||
TempSlot = serverSlot - 1;
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::legacy::ITEM_CONTAINER_SIZE) - 2;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::legacy::ITEM_CONTAINER_SIZE);
|
||||
RoF2Slot.Slot = int(TempSlot / EQEmu::inventory::ContainerCount) - 2;
|
||||
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::inventory::ContainerCount);
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01);
|
||||
@@ -6111,7 +6081,7 @@ namespace RoF2
|
||||
|
||||
if (rof2Slot.Type == invtype::InvTypePossessions && rof2Slot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 51)
|
||||
if (rof2Slot.Slot == invslot::PossessionsPowerSource)
|
||||
TempSlot = EQEmu::legacy::SlotPowerSource;
|
||||
TempSlot = EQEmu::inventory::slotPowerSource;
|
||||
|
||||
else if (rof2Slot.Slot >= invslot::PossessionsCursor) // Cursor and Extended Corpse Inventory
|
||||
TempSlot = rof2Slot.Slot - 3;
|
||||
@@ -6133,8 +6103,8 @@ namespace RoF2
|
||||
else // Worn Slots
|
||||
TempSlot = rof2Slot.Slot;
|
||||
|
||||
if (rof2Slot.SubIndex >= SUB_INDEX_BEGIN) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rof2Slot.SubIndex + 1;
|
||||
if (rof2Slot.SubIndex >= EQEmu::inventory::containerBegin) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::inventory::ContainerCount) + rof2Slot.SubIndex + 1;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
@@ -6142,8 +6112,8 @@ namespace RoF2
|
||||
else if (rof2Slot.Type == invtype::InvTypeBank) {
|
||||
TempSlot = EQEmu::legacy::BANK_BEGIN;
|
||||
|
||||
if (rof2Slot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rof2Slot.SubIndex + 1;
|
||||
if (rof2Slot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::inventory::ContainerCount) + rof2Slot.SubIndex + 1;
|
||||
|
||||
else
|
||||
TempSlot += rof2Slot.Slot;
|
||||
@@ -6154,8 +6124,8 @@ namespace RoF2
|
||||
else if (rof2Slot.Type == invtype::InvTypeSharedBank) {
|
||||
TempSlot = EQEmu::legacy::SHARED_BANK_BEGIN;
|
||||
|
||||
if (rof2Slot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rof2Slot.SubIndex + 1;
|
||||
if (rof2Slot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::inventory::ContainerCount) + rof2Slot.SubIndex + 1;
|
||||
|
||||
else
|
||||
TempSlot += rof2Slot.Slot;
|
||||
@@ -6166,8 +6136,8 @@ namespace RoF2
|
||||
else if (rof2Slot.Type == invtype::InvTypeTrade) {
|
||||
TempSlot = EQEmu::legacy::TRADE_BEGIN;
|
||||
|
||||
if (rof2Slot.SubIndex >= SUB_INDEX_BEGIN)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rof2Slot.SubIndex + 1;
|
||||
if (rof2Slot.SubIndex >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::inventory::ContainerCount) + rof2Slot.SubIndex + 1;
|
||||
// OLD CODE:
|
||||
//TempSlot += 100 + (RoF2Slot.MainSlot * EmuConstants::ITEM_CONTAINER_SIZE) + RoF2Slot.SubSlot;
|
||||
|
||||
@@ -6180,7 +6150,7 @@ namespace RoF2
|
||||
else if (rof2Slot.Type == invtype::InvTypeWorld) {
|
||||
TempSlot = EQEmu::legacy::WORLD_BEGIN;
|
||||
|
||||
if (rof2Slot.Slot >= SUB_INDEX_BEGIN)
|
||||
if (rof2Slot.Slot >= EQEmu::inventory::containerBegin)
|
||||
TempSlot += rof2Slot.Slot;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
@@ -6215,7 +6185,7 @@ namespace RoF2
|
||||
|
||||
if (rof2Slot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 33)
|
||||
if (rof2Slot.Slot == invslot::PossessionsPowerSource)
|
||||
TempSlot = EQEmu::legacy::SlotPowerSource;
|
||||
TempSlot = EQEmu::inventory::slotPowerSource;
|
||||
|
||||
else if (rof2Slot.Slot >= invslot::PossessionsCursor) // Cursor and Extended Corpse Inventory
|
||||
TempSlot = rof2Slot.Slot - 3;
|
||||
@@ -6232,8 +6202,8 @@ namespace RoF2
|
||||
else
|
||||
TempSlot = rof2Slot.Slot;
|
||||
|
||||
if (rof2Slot.SubIndex >= SUB_INDEX_BEGIN) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + rof2Slot.SubIndex + 1;
|
||||
if (rof2Slot.SubIndex >= EQEmu::inventory::containerBegin) // Bag Slots
|
||||
TempSlot = ((TempSlot + 3) * EQEmu::inventory::ContainerCount) + rof2Slot.SubIndex + 1;
|
||||
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
@@ -6388,4 +6358,32 @@ namespace RoF2
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
// these should be optimized out for RoF2 since they should all boil down to return index :P
|
||||
// but lets leave it here for future proofing
|
||||
static inline int ServerToRoF2BuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int RoF2ToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*RoF2*/
|
||||
|
||||
@@ -277,6 +277,14 @@ namespace RoF2
|
||||
|
||||
const size_t SayLinkBodySize = 56;
|
||||
|
||||
const int LongBuffs = 42;
|
||||
const int ShortBuffs = 20;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 97;
|
||||
const int PetBuffs = NPCBuffs;
|
||||
const int MercBuffs = LongBuffs;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
|
||||
@@ -85,7 +85,6 @@ E(OP_HPUpdate)
|
||||
E(OP_Illusion)
|
||||
E(OP_InspectBuffs)
|
||||
E(OP_InspectRequest)
|
||||
E(OP_InterruptCast)
|
||||
E(OP_ItemLinkResponse)
|
||||
E(OP_ItemPacket)
|
||||
E(OP_ItemVerifyReply)
|
||||
|
||||
@@ -190,7 +190,7 @@ struct TintProfile
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1082,7 +1082,7 @@ union
|
||||
/*00184*/ Texture_Struct equipment[22]; // Total Slots
|
||||
};
|
||||
/*00624*/ uint32 equip2_count; // Seen 9
|
||||
/*00628*/ Texture_Struct equipment2[EQEmu::textures::TextureCount]; // Appears to be Visible slots, but all 0s
|
||||
/*00628*/ Texture_Struct equipment2[EQEmu::textures::materialCount]; // Appears to be Visible slots, but all 0s
|
||||
/*00808*/ uint32 tint_count; // Seen 9
|
||||
/*00812*/ TintProfile item_tint; // RR GG BB 00
|
||||
/*00848*/ uint32 tint_count2; // Seen 9
|
||||
@@ -2423,7 +2423,7 @@ struct AdventureLeaderboard_Struct
|
||||
/*struct Item_Shop_Struct {
|
||||
uint16 merchantid;
|
||||
uint8 itemtype;
|
||||
ItemBase item;
|
||||
ItemData item;
|
||||
uint8 iss_unknown001[6];
|
||||
};*/
|
||||
|
||||
|
||||
@@ -268,6 +268,14 @@ namespace RoF
|
||||
|
||||
const size_t SayLinkBodySize = 55;
|
||||
|
||||
const int LongBuffs = 42;
|
||||
const int ShortBuffs = 20;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 97;
|
||||
const int PetBuffs = NPCBuffs;
|
||||
const int MercBuffs = LongBuffs;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
|
||||
@@ -70,7 +70,6 @@ E(OP_HPUpdate)
|
||||
E(OP_Illusion)
|
||||
E(OP_InspectBuffs)
|
||||
E(OP_InspectRequest)
|
||||
E(OP_InterruptCast)
|
||||
E(OP_ItemLinkResponse)
|
||||
E(OP_ItemPacket)
|
||||
E(OP_ItemVerifyReply)
|
||||
|
||||
@@ -190,7 +190,7 @@ struct TintProfile
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2021,7 +2021,7 @@ struct LootingItem_Struct {
|
||||
/*004*/ uint32 looter;
|
||||
/*008*/ uint16 slot_id;
|
||||
/*010*/ uint16 unknown10;
|
||||
/*012*/ uint32 auto_loot;
|
||||
/*012*/ int32 auto_loot;
|
||||
/*016*/ uint32 unknown16;
|
||||
/*020*/
|
||||
};
|
||||
@@ -2450,7 +2450,7 @@ struct AdventureLeaderboard_Struct
|
||||
/*struct Item_Shop_Struct {
|
||||
uint16 merchantid;
|
||||
uint8 itemtype;
|
||||
ItemBase item;
|
||||
ItemData item;
|
||||
uint8 iss_unknown001[6];
|
||||
};*/
|
||||
|
||||
|
||||
+54
-25
@@ -29,7 +29,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../item_instance.h"
|
||||
#include "sod_structs.h"
|
||||
#include "../rulesys.h"
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SoD
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id, uint8 depth);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline uint32 ServerToSoDSlot(uint32 ServerSlot);
|
||||
@@ -62,6 +62,9 @@ namespace SoD
|
||||
static inline CastingSlot ServerToSoDCastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot SoDToServerCastingSlot(CastingSlot slot);
|
||||
|
||||
static inline int ServerToSoDBuffSlot(int index);
|
||||
static inline int SoDToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
//create our opcode manager if we havent already
|
||||
@@ -315,7 +318,7 @@ namespace SoD
|
||||
OUT(buff.duration);
|
||||
OUT(buff.counters);
|
||||
OUT(buff.player_id);
|
||||
OUT(slotid);
|
||||
eq->slotid = ServerToSoDBuffSlot(emu->slotid);
|
||||
OUT(bufffade);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -396,7 +399,7 @@ namespace SoD
|
||||
ob.write((const char*)&item_count, sizeof(uint32));
|
||||
|
||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -1060,7 +1063,7 @@ namespace SoD
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -1558,7 +1561,7 @@ namespace SoD
|
||||
OUT(hairstyle);
|
||||
OUT(beard);
|
||||
// OUT(unknown00178[10]);
|
||||
for (r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++) {
|
||||
for (r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++) {
|
||||
eq->equipment.Slot[r].Material = emu->item_material.Slot[r].Material;
|
||||
eq->equipment.Slot[r].Unknown1 = 0;
|
||||
eq->equipment.Slot[r].EliteMaterial = 0;
|
||||
@@ -1998,10 +2001,10 @@ namespace SoD
|
||||
eq_cse->HairColor = emu_cse->HairColor;
|
||||
eq_cse->Face = emu_cse->Face;
|
||||
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::TextureCount; equip_index++) {
|
||||
for (int equip_index = EQEmu::textures::textureBegin; equip_index < EQEmu::textures::materialCount; equip_index++) {
|
||||
eq_cse->Equip[equip_index].Material = emu_cse->Equip[equip_index].Material;
|
||||
eq_cse->Equip[equip_index].Unknown1 = emu_cse->Equip[equip_index].Unknown1;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteMaterial;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteModel;
|
||||
eq_cse->Equip[equip_index].Color = emu_cse->Equip[equip_index].Color;
|
||||
}
|
||||
|
||||
@@ -2568,7 +2571,7 @@ namespace SoD
|
||||
float SpawnSize = emu->size;
|
||||
if (!((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522)))
|
||||
{
|
||||
PacketSize -= (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
PacketSize -= (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
|
||||
if (emu->size == 0)
|
||||
{
|
||||
@@ -2765,7 +2768,7 @@ namespace SoD
|
||||
|
||||
if ((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522))
|
||||
{
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; ++k)
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; ++k)
|
||||
{
|
||||
{
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->equipment_tint.Slot[k].Color);
|
||||
@@ -2792,13 +2795,13 @@ namespace SoD
|
||||
{
|
||||
structs::Texture_Struct *Equipment = (structs::Texture_Struct *)Buffer;
|
||||
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
Equipment[k].Material = emu->equipment.Slot[k].Material;
|
||||
Equipment[k].Unknown1 = emu->equipment.Slot[k].Unknown1;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteMaterial;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteModel;
|
||||
}
|
||||
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
}
|
||||
if (strlen(emu->title))
|
||||
{
|
||||
@@ -2921,8 +2924,8 @@ namespace SoD
|
||||
IN(buff.bard_modifier);
|
||||
IN(buff.spellid);
|
||||
IN(buff.duration);
|
||||
IN(buff.counters)
|
||||
IN(slotid);
|
||||
IN(buff.counters);
|
||||
emu->slotid = SoDToServerBuffSlot(eq->slotid);
|
||||
IN(bufffade);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -3553,9 +3556,9 @@ namespace SoD
|
||||
return NextItemInstSerialNumber;
|
||||
}
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
|
||||
{
|
||||
const EQEmu::ItemBase *item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData *item = inst->GetUnscaledItem();
|
||||
|
||||
SoD::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@@ -3869,18 +3872,18 @@ namespace SoD
|
||||
|
||||
ob.write((const char*)&subitem_count, sizeof(uint32));
|
||||
|
||||
for (uint32 index = SUB_INDEX_BEGIN; index < EQEmu::legacy::ITEM_CONTAINER_SIZE; ++index) {
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
for (uint32 index = EQEmu::inventory::containerBegin; index < EQEmu::inventory::ContainerCount; ++index) {
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
int SubSlotNumber = INVALID_INDEX;
|
||||
if (slot_id_in >= EQEmu::legacy::GENERAL_BEGIN && slot_id_in <= EQEmu::legacy::GENERAL_END)
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + index + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::inventory::ContainerCount) + index + 1);
|
||||
else if (slot_id_in >= EQEmu::legacy::BANK_BEGIN && slot_id_in <= EQEmu::legacy::BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
else if (slot_id_in >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::legacy::SHARED_BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
else
|
||||
SubSlotNumber = slot_id_in;
|
||||
|
||||
@@ -3898,7 +3901,7 @@ namespace SoD
|
||||
{
|
||||
uint32 SoDSlot = 0;
|
||||
|
||||
if (serverSlot >= EQEmu::legacy::SlotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
if (serverSlot >= EQEmu::inventory::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
SoDSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END)
|
||||
SoDSlot = serverSlot + 11;
|
||||
@@ -3906,7 +3909,7 @@ namespace SoD
|
||||
SoDSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::legacy::SHARED_BANK_BAGS_END)
|
||||
SoDSlot = serverSlot + 1;
|
||||
else if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
else if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
SoDSlot = invslot::PossessionsPowerSource;
|
||||
else
|
||||
SoDSlot = serverSlot;
|
||||
@@ -3932,7 +3935,7 @@ namespace SoD
|
||||
else if (sodSlot >= invbag::SharedBankBagsBegin && sodSlot <= invbag::SharedBankBagsEnd)
|
||||
ServerSlot = sodSlot - 1;
|
||||
else if (sodSlot == invslot::PossessionsPowerSource)
|
||||
ServerSlot = EQEmu::legacy::SlotPowerSource;
|
||||
ServerSlot = EQEmu::inventory::slotPowerSource;
|
||||
else
|
||||
ServerSlot = sodSlot;
|
||||
return ServerSlot;
|
||||
@@ -4088,4 +4091,30 @@ namespace SoD
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ServerToSoDBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int SoDToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*SoD*/
|
||||
|
||||
@@ -295,6 +295,14 @@ namespace SoD
|
||||
|
||||
const size_t SayLinkBodySize = 50;
|
||||
|
||||
const int LongBuffs = 25;
|
||||
const int ShortBuffs = 15;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 85;
|
||||
const int PetBuffs = NPCBuffs;
|
||||
const int MercBuffs = LongBuffs;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
|
||||
@@ -149,7 +149,7 @@ struct TintProfile
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -178,7 +178,7 @@ struct TextureProfile
|
||||
Texture_Struct Primary;
|
||||
Texture_Struct Secondary;
|
||||
};
|
||||
Texture_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Texture_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
|
||||
TextureProfile();
|
||||
@@ -195,7 +195,7 @@ struct CharacterSelectEntry_Struct
|
||||
/*0000*/ uint8 Beard; //
|
||||
/*0001*/ uint8 HairColor; //
|
||||
/*0000*/ uint8 Face; //
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::TextureCount];
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::materialCount];
|
||||
/*0000*/ uint32 PrimaryIDFile; //
|
||||
/*0000*/ uint32 SecondaryIDFile; //
|
||||
/*0000*/ uint8 Unknown15; // 0xff
|
||||
@@ -1666,7 +1666,7 @@ struct LootingItem_Struct {
|
||||
/*000*/ uint32 lootee;
|
||||
/*004*/ uint32 looter;
|
||||
/*008*/ uint32 slot_id;
|
||||
/*012*/ uint32 auto_loot;
|
||||
/*012*/ int32 auto_loot;
|
||||
/*016*/ uint32 unknown16;
|
||||
/*020*/
|
||||
};
|
||||
@@ -1970,7 +1970,7 @@ struct AdventureLeaderboard_Struct
|
||||
/*struct Item_Shop_Struct {
|
||||
uint16 merchantid;
|
||||
uint8 itemtype;
|
||||
ItemBase item;
|
||||
ItemData item;
|
||||
uint8 iss_unknown001[6];
|
||||
};*/
|
||||
|
||||
|
||||
+51
-22
@@ -29,7 +29,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../item_instance.h"
|
||||
#include "sof_structs.h"
|
||||
#include "../rulesys.h"
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SoF
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id, uint8 depth);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline uint32 ServerToSoFSlot(uint32 serverSlot);
|
||||
@@ -62,6 +62,9 @@ namespace SoF
|
||||
static inline CastingSlot ServerToSoFCastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot SoFToServerCastingSlot(CastingSlot slot, uint32 itemlocation);
|
||||
|
||||
static inline int ServerToSoFBuffSlot(int index);
|
||||
static inline int SoFToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
//create our opcode manager if we havent already
|
||||
@@ -297,7 +300,7 @@ namespace SoF
|
||||
OUT(buff.duration);
|
||||
OUT(buff.counters);
|
||||
OUT(buff.player_id);
|
||||
OUT(slotid);
|
||||
eq->slotid = ServerToSoFBuffSlot(emu->slotid);
|
||||
OUT(bufffade);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -378,7 +381,7 @@ namespace SoF
|
||||
ob.write((const char*)&item_count, sizeof(uint32));
|
||||
|
||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -857,7 +860,7 @@ namespace SoF
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -1230,7 +1233,7 @@ namespace SoF
|
||||
OUT(hairstyle);
|
||||
OUT(beard);
|
||||
// OUT(unknown00178[10]);
|
||||
for (r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++) {
|
||||
for (r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++) {
|
||||
eq->equipment.Slot[r].Material = emu->item_material.Slot[r].Material;
|
||||
eq->equipment.Slot[r].Unknown1 = 0;
|
||||
eq->equipment.Slot[r].EliteMaterial = 0;
|
||||
@@ -1670,10 +1673,10 @@ namespace SoF
|
||||
eq_cse->HairColor = emu_cse->HairColor;
|
||||
eq_cse->Face = emu_cse->Face;
|
||||
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::TextureCount; equip_index++) {
|
||||
for (int equip_index = EQEmu::textures::textureBegin; equip_index < EQEmu::textures::materialCount; equip_index++) {
|
||||
eq_cse->Equip[equip_index].Material = emu_cse->Equip[equip_index].Material;
|
||||
eq_cse->Equip[equip_index].Unknown1 = emu_cse->Equip[equip_index].Unknown1;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteMaterial;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteModel;
|
||||
eq_cse->Equip[equip_index].Color = emu_cse->Equip[equip_index].Color;
|
||||
}
|
||||
|
||||
@@ -2101,10 +2104,10 @@ namespace SoF
|
||||
eq->deity = emu->deity;
|
||||
eq->drakkin_heritage = emu->drakkin_heritage;
|
||||
eq->gender = emu->gender;
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
eq->equipment.Slot[k].Material = emu->equipment.Slot[k].Material;
|
||||
eq->equipment.Slot[k].Unknown1 = emu->equipment.Slot[k].Unknown1;
|
||||
eq->equipment.Slot[k].EliteMaterial = emu->equipment.Slot[k].EliteMaterial;
|
||||
eq->equipment.Slot[k].EliteMaterial = emu->equipment.Slot[k].EliteModel;
|
||||
eq->equipment_tint.Slot[k].Color = emu->equipment_tint.Slot[k].Color;
|
||||
}
|
||||
eq->StandState = emu->StandState;
|
||||
@@ -2167,7 +2170,7 @@ namespace SoF
|
||||
strcpy(eq->name, emu->name);
|
||||
eq->petOwnerId = emu->petOwnerId;
|
||||
eq->pvp = 0; // 0 = non-pvp colored name, 1 = red pvp name
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
eq->equipment_tint.Slot[k].Color = emu->equipment_tint.Slot[k].Color;
|
||||
}
|
||||
eq->anon = emu->anon;
|
||||
@@ -2375,7 +2378,7 @@ namespace SoF
|
||||
IN(buff.duration);
|
||||
IN(buff.counters);
|
||||
IN(buff.player_id);
|
||||
IN(slotid);
|
||||
emu->slotid = SoFToServerBuffSlot(eq->slotid);
|
||||
IN(bufffade);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2923,9 +2926,9 @@ namespace SoF
|
||||
return NextItemInstSerialNumber;
|
||||
}
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
|
||||
{
|
||||
const EQEmu::ItemBase *item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData *item = inst->GetUnscaledItem();
|
||||
|
||||
SoF::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@@ -3237,18 +3240,18 @@ namespace SoF
|
||||
|
||||
ob.write((const char*)&subitem_count, sizeof(uint32));
|
||||
|
||||
for (uint32 index = SUB_INDEX_BEGIN; index < EQEmu::legacy::ITEM_CONTAINER_SIZE; ++index) {
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
for (uint32 index = EQEmu::inventory::containerBegin; index < EQEmu::inventory::ContainerCount; ++index) {
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
int SubSlotNumber = INVALID_INDEX;
|
||||
if (slot_id_in >= EQEmu::legacy::GENERAL_BEGIN && slot_id_in <= EQEmu::legacy::GENERAL_END)
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + index + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::inventory::ContainerCount) + index + 1);
|
||||
else if (slot_id_in >= EQEmu::legacy::BANK_BEGIN && slot_id_in <= EQEmu::legacy::BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
else if (slot_id_in >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::legacy::SHARED_BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
else
|
||||
SubSlotNumber = slot_id_in;
|
||||
|
||||
@@ -3266,7 +3269,7 @@ namespace SoF
|
||||
{
|
||||
uint32 SoFSlot = 0;
|
||||
|
||||
if (serverSlot >= EQEmu::legacy::SlotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
if (serverSlot >= EQEmu::inventory::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
SoFSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END)
|
||||
SoFSlot = serverSlot + 11;
|
||||
@@ -3274,7 +3277,7 @@ namespace SoF
|
||||
SoFSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::legacy::SHARED_BANK_BAGS_END)
|
||||
SoFSlot = serverSlot + 1;
|
||||
else if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
else if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
SoFSlot = invslot::PossessionsPowerSource;
|
||||
else
|
||||
SoFSlot = serverSlot;
|
||||
@@ -3301,7 +3304,7 @@ namespace SoF
|
||||
else if (sofSlot >= invbag::SharedBankBagsBegin && sofSlot <= invbag::SharedBankBagsEnd)
|
||||
ServerSlot = sofSlot - 1;
|
||||
else if (sofSlot == invslot::PossessionsPowerSource)
|
||||
ServerSlot = EQEmu::legacy::SlotPowerSource;
|
||||
ServerSlot = EQEmu::inventory::slotPowerSource;
|
||||
else
|
||||
ServerSlot = sofSlot;
|
||||
|
||||
@@ -3461,4 +3464,30 @@ namespace SoF
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ServerToSoFBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int SoFToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*SoF*/
|
||||
|
||||
@@ -295,6 +295,14 @@ namespace SoF
|
||||
|
||||
const size_t SayLinkBodySize = 50;
|
||||
|
||||
const int LongBuffs = 25;
|
||||
const int ShortBuffs = 15;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 60;
|
||||
const int PetBuffs = 30;
|
||||
const int MercBuffs = 0;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
|
||||
@@ -149,7 +149,7 @@ struct TintProfile
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -178,7 +178,7 @@ struct TextureProfile
|
||||
Texture_Struct Primary;
|
||||
Texture_Struct Secondary;
|
||||
};
|
||||
Texture_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Texture_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
|
||||
TextureProfile();
|
||||
@@ -195,7 +195,7 @@ struct CharacterSelectEntry_Struct
|
||||
/*0000*/ uint8 Beard; //
|
||||
/*0001*/ uint8 HairColor; //
|
||||
/*0000*/ uint8 Face; //
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::TextureCount];
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::materialCount];
|
||||
/*0000*/ uint32 PrimaryIDFile; //
|
||||
/*0000*/ uint32 SecondaryIDFile; //
|
||||
/*0000*/ uint8 Unknown15; // 0xff
|
||||
@@ -1648,7 +1648,7 @@ struct LootingItem_Struct {
|
||||
/*002*/ uint32 looter;
|
||||
/*004*/ uint16 slot_id;
|
||||
/*006*/ uint8 unknown3[2];
|
||||
/*008*/ uint32 auto_loot;
|
||||
/*008*/ int32 auto_loot;
|
||||
};
|
||||
|
||||
struct GuildManageStatus_Struct{
|
||||
|
||||
+45
-16
@@ -30,7 +30,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../item_instance.h"
|
||||
#include "titanium_structs.h"
|
||||
|
||||
#include <sstream>
|
||||
@@ -42,7 +42,7 @@ namespace Titanium
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline int16 ServerToTitaniumSlot(uint32 serverSlot);
|
||||
@@ -61,6 +61,9 @@ namespace Titanium
|
||||
static inline CastingSlot ServerToTitaniumCastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot TitaniumToServerCastingSlot(CastingSlot slot, uint32 itemlocation);
|
||||
|
||||
static inline int ServerToTitaniumBuffSlot(int index);
|
||||
static inline int TitaniumToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
auto Config = EQEmuConfig::get();
|
||||
@@ -270,7 +273,7 @@ namespace Titanium
|
||||
OUT(buff.duration);
|
||||
OUT(buff.counters);
|
||||
OUT(buff.player_id);
|
||||
OUT(slotid);
|
||||
eq->slotid = ServerToTitaniumBuffSlot(emu->slotid);
|
||||
OUT(bufffade);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -329,7 +332,7 @@ namespace Titanium
|
||||
EQEmu::OutBuffer::pos_type last_pos = ob.tellp();
|
||||
|
||||
for (int r = 0; r < itemcount; r++, eq++) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -815,7 +818,7 @@ namespace Titanium
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -981,7 +984,7 @@ namespace Titanium
|
||||
OUT(hairstyle);
|
||||
OUT(beard);
|
||||
// OUT(unknown00178[10]);
|
||||
for (r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++) {
|
||||
for (r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++) {
|
||||
OUT(item_material.Slot[r].Material);
|
||||
OUT(item_tint.Slot[r].Color);
|
||||
}
|
||||
@@ -1301,14 +1304,14 @@ namespace Titanium
|
||||
if (eq->Race[char_index] > 473)
|
||||
eq->Race[char_index] = 1;
|
||||
|
||||
for (int index = 0; index < EQEmu::textures::TextureCount; ++index) {
|
||||
for (int index = 0; index < EQEmu::textures::materialCount; ++index) {
|
||||
eq->CS_Colors[char_index].Slot[index].Color = emu_cse->Equip[index].Color;
|
||||
}
|
||||
|
||||
eq->BeardColor[char_index] = emu_cse->BeardColor;
|
||||
eq->HairStyle[char_index] = emu_cse->HairStyle;
|
||||
|
||||
for (int index = 0; index < EQEmu::textures::TextureCount; ++index) {
|
||||
for (int index = 0; index < EQEmu::textures::materialCount; ++index) {
|
||||
eq->Equip[char_index].Slot[index].Material = emu_cse->Equip[index].Material;
|
||||
}
|
||||
|
||||
@@ -1338,14 +1341,14 @@ namespace Titanium
|
||||
for (; char_index < 10; ++char_index) {
|
||||
eq->Race[char_index] = 0;
|
||||
|
||||
for (int index = 0; index < EQEmu::textures::TextureCount; ++index) {
|
||||
for (int index = 0; index < EQEmu::textures::materialCount; ++index) {
|
||||
eq->CS_Colors[char_index].Slot[index].Color = 0;
|
||||
}
|
||||
|
||||
eq->BeardColor[char_index] = 0;
|
||||
eq->HairStyle[char_index] = 0;
|
||||
|
||||
for (int index = 0; index < EQEmu::textures::TextureCount; ++index) {
|
||||
for (int index = 0; index < EQEmu::textures::materialCount; ++index) {
|
||||
eq->Equip[char_index].Slot[index].Material = 0;
|
||||
}
|
||||
|
||||
@@ -1677,7 +1680,7 @@ namespace Titanium
|
||||
eq->petOwnerId = emu->petOwnerId;
|
||||
eq->guildrank = emu->guildrank;
|
||||
// eq->unknown0194[3] = emu->unknown0194[3];
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
eq->equipment.Slot[k].Material = emu->equipment.Slot[k].Material;
|
||||
eq->equipment_tint.Slot[k].Color = emu->equipment_tint.Slot[k].Color;
|
||||
}
|
||||
@@ -1779,7 +1782,7 @@ namespace Titanium
|
||||
IN(buff.duration);
|
||||
IN(buff.counters);
|
||||
IN(buff.player_id);
|
||||
IN(slotid);
|
||||
emu->slotid = TitaniumToServerBuffSlot(eq->slotid);
|
||||
IN(bufffade);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2216,10 +2219,10 @@ namespace Titanium
|
||||
}
|
||||
|
||||
// file scope helper methods
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
|
||||
{
|
||||
const char* protection = "\\\\\\\\\\";
|
||||
const EQEmu::ItemBase* item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData* item = inst->GetUnscaledItem();
|
||||
|
||||
ob << StringFormat("%.*s%s", (depth ? (depth - 1) : 0), protection, (depth ? "\"" : "")); // For leading quotes (and protection) if a subitem;
|
||||
|
||||
@@ -2437,10 +2440,10 @@ namespace Titanium
|
||||
ob << StringFormat("%.*s\"", depth, protection); // Quotes (and protection, if needed) around static data
|
||||
|
||||
// Sub data
|
||||
for (int index = SUB_INDEX_BEGIN; index < invbag::ItemBagSize; ++index) {
|
||||
for (int index = EQEmu::inventory::containerBegin; index < invbag::ItemBagSize; ++index) {
|
||||
ob << '|';
|
||||
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
@@ -2632,4 +2635,30 @@ namespace Titanium
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ServerToTitaniumBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int TitaniumToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*Titanium*/
|
||||
|
||||
@@ -294,6 +294,14 @@ namespace Titanium
|
||||
|
||||
const size_t SayLinkBodySize = 45;
|
||||
|
||||
const int LongBuffs = 25;
|
||||
const int ShortBuffs = 12;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 60;
|
||||
const int PetBuffs = 30;
|
||||
const int MercBuffs = 0;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
|
||||
@@ -144,7 +144,7 @@ struct TintProfile {
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ struct TextureProfile
|
||||
Texture_Struct Primary;
|
||||
Texture_Struct Secondary;
|
||||
};
|
||||
Texture_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Texture_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
|
||||
TextureProfile();
|
||||
@@ -1420,7 +1420,7 @@ struct LootingItem_Struct {
|
||||
/*002*/ uint32 looter;
|
||||
/*004*/ uint16 slot_id;
|
||||
/*006*/ uint8 unknown3[2];
|
||||
/*008*/ uint32 auto_loot;
|
||||
/*008*/ int32 auto_loot;
|
||||
};
|
||||
|
||||
struct GuildManageStatus_Struct{
|
||||
|
||||
+57
-44
@@ -29,7 +29,7 @@
|
||||
#include "../eq_packet_structs.h"
|
||||
#include "../misc_functions.h"
|
||||
#include "../string_util.h"
|
||||
#include "../item.h"
|
||||
#include "../item_instance.h"
|
||||
#include "uf_structs.h"
|
||||
#include "../rulesys.h"
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace UF
|
||||
static OpcodeManager *opcodes = nullptr;
|
||||
static Strategy struct_strategy;
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id, uint8 depth);
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth);
|
||||
|
||||
// server to client inventory location converters
|
||||
static inline uint32 ServerToUFSlot(uint32 serverSlot);
|
||||
@@ -62,6 +62,9 @@ namespace UF
|
||||
static inline CastingSlot ServerToUFCastingSlot(EQEmu::CastingSlot slot);
|
||||
static inline EQEmu::CastingSlot UFToServerCastingSlot(CastingSlot slot);
|
||||
|
||||
static inline int ServerToUFBuffSlot(int index);
|
||||
static inline int UFToServerBuffSlot(int index);
|
||||
|
||||
void Register(EQStreamIdentifier &into)
|
||||
{
|
||||
//create our opcode manager if we havent already
|
||||
@@ -377,17 +380,8 @@ namespace UF
|
||||
OUT(buff.spellid);
|
||||
OUT(buff.duration);
|
||||
OUT(buff.num_hits);
|
||||
uint16 buffslot = emu->slotid;
|
||||
if (buffslot >= 25 && buffslot < 37)
|
||||
{
|
||||
buffslot += 5;
|
||||
}
|
||||
else if (buffslot >= 37)
|
||||
{
|
||||
buffslot += 14;
|
||||
}
|
||||
// TODO: implement slot_data stuff
|
||||
eq->slotid = buffslot;
|
||||
eq->slotid = ServerToUFBuffSlot(emu->slotid);
|
||||
OUT(bufffade); // Live (October 2011) sends a 2 rather than 0 when a buff is created, but it doesn't seem to matter.
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -407,17 +401,9 @@ namespace UF
|
||||
__packet->WriteUInt8(emu->all_buffs); // 1 = all buffs, 0 = 1 buff
|
||||
__packet->WriteUInt16(emu->count);
|
||||
|
||||
for (uint16 i = 0; i < emu->count; ++i)
|
||||
for (int i = 0; i < emu->count; ++i)
|
||||
{
|
||||
uint16 buffslot = emu->entries[i].buff_slot;
|
||||
if (emu->type == 0) { // only correct for self packets
|
||||
if (emu->entries[i].buff_slot >= 25 && emu->entries[i].buff_slot < 37)
|
||||
buffslot += 5;
|
||||
else if (emu->entries[i].buff_slot >= 37)
|
||||
buffslot += 14;
|
||||
}
|
||||
|
||||
__packet->WriteUInt32(buffslot);
|
||||
__packet->WriteUInt32(emu->type == 0 ? ServerToUFBuffSlot(emu->entries[i].buff_slot) : emu->entries[i].buff_slot);
|
||||
__packet->WriteUInt32(emu->entries[i].spell_id);
|
||||
__packet->WriteUInt32(emu->entries[i].tics_remaining);
|
||||
__packet->WriteUInt32(emu->entries[i].num_hits);
|
||||
@@ -541,7 +527,7 @@ namespace UF
|
||||
ob.write((const char*)&item_count, sizeof(uint32));
|
||||
|
||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||
SerializeItem(ob, (const ItemInst*)eq->inst, eq->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
|
||||
if (ob.tellp() == last_pos)
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
|
||||
@@ -1293,7 +1279,7 @@ namespace UF
|
||||
|
||||
ob.write((const char*)__emu_buffer, 4);
|
||||
|
||||
SerializeItem(ob, (const ItemInst*)int_struct->inst, int_struct->slot_id, 0);
|
||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
|
||||
if (ob.tellp() == last_pos) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
@@ -1817,7 +1803,7 @@ namespace UF
|
||||
OUT(hairstyle);
|
||||
OUT(beard);
|
||||
// OUT(unknown00178[10]);
|
||||
for (r = EQEmu::textures::TextureBegin; r < EQEmu::textures::TextureCount; r++) {
|
||||
for (r = EQEmu::textures::textureBegin; r < EQEmu::textures::materialCount; r++) {
|
||||
eq->equipment.Slot[r].Material = emu->item_material.Slot[r].Material;
|
||||
eq->equipment.Slot[r].Unknown1 = 0;
|
||||
eq->equipment.Slot[r].EliteMaterial = 0;
|
||||
@@ -2301,10 +2287,10 @@ namespace UF
|
||||
eq_cse->HairColor = emu_cse->HairColor;
|
||||
eq_cse->Face = emu_cse->Face;
|
||||
|
||||
for (int equip_index = 0; equip_index < EQEmu::textures::TextureCount; equip_index++) {
|
||||
for (int equip_index = EQEmu::textures::textureBegin; equip_index < EQEmu::textures::materialCount; equip_index++) {
|
||||
eq_cse->Equip[equip_index].Material = emu_cse->Equip[equip_index].Material;
|
||||
eq_cse->Equip[equip_index].Unknown1 = emu_cse->Equip[equip_index].Unknown1;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteMaterial;
|
||||
eq_cse->Equip[equip_index].EliteMaterial = emu_cse->Equip[equip_index].EliteModel;
|
||||
eq_cse->Equip[equip_index].Color = emu_cse->Equip[equip_index].Color;
|
||||
}
|
||||
|
||||
@@ -2869,7 +2855,7 @@ namespace UF
|
||||
float SpawnSize = emu->size;
|
||||
if (!((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522)))
|
||||
{
|
||||
PacketSize -= (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
PacketSize -= (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
|
||||
if (emu->size == 0)
|
||||
{
|
||||
@@ -3068,7 +3054,7 @@ namespace UF
|
||||
|
||||
if ((emu->NPC == 0) || (emu->race <= 12) || (emu->race == 128) || (emu->race == 130) || (emu->race == 330) || (emu->race == 522))
|
||||
{
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; ++k)
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; ++k)
|
||||
{
|
||||
{
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->equipment_tint.Slot[k].Color);
|
||||
@@ -3104,17 +3090,17 @@ namespace UF
|
||||
{
|
||||
structs::Texture_Struct *Equipment = (structs::Texture_Struct *)Buffer;
|
||||
|
||||
for (k = EQEmu::textures::TextureBegin; k < EQEmu::textures::TextureCount; k++) {
|
||||
for (k = EQEmu::textures::textureBegin; k < EQEmu::textures::materialCount; k++) {
|
||||
if (emu->equipment.Slot[k].Material > 99999) {
|
||||
Equipment[k].Material = 63;
|
||||
} else {
|
||||
Equipment[k].Material = emu->equipment.Slot[k].Material;
|
||||
}
|
||||
Equipment[k].Unknown1 = emu->equipment.Slot[k].Unknown1;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteMaterial;
|
||||
Equipment[k].EliteMaterial = emu->equipment.Slot[k].EliteModel;
|
||||
}
|
||||
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::TextureCount);
|
||||
Buffer += (sizeof(structs::Texture_Struct) * EQEmu::textures::materialCount);
|
||||
}
|
||||
if (strlen(emu->title))
|
||||
{
|
||||
@@ -3236,6 +3222,7 @@ namespace UF
|
||||
IN(buff.unknown003);
|
||||
IN(buff.spellid);
|
||||
IN(buff.duration);
|
||||
emu->slotid = UFToServerBuffSlot(eq->slotid);
|
||||
IN(slotid);
|
||||
IN(bufffade);
|
||||
|
||||
@@ -3249,7 +3236,7 @@ namespace UF
|
||||
DECODE_LENGTH_EXACT(structs::BuffRemoveRequest_Struct);
|
||||
SETUP_DIRECT_DECODE(BuffRemoveRequest_Struct, structs::BuffRemoveRequest_Struct);
|
||||
|
||||
emu->SlotID = (eq->SlotID < 30) ? eq->SlotID : (eq->SlotID - 5);
|
||||
emu->SlotID = UFToServerBuffSlot(eq->SlotID);
|
||||
|
||||
IN(EntityID);
|
||||
|
||||
@@ -3847,9 +3834,9 @@ namespace UF
|
||||
return NextItemInstSerialNumber;
|
||||
}
|
||||
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const ItemInst *inst, int16 slot_id_in, uint8 depth)
|
||||
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
|
||||
{
|
||||
const EQEmu::ItemBase *item = inst->GetUnscaledItem();
|
||||
const EQEmu::ItemData *item = inst->GetUnscaledItem();
|
||||
|
||||
UF::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@@ -3893,7 +3880,7 @@ namespace UF
|
||||
int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
|
||||
uint16 ornaIcon = 0;
|
||||
if (inst->GetOrnamentationAug(ornamentationAugtype)) {
|
||||
const EQEmu::ItemBase *aug_weap = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem();
|
||||
const EQEmu::ItemData *aug_weap = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem();
|
||||
ornaIcon = aug_weap->Icon;
|
||||
|
||||
ob.write(aug_weap->IDFile, strlen(aug_weap->IDFile));
|
||||
@@ -4224,18 +4211,18 @@ namespace UF
|
||||
|
||||
ob.write((const char*)&subitem_count, sizeof(uint32));
|
||||
|
||||
for (uint32 index = SUB_INDEX_BEGIN; index < EQEmu::legacy::ITEM_CONTAINER_SIZE; ++index) {
|
||||
ItemInst* sub = inst->GetItem(index);
|
||||
for (uint32 index = EQEmu::inventory::containerBegin; index < EQEmu::inventory::ContainerCount; ++index) {
|
||||
EQEmu::ItemInstance* sub = inst->GetItem(index);
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
int SubSlotNumber = INVALID_INDEX;
|
||||
if (slot_id_in >= EQEmu::legacy::GENERAL_BEGIN && slot_id_in <= EQEmu::legacy::GENERAL_END)
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + index + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EQEmu::inventory::ContainerCount) + index + 1);
|
||||
else if (slot_id_in >= EQEmu::legacy::BANK_BEGIN && slot_id_in <= EQEmu::legacy::BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::BANK_BAGS_BEGIN + index);
|
||||
else if (slot_id_in >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::legacy::SHARED_BANK_END)
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::legacy::ITEM_CONTAINER_SIZE) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
SubSlotNumber = (((slot_id_in - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount) + EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + index);
|
||||
else
|
||||
SubSlotNumber = slot_id_in;
|
||||
|
||||
@@ -4253,7 +4240,7 @@ namespace UF
|
||||
{
|
||||
uint32 UnderfootSlot = 0;
|
||||
|
||||
if (serverSlot >= EQEmu::legacy::SlotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
if (serverSlot >= EQEmu::inventory::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
UnderfootSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::legacy::CURSOR_BAG_END)
|
||||
UnderfootSlot = serverSlot + 11;
|
||||
@@ -4261,7 +4248,7 @@ namespace UF
|
||||
UnderfootSlot = serverSlot + 1;
|
||||
else if (serverSlot >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::legacy::SHARED_BANK_BAGS_END)
|
||||
UnderfootSlot = serverSlot + 1;
|
||||
else if (serverSlot == EQEmu::legacy::SlotPowerSource)
|
||||
else if (serverSlot == EQEmu::inventory::slotPowerSource)
|
||||
UnderfootSlot = invslot::PossessionsPowerSource;
|
||||
else
|
||||
UnderfootSlot = serverSlot;
|
||||
@@ -4288,7 +4275,7 @@ namespace UF
|
||||
else if (ufSlot >= invbag::SharedBankBagsBegin && ufSlot <= invbag::SharedBankBagsEnd)
|
||||
ServerSlot = ufSlot - 1;
|
||||
else if (ufSlot == invslot::PossessionsPowerSource)
|
||||
ServerSlot = EQEmu::legacy::SlotPowerSource;
|
||||
ServerSlot = EQEmu::inventory::slotPowerSource;
|
||||
else
|
||||
ServerSlot = ufSlot;
|
||||
|
||||
@@ -4453,4 +4440,30 @@ namespace UF
|
||||
return EQEmu::CastingSlot::Discipline;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ServerToUFBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= EQEmu::constants::LongBuffs + EQEmu::constants::ShortBuffs)
|
||||
return index - EQEmu::constants::LongBuffs - EQEmu::constants::ShortBuffs +
|
||||
constants::LongBuffs + constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= EQEmu::constants::LongBuffs)
|
||||
return index - EQEmu::constants::LongBuffs + constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
|
||||
static inline int UFToServerBuffSlot(int index)
|
||||
{
|
||||
// we're a disc
|
||||
if (index >= constants::LongBuffs + constants::ShortBuffs)
|
||||
return index - constants::LongBuffs - constants::ShortBuffs + EQEmu::constants::LongBuffs +
|
||||
EQEmu::constants::ShortBuffs;
|
||||
// we're a song
|
||||
if (index >= constants::LongBuffs)
|
||||
return index - constants::LongBuffs + EQEmu::constants::LongBuffs;
|
||||
// we're a normal buff
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*UF*/
|
||||
|
||||
+24
-16
@@ -64,7 +64,7 @@ namespace UF
|
||||
InvTypeOther,
|
||||
InvTypeCount
|
||||
};
|
||||
|
||||
|
||||
} /*invtype*/
|
||||
|
||||
namespace invslot {
|
||||
@@ -115,21 +115,21 @@ namespace UF
|
||||
const int GeneralBegin = PossessionsGeneral1;
|
||||
const int GeneralEnd = PossessionsGeneral8;
|
||||
const int GeneralCount = (GeneralEnd - GeneralBegin + 1);
|
||||
|
||||
|
||||
} /*invslot*/
|
||||
|
||||
namespace invbag {
|
||||
inline EQEmu::versions::ClientVersion GetInvBagRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
enum : int { InvBagInvalid = -1, InvBagBegin };
|
||||
|
||||
|
||||
} /*invbag*/
|
||||
|
||||
namespace invaug {
|
||||
inline EQEmu::versions::ClientVersion GetInvAugRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
enum : int { InvAugInvalid = -1, InvAugBegin };
|
||||
|
||||
|
||||
} /*invaug*/
|
||||
|
||||
namespace item {
|
||||
@@ -148,27 +148,27 @@ namespace UF
|
||||
ItemPacketCharmUpdate = 110,
|
||||
ItemPacket11 = 111
|
||||
};
|
||||
|
||||
|
||||
} /*item*/
|
||||
|
||||
namespace profile {
|
||||
inline EQEmu::versions::ClientVersion GetProfileRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
|
||||
} /*profile*/
|
||||
|
||||
namespace constants {
|
||||
inline EQEmu::versions::ClientVersion GetConstantsRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
inline EQEmu::versions::ClientVersion GetBehaviorRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
|
||||
} /*behavior*/
|
||||
|
||||
namespace skills {
|
||||
inline EQEmu::versions::ClientVersion GetSkillsRef() { return EQEmu::versions::ClientVersion::UF; }
|
||||
|
||||
|
||||
} /*skills*/
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace UF
|
||||
extern const char* GetInvTypeName(int inv_type);
|
||||
|
||||
extern bool IsInvTypePersistent(int inv_type);
|
||||
|
||||
|
||||
} /*invtype*/
|
||||
|
||||
namespace invslot {
|
||||
@@ -237,7 +237,7 @@ namespace UF
|
||||
extern const char* GetInvPossessionsSlotName(int inv_slot);
|
||||
extern const char* GetInvCorpseSlotName(int inv_slot);
|
||||
extern const char* GetInvSlotName(int inv_type, int inv_slot);
|
||||
|
||||
|
||||
} /*invslot*/
|
||||
|
||||
namespace invbag {
|
||||
@@ -264,7 +264,7 @@ namespace UF
|
||||
const int TradeBagsEnd = (TradeBagsBegin + TradeBagsSize) - 1;
|
||||
|
||||
extern const char* GetInvBagIndexName(int bag_index);
|
||||
|
||||
|
||||
} /*invbag*/
|
||||
|
||||
namespace invaug {
|
||||
@@ -288,24 +288,32 @@ namespace UF
|
||||
const size_t PotionBeltSize = 5;
|
||||
|
||||
const size_t SkillArraySize = 100;
|
||||
|
||||
|
||||
} /*profile*/
|
||||
|
||||
namespace constants {
|
||||
const size_t CharacterCreationLimit = 12;
|
||||
|
||||
const size_t SayLinkBodySize = 50;
|
||||
|
||||
|
||||
const int LongBuffs = 30;
|
||||
const int ShortBuffs = 20;
|
||||
const int DiscBuffs = 1;
|
||||
const int TotalBuffs = LongBuffs + ShortBuffs + DiscBuffs;
|
||||
const int NPCBuffs = 85;
|
||||
const int PetBuffs = NPCBuffs;
|
||||
const int MercBuffs = LongBuffs;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace behavior {
|
||||
const bool CoinHasWeight = false;
|
||||
|
||||
|
||||
} /*behavior*/
|
||||
|
||||
namespace skills {
|
||||
const size_t LastUsableSkill = EQEmu::skills::SkillTripleAttack;
|
||||
|
||||
|
||||
} /*skills*/
|
||||
|
||||
}; /*UF*/
|
||||
|
||||
@@ -149,7 +149,7 @@ struct TintProfile
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Tint_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -178,7 +178,7 @@ struct TextureProfile
|
||||
Texture_Struct Primary;
|
||||
Texture_Struct Secondary;
|
||||
};
|
||||
Texture_Struct Slot[EQEmu::textures::TextureCount];
|
||||
Texture_Struct Slot[EQEmu::textures::materialCount];
|
||||
};
|
||||
|
||||
TextureProfile();
|
||||
@@ -195,7 +195,7 @@ struct CharacterSelectEntry_Struct
|
||||
/*0000*/ uint8 Beard; //
|
||||
/*0001*/ uint8 HairColor; //
|
||||
/*0000*/ uint8 Face; //
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::TextureCount];
|
||||
/*0000*/ CharSelectEquip Equip[EQEmu::textures::materialCount];
|
||||
/*0000*/ uint32 PrimaryIDFile; //
|
||||
/*0000*/ uint32 SecondaryIDFile; //
|
||||
/*0000*/ uint8 Unknown15; // 0xff
|
||||
@@ -1707,7 +1707,7 @@ struct LootingItem_Struct {
|
||||
/*000*/ uint32 lootee;
|
||||
/*004*/ uint32 looter;
|
||||
/*008*/ uint32 slot_id;
|
||||
/*012*/ uint32 auto_loot;
|
||||
/*012*/ int32 auto_loot;
|
||||
/*016*/ uint32 unknown16;
|
||||
/*020*/
|
||||
};
|
||||
@@ -2011,7 +2011,7 @@ struct AdventureLeaderboard_Struct
|
||||
/*struct Item_Shop_Struct {
|
||||
uint16 merchantid;
|
||||
uint8 itemtype;
|
||||
ItemBase item;
|
||||
ItemData item;
|
||||
uint8 iss_unknown001[6];
|
||||
};*/
|
||||
|
||||
|
||||
@@ -65,6 +65,15 @@ namespace EQEmu {
|
||||
return Real(0.0, 1.0) <= required;
|
||||
}
|
||||
|
||||
// same range as client's roll0
|
||||
// This is their main high level RNG function
|
||||
int Roll0(int max)
|
||||
{
|
||||
if (max - 1 > 0)
|
||||
return Int(0, max - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// std::shuffle requires a RNG engine passed to it, so lets provide a wrapper to use our engine
|
||||
template<typename RandomAccessIterator>
|
||||
void Shuffle(RandomAccessIterator first, RandomAccessIterator last)
|
||||
|
||||
+12
-7
@@ -55,6 +55,7 @@ RULE_REAL(Character, AAExpMultiplier, 0.5)
|
||||
RULE_REAL(Character, GroupExpMultiplier, 0.5)
|
||||
RULE_REAL(Character, RaidExpMultiplier, 0.2)
|
||||
RULE_BOOL(Character, UseXPConScaling, true)
|
||||
RULE_INT(Character, ShowExpValues, 0) //0 - normal, 1 - Show raw experience values, 2 - Show raw experience values AND percent.
|
||||
RULE_INT(Character, LightBlueModifier, 40)
|
||||
RULE_INT(Character, BlueModifier, 90)
|
||||
RULE_INT(Character, WhiteModifier, 100)
|
||||
@@ -146,7 +147,7 @@ RULE_BOOL(Character, EnableAvoidanceCap, false)
|
||||
RULE_INT(Character, AvoidanceCap, 750) // 750 Is a pretty good value, seen people dodge all attacks beyond 1,000 Avoidance
|
||||
RULE_BOOL(Character, AllowMQTarget, false) // Disables putting players in the 'hackers' list for targeting beyond the clip plane or attempting to target something untargetable
|
||||
RULE_BOOL(Character, UseOldBindWound, false) // Uses the original bind wound behavior
|
||||
|
||||
RULE_BOOL(Character, GrantHoTTOnCreate, false) // Grant Health of Target's Target leadership AA on character creation
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Mercs)
|
||||
@@ -256,6 +257,7 @@ RULE_INT(Zone, WeatherTimer, 600) // Weather timer when no duration is available
|
||||
RULE_BOOL(Zone, EnableLoggedOffReplenishments, true)
|
||||
RULE_INT(Zone, MinOfflineTimeToReplenishments, 21600) // 21600 seconds is 6 Hours
|
||||
RULE_BOOL(Zone, UseZoneController, true) // Enables the ability to use persistent quest based zone controllers (zone_controller.pl/lua)
|
||||
RULE_BOOL(Zone, EnableZoneControllerGlobals, false) // Enables the ability to use quest globals with the zone controller NPC
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Map)
|
||||
@@ -331,11 +333,11 @@ RULE_INT(Spells, SacrificeMinLevel, 46) //first level Sacrifice will work on
|
||||
RULE_INT(Spells, SacrificeMaxLevel, 69) //last level Sacrifice will work on
|
||||
RULE_INT(Spells, SacrificeItemID, 9963) //Item ID of the item Sacrifice will return (defaults to an EE)
|
||||
RULE_BOOL(Spells, EnableSpellGlobals, false) // If Enabled, spells check the spell_globals table and compare character data from the quest globals before allowing that spell to scribe with scribespells
|
||||
RULE_INT(Spells, MaxBuffSlotsNPC, 25)
|
||||
RULE_INT(Spells, MaxSongSlotsNPC, 10)
|
||||
RULE_INT(Spells, MaxDiscSlotsNPC, 1)
|
||||
RULE_INT(Spells, MaxTotalSlotsNPC, 36)
|
||||
RULE_INT(Spells, MaxTotalSlotsPET, 30) // do not set this higher than 25 until the player profile is removed from the blob
|
||||
RULE_INT(Spells, MaxBuffSlotsNPC, 60) // default to Tit's limit
|
||||
RULE_INT(Spells, MaxSongSlotsNPC, 0) // NPCs don't have songs ...
|
||||
RULE_INT(Spells, MaxDiscSlotsNPC, 0) // NPCs don't have discs ...
|
||||
RULE_INT(Spells, MaxTotalSlotsNPC, 60) // default to Tit's limit
|
||||
RULE_INT(Spells, MaxTotalSlotsPET, 30) // default to Tit's limit
|
||||
RULE_BOOL (Spells, EnableBlockedBuffs, true)
|
||||
RULE_INT(Spells, ReflectType, 1) //0 = disabled, 1 = single target player spells only, 2 = all player spells, 3 = all single target spells, 4 = all spells
|
||||
RULE_INT(Spells, VirusSpreadDistance, 30) // The distance a viral spell will jump to its next victim
|
||||
@@ -489,6 +491,8 @@ RULE_BOOL(Combat, UseLiveCombatRounds, true) // turn this false if you don't wan
|
||||
RULE_INT(Combat, NPCAssistCap, 5) // Maxiumium number of NPCs that will assist another NPC at once
|
||||
RULE_INT(Combat, NPCAssistCapTimer, 6000) // Time in milliseconds a NPC will take to clear assist aggro cap space
|
||||
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_INT(Combat, LevelToStopDamageCaps, 0) // 1 will effectively disable them, 20 should give basically same results as old incorrect system
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(NPC)
|
||||
@@ -553,12 +557,13 @@ RULE_REAL(Bots, ManaRegen, 2.0) // Adjust mana regen for bots, 1 is fast and hig
|
||||
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 raid
|
||||
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 (bots are not raidable at this time)
|
||||
RULE_BOOL(Bots, BotGroupXP, false) // Determines whether client gets xp 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) // 0 as default (if level > this value you can spawn bots if BotCharacterLevelEnabled is true)
|
||||
RULE_INT(Bots, CasterStopMeleeLevel, 13) // Level at which caster bots stop melee attacks
|
||||
RULE_CATEGORY_END()
|
||||
#endif
|
||||
|
||||
|
||||
+4
-4
@@ -21,8 +21,8 @@
|
||||
#include "emu_constants.h"
|
||||
|
||||
#include "string_util.h"
|
||||
#include "item.h"
|
||||
#include "item_base.h"
|
||||
#include "item_instance.h"
|
||||
#include "item_data.h"
|
||||
#include "../zone/zonedb.h"
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void EQEmu::SayLinkEngine::generate_body()
|
||||
|
||||
memset(&m_LinkBodyStruct, 0, sizeof(SayLinkBody_Struct));
|
||||
|
||||
const EQEmu::ItemBase* item_data = nullptr;
|
||||
const EQEmu::ItemData* item_data = nullptr;
|
||||
|
||||
switch (m_LinkType) {
|
||||
case saylink::SayLinkBlank:
|
||||
@@ -250,7 +250,7 @@ void EQEmu::SayLinkEngine::generate_text()
|
||||
return;
|
||||
}
|
||||
|
||||
const EQEmu::ItemBase* item_data = nullptr;
|
||||
const EQEmu::ItemData* item_data = nullptr;
|
||||
|
||||
switch (m_LinkType) {
|
||||
case saylink::SayLinkBlank:
|
||||
|
||||
+6
-6
@@ -26,11 +26,11 @@
|
||||
|
||||
|
||||
struct ServerLootItem_Struct;
|
||||
class ItemInst;
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
struct ItemBase;
|
||||
struct ItemData;
|
||||
class ItemInstance;
|
||||
struct SayLinkBody_Struct;
|
||||
|
||||
namespace saylink {
|
||||
@@ -67,9 +67,9 @@ namespace EQEmu
|
||||
SayLinkEngine();
|
||||
|
||||
void SetLinkType(saylink::SayLinkType link_type) { m_LinkType = link_type; }
|
||||
void SetItemData(const EQEmu::ItemBase* item_data) { m_ItemData = item_data; }
|
||||
void SetItemData(const EQEmu::ItemData* item_data) { m_ItemData = item_data; }
|
||||
void SetLootData(const ServerLootItem_Struct* loot_data) { m_LootData = loot_data; }
|
||||
void SetItemInst(const ItemInst* item_inst) { m_ItemInst = item_inst; }
|
||||
void SetItemInst(const ItemInstance* item_inst) { m_ItemInst = item_inst; }
|
||||
|
||||
// mainly for saylinks..but, not limited to
|
||||
void SetProxyUnknown1(uint8 proxy_unknown_1) { m_Proxy_unknown_1 = proxy_unknown_1; }
|
||||
@@ -103,9 +103,9 @@ namespace EQEmu
|
||||
void generate_text();
|
||||
|
||||
int m_LinkType;
|
||||
const ItemBase* m_ItemData;
|
||||
const ItemData* m_ItemData;
|
||||
const ServerLootItem_Struct* m_LootData;
|
||||
const ItemInst* m_ItemInst;
|
||||
const ItemInstance* m_ItemInst;
|
||||
|
||||
uint8 m_Proxy_unknown_1;
|
||||
uint32 m_ProxyItemID;
|
||||
|
||||
+81
-69
@@ -29,7 +29,7 @@
|
||||
#include "faction.h"
|
||||
#include "features.h"
|
||||
#include "ipc_mutex.h"
|
||||
#include "item.h"
|
||||
#include "inventory_profile.h"
|
||||
#include "loottable.h"
|
||||
#include "memory_mapped_file.h"
|
||||
#include "mysql.h"
|
||||
@@ -38,6 +38,17 @@
|
||||
#include "string_util.h"
|
||||
#include "eqemu_config.h"
|
||||
|
||||
namespace ItemField
|
||||
{
|
||||
enum {
|
||||
source = 0,
|
||||
#define F(x) x,
|
||||
#include "item_fieldlist.h"
|
||||
#undef F
|
||||
updated
|
||||
};
|
||||
}
|
||||
|
||||
SharedDatabase::SharedDatabase()
|
||||
: Database()
|
||||
{
|
||||
@@ -99,13 +110,13 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
||||
return EntitledTime;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end)
|
||||
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<EQEmu::ItemInstance*>::const_iterator &start, std::list<EQEmu::ItemInstance*>::const_iterator &end)
|
||||
{
|
||||
// Delete cursor items
|
||||
std::string query = StringFormat("DELETE FROM inventory WHERE charid = %i "
|
||||
"AND ((slotid >= 8000 AND slotid <= 8999) "
|
||||
"OR slotid = %i OR (slotid >= %i AND slotid <= %i) )",
|
||||
char_id, EQEmu::legacy::SlotCursor,
|
||||
char_id, EQEmu::inventory::slotCursor,
|
||||
EQEmu::legacy::CURSOR_BAG_BEGIN, EQEmu::legacy::CURSOR_BAG_END);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@@ -116,8 +127,8 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
||||
int i = 8000;
|
||||
for(auto it = start; it != end; ++it, i++) {
|
||||
if (i > 8999) { break; } // shouldn't be anything in the queue that indexes this high
|
||||
ItemInst *inst = *it;
|
||||
int16 use_slot = (i == 8000) ? EQEmu::legacy::SlotCursor : i;
|
||||
EQEmu::ItemInstance *inst = *it;
|
||||
int16 use_slot = (i == 8000) ? EQEmu::inventory::slotCursor : i;
|
||||
if (!SaveInventory(char_id, inst, use_slot)) {
|
||||
return false;
|
||||
}
|
||||
@@ -126,7 +137,7 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const EQEmu::ItemInstance* inst)
|
||||
{
|
||||
// Delete cursor items
|
||||
std::string query = StringFormat("SELECT itemid, charges FROM sharedbank "
|
||||
@@ -159,7 +170,7 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||
bool SharedDatabase::SaveInventory(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id) {
|
||||
|
||||
//never save tribute slots:
|
||||
if (slot_id >= EQEmu::legacy::TRIBUTE_BEGIN && slot_id <= EQEmu::legacy::TRIBUTE_END)
|
||||
@@ -173,7 +184,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
else {
|
||||
// Needed to clear out bag slots that 'REPLACE' in UpdateSharedBankSlot does not overwrite..otherwise, duplication occurs
|
||||
// (This requires that parent then child items be sent..which should be how they are currently passed)
|
||||
if (Inventory::SupportsContainers(slot_id))
|
||||
if (EQEmu::InventoryProfile::SupportsContainers(slot_id))
|
||||
DeleteSharedBankSlot(char_id, slot_id);
|
||||
return UpdateSharedBankSlot(char_id, inst, slot_id);
|
||||
}
|
||||
@@ -184,18 +195,18 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
|
||||
// Needed to clear out bag slots that 'REPLACE' in UpdateInventorySlot does not overwrite..otherwise, duplication occurs
|
||||
// (This requires that parent then child items be sent..which should be how they are currently passed)
|
||||
if (Inventory::SupportsContainers(slot_id))
|
||||
if (EQEmu::InventoryProfile::SupportsContainers(slot_id))
|
||||
DeleteInventorySlot(char_id, slot_id);
|
||||
return UpdateInventorySlot(char_id, inst, slot_id);
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||
bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id) {
|
||||
// need to check 'inst' argument for valid pointer
|
||||
|
||||
uint32 augslot[EQEmu::legacy::ITEM_COMMON_SIZE] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint32 augslot[EQEmu::inventory::SocketCount] = { 0, 0, 0, 0, 0, 0 };
|
||||
if (inst->IsClassCommon()) {
|
||||
for (int i = AUG_INDEX_BEGIN; i < EQEmu::legacy::ITEM_COMMON_SIZE; i++) {
|
||||
ItemInst *auginst = inst->GetItem(i);
|
||||
for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) {
|
||||
EQEmu::ItemInstance *auginst = inst->GetItem(i);
|
||||
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
|
||||
}
|
||||
}
|
||||
@@ -221,12 +232,12 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst->IsClassBag() && Inventory::SupportsContainers(slot_id))
|
||||
if (inst->IsClassBag() && EQEmu::InventoryProfile::SupportsContainers(slot_id))
|
||||
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
|
||||
// messages through attrition (and the modded code in SaveInventory)
|
||||
for (uint8 idx = SUB_INDEX_BEGIN; idx < inst->GetItem()->BagSlots && idx < EQEmu::legacy::ITEM_CONTAINER_SIZE; idx++) {
|
||||
const ItemInst* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx));
|
||||
for (uint8 idx = EQEmu::inventory::containerBegin; idx < inst->GetItem()->BagSlots && idx < EQEmu::inventory::ContainerCount; idx++) {
|
||||
const EQEmu::ItemInstance* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, EQEmu::InventoryProfile::CalcSlotId(slot_id, idx));
|
||||
}
|
||||
|
||||
if (!results.Success()) {
|
||||
@@ -236,13 +247,13 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||
bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id) {
|
||||
// need to check 'inst' argument for valid pointer
|
||||
|
||||
uint32 augslot[EQEmu::legacy::ITEM_COMMON_SIZE] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint32 augslot[EQEmu::inventory::SocketCount] = { 0, 0, 0, 0, 0, 0 };
|
||||
if (inst->IsClassCommon()) {
|
||||
for (int i = AUG_INDEX_BEGIN; i < EQEmu::legacy::ITEM_COMMON_SIZE; i++) {
|
||||
ItemInst *auginst = inst->GetItem(i);
|
||||
for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) {
|
||||
EQEmu::ItemInstance *auginst = inst->GetItem(i);
|
||||
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
|
||||
}
|
||||
}
|
||||
@@ -267,12 +278,12 @@ bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst,
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst->IsClassBag() && Inventory::SupportsContainers(slot_id)) {
|
||||
if (inst->IsClassBag() && EQEmu::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
|
||||
// messages through attrition (and the modded code in SaveInventory)
|
||||
for (uint8 idx = SUB_INDEX_BEGIN; idx < inst->GetItem()->BagSlots && idx < EQEmu::legacy::ITEM_CONTAINER_SIZE; idx++) {
|
||||
const ItemInst* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx));
|
||||
for (uint8 idx = EQEmu::inventory::containerBegin; idx < inst->GetItem()->BagSlots && idx < EQEmu::inventory::ContainerCount; idx++) {
|
||||
const EQEmu::ItemInstance* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, EQEmu::InventoryProfile::CalcSlotId(slot_id, idx));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,10 +304,10 @@ bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) {
|
||||
}
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (!Inventory::SupportsContainers(slot_id))
|
||||
if (!EQEmu::InventoryProfile::SupportsContainers(slot_id))
|
||||
return true;
|
||||
|
||||
int16 base_slot_id = Inventory::CalcSlotId(slot_id, SUB_INDEX_BEGIN);
|
||||
int16 base_slot_id = EQEmu::InventoryProfile::CalcSlotId(slot_id, EQEmu::inventory::containerBegin);
|
||||
query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid >= %i AND slotid < %i",
|
||||
char_id, base_slot_id, (base_slot_id+10));
|
||||
results = QueryDatabase(query);
|
||||
@@ -319,10 +330,10 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
|
||||
}
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (!Inventory::SupportsContainers(slot_id))
|
||||
if (!EQEmu::InventoryProfile::SupportsContainers(slot_id))
|
||||
return true;
|
||||
|
||||
int16 base_slot_id = Inventory::CalcSlotId(slot_id, SUB_INDEX_BEGIN);
|
||||
int16 base_slot_id = EQEmu::InventoryProfile::CalcSlotId(slot_id, EQEmu::inventory::containerBegin);
|
||||
query = StringFormat("DELETE FROM sharedbank WHERE acctid = %i "
|
||||
"AND slotid >= %i AND slotid < %i",
|
||||
account_id, base_slot_id, (base_slot_id+10));
|
||||
@@ -362,9 +373,9 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) {
|
||||
bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) {
|
||||
|
||||
const EQEmu::ItemBase* myitem;
|
||||
const EQEmu::ItemData* myitem;
|
||||
|
||||
std::string query = StringFormat("SELECT itemid, item_charges, slot FROM starting_items "
|
||||
"WHERE (race = %i or race = 0) AND (class = %i or class = 0) AND "
|
||||
@@ -385,7 +396,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
|
||||
if(!myitem)
|
||||
continue;
|
||||
|
||||
ItemInst* myinst = CreateBaseItem(myitem, charges);
|
||||
EQEmu::ItemInstance* myinst = CreateBaseItem(myitem, charges);
|
||||
|
||||
if(slot < 0)
|
||||
slot = inv->FindFreeSlot(0, 0);
|
||||
@@ -399,7 +410,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
|
||||
|
||||
|
||||
// Retrieve shared bank inventory based on either account or character
|
||||
bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
|
||||
bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool is_charid)
|
||||
{
|
||||
std::string query;
|
||||
|
||||
@@ -428,7 +439,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
|
||||
uint32 item_id = (uint32)atoi(row[1]);
|
||||
int8 charges = (int8)atoi(row[2]);
|
||||
|
||||
uint32 aug[EQEmu::legacy::ITEM_COMMON_SIZE];
|
||||
uint32 aug[EQEmu::inventory::SocketCount];
|
||||
aug[0] = (uint32)atoi(row[3]);
|
||||
aug[1] = (uint32)atoi(row[4]);
|
||||
aug[2] = (uint32)atoi(row[5]);
|
||||
@@ -436,7 +447,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
|
||||
aug[4] = (uint32)atoi(row[7]);
|
||||
aug[5] = (uint32)atoi(row[8]);
|
||||
|
||||
const EQEmu::ItemBase *item = GetItem(item_id);
|
||||
const EQEmu::ItemData *item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
Log.Out(Logs::General, Logs::Error,
|
||||
@@ -447,9 +458,9 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
|
||||
|
||||
int16 put_slot_id = INVALID_INDEX;
|
||||
|
||||
ItemInst *inst = CreateBaseItem(item, charges);
|
||||
EQEmu::ItemInstance *inst = CreateBaseItem(item, charges);
|
||||
if (inst && item->IsClassCommon()) {
|
||||
for (int i = AUG_INDEX_BEGIN; i < EQEmu::legacy::ITEM_COMMON_SIZE; i++) {
|
||||
for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) {
|
||||
if (aug[i])
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
@@ -500,7 +511,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
|
||||
}
|
||||
|
||||
// Overloaded: Retrieve character inventory based on character id
|
||||
bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
|
||||
{
|
||||
// Retrieve character inventory
|
||||
std::string query =
|
||||
@@ -524,7 +535,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
uint16 charges = atoi(row[2]);
|
||||
uint32 color = atoul(row[3]);
|
||||
|
||||
uint32 aug[EQEmu::legacy::ITEM_COMMON_SIZE];
|
||||
uint32 aug[EQEmu::inventory::SocketCount];
|
||||
|
||||
aug[0] = (uint32)atoul(row[4]);
|
||||
aug[1] = (uint32)atoul(row[5]);
|
||||
@@ -539,7 +550,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
uint32 ornament_idfile = (uint32)atoul(row[13]);
|
||||
uint32 ornament_hero_model = (uint32)atoul(row[14]);
|
||||
|
||||
const EQEmu::ItemBase *item = GetItem(item_id);
|
||||
const EQEmu::ItemData *item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
Log.Out(Logs::General, Logs::Error,
|
||||
@@ -550,7 +561,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
|
||||
int16 put_slot_id = INVALID_INDEX;
|
||||
|
||||
ItemInst *inst = CreateBaseItem(item, charges);
|
||||
EQEmu::ItemInstance *inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr)
|
||||
continue;
|
||||
@@ -583,11 +594,11 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(ornament_hero_model);
|
||||
inst->SetOrnamentHeroModel(item->HerosForgeModel);
|
||||
|
||||
if (instnodrop ||
|
||||
(((slot_id >= EQEmu::legacy::EQUIPMENT_BEGIN && slot_id <= EQEmu::legacy::EQUIPMENT_END) ||
|
||||
slot_id == EQEmu::legacy::SlotPowerSource) &&
|
||||
slot_id == EQEmu::inventory::slotPowerSource) &&
|
||||
inst->GetItem()->Attuneable))
|
||||
inst->SetAttuned(true);
|
||||
|
||||
@@ -609,7 +620,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
}
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
for (int i = AUG_INDEX_BEGIN; i < EQEmu::legacy::ITEM_COMMON_SIZE; i++) {
|
||||
for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) {
|
||||
if (aug[i])
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
@@ -642,7 +653,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
|
||||
}
|
||||
|
||||
// Overloaded: Retrieve character inventory based on account_id and character name
|
||||
bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
|
||||
bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::InventoryProfile *inv)
|
||||
{
|
||||
// Retrieve character inventory
|
||||
std::string query =
|
||||
@@ -666,7 +677,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
|
||||
int8 charges = atoi(row[2]);
|
||||
uint32 color = atoul(row[3]);
|
||||
|
||||
uint32 aug[EQEmu::legacy::ITEM_COMMON_SIZE];
|
||||
uint32 aug[EQEmu::inventory::SocketCount];
|
||||
aug[0] = (uint32)atoi(row[4]);
|
||||
aug[1] = (uint32)atoi(row[5]);
|
||||
aug[2] = (uint32)atoi(row[6]);
|
||||
@@ -679,12 +690,12 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
|
||||
uint32 ornament_idfile = (uint32)atoul(row[13]);
|
||||
uint32 ornament_hero_model = (uint32)atoul(row[14]);
|
||||
|
||||
const EQEmu::ItemBase *item = GetItem(item_id);
|
||||
const EQEmu::ItemData *item = GetItem(item_id);
|
||||
int16 put_slot_id = INVALID_INDEX;
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
ItemInst *inst = CreateBaseItem(item, charges);
|
||||
EQEmu::ItemInstance *inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr)
|
||||
continue;
|
||||
@@ -719,7 +730,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
|
||||
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(ornament_hero_model);
|
||||
inst->SetOrnamentHeroModel(item->HerosForgeModel);
|
||||
|
||||
if (color > 0)
|
||||
inst->SetColor(color);
|
||||
@@ -727,7 +738,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
|
||||
inst->SetCharges(charges);
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
for (int i = AUG_INDEX_BEGIN; i < EQEmu::legacy::ITEM_COMMON_SIZE; i++) {
|
||||
for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) {
|
||||
if (aug[i])
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
@@ -816,7 +827,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
|
||||
mutex.Lock();
|
||||
std::string file_name = Config->SharedMemDir + prefix + std::string("items");
|
||||
items_mmf = std::unique_ptr<EQEmu::MemoryMappedFile>(new EQEmu::MemoryMappedFile(file_name));
|
||||
items_hash = std::unique_ptr<EQEmu::FixedMemoryHashSet<EQEmu::ItemBase>>(new EQEmu::FixedMemoryHashSet<EQEmu::ItemBase>(reinterpret_cast<uint8*>(items_mmf->Get()), items_mmf->Size()));
|
||||
items_hash = std::unique_ptr<EQEmu::FixedMemoryHashSet<EQEmu::ItemData>>(new EQEmu::FixedMemoryHashSet<EQEmu::ItemData>(reinterpret_cast<uint8*>(items_mmf->Get()), items_mmf->Size()));
|
||||
mutex.Unlock();
|
||||
} catch(std::exception& ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error Loading Items: %s", ex.what());
|
||||
@@ -828,7 +839,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
|
||||
|
||||
void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id)
|
||||
{
|
||||
EQEmu::FixedMemoryHashSet<EQEmu::ItemBase> hash(reinterpret_cast<uint8 *>(data), size, items, max_item_id);
|
||||
EQEmu::FixedMemoryHashSet<EQEmu::ItemData> hash(reinterpret_cast<uint8 *>(data), size, items, max_item_id);
|
||||
|
||||
std::string ndbuffer;
|
||||
bool disableNoRent = false;
|
||||
@@ -856,7 +867,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::ItemBase item;
|
||||
EQEmu::ItemData item;
|
||||
|
||||
const std::string query = "SELECT source,"
|
||||
#define F(x) "`"#x"`,"
|
||||
@@ -869,7 +880,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
memset(&item, 0, sizeof(EQEmu::ItemBase));
|
||||
memset(&item, 0, sizeof(EQEmu::ItemData));
|
||||
|
||||
item.ItemClass = (uint8)atoi(row[ItemField::itemclass]);
|
||||
strcpy(item.Name, row[ItemField::name]);
|
||||
@@ -1086,7 +1097,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
}
|
||||
}
|
||||
|
||||
const EQEmu::ItemBase* SharedDatabase::GetItem(uint32 id) {
|
||||
const EQEmu::ItemData* SharedDatabase::GetItem(uint32 id) {
|
||||
if (id == 0)
|
||||
{
|
||||
return nullptr;
|
||||
@@ -1105,7 +1116,7 @@ const EQEmu::ItemBase* SharedDatabase::GetItem(uint32 id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const EQEmu::ItemBase* SharedDatabase::IterateItems(uint32* id) {
|
||||
const EQEmu::ItemData* SharedDatabase::IterateItems(uint32* id) {
|
||||
if(!items_hash || !id) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1250,18 +1261,18 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create appropriate ItemInst class
|
||||
ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
// Create appropriate EQEmu::ItemInstance class
|
||||
EQEmu::ItemInstance* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
{
|
||||
const EQEmu::ItemBase* item = nullptr;
|
||||
ItemInst* inst = nullptr;
|
||||
const EQEmu::ItemData* item = nullptr;
|
||||
EQEmu::ItemInstance* inst = nullptr;
|
||||
|
||||
item = GetItem(item_id);
|
||||
if (item) {
|
||||
inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1279,15 +1290,15 @@ ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1,
|
||||
}
|
||||
|
||||
|
||||
// Create appropriate ItemInst class
|
||||
ItemInst* SharedDatabase::CreateItem(const EQEmu::ItemBase* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
// Create appropriate EQEmu::ItemInstance class
|
||||
EQEmu::ItemInstance* SharedDatabase::CreateItem(const EQEmu::ItemData* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
{
|
||||
ItemInst* inst = nullptr;
|
||||
EQEmu::ItemInstance* inst = nullptr;
|
||||
if (item) {
|
||||
inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1304,8 +1315,8 @@ ItemInst* SharedDatabase::CreateItem(const EQEmu::ItemBase* item, int16 charges,
|
||||
return inst;
|
||||
}
|
||||
|
||||
ItemInst* SharedDatabase::CreateBaseItem(const EQEmu::ItemBase* item, int16 charges) {
|
||||
ItemInst* inst = nullptr;
|
||||
EQEmu::ItemInstance* SharedDatabase::CreateBaseItem(const EQEmu::ItemData* item, int16 charges) {
|
||||
EQEmu::ItemInstance* inst = nullptr;
|
||||
if (item) {
|
||||
// if maxcharges is -1 that means it is an unlimited use item.
|
||||
// set it to 1 charge so that it is usable on creation
|
||||
@@ -1315,10 +1326,10 @@ ItemInst* SharedDatabase::CreateBaseItem(const EQEmu::ItemBase* item, int16 char
|
||||
if(charges <= 0 && item->Stackable)
|
||||
charges = 1;
|
||||
|
||||
inst = new ItemInst(item, charges);
|
||||
inst = new EQEmu::ItemInstance(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateBaseItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateBaseItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1689,6 +1700,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
||||
sp[tempid].pvpresistcalc=atoi(row[178]);
|
||||
sp[tempid].pvpresistcap=atoi(row[179]);
|
||||
sp[tempid].spell_category=atoi(row[180]);
|
||||
sp[tempid].pcnpc_only_flag=atoi(row[183]);
|
||||
sp[tempid].cast_not_standing = atoi(row[184]) != 0;
|
||||
sp[tempid].can_mgb=atoi(row[185]);
|
||||
sp[tempid].dispel_flag = atoi(row[186]);
|
||||
|
||||
+19
-19
@@ -33,8 +33,6 @@
|
||||
#include <memory>
|
||||
|
||||
class EvolveInfo;
|
||||
class Inventory;
|
||||
class ItemInst;
|
||||
struct BaseDataStruct;
|
||||
struct InspectMessage_Struct;
|
||||
struct PlayerProfile_Struct;
|
||||
@@ -45,7 +43,9 @@ struct LootDrop_Struct;
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
struct ItemBase;
|
||||
struct ItemData;
|
||||
class ItemInstance;
|
||||
class InventoryProfile;
|
||||
class MemoryMappedFile;
|
||||
}
|
||||
|
||||
@@ -74,24 +74,24 @@ class SharedDatabase : public Database
|
||||
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
|
||||
|
||||
/*
|
||||
Character Inventory
|
||||
Character InventoryProfile
|
||||
*/
|
||||
bool SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end);
|
||||
bool SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id);
|
||||
bool SaveCursor(uint32 char_id, std::list<EQEmu::ItemInstance*>::const_iterator &start, std::list<EQEmu::ItemInstance*>::const_iterator &end);
|
||||
bool SaveInventory(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id);
|
||||
bool DeleteSharedBankSlot(uint32 char_id, int16 slot_id);
|
||||
bool DeleteInventorySlot(uint32 char_id, int16 slot_id);
|
||||
bool UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
|
||||
bool UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
|
||||
bool VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst);
|
||||
bool GetSharedBank(uint32 id, Inventory* inv, bool is_charid);
|
||||
bool UpdateInventorySlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id);
|
||||
bool UpdateSharedBankSlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id);
|
||||
bool VerifyInventory(uint32 account_id, int16 slot_id, const EQEmu::ItemInstance* inst);
|
||||
bool GetSharedBank(uint32 id, EQEmu::InventoryProfile* inv, bool is_charid);
|
||||
int32 GetSharedPlatinum(uint32 account_id);
|
||||
bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add);
|
||||
bool GetInventory(uint32 char_id, Inventory* inv);
|
||||
bool GetInventory(uint32 account_id, char* name, Inventory* inv);
|
||||
bool GetInventory(uint32 char_id, EQEmu::InventoryProfile* inv);
|
||||
bool GetInventory(uint32 account_id, char* name, EQEmu::InventoryProfile* inv);
|
||||
std::map<uint32, uint32> GetItemRecastTimestamps(uint32 char_id);
|
||||
uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type);
|
||||
void ClearOldRecastTimestamps(uint32 char_id);
|
||||
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
|
||||
bool SetStartingItems(PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
|
||||
|
||||
|
||||
std::string GetBook(const char *txtfile);
|
||||
@@ -99,9 +99,9 @@ class SharedDatabase : public Database
|
||||
/*
|
||||
Item Methods
|
||||
*/
|
||||
ItemInst* CreateItem(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateItem(const EQEmu::ItemBase* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateBaseItem(const EQEmu::ItemBase* item, int16 charges = 0);
|
||||
EQEmu::ItemInstance* CreateItem(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
EQEmu::ItemInstance* CreateItem(const EQEmu::ItemData* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
EQEmu::ItemInstance* CreateBaseItem(const EQEmu::ItemData* item, int16 charges = 0);
|
||||
|
||||
/*
|
||||
Shared Memory crap
|
||||
@@ -111,8 +111,8 @@ class SharedDatabase : public Database
|
||||
void GetItemsCount(int32 &item_count, uint32 &max_id);
|
||||
void LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id);
|
||||
bool LoadItems(const std::string &prefix);
|
||||
const EQEmu::ItemBase* IterateItems(uint32* id);
|
||||
const EQEmu::ItemBase* GetItem(uint32 id);
|
||||
const EQEmu::ItemData* IterateItems(uint32* id);
|
||||
const EQEmu::ItemData* GetItem(uint32 id);
|
||||
const EvolveInfo* GetEvolveInfo(uint32 loregroup);
|
||||
|
||||
//faction lists
|
||||
@@ -149,7 +149,7 @@ class SharedDatabase : public Database
|
||||
|
||||
std::unique_ptr<EQEmu::MemoryMappedFile> skill_caps_mmf;
|
||||
std::unique_ptr<EQEmu::MemoryMappedFile> items_mmf;
|
||||
std::unique_ptr<EQEmu::FixedMemoryHashSet<EQEmu::ItemBase>> items_hash;
|
||||
std::unique_ptr<EQEmu::FixedMemoryHashSet<EQEmu::ItemData>> items_hash;
|
||||
std::unique_ptr<EQEmu::MemoryMappedFile> faction_mmf;
|
||||
std::unique_ptr<EQEmu::FixedMemoryHashSet<NPCFactionList>> faction_hash;
|
||||
std::unique_ptr<EQEmu::MemoryMappedFile> loot_table_mmf;
|
||||
|
||||
@@ -124,6 +124,30 @@ bool EQEmu::skills::IsCastingSkill(SkillType skill)
|
||||
}
|
||||
}
|
||||
|
||||
int32 EQEmu::skills::GetBaseDamage(SkillType skill)
|
||||
{
|
||||
switch (skill) {
|
||||
case SkillBash:
|
||||
return 2;
|
||||
case SkillDragonPunch:
|
||||
return 12;
|
||||
case SkillEagleStrike:
|
||||
return 7;
|
||||
case SkillFlyingKick:
|
||||
return 25;
|
||||
case SkillKick:
|
||||
return 3;
|
||||
case SkillRoundKick:
|
||||
return 5;
|
||||
case SkillTigerClaw:
|
||||
return 4;
|
||||
case SkillFrenzy:
|
||||
return 10;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<EQEmu::skills::SkillType, std::string>& EQEmu::skills::GetSkillTypeMap()
|
||||
{
|
||||
/* VS2013 code
|
||||
|
||||
@@ -166,6 +166,7 @@ namespace EQEmu
|
||||
float GetSkillMeleePushForce(SkillType skill);
|
||||
bool IsBardInstrumentSkill(SkillType skill);
|
||||
bool IsCastingSkill(SkillType skill);
|
||||
int32 GetBaseDamage(SkillType skill);
|
||||
|
||||
extern const std::map<SkillType, std::string>& GetSkillTypeMap();
|
||||
|
||||
|
||||
+13
-2
@@ -409,8 +409,19 @@ bool IsPartialCapableSpell(uint16 spell_id)
|
||||
if (spells[spell_id].no_partial_resist)
|
||||
return false;
|
||||
|
||||
if (IsPureNukeSpell(spell_id))
|
||||
return true;
|
||||
// spell uses 600 (partial) scale if first effect is damage, else it uses 200 scale.
|
||||
// this includes DoTs. no_partial_resist excludes spells like necro snares
|
||||
for (int o = 0; o < EFFECT_COUNT; o++) {
|
||||
auto tid = spells[spell_id].effectid[o];
|
||||
|
||||
if (IsBlankSpellEffect(spell_id, o))
|
||||
continue;
|
||||
|
||||
if ((tid == SE_CurrentHPOnce || tid == SE_CurrentHP) && spells[spell_id].base[o] < 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+4
-4
@@ -485,7 +485,7 @@ typedef enum {
|
||||
#define SE_ManaAbsorbPercentDamage 329 // implemented
|
||||
#define SE_CriticalDamageMob 330 // implemented
|
||||
#define SE_Salvage 331 // implemented - chance to recover items that would be destroyed in failed tradeskill combine
|
||||
//#define SE_SummonToCorpse 332 // *not implemented AA - Call of the Wild (Druid/Shaman Res spell with no exp)
|
||||
#define SE_SummonToCorpse 332 // *not implemented AA - Call of the Wild (Druid/Shaman Res spell with no exp)
|
||||
#define SE_CastOnRuneFadeEffect 333 // implemented
|
||||
#define SE_BardAEDot 334 // implemented
|
||||
#define SE_BlockNextSpellFocus 335 // implemented - base1 chance to block next spell ie Puratus (8494)
|
||||
@@ -502,7 +502,7 @@ typedef enum {
|
||||
#define SE_HeadShotLevel 346 // implemented[AA] - HeadShot max level to kill
|
||||
#define SE_DoubleRangedAttack 347 // implemented - chance at an additional archery attack (consumes arrow)
|
||||
#define SE_LimitManaMin 348 // implemented
|
||||
#define SE_ShieldEquipHateMod 349 // implemented[AA] Increase melee hate when wearing a shield.
|
||||
#define SE_ShieldEquipDmgMod 349 // implemented[AA] Increase melee base damage (indirectly increasing hate) when wearing a shield.
|
||||
#define SE_ManaBurn 350 // implemented - Drains mana for damage/heal at a defined ratio up to a defined maximum amount of mana.
|
||||
//#define SE_PersistentEffect 351 // *not implemented. creates a trap/totem that casts a spell (spell id + base1?) when anything comes near it. can probably make a beacon for this
|
||||
//#define SE_IncreaseTrapCount 352 // *not implemented - looks to be some type of invulnerability? Test ITC (8755)
|
||||
@@ -519,7 +519,7 @@ typedef enum {
|
||||
#define SE_BandolierSlots 363 // *not implemented[AA] 'Battle Ready' expands the bandolier by one additional save slot per rank.
|
||||
#define SE_TripleAttackChance 364 // implemented
|
||||
#define SE_ProcOnSpellKillShot 365 // implemented - chance to trigger a spell on kill when the kill is caused by a specific spell with this effect in it (10470 Venin)
|
||||
#define SE_ShieldEquipDmgMod 366 // implemented[AA] Damage modifier to melee if shield equiped. (base1 = dmg mod , base2 = ?) ie Shield Specialist AA
|
||||
#define SE_GroupShielding 366 // *not implemented[AA] This gives you /shieldgroup
|
||||
#define SE_SetBodyType 367 // implemented - set body type of base1 so it can be affected by spells that are limited to that type (Plant, Animal, Undead, etc)
|
||||
//#define SE_FactionMod 368 // *not implemented - increases faction with base1 (faction id, live won't match up w/ ours) by base2
|
||||
#define SE_CorruptionCounter 369 // implemented
|
||||
@@ -735,7 +735,7 @@ struct SPDat_Spell_Struct
|
||||
/* 180 */ int spell_category; // -- GLOBAL_GROUP
|
||||
/* 181 */ //int pvp_duration; // buffdurationformula for PvP -- PVP_DURATION
|
||||
/* 182 */ //int pvp_duration_cap; // buffduration for PvP -- PVP_DURATION_CAP
|
||||
/* 183 */ //int pcnpc_only_flag; // valid values are 0, 1 = PCs (and mercs), and 2 = NPCs (and not mercs) -- PCNPC_ONLY_FLAG
|
||||
/* 183 */ int pcnpc_only_flag; // valid values are 0, 1 = PCs (and mercs), and 2 = NPCs (and not mercs) -- PCNPC_ONLY_FLAG
|
||||
/* 184 */ bool cast_not_standing; // this is checked in the client's EQ_Spell::IsCastWhileInvisSpell, this also blocks SE_InterruptCasting from affecting this spell -- CAST_NOT_STANDING
|
||||
/* 185 */ bool can_mgb; // 0=no, -1 or 1 = yes -- CAN_MGB
|
||||
/* 186 */ int dispel_flag; // -- NO_DISPELL
|
||||
|
||||
@@ -18,82 +18,3 @@
|
||||
*/
|
||||
|
||||
#include "textures.h"
|
||||
//#include "inventory_slot.h"
|
||||
|
||||
#include <string.h> // temp
|
||||
|
||||
|
||||
//int EQEmu::textures::ConvertEquipmentSlotToTextureSlot(int equipment_slot)
|
||||
//{
|
||||
// switch (equipment_slot) {
|
||||
// case inventory::PossessionsHead:
|
||||
// return textures::TextureHead;
|
||||
// case inventory::PossessionsChest:
|
||||
// return textures::TextureChest;
|
||||
// case inventory::PossessionsArms:
|
||||
// return textures::TextureArms;
|
||||
// case inventory::PossessionsWrist1:
|
||||
// return textures::TextureWrist;
|
||||
// case inventory::PossessionsHands:
|
||||
// return textures::TextureHands;
|
||||
// case inventory::PossessionsLegs:
|
||||
// return textures::TextureLegs;
|
||||
// case inventory::PossessionsFeet:
|
||||
// return textures::TextureFeet;
|
||||
// case inventory::PossessionsPrimary:
|
||||
// return textures::TexturePrimary;
|
||||
// case inventory::PossessionsSecondary:
|
||||
// return textures::TextureSecondary;
|
||||
// default:
|
||||
// return textures::TextureInvalid;
|
||||
// }
|
||||
//}
|
||||
|
||||
//int EQEmu::textures::ConvertEquipmentSlotToTextureSlot(const InventorySlot &equipment_slot)
|
||||
//{
|
||||
// if (equipment_slot.Type() != inventory::InvTypePossessions || equipment_slot.Bag() != inventory::InvBagInvalid || equipment_slot.Aug() != inventory::InvAugInvalid)
|
||||
// return textures::TextureInvalid;
|
||||
//
|
||||
// return ConvertEquipmentSlotToTextureSlot(equipment_slot.Slot());
|
||||
//}
|
||||
|
||||
//EQEmu::InventorySlot EQEmu::textures::ConvertTextureSlotToEquipmentSlot(int texture_slot)
|
||||
//{
|
||||
// switch (texture_slot) {
|
||||
// case textures::TextureHead:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsHead);
|
||||
// case textures::TextureChest:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsChest);
|
||||
// case textures::TextureArms:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsArms);
|
||||
// case textures::TextureWrist:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsWrist1);
|
||||
// case textures::TextureHands:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsHands);
|
||||
// case textures::TextureLegs:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsLegs);
|
||||
// case textures::TextureFeet:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsFeet);
|
||||
// case textures::TexturePrimary:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsPrimary);
|
||||
// case textures::TextureSecondary:
|
||||
// return EQEmu::InventorySlot(inventory::InvTypePossessions, inventory::PossessionsSecondary);
|
||||
// default:
|
||||
// return EQEmu::InventorySlot();
|
||||
// }
|
||||
//}
|
||||
|
||||
EQEmu::TextureProfile::TextureProfile()
|
||||
{
|
||||
memset(&Slot, 0, (sizeof(Texture_Struct) * textures::TextureCount));
|
||||
}
|
||||
|
||||
EQEmu::TextureShortProfile::TextureShortProfile()
|
||||
{
|
||||
memset(&Slot, 0, (sizeof(uint32) * textures::TextureCount));
|
||||
}
|
||||
|
||||
EQEmu::TintProfile::TintProfile()
|
||||
{
|
||||
memset(&Slot, 0, (sizeof(uint32) * textures::TextureCount));
|
||||
}
|
||||
|
||||
+81
-84
@@ -25,116 +25,113 @@
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
//class InventorySlot;
|
||||
|
||||
namespace textures {
|
||||
//enum : int { TextureInvalid = -1, TextureBegin };
|
||||
enum : uint8 { TextureInvalid = 255, TextureBegin = 0 };
|
||||
enum : int8 { textureInvalid = -1, textureBegin };
|
||||
|
||||
//enum TextureSlot : int {
|
||||
enum TextureSlot : uint8 {
|
||||
TextureHead = TextureBegin,
|
||||
TextureChest,
|
||||
TextureArms,
|
||||
TextureWrist,
|
||||
TextureHands,
|
||||
TextureLegs,
|
||||
TextureFeet,
|
||||
TexturePrimary,
|
||||
TextureSecondary,
|
||||
TextureCount
|
||||
enum TextureSlot : int8 {
|
||||
armorHead = textureBegin,
|
||||
armorChest,
|
||||
armorArms,
|
||||
armorWrist,
|
||||
armorHands,
|
||||
armorLegs,
|
||||
armorFeet,
|
||||
weaponPrimary,
|
||||
weaponSecondary,
|
||||
materialCount,
|
||||
materialInvalid = textureInvalid
|
||||
};
|
||||
|
||||
const int LastTexture = TextureSecondary;
|
||||
const int LastTintableTexture = TextureFeet;
|
||||
enum TintSlot : int8 {
|
||||
tintHead = textureBegin,
|
||||
tintChest,
|
||||
tintArms,
|
||||
tintWrist,
|
||||
tintHands,
|
||||
tintLegs,
|
||||
tintFeet,
|
||||
tintCount,
|
||||
tintInvalid = textureInvalid
|
||||
};
|
||||
|
||||
//extern int ConvertEquipmentSlotToTextureSlot(int equipment_slot);
|
||||
//extern int ConvertEquipmentSlotToTextureSlot(const InventorySlot &equipment_slot);
|
||||
//extern InventorySlot ConvertTextureSlotToEquipmentSlot(int texture_slot);
|
||||
const int8 LastTexture = weaponSecondary;
|
||||
const int8 LastTintableTexture = tintFeet;
|
||||
|
||||
struct Texture_Struct {
|
||||
uint32 Material;
|
||||
uint32 Unknown1;
|
||||
uint32 EliteModel;
|
||||
uint32 HerosForgeModel;
|
||||
uint32 Unknown2; // same as material?
|
||||
};
|
||||
|
||||
struct TextureMaterial_Struct {
|
||||
uint32 Material;
|
||||
};
|
||||
|
||||
struct Tint_Struct {
|
||||
union {
|
||||
struct {
|
||||
uint8 Blue;
|
||||
uint8 Green;
|
||||
uint8 Red;
|
||||
uint8 UseTint; // if there's a tint, this is FF
|
||||
};
|
||||
uint32 Color;
|
||||
};
|
||||
};
|
||||
|
||||
} /*textures*/
|
||||
|
||||
struct Texture_Struct {
|
||||
uint32 Material;
|
||||
uint32 Unknown1;
|
||||
uint32 EliteMaterial;
|
||||
uint32 HeroForgeModel;
|
||||
uint32 Material2; // Same as material?
|
||||
};
|
||||
|
||||
struct TextureProfile {
|
||||
union {
|
||||
struct {
|
||||
Texture_Struct Head;
|
||||
Texture_Struct Chest;
|
||||
Texture_Struct Arms;
|
||||
Texture_Struct Wrist;
|
||||
Texture_Struct Hands;
|
||||
Texture_Struct Legs;
|
||||
Texture_Struct Feet;
|
||||
Texture_Struct Primary;
|
||||
Texture_Struct Secondary;
|
||||
textures::Texture_Struct Head;
|
||||
textures::Texture_Struct Chest;
|
||||
textures::Texture_Struct Arms;
|
||||
textures::Texture_Struct Wrist;
|
||||
textures::Texture_Struct Hands;
|
||||
textures::Texture_Struct Legs;
|
||||
textures::Texture_Struct Feet;
|
||||
textures::Texture_Struct Primary;
|
||||
textures::Texture_Struct Secondary;
|
||||
};
|
||||
Texture_Struct Slot[textures::TextureCount];
|
||||
textures::Texture_Struct Slot[textures::materialCount];
|
||||
};
|
||||
|
||||
TextureProfile();
|
||||
};
|
||||
|
||||
struct TextureShort_Struct {
|
||||
uint32 Material;
|
||||
};
|
||||
|
||||
struct TextureShortProfile {
|
||||
struct TextureMaterialProfile {
|
||||
union {
|
||||
struct {
|
||||
TextureShort_Struct Head;
|
||||
TextureShort_Struct Chest;
|
||||
TextureShort_Struct Arms;
|
||||
TextureShort_Struct Wrist;
|
||||
TextureShort_Struct Hands;
|
||||
TextureShort_Struct Legs;
|
||||
TextureShort_Struct Feet;
|
||||
TextureShort_Struct Primary;
|
||||
TextureShort_Struct Secondary;
|
||||
textures::TextureMaterial_Struct Head;
|
||||
textures::TextureMaterial_Struct Chest;
|
||||
textures::TextureMaterial_Struct Arms;
|
||||
textures::TextureMaterial_Struct Wrist;
|
||||
textures::TextureMaterial_Struct Hands;
|
||||
textures::TextureMaterial_Struct Legs;
|
||||
textures::TextureMaterial_Struct Feet;
|
||||
textures::TextureMaterial_Struct Primary;
|
||||
textures::TextureMaterial_Struct Secondary;
|
||||
};
|
||||
TextureShort_Struct Slot[textures::TextureCount];
|
||||
textures::TextureMaterial_Struct Slot[textures::materialCount];
|
||||
};
|
||||
|
||||
TextureShortProfile();
|
||||
};
|
||||
|
||||
struct Tint_Struct {
|
||||
union {
|
||||
struct {
|
||||
uint8 Blue;
|
||||
uint8 Green;
|
||||
uint8 Red;
|
||||
uint8 UseTint; // if there's a tint this is FF
|
||||
};
|
||||
uint32 Color;
|
||||
};
|
||||
|
||||
//Tint_Struct();
|
||||
};
|
||||
|
||||
struct TintProfile {
|
||||
union {
|
||||
struct {
|
||||
Tint_Struct Head;
|
||||
Tint_Struct Chest;
|
||||
Tint_Struct Arms;
|
||||
Tint_Struct Wrist;
|
||||
Tint_Struct Hands;
|
||||
Tint_Struct Legs;
|
||||
Tint_Struct Feet;
|
||||
Tint_Struct Primary;
|
||||
Tint_Struct Secondary;
|
||||
textures::Tint_Struct Head;
|
||||
textures::Tint_Struct Chest;
|
||||
textures::Tint_Struct Arms;
|
||||
textures::Tint_Struct Wrist;
|
||||
textures::Tint_Struct Hands;
|
||||
textures::Tint_Struct Legs;
|
||||
textures::Tint_Struct Feet;
|
||||
textures::Tint_Struct Primary;
|
||||
textures::Tint_Struct Secondary;
|
||||
};
|
||||
Tint_Struct Slot[textures::TextureCount];
|
||||
textures::Tint_Struct Slot[textures::materialCount]; // materialCount is correct..but, {[weaponPrimary],[weaponSecondary]} are not tintable...
|
||||
};
|
||||
|
||||
TintProfile();
|
||||
};
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <streambuf>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Util {
|
||||
class MemoryBuffer : public std::streambuf
|
||||
{
|
||||
public:
|
||||
MemoryBuffer(char* base, size_t size) {
|
||||
setg(base, base, base + size);
|
||||
setp(base, base + size);
|
||||
}
|
||||
};
|
||||
|
||||
class MemoryStreamWriter : virtual MemoryBuffer, public std::ostream
|
||||
{
|
||||
public:
|
||||
MemoryStreamWriter(char* base, size_t size) : MemoryBuffer(base, size), std::ostream(static_cast<std::streambuf*>(this)) { }
|
||||
};
|
||||
|
||||
class MemoryStreamReader : virtual MemoryBuffer, public std::istream
|
||||
{
|
||||
public:
|
||||
MemoryStreamReader(char* base, size_t size) : MemoryBuffer(base, size), std::istream(static_cast<std::streambuf*>(this)) { }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
#include "uuid.h"
|
||||
|
||||
#include <core/logsys.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <objbase.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CFUUID.h>
|
||||
#endif
|
||||
|
||||
unsigned char hexDigitToChar(char ch)
|
||||
{
|
||||
if (ch > 47 && ch < 58)
|
||||
return ch - 48;
|
||||
|
||||
if (ch > 96 && ch < 103)
|
||||
return ch - 87;
|
||||
|
||||
if (ch > 64 && ch < 71)
|
||||
return ch - 55;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char hexPairToChar(char a, char b)
|
||||
{
|
||||
return hexDigitToChar(a) * 16 + hexDigitToChar(b);
|
||||
}
|
||||
|
||||
EQ::Util::UUID::UUID()
|
||||
{
|
||||
m_bytes = std::vector<char>(16, 0);
|
||||
}
|
||||
|
||||
EQ::Util::UUID::UUID(const unsigned char *bytes)
|
||||
{
|
||||
m_bytes.assign(bytes, bytes + 16);
|
||||
}
|
||||
|
||||
EQ::Util::UUID::UUID(const UUID &o)
|
||||
{
|
||||
m_bytes = o.m_bytes;
|
||||
}
|
||||
|
||||
EQ::Util::UUID::UUID(UUID &&o)
|
||||
{
|
||||
std::swap(m_bytes, o.m_bytes);
|
||||
}
|
||||
|
||||
EQ::Util::UUID& EQ::Util::UUID::operator=(const UUID &o)
|
||||
{
|
||||
m_bytes = o.m_bytes;
|
||||
return *this;
|
||||
}
|
||||
|
||||
EQ::Util::UUID::~UUID()
|
||||
{
|
||||
}
|
||||
|
||||
EQ::Util::UUID EQ::Util::UUID::Generate()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
GUID id;
|
||||
CoCreateGuid(&id);
|
||||
|
||||
const unsigned char buffer[16] =
|
||||
{
|
||||
static_cast<unsigned char>((id.Data1 >> 24) & 0xFF),
|
||||
static_cast<unsigned char>((id.Data1 >> 16) & 0xFF),
|
||||
static_cast<unsigned char>((id.Data1 >> 8) & 0xFF),
|
||||
static_cast<unsigned char>((id.Data1) & 0xff),
|
||||
static_cast<unsigned char>((id.Data2 >> 8) & 0xFF),
|
||||
static_cast<unsigned char>((id.Data2) & 0xff),
|
||||
static_cast<unsigned char>((id.Data3 >> 8) & 0xFF),
|
||||
static_cast<unsigned char>((id.Data3) & 0xFF),
|
||||
id.Data4[0],
|
||||
id.Data4[1],
|
||||
id.Data4[2],
|
||||
id.Data4[3],
|
||||
id.Data4[4],
|
||||
id.Data4[5],
|
||||
id.Data4[6],
|
||||
id.Data4[7]
|
||||
};
|
||||
|
||||
return buffer;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
uuid_t id;
|
||||
uuid_generate(id);
|
||||
return id;
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
auto id = CFUUIDCreate(nullptr);
|
||||
auto bytes = CFUUIDGetUUIDBytes(id);
|
||||
|
||||
const unsigned char buffer[16] =
|
||||
{
|
||||
bytes.byte0,
|
||||
bytes.byte1,
|
||||
bytes.byte2,
|
||||
bytes.byte3,
|
||||
bytes.byte4,
|
||||
bytes.byte5,
|
||||
bytes.byte6,
|
||||
bytes.byte7,
|
||||
bytes.byte8,
|
||||
bytes.byte9,
|
||||
bytes.byte10,
|
||||
bytes.byte11,
|
||||
bytes.byte12,
|
||||
bytes.byte13,
|
||||
bytes.byte14,
|
||||
bytes.byte15
|
||||
};
|
||||
|
||||
CFRelease(id);
|
||||
|
||||
return buffer;
|
||||
#endif
|
||||
}
|
||||
|
||||
EQ::Util::UUID EQ::Util::UUID::FromString(const std::string &str)
|
||||
{
|
||||
UUID ret;
|
||||
ret.m_bytes.clear();
|
||||
|
||||
size_t i = 0;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
ret.m_bytes.push_back(hexPairToChar(str[i], str[i + 1])); ++i;
|
||||
return ret;
|
||||
}
|
||||
|
||||
EQ::Util::UUID EQ::Util::UUID::FromByteArray(const char *buffer)
|
||||
{
|
||||
return UUID((unsigned char*)buffer);
|
||||
}
|
||||
|
||||
std::string EQ::Util::UUID::ToString() const
|
||||
{
|
||||
return fmt::format("{:0<2x}{:0<2x}{:0<2x}{:0<2x}-{:0<2x}{:0<2x}-{:0<2x}{:0<2x}-{:0<2x}{:0<2x}-{:0<2x}{:0<2x}{:0<2x}{:0<2x}{:0<2x}{:0<2x}",
|
||||
(unsigned char)m_bytes[0],
|
||||
(unsigned char)m_bytes[1],
|
||||
(unsigned char)m_bytes[2],
|
||||
(unsigned char)m_bytes[3],
|
||||
(unsigned char)m_bytes[4],
|
||||
(unsigned char)m_bytes[5],
|
||||
(unsigned char)m_bytes[6],
|
||||
(unsigned char)m_bytes[7],
|
||||
(unsigned char)m_bytes[8],
|
||||
(unsigned char)m_bytes[9],
|
||||
(unsigned char)m_bytes[10],
|
||||
(unsigned char)m_bytes[11],
|
||||
(unsigned char)m_bytes[12],
|
||||
(unsigned char)m_bytes[13],
|
||||
(unsigned char)m_bytes[14],
|
||||
(unsigned char)m_bytes[15]);
|
||||
}
|
||||
|
||||
const std::vector<char>& EQ::Util::UUID::ToByteArray() const
|
||||
{
|
||||
return m_bytes;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ios>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace Util
|
||||
{
|
||||
class UUID
|
||||
{
|
||||
public:
|
||||
UUID(const UUID &o);
|
||||
UUID(UUID &&o);
|
||||
UUID& operator=(const UUID &o);
|
||||
~UUID();
|
||||
|
||||
static UUID Generate();
|
||||
static UUID FromString(const std::string &str);
|
||||
static UUID FromByteArray(const char *buffer);
|
||||
|
||||
std::string ToString() const;
|
||||
const std::vector<char>& ToByteArray() const;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &os, const UUID &id) {
|
||||
return os << id.ToString();
|
||||
}
|
||||
private:
|
||||
UUID();
|
||||
UUID(const unsigned char *bytes);
|
||||
std::vector<char> m_bytes;
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9100
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9101
|
||||
#ifdef BOTS
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9008
|
||||
#else
|
||||
|
||||
@@ -13,7 +13,7 @@ SET(eqlaunch_headers
|
||||
|
||||
ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers})
|
||||
|
||||
INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
TARGET_LINK_LIBRARIES(eqlaunch common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||
|
||||
@@ -34,6 +34,7 @@ IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(eqlaunch "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(eqlaunch "pthread")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_SUBDIRECTORY(luabind)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
ADD_SUBDIRECTORY(libuv)
|
||||
ADD_SUBDIRECTORY(format)
|
||||
@@ -1,427 +0,0 @@
|
||||
/*! \file access.hpp
|
||||
\brief Access control, default construction, and serialization disambiguation */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ACCESS_HPP_
|
||||
#define CEREAL_ACCESS_HPP_
|
||||
|
||||
#include <type_traits>
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
|
||||
#include <cereal/macros.hpp>
|
||||
#include <cereal/details/helpers.hpp>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
// ######################################################################
|
||||
//! A class that allows cereal to load smart pointers to types that have no default constructor
|
||||
/*! If your class does not have a default constructor, cereal will not be able
|
||||
to load any smart pointers to it unless you overload LoadAndConstruct
|
||||
for your class, and provide an appropriate load_and_construct method. You can also
|
||||
choose to define a member static function instead of specializing this class.
|
||||
|
||||
The specialization of LoadAndConstruct must be placed within the cereal namespace:
|
||||
|
||||
@code{.cpp}
|
||||
struct MyType
|
||||
{
|
||||
MyType( int x ); // note: no default ctor
|
||||
int myX;
|
||||
|
||||
// Define a serialize or load/save pair as you normally would
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{
|
||||
ar( myX );
|
||||
}
|
||||
};
|
||||
|
||||
// Provide a specialization for LoadAndConstruct for your type
|
||||
namespace cereal
|
||||
{
|
||||
template <> struct LoadAndConstruct<MyType>
|
||||
{
|
||||
// load_and_construct will be passed the archive that you will be loading
|
||||
// from as well as a construct object which you can use as if it were the
|
||||
// constructor for your type. cereal will handle all memory management for you.
|
||||
template <class Archive>
|
||||
static void load_and_construct( Archive & ar, cereal::construct<MyType> & construct )
|
||||
{
|
||||
int x;
|
||||
ar( x );
|
||||
construct( x );
|
||||
}
|
||||
};
|
||||
} // end namespace cereal
|
||||
@endcode
|
||||
|
||||
Please note that just as in using external serialization functions, you cannot get
|
||||
access to non-public members of your class by befriending cereal::access. If you
|
||||
have the ability to modify the class you wish to serialize, it is recommended that you
|
||||
use member serialize functions and a static member load_and_construct function.
|
||||
|
||||
@tparam T The type to specialize for
|
||||
@ingroup Access */
|
||||
template <class T>
|
||||
struct LoadAndConstruct
|
||||
{
|
||||
//! Called by cereal if no default constructor exists to load and construct data simultaneously
|
||||
/*! Overloads of this should return a pointer to T and expect an archive as a parameter */
|
||||
static std::false_type load_and_construct(...)
|
||||
{ return std::false_type(); }
|
||||
};
|
||||
|
||||
// forward decl for construct
|
||||
//! @cond PRIVATE_NEVERDEFINED
|
||||
namespace memory_detail{ template <class Ar, class T> struct LoadAndConstructLoadWrapper; }
|
||||
//! @endcond
|
||||
|
||||
//! Used to construct types with no default constructor
|
||||
/*! When serializing a type that has no default constructor, cereal
|
||||
will attempt to call either the class static function load_and_construct
|
||||
or the appropriate template specialization of LoadAndConstruct. cereal
|
||||
will pass that function a reference to the archive as well as a reference
|
||||
to a construct object which should be used to perform the allocation once
|
||||
data has been appropriately loaded.
|
||||
|
||||
@code{.cpp}
|
||||
struct MyType
|
||||
{
|
||||
// note the lack of default constructor
|
||||
MyType( int xx, int yy );
|
||||
|
||||
int x, y;
|
||||
double notInConstructor;
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{
|
||||
ar( x, y );
|
||||
ar( notInConstructor );
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
static void load_and_construct( Archive & ar, cereal::construct<MyType> & construct )
|
||||
{
|
||||
int x, y;
|
||||
ar( x, y );
|
||||
|
||||
// use construct object to initialize with loaded data
|
||||
construct( x, y );
|
||||
|
||||
// access to member variables and functions via -> operator
|
||||
ar( construct->notInConstructor );
|
||||
|
||||
// could also do the above section by:
|
||||
double z;
|
||||
ar( z );
|
||||
construct->notInConstructor = z;
|
||||
}
|
||||
};
|
||||
@endcode
|
||||
|
||||
@tparam T The class type being serialized
|
||||
*/
|
||||
template <class T>
|
||||
class construct
|
||||
{
|
||||
public:
|
||||
//! Construct and initialize the type T with the given arguments
|
||||
/*! This will forward all arguments to the underlying type T,
|
||||
calling an appropriate constructor.
|
||||
|
||||
Calling this function more than once will result in an exception
|
||||
being thrown.
|
||||
|
||||
@param args The arguments to the constructor for T
|
||||
@throw Exception If called more than once */
|
||||
template <class ... Args>
|
||||
void operator()( Args && ... args );
|
||||
// implementation deferred due to reliance on cereal::access
|
||||
|
||||
//! Get a reference to the initialized underlying object
|
||||
/*! This must be called after the object has been initialized.
|
||||
|
||||
@return A reference to the initialized object
|
||||
@throw Exception If called before initialization */
|
||||
T * operator->()
|
||||
{
|
||||
if( !itsValid )
|
||||
throw Exception("Object must be initialized prior to accessing members");
|
||||
|
||||
return itsPtr;
|
||||
}
|
||||
|
||||
//! Returns a raw pointer to the initialized underlying object
|
||||
/*! This is mainly intended for use with passing an instance of
|
||||
a constructed object to cereal::base_class.
|
||||
|
||||
It is strongly recommended to avoid using this function in
|
||||
any other circumstance.
|
||||
|
||||
@return A raw pointer to the initialized type */
|
||||
T * ptr()
|
||||
{
|
||||
return operator->();
|
||||
}
|
||||
|
||||
private:
|
||||
template <class A, class B> friend struct ::cereal::memory_detail::LoadAndConstructLoadWrapper;
|
||||
|
||||
construct( T * p ) : itsPtr( p ), itsValid( false ) {}
|
||||
construct( construct const & ) = delete;
|
||||
construct & operator=( construct const & ) = delete;
|
||||
|
||||
T * itsPtr;
|
||||
bool itsValid;
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
//! A class that can be made a friend to give cereal access to non public functions
|
||||
/*! If you desire non-public serialization functions within a class, cereal can only
|
||||
access these if you declare cereal::access a friend.
|
||||
|
||||
@code{.cpp}
|
||||
class MyClass
|
||||
{
|
||||
private:
|
||||
friend class cereal::access; // gives access to the private serialize
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{
|
||||
// some code
|
||||
}
|
||||
};
|
||||
@endcode
|
||||
@ingroup Access */
|
||||
class access
|
||||
{
|
||||
public:
|
||||
// ####### Standard Serialization ########################################
|
||||
template<class Archive, class T> inline
|
||||
static auto member_serialize(Archive & ar, T & t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save(Archive & ar, T const & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_SAVE_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_non_const(Archive & ar, T & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_SAVE_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_load(Archive & ar, T & t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_LOAD_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_minimal(Archive const & ar, T const & t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_minimal_non_const(Archive const & ar, T & t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
|
||||
{ return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }
|
||||
|
||||
template<class Archive, class T, class U> inline
|
||||
static auto member_load_minimal(Archive const & ar, T & t, U && u) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)))
|
||||
{ return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)); }
|
||||
|
||||
// ####### Versioned Serialization #######################################
|
||||
template<class Archive, class T> inline
|
||||
static auto member_serialize(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save(Archive & ar, T const & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_non_const(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_load(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_LOAD_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_minimal(Archive const & ar, T const & t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_minimal_non_const(Archive const & ar, T & t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
|
||||
{ return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }
|
||||
|
||||
template<class Archive, class T, class U> inline
|
||||
static auto member_load_minimal(Archive const & ar, T & t, U && u, const std::uint32_t version) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version))
|
||||
{ return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version); }
|
||||
|
||||
// ####### Other Functionality ##########################################
|
||||
// for detecting inheritance from enable_shared_from_this
|
||||
template <class T> inline
|
||||
static auto shared_from_this(T & t) -> decltype(t.shared_from_this());
|
||||
|
||||
// for placement new
|
||||
template <class T, class ... Args> inline
|
||||
static void construct( T *& ptr, Args && ... args )
|
||||
{
|
||||
new (ptr) T( std::forward<Args>( args )... );
|
||||
}
|
||||
|
||||
// for non-placement new with a default constructor
|
||||
template <class T> inline
|
||||
static T * construct()
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
static std::false_type load_and_construct(...)
|
||||
{ return std::false_type(); }
|
||||
|
||||
template<class T, class Archive> inline
|
||||
static auto load_and_construct(Archive & ar, ::cereal::construct<T> & construct) -> decltype(T::load_and_construct(ar, construct))
|
||||
{
|
||||
T::load_and_construct( ar, construct );
|
||||
}
|
||||
}; // end class access
|
||||
|
||||
// ######################################################################
|
||||
//! A specifier used in conjunction with cereal::specialize to disambiguate
|
||||
//! serialization in special cases
|
||||
/*! @relates specialize
|
||||
@ingroup Access */
|
||||
enum class specialization
|
||||
{
|
||||
member_serialize, //!< Force the use of a member serialize function
|
||||
member_load_save, //!< Force the use of a member load/save pair
|
||||
member_load_save_minimal, //!< Force the use of a member minimal load/save pair
|
||||
non_member_serialize, //!< Force the use of a non-member serialize function
|
||||
non_member_load_save, //!< Force the use of a non-member load/save pair
|
||||
non_member_load_save_minimal //!< Force the use of a non-member minimal load/save pair
|
||||
};
|
||||
|
||||
//! A class used to disambiguate cases where cereal cannot detect a unique way of serializing a class
|
||||
/*! cereal attempts to figure out which method of serialization (member vs. non-member serialize
|
||||
or load/save pair) at compile time. If for some reason cereal cannot find a non-ambiguous way
|
||||
of serializing a type, it will produce a static assertion complaining about this.
|
||||
|
||||
This can happen because you have both a serialize and load/save pair, or even because a base
|
||||
class has a serialize (public or private with friend access) and a derived class does not
|
||||
overwrite this due to choosing some other serialization type.
|
||||
|
||||
Specializing this class will tell cereal to explicitly use the serialization type you specify
|
||||
and it will not complain about ambiguity in its compile time selection. However, if cereal detects
|
||||
an ambiguity in specializations, it will continue to issue a static assertion.
|
||||
|
||||
@code{.cpp}
|
||||
class MyParent
|
||||
{
|
||||
friend class cereal::access;
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar ) {}
|
||||
};
|
||||
|
||||
// Although serialize is private in MyParent, to cereal::access it will look public,
|
||||
// even through MyDerived
|
||||
class MyDerived : public MyParent
|
||||
{
|
||||
public:
|
||||
template <class Archive>
|
||||
void load( Archive & ar ) {}
|
||||
|
||||
template <class Archive>
|
||||
void save( Archive & ar ) {}
|
||||
};
|
||||
|
||||
// The load/save pair in MyDerived is ambiguous because serialize in MyParent can
|
||||
// be accessed from cereal::access. This looks the same as making serialize public
|
||||
// in MyParent, making it seem as though MyDerived has both a serialize and a load/save pair.
|
||||
// cereal will complain about this at compile time unless we disambiguate:
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
// This struct specialization will tell cereal which is the right way to serialize the ambiguity
|
||||
template <class Archive> struct specialize<Archive, MyDerived, cereal::specialization::member_load_save> {};
|
||||
|
||||
// If we only had a disambiguation for a specific archive type, it would look something like this
|
||||
template <> struct specialize<cereal::BinaryOutputArchive, MyDerived, cereal::specialization::member_load_save> {};
|
||||
}
|
||||
@endcode
|
||||
|
||||
You can also choose to use the macros CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES or
|
||||
CEREAL_SPECIALIZE_FOR_ARCHIVE if you want to type a little bit less.
|
||||
|
||||
@tparam T The type to specialize the serialization for
|
||||
@tparam S The specialization type to use for T
|
||||
@ingroup Access */
|
||||
template <class Archive, class T, specialization S>
|
||||
struct specialize : public std::false_type {};
|
||||
|
||||
//! Convenient macro for performing specialization for all archive types
|
||||
/*! This performs specialization for the specific type for all types of archives.
|
||||
This macro should be placed at the global namespace.
|
||||
|
||||
@code{cpp}
|
||||
struct MyType {};
|
||||
CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( MyType, cereal::specialization::member_load_save );
|
||||
@endcode
|
||||
|
||||
@relates specialize
|
||||
@ingroup Access */
|
||||
#define CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( Type, Specialization ) \
|
||||
namespace cereal { template <class Archive> struct specialize<Archive, Type, Specialization> {}; }
|
||||
|
||||
//! Convenient macro for performing specialization for a single archive type
|
||||
/*! This performs specialization for the specific type for a single type of archive.
|
||||
This macro should be placed at the global namespace.
|
||||
|
||||
@code{cpp}
|
||||
struct MyType {};
|
||||
CEREAL_SPECIALIZE_FOR_ARCHIVE( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save );
|
||||
@endcode
|
||||
|
||||
@relates specialize
|
||||
@ingroup Access */
|
||||
#define CEREAL_SPECIALIZE_FOR_ARCHIVE( Archive, Type, Specialization ) \
|
||||
namespace cereal { template <> struct specialize<Archive, Type, Specialization> {}; }
|
||||
|
||||
// ######################################################################
|
||||
// Deferred Implementation, see construct for more information
|
||||
template <class T> template <class ... Args> inline
|
||||
void construct<T>::operator()( Args && ... args )
|
||||
{
|
||||
if( itsValid )
|
||||
throw Exception("Attempting to construct an already initialized object");
|
||||
|
||||
::cereal::access::construct( itsPtr, std::forward<Args>( args )... );
|
||||
itsValid = true;
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif // CEREAL_ACCESS_HPP_
|
||||
@@ -1,163 +0,0 @@
|
||||
/*! \file adapters.hpp
|
||||
\brief Archive adapters that provide additional functionality
|
||||
on top of an existing archive */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ARCHIVES_ADAPTERS_HPP_
|
||||
#define CEREAL_ARCHIVES_ADAPTERS_HPP_
|
||||
|
||||
#include <cereal/details/helpers.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
#ifdef CEREAL_FUTURE_EXPERIMENTAL
|
||||
|
||||
// Forward declaration for friend access
|
||||
template <class U, class A> U & get_user_data( A & );
|
||||
|
||||
//! Wraps an archive and gives access to user data
|
||||
/*! This adapter is useful if you require access to
|
||||
either raw pointers or references within your
|
||||
serialization functions.
|
||||
|
||||
While cereal does not directly support serialization
|
||||
raw pointers or references, it is sometimes the case
|
||||
that you may want to supply something such as a raw
|
||||
pointer or global reference to some constructor.
|
||||
In this situation this adapter would likely be used
|
||||
with the construct class to allow for non-default
|
||||
constructors.
|
||||
|
||||
@note This feature is experimental and may be altered or removed in a future release. See issue #46.
|
||||
|
||||
@code{.cpp}
|
||||
struct MyUserData
|
||||
{
|
||||
int * myRawPointer;
|
||||
std::reference_wrapper<MyOtherType> myReference;
|
||||
};
|
||||
|
||||
struct MyClass
|
||||
{
|
||||
// Note the raw pointer parameter
|
||||
MyClass( int xx, int * rawP );
|
||||
|
||||
int x;
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{ ar( x ); }
|
||||
|
||||
template <class Archive>
|
||||
static void load_and_construct( Archive & ar, cereal::construct<MyClass> & construct )
|
||||
{
|
||||
int xx;
|
||||
ar( xx );
|
||||
// note the need to use get_user_data to retrieve user data from the archive
|
||||
construct( xx, cereal::get_user_data<MyUserData>( ar ).myRawPointer );
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
MyUserData md;
|
||||
md.myRawPointer = &something;
|
||||
md.myReference = someInstanceOfType;
|
||||
|
||||
std::ifstream is( "data.xml" );
|
||||
cereal::UserDataAdapter<MyUserData, cereal::XMLInputArchive> ar( md, is );
|
||||
|
||||
std::unique_ptr<MyClass> sc;
|
||||
ar( sc ); // use as normal
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
|
||||
@relates get_user_data
|
||||
|
||||
@tparam UserData The type to give the archive access to
|
||||
@tparam Archive The archive to wrap */
|
||||
template <class UserData, class Archive>
|
||||
class UserDataAdapter : public Archive
|
||||
{
|
||||
public:
|
||||
//! Construct the archive with some user data struct
|
||||
/*! This will forward all arguments (other than the user
|
||||
data) to the wrapped archive type. The UserDataAdapter
|
||||
can then be used identically to the wrapped archive type
|
||||
|
||||
@tparam Args The arguments to pass to the constructor of
|
||||
the archive. */
|
||||
template <class ... Args>
|
||||
UserDataAdapter( UserData & ud, Args && ... args ) :
|
||||
Archive( std::forward<Args>( args )... ),
|
||||
userdata( ud )
|
||||
{ }
|
||||
|
||||
private:
|
||||
//! Overload the rtti function to enable dynamic_cast
|
||||
void rtti() {}
|
||||
friend UserData & get_user_data<UserData>( Archive & ar );
|
||||
UserData & userdata; //!< The actual user data
|
||||
};
|
||||
|
||||
//! Retrieves user data from an archive wrapped by UserDataAdapter
|
||||
/*! This will attempt to retrieve the user data associated with
|
||||
some archive wrapped by UserDataAdapter. If this is used on
|
||||
an archive that is not wrapped, a run-time exception will occur.
|
||||
|
||||
@note This feature is experimental and may be altered or removed in a future release. See issue #46.
|
||||
|
||||
@note The correct use of this function cannot be enforced at compile
|
||||
time.
|
||||
|
||||
@relates UserDataAdapter
|
||||
@tparam UserData The data struct contained in the archive
|
||||
@tparam Archive The archive, which should be wrapped by UserDataAdapter
|
||||
@param ar The archive
|
||||
@throws Exception if the archive this is used upon is not wrapped with
|
||||
UserDataAdapter. */
|
||||
template <class UserData, class Archive>
|
||||
UserData & get_user_data( Archive & ar )
|
||||
{
|
||||
try
|
||||
{
|
||||
return dynamic_cast<UserDataAdapter<UserData, Archive> &>( ar ).userdata;
|
||||
}
|
||||
catch( std::bad_cast const & )
|
||||
{
|
||||
throw ::cereal::Exception("Attempting to get user data from archive not wrapped in UserDataAdapter");
|
||||
}
|
||||
}
|
||||
#endif // CEREAL_FUTURE_EXPERIMENTAL
|
||||
} // namespace cereal
|
||||
|
||||
#endif // CEREAL_ARCHIVES_ADAPTERS_HPP_
|
||||
@@ -1,165 +0,0 @@
|
||||
/*! \file binary.hpp
|
||||
\brief Binary input and output archives */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ARCHIVES_BINARY_HPP_
|
||||
#define CEREAL_ARCHIVES_BINARY_HPP_
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
// ######################################################################
|
||||
//! An output archive designed to save data in a compact binary representation
|
||||
/*! This archive outputs data to a stream in an extremely compact binary
|
||||
representation with as little extra metadata as possible.
|
||||
|
||||
This archive does nothing to ensure that the endianness of the saved
|
||||
and loaded data is the same. If you need to have portability over
|
||||
architectures with different endianness, use PortableBinaryOutputArchive.
|
||||
|
||||
When using a binary archive and a file stream, you must use the
|
||||
std::ios::binary format flag to avoid having your data altered
|
||||
inadvertently.
|
||||
|
||||
\ingroup Archives */
|
||||
class BinaryOutputArchive : public OutputArchive<BinaryOutputArchive, AllowEmptyClassElision>
|
||||
{
|
||||
public:
|
||||
//! Construct, outputting to the provided stream
|
||||
/*! @param stream The stream to output to. Can be a stringstream, a file stream, or
|
||||
even cout! */
|
||||
BinaryOutputArchive(std::ostream & stream) :
|
||||
OutputArchive<BinaryOutputArchive, AllowEmptyClassElision>(this),
|
||||
itsStream(stream)
|
||||
{ }
|
||||
|
||||
//! Writes size bytes of data to the output stream
|
||||
void saveBinary( const void * data, std::size_t size )
|
||||
{
|
||||
auto const writtenSize = static_cast<std::size_t>( itsStream.rdbuf()->sputn( reinterpret_cast<const char*>( data ), size ) );
|
||||
|
||||
if(writtenSize != size)
|
||||
throw Exception("Failed to write " + std::to_string(size) + " bytes to output stream! Wrote " + std::to_string(writtenSize));
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream & itsStream;
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
//! An input archive designed to load data saved using BinaryOutputArchive
|
||||
/* This archive does nothing to ensure that the endianness of the saved
|
||||
and loaded data is the same. If you need to have portability over
|
||||
architectures with different endianness, use PortableBinaryOutputArchive.
|
||||
|
||||
When using a binary archive and a file stream, you must use the
|
||||
std::ios::binary format flag to avoid having your data altered
|
||||
inadvertently.
|
||||
|
||||
\ingroup Archives */
|
||||
class BinaryInputArchive : public InputArchive<BinaryInputArchive, AllowEmptyClassElision>
|
||||
{
|
||||
public:
|
||||
//! Construct, loading from the provided stream
|
||||
BinaryInputArchive(std::istream & stream) :
|
||||
InputArchive<BinaryInputArchive, AllowEmptyClassElision>(this),
|
||||
itsStream(stream)
|
||||
{ }
|
||||
|
||||
//! Reads size bytes of data from the input stream
|
||||
void loadBinary( void * const data, std::size_t size )
|
||||
{
|
||||
auto const readSize = static_cast<std::size_t>( itsStream.rdbuf()->sgetn( reinterpret_cast<char*>( data ), size ) );
|
||||
|
||||
if(readSize != size)
|
||||
throw Exception("Failed to read " + std::to_string(size) + " bytes from input stream! Read " + std::to_string(readSize));
|
||||
}
|
||||
|
||||
private:
|
||||
std::istream & itsStream;
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
// Common BinaryArchive serialization functions
|
||||
|
||||
//! Saving for POD types to binary
|
||||
template<class T> inline
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
|
||||
CEREAL_SAVE_FUNCTION_NAME(BinaryOutputArchive & ar, T const & t)
|
||||
{
|
||||
ar.saveBinary(std::addressof(t), sizeof(t));
|
||||
}
|
||||
|
||||
//! Loading for POD types from binary
|
||||
template<class T> inline
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
|
||||
CEREAL_LOAD_FUNCTION_NAME(BinaryInputArchive & ar, T & t)
|
||||
{
|
||||
ar.loadBinary(std::addressof(t), sizeof(t));
|
||||
}
|
||||
|
||||
//! Serializing NVP types to binary
|
||||
template <class Archive, class T> inline
|
||||
CEREAL_ARCHIVE_RESTRICT(BinaryInputArchive, BinaryOutputArchive)
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, NameValuePair<T> & t )
|
||||
{
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
//! Serializing SizeTags to binary
|
||||
template <class Archive, class T> inline
|
||||
CEREAL_ARCHIVE_RESTRICT(BinaryInputArchive, BinaryOutputArchive)
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, SizeTag<T> & t )
|
||||
{
|
||||
ar( t.size );
|
||||
}
|
||||
|
||||
//! Saving binary data
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(BinaryOutputArchive & ar, BinaryData<T> const & bd)
|
||||
{
|
||||
ar.saveBinary( bd.data, static_cast<std::size_t>( bd.size ) );
|
||||
}
|
||||
|
||||
//! Loading binary data
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(BinaryInputArchive & ar, BinaryData<T> & bd)
|
||||
{
|
||||
ar.loadBinary(bd.data, static_cast<std::size_t>(bd.size));
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
// register archives for polymorphic support
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::BinaryOutputArchive)
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::BinaryInputArchive)
|
||||
|
||||
// tie input and output archives together
|
||||
CEREAL_SETUP_ARCHIVE_TRAITS(cereal::BinaryInputArchive, cereal::BinaryOutputArchive)
|
||||
|
||||
#endif // CEREAL_ARCHIVES_BINARY_HPP_
|
||||
@@ -1,912 +0,0 @@
|
||||
/*! \file json.hpp
|
||||
\brief JSON input and output archives */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ARCHIVES_JSON_HPP_
|
||||
#define CEREAL_ARCHIVES_JSON_HPP_
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/details/util.hpp>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
//! An exception thrown when rapidjson fails an internal assertion
|
||||
/*! @ingroup Utility */
|
||||
struct RapidJSONException : Exception
|
||||
{ RapidJSONException( const char * what_ ) : Exception( what_ ) {} };
|
||||
}
|
||||
|
||||
// Override rapidjson assertions to throw exceptions by default
|
||||
#ifndef RAPIDJSON_ASSERT
|
||||
#define RAPIDJSON_ASSERT(x) if(!(x)){ \
|
||||
throw ::cereal::RapidJSONException("rapidjson internal assertion failure: " #x); }
|
||||
#endif // RAPIDJSON_ASSERT
|
||||
|
||||
#include <cereal/external/rapidjson/prettywriter.h>
|
||||
#include <cereal/external/rapidjson/genericstream.h>
|
||||
#include <cereal/external/rapidjson/reader.h>
|
||||
#include <cereal/external/rapidjson/document.h>
|
||||
#include <cereal/external/base64.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
// ######################################################################
|
||||
//! An output archive designed to save data to JSON
|
||||
/*! This archive uses RapidJSON to build serialie data to JSON.
|
||||
|
||||
JSON archives provides a human readable output but at decreased
|
||||
performance (both in time and space) compared to binary archives.
|
||||
|
||||
JSON benefits greatly from name-value pairs, which if present, will
|
||||
name the nodes in the output. If these are not present, each level
|
||||
of the output will be given an automatically generated delimited name.
|
||||
|
||||
The precision of the output archive controls the number of decimals output
|
||||
for floating point numbers and should be sufficiently large (i.e. at least 20)
|
||||
if there is a desire to have binary equality between the numbers output and
|
||||
those read in. In general you should expect a loss of precision when going
|
||||
from floating point to text and back.
|
||||
|
||||
JSON archives do not output the size information for any dynamically sized structure
|
||||
and instead infer it from the number of children for a node. This means that data
|
||||
can be hand edited for dynamic sized structures and will still be readable. This
|
||||
is accomplished through the cereal::SizeTag object, which will cause the archive
|
||||
to output the data as a JSON array (e.g. marked by [] instead of {}), which indicates
|
||||
that the container is variable sized and may be edited.
|
||||
|
||||
\ingroup Archives */
|
||||
class JSONOutputArchive : public OutputArchive<JSONOutputArchive>, public traits::TextArchive
|
||||
{
|
||||
enum class NodeType { StartObject, InObject, StartArray, InArray };
|
||||
|
||||
typedef rapidjson::GenericWriteStream WriteStream;
|
||||
typedef rapidjson::PrettyWriter<WriteStream> JSONWriter;
|
||||
|
||||
public:
|
||||
/*! @name Common Functionality
|
||||
Common use cases for directly interacting with an JSONOutputArchive */
|
||||
//! @{
|
||||
|
||||
//! A class containing various advanced options for the JSON archive
|
||||
class Options
|
||||
{
|
||||
public:
|
||||
//! Default options
|
||||
static Options Default(){ return Options(); }
|
||||
|
||||
//! Default options with no indentation
|
||||
static Options NoIndent(){ return Options( std::numeric_limits<double>::max_digits10, IndentChar::space, 0 ); }
|
||||
|
||||
//! The character to use for indenting
|
||||
enum class IndentChar : char
|
||||
{
|
||||
space = ' ',
|
||||
tab = '\t',
|
||||
newline = '\n',
|
||||
carriage_return = '\r'
|
||||
};
|
||||
|
||||
//! Specify specific options for the JSONOutputArchive
|
||||
/*! @param precision The precision used for floating point numbers
|
||||
@param indentChar The type of character to indent with
|
||||
@param indentLength The number of indentChar to use for indentation
|
||||
(0 corresponds to no indentation) */
|
||||
explicit Options( int precision = std::numeric_limits<double>::max_digits10,
|
||||
IndentChar indentChar = IndentChar::space,
|
||||
unsigned int indentLength = 4 ) :
|
||||
itsPrecision( precision ),
|
||||
itsIndentChar( static_cast<char>(indentChar) ),
|
||||
itsIndentLength( indentLength ) { }
|
||||
|
||||
private:
|
||||
friend class JSONOutputArchive;
|
||||
int itsPrecision;
|
||||
char itsIndentChar;
|
||||
unsigned int itsIndentLength;
|
||||
};
|
||||
|
||||
//! Construct, outputting to the provided stream
|
||||
/*! @param stream The stream to output to.
|
||||
@param options The JSON specific options to use. See the Options struct
|
||||
for the values of default parameters */
|
||||
JSONOutputArchive(std::ostream & stream, Options const & options = Options::Default() ) :
|
||||
OutputArchive<JSONOutputArchive>(this),
|
||||
itsWriteStream(stream),
|
||||
itsWriter(itsWriteStream, options.itsPrecision),
|
||||
itsNextName(nullptr)
|
||||
{
|
||||
itsWriter.SetIndent( options.itsIndentChar, options.itsIndentLength );
|
||||
itsNameCounter.push(0);
|
||||
itsNodeStack.push(NodeType::StartObject);
|
||||
}
|
||||
|
||||
//! Destructor, flushes the JSON
|
||||
~JSONOutputArchive()
|
||||
{
|
||||
if (itsNodeStack.top() == NodeType::InObject)
|
||||
itsWriter.EndObject();
|
||||
}
|
||||
|
||||
//! Saves some binary data, encoded as a base64 string, with an optional name
|
||||
/*! This will create a new node, optionally named, and insert a value that consists of
|
||||
the data encoded as a base64 string */
|
||||
void saveBinaryValue( const void * data, size_t size, const char * name = nullptr )
|
||||
{
|
||||
setNextName( name );
|
||||
writeName();
|
||||
|
||||
auto base64string = base64::encode( reinterpret_cast<const unsigned char *>( data ), size );
|
||||
saveValue( base64string );
|
||||
};
|
||||
|
||||
//! @}
|
||||
/*! @name Internal Functionality
|
||||
Functionality designed for use by those requiring control over the inner mechanisms of
|
||||
the JSONOutputArchive */
|
||||
//! @{
|
||||
|
||||
//! Starts a new node in the JSON output
|
||||
/*! The node can optionally be given a name by calling setNextName prior
|
||||
to creating the node
|
||||
|
||||
Nodes only need to be started for types that are themselves objects or arrays */
|
||||
void startNode()
|
||||
{
|
||||
writeName();
|
||||
itsNodeStack.push(NodeType::StartObject);
|
||||
itsNameCounter.push(0);
|
||||
}
|
||||
|
||||
//! Designates the most recently added node as finished
|
||||
void finishNode()
|
||||
{
|
||||
// if we ended up serializing an empty object or array, writeName
|
||||
// will never have been called - so start and then immediately end
|
||||
// the object/array.
|
||||
//
|
||||
// We'll also end any object/arrays we happen to be in
|
||||
switch(itsNodeStack.top())
|
||||
{
|
||||
case NodeType::StartArray:
|
||||
itsWriter.StartArray();
|
||||
case NodeType::InArray:
|
||||
itsWriter.EndArray();
|
||||
break;
|
||||
case NodeType::StartObject:
|
||||
itsWriter.StartObject();
|
||||
case NodeType::InObject:
|
||||
itsWriter.EndObject();
|
||||
break;
|
||||
}
|
||||
|
||||
itsNodeStack.pop();
|
||||
itsNameCounter.pop();
|
||||
}
|
||||
|
||||
//! Sets the name for the next node created with startNode
|
||||
void setNextName( const char * name )
|
||||
{
|
||||
itsNextName = name;
|
||||
}
|
||||
|
||||
//! Saves a bool to the current node
|
||||
void saveValue(bool b) { itsWriter.Bool_(b); }
|
||||
//! Saves an int to the current node
|
||||
void saveValue(int i) { itsWriter.Int(i); }
|
||||
//! Saves a uint to the current node
|
||||
void saveValue(unsigned u) { itsWriter.Uint(u); }
|
||||
//! Saves an int64 to the current node
|
||||
void saveValue(int64_t i64) { itsWriter.Int64(i64); }
|
||||
//! Saves a uint64 to the current node
|
||||
void saveValue(uint64_t u64) { itsWriter.Uint64(u64); }
|
||||
//! Saves a double to the current node
|
||||
void saveValue(double d) { itsWriter.Double(d); }
|
||||
//! Saves a string to the current node
|
||||
void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); }
|
||||
//! Saves a const char * to the current node
|
||||
void saveValue(char const * s) { itsWriter.String(s); }
|
||||
|
||||
private:
|
||||
// Some compilers/OS have difficulty disambiguating the above for various flavors of longs, so we provide
|
||||
// special overloads to handle these cases.
|
||||
|
||||
//! 32 bit signed long saving to current node
|
||||
template <class T, traits::EnableIf<sizeof(T) == sizeof(std::int32_t),
|
||||
std::is_signed<T>::value> = traits::sfinae> inline
|
||||
void saveLong(T l){ saveValue( static_cast<std::int32_t>( l ) ); }
|
||||
|
||||
//! non 32 bit signed long saving to current node
|
||||
template <class T, traits::EnableIf<sizeof(T) != sizeof(std::int32_t),
|
||||
std::is_signed<T>::value> = traits::sfinae> inline
|
||||
void saveLong(T l){ saveValue( static_cast<std::int64_t>( l ) ); }
|
||||
|
||||
//! 32 bit unsigned long saving to current node
|
||||
template <class T, traits::EnableIf<sizeof(T) == sizeof(std::int32_t),
|
||||
std::is_unsigned<T>::value> = traits::sfinae> inline
|
||||
void saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
|
||||
|
||||
//! non 32 bit unsigned long saving to current node
|
||||
template <class T, traits::EnableIf<sizeof(T) != sizeof(std::int32_t),
|
||||
std::is_unsigned<T>::value> = traits::sfinae> inline
|
||||
void saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
|
||||
|
||||
public:
|
||||
#ifdef _MSC_VER
|
||||
//! MSVC only long overload to current node
|
||||
void saveValue( unsigned long lu ){ saveLong( lu ); };
|
||||
#else // _MSC_VER
|
||||
//! Serialize a long if it would not be caught otherwise
|
||||
template <class T, traits::EnableIf<std::is_same<T, long>::value,
|
||||
!std::is_same<T, std::int32_t>::value,
|
||||
!std::is_same<T, std::int64_t>::value> = traits::sfinae> inline
|
||||
void saveValue( T t ){ saveLong( t ); }
|
||||
|
||||
//! Serialize an unsigned long if it would not be caught otherwise
|
||||
template <class T, traits::EnableIf<std::is_same<T, unsigned long>::value,
|
||||
!std::is_same<T, std::uint32_t>::value,
|
||||
!std::is_same<T, std::uint64_t>::value> = traits::sfinae> inline
|
||||
void saveValue( T t ){ saveLong( t ); }
|
||||
#endif // _MSC_VER
|
||||
|
||||
//! Save exotic arithmetic as strings to current node
|
||||
/*! Handles long long (if distinct from other types), unsigned long (if distinct), and long double */
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value,
|
||||
!std::is_same<T, long>::value,
|
||||
!std::is_same<T, unsigned long>::value,
|
||||
!std::is_same<T, std::int64_t>::value,
|
||||
!std::is_same<T, std::uint64_t>::value,
|
||||
(sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long))> = traits::sfinae> inline
|
||||
void saveValue(T const & t)
|
||||
{
|
||||
std::stringstream ss; ss.precision( std::numeric_limits<long double>::max_digits10 );
|
||||
ss << t;
|
||||
saveValue( ss.str() );
|
||||
}
|
||||
|
||||
//! Write the name of the upcoming node and prepare object/array state
|
||||
/*! Since writeName is called for every value that is output, regardless of
|
||||
whether it has a name or not, it is the place where we will do a deferred
|
||||
check of our node state and decide whether we are in an array or an object.
|
||||
|
||||
The general workflow of saving to the JSON archive is:
|
||||
|
||||
1. (optional) Set the name for the next node to be created, usually done by an NVP
|
||||
2. Start the node
|
||||
3. (if there is data to save) Write the name of the node (this function)
|
||||
4. (if there is data to save) Save the data (with saveValue)
|
||||
5. Finish the node
|
||||
*/
|
||||
void writeName()
|
||||
{
|
||||
NodeType const & nodeType = itsNodeStack.top();
|
||||
|
||||
// Start up either an object or an array, depending on state
|
||||
if(nodeType == NodeType::StartArray)
|
||||
{
|
||||
itsWriter.StartArray();
|
||||
itsNodeStack.top() = NodeType::InArray;
|
||||
}
|
||||
else if(nodeType == NodeType::StartObject)
|
||||
{
|
||||
itsNodeStack.top() = NodeType::InObject;
|
||||
itsWriter.StartObject();
|
||||
}
|
||||
|
||||
// Array types do not output names
|
||||
if(nodeType == NodeType::InArray) return;
|
||||
|
||||
if(itsNextName == nullptr)
|
||||
{
|
||||
std::string name = "value" + std::to_string( itsNameCounter.top()++ ) + "\0";
|
||||
saveValue(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
saveValue(itsNextName);
|
||||
itsNextName = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//! Designates that the current node should be output as an array, not an object
|
||||
void makeArray()
|
||||
{
|
||||
itsNodeStack.top() = NodeType::StartArray;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
private:
|
||||
WriteStream itsWriteStream; //!< Rapidjson write stream
|
||||
JSONWriter itsWriter; //!< Rapidjson writer
|
||||
char const * itsNextName; //!< The next name
|
||||
std::stack<uint32_t> itsNameCounter; //!< Counter for creating unique names for unnamed nodes
|
||||
std::stack<NodeType> itsNodeStack;
|
||||
}; // JSONOutputArchive
|
||||
|
||||
// ######################################################################
|
||||
//! An input archive designed to load data from JSON
|
||||
/*! This archive uses RapidJSON to read in a JSON archive.
|
||||
|
||||
Input JSON should have been produced by the JSONOutputArchive. Data can
|
||||
only be added to dynamically sized containers (marked by JSON arrays) -
|
||||
the input archive will determine their size by looking at the number of child nodes.
|
||||
Only JSON originating from a JSONOutputArchive is officially supported, but data
|
||||
from other sources may work if properly formatted.
|
||||
|
||||
The JSONInputArchive does not require that nodes are loaded in the same
|
||||
order they were saved by JSONOutputArchive. Using name value pairs (NVPs),
|
||||
it is possible to load in an out of order fashion or otherwise skip/select
|
||||
specific nodes to load.
|
||||
|
||||
The default behavior of the input archive is to read sequentially starting
|
||||
with the first node and exploring its children. When a given NVP does
|
||||
not match the read in name for a node, the archive will search for that
|
||||
node at the current level and load it if it exists. After loading an out of
|
||||
order node, the archive will then proceed back to loading sequentially from
|
||||
its new position.
|
||||
|
||||
Consider this simple example where loading of some data is skipped:
|
||||
|
||||
@code{cpp}
|
||||
// imagine the input file has someData(1-9) saved in order at the top level node
|
||||
ar( someData1, someData2, someData3 ); // XML loads in the order it sees in the file
|
||||
ar( cereal::make_nvp( "hello", someData6 ) ); // NVP given does not
|
||||
// match expected NVP name, so we search
|
||||
// for the given NVP and load that value
|
||||
ar( someData7, someData8, someData9 ); // with no NVP given, loading resumes at its
|
||||
// current location, proceeding sequentially
|
||||
@endcode
|
||||
|
||||
\ingroup Archives */
|
||||
class JSONInputArchive : public InputArchive<JSONInputArchive>, public traits::TextArchive
|
||||
{
|
||||
private:
|
||||
typedef rapidjson::GenericReadStream ReadStream;
|
||||
typedef rapidjson::GenericValue<rapidjson::UTF8<>> JSONValue;
|
||||
typedef JSONValue::ConstMemberIterator MemberIterator;
|
||||
typedef JSONValue::ConstValueIterator ValueIterator;
|
||||
typedef rapidjson::Document::GenericValue GenericValue;
|
||||
|
||||
public:
|
||||
/*! @name Common Functionality
|
||||
Common use cases for directly interacting with an JSONInputArchive */
|
||||
//! @{
|
||||
|
||||
//! Construct, reading from the provided stream
|
||||
/*! @param stream The stream to read from */
|
||||
JSONInputArchive(std::istream & stream) :
|
||||
InputArchive<JSONInputArchive>(this),
|
||||
itsNextName( nullptr ),
|
||||
itsReadStream(stream)
|
||||
{
|
||||
itsDocument.ParseStream<0>(itsReadStream);
|
||||
itsIteratorStack.emplace_back(itsDocument.MemberBegin(), itsDocument.MemberEnd());
|
||||
}
|
||||
|
||||
//! Loads some binary data, encoded as a base64 string
|
||||
/*! This will automatically start and finish a node to load the data, and can be called directly by
|
||||
users.
|
||||
|
||||
Note that this follows the same ordering rules specified in the class description in regards
|
||||
to loading in/out of order */
|
||||
void loadBinaryValue( void * data, size_t size, const char * name = nullptr )
|
||||
{
|
||||
itsNextName = name;
|
||||
|
||||
std::string encoded;
|
||||
loadValue( encoded );
|
||||
auto decoded = base64::decode( encoded );
|
||||
|
||||
if( size != decoded.size() )
|
||||
throw Exception("Decoded binary data size does not match specified size");
|
||||
|
||||
std::memcpy( data, decoded.data(), decoded.size() );
|
||||
itsNextName = nullptr;
|
||||
};
|
||||
|
||||
private:
|
||||
//! @}
|
||||
/*! @name Internal Functionality
|
||||
Functionality designed for use by those requiring control over the inner mechanisms of
|
||||
the JSONInputArchive */
|
||||
//! @{
|
||||
|
||||
//! An internal iterator that handles both array and object types
|
||||
/*! This class is a variant and holds both types of iterators that
|
||||
rapidJSON supports - one for arrays and one for objects. */
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
Iterator() : itsIndex( 0 ), itsType(Null_) {}
|
||||
|
||||
Iterator(MemberIterator begin, MemberIterator end) :
|
||||
itsMemberItBegin(begin), itsMemberItEnd(end), itsIndex(0), itsType(Member)
|
||||
{ }
|
||||
|
||||
Iterator(ValueIterator begin, ValueIterator end) :
|
||||
itsValueItBegin(begin), itsValueItEnd(end), itsIndex(0), itsType(Value)
|
||||
{ }
|
||||
|
||||
//! Advance to the next node
|
||||
Iterator & operator++()
|
||||
{
|
||||
++itsIndex;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Get the value of the current node
|
||||
GenericValue const & value()
|
||||
{
|
||||
switch(itsType)
|
||||
{
|
||||
case Value : return itsValueItBegin[itsIndex];
|
||||
case Member: return itsMemberItBegin[itsIndex].value;
|
||||
default: throw cereal::Exception("Invalid Iterator Type!");
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the name of the current node, or nullptr if it has no name
|
||||
const char * name() const
|
||||
{
|
||||
if( itsType == Member && (itsMemberItBegin + itsIndex) != itsMemberItEnd )
|
||||
return itsMemberItBegin[itsIndex].name.GetString();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//! Adjust our position such that we are at the node with the given name
|
||||
/*! @throws Exception if no such named node exists */
|
||||
inline void search( const char * searchName )
|
||||
{
|
||||
const auto len = std::strlen( searchName );
|
||||
size_t index = 0;
|
||||
for( auto it = itsMemberItBegin; it != itsMemberItEnd; ++it, ++index )
|
||||
{
|
||||
const auto currentName = it->name.GetString();
|
||||
if( ( std::strncmp( searchName, currentName, len ) == 0 ) &&
|
||||
( std::strlen( currentName ) == len ) )
|
||||
{
|
||||
itsIndex = index;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw Exception("JSON Parsing failed - provided NVP not found");
|
||||
}
|
||||
|
||||
private:
|
||||
MemberIterator itsMemberItBegin, itsMemberItEnd; //!< The member iterator (object)
|
||||
ValueIterator itsValueItBegin, itsValueItEnd; //!< The value iterator (array)
|
||||
size_t itsIndex; //!< The current index of this iterator
|
||||
enum Type {Value, Member, Null_} itsType; //!< Whether this holds values (array) or members (objects) or nothing
|
||||
};
|
||||
|
||||
//! Searches for the expectedName node if it doesn't match the actualName
|
||||
/*! This needs to be called before every load or node start occurs. This function will
|
||||
check to see if an NVP has been provided (with setNextName) and if so, see if that name matches the actual
|
||||
next name given. If the names do not match, it will search in the current level of the JSON for that name.
|
||||
If the name is not found, an exception will be thrown.
|
||||
|
||||
Resets the NVP name after called.
|
||||
|
||||
@throws Exception if an expectedName is given and not found */
|
||||
inline void search()
|
||||
{
|
||||
// The name an NVP provided with setNextName()
|
||||
if( itsNextName )
|
||||
{
|
||||
// The actual name of the current node
|
||||
auto const actualName = itsIteratorStack.back().name();
|
||||
|
||||
// Do a search if we don't see a name coming up, or if the names don't match
|
||||
if( !actualName || std::strcmp( itsNextName, actualName ) != 0 )
|
||||
itsIteratorStack.back().search( itsNextName );
|
||||
}
|
||||
|
||||
itsNextName = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Starts a new node, going into its proper iterator
|
||||
/*! This places an iterator for the next node to be parsed onto the iterator stack. If the next
|
||||
node is an array, this will be a value iterator, otherwise it will be a member iterator.
|
||||
|
||||
By default our strategy is to start with the document root node and then recursively iterate through
|
||||
all children in the order they show up in the document.
|
||||
We don't need to know NVPs to do this; we'll just blindly load in the order things appear in.
|
||||
|
||||
If we were given an NVP, we will search for it if it does not match our the name of the next node
|
||||
that would normally be loaded. This functionality is provided by search(). */
|
||||
void startNode()
|
||||
{
|
||||
search();
|
||||
|
||||
if(itsIteratorStack.back().value().IsArray())
|
||||
itsIteratorStack.emplace_back(itsIteratorStack.back().value().Begin(), itsIteratorStack.back().value().End());
|
||||
else
|
||||
itsIteratorStack.emplace_back(itsIteratorStack.back().value().MemberBegin(), itsIteratorStack.back().value().MemberEnd());
|
||||
}
|
||||
|
||||
//! Finishes the most recently started node
|
||||
void finishNode()
|
||||
{
|
||||
itsIteratorStack.pop_back();
|
||||
++itsIteratorStack.back();
|
||||
}
|
||||
|
||||
//! Retrieves the current node name
|
||||
/*! @return nullptr if no name exists */
|
||||
const char * getNodeName() const
|
||||
{
|
||||
return itsIteratorStack.back().name();
|
||||
}
|
||||
|
||||
//! Sets the name for the next node created with startNode
|
||||
void setNextName( const char * name )
|
||||
{
|
||||
itsNextName = name;
|
||||
}
|
||||
|
||||
//! Loads a value from the current node - small signed overload
|
||||
template <class T, traits::EnableIf<std::is_signed<T>::value,
|
||||
sizeof(T) < sizeof(int64_t)> = traits::sfinae> inline
|
||||
void loadValue(T & val)
|
||||
{
|
||||
search();
|
||||
|
||||
val = static_cast<T>( itsIteratorStack.back().value().GetInt() );
|
||||
++itsIteratorStack.back();
|
||||
}
|
||||
|
||||
//! Loads a value from the current node - small unsigned overload
|
||||
template <class T, traits::EnableIf<std::is_unsigned<T>::value,
|
||||
sizeof(T) < sizeof(uint64_t),
|
||||
!std::is_same<bool, T>::value> = traits::sfinae> inline
|
||||
void loadValue(T & val)
|
||||
{
|
||||
search();
|
||||
|
||||
val = static_cast<T>( itsIteratorStack.back().value().GetUint() );
|
||||
++itsIteratorStack.back();
|
||||
}
|
||||
|
||||
//! Loads a value from the current node - bool overload
|
||||
void loadValue(bool & val) { search(); val = itsIteratorStack.back().value().GetBool_(); ++itsIteratorStack.back(); }
|
||||
//! Loads a value from the current node - int64 overload
|
||||
void loadValue(int64_t & val) { search(); val = itsIteratorStack.back().value().GetInt64(); ++itsIteratorStack.back(); }
|
||||
//! Loads a value from the current node - uint64 overload
|
||||
void loadValue(uint64_t & val) { search(); val = itsIteratorStack.back().value().GetUint64(); ++itsIteratorStack.back(); }
|
||||
//! Loads a value from the current node - float overload
|
||||
void loadValue(float & val) { search(); val = static_cast<float>(itsIteratorStack.back().value().GetDouble()); ++itsIteratorStack.back(); }
|
||||
//! Loads a value from the current node - double overload
|
||||
void loadValue(double & val) { search(); val = itsIteratorStack.back().value().GetDouble(); ++itsIteratorStack.back(); }
|
||||
//! Loads a value from the current node - string overload
|
||||
void loadValue(std::string & val) { search(); val = itsIteratorStack.back().value().GetString(); ++itsIteratorStack.back(); }
|
||||
|
||||
// Special cases to handle various flavors of long, which tend to conflict with
|
||||
// the int32_t or int64_t on various compiler/OS combinations. MSVC doesn't need any of this.
|
||||
#ifndef _MSC_VER
|
||||
private:
|
||||
//! 32 bit signed long loading from current node
|
||||
template <class T> inline
|
||||
typename std::enable_if<sizeof(T) == sizeof(std::int32_t) && std::is_signed<T>::value, void>::type
|
||||
loadLong(T & l){ loadValue( reinterpret_cast<std::int32_t&>( l ) ); }
|
||||
|
||||
//! non 32 bit signed long loading from current node
|
||||
template <class T> inline
|
||||
typename std::enable_if<sizeof(T) == sizeof(std::int64_t) && std::is_signed<T>::value, void>::type
|
||||
loadLong(T & l){ loadValue( reinterpret_cast<std::int64_t&>( l ) ); }
|
||||
|
||||
//! 32 bit unsigned long loading from current node
|
||||
template <class T> inline
|
||||
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t) && !std::is_signed<T>::value, void>::type
|
||||
loadLong(T & lu){ loadValue( reinterpret_cast<std::uint32_t&>( lu ) ); }
|
||||
|
||||
//! non 32 bit unsigned long loading from current node
|
||||
template <class T> inline
|
||||
typename std::enable_if<sizeof(T) == sizeof(std::uint64_t) && !std::is_signed<T>::value, void>::type
|
||||
loadLong(T & lu){ loadValue( reinterpret_cast<std::uint64_t&>( lu ) ); }
|
||||
|
||||
public:
|
||||
//! Serialize a long if it would not be caught otherwise
|
||||
template <class T> inline
|
||||
typename std::enable_if<std::is_same<T, long>::value &&
|
||||
!std::is_same<T, std::int32_t>::value &&
|
||||
!std::is_same<T, std::int64_t>::value, void>::type
|
||||
loadValue( T & t ){ loadLong(t); }
|
||||
|
||||
//! Serialize an unsigned long if it would not be caught otherwise
|
||||
template <class T> inline
|
||||
typename std::enable_if<std::is_same<T, unsigned long>::value &&
|
||||
!std::is_same<T, std::uint32_t>::value &&
|
||||
!std::is_same<T, std::uint64_t>::value, void>::type
|
||||
loadValue( T & t ){ loadLong(t); }
|
||||
#endif // _MSC_VER
|
||||
|
||||
private:
|
||||
//! Convert a string to a long long
|
||||
void stringToNumber( std::string const & str, long long & val ) { val = std::stoll( str ); }
|
||||
//! Convert a string to an unsigned long long
|
||||
void stringToNumber( std::string const & str, unsigned long long & val ) { val = std::stoull( str ); }
|
||||
//! Convert a string to a long double
|
||||
void stringToNumber( std::string const & str, long double & val ) { val = std::stold( str ); }
|
||||
|
||||
public:
|
||||
//! Loads a value from the current node - long double and long long overloads
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value,
|
||||
!std::is_same<T, long>::value,
|
||||
!std::is_same<T, unsigned long>::value,
|
||||
!std::is_same<T, std::int64_t>::value,
|
||||
!std::is_same<T, std::uint64_t>::value,
|
||||
(sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long))> = traits::sfinae>
|
||||
inline void loadValue(T & val)
|
||||
{
|
||||
std::string encoded;
|
||||
loadValue( encoded );
|
||||
stringToNumber( encoded, val );
|
||||
}
|
||||
|
||||
//! Loads the size for a SizeTag
|
||||
void loadSize(size_type & size)
|
||||
{
|
||||
size = (itsIteratorStack.rbegin() + 1)->value().Size();
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
private:
|
||||
const char * itsNextName; //!< Next name set by NVP
|
||||
ReadStream itsReadStream; //!< Rapidjson write stream
|
||||
std::vector<Iterator> itsIteratorStack; //!< 'Stack' of rapidJSON iterators
|
||||
rapidjson::Document itsDocument; //!< Rapidjson document
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
// JSONArchive prologue and epilogue functions
|
||||
// ######################################################################
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for NVPs for JSON archives
|
||||
/*! NVPs do not start or finish nodes - they just set up the names */
|
||||
template <class T> inline
|
||||
void prologue( JSONOutputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
//! Prologue for NVPs for JSON archives
|
||||
template <class T> inline
|
||||
void prologue( JSONInputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for NVPs for JSON archives
|
||||
/*! NVPs do not start or finish nodes - they just set up the names */
|
||||
template <class T> inline
|
||||
void epilogue( JSONOutputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
//! Epilogue for NVPs for JSON archives
|
||||
/*! NVPs do not start or finish nodes - they just set up the names */
|
||||
template <class T> inline
|
||||
void epilogue( JSONInputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for SizeTags for JSON archives
|
||||
/*! SizeTags are strictly ignored for JSON, they just indicate
|
||||
that the current node should be made into an array */
|
||||
template <class T> inline
|
||||
void prologue( JSONOutputArchive & ar, SizeTag<T> const & )
|
||||
{
|
||||
ar.makeArray();
|
||||
}
|
||||
|
||||
//! Prologue for SizeTags for JSON archives
|
||||
template <class T> inline
|
||||
void prologue( JSONInputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for SizeTags for JSON archives
|
||||
/*! SizeTags are strictly ignored for JSON */
|
||||
template <class T> inline
|
||||
void epilogue( JSONOutputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
//! Epilogue for SizeTags for JSON archives
|
||||
template <class T> inline
|
||||
void epilogue( JSONInputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for all other types for JSON archives (except minimal types)
|
||||
/*! Starts a new node, named either automatically or by some NVP,
|
||||
that may be given data by the type about to be archived
|
||||
|
||||
Minimal types do not start or finish nodes */
|
||||
template <class T, traits::DisableIf<std::is_arithmetic<T>::value ||
|
||||
traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, JSONOutputArchive>::value ||
|
||||
traits::has_minimal_output_serialization<T, JSONOutputArchive>::value> = traits::sfinae>
|
||||
inline void prologue( JSONOutputArchive & ar, T const & )
|
||||
{
|
||||
ar.startNode();
|
||||
}
|
||||
|
||||
//! Prologue for all other types for JSON archives
|
||||
template <class T, traits::DisableIf<std::is_arithmetic<T>::value ||
|
||||
traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, JSONInputArchive>::value ||
|
||||
traits::has_minimal_input_serialization<T, JSONInputArchive>::value> = traits::sfinae>
|
||||
inline void prologue( JSONInputArchive & ar, T const & )
|
||||
{
|
||||
ar.startNode();
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for all other types other for JSON archives (except minimal types
|
||||
/*! Finishes the node created in the prologue
|
||||
|
||||
Minimal types do not start or finish nodes */
|
||||
template <class T, traits::DisableIf<std::is_arithmetic<T>::value ||
|
||||
traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, JSONOutputArchive>::value ||
|
||||
traits::has_minimal_output_serialization<T, JSONOutputArchive>::value> = traits::sfinae>
|
||||
inline void epilogue( JSONOutputArchive & ar, T const & )
|
||||
{
|
||||
ar.finishNode();
|
||||
}
|
||||
|
||||
//! Epilogue for all other types other for JSON archives
|
||||
template <class T, traits::DisableIf<std::is_arithmetic<T>::value ||
|
||||
traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, JSONInputArchive>::value ||
|
||||
traits::has_minimal_input_serialization<T, JSONInputArchive>::value> = traits::sfinae>
|
||||
inline void epilogue( JSONInputArchive & ar, T const & )
|
||||
{
|
||||
ar.finishNode();
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for arithmetic types for JSON archives
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void prologue( JSONOutputArchive & ar, T const & )
|
||||
{
|
||||
ar.writeName();
|
||||
}
|
||||
|
||||
//! Prologue for arithmetic types for JSON archives
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void prologue( JSONInputArchive &, T const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for arithmetic types for JSON archives
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void epilogue( JSONOutputArchive &, T const & )
|
||||
{ }
|
||||
|
||||
//! Epilogue for arithmetic types for JSON archives
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void epilogue( JSONInputArchive &, T const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for strings for JSON archives
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void prologue(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const &)
|
||||
{
|
||||
ar.writeName();
|
||||
}
|
||||
|
||||
//! Prologue for strings for JSON archives
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void prologue(JSONInputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for strings for JSON archives
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void epilogue(JSONOutputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
|
||||
{ }
|
||||
|
||||
//! Epilogue for strings for JSON archives
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void epilogue(JSONInputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
// Common JSONArchive serialization functions
|
||||
// ######################################################################
|
||||
//! Serializing NVP types to JSON
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive & ar, NameValuePair<T> const & t )
|
||||
{
|
||||
ar.setNextName( t.name );
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, NameValuePair<T> & t )
|
||||
{
|
||||
ar.setNextName( t.name );
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
//! Saving for arithmetic to JSON
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, T const & t)
|
||||
{
|
||||
ar.saveValue( t );
|
||||
}
|
||||
|
||||
//! Loading arithmetic from JSON
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, T & t)
|
||||
{
|
||||
ar.loadValue( t );
|
||||
}
|
||||
|
||||
//! saving string to JSON
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
|
||||
{
|
||||
ar.saveValue( str );
|
||||
}
|
||||
|
||||
//! loading string from JSON
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
|
||||
{
|
||||
ar.loadValue( str );
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Saving SizeTags to JSON
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive &, SizeTag<T> const & )
|
||||
{
|
||||
// nothing to do here, we don't explicitly save the size
|
||||
}
|
||||
|
||||
//! Loading SizeTags from JSON
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, SizeTag<T> & st )
|
||||
{
|
||||
ar.loadSize( st.size );
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
// register archives for polymorphic support
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::JSONInputArchive)
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive)
|
||||
|
||||
// tie input and output archives together
|
||||
CEREAL_SETUP_ARCHIVE_TRAITS(cereal::JSONInputArchive, cereal::JSONOutputArchive)
|
||||
|
||||
#endif // CEREAL_ARCHIVES_JSON_HPP_
|
||||
@@ -1,245 +0,0 @@
|
||||
/*! \file binary.hpp
|
||||
\brief Binary input and output archives */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ARCHIVES_PORTABLE_BINARY_HPP_
|
||||
#define CEREAL_ARCHIVES_PORTABLE_BINARY_HPP_
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
namespace portable_binary_detail
|
||||
{
|
||||
//! Returns true if the current machine is little endian
|
||||
/*! @ingroup Internal */
|
||||
inline bool is_little_endian()
|
||||
{
|
||||
static std::int32_t test = 1;
|
||||
return *reinterpret_cast<std::int8_t*>( &test ) == 1;
|
||||
}
|
||||
|
||||
//! Swaps the order of bytes for some chunk of memory
|
||||
/*! @param data The data as a uint8_t pointer
|
||||
@tparam DataSize The true size of the data
|
||||
@ingroup Internal */
|
||||
template <std::size_t DataSize>
|
||||
inline void swap_bytes( std::uint8_t * data )
|
||||
{
|
||||
for( std::size_t i = 0, end = DataSize / 2; i < end; ++i )
|
||||
std::swap( data[i], data[DataSize - i - 1] );
|
||||
}
|
||||
} // end namespace portable_binary_detail
|
||||
|
||||
// ######################################################################
|
||||
//! An output archive designed to save data in a compact binary representation portable over different architectures
|
||||
/*! This archive outputs data to a stream in an extremely compact binary
|
||||
representation with as little extra metadata as possible.
|
||||
|
||||
This archive will record the endianness of the data and assuming that
|
||||
the user takes care of ensuring serialized types are the same size
|
||||
across machines, is portable over different architectures.
|
||||
|
||||
When using a binary archive and a file stream, you must use the
|
||||
std::ios::binary format flag to avoid having your data altered
|
||||
inadvertently.
|
||||
|
||||
\warning This archive has not been thoroughly tested across different architectures.
|
||||
Please report any issues, optimizations, or feature requests at
|
||||
<a href="www.github.com/USCiLab/cereal">the project github</a>.
|
||||
|
||||
\ingroup Archives */
|
||||
class PortableBinaryOutputArchive : public OutputArchive<PortableBinaryOutputArchive, AllowEmptyClassElision>
|
||||
{
|
||||
public:
|
||||
//! Construct, outputting to the provided stream
|
||||
/*! @param stream The stream to output to. Can be a stringstream, a file stream, or
|
||||
even cout! */
|
||||
PortableBinaryOutputArchive(std::ostream & stream) :
|
||||
OutputArchive<PortableBinaryOutputArchive, AllowEmptyClassElision>(this),
|
||||
itsStream(stream)
|
||||
{
|
||||
this->operator()( portable_binary_detail::is_little_endian() );
|
||||
}
|
||||
|
||||
//! Writes size bytes of data to the output stream
|
||||
void saveBinary( const void * data, std::size_t size )
|
||||
{
|
||||
auto const writtenSize = static_cast<std::size_t>( itsStream.rdbuf()->sputn( reinterpret_cast<const char*>( data ), size ) );
|
||||
|
||||
if(writtenSize != size)
|
||||
throw Exception("Failed to write " + std::to_string(size) + " bytes to output stream! Wrote " + std::to_string(writtenSize));
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream & itsStream;
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
//! An input archive designed to load data saved using PortableBinaryOutputArchive
|
||||
/*! This archive outputs data to a stream in an extremely compact binary
|
||||
representation with as little extra metadata as possible.
|
||||
|
||||
This archive will load the endianness of the serialized data and
|
||||
if necessary transform it to match that of the local machine. This comes
|
||||
at a significant performance cost compared to non portable archives if
|
||||
the transformation is necessary, and also causes a small performance hit
|
||||
even if it is not necessary.
|
||||
|
||||
It is recommended to use portable archives only if you know that you will
|
||||
be sending binary data to machines with different endianness.
|
||||
|
||||
The archive will do nothing to ensure types are the same size - that is
|
||||
the responsibility of the user.
|
||||
|
||||
When using a binary archive and a file stream, you must use the
|
||||
std::ios::binary format flag to avoid having your data altered
|
||||
inadvertently.
|
||||
|
||||
\warning This archive has not been thoroughly tested across different architectures.
|
||||
Please report any issues, optimizations, or feature requests at
|
||||
<a href="www.github.com/USCiLab/cereal">the project github</a>.
|
||||
|
||||
\ingroup Archives */
|
||||
class PortableBinaryInputArchive : public InputArchive<PortableBinaryInputArchive, AllowEmptyClassElision>
|
||||
{
|
||||
public:
|
||||
//! Construct, loading from the provided stream
|
||||
/*! @param stream The stream to read from. */
|
||||
PortableBinaryInputArchive(std::istream & stream) :
|
||||
InputArchive<PortableBinaryInputArchive, AllowEmptyClassElision>(this),
|
||||
itsStream(stream),
|
||||
itsConvertEndianness( false )
|
||||
{
|
||||
bool streamLittleEndian;
|
||||
this->operator()( streamLittleEndian );
|
||||
itsConvertEndianness = portable_binary_detail::is_little_endian() ^ streamLittleEndian;
|
||||
}
|
||||
|
||||
//! Reads size bytes of data from the input stream
|
||||
/*! @param data The data to save
|
||||
@param size The number of bytes in the data
|
||||
@tparam DataSize T The size of the actual type of the data elements being loaded */
|
||||
template <std::size_t DataSize>
|
||||
void loadBinary( void * const data, std::size_t size )
|
||||
{
|
||||
// load data
|
||||
auto const readSize = static_cast<std::size_t>( itsStream.rdbuf()->sgetn( reinterpret_cast<char*>( data ), size ) );
|
||||
|
||||
if(readSize != size)
|
||||
throw Exception("Failed to read " + std::to_string(size) + " bytes from input stream! Read " + std::to_string(readSize));
|
||||
|
||||
// flip bits if needed
|
||||
if( itsConvertEndianness )
|
||||
{
|
||||
std::uint8_t * ptr = reinterpret_cast<std::uint8_t*>( data );
|
||||
for( std::size_t i = 0; i < size; i += DataSize )
|
||||
portable_binary_detail::swap_bytes<DataSize>( ptr );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::istream & itsStream;
|
||||
bool itsConvertEndianness; //!< If set to true, we will need to swap bytes upon loading
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
// Common BinaryArchive serialization functions
|
||||
|
||||
//! Saving for POD types to portable binary
|
||||
template<class T> inline
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
|
||||
CEREAL_SAVE_FUNCTION_NAME(PortableBinaryOutputArchive & ar, T const & t)
|
||||
{
|
||||
static_assert( !std::is_floating_point<T>::value ||
|
||||
(std::is_floating_point<T>::value && std::numeric_limits<T>::is_iec559),
|
||||
"Portable binary only supports IEEE 754 standardized floating point" );
|
||||
ar.saveBinary(std::addressof(t), sizeof(t));
|
||||
}
|
||||
|
||||
//! Loading for POD types from portable binary
|
||||
template<class T> inline
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
|
||||
CEREAL_LOAD_FUNCTION_NAME(PortableBinaryInputArchive & ar, T & t)
|
||||
{
|
||||
static_assert( !std::is_floating_point<T>::value ||
|
||||
(std::is_floating_point<T>::value && std::numeric_limits<T>::is_iec559),
|
||||
"Portable binary only supports IEEE 754 standardized floating point" );
|
||||
ar.template loadBinary<sizeof(T)>(std::addressof(t), sizeof(t));
|
||||
}
|
||||
|
||||
//! Serializing NVP types to portable binary
|
||||
template <class Archive, class T> inline
|
||||
CEREAL_ARCHIVE_RESTRICT(PortableBinaryInputArchive, PortableBinaryOutputArchive)
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, NameValuePair<T> & t )
|
||||
{
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
//! Serializing SizeTags to portable binary
|
||||
template <class Archive, class T> inline
|
||||
CEREAL_ARCHIVE_RESTRICT(PortableBinaryInputArchive, PortableBinaryOutputArchive)
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, SizeTag<T> & t )
|
||||
{
|
||||
ar( t.size );
|
||||
}
|
||||
|
||||
//! Saving binary data to portable binary
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(PortableBinaryOutputArchive & ar, BinaryData<T> const & bd)
|
||||
{
|
||||
typedef typename std::remove_pointer<T>::type TT;
|
||||
static_assert( !std::is_floating_point<TT>::value ||
|
||||
(std::is_floating_point<TT>::value && std::numeric_limits<TT>::is_iec559),
|
||||
"Portable binary only supports IEEE 754 standardized floating point" );
|
||||
|
||||
ar.saveBinary( bd.data, static_cast<std::size_t>( bd.size ) );
|
||||
}
|
||||
|
||||
//! Loading binary data from portable binary
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(PortableBinaryInputArchive & ar, BinaryData<T> & bd)
|
||||
{
|
||||
typedef typename std::remove_pointer<T>::type TT;
|
||||
static_assert( !std::is_floating_point<TT>::value ||
|
||||
(std::is_floating_point<TT>::value && std::numeric_limits<TT>::is_iec559),
|
||||
"Portable binary only supports IEEE 754 standardized floating point" );
|
||||
|
||||
ar.template loadBinary<sizeof(TT)>( bd.data, static_cast<std::size_t>( bd.size ) );
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
// register archives for polymorphic support
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryOutputArchive)
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryInputArchive)
|
||||
|
||||
// tie input and output archives together
|
||||
CEREAL_SETUP_ARCHIVE_TRAITS(cereal::PortableBinaryInputArchive, cereal::PortableBinaryOutputArchive)
|
||||
|
||||
#endif // CEREAL_ARCHIVES_PORTABLE_BINARY_HPP_
|
||||
@@ -1,882 +0,0 @@
|
||||
/*! \file xml.hpp
|
||||
\brief XML input and output archives */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_ARCHIVES_XML_HPP_
|
||||
#define CEREAL_ARCHIVES_XML_HPP_
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/details/util.hpp>
|
||||
|
||||
#include <cereal/external/rapidxml/rapidxml.hpp>
|
||||
#include <cereal/external/rapidxml/rapidxml_print.hpp>
|
||||
#include <cereal/external/base64.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
namespace xml_detail
|
||||
{
|
||||
#ifndef CEREAL_XML_STRING_VALUE
|
||||
//! The default name for the root node in a cereal xml archive.
|
||||
/*! You can define CEREAL_XML_STRING_VALUE to be different assuming you do so
|
||||
before this file is included. */
|
||||
#define CEREAL_XML_STRING_VALUE "cereal"
|
||||
#endif // CEREAL_XML_STRING_VALUE
|
||||
|
||||
//! The name given to the root node in a cereal xml archive
|
||||
static const char * CEREAL_XML_STRING = CEREAL_XML_STRING_VALUE;
|
||||
|
||||
//! Returns true if the character is whitespace
|
||||
inline bool isWhitespace( char c )
|
||||
{
|
||||
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
|
||||
}
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! An output archive designed to save data to XML
|
||||
/*! This archive uses RapidXML to build an in memory XML tree of the
|
||||
data it serializes before outputting it to its stream upon destruction.
|
||||
The envisioned way of using this archive is in an RAII fashion, letting
|
||||
the automatic destruction of the object cause the flush to its stream.
|
||||
|
||||
XML archives provides a human readable output but at decreased
|
||||
performance (both in time and space) compared to binary archives.
|
||||
|
||||
XML benefits greatly from name-value pairs, which if present, will
|
||||
name the nodes in the output. If these are not present, each level
|
||||
of the output tree will be given an automatically generated delimited name.
|
||||
|
||||
The precision of the output archive controls the number of decimals output
|
||||
for floating point numbers and should be sufficiently large (i.e. at least 20)
|
||||
if there is a desire to have binary equality between the numbers output and
|
||||
those read in. In general you should expect a loss of precision when going
|
||||
from floating point to text and back.
|
||||
|
||||
XML archives can optionally print the type of everything they serialize, which
|
||||
adds an attribute to each node.
|
||||
|
||||
XML archives do not output the size information for any dynamically sized structure
|
||||
and instead infer it from the number of children for a node. This means that data
|
||||
can be hand edited for dynamic sized structures and will still be readable. This
|
||||
is accomplished through the cereal::SizeTag object, which will also add an attribute
|
||||
to its parent field.
|
||||
\ingroup Archives */
|
||||
class XMLOutputArchive : public OutputArchive<XMLOutputArchive>, public traits::TextArchive
|
||||
{
|
||||
public:
|
||||
/*! @name Common Functionality
|
||||
Common use cases for directly interacting with an XMLOutputArchive */
|
||||
//! @{
|
||||
|
||||
//! A class containing various advanced options for the XML archive
|
||||
class Options
|
||||
{
|
||||
public:
|
||||
//! Default options
|
||||
static Options Default(){ return Options(); }
|
||||
|
||||
//! Default options with no indentation
|
||||
static Options NoIndent(){ return Options( std::numeric_limits<double>::max_digits10, false ); }
|
||||
|
||||
//! Specify specific options for the XMLOutputArchive
|
||||
/*! @param precision The precision used for floating point numbers
|
||||
@param indent Whether to indent each line of XML
|
||||
@param outputType Whether to output the type of each serialized object as an attribute */
|
||||
explicit Options( int precision = std::numeric_limits<double>::max_digits10,
|
||||
bool indent = true,
|
||||
bool outputType = false ) :
|
||||
itsPrecision( precision ),
|
||||
itsIndent( indent ),
|
||||
itsOutputType( outputType ) { }
|
||||
|
||||
private:
|
||||
friend class XMLOutputArchive;
|
||||
int itsPrecision;
|
||||
bool itsIndent;
|
||||
bool itsOutputType;
|
||||
};
|
||||
|
||||
//! Construct, outputting to the provided stream upon destruction
|
||||
/*! @param stream The stream to output to. Note that XML is only guaranteed to flush
|
||||
its output to the stream upon destruction.
|
||||
@param options The XML specific options to use. See the Options struct
|
||||
for the values of default parameters */
|
||||
XMLOutputArchive( std::ostream & stream, Options const & options = Options::Default() ) :
|
||||
OutputArchive<XMLOutputArchive>(this),
|
||||
itsStream(stream),
|
||||
itsOutputType( options.itsOutputType ),
|
||||
itsIndent( options.itsIndent )
|
||||
{
|
||||
// rapidxml will delete all allocations when xml_document is cleared
|
||||
auto node = itsXML.allocate_node( rapidxml::node_declaration );
|
||||
node->append_attribute( itsXML.allocate_attribute( "version", "1.0" ) );
|
||||
node->append_attribute( itsXML.allocate_attribute( "encoding", "utf-8" ) );
|
||||
itsXML.append_node( node );
|
||||
|
||||
// allocate root node
|
||||
auto root = itsXML.allocate_node( rapidxml::node_element, xml_detail::CEREAL_XML_STRING );
|
||||
itsXML.append_node( root );
|
||||
itsNodes.emplace( root );
|
||||
|
||||
// set attributes on the streams
|
||||
itsStream << std::boolalpha;
|
||||
itsStream.precision( options.itsPrecision );
|
||||
itsOS << std::boolalpha;
|
||||
itsOS.precision( options.itsPrecision );
|
||||
}
|
||||
|
||||
//! Destructor, flushes the XML
|
||||
~XMLOutputArchive()
|
||||
{
|
||||
const int flags = itsIndent ? 0x0 : rapidxml::print_no_indenting;
|
||||
rapidxml::print( itsStream, itsXML, flags );
|
||||
itsXML.clear();
|
||||
}
|
||||
|
||||
//! Saves some binary data, encoded as a base64 string, with an optional name
|
||||
/*! This can be called directly by users and it will automatically create a child node for
|
||||
the current XML node, populate it with a base64 encoded string, and optionally name
|
||||
it. The node will be finished after it has been populated. */
|
||||
void saveBinaryValue( const void * data, size_t size, const char * name = nullptr )
|
||||
{
|
||||
itsNodes.top().name = name;
|
||||
|
||||
startNode();
|
||||
|
||||
auto base64string = base64::encode( reinterpret_cast<const unsigned char *>( data ), size );
|
||||
saveValue( base64string );
|
||||
|
||||
if( itsOutputType )
|
||||
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "type", "cereal binary data" ) );
|
||||
|
||||
finishNode();
|
||||
};
|
||||
|
||||
//! @}
|
||||
/*! @name Internal Functionality
|
||||
Functionality designed for use by those requiring control over the inner mechanisms of
|
||||
the XMLOutputArchive */
|
||||
//! @{
|
||||
|
||||
//! Creates a new node that is a child of the node at the top of the stack
|
||||
/*! Nodes will be given a name that has either been pre-set by a name value pair,
|
||||
or generated based upon a counter unique to the parent node. If you want to
|
||||
give a node a specific name, use setNextName prior to calling startNode.
|
||||
|
||||
The node will then be pushed onto the node stack. */
|
||||
void startNode()
|
||||
{
|
||||
// generate a name for this new node
|
||||
const auto nameString = itsNodes.top().getValueName();
|
||||
|
||||
// allocate strings for all of the data in the XML object
|
||||
auto namePtr = itsXML.allocate_string( nameString.data(), nameString.length() + 1 );
|
||||
|
||||
// insert into the XML
|
||||
auto node = itsXML.allocate_node( rapidxml::node_element, namePtr, nullptr, nameString.size() );
|
||||
itsNodes.top().node->append_node( node );
|
||||
itsNodes.emplace( node );
|
||||
}
|
||||
|
||||
//! Designates the most recently added node as finished
|
||||
void finishNode()
|
||||
{
|
||||
itsNodes.pop();
|
||||
}
|
||||
|
||||
//! Sets the name for the next node created with startNode
|
||||
void setNextName( const char * name )
|
||||
{
|
||||
itsNodes.top().name = name;
|
||||
}
|
||||
|
||||
//! Saves some data, encoded as a string, into the current top level node
|
||||
/*! The data will be be named with the most recent name if one exists,
|
||||
otherwise it will be given some default delimited value that depends upon
|
||||
the parent node */
|
||||
template <class T> inline
|
||||
void saveValue( T const & value )
|
||||
{
|
||||
itsOS.clear(); itsOS.seekp( 0, std::ios::beg );
|
||||
itsOS << value << std::ends;
|
||||
|
||||
const auto strValue = itsOS.str();
|
||||
|
||||
// If the first or last character is a whitespace, add xml:space attribute
|
||||
// the string always contains a '\0' added by std::ends, so the last character is at len-2 and an 'empty'
|
||||
// string has a length of 1 or lower
|
||||
const auto len = strValue.length();
|
||||
if ( len > 1 && ( xml_detail::isWhitespace( strValue[0] ) || xml_detail::isWhitespace( strValue[len - 2] ) ) )
|
||||
{
|
||||
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "xml:space", "preserve" ) );
|
||||
}
|
||||
|
||||
// allocate strings for all of the data in the XML object
|
||||
auto dataPtr = itsXML.allocate_string( itsOS.str().c_str(), itsOS.str().length() + 1 );
|
||||
|
||||
// insert into the XML
|
||||
itsNodes.top().node->append_node( itsXML.allocate_node( rapidxml::node_data, nullptr, dataPtr ) );
|
||||
}
|
||||
|
||||
//! Overload for uint8_t prevents them from being serialized as characters
|
||||
void saveValue( uint8_t const & value )
|
||||
{
|
||||
saveValue( static_cast<uint32_t>( value ) );
|
||||
}
|
||||
|
||||
//! Overload for int8_t prevents them from being serialized as characters
|
||||
void saveValue( int8_t const & value )
|
||||
{
|
||||
saveValue( static_cast<int32_t>( value ) );
|
||||
}
|
||||
|
||||
//! Causes the type to be appended as an attribute to the most recently made node if output type is set to true
|
||||
template <class T> inline
|
||||
void insertType()
|
||||
{
|
||||
if( !itsOutputType )
|
||||
return;
|
||||
|
||||
// generate a name for this new node
|
||||
const auto nameString = util::demangledName<T>();
|
||||
|
||||
// allocate strings for all of the data in the XML object
|
||||
auto namePtr = itsXML.allocate_string( nameString.data(), nameString.length() + 1 );
|
||||
|
||||
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "type", namePtr ) );
|
||||
}
|
||||
|
||||
//! Appends an attribute to the current top level node
|
||||
void appendAttribute( const char * name, const char * value )
|
||||
{
|
||||
auto namePtr = itsXML.allocate_string( name );
|
||||
auto valuePtr = itsXML.allocate_string( value );
|
||||
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( namePtr, valuePtr ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
//! A struct that contains metadata about a node
|
||||
struct NodeInfo
|
||||
{
|
||||
NodeInfo( rapidxml::xml_node<> * n = nullptr,
|
||||
const char * nm = nullptr ) :
|
||||
node( n ),
|
||||
counter( 0 ),
|
||||
name( nm )
|
||||
{ }
|
||||
|
||||
rapidxml::xml_node<> * node; //!< A pointer to this node
|
||||
size_t counter; //!< The counter for naming child nodes
|
||||
const char * name; //!< The name for the next child node
|
||||
|
||||
//! Gets the name for the next child node created from this node
|
||||
/*! The name will be automatically generated using the counter if
|
||||
a name has not been previously set. If a name has been previously
|
||||
set, that name will be returned only once */
|
||||
std::string getValueName()
|
||||
{
|
||||
if( name )
|
||||
{
|
||||
auto n = name;
|
||||
name = nullptr;
|
||||
return {n};
|
||||
}
|
||||
else
|
||||
return "value" + std::to_string( counter++ ) + "\0";
|
||||
}
|
||||
}; // NodeInfo
|
||||
|
||||
//! @}
|
||||
|
||||
private:
|
||||
std::ostream & itsStream; //!< The output stream
|
||||
rapidxml::xml_document<> itsXML; //!< The XML document
|
||||
std::stack<NodeInfo> itsNodes; //!< A stack of nodes added to the document
|
||||
std::ostringstream itsOS; //!< Used to format strings internally
|
||||
bool itsOutputType; //!< Controls whether type information is printed
|
||||
bool itsIndent; //!< Controls whether indenting is used
|
||||
}; // XMLOutputArchive
|
||||
|
||||
// ######################################################################
|
||||
//! An output archive designed to load data from XML
|
||||
/*! This archive uses RapidXML to build an in memory XML tree of the
|
||||
data in the stream it is given before loading any types serialized.
|
||||
|
||||
Input XML should have been produced by the XMLOutputArchive. Data can
|
||||
only be added to dynamically sized containers - the input archive will
|
||||
determine their size by looking at the number of child nodes. Data that
|
||||
did not originate from an XMLOutputArchive is not officially supported,
|
||||
but may be possible to use if properly formatted.
|
||||
|
||||
The XMLInputArchive does not require that nodes are loaded in the same
|
||||
order they were saved by XMLOutputArchive. Using name value pairs (NVPs),
|
||||
it is possible to load in an out of order fashion or otherwise skip/select
|
||||
specific nodes to load.
|
||||
|
||||
The default behavior of the input archive is to read sequentially starting
|
||||
with the first node and exploring its children. When a given NVP does
|
||||
not match the read in name for a node, the archive will search for that
|
||||
node at the current level and load it if it exists. After loading an out of
|
||||
order node, the archive will then proceed back to loading sequentially from
|
||||
its new position.
|
||||
|
||||
Consider this simple example where loading of some data is skipped:
|
||||
|
||||
@code{cpp}
|
||||
// imagine the input file has someData(1-9) saved in order at the top level node
|
||||
ar( someData1, someData2, someData3 ); // XML loads in the order it sees in the file
|
||||
ar( cereal::make_nvp( "hello", someData6 ) ); // NVP given does not
|
||||
// match expected NVP name, so we search
|
||||
// for the given NVP and load that value
|
||||
ar( someData7, someData8, someData9 ); // with no NVP given, loading resumes at its
|
||||
// current location, proceeding sequentially
|
||||
@endcode
|
||||
|
||||
\ingroup Archives */
|
||||
class XMLInputArchive : public InputArchive<XMLInputArchive>, public traits::TextArchive
|
||||
{
|
||||
public:
|
||||
/*! @name Common Functionality
|
||||
Common use cases for directly interacting with an XMLInputArchive */
|
||||
//! @{
|
||||
|
||||
//! Construct, reading in from the provided stream
|
||||
/*! Reads in an entire XML document from some stream and parses it as soon
|
||||
as serialization starts
|
||||
|
||||
@param stream The stream to read from. Can be a stringstream or a file. */
|
||||
XMLInputArchive( std::istream & stream ) :
|
||||
InputArchive<XMLInputArchive>( this ),
|
||||
itsData( std::istreambuf_iterator<char>( stream ), std::istreambuf_iterator<char>() )
|
||||
{
|
||||
try
|
||||
{
|
||||
itsData.push_back('\0'); // rapidxml will do terrible things without the data being null terminated
|
||||
itsXML.parse<rapidxml::parse_trim_whitespace | rapidxml::parse_no_data_nodes | rapidxml::parse_declaration_node>( reinterpret_cast<char *>( itsData.data() ) );
|
||||
}
|
||||
catch( rapidxml::parse_error const & )
|
||||
{
|
||||
//std::cerr << "-----Original-----" << std::endl;
|
||||
//stream.seekg(0);
|
||||
//std::cout << std::string( std::istreambuf_iterator<char>( stream ), std::istreambuf_iterator<char>() ) << std::endl;
|
||||
|
||||
//std::cerr << "-----Error-----" << std::endl;
|
||||
//std::cerr << e.what() << std::endl;
|
||||
//std::cerr << e.where<char>() << std::endl;
|
||||
throw Exception("XML Parsing failed - likely due to invalid characters or invalid naming");
|
||||
}
|
||||
|
||||
// Parse the root
|
||||
auto root = itsXML.first_node( xml_detail::CEREAL_XML_STRING );
|
||||
if( root == nullptr )
|
||||
throw Exception("Could not detect cereal root node - likely due to empty or invalid input");
|
||||
else
|
||||
itsNodes.emplace( root );
|
||||
}
|
||||
|
||||
//! Loads some binary data, encoded as a base64 string, optionally specified by some name
|
||||
/*! This will automatically start and finish a node to load the data, and can be called directly by
|
||||
users.
|
||||
|
||||
Note that this follows the same ordering rules specified in the class description in regards
|
||||
to loading in/out of order */
|
||||
void loadBinaryValue( void * data, size_t size, const char * name = nullptr )
|
||||
{
|
||||
setNextName( name );
|
||||
startNode();
|
||||
|
||||
std::string encoded;
|
||||
loadValue( encoded );
|
||||
|
||||
auto decoded = base64::decode( encoded );
|
||||
|
||||
if( size != decoded.size() )
|
||||
throw Exception("Decoded binary data size does not match specified size");
|
||||
|
||||
std::memcpy( data, decoded.data(), decoded.size() );
|
||||
|
||||
finishNode();
|
||||
};
|
||||
|
||||
//! @}
|
||||
/*! @name Internal Functionality
|
||||
Functionality designed for use by those requiring control over the inner mechanisms of
|
||||
the XMLInputArchive */
|
||||
//! @{
|
||||
|
||||
//! Prepares to start reading the next node
|
||||
/*! This places the next node to be parsed onto the nodes stack.
|
||||
|
||||
By default our strategy is to start with the document root node and then
|
||||
recursively iterate through all children in the order they show up in the document.
|
||||
We don't need to know NVPs do to this; we'll just blindly load in the order things appear in.
|
||||
|
||||
We check to see if the specified NVP matches what the next automatically loaded node is. If they
|
||||
match, we just continue as normal, going in order. If they don't match, we attempt to find a node
|
||||
named after the NVP that is being loaded. If that NVP does not exist, we throw an exception. */
|
||||
void startNode()
|
||||
{
|
||||
auto next = itsNodes.top().child; // By default we would move to the next child node
|
||||
auto const expectedName = itsNodes.top().name; // this is the expected name from the NVP, if provided
|
||||
|
||||
// If we were given an NVP name, look for it in the current level of the document.
|
||||
// We only need to do this if either we have exhausted the siblings of the current level or
|
||||
// the NVP name does not match the name of the node we would normally read next
|
||||
if( expectedName && ( next == nullptr || std::strcmp( next->name(), expectedName ) != 0 ) )
|
||||
{
|
||||
next = itsNodes.top().search( expectedName );
|
||||
|
||||
if( next == nullptr )
|
||||
throw Exception("XML Parsing failed - provided NVP not found");
|
||||
}
|
||||
|
||||
itsNodes.emplace( next );
|
||||
}
|
||||
|
||||
//! Finishes reading the current node
|
||||
void finishNode()
|
||||
{
|
||||
// remove current
|
||||
itsNodes.pop();
|
||||
|
||||
// advance parent
|
||||
itsNodes.top().advance();
|
||||
|
||||
// Reset name
|
||||
itsNodes.top().name = nullptr;
|
||||
}
|
||||
|
||||
//! Retrieves the current node name
|
||||
//! will return @c nullptr if the node does not have a name
|
||||
const char * getNodeName() const
|
||||
{
|
||||
return itsNodes.top().node->name();
|
||||
}
|
||||
|
||||
//! Sets the name for the next node created with startNode
|
||||
void setNextName( const char * name )
|
||||
{
|
||||
itsNodes.top().name = name;
|
||||
}
|
||||
|
||||
//! Loads a bool from the current top node
|
||||
template <class T, traits::EnableIf<std::is_unsigned<T>::value,
|
||||
std::is_same<T, bool>::value> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
std::istringstream is( itsNodes.top().node->value() );
|
||||
is.setf( std::ios::boolalpha );
|
||||
is >> value;
|
||||
}
|
||||
|
||||
//! Loads a char (signed or unsigned) from the current top node
|
||||
template <class T, traits::EnableIf<std::is_integral<T>::value,
|
||||
!std::is_same<T, bool>::value,
|
||||
sizeof(T) == sizeof(char)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = *reinterpret_cast<T*>( itsNodes.top().node->value() );
|
||||
}
|
||||
|
||||
//! Load an int8_t from the current top node (ensures we parse entire number)
|
||||
void loadValue( int8_t & value )
|
||||
{
|
||||
int32_t val; loadValue( val ); value = static_cast<int8_t>( val );
|
||||
}
|
||||
|
||||
//! Load a uint8_t from the current top node (ensures we parse entire number)
|
||||
void loadValue( uint8_t & value )
|
||||
{
|
||||
uint32_t val; loadValue( val ); value = static_cast<uint8_t>( val );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as an unsigned long from the current top node
|
||||
template <class T, traits::EnableIf<std::is_unsigned<T>::value,
|
||||
!std::is_same<T, bool>::value,
|
||||
!std::is_same<T, unsigned char>::value,
|
||||
sizeof(T) < sizeof(long long)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = static_cast<T>( std::stoul( itsNodes.top().node->value() ) );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as an unsigned long long from the current top node
|
||||
template <class T, traits::EnableIf<std::is_unsigned<T>::value,
|
||||
!std::is_same<T, bool>::value,
|
||||
sizeof(T) >= sizeof(long long)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = static_cast<T>( std::stoull( itsNodes.top().node->value() ) );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as an int from the current top node
|
||||
template <class T, traits::EnableIf<std::is_signed<T>::value,
|
||||
!std::is_same<T, char>::value,
|
||||
sizeof(T) <= sizeof(int)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = static_cast<T>( std::stoi( itsNodes.top().node->value() ) );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as a long from the current top node
|
||||
template <class T, traits::EnableIf<std::is_signed<T>::value,
|
||||
(sizeof(T) > sizeof(int)),
|
||||
sizeof(T) <= sizeof(long)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = static_cast<T>( std::stol( itsNodes.top().node->value() ) );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as a long long from the current top node
|
||||
template <class T, traits::EnableIf<std::is_signed<T>::value,
|
||||
(sizeof(T) > sizeof(long)),
|
||||
sizeof(T) <= sizeof(long long)> = traits::sfinae> inline
|
||||
void loadValue( T & value )
|
||||
{
|
||||
value = static_cast<T>( std::stoll( itsNodes.top().node->value() ) );
|
||||
}
|
||||
|
||||
//! Loads a type best represented as a float from the current top node
|
||||
void loadValue( float & value )
|
||||
{
|
||||
try
|
||||
{
|
||||
value = std::stof( itsNodes.top().node->value() );
|
||||
}
|
||||
catch( std::out_of_range const & )
|
||||
{
|
||||
// special case for denormalized values
|
||||
std::istringstream is( itsNodes.top().node->value() );
|
||||
is >> value;
|
||||
if( std::fpclassify( value ) != FP_SUBNORMAL )
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//! Loads a type best represented as a double from the current top node
|
||||
void loadValue( double & value )
|
||||
{
|
||||
try
|
||||
{
|
||||
value = std::stod( itsNodes.top().node->value() );
|
||||
}
|
||||
catch( std::out_of_range const & )
|
||||
{
|
||||
// special case for denormalized values
|
||||
std::istringstream is( itsNodes.top().node->value() );
|
||||
is >> value;
|
||||
if( std::fpclassify( value ) != FP_SUBNORMAL )
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//! Loads a type best represented as a long double from the current top node
|
||||
void loadValue( long double & value )
|
||||
{
|
||||
try
|
||||
{
|
||||
value = std::stold( itsNodes.top().node->value() );
|
||||
}
|
||||
catch( std::out_of_range const & )
|
||||
{
|
||||
// special case for denormalized values
|
||||
std::istringstream is( itsNodes.top().node->value() );
|
||||
is >> value;
|
||||
if( std::fpclassify( value ) != FP_SUBNORMAL )
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//! Loads a string from the current node from the current top node
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void loadValue( std::basic_string<CharT, Traits, Alloc> & str )
|
||||
{
|
||||
std::basic_istringstream<CharT, Traits> is( itsNodes.top().node->value() );
|
||||
|
||||
str.assign( std::istreambuf_iterator<CharT, Traits>( is ),
|
||||
std::istreambuf_iterator<CharT, Traits>() );
|
||||
}
|
||||
|
||||
//! Loads the size of the current top node
|
||||
template <class T> inline
|
||||
void loadSize( T & value )
|
||||
{
|
||||
value = getNumChildren( itsNodes.top().node );
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Gets the number of children (usually interpreted as size) for the specified node
|
||||
static size_t getNumChildren( rapidxml::xml_node<> * node )
|
||||
{
|
||||
size_t size = 0;
|
||||
node = node->first_node(); // get first child
|
||||
|
||||
while( node != nullptr )
|
||||
{
|
||||
++size;
|
||||
node = node->next_sibling();
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
//! A struct that contains metadata about a node
|
||||
/*! Keeps track of some top level node, its number of
|
||||
remaining children, and the current active child node */
|
||||
struct NodeInfo
|
||||
{
|
||||
NodeInfo( rapidxml::xml_node<> * n = nullptr ) :
|
||||
node( n ),
|
||||
child( n->first_node() ),
|
||||
size( XMLInputArchive::getNumChildren( n ) ),
|
||||
name( nullptr )
|
||||
{ }
|
||||
|
||||
//! Advances to the next sibling node of the child
|
||||
/*! If this is the last sibling child will be null after calling */
|
||||
void advance()
|
||||
{
|
||||
if( size > 0 )
|
||||
{
|
||||
--size;
|
||||
child = child->next_sibling();
|
||||
}
|
||||
}
|
||||
|
||||
//! Searches for a child with the given name in this node
|
||||
/*! @param searchName The name to search for (must be null terminated)
|
||||
@return The node if found, nullptr otherwise */
|
||||
rapidxml::xml_node<> * search( const char * searchName )
|
||||
{
|
||||
if( searchName )
|
||||
{
|
||||
size_t new_size = XMLInputArchive::getNumChildren( node );
|
||||
const size_t name_size = rapidxml::internal::measure( searchName );
|
||||
|
||||
for( auto new_child = node->first_node(); new_child != nullptr; new_child = new_child->next_sibling() )
|
||||
{
|
||||
if( rapidxml::internal::compare( new_child->name(), new_child->name_size(), searchName, name_size, true ) )
|
||||
{
|
||||
size = new_size;
|
||||
child = new_child;
|
||||
|
||||
return new_child;
|
||||
}
|
||||
--new_size;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rapidxml::xml_node<> * node; //!< A pointer to this node
|
||||
rapidxml::xml_node<> * child; //!< A pointer to its current child
|
||||
size_t size; //!< The remaining number of children for this node
|
||||
const char * name; //!< The NVP name for next next child node
|
||||
}; // NodeInfo
|
||||
|
||||
//! @}
|
||||
|
||||
private:
|
||||
std::vector<char> itsData; //!< The raw data loaded
|
||||
rapidxml::xml_document<> itsXML; //!< The XML document
|
||||
std::stack<NodeInfo> itsNodes; //!< A stack of nodes read from the document
|
||||
};
|
||||
|
||||
// ######################################################################
|
||||
// XMLArchive prologue and epilogue functions
|
||||
// ######################################################################
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for NVPs for XML output archives
|
||||
/*! NVPs do not start or finish nodes - they just set up the names */
|
||||
template <class T> inline
|
||||
void prologue( XMLOutputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
//! Prologue for NVPs for XML input archives
|
||||
template <class T> inline
|
||||
void prologue( XMLInputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for NVPs for XML output archives
|
||||
/*! NVPs do not start or finish nodes - they just set up the names */
|
||||
template <class T> inline
|
||||
void epilogue( XMLOutputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
//! Epilogue for NVPs for XML input archives
|
||||
template <class T> inline
|
||||
void epilogue( XMLInputArchive &, NameValuePair<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for SizeTags for XML output archives
|
||||
/*! SizeTags do not start or finish nodes */
|
||||
template <class T> inline
|
||||
void prologue( XMLOutputArchive & ar, SizeTag<T> const & )
|
||||
{
|
||||
ar.appendAttribute( "size", "dynamic" );
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
void prologue( XMLInputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
//! Epilogue for SizeTags for XML output archives
|
||||
/*! SizeTags do not start or finish nodes */
|
||||
template <class T> inline
|
||||
void epilogue( XMLOutputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
template <class T> inline
|
||||
void epilogue( XMLInputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Prologue for all other types for XML output archives (except minimal types)
|
||||
/*! Starts a new node, named either automatically or by some NVP,
|
||||
that may be given data by the type about to be archived
|
||||
|
||||
Minimal types do not start or end nodes */
|
||||
template <class T, traits::DisableIf<traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, XMLOutputArchive>::value ||
|
||||
traits::has_minimal_output_serialization<T, XMLOutputArchive>::value> = traits::sfinae> inline
|
||||
void prologue( XMLOutputArchive & ar, T const & )
|
||||
{
|
||||
ar.startNode();
|
||||
ar.insertType<T>();
|
||||
}
|
||||
|
||||
//! Prologue for all other types for XML input archives (except minimal types)
|
||||
template <class T, traits::DisableIf<traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, XMLInputArchive>::value ||
|
||||
traits::has_minimal_input_serialization<T, XMLInputArchive>::value> = traits::sfinae> inline
|
||||
void prologue( XMLInputArchive & ar, T const & )
|
||||
{
|
||||
ar.startNode();
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Epilogue for all other types other for XML output archives (except minimal types)
|
||||
/*! Finishes the node created in the prologue
|
||||
|
||||
Minimal types do not start or end nodes */
|
||||
template <class T, traits::DisableIf<traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, XMLOutputArchive>::value ||
|
||||
traits::has_minimal_output_serialization<T, XMLOutputArchive>::value> = traits::sfinae> inline
|
||||
void epilogue( XMLOutputArchive & ar, T const & )
|
||||
{
|
||||
ar.finishNode();
|
||||
}
|
||||
|
||||
//! Epilogue for all other types other for XML output archives (except minimal types)
|
||||
template <class T, traits::DisableIf<traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, XMLInputArchive>::value ||
|
||||
traits::has_minimal_input_serialization<T, XMLInputArchive>::value> = traits::sfinae> inline
|
||||
void epilogue( XMLInputArchive & ar, T const & )
|
||||
{
|
||||
ar.finishNode();
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
// Common XMLArchive serialization functions
|
||||
// ######################################################################
|
||||
|
||||
//! Saving NVP types to XML
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME( XMLOutputArchive & ar, NameValuePair<T> const & t )
|
||||
{
|
||||
ar.setNextName( t.name );
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
//! Loading NVP types from XML
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME( XMLInputArchive & ar, NameValuePair<T> & t )
|
||||
{
|
||||
ar.setNextName( t.name );
|
||||
ar( t.value );
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Saving SizeTags to XML
|
||||
template <class T> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME( XMLOutputArchive &, SizeTag<T> const & )
|
||||
{ }
|
||||
|
||||
//! Loading SizeTags from XML
|
||||
template <class T> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME( XMLInputArchive & ar, SizeTag<T> & st )
|
||||
{
|
||||
ar.loadSize( st.size );
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Saving for POD types to xml
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(XMLOutputArchive & ar, T const & t)
|
||||
{
|
||||
ar.saveValue( t );
|
||||
}
|
||||
|
||||
//! Loading for POD types from xml
|
||||
template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(XMLInputArchive & ar, T & t)
|
||||
{
|
||||
ar.loadValue( t );
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! saving string to xml
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void CEREAL_SAVE_FUNCTION_NAME(XMLOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
|
||||
{
|
||||
ar.saveValue( str );
|
||||
}
|
||||
|
||||
//! loading string from xml
|
||||
template<class CharT, class Traits, class Alloc> inline
|
||||
void CEREAL_LOAD_FUNCTION_NAME(XMLInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
|
||||
{
|
||||
ar.loadValue( str );
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
// register archives for polymorphic support
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::XMLOutputArchive)
|
||||
CEREAL_REGISTER_ARCHIVE(cereal::XMLInputArchive)
|
||||
|
||||
// tie input and output archives together
|
||||
CEREAL_SETUP_ARCHIVE_TRAITS(cereal::XMLInputArchive, cereal::XMLOutputArchive)
|
||||
|
||||
#endif // CEREAL_ARCHIVES_XML_HPP_
|
||||
@@ -1,955 +0,0 @@
|
||||
/*! \file cereal.hpp
|
||||
\brief Main cereal functionality */
|
||||
/*
|
||||
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of cereal nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CEREAL_CEREAL_HPP_
|
||||
#define CEREAL_CEREAL_HPP_
|
||||
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
#include <cereal/macros.hpp>
|
||||
#include <cereal/details/traits.hpp>
|
||||
#include <cereal/details/helpers.hpp>
|
||||
#include <cereal/types/base_class.hpp>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
// ######################################################################
|
||||
//! Creates a name value pair
|
||||
/*! @relates NameValuePair
|
||||
@ingroup Utility */
|
||||
template <class T> inline
|
||||
NameValuePair<T> make_nvp( std::string const & name, T && value )
|
||||
{
|
||||
return {name.c_str(), std::forward<T>(value)};
|
||||
}
|
||||
|
||||
//! Creates a name value pair
|
||||
/*! @relates NameValuePair
|
||||
@ingroup Utility */
|
||||
template <class T> inline
|
||||
NameValuePair<T> make_nvp( const char * name, T && value )
|
||||
{
|
||||
return {name, std::forward<T>(value)};
|
||||
}
|
||||
|
||||
//! Creates a name value pair for the variable T with the same name as the variable
|
||||
/*! @relates NameValuePair
|
||||
@ingroup Utility */
|
||||
#define CEREAL_NVP(T) ::cereal::make_nvp(#T, T)
|
||||
|
||||
// ######################################################################
|
||||
//! Convenience function to create binary data for both const and non const pointers
|
||||
/*! @param data Pointer to beginning of the data
|
||||
@param size The size in bytes of the data
|
||||
@relates BinaryData
|
||||
@ingroup Utility */
|
||||
template <class T> inline
|
||||
BinaryData<T> binary_data( T && data, size_t size )
|
||||
{
|
||||
return {std::forward<T>(data), size};
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Creates a size tag from some variable.
|
||||
/*! Will normally be used to serialize size (e.g. size()) information for
|
||||
variable size containers. If you have a variable sized container,
|
||||
the very first thing it serializes should be its size, wrapped in
|
||||
a SizeTag.
|
||||
|
||||
@relates SizeTag
|
||||
@ingroup Utility */
|
||||
template <class T>
|
||||
SizeTag<T> make_size_tag( T && sz )
|
||||
{
|
||||
return {std::forward<T>(sz)};
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
//! Called before a type is serialized to set up any special archive state
|
||||
//! for processing some type
|
||||
/*! If designing a serializer that needs to set up any kind of special
|
||||
state or output extra information for a type, specialize this function
|
||||
for the archive type and the types that require the extra information.
|
||||
@ingroup Internal */
|
||||
template <class Archive, class T>
|
||||
void prologue( Archive & /* archive */, T const & /* data */)
|
||||
{ }
|
||||
|
||||
//! Called after a type is serialized to tear down any special archive state
|
||||
//! for processing some type
|
||||
/*! @ingroup Internal */
|
||||
template <class Archive, class T>
|
||||
void epilogue( Archive & /* archive */, T const & /* data */)
|
||||
{ }
|
||||
|
||||
// ######################################################################
|
||||
//! Special flags for archives
|
||||
/*! AllowEmptyClassElision
|
||||
This allows for empty classes to be serialized even if they do not provide
|
||||
a serialization function. Classes with no data members are considered to be
|
||||
empty. Be warned that if this is enabled and you attempt to serialize an
|
||||
empty class with improperly formed serialize or load/save functions, no
|
||||
static error will occur - the error will propogate silently and your
|
||||
intended serialization functions may not be called. You can manually
|
||||
ensure that your classes that have custom serialization are correct
|
||||
by using the traits is_output_serializable and is_input_serializable
|
||||
in cereal/details/traits.hpp.
|
||||
@ingroup Internal */
|
||||
enum Flags { AllowEmptyClassElision = 1 };
|
||||
|
||||
// ######################################################################
|
||||
//! Registers a specific Archive type with cereal
|
||||
/*! This registration should be done once per archive. A good place to
|
||||
put this is immediately following the definition of your archive.
|
||||
Archive registration is only strictly necessary if you wish to
|
||||
support pointers to polymorphic data types. All archives that
|
||||
come with cereal are already registered.
|
||||
@ingroup Internal */
|
||||
#define CEREAL_REGISTER_ARCHIVE(Archive) \
|
||||
namespace cereal { namespace detail { \
|
||||
template <class T, class BindingTag> \
|
||||
typename polymorphic_serialization_support<Archive, T>::type \
|
||||
instantiate_polymorphic_binding( T*, Archive*, BindingTag, adl_tag ); \
|
||||
} } /* end namespaces */
|
||||
|
||||
// ######################################################################
|
||||
//! Defines a class version for some type
|
||||
/*! Versioning information is optional and adds some small amount of
|
||||
overhead to serialization. This overhead will occur both in terms of
|
||||
space in the archive (the version information for each class will be
|
||||
stored exactly once) as well as runtime (versioned serialization functions
|
||||
must check to see if they need to load or store version information).
|
||||
|
||||
Versioning is useful if you plan on fundamentally changing the way some
|
||||
type is serialized in the future. Versioned serialization functions
|
||||
cannot be used to load non-versioned data.
|
||||
|
||||
By default, all types have an assumed version value of zero. By
|
||||
using this macro, you may change the version number associated with
|
||||
some type. cereal will then use this value as a second parameter
|
||||
to your serialization functions.
|
||||
|
||||
The interface for the serialization functions is nearly identical
|
||||
to non-versioned serialization with the addition of a second parameter,
|
||||
const std::uint32_t version, which will be supplied with the correct
|
||||
version number. Serializing the version number on a save happens
|
||||
automatically.
|
||||
|
||||
Versioning cannot be mixed with non-versioned serialization functions.
|
||||
Having both types will result result in a compile time error. Data
|
||||
serialized without versioning cannot be loaded by a serialization
|
||||
function with added versioning support.
|
||||
|
||||
Example interface for versioning on a non-member serialize function:
|
||||
|
||||
@code{cpp}
|
||||
CEREAL_CLASS_VERSION( Mytype, 77 ); // register class version
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar, Mytype & t, const std::uint32_t version )
|
||||
{
|
||||
// When performing a load, the version associated with the class
|
||||
// is whatever it was when that data was originally serialized
|
||||
//
|
||||
// When we save, we'll use the version that is defined in the macro
|
||||
|
||||
if( version >= some_number )
|
||||
// do this
|
||||
else
|
||||
// do that
|
||||
}
|
||||
@endcode
|
||||
|
||||
Interfaces for other forms of serialization functions is similar. This
|
||||
macro should be placed at global scope.
|
||||
@ingroup Utility */
|
||||
#define CEREAL_CLASS_VERSION(TYPE, VERSION_NUMBER) \
|
||||
namespace cereal { namespace detail { \
|
||||
template <> struct Version<TYPE> \
|
||||
{ \
|
||||
static const std::uint32_t version; \
|
||||
static std::uint32_t registerVersion() \
|
||||
{ \
|
||||
::cereal::detail::StaticObject<Versions>::getInstance().mapping.emplace( \
|
||||
std::type_index(typeid(TYPE)).hash_code(), VERSION_NUMBER ); \
|
||||
return VERSION_NUMBER; \
|
||||
} \
|
||||
static void unused() { (void)version; } \
|
||||
}; /* end Version */ \
|
||||
const std::uint32_t Version<TYPE>::version = \
|
||||
Version<TYPE>::registerVersion(); \
|
||||
} } // end namespaces
|
||||
|
||||
// ######################################################################
|
||||
//! The base output archive class
|
||||
/*! This is the base output archive for all output archives. If you create
|
||||
a custom archive class, it should derive from this, passing itself as
|
||||
a template parameter for the ArchiveType.
|
||||
|
||||
The base class provides all of the functionality necessary to
|
||||
properly forward data to the correct serialization functions.
|
||||
|
||||
Individual archives should use a combination of prologue and
|
||||
epilogue functions together with specializations of serialize, save,
|
||||
and load to alter the functionality of their serialization.
|
||||
|
||||
@tparam ArchiveType The archive type that derives from OutputArchive
|
||||
@tparam Flags Flags to control advanced functionality. See the Flags
|
||||
enum for more information.
|
||||
@ingroup Internal */
|
||||
template<class ArchiveType, std::uint32_t Flags = 0>
|
||||
class OutputArchive : public detail::OutputArchiveBase
|
||||
{
|
||||
public:
|
||||
//! Construct the output archive
|
||||
/*! @param derived A pointer to the derived ArchiveType (pass this from the derived archive) */
|
||||
OutputArchive(ArchiveType * const derived) : self(derived), itsCurrentPointerId(1), itsCurrentPolymorphicTypeId(1)
|
||||
{ }
|
||||
|
||||
OutputArchive & operator=( OutputArchive const & ) = delete;
|
||||
|
||||
//! Serializes all passed in data
|
||||
/*! This is the primary interface for serializing data with an archive */
|
||||
template <class ... Types> inline
|
||||
ArchiveType & operator()( Types && ... args )
|
||||
{
|
||||
self->process( std::forward<Types>( args )... );
|
||||
return *self;
|
||||
}
|
||||
|
||||
/*! @name Boost Transition Layer
|
||||
Functionality that mirrors the syntax for Boost. This is useful if you are transitioning
|
||||
a large project from Boost to cereal. The preferred interface for cereal is using operator(). */
|
||||
//! @{
|
||||
|
||||
//! Serializes passed in data
|
||||
/*! This is a boost compatability layer and is not the preferred way of using
|
||||
cereal. If you are transitioning from boost, use this until you can
|
||||
transition to the operator() overload */
|
||||
template <class T> inline
|
||||
ArchiveType & operator&( T && arg )
|
||||
{
|
||||
self->process( std::forward<T>( arg ) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Serializes passed in data
|
||||
/*! This is a boost compatability layer and is not the preferred way of using
|
||||
cereal. If you are transitioning from boost, use this until you can
|
||||
transition to the operator() overload */
|
||||
template <class T> inline
|
||||
ArchiveType & operator<<( T && arg )
|
||||
{
|
||||
self->process( std::forward<T>( arg ) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
//! Registers a shared pointer with the archive
|
||||
/*! This function is used to track shared pointer targets to prevent
|
||||
unnecessary saves from taking place if multiple shared pointers
|
||||
point to the same data.
|
||||
|
||||
@internal
|
||||
@param addr The address (see shared_ptr get()) pointed to by the shared pointer
|
||||
@return A key that uniquely identifies the pointer */
|
||||
inline std::uint32_t registerSharedPointer( void const * addr )
|
||||
{
|
||||
// Handle null pointers by just returning 0
|
||||
if(addr == 0) return 0;
|
||||
|
||||
auto id = itsSharedPointerMap.find( addr );
|
||||
if( id == itsSharedPointerMap.end() )
|
||||
{
|
||||
auto ptrId = itsCurrentPointerId++;
|
||||
itsSharedPointerMap.insert( {addr, ptrId} );
|
||||
return ptrId | detail::msb_32bit; // mask MSB to be 1
|
||||
}
|
||||
else
|
||||
return id->second;
|
||||
}
|
||||
|
||||
//! Registers a polymorphic type name with the archive
|
||||
/*! This function is used to track polymorphic types to prevent
|
||||
unnecessary saves of identifying strings used by the polymorphic
|
||||
support functionality.
|
||||
|
||||
@internal
|
||||
@param name The name to associate with a polymorphic type
|
||||
@return A key that uniquely identifies the polymorphic type name */
|
||||
inline std::uint32_t registerPolymorphicType( char const * name )
|
||||
{
|
||||
auto id = itsPolymorphicTypeMap.find( name );
|
||||
if( id == itsPolymorphicTypeMap.end() )
|
||||
{
|
||||
auto polyId = itsCurrentPolymorphicTypeId++;
|
||||
itsPolymorphicTypeMap.insert( {name, polyId} );
|
||||
return polyId | detail::msb_32bit; // mask MSB to be 1
|
||||
}
|
||||
else
|
||||
return id->second;
|
||||
}
|
||||
|
||||
private:
|
||||
//! Serializes data after calling prologue, then calls epilogue
|
||||
template <class T> inline
|
||||
void process( T && head )
|
||||
{
|
||||
prologue( *self, head );
|
||||
self->processImpl( head );
|
||||
epilogue( *self, head );
|
||||
}
|
||||
|
||||
//! Unwinds to process all data
|
||||
template <class T, class ... Other> inline
|
||||
void process( T && head, Other && ... tail )
|
||||
{
|
||||
self->process( std::forward<T>( head ) );
|
||||
self->process( std::forward<Other>( tail )... );
|
||||
}
|
||||
|
||||
//! Serialization of a virtual_base_class wrapper
|
||||
/*! \sa virtual_base_class */
|
||||
template <class T> inline
|
||||
ArchiveType & processImpl(virtual_base_class<T> const & b)
|
||||
{
|
||||
traits::detail::base_class_id id(b.base_ptr);
|
||||
if(itsBaseClassSet.count(id) == 0)
|
||||
{
|
||||
itsBaseClassSet.insert(id);
|
||||
self->processImpl( *b.base_ptr );
|
||||
}
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Serialization of a base_class wrapper
|
||||
/*! \sa base_class */
|
||||
template <class T> inline
|
||||
ArchiveType & processImpl(base_class<T> const & b)
|
||||
{
|
||||
self->processImpl( *b.base_ptr );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Helper macro that expands the requirements for activating an overload
|
||||
/*! Requirements:
|
||||
Has the requested serialization function
|
||||
Does not have version and unversioned at the same time
|
||||
Is output serializable AND
|
||||
is specialized for this type of function OR
|
||||
has no specialization at all */
|
||||
#define PROCESS_IF(name) \
|
||||
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
|
||||
!traits::has_invalid_output_versioning<T, ArchiveType>::value, \
|
||||
(traits::is_output_serializable<T, ArchiveType>::value && \
|
||||
(traits::is_specialized_##name<T, ArchiveType>::value || \
|
||||
!traits::is_specialized<T, ArchiveType>::value))> = traits::sfinae
|
||||
|
||||
//! Member serialization
|
||||
template <class T, PROCESS_IF(member_serialize)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
access::member_serialize(*self, const_cast<T &>(t));
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member serialization
|
||||
template <class T, PROCESS_IF(non_member_serialize)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME(*self, const_cast<T &>(t));
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (save)
|
||||
template <class T, PROCESS_IF(member_save)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
access::member_save(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (save)
|
||||
template <class T, PROCESS_IF(non_member_save)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
CEREAL_SAVE_FUNCTION_NAME(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (save_minimal)
|
||||
template <class T, PROCESS_IF(member_save_minimal)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
self->process( access::member_save_minimal(*self, t) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (save_minimal)
|
||||
template <class T, PROCESS_IF(non_member_save_minimal)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
self->process( CEREAL_SAVE_MINIMAL_FUNCTION_NAME(*self, t) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Empty class specialization
|
||||
template <class T, traits::EnableIf<(Flags & AllowEmptyClassElision),
|
||||
!traits::is_output_serializable<T, ArchiveType>::value,
|
||||
std::is_empty<T>::value> = traits::sfinae> inline
|
||||
ArchiveType & processImpl(T const &)
|
||||
{
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! No matching serialization
|
||||
/*! Invalid if we have invalid output versioning or
|
||||
we are not output serializable, and either
|
||||
don't allow empty class ellision or allow it but are not serializing an empty class */
|
||||
template <class T, traits::EnableIf<traits::has_invalid_output_versioning<T, ArchiveType>::value ||
|
||||
(!traits::is_output_serializable<T, ArchiveType>::value &&
|
||||
(!(Flags & AllowEmptyClassElision) || ((Flags & AllowEmptyClassElision) && !std::is_empty<T>::value)))> = traits::sfinae> inline
|
||||
ArchiveType & processImpl(T const &)
|
||||
{
|
||||
static_assert(traits::detail::count_output_serializers<T, ArchiveType>::value != 0,
|
||||
"cereal could not find any output serialization functions for the provided type and archive combination. \n\n "
|
||||
"Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these). \n "
|
||||
"Serialize functions generally have the following signature: \n\n "
|
||||
"template<class Archive> \n "
|
||||
" void serialize(Archive & ar) \n "
|
||||
" { \n "
|
||||
" ar( member1, member2, member3 ); \n "
|
||||
" } \n\n " );
|
||||
|
||||
static_assert(traits::detail::count_output_serializers<T, ArchiveType>::value < 2,
|
||||
"cereal found more than one compatible output serialization function for the provided type and archive combination. \n\n "
|
||||
"Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these). \n "
|
||||
"Use specialization (see access.hpp) if you need to disambiguate between serialize vs load/save functions. \n "
|
||||
"Note that serialization functions can be inherited which may lead to the aforementioned ambiguities. \n "
|
||||
"In addition, you may not mix versioned with non-versioned serialization functions. \n\n ");
|
||||
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Registers a class version with the archive and serializes it if necessary
|
||||
/*! If this is the first time this class has been serialized, we will record its
|
||||
version number and serialize that.
|
||||
|
||||
@tparam T The type of the class being serialized
|
||||
@param version The version number associated with it */
|
||||
template <class T> inline
|
||||
std::uint32_t registerClassVersion()
|
||||
{
|
||||
static const auto hash = std::type_index(typeid(T)).hash_code();
|
||||
const auto insertResult = itsVersionedTypes.insert( hash );
|
||||
const auto version =
|
||||
detail::StaticObject<detail::Versions>::getInstance().find( hash, detail::Version<T>::version );
|
||||
|
||||
if( insertResult.second ) // insertion took place, serialize the version number
|
||||
process( make_nvp<ArchiveType>("cereal_class_version", version) );
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
//! Member serialization
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_serialize)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
access::member_serialize(*self, const_cast<T &>(t), registerClassVersion<T>());
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member serialization
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_serialize)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME(*self, const_cast<T &>(t), registerClassVersion<T>());
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (save)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_save)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
access::member_save(*self, t, registerClassVersion<T>());
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (save)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_save)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
CEREAL_SAVE_FUNCTION_NAME(*self, t, registerClassVersion<T>());
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (save_minimal)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_save_minimal)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
self->process( access::member_save_minimal(*self, t, registerClassVersion<T>()) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (save_minimal)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_save_minimal)> inline
|
||||
ArchiveType & processImpl(T const & t)
|
||||
{
|
||||
self->process( CEREAL_SAVE_MINIMAL_FUNCTION_NAME(*self, t, registerClassVersion<T>()) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
#undef PROCESS_IF
|
||||
|
||||
private:
|
||||
ArchiveType * const self;
|
||||
|
||||
//! A set of all base classes that have been serialized
|
||||
std::unordered_set<traits::detail::base_class_id, traits::detail::base_class_id_hash> itsBaseClassSet;
|
||||
|
||||
//! Maps from addresses to pointer ids
|
||||
std::unordered_map<void const *, std::uint32_t> itsSharedPointerMap;
|
||||
|
||||
//! The id to be given to the next pointer
|
||||
std::uint32_t itsCurrentPointerId;
|
||||
|
||||
//! Maps from polymorphic type name strings to ids
|
||||
std::unordered_map<char const *, std::uint32_t> itsPolymorphicTypeMap;
|
||||
|
||||
//! The id to be given to the next polymorphic type name
|
||||
std::uint32_t itsCurrentPolymorphicTypeId;
|
||||
|
||||
//! Keeps track of classes that have versioning information associated with them
|
||||
std::unordered_set<size_type> itsVersionedTypes;
|
||||
}; // class OutputArchive
|
||||
|
||||
// ######################################################################
|
||||
//! The base input archive class
|
||||
/*! This is the base input archive for all input archives. If you create
|
||||
a custom archive class, it should derive from this, passing itself as
|
||||
a template parameter for the ArchiveType.
|
||||
|
||||
The base class provides all of the functionality necessary to
|
||||
properly forward data to the correct serialization functions.
|
||||
|
||||
Individual archives should use a combination of prologue and
|
||||
epilogue functions together with specializations of serialize, save,
|
||||
and load to alter the functionality of their serialization.
|
||||
|
||||
@tparam ArchiveType The archive type that derives from InputArchive
|
||||
@tparam Flags Flags to control advanced functionality. See the Flags
|
||||
enum for more information.
|
||||
@ingroup Internal */
|
||||
template<class ArchiveType, std::uint32_t Flags = 0>
|
||||
class InputArchive : public detail::InputArchiveBase
|
||||
{
|
||||
public:
|
||||
//! Construct the output archive
|
||||
/*! @param derived A pointer to the derived ArchiveType (pass this from the derived archive) */
|
||||
InputArchive(ArchiveType * const derived) :
|
||||
self(derived),
|
||||
itsBaseClassSet(),
|
||||
itsSharedPointerMap(),
|
||||
itsPolymorphicTypeMap(),
|
||||
itsVersionedTypes()
|
||||
{ }
|
||||
|
||||
InputArchive & operator=( InputArchive const & ) = delete;
|
||||
|
||||
//! Serializes all passed in data
|
||||
/*! This is the primary interface for serializing data with an archive */
|
||||
template <class ... Types> inline
|
||||
ArchiveType & operator()( Types && ... args )
|
||||
{
|
||||
process( std::forward<Types>( args )... );
|
||||
return *self;
|
||||
}
|
||||
|
||||
/*! @name Boost Transition Layer
|
||||
Functionality that mirrors the syntax for Boost. This is useful if you are transitioning
|
||||
a large project from Boost to cereal. The preferred interface for cereal is using operator(). */
|
||||
//! @{
|
||||
|
||||
//! Serializes passed in data
|
||||
/*! This is a boost compatability layer and is not the preferred way of using
|
||||
cereal. If you are transitioning from boost, use this until you can
|
||||
transition to the operator() overload */
|
||||
template <class T> inline
|
||||
ArchiveType & operator&( T && arg )
|
||||
{
|
||||
self->process( std::forward<T>( arg ) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Serializes passed in data
|
||||
/*! This is a boost compatability layer and is not the preferred way of using
|
||||
cereal. If you are transitioning from boost, use this until you can
|
||||
transition to the operator() overload */
|
||||
template <class T> inline
|
||||
ArchiveType & operator>>( T && arg )
|
||||
{
|
||||
self->process( std::forward<T>( arg ) );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
//! Retrieves a shared pointer given a unique key for it
|
||||
/*! This is used to retrieve a previously registered shared_ptr
|
||||
which has already been loaded.
|
||||
|
||||
@param id The unique id that was serialized for the pointer
|
||||
@return A shared pointer to the data
|
||||
@throw Exception if the id does not exist */
|
||||
inline std::shared_ptr<void> getSharedPointer(std::uint32_t const id)
|
||||
{
|
||||
if(id == 0) return std::shared_ptr<void>(nullptr);
|
||||
|
||||
auto iter = itsSharedPointerMap.find( id );
|
||||
if(iter == itsSharedPointerMap.end())
|
||||
throw Exception("Error while trying to deserialize a smart pointer. Could not find id " + std::to_string(id));
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
//! Registers a shared pointer to its unique identifier
|
||||
/*! After a shared pointer has been allocated for the first time, it should
|
||||
be registered with its loaded id for future references to it.
|
||||
|
||||
@param id The unique identifier for the shared pointer
|
||||
@param ptr The actual shared pointer */
|
||||
inline void registerSharedPointer(std::uint32_t const id, std::shared_ptr<void> ptr)
|
||||
{
|
||||
std::uint32_t const stripped_id = id & ~detail::msb_32bit;
|
||||
itsSharedPointerMap[stripped_id] = ptr;
|
||||
}
|
||||
|
||||
//! Retrieves the string for a polymorphic type given a unique key for it
|
||||
/*! This is used to retrieve a string previously registered during
|
||||
a polymorphic load.
|
||||
|
||||
@param id The unique id that was serialized for the polymorphic type
|
||||
@return The string identifier for the tyep */
|
||||
inline std::string getPolymorphicName(std::uint32_t const id)
|
||||
{
|
||||
auto name = itsPolymorphicTypeMap.find( id );
|
||||
if(name == itsPolymorphicTypeMap.end())
|
||||
{
|
||||
throw Exception("Error while trying to deserialize a polymorphic pointer. Could not find type id " + std::to_string(id));
|
||||
}
|
||||
return name->second;
|
||||
}
|
||||
|
||||
//! Registers a polymorphic name string to its unique identifier
|
||||
/*! After a polymorphic type has been loaded for the first time, it should
|
||||
be registered with its loaded id for future references to it.
|
||||
|
||||
@param id The unique identifier for the polymorphic type
|
||||
@param name The name associated with the tyep */
|
||||
inline void registerPolymorphicName(std::uint32_t const id, std::string const & name)
|
||||
{
|
||||
std::uint32_t const stripped_id = id & ~detail::msb_32bit;
|
||||
itsPolymorphicTypeMap.insert( {stripped_id, name} );
|
||||
}
|
||||
|
||||
private:
|
||||
//! Serializes data after calling prologue, then calls epilogue
|
||||
template <class T> inline
|
||||
void process( T && head )
|
||||
{
|
||||
prologue( *self, head );
|
||||
self->processImpl( head );
|
||||
epilogue( *self, head );
|
||||
}
|
||||
|
||||
//! Unwinds to process all data
|
||||
template <class T, class ... Other> inline
|
||||
void process( T && head, Other && ... tail )
|
||||
{
|
||||
process( std::forward<T>( head ) );
|
||||
process( std::forward<Other>( tail )... );
|
||||
}
|
||||
|
||||
//! Serialization of a virtual_base_class wrapper
|
||||
/*! \sa virtual_base_class */
|
||||
template <class T> inline
|
||||
ArchiveType & processImpl(virtual_base_class<T> & b)
|
||||
{
|
||||
traits::detail::base_class_id id(b.base_ptr);
|
||||
if(itsBaseClassSet.count(id) == 0)
|
||||
{
|
||||
itsBaseClassSet.insert(id);
|
||||
self->processImpl( *b.base_ptr );
|
||||
}
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Serialization of a base_class wrapper
|
||||
/*! \sa base_class */
|
||||
template <class T> inline
|
||||
ArchiveType & processImpl(base_class<T> & b)
|
||||
{
|
||||
self->processImpl( *b.base_ptr );
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Helper macro that expands the requirements for activating an overload
|
||||
/*! Requirements:
|
||||
Has the requested serialization function
|
||||
Does not have version and unversioned at the same time
|
||||
Is input serializable AND
|
||||
is specialized for this type of function OR
|
||||
has no specialization at all */
|
||||
#define PROCESS_IF(name) \
|
||||
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
|
||||
!traits::has_invalid_input_versioning<T, ArchiveType>::value, \
|
||||
(traits::is_input_serializable<T, ArchiveType>::value && \
|
||||
(traits::is_specialized_##name<T, ArchiveType>::value || \
|
||||
!traits::is_specialized<T, ArchiveType>::value))> = traits::sfinae
|
||||
|
||||
//! Member serialization
|
||||
template <class T, PROCESS_IF(member_serialize)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
access::member_serialize(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member serialization
|
||||
template <class T, PROCESS_IF(non_member_serialize)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (load)
|
||||
template <class T, PROCESS_IF(member_load)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
access::member_load(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (load)
|
||||
template <class T, PROCESS_IF(non_member_load)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
CEREAL_LOAD_FUNCTION_NAME(*self, t);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (load_minimal)
|
||||
template <class T, PROCESS_IF(member_load_minimal)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
using OutArchiveType = typename traits::detail::get_output_from_input<ArchiveType>::type;
|
||||
typename traits::has_member_save_minimal<T, OutArchiveType>::type value;
|
||||
self->process( value );
|
||||
access::member_load_minimal(*self, t, value);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (load_minimal)
|
||||
template <class T, PROCESS_IF(non_member_load_minimal)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
using OutArchiveType = typename traits::detail::get_output_from_input<ArchiveType>::type;
|
||||
typename traits::has_non_member_save_minimal<T, OutArchiveType>::type value;
|
||||
self->process( value );
|
||||
CEREAL_LOAD_MINIMAL_FUNCTION_NAME(*self, t, value);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Empty class specialization
|
||||
template <class T, traits::EnableIf<(Flags & AllowEmptyClassElision),
|
||||
!traits::is_input_serializable<T, ArchiveType>::value,
|
||||
std::is_empty<T>::value> = traits::sfinae> inline
|
||||
ArchiveType & processImpl(T const &)
|
||||
{
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! No matching serialization
|
||||
/*! Invalid if we have invalid input versioning or
|
||||
we are not input serializable, and either
|
||||
don't allow empty class ellision or allow it but are not serializing an empty class */
|
||||
template <class T, traits::EnableIf<traits::has_invalid_input_versioning<T, ArchiveType>::value ||
|
||||
(!traits::is_input_serializable<T, ArchiveType>::value &&
|
||||
(!(Flags & AllowEmptyClassElision) || ((Flags & AllowEmptyClassElision) && !std::is_empty<T>::value)))> = traits::sfinae> inline
|
||||
ArchiveType & processImpl(T const &)
|
||||
{
|
||||
static_assert(traits::detail::count_input_serializers<T, ArchiveType>::value != 0,
|
||||
"cereal could not find any input serialization functions for the provided type and archive combination. \n\n "
|
||||
"Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these). \n "
|
||||
"Serialize functions generally have the following signature: \n\n "
|
||||
"template<class Archive> \n "
|
||||
" void serialize(Archive & ar) \n "
|
||||
" { \n "
|
||||
" ar( member1, member2, member3 ); \n "
|
||||
" } \n\n " );
|
||||
|
||||
static_assert(traits::detail::count_input_serializers<T, ArchiveType>::value < 2,
|
||||
"cereal found more than one compatible input serialization function for the provided type and archive combination. \n\n "
|
||||
"Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these). \n "
|
||||
"Use specialization (see access.hpp) if you need to disambiguate between serialize vs load/save functions. \n "
|
||||
"Note that serialization functions can be inherited which may lead to the aforementioned ambiguities. \n "
|
||||
"In addition, you may not mix versioned with non-versioned serialization functions. \n\n ");
|
||||
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Registers a class version with the archive and serializes it if necessary
|
||||
/*! If this is the first time this class has been serialized, we will record its
|
||||
version number and serialize that.
|
||||
|
||||
@tparam T The type of the class being serialized
|
||||
@param version The version number associated with it */
|
||||
template <class T> inline
|
||||
std::uint32_t loadClassVersion()
|
||||
{
|
||||
static const auto hash = std::type_index(typeid(T)).hash_code();
|
||||
auto lookupResult = itsVersionedTypes.find( hash );
|
||||
|
||||
if( lookupResult != itsVersionedTypes.end() ) // already exists
|
||||
return lookupResult->second;
|
||||
else // need to load
|
||||
{
|
||||
std::uint32_t version;
|
||||
|
||||
process( make_nvp<ArchiveType>("cereal_class_version", version) );
|
||||
itsVersionedTypes.emplace_hint( lookupResult, hash, version );
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
//! Member serialization
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_serialize)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
const auto version = loadClassVersion<T>();
|
||||
access::member_serialize(*self, t, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member serialization
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_serialize)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
const auto version = loadClassVersion<T>();
|
||||
CEREAL_SERIALIZE_FUNCTION_NAME(*self, t, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (load)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_load)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
const auto version = loadClassVersion<T>();
|
||||
access::member_load(*self, t, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (load)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_load)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
const auto version = loadClassVersion<T>();
|
||||
CEREAL_LOAD_FUNCTION_NAME(*self, t, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Member split (load_minimal)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(member_versioned_load_minimal)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
using OutArchiveType = typename traits::detail::get_output_from_input<ArchiveType>::type;
|
||||
const auto version = loadClassVersion<T>();
|
||||
typename traits::has_member_versioned_save_minimal<T, OutArchiveType>::type value;
|
||||
self->process(value);
|
||||
access::member_load_minimal(*self, t, value, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
//! Non member split (load_minimal)
|
||||
/*! Versioning implementation */
|
||||
template <class T, PROCESS_IF(non_member_versioned_load_minimal)> inline
|
||||
ArchiveType & processImpl(T & t)
|
||||
{
|
||||
using OutArchiveType = typename traits::detail::get_output_from_input<ArchiveType>::type;
|
||||
const auto version = loadClassVersion<T>();
|
||||
typename traits::has_non_member_versioned_save_minimal<T, OutArchiveType>::type value;
|
||||
self->process(value);
|
||||
CEREAL_LOAD_MINIMAL_FUNCTION_NAME(*self, t, value, version);
|
||||
return *self;
|
||||
}
|
||||
|
||||
#undef PROCESS_IF
|
||||
|
||||
private:
|
||||
ArchiveType * const self;
|
||||
|
||||
//! A set of all base classes that have been serialized
|
||||
std::unordered_set<traits::detail::base_class_id, traits::detail::base_class_id_hash> itsBaseClassSet;
|
||||
|
||||
//! Maps from pointer ids to metadata
|
||||
std::unordered_map<std::uint32_t, std::shared_ptr<void>> itsSharedPointerMap;
|
||||
|
||||
//! Maps from name ids to names
|
||||
std::unordered_map<std::uint32_t, std::string> itsPolymorphicTypeMap;
|
||||
|
||||
//! Maps from type hash codes to version numbers
|
||||
std::unordered_map<std::size_t, std::uint32_t> itsVersionedTypes;
|
||||
}; // class InputArchive
|
||||
} // namespace cereal
|
||||
|
||||
// This include needs to come after things such as binary_data, make_nvp, etc
|
||||
#include <cereal/types/common.hpp>
|
||||
|
||||
#endif // CEREAL_CEREAL_HPP_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user