Compare commits

..

306 Commits

Author SHA1 Message Date
KimLS e811e3975b Mod functions should respect perl being turned off. 2013-06-16 21:04:36 -07:00
SecretsOTheP 68261e0308 Fixed an issue with RoF items that have Rec/Req above 100. Forgot commit message/changelog.txt. 2013-06-16 13:07:48 -07:00
SecretsOTheP d03e8d05ec 2013-06-16 13:04:48 -07:00
Alex 3f2815e30c Merge pull request #73 from hateborne/master
spell.max conversion from int16 to int32.  Make sure to re-run your shared_memory program.
2013-06-15 17:44:34 -07:00
KimLS 91b01c2fcc Image fix for OP_CastSpell exploit. 2013-06-15 13:08:32 -07:00
Hateborne 179063c863 spell.max convert int16 to int32
Converting the spell.max field to int32 to handle larger numbers in the
PercentalHeal field.
2013-06-13 17:59:24 -04:00
Uleat 28eb80e27f Added changelog message for predated commit (Bot procs and AE buff casting) 2013-06-12 22:04:07 -04:00
KimLS 0dbd0478c0 Merge of hatebourne's stuff 2013-06-12 12:11:56 -07:00
Alex 29c0c4801c Merge pull request #70 from josheb/master
Mod functions updates and fixes
2013-06-05 16:54:36 -07:00
root a8de7e9ffc Removed comments from mod_client.cpp for erroneous 255 stat cap. 2013-06-03 17:08:58 -05:00
root 7fca5a7a89 Merge branch 'master' of https://github.com/EQEmu/Server into EQEmu-master
Conflicts:
	zone/client.h
	zone/mod_functions.cpp
	zone/mod_functions_base.cpp
2013-06-01 19:17:23 -05:00
josheb ac5926bdfe Merge pull request #7 from josheb/dungeoncrawl
Sync mod_functions updates
2013-06-01 08:56:19 -07:00
root b16cf57510 Cautionary XP mod update. 2013-06-01 10:49:58 -05:00
root 851c842529 Updated mod_functions and mod_functions_base with new hooks and descriptions 2013-06-01 10:44:32 -05:00
root 567c17cc9e Berserker updates. 2013-05-28 20:27:17 -05:00
root 0ee54f1117 Added mod_spell_cast and various mod_functions fixes. 2013-05-28 19:58:40 -05:00
Alex 39426789f4 Merge pull request #69 from j883376/login-db-crash
Fix loginserver crash on DB connect failure
2013-05-27 17:33:57 -07:00
Tabasco fa0196b987 Fixed some mod function bugs and stat caps. 2013-05-27 15:32:59 -05:00
j883376 44477a0d47 Fix loginserver crash on DB connect failure 2013-05-27 12:35:45 -04:00
root 510ce16f0e Added reloadworld console command 2013-05-27 08:46:50 -05:00
Alex 52b8c0e078 Merge pull request #66 from j883376/gcc-changes
GCC Changes
2013-05-24 01:16:10 -07:00
KimLS 3c7f7beb6d Red. include string 2013-05-24 01:10:19 -07:00
KimLS ee7d7c6f24 Merge branch 'small_stage_cleanup' of git://github.com/addtheice/Server into addtheice-small_stage_cleanup 2013-05-24 00:56:20 -07:00
KimLS a66ef1b778 Function for retrieving a qglobal or list of them 2013-05-24 00:52:28 -07:00
j883376 b47597b813 Merge branch 'master' of git://github.com/EQEmu/Server into gcc-changes 2013-05-23 21:12:07 -04:00
j883376 d6ff01d63c Fix several GCC warnings 2013-05-23 20:22:42 -04:00
Arthur Ice fcb769e353 Merge branch 'master' into small_stage_cleanup
Conflicts:
	common/EQStream.cpp
	zone/client.h
2013-05-23 12:49:22 -07:00
KimLS 815c3dc73f Merge branch 'master' of https://github.com/EQEmu/Server into string 2013-05-23 12:35:21 -07:00
KimLS efe7092995 Merge and a few cleanup / bug fixes 2013-05-23 12:35:00 -07:00
Alex 12ddd30f67 Merge pull request #64 from af4t/master
Windows compile fix: bots
2013-05-23 12:30:06 -07:00
af4t 879ddb208b Windows compile fixes (bots) 2013-05-23 12:17:30 -04:00
Kemmler 70dab7d920 Merge pull request #6 from EQEmu/master
Sync 2013-05-23
2013-05-23 03:53:22 -07:00
KimLS 2840e32853 Merge branch 'master' into string 2013-05-23 00:56:27 -07:00
KimLS 320494c83d Windows compile fix 2013-05-23 00:55:29 -07:00
KimLS e6fba5ba82 Merging 2013-05-23 00:31:02 -07:00
Arthur Ice 5255c236c3 added std:: to a lot of locations which where
missed and added NOMINMAX to cmakelist
2013-05-22 23:55:49 -07:00
Arthur Ice e5d4b35a32 Spelling fix in a comment. Nothing else. 2013-05-22 22:21:28 -07:00
Arthur Ice b4e65a8840 tabbify and cleaned up std issues and min/max problems. 2013-05-22 21:27:37 -07:00
Arthur Ice ac78841e55 Removed MakeUpperString since it's not used anywhere. 2013-05-22 19:41:16 -07:00
Arthur Ice 54914a970e Merge branch 'StringFormatting' into small_stage_cleanup
Conflicts:
	common/Item.cpp
	world/client.cpp
	zone/net.cpp
2013-05-22 18:55:06 -07:00
Arthur Ice ea2a1651d5 Merge branch 'master' into StringFormatting
Conflicts:
	common/debug.cpp
2013-05-22 18:07:39 -07:00
Arthur Ice 5c6e95f921 Merge branch 'master' of https://github.com/EQEmu/Server 2013-05-22 17:38:26 -07:00
Kemmler 555e21c3c7 Merge pull request #5 from EQEmu/master
Sync 2013-05-22
2013-05-22 16:31:52 -07:00
Michael Cook 0fdfe025cb Remove 'using namespaces std' fixes #61 2013-05-22 16:17:19 -04:00
root 930fda07c9 Added exp for level mod, misc fixes. 2013-05-22 07:19:09 -05:00
Arthur Ice 41dcd5bc29 Should only need dumpItemCollection and dumpBagContents internally so made them protected. 2013-05-21 23:34:55 -07:00
Arthur Ice d7546e09ee broke up dumpInventory into methods, changed it to dumpEntireInventory (dumpInventory now only dumps a small peice) 2013-05-21 22:53:22 -07:00
Arthur Ice e9577db9c2 removed DBMemLeak.cpp and DBMemLeak.h, unused. 2013-05-21 22:51:19 -07:00
Arthur Ice cdc7b2a000 weird #ifdef pattern, reorganized and cleaned it up. easier to understand now. 2013-05-21 00:36:34 -07:00
Arthur Ice a7084b4d6c reorganized includes to allow for consolidation and cleanup. 2013-05-21 00:36:34 -07:00
Arthur Ice 64212176ec removed unneeded defines. snprintf and friends are used within StringUtil.h 2013-05-21 00:36:34 -07:00
Arthur Ice 70eb226fea changed from using a preset char buffer to string. 2013-05-21 00:36:34 -07:00
Arthur Ice c18d868d03 set many pointers to nullptr instead of 0. 2013-05-21 00:36:34 -07:00
Arthur Ice 9002bfb9a0 corrected incorrect use of StringFormat and did basic indenting fix. 2013-05-21 00:36:00 -07:00
Arthur Ice 26143750f3 removed visual studio 5,6,7 specific code except in tinyxml and StackWalker. 2013-05-20 22:40:10 -07:00
Arthur Ice 3c11f8f26b simplified the includes to be a bit clearer. 2013-05-20 22:20:01 -07:00
Arthur Ice dcec112b91 reordering includes to make it easier to simplify. 2013-05-20 22:17:56 -07:00
Arthur Ice 7b0de551e1 removed char buffer in 'UpdateWindowTitle" 2013-05-20 22:15:33 -07:00
Arthur Ice d41331d948 Apparently the original implementation from facebook was incorrect.
Fixed it, sadly this does mean we need to call vsnprintf twice.
Once to find out the size involved, a second time to apply.
2013-05-20 17:51:08 -07:00
Tabasco 1e5d6b0e34 Chat filter tests 2013-05-20 16:24:10 -05:00
Arthur Ice f1a487f606 Merge branch 'master' into StringFormatting.
Cleaned up the problems. Tested on Linux. Still need to test on windows.

Conflicts:
	common/CMakeLists.txt
	common/MiscFunctions.cpp
	common/MiscFunctions.h
	common/debug.cpp
	world/Adventure.cpp
2013-05-19 18:56:21 -07:00
Arthur Ice fca9c1458b Merge branch 'master' of https://github.com/EQEmu/Server
Conflicts:
	common/debug.cpp
	common/debug.h
	zone/PlayerCorpse.cpp
	zone/beacon.cpp
	zone/client.cpp
	zone/net.cpp
	zone/tribute.cpp
2013-05-19 16:19:22 -07:00
Tabasco 7b21e3be72 Added server man quest events and command parsing. 2013-05-18 11:21:19 -05:00
root 1b9647f57e Updated mod_functions with DC examples 2013-05-17 12:27:18 -05:00
root 2d1805c983 Mod function updates - better documentation 2013-05-17 12:20:49 -05:00
Kemmler 7185ff25be Merge pull request #4 from EQEmu/master
Sync 2013-05-16
2013-05-16 05:11:13 -07:00
josheb 55c66022eb Merge pull request #6 from EQEmu/master
sync
2013-05-15 17:00:08 -07:00
KimLS 312100e1c6 Azone fix for new compilers and possible fix for x64 2013-05-15 14:37:30 -07:00
j883376 f51f6e00c4 Add install paths to CMakeLists 2013-05-15 17:04:08 -04:00
KimLS 9e13a2271c Merge conflicts 2013-05-15 13:22:46 -07:00
Kemmler b0fb8aa4be Merge pull request #3 from EQEmu/master
Sync 2013-05-12
2013-05-12 20:00:28 -07:00
josheb b9a32185d7 Merge pull request #60 from josheb/master
CHA scribe logic fix.
2013-05-12 19:44:07 -07:00
root 0f880177e4 Merge branch 'master' of https://github.com/josheb/Server 2013-05-12 21:36:13 -05:00
root 7683252896 CHA scribe rule logic fix 2013-05-12 21:35:21 -05:00
Kemmler ca9a1de44c Merge pull request #2 from EQEmu/master
Sync 2013-05-11
2013-05-11 21:49:12 -07:00
Michael Cook 73a4e87379 FreeBSD support and clean up of unnecessary ifdef FREEBSD 2013-05-11 14:32:14 -04:00
josheb 3a31ad55fb Merge pull request #5 from EQEmu/master
sync
2013-05-11 07:03:50 -07:00
Arthur Ice b19755a313 For windows compile, moved definve of va_copy 2013-05-11 00:46:46 -07:00
Arthur Ice 9a139a7604 missed two string conversion functions. Moved them to StringUtil 2013-05-11 00:17:02 -07:00
Arthur Ice 373ff66240 moved string functions from MiscFunctions to StringUtil 2013-05-11 00:05:11 -07:00
Arthur Ice babd3949f6 Added StringUtil h/cpp which contains StringFormat 2013-05-10 23:18:00 -07:00
Arthur Ice 3521472942 Merge branch 'master' of https://github.com/EQEmu/Server 2013-05-10 22:55:15 -07:00
Uleat 9ea71dd94f Merge pull request #58 from EQEmu/botproc
-- Added Bot primary weapon proc (secondary and ranged already exist)
2013-05-10 19:38:14 -07:00
Uleat 7a4cac84ac -- Added missing wrapper to bot update message
-- Added notes to AESpell() update
2013-05-10 22:24:56 -04:00
Uleat c98c115cb6 -- Added Bot primary weapon proc (secondary and ranged already exist)
-- Added Bard Bot Instrumentation bonuses
-- Added checks to avoid AE Buff casting on enemy mobs
-- Fixed a few typos in 'Vah Shir'-related code
2013-05-09 20:57:02 -04:00
j883376 4bdd8b2502 Change space indentation to tabs 2013-05-09 11:37:51 -04:00
j883376 ffcff4aea1 Remove trailing whitespace 2013-05-09 11:13:16 -04:00
josheb 56b15f558c Merge pull request #4 from EQEmu/master
sync
2013-05-09 06:19:29 -07:00
af4t 6ea9c9218d Merge branch 'master' of git://github.com/EQEmu/Server 2013-05-09 09:07:16 -04:00
KimLS 7a93966158 VS2012 fix + return 0 fix 2013-05-08 21:03:35 -07:00
Arthur Ice 273cb928bf removed using namespace std 2013-05-08 18:13:33 -07:00
Arthur Ice 7735639e57 Merge branch 'c_11_conversion' of https://github.com/addtheice/Server 2013-05-08 17:40:04 -07:00
Arthur Ice 23c524812d Removed the _MSC_VER special cases for Visual Studio 2008 and lower.
We no longer support 2008 and lower so these defines will never be used.
2013-05-08 17:09:13 -07:00
Arthur Ice c6ca89907c Converted a lot of the char[] stuff internally into std:string
in addition I switched over to <string> rather than <string.h>
2013-05-08 17:09:13 -07:00
Kemmler 87a75c6100 Merge pull request #1 from EQEmu/master
Sync 2013-05-08
2013-05-08 14:22:30 -07:00
mackal f6100ed834 Fixed NPC::GetScore and XS_NPC_GetScore 2013-05-08 17:07:49 -04:00
Derision 21a9434f89 Changed dummy strings written into the TaskSelector packet from nullptr to ABCD since the packet size calculation was based on the strings being 4 characters long. 2013-05-08 20:02:55 +01:00
josheb ea6e239d58 Merge pull request #54 from af4t/master
VS2010 compatibility adjusts
2013-05-08 05:46:49 -07:00
af4t 4ee4992330 Merge branch 'master' of git://github.com/EQEmu/Server 2013-05-08 06:07:11 -04:00
Michael Cook 059ecdb50b Fix NULL to nullptr for SQL queries take 2 2013-05-07 18:20:09 -04:00
Michael Cook 0838d4507a Fix NULL to nullptr for SQL queries 2013-05-07 17:41:05 -04:00
af4t 5cda797531 VS2010 compatibility 2013-05-07 15:19:27 -04:00
josheb 308a21e0e2 Merge pull request #51 from josheb/master
Quest events and customizations
2013-05-07 05:44:07 -07:00
tabasco a0a92587b4 Fixing some regressions 2013-05-06 16:24:44 -05:00
josheb 8e49ab9179 Merge pull request #3 from EQEmu/master
sync
2013-05-06 14:16:46 -07:00
Alex 90c7fab452 Merge pull request #50 from j883376/master
Fix Auto XTargets not clearing on death
2013-05-05 23:42:14 -07:00
Alex a4b985cd96 Merge pull request #49 from addtheice/master
NULL to nullptr
2013-05-05 23:41:47 -07:00
Arthur Ice d7dff7d7a6 Removed the _MSC_VER special cases for Visual Studio 2008 and lower.
We no longer support 2008 and lower so these defines will never be used.
2013-05-05 16:58:16 -07:00
Arthur Ice 37b7a49faf Converted a lot of the char[] stuff internally into std:string
in addition I switched over to <string> rather than <string.h>
2013-05-05 16:40:03 -07:00
Tabasco 05d7c12d38 Various customizations from DungeonCrawl 2013-05-05 18:20:22 -05:00
Tabasco f983d19e01 Removed my bookmark comments and cleaned up itemtick for cases where there are no tick items. 2013-05-05 18:04:22 -05:00
j883376 4a0749f811 Change NULL to nullptr in RemoveAutoXTargets() 2013-05-05 18:51:20 -04:00
j883376 e2fd78b510 Fix Auto XTargets not clearing on death 2013-05-05 06:47:53 -04:00
Arthur Ice 7560b6b0a7 NULL to nullptr 2013-05-04 18:06:58 -07:00
josheb 824b101831 Merge pull request #2 from EQEmu/master
sync
2013-05-04 07:30:46 -07:00
Derision e1c2657b11 NULL check in Merc::CalcItemBonuses 2013-05-03 09:36:16 +01:00
KimLS d3588d2c95 PERL ON BY DEFAULT - THANKS DALAYA 2013-05-02 23:24:52 -07:00
KimLS c5c945f0c3 Make perl truely optional (Dalaya) 2013-05-02 23:21:04 -07:00
Derision 022713996a Changed return type of CRC16 to uint16 2013-04-28 19:09:48 +01:00
PiB d2c7f23ec9 Implement CRC16 using CRC32. 2013-04-28 18:56:19 +01:00
Derision 232d1e2ca8 Verify minimum size of OP_Packet, OP_Fragment and OP_OutOfOrderAck 2013-04-27 16:22:29 +01:00
Derision 401e897019 Verify OP_Ack size & fix crash in BasePacket::build_raw_header_dump due to uninitialised timestamp 2013-04-27 15:45:24 +01:00
Derision 61f7009378 EQExtractor2 SQL gen support for current client. 2013-04-25 19:04:33 +01:00
josheb 43b91b5938 Merge pull request #1 from EQEmu/master
Sync
2013-04-25 05:34:17 -07:00
badcaptain e2f25d1c92 Fixed a couple of merc stat issues and a few bot aggro issues, removed unneeded bot pet AI. 2013-04-25 00:42:52 -04:00
Tabasco 56490400ca Dungeon Crawl custom code merge
Added numerous modding hooks.
Added rules:
	Character:KeepLevelOverMax - Don't delevel a character if they are found to be over max level rule.
	Spells:UseCHAScribeHack - Optionally omit spells with CHA in effect12 when using scribespells and traindiscs
	Combat:MonkACBonusWeight - Adjust the weight threshold for monk AC bonus
	Combat:ClientStunLevel - Adjust the level clients kicks and bashes start to roll for stuns
	Combat;QuiverWRHasteDiv - Adjust the divisor applied to weight reduction for haste calcs
	Combat:UseArcheryBonusRoll - Make archery stationary bonus a roll
	Combat:ArcheryBonusChance - Archery stationary bonus chance

Added account flags and associated perl wrappers
Added EVENT_ITEM_TICK for interactive items
Added EVENT_DUEL_WIN and EVENT_DUEL_LOSE, which exports $enemyname and $enemyid
Added timer and interval to console worldshutdown command
Added EQW interface for worldshutdown and server-wide messages
2013-04-24 15:58:51 -05:00
Derision b15cb08f54 EQExtractor2 update. 2013-04-24 19:31:13 +01:00
Derision 9b015a2975 Merge pull request #48 from addtheice/master
Cleaned up Packet Handling in world/Client
2013-04-23 13:16:25 -07:00
Arthur Dene Ice b09a3840eb Turn HandleZoneChangePacket into method. 2013-04-22 23:22:13 -07:00
Arthur Dene Ice 495510a02e Reorganized handling of Packets to be a bit cleaner. 2013-04-22 23:18:40 -07:00
Arthur Dene Ice ea606ef80d Turn DeleteCharacterPacket handling into a method. 2013-04-22 23:14:00 -07:00
Arthur Dene Ice 27493c3d75 Turn EnterWorldPacket handling into a method. 2013-04-22 23:10:57 -07:00
Arthur Dene Ice cc07d511a5 Turn CharacterCreatePacket handling into a method. 2013-04-22 23:00:44 -07:00
Arthur Dene Ice 5b3ec4fb7c Turn CharacterCreateRequestPacket handling into a method. 2013-04-22 22:56:55 -07:00
Arthur Dene Ice 18da8fe44d Turn GenerateRandomNamePacket handling into a method. 2013-04-22 22:52:29 -07:00
Arthur Dene Ice 211248b50e Turn SendLoginInfoPacket handling into a method. 2013-04-22 22:47:19 -07:00
Arthur Dene Ice 969f0c535e Turn NameApprovalPacket handling into a method. 2013-04-22 22:44:29 -07:00
JJ a7ce66856b Fix rare case where heals from buffs could be negative. 2013-04-20 14:04:08 -04:00
Derision 3b42f295d6 Moved entity_list.Clear() prior to destruction of Perl objects in zone shutdown 2013-04-12 19:20:43 +01:00
mackal b8febdd440 Realized there was a better way to do the DB entries for salvage, so I changed the script.
Run the optional 2013_04_09_SalvageCleanOld.sql if you ran the old script.
2013-04-09 14:50:51 -04:00
mackal f8795bcd72 Implemented Salvage AA.
Added a new coloumn to tradeskill_recipe_entires called salvagecount that works much in the same way to fail/success/componentcount
The code will default to the component list if nothing is found with a salvagecount
New script: generate_salvage.py will generate the entries for recipes with a failcount (make sure your config is vaild XML as well, it complains if it isn't)
2013-04-08 22:33:19 -04:00
mackal 53301289f5 Merge branch 'salvage' 2013-04-08 17:30:22 -04:00
mackal 51896050ed Fix XML Type Declaration in example configs 2013-04-08 17:20:03 -04:00
mackal 81ca7a1bfd More work on salvage, added some extra checks and won't return stacks of items 2013-04-08 14:16:08 -04:00
mackal 91c817d9dd Work on implementing salvage 2013-04-07 22:38:43 -04:00
JJ 88b9f96b91 Attempting manual merge for Nature's Bounty 2013-04-06 08:23:09 -04:00
JJ b2d5ad6904 Merge pull request #46 from mackal/pet_fixes_again
Switched rest of pet messages to MT_PetResponse
2013-04-05 17:16:19 -07:00
mackal 20f086dc37 Switched rest of pet messages to MT_PetResponse
Overloaded Mob::Say_StringID with a version that takes a message type
2013-04-03 16:09:44 -04:00
badcaptain 6fa93f243f Merged from Master & changelog. 2013-04-02 19:17:28 -04:00
badcaptain 15e31d1c03 Merge branch 'master' of https://github.com/EQEmu/Server 2013-04-02 19:10:18 -04:00
badcaptain a787a7ce72 Fixed Merc lack of use of heal over time spells (causing excessive healing), fixed pet mitigation/AC issues. 2013-04-02 19:09:32 -04:00
JJ 989d132423 Merge pull request #45 from mackal/aa_fix
Bards can now use instant cast AAs while singing (Fading Memories, Boast...
2013-04-01 15:49:19 -07:00
KimLS 757fc01b78 Patch for:
-Perl blessing of exported variables is causing the SVs to be overwritten but never freed by the Perl GC.  I'm not sure if this is a feature or a bug in Perl as the documentation sucks.

Addressed by setting the blessed SVs in question to be undefined at the end of every script.  Caused a noticeable drop in memory for zones with a lot of quest events firing but it's probably not perfect.
2013-04-01 14:23:54 -07:00
mackal 353d7cede0 Bards can now use instant cast AAs while singing (Fading Memories, Boastful Bellow)
AA reuse timers now start before the spell is cast and reset upon failure or canceling
2013-04-01 17:19:45 -04:00
Derision fb0add070b Merge pull request #43 from mackal/pet_fixes
Fix pet message to use StringIDs, most should be correct related to pet ...
2013-03-31 04:06:16 -07:00
mackal 96b42ed86f Fix pet message to use StringIDs, most should be correct related to pet "saying" or just the client getting a message
Added the pet taunting message
2013-03-30 22:57:20 -04:00
JJ 2dde4dce12 Merge pull request #42 from SecretsOTheP/master
Potential fix for a Merc deconstructor crash.
2013-03-26 18:15:50 -07:00
SecretsOTheP c7ff207017 Made Merc::AddMercToGroup handle cleaning up old groups as opposed to doing it in each location before AddMercToGroup. This should fix cases where the Merc's owner is invalid and being referenced, which causes the crash located in:
http://www.eqemulator.org/forums/showthread.php?t=36670&page=2
2013-03-25 13:07:58 -04:00
SecretsOTheP 23820a369e Moved around some data in Mercs to help prevent another crash... dunno if it actually will fix it but it can't hurt >_< 2013-03-24 18:08:03 -04:00
JJ 24d4eaf65d Merge pull request #41 from SecretsOTheP/master
Merc Group Crash Fix
2013-03-24 11:56:06 -07:00
SecretsOTheP e0b05e573e Merc group/depop crash fixes. 2013-03-24 14:31:03 -04:00
JJ e2b9efaf49 Fixed SQL 2013-03-24 08:36:53 -04:00
JJ 349eb371c6 Merge pull request #40 from af4t/master
Fix typos in utils/sql/git/required/2013_03_23_Escape_FadingMemories.sql
2013-03-24 05:20:29 -07:00
af4t afe3ba40cf Fix typos 2013-03-24 08:14:50 -04:00
Alex 5e618a1ca4 Merge pull request #39 from mackal/Fade_Escape_Fix
Fixed and cleaned up Client::Escape()
2013-03-24 01:13:54 -07:00
Alex d011332647 Merge pull request #38 from SecretsOTheP/master
Merc Fixes Again
2013-03-24 01:13:14 -07:00
SecretsOTheP bc73e9c4e3 Whoops. Fixed a small change I did. 2013-03-24 04:02:47 -04:00
SecretsOTheP e609ec1df6 Fix for a crash issue related to groups that both PEQ and Armm reported on the forums. 2013-03-24 04:01:49 -04:00
mackal 2073ca8d38 Fixed and cleaned up Client::Escape()
Fixed SE_FadingMemories to use Client::Escape()
Rogue AA Escape now uses a spell instead of AA Action
Bard AA Fading Memories now only uses the AA Action to eat mana
2013-03-23 18:34:06 -04:00
SecretsOTheP a6f2c1be8a Syntax error, better place for entity list removal 2013-03-23 10:13:29 -04:00
SecretsOTheP 18e9714273 Another safeguard against a dangling pointer. 2013-03-23 10:10:03 -04:00
SecretsOTheP fa18991917 Added a few checks to resolve dangling pointers involving Mercs. Similar to the AIYellForHelp crash fixed years ago by Rogean. 2013-03-23 10:04:49 -04:00
SecretsOTheP b0b342a020 Merge branch 'master' of https://github.com/SecretsOTheP/Server
Conflicts:
	common/patches/RoF.cpp
2013-03-23 05:05:16 -04:00
SecretsOTheP 8e604fd3db Merge branch 'master' of https://github.com/EQEmu/Server
Conflicts:
	zone/client_packet.cpp
	zone/merc.cpp
	zone/npc.cpp
2013-03-23 05:02:27 -04:00
SecretsOTheP abaad22eb4 -Merc upkeep timers fixed to display properly. They now persist through zones as well as save to the database properly.
-Merc unsuspend timers should now be more reliable across zone shutdown.
2013-03-23 04:58:03 -04:00
JJ ac040b5197 Added some pointer checks as discussed in issue #36 2013-03-22 21:48:57 -04:00
badcaptain 9b1a18d9a3 Merge branch 'master' of https://github.com/EQEmu/Server
Conflicts:
	changelog.txt
2013-03-22 00:07:22 -04:00
badcaptain a20c7735e8 Fixed merc buffing bugs, added checks before dismissing merc to prevent possible bugged mercs, merged in Secret's merc memory leak fixes. 2013-03-22 00:03:50 -04:00
Derision c94822a2a1 Merge pull request #37 from mackal/stacking_SE_Limits
Fixed stacking issues with SE_Limit* (ex. Unholy Aura Discipline and Aur...
2013-03-21 13:13:14 -07:00
SecretsOTheP 2124b63982 -Fixed a memleak in inviting mercs to group.
-Fixed a duplicate merc in window bug.
2013-03-21 00:40:59 -04:00
mackal 886c7bf634 Fixed stacking issues with SE_Limit* (ex. Unholy Aura Discipline and Aura of Reverence) 2013-03-20 23:29:00 -04:00
SecretsOTheP 56825e9ed0 Two crash fixes reported on the forums are hopefully fixed. 2013-03-20 10:46:09 -04:00
SecretsOTheP 925ba2199e Whoops, forgot CMakeLists.txt 2013-03-20 07:19:20 -04:00
SecretsOTheP fd8650b8a0 Merge branch 'master' of https://github.com/SecretsOTheP/Server 2013-03-20 04:25:34 -04:00
SecretsOTheP 549455b3df Merc message removed.
VLD removed, oops.
2013-03-20 04:24:36 -04:00
SecretsOTheP f90a5b5b71 Merc message removed. 2013-03-20 04:02:33 -04:00
SecretsOTheP 5c76297e5f Merge branch 'master' of https://github.com/EQEmu/Server 2013-03-20 04:01:44 -04:00
SecretsOTheP cabf8631d4 Fixed mercenary memleaks in AI_Start and Unsuspend. 2013-03-20 04:00:08 -04:00
Derision 6ae8fbc0e4 Initialised some data in Mob/Merc constructors to stop valgrind complaining. 2013-03-19 20:44:22 +00:00
Derision f32a277643 Fixed memory leak in OP_VeteranRewardsAvailable 2013-03-19 19:22:16 +00:00
badcaptain 09df77b56e Changelog fix. 2013-03-19 01:03:15 -04:00
badcaptain f5e58e0125 Merge branch 'master' of https://github.com/EQEmu/Server into Mercs
Conflicts:
	changelog.txt
2013-03-19 00:57:15 -04:00
badcaptain 660ab53476 Fixed zone crash due to merc focus effects & tribute, merc aggro issues when client in melee range, spell recast timers. Added melee DPS spells/disciplines & support. 2013-03-19 00:53:01 -04:00
Derision 5c9f2c0d50 Fixed a couple of memory leaks. 2013-03-18 21:09:23 +00:00
Derision d036afee5b Fixed missing version parameter in DB select in GetZoneWeather. 2013-03-17 15:52:48 +00:00
SecretsOTheP 4ab7786828 Merge branch 'master' of https://github.com/EQEmu/Server
Conflicts:
	zone/client_packet.cpp
2013-03-17 10:14:25 -04:00
Derision 981cabe857 Fixed a couple of merc memory leaks and removed some commented out DumpPacket calls. 2013-03-17 13:52:43 +00:00
SecretsOTheP 8eef122cec Forgot changelog :x 2013-03-17 13:01:54 +00:00
SecretsOTheP 1dc1655891 Hopefully fixed that pesky merc memleak and cleaned up mercs a tad. 2013-03-17 13:01:54 +00:00
SecretsOTheP 0bc942f4d5 Test 2013-03-17 13:01:53 +00:00
SecretsOTheP 9fbf9abd47 Forgot changelog :x 2013-03-17 06:20:12 -04:00
SecretsOTheP b8170df498 Hopefully fixed that pesky merc memleak and cleaned up mercs a tad. 2013-03-17 06:18:32 -04:00
Derision d76a8bd34a EQExtractor2: Added SQL generation support for current Live client decoder. 2013-03-17 10:09:13 +00:00
SecretsOTheP 021faf68b3 Merge branch 'master' of https://github.com/EQEmu/Server 2013-03-17 04:52:52 -04:00
Derision 7c264ad097 EQExtractor2 update. 2013-03-16 19:56:09 +00:00
Derision 810fdf3cca Resurrection - Fix for RoF + fixed a couple of memory leaks. 2013-03-15 19:37:29 +00:00
SecretsOTheP c301b30c3a Merge branch 'master' of https://github.com/EQEmu/Server
Conflicts:
	zone/client_packet.cpp
2013-03-15 03:32:43 -04:00
SecretsOTheP 735b4181fa Test 2013-03-15 03:27:45 -04:00
badcaptain a14fecaf78 Forgot to remove debugging. 2013-03-14 23:13:49 -04:00
badcaptain e12b06a9ad Merge branch 'master' of https://github.com/EQEmu/Server 2013-03-14 23:03:39 -04:00
badcaptain 9a82875ad4 Forgot changelog. 2013-03-14 22:56:45 -04:00
JJ 0b0ee921a5 Fix for hatelist random missing last member on hatelist. 2013-03-14 20:42:02 -04:00
badcaptain 7109a40637 Merge branch 'master' of https://github.com/EQEmu/Server 2013-03-14 20:03:48 -04:00
badcaptain 0a805feeec Fixed Merc spell recast timers, changed how Mercs add mobs to their hate lists (should prevent IsEngaged() issues), initial Caster DPS Merc spell casting AI, initial Merc stance implementation, Mercs now suspend when their owner dies to prevent them being bugged (until it can be fixed), added 2 seconds between spell casts to be live-like. 2013-03-14 19:51:29 -04:00
Derision 9fdb6862f8 Updated comment in Handle_OP_ItemPreview 2013-03-10 20:41:09 +00:00
Derision e53ae5f6d5 More compiler warning fixes. 2013-03-10 18:55:18 +00:00
Derision 0ad1044b2e Added some error logging into ZoneDatabase::NPCSpawnDB for #npcspawn create 2013-03-09 20:13:11 +00:00
Derision 64c53fe37b Merge pull request #29 from addtheice/master
consts on char*'s to remove the deprecation of const string to char* warning
2013-03-09 11:55:11 -08:00
Arthur Ice faa93c3739 Added some consts to remove 'deprecated string to char*' warnings. 2013-03-09 10:52:25 -08:00
Derision 0e6272e6d8 Removed _log message from zone/CatchSignal on Linux as it can deadlock on shutdown if another signal is received while the _log call is being processed. 2013-03-09 13:31:54 +00:00
Derision c363261d00 Fix from Zaela_S to stop mobs aggroing on dead players when using RespawnFromHover. 2013-03-09 13:18:36 +00:00
KimLS a2500ff814 Fix for DBCore crash 2013-03-08 18:07:28 -08:00
JJ 2af6e8cd16 Merge pull request #28 from af4t/master
Melee tomes named "Skill:  ", again
2013-03-08 08:42:54 -08:00
af4t eb1e88b38c Reword blurbs in changelog.txt. 2013-03-07 23:33:21 -05:00
af4t c81549a441 Melee tomes named "Skill: ...": had overlooked learn-by-right-click, updated. 2013-03-07 09:42:16 -05:00
KimLS adf42c8750 Changed some stuff to keep it consistent with old behavior: was seeing crashes related to ptimers on peq. 2013-03-06 11:19:44 -08:00
Alex 2ee8e17ac0 Merge pull request #27 from af4t/master
Fix NPCs aggro each other from beneficial spells
2013-03-05 23:06:52 -08:00
Alex f7469412f1 Merge pull request #23 from addtheice/master
Fixed missing include that blocked compile on linux.
2013-03-05 23:05:27 -08:00
af4t 55a72c86cf Merge branch 'master' of https://github.com/af4t/Server
Conflicts:
	zone/spells.cpp
2013-03-05 16:22:22 -05:00
af4t a80eb397d5 Stop NPCs from aggroing each other with buffs/beneficial spells. 2013-03-05 16:19:46 -05:00
af4t 7926362ab5 Stop NPCs from aggroing each other with buffs/beneficial spells. 2013-03-05 15:44:05 -05:00
Derision 7af51ff346 Merge pull request #24 from af4t/master
Forgot to update changelog.txt earlier
2013-03-04 12:56:32 -08:00
Derision c8ca362eba Few minor issues highlighted by cppcheck/valgrind. 2013-03-04 19:15:07 +00:00
af4t 4964c17abb Forgot to update changelog.txt earlier 2013-03-04 13:08:53 -05:00
Arthur Ice 0c6eee6d81 More warning clean ups (NULL to 0 on int, sprintf flags, typedef on enum) 2013-03-03 21:45:46 -08:00
Arthur Ice 950f00fae6 Fixed some warnings, like sprintf %i warnings (converted to %lu), fals vs NULL, etc 2013-03-03 16:17:06 -08:00
Arthur Ice d8628170b5 Fixed missing include that blocked compile on linux. 2013-03-03 15:26:40 -08:00
Arthur Ice 68338dace1 Merge branch 'master' of git://github.com/EQEmu/Server 2013-03-03 15:22:52 -08:00
Derision af1f87a00f Fixed uninitialised variabled tempBot in #bot stance command (cppcheck) 2013-03-03 22:26:57 +00:00
Derision 9a47e79e8e Fixed memleak in Client::Handle_OP_MercenaryDataRequest (cppcheck) 2013-03-03 22:22:04 +00:00
Derision aceaba0fb0 Fixed uninitialised mercOwner highlighted by cppcheck. 2013-03-03 22:12:14 +00:00
Arthur Ice e0887d81aa Merge branch 'master' of git://github.com/EQEmu/Server 2013-03-03 13:02:36 -08:00
Derision ff9e4e0780 Merge pull request #22 from addtheice/master
just removed a duplicate GNU License in test main
2013-03-02 12:30:26 -08:00
Arthur Ice 6a4f61d3a3 Merge branch 'master' of git://github.com/EQEmu/Server 2013-03-02 12:01:01 -08:00
Arthur Ice c8da17c664 Deleted the old and duplicated GNU license text 2013-03-02 11:58:39 -08:00
badcaptain 7c34a89ec5 Fixed Merc depop bug, added merc rest regen, fixed merc group spell casting bug where mercs would continue to try to cast group buffs on pets of caster who didn't have Pet Affinity AA. 2013-03-02 01:07:18 -05:00
Alex da4cddf1ef Update README.md 2013-03-01 16:45:10 -08:00
KimLS 9262c0895f Merge branch 'master' of https://github.com/EQEmu/Server 2013-02-28 22:33:31 -08:00
KimLS b5405c35e2 Tests fix + fix for certain factions not loading 2013-02-28 22:33:20 -08:00
Ludwig 0137a271cc Merge pull request #21 from af4t/master
Undo MAG pet targeting change.
2013-02-28 21:47:07 -08:00
badcaptain 5d8af58e57 Oops, it's not a leap year. 2013-03-01 00:34:25 -05:00
af4t c054cb3dd0 Merge branch 'master' of git://github.com/EQEmu/Server 2013-03-01 00:27:20 -05:00
af4t 8640a89323 Undo MAG pet targeting change 2013-03-01 00:23:21 -05:00
badcaptain ea72975e69 Fixed Merc duplicate save bug, focus items, spell_scale and heal_scale now work implemented, new merc equipment (with focus items), added checks during merc hire, unsuspend, & timer update for states where a merc can't be hired, unsuspended, or can't be retained due to insufficient funds, no room in group, in raid, invalid merc data, etc, and give appropriate feedback, added rules for charging of merc purchase and upkeep costs. 2013-03-01 00:01:27 -05:00
KimLS 7237c1f54c Shared Memory changelog + something with CMake to support rvalue refs 2013-02-27 16:16:20 -08:00
KimLS 92ed7e694f Merge branch 'master' into shared_mem 2013-02-26 21:29:34 -08:00
Alex ffe24cdfaa Merge pull request #19 from af4t/IHT_LT
Enhancement: Improved Harm Touch & Leech Touch
2013-02-26 21:29:01 -08:00
af4t 04dfe4512f SK AA Touch of the Wicked should reduce reuse timers for Improved Harm Touch & Leech Touch as well as regular HT. Add to aa_actions with same redux rate as regular HT 2013-02-26 09:48:36 -05:00
Alex a95205905e Merge pull request #16 from af4t/TomeFix
Melee tomes named "Skill: ..." can be handed to guildmasters and memoriz...
2013-02-26 01:09:33 -08:00
Alex 55347aeab6 Merge pull request #17 from af4t/SummonedPetTarget
Fix targeting for summoned pets in Mob::DetermineSpellTargets
2013-02-26 01:08:44 -08:00
af4t 945db17cb8 Fix targeting for summoned pets in Mob::DetermineSpellTargets 2013-02-25 10:38:03 -05:00
af4t e48d59b07b Melee tomes named "Skill: ..." can be handed to guildmasters and memorized. 2013-02-25 09:19:07 -05:00
KimLS aff4d53d7e Fix for sdrawkcab index in skill_caps 2013-02-24 22:08:10 -08:00
KimLS 5bb604248f Removed obsolete cleanipc program 2013-02-24 10:52:52 -08:00
KimLS 7e63135a3d Fix for linux ipc mutex 2013-02-24 10:51:04 -08:00
KimLS 3092286604 Fix for bad data on factions 2013-02-24 10:33:07 -08:00
KimLS d42ff6ce19 Merge branch 'master' into shared_mem 2013-02-23 22:43:24 -08:00
KimLS 26f965e251 Fix for shared memory loot: both the inconsistent tables and the not loading of tables with no items 2013-02-23 22:42:40 -08:00
Derision 34a4b2ab37 Misc fizes. 2013-02-23 23:12:10 +00:00
KimLS 9c1159837a Merge branch 'master' into shared_mem 2013-02-23 15:04:16 -08:00
KimLS 147c96970c Moved faction stuff around, removed stupid external item status stuff 2013-02-23 15:03:15 -08:00
Derision e7e1b46b36 Set #reloadlevelmods to status 255 2013-02-23 22:17:19 +00:00
Derision 299dc525d0 Set #reloadworld to 255 status 2013-02-23 22:00:43 +00:00
KimLS 5a69f41f4d Missing EOL 2013-02-23 13:48:05 -08:00
KimLS c31b2b65c1 NPC Faction lists to new shared memory scheme 2013-02-23 13:45:19 -08:00
KimLS 8937c5be86 Fix for mmf failing on linux (relies on size_ which wasn't init properly on one of the constructors, now is) 2013-02-23 01:32:05 -08:00
KimLS 54883b0795 mmf wont lock - programmer can handle that 2013-02-23 00:48:16 -08:00
KimLS 39a77a855e Stupid design choice in cppunit fixt -.- 2013-02-23 00:37:12 -08:00
KimLS 4c10d4dd2f c++11 linux compile conflicts with perl more 2013-02-23 00:07:47 -08:00
KimLS f32048808a c++11 linux compile conflicts with perl 2013-02-23 00:06:03 -08:00
KimLS 86c8b11102 IPCMutex needed to be rewritten for Linux due to an annoying limitation of posix semaphores that makes encapping them moronic 2013-02-22 23:40:16 -08:00
KimLS 8c425ff9d8 Merge branch 'master' into shared_mem 2013-02-22 22:36:30 -08:00
KimLS 9eaa98675b Shared Memory Loot works 2013-02-22 18:25:17 -08:00
KimLS 6f13d0cfbc Partial work on loot tables (non-compiling) 2013-02-21 22:13:33 -08:00
KimLS 543ef3fb32 Merge branch 'master' into shared_mem 2013-02-21 08:58:53 -08:00
KimLS 3e9c2a06a3 Items in shared memory 2013-02-20 22:36:30 -08:00
KimLS 0115b18e67 Delete some pointless files 2013-02-20 15:36:36 -08:00
KimLS ef9498b03a Got rid of rules global (ugh) and gonna start work on items loading next 2013-02-20 15:35:46 -08:00
KimLS 8eb7d0aaa8 Skill caps load with new smem scheme 2013-02-20 13:54:26 -08:00
KimLS 12bde7434a Starting on skill caps today 2013-02-20 11:26:23 -08:00
KimLS 23dbd00d40 Style + compile option for rvalue-move 2013-02-19 23:06:00 -08:00
KimLS f8bae86082 Spells via shared memory work, removal of blah, general fixes 2013-02-19 22:20:30 -08:00
KimLS acecff23f4 Almost have spells loaded 2013-02-19 16:50:05 -08:00
KimLS 7ce6f4de0d More shared memory work + moved spdat from zone to common 2013-02-19 15:33:21 -08:00
KimLS 78b2385785 Merge branch 'master' into shared_mem 2013-02-19 13:38:12 -08:00
KimLS d4dbf0042e Merge branch 'master' into shared_mem 2013-02-18 19:26:11 -08:00
KimLS 0d16361a40 Working on shared memory stuff - removed some stuff dealing with older code and loading spells from the non-database 2013-02-18 19:00:07 -08:00
KimLS 70543c2b8a Merge branch 'master' into shared_mem 2013-02-18 12:40:27 -08:00
KimLS a5ad05f274 Merge branch 'master' into shared_mem 2013-02-17 22:02:45 -08:00
KimLS 53d6e4000c Unit tests + cleanup 2013-02-17 13:36:39 -08:00
KimLS a192e726d4 Merge branch 'master' into shared_mem 2013-02-17 12:32:13 -08:00
KimLS 886fe5cc31 Working on tests, not there yet, added licensing stuff 2013-02-17 12:31:18 -08:00
KimLS c734708809 MMFs + a scaled down hash set to use them with 2013-02-17 11:51:32 -08:00
KimLS 1c0f35a945 Way to miss two files KLS - doh 2013-02-17 11:35:50 -08:00
KimLS 06a3873c9b IPC mutex 2013-02-17 11:35:03 -08:00
KimLS 7a2be102aa Exception classes & required C++11 stuff from GCC(still needs to be fixed) 2013-02-17 11:27:43 -08:00
697 changed files with 58221 additions and 51968 deletions
+98 -90
View File
@@ -15,96 +15,106 @@ PROJECT(EQEmu)
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles #Default build type is set to RelWithDebInfo for generators that honor that like makefiles
IF(NOT CMAKE_BUILD_TYPE) IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE)
#Add our various windows definitions #Add our various windows definitions
IF(MSVC OR MINGW) IF(MSVC OR MINGW)
ADD_DEFINITIONS(-D_WINDOWS) ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64) IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64) ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64) ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32) ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64) ENDIF(CMAKE_CL_64)
ENDIF(MSVC OR MINGW) ENDIF(MSVC OR MINGW)
IF(MSVC) IF(MSVC)
#Set our default locations for zlib/mysql based on x86/x64 #Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64) IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64") SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64") SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
ELSE(CMAKE_CL_64) ELSE(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86") SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86") SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
ENDIF(CMAKE_CL_64) ENDIF(CMAKE_CL_64)
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere #disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON) OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS) IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS) ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it #fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON) OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT) IF(EQEMU_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast) ADD_DEFINITIONS(/fp:fast)
ENDIF(EQEMU_FAST_FLOATINGPOINT) ENDIF(EQEMU_FAST_FLOATINGPOINT)
#crash logging currently only works on windows x86/x64 #crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON) OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING) IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING) ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING) ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not? #Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF) OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH) IF(EQEMU_DISABLE_SAFESEH)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH) ENDIF(EQEMU_DISABLE_SAFESEH)
#We want to compile /MT not /MD so we change that #We want to compile /MT not /MD so we change that
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD") IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD") ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var) ENDFOREACH(flag_var)
ADD_DEFINITIONS(-DNOMINMAX)
ELSE(MSVC) ELSE(MSVC)
#Normally set by perl but we don't use the perl flags anymore so we set it. #Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN) ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC) ENDIF(MSVC)
#FreeBSD support
IF(UNIX)
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
ADD_DEFINITIONS(-DFREEBSD)
SET(FREEBSD TRUE)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
ENDIF(UNIX)
#use stdint.h types if they exist for this platform (we have to guess otherwise) #use stdint.h types if they exist for this platform (we have to guess otherwise)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H) IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT) ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
ENDIF(HAVE_STDINT_H) ENDIF(HAVE_STDINT_H)
#debug level, 5 is default. Most people wont ever change this but it's there if you want to #debug level, 5 is default. Most people wont ever change this but it's there if you want to
SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level: SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
0 - Quiet mode Errors to file Status and Normal ignored 0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile 1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile 2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status 3 - Light debug release errors and status
4 - Moderate debug release errors and status 4 - Moderate debug release errors and status
5 - Maximum debug release errors and status 5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see" 10 - More errors than you ever wanted to see"
) )
#Bots are a compile time option so on/off #Bots are a compile time option so on/off
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF) OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
IF(EQEMU_ENABLE_BOTS) IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS) ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS) ENDIF(EQEMU_ENABLE_BOTS)
#What to build #What to build
@@ -112,23 +122,19 @@ OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF) OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
OPTION(EQEMU_BUILD_AZONE "Build azone utility." OFF) OPTION(EQEMU_BUILD_AZONE "Build azone utility." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF) OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
IF(UNIX) #C++11 stuff
#Whether to build cleanipc or not (probably a good idea if you build server) IF(NOT MSVC)
OPTION(EQEMU_BUILD_CLEANIPC "Build cleanipc." ON) ADD_DEFINITIONS(-std=c++0x)
ENDIF(NOT MSVC)
#Use C++11 stuff, support for this is still it infancy
OPTION(EQEMU_CPP_ELEVEN "Enable C++11 extentions in g++" OFF)
IF(EQEMU_CPP_ELEVEN)
ADD_DEFINITIONS(-std=c++0x)
ENDIF(EQEMU_CPP_ELEVEN)
ENDIF(UNIX)
#Various definitions #Various definitions
ADD_DEFINITIONS(-DEMBPERL) IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN) ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL}) ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DSHAREMEM)
ADD_DEFINITIONS(-DINVERSEXY) ADD_DEFINITIONS(-DINVERSEXY)
ADD_DEFINITIONS(-DFIELD_ITEMS) ADD_DEFINITIONS(-DFIELD_ITEMS)
ADD_DEFINITIONS(-DMAP_DIR="./Maps") ADD_DEFINITIONS(-DMAP_DIR="./Maps")
@@ -136,29 +142,31 @@ ADD_DEFINITIONS(-DMAP_DIR="./Maps")
#Find everything we need #Find everything we need
FIND_PACKAGE(ZLIB REQUIRED) FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(MySQL REQUIRED) FIND_PACKAGE(MySQL REQUIRED)
FIND_PACKAGE(PerlLibs REQUIRED) IF(EQEMU_BUILD_PERL)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${PERL_INCLUDE_PATH}" "${MySQL_INCLUDE_DIR}") FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}")
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(common)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
IF(EQEMU_BUILD_SERVER) IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(EMuShareMem) ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world) ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone) ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs) ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv) ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch) ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER) ENDIF(EQEMU_BUILD_SERVER)
IF(EQEMU_BUILD_LOGIN) IF(EQEMU_BUILD_LOGIN)
ADD_SUBDIRECTORY(loginserver) ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN) ENDIF(EQEMU_BUILD_LOGIN)
IF(EQEMU_BUILD_AZONE OR EQEMU_BUILD_CLEANIPC) IF(EQEMU_BUILD_AZONE)
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ENDIF(EQEMU_BUILD_AZONE OR EQEMU_BUILD_CLEANIPC) ENDIF(EQEMU_BUILD_AZONE)
IF(EQEMU_BUILD_TESTS) IF(EQEMU_BUILD_TESTS)
# Testing framework not quite ready for prime time. ADD_SUBDIRECTORY(tests)
# ADD_SUBDIRECTORY(tests)
ENDIF(EQEMU_BUILD_TESTS) ENDIF(EQEMU_BUILD_TESTS)
-46
View File
@@ -1,46 +0,0 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(sharedmem_src
DLLMain.cpp
Doors.cpp
Items.cpp
Loot.cpp
MMF.cpp
MMFMutex.cpp
NPCFactionLists.cpp
Opcodes.cpp
SkillCaps.cpp
Spells.cpp
)
SET(sharedmem_headers
Doors.h
Items.h
Loot.h
MMF.h
MMFMutex.h
NPCFactionLists.h
Opcodes.h
SkillCaps.h
Spells.h
)
SET(EQEMU_MAX_ITEMS 300000 CACHE STRING "Maxium number of items to load into memory. Make sure this is bigger than the total number of items in the server database")
SET(EQEMU_MAX_DOORS 30000 CACHE STRING "Maxium number of doors to load into memory. Make sure this is bigger than the total number of doors in the server database")
SET(EQEMU_MAX_FACTIONLIST_IDS 50000 CACHE STRING "Maxium number of FactionList IDs to load into memory. Make sure this is bigger than the total number of FactionList IDs in the server database")
ADD_DEFINITIONS(-DMMF_EQMAX_ITEMS=${EQEMU_MAX_ITEMS})
ADD_DEFINITIONS(-DMMF_MAX_Door_ID=${EQEMU_MAX_DOORS})
ADD_DEFINITIONS(-DMMF_MAX_NPCFactionList_ID=${EQEMU_MAX_FACTIONLIST_IDS})
ADD_LIBRARY(EMuShareMem SHARED ${sharedmem_src} ${sharedmem_headers})
TARGET_LINK_LIBRARIES(EMuShareMem Common)
IF(UNIX)
TARGET_LINK_LIBRARIES(EMuShareMem "dl")
TARGET_LINK_LIBRARIES(EMuShareMem "m")
TARGET_LINK_LIBRARIES(EMuShareMem "rt")
TARGET_LINK_LIBRARIES(EMuShareMem "pthread")
ENDIF(UNIX)
SET(LIBRARY_OUTPUT_PATH ../Bin)
-37
View File
@@ -1,37 +0,0 @@
/*
EMuShareMem.dll
by Quagmire
Released under GPL
This DLL's purpose it to hold a single shared copy of items, npctypes, spells, and other
stuff that's normally cached in memory, thus allowing all processes on the server to share
one copy of the data, greatly reducing the amount of RAM used.
*/
#ifdef _WINDOWS
#include <windows.h>
void CloseMemShare();
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved ) // reserved
{
// Perform actions based on the reason for calling.
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH: {
break;
}
case DLL_THREAD_DETACH: {
break;
}
case DLL_PROCESS_DETACH: {
break;
}
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#endif //WIN32
-136
View File
@@ -1,136 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "Doors.h"
#include "../common/timer.h"
#include "MMF.h"
MMF DoorsMMF;
const MMFDoors_Struct* MMFDoorsData = 0;
MMFDoors_Struct* MMFDoorsData_Writable = 0;
#ifdef _WINDOWS
extern "C" __declspec(dllexport) const Door* GetDoor(uint32 id) {
return pGetDoor(id);
};
extern "C" __declspec(dllexport) bool AddDoor(uint32 id, const Door* door) {
return pAddDoor(id, door);
};
extern "C" __declspec(dllexport) bool DLLLoadDoors(CALLBACK_DBLoadDoors cbDBLoadDoors, uint32 iDoorstructSize, int32* iDoorsCount, uint32* iMaxDoorID) {
return pDLLLoadDoors(cbDBLoadDoors, iDoorstructSize, iDoorsCount, iMaxDoorID);
};
#else
extern "C" const Door* GetDoor(uint32 id) {
return pGetDoor(id);
};
extern "C" bool AddDoor(uint32 id, const Door* door) {
return pAddDoor(id, door);
};
extern "C" bool DLLLoadDoors(CALLBACK_DBLoadDoors cbDBLoadDoors, uint32 iDoorstructSize, int32* iDoorsCount, uint32* iMaxDoorID) {
return pDLLLoadDoors(cbDBLoadDoors, iDoorstructSize, iDoorsCount, iMaxDoorID);
};
#endif
bool pAddDoor(uint32 id, const Door* door) {
if (!MMFDoorsData_Writable)
return false;
if (id > MMF_MAX_Door_ID || MMFDoorsData_Writable->NextFreeIndex >= MMFDoorsData_Writable->DoorCount)
return false;
if (MMFDoorsData_Writable->DoorIndex[id] != 0xFFFFFFFF)
return false;
MMFDoorsData_Writable->DoorIndex[id] = MMFDoorsData_Writable->NextFreeIndex++;
memcpy(&MMFDoorsData_Writable->Doors[MMFDoorsData_Writable->DoorIndex[id]], door, sizeof(Door));
return true;
}
bool pDLLLoadDoors(CALLBACK_DBLoadDoors cbDBLoadDoors, uint32 iDoorstructSize, int32* iDoorsCount, uint32* iMaxDoorID) {
if (iDoorstructSize != sizeof(Door)) {
cout << "Error: EMuShareMem: DLLLoadDoors: iDoorstructSize != sizeof(Door)" << endl;
cout << "Door struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (*iMaxDoorID > MMF_MAX_Door_ID) {
cout << "Error: EMuShareMem: pDLLLoadDoors: iMaxDoorID > MMF_MAX_Door_ID" << endl;
cout << "You need to increase the define in Doors.h." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFDoors_Struct) + 256 + (sizeof(Door) * (*iDoorsCount));
if (DoorsMMF.Open("EQEMuDoors", tmpMemSize)) {
if (DoorsMMF.CanWrite()) {
MMFDoorsData_Writable = (MMFDoors_Struct*) DoorsMMF.GetWriteableHandle();
if (!MMFDoorsData_Writable) {
cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData_Writable" << endl;
return false;
}
memset(MMFDoorsData_Writable, 0, tmpMemSize);
for(int i=0; i<MMF_MAX_Door_ID; i++)
MMFDoorsData_Writable->DoorIndex[i] = 0xFFFFFFFF;
MMFDoorsData_Writable->MaxDoorID = *iMaxDoorID;
MMFDoorsData_Writable->DoorCount = *iDoorsCount;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadDoors(*iDoorsCount, *iMaxDoorID)) {
cout << "Error: EMuShareMem: DLLLoadDoors: !cbDBLoadDoors" << endl;
return false;
}
MMFDoorsData_Writable = 0;
DoorsMMF.SetLoaded();
MMFDoorsData = (const MMFDoors_Struct*) DoorsMMF.GetHandle();
if (!MMFDoorsData) {
cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData (CanWrite=true)" << endl;
return false;
}
return true;
}
else {
if (!DoorsMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!DoorsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(10);
Timer::SetCurrentTime();
}
if (!DoorsMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadDoors: !DoorsMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFDoorsData = (const MMFDoors_Struct*) DoorsMMF.GetHandle();
if (!MMFDoorsData) {
cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData (CanWrite=false)" << endl;
return false;
}
*iMaxDoorID = MMFDoorsData->MaxDoorID;
*iDoorsCount = MMFDoorsData->DoorCount;
return true;
}
}
else {
cout << "Error Loading Doors: Doors.cpp: pDLLLoadDoors: ret == 0" << endl;
return false;
}
return false;
};
const Door* pGetDoor(uint32 id) {
if (MMFDoorsData == 0 || (!DoorsMMF.IsLoaded()) || id > MMF_MAX_Door_ID || MMFDoorsData->DoorIndex[id] == 0xFFFFFFFF)
return 0;
return &MMFDoorsData->Doors[MMFDoorsData->DoorIndex[id]];
}
-22
View File
@@ -1,22 +0,0 @@
#include "../common/types.h"
#include "../zone/zonedump.h"
#include "../common/EMuShareMem.h"
// MMF_MAX_Door_ID: Make sure this is bigger than the highest Door ID#
#ifndef MMF_MAX_Door_ID
#define MMF_MAX_Door_ID 30000
#endif
// MMF_MAX_Door_MEM: Maxium number of Doors to load into memory. Make sure this is bigger
// than the total number of Doors in the server's database!
struct MMFDoors_Struct {
uint32 MaxDoorID;
uint32 NextFreeIndex;
uint32 DoorCount;
uint32 DoorIndex[MMF_MAX_Door_ID+1];
Door Doors[0];
};
bool pDLLLoadDoors(CALLBACK_DBLoadDoors cbDBLoadDoors, uint32 iDoorstructSize, int32* iDoorsCount, uint32* iMaxDoorID);
bool pAddDoor(uint32 id, const Door* door);
const Door* pGetDoor(uint32 id);
-152
View File
@@ -1,152 +0,0 @@
/*
Note: Do NOT change this to load items on an as-needed basis. Since this memory is
accessed from multiple threads, you'd need mutex's all over the place if it was
ever to be modified/updated/added to. The overhead of the mutexes would be alot more
in the long run than the delay in loading.
-Quagmire
*/
#ifdef _WINDOWS
#include <winsock2.h>
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "Items.h"
#include "../common/timer.h"
#include "MMF.h"
MMF ItemsMMF;
const MMFItems_Struct* MMFItemsData = 0;
MMFItems_Struct* MMFItemsData_Writable = 0;
DLLFUNC bool AddItem(uint32 id, const Item_Struct* item) {
if (!MMFItemsData_Writable) {
return false;
}
if (id > MMF_EQMAX_ITEMS || MMFItemsData_Writable->NextFreeIndex >= MMFItemsData_Writable->ItemCount) {
return false;
}
if (MMFItemsData_Writable->ItemIndex[id] != 0xFFFF) {
return false;
}
uint32 nextid = MMFItemsData_Writable->NextFreeIndex++;
MMFItemsData_Writable->ItemIndex[id] = nextid;
memcpy(&MMFItemsData_Writable->Items[nextid], item, sizeof(Item_Struct));
return true;
}
DLLFUNC bool DLLLoadItems(CALLBACK_DBLoadItems cbDBLoadItems, uint32 iItemStructSize, int32* iItemCount, uint32* iMaxItemID) {
if (iItemStructSize != sizeof(Item_Struct)) {
cout << "Error: EMuShareMem: DLLLoadItems: iItemStructSize != sizeof(Item_Struct)" << endl;
cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (*iMaxItemID > MMF_EQMAX_ITEMS) {
cout << "Error: EMuShareMem: pDLLLoadItems: iMaxItemID > MMF_EQMAX_ITEMS" << endl;
cout << "You need to increase the define in Items.h." << endl;
return false;
}
MMFItemsData_Writable = 0;
//Allocate the shared memory for the item structures
uint32 tmpMemSize = sizeof(MMFItems_Struct) + 256 + (sizeof(Item_Struct) * (*iItemCount));
//cout << tmpMemSize << endl;
if (ItemsMMF.Open("EQEMuItems", tmpMemSize)) {
if (ItemsMMF.CanWrite()) {
MMFItemsData_Writable = (MMFItems_Struct*) ItemsMMF.GetWriteableHandle();
if (!MMFItemsData_Writable) {
cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData_Writable" << endl;
return false;
}
memset(MMFItemsData_Writable, 0, tmpMemSize);
for(int i=0; i<MMF_EQMAX_ITEMS; i++)
MMFItemsData_Writable->ItemIndex[i] = 0xFFFF;
MMFItemsData_Writable->MaxItemID = *iMaxItemID;
MMFItemsData_Writable->ItemCount = *iItemCount;
//the writable handle has been created, do the load below after we have the
//serialization handle as well.
} else {
if (!ItemsMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!ItemsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(10);
Timer::SetCurrentTime();
}
if (!ItemsMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadItems: !ItemsMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFItemsData = (const MMFItems_Struct*) ItemsMMF.GetHandle();
if (!MMFItemsData) {
cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData (CanWrite=false)" << endl;
return false;
}
*iMaxItemID = MMFItemsData->MaxItemID;
*iItemCount = MMFItemsData->ItemCount;
return true;
}
} else {
cout << "Error Loading Items: Items.cpp: pDLLLoadItems: Open() == false" << endl;
return false;
}
/*
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadItems(*iItemCount, *iMaxItemID)) {
cout << "Error: EMuShareMem: DLLLoadItems: !cbDBLoadItems" << endl;
return false;
}
*/
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadItems(*iItemCount, *iMaxItemID)) {
cout << "Error: EMuShareMem: DLLLoadItems: !cbDBLoadItems" << endl;
return false;
}
//Now, Disable the write handle and get the read handle.
//do this for both item struct and serialization data
MMFItemsData_Writable = 0;
ItemsMMF.SetLoaded();
MMFItemsData = (const MMFItems_Struct*) ItemsMMF.GetHandle();
if (!MMFItemsData) {
cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData (CanWrite=true)" << endl;
return false;
}
return true;
};
DLLFUNC const Item_Struct* GetItem(uint32 id) {
if (MMFItemsData == 0 || (!ItemsMMF.IsLoaded()) || id > MMF_EQMAX_ITEMS || MMFItemsData->ItemIndex[id] == 0xFFFF)
return 0;
return &MMFItemsData->Items[MMFItemsData->ItemIndex[id]];
}
DLLFUNC const Item_Struct* IterateItems(uint32* NextIndex) {
if (MMFItemsData == 0 || (!ItemsMMF.IsLoaded()) || (*NextIndex) > MMF_EQMAX_ITEMS)
return 0;
do {
if (MMFItemsData->ItemIndex[*NextIndex] != 0xFFFF)
return &MMFItemsData->Items[MMFItemsData->ItemIndex[(*NextIndex)++]];
} while (++(*NextIndex) < MMF_EQMAX_ITEMS);
return 0;
}
-23
View File
@@ -1,23 +0,0 @@
#include "../common/types.h"
#include "../common/eq_packet_structs.h"
#include "../common/EMuShareMem.h"
// MMF_EQMAX_ITEMS: Make sure this is bigger than the highest item ID#
#ifndef MMF_EQMAX_ITEMS
#define MMF_EQMAX_ITEMS 300000
#endif
// MMF_MEMMAX_ITEMS: Maxium number of items to load into memory. Make sure this is bigger
// than the total number of items in the server's database!
struct MMFItems_Struct {
uint32 MaxItemID;
uint32 NextFreeIndex;
uint32 ItemCount;
uint32 ItemIndex[MMF_EQMAX_ITEMS+1];
Item_Struct Items[0];
};
//#define MMF_MAX_ITEMS_MEMSIZE sizeof(MMFItems_Struct) + 256
-214
View File
@@ -1,214 +0,0 @@
#include "../common/debug.h"
#include <memory.h>
#include <iostream>
using namespace std;
#include "Loot.h"
#include "../common/timer.h"
#include "MMF.h"
MMF LootMMF;
const MMFLoot_Struct* MMFLootData = 0;
MMFLoot_Struct* MMFLootData_Writable = 0;
uint32* LootTable;
uint32* LootDrop;
#ifdef _WINDOWS
#define exportfunc extern "C" __declspec(dllexport)
#else
#define exportfunc extern "C"
#endif
exportfunc const LootTable_Struct* GetLootTable(uint32 id) {
return pGetLootTable(id);
};
exportfunc const LootDrop_Struct* GetLootDrop(uint32 id) {
return pGetLootDrop(id);
};
exportfunc bool AddLootTable(uint32 id, const LootTable_Struct* lts) {
return pAddLootTable(id, lts);
};
exportfunc bool AddLootDrop(uint32 id, const LootDrop_Struct* lds) {
return pAddLootDrop(id, lds);
};
exportfunc bool DLLLoadLoot(CALLBACK_DBLoadLoot cbDBLoadLoot,
uint32 iLootTableStructsize, uint32 iLootTableCount, uint32 iMaxLootTable,
uint32 iLootTableEntryStructsize, uint32 iLootTableEntryCount,
uint32 iLootDropStructsize, uint32 iLootDropCount, uint32 iMaxLootDrop,
uint32 iLootDropEntryStructsize, uint32 iLootDropEntryCount
) {
return pDLLLoadLoot(cbDBLoadLoot,
iLootTableStructsize, iLootTableCount, iMaxLootTable,
iLootTableEntryStructsize, iLootTableEntryCount,
iLootDropStructsize, iLootDropCount, iMaxLootDrop,
iLootDropEntryStructsize, iLootDropEntryCount);
};
bool pAddLootTable(uint32 id, const LootTable_Struct* lts) {
if (!MMFLootData_Writable)
return false;
if (id > MMFLootData_Writable->MaxLootTableID)
return false;
if (!LootTable || LootTable[id] != 0)
return false;
uint32 tmp = sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * lts->NumEntries);
if (MMFLootData_Writable->dataindex + tmp >= MMFLootData_Writable->datamax)
return false;
LootTable[id] = MMFLootData_Writable->dataindex;
memcpy(&MMFLootData_Writable->data[MMFLootData_Writable->dataindex], lts, tmp);
MMFLootData_Writable->dataindex += tmp;
return true;
}
bool pAddLootDrop(uint32 id, const LootDrop_Struct* lds) {
if (!MMFLootData_Writable)
return false;
if (id > MMFLootData_Writable->MaxLootDropID)
return false;
if (!LootDrop || LootDrop[id] != 0)
return false;
uint32 tmp = sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * lds->NumEntries);
if (MMFLootData_Writable->dataindex + tmp >= MMFLootData_Writable->datamax)
return false;
LootDrop[id] = MMFLootData_Writable->dataindex;
memcpy(&MMFLootData_Writable->data[MMFLootData_Writable->dataindex], lds, tmp);
MMFLootData_Writable->dataindex += tmp;
return true;
}
bool pDLLLoadLoot(CALLBACK_DBLoadLoot cbDBLoadLoot,
uint32 iLootTableStructsize, uint32 iLootTableCount, uint32 iMaxLootTable,
uint32 iLootTableEntryStructsize, uint32 iLootTableEntryCount,
uint32 iLootDropStructsize, uint32 iLootDropCount, uint32 iMaxLootDrop,
uint32 iLootDropEntryStructsize, uint32 iLootDropEntryCount
) {
#if 0
cout << "iLootTableCount: " << iLootTableCount << endl;
cout << "iMaxLootTable: " << iMaxLootTable << endl;
cout << "iLootTableEntryCount: " << iLootTableEntryCount << endl;
cout << "iLootDropCount: " << iLootDropCount << endl;
cout << "iMaxLootDrop: " << iMaxLootDrop << endl;
cout << "iLootDropEntryCount: " << iLootDropEntryCount << endl;
#endif
if (iLootTableStructsize != sizeof(LootTable_Struct)) {
cout << "Error: EMuShareMem: DLLLoadLoot: iLootTableStructsize != sizeof(LootTable_Struct)" << endl;
cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (iLootTableEntryStructsize != sizeof(LootTableEntries_Struct)) {
cout << "Error: EMuShareMem: DLLLoadLoot: iLootTableEntryStructsize != sizeof(LootTableEntries_Struct)" << endl;
cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (iLootDropStructsize != sizeof(LootDrop_Struct)) {
cout << "Error: EMuShareMem: DLLLoadLoot: iLootDropStructsize != sizeof(LootDrop_Struct)" << endl;
cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (iLootDropEntryStructsize != sizeof(LootDropEntries_Struct)) {
cout << "Error: EMuShareMem: DLLLoadLoot: iLootDropEntryStructsize != sizeof(LootDropEntries_Struct)" << endl;
cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFLoot_Struct) + 256
+ (sizeof(uint32) * (iMaxLootTable+1))
+ (sizeof(LootTable_Struct) * iLootTableCount) + (sizeof(LootTableEntries_Struct) * iLootTableEntryCount)
+ (sizeof(uint32) * (iMaxLootDrop+1))
+ (sizeof(LootDrop_Struct) * iLootDropCount) + (sizeof(LootDropEntries_Struct) * iLootDropEntryCount)
;
if (LootMMF.Open("EQEMuLoot", tmpMemSize)) {
if (LootMMF.CanWrite()) {
MMFLootData_Writable = (MMFLoot_Struct*) LootMMF.GetWriteableHandle();
if (!MMFLootData_Writable) {
cout << "Error: EMuShareMem: DLLLoadLoot: !MMFLootData_Writable" << endl;
return false;
}
memset(MMFLootData_Writable, 0, tmpMemSize);
MMFLootData_Writable->LootTableCount = iLootTableCount;
MMFLootData_Writable->MaxLootTableID = iMaxLootTable;
MMFLootData_Writable->LootDropCount = iLootDropCount;
MMFLootData_Writable->MaxLootDropID = iMaxLootDrop;
MMFLootData_Writable->datamax = tmpMemSize - sizeof(MMFLoot_Struct);
MMFLootData_Writable->dataindex = 0;
MMFLootData_Writable->LootTableOffset = MMFLootData_Writable->dataindex;
MMFLootData_Writable->dataindex += (sizeof(uint32) * (iMaxLootTable+1));
MMFLootData_Writable->LootDropOffset = MMFLootData_Writable->dataindex;
MMFLootData_Writable->dataindex += (sizeof(uint32) * (iMaxLootDrop+1));
LootTable = (uint32*) &MMFLootData_Writable->data[MMFLootData_Writable->LootTableOffset];
LootDrop = (uint32*) &MMFLootData_Writable->data[MMFLootData_Writable->LootDropOffset];
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadLoot()) {
cout << "Error: EMuShareMem: DLLLoadLoot: !cbDBLoadLoot" << endl;
return false;
}
MMFLootData_Writable = 0;
LootMMF.SetLoaded();
}
else {
if (!LootMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!LootMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(10);
Timer::SetCurrentTime();
}
if (!LootMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadLoot: !LootMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
}
}
else {
cout << "Error Loading Loot: Loot.cpp: pDLLLoadLoot: Open() == false" << endl;
return false;
}
MMFLootData = (const MMFLoot_Struct*) LootMMF.GetHandle();
if (!MMFLootData) {
cout << "Error: EMuShareMem: DLLLoadLoot: !MMFLootData" << endl;
MMFLootData = 0;
return false;
}
if (MMFLootData->LootTableCount != iLootTableCount
|| MMFLootData->MaxLootTableID != iMaxLootTable
|| MMFLootData->LootDropCount != iLootDropCount
|| MMFLootData->MaxLootDropID != iMaxLootDrop) {
cout << "Error: EMuShareMem: DLLLoadLoot: Count/Max mismatch" << endl;
MMFLootData = 0;
return false;
}
LootTable = (uint32*) &MMFLootData->data[MMFLootData->LootTableOffset];
LootDrop = (uint32*) &MMFLootData->data[MMFLootData->LootDropOffset];
return true;
};
const LootTable_Struct* pGetLootTable(uint32 id) {
if (MMFLootData == 0 || !LootMMF.IsLoaded())
return 0;
if (id > MMFLootData->MaxLootTableID || LootTable[id] == 0)
return 0;
return (LootTable_Struct*) &MMFLootData->data[LootTable[id]];
}
const LootDrop_Struct* pGetLootDrop(uint32 id) {
if (MMFLootData == 0 || !LootMMF.IsLoaded())
return 0;
if (id > MMFLootData->MaxLootDropID || LootDrop[id] == 0)
return 0;
return (LootDrop_Struct*) &MMFLootData->data[LootDrop[id]];
}
-29
View File
@@ -1,29 +0,0 @@
#include "../common/types.h"
#include "../common/eq_packet_structs.h"
#include "../common/EMuShareMem.h"
#pragma pack(1)
struct MMFLoot_Struct {
bool Loaded;
uint32 MaxLootTableID;
uint32 LootTableCount;
uint32 LootTableOffset;
uint32 MaxLootDropID;
uint32 LootDropCount;
uint32 LootDropOffset;
uint32 datamax;
uint32 dataindex;
uint8 data[0];
};
#pragma pack()
bool pDLLLoadLoot(CALLBACK_DBLoadLoot cbDBLoadLoot,
uint32 iLootTableStructsize, uint32 iLootTableCount, uint32 iMaxLootTable,
uint32 iLootTableEntryStructsize, uint32 iLootTableEntryCount,
uint32 iLootDropStructsize, uint32 iLootDropCount, uint32 iMaxLootDrop,
uint32 iLootDropEntryStructsize, uint32 iLootDropEntryCount
);
bool pAddLootTable(uint32 id, const LootTable_Struct* lts);
bool pAddLootDrop(uint32, const LootDrop_Struct* lds);
const LootTable_Struct* pGetLootTable(uint32 id);
const LootDrop_Struct* pGetLootDrop(uint32 id);
-353
View File
@@ -1,353 +0,0 @@
// start mingw
#ifdef __MINGW32__
#define __try
#define __finally
#endif
// end mingw
#include "MMF.h"
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifdef _WINDOWS
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include "MMFMutex.h"
#include "../common/unix.h"
#endif
MMF::MMF() {
SharedMemory = 0;
pCanWrite = false;
#ifdef _WINDOWS
hMapObject = NULL;
lpvMem = 0;
#else
lpvMem = 0;
pMMFMutex = 0;
m_alloc = false;
#endif
}
MMF::~MMF() {
Close();
}
bool MMF::Open(const char* iName, uint32 iSize) {
if (iSize < 1) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: iSize < 1" << endl;
return false;
}
if (strlen(iName) < 2) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: strlen(iName) < 2" << endl;
return false;
}
char MMFname[200];
memset(MMFname, 0, sizeof(MMFname));
snprintf(MMFname, sizeof(MMFname), "memfilemap_%s", iName);
uint32 tmpSize = sizeof(MMF_Struct) + iSize;
#ifdef _WINDOWS
char MMFMutexName[200];
memset(MMFMutexName, 0, sizeof(MMFMutexName));
snprintf(MMFMutexName, sizeof(MMFMutexName), "MutexToProtectOpenMMF_%s", iName);
HANDLE hMutex;
hMutex = CreateMutex(
NULL, // no security attributes
FALSE, // initially not owned
MMFMutexName); // name of mutex
if (hMutex == NULL) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: hMutex == Null" << endl;
return false;
}
DWORD dwWaitResult;
// Request ownership of mutex.
dwWaitResult = WaitForSingleObject(
hMutex, // handle to mutex
2000L); // two-second time-out interval
if (dwWaitResult != WAIT_OBJECT_0) {
// Mutex not aquired, crap out
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: dwWaitResult != WAIT_OBJECT_0" << endl;
return false;
}
// Finally, ready to rock.
bool fInit = false;
__try {
hMapObject = CreateFileMapping(
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security attributes
PAGE_READWRITE, // read/write access
0, // size: high 32-bits
tmpSize, // size: low 32-bits
MMFname); // name of map object
if (hMapObject == NULL) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: hMapObject == Null" << endl;
return false;
}
// The first process to attach initializes memory.
fInit = (bool) (GetLastError() != ERROR_ALREADY_EXISTS);
// Get a pointer to the file-mapped shared memory.
lpvMem = MapViewOfFile(
hMapObject, // object to map view of
FILE_MAP_WRITE, // read/write access
0, // high offset: map from
0, // low offset: beginning
0); // default: map entire file
if (lpvMem == NULL) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: lpvMem == Null" << endl;
Close();
return false;
}
SharedMemory = (MMF_Struct*) lpvMem;
// Initialize memory if this is the first process.
if (fInit) {
memset(lpvMem, 0, sizeof(MMF_Struct));
pCanWrite = true;
SharedMemory->Loaded = false;
SharedMemory->datasize = iSize;
}
else {
pCanWrite = false;
if (SharedMemory->datasize != iSize) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: SharedMemory->datasize != iSize" << endl;
Close();
return false;
}
}
} // end of try block
__finally {
// Clean up the Mutex stuff
if (!ReleaseMutex(hMutex)) {
cout << "Error Loading MMF: " << __FILE__ << ":" << __LINE__ << " OpenMMF: !ReleaseMutex(hMutex)" << endl;
Close();
return false;
}
}
CloseHandle(hMutex);
return true;
#else //else, NOT WINDOWS
int load_share;
//int max_share = 7;
key_t share_key;
switch (MMFname[16]) {
case 'I': load_share = 0; break;
case 'N': load_share = 1; break;
case 'D': load_share = 2; break;
case 'S': load_share = 3; break;
case 'F': load_share = 4; break;
case 'L': load_share = 5; break;
case 'M': load_share = 6; break;
case 'O': load_share = 7; break;
case 'Z': load_share = 8; break;
case 'K': load_share = 9; break;
#ifdef CATCH_CRASH
default:
cerr<<"Failed to load shared memory segment="<<MMFname<<" ("<<MMFname[16]<<")"<<endl;
// malloc some memory here or something fancy
return false; // and make this return true
break;
#else
default: cerr<<"FATAL="<<(char)MMFname[16]<<endl; return false; break;
#endif
}
switch (load_share) {
// Item
case 0: share_key = ftok(".", 'I'); break;
// Npctype
case 1: share_key = ftok(".", 'N'); break;
// Door
case 2: share_key = ftok(".", 'D'); break;
// Spell
case 3: share_key = ftok(".", 'S'); break;
// Faction
case 4: share_key = ftok(".", 'F'); break;
// Loot
case 5: share_key = ftok(".", 'L'); break;
// ??
case 6: share_key = ftok(".", 'M'); break;
// Opcodes
case 7: share_key = ftok(".", 'O'); break;
// Item Serialization
case 8: share_key = ftok(".", 'Z'); break;
// Skills
case 9: share_key = ftok(".", 'K'); break;
// ERROR Fatal
default: cerr<<"Opps!"<<endl; share_key = 0xFF; break;
}
pMMFMutex = new MMFMutex(share_key);
if (!pMMFMutex){
assert(false);
}
//if (!tmpSize) {
int share_id = shmget(share_key, tmpSize, IPC_CREAT|IPC_EXCL|SHM_R|SHM_W);
if ( share_id <= 0) {
share_id = shmget(share_key, tmpSize, IPC_CREAT|IPC_NOWAIT);
if (share_id <= 0) {
shmid_ds mem_size;
share_id = shmget(share_key, 1, IPC_CREAT|IPC_NOWAIT|SHM_R|SHM_W);
if(share_id == -1) {
cerr << "failed to get 0-length shared mem: " << strerror(errno) << endl;
}
if ((lpvMem = shmat(share_id, NULL,SHM_RDONLY)) == (void *)-1) {
cerr << "shmat failed! " << strerror(errno) << endl;
}
if( (shmctl(share_id, IPC_STAT, &mem_size)) == 0){
if (mem_size.shm_segsz != int(tmpSize)){ //comparison between signed and unsigned integer expressions
cout<<"[Warning] requested shared memory of size:"<<tmpSize<<" but that Key is already in use with size:"<< mem_size.shm_segsz<<endl;
shmid_ds mem_users;
if( (shmctl(share_id, IPC_STAT, &mem_users)) == 0 && mem_users.shm_nattch == 1){
cout<<"[Warning] Attempting resize"<<endl;
shmctl(share_id, IPC_RMID, 0);
shmdt(lpvMem);
if ((share_id = shmget(share_key, tmpSize, IPC_CREAT|IPC_EXCL|SHM_R|SHM_W)) <= 0) {
// Failed proceed on malloc
cerr<<"[Error] Failed to resize" << strerror(errno) <<endl;
}
else{
cerr<<"[Error] Resize successful." << endl;
// Success
lpvMem = shmat(share_id, NULL, SHM_R|SHM_W);
memset(lpvMem, 0, sizeof(MMF_Struct));
pCanWrite = true;
SharedMemory = (MMF_Struct*) lpvMem;
SharedMemory->Loaded = false;
SharedMemory->datasize = iSize;
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
}
}
else{
cout<<"[Warning] Resize not possible"<<endl;
}
}
}
// Can not attatch to shared memory we'll malloc it here
if ((lpvMem == 0 || lpvMem == (void *)-1) && (lpvMem = malloc(tmpSize))) {
cout<<"[Warning] Could not attach to shared memory proceeding on isolated memory (share_id <= 0)"<<endl;
// Success!
m_alloc = true;
memset(lpvMem, 0, sizeof(MMF_Struct));
pCanWrite = true;
SharedMemory = (MMF_Struct*) lpvMem;
SharedMemory->datasize = iSize;
SharedMemory->Loaded = false;
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
} else if (!lpvMem){
//LogFile->write(EQEMuLog::Error, "Could not connect to shared memory and allocation of isolated memory failed.");
cout<<"Could not connect to shared memory and allocation of isolated memory failed."<<endl;
pMMFMutex->Release(this);
delete pMMFMutex;
exit(1);
}
pCanWrite = false;
SharedMemory = (MMF_Struct*) lpvMem;
if (SharedMemory->datasize != iSize) {
cerr<<"SharedMemory->datasize("<<SharedMemory->datasize<<") != iSize("<<iSize<<"), We can rebuild him faster better STRONGER!"<<endl;
cerr<<"Or not.. restart all servers on this machine"<<endl;
shmctl(share_id, IPC_RMID, 0);
pMMFMutex->Release(this);
exit(1);
}
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
}
shmid_ds mem_users;
if ((shmctl(share_id, IPC_STAT, &mem_users)) != 0) {
if ((lpvMem = malloc(tmpSize))) {
// Success!
cout<<"[Warning] Could not attach to shared memory proceeding on isolated memory"<<endl;
m_alloc = true;
memset(lpvMem, 0, sizeof(MMF_Struct));
pCanWrite = true;
SharedMemory = (MMF_Struct*) lpvMem;
SharedMemory->datasize = iSize;
SharedMemory->Loaded = false;
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
} else {
//LogFile->write(EQEMuLog::Error, "Could not connect to shared memory and allocation of isolated memory failed.");
cout<<"Could not connect to shared memory and allocation of isolated memory failed."<<endl;
pMMFMutex->Release(this);
delete pMMFMutex;
exit(1);
}
}
lpvMem = shmat(share_id, NULL,SHM_RDONLY);
pCanWrite = false;
SharedMemory = (MMF_Struct*) lpvMem;
//cerr << "lpvMem=" << (int)lpvMem << endl;
if (lpvMem==(void *)-1 || SharedMemory->datasize != iSize) {
cerr<<"SharedMemory->datasize("<<SharedMemory->datasize<<") != iSize("<<iSize<<"), or "<<((void *)lpvMem)<<"==-1, We can rebuild him faster better STRONGER!"<<endl;
cerr<<"Or not.. restart all servers on this machine"<<endl;
shmctl(share_id, IPC_RMID, 0);
pMMFMutex->Release(this);
exit(1);
}
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
}
lpvMem = shmat(share_id, NULL, SHM_R|SHM_W);
memset(lpvMem, 0, sizeof(MMF_Struct));
pCanWrite = true;
SharedMemory = (MMF_Struct*) lpvMem;
SharedMemory->Loaded = false;
SharedMemory->datasize = iSize;
//}
pMMFMutex->Release(this);
delete pMMFMutex;
return true;
#endif //end NOT WINDOWS
}
void MMF::Close() {
SharedMemory = 0;
pCanWrite = false;
#ifdef _WINDOWS
if (lpvMem) {
// Unmap shared memory from the process's address space.
UnmapViewOfFile(lpvMem);
lpvMem = 0;
}
if (hMapObject) {
// Close the process's handle to the file-mapping object.
CloseHandle(hMapObject);
hMapObject = NULL;
}
#else
if (lpvMem) {
if (m_alloc == true)
free(lpvMem);
else
if (shmdt(lpvMem) == -1)
//LogFile->write(EQEMuLog::Error, "Warning something odd happened freeing shared memory");
cout<<"Warning something odd happened freeing shared memory"<<endl;
lpvMem = 0;
}
#endif
}
-46
View File
@@ -1,46 +0,0 @@
#ifndef MMF_H
#define MMF_H
#include "../common/types.h"
#ifdef _WINDOWS
#include <windows.h>
#else
//#include "MMFMutex.h"
class MMFMutex;
#endif
class MMF {
public:
struct MMF_Struct {
bool Loaded;
uint32 datasize;
uint8 data[0];
};
MMF();
virtual ~MMF();
bool Open(const char* iName, uint32 iSize);
void Close();
const void* GetHandle() { if (IsLoaded()) { return SharedMemory->data; } return 0; }
void* GetWriteableHandle() { if (!IsLoaded() && CanWrite()) { return SharedMemory->data; } return 0; }
inline bool IsOpen() { return (bool) (SharedMemory != 0); }
inline bool IsLoaded() { if (SharedMemory) { return SharedMemory->Loaded; } return false; }
bool SetLoaded() { if (SharedMemory && CanWrite()) { SharedMemory->Loaded = true; return true; } return false; }
inline bool CanWrite() { if (SharedMemory) { return pCanWrite; } return false; }
#ifndef WIN32
bool m_alloc;
#endif
private:
bool pCanWrite;
MMF_Struct* SharedMemory;
#ifdef _WINDOWS
HANDLE hMapObject;
LPVOID lpvMem;
#else
void* lpvMem;
MMFMutex* pMMFMutex;
#endif
};
#endif
-126
View File
@@ -1,126 +0,0 @@
#include "MMFMutex.h"
#ifndef WIN32
MMFMutex::MMFMutex( int key )
{
m_key = key;
if( m_key == 0 )
{
// initialize POSIX semaphore
sem_init( &m_semaphore, 0, 1);
}
else
{
// currently, this thread does not own the semaphore
m_owner = 0;
m_recursive_count = 0;
// try to get an existing semaphore. the access permissions are "full access for everyone"
m_id = semget(m_key, 1, 0x1b6);
if( m_id == -1 )
{
// it doesn't exist yet, try to create a new one
m_id = semget(m_key, 1, IPC_CREAT | 0x1b6);
if( m_id != -1 )
{
// initialize it to 1
semun data;
data.val = 1;
semctl(m_id, 0, SETVAL, data);
}
}
}
}
MMFMutex::~MMFMutex()
{
if( m_key == 0 )
{
sem_destroy(&m_semaphore);
}
else
{
semctl(m_id, 0, IPC_RMID, 0);
}
}
bool MMFMutex::Lock( uint32 dwTimeout )
{
if( m_owner == pthread_self() )
{
m_recursive_count++;
return true;
}
bool bUseTimeout = (dwTimeout != 0);
while(true) {
bool bGotSemaphore = false;
if( m_key == 0 )
{
bGotSemaphore = (sem_trywait(&m_semaphore) == 0);
}
else
{
struct sembuf operations[1];
operations[0].sem_num = 0;
operations[0].sem_op = -1;
operations[0].sem_flg = SEM_UNDO|IPC_NOWAIT;
bGotSemaphore = (semop(m_id, operations, 1) >= 0);
}
if( bGotSemaphore )
{
m_owner = pthread_self();
m_recursive_count = 1;
return true;
}
sleep(1);
if( bUseTimeout )
{
if( dwTimeout > 1000 )
dwTimeout -= 1000;
else
dwTimeout = 0;
if( dwTimeout == 0 )
return false;
}
}
}
void MMFMutex::Release(const MMF* pMMF)
{
if( m_owner != pthread_self() && pMMF->m_alloc != true )
{
//We're supposed to explode here with an assert
//assert(false);
}
else if ( pMMF->m_alloc == true ){
// Just do it nothing is useing but us
return;
}
else if( m_recursive_count > 1 )
{
m_recursive_count--;
}
else
{
if( m_key == 0 )
{
sem_post(&m_semaphore);
}
else
{
struct sembuf operations[1];
operations[0].sem_num = 0;
operations[0].sem_op = 1;
operations[0].sem_flg = SEM_UNDO;
semop(m_id, operations, 1);
}
m_recursive_count = 0;
m_owner = 0;
}
}
#endif //!WIN32
-43
View File
@@ -1,43 +0,0 @@
#ifndef MMFMUTEX_H
#define MMFMUTEX_H
#ifndef WIN32
#include <sys/types.h> // moved before sys/shm.h for freeBSD
#include <sys/shm.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <semaphore.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include "../common/types.h"
#include "MMF.h"
// the manuals say you have to define this struct your self.
#if !defined FREEBSD || defined __NetBSD__ // for BSDs
union semun
{
int val;
struct semid_ds* buf;
unsigned short int *array;
struct seminfo *__buf;
};
#endif // for freeBSD
class MMFMutex
{
public:
MMFMutex(int iIndex);
virtual ~MMFMutex();
bool Lock( uint32 dwTimeout = 0 );
void Release(const MMF*);
protected:
int m_id;
key_t m_key;
pthread_t m_owner;
sem_t m_semaphore;
int m_recursive_count;
};
#endif //!WIN32
#endif
-178
View File
@@ -1,178 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "NPCFactionLists.h"
#include "../common/timer.h"
#include "MMF.h"
MMF NPCFactionListsMMF;
const MMFNPCFactionLists_Struct* MMFNPCFactionListsData = 0;
MMFNPCFactionLists_Struct* MMFNPCFactionListsData_Writable = 0;
#ifdef _WINDOWS
extern "C" __declspec(dllexport) const NPCFactionList* GetNPCFactionList(uint32 id) {
return pGetNPCFactionList(id);
};
extern "C" __declspec(dllexport) bool AddNPCFactionList(uint32 id, const NPCFactionList* nfl) {
return pAddNPCFactionList(id, nfl);
};
extern "C" __declspec(dllexport) bool DLLLoadNPCFactionLists(CALLBACK_DBLoadNPCFactionLists cbDBLoadNPCFactionLists, uint32 iNPCFactionListStructSize, int32* iNPCFactionListsCount, uint32* iMaxNPCFactionListID, uint8 iMaxNPCFactions) {
return pDLLLoadNPCFactionLists(cbDBLoadNPCFactionLists, iNPCFactionListStructSize, iNPCFactionListsCount, iMaxNPCFactionListID, iMaxNPCFactions);
};
extern "C" __declspec(dllexport) bool SetNPCFaction(uint32 id, uint32* factionid, int32* factionvalue, int8 *factionnpcvalue, uint8 *factiontemp) {
return pSetNPCFaction(id, factionid, factionvalue, factionnpcvalue, factiontemp);
}
#else
extern "C" const NPCFactionList* GetNPCFactionList(uint32 id) {
return pGetNPCFactionList(id);
};
extern "C" bool AddNPCFactionList(uint32 id, const NPCFactionList* nfl) {
return pAddNPCFactionList(id, nfl);
};
extern "C" bool DLLLoadNPCFactionLists(CALLBACK_DBLoadNPCFactionLists cbDBLoadNPCFactionLists, uint32 iNPCFactionListStructSize, int32* iNPCFactionListsCount, uint32* iMaxNPCFactionListID, uint8 iMaxNPCFactions) {
return pDLLLoadNPCFactionLists(cbDBLoadNPCFactionLists, iNPCFactionListStructSize, iNPCFactionListsCount, iMaxNPCFactionListID, iMaxNPCFactions);
};
extern "C" bool SetNPCFaction(uint32 id, uint32* factionid, int32* factionvalue, int8 *factionnpcvalue, uint8 *factiontemp) {
return pSetNPCFaction(id, factionid, factionvalue, factionnpcvalue, factiontemp);
}
#endif
bool pAddNPCFactionList(uint32 id, const NPCFactionList* nfl) {
if (!MMFNPCFactionListsData_Writable){
if (EQDEBUG>=1) cout<<"[Debug] !MMFNPCFactionListsData_Writable"<<endl;
return false;
}
if (id > MMF_MAX_NPCFactionList_ID || MMFNPCFactionListsData_Writable->NextFreeIndex >= MMFNPCFactionListsData_Writable->NPCFactionListCount){
if (EQDEBUG>=1) cout<<"[Debug] id > MMF_MAX_NPCFactionList_ID || MMFNPCFactionListsData_Writable->NextFreeIndex >= MMFNPCFactionListsData_Writable->NPCFactionListCount"<<endl;
return false;
}
if (MMFNPCFactionListsData_Writable->NPCFactionListIndex[id] != 0xFFFFFFFF){
if (EQDEBUG>=1) cout<<"[Debug] MMFNPCFactionListsData_Writable->NPCFactionListIndex[id] != 0xFFFFFFFF"<<endl;
return false;
}
MMFNPCFactionListsData_Writable->NPCFactionListIndex[id] = MMFNPCFactionListsData_Writable->NextFreeIndex++;
memcpy(&MMFNPCFactionListsData_Writable->NPCFactionLists[MMFNPCFactionListsData_Writable->NPCFactionListIndex[id]], nfl, sizeof(NPCFactionList));
return true;
}
bool pSetNPCFaction(uint32 id, uint32* factionid, int32* factionvalue, int8 *factionnpcvalue, uint8 *factiontemp) {
if (!MMFNPCFactionListsData_Writable) {
if(EQDEBUG>=1) cout<<"[Debug] !MMFNPCFactionListsData_Writable"<<endl;
return false;
}
if (id > MMF_MAX_NPCFactionList_ID) {
if(EQDEBUG>=1) cout<<"[Debug] id > MMF_MAX_NPCFactionList_ID"<<endl;
return false;
}
if (MMFNPCFactionListsData_Writable->NPCFactionListIndex[id] == 0xFFFFFFFF) {
if(EQDEBUG>=1) cout<<"[Debug] MMFNPCFactionListsData_Writable->NPCFactionListIndex[id="<<id<<"] == 0xFFFFFFFF"<<endl;
return false;
}
for (int i=0; i<MAX_NPC_FACTIONS; i++) {
MMFNPCFactionListsData_Writable->NPCFactionLists[MMFNPCFactionListsData_Writable->NPCFactionListIndex[id]].factionid[i] = factionid[i];
MMFNPCFactionListsData_Writable->NPCFactionLists[MMFNPCFactionListsData_Writable->NPCFactionListIndex[id]].factionvalue[i] = factionvalue[i];
MMFNPCFactionListsData_Writable->NPCFactionLists[MMFNPCFactionListsData_Writable->NPCFactionListIndex[id]].factionnpcvalue[i] = factionnpcvalue[i];
MMFNPCFactionListsData_Writable->NPCFactionLists[MMFNPCFactionListsData_Writable->NPCFactionListIndex[id]].factiontemp[i] = factiontemp[i];
}
return true;
}
bool pDLLLoadNPCFactionLists(CALLBACK_DBLoadNPCFactionLists cbDBLoadNPCFactionLists, uint32 iNPCFactionListStructSize, int32* iNPCFactionListsCount, uint32* iMaxNPCFactionListID, uint8 iMaxNPCFactions) {
if (iNPCFactionListStructSize != sizeof(NPCFactionList)) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iNPCFactionListStructSize != sizeof(NPCFactionList)" << endl;
cout << "NPCFactionList struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (iMaxNPCFactions != MAX_NPC_FACTIONS) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iMaxNPCFactions != MAX_NPC_FACTIONS" << endl;
cout << "NPCFactionList struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (*iMaxNPCFactionListID > MMF_MAX_NPCFactionList_ID) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iMaxNPCFactions > MMF_MAX_NPCFactionList_ID" << endl;
cout << "You need to increase the define in NPCFactionList.h." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFNPCFactionLists_Struct) + 256 + (sizeof(NPCFactionList) * (*iNPCFactionListsCount));
if (NPCFactionListsMMF.Open("EQEMuFactionLists", tmpMemSize)) {
// MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
if (NPCFactionListsMMF.CanWrite()) {
MMFNPCFactionListsData_Writable = (MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetWriteableHandle();
if (!MMFNPCFactionListsData_Writable) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData_Writable" << endl;
return false;
}
memset(MMFNPCFactionListsData_Writable, 0, tmpMemSize);
for(int i=0; i<MMF_MAX_NPCFactionList_ID; i++)
MMFNPCFactionListsData_Writable->NPCFactionListIndex[i] = 0xFFFFFFFF;
MMFNPCFactionListsData_Writable->MaxNPCFactionListID = *iMaxNPCFactionListID;
MMFNPCFactionListsData_Writable->NPCFactionListCount = *iNPCFactionListsCount;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadNPCFactionLists(MMFNPCFactionListsData_Writable->NPCFactionListCount, MMFNPCFactionListsData_Writable->MaxNPCFactionListID)) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !cbDBLoadNPCFactionLists" << endl;
return false;
}
MMFNPCFactionListsData_Writable = 0;
NPCFactionListsMMF.SetLoaded();
MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
if (!MMFNPCFactionListsData) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData (CanWrite=true)" << endl;
return false;
}
return true;
}
else {
if (!NPCFactionListsMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!NPCFactionListsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(100);
Timer::SetCurrentTime();
}
if (!NPCFactionListsMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !NPCFactionListsMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
if (!MMFNPCFactionListsData) {
cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData (CanWrite=false)" << endl;
return false;
}
*iMaxNPCFactionListID = MMFNPCFactionListsData->MaxNPCFactionListID;
*iNPCFactionListsCount = MMFNPCFactionListsData->NPCFactionListCount;
return true;
}
}
else {
cout << "Error Loading NPCFactionLists: NPCFactionLists.cpp: pDLLLoadNPCFactionLists: Open() == false" << endl;
return false;
}
return false;
};
const NPCFactionList* pGetNPCFactionList(uint32 id) {
if (MMFNPCFactionListsData == 0 || (!NPCFactionListsMMF.IsLoaded()) || id > MMF_MAX_NPCFactionList_ID || MMFNPCFactionListsData->NPCFactionListIndex[id] == 0xFFFFFFFF)
return 0;
return &MMFNPCFactionListsData->NPCFactionLists[MMFNPCFactionListsData->NPCFactionListIndex[id]];
}
-22
View File
@@ -1,22 +0,0 @@
#include "../common/types.h"
#include "../zone/features.h"
#include "../zone/faction.h"
#include "../common/EMuShareMem.h"
// MMF_MAX_NPCFactionList_ID: Make sure this is bigger than the highest NPCFactionList ID#
#ifndef MMF_MAX_NPCFactionList_ID
#define MMF_MAX_NPCFactionList_ID 50000
#endif
struct MMFNPCFactionLists_Struct {
uint32 MaxNPCFactionListID;
uint32 NextFreeIndex;
uint32 NPCFactionListCount;
uint32 NPCFactionListIndex[MMF_MAX_NPCFactionList_ID+1];
NPCFactionList NPCFactionLists[0];
};
bool pDLLLoadNPCFactionLists(CALLBACK_DBLoadNPCFactionLists cbDBLoadNPCFactionLists, uint32 iNPCFactionListStructSize, int32* iNPCFactionListCount, uint32* iMaxNPCFactionListID, uint8 iMaxNPCFactions);
bool pAddNPCFactionList(uint32 id, const NPCFactionList* nfl);
bool pSetNPCFaction(uint32 id, uint32* factionid, int32* factionvalue, int8 *factionnpcvalue, uint8 *factiontemp);
const NPCFactionList* pGetNPCFactionList(uint32 id);
-137
View File
@@ -1,137 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "NPCTypes.h"
#include "../common/timer.h"
#include "MMF.h"
MMF NPCTypesMMF;
const MMFNPCTypes_Struct* MMFNPCTypesData = 0;
MMFNPCTypes_Struct* MMFNPCTypesData_Writable = 0;
#ifdef _WINDOWS
extern "C" __declspec(dllexport) const NPCType* GetNPCType(uint32 id) {
return pGetNPCType(id);
};
extern "C" __declspec(dllexport) bool AddNPCType(uint32 id, const NPCType* npctype) {
return pAddNPCType(id, npctype);
};
/*extern "C" __declspec(dllexport) bool DLLLoadNPCTypes(CALLBACK_DBLoadNPCTypes cbDBLoadNPCTypes, uint32 iNPCTypeStructSize, int32* iNPCTypesCount, uint32* iMaxNPCTypeID) {
return pDLLLoadNPCTypes(cbDBLoadNPCTypes, iNPCTypeStructSize, iNPCTypesCount, iMaxNPCTypeID);
};*/
#else
extern "C" const NPCType* GetNPCType(uint32 id) {
return pGetNPCType(id);
};
extern "C" bool AddNPCType(uint32 id, const NPCType* npctype) {
return pAddNPCType(id, npctype);
};
extern "C" bool DLLLoadNPCTypes(CALLBACK_DBLoadNPCTypes cbDBLoadNPCTypes, uint32 iNPCTypeStructSize, int32* iNPCTypesCount, uint32* iMaxNPCTypeID) {
return pDLLLoadNPCTypes(cbDBLoadNPCTypes, iNPCTypeStructSize, iNPCTypesCount, iMaxNPCTypeID);
};
#endif
bool pAddNPCType(uint32 id, const NPCType* npctype) {
if (!MMFNPCTypesData_Writable)
return false;
if (id > MMF_MAX_NPCTYPE_ID || MMFNPCTypesData_Writable->NextFreeIndex >= MMFNPCTypesData_Writable->NPCTypeCount)
return false;
if (MMFNPCTypesData_Writable->NPCTypeIndex[id] != 0xFFFFFFFF)
return false;
MMFNPCTypesData_Writable->NPCTypeIndex[id] = MMFNPCTypesData_Writable->NextFreeIndex++;
memcpy(&MMFNPCTypesData_Writable->NPCTypes[MMFNPCTypesData_Writable->NPCTypeIndex[id]], npctype, sizeof(NPCType));
return true;
}
/*bool pDLLLoadNPCTypes(CALLBACK_DBLoadNPCTypes cbDBLoadNPCTypes, uint32 iNPCTypeStructSize, int32* iNPCTypesCount, uint32* iMaxNPCTypeID) {
if (iNPCTypeStructSize != sizeof(NPCType)) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: iNPCTypeStructSize != sizeof(NPCType)" << endl;
cout << "NPCType struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
if (*iMaxNPCTypeID > MMF_MAX_NPCTYPE_ID) {
cout << "Error: EMuShareMem: pDLLLoadNPCTypes: iMaxNPCTypeID > MMF_MAX_NPCTYPE_ID" << endl;
cout << "You need to increase the define in NPCTypes.h." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFNPCTypes_Struct) + 256 + (sizeof(NPCType) * (*iNPCTypesCount));
if (NPCTypesMMF.Open("EQEMuNPCTypes", tmpMemSize)) {
// MMFNPCTypesData = (const MMFNPCTypes_Struct*) NPCTypesMMF.GetHandle();
if (NPCTypesMMF.CanWrite()) {
MMFNPCTypesData_Writable = (MMFNPCTypes_Struct*) NPCTypesMMF.GetWriteableHandle();
if (!MMFNPCTypesData_Writable) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: !MMFNPCTypesData_Writable" << endl;
return false;
}
memset(MMFNPCTypesData_Writable, 0, tmpMemSize);
for(int i=0; i<MMF_MAX_NPCTYPE_ID; i++)
MMFNPCTypesData_Writable->NPCTypeIndex[i] = 0xFFFFFFFF;
MMFNPCTypesData_Writable->MaxNPCTypeID = *iMaxNPCTypeID;
MMFNPCTypesData_Writable->NPCTypeCount = *iNPCTypesCount;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cbDBLoadNPCTypes(MMFNPCTypesData_Writable->NPCTypeCount, MMFNPCTypesData_Writable->MaxNPCTypeID)) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: !cbDBLoadNPCTypes" << endl;
return false;
}
MMFNPCTypesData_Writable = 0;
NPCTypesMMF.SetLoaded();
MMFNPCTypesData = (const MMFNPCTypes_Struct*) NPCTypesMMF.GetHandle();
if (!MMFNPCTypesData) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: !MMFNPCTypesData (CanWrite=true)" << endl;
return false;
}
return true;
}
else {
if (!NPCTypesMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!NPCTypesMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(100);
Timer::SetCurrentTime();
}
if (!NPCTypesMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: !NPCTypesMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFNPCTypesData = (const MMFNPCTypes_Struct*) NPCTypesMMF.GetHandle();
if (!MMFNPCTypesData) {
cout << "Error: EMuShareMem: DLLLoadNPCTypes: !MMFNPCTypesData (CanWrite=false)" << endl;
return false;
}
*iMaxNPCTypeID = MMFNPCTypesData->MaxNPCTypeID;
*iNPCTypesCount = MMFNPCTypesData->NPCTypeCount;
return true;
}
}
else {
cout << "Error Loading NPCTypes: NPCTypes.cpp: pDLLLoadNPCTypes: Open() == false" << endl;
return false;
}
return false;
};*/
const NPCType* pGetNPCType(uint32 id) {
if (MMFNPCTypesData == 0 || (!NPCTypesMMF.IsLoaded()) || id > MMF_MAX_NPCTYPE_ID || MMFNPCTypesData->NPCTypeIndex[id] == 0xFFFFFFFF)
return 0;
return &MMFNPCTypesData->NPCTypes[MMFNPCTypesData->NPCTypeIndex[id]];
}
-18
View File
@@ -1,18 +0,0 @@
#include "../common/types.h"
#include "../zone/zonedump.h"
#include "../common/EMuShareMem.h"
// MMF_MAX_NPCTYPE_ID: Make sure this is bigger than the highest NPCType ID#
#define MMF_MAX_NPCTYPE_ID 400000
struct MMFNPCTypes_Struct {
uint32 MaxNPCTypeID;
uint32 NextFreeIndex;
uint32 NPCTypeCount;
uint32 NPCTypeIndex[MMF_MAX_NPCTYPE_ID+1];
NPCType NPCTypes[0];
};
//bool pDLLLoadNPCTypes(CALLBACK_DBLoadNPCTypes cbDBLoadNPCTypes, uint32 iNPCTypeStructSize, int32* iNPCTypesCount, uint32* iMaxNPCTypeID);
bool pAddNPCType(uint32 id, const NPCType* npctype);
const NPCType* pGetNPCType(uint32 id);
-140
View File
@@ -1,140 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "Opcodes.h"
#include "../common/timer.h"
#include "MMF.h"
MMF OpcodesMMF;
const MMFOpcodes_Struct* MMFOpcodesData = 0;
MMFOpcodes_Struct* MMFOpcodesData_Writable = 0;
const uint16 *MMFOpcodesData_emu_to_eq = NULL;
uint16 *MMFOpcodesData_emu_to_eq_write = NULL;
//we choose to store all opcodes as 16 bits, so if they are a different
//size in emu, they are gunna get casted to 16 bits... prolly will never
//be a problem, but I figured it was noteworthy
DLLFUNC uint16 GetEQOpcode(uint16 emu_op) {
if (MMFOpcodesData == 0 || (!OpcodesMMF.IsLoaded()) || emu_op >= MMFOpcodesData->EmuOpcodeCount )
return 0;
return MMFOpcodesData_emu_to_eq[emu_op];
}
DLLFUNC uint16 GetEmuOpcode(uint16 eq_op) {
if (MMFOpcodesData == 0 || (!OpcodesMMF.IsLoaded()) || eq_op >= MMFOpcodesData->EQOpcodeCount )
return 0;
return MMFOpcodesData->eq_to_emu[eq_op];
}
DLLFUNC bool SetOpcodePair(uint16 emu_op, uint16 eq_op) {
if (!MMFOpcodesData_Writable || !MMFOpcodesData_emu_to_eq_write)
return false;
if (emu_op >= MMFOpcodesData_Writable->EmuOpcodeCount || eq_op >= MMFOpcodesData_Writable->EQOpcodeCount)
return false;
MMFOpcodesData_emu_to_eq_write[emu_op] = eq_op;
MMFOpcodesData_Writable->eq_to_emu[eq_op] = emu_op;
return true;
}
DLLFUNC void ClearEQOpcodes() {
if (!MMFOpcodesData_Writable)
return;
memset(MMFOpcodesData_Writable->eq_to_emu, 0, sizeof(uint16)*MMFOpcodesData->EQOpcodeCount);
}
DLLFUNC bool DLLLoadOpcodes(CALLBACK_DBLoadOpcodes cb, uint32 opsize, uint32 eq_count, uint32 emu_count, const char *filename) {
if(opsize != sizeof(uint16)) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: opsize != sizeof(uint16)" << endl;
cout << "Opcode size has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFOpcodes_Struct) + opsize * (eq_count+emu_count);
if (OpcodesMMF.Open("EQEMuOpcodes", tmpMemSize)) {
if (OpcodesMMF.CanWrite()) {
MMFOpcodesData_Writable = (MMFOpcodes_Struct*) OpcodesMMF.GetWriteableHandle();
if (!MMFOpcodesData_Writable) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: !MMFOpcodesData_Writable" << endl;
return false;
}
//emu_to_eq is right after eq_to_emu
MMFOpcodesData_emu_to_eq = MMFOpcodesData_Writable->eq_to_emu + eq_count;
MMFOpcodesData_emu_to_eq_write = MMFOpcodesData_Writable->eq_to_emu + eq_count;
//we need to memset the eq opcodes
memset(MMFOpcodesData_Writable->eq_to_emu, 0, sizeof(uint16)*eq_count);
MMFOpcodesData_Writable->EQOpcodeCount = eq_count;
MMFOpcodesData_Writable->EmuOpcodeCount = emu_count;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cb(filename)) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: !cbDBLoadOpcodes" << endl;
return false;
}
//we dont disable the write handle here, so we can reload them
//MMFOpcodesData_Writable = 0;
OpcodesMMF.SetLoaded();
MMFOpcodesData = (const MMFOpcodes_Struct*) OpcodesMMF.GetHandle();
if (!MMFOpcodesData) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: !MMFOpcodesData (CanWrite=true)" << endl;
return false;
}
return true;
} else {
if (!OpcodesMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!OpcodesMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(10);
Timer::SetCurrentTime();
}
if (!OpcodesMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: !OpcodesMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFOpcodesData = (const MMFOpcodes_Struct*) OpcodesMMF.GetHandle();
if (!MMFOpcodesData) {
cout << "Error: EMuShareMem: DLLLoadOpcodes: !MMFOpcodesData (CanWrite=false)" << endl;
return false;
}
//emu_to_eq is right after eq_to_emu
MMFOpcodesData_emu_to_eq = MMFOpcodesData->eq_to_emu + MMFOpcodesData->EQOpcodeCount;
//cheat a little so we can retain writeable handles for reloading
MMFOpcodesData_Writable = const_cast<MMFOpcodes_Struct*>(MMFOpcodesData);
MMFOpcodesData_emu_to_eq_write = MMFOpcodesData_Writable->eq_to_emu + eq_count;
return true;
}
}
else {
cout << "Error Loading Opcodes: Opcodes.cpp: pDLLLoadOpcodes: ret == 0, size = " << tmpMemSize << endl;
return false;
}
return false;
}
-10
View File
@@ -1,10 +0,0 @@
#include "../common/types.h"
#include "../common/EMuShareMem.h"
struct MMFOpcodes_Struct {
uint32 EQOpcodeCount;
uint32 EmuOpcodeCount;
uint16 eq_to_emu[0];
//uint16 emu_to_eq[0]; //logical, not really here... EQOpcodeCount indexes in
};
-142
View File
@@ -1,142 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "SkillCaps.h"
#include "../common/timer.h"
#include "MMF.h"
MMF SkillCapsMMF;
const MMFSkillCaps_Struct* MMFSkillCapsData = 0;
MMFSkillCaps_Struct* MMFSkillCapsData_Writable = 0;
DLLFUNC uint16 GetSkillCap(uint8 Class_, uint8 Skill, uint8 Level) {
if (MMFSkillCapsData == 0 || (!SkillCapsMMF.IsLoaded()))
return 0;
if (Class_ >= MMFSkillCapsData->ClassCount || Skill >= MMFSkillCapsData->SkillCount || Level >= MMFSkillCapsData->LevelCount)
return(0);
uint32 index =
(((Class_ * MMFSkillCapsData->SkillCount) + Skill) * MMFSkillCapsData->LevelCount)
+ Level;
return MMFSkillCapsData->caps[index];
}
DLLFUNC bool SetSkillCap(uint8 Class_, uint8 Skill, uint8 Level, uint16 cap) {
if (!MMFSkillCapsData_Writable)
return false;
if (Class_ >= MMFSkillCapsData_Writable->ClassCount || Skill >= MMFSkillCapsData_Writable->SkillCount || Level >= MMFSkillCapsData_Writable->LevelCount)
return false;
uint32 index =
(((Class_ * MMFSkillCapsData_Writable->SkillCount) + Skill) * MMFSkillCapsData_Writable->LevelCount)
+ Level;
MMFSkillCapsData_Writable->caps[index] = cap;
return true;
}
DLLFUNC uint8 GetTrainLevel(uint8 Class_, uint8 Skill, uint8 Level){
if (MMFSkillCapsData == 0 || (!SkillCapsMMF.IsLoaded()))
return 0;
if (Class_ >= MMFSkillCapsData->ClassCount || Skill >= MMFSkillCapsData->SkillCount || Level >= MMFSkillCapsData->LevelCount)
return(0);
uint32 index = (((Class_ * MMFSkillCapsData->SkillCount) + Skill) * MMFSkillCapsData->LevelCount);
for(int x = 0; x < Level; x++){
if(MMFSkillCapsData->caps[index + x]){
return (x);
}
}
return(0);
}
DLLFUNC void ClearSkillCaps() {
if (!MMFSkillCapsData_Writable)
return;
memset(MMFSkillCapsData_Writable->caps, 0,
sizeof(uint16)*(MMFSkillCapsData->ClassCount*MMFSkillCapsData->SkillCount*MMFSkillCapsData->LevelCount));
}
DLLFUNC bool LoadSkillCaps(CALLBACK_DBLoadSkillCaps cb, uint32 opsize, uint8 ClassCount, uint8 SkillCount, uint8 LevelCount) {
if(opsize != sizeof(uint16)) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: opsize != sizeof(uint16)" << endl;
cout << "SkillCap size has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFSkillCaps_Struct) + opsize * (ClassCount*SkillCount*LevelCount);
if (SkillCapsMMF.Open("EQEMuKSkillCaps", tmpMemSize)) {
if (SkillCapsMMF.CanWrite()) {
MMFSkillCapsData_Writable = (MMFSkillCaps_Struct*) SkillCapsMMF.GetWriteableHandle();
if (!MMFSkillCapsData_Writable) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData_Writable" << endl;
return false;
}
//we need to memset the eq SkillCaps
memset(MMFSkillCapsData_Writable->caps, 0, sizeof(uint16)*(ClassCount*SkillCount*LevelCount));
MMFSkillCapsData_Writable->ClassCount = ClassCount;
MMFSkillCapsData_Writable->SkillCount = SkillCount;
MMFSkillCapsData_Writable->LevelCount = LevelCount;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (!cb()) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: !cbDBLoadSkillCaps" << endl;
return false;
}
MMFSkillCapsData_Writable = 0;
SkillCapsMMF.SetLoaded();
MMFSkillCapsData = (const MMFSkillCaps_Struct*) SkillCapsMMF.GetHandle();
if (!MMFSkillCapsData) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData (CanWrite=true)" << endl;
return false;
}
return true;
} else {
if (!SkillCapsMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!SkillCapsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(10);
Timer::SetCurrentTime();
}
if (!SkillCapsMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: !SkillCapsMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFSkillCapsData = (const MMFSkillCaps_Struct*) SkillCapsMMF.GetHandle();
if (!MMFSkillCapsData) {
cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData (CanWrite=false)" << endl;
return false;
}
return true;
}
}
else {
cout << "Error Loading SkillCaps: SkillCaps.cpp: pDLLLoadSkillCaps: ret == 0, size = " << tmpMemSize << endl;
return false;
}
return false;
}
-10
View File
@@ -1,10 +0,0 @@
#include "../common/types.h"
#include "../common/EMuShareMem.h"
struct MMFSkillCaps_Struct {
uint8 ClassCount;
uint8 SkillCount;
uint8 LevelCount;
uint16 caps[0];
};
-98
View File
@@ -1,98 +0,0 @@
#include "../common/debug.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include <memory.h>
#include <iostream>
using namespace std;
#include "Spells.h"
#include "../common/timer.h"
//#include "../zone/masterentity.h"
#include "MMF.h"
MMF SpellsMMF;
const MMFSpells_Struct* MMFSpellsData = 0;
MMFSpells_Struct* MMFSpellsData_Writable = 0;
#ifdef _WINDOWS
extern "C" __declspec(dllexport) bool DLLLoadSPDat(const CALLBACK_FileLoadSPDat cbFileLoadSPDat, const void** oSpellsPointer, int32* oSPDAT_RECORDS, uint32 iSPDat_Struct_Size) {
return pDLLLoadSPDat(cbFileLoadSPDat, oSpellsPointer, oSPDAT_RECORDS, iSPDat_Struct_Size);
};
#else
extern "C" bool DLLLoadSPDat(const CALLBACK_FileLoadSPDat cbFileLoadSPDat, const void** oSpellsPointer, int32* oSPDAT_RECORDS, uint32 iSPDat_Struct_Size) {
return pDLLLoadSPDat(cbFileLoadSPDat, oSpellsPointer, oSPDAT_RECORDS, iSPDat_Struct_Size);
};
#endif
bool pDLLLoadSPDat(const CALLBACK_FileLoadSPDat cbFileLoadSPDat, const void** oSpellsPointer, int32* oSPDAT_RECORDS, uint32 iSPDat_Struct_Size) {
if (iSPDat_Struct_Size != sizeof(SPDat_Spell_Struct)) {
cout << "Error: EMuShareMem: DLLLoadSPDat: iSPDat_Struct_Size != sizeof(SPDat_Spell_Struct)" << endl;
cout << "SPDat_Spell_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
return false;
}
uint32 tmpMemSize = sizeof(MMFSpells_Struct) + 256 + (sizeof(SPDat_Spell_Struct) * (*oSPDAT_RECORDS));
if (SpellsMMF.Open("EQEMuSpells", tmpMemSize)) {
if (SpellsMMF.CanWrite()) {
MMFSpellsData_Writable = (MMFSpells_Struct*) SpellsMMF.GetWriteableHandle();
if (!MMFSpellsData_Writable) {
cout << "Error: EMuShareMem: DLLLoadSPDat: !MMFSpellsData_Writable" << endl;
return false;
}
memset(MMFSpellsData_Writable, 0, tmpMemSize);
MMFSpellsData_Writable->SPDAT_RECORDS = *oSPDAT_RECORDS;
// use a callback so the DB functions are done in the main exe
// this way the DLL doesnt have to open a connection to mysql
if (MMFSpellsData_Writable->SPDAT_RECORDS > 0) {
cbFileLoadSPDat(&MMFSpellsData_Writable->spells[0], MMFSpellsData_Writable->SPDAT_RECORDS-1);
*oSpellsPointer = &MMFSpellsData_Writable->spells[0];
}
else
*oSpellsPointer = 0;
MMFSpellsData_Writable = 0;
SpellsMMF.SetLoaded();
MMFSpellsData = (const MMFSpells_Struct*) SpellsMMF.GetHandle();
if (!MMFSpellsData) {
cout << "Error: EMuShareMem: DLLLoadSPDat: !MMFSpellsData (CanWrite=true)" << endl;
return false;
}
return true;
}
else {
if (!SpellsMMF.IsLoaded()) {
Timer::SetCurrentTime();
uint32 starttime = Timer::GetCurrentTime();
while ((!SpellsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
Sleep(100);
Timer::SetCurrentTime();
}
if (!SpellsMMF.IsLoaded()) {
cout << "Error: EMuShareMem: DLLLoadSPDat: !SpellsMMF.IsLoaded() (timeout)" << endl;
return false;
}
}
MMFSpellsData = (const MMFSpells_Struct*) SpellsMMF.GetHandle();
if (!MMFSpellsData) {
cout << "Error: EMuShareMem: DLLLoadSPDat: !SpellsMMF (CanWrite=false)" << endl;
return false;
}
*oSPDAT_RECORDS = MMFSpellsData->SPDAT_RECORDS;
if (MMFSpellsData->SPDAT_RECORDS > 0)
*oSpellsPointer = &MMFSpellsData->spells[0];
else
*oSpellsPointer = 0;
return true;
}
}
else {
cout << "Error Loading SPDat: Spells.cpp: pDLLLoadSPDat: Open() == false" << endl;
return false;
}
return false;
}
-16
View File
@@ -1,16 +0,0 @@
#ifndef MEMSHARE_SPELLS_H
#define MEMSHARE_SPELLS_H
#include "../common/types.h"
#include "../zone/spdat.h"
#include "../common/EMuShareMem.h"
struct MMFSpells_Struct {
uint32 SPDAT_RECORDS; // maxspellid + 1, size of array
SPDat_Spell_Struct spells[0];
};
bool pDLLLoadSPDat(const CALLBACK_FileLoadSPDat cbFileLoadSPDat, const void** oSpellsPointer, int32* oSPDAT_RECORDS, uint32 iSPDat_Struct_Size);
#endif
+3 -1
View File
@@ -1,4 +1,4 @@
The server code and utilities are released under GPL. The server code and utilities are released under GPLv3.
We also include some small libraries for convienence that may be under different licensing: We also include some small libraries for convienence that may be under different licensing:
@@ -8,3 +8,5 @@ StackWalker - New BSD License
ZLib - ZLib License ZLib - ZLib License
MySQL - GPL MySQL - GPL
Perl - GPL / ActiveState (under the assumption that this is a free project). Perl - GPL / ActiveState (under the assumption that this is a free project).
CPPUnit - GLP
StringUtilities - Apache
+3
View File
@@ -1,2 +1,5 @@
EQEmu - Custom Game Implementation for EverQuest EQEmu - Custom Game Implementation for EverQuest
TODO: A less useless readme file.
Dependencies can be obtained at http://eqemu.github.com/
+152
View File
@@ -1,5 +1,157 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50) EQEMu Changelog (Started on Sept 24, 2003 15:50)
------------------------------------------------------- -------------------------------------------------------
== 06/16/2013 ==
Secrets: Fixed an issue with RoF items and Req/Rec level above 100 appearing yellow. Recommended to enable the #iteminfo command for items that have a req/rec above 100 to display proper information regarding the info.
== 06/15/2013 ==
KLS: (image) Potentially could bypass some spell checks by passing a specially crafted spell slot. This has been addressed.
== 06/12/2013 ==
KLS: Merge Hateborne's hp cap stuff
KLS: We haven't updated changelog in a while but there's been:
-Some string stuff
-A lot of fixes to things like caps.
-More work on custom mod stuff (including examples)
-Fix for login not bailing out if it cant connect to a db
-Quite a few warning changes.
== 05/09/2013 ==
Uleat: (Updated: 06/12/2013) Fixed a few observed bot issues and an beneficial AE casting bug:
Added missing Bot primary weapon proc call (secondary and ranged already exist)
Added Bard Bot instrumentation bonuses
Added checks to avoid AE Buff casting on enemy mobs
Fixed a few typos in 'Vah Shir'-related code
(Please post any discrepancies as bugs)
== 05/05/2013 ==
Tabasco: Added EVENT_ITEM_TICK for interactive item quest scripts. (See https://github.com/josheb/quests_dc/blob/master/items/12204.pl)
Added simple account flags. Would this work better as an additional qglobal category?
Added SendMessage to EQW, useful for using CURL to broadcast to the server.
Added WorldShutDown to EQW for timed world shutdowns, also updated console worldshutdown command to optionally use timed behavior.
Added numerous modding hooks and mod_functions.cpp for easy custom formulas or future lua integration.
Added various rules for monk AC bonus weight, archery bonuses, kick/bash stuns and mob stun levels.
required SQL: 2013_05_05_Account_Flags.sql
required SQL: 2013_05_05_Item_Tick.sql
== 04/28/2013 ==
PiB: Implement CRC16 using CRC32.
== 04/27/2013 ==
PiB: Verify OP_Ack size & fix crash in BasePacket::build_raw_header_dump due to uninitialised timestamp.
Derision: Verify minimum size of OP_Packet, OP_Fragment and OP_OutOfOrderAck.
== 04/24/2013 ==
Bad_Captain: Fixed a couple of merc stat issues.
Bad_Captain: Removed unneeded bot pet AI.
Bad_Captain: Fixed a few bot aggro issues. (Uleat)
== 04/20/2013 ==
JJ: Fixed rare case where heals from buffs could go negative.
== 04/12/2013 ==
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
optional SQL: 2013_04_09_SalvageCleanOld.sql - run if ran old script
== 04/08/2013 ==
demonstar55: 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
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)
== 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
== 03/30/2013 ==
demonstar55: 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.
Escape now uses just the spell and not the AA Actoin
Fading Memories now only uses the AA Action to eat mana
== 03/21/2013 ==
Bad_Captain: Fixed merc buffing bugs.
Bad_Captain: Added checks before dismissing merc to prevent possible bugged mercs.
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)
== 03/18/2013 ==
Bad_Captain: Fixed zone crash due to merc focus effects & tribute.
Bad_Captain: Fixed merc aggro issues when client in melee range & spell recast timers.
Bad_Captain: Added melee DPS spells/disciplines & support.
== 03/17/2013 ==
Secrets: Fixed that pesky merc memleak.
Secrets: Bit of code cleanup regarding mercs.
== 03/15/2013 ==
Derision: RoF: Added ENCODE for Resurrect_struct (Accepting a rez should now work).
Derision: Fixed a couple of memory leaks in Rez code.
== 03/14/2013 ==
JJ: (NatedogEZ) Fix for hate list random never selecting last member of hate list.
Bad_Captain: Fixed Merc spell recast timers.
Bad_Captain: Changed how Mercs add mobs to their hate lists (should prevent IsEngaged() issues).
Bad_Captain: Initial Caster DPS Merc spell casting AI, including initial Merc stance implementation.
Bad_Captain: Mercs now suspend when their owner dies to prevent them being bugged (until it can be fixed).
OPTIONAL SQL: 2013_03_14_Merc_Spells.sql
== 03/09/2013 ==
Zaela_S: Stop mobs aggroing on dead players when using RespawnFromHover.
Derision: Removed _log message from zone/CatchSignal on Linux as it can deadlock on shutdown if another signal is received while the _log call is being processed.
Derision: Added some error logging into ZoneDatabase::NPCSpawnDB for #npcspawn create.
== 03/07/2013 ==
af4t: Melee tomes with names beginning "Skill:" (e.g. RNG Warder's Wrath, etc) can be memorized now, by hand-in-to-guildmaster or right-click-from-inventory.
== 03/02/2013 ==
af4t: Stop NPCs aggroing each other with buffs/beneficial spells.
== 03/2/2013 ==
Bad_Captain: Fixed Merc depop bug.
Bad_Captain: Added merc rest regen.
Bad_Captain: Fixed merc group spell casting bug where mercs would continue to try to cast group buffs on pets of caster who didn't have Pet Affinity AA.
== 03/1/2013 ==
Bad_Captain: Fixed Merc duplicate save bug.
Bad_Captain: Focus items, spell_scale and heal_scale now work implemented and new merc equipment (with focus items).
Bad_Captain: Added checks during merc hire, unsuspend, & timer update for states where a merc can't be hired, unsuspended, or can't be retained due to insufficient funds, no room in group, in raid, invalid merc data, etc, and give appropriate feedback.
Bad_Captain: Added rules for charging of merc purchase and upkeep costs.
REQUIRED SQL: 2013_03_1_Merc_Rules_and_Equipment.sql
== 02/27/2013 ==
KLS: Changed how shared memory works:
Instead of System V/windows pagefile shared memory we now have shared memory that's backed by the filesystem.
What that means is basically instead of EMuSharedMem(shared library) we now have shared_memory(executable), shared memory will be persistent between runs until you delete or reload it using the shared_memory executable.
STEPS FOR PEOPLE WHO CAN'T BE BOTHERED TO FIGURE IT OUT:
1) Create a directory in the place you run world/zone named shared and make sure files can write there.
2) Run the shared_memory executable from the same place you run world/zone (it's basically doing the loading we would do on startup so will take a moment).
3) Run world/zone/whatever
== 02/25/2013 ==
af4t: Add Touch of the Wicked AA redux to SK Improved Harm Touch and Leech Touch.
== 02/22/2013 == == 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 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
+46 -47
View File
@@ -4,65 +4,65 @@
# #
# Find the native MySQL includes and library # Find the native MySQL includes and library
# #
# MySQL_INCLUDE_DIR - where to find mysql.h, etc. # MySQL_INCLUDE_DIR - where to find mysql.h, etc.
# MySQL_LIBRARIES - List of libraries when using MySQL. # MySQL_LIBRARIES - List of libraries when using MySQL.
# MySQL_FOUND - True if MySQL found. # MySQL_FOUND - True if MySQL found.
# The following can be used as a hint as to where to search: # The following can be used as a hint as to where to search:
# MYSQL_ROOT # MYSQL_ROOT
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES) IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Already in cache, be silent # Already in cache, be silent
SET(MySQL_FIND_QUIETLY TRUE) SET(MySQL_FIND_QUIETLY TRUE)
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES) ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Include dir # Include dir
IF(MYSQL_ROOT) IF(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h NAMES mysql.h
PATHS ${MYSQL_ROOT}/include PATHS ${MYSQL_ROOT}/include
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ELSE(MYSQL_ROOT) ELSE(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h NAMES mysql.h
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ENDIF(MYSQL_ROOT) ENDIF(MYSQL_ROOT)
# Library # Library
SET(MySQL_NAMES mysqlclient_r mysqlclient) SET(MySQL_NAMES mysqlclient_r mysqlclient)
IF(MYSQL_ROOT) IF(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
FIND_LIBRARY(MySQL_LIBRARY_RELEASE FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ELSE(MYSQL_ROOT) ELSE(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
FIND_LIBRARY(MySQL_LIBRARY_RELEASE FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ENDIF(MYSQL_ROOT) ENDIF(MYSQL_ROOT)
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND TRUE) SET(MySQL_FOUND TRUE)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} ) SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND FALSE) SET(MySQL_FOUND FALSE)
SET( MySQL_LIBRARIES ) SET( MySQL_LIBRARIES )
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
@@ -72,14 +72,13 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR)
IF(MySQL_FOUND) IF(MySQL_FOUND)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} ) SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE(MySQL_FOUND) ELSE(MySQL_FOUND)
SET( MySQL_LIBRARIES ) SET( MySQL_LIBRARIES )
ENDIF(MySQL_FOUND) ENDIF(MySQL_FOUND)
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
MySQL_LIBRARY_DEBUG MySQL_LIBRARY_DEBUG
MySQL_LIBRARY_RELEASE MySQL_LIBRARY_RELEASE
MySQL_INCLUDE_DIR MySQL_INCLUDE_DIR
) )
+17 -37
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "BasePacket.h" #include "BasePacket.h"
@@ -24,16 +24,17 @@
BasePacket::BasePacket(const unsigned char *buf, uint32 len) BasePacket::BasePacket(const unsigned char *buf, uint32 len)
{ {
this->pBuffer=NULL; this->pBuffer=nullptr;
this->size=0; this->size=0;
this->_wpos = 0; this->_wpos = 0;
this->_rpos = 0; this->_rpos = 0;
this->timestamp.tv_sec = 0;
if (len>0) { if (len>0) {
this->size=len; this->size=len;
pBuffer= new unsigned char[len]; pBuffer= new unsigned char[len];
if (buf) { if (buf) {
memcpy(this->pBuffer,buf,len); memcpy(this->pBuffer,buf,len);
} else { } else {
memset(this->pBuffer,0,len); memset(this->pBuffer,0,len);
} }
} }
@@ -43,7 +44,7 @@ BasePacket::~BasePacket()
{ {
if (pBuffer) if (pBuffer)
delete[] pBuffer; delete[] pBuffer;
pBuffer=NULL; pBuffer=nullptr;
} }
@@ -55,7 +56,7 @@ void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec); buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
} }
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port); buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -79,7 +80,7 @@ void BasePacket::build_header_dump(char *buffer) const
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -123,24 +124,3 @@ void DumpPacketBin(const BasePacket* app) {
DumpPacketBin(app->pBuffer, app->size); DumpPacketBin(app->pBuffer, app->size);
} }
+13 -15
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef BASEPACKET_H_ #ifndef BASEPACKET_H_
#define BASEPACKET_H_ #define BASEPACKET_H_
@@ -50,7 +50,7 @@ public:
void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; } void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; }
void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; } void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; }
void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; } void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; }
void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; } void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; }
inline bool operator<(const BasePacket &rhs) { inline bool operator<(const BasePacket &rhs) {
return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec)); return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec));
@@ -79,7 +79,7 @@ public:
protected: protected:
virtual ~BasePacket(); virtual ~BasePacket();
BasePacket() { pBuffer=NULL; size=0; _wpos = 0; _rpos = 0; } BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
BasePacket(const unsigned char *buf, const uint32 len); BasePacket(const unsigned char *buf, const uint32 len);
}; };
@@ -89,5 +89,3 @@ extern void DumpPacketBin(const BasePacket* app);
#endif /*BASEPACKET_H_*/ #endif /*BASEPACKET_H_*/
+293 -285
View File
@@ -1,313 +1,321 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(common_sources SET(common_sources
BasePacket.cpp BasePacket.cpp
classes.cpp classes.cpp
Condition.cpp Condition.cpp
crash.cpp crash.cpp
CRC16.cpp CRC16.cpp
crc32.cpp crc32.cpp
database.cpp database.cpp
dbasync.cpp dbasync.cpp
dbcore.cpp dbcore.cpp
DBMemLeak.cpp debug.cpp
debug.cpp emu_opcodes.cpp
emu_opcodes.cpp EmuTCPConnection.cpp
EMuShareMem.cpp EmuTCPServer.cpp
EmuTCPConnection.cpp EQDB.cpp
EmuTCPServer.cpp EQDBRes.cpp
EQDB.cpp eqemu_exception.cpp
EQDBRes.cpp EQEmuConfig.cpp
EQEmuConfig.cpp EQEMuError.cpp
EQEMuError.cpp EQPacket.cpp
EQPacket.cpp EQStream.cpp
EQStream.cpp EQStreamFactory.cpp
EQStreamFactory.cpp EQStreamIdent.cpp
EQStreamIdent.cpp EQStreamProxy.cpp
EQStreamProxy.cpp eqtime.cpp
eqtime.cpp extprofile.cpp
extprofile.cpp faction.cpp
guild_base.cpp guild_base.cpp
guilds.cpp guilds.cpp
Item.cpp ipc_mutex.cpp
logsys.cpp Item.cpp
logsys_eqemu.cpp logsys.cpp
md5.cpp logsys_eqemu.cpp
misc.cpp md5.cpp
MiscFunctions.cpp memory_mapped_file.cpp
moremath.cpp misc.cpp
Mutex.cpp MiscFunctions.cpp
opcode_map.cpp moremath.cpp
opcodemgr.cpp Mutex.cpp
packet_dump.cpp opcode_map.cpp
packet_dump_file.cpp opcodemgr.cpp
packet_functions.cpp packet_dump.cpp
perl_EQDB.cpp packet_dump_file.cpp
perl_EQDBRes.cpp packet_functions.cpp
ProcLauncher.cpp perl_EQDB.cpp
ptimer.cpp perl_EQDBRes.cpp
races.cpp ProcLauncher.cpp
rdtsc.cpp ptimer.cpp
rulesys.cpp races.cpp
serverinfo.cpp rdtsc.cpp
shareddb.cpp rulesys.cpp
SharedLibrary.cpp serverinfo.cpp
StructStrategy.cpp shareddb.cpp
TCPConnection.cpp spdat.cpp
TCPServer.cpp StringUtil.cpp
timeoutmgr.cpp StructStrategy.cpp
timer.cpp TCPConnection.cpp
unix.cpp TCPServer.cpp
worldconn.cpp timeoutmgr.cpp
XMLParser.cpp timer.cpp
platform.cpp unix.cpp
patches/Client62.cpp worldconn.cpp
patches/patches.cpp XMLParser.cpp
patches/SoD.cpp platform.cpp
patches/SoF.cpp patches/Client62.cpp
patches/RoF.cpp patches/patches.cpp
patches/Titanium.cpp patches/SoD.cpp
patches/Underfoot.cpp patches/SoF.cpp
SocketLib/Base64.cpp patches/RoF.cpp
SocketLib/File.cpp patches/Titanium.cpp
SocketLib/HttpdCookies.cpp patches/Underfoot.cpp
SocketLib/HttpdForm.cpp SocketLib/Base64.cpp
SocketLib/HttpdSocket.cpp SocketLib/File.cpp
SocketLib/HTTPSocket.cpp SocketLib/HttpdCookies.cpp
SocketLib/MemFile.cpp SocketLib/HttpdForm.cpp
SocketLib/Mime.cpp SocketLib/HttpdSocket.cpp
SocketLib/Parse.cpp SocketLib/HTTPSocket.cpp
SocketLib/socket_include.cpp SocketLib/MemFile.cpp
SocketLib/Utility.cpp SocketLib/Mime.cpp
StackWalker/StackWalker.cpp SocketLib/Parse.cpp
tinyxml/tinystr.cpp SocketLib/socket_include.cpp
tinyxml/tinyxml.cpp SocketLib/Utility.cpp
tinyxml/tinyxmlerror.cpp StackWalker/StackWalker.cpp
tinyxml/tinyxmlparser.cpp tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp
) )
SET(common_headers SET(common_headers
BasePacket.h BasePacket.h
bodytypes.h bodytypes.h
breakdowns.h breakdowns.h
classes.h classes.h
common_profile.h common_profile.h
Condition.h Condition.h
crash.h crash.h
CRC16.h CRC16.h
crc32.h crc32.h
database.h database.h
dbasync.h dbasync.h
dbcore.h dbcore.h
DBMemLeak.h debug.h
debug.h deity.h
deity.h emu_opcodes.h
emu_opcodes.h emu_oplist.h
emu_oplist.h EmuTCPConnection.h
EMuShareMem.h EmuTCPServer.h
EmuTCPConnection.h eq_constants.h
EmuTCPServer.h eq_packet_structs.h
eq_constants.h EQDB.h
eq_opcodes.h EQDBRes.h
eq_packet_structs.h eqemu_exception.h
EQDB.h EQEmuConfig.h
EQDBRes.h EQEmuConfig_elements.h
EQEmuConfig.h EQEMuError.h
EQEmuConfig_elements.h EQPacket.h
EQEMuError.h EQStream.h
EQPacket.h EQStreamFactory.h
EQStream.h EQStreamIdent.h
EQStreamFactory.h EQStreamIntf.h
EQStreamIdent.h EQStreamLocator.h
EQStreamIntf.h EQStreamProxy.h
EQStreamLocator.h EQStreamType.h
EQStreamProxy.h eqtime.h
EQStreamType.h errmsg.h
eqtime.h extprofile.h
errmsg.h faction.h
extprofile.h features.h
guild_base.h fixed_memory_hash_set.h
guilds.h fixed_memory_variable_hash_set.h
Item.h guild_base.h
item_fieldlist.h guilds.h
item_struct.h ipc_mutex.h
languages.h Item.h
linked_list.h item_fieldlist.h
logsys.h item_struct.h
logtypes.h languages.h
mail_oplist.h linked_list.h
md5.h logsys.h
misc.h logtypes.h
MiscFunctions.h loottable.h
moremath.h mail_oplist.h
Mutex.h md5.h
op_codes.h memory_mapped_file.h
opcode_dispatch.h misc.h
opcodemgr.h MiscFunctions.h
packet_dump.h moremath.h
packet_dump_file.h Mutex.h
packet_functions.h op_codes.h
ProcLauncher.h opcode_dispatch.h
profiler.h opcodemgr.h
ptimer.h packet_dump.h
queue.h packet_dump_file.h
races.h packet_functions.h
rdtsc.h ProcLauncher.h
rulesys.h profiler.h
ruletypes.h ptimer.h
seperator.h queue.h
serverinfo.h races.h
servertalk.h rdtsc.h
shareddb.h rulesys.h
SharedLibrary.h ruletypes.h
skills.h seperator.h
StructStrategy.h serverinfo.h
TCPBasicServer.h servertalk.h
TCPConnection.h shareddb.h
TCPServer.h skills.h
timeoutmgr.h spdat.h
timer.h StringUtil.h
types.h StructStrategy.h
unix.h TCPBasicServer.h
useperl.h TCPConnection.h
version.h TCPServer.h
worldconn.h timeoutmgr.h
XMLParser.h timer.h
ZoneNumbers.h types.h
platform.h unix.h
patches/Client62.h useperl.h
patches/Client62_itemfields.h version.h
patches/Client62_ops.h worldconn.h
patches/Client62_structs.h XMLParser.h
patches/patches.h ZoneNumbers.h
patches/SoD.h platform.h
patches/SoD_itemfields.h patches/Client62.h
patches/SoD_ops.h patches/Client62_itemfields.h
patches/SoD_structs.h patches/Client62_ops.h
patches/SoF.h patches/Client62_structs.h
patches/SoF_itemfields.h patches/patches.h
patches/SoF_opcode_list.h patches/SoD.h
patches/SoF_ops.h patches/SoD_itemfields.h
patches/SoF_structs.h patches/SoD_ops.h
patches/SSDeclare.h patches/SoD_structs.h
patches/SSDefine.h patches/SoF.h
patches/SSRegister.h patches/SoF_itemfields.h
patches/RoF.h patches/SoF_opcode_list.h
patches/RoF_itemfields.h patches/SoF_ops.h
patches/RoF_ops.h patches/SoF_structs.h
patches/RoF_structs.h patches/SSDeclare.h
patches/Titanium.h patches/SSDefine.h
patches/Titanium_itemfields.h patches/SSRegister.h
patches/Titanium_ops.h patches/RoF.h
patches/Titanium_structs.h patches/RoF_itemfields.h
patches/Underfoot.h patches/RoF_ops.h
patches/Underfoot_itemfields.h patches/RoF_structs.h
patches/Underfoot_ops.h patches/Titanium.h
patches/Underfoot_structs.h patches/Titanium_itemfields.h
SocketLib/Base64.h patches/Titanium_ops.h
SocketLib/File.h patches/Titanium_structs.h
SocketLib/HttpdCookies.h patches/Underfoot.h
SocketLib/HttpdForm.h patches/Underfoot_itemfields.h
SocketLib/HttpdSocket.h patches/Underfoot_ops.h
SocketLib/HTTPSocket.h patches/Underfoot_structs.h
SocketLib/IFile.h SocketLib/Base64.h
SocketLib/MemFile.h SocketLib/File.h
SocketLib/Mime.h SocketLib/HttpdCookies.h
SocketLib/Parse.h SocketLib/HttpdForm.h
SocketLib/socket_include.h SocketLib/HttpdSocket.h
SocketLib/Utility.h SocketLib/HTTPSocket.h
StackWalker/StackWalker.h SocketLib/IFile.h
tinyxml/tinystr.h SocketLib/MemFile.h
tinyxml/tinyxml.h SocketLib/Mime.h
SocketLib/Parse.h
SocketLib/socket_include.h
SocketLib/Utility.h
StackWalker/StackWalker.h
tinyxml/tinystr.h
tinyxml/tinyxml.h
) )
SOURCE_GROUP(Patches FILES SOURCE_GROUP(Patches FILES
patches/Client62.h patches/Client62.h
patches/Client62_itemfields.h patches/Client62_itemfields.h
patches/Client62_ops.h patches/Client62_ops.h
patches/Client62_structs.h patches/Client62_structs.h
patches/patches.h patches/patches.h
patches/SoD.h patches/SoD.h
patches/SoD_itemfields.h patches/SoD_itemfields.h
patches/SoD_ops.h patches/SoD_ops.h
patches/SoD_structs.h patches/SoD_structs.h
patches/SoF.h patches/SoF.h
patches/SoF_itemfields.h patches/SoF_itemfields.h
patches/SoF_opcode_list.h patches/SoF_opcode_list.h
patches/SoF_ops.h patches/SoF_ops.h
patches/SoF_structs.h patches/SoF_structs.h
patches/SSDeclare.h patches/SSDeclare.h
patches/SSDefine.h patches/SSDefine.h
patches/SSRegister.h patches/SSRegister.h
patches/RoF.h patches/RoF.h
patches/RoF_itemfields.h patches/RoF_itemfields.h
patches/RoF_ops.h patches/RoF_ops.h
patches/RoF_structs.h patches/RoF_structs.h
patches/Titanium.h patches/Titanium.h
patches/Titanium_itemfields.h patches/Titanium_itemfields.h
patches/Titanium_ops.h patches/Titanium_ops.h
patches/Titanium_structs.h patches/Titanium_structs.h
patches/Underfoot.h patches/Underfoot.h
patches/Underfoot_itemfields.h patches/Underfoot_itemfields.h
patches/Underfoot_ops.h patches/Underfoot_ops.h
patches/Underfoot_structs.h patches/Underfoot_structs.h
patches/Client62.cpp patches/Client62.cpp
patches/patches.cpp patches/patches.cpp
patches/SoD.cpp patches/SoD.cpp
patches/SoF.cpp patches/SoF.cpp
patches/RoF.cpp patches/RoF.cpp
patches/Titanium.cpp patches/Titanium.cpp
patches/Underfoot.cpp patches/Underfoot.cpp
) )
SOURCE_GROUP(SocketLib FILES SOURCE_GROUP(SocketLib FILES
SocketLib/Base64.h SocketLib/Base64.h
SocketLib/File.h SocketLib/File.h
SocketLib/HttpdCookies.h SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h SocketLib/HTTPSocket.h
SocketLib/IFile.h SocketLib/IFile.h
SocketLib/MemFile.h SocketLib/MemFile.h
SocketLib/Mime.h SocketLib/Mime.h
SocketLib/Parse.h SocketLib/Parse.h
SocketLib/socket_include.h SocketLib/socket_include.h
SocketLib/Utility.h SocketLib/Utility.h
SocketLib/Base64.cpp SocketLib/Base64.cpp
SocketLib/File.cpp SocketLib/File.cpp
SocketLib/HttpdCookies.cpp SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp SocketLib/MemFile.cpp
SocketLib/Mime.cpp SocketLib/Mime.cpp
SocketLib/Parse.cpp SocketLib/Parse.cpp
SocketLib/socket_include.cpp SocketLib/socket_include.cpp
SocketLib/Utility.cpp SocketLib/Utility.cpp
) )
SOURCE_GROUP(StackWalker FILES SOURCE_GROUP(StackWalker FILES
StackWalker/StackWalker.h StackWalker/StackWalker.h
StackWalker/StackWalker.cpp StackWalker/StackWalker.cpp
) )
SOURCE_GROUP(TinyXML FILES SOURCE_GROUP(TinyXML FILES
tinyxml/tinystr.h tinyxml/tinystr.h
tinyxml/tinyxml.h tinyxml/tinyxml.h
tinyxml/tinystr.cpp tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp tinyxml/tinyxmlparser.cpp
) )
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML) INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
ADD_LIBRARY(Common ${common_sources} ${common_headers}) ADD_LIBRARY(Common ${common_sources} ${common_headers})
IF(UNIX) IF(UNIX)
ADD_DEFINITIONS(-fPIC) ADD_DEFINITIONS(-fPIC)
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0) SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
ENDIF(UNIX) ENDIF(UNIX)
SET(LIBRARY_OUTPUT_PATH ../Bin) SET(LIBRARY_OUTPUT_PATH ../Bin)
+11 -342
View File
@@ -1,346 +1,15 @@
#include <stdio.h> #include "crc32.h"
unsigned long IntArray[]={ uint16 CRC16(const unsigned char *buf, int size, int key)
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,
};
unsigned long CRC16(const unsigned char *buf, int size, int key)
{ {
// This is computed as the lowest 16 bits of an Ethernet CRC32 checksum
//printf("CRC16() key=%d\n",key); // where the key is prepended to the data in little endian order.
/* uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
sub_0_10020760 proc near ; CODE XREF: sub_0_10008620+AEp (uint8)((key >> 8) & 0xff),
; sub_0_10022A90+14Fp ... (uint8)((key >> 16) & 0xff),
(uint8)((key >> 24) & 0xff)};
arg_0 = dword ptr 4 uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
arg_4 = dword ptr 8 crc = CRC32::Update(buf, size, crc);
arg_8 = dword ptr 0Ch return CRC32::Finish(crc) & 0xffff;
*/
//int *pecx = buf;
unsigned long ecx = key; //mov ecx, [esp+arg_8]
unsigned long eax = ecx; //mov eax, ecx
unsigned long edi;
/* int ecx = key; //mov ecx, [esp+arg_8]
int eax = ecx; //mov eax, ecx
int edi;
*/
eax = ~ eax; //not eax
eax&=0xFF; //and eax, 0FFh
eax=IntArray[eax]; //mov eax, dword_0_10115D38[eax*4] IntArray
eax ^= 0x00FFFFFF; //xor eax, 0FFFFFFh
int edx = ecx; //mov edx, ecx
edx = edx >> 8; //sar edx, 8
edx = edx ^ eax; //xor edx, eax
eax = eax >> 8; //sar eax, 8
edx &= 0xFF; //and edx, 0FFh
eax &= 0x00FFFFFF; //and eax, 0FFFFFFh
//push esi
eax ^= IntArray[edx]; //xor eax, dword_0_10115D38[edx*4]
edx = ecx; //mov edx, ecx
edx = edx >> 0x10; //sar edx, 10h
edx ^= eax; //xor edx, eax
eax = eax >> 8; //sar eax, 8
edx &= 0xFF; //and edx, 0FFh
int esi = IntArray[edx]; //mov esi, dword_0_10115D38[edx*4]
edx = size; //mov edx, [esp+4+arg_4]
eax &= 0x00FFFFFF; //and eax, 0FFFFFFh
eax ^= esi; //xor eax, esi
ecx = ecx >> 0x18; //sar ecx, 18h
ecx ^= eax; //xor ecx, eax
ecx &= 0xFF; //and ecx, 0FFh
esi = IntArray[ecx]; //mov esi, dword_0_10115D38[ecx*4]
/*ecx = (int) buf; not used */ //mov ecx, [esp+4+arg_0]
eax = eax >> 8; //sar eax, 8
eax &= 0x00FFFFFF; //and eax, 0FFFFFFh
eax ^= esi; //xor eax, esi
/* int* esi = ecx+edx //??*///lea esi, [ecx+edx]
for(int x = 0; x < size; x++)
{ //eax is the crc, ecx is the current part of the buffer
int edx = 0; //xor edx, edx
edx = buf[x] & 0x00FF; //mov dl, [ecx]
/*if(pos > size) //cmp ecx, esi
return ~eax; //jnb short loc_0_10020803
*/
//push edi
//loc_0_100207E0: ; CODE XREF: sub_0_10020760+A0j
//LOOP
edx ^= eax; //xor edx, eax
eax = eax >> 8; //sar eax, 8
edx &= 0xFF; //and edx, 0FFh
edi = IntArray[edx]; //mov edi, dword_0_10115D38[edx*4]
eax &= 0x00FFFFFF; //and eax, 0FFFFFFh
eax ^= edi; //xor eax, edi
//inc ecx
//cmp ecx, esi
// jb short loc_0_100207E0
//pop edi
}
return ~eax;
} }
/*loc_0_10020803: ; CODE XREF: sub_0_10020760+7Dj
not eax
pop esi
retn
sub_0_10020760 endp
*/
+2 -1
View File
@@ -1,6 +1,7 @@
#ifndef _CRC16_H #ifndef _CRC16_H
#define _CRC16_H #define _CRC16_H
#include "types.h"
unsigned long CRC16(const unsigned char *buf, int size, int key); uint16 CRC16(const unsigned char *buf, int size, int key);
#endif #endif
+126 -131
View File
@@ -1,153 +1,148 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "Condition.h" #include "Condition.h"
#ifdef _WINDOWS #ifdef _WINDOWS
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_waiters = 0;
InitializeCriticalSection(&CSMutex);
}
Condition::~Condition()
{
DeleteCriticalSection(&CSMutex);
CloseHandle(m_events[SignalEvent]);
CloseHandle(m_events[BroadcastEvent]);
}
void Condition::Signal()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[SignalEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::SignalAll()
{
EnterCriticalSection(&CSMutex);
if(m_waiters > 0)
SetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
void Condition::Wait()
{
EnterCriticalSection(&CSMutex);
m_waiters++;
LeaveCriticalSection(&CSMutex);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
EnterCriticalSection(&CSMutex);
m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast
//if so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
#else #else
#include <pthread.h> #include <pthread.h>
#include <sys/time.h> #include <sys/time.h>
#include <errno.h> #include <errno.h>
#endif
#ifdef _WINDOWS Condition::Condition()
{
pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr);
}
void Condition::Signal()
{
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
Condition::Condition() void Condition::SignalAll()
{ {
m_events[SignalEvent] = CreateEvent (NULL, // security pthread_mutex_lock(&mutex);
FALSE, // is auto-reset event? pthread_cond_broadcast(&cond);
FALSE, // is signaled initially? pthread_mutex_unlock(&mutex);
NULL); // name }
m_events[BroadcastEvent] = CreateEvent (NULL, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
NULL); // name
m_waiters = 0;
InitializeCriticalSection(&CSMutex);
}
Condition::~Condition() void Condition::Wait()
{ {
DeleteCriticalSection(&CSMutex); pthread_mutex_lock(&mutex);
CloseHandle(m_events[SignalEvent]); pthread_cond_wait(&cond,&mutex);
CloseHandle(m_events[BroadcastEvent]); pthread_mutex_unlock(&mutex);
} }
void Condition::Signal() /*
{ I commented this specifically because I think it might be very
EnterCriticalSection(&CSMutex); difficult to write a windows counterpart to it, so I would like
if(m_waiters > 0) to discourage its use until we can confirm that it can be reasonably
SetEvent(m_events[SignalEvent]); implemented on windows.
LeaveCriticalSection(&CSMutex);
}
void Condition::SignalAll() bool Condition::TimedWait(unsigned long usec)
{ {
EnterCriticalSection(&CSMutex); struct timeval now;
if(m_waiters > 0) struct timespec timeout;
SetEvent(m_events[BroadcastEvent]); int retcode=0;
LeaveCriticalSection(&CSMutex); pthread_mutex_lock(&mutex);
} gettimeofday(&now,nullptr);
now.tv_usec+=usec;
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
pthread_mutex_unlock(&mutex);
void Condition::Wait() return retcode!=ETIMEDOUT;
{ }
EnterCriticalSection(&CSMutex); */
m_waiters++; Condition::~Condition()
{
pthread_mutex_lock(&mutex);
LeaveCriticalSection(&CSMutex); pthread_cond_destroy(&cond);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE); pthread_mutex_unlock(&mutex);
EnterCriticalSection(&CSMutex); pthread_mutex_destroy(&mutex);
}
m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast
//if so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
#else //!WIN32
Condition::Condition()
{
pthread_cond_init(&cond,NULL);
pthread_mutex_init(&mutex,NULL);
}
void Condition::Signal()
{
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::SignalAll()
{
pthread_mutex_lock(&mutex);
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
}
void Condition::Wait()
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond,&mutex);
pthread_mutex_unlock(&mutex);
}
/*
I commented this specifically because I think it might be very
difficult to write a windows counterpart to it, so I would like
to discourage its use until we can confirm that it can be reasonably
implemented on windows.
bool Condition::TimedWait(unsigned long usec)
{
struct timeval now;
struct timespec timeout;
int retcode=0;
pthread_mutex_lock(&mutex);
gettimeofday(&now,NULL);
now.tv_usec+=usec;
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
pthread_mutex_unlock(&mutex);
return retcode!=ETIMEDOUT;
}
*/
Condition::~Condition()
{
pthread_mutex_lock(&mutex);
pthread_cond_destroy(&cond);
pthread_mutex_unlock(&mutex);
pthread_mutex_destroy(&mutex);
}
#endif #endif
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef __CONDITION_H #ifndef __CONDITION_H
#define __CONDITION_H #define __CONDITION_H
-62
View File
@@ -1,62 +0,0 @@
#ifdef _EQDEBUG
#include "../common/debug.h"
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "../common/Mutex.h"
#include "DBMemLeak.h"
#include <crtdbg.h>
#ifdef _WINDOWS
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
DBMemLeak dbmemleak;
LinkedList<DBMemLeakStruct*>* list = 0;
Mutex MDBMemLeak;
DBMemLeak::DBMemLeak() {
list = new LinkedList<DBMemLeakStruct*>;
}
DBMemLeak::~DBMemLeak() {
LinkedListIterator<DBMemLeakStruct*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
char tmp[200];
snprintf(tmp, sizeof(tmp) - 3, "DB Mem Leak: Block=%6d, Query=%s", iterator.GetData()->memblock, iterator.GetData()->query);
snprintf(tmp, sizeof(tmp), "%s\n", tmp);
OutputDebugString(tmp);
iterator.Advance();
}
safe_delete(list);
}
void DBMemLeak::Alloc(const void* result, const char* query) {
LockMutex lock(&MDBMemLeak);
long requestNumber;
uint8* tmp2 = new uint8;
_CrtIsMemoryBlock( tmp2, 1, &requestNumber, 0, 0 );
safe_delete(tmp2);
DBMemLeakStruct* tmp = (DBMemLeakStruct*) new uchar[sizeof(DBMemLeakStruct) + strlen(query) + 1];
tmp->result = result;
tmp->memblock = requestNumber;
strcpy(tmp->query, query);
list->Append(tmp);
}
void DBMemLeak::Free(const void* result) {
LockMutex lock(&MDBMemLeak);
LinkedListIterator<DBMemLeakStruct*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
if (result == iterator.GetData()->result)
iterator.RemoveCurrent();
else
iterator.Advance();
}
}
#endif
-25
View File
@@ -1,25 +0,0 @@
#ifdef _EQDEBUG
#ifndef DBMemLeak_H
#define DBMemLeak_H
#include "../common/types.h"
#include "../common/linked_list.h"
#define mysql_free_result(r) { DBMemLeak::Free(r); mysql_free_result(r); }
struct DBMemLeakStruct {
const void* result;
uint32 memblock;
char query[0];
};
class DBMemLeak {
public:
DBMemLeak();
~DBMemLeak();
static void Alloc(const void* result, const char* query);
static void Free(const void* result);
};
#endif
#endif
-300
View File
@@ -1,300 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include <iostream>
using namespace std;
#include "../common/types.h"
#include "EMuShareMem.h"
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define EmuLibName "EMuShareMem"
#else
#define EmuLibName "libEMuShareMem.so"
#endif
LoadEMuShareMemDLL EMuShareMemDLL;
#ifndef WIN32
uint32 LoadEMuShareMemDLL::refCount = 0;
#endif
LoadEMuShareMemDLL::LoadEMuShareMemDLL() {
ClearFunc();
#ifndef WIN32
refCountU();
#endif
}
LoadEMuShareMemDLL::~LoadEMuShareMemDLL() {
#ifndef WIN32
if (refCountD() <= 0) {
#endif
Unload();
#ifndef WIN32
}
#endif
}
bool LoadEMuShareMemDLL::Load() {
if(loaded)
return(true);
if(!SharedLibrary::Load(EmuLibName))
return(false);
if (Loaded()) {
Items.GetItem = (DLLFUNC_GetItem) GetSym("GetItem");
Items.IterateItems = (DLLFUNC_IterateItems) GetSym("IterateItems");
Items.cbAddItem = (DLLFUNC_AddItem) GetSym("AddItem");
Items.DLLLoadItems = (DLLFUNC_DLLLoadItems) GetSym("DLLLoadItems");
Doors.GetDoor = (DLLFUNC_GetDoor) GetSym("GetDoor");
Doors.cbAddDoor = (DLLFUNC_AddDoor) GetSym("AddDoor");
Doors.DLLLoadDoors = (DLLFUNC_DLLLoadDoors) GetSym("DLLLoadDoors");
Spells.DLLLoadSPDat = (DLLFUNC_DLLLoadSPDat) GetSym("DLLLoadSPDat");
NPCFactionList.DLLLoadNPCFactionLists = (DLLFUNC_DLLLoadNPCFactionLists) GetSym("DLLLoadNPCFactionLists");
NPCFactionList.GetNPCFactionList = (DLLFUNC_GetNPCFactionList) GetSym("GetNPCFactionList");
NPCFactionList.cbAddNPCFactionList = (DLLFUNC_AddNPCFactionList) GetSym("AddNPCFactionList");
NPCFactionList.cbSetFaction = (DLLFUNC_SetFaction) GetSym("SetNPCFaction");
Loot.DLLLoadLoot = (DLLFUNC_DLLLoadLoot) GetSym("DLLLoadLoot");
Loot.cbAddLootTable = (DLLFUNC_AddLootTable) GetSym("AddLootTable");
Loot.cbAddLootDrop = (DLLFUNC_AddLootDrop) GetSym("AddLootDrop");
Loot.GetLootTable = (DLLFUNC_GetLootTable) GetSym("GetLootTable");
Loot.GetLootDrop = (DLLFUNC_GetLootDrop) GetSym("GetLootDrop");
Opcodes.GetEQOpcode = (DLLFUNC_GetEQOpcode) GetSym("GetEQOpcode");
Opcodes.GetEmuOpcode = (DLLFUNC_GetEmuOpcode) GetSym("GetEmuOpcode");
Opcodes.SetOpcodePair = (DLLFUNC_SetOpcodePair) GetSym("SetOpcodePair");
Opcodes.DLLLoadOpcodes = (DLLFUNC_DLLLoadOpcodes) GetSym("DLLLoadOpcodes");
Opcodes.ClearEQOpcodes = (DLLFUNC_ClearEQOpcodes) GetSym("ClearEQOpcodes");
SkillCaps.LoadSkillCaps = (DLLFUNC_DLLLoadSkillCaps) GetSym("LoadSkillCaps");
SkillCaps.GetSkillCap = (DLLFUNC_GetSkillCap) GetSym("GetSkillCap");
SkillCaps.SetSkillCap = (DLLFUNC_SetSkillCap) GetSym("SetSkillCap");
SkillCaps.ClearSkillCaps = (DLLFUNC_ClearSkillCaps) GetSym("ClearSkillCaps");
SkillCaps.GetTrainLevel = (DLLFUNC_GetTrainLevel) GetSym("GetTrainLevel");
if(Items.GetItem == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Items.GetItem");
return(false);
}
if(Items.IterateItems == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Items.IterateItems");
return(false);
}
if(Items.cbAddItem == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Items.cbAddItem");
return(false);
}
if(Items.DLLLoadItems == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Items.DLLLoadItems");
return(false);
}
if(Doors.GetDoor == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Doors.GetDoor");
return(false);
}
if(Doors.cbAddDoor == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Doors.cbAddDoor");
return(false);
}
if(Doors.DLLLoadDoors == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Doors.DLLLoadDoors");
return(false);
}
if(Spells.DLLLoadSPDat == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Spells.DLLLoadSPDat");
return(false);
}
if(NPCFactionList.DLLLoadNPCFactionLists == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach NPCFactionList.DLLLoadNPCFactionLists");
return(false);
}
if(NPCFactionList.GetNPCFactionList == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach NPCFactionList.GetNPCFactionList");
return(false);
}
if(NPCFactionList.cbAddNPCFactionList == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach NPCFactionList.cbAddNPCFactionList");
return(false);
}
if(NPCFactionList.cbSetFaction == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach NPCFactionList.cbSetFaction");
return(false);
}
if(Loot.DLLLoadLoot == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.DLLLoadLoot");
return(false);
}
if(Loot.cbAddLootTable == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.cbAddLootTable");
return(false);
}
if(Loot.cbAddLootDrop == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.cbAddLootDrop");
return(false);
}
if(Loot.GetLootTable == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.GetLootTable");
return(false);
}
if(Loot.GetLootDrop == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.GetLootDrop");
return(false);
}
if(Opcodes.GetEQOpcode == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.GetEQOpcode");
return(false);
}
if(Opcodes.GetEmuOpcode == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.GetEmuOpcode");
return(false);
}
if(Opcodes.SetOpcodePair == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.SetOpcodePair");
return(false);
}
if(Opcodes.DLLLoadOpcodes == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.DLLLoadOpcodes");
return(false);
}
if(Opcodes.ClearEQOpcodes == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.ClearEQOpcodes");
return(false);
}
if(SkillCaps.LoadSkillCaps == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.LoadSkillCaps");
return(false);
}
if(SkillCaps.GetSkillCap == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.GetSkillCap");
return(false);
}
if(SkillCaps.SetSkillCap == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.SetSkillCap");
return(false);
}
if(SkillCaps.ClearSkillCaps == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.ClearSkillCaps");
return(false);
}
if(SkillCaps.GetTrainLevel == NULL) {
Unload();
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.GetTrainLevel");
return(false);
}
LogFile->write(EQEMuLog::Status, "%s loaded", EmuLibName);
loaded = true;
return true;
}
else {
LogFile->write(EQEMuLog::Error, "%s was not loaded, but did not report an error.", EmuLibName);
}
return false;
}
void LoadEMuShareMemDLL::Unload() {
ClearFunc();
SharedLibrary::Unload();
}
void LoadEMuShareMemDLL::ClearFunc() {
Items.GetItem = 0;
Items.IterateItems = 0;
Items.cbAddItem = 0;
Items.DLLLoadItems = 0;
Doors.GetDoor = 0;
Doors.cbAddDoor = 0;
Doors.DLLLoadDoors = 0;
NPCFactionList.DLLLoadNPCFactionLists = 0;
NPCFactionList.GetNPCFactionList = 0;
NPCFactionList.cbAddNPCFactionList = 0;
NPCFactionList.cbSetFaction = 0;
Loot.DLLLoadLoot = 0;
Loot.cbAddLootTable = 0;
Loot.cbAddLootDrop = 0;
Loot.GetLootTable = 0;
Loot.GetLootDrop = 0;
Opcodes.GetEQOpcode = NULL;
Opcodes.GetEmuOpcode = NULL;
Opcodes.SetOpcodePair = NULL;
Opcodes.DLLLoadOpcodes = NULL;
Opcodes.ClearEQOpcodes = NULL;
SkillCaps.LoadSkillCaps = NULL;
SkillCaps.GetSkillCap = NULL;
SkillCaps.SetSkillCap = NULL;
SkillCaps.ClearSkillCaps = NULL;
SkillCaps.GetTrainLevel = NULL;
loaded = false;
}
-187
View File
@@ -1,187 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 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 EMuShareMem_H
#define EMuShareMem_H
#ifdef _WINDOWS
#include <windows.h>
#else
#include "../common/unix.h"
#endif
#include "../common/eq_packet_structs.h"
#include "../zone/zonedump.h"
#include "../zone/loottable.h"
#include "SharedLibrary.h"
////////////
// Items //
///////////
typedef bool(*CALLBACK_DBLoadItems)(int32, uint32);
typedef bool(*DLLFUNC_DLLLoadItems)(const CALLBACK_DBLoadItems, uint32, int32*, uint32*);
typedef const Item_Struct*(*DLLFUNC_GetItem)(uint32);
typedef const Item_Struct*(*DLLFUNC_IterateItems)(uint32*);
typedef bool(*DLLFUNC_AddItem)(uint32, const Item_Struct*);
struct ItemsDLLFunc_Struct {
DLLFUNC_DLLLoadItems DLLLoadItems;
DLLFUNC_GetItem GetItem;
DLLFUNC_IterateItems IterateItems;
DLLFUNC_AddItem cbAddItem;
};
/*
typedef bool(*CALLBACK_DBLoadNPCTypes)(int32, uint32);
typedef bool(*DLLFUNC_DLLLoadNPCTypes)(const CALLBACK_DBLoadNPCTypes, uint32, int32*, uint32*);
typedef const NPCType*(*DLLFUNC_GetNPCType)(uint32);
typedef bool(*DLLFUNC_AddNPCType)(uint32, const NPCType*);
struct NPCTypesDLLFunc_Struct {
DLLFUNC_DLLLoadNPCTypes DLLLoadNPCTypes;
DLLFUNC_GetNPCType GetNPCType;
DLLFUNC_AddNPCType cbAddNPCType;
};
*/
////////////
// Doors ///
////////////
typedef bool(*CALLBACK_DBLoadDoors)(int32, uint32);
typedef bool(*DLLFUNC_DLLLoadDoors)(const CALLBACK_DBLoadDoors, uint32, int32*, uint32*);
typedef const Door*(*DLLFUNC_GetDoor)(uint32);
typedef bool(*DLLFUNC_AddDoor)(uint32, const Door*);
struct DoorsDLLFunc_Struct {
DLLFUNC_DLLLoadDoors DLLLoadDoors;
DLLFUNC_GetDoor GetDoor;
DLLFUNC_AddDoor cbAddDoor;
};
////////////
// Spells //
////////////
typedef bool(*CALLBACK_FileLoadSPDat)(void*, int32);
typedef bool(*DLLFUNC_DLLLoadSPDat)(const CALLBACK_FileLoadSPDat, const void**, int32*, uint32);
struct SpellsDLLFunc_Struct {
DLLFUNC_DLLLoadSPDat DLLLoadSPDat;
};
//////////////
// Factions //
//////////////
typedef bool(*CALLBACK_DBLoadNPCFactionLists)(int32, uint32);
typedef bool(*DLLFUNC_DLLLoadNPCFactionLists)(const CALLBACK_DBLoadNPCFactionLists, uint32, int32*, uint32*, uint8);
typedef const NPCFactionList*(*DLLFUNC_GetNPCFactionList)(uint32);
typedef bool(*DLLFUNC_AddNPCFactionList)(uint32, const NPCFactionList*);
typedef bool(*DLLFUNC_SetFaction)(uint32, uint32*, int32*, int8*, uint8*);
struct NPCFactionListDLLFunc_Struct {
DLLFUNC_DLLLoadNPCFactionLists DLLLoadNPCFactionLists;
DLLFUNC_GetNPCFactionList GetNPCFactionList;
DLLFUNC_AddNPCFactionList cbAddNPCFactionList;
DLLFUNC_SetFaction cbSetFaction;
};
////////////
// Loot //
///////////
typedef bool(*CALLBACK_DBLoadLoot)();
typedef bool(*DLLFUNC_DLLLoadLoot)(const CALLBACK_DBLoadLoot, uint32, uint32, uint32, uint32, uint32, uint32, uint32, uint32, uint32, uint32);
typedef bool(*DLLFUNC_AddLootTable)(uint32, const LootTable_Struct*);
typedef bool(*DLLFUNC_AddLootDrop)(uint32, const LootDrop_Struct*);
typedef const LootTable_Struct*(*DLLFUNC_GetLootTable)(uint32);
typedef const LootDrop_Struct*(*DLLFUNC_GetLootDrop)(uint32);
struct LootDLLFunc_Struct {
DLLFUNC_DLLLoadLoot DLLLoadLoot;
DLLFUNC_AddLootTable cbAddLootTable;
DLLFUNC_AddLootDrop cbAddLootDrop;
DLLFUNC_GetLootTable GetLootTable;
DLLFUNC_GetLootDrop GetLootDrop;
};
/////////////
// Opcodes //
/////////////
typedef bool(*CALLBACK_DBLoadOpcodes)(const char *filename);
typedef bool(*DLLFUNC_DLLLoadOpcodes)(const CALLBACK_DBLoadOpcodes, uint32 opsize, uint32 eq_count, uint32 emu_count, const char *filename);
typedef uint16 (*DLLFUNC_GetEQOpcode)(uint16 emu_op);
typedef uint16 (*DLLFUNC_GetEmuOpcode)(uint16 eq_op);
typedef void (*DLLFUNC_ClearEQOpcodes)();
typedef bool(*DLLFUNC_SetOpcodePair)(uint16 emu_op, uint16 eq_op);
struct OpcodeDLLFunc_Struct {
DLLFUNC_DLLLoadOpcodes DLLLoadOpcodes;
DLLFUNC_GetEQOpcode GetEQOpcode;
DLLFUNC_GetEmuOpcode GetEmuOpcode;
DLLFUNC_SetOpcodePair SetOpcodePair;
DLLFUNC_ClearEQOpcodes ClearEQOpcodes;
};
////////////////
// Skill Caps //
////////////////
typedef bool(*CALLBACK_DBLoadSkillCaps)();
typedef bool(*DLLFUNC_DLLLoadSkillCaps)(const CALLBACK_DBLoadSkillCaps, uint32 opsize, uint8 ClassCount, uint8 SkillCount, uint8 LevelCount);
typedef uint16 (*DLLFUNC_GetSkillCap)(uint8 Class_, uint8 Skill, uint8 Level);
typedef void (*DLLFUNC_ClearSkillCaps)();
typedef bool(*DLLFUNC_SetSkillCap)(uint8 Class_, uint8 Skill, uint8 Level, uint16 cap);
typedef uint8 (*DLLFUNC_GetTrainLevel)(uint8 Class_, uint8 Skill, uint8 Level);
struct SkillCapDLLFunc_Struct {
DLLFUNC_DLLLoadSkillCaps LoadSkillCaps;
DLLFUNC_GetSkillCap GetSkillCap;
DLLFUNC_SetSkillCap SetSkillCap;
DLLFUNC_ClearSkillCaps ClearSkillCaps;
DLLFUNC_GetTrainLevel GetTrainLevel;
};
class LoadEMuShareMemDLL : public SharedLibrary {
public:
LoadEMuShareMemDLL();
~LoadEMuShareMemDLL();
bool Load();
void Unload();
ItemsDLLFunc_Struct Items;
//NPCTypesDLLFunc_Struct NPCTypes;
DoorsDLLFunc_Struct Doors;
SpellsDLLFunc_Struct Spells;
NPCFactionListDLLFunc_Struct NPCFactionList;
LootDLLFunc_Struct Loot;
OpcodeDLLFunc_Struct Opcodes;
SkillCapDLLFunc_Struct SkillCaps;
private:
void ClearFunc();
bool loaded;
#ifdef _WINDOWS
#else
static uint32 refCount;
static uint32 refCountU() { return ++refCount; };
static uint32 refCountD() { return --refCount; };
#endif
};
#endif
+13 -16
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "EQDB.h" #include "EQDB.h"
@@ -53,11 +53,11 @@ EQDBRes * EQDB::query(Const_char *q) {
return new EQDBRes(r); return new EQDBRes(r);
} else { } else {
//no result, give them back a 'true but empty' result set //no result, give them back a 'true but empty' result set
return(new EQDBRes(NULL)); return(new EQDBRes(nullptr));
} }
} }
return NULL; return nullptr;
} }
//NOT THREAD SAFE! //NOT THREAD SAFE!
@@ -73,6 +73,3 @@ Const_char *EQDB::escape_string(Const_char *from) {
return(m_escapeBuffer.c_str()); return(m_escapeBuffer.c_str());
} }
+12 -12
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EQDB_H_ #ifndef EQDB_H_
#define EQDB_H_ #define EQDB_H_
@@ -46,7 +46,7 @@ public:
//END PERL EXPORT //END PERL EXPORT
private: private:
string m_escapeBuffer; std::string m_escapeBuffer;
static EQDB s_EQDB; static EQDB s_EQDB;
MYSQL *mysql_ref; MYSQL *mysql_ref;
}; };
+19 -18
View File
@@ -1,27 +1,27 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "EQDBRes.h" #include "EQDBRes.h"
#include <mysql.h> #include <mysql.h>
vector<string> EQDBRes::fetch_row_array() { std::vector<std::string> EQDBRes::fetch_row_array() {
vector<string> array; std::vector<std::string> array;
if(res == NULL) if(res == nullptr)
return(array); return(array);
int count=mysql_num_fields(res); int count=mysql_num_fields(res);
@@ -32,16 +32,16 @@ vector<string> EQDBRes::fetch_row_array() {
return array; return array;
} }
map<string,string> EQDBRes::fetch_row_hash() { std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash; std::map<std::string,std::string> rowhash;
if(res == NULL) if(res == nullptr)
return(rowhash); return(rowhash);
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long num_fields,i; unsigned long num_fields,i;
if (res && (num_fields=mysql_num_fields(res)) && (row = mysql_fetch_row(res))!=NULL && (fields = mysql_fetch_fields(res))!=NULL) { if (res && (num_fields=mysql_num_fields(res)) && (row = mysql_fetch_row(res))!=nullptr && (fields = mysql_fetch_fields(res))!=nullptr) {
for(i=0;i<num_fields;i++) { for(i=0;i<num_fields;i++) {
rowhash[fields[i].name]=(row[i] ? row[i] : ""); rowhash[fields[i].name]=(row[i] ? row[i] : "");
} }
@@ -49,3 +49,4 @@ map<string,string> EQDBRes::fetch_row_hash() {
return rowhash; return rowhash;
} }
+14 -14
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EQDBRes_H_ #ifndef EQDBRes_H_
#define EQDBRes_H_ #define EQDBRes_H_
@@ -35,9 +35,9 @@ public:
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; } unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; } unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
void DESTROY() { } void DESTROY() { }
void finish() { if (res) mysql_free_result(res); res=NULL; }; void finish() { if (res) mysql_free_result(res); res=nullptr; };
vector<string> fetch_row_array(); std::vector<std::string> fetch_row_array();
map<string,string> fetch_row_hash(); std::map<std::string,std::string> fetch_row_hash();
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; } unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
//END PERL EXPORT //END PERL EXPORT
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EQEMuError_H #ifndef EQEMuError_H
#define EQEMuError_H #define EQEMuError_H
+58 -82
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "EQEmuConfig.h" #include "EQEmuConfig.h"
@@ -21,8 +21,8 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
string EQEmuConfig::ConfigFile = "eqemu_config.xml"; std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = NULL; EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) { void EQEmuConfig::do_world(TiXmlElement *ele) {
const char *text; const char *text;
@@ -100,12 +100,12 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
// Check for locked // Check for locked
sub_ele = ele->FirstChildElement("locked"); sub_ele = ele->FirstChildElement("locked");
if (sub_ele != NULL) if (sub_ele != nullptr)
Locked=true; Locked=true;
// Get the <tcp> element // Get the <tcp> element
sub_ele = ele->FirstChildElement("tcp"); sub_ele = ele->FirstChildElement("tcp");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("ip"); text = sub_ele->Attribute("ip");
if (text) if (text)
@@ -123,7 +123,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
// Get the <http> element // Get the <http> element
sub_ele = ele->FirstChildElement("http"); sub_ele = ele->FirstChildElement("http");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
// text = sub_ele->Attribute("ip"); // text = sub_ele->Attribute("ip");
// if (text) // if (text)
@@ -228,7 +228,7 @@ void EQEmuConfig::do_zones(TiXmlElement *ele) {
// Get the <ports> element // Get the <ports> element
sub_ele = ele->FirstChildElement("ports"); sub_ele = ele->FirstChildElement("ports");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("low"); text = sub_ele->Attribute("low");
if (text) if (text)
@@ -296,7 +296,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
// Get the <timers> element // Get the <timers> element
sub_ele = ele->FirstChildElement("timers"); sub_ele = ele->FirstChildElement("timers");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("restart"); text = sub_ele->Attribute("restart");
if (text) if (text)
RestartWait = atoi(text); RestartWait = atoi(text);
@@ -315,7 +315,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
} }
} }
string EQEmuConfig::GetByName(const string &var_name) const { std::string EQEmuConfig::GetByName(const std::string &var_name) const {
if(var_name == "ShortName") if(var_name == "ShortName")
return(ShortName); return(ShortName);
if(var_name == "LongName") if(var_name == "LongName")
@@ -405,68 +405,44 @@ string EQEmuConfig::GetByName(const string &var_name) const {
void EQEmuConfig::Dump() const void EQEmuConfig::Dump() const
{ {
cout << "ShortName = " << ShortName << endl; std::cout << "ShortName = " << ShortName << std::endl;
cout << "LongName = " << LongName << endl; std::cout << "LongName = " << LongName << std::endl;
cout << "WorldAddress = " << WorldAddress << endl; std::cout << "WorldAddress = " << WorldAddress << std::endl;
cout << "LoginHost = " << LoginHost << endl; std::cout << "LoginHost = " << LoginHost << std::endl;
cout << "LoginAccount = " << LoginAccount << endl; std::cout << "LoginAccount = " << LoginAccount << std::endl;
cout << "LoginPassword = " << LoginPassword << endl; std::cout << "LoginPassword = " << LoginPassword << std::endl;
cout << "LoginPort = " << LoginPort << endl; std::cout << "LoginPort = " << LoginPort << std::endl;
cout << "Locked = " << Locked << endl; std::cout << "Locked = " << Locked << std::endl;
cout << "WorldTCPPort = " << WorldTCPPort << endl; std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
cout << "WorldIP = " << WorldIP << endl; std::cout << "WorldIP = " << WorldIP << std::endl;
cout << "TelnetEnabled = " << TelnetEnabled << endl; std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
cout << "WorldHTTPPort = " << WorldHTTPPort << endl; std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << endl; std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << endl; std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
cout << "ChatHost = " << ChatHost << endl; std::cout << "ChatHost = " << ChatHost << std::endl;
cout << "ChatPort = " << ChatPort << endl; std::cout << "ChatPort = " << ChatPort << std::endl;
cout << "MailHost = " << MailHost << endl; std::cout << "MailHost = " << MailHost << std::endl;
cout << "MailPort = " << MailPort << endl; std::cout << "MailPort = " << MailPort << std::endl;
cout << "DatabaseHost = " << DatabaseHost << endl; std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
cout << "DatabaseUsername = " << DatabaseUsername << endl; std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
cout << "DatabasePassword = " << DatabasePassword << endl; std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
cout << "DatabaseDB = " << DatabaseDB << endl; std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
cout << "DatabasePort = " << DatabasePort << endl; std::cout << "DatabasePort = " << DatabasePort << std::endl;
cout << "QSDatabaseHost = " << QSDatabaseHost << endl; std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
cout << "QSDatabaseUsername = " << QSDatabaseUsername << endl; std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
cout << "QSDatabasePassword = " << QSDatabasePassword << endl; std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
cout << "QSDatabaseDB = " << QSDatabaseDB << endl; std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
cout << "QSDatabasePort = " << QSDatabasePort << endl; std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
cout << "SpellsFile = " << SpellsFile << endl; std::cout << "SpellsFile = " << SpellsFile << std::endl;
cout << "OpCodesFile = " << OpCodesFile << endl; std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
cout << "EQTimeFile = " << EQTimeFile << endl; std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
cout << "LogSettingsFile = " << LogSettingsFile << endl; std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
cout << "MapDir = " << MapDir << endl; std::cout << "MapDir = " << MapDir << std::endl;
cout << "QuestDir = " << QuestDir << endl; std::cout << "QuestDir = " << QuestDir << std::endl;
cout << "PluginDir = " << PluginDir << endl; std::cout << "PluginDir = " << PluginDir << std::endl;
cout << "ZonePortLow = " << ZonePortLow << endl; std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
cout << "ZonePortHigh = " << ZonePortHigh << endl; std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
cout << "DefaultStatus = " << (int)DefaultStatus << endl; std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
// cout << "DynamicCount = " << DynamicCount << endl; // std::cout << "DynamicCount = " << DynamicCount << std::endl;
} }
+49 -49
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef __EQEmuConfig_H #ifndef __EQEmuConfig_H
#define __EQEmuConfig_H #define __EQEmuConfig_H
@@ -22,74 +22,74 @@
#include "linked_list.h" #include "linked_list.h"
struct LoginConfig { struct LoginConfig {
string LoginHost; std::string LoginHost;
string LoginAccount; std::string LoginAccount;
string LoginPassword; std::string LoginPassword;
uint16 LoginPort; uint16 LoginPort;
}; };
class EQEmuConfig : public XMLParser { class EQEmuConfig : public XMLParser {
public: public:
virtual string GetByName(const string &var_name) const; virtual std::string GetByName(const std::string &var_name) const;
// From <world/> // From <world/>
string ShortName; std::string ShortName;
string LongName; std::string LongName;
string WorldAddress; std::string WorldAddress;
string LocalAddress; std::string LocalAddress;
string LoginHost; std::string LoginHost;
string LoginAccount; std::string LoginAccount;
string LoginPassword; std::string LoginPassword;
uint16 LoginPort; uint16 LoginPort;
uint32 LoginCount; uint32 LoginCount;
LinkedList<LoginConfig*> loginlist; LinkedList<LoginConfig*> loginlist;
bool Locked; bool Locked;
uint16 WorldTCPPort; uint16 WorldTCPPort;
string WorldIP; std::string WorldIP;
bool TelnetEnabled; bool TelnetEnabled;
int32 MaxClients; int32 MaxClients;
bool WorldHTTPEnabled; bool WorldHTTPEnabled;
uint16 WorldHTTPPort; uint16 WorldHTTPPort;
string WorldHTTPMimeFile; std::string WorldHTTPMimeFile;
string SharedKey; std::string SharedKey;
// From <chatserver/> // From <chatserver/>
string ChatHost; std::string ChatHost;
uint16 ChatPort; uint16 ChatPort;
// From <mailserver/> // From <mailserver/>
string MailHost; std::string MailHost;
uint16 MailPort; uint16 MailPort;
// From <database/> // From <database/>
string DatabaseHost; std::string DatabaseHost;
string DatabaseUsername; std::string DatabaseUsername;
string DatabasePassword; std::string DatabasePassword;
string DatabaseDB; std::string DatabaseDB;
uint16 DatabasePort; uint16 DatabasePort;
// From <qsdatabase> // QueryServ // From <qsdatabase> // QueryServ
string QSDatabaseHost; std::string QSDatabaseHost;
string QSDatabaseUsername; std::string QSDatabaseUsername;
string QSDatabasePassword; std::string QSDatabasePassword;
string QSDatabaseDB; std::string QSDatabaseDB;
uint16 QSDatabasePort; uint16 QSDatabasePort;
// From <files/> // From <files/>
string SpellsFile; std::string SpellsFile;
string OpCodesFile; std::string OpCodesFile;
string EQTimeFile; std::string EQTimeFile;
string LogSettingsFile; std::string LogSettingsFile;
// From <directories/> // From <directories/>
string MapDir; std::string MapDir;
string QuestDir; std::string QuestDir;
string PluginDir; std::string PluginDir;
// From <launcher/> // From <launcher/>
string LogPrefix; std::string LogPrefix;
string LogSuffix; std::string LogSuffix;
string ZoneExe; std::string ZoneExe;
uint32 RestartWait; uint32 RestartWait;
uint32 TerminateWait; uint32 TerminateWait;
uint32 InitialBootWait; uint32 InitialBootWait;
@@ -108,7 +108,7 @@ protected:
static EQEmuConfig *_config; static EQEmuConfig *_config;
static string ConfigFile; static std::string ConfigFile;
#define ELEMENT(name) \ #define ELEMENT(name) \
void do_##name(TiXmlElement *ele); void do_##name(TiXmlElement *ele);
@@ -204,17 +204,17 @@ public:
// Produce a const singleton // Produce a const singleton
static const EQEmuConfig *get() { static const EQEmuConfig *get() {
if (_config == NULL) if (_config == nullptr)
LoadConfig(); LoadConfig();
return(_config); return(_config);
} }
// Allow the use to set the conf file to be used. // Allow the use to set the conf file to be used.
static void SetConfigFile(string file) { EQEmuConfig::ConfigFile = file; } static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
// Load the config // Load the config
static bool LoadConfig() { static bool LoadConfig() {
if (_config != NULL) if (_config != nullptr)
delete _config; delete _config;
_config=new EQEmuConfig; _config=new EQEmuConfig;
+36 -38
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* /*
* EQStream classes, by Quagmire * EQStream classes, by Quagmire
@@ -46,8 +46,6 @@
#include "../common/crc32.h" #include "../common/crc32.h"
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
using namespace std;
#define EQN_DEBUG 0 #define EQN_DEBUG 0
#define EQN_DEBUG_Error 0 #define EQN_DEBUG_Error 0
#define EQN_DEBUG_Packet 0 #define EQN_DEBUG_Packet 0
@@ -60,18 +58,18 @@ using namespace std;
#define LOG_RAW_PACKETS_IN 0 #define LOG_RAW_PACKETS_IN 0
//#define PRIORITYTEST //#define PRIORITYTEST
template <typename type> // LO_BYTE template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);} type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);} type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);} type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);} type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort template <typename type> // HI_LOSWAPshort
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);} type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
template <typename type> // HI_LOSWAPlong template <typename type> // HI_LOSWAPlong
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);} type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
EQStreamServer::EQStreamServer(uint16 iPort) { EQStreamServer::EQStreamServer(uint16 iPort) {
RunLoop = false; RunLoop = false;
@@ -125,8 +123,8 @@ bool EQStreamServer::Open(uint16 iPort) {
unsigned long nonblocking = 1; unsigned long nonblocking = 1;
#endif #endif
/* Setup internet address information. /* Setup internet address information.
This is used with the bind() call */ This is used with the bind() call */
memset((char *) &address, 0, sizeof(address)); memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET; address.sin_family = AF_INET;
address.sin_port = htons(pPort); address.sin_port = htons(pPort);
@@ -206,14 +204,14 @@ void EQStreamServer::Process() {
return; return;
} }
uchar buffer[1518]; uchar buffer[1518];
int status; int status;
struct sockaddr_in from; struct sockaddr_in from;
unsigned int fromlen; unsigned int fromlen;
from.sin_family = AF_INET; from.sin_family = AF_INET;
fromlen = sizeof(from); fromlen = sizeof(from);
while (1) { while (1) {
#ifdef WIN32 #ifdef WIN32
@@ -230,19 +228,19 @@ void EQStreamServer::Process() {
} }
} }
map <string, EQStream*>::iterator connection; std::map <std::string, EQStream*>::iterator connection;
for (connection = connection_list.begin( ); connection != connection_list.end( );) for (connection = connection_list.begin( ); connection != connection_list.end( );)
{ {
if(!connection->second) if(!connection->second)
{ {
map <string, EQStream*>::iterator tmp=connection; std::map <std::string, EQStream*>::iterator tmp=connection;
connection++; connection++;
connection_list.erase(tmp); connection_list.erase(tmp);
continue; continue;
} }
EQStream* eqs_data = connection->second; EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) { if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection; std::map <std::string, EQStream*>::iterator tmp=connection;
connection++; connection++;
safe_delete(eqs_data); safe_delete(eqs_data);
connection_list.erase(tmp); connection_list.erase(tmp);
@@ -277,7 +275,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort); sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
cout << "Data from " << temp << endl; cout << "Data from " << temp << endl;
EQStream* tmp = NULL; EQStream* tmp = NULL;
map <string, EQStream*>::iterator connection; std::map <std::string, EQStream*>::iterator connection;
if ((connection=connection_list.find(temp))!=connection_list.end()) if ((connection=connection_list.find(temp))!=connection_list.end())
tmp=connection->second; tmp=connection->second;
if(tmp != NULL && tmp->GetrPort() == irPort) if(tmp != NULL && tmp->GetrPort() == irPort)
@@ -285,7 +283,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
tmp->RecvData(data, size); tmp->RecvData(data, size);
return; return;
} }
else if(tmp != NULL && tmp->GetrPort() != irPort) else if(tmp != NULL && tmp->GetrPort() != irPort)
{ {
printf("Conflicting IPs & Ports: IP %i and Port %i is conflicting with IP %i and Port %i\n",irIP,irPort,tmp->GetrIP(),tmp->GetrPort()); printf("Conflicting IPs & Ports: IP %i and Port %i is conflicting with IP %i and Port %i\n",irIP,irPort,tmp->GetrIP(),tmp->GetrPort());
return; return;
+13 -14
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EQNETWORK_H #ifndef EQNETWORK_H
#define EQNETWORK_H #define EQNETWORK_H
@@ -30,7 +30,6 @@
#include <map> #include <map>
#include <list> #include <list>
#include <queue> #include <queue>
using namespace std;
#include "../common/types.h" #include "../common/types.h"
#include "../common/timer.h" #include "../common/timer.h"
@@ -114,8 +113,8 @@ private:
Mutex MNewQueue; Mutex MNewQueue;
Mutex MOpen; Mutex MOpen;
map<string,EQStream*> connection_list; std::map<std::string,EQStream*> connection_list;
queue<EQStream *> NewQueue; std::queue<EQStream *> NewQueue;
}; };
#endif #endif
+56 -58
View File
@@ -1,19 +1,19 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include <stdio.h> #include <stdio.h>
@@ -32,11 +32,9 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len) EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
emu_opcode(op) emu_opcode(op)
{ {
} }
@@ -61,7 +59,7 @@ void EQPacket::build_header_dump(char *buffer) const {
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -95,7 +93,7 @@ void EQProtocolPacket::build_header_dump(char *buffer) const
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -137,7 +135,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -183,7 +181,7 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -200,7 +198,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
uint32 EQProtocolPacket::serialize(unsigned char *dest) const uint32 EQProtocolPacket::serialize(unsigned char *dest) const
{ {
if (opcode>0xff) { if (opcode>0xff) {
*(uint16 *)dest=opcode; *(uint16 *)dest=opcode;
} else { } else {
*(dest)=0; *(dest)=0;
@@ -235,8 +233,8 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
} }
/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) /*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
opcode(op) opcode(op)
{ {
uint32 offset; uint32 offset;
@@ -248,7 +246,7 @@ uint32 offset;
memcpy(pBuffer,buf+offset,len-offset); memcpy(pBuffer,buf+offset,len-offset);
size=len-offset; size=len-offset;
} else { } else {
pBuffer=NULL; pBuffer=nullptr;
size=0; size=0;
} }
OpMgr=&RawOpcodeManager; OpMgr=&RawOpcodeManager;
@@ -294,7 +292,7 @@ get running again... but might be a good thing some day.
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs) bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
{ {
uint32 newsize=0, offset=0; uint32 newsize=0, offset=0;
unsigned char *tmpbuffer=NULL; unsigned char *tmpbuffer=nullptr;
if (opcode!=OP_AppCombined) { if (opcode!=OP_AppCombined) {
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1); newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);
@@ -364,7 +362,7 @@ uint32 flag_offset=0;
} else } else
flag_offset=1; flag_offset=1;
if (length>2 && buffer[flag_offset]==0x5a) { if (length>2 && buffer[flag_offset]==0x5a) {
newlen=InflatePacket(buffer+flag_offset+1,length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2; newlen=InflatePacket(buffer+flag_offset+1,length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
newbuf[newlen++]=buffer[length-2]; newbuf[newlen++]=buffer[length-2];
newbuf[newlen++]=buffer[length-1]; newbuf[newlen++]=buffer[length-1];
@@ -409,7 +407,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
buffer+=2; buffer+=2;
size-=2; size-=2;
int i; int i;
for (i = 0 ; i+4 <= size ; i+=4) for (i = 0 ; i+4 <= size ; i+=4)
{ {
int pt = (*(int*)&buffer[i])^(Key); int pt = (*(int*)&buffer[i])^(Key);
@@ -461,49 +459,49 @@ EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
} }
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len) EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf, len), : EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode) opcode(opcode)
{ {
} }
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len) EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16)) : EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
{ {
if(GetExecutablePlatform() != ExePlatformUCS) { if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf); opcode = *((const uint16 *) buf);
if(opcode == 0x0000) if(opcode == 0x0000)
{ {
if(len >= 3) if(len >= 3)
{ {
opcode = *((const uint16 *) (buf + 1)); opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3); const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3; const int32 packet_length = len - 3;
safe_delete_array(pBuffer); safe_delete_array(pBuffer);
if(len >= 0) if(len >= 0)
{ {
size = packet_length; size = packet_length;
pBuffer = new unsigned char[size]; pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size); memcpy(pBuffer, packet_start, size);
} }
else else
{ {
size = 0; size = 0;
} }
} }
else else
{ {
safe_delete_array(pBuffer); safe_delete_array(pBuffer);
size = 0; size = 0;
} }
} }
} else { } else {
opcode = *((const uint8 *) buf); opcode = *((const uint8 *) buf);
} }
} }
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) { void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
if (iShowInfo) { if (iShowInfo) {
cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec; std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
cout << " size:" << app->size << endl; std::cout << " size:" << app->size << std::endl;
} }
DumpPacketHex(app->pBuffer, app->size); DumpPacketHex(app->pBuffer, app->size);
// DumpPacketAscii(app->pBuffer, app->size); // DumpPacketAscii(app->pBuffer, app->size);
+17 -19
View File
@@ -1,19 +1,19 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef _EQPACKET_H #ifndef _EQPACKET_H
#define _EQPACKET_H #define _EQPACKET_H
@@ -30,8 +30,6 @@
#include "emu_opcodes.h" #include "emu_opcodes.h"
#endif #endif
using namespace std;
class EQStream; class EQStream;
class EQStreamPair; class EQStreamPair;
@@ -58,7 +56,7 @@ protected:
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len); EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
// EQPacket(const EQPacket &p) { } // EQPacket(const EQPacket &p) { }
EQPacket() { emu_opcode=OP_Unknown; pBuffer=NULL; size=0; } EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
}; };
@@ -102,14 +100,14 @@ class EQApplicationPacket : public EQPacket {
// friend class EQProtocolPacket; // friend class EQProtocolPacket;
friend class EQStream; friend class EQStream;
public: public:
EQApplicationPacket() : EQPacket(OP_Unknown,NULL,0) EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,NULL,0) EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,NULL,len) EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len) EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
bool combine(const EQApplicationPacket *rhs); bool combine(const EQApplicationPacket *rhs);
uint32 serialize (uint16 opcode, unsigned char *dest) const; uint32 serialize (uint16 opcode, unsigned char *dest) const;
uint32 Size() const { return size+app_opcode_size; } uint32 Size() const { return size+app_opcode_size; }
+104 -82
View File
@@ -1,30 +1,46 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "EQPacket.h"
#include "EQStream.h"
#include "misc.h"
#include "Mutex.h"
#include "op_codes.h"
#include "CRC16.h"
#include <string> #include <string>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <time.h> #include <algorithm>
#include <sys/types.h>
#if defined(ZONE) || defined(WORLD)
#define RETRANSMITS
#endif
#ifdef RETRANSMITS
#include "rulesys.h"
#endif
#ifdef _WINDOWS #ifdef _WINDOWS
#include <time.h> #include <time.h>
#else #else
#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
@@ -33,20 +49,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "EQPacket.h"
#include "EQStream.h"
//#include "EQStreamFactory.h"
#include "misc.h"
#include "Mutex.h"
#include "op_codes.h"
#include "CRC16.h"
#if defined(ZONE) || defined(WORLD)
#define RETRANSMITS
#endif
#ifdef RETRANSMITS
#include "rulesys.h"
#endif
//for logsys //for logsys
#define _L "%s:%d: " #define _L "%s:%d: "
@@ -65,7 +67,7 @@ void EQStream::init() {
LastAckSent=-1; LastAckSent=-1;
MaxSends=5; MaxSends=5;
LastPacket=0; LastPacket=0;
oversize_buffer=NULL; oversize_buffer=nullptr;
oversize_length=0; oversize_length=0;
oversize_offset=0; oversize_offset=0;
RateThreshold=RATEBASE/250; RateThreshold=RATEBASE/250;
@@ -77,7 +79,7 @@ void EQStream::init() {
retransmittimer = Timer::GetCurrentTime(); retransmittimer = Timer::GetCurrentTime();
retransmittimeout = 500 * RuleR(EQStream, RetransmitTimeoutMult); //use 500ms as base before we have connection stats retransmittimeout = 500 * RuleR(EQStream, RetransmitTimeoutMult); //use 500ms as base before we have connection stats
#endif #endif
OpMgr = NULL; OpMgr = nullptr;
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
_log(NET__ERROR, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); _log(NET__ERROR, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
} }
@@ -88,7 +90,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p) EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
{ {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, p->size); _log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, p->size);
_raw(NET__APP_CREATE_HEX, 0xFFFF, p); _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
ap = p->MakeAppPacket(); ap = p->MakeAppPacket();
@@ -97,7 +99,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len) EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
{ {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, len); _log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, len);
_hex(NET__APP_CREATE_HEX, buf, len); _hex(NET__APP_CREATE_HEX, buf, len);
ap = new EQRawApplicationPacket(buf, len); ap = new EQRawApplicationPacket(buf, len);
@@ -117,11 +119,11 @@ EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32
void EQStream::ProcessPacket(EQProtocolPacket *p) void EQStream::ProcessPacket(EQProtocolPacket *p)
{ {
uint32 processed=0,subpacket_length=0; uint32 processed=0,subpacket_length=0;
if (p == NULL) if (p == nullptr)
return; return;
// Raw Application packet // Raw Application packet
if (p->opcode > 0xff) { if (p->opcode > 0xff) {
p->opcode = htons(p->opcode); //byte order is backwards in the protocol packet p->opcode = htons(p->opcode); //byte order is backwards in the protocol packet
EQRawApplicationPacket *ap=MakeApplicationPacket(p); EQRawApplicationPacket *ap=MakeApplicationPacket(p);
if (ap) if (ap)
InboundQueuePush(ap); InboundQueuePush(ap);
@@ -153,7 +155,7 @@ uint32 processed=0,subpacket_length=0;
case OP_AppCombined: { case OP_AppCombined: {
processed=0; processed=0;
while(processed<p->size) { while(processed<p->size) {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) { if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) {
_log(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); _log(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length); ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length);
@@ -173,6 +175,11 @@ uint32 processed=0,subpacket_length=0;
break; break;
case OP_Packet: { case OP_Packet: {
if(!p->pBuffer || (p->Size() < 4))
{
_log(NET__ERROR, _L "Received OP_Packet that was of malformed size" __L);
break;
}
uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
SeqOrder check=CompareSequence(NextInSeq,seq); SeqOrder check=CompareSequence(NextInSeq,seq);
if (check == SeqFuture) { if (check == SeqFuture) {
@@ -187,7 +194,7 @@ uint32 processed=0,subpacket_length=0;
} else if (check == SeqPast) { } else if (check == SeqPast) {
_log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); _log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
_raw(NET__DEBUG, seq, p); _raw(NET__DEBUG, seq, p);
SendOutOfOrderAck(seq); //we already got this packet but it was out of order SendOutOfOrderAck(seq); //we already got this packet but it was out of order
} else { } else {
// In case we did queue one before as well. // In case we did queue one before as well.
EQProtocolPacket *qp=RemoveQueue(seq); EQProtocolPacket *qp=RemoveQueue(seq);
@@ -218,6 +225,11 @@ uint32 processed=0,subpacket_length=0;
break; break;
case OP_Fragment: { case OP_Fragment: {
if(!p->pBuffer || (p->Size() < 4))
{
_log(NET__ERROR, _L "Received OP_Fragment that was of malformed size" __L);
break;
}
uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
SeqOrder check=CompareSequence(NextInSeq,seq); SeqOrder check=CompareSequence(NextInSeq,seq);
if (check == SeqFuture) { if (check == SeqFuture) {
@@ -263,7 +275,7 @@ uint32 processed=0,subpacket_length=0;
} }
} }
delete[] oversize_buffer; delete[] oversize_buffer;
oversize_buffer=NULL; oversize_buffer=nullptr;
oversize_offset=0; oversize_offset=0;
} }
} else { } else {
@@ -284,6 +296,11 @@ uint32 processed=0,subpacket_length=0;
} }
break; break;
case OP_Ack: { case OP_Ack: {
if(!p->pBuffer || (p->Size() < 4))
{
_log(NET__ERROR, _L "Received OP_Ack that was of malformed size" __L);
break;
}
#ifndef COLLECTOR #ifndef COLLECTOR
uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
AckPackets(seq); AckPackets(seq);
@@ -383,6 +400,11 @@ uint32 processed=0,subpacket_length=0;
} }
break; break;
case OP_OutOfOrderAck: { case OP_OutOfOrderAck: {
if(!p->pBuffer || (p->Size() < 4))
{
_log(NET__ERROR, _L "Received OP_OutOfOrderAck that was of malformed size" __L);
break;
}
#ifndef COLLECTOR #ifndef COLLECTOR
uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
MOutboundQueue.lock(); MOutboundQueue.lock();
@@ -398,20 +420,20 @@ if(NextSequencedSend > SequencedQueue.size()) {
_log(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L, _log(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L,
seq, SequencedBase, SequencedBase+NextSequencedSend); seq, SequencedBase, SequencedBase+NextSequencedSend);
#ifdef RETRANSMITS #ifdef RETRANSMITS
if (!RuleB(EQStream, RetransmitAckedPackets)) { if (!RuleB(EQStream, RetransmitAckedPackets)) {
#endif #endif
uint16 sqsize = SequencedQueue.size(); uint16 sqsize = SequencedQueue.size();
uint16 index = seq - SequencedBase; uint16 index = seq - SequencedBase;
_log(NET__NET_TRACE, _L " OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize); _log(NET__NET_TRACE, _L " OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
if (index < sqsize) { if (index < sqsize) {
deque<EQProtocolPacket *>::iterator sitr; std::deque<EQProtocolPacket *>::iterator sitr;
sitr = SequencedQueue.begin(); sitr = SequencedQueue.begin();
sitr += index; sitr += index;
(*sitr)->acked = true; (*sitr)->acked = true;
} }
#ifdef RETRANSMITS #ifdef RETRANSMITS
} }
if (RuleR(EQStream, RetransmitTimeoutMult)) { // only choose new behavior if multiplier is set if (RuleR(EQStream, RetransmitTimeoutMult)) { // only choose new behavior if multiplier is set
retransmittimer = Timer::GetCurrentTime(); retransmittimer = Timer::GetCurrentTime();
} }
#endif #endif
@@ -480,24 +502,24 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req) void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
{ {
if(p == NULL) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
if (newp != NULL) if (newp != nullptr)
FastQueuePacket(&newp, ack_req); FastQueuePacket(&newp, ack_req);
} }
void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req) void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
{ {
EQApplicationPacket *pack=*p; EQApplicationPacket *pack=*p;
*p = NULL; //clear caller's pointer.. effectively takes ownership *p = nullptr; //clear caller's pointer.. effectively takes ownership
if(pack == NULL) if(pack == nullptr)
return; return;
if(OpMgr == NULL || *OpMgr == NULL) { if(OpMgr == nullptr || *OpMgr == nullptr) {
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L); _log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
delete pack; delete pack;
return; return;
@@ -537,7 +559,7 @@ uint32 length;
unsigned char *tmpbuff=new unsigned char[p->size+3]; unsigned char *tmpbuff=new unsigned char[p->size+3];
length=p->serialize(opcode, tmpbuff); length=p->serialize(opcode, tmpbuff);
EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,NULL,MaxLen-4); EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
*(uint32 *)(out->pBuffer+2)=htonl(p->Size()); *(uint32 *)(out->pBuffer+2)=htonl(p->Size());
used=MaxLen-10; used=MaxLen-10;
memcpy(out->pBuffer+6,tmpbuff,used); memcpy(out->pBuffer+6,tmpbuff,used);
@@ -546,8 +568,8 @@ uint32 length;
while (used<length) { while (used<length) {
out=new EQProtocolPacket(OP_Fragment,NULL,MaxLen-4); out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
chunksize=min(length-used,MaxLen-6); chunksize=std::min(length-used,MaxLen-6);
memcpy(out->pBuffer+2,tmpbuff+used,chunksize); memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
out->size=chunksize+2; out->size=chunksize+2;
SequencedPush(out); SequencedPush(out);
@@ -626,9 +648,9 @@ uint16 Seq=htons(seq);
void EQStream::Write(int eq_fd) void EQStream::Write(int eq_fd)
{ {
queue<EQProtocolPacket *> ReadyToSend; std::queue<EQProtocolPacket *> ReadyToSend;
bool SeqEmpty=false,NonSeqEmpty=false; bool SeqEmpty=false,NonSeqEmpty=false;
deque<EQProtocolPacket *>::iterator sitr; std::deque<EQProtocolPacket *>::iterator sitr;
// Check our rate to make sure we can send more // Check our rate to make sure we can send more
MRate.lock(); MRate.lock();
@@ -649,7 +671,7 @@ deque<EQProtocolPacket *>::iterator sitr;
MOutboundQueue.lock(); MOutboundQueue.lock();
// Place to hold the base packet t combine into // Place to hold the base packet t combine into
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
#ifdef RETRANSMITS #ifdef RETRANSMITS
// if we have a timeout defined and we have not received an ack recently enough, retransmit from beginning of queue // if we have a timeout defined and we have not received an ack recently enough, retransmit from beginning of queue
@@ -666,7 +688,7 @@ deque<EQProtocolPacket *>::iterator sitr;
sitr += NextSequencedSend; sitr += NextSequencedSend;
// Loop until both are empty or MaxSends is reached // Loop until both are empty or MaxSends is reached
while(!SeqEmpty || !NonSeqEmpty) { while(!SeqEmpty || !NonSeqEmpty) {
// See if there are more non-sequenced packets left // See if there are more non-sequenced packets left
if (!NonSequencedQueue.empty()) { if (!NonSequencedQueue.empty()) {
@@ -682,7 +704,7 @@ deque<EQProtocolPacket *>::iterator sitr;
_log(NET__NET_COMBINE, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size); _log(NET__NET_COMBINE, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size);
ReadyToSend.push(p); ReadyToSend.push(p);
BytesWritten+=p->size; BytesWritten+=p->size;
p=NULL; p=nullptr;
if (BytesWritten > threshold) { if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair // Sent enough this round, lets stop to be fair
@@ -741,7 +763,7 @@ continue;
_log(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size); _log(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size);
ReadyToSend.push(p); ReadyToSend.push(p);
BytesWritten+=p->size; BytesWritten+=p->size;
p=NULL; p=nullptr;
if (BytesWritten > threshold) { if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair // Sent enough this round, lets stop to be fair
@@ -844,7 +866,7 @@ EQProtocolPacket *EQStream::Read(int eq_fd, sockaddr_in *from)
{ {
int socklen; int socklen;
int length=0; int length=0;
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
char temp[15]; char temp[15];
socklen=sizeof(sockaddr); socklen=sizeof(sockaddr);
@@ -873,7 +895,7 @@ char temp[15];
void EQStream::SendSessionResponse() void EQStream::SendSessionResponse()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,NULL,sizeof(SessionResponse)); EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(SessionResponse));
SessionResponse *Response=(SessionResponse *)out->pBuffer; SessionResponse *Response=(SessionResponse *)out->pBuffer;
Response->Session=htonl(Session); Response->Session=htonl(Session);
Response->MaxLength=htonl(MaxLen); Response->MaxLength=htonl(MaxLen);
@@ -895,10 +917,10 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,NULL,sizeof(Sessio
void EQStream::SendSessionRequest() void EQStream::SendSessionRequest()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,NULL,sizeof(SessionRequest)); EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(SessionRequest));
SessionRequest *Request=(SessionRequest *)out->pBuffer; SessionRequest *Request=(SessionRequest *)out->pBuffer;
memset(Request,0,sizeof(SessionRequest)); memset(Request,0,sizeof(SessionRequest));
Request->Session=htonl(time(NULL)); Request->Session=htonl(time(nullptr));
Request->MaxLength=htonl(512); Request->MaxLength=htonl(512);
_log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength)); _log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
@@ -911,7 +933,7 @@ void EQStream::_SendDisconnect()
if(GetState() == CLOSED) if(GetState() == CLOSED)
return; return;
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,NULL,sizeof(uint32)); EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32));
*(uint32 *)out->pBuffer=htonl(Session); *(uint32 *)out->pBuffer=htonl(Session);
NonSequencedPush(out); NonSequencedPush(out);
@@ -927,11 +949,11 @@ void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
EQApplicationPacket *EQStream::PopPacket() EQApplicationPacket *EQStream::PopPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
@@ -939,7 +961,7 @@ EQRawApplicationPacket *p=NULL;
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != NULL && *OpMgr != NULL) { if(OpMgr != nullptr && *OpMgr != nullptr) {
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
#if EQDEBUG >= 4 #if EQDEBUG >= 4
if(emu_op == OP_Unknown) { if(emu_op == OP_Unknown) {
@@ -955,11 +977,11 @@ EQRawApplicationPacket *p=NULL;
EQRawApplicationPacket *EQStream::PopRawPacket() EQRawApplicationPacket *EQStream::PopRawPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
@@ -967,7 +989,7 @@ EQRawApplicationPacket *p=NULL;
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != NULL && *OpMgr != NULL) { if(OpMgr != nullptr && *OpMgr != nullptr) {
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
#if EQDEBUG >= 4 #if EQDEBUG >= 4
if(emu_op == OP_Unknown) { if(emu_op == OP_Unknown) {
@@ -983,11 +1005,11 @@ EQRawApplicationPacket *p=NULL;
EQRawApplicationPacket *EQStream::PeekPacket() EQRawApplicationPacket *EQStream::PeekPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
@@ -997,13 +1019,13 @@ EQRawApplicationPacket *p=NULL;
void EQStream::InboundQueueClear() void EQStream::InboundQueueClear()
{ {
EQApplicationPacket *p=NULL; EQApplicationPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L); _log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
MInboundQueue.lock(); MInboundQueue.lock();
if (!InboundQueue.empty()) { if (!InboundQueue.empty()) {
vector<EQRawApplicationPacket *>::iterator itr; std::vector<EQRawApplicationPacket *>::iterator itr;
for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) { for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) {
p=*itr; p=*itr;
delete p; delete p;
@@ -1040,7 +1062,7 @@ bool flag;
void EQStream::OutboundQueueClear() void EQStream::OutboundQueueClear()
{ {
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L); _log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
@@ -1050,7 +1072,7 @@ EQProtocolPacket *p=NULL;
NonSequencedQueue.pop(); NonSequencedQueue.pop();
} }
if(!SequencedQueue.empty()) { if(!SequencedQueue.empty()) {
deque<EQProtocolPacket *>::iterator itr; std::deque<EQProtocolPacket *>::iterator itr;
for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) { for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) {
p=*itr; p=*itr;
delete p; delete p;
@@ -1070,12 +1092,12 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::PacketQueueClear() void EQStream::PacketQueueClear()
{ {
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L); _log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
if(!PacketQueue.empty()) { if(!PacketQueue.empty()) {
map<unsigned short,EQProtocolPacket *>::iterator itr; std::map<unsigned short,EQProtocolPacket *>::iterator itr;
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) { for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
p=itr->second; p=itr->second;
delete p; delete p;
@@ -1129,7 +1151,7 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq) void EQStream::AckPackets(uint16 seq)
{ {
deque<EQProtocolPacket *>::iterator itr, tmp; std::deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock(); MOutboundQueue.lock();
//do a bit of sanity checking. //do a bit of sanity checking.
@@ -1203,8 +1225,8 @@ void EQStream::ProcessQueue()
return; return;
} }
EQProtocolPacket *qp=NULL; EQProtocolPacket *qp=nullptr;
while((qp=RemoveQueue(NextInSeq))!=NULL) { while((qp=RemoveQueue(NextInSeq))!=nullptr) {
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq); _log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
ProcessPacket(qp); ProcessPacket(qp);
delete qp; delete qp;
@@ -1214,8 +1236,8 @@ void EQStream::ProcessQueue()
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq) EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
{ {
map<unsigned short,EQProtocolPacket *>::iterator itr; std::map<unsigned short,EQProtocolPacket *>::iterator itr;
EQProtocolPacket *qp=NULL; EQProtocolPacket *qp=nullptr;
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) { if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
qp=itr->second; qp=itr->second;
PacketQueue.erase(itr); PacketQueue.erase(itr);
@@ -1288,7 +1310,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
if (expected_seq==seq) { if (expected_seq==seq) {
// Curent // Curent
return SeqInOrder; return SeqInOrder;
} else if ((seq > expected_seq && (uint32)seq < ((uint32)expected_seq + EQStream::MaxWindowSize)) || seq < (expected_seq - EQStream::MaxWindowSize)) { } else if ((seq > expected_seq && (uint32)seq < ((uint32)expected_seq + EQStream::MaxWindowSize)) || seq < (expected_seq - EQStream::MaxWindowSize)) {
// Future // Future
return SeqFuture; return SeqFuture;
} else { } else {
@@ -1336,6 +1358,9 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
_log(NET__DEBUG, _L "Timeout expired in established state. Closing connection." __L); _log(NET__DEBUG, _L "Timeout expired in established state. Closing connection." __L);
_SendDisconnect(); _SendDisconnect();
SetState(DISCONNECTING); SetState(DISCONNECTING);
break;
default:
break;
} }
} }
} }
@@ -1388,7 +1413,7 @@ void EQStream::Close() {
//this could be expanded to check more than the fitst opcode if //this could be expanded to check more than the fitst opcode if
//we needed more complex matching //we needed more complex matching
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) { EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
EQRawApplicationPacket *p = NULL; EQRawApplicationPacket *p = nullptr;
MatchState res = MatchNotReady; MatchState res = MatchNotReady;
MInboundQueue.lock(); MInboundQueue.lock();
@@ -1399,10 +1424,10 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
if(InboundQueue.size() > 1) { if(InboundQueue.size() > 1) {
p = InboundQueue[1]; p = InboundQueue[1];
} else { } else {
p = NULL; p = nullptr;
} }
} }
if(p == NULL) { if(p == nullptr) {
//first opcode is ignored, and nothing else remains... keep waiting //first opcode is ignored, and nothing else remains... keep waiting
} else if(p->opcode == sig->first_eq_opcode) { } else if(p->opcode == sig->first_eq_opcode) {
//opcode matches, check length.. //opcode matches, check length..
@@ -1428,6 +1453,3 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
return(res); return(res);
} }
+9 -11
View File
@@ -18,8 +18,6 @@
#include "../common/Condition.h" #include "../common/Condition.h"
#include "../common/timer.h" #include "../common/timer.h"
using namespace std;
#define FLAG_COMPRESSED 0x01 #define FLAG_COMPRESSED 0x01
#define FLAG_ENCODED 0x04 #define FLAG_ENCODED 0x04
@@ -89,7 +87,7 @@ class EQStream : public EQStreamInterface {
uint32 Session, Key; uint32 Session, Key;
uint16 NextInSeq; uint16 NextInSeq;
uint32 MaxLen; uint32 MaxLen;
uint16 MaxSends; uint16 MaxSends;
uint8 active_users; //how many things are actively using this uint8 active_users; //how many things are actively using this
@@ -113,8 +111,8 @@ class EQStream : public EQStreamInterface {
Mutex MAcks; Mutex MAcks;
// Packets waiting to be sent (all protected by MOutboundQueue) // Packets waiting to be sent (all protected by MOutboundQueue)
queue<EQProtocolPacket *> NonSequencedQueue; std::queue<EQProtocolPacket *> NonSequencedQueue;
deque<EQProtocolPacket *> SequencedQueue; std::deque<EQProtocolPacket *> SequencedQueue;
uint16 NextOutSeq; uint16 NextOutSeq;
uint16 SequencedBase; //the sequence number of SequencedQueue[0] uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue long NextSequencedSend; //index into SequencedQueue
@@ -124,8 +122,8 @@ class EQStream : public EQStreamInterface {
unsigned char _tempBuffer[2048]; unsigned char _tempBuffer[2048];
// Packets waiting to be processed // Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue; std::vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process() std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
Mutex MInboundQueue; Mutex MInboundQueue;
static uint16 MaxWindowSize; static uint16 MaxWindowSize;
@@ -167,7 +165,7 @@ class EQStream : public EQStreamInterface {
// virtual void DispatchPacket(EQApplicationPacket *p) { p->DumpRaw(); } // virtual void DispatchPacket(EQApplicationPacket *p) { p->DumpRaw(); }
bool Stale(uint32 now, uint32 timeout=30) { return (LastPacket && (now-LastPacket) > timeout); } bool Stale(uint32 now, uint32 timeout=30) { return (LastPacket && (now-LastPacket) > timeout); }
void InboundQueuePush(EQRawApplicationPacket *p); void InboundQueuePush(EQRawApplicationPacket *p);
EQRawApplicationPacket *PeekPacket(); //for collector. EQRawApplicationPacket *PeekPacket(); //for collector.
@@ -264,9 +262,9 @@ class EQStream : public EQStreamInterface {
class Signature { class Signature {
public: public:
//this object could get more complicated if needed... //this object could get more complicated if needed...
uint16 ignore_eq_opcode; //0=dont ignore uint16 ignore_eq_opcode; //0=dont ignore
uint16 first_eq_opcode; uint16 first_eq_opcode;
uint32 first_length; //0=dont check length uint32 first_length; //0=dont check length
}; };
typedef enum { typedef enum {
MatchNotReady, MatchNotReady,
@@ -277,5 +275,5 @@ class EQStream : public EQStreamInterface {
}; };
#endif #endif
+16 -36
View File
@@ -19,8 +19,6 @@
#include "EQStream.h" #include "EQStream.h"
#include "logsys.h" #include "logsys.h"
using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs=(EQStreamFactory *)eqfs;
@@ -35,7 +33,7 @@ EQStreamFactory *fs=(EQStreamFactory *)eqfs;
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs) ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
@@ -52,11 +50,11 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout) EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout) : Timeoutable(5000), stream_timeout(timeout)
{ {
StreamType=type; StreamType=type;
Port=port; Port=port;
@@ -112,15 +110,15 @@ struct sockaddr_in address;
_beginthread(EQStreamFactoryReaderLoop,0, this); _beginthread(EQStreamFactoryReaderLoop,0, this);
_beginthread(EQStreamFactoryWriterLoop,0, this); _beginthread(EQStreamFactoryWriterLoop,0, this);
#else #else
pthread_create(&t1,NULL,EQStreamFactoryReaderLoop,this); pthread_create(&t1,nullptr,EQStreamFactoryReaderLoop,this);
pthread_create(&t2,NULL,EQStreamFactoryWriterLoop,this); pthread_create(&t2,nullptr,EQStreamFactoryWriterLoop,this);
#endif #endif
return true; return true;
} }
EQStream *EQStreamFactory::Pop() EQStream *EQStreamFactory::Pop()
{ {
EQStream *s=NULL; EQStream *s=nullptr;
//cout << "Pop():Locking MNewStreams" << endl; //cout << "Pop():Locking MNewStreams" << endl;
MNewStreams.lock(); MNewStreams.lock();
if (NewStreams.size()) { if (NewStreams.size()) {
@@ -146,7 +144,7 @@ void EQStreamFactory::Push(EQStream *s)
void EQStreamFactory::ReaderLoop() void EQStreamFactory::ReaderLoop()
{ {
fd_set readset; fd_set readset;
map<string,EQStream *>::iterator stream_itr; std::map<std::string,EQStream *>::iterator stream_itr;
int num; int num;
int length; int length;
unsigned char buffer[2048]; unsigned char buffer[2048];
@@ -167,7 +165,7 @@ timeval sleep_time;
sleep_time.tv_sec=30; sleep_time.tv_sec=30;
sleep_time.tv_usec=0; sleep_time.tv_usec=0;
if ((num=select(sock+1,&readset,NULL,NULL,&sleep_time))<0) { if ((num=select(sock+1,&readset,nullptr,nullptr,&sleep_time))<0) {
// What do we wanna do? // What do we wanna do?
continue; continue;
} else if (num==0) } else if (num==0)
@@ -204,7 +202,7 @@ timeval sleep_time;
EQStream *curstream = stream_itr->second; EQStream *curstream = stream_itr->second;
//dont bother processing incoming packets for closed connections //dont bother processing incoming packets for closed connections
if(curstream->CheckClosed()) if(curstream->CheckClosed())
curstream = NULL; curstream = nullptr;
else else
curstream->PutInUse(); curstream->PutInUse();
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it. MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
@@ -227,7 +225,7 @@ void EQStreamFactory::CheckTimeout()
MStreams.lock(); MStreams.lock();
unsigned long now=Timer::GetCurrentTime(); unsigned long now=Timer::GetCurrentTime();
map<string,EQStream *>::iterator stream_itr; std::map<std::string,EQStream *>::iterator stream_itr;
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) { for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second; EQStream *s = stream_itr->second;
@@ -243,7 +241,7 @@ void EQStreamFactory::CheckTimeout()
} else { } else {
//everybody is done, we can delete it now //everybody is done, we can delete it now
//cout << "Removing connection" << endl; //cout << "Removing connection" << endl;
map<string,EQStream *>::iterator temp=stream_itr; std::map<std::string,EQStream *>::iterator temp=stream_itr;
stream_itr++; stream_itr++;
//let whoever has the stream outside delete it //let whoever has the stream outside delete it
delete temp->second; delete temp->second;
@@ -259,10 +257,10 @@ void EQStreamFactory::CheckTimeout()
void EQStreamFactory::WriterLoop() void EQStreamFactory::WriterLoop()
{ {
map<string,EQStream *>::iterator stream_itr; std::map<std::string,EQStream *>::iterator stream_itr;
bool havework=true; bool havework=true;
vector<EQStream *> wants_write; std::vector<EQStream *> wants_write;
vector<EQStream *>::iterator cur,end; std::vector<EQStream *>::iterator cur,end;
bool decay=false; bool decay=false;
uint32 stream_count; uint32 stream_count;
@@ -293,8 +291,8 @@ Timer DecayTimer(20);
stream_itr->second->Decay(); stream_itr->second->Decay();
//bullshit checking, to see if this is really happening, GDB seems to think so... //bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == NULL) { if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: NULL Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str()); fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
continue; continue;
} }
@@ -314,7 +312,6 @@ Timer DecayTimer(20);
(*cur)->ReleaseFromUse(); (*cur)->ReleaseFromUse();
} }
Sleep(10); Sleep(10);
MStreams.lock(); MStreams.lock();
@@ -328,20 +325,3 @@ Timer DecayTimer(20);
} }
} }
+3 -3
View File
@@ -24,17 +24,17 @@ class EQStreamFactory : private Timeoutable {
EQStreamType StreamType; EQStreamType StreamType;
queue<EQStream *> NewStreams; std::queue<EQStream *> NewStreams;
Mutex MNewStreams; Mutex MNewStreams;
map<string,EQStream *> Streams; std::map<std::string,EQStream *> Streams;
Mutex MStreams; Mutex MStreams;
virtual void CheckTimeout(); virtual void CheckTimeout();
Timer *DecayTimer; Timer *DecayTimer;
uint32 stream_timeout; uint32 stream_timeout;
public: public:
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; } EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
+8 -45
View File
@@ -1,17 +1,14 @@
#include "debug.h" #include "debug.h"
#include "EQStreamIdent.h" #include "EQStreamIdent.h"
#include "EQStreamProxy.h" #include "EQStreamProxy.h"
#include "logsys.h" #include "logsys.h"
using namespace std;
EQStreamIdentifier::~EQStreamIdentifier() { EQStreamIdentifier::~EQStreamIdentifier() {
while(!m_identified.empty()) { while(!m_identified.empty()) {
m_identified.front()->ReleaseFromUse(); m_identified.front()->ReleaseFromUse();
m_identified.pop(); m_identified.pop();
} }
vector<Record *>::iterator cur, end; std::vector<Record *>::iterator cur, end;
cur = m_streams.begin(); cur = m_streams.begin();
end = m_streams.end(); end = m_streams.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -19,7 +16,7 @@ EQStreamIdentifier::~EQStreamIdentifier() {
r->stream->ReleaseFromUse(); r->stream->ReleaseFromUse();
delete r; delete r;
} }
vector<Patch *>::iterator curp, endp; std::vector<Patch *>::iterator curp, endp;
curp = m_patches.begin(); curp = m_patches.begin();
endp = m_patches.end(); endp = m_patches.end();
for(; curp != endp; curp++) { for(; curp != endp; curp++) {
@@ -37,8 +34,8 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
} }
void EQStreamIdentifier::Process() { void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur; std::vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp; std::vector<Patch *>::iterator curp, endp;
//foreach pending stream. //foreach pending stream.
cur = m_streams.begin(); cur = m_streams.begin();
@@ -146,54 +143,20 @@ void EQStreamIdentifier::Process() {
void EQStreamIdentifier::AddStream(EQStream *&eqs) { void EQStreamIdentifier::AddStream(EQStream *&eqs) {
m_streams.push_back(new Record(eqs)); m_streams.push_back(new Record(eqs));
eqs = NULL; eqs = nullptr;
} }
EQStreamInterface *EQStreamIdentifier::PopIdentified() { EQStreamInterface *EQStreamIdentifier::PopIdentified() {
if(m_identified.empty()) if(m_identified.empty())
return(NULL); return(nullptr);
EQStreamInterface *res = m_identified.front(); EQStreamInterface *res = m_identified.front();
m_identified.pop(); m_identified.pop();
return(res); return(res);
} }
EQStreamIdentifier::Record::Record(EQStream *s) EQStreamIdentifier::Record::Record(EQStream *s)
: stream(s), : stream(s),
expire(STREAM_IDENT_WAIT_MS) expire(STREAM_IDENT_WAIT_MS)
{ {
} }
+1 -1
View File
@@ -30,7 +30,7 @@ protected:
class Patch { class Patch {
public: public:
std::string name; std::string name;
EQStream::Signature signature; EQStream::Signature signature;
OpcodeManager ** opcodes; OpcodeManager ** opcodes;
const StructStrategy *structs; const StructStrategy *structs;
}; };
+13 -16
View File
@@ -1,19 +1,19 @@
/* /*
Copyright (C) 2005 EQEmulator Team Copyright (C) 2005 EQEmulator Team
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef _EQSTREAM_LOCATOR_H #ifndef _EQSTREAM_LOCATOR_H
#define _EQSTREAM_LOCATOR_H #define _EQSTREAM_LOCATOR_H
@@ -24,7 +24,6 @@ This did not turn out nearly as nice as I hoped.
#include <map> #include <map>
#include <string> #include <string>
using namespace std;
class EQStreamInfo { class EQStreamInfo {
public: public:
@@ -99,11 +98,11 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port); return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port);
} }
//Forces the pointer T thing so we can return NULL //Forces the pointer T thing so we can return nullptr
template <class T> template <class T>
class EQStreamLocator { class EQStreamLocator {
protected: protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator; typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
public: public:
void Clear() { void Clear() {
@@ -157,7 +156,7 @@ public:
//may not be a constant time operation in theory, and update our //may not be a constant time operation in theory, and update our
//stored copy only on insert or delete //stored copy only on insert or delete
if(res == streams.end()) if(res == streams.end())
return(NULL); return(nullptr);
return(res->second); return(res->second);
} }
@@ -167,9 +166,7 @@ public:
// inline iterator end() const { return(streams.end()); } // inline iterator end() const { return(streams.end()); }
protected: protected:
map<const EQStreamInfo, T *> streams; std::map<const EQStreamInfo, T *> streams;
}; };
#endif #endif
+8 -8
View File
@@ -6,11 +6,11 @@
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes) EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
: m_stream(stream), : m_stream(stream),
m_structs(structs), m_structs(structs),
m_opcodes(opcodes) m_opcodes(opcodes)
{ {
stream = NULL; //take the stream. stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes); m_stream->SetOpcodeManager(m_opcodes);
} }
@@ -28,7 +28,7 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
} }
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) { void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if(p == NULL) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
@@ -36,15 +36,15 @@ void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
} }
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) { void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
if(p == NULL || *p == NULL) if(p == nullptr || *p == nullptr)
return; return;
m_structs->Encode(p, m_stream, ack_req); m_structs->Encode(p, m_stream, ack_req);
} }
EQApplicationPacket *EQStreamProxy::PopPacket() { EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket(); EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == NULL) if(pack == nullptr)
return(NULL); return(nullptr);
//pass this packet through the struct strategy. //pass this packet through the struct strategy.
m_structs->Decode(pack); m_structs->Decode(pack);
+1 -10
View File
@@ -35,21 +35,12 @@ public:
virtual const uint32 GetBytesRecvPerSecond() const; virtual const uint32 GetBytesRecvPerSecond() const;
protected: protected:
EQStream *const m_stream; //we own this stream object. EQStream *const m_stream; //we own this stream object.
const StructStrategy *const m_structs; //we do not own this object. const StructStrategy *const m_structs; //we do not own this object.
//this is a pointer to a pointer to make it less likely that a packet will //this is a pointer to a pointer to make it less likely that a packet will
//reference an invalid opcode manager when they are being reloaded. //reference an invalid opcode manager when they are being reloaded.
OpcodeManager **const m_opcodes; //we do not own this object. OpcodeManager **const m_opcodes; //we do not own this object.
}; };
#endif /*EQSTREAMPROXY_H_*/ #endif /*EQSTREAMPROXY_H_*/
+52 -89
View File
@@ -1,56 +1,34 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* /*
* There are really two or three different objects shoe-hored into this
* connection object. Sombody really needs to factor out the relay link
* crap into its own subclass of this object, it will clean things up
* tremendously.
* There are really two or three different objects shoe-hored into this */
* connection object. Sombody really needs to factor out the relay link
* crap into its own subclass of this object, it will clean things up
* tremendously.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
using namespace std;
#include "EmuTCPConnection.h" #include "EmuTCPConnection.h"
#include "EmuTCPServer.h" #include "EmuTCPServer.h"
@@ -71,12 +49,12 @@ using namespace std;
//server side case //server side case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat) EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
: TCPConnection(ID, in_socket, irIP, irPort), : TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
id = 0; id = 0;
Server = NULL; Server = nullptr;
pOldFormat = iOldFormat; pOldFormat = iOldFormat;
#ifdef MINILOGIN #ifdef MINILOGIN
TCPMode = modePacket; TCPMode = modePacket;
@@ -97,9 +75,9 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
//client outgoing connection case (and client side relay) //client outgoing connection case (and client side relay)
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode) EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
: TCPConnection(), : TCPConnection(),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
Server = iRelayServer; Server = iRelayServer;
if (Server) if (Server)
@@ -113,29 +91,27 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
TCPMode = iMode; TCPMode = iMode;
PacketMode = packetModeZone; PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #1 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
//server side relay case //server side relay case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort) EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
: TCPConnection(ID, 0, irIP, irPort), : TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
Server = iServer; Server = iServer;
RelayLink = iRelayLink; RelayLink = iRelayLink;
RelayServer = true; RelayServer = true;
RelayCount = 0; RelayCount = 0;
RemoteID = iRemoteID; RemoteID = iRemoteID;
if (!RemoteID)
ThrowError("Error: TCPConnection: RemoteID == 0 on RelayLink constructor");
pOldFormat = false; pOldFormat = false;
ConnectionType = Incomming; ConnectionType = Incomming;
TCPMode = modePacket; TCPMode = modePacket;
PacketMode = packetModeZone; PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #3 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
@@ -143,7 +119,6 @@ EmuTCPConnection::~EmuTCPConnection() {
//the queues free their content right now I believe. //the queues free their content right now I believe.
} }
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) { EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size; int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
if (pack->compressed) { if (pack->compressed) {
@@ -196,7 +171,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl; std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@@ -223,7 +198,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl; std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@@ -262,10 +237,10 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
if (pOldFormat) if (pOldFormat)
cout << " (OldFormat)"; std::cout << " (OldFormat)";
cout << endl; std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (tnps->size >= 32) if (tnps->size >= 32)
DumpPacket((uchar*) tnps, 32); DumpPacket((uchar*) tnps, 32);
@@ -284,7 +259,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
ServerPacket* EmuTCPConnection::PopPacket() { ServerPacket* EmuTCPConnection::PopPacket() {
ServerPacket* ret; ServerPacket* ret;
if (!MOutQueueLock.trylock()) if (!MOutQueueLock.trylock())
return NULL; return nullptr;
ret = OutQueue.pop(); ret = OutQueue.pop();
MOutQueueLock.unlock(); MOutQueueLock.unlock();
return ret; return ret;
@@ -307,7 +282,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
#if defined(GOTFRAGS) && 0 #if defined(GOTFRAGS) && 0
if (strcmp(line, "**CRASHME**") == 0) { if (strcmp(line, "**CRASHME**") == 0) {
int i = 0; int i = 0;
cout << (5 / i) << endl; std::cout << (5 / i) << std::endl;
} }
#endif #endif
if(line[0] == '*') { if(line[0] == '*') {
@@ -475,15 +450,14 @@ void EmuTCPConnection::ClearBuffers() {
timeout_timer.Start(); timeout_timer.Start();
} }
void EmuTCPConnection::SendNetErrorPacket(const char* reason) { void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1 #if TCPC_DEBUG >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout "NetError: '"; std::cout "NetError: '";
if (reason) if (reason)
cout << reason; std::cout << reason;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl; std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif #endif
ServerPacket* pack = new ServerPacket(0); ServerPacket* pack = new ServerPacket(0);
pack->size = 1; pack->size = 1;
@@ -546,7 +520,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
size = tnps->size; size = tnps->size;
if (size >= MaxTCPReceiveBuffferSize) { if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1 #if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl; std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
DumpPacket(&recvbuf[base], 16); DumpPacket(&recvbuf[base], 16);
#endif #endif
if (errbuf) if (errbuf)
@@ -586,13 +560,13 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
if (pack->opcode == 0) { if (pack->opcode == 0) {
if (pack->size) { if (pack->size) {
#if TCPN_DEBUG >= 2 #if TCPN_DEBUG >= 2
cout << "Received TCP Network layer packet" << endl; std::cout << "Received TCP Network layer packet" << std::endl;
#endif #endif
ProcessNetworkLayerPacket(pack); ProcessNetworkLayerPacket(pack);
} }
#if TCPN_DEBUG >= 5 #if TCPN_DEBUG >= 5
else { else {
cout << "Received TCP keepalive packet. (opcode=0)" << endl; std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
} }
#endif #endif
// keepalive, no need to process // keepalive, no need to process
@@ -604,7 +578,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl; std::cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@@ -620,7 +594,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
EmuTCPConnection* con = Server->FindConnection(pack->destination); EmuTCPConnection* con = Server->FindConnection(pack->destination);
if (!con) { if (!con) {
#if TCPN_DEBUG >= 1 #if TCPN_DEBUG >= 1
cout << "Error relaying packet: con = 0" << endl; std::cout << "Error relaying packet: con = 0" << std::endl;
#endif #endif
safe_delete(pack); safe_delete(pack);
} }
@@ -659,7 +633,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
memcpy(&size, &buffer[2], 2); memcpy(&size, &buffer[2], 2);
if (size >= MaxTCPReceiveBuffferSize) { if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1 #if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl; std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
#endif #endif
if (errbuf) if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize"); snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
@@ -689,7 +663,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl; std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@@ -750,7 +724,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 3 #if TCPC_DEBUG >= 3
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << endl; std::cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif #endif
RelayServer = true; RelayServer = true;
break; break;
@@ -798,10 +772,10 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 1 #if TCPC_DEBUG >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout "Received NetError: '"; std::cout "Received NetError: '";
if (pack->size > 1) if (pack->size > 1)
cout << (char*) data; std::cout << (char*) data;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl; std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif #endif
break; break;
} }
@@ -820,11 +794,11 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
SendPacket(pack); SendPacket(pack);
safe_delete(pack); safe_delete(pack);
#if TCPN_DEBUG >= 5 #if TCPN_DEBUG >= 5
cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl; std::cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << std::endl;
#endif #endif
} }
return(true); return(true);
} }
bool EmuTCPConnection::RecvData(char* errbuf) { bool EmuTCPConnection::RecvData(char* errbuf) {
@@ -844,14 +818,3 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
return(true); return(true);
} }
+1 -1
View File
@@ -49,7 +49,7 @@ public:
void SetPacketMode(ePacketMode mode) { PacketMode = mode; } void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
eTCPMode GetMode() const { return TCPMode; } eTCPMode GetMode() const { return TCPMode; }
ePacketMode GetPacketMode() const { return(PacketMode); } ePacketMode GetPacketMode() const { return(PacketMode); }
//relay crap: //relay crap:
inline bool IsRelayServer() const { return RelayServer; } inline bool IsRelayServer() const { return RelayServer; }
+5 -20
View File
@@ -1,14 +1,10 @@
#include "debug.h" #include "debug.h"
#include "EmuTCPServer.h" #include "EmuTCPServer.h"
#include "EmuTCPConnection.h" #include "EmuTCPConnection.h"
EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat) EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
: TCPServer<EmuTCPConnection>(iPort), : TCPServer<EmuTCPConnection>(iPort),
pOldFormat(iOldFormat) pOldFormat(iOldFormat)
{ {
} }
@@ -42,7 +38,7 @@ void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
MInQueue.lock(); MInQueue.lock();
m_InQueue.push(*tnps); m_InQueue.push(*tnps);
MInQueue.unlock(); MInQueue.unlock();
tnps = NULL; tnps = nullptr;
} }
void EmuTCPServer::CheckInQueue() { void EmuTCPServer::CheckInQueue() {
@@ -61,7 +57,7 @@ void EmuTCPServer::CheckInQueue() {
} }
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() { EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
EmuTCPNetPacket_Struct* ret = NULL; EmuTCPNetPacket_Struct* ret = nullptr;
MInQueue.lock(); MInQueue.lock();
if(!m_InQueue.empty()) { if(!m_InQueue.empty()) {
ret = m_InQueue.front(); ret = m_InQueue.front();
@@ -80,17 +76,6 @@ EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
if ((*cur)->GetID() == iID) if ((*cur)->GetID() == iID)
return *cur; return *cur;
} }
return(NULL); return(nullptr);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ public:
EmuTCPConnection *FindConnection(uint32 iID); EmuTCPConnection *FindConnection(uint32 iID);
//exposed for some crap we pull. Do not call from outside this object. //exposed for some crap we pull. Do not call from outside this object.
TCPServer<EmuTCPConnection>::AddConnection; using TCPServer<EmuTCPConnection>::AddConnection;
protected: protected:
virtual void Process(); virtual void Process();
+167 -203
View File
@@ -1,42 +1,34 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef _WINDOWS #include "debug.h"
// VS6 doesn't like the length of STL generated names: disabling #include "StringUtil.h"
#pragma warning(disable:4786)
// Quagmire: Dont know why the one in debug.h doesnt work, but it doesnt.
#endif
#include "../common/debug.h"
/*#ifdef _CRTDBG_MAP_ALLOC
#undef new
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
*/
#include <sstream>
#include <iostream>
#include <limits.h>
#include "Item.h" #include "Item.h"
#include "database.h" #include "database.h"
#include "misc.h" #include "misc.h"
#include "races.h" #include "races.h"
#include "shareddb.h" #include "shareddb.h"
#include "classes.h" #include "classes.h"
using namespace std;
#include <limits.h>
#include <sstream>
#include <iostream>
int32 NextItemInstSerialNumber = 1; int32 NextItemInstSerialNumber = 1;
@@ -102,7 +94,7 @@ ItemInstQueue::~ItemInstQueue() {
} }
Inventory::~Inventory() { Inventory::~Inventory() {
map<int16, ItemInst*>::iterator cur,end; std::map<int16, ItemInst*>::iterator cur,end;
cur = m_worn.begin(); cur = m_worn.begin();
@@ -162,22 +154,22 @@ ItemInst::ItemInst(const ItemInst& copy)
iter_contents it; iter_contents it;
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) { for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy.m_SerialNumber; m_SerialNumber = copy.m_SerialNumber;
m_custom_data = copy.m_custom_data; m_custom_data = copy.m_custom_data;
} }
// Clean up container contents // Clean up container contents
@@ -293,7 +285,7 @@ uint32 ItemInst::GetItemID(uint8 slot) const
{ {
const ItemInst *item; const ItemInst *item;
uint32 id=0; uint32 id=0;
if ((item=GetItem(slot))!=NULL) if ((item=GetItem(slot))!=nullptr)
id= item->GetItem()->ID; id= item->GetItem()->ID;
return id; return id;
@@ -316,9 +308,9 @@ bool ItemInst::IsAmmo() const {
if(!m_item) return false; if(!m_item) return false;
if((m_item->ItemType == ItemTypeArrow) || if((m_item->ItemType == ItemTypeArrow) ||
(m_item->ItemType == ItemTypeThrowing) || (m_item->ItemType == ItemTypeThrowing) ||
(m_item->ItemType == ItemTypeThrowingv2)) (m_item->ItemType == ItemTypeThrowingv2))
return true; return true;
return false; return false;
@@ -330,7 +322,7 @@ ItemInst* ItemInst::GetAugment(uint8 slot) const
if (m_item->ItemClass == ItemClassCommon) if (m_item->ItemClass == ItemClassCommon)
return GetItem(slot); return GetItem(slot);
return NULL; return nullptr;
} }
// Remove augment from item and destroy it // Remove augment from item and destroy it
@@ -346,7 +338,7 @@ ItemInst* ItemInst::RemoveAugment(uint8 index)
if (m_item->ItemClass == ItemClassCommon) if (m_item->ItemClass == ItemClassCommon)
return PopItem(index); return PopItem(index);
return NULL; return nullptr;
} }
// Add an augment to the item // Add an augment to the item
@@ -377,7 +369,7 @@ ItemInst* ItemInst::GetItem(uint8 index) const
return inst; return inst;
} }
return NULL; return nullptr;
} }
void ItemInst::PutItem(uint8 index, const ItemInst& inst) void ItemInst::PutItem(uint8 index, const ItemInst& inst)
@@ -472,7 +464,7 @@ ItemInst* ItemInst::PopItem(uint8 index)
} }
// Return pointer that needs to be deleted (or otherwise managed) // Return pointer that needs to be deleted (or otherwise managed)
return NULL; return nullptr;
} }
// Put item onto back of queue // Put item onto back of queue
@@ -491,7 +483,7 @@ void ItemInstQueue::push_front(ItemInst* inst)
ItemInst* ItemInstQueue::pop() ItemInst* ItemInstQueue::pop()
{ {
if (m_list.size() == 0) if (m_list.size() == 0)
return NULL; return nullptr;
ItemInst* inst = m_list.front(); ItemInst* inst = m_list.front();
m_list.pop_front(); m_list.pop_front();
@@ -501,14 +493,14 @@ ItemInst* ItemInstQueue::pop()
// Look at item at front of queue // Look at item at front of queue
ItemInst* ItemInstQueue::peek_front() const ItemInst* ItemInstQueue::peek_front() const
{ {
return (m_list.size()==0) ? NULL : m_list.front(); return (m_list.size()==0) ? nullptr : m_list.front();
} }
// Retrieve item at specified slot; returns false if item not found // Retrieve item at specified slot; returns false if item not found
ItemInst* Inventory::GetItem(int16 slot_id) const ItemInst* Inventory::GetItem(int16 slot_id) const
{ {
_CP(Inventory_GetItem); _CP(Inventory_GetItem);
ItemInst* result = NULL; ItemInst* result = nullptr;
// Cursor // Cursor
if (slot_id == SLOT_CURSOR) { if (slot_id == SLOT_CURSOR) {
@@ -579,64 +571,64 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
} }
std::string ItemInst::GetCustomDataString() const { std::string ItemInst::GetCustomDataString() const {
std::string ret_val; std::string ret_val;
map<std::string, std::string>::const_iterator iter = m_custom_data.begin(); std::map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
while(iter != m_custom_data.end()) { while(iter != m_custom_data.end()) {
if(ret_val.length() > 0) { if(ret_val.length() > 0) {
ret_val += "^"; ret_val += "^";
} }
ret_val += iter->first; ret_val += iter->first;
ret_val += "^"; ret_val += "^";
ret_val += iter->second; ret_val += iter->second;
iter++; iter++;
if(ret_val.length() > 0) { if(ret_val.length() > 0) {
ret_val += "^"; ret_val += "^";
} }
} }
return ret_val; return ret_val;
} }
void ItemInst::SetCustomData(std::string identifier, std::string value) { void ItemInst::SetCustomData(std::string identifier, std::string value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
m_custom_data[identifier] = value; m_custom_data[identifier] = value;
} }
void ItemInst::SetCustomData(std::string identifier, int value) { void ItemInst::SetCustomData(std::string identifier, int value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::SetCustomData(std::string identifier, float value) { void ItemInst::SetCustomData(std::string identifier, float value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::SetCustomData(std::string identifier, bool value) { void ItemInst::SetCustomData(std::string identifier, bool value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::DeleteCustomData(std::string identifier) { void ItemInst::DeleteCustomData(std::string identifier) {
map<std::string, std::string>::iterator iter = m_custom_data.find(identifier); std::map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) { if(iter != m_custom_data.end()) {
m_custom_data.erase(iter); m_custom_data.erase(iter);
} }
} }
std::string ItemInst::GetCustomData(std::string identifier) { std::string ItemInst::GetCustomData(std::string identifier) {
map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier); std::map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) { if(iter != m_custom_data.end()) {
return iter->second; return iter->second;
} }
return ""; return "";
} }
// Retrieve item at specified position within bag // Retrieve item at specified position within bag
@@ -857,7 +849,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
InvItem = GetItem(BaseSlotID + BagSlot); InvItem = GetItem(BaseSlotID + BagSlot);
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) &&
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) { (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges(); int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
@@ -940,17 +932,17 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
// If there are no charges left on the item, // If there are no charges left on the item,
if(item_to_delete->GetCharges() <= 0) { if(item_to_delete->GetCharges() <= 0) {
// If the item is stackable (e.g arrows), or // If the item is stackable (e.g arrows), or
// the item is not stackable, and is not a charged item, or is expendable, delete it // the item is not stackable, and is not a charged item, or is expendable, delete it
if(item_to_delete->IsStackable() || if(item_to_delete->IsStackable() ||
(!item_to_delete->IsStackable() && (!item_to_delete->IsStackable() &&
((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) { ((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) {
// Item can now be destroyed // Item can now be destroyed
safe_delete(item_to_delete); safe_delete(item_to_delete);
return true; return true;
} }
} }
// Charges still exist, or it is a charged item that is not expendable. Put back into inventory // Charges still exist, or it is a charged item that is not expendable. Put back into inventory
_PutItem(slot_id, item_to_delete); _PutItem(slot_id, item_to_delete);
return false; return false;
} }
@@ -963,11 +955,11 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
// Checks All items in a bag for No Drop // Checks All items in a bag for No Drop
bool Inventory::CheckNoDrop(int16 slot_id) { bool Inventory::CheckNoDrop(int16 slot_id) {
ItemInst* inst = GetItem(slot_id); ItemInst* inst = GetItem(slot_id);
if (!inst) return false; if (!inst) return false;
if (!inst->GetItem()->NoDrop) return true; if (!inst->GetItem()->NoDrop) return true;
if (inst->GetItem()->ItemClass == 1) { if (inst->GetItem()->ItemClass == 1) {
for (uint16 i=0; i<10; i++) { for (uint8 i = 0; i < 10; i++) {
ItemInst* bagitem = GetItem(Inventory::CalcSlotId(slot_id, i)); ItemInst* bagitem = GetItem(Inventory::CalcSlotId(slot_id, i));
if (bagitem && !bagitem->GetItem()->NoDrop) return true; if (bagitem && !bagitem->GetItem()->NoDrop) return true;
} }
@@ -979,7 +971,7 @@ bool Inventory::CheckNoDrop(int16 slot_id) {
// Returns item pointer if full delete was successful // Returns item pointer if full delete was successful
ItemInst* Inventory::PopItem(int16 slot_id) ItemInst* Inventory::PopItem(int16 slot_id)
{ {
ItemInst* p = NULL; ItemInst* p = nullptr;
if (slot_id==SLOT_CURSOR) { // Cursor if (slot_id==SLOT_CURSOR) { // Cursor
p = m_cursor.pop(); p = m_cursor.pop();
@@ -1007,7 +999,7 @@ ItemInst* Inventory::PopItem(int16 slot_id)
else { else {
// Is slot inside bag? // Is slot inside bag?
ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id)); ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id));
if (baginst != NULL && baginst->IsType(ItemClassContainer)) { if (baginst != nullptr && baginst->IsType(ItemClassContainer)) {
p = baginst->PopItem(Inventory::CalcBagIdx(slot_id)); p = baginst->PopItem(Inventory::CalcBagIdx(slot_id));
} }
} }
@@ -1060,107 +1052,79 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
return SLOT_INVALID; return SLOT_INVALID;
} }
void Inventory::dumpInventory() { void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
iter_contents itb;
if (!inst || !inst->IsType(ItemClassContainer))
return;
// Go through bag, if bag
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
std::string subSlot;
StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
}
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) for (it=collection.begin(); it!=collection.end(); it++) {
printf("Worn items:\n");
for (it=m_worn.begin(); it!=m_worn.end(); it++) {
inst = it->second; inst = it->second;
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); std::string slot;
StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
std::cout << slot << std::endl;
// Go through bag, if bag dumpBagContents(inst, &it);
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
} }
}
printf("Inventory items:\n"); void Inventory::dumpWornItems() {
for (it=m_inv.begin(); it!=m_inv.end(); it++) { std::cout << "Worn items:" << std::endl;
inst = it->second; dumpItemCollection(m_worn);
it->first; }
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); void Inventory::dumpInventory() {
std::cout << "Inventory items:" << std::endl;
dumpItemCollection(m_inv);
}
// Go through bag, if bag void Inventory::dumpBankItems() {
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} std::cout << "Bank items:" << std::endl;
} dumpItemCollection(m_bank);
} }
printf("Bank items:\n"); void Inventory::dumpSharedBankItems() {
for (it=m_bank.begin(); it!=m_bank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); std::cout << "Shared Bank items:" << std::endl;
dumpItemCollection(m_shbank);
}
// Go through bag, if bag void Inventory::dumpEntireInventory() {
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { dumpWornItems();
ItemInst* baginst = itb->second; dumpInventory();
if(!baginst || !baginst->GetItem()) dumpBankItems();
continue; dumpSharedBankItems();
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} std::cout << std::endl;
}
}
printf("Shared Bank items:\n");
for (it=m_shbank.begin(); it!=m_shbank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("\n");
fflush(stdout);
} }
// Internal Method: Retrieves item within an inventory bucket // Internal Method: Retrieves item within an inventory bucket
ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
{ {
iter_inst it = bucket.find(slot_id); iter_inst it = bucket.find(slot_id);
if (it != bucket.end()) { if (it != bucket.end()) {
@@ -1168,15 +1132,15 @@ ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id
} }
// Not found! // Not found!
return NULL; return nullptr;
} }
// Internal Method: "put" item into bucket, without regard for what is currently in bucket // Internal Method: "put" item into bucket, without regard for what is currently in bucket
// Assumes item has already been allocated // Assumes item has already been allocated
int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
{ {
// If putting a NULL into slot, we need to remove slot without memory delete // If putting a nullptr into slot, we need to remove slot without memory delete
if (inst == NULL) { if (inst == nullptr) {
//Why do we not delete the poped item here???? //Why do we not delete the poped item here????
PopItem(slot_id); PopItem(slot_id);
return slot_id; return slot_id;
@@ -1228,11 +1192,11 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
} }
// Internal Method: Checks an inventory bucket for a particular item // Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity) int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
@@ -1318,11 +1282,11 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
} }
// Internal Method: Checks an inventory bucket for a particular item // Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity) int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
@@ -1386,11 +1350,11 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
return SLOT_INVALID; return SLOT_INVALID;
} }
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup) int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) { for (it=bucket.begin(); it!=bucket.end(); it++) {
@@ -1690,29 +1654,29 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
iter_contents it; iter_contents it;
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) { for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy.m_SerialNumber; m_SerialNumber = copy.m_SerialNumber;
m_exp = copy.m_exp; m_exp = copy.m_exp;
m_evolveLvl = copy.m_evolveLvl; m_evolveLvl = copy.m_evolveLvl;
m_activated = copy.m_activated; m_activated = copy.m_activated;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
if (copy.m_scaledItem) if (copy.m_scaledItem)
m_scaledItem = new Item_Struct(*copy.m_scaledItem); m_scaledItem = new Item_Struct(*copy.m_scaledItem);
else else
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::EvoItemInst(const ItemInst &basecopy) { EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
@@ -1731,27 +1695,27 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
iter_contents it; iter_contents it;
for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) { for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy->m_custom_data.begin(); iter != copy->m_custom_data.end(); iter++) { for (iter = copy->m_custom_data.begin(); iter != copy->m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy->m_SerialNumber; m_SerialNumber = copy->m_SerialNumber;
m_exp = 0; m_exp = 0;
m_evolveLvl = 0; m_evolveLvl = 0;
m_activated = false; m_activated = false;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) { EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
@@ -1770,8 +1734,8 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
m_exp = 0; m_exp = 0;
m_evolveLvl = 0; m_evolveLvl = 0;
m_activated = false; m_activated = false;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::~EvoItemInst() { EvoItemInst::~EvoItemInst() {
@@ -1924,9 +1888,9 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
{ {
if (Classes_ % 2 == 1) if (Classes_ % 2 == 1)
{ {
if (CurrentClass == Class_) if (CurrentClass == Class_)
{ {
IsClass = true; IsClass = true;
break; break;
} }
} }
@@ -1939,11 +1903,11 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
{ {
if (Races_ % 2 == 1) if (Races_ % 2 == 1)
{ {
if (CurrentRace == Race_) if (CurrentRace == Race_)
{ {
IsRace = true; IsRace = true;
break; break;
} }
} }
Races_ >>= 1; Races_ >>= 1;
} }
+57 -51
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
// @merth notes: // @merth notes:
@@ -34,15 +34,14 @@ class EvolveInfo; // Stores information about an evolving item family
#include <vector> #include <vector>
#include <map> #include <map>
#include <list> #include <list>
using namespace std;
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h" #include "../common/eq_constants.h"
#include "../common/item_struct.h" #include "../common/item_struct.h"
// Helper typedefs // Helper typedefs
typedef list<ItemInst*>::const_iterator iter_queue; typedef std::list<ItemInst*>::const_iterator iter_queue;
typedef map<int16, ItemInst*>::const_iterator iter_inst; typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
typedef map<uint8, ItemInst*>::const_iterator iter_contents; typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
namespace ItemField { namespace ItemField {
enum { enum {
@@ -86,7 +85,7 @@ typedef enum {
//FatherNitwit: location bits for searching specific //FatherNitwit: location bits for searching specific
//places with HasItem() and HasItemByUse() //places with HasItem() and HasItemByUse()
enum { enum {
invWhereWorn = 0x01, invWhereWorn = 0x01,
invWherePersonal = 0x02, //in the character's inventory invWherePersonal = 0x02, //in the character's inventory
invWhereBank = 0x04, invWhereBank = 0x04,
invWhereSharedBank = 0x08, invWhereSharedBank = 0x08,
@@ -113,14 +112,14 @@ public:
void push_front(ItemInst* inst); void push_front(ItemInst* inst);
ItemInst* pop(); ItemInst* pop();
ItemInst* peek_front() const; ItemInst* peek_front() const;
inline int size() { return static_cast<int>(m_list.size()); } inline int size() { return static_cast<int>(m_list.size()); }
protected: protected:
///////////////////////// /////////////////////////
// Protected Members // Protected Members
///////////////////////// /////////////////////////
list<ItemInst*> m_list; std::list<ItemInst*> m_list;
}; };
@@ -196,39 +195,46 @@ public:
// Test whether a given slot can support a container item // Test whether a given slot can support a container item
static bool SupportsContainers(int16 slot_id); static bool SupportsContainers(int16 slot_id);
void dumpEntireInventory();
void dumpWornItems();
void dumpInventory(); 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, 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, 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, float value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier); std::string GetCustomItemData(int16 slot_id, std::string identifier);
protected: protected:
/////////////////////////////// ///////////////////////////////
// Protected Methods // Protected Methods
/////////////////////////////// ///////////////////////////////
void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it);
// Retrieves item within an inventory bucket // Retrieves item within an inventory bucket
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const; 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 // Private "put" item into bucket, without regard for what is currently in bucket
int16 _PutItem(int16 slot_id, ItemInst* inst); int16 _PutItem(int16 slot_id, ItemInst* inst);
// Checks an inventory bucket for a particular item // Checks an inventory bucket for a particular item
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity); int16 _HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity); int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
int16 _HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity); int16 _HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity); int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup); int16 _HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup); int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory // Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character std::map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
map<int16, ItemInst*> m_bank; // Items in character bank std::map<int16, ItemInst*> m_bank; // Items in character bank
map<int16, ItemInst*> m_shbank; // Items in character shared bank std::map<int16, ItemInst*> m_shbank; // Items in character shared bank
map<int16, ItemInst*> m_trade; // Items in a trade session std::map<int16, ItemInst*> m_trade; // Items in a trade session
ItemInstQueue m_cursor; // Items on cursor: FIFO ItemInstQueue m_cursor; // Items on cursor: FIFO
}; };
@@ -247,13 +253,13 @@ public:
///////////////////////// /////////////////////////
// Constructors/Destructor // Constructors/Destructor
ItemInst(const Item_Struct* item = NULL, int16 charges = 0); ItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0); ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
ItemInst(ItemUseType use_type) { ItemInst(ItemUseType use_type) {
m_use_type = use_type; m_use_type = use_type;
m_item = NULL; m_item = nullptr;
m_charges = 0; m_charges = 0;
m_price = 0; m_price = 0;
m_instnodrop = false; m_instnodrop = false;
@@ -300,7 +306,7 @@ public:
uint8 FirstOpenSlot() const; uint8 FirstOpenSlot() const;
uint8 GetTotalItemCount() const; uint8 GetTotalItemCount() const;
bool IsNoneEmptyContainer(); bool IsNoneEmptyContainer();
map<uint8, ItemInst*>* GetContents() { return &m_contents; } std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
// //
// Augments // Augments
@@ -339,7 +345,7 @@ public:
void SetMerchantCount(int32 count) { m_merchantcount = count; } void SetMerchantCount(int32 count) { m_merchantcount = count; }
int16 GetCurrentSlot() const { return m_currentslot; } int16 GetCurrentSlot() const { return m_currentslot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; } void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
@@ -348,16 +354,16 @@ public:
bool IsInstNoDrop() const { return m_instnodrop; } bool IsInstNoDrop() const { return m_instnodrop; }
void SetInstNoDrop(bool flag) { m_instnodrop=flag; } void SetInstNoDrop(bool flag) { m_instnodrop=flag; }
std::string GetCustomDataString() const; std::string GetCustomDataString() const;
void SetCustomData(std::string identifier, std::string value); void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value); void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value); void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value); void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier); std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier); void DeleteCustomData(std::string identifier);
// Allows treatment of this object as though it were a pointer to m_item // Allows treatment of this object as though it were a pointer to m_item
operator bool() const { return (m_item != NULL); } operator bool() const { return (m_item != nullptr); }
// Compare inner Item_Struct of two ItemInst objects // 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); }
@@ -371,7 +377,7 @@ public:
virtual bool IsScaling() const { return false; } virtual bool IsScaling() const { return false; }
virtual bool IsEvolving() const { return false; } virtual bool IsEvolving() const { return false; }
string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; } 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; }
inline int32 GetSerialNumber() const { return m_SerialNumber; } inline int32 GetSerialNumber() const { return m_SerialNumber; }
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; } inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
@@ -379,8 +385,8 @@ protected:
////////////////////////// //////////////////////////
// Protected Members // Protected Members
////////////////////////// //////////////////////////
iter_contents _begin() { return m_contents.begin(); } iter_contents _begin() { return m_contents.begin(); }
iter_contents _end() { return m_contents.end(); } iter_contents _end() { return m_contents.end(); }
friend class Inventory; friend class Inventory;
@@ -394,13 +400,13 @@ protected:
uint32 m_color; uint32 m_color;
uint32 m_merchantslot; uint32 m_merchantslot;
int16 m_currentslot; int16 m_currentslot;
bool m_instnodrop; bool m_instnodrop;
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar. int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
// //
// Items inside of this item (augs or contents); // Items inside of this item (augs or contents);
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9 std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
map<std::string, std::string> m_custom_data; std::map<std::string, std::string> m_custom_data;
}; };
class EvoItemInst: public ItemInst { class EvoItemInst: public ItemInst {
@@ -408,7 +414,7 @@ public:
// constructor and destructor // constructor and destructor
EvoItemInst(const EvoItemInst& copy); EvoItemInst(const EvoItemInst& copy);
EvoItemInst(const ItemInst& copy); EvoItemInst(const ItemInst& copy);
EvoItemInst(const Item_Struct* item = NULL, int16 charges = 0); EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
~EvoItemInst(); ~EvoItemInst();
// accessors... a lot of these are for evolving items (not complete yet) // accessors... a lot of these are for evolving items (not complete yet)
@@ -424,7 +430,7 @@ public:
EvoItemInst* Clone() const; EvoItemInst* Clone() const;
const Item_Struct* GetItem() const; const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const; const Item_Struct* GetUnscaledItem() const;
void Initialize(SharedDatabase *db = NULL); void Initialize(SharedDatabase *db = nullptr);
void ScaleItem(); void ScaleItem();
bool EvolveOnAllKills() const; bool EvolveOnAllKills() const;
int8 GetMaxEvolveLvl() const; int8 GetMaxEvolveLvl() const;
+3 -4
View File
@@ -643,9 +643,8 @@ uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) {
// Melee // Melee
case MONK: case MONKGM:{ case MONK: case MONKGM:{
// 1 252 252 // 1 252 252
r_value = level*7; // This can't be right can it? r_value = level*7; // This can't be right can it?
break break;
;
} }
case WARRIOR: case WARRIORGM: case WARRIOR: case WARRIORGM:
case ROGUE: case ROGUEGM: { case ROGUE: case ROGUEGM: {
@@ -1894,7 +1893,7 @@ uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) {
break; break;
} }
} // end switch (skillid) } // end switch (skillid)
// NO skill may go over 252 // NO skill may go over 252
if (r_value > 252) if (r_value > 252)
r_value = 252; r_value = 252;
return r_value; return r_value;
+114 -373
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "MiscFunctions.h" #include "MiscFunctions.h"
@@ -32,17 +32,12 @@
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/seperator.h" #include "../common/seperator.h"
using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
@@ -50,19 +45,15 @@ using namespace std;
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003 #ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <netdb.h> #include <netdb.h>
#include <errno.h> #include <errno.h>
#endif #endif
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
static bool WELLRNG_init = false; static bool WELLRNG_init = false;
static int state_i = 0; static int state_i = 0;
static unsigned int STATE[R]; static unsigned int STATE[R];
@@ -83,210 +74,15 @@ void CoutTimestamp(bool ms) {
time(&rawtime); time(&rawtime);
gmt_t = gmtime(&rawtime); gmt_t = gmtime(&rawtime);
struct timeval read_time; struct timeval read_time;
gettimeofday(&read_time,0); gettimeofday(&read_time,0);
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec; std::cout << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec;
if (ms) if (ms)
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000); std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
cout << " GMT"; std::cout << " GMT";
} }
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return dest;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return dest;
}
// String N w/null Copy Truncated?
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return false;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return (bool) (source[strlen(dest)] == 0);
}
const char *MakeUpperString(const char *source) {
static char str[128];
if (!source)
return NULL;
MakeUpperString(source, str);
return str;
}
void MakeUpperString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
}
const char *MakeLowerString(const char *source) {
static char str[128];
if (!source)
return NULL;
MakeLowerString(source, str);
return str;
}
void MakeLowerString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
va_copy(tmpargptr, argptr);
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
}
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
if (*bufsize == 0)
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
else
*bufsize += chars + 25;
oldret = *ret;
*ret = new char[*bufsize];
if (oldret) {
if (*strlen)
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
va_copy(tmpargptr, argptr);
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
return *strlen;
}
uint32 hextoi(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint32 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
uint64 hextoi64(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint64 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
bool atobool(char* iBool) {
if (!strcasecmp(iBool, "true"))
return true;
if (!strcasecmp(iBool, "false"))
return false;
if (!strcasecmp(iBool, "yes"))
return true;
if (!strcasecmp(iBool, "no"))
return false;
if (!strcasecmp(iBool, "on"))
return true;
if (!strcasecmp(iBool, "off"))
return false;
if (!strcasecmp(iBool, "enable"))
return true;
if (!strcasecmp(iBool, "disable"))
return false;
if (!strcasecmp(iBool, "enabled"))
return true;
if (!strcasecmp(iBool, "disabled"))
return false;
if (!strcasecmp(iBool, "y"))
return true;
if (!strcasecmp(iBool, "n"))
return false;
if (atoi(iBool))
return true;
return false;
}
int32 filesize(FILE* fp) { int32 filesize(FILE* fp) {
#ifdef _WINDOWS #ifdef _WINDOWS
@@ -314,14 +110,14 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0"); snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0");
return 0; return 0;
} }
struct sockaddr_in server_sin; struct sockaddr_in server_sin;
#ifdef _WINDOWS #ifdef _WINDOWS
PHOSTENT phostent = NULL; PHOSTENT phostent = nullptr;
#else #else
struct hostent *phostent = NULL; struct hostent *phostent = nullptr;
#endif #endif
server_sin.sin_family = AF_INET; server_sin.sin_family = AF_INET;
if ((phostent = gethostbyname(hostname)) == NULL) { if ((phostent = gethostbyname(hostname)) == nullptr) {
#ifdef _WINDOWS #ifdef _WINDOWS
if (errbuf) if (errbuf)
snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError()); snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError());
@@ -394,9 +190,9 @@ int MakeRandomInt(int low, int high)
return(low); return(low);
//return (rand()%(high-low+1) + (low)); //return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
} }
unsigned int randomnum = ((WELLRNG19937)()); unsigned int randomnum = ((WELLRNG19937)());
@@ -412,9 +208,9 @@ double MakeRandomFloat(double low, double high)
return(low); return(low);
//return (rand() / (double)RAND_MAX * (high - low) + low); //return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
} }
return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low); return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low);
@@ -422,41 +218,41 @@ double MakeRandomFloat(double low, double high)
uint32 rnd_hash( time_t t, clock_t c ) uint32 rnd_hash( time_t t, clock_t c )
{ {
// Get a uint32 from t and c // Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1] // Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk) // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0; uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t; unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i ) for( size_t i = 0; i < sizeof(t); ++i )
{ {
h1 *= 255 + 2U; h1 *= 255 + 2U;
h1 += p[i]; h1 += p[i];
} }
uint32 h2 = 0; uint32 h2 = 0;
p = (unsigned char *) &c; p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j ) for( size_t j = 0; j < sizeof(c); ++j )
{ {
h2 *= 255 + 2U; h2 *= 255 + 2U;
h2 += p[j]; h2 += p[j];
} }
return ( h1 + differ++ ) ^ h2; return ( h1 + differ++ ) ^ h2;
} }
void oneseed( const uint32 seed ) void oneseed( const uint32 seed )
{ {
// Initialize generator state with seed // Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect // In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. // only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0; register int j = 0;
STATE[j] = seed & 0xffffffffUL; STATE[j] = seed & 0xffffffffUL;
for (j = 1; j < R; j++) for (j = 1; j < R; j++)
{ {
STATE[j] = ( 1812433253UL * ( STATE[j-1] ^ (STATE[j-1] >> 30) ) + j ) & 0xffffffffUL; STATE[j] = ( 1812433253UL * ( STATE[j-1] ^ (STATE[j-1] >> 30) ) + j ) & 0xffffffffUL;
} }
} }
// WELL RNG code // WELL RNG code
@@ -472,117 +268,83 @@ void oneseed( const uint32 seed )
/* ***************************************************************************** */ /* ***************************************************************************** */
unsigned int case_1 (void){ unsigned int case_1 (void){
// state_i == 0 // state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU); z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1; state_i = R - 1;
WELLRNG19937 = case_3; WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_2 (void){ static unsigned int case_2 (void){
// state_i == 1 // state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU); z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0; state_i = 0;
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
static unsigned int case_3 (void){ static unsigned int case_3 (void){
// state_i+M1 >= R // state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M1 < R) if (state_i + M1 < R)
WELLRNG19937 = case_5; WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_4 (void){ static unsigned int case_4 (void){
// state_i+M3 >= R // state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M3 < R) if (state_i + M3 < R)
WELLRNG19937 = case_6; WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
static unsigned int case_5 (void){ static unsigned int case_5 (void){
// state_i+M2 >= R // state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M2 < R) if (state_i + M2 < R)
WELLRNG19937 = case_4; WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_6 (void){ static unsigned int case_6 (void){
// 2 <= state_i <= (R - M3 - 1) // 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i == 1) if (state_i == 1)
WELLRNG19937 = case_2; WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
// end WELL RNG code // end WELL RNG code
// solar: removes the crap and turns the underscores into spaces.
char *CleanMobName(const char *in, char *out)
{
unsigned i, j;
for(i = j = 0; i < strlen(in); i++)
{
// convert _ to space.. any other conversions like this? I *think* this
// is the only non alpha char that's not stripped but converted.
if(in[i] == '_')
{
out[j++] = ' ';
}
else
{
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
out[j++] = in[i];
}
}
out[j] = 0; // terimnate the string before returning it
return out;
}
const char *ConvertArray(int input, char *returnchar)
{
sprintf(returnchar, "%i" ,input);
return returnchar;
}
const char *ConvertArrayF(float input, char *returnchar)
{
sprintf(returnchar, "%0.2f", input);
return returnchar;
}
float EQ13toFloat(int d) float EQ13toFloat(int d)
{ {
@@ -627,24 +389,3 @@ float EQHtoFloat(int d)
{ {
return(360.0f - float((d * 360) >> 11)); return(360.0f - float((d * 360) >> 11));
} }
void RemoveApostrophes(std::string &s)
{
for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'')
s[i] = '_';
}
char *RemoveApostrophes(const char *s)
{
char *NewString = new char[strlen(s) + 1];
strcpy(NewString, s);
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'')
NewString[i] = '_';
return NewString;
}
+34 -61
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef MISCFUNCTIONS_H #ifndef MISCFUNCTIONS_H
#define MISCFUNCTIONS_H #define MISCFUNCTIONS_H
@@ -32,9 +32,9 @@
// These are helper macros for dealing with packets of variable length, typically those that contain // These are helper macros for dealing with packets of variable length, typically those that contain
// variable length strings where it is not convenient to use a fixed length struct. // variable length strings where it is not convenient to use a fixed length struct.
// //
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type); #define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1; #define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; } #define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, "%s", String); Buffer += strlen(String) + 1; }
#define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; } #define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; }
#define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); } #define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
#define VARSTRUCT_SKIP_TYPE(Type, Buffer) Buffer += sizeof(Type); #define VARSTRUCT_SKIP_TYPE(Type, Buffer) Buffer += sizeof(Type);
@@ -63,62 +63,37 @@
#define MAT1(v) v #define MAT1(v) v
#define MAT3POS(t,v) (v>>t) #define MAT3POS(t,v) (v>>t)
#define V0 STATE[state_i] #define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R] #define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1] #define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R] #define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2] #define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R] #define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3] #define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1] #define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1] #define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2] #define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2] #define VRm2Under STATE[state_i+R-2]
#define newV0 STATE[state_i-1] #define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R] #define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i] #define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2] #define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R] #define newVRm1Under STATE[state_i-2+R]
#define newVM2Over STATE[state_i+M2-R+1] #define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1] #define newVM2 STATE[state_i+M2+1]
#define BITMASK 0x41180000 #define BITMASK 0x41180000
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target);
int MakeAnyLenString(char** ret, const char* format, ...);
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
uint32 hextoi(char* num);
uint64 hextoi64(char* num);
bool atobool(char* iBool);
int32 filesize(FILE* fp); int32 filesize(FILE* fp);
uint32 ResolveIP(const char* hostname, char* errbuf = 0); uint32 ResolveIP(const char* hostname, char* errbuf = 0);
bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0); bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0);
void CoutTimestamp(bool ms = true); void CoutTimestamp(bool ms = true);
char* strn0cpy(char* dest, const char* source, uint32 size);
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size);
int MakeRandomInt(int low, int high); int MakeRandomInt(int low, int high);
double MakeRandomFloat(double low, double high); double MakeRandomFloat(double low, double high);
char *CleanMobName(const char *in, char *out);
const char *ConvertArray(int input, char *returnchar);
const char *ConvertArrayF(float input, char *returnchar);
float EQ13toFloat(int d); float EQ13toFloat(int d);
float NewEQ13toFloat(int d); float NewEQ13toFloat(int d);
float EQ19toFloat(int d); float EQ19toFloat(int d);
@@ -127,8 +102,6 @@ int FloatToEQ13(float d);
int NewFloatToEQ13(float d); int NewFloatToEQ13(float d);
int FloatToEQ19(float d); int FloatToEQ19(float d);
int FloatToEQH(float d); int FloatToEQH(float d);
void RemoveApostrophes(std::string &s);
char *RemoveApostrophes(const char *s);
@@ -149,7 +122,7 @@ public:
AutoDelete(T** iVar, T* iSetTo = 0) { AutoDelete(T** iVar, T* iSetTo = 0) {
init(iVar, iSetTo); init(iVar, iSetTo);
} }
AutoDelete() { pVar = NULL; } AutoDelete() { pVar = nullptr; }
void init(T** iVar, T* iSetTo = 0) void init(T** iVar, T* iSetTo = 0)
{ {
pVar = iVar; pVar = iVar;
@@ -157,11 +130,11 @@ public:
*pVar = iSetTo; *pVar = iSetTo;
} }
~AutoDelete() { ~AutoDelete() {
if(pVar != NULL) if(pVar != nullptr)
safe_delete(*pVar); safe_delete(*pVar);
} }
void ReallyClearIt() { void ReallyClearIt() {
pVar = NULL; pVar = nullptr;
} }
private: private:
T** pVar; T** pVar;
+30 -40
View File
@@ -1,25 +1,24 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/Mutex.h" #include "../common/Mutex.h"
#include <iostream> #include <iostream>
using namespace std;
#define DEBUG_MUTEX_CLASS 0 #define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
@@ -43,7 +42,7 @@ bool IsTryLockSupported() {
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) { if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl; std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif #endif
return false; return false;
} }
@@ -52,13 +51,13 @@ bool IsTryLockSupported() {
// Tests for Windows NT product family. // Tests for Windows NT product family.
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) { if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() SUPPORTED" << endl; std::cout << "Mutex::trylock() SUPPORTED" << std::endl;
#endif #endif
return true; return true;
} }
else { else {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl; std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif #endif
return false; return false;
} }
@@ -66,27 +65,28 @@ bool IsTryLockSupported() {
#endif #endif
Mutex::Mutex() { Mutex::Mutex() {
#if DEBUG_MUTEX_CLASS >= 7 #if DEBUG_MUTEX_CLASS >= 7
cout << "Constructing Mutex" << endl; std::cout << "Constructing Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
InitializeCriticalSection(&CSMutex); InitializeCriticalSection(&CSMutex);
#else #else
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr); pthread_mutexattr_init(&attr);
#if defined(__CYGWIN__) || defined(__APPLE__) #if defined(__CYGWIN__) || defined(__APPLE__) || defined(FREEBSD)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#else #else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif #endif
pthread_mutex_init(&CSMutex, &attr); pthread_mutex_init(&CSMutex, &attr);
pthread_mutexattr_destroy(&attr); pthread_mutexattr_destroy(&attr);
#endif #endif
} }
Mutex::~Mutex() { Mutex::~Mutex() {
#if DEBUG_MUTEX_CLASS >= 7 #if DEBUG_MUTEX_CLASS >= 7
cout << "Deconstructing Mutex" << endl; std::cout << "Deconstructing Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
DeleteCriticalSection(&CSMutex); DeleteCriticalSection(&CSMutex);
@@ -98,11 +98,11 @@ Mutex::~Mutex() {
void Mutex::lock() { void Mutex::lock() {
_CP(Mutex_lock); _CP(Mutex_lock);
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "Locking Mutex" << endl; std::cout << "Locking Mutex" << std::endl;
#endif #endif
#if DEBUG_MUTEX_CLASS >= 5 #if DEBUG_MUTEX_CLASS >= 5
if (!trylock()) { if (!trylock()) {
cout << "Locking Mutex: Having to wait" << endl; std::cout << "Locking Mutex: Having to wait" << std::endl;
#ifdef _WINDOWS #ifdef _WINDOWS
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
#else #else
@@ -120,7 +120,7 @@ void Mutex::lock() {
bool Mutex::trylock() { bool Mutex::trylock() {
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "TryLocking Mutex" << endl; std::cout << "TryLocking Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
#if(_WIN32_WINNT >= 0x0400) #if(_WIN32_WINNT >= 0x0400)
@@ -141,7 +141,7 @@ bool Mutex::trylock() {
void Mutex::unlock() { void Mutex::unlock() {
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "Unlocking Mutex" << endl; std::cout << "Unlocking Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
@@ -187,7 +187,7 @@ MRMutex::MRMutex() {
MRMutex::~MRMutex() { MRMutex::~MRMutex() {
#ifdef _EQDEBUG #ifdef _EQDEBUG
if (wl || rl) { if (wl || rl) {
cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << endl; std::cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << std::endl;
} }
#endif #endif
} }
@@ -214,11 +214,6 @@ bool MRMutex::TryReadLock() {
void MRMutex::UnReadLock() { void MRMutex::UnReadLock() {
MCounters.lock(); MCounters.lock();
rl--; rl--;
#ifdef _EQDEBUG
if (rl < 0) {
ThrowError("rl < 0 in MRMutex::UnReadLock()");
}
#endif
MCounters.unlock(); MCounters.unlock();
} }
@@ -261,11 +256,6 @@ bool MRMutex::TryWriteLock() {
void MRMutex::UnWriteLock() { void MRMutex::UnWriteLock() {
MCounters.lock(); MCounters.lock();
wl--; wl--;
#ifdef _EQDEBUG
if (wl < 0) {
ThrowError("wl < 0 in MRMutex::UnWriteLock()");
}
#endif
MCounters.unlock(); MCounters.unlock();
} }
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef MYMUTEX_H #ifndef MYMUTEX_H
#define MYMUTEX_H #define MYMUTEX_H
+49 -62
View File
@@ -1,39 +1,41 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <string>
#include <vector>
#include "debug.h" #include "debug.h"
#include "ProcLauncher.h" #include "ProcLauncher.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#endif #endif
using namespace std;
ProcLauncher ProcLauncher::s_launcher; ProcLauncher ProcLauncher::s_launcher;
#ifdef _WINDOWS #ifdef _WINDOWS
@@ -51,10 +53,9 @@ ProcLauncher::ProcLauncher()
#endif #endif
} }
void ProcLauncher::Process() { void ProcLauncher::Process() {
#ifdef _WINDOWS #ifdef _WINDOWS
map<ProcRef, Spec *>::iterator cur, end, tmp; std::map<ProcRef, Spec *>::iterator cur, end, tmp;
cur = m_running.begin(); cur = m_running.begin();
end = m_running.end(); end = m_running.end();
while(cur != end) { while(cur != end) {
@@ -91,7 +92,7 @@ void ProcLauncher::Process() {
break; break;
} else { } else {
//one died... //one died...
map<ProcRef, Spec *>::iterator ref; std::map<ProcRef, Spec *>::iterator ref;
ref = m_running.find(died); ref = m_running.find(died);
if(ref == m_running.end()) { if(ref == m_running.end()) {
//unable to find this process in our list... //unable to find this process in our list...
@@ -107,7 +108,7 @@ void ProcLauncher::Process() {
void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) { void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
if(it->second->handler != NULL) if(it->second->handler != nullptr)
it->second->handler->OnTerminate(it->first, it->second); it->second->handler->OnTerminate(it->first, it->second);
#ifdef _WINDOWS #ifdef _WINDOWS
@@ -121,7 +122,7 @@ void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) { ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
//consume the pointer //consume the pointer
Spec *it = to_launch; Spec *it = to_launch;
to_launch = NULL; to_launch = nullptr;
#ifdef _WINDOWS #ifdef _WINDOWS
STARTUPINFO siStartInfo; STARTUPINFO siStartInfo;
@@ -138,15 +139,15 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
siStartInfo.dwFlags = 0; siStartInfo.dwFlags = 0;
//handle output redirection. //handle output redirection.
HANDLE logOut = NULL; HANDLE logOut = nullptr;
BOOL inherit_handles = FALSE; BOOL inherit_handles = FALSE;
if(it->logFile.length() > 0) { if(it->logFile.length() > 0) {
inherit_handles = TRUE; inherit_handles = TRUE;
// Set up our log file to redirect output into. // Set up our log file to redirect output into.
SECURITY_ATTRIBUTES saAttr; SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child. saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = NULL; saAttr.lpSecurityDescriptor = nullptr;
logOut = CreateFile( logOut = CreateFile(
it->logFile.c_str(), //lpFileName it->logFile.c_str(), //lpFileName
FILE_WRITE_DATA, //dwDesiredAccess FILE_WRITE_DATA, //dwDesiredAccess
@@ -154,12 +155,12 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
&saAttr, //lpSecurityAttributes &saAttr, //lpSecurityAttributes
CREATE_ALWAYS, //dwCreationDisposition CREATE_ALWAYS, //dwCreationDisposition
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
NULL ); //hTemplateFile nullptr ); //hTemplateFile
//configure the startup info to redirect output appropriately. //configure the startup info to redirect output appropriately.
siStartInfo.hStdError = logOut; siStartInfo.hStdError = logOut;
siStartInfo.hStdOutput = logOut; siStartInfo.hStdOutput = logOut;
siStartInfo.hStdInput = NULL; siStartInfo.hStdInput = nullptr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES; siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
} }
@@ -168,8 +169,8 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
// Create the child process. // Create the child process.
//glue together all the nice command line arguments //glue together all the nice command line arguments
string args(it->program); std::string args(it->program);
vector<string>::iterator cur, end; std::vector<std::string>::iterator cur, end;
cur = it->args.begin(); cur = it->args.begin();
end = it->args.end(); end = it->args.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -178,15 +179,15 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
} }
bFuncRetn = CreateProcess(it->program.c_str(), bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line const_cast<char *>(args.c_str()), // command line
NULL, // process security attributes nullptr, // process security attributes
NULL, // primary thread security attributes nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe) 0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
NULL, // use parent's environment nullptr, // use parent's environment
NULL, // use parent's current directory nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer &siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION &it->proc_info); // receives PROCESS_INFORMATION
if (bFuncRetn == 0) { if (bFuncRetn == 0) {
safe_delete(it); safe_delete(it);
@@ -197,7 +198,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
//keep process handle open to get exit code //keep process handle open to get exit code
CloseHandle(it->proc_info.hThread); //we dont need their thread handle CloseHandle(it->proc_info.hThread); //we dont need their thread handle
if(logOut != NULL) if(logOut != nullptr)
CloseHandle(logOut); //we dont want their output handle either. CloseHandle(logOut); //we dont want their output handle either.
ProcRef res = it->proc_info.dwProcessId; ProcRef res = it->proc_info.dwProcessId;
@@ -216,7 +217,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
for(r = 1; r <= it->args.size(); r++) { for(r = 1; r <= it->args.size(); r++) {
argv[r] = const_cast<char *>(it->args[r-1].c_str()); argv[r] = const_cast<char *>(it->args[r-1].c_str());
} }
argv[r] = NULL; argv[r] = nullptr;
ProcRef res = fork(); //cant use vfork since we are opening the log file. ProcRef res = fork(); //cant use vfork since we are opening the log file.
if(res == -1) { if(res == -1) {
@@ -334,7 +335,7 @@ void ProcLauncher::HandleSigChild(int signum) {
ProcLauncher::Spec::Spec() { ProcLauncher::Spec::Spec() {
handler = NULL; handler = nullptr;
} }
ProcLauncher::Spec::Spec(const Spec &other) { ProcLauncher::Spec::Spec(const Spec &other) {
@@ -352,17 +353,3 @@ ProcLauncher::Spec &ProcLauncher::Spec::operator=(const Spec &other) {
return(*this); return(*this);
} }
+15 -46
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef PROCLAUNCHER_H_ #ifndef PROCLAUNCHER_H_
#define PROCLAUNCHER_H_ #define PROCLAUNCHER_H_
@@ -65,25 +65,18 @@ public:
virtual void OnTerminate(const ProcRef &ref, const Spec *spec) = 0; virtual void OnTerminate(const ProcRef &ref, const Spec *spec) = 0;
}; };
/* /* The main launch method, call to start a new background process. */
* The main launch method, call to start a new background process.
*/
ProcRef Launch(Spec *&to_launch); //takes ownership of the pointer ProcRef Launch(Spec *&to_launch); //takes ownership of the pointer
/* /* The terminate method */
* The terminate method
*/
bool Terminate(const ProcRef &proc, bool graceful = true); bool Terminate(const ProcRef &proc, bool graceful = true);
void TerminateAll(bool final = true); void TerminateAll(bool final = true);
/* /* The main processing method. Call regularly to check for terminated background processes. */
* The main processing method. Call regularly to check for terminated
* background processes.
*/
void Process(); void Process();
protected: protected:
// std::vector<Spec *> m_specs; //std::vector<Spec *> m_specs;
std::map<ProcRef, Spec *> m_running; //we own the pointers in this map std::map<ProcRef, Spec *> m_running; //we own the pointers in this map
void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it); void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it);
@@ -96,29 +89,5 @@ private:
#endif #endif
}; };
#endif /*PROCLAUNCHER_H_*/ #endif /*PROCLAUNCHER_H_*/
-117
View File
@@ -1,117 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 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 "SharedLibrary.h"
#include <stdio.h>
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define EmuLibName "EMuShareMem"
#else
#define EmuLibName "libEMuShareMem.so"
#include "../common/unix.h"
#include <dlfcn.h>
#define GetProcAddress(a,b) dlsym(a,b)
#define LoadLibrary(a) dlopen(a, RTLD_NOW)
#define FreeLibrary(a) dlclose(a)
#define GetLastError() dlerror()
#endif
SharedLibrary::SharedLibrary() {
hDLL = NULL;
}
SharedLibrary::~SharedLibrary() {
Unload();
}
bool SharedLibrary::Load(const char *name)
{
#ifdef _WINDOWS
SetLastError(0);
#endif
hDLL = LoadLibrary(name);
if(!hDLL) {
const char *load_error = GetError();
fprintf(stderr, "[Error] Load Shared Library '%s' failed. Error=%s\n", name, load_error?load_error:"Null Return, no error");
return false;
}
#ifdef _WINDOWS
else { SetLastError(0); } // Clear the win9x error
#endif
return(true);
}
void SharedLibrary::Unload() {
if (hDLL != NULL) {
FreeLibrary(hDLL);
#ifndef WIN32
const char* error;
if ((error = GetError()) != NULL)
fprintf(stderr, "FreeLibrary() error = %s", error);
#endif
hDLL = NULL;
}
}
void *SharedLibrary::GetSym(const char *name) {
if (!Loaded())
return(NULL);
void *r = GetProcAddress(hDLL, name);
if(GetError() != NULL)
r = NULL;
return(r);
}
bool SharedLibrary::GetSym(const char *name, void **sym)
{
bool result=false;
if (Loaded()) {
*sym = GetProcAddress(hDLL, name);
result= (GetError() == NULL);
}
return result;
}
const char *SharedLibrary::GetError()
{
#ifdef _WINDOWS
//not thread safe, dont care.
static char ErrBuf[128];
unsigned long err = GetLastError();
if(err == 0)
return(NULL);
sprintf(ErrBuf, "Error #%lu", (unsigned long)err);
return(ErrBuf);
#else
return GetLastError();
#endif
}
-49
View File
@@ -1,49 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 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 _SHAREDLIBRARY_H
#define _SHAREDLIBRARY_H
#ifdef _WINDOWS
#include <windows.h>
#endif
class SharedLibrary {
public:
SharedLibrary();
virtual ~SharedLibrary();
//two call styles for GetSym, one returns bool, other NULL for fail
bool GetSym(const char *name, void **sym);
void *GetSym(const char *name);
const char *GetError();
virtual bool Load(const char *file);
virtual void Unload();
inline bool Loaded() { return (hDLL != 0); }
protected:
#ifdef _WINDOWS
HINSTANCE hDLL;
#else
void* hDLL;
#endif
};
#endif
+2 -2
View File
@@ -43,7 +43,7 @@ namespace SOCKETS_NAMESPACE {
File::File() File::File()
:m_fil(NULL) :m_fil(nullptr)
{ {
} }
@@ -85,7 +85,7 @@ size_t File::fwrite(const char *ptr, size_t size, size_t nmemb)
char *File::fgets(char *s, int size) char *File::fgets(char *s, int size)
{ {
return m_fil ? ::fgets(s, size, m_fil) : NULL; return m_fil ? ::fgets(s, size, m_fil) : nullptr;
} }
+5 -5
View File
@@ -93,14 +93,14 @@ bool HttpdCookies::getvalue(const std::string& name,std::string& buffer) //char
void HttpdCookies::replacevalue(const std::string& name,const std::string& value) void HttpdCookies::replacevalue(const std::string& name,const std::string& value)
{ {
COOKIE *c = NULL; COOKIE *c = nullptr;
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++) for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
{ {
c = *it; c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str())) if (!strcasecmp(c -> name.c_str(),name.c_str()))
break; break;
c = NULL; c = nullptr;
} }
if (c) if (c)
@@ -126,14 +126,14 @@ void HttpdCookies::replacevalue(const std::string& name,int i)
size_t HttpdCookies::getlength(const std::string& name) size_t HttpdCookies::getlength(const std::string& name)
{ {
COOKIE *c = NULL; COOKIE *c = nullptr;
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++) for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
{ {
c = *it; c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str())) if (!strcasecmp(c -> name.c_str(),name.c_str()))
break; break;
c = NULL; c = nullptr;
} }
return c ? c -> value.size() : 0; return c ? c -> value.size() : 0;
} }
@@ -223,7 +223,7 @@ void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const
const std::string& HttpdCookies::expiredatetime() const std::string& HttpdCookies::expiredatetime()
{ {
time_t t = time(NULL); time_t t = time(nullptr);
struct tm * tp = gmtime(&t); struct tm * tp = gmtime(&t);
const char *days[7] = {"Sunday", "Monday", const char *days[7] = {"Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+10 -10
View File
@@ -47,7 +47,7 @@ namespace SOCKETS_NAMESPACE {
HttpdForm::HttpdForm(IFile *infil) : raw(false) HttpdForm::HttpdForm(IFile *infil) : raw(false)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
char *c_t = getenv("CONTENT_TYPE"); char *c_t = getenv("CONTENT_TYPE");
char *c_l = getenv("CONTENT_LENGTH"); char *c_l = getenv("CONTENT_LENGTH");
size_t extra = 2; size_t extra = 2;
@@ -59,7 +59,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
if (c_t && !strncmp(c_t, "multipart/form-data",19)) if (c_t && !strncmp(c_t, "multipart/form-data",19))
{ {
Parse pa(c_t,";="); Parse pa(c_t,";=");
char *tempcmp = NULL; char *tempcmp = nullptr;
size_t tc = 0; size_t tc = 0;
size_t l = 0; size_t l = 0;
std::string str = pa.getword(); std::string str = pa.getword();
@@ -80,7 +80,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
std::string content_type; std::string content_type;
std::string current_name; std::string current_name;
std::string current_filename; std::string current_filename;
char slask[200]; char slask[2000];
infil -> fgets(slask, 200); infil -> fgets(slask, 200);
while (!infil -> eof()) while (!infil -> eof())
{ {
@@ -209,7 +209,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
#else #else
sprintf(fn,"/tmp/%s",current_filename.c_str()); sprintf(fn,"/tmp/%s",current_filename.c_str());
#endif #endif
if ((fil = fopen(fn, "wb")) != NULL) if ((fil = fopen(fn, "wb")) != nullptr)
{ {
infil -> fread(&c,1,1); infil -> fread(&c,1,1);
while (!infil -> eof()) while (!infil -> eof())
@@ -353,7 +353,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false) HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
char slask[8888]; char slask[8888];
char name[200]; char name[200];
int i = 0; int i = 0;
@@ -424,7 +424,7 @@ HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
HttpdForm::~HttpdForm() HttpdForm::~HttpdForm()
{ {
CGI *cgi = NULL; //,*tmp; CGI *cgi = nullptr; //,*tmp;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
{ {
@@ -525,7 +525,7 @@ bool HttpdForm::getnext(std::string& n,std::string& v) //char *n,size_t len,char
int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len) int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
int r = 0; int r = 0;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
@@ -533,7 +533,7 @@ int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t le
cgi = *it; cgi = *it;
if (cgi -> name == n) if (cgi -> name == n)
break; break;
cgi = NULL; cgi = nullptr;
} }
if (cgi) if (cgi)
{ {
@@ -572,7 +572,7 @@ std::string HttpdForm::getvalue(const std::string& n)
size_t HttpdForm::getlength(const std::string& n) size_t HttpdForm::getlength(const std::string& n)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
size_t l; size_t l;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
@@ -580,7 +580,7 @@ size_t HttpdForm::getlength(const std::string& n)
cgi = *it; cgi = *it;
if (cgi -> name == n) if (cgi -> name == n)
break; break;
cgi = NULL; cgi = nullptr;
} }
l = cgi ? cgi -> value.size() : 0; l = cgi ? cgi -> value.size() : 0;
if (cgi && !raw) if (cgi && !raw)
+7 -7
View File
@@ -64,11 +64,11 @@ std::string HttpdSocket::m_start = "";
HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: HTTPSocket(ID,in_socket,irIP,irPort) : HTTPSocket(ID,in_socket,irIP,irPort)
,m_content_length(0) ,m_content_length(0)
,m_file(NULL) ,m_file(nullptr)
,m_received(0) ,m_received(0)
,m_request_id(++m_request_count) ,m_request_id(++m_request_count)
,m_cookies(NULL) ,m_cookies(nullptr)
,m_form(NULL) ,m_form(nullptr)
{ {
m_http_date = datetime2httpdate(GetDate()); m_http_date = datetime2httpdate(GetDate());
if (!m_start.size()) if (!m_start.size())
@@ -289,7 +289,7 @@ std::string HttpdSocket::datetime2httpdate(const std::string& dt)
std::string HttpdSocket::GetDate() std::string HttpdSocket::GetDate()
{ {
time_t t = time(NULL); time_t t = time(nullptr);
struct tm* tp = localtime(&t); struct tm* tp = localtime(&t);
char slask[40]; char slask[40];
if (tp) if (tp)
@@ -315,16 +315,16 @@ void HttpdSocket::Reset()
if (m_file) if (m_file)
{ {
delete m_file; delete m_file;
m_file = NULL; m_file = nullptr;
} }
m_received = 0; m_received = 0;
m_request_id = ++m_request_count; m_request_id = ++m_request_count;
if (m_cookies) if (m_cookies)
delete m_cookies; delete m_cookies;
m_cookies = NULL; m_cookies = nullptr;
if (m_form) if (m_form)
delete m_form; delete m_form;
m_form = NULL; m_form = nullptr;
} }
+2 -2
View File
@@ -66,8 +66,8 @@ MemFile::MemFile(const std::string& path)
:m_path(path) :m_path(path)
,m_temporary(false) ,m_temporary(false)
,m_base(m_files[path]) ,m_base(m_files[path])
,m_current_read(NULL) ,m_current_read(nullptr)
,m_current_write(NULL) ,m_current_write(nullptr)
,m_read_ptr(0) ,m_read_ptr(0)
,m_write_ptr(0) ,m_write_ptr(0)
{ {
+1 -1
View File
@@ -48,7 +48,7 @@ public:
/** File block structure. /** File block structure.
\ingroup file */ \ingroup file */
struct block_t { struct block_t {
block_t() : next(NULL) {} block_t() : next(nullptr) {}
struct block_t *next; struct block_t *next;
char data[BLOCKSIZE]; char data[BLOCKSIZE];
}; };
+1 -1
View File
@@ -37,7 +37,7 @@ Mime::Mime(const std::string& filename) {
bool Mime::LoadMimeFile(const std::string& filename) { bool Mime::LoadMimeFile(const std::string& filename) {
FILE *fil; FILE *fil;
if ((fil = fopen(filename.c_str(),"rt")) != NULL) { if ((fil = fopen(filename.c_str(),"rt")) != nullptr) {
char * slask = new char[1000]; char * slask = new char[1000];
fgets(slask,1000,fil); fgets(slask,1000,fil);
while (!feof(fil)) while (!feof(fil))
+84 -84
View File
@@ -104,7 +104,7 @@ typedef struct _tagSTACKFRAME64 {
ADDRESS64 AddrFrame; // frame pointer ADDRESS64 AddrFrame; // frame pointer
ADDRESS64 AddrStack; // stack pointer ADDRESS64 AddrStack; // stack pointer
ADDRESS64 AddrBStore; // backing store pointer ADDRESS64 AddrBStore; // backing store pointer
PVOID FuncTableEntry; // pointer to pdata/fpo or NULL PVOID FuncTableEntry; // pointer to pdata/fpo or nullptr
DWORD64 Params[4]; // possible arguments to the function DWORD64 Params[4]; // possible arguments to the function
BOOL Far; // WOW far call BOOL Far; // WOW far call
BOOL Virtual; // is this a virtual frame? BOOL Virtual; // is this a virtual frame?
@@ -187,44 +187,44 @@ public:
StackWalkerInternal(StackWalker *parent, HANDLE hProcess) StackWalkerInternal(StackWalker *parent, HANDLE hProcess)
{ {
m_parent = parent; m_parent = parent;
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
pSC = NULL; pSC = nullptr;
m_hProcess = hProcess; m_hProcess = hProcess;
m_szSymPath = NULL; m_szSymPath = nullptr;
pSFTA = NULL; pSFTA = nullptr;
pSGLFA = NULL; pSGLFA = nullptr;
pSGMB = NULL; pSGMB = nullptr;
pSGMI = NULL; pSGMI = nullptr;
pSGO = NULL; pSGO = nullptr;
pSGSFA = NULL; pSGSFA = nullptr;
pSI = NULL; pSI = nullptr;
pSLM = NULL; pSLM = nullptr;
pSSO = NULL; pSSO = nullptr;
pSW = NULL; pSW = nullptr;
pUDSN = NULL; pUDSN = nullptr;
pSGSP = NULL; pSGSP = nullptr;
} }
~StackWalkerInternal() ~StackWalkerInternal()
{ {
if (pSC != NULL) if (pSC != nullptr)
pSC(m_hProcess); // SymCleanup pSC(m_hProcess); // SymCleanup
if (m_hDbhHelp != NULL) if (m_hDbhHelp != nullptr)
FreeLibrary(m_hDbhHelp); FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
m_parent = NULL; m_parent = nullptr;
if(m_szSymPath != NULL) if(m_szSymPath != nullptr)
free(m_szSymPath); free(m_szSymPath);
m_szSymPath = NULL; m_szSymPath = nullptr;
} }
BOOL Init(LPCSTR szSymPath) BOOL Init(LPCSTR szSymPath)
{ {
if (m_parent == NULL) if (m_parent == nullptr)
return FALSE; return FALSE;
// Dynamically load the Entry-Points for dbghelp.dll: // Dynamically load the Entry-Points for dbghelp.dll:
// First try to load the newsest one from // First try to load the newsest one from
TCHAR szTemp[4096]; TCHAR szTemp[4096];
// But before wqe do this, we first check if the ".local" file exists // But before wqe do this, we first check if the ".local" file exists
if (GetModuleFileName(NULL, szTemp, 4096) > 0) if (GetModuleFileName(nullptr, szTemp, 4096) > 0)
{ {
_tcscat_s(szTemp, _T(".local")); _tcscat_s(szTemp, _T(".local"));
if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
@@ -240,7 +240,7 @@ public:
} }
} }
// Still not found? Then try to load the 64-Bit version: // Still not found? Then try to load the 64-Bit version:
if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) ) if ( (m_hDbhHelp == nullptr) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
{ {
_tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll")); _tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll"));
if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
@@ -250,9 +250,9 @@ public:
} }
} }
} }
if (m_hDbhHelp == NULL) // if not already loaded, try to load a default-one if (m_hDbhHelp == nullptr) // if not already loaded, try to load a default-one
m_hDbhHelp = LoadLibrary( _T("dbghelp.dll") ); m_hDbhHelp = LoadLibrary( _T("dbghelp.dll") );
if (m_hDbhHelp == NULL) if (m_hDbhHelp == nullptr)
return FALSE; return FALSE;
pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" ); pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" );
pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" ); pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" );
@@ -271,18 +271,18 @@ public:
pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" ); pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" );
pSGSP =(tSGSP) GetProcAddress(m_hDbhHelp, "SymGetSearchPath" ); pSGSP =(tSGSP) GetProcAddress(m_hDbhHelp, "SymGetSearchPath" );
if ( pSC == NULL || pSFTA == NULL || pSGMB == NULL || pSGMI == NULL || if ( pSC == nullptr || pSFTA == nullptr || pSGMB == nullptr || pSGMI == nullptr ||
pSGO == NULL || pSGSFA == NULL || pSI == NULL || pSSO == NULL || pSGO == nullptr || pSGSFA == nullptr || pSI == nullptr || pSSO == nullptr ||
pSW == NULL || pUDSN == NULL || pSLM == NULL ) pSW == nullptr || pUDSN == nullptr || pSLM == nullptr )
{ {
FreeLibrary(m_hDbhHelp); FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
pSC = NULL; pSC = nullptr;
return FALSE; return FALSE;
} }
// SymInitialize // SymInitialize
if (szSymPath != NULL) if (szSymPath != nullptr)
m_szSymPath = _strdup(szSymPath); m_szSymPath = _strdup(szSymPath);
if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE) if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE)
this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0); this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0);
@@ -295,7 +295,7 @@ public:
symOptions = this->pSSO(symOptions); symOptions = this->pSSO(symOptions);
char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0}; char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0};
if (this->pSGSP != NULL) if (this->pSGSP != nullptr)
{ {
if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE) if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE)
this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0); this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0);
@@ -458,10 +458,10 @@ private:
// try both dlls... // try both dlls...
const TCHAR *dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") }; const TCHAR *dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") };
HINSTANCE hToolhelp = NULL; HINSTANCE hToolhelp = nullptr;
tCT32S pCT32S = NULL; tCT32S pCT32S = nullptr;
tM32F pM32F = NULL; tM32F pM32F = nullptr;
tM32N pM32N = NULL; tM32N pM32N = nullptr;
HANDLE hSnap; HANDLE hSnap;
MODULEENTRY32 me; MODULEENTRY32 me;
@@ -472,18 +472,18 @@ private:
for (i = 0; i<(sizeof(dllname) / sizeof(dllname[0])); i++ ) for (i = 0; i<(sizeof(dllname) / sizeof(dllname[0])); i++ )
{ {
hToolhelp = LoadLibrary( dllname[i] ); hToolhelp = LoadLibrary( dllname[i] );
if (hToolhelp == NULL) if (hToolhelp == nullptr)
continue; continue;
pCT32S = (tCT32S) GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot"); pCT32S = (tCT32S) GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot");
pM32F = (tM32F) GetProcAddress(hToolhelp, "Module32First"); pM32F = (tM32F) GetProcAddress(hToolhelp, "Module32First");
pM32N = (tM32N) GetProcAddress(hToolhelp, "Module32Next"); pM32N = (tM32N) GetProcAddress(hToolhelp, "Module32Next");
if ( (pCT32S != NULL) && (pM32F != NULL) && (pM32N != NULL) ) if ( (pCT32S != nullptr) && (pM32F != nullptr) && (pM32N != nullptr) )
break; // found the functions! break; // found the functions!
FreeLibrary(hToolhelp); FreeLibrary(hToolhelp);
hToolhelp = NULL; hToolhelp = nullptr;
} }
if (hToolhelp == NULL) if (hToolhelp == nullptr)
return FALSE; return FALSE;
hSnap = pCT32S( TH32CS_SNAPMODULE, pid ); hSnap = pCT32S( TH32CS_SNAPMODULE, pid );
@@ -534,20 +534,20 @@ private:
DWORD cbNeeded; DWORD cbNeeded;
MODULEINFO mi; MODULEINFO mi;
HMODULE *hMods = 0; HMODULE *hMods = 0;
char *tt = NULL; char *tt = nullptr;
char *tt2 = NULL; char *tt2 = nullptr;
const SIZE_T TTBUFLEN = 8096; const SIZE_T TTBUFLEN = 8096;
int cnt = 0; int cnt = 0;
hPsapi = LoadLibrary( _T("psapi.dll") ); hPsapi = LoadLibrary( _T("psapi.dll") );
if (hPsapi == NULL) if (hPsapi == nullptr)
return FALSE; return FALSE;
pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" ); pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" );
pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" ); pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" );
pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" ); pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" );
pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" ); pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" );
if ( (pEPM == NULL) || (pGMFNE == NULL) || (pGMBN == NULL) || (pGMI == NULL) ) if ( (pEPM == nullptr) || (pGMFNE == nullptr) || (pGMBN == nullptr) || (pGMI == nullptr) )
{ {
// we couldn?t find all functions // we couldn?t find all functions
FreeLibrary(hPsapi); FreeLibrary(hPsapi);
@@ -557,7 +557,7 @@ private:
hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE)); hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE));
tt = (char*) malloc(sizeof(char) * TTBUFLEN); tt = (char*) malloc(sizeof(char) * TTBUFLEN);
tt2 = (char*) malloc(sizeof(char) * TTBUFLEN); tt2 = (char*) malloc(sizeof(char) * TTBUFLEN);
if ( (hMods == NULL) || (tt == NULL) || (tt2 == NULL) ) if ( (hMods == nullptr) || (tt == nullptr) || (tt2 == nullptr) )
goto cleanup; goto cleanup;
if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) ) if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) )
@@ -590,10 +590,10 @@ private:
} }
cleanup: cleanup:
if (hPsapi != NULL) FreeLibrary(hPsapi); if (hPsapi != nullptr) FreeLibrary(hPsapi);
if (tt2 != NULL) free(tt2); if (tt2 != nullptr) free(tt2);
if (tt != NULL) free(tt); if (tt != nullptr) free(tt);
if (hMods != NULL) free(hMods); if (hMods != nullptr) free(hMods);
return cnt != 0; return cnt != 0;
} // GetModuleListPSAPI } // GetModuleListPSAPI
@@ -603,7 +603,7 @@ private:
CHAR *szImg = _strdup(img); CHAR *szImg = _strdup(img);
CHAR *szMod = _strdup(mod); CHAR *szMod = _strdup(mod);
DWORD result = ERROR_SUCCESS; DWORD result = ERROR_SUCCESS;
if ( (szImg == NULL) || (szMod == NULL) ) if ( (szImg == nullptr) || (szMod == nullptr) )
result = ERROR_NOT_ENOUGH_MEMORY; result = ERROR_NOT_ENOUGH_MEMORY;
else else
{ {
@@ -611,25 +611,25 @@ private:
result = GetLastError(); result = GetLastError();
} }
ULONGLONG fileVersion = 0; ULONGLONG fileVersion = 0;
if ( (m_parent != NULL) && (szImg != NULL) ) if ( (m_parent != nullptr) && (szImg != nullptr) )
{ {
// try to retrive the file-version: // try to retrive the file-version:
if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0) if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0)
{ {
VS_FIXEDFILEINFO *fInfo = NULL; VS_FIXEDFILEINFO *fInfo = nullptr;
DWORD dwHandle; DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle); DWORD dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle);
if (dwSize > 0) if (dwSize > 0)
{ {
LPVOID vData = malloc(dwSize); LPVOID vData = malloc(dwSize);
if (vData != NULL) if (vData != nullptr)
{ {
if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0) if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
{ {
UINT len; UINT len;
TCHAR szSubBlock[] = _T("\\"); TCHAR szSubBlock[] = _T("\\");
if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0) if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
fInfo = NULL; fInfo = nullptr;
else else
{ {
fileVersion = ((ULONGLONG)fInfo->dwFileVersionLS) + ((ULONGLONG)fInfo->dwFileVersionMS << 32); fileVersion = ((ULONGLONG)fInfo->dwFileVersionLS) + ((ULONGLONG)fInfo->dwFileVersionMS << 32);
@@ -678,8 +678,8 @@ private:
} }
this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, Module.LoadedImageName, fileVersion); this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, Module.LoadedImageName, fileVersion);
} }
if (szImg != NULL) free(szImg); if (szImg != nullptr) free(szImg);
if (szMod != NULL) free(szMod); if (szMod != nullptr) free(szMod);
return result; return result;
} }
public: public:
@@ -695,7 +695,7 @@ public:
BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo) BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo)
{ {
if(this->pSGMI == NULL) if(this->pSGMI == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@@ -703,7 +703,7 @@ public:
// First try to use the larger ModuleInfo-Structure // First try to use the larger ModuleInfo-Structure
// memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3)); // memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3));
// pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3); // pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3);
// if (this->pSGMI_V3 != NULL) // if (this->pSGMI_V3 != nullptr)
// { // {
// if (this->pSGMI_V3(hProcess, baseAddr, pModuleInfo) != FALSE) // if (this->pSGMI_V3(hProcess, baseAddr, pModuleInfo) != FALSE)
// return TRUE; // return TRUE;
@@ -714,7 +714,7 @@ public:
// could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)... // could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)...
pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2); pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
void *pData = malloc(4096); // reserve enough memory, so the bug in v6.3.5.1 does not lead to memory-overwrites... void *pData = malloc(4096); // reserve enough memory, so the bug in v6.3.5.1 does not lead to memory-overwrites...
if (pData == NULL) if (pData == nullptr)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
@@ -742,7 +742,7 @@ StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess)
this->m_hProcess = hProcess; this->m_hProcess = hProcess;
this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId; this->m_dwProcessId = dwProcessId;
this->m_szSymPath = NULL; this->m_szSymPath = nullptr;
} }
StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess) StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
{ {
@@ -751,28 +751,28 @@ StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDL
this->m_hProcess = hProcess; this->m_hProcess = hProcess;
this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId; this->m_dwProcessId = dwProcessId;
if (szSymPath != NULL) if (szSymPath != nullptr)
{ {
this->m_szSymPath = _strdup(szSymPath); this->m_szSymPath = _strdup(szSymPath);
this->m_options |= SymBuildPath; this->m_options |= SymBuildPath;
} }
else else
this->m_szSymPath = NULL; this->m_szSymPath = nullptr;
} }
StackWalker::~StackWalker() StackWalker::~StackWalker()
{ {
if (m_szSymPath != NULL) if (m_szSymPath != nullptr)
free(m_szSymPath); free(m_szSymPath);
m_szSymPath = NULL; m_szSymPath = nullptr;
if (this->m_sw != NULL) if (this->m_sw != nullptr)
delete this->m_sw; delete this->m_sw;
this->m_sw = NULL; this->m_sw = nullptr;
} }
BOOL StackWalker::LoadModules() BOOL StackWalker::LoadModules()
{ {
if (this->m_sw == NULL) if (this->m_sw == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@@ -781,19 +781,19 @@ BOOL StackWalker::LoadModules()
return TRUE; return TRUE;
// Build the sym-path: // Build the sym-path:
char *szSymPath = NULL; char *szSymPath = nullptr;
if ( (this->m_options & SymBuildPath) != 0) if ( (this->m_options & SymBuildPath) != 0)
{ {
const size_t nSymPathLen = 4096; const size_t nSymPathLen = 4096;
szSymPath = (char*) malloc(nSymPathLen); szSymPath = (char*) malloc(nSymPathLen);
if (szSymPath == NULL) if (szSymPath == nullptr)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
} }
szSymPath[0] = 0; szSymPath[0] = 0;
// Now first add the (optional) provided sympath: // Now first add the (optional) provided sympath:
if (this->m_szSymPath != NULL) if (this->m_szSymPath != nullptr)
{ {
strcat_s(szSymPath, nSymPathLen, this->m_szSymPath); strcat_s(szSymPath, nSymPathLen, this->m_szSymPath);
strcat_s(szSymPath, nSymPathLen, ";"); strcat_s(szSymPath, nSymPathLen, ";");
@@ -812,7 +812,7 @@ BOOL StackWalker::LoadModules()
} }
// Now add the path for the main-module: // Now add the path for the main-module:
if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0) if (GetModuleFileNameA(nullptr, szTemp, nTempLen) > 0)
{ {
szTemp[nTempLen-1] = 0; szTemp[nTempLen-1] = 0;
for (char *p = (szTemp+strlen(szTemp)-1); p >= szTemp; --p) for (char *p = (szTemp+strlen(szTemp)-1); p >= szTemp; --p)
@@ -870,7 +870,7 @@ BOOL StackWalker::LoadModules()
// First Init the whole stuff... // First Init the whole stuff...
BOOL bRet = this->m_sw->Init(szSymPath); BOOL bRet = this->m_sw->Init(szSymPath);
if (szSymPath != NULL) free(szSymPath); szSymPath = NULL; if (szSymPath != nullptr) free(szSymPath); szSymPath = nullptr;
if (bRet == FALSE) if (bRet == FALSE)
{ {
this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0); this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0);
@@ -889,14 +889,14 @@ BOOL StackWalker::LoadModules()
// This has to be done due to a problem with the "hProcess"-parameter in x64... // This has to be done due to a problem with the "hProcess"-parameter in x64...
// Because this class is in no case multi-threading-enabled (because of the limitations // Because this class is in no case multi-threading-enabled (because of the limitations
// of dbghelp.dll) it is "safe" to use a static-variable // of dbghelp.dll) it is "safe" to use a static-variable
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL; static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = nullptr;
static LPVOID s_readMemoryFunction_UserData = NULL; static LPVOID s_readMemoryFunction_UserData = nullptr;
BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData) BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData)
{ {
CONTEXT c;; CONTEXT c;;
CallstackEntry csEntry; CallstackEntry csEntry;
IMAGEHLP_SYMBOL64 *pSym = NULL; IMAGEHLP_SYMBOL64 *pSym = nullptr;
StackWalkerInternal::IMAGEHLP_MODULE64_V2 Module; StackWalkerInternal::IMAGEHLP_MODULE64_V2 Module;
IMAGEHLP_LINE64 Line; IMAGEHLP_LINE64 Line;
int frameNum; int frameNum;
@@ -904,7 +904,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
if (m_modulesLoaded == FALSE) if (m_modulesLoaded == FALSE)
this->LoadModules(); // ignore the result... this->LoadModules(); // ignore the result...
if (this->m_sw->m_hDbhHelp == NULL) if (this->m_sw->m_hDbhHelp == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@@ -913,7 +913,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
s_readMemoryFunction = readMemoryFunction; s_readMemoryFunction = readMemoryFunction;
s_readMemoryFunction_UserData = pUserData; s_readMemoryFunction_UserData = pUserData;
if (context == NULL) if (context == nullptr)
{ {
// If no context is provided, capture the context // If no context is provided, capture the context
if (hThread == GetCurrentThread()) if (hThread == GetCurrentThread())
@@ -989,7 +989,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
// assume that either you are done, or that the stack is so hosed that the next // assume that either you are done, or that the stack is so hosed that the next
// deeper frame could not be found. // deeper frame could not be found.
// CONTEXT need not to be suplied if imageTyp is IMAGE_FILE_MACHINE_I386! // CONTEXT need not to be suplied if imageTyp is IMAGE_FILE_MACHINE_I386!
if ( ! this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem, this->m_sw->pSFTA, this->m_sw->pSGMB, NULL) ) if ( ! this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem, this->m_sw->pSFTA, this->m_sw->pSGMB, nullptr) )
{ {
this->OnDbgHelpErr("StackWalk64", GetLastError(), s.AddrPC.Offset); this->OnDbgHelpErr("StackWalk64", GetLastError(), s.AddrPC.Offset);
break; break;
@@ -1028,7 +1028,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
} }
// show line number info, NT5.0-method (SymGetLineFromAddr64()) // show line number info, NT5.0-method (SymGetLineFromAddr64())
if (this->m_sw->pSGLFA != NULL ) if (this->m_sw->pSGLFA != nullptr )
{ // yes, we have SymGetLineFromAddr64() { // yes, we have SymGetLineFromAddr64()
if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line) != FALSE) if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line) != FALSE)
{ {
@@ -1078,7 +1078,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
break; break;
default: default:
//_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType ); //_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType );
csEntry.symTypeString = NULL; csEntry.symTypeString = nullptr;
break; break;
} }
@@ -1109,7 +1109,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
cleanup: cleanup:
if (pSym) free( pSym ); if (pSym) free( pSym );
if (context == NULL) if (context == nullptr)
ResumeThread(hThread); ResumeThread(hThread);
return TRUE; return TRUE;
@@ -1123,7 +1123,7 @@ BOOL __stdcall StackWalker::myReadProcMem(
LPDWORD lpNumberOfBytesRead LPDWORD lpNumberOfBytesRead
) )
{ {
if (s_readMemoryFunction == NULL) if (s_readMemoryFunction == nullptr)
{ {
SIZE_T st; SIZE_T st;
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st); BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);
+6 -6
View File
@@ -66,7 +66,7 @@ public:
StackWalker( StackWalker(
int options = OptionsAll, // 'int' is by design, to combine the enum-flags int options = OptionsAll, // 'int' is by design, to combine the enum-flags
LPCSTR szSymPath = NULL, LPCSTR szSymPath = nullptr,
DWORD dwProcessId = GetCurrentProcessId(), DWORD dwProcessId = GetCurrentProcessId(),
HANDLE hProcess = GetCurrentProcess() HANDLE hProcess = GetCurrentProcess()
); );
@@ -86,9 +86,9 @@ public:
BOOL ShowCallstack( BOOL ShowCallstack(
HANDLE hThread = GetCurrentThread(), HANDLE hThread = GetCurrentThread(),
const CONTEXT *context = NULL, const CONTEXT *context = nullptr,
PReadProcessMemoryRoutine readMemoryFunction = NULL, PReadProcessMemoryRoutine readMemoryFunction = nullptr,
LPVOID pUserData = NULL // optional to identify some data in the 'readMemoryFunction'-callback LPVOID pUserData = nullptr // optional to identify some data in the 'readMemoryFunction'-callback
); );
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
@@ -157,11 +157,11 @@ protected:
#define GET_CURRENT_CONTEXT(c, contextFlags) \ #define GET_CURRENT_CONTEXT(c, contextFlags) \
do { \ do { \
memset(&c, 0, sizeof(CONTEXT)); \ memset(&c, 0, sizeof(CONTEXT)); \
EXCEPTION_POINTERS *pExp = NULL; \ EXCEPTION_POINTERS *pExp = nullptr; \
__try { \ __try { \
throw 0; \ throw 0; \
} __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \ } __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
if (pExp != NULL) \ if (pExp != nullptr) \
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \ memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
c.ContextFlags = contextFlags; \ c.ContextFlags = contextFlags; \
} while(0); } while(0);
+330
View File
@@ -0,0 +1,330 @@
/*
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "StringUtil.h"
#include <string>
#include <cstdarg>
#include <cstring> // for strncpy
#include <stdexcept>
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include <stdlib.h>
#include <stdio.h>
#endif
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
// original source:
// https://github.com/facebook/folly/blob/master/folly/String.cpp
//
void vStringFormat(std::string& output, const char* format, va_list args)
{
va_list tmpargs;
va_copy(tmpargs,args);
int characters_used = vsnprintf(nullptr, 0, format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// Looks like we have an invalid format string.
// error out.
std::string errorMessage("Invalid format string; snprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
else if ((unsigned int)characters_used > output.capacity()) {
output.resize(characters_used+1);
va_copy(tmpargs,args);
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. Still, error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
}
else {
output.resize(characters_used + 1);
va_copy(tmpargs,args);
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. still error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
}
}
void StringFormat(std::string& output, const char* format, ...)
{
va_list args;
va_start(args, format);
vStringFormat(output,format,args);
va_end(args);
}
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return dest;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return dest;
}
// String N w/null Copy Truncated?
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return false;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return (bool) (source[strlen(dest)] == 0);
}
const char *MakeLowerString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeLowerString(source, str);
return str;
}
void MakeLowerString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
va_copy(tmpargptr, argptr);
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
}
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
if (*bufsize == 0)
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
else
*bufsize += chars + 25;
oldret = *ret;
*ret = new char[*bufsize];
if (oldret) {
if (*strlen)
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
va_copy(tmpargptr, argptr);
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
return *strlen;
}
uint32 hextoi(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint32 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
uint64 hextoi64(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint64 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
bool atobool(char* iBool) {
if (!strcasecmp(iBool, "true"))
return true;
if (!strcasecmp(iBool, "false"))
return false;
if (!strcasecmp(iBool, "yes"))
return true;
if (!strcasecmp(iBool, "no"))
return false;
if (!strcasecmp(iBool, "on"))
return true;
if (!strcasecmp(iBool, "off"))
return false;
if (!strcasecmp(iBool, "enable"))
return true;
if (!strcasecmp(iBool, "disable"))
return false;
if (!strcasecmp(iBool, "enabled"))
return true;
if (!strcasecmp(iBool, "disabled"))
return false;
if (!strcasecmp(iBool, "y"))
return true;
if (!strcasecmp(iBool, "n"))
return false;
if (atoi(iBool))
return true;
return false;
}
// solar: removes the crap and turns the underscores into spaces.
char *CleanMobName(const char *in, char *out)
{
unsigned i, j;
for(i = j = 0; i < strlen(in); i++)
{
// convert _ to space.. any other conversions like this? I *think* this
// is the only non alpha char that's not stripped but converted.
if(in[i] == '_')
{
out[j++] = ' ';
}
else
{
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
out[j++] = in[i];
}
}
out[j] = 0; // terimnate the string before returning it
return out;
}
void RemoveApostrophes(std::string &s)
{
for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'')
s[i] = '_';
}
char *RemoveApostrophes(const char *s)
{
char *NewString = new char[strlen(s) + 1];
strcpy(NewString, s);
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'')
NewString[i] = '_';
return NewString;
}
const char *ConvertArray(int input, char *returnchar)
{
sprintf(returnchar, "%i" ,input);
return returnchar;
}
const char *ConvertArrayF(float input, char *returnchar)
{
sprintf(returnchar, "%0.2f", input);
return returnchar;
}
+51
View File
@@ -0,0 +1,51 @@
/*
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _STRINGUTIL_H_
#define _STRINGUTIL_H_
#include <string>
#include <cstdarg>
#include "types.h"
void vStringFormat(std::string& output, const char* format, va_list args);
void StringFormat(std::string& output, const char* format, ...);
const char *MakeLowerString(const char *source);
void MakeLowerString(const char *source, char *target);
int MakeAnyLenString(char** ret, const char* format, ...);
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
uint32 hextoi(char* num);
uint64 hextoi64(char* num);
bool atobool(char* iBool);
char* strn0cpy(char* dest, const char* source, uint32 size);
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size);
char *CleanMobName(const char *in, char *out);
const char *ConvertArray(int input, char *returnchar);
const char *ConvertArrayF(float input, char *returnchar);
void RemoveApostrophes(std::string &s);
char *RemoveApostrophes(const char *s);
#endif
+4 -4
View File
@@ -31,7 +31,7 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) { void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
EQApplicationPacket *p = *in_p; EQApplicationPacket *p = *in_p;
*in_p = NULL; *in_p = nullptr;
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode())); _log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
@@ -57,17 +57,17 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
//effectively a singleton, but I decided to do it this way for no apparent reason. //effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory { namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies; static std::map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) { void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs; strategies[first_opcode] = structs;
} }
const StructStrategy *FindPatch(EmuOpcode first_opcode) { const StructStrategy *FindPatch(EmuOpcode first_opcode) {
map<EmuOpcode, const StructStrategy *>::const_iterator res; std::map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode); res = strategies.find(first_opcode);
if(res == strategies.end()) if(res == strategies.end())
return(NULL); return(nullptr);
return(res->second); return(res->second);
} }
+58 -74
View File
@@ -1,28 +1,26 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
using namespace std;
#include "TCPConnection.h" #include "TCPConnection.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
@@ -47,45 +45,45 @@ InitWinsock winsock;
//client version //client version
TCPConnection::TCPConnection() TCPConnection::TCPConnection()
: ConnectionType(Outgoing), : ConnectionType(Outgoing),
connection_socket(0), connection_socket(0),
id(0), id(0),
rIP(0), rIP(0),
rPort(0) rPort(0)
{ {
pState = TCPS_Ready; pState = TCPS_Ready;
pFree = false; pFree = false;
pEcho = false; pEcho = false;
recvbuf = NULL; recvbuf = nullptr;
sendbuf = NULL; sendbuf = nullptr;
pRunLoop = false; pRunLoop = false;
charAsyncConnect = 0; charAsyncConnect = 0;
pAsyncConnect = false; pAsyncConnect = false;
m_previousLineEnd = false; m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
//server version //server version
TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: ConnectionType(Incomming), : ConnectionType(Incomming),
connection_socket(in_socket), connection_socket(in_socket),
id(ID), id(ID),
rIP(irIP), rIP(irIP),
rPort(irPort) rPort(irPort)
{ {
pState = TCPS_Connected; pState = TCPS_Connected;
pFree = false; pFree = false;
pEcho = false; pEcho = false;
recvbuf = NULL; recvbuf = nullptr;
sendbuf = NULL; sendbuf = nullptr;
pRunLoop = false; pRunLoop = false;
charAsyncConnect = 0; charAsyncConnect = 0;
pAsyncConnect = false; pAsyncConnect = false;
m_previousLineEnd = false; m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on incoming TCP# " << GetID() << endl; std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl;
#endif #endif
} }
@@ -99,12 +97,12 @@ TCPConnection::~TCPConnection() {
MLoopRunning.lock(); MLoopRunning.lock();
MLoopRunning.unlock(); MLoopRunning.unlock();
#if TCPN_DEBUG_Memory >= 6 #if TCPN_DEBUG_Memory >= 6
cout << "Deconstructor on outgoing TCP# " << GetID() << endl; std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
#if TCPN_DEBUG_Memory >= 5 #if TCPN_DEBUG_Memory >= 5
else { else {
cout << "Deconstructor on incomming TCP# " << GetID() << endl; std::cout << "Deconstructor on incomming TCP# " << GetID() << std::endl;
} }
#endif #endif
safe_delete_array(recvbuf); safe_delete_array(recvbuf);
@@ -165,12 +163,6 @@ bool TCPConnection::GetSockName(char *host, uint16 *port)
} }
void TCPConnection::Free() { void TCPConnection::Free() {
if (ConnectionType == Outgoing) {
ThrowError("TCPConnection::Free() called on an Outgoing connection");
}
#if TCPN_DEBUG_Memory >= 5
cout << "Free on TCP# " << GetID() << endl;
#endif
Disconnect(); Disconnect();
pFree = true; pFree = true;
} }
@@ -186,7 +178,7 @@ bool TCPConnection::Send(const uchar* data, int32 size) {
void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) { void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) {
MSendQueue.lock(); MSendQueue.lock();
if (sendbuf == NULL) { if (sendbuf == nullptr) {
sendbuf = new uchar[size]; sendbuf = new uchar[size];
sendbuf_size = size; sendbuf_size = size;
sendbuf_used = 0; sendbuf_used = 0;
@@ -362,7 +354,6 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
if (ConnectionType != Outgoing) { if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems // If this code runs, we got serious problems
// Crash and burn. // Crash and burn.
ThrowError("TCPConnection::AsyncConnect() call on a Incomming connection object!");
return; return;
} }
if(!ConnectReady()) { if(!ConnectReady()) {
@@ -394,7 +385,7 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
_beginthread(TCPConnectionLoop, 0, this); _beginthread(TCPConnectionLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this); pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif #endif
} }
return; return;
@@ -423,7 +414,6 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
if (ConnectionType != Outgoing) { if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems // If this code runs, we got serious problems
// Crash and burn. // Crash and burn.
ThrowError("TCPConnection::Connect() call on a Incomming connection object!");
return false; return false;
} }
MState.lock(); MState.lock();
@@ -441,13 +431,13 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
_beginthread(TCPConnectionLoop, 0, this); _beginthread(TCPConnectionLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this); pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif #endif
} }
connection_socket = INVALID_SOCKET; connection_socket = INVALID_SOCKET;
struct sockaddr_in server_sin; struct sockaddr_in server_sin;
// struct in_addr in; //struct in_addr in;
if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) { if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) {
#ifdef _WINDOWS #ifdef _WINDOWS
@@ -547,7 +537,7 @@ bool TCPConnection::Process() {
case TCPS_Connected: case TCPS_Connected:
// only receive data in the connected state, no others... // only receive data in the connected state, no others...
if (!RecvData(errbuf)) { if (!RecvData(errbuf)) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
//cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; //cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false; return false;
@@ -593,9 +583,9 @@ bool TCPConnection::Process() {
bool sent_something = false; bool sent_something = false;
if (!SendData(sent_something, errbuf)) { if (!SendData(sent_something, errbuf)) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
return false; return false;
} }
@@ -629,15 +619,15 @@ bool TCPConnection::RecvData(char* errbuf) {
} }
} }
status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0); status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0);
if (status >= 1) { if (status >= 1) {
#if TCPN_LOG_RAW_DATA_IN >= 1 #if TCPN_LOG_RAW_DATA_IN >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_IN == 2 #if TCPN_LOG_RAW_DATA_IN == 2
int32 tmp = status; int32 tmp = status;
if (tmp > 32) if (tmp > 32)
@@ -650,7 +640,7 @@ bool TCPConnection::RecvData(char* errbuf) {
recvbuf_used += status; recvbuf_used += status;
if (!ProcessReceivedData(errbuf)) if (!ProcessReceivedData(errbuf))
return false; return false;
} }
else if (status == SOCKET_ERROR) { else if (status == SOCKET_ERROR) {
#ifdef _WINDOWS #ifdef _WINDOWS
if (!(WSAGetLastError() == WSAEWOULDBLOCK)) { if (!(WSAGetLastError() == WSAEWOULDBLOCK)) {
@@ -691,7 +681,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
return true; return true;
#if TCPN_DEBUG_Console >= 4 #if TCPN_DEBUG_Console >= 4
if (recvbuf_used) { if (recvbuf_used) {
cout << "Starting Processing: recvbuf=" << recvbuf_used << endl; std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
#endif #endif
@@ -723,13 +713,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
} }
} }
#if TCPN_DEBUG_Console >= 5 #if TCPN_DEBUG_Console >= 5
cout << "Removed 0x00" << endl; std::cout << "Removed 0x00" << std::endl;
if (recvbuf_used) { if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl; std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
else else
cout << "recbuf left: None" << endl; std::cout << "recbuf left: None" << std::endl;
#endif #endif
m_previousLineEnd = false; m_previousLineEnd = false;
break; break;
@@ -737,7 +727,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
case 10: case 10:
case 13: // newline marker case 13: // newline marker
{ {
char *line = NULL; char *line = nullptr;
if (i==0) { // empty line if (i==0) { // empty line
if(!m_previousLineEnd) { if(!m_previousLineEnd) {
//char right before this was NOT a CR, report the empty line. //char right before this was NOT a CR, report the empty line.
@@ -756,7 +746,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
memset(line, 0, i+1); memset(line, 0, i+1);
memcpy(line, recvbuf, i); memcpy(line, recvbuf, i);
#if TCPN_DEBUG_Console >= 3 #if TCPN_DEBUG_Console >= 3
cout << "Line Out: " << endl; std::cout << "Line Out: " << std::endl;
DumpPacket((uchar*) line, i); DumpPacket((uchar*) line, i);
#endif #endif
//line[i] = 0; //line[i] = 0;
@@ -766,13 +756,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
recvbuf_echo -= i+1; recvbuf_echo -= i+1;
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used); memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
#if TCPN_DEBUG_Console >= 5 #if TCPN_DEBUG_Console >= 5
cout << "i+1=" << i+1 << endl; std::cout << "i+1=" << i+1 << std::endl;
if (recvbuf_used) { if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl; std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
else else
cout << "recbuf left: None" << endl; std::cout << "recbuf left: None" << std::endl;
#endif #endif
safe_delete_array(tmpdel); safe_delete_array(tmpdel);
i = -1; i = -1;
@@ -780,7 +770,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
} }
if(line != NULL) { if(line != nullptr) {
bool finish_proc = false; bool finish_proc = false;
finish_proc = LineOutQueuePush(line); finish_proc = LineOutQueuePush(line);
if(finish_proc) if(finish_proc)
@@ -837,8 +827,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_OUT == 2 #if TCPN_LOG_RAW_DATA_OUT == 2
int32 tmp = status; int32 tmp = status;
if (tmp > 32) if (tmp > 32)
@@ -854,15 +844,14 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#endif #endif
// If there's network congestion, the number of bytes sent can be less than // If there's network congestion, the number of bytes sent can be less than
// what we tried to give it... Push the extra back on the queue for later // what we tried to give it... Push the extra back on the queue for later
ServerSendQueuePushFront(&data[status], size - status); ServerSendQueuePushFront(&data[status], size - status);
} }
else if (status > (signed)size) { else if (status > (signed)size) {
ThrowError("TCPConnection::SendData(): WTF! status > size");
return false; return false;
} }
// else if (status == size) {} // else if (status == size) {}
@@ -905,8 +894,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
ThrowError("TCPConnectionLoop(): tmp = 0!"); THREAD_RETURN(nullptr);
THREAD_RETURN(NULL);
} }
TCPConnection* tcpc = (TCPConnection*) tmp; TCPConnection* tcpc = (TCPConnection*) tmp;
#ifndef WIN32 #ifndef WIN32
@@ -942,7 +930,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
bool TCPConnection::RunLoop() { bool TCPConnection::RunLoop() {
@@ -953,7 +941,3 @@ bool TCPConnection::RunLoop() {
return ret; return ret;
} }
+14 -19
View File
@@ -1,34 +1,31 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef TCP_CONNECTION_H #ifndef TCP_CONNECTION_H
#define TCP_CONNECTION_H #define TCP_CONNECTION_H
/* /*
Parent classes for interserver TCP Communication. Parent classes for interserver TCP Communication.
-Quagmire -Quagmire
*/ */
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#include <process.h> #include <process.h>
#else #else
@@ -177,5 +174,3 @@ private:
#endif #endif
+10 -18
View File
@@ -1,5 +1,3 @@
#include "debug.h" #include "debug.h"
#include "TCPServer.h" #include "TCPServer.h"
#include <stdio.h> #include <stdio.h>
@@ -18,12 +16,8 @@
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#endif #endif
#define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues #define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues
BaseTCPServer::BaseTCPServer(uint16 in_port) { BaseTCPServer::BaseTCPServer(uint16 in_port) {
NextID = 1; NextID = 1;
pPort = in_port; pPort = in_port;
@@ -33,7 +27,7 @@ BaseTCPServer::BaseTCPServer(uint16 in_port) {
_beginthread(BaseTCPServer::TCPServerLoop, 0, this); _beginthread(BaseTCPServer::TCPServerLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, &BaseTCPServer::TCPServerLoop, this); pthread_create(&thread, nullptr, &BaseTCPServer::TCPServerLoop, this);
#endif #endif
} }
@@ -67,8 +61,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
// ThrowError("BaseTCPServerLoop(): tmp = 0!"); THREAD_RETURN(nullptr);
THREAD_RETURN(NULL);
} }
BaseTCPServer* tcps = (BaseTCPServer*) tmp; BaseTCPServer* tcps = (BaseTCPServer*) tmp;
@@ -88,7 +81,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
void BaseTCPServer::Process() { void BaseTCPServer::Process() {
@@ -96,14 +89,14 @@ void BaseTCPServer::Process() {
} }
void BaseTCPServer::ListenNewConnections() { void BaseTCPServer::ListenNewConnections() {
SOCKET tmpsock; SOCKET tmpsock;
struct sockaddr_in from; struct sockaddr_in from;
struct in_addr in; struct in_addr in;
unsigned int fromlen; unsigned int fromlen;
unsigned short port; unsigned short port;
from.sin_family = AF_INET; from.sin_family = AF_INET;
fromlen = sizeof(from); fromlen = sizeof(from);
LockMutex lock(&MSock); LockMutex lock(&MSock);
if (!sock) if (!sock)
return; return;
@@ -231,4 +224,3 @@ bool BaseTCPServer::IsOpen() {
return ret; return ret;
} }
+1 -1
View File
@@ -71,7 +71,7 @@ public:
} }
T * NewQueuePop() { T * NewQueuePop() {
T * ret = NULL; T * ret = nullptr;
MNewQueue.lock(); MNewQueue.lock();
if(!m_NewQueue.empty()) { if(!m_NewQueue.empty()) {
ret = m_NewQueue.front(); ret = m_NewQueue.front();
+29 -29
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
#include "XMLParser.h" #include "XMLParser.h"
@@ -23,7 +23,7 @@ XMLParser::XMLParser() {
} }
bool XMLParser::ParseFile(const char *file, const char *root_ele) { bool XMLParser::ParseFile(const char *file, const char *root_ele) {
map<string,ElementHandler>::iterator handler; std::map<std::string,ElementHandler>::iterator handler;
TiXmlDocument doc( file ); TiXmlDocument doc( file );
if(!doc.LoadFile()) { if(!doc.LoadFile()) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc()); printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
@@ -31,14 +31,14 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
} }
TiXmlElement *root = doc.FirstChildElement( root_ele ); TiXmlElement *root = doc.FirstChildElement( root_ele );
if(root == NULL) { if(root == nullptr) {
printf("Unable to find root '%s' in %s\n",root_ele, file); printf("Unable to find root '%s' in %s\n",root_ele, file);
return(false); return(false);
} }
ParseOkay=true; ParseOkay=true;
TiXmlNode *main_element = NULL; TiXmlNode *main_element = nullptr;
while( (main_element = root->IterateChildren( main_element )) ) { while( (main_element = root->IterateChildren( main_element )) ) {
if(main_element->Type() != TiXmlNode::ELEMENT) if(main_element->Type() != TiXmlNode::ELEMENT)
continue; //skip crap we dont care about continue; //skip crap we dont care about
@@ -49,15 +49,15 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
ElementHandler h=handler->second; ElementHandler h=handler->second;
/* /*
* *
* This is kinda a sketchy operation here, since all of these * This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes. * element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence * This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This * un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance. * WILL BREAK if any children classes do multiple inheritance.
* *
* *
*/ */
(this->*h)(ele); (this->*h)(ele);
} else { } else {
@@ -71,30 +71,30 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
const char *XMLParser::ParseTextBlock(TiXmlNode *within, const char *name, bool optional) { const char *XMLParser::ParseTextBlock(TiXmlNode *within, const char *name, bool optional) {
TiXmlElement * txt = within->FirstChildElement(name); TiXmlElement * txt = within->FirstChildElement(name);
if(txt == NULL) { if(txt == nullptr) {
if(!optional) { if(!optional) {
printf("Unable to find a '%s' element on %s element at line %d\n", name, within->Value(), within->Row()); printf("Unable to find a '%s' element on %s element at line %d\n", name, within->Value(), within->Row());
ParseOkay=false; ParseOkay=false;
} }
return(NULL); return(nullptr);
} }
TiXmlNode *contents = txt->FirstChild(); TiXmlNode *contents = txt->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) { if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional) if(!optional)
printf("Node '%s' was expected to be a text element in %s element at line %d\n", name, txt->Value(), txt->Row()); printf("Node '%s' was expected to be a text element in %s element at line %d\n", name, txt->Value(), txt->Row());
return(NULL); return(nullptr);
} }
return(contents->Value()); return(contents->Value());
} }
const char *XMLParser::GetText(TiXmlNode *within, bool optional) { const char *XMLParser::GetText(TiXmlNode *within, bool optional) {
TiXmlNode *contents = within->FirstChild(); TiXmlNode *contents = within->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) { if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional) { if(!optional) {
printf("Node was expected to be a text element in %s element at line %d\n", within->Value(), within->Row()); printf("Node was expected to be a text element in %s element at line %d\n", within->Value(), within->Row());
ParseOkay=false; ParseOkay=false;
} }
return(NULL); return(nullptr);
} }
return(contents->Value()); return(contents->Value());
} }
+14 -21
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef XMLParser_H #ifndef XMLParser_H
#define XMLParser_H #define XMLParser_H
@@ -24,13 +24,10 @@
#include <string> #include <string>
#include <map> #include <map>
using namespace std;
/* /*
* See note in XMLParser::ParseFile() before inheriting this class. * See note in XMLParser::ParseFile() before inheriting this class.
*/ */
class XMLParser { class XMLParser {
public: public:
typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele); typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele);
@@ -45,15 +42,11 @@ protected:
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false); const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false); const char *GetText(TiXmlNode *within, bool optional = false);
map<string,ElementHandler> Handlers; std::map<std::string,ElementHandler> Handlers;
bool ParseOkay; bool ParseOkay;
}; };
#endif #endif
+12 -12
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef BODYTYPES_H #ifndef BODYTYPES_H
#define BODYTYPES_H #define BODYTYPES_H
@@ -45,7 +45,7 @@ typedef enum {
BT_Dragon = 26, BT_Dragon = 26,
BT_Summoned2 = 27, BT_Summoned2 = 27,
BT_Summoned3 = 28, BT_Summoned3 = 28,
// 29 //29
BT_VeliousDragon = 30, //might not be a tight set BT_VeliousDragon = 30, //might not be a tight set
// ... // ...
BT_Dragon3 = 32, BT_Dragon3 = 32,
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef BREAKDOWNS_H_ #ifndef BREAKDOWNS_H_
#define BREAKDOWNS_H_ #define BREAKDOWNS_H_
+251 -251
View File
@@ -1,279 +1,279 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/classes.h" #include "../common/classes.h"
const char* GetEQClassName(uint8 class_, uint8 level) { const char* GetEQClassName(uint8 class_, uint8 level) {
switch(class_) { switch(class_) {
case WARRIOR: case WARRIOR:
if (level >= 70) if (level >= 70)
return "Vanquisher"; return "Vanquisher";
else if (level >= 65) else if (level >= 65)
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE. return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
else if (level >= 60) else if (level >= 60)
return "Warlord"; return "Warlord";
else if (level >= 55) else if (level >= 55)
return "Myrmidon"; return "Myrmidon";
else if (level >= 51) else if (level >= 51)
return "Champion"; return "Champion";
else else
return "Warrior"; return "Warrior";
case CLERIC: case CLERIC:
if (level >= 70) if (level >= 70)
return "Prelate"; return "Prelate";
else if (level >= 65) else if (level >= 65)
return "Archon"; return "Archon";
else if (level >= 60) else if (level >= 60)
return "High Priest"; return "High Priest";
else if (level >= 55) else if (level >= 55)
return "Templar"; return "Templar";
else if (level >= 51) else if (level >= 51)
return "Vicar"; return "Vicar";
else else
return "Cleric"; return "Cleric";
case PALADIN: case PALADIN:
if (level >= 70) if (level >= 70)
return "Lord"; return "Lord";
else if (level >= 65) else if (level >= 65)
return "Lord Protector"; return "Lord Protector";
else if (level >= 60) else if (level >= 60)
return "Crusader"; return "Crusader";
else if (level >= 55) else if (level >= 55)
return "Knight"; return "Knight";
else if (level >= 51) else if (level >= 51)
return "Cavalier"; return "Cavalier";
else else
return "Paladin"; return "Paladin";
case RANGER: case RANGER:
if (level >= 70) if (level >= 70)
return "Plainswalker"; return "Plainswalker";
else if (level >= 65) else if (level >= 65)
return "Forest Stalker"; return "Forest Stalker";
else if (level >= 60) else if (level >= 60)
return "Warder"; return "Warder";
else if (level >= 55) else if (level >= 55)
return "Outrider"; return "Outrider";
else if (level >= 51) else if (level >= 51)
return "Pathfinder"; return "Pathfinder";
else else
return "Ranger"; return "Ranger";
case SHADOWKNIGHT: case SHADOWKNIGHT:
if (level >= 70) if (level >= 70)
return "Scourge Knight"; return "Scourge Knight";
else if (level >= 65) else if (level >= 65)
return "Dread Lord"; return "Dread Lord";
else if (level >= 60) else if (level >= 60)
return "Grave Lord"; return "Grave Lord";
else if (level >= 55) else if (level >= 55)
return "Revenant"; return "Revenant";
else if (level >= 51) else if (level >= 51)
return "Reaver"; return "Reaver";
else else
return "Shadowknight"; return "Shadowknight";
case DRUID: case DRUID:
if (level >= 70) if (level >= 70)
return "Natureguard"; return "Natureguard";
else if (level >= 65) else if (level >= 65)
return "Storm Warden"; return "Storm Warden";
else if (level >= 60) else if (level >= 60)
return "Hierophant"; return "Hierophant";
else if (level >= 55) else if (level >= 55)
return "Preserver"; return "Preserver";
else if (level >= 51) else if (level >= 51)
return "Wanderer"; return "Wanderer";
else else
return "Druid"; return "Druid";
case MONK: case MONK:
if (level >= 70) if (level >= 70)
return "Stone Fist"; return "Stone Fist";
else if (level >= 65) else if (level >= 65)
return "Transcendent"; return "Transcendent";
else if (level >= 60) else if (level >= 60)
return "Grandmaster"; return "Grandmaster";
else if (level >= 55) else if (level >= 55)
return "Master"; return "Master";
else if (level >= 51) else if (level >= 51)
return "Disciple"; return "Disciple";
else else
return "Monk"; return "Monk";
case BARD: case BARD:
if (level >= 70) if (level >= 70)
return "Performer"; return "Performer";
else if (level >= 65) else if (level >= 65)
return "Maestro"; return "Maestro";
else if (level >= 60) else if (level >= 60)
return "Virtuoso"; return "Virtuoso";
else if (level >= 55) else if (level >= 55)
return "Troubadour"; return "Troubadour";
else if (level >= 51) else if (level >= 51)
return "Minstrel"; return "Minstrel";
else else
return "Bard"; return "Bard";
case ROGUE: case ROGUE:
if (level >= 70) if (level >= 70)
return "Nemesis"; return "Nemesis";
else if (level >= 65) else if (level >= 65)
return "Deceiver"; return "Deceiver";
else if (level >= 60) else if (level >= 60)
return "Assassin"; return "Assassin";
else if (level >= 55) else if (level >= 55)
return "Blackguard"; return "Blackguard";
else if (level >= 51) else if (level >= 51)
return "Rake"; return "Rake";
else else
return "Rogue"; return "Rogue";
case SHAMAN: case SHAMAN:
if (level >= 70) if (level >= 70)
return "Soothsayer"; return "Soothsayer";
else if (level >= 65) else if (level >= 65)
return "Prophet"; return "Prophet";
else if (level >= 60) else if (level >= 60)
return "Oracle"; return "Oracle";
else if (level >= 55) else if (level >= 55)
return "Luminary"; return "Luminary";
else if (level >= 51) else if (level >= 51)
return "Mystic"; return "Mystic";
else else
return "Shaman"; return "Shaman";
case NECROMANCER: case NECROMANCER:
if (level >= 70) if (level >= 70)
return "Wraith"; return "Wraith";
else if (level >= 65) else if (level >= 65)
return "Arch Lich"; return "Arch Lich";
else if (level >= 60) else if (level >= 60)
return "Warlock"; return "Warlock";
else if (level >= 55) else if (level >= 55)
return "Defiler"; return "Defiler";
else if (level >= 51) else if (level >= 51)
return "Heretic"; return "Heretic";
else else
return "Necromancer"; return "Necromancer";
case WIZARD: case WIZARD:
if (level >= 70) if (level >= 70)
return "Grand Arcanist"; return "Grand Arcanist";
else if (level >= 65) else if (level >= 65)
return "Arcanist"; return "Arcanist";
else if (level >= 60) else if (level >= 60)
return "Sorcerer"; return "Sorcerer";
else if (level >= 55) else if (level >= 55)
return "Evoker"; return "Evoker";
else if (level >= 51) else if (level >= 51)
return "Channeler"; return "Channeler";
else else
return "Wizard"; return "Wizard";
case MAGICIAN: case MAGICIAN:
if (level >= 70) if (level >= 70)
return "Arch Magus"; return "Arch Magus";
else if (level >= 65) else if (level >= 65)
return "Arch Convoker"; return "Arch Convoker";
else if (level >= 60) else if (level >= 60)
return "Arch Mage"; return "Arch Mage";
else if (level >= 55) else if (level >= 55)
return "Conjurer"; return "Conjurer";
if (level >= 51) if (level >= 51)
return "Elementalist"; return "Elementalist";
else else
return "Magician"; return "Magician";
case ENCHANTER: case ENCHANTER:
if (level >= 70) if (level >= 70)
return "Bedazzler"; return "Bedazzler";
else if (level >= 65) else if (level >= 65)
return "Coercer"; return "Coercer";
else if (level >= 60) else if (level >= 60)
return "Phantasmist"; return "Phantasmist";
else if (level >= 55) else if (level >= 55)
return "Beguiler"; return "Beguiler";
else if (level >= 51) else if (level >= 51)
return "Illusionist"; return "Illusionist";
else else
return "Enchanter"; return "Enchanter";
case BEASTLORD: case BEASTLORD:
if (level >= 70) if (level >= 70)
return "Wildblood"; return "Wildblood";
else if (level >= 65) else if (level >= 65)
return "Feral Lord"; return "Feral Lord";
else if (level >= 60) else if (level >= 60)
return "Savage Lord"; return "Savage Lord";
else if (level >= 55) else if (level >= 55)
return "Animist"; return "Animist";
else if (level >= 51) else if (level >= 51)
return "Primalist"; return "Primalist";
else else
return "Beastlord"; return "Beastlord";
case BERSERKER: case BERSERKER:
if (level >= 70) if (level >= 70)
return "Ravager"; return "Ravager";
else if (level >= 65) else if (level >= 65)
return "Fury"; return "Fury";
else if (level >= 60) else if (level >= 60)
return "Rager"; return "Rager";
else if (level >= 55) else if (level >= 55)
return "Vehement"; return "Vehement";
else if (level >= 51) else if (level >= 51)
return "Brawler"; return "Brawler";
else else
return "Berserker"; return "Berserker";
case BANKER: case BANKER:
if (level >= 70) if (level >= 70)
return "Master Banker"; return "Master Banker";
else if (level >= 65) else if (level >= 65)
return "Elder Banker"; return "Elder Banker";
else if (level >= 60) else if (level >= 60)
return "Oldest Banker"; return "Oldest Banker";
else if (level >= 55) else if (level >= 55)
return "Older Banker"; return "Older Banker";
else if (level >= 51) else if (level >= 51)
return "Old Banker"; return "Old Banker";
else else
return "Banker"; return "Banker";
case WARRIORGM: case WARRIORGM:
return "Warrior Guildmaster"; return "Warrior Guildmaster";
case CLERICGM: case CLERICGM:
return "Cleric Guildmaster"; return "Cleric Guildmaster";
case PALADINGM: case PALADINGM:
return "Paladin Guildmaster"; return "Paladin Guildmaster";
case RANGERGM: case RANGERGM:
return "Ranger Guildmaster"; return "Ranger Guildmaster";
case SHADOWKNIGHTGM: case SHADOWKNIGHTGM:
return "Shadowknight Guildmaster"; return "Shadowknight Guildmaster";
case DRUIDGM: case DRUIDGM:
return "Druid Guildmaster"; return "Druid Guildmaster";
case MONKGM: case MONKGM:
return "Monk Guildmaster"; return "Monk Guildmaster";
case BARDGM: case BARDGM:
return "Bard Guildmaster"; return "Bard Guildmaster";
case ROGUEGM: case ROGUEGM:
return "Rogue Guildmaster"; return "Rogue Guildmaster";
case SHAMANGM: case SHAMANGM:
return "Shaman Guildmaster"; return "Shaman Guildmaster";
case NECROMANCERGM: case NECROMANCERGM:
return "Necromancer Guildmaster"; return "Necromancer Guildmaster";
case WIZARDGM: case WIZARDGM:
return "Wizard Guildmaster"; return "Wizard Guildmaster";
case MAGICIANGM: case MAGICIANGM:
return "Magician Guildmaster"; return "Magician Guildmaster";
case ENCHANTERGM: case ENCHANTERGM:
return "Enchanter Guildmaster"; return "Enchanter Guildmaster";
case BEASTLORDGM: case BEASTLORDGM:
return "Beastlord Guildmaster"; return "Beastlord Guildmaster";
case BERSERKERGM: case BERSERKERGM:
return "Berserker Guildmaster"; return "Berserker Guildmaster";
case MERCHANT: case MERCHANT:
return "Merchant"; return "Merchant";
case ADVENTURERECRUITER: case ADVENTURERECRUITER:
return "Adventure Recruiter"; return "Adventure Recruiter";
@@ -285,7 +285,7 @@ const char* GetEQClassName(uint8 class_, uint8 level) {
return "Tribute Master"; return "Tribute Master";
case GUILD_TRIBUTE_MASTER: case GUILD_TRIBUTE_MASTER:
return "Guild Tribute Master"; return "Guild Tribute Master";
default: default:
return "Unknown"; return "Unknown";
} }
} }
+27 -27
View File
@@ -1,41 +1,41 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef CLASSES_CH #ifndef CLASSES_CH
#define CLASSES_CH #define CLASSES_CH
#include "../common/types.h" #include "../common/types.h"
#define Array_Class_UNKNOWN 0 #define Array_Class_UNKNOWN 0
#define WARRIOR 1 #define WARRIOR 1
#define CLERIC 2 #define CLERIC 2
#define PALADIN 3 #define PALADIN 3
#define RANGER 4 #define RANGER 4
#define SHADOWKNIGHT 5 #define SHADOWKNIGHT 5
#define DRUID 6 #define DRUID 6
#define MONK 7 #define MONK 7
#define BARD 8 #define BARD 8
#define ROGUE 9 #define ROGUE 9
#define SHAMAN 10 #define SHAMAN 10
#define NECROMANCER 11 #define NECROMANCER 11
#define WIZARD 12 #define WIZARD 12
#define MAGICIAN 13 #define MAGICIAN 13
#define ENCHANTER 14 #define ENCHANTER 14
#define BEASTLORD 15 #define BEASTLORD 15
#define BERSERKER 16 #define BERSERKER 16
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes #define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
#define WARRIORGM 20 #define WARRIORGM 20
#define CLERICGM 21 #define CLERICGM 21
+12 -12
View File
@@ -1,25 +1,25 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef COMMON_PROFILE_H #ifndef COMMON_PROFILE_H
#define COMMON_PROFILE_H #define COMMON_PROFILE_H
#ifdef ZONE #ifdef ZONE
#include "../zone/features.h" #include "../common/features.h"
#ifndef EQPROFILE #ifndef EQPROFILE
#ifdef COMMON_PROFILE #ifdef COMMON_PROFILE
+90 -90
View File
@@ -7,107 +7,107 @@
class EQEmuStackWalker : public StackWalker class EQEmuStackWalker : public StackWalker
{ {
public: public:
EQEmuStackWalker() : StackWalker() { } EQEmuStackWalker() : StackWalker() { }
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { } EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
virtual void OnOutput(LPCSTR szText) { virtual void OnOutput(LPCSTR szText) {
char buffer[4096]; char buffer[4096];
for(int i = 0; i < 4096; ++i) { for(int i = 0; i < 4096; ++i) {
if(szText[i] == 0) { if(szText[i] == 0) {
buffer[i] = '\0'; buffer[i] = '\0';
break; break;
} }
if(szText[i] == '\n' || szText[i] == '\r') { if(szText[i] == '\n' || szText[i] == '\r') {
buffer[i] = ' '; buffer[i] = ' ';
} else { } else {
buffer[i] = szText[i]; buffer[i] = szText[i];
} }
} }
LogFile->write(EQEMuLog::Crash, buffer); LogFile->write(EQEMuLog::Crash, buffer);
StackWalker::OnOutput(szText); StackWalker::OnOutput(szText);
} }
}; };
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo) LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
{ {
switch(ExceptionInfo->ExceptionRecord->ExceptionCode) switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
{ {
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
break; break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break; break;
case EXCEPTION_BREAKPOINT: case EXCEPTION_BREAKPOINT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
break; break;
case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_DATATYPE_MISALIGNMENT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
break; break;
case EXCEPTION_FLT_DENORMAL_OPERAND: case EXCEPTION_FLT_DENORMAL_OPERAND:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
break; break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO: case EXCEPTION_FLT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
break; break;
case EXCEPTION_FLT_INEXACT_RESULT: case EXCEPTION_FLT_INEXACT_RESULT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
break; break;
case EXCEPTION_FLT_INVALID_OPERATION: case EXCEPTION_FLT_INVALID_OPERATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
break; break;
case EXCEPTION_FLT_OVERFLOW: case EXCEPTION_FLT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
break; break;
case EXCEPTION_FLT_STACK_CHECK: case EXCEPTION_FLT_STACK_CHECK:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
break; break;
case EXCEPTION_FLT_UNDERFLOW: case EXCEPTION_FLT_UNDERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
break; break;
case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
break; break;
case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_IN_PAGE_ERROR:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
break; break;
case EXCEPTION_INT_DIVIDE_BY_ZERO: case EXCEPTION_INT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
break; break;
case EXCEPTION_INT_OVERFLOW: case EXCEPTION_INT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
break; break;
case EXCEPTION_INVALID_DISPOSITION: case EXCEPTION_INVALID_DISPOSITION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
break; break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION: case EXCEPTION_NONCONTINUABLE_EXCEPTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
break; break;
case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_PRIV_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
break; break;
case EXCEPTION_SINGLE_STEP: case EXCEPTION_SINGLE_STEP:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
break; break;
case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_STACK_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
break; break;
default: default:
LogFile->write(EQEMuLog::Crash, "Unknown Exception"); LogFile->write(EQEMuLog::Crash, "Unknown Exception");
break; break;
} }
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode) if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
{ {
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord); EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
} }
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
void set_exception_handler() { void set_exception_handler() {
SetUnhandledExceptionFilter(windows_exception_handler); SetUnhandledExceptionFilter(windows_exception_handler);
} }
#else #else
// crash is off or an unhandled platform // crash is off or an unhandled platform
+11 -11
View File
@@ -84,21 +84,21 @@ uint32 CRC32::GenerateNoFlip(const uint8* buf, uint32 bufsize) {
void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at) void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
{ {
unsigned long data; unsigned long data;
unsigned long check = 0xffffffff; unsigned long check = 0xffffffff;
assert(in_length >= start_at && in_data); assert(in_length >= start_at && in_data);
for(uint32 i=start_at; i<in_length; i++) for(uint32 i=start_at; i<in_length; i++)
{ {
data = in_data[i]; data = in_data[i];
data = data ^ (check); data = data ^ (check);
data = data & 0x000000ff; data = data & 0x000000ff;
check = check >> 8; check = check >> 8;
data = CRC32Table[data]; data = CRC32Table[data];
check = check ^ data; check = check ^ data;
} }
memcpy(in_data, (char*)&check, 4); memcpy(in_data, (char*)&check, 4);
} }
uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) { uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) {
+294 -298
View File
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More