Compare commits

...

920 Commits

Author SHA1 Message Date
KimLS 308562f939 Work around for msvc tuple bug 2014-06-16 15:09:17 -07:00
Michael Cook 64784be57e Merge pull request #159 from KayenEQ/Development
Additional functionality for damage shield and skill damage taken effects via npc_spell_effects  table.
2014-06-14 01:14:44 -04:00
KayenEQ f0e8d88178 Implemented 'special_abilities' 38 ALLOW_BENEFICIAL (Allows an NPC to recieve player buffs/heals)
Implemented 'special_abilities' 39 DISABLE_MELEE (Prevents NPC from auto attacking, will still aggro)
2014-06-13 17:46:34 -04:00
KayenEQ 5137b84ba8 Implemented SE_AlterNPCLevel 2014-06-13 14:51:26 -04:00
KayenEQ 216113e14b Additional functionality for damage shield and skill damage taken
effects va the npc_spell_effects table. See change log and wiki.
2014-06-13 05:32:41 -04:00
KimLS a1adda36fa Experimental changes to lua get_qglobal implementation to try to see if we can figure out this gcc x86 bug. 2014-06-08 15:18:48 -07:00
Michael Cook 5d074ea998 Update LS default entry in example config 2014-06-05 02:57:56 -04:00
KimLS e9c4613368 Merge branch 'master' into water_map_v2 2014-06-04 18:32:48 -07:00
KimLS 3690f93302 Fix for fear failing, removed #fear command because it was blank anyway, added a cmake command to change the default map/water/path directory 2014-05-31 16:32:15 -07:00
KimLS dd73b82ec2 Fix for a problem with global player quests and hasquestsub 2014-05-27 16:16:06 -07:00
KimLS 8a5405060f Fix for string.h missing in water map 2014-05-23 17:39:16 -07:00
KimLS 83270d0983 Merge from master stuff 2014-05-23 16:10:23 -07:00
KimLS fd4343702f Merge branch 'master' into water_map_v2 2014-05-23 16:09:46 -07:00
KimLS 0483e8bd1b Removed the logging now that the issue is resolved 2014-05-23 16:08:02 -07:00
KimLS 39cbdbd5c2 Debug logs for map, also can actually turn perl off on zone 2014-05-23 15:54:26 -07:00
Michael Cook (mackal) 5af47c5951 Fix for Technique of Master Wu triple attack 2014-05-23 17:21:47 -04:00
Michael Cook (mackal) c447c251cd Fix issue with avoidance discs 2014-05-22 13:45:44 -04:00
KimLS 3a2ccd7521 Added loading of v2 regular maps, also #bestz will report water info even if a reg map failed to load. 2014-05-21 17:30:54 -07:00
KimLS 8c92271804 Initial v2 water map format. 2014-05-20 00:14:26 -07:00
Michael Cook (mackal) cd7b5e4dce Merge branch 'KayenEQ-Development' 2014-05-20 00:49:06 -04:00
Michael Cook (mackal) ecc3459d93 Merge branch 'Development' of github.com:KayenEQ/Server into KayenEQ-Development
Conflicts:
	changelog.txt
2014-05-20 00:48:44 -04:00
SecretsOTheP cc6dce25ad Identified the opcode/struct for guild ranks in Rain of Fear+ clients and created a temporary workaround for permissions until full DB support is added for the new permissions system. 2014-05-17 23:33:35 -04:00
KayenEQ 87ecdd38e5 Update for spell effect SE_LimitHPPercent, SE_LimitManaPercent, SE_LimitEndPercent
to utilize limit values. These effects cap your hp/end/mana at a set percent (base)
OR flat value (limit) which is ever is lower.
2014-05-14 09:27:47 -04:00
KayenEQ fc79521dd3 Rooted NPC's will no longer target players with Divine Aura effect if
they are the closest target and other targets exist on the hate list.
2014-05-14 08:40:18 -04:00
KayenEQ 7d8f1bef87 Missing rule SQL from prior update. 2014-05-14 07:59:12 -04:00
Uleat 10c43bfa51 Re-arranged Item.cpp functions to match their declaration order in Item.h (prep for upcoming changes) 2014-05-12 03:06:13 -04:00
Michael Cook f50b83b293 Merge pull request #152 from KinglyKrab/master
Command.cpp
2014-05-11 13:39:43 -04:00
Alex f89357f3c8 WIS fix.
WIS was actually setting MR.
2014-05-11 13:27:33 -04:00
Alex 1f43e69b4c Updated with fix. 2014-05-10 12:02:48 -04:00
KimLS 670c5e2e1a Fix for crash in loading loot drops when you hit the actual lootdrop entry limit of 1260 2014-05-09 15:06:33 -07:00
KinglyKrab e097722ec6 Update command.cpp
Removed an accidental repetition of atoi.
2014-05-08 13:42:21 -04:00
Michael Cook b54c50ba7a Merge pull request #151 from KayenEQ/AAupdates
Swarm pet critical/flurry bonuses
2014-05-07 23:14:33 -04:00
KayenEQ 7b1a084d39 AA/Item/Spell that allow pets to flurry and critical will now
also apply to owners swarm pets consistent with live.
2014-05-07 22:46:00 -04:00
Uleat 6477de8c4f Fix for test... (conn_state != client_state) 2014-05-05 21:59:21 -04:00
JJ 5c0a75071c SQL file rename (added '0') 2014-05-05 21:18:08 -04:00
Uleat 391eee4289 Test fix for 'random' zone crashes..particularly relating to MGB use. 2014-05-05 20:42:31 -04:00
Michael Cook (mackal) 2cf546accd Fix #150 2014-05-05 18:23:55 -04:00
KinglyKrab ffa8e5ff62 Update command.cpp 2014-05-05 15:58:36 -04:00
Michael Cook (mackal) 84f99b6d6b Added pointer check 2014-05-05 15:48:19 -04:00
Michael Cook (mackal) eb33e8ae11 Melee 'facing' code updated to client derived function
These new functions are derived from the client
The need was because the old function sometimes didn't line
up with the client generated messages.
2014-05-05 15:29:29 -04:00
JJ 5af0cb2844 Merge pull request #148 from KayenEQ/AAupdates
SlowMItigation sql fix
2014-05-05 09:58:06 -04:00
KinglyKrab 26255b79db Added new abilites to #npcedit.
I added the ability to modify stats, version, maxlevel, PhR, no_target_hotkey, adventure_template_id, npc_spell_effects_id, trap_template, special_abilities, scalerate, healscale, spellscale, and color.
2014-05-04 10:30:52 -04:00
KayenEQ f6e6f10716 Fix for npc_types table error setting SlowMitigation to null by default.
If you already ran the 4-12 update you do not need to run it again,
just run the new one.
2014-05-04 01:02:04 -04:00
Michael Cook b5ca3219a1 Merge pull request #146 from KayenEQ/AAupdates
Fix for AA stacking where first AA in series has only 1 rank.
2014-05-01 02:59:54 -04:00
KayenEQ fb1d4109a9 Fix for AA stacking where first AA in series has only 1 rank. 2014-04-29 22:23:25 -04:00
KimLS a2e86ebec5 Some compile fixes for older versions of C++ on windows 2014-04-29 17:49:17 -07:00
KimLS c6b637e5a5 Changelog 2014-04-29 13:05:45 -07:00
KimLS 0c9d640683 Merge branch 'master' into raycast 2014-04-29 13:01:26 -07:00
Michael Cook db63c947b8 Merge pull request #145 from KayenEQ/AISpellEffects
AI Spell Effects
2014-04-28 17:34:24 -04:00
KayenEQ 649f363917 fix sql 2014-04-28 17:18:23 -04:00
KimLS 6ad4a95cc6 And of course memset too way to not include the whole error message the first time jerk 2014-04-28 13:15:43 -07:00
KimLS d652cc8ea4 Raycastmesh missing malloc, free, NULL refs 2014-04-28 13:10:11 -07:00
KimLS 989bffee81 Merge branch 'master' into raycast 2014-04-27 14:36:05 -07:00
KayenEQ cd9cf9f52f sql hot fix 2014-04-27 04:27:02 -04:00
KayenEQ d3a9d509a8 remove old sql 2014-04-27 04:02:41 -04:00
KayenEQ 380cf8691a Implemented new table 'npc_spells_effects' and 'npc_spells_effects_entires'.
Implemented new field in 'npc_spell_effects_id' in npc_types.

These are used to directly apply spell effect bonuses to NPC's without requirings spells/buffs.
Example: Allow an npc to spawn with an innate 50 pt damage shield and a 5% chance to critical hit.

Please see the wiki page: http://wiki.eqemulator.org/p?npc_spell_effects_entries for details.

*NPC's can now do critical heals / damage spells if bonus is applied from table.

Required SQL: utils/sql/git/required/2014_04_27_AISpellEffects.sql
Note: 30 examples of spell effects have been included by default in this sql. Edited/removed as needed.
2014-04-27 03:57:14 -04:00
KayenEQ 62e48e7701 Merge git://github.com/EQEmu/Server into AISpellEffects 2014-04-27 03:29:15 -04:00
KimLS 5e81848445 Darwin caused ipc mutex to stop working for non-darwin, non-windows systems. Hopefully fixed 2014-04-25 18:45:19 -07:00
Alex e047d99a6c Merge pull request #138 from Corysia/master
Changes for intel Mac OSX build
2014-04-25 13:47:48 -07:00
cavedude00 d8ad337c0e Fixed a zone crash in spawn_conditions.
spawn_events changes, fixes, and additions.
2014-04-25 12:40:25 -07:00
KayenEQ 391b6ed515 fix 2014-04-25 09:07:48 -04:00
KayenEQ d64f762277 Developement Branch AISpellEffects.
Debug crash on NPC death.
2014-04-25 08:52:49 -04:00
Michael Cook 4d3ba5087d Merge pull request #143 from KayenEQ/master
Focus limit changes/additions
2014-04-25 02:39:19 -04:00
KayenEQ aba1acea9c Merge branch 'master' of git://github.com/EQEmu/Server 2014-04-24 04:30:31 -04:00
SecretsOTheP 9502f0aadf Revert "It's never ogre with these hatelist crashes.."
This reverts commit dffee38dc6.
2014-04-23 12:50:25 -04:00
KayenEQ 564c31c54d Improved SE_LimitCombatSkills will now more accurately determine if a spell is a combat proc.
SE_LimitInstant will now also work when set to include instant spells.

Optional SQL: utils/sql/git/optional/2014_04_23_FocusComabtProcs.sql
Note: Set to false, if enabled will allow all combat procs to receive spell focuses.
2014-04-23 03:54:54 -04:00
SecretsOTheP 6aa0c9d694 hatelist fixes to fixes to fixes 2014-04-22 13:37:35 -04:00
SecretsOTheP e726a82cc3 Merge branch 'master' of https://github.com/EQEmu/Server 2014-04-22 13:24:57 -04:00
SecretsOTheP dd1f5f6a11 More hatelist fixes. Trying to nail the crash :S 2014-04-22 13:24:07 -04:00
Michael Cook (mackal) f08799f7ff Add mez break message 2014-04-22 00:48:46 -04:00
SecretsOTheP dffee38dc6 It's never ogre with these hatelist crashes.. 2014-04-21 22:19:12 -04:00
SecretsOTheP fe542deb89 indentation is important 2014-04-20 21:00:50 -04:00
SecretsOTheP 8aa13b51f4 Hatelist crash fix 2014-04-20 20:54:21 -04:00
KimLS c16fe3c810 CMake flags to defining what is logged and where 2014-04-20 17:46:43 -07:00
KimLS 635d28cd65 Change to how quest signals work 2014-04-20 17:26:51 -07:00
Corysia Taware f915eed0f4 Apparently 0 is a vaid file descriptor in OSX 2014-04-19 21:45:54 -07:00
SecretsOTheP 87994ebfba smoke commits everyday 2014-04-20 00:26:54 -04:00
Akkadius 0b2281967b Added #command error message suppression for those who don't want to see 'Command is not recognized' constantly
- You need to have rule 'Chat:SuppressCommandErrors' set to true, this is set to false by default
	- Required SQL: 2014_04_18_Suppress_Command_Error.sql
2014-04-18 19:37:26 -05:00
Michael Cook (mackal) fc9e7a3a3b Fix linux compile issue with 884b0291 2014-04-16 12:44:02 -04:00
Akkadius 884b0291f7 Exported $client->SendMarqueeMessage(type, priority, fade_in, fade_out, duration, msg) - Will be available for simple plugin use
Exported $client->ExpeditionMessage(THIS, ExpdID, Message) - In use with custom expedition mod that will be released soon
2014-04-15 12:00:33 -05:00
Michael Cook 8d8b3241d1 Merge pull request #141 from KayenEQ/master
Revision of SE_PercentHeal
2014-04-14 02:37:08 -04:00
KayenEQ 272bbdb4d2 Revision of SE_PercentHeal
Will now apply focus properly
Can now do damage if set to negative value
2014-04-12 21:15:13 -04:00
Michael Cook 168183201a Merge pull request #140 from KayenEQ/master
Revision of slow mitigation code.
2014-04-12 12:41:50 -04:00
KayenEQ aedd70f5fa removed commented out code. 2014-04-12 03:31:30 -04:00
KayenEQ f9b46b46b1 Revision of slow mitigation code.
Fix for the slow mitigation spam messages
Converted value from FLOAT to INT
Use SQL to update your npc_types table
2014-04-12 00:18:19 -04:00
Michael Cook 983c7a9c91 Merge pull request #139 from KayenEQ/master
-Implemented the ability to properly use live spell projectile graphics.
2014-04-10 14:06:53 -04:00
KayenEQ 48a9f05efb SQL 2014-04-10 00:55:31 -04:00
KayenEQ f0a0f0677f Rule to make player cast swarm pets untargetable with F8.
New npc_types field to allow any NPC to be untargetable with F8
Swarm pets will now be heal/buffable like live.
See change log for more details.

Note: The method used here to prevent
targeting is a hack but the only side
effect it turns affected NPC's names Yellow.
2014-04-10 00:47:20 -04:00
KayenEQ 35cd98c7a7 -Implemented the ability to properly use live spell projectile graphics.
This data is found in the player_1 field of the spells_new table.
-Rule for this set to be disabled by default.
-Enable IF your server uses an UF+ spell file
and your players use UF+ clients
-Otherwise your better off with alternative method/rules
already implemented so that all players can see the effect.
-Added ability for PERL ProjectileAnim function to only
need an IT#### and not an actual item id.
-If you want it in LUA somebody needs to add it.
- Change to wizard innate critical ratios based on parse data.
2014-04-09 05:17:36 -04:00
Michael Cook (mackal) 8b2f325cd0 Fix wiz innate crit issue 2014-04-07 21:21:08 -04:00
Corysia Taware 4d70cb20e7 Merge remote-tracking branch 'upstream/master' 2014-04-07 10:05:46 -07:00
Uleat 8e55b6618e Dual Wield changes - see posting linked in changelog.txt 2014-04-06 05:39:37 -04:00
Michael Cook (mackal) 7e75f7559a Fix issue with optional SQL 2014-04-06 03:03:18 -04:00
Akkadius 8ad1c1d8a9 changelog.txt 2014-04-05 18:12:58 -05:00
Akkadius fb03db8980 Merge branch 'master' of https://github.com/EQEmu/Server 2014-04-05 18:11:05 -05:00
Akkadius 11d5e4b6ca Fix for the Fix for the Fix: Rule Combat:OneProcPerWeapon was created so that you can revert to the original proc functionality
for custom servers that have balanced their content around having more than 1 aug proc on weapons. By having this rule set to 'false' you revert this functionality.
	This rule is set to 'true' by default as the original functionality from Live was intended to be
2014-04-05 18:09:12 -05:00
KimLS 8db6060089 Renamed errant sql file. 2014-04-05 16:07:13 -07:00
Michael Cook (mackal) 07625336fd Allow multiple aug procs if Combat:OneProcPerWeapon is false 2014-04-05 18:47:14 -04:00
SecretsOTheP 35fad4d5a7 Added a rule to enable multiple procs from the same weapon's other slots if a proc is deemed to trigger, Defaults to true. 2014-04-05 17:18:19 -04:00
Corysia Taware 0f67e93a0f Backward port to OSX 10.6 (Snow Leopard) 2014-04-05 10:24:28 -07:00
Michael Cook (mackal) 628a5764cc Merge branch 'master' of github.com:KayenEQ/Server into KayenEQ-master
Conflicts:
	changelog.txt
2014-04-05 13:00:19 -04:00
Akkadius 7cfc5b085e (Performance Adjustment) Removed AsyncLoadVariables from InterserverTimer.Check() in both zone and world. By watching the MySQL general.log file on mass zone idle activity, you can
see that the query 'SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= timestamp' is called every 10 seconds. This function is loading
	variables that are initially loaded on World and Zone bootup. When running a large amount of zone servers, the amount of MySQL chatter that is produced is enormous and
	unnecessary. For example, if I ran 400 zone servers, I would see 3,456,000 unnecessary queries from all idle or active zone processes in a 24 hour interval.
2014-04-05 03:38:58 -05:00
Akkadius fb3c6365e1 Test 2014-04-05 01:58:16 -05:00
KayenEQ 2c69dd7c93 Implemented proper functionality of SE_Screech
If you have a buff with SE_Screech with value of 1
it will block any other buff with SE_Screen that has
a value of -1, giving you an immunity message.
Example: 1383 Screech and 2785 Screech Immunity
2014-04-04 22:03:32 -04:00
KayenEQ 1d6e947387 Change log correction. 2014-04-04 21:32:56 -04:00
KayenEQ c26637de53 Merge branch 'master' of git://github.com/EQEmu/Server 2014-04-04 18:12:02 -04:00
KimLS d1ecb32652 Fix for crash in EntityList::MobInZone(Mob *who) when a dangling pointer is passed to the function. Which used to work without crashing but was changed at some point which can be triggered by quests in some situations. 2014-04-04 12:27:18 -07:00
KayenEQ 4b14ec53f1 Implemented Physical Resists consistent with live.
SQL to add new column 'PhR' to npc_types
Values to populate table based on extensive parsing.
Fixes for spell projectile code.
2014-04-04 01:59:55 -04:00
Corysia Taware f6046477b4 Changes for intel Mac OSX build 2014-04-03 14:10:03 -07:00
KayenEQ 2cdd50b9e9 -Implemented live like spell projectiles (ie mage bolts).
-See function in spells.cpp for more info on bolt behavior.
-This works reasonably well, but still room for improvements.
-Rules are for setting what item id is used for the projectile
since live uses an item id from SOF+ I added alternate item graphic
for titanium clients.
-Note: Max number of projectiles (set at 10) is a made up value in most
situations it would be nearly impossible to have more than 3 bolts
in the air at the same time. This values gives enough wiggle room that no
server should have an issue though.
-Small fix to SE_CompleteHeal
2014-04-03 04:25:45 -04:00
Trevius bb541eeb60 Fixed potential endless quest loop with EVENT_COMBAT and WipeHateList(). 2014-04-01 23:00:15 -05:00
Michael Cook (mackal) 8866b3170e Implement ability for NPC Merchants to open and close shop 2014-04-01 21:03:49 -04:00
Trevius 174cb1876a Prevented an endless loop crash related to EVENT_TASK_STAGE_COMPLETE. 2014-03-31 22:03:11 -05:00
Uleat 955f164efb Added optional rule for allowing bots to auto-update with their owner.
(Run the optional sql script to activate this feature)
2014-03-31 09:31:49 -04:00
Uleat d939820918 Fix for unconscious ability skillups.
Fix for zone crash related to item==nullptr in Client::SummonItem().
2014-03-31 03:21:22 -04:00
Michael Cook 12f8357373 Merge pull request #136 from KayenEQ/master
Spell Effect Updates.
2014-03-28 02:42:22 -04:00
KayenEQ cbe0e94ca7 Implemented SE_NegateIfCombat 2014-03-27 23:23:15 -04:00
KayenEQ 079d1ca870 String updates
Level requirment for Summon Corpse spells
2014-03-27 19:17:05 -04:00
KayenEQ 41903e8f09 Spell Effect Updates.
Implemented fail chances for SE, Gate, Succor, FeignDeath.
Minor fixes to haste bonuses to allow for negatives.
Rule added for Succor failure rate.
2014-03-27 05:14:54 -04:00
Michael Cook (mackal) 6906125725 Fix for wizard innate crits when they have no chance otherwise 2014-03-27 02:41:39 -04:00
Uleat cfdd48b2a3 Fix for bot guild script failures.
MOVED 'load_bots.sql' and 'drop_bots.sql' into this repository. (They are updated)
2014-03-22 05:17:38 -04:00
Michael Cook 2cef299775 Merge pull request #135 from KayenEQ/master
Further refinements to root, charm, mez and fear behaviors.
2014-03-21 14:00:37 -04:00
KayenEQ 02e291d4e8 Further refinements to root, charm, mez and fear behaviors.
Updates to a few rule due to new/corrected parse data.

All behaviors defined from weeks of extensive live parsing

Root Break Chance from DD now will scale based on level difference.

Root has a baseline aproximately 6% chance to break per check when target has
at 0% chance to resist spells.(ie green cons 60 levels lower with tash).

Fear has an approximately 70% chance to trigger a resist check each tick
to determine if it will fade early. (no baseline break chance)

Charisma less than 100, gives -20 resist mod to intial fear casts
Charisma from 100 to 255 will progressively reduce this mod to 0.
Charisma DOES NOT effect UNDEAD fears

Charmisma less than 75 significantly increase CHARM/MEZ/LULL resist rates.

Mez spells will now also use charisma resist check, as they do on live.
2014-03-20 00:53:49 -04:00
Uleat a84862897a Fix for name/account discrepancy in \\zone\inventory.cpp.
Rearranged/condensed code snippets in Client::SummonItem().
Added 'augslotvisible' check to augment validation in C::SI().
2014-03-18 06:00:46 -04:00
Alex 2781f82d29 Merge pull request #134 from addtheice/master
Tests for hextoi, hextoi64, atobool
2014-03-17 22:34:58 -07:00
Alex f809f503c9 Merge pull request #131 from Siroro/master
Pull Request from Siroro/Server
2014-03-17 22:34:20 -07:00
Uleat 4170434b96 ** Fix for RoF clients not displaying Augment Restrictions in the Item Info window.
** Change to Client::SummonItem() to enforce valid item/augment combinations. (Run the optional sql file first, before posting any
SummonItem() failure issues in the forums.)
2014-03-17 04:53:47 -04:00
Michael Cook 65e8c2ffde Merge pull request #133 from KayenEQ/master
Rune revisions and fixes
2014-03-14 01:55:45 -04:00
Arthur Ice c239964427 Tests for hextoi, hextoi64, atobool
const hextoi / hextoi64 / atobool. null check for each. tests for each.
2014-03-13 14:45:54 -07:00
KayenEQ 21bdc8c5b6 Coverted melee and magic runes to use bonuses.
Removed all the old rune flags now that none of them are used.
Fixed issues where runes would not fade properly if damage = remaing rune amount
Fixed issue where runes would stop absorbing damage if you had multiple runes.
2014-03-12 05:14:19 -04:00
KimLS 39abb4f50c Changed how item faction bonuses are cleared. 2014-03-10 16:43:33 -07:00
KimLS 93105966b6 Added some missing bufffadebyx functions to lua mob 2014-03-09 18:41:50 -07:00
KimLS 2e4b4b94ed Memory leak work around for perl, should play better with events that call other events now. 2014-03-09 17:55:24 -07:00
Michael Cook bad963ddbc Merge pull request #132 from KayenEQ/master
Lull spell effect revisions
2014-03-08 12:49:23 -05:00
KayenEQ 9ecf98195c Lull spell effect revisions 2014-03-08 05:35:22 -05:00
KimLS 1476ebdfe6 Merge branch 'timer' 2014-03-07 20:00:11 -08:00
KimLS e25fd47828 Added some other timer functions to lua, removed perl memory leak stop gap for the moment until i decide how to fix it... 2014-03-07 19:59:44 -08:00
ukmeth0d d559a9ac0d Merge branch 'master' of git://github.com/Siroro/Server 2014-03-07 09:03:07 +01:00
Michael Cook e8394c2b01 Merge pull request #130 from KayenEQ/master
SE_Root and SE_RootBreakChance updates
2014-03-07 03:00:14 -05:00
ukmeth0d 3ec1c894ee Fixed 2H Blunt Animation to match Live
Melee bots (with no mana) will now sit when not full HP and out of combat.
2014-03-07 01:34:30 +01:00
KayenEQ fb3e3c8447 fix 2014-03-06 07:52:10 -05:00
KayenEQ 496f8151c9 root related bonuses for negate effect. 2014-03-06 07:44:39 -05:00
KayenEQ 55f5d4affa SE_Root and SE_RootBreakChance updates 2014-03-06 07:36:47 -05:00
Michael Cook (mackal) d22c8832f7 Renamed optional SQL 2014-03-06 02:39:54 -05:00
Michael Cook (mackal) d8138d2c56 Merge branch 'master' of github.com:EQEmu/Server 2014-03-06 02:38:53 -05:00
Michael Cook (mackal) 6c00eb9344 Renamed optional SQL 2014-03-06 02:38:22 -05:00
sorvani b0e24b346e Fixes #119 2014-03-05 22:19:55 -06:00
Michael Cook (mackal) 822a1b1003 Fix NPC swarm pets despawning on owner death
Fix NPC swarm pets IsAttackAllowed logic
2014-03-05 23:02:57 -05:00
Michael Cook (mackal) 3d5f99e14a Merge branch 'master' of github.com:KayenEQ/Server into KayenEQ-master
Conflicts:
	changelog.txt
2014-03-05 19:49:59 -05:00
Michael Cook (mackal) 0e8f62b480 Fixes #129 - Initialize pointer to nullptr. 2014-03-05 01:52:41 -05:00
Michael Cook (mackal) d70c4d7bbe Fix rogue's evade to be single target
This is also a lot nice performance wise
2014-03-05 01:34:17 -05:00
Michael Cook (mackal) 05df6c5b21 Fix QuestManager::RemoveAllFromInstance 2014-03-05 01:09:18 -05:00
sorvani 3f6036a512 missed a couple MT_Say 2014-03-04 23:11:33 -06:00
sorvani 58f42f1af1 Created RemoveFromInstance and RemoveAllFromInstance and exported to lua_general.cpp 2014-03-04 22:39:52 -06:00
KayenEQ 0ef95d8fe6 Root rule optional SQL 2014-03-04 06:43:57 -05:00
KayenEQ ea677389ad Root spell revision
Optional SQL
2014-03-04 06:42:41 -05:00
Michael Cook (mackal) 057e4603db Optimized EntityList::AddHealAggro 2014-03-03 15:01:52 -05:00
Michael Cook (mackal) a67aed9538 Implemented deadly strikes and increase rogue throwing crit rate
New rules:
	Combat:RogueCritThrowingChance, Combat:RogueDeadlyStrikeChance, Combat:RogueDeadlyStrikeMod
Rogue throwing crit rate is rather ridiculous. These rules might need tweaking
but they gave me fairly live-like results, even with AA added
2014-03-03 14:59:39 -05:00
Michael Cook (mackal) 00068158c1 Melee Crits, HoTs, DoTs messages should now filter correctly
Clients that also support seeing others DoTs will now see them
if they don't filter them.

    Note: HoTs 'mine only' doesn't seem to be different from 'show'
2014-03-02 22:10:32 -05:00
Michael Cook 9e4cf19e0c Merge pull request #125 from KayenEQ/master
Added lower bounds for chance of charm fading.
2014-03-02 20:40:34 -05:00
KayenEQ 84c85a4605 Added lower bounds for chance of charm fading.
Parsed on live to be approximately no lower
than 5% regardless of level difference.
2014-03-02 19:44:42 -05:00
Michael Cook c02ba17845 Merge pull request #124 from KayenEQ/master
Fix for SQL
2014-03-02 17:43:33 -05:00
KayenEQ f4b30c5861 Fix for SQL 2014-03-02 17:36:18 -05:00
Michael Cook 5d9e400e86 Merge pull request #122 from KayenEQ/master
Revisions to how charm works.
2014-03-02 12:55:41 -05:00
KayenEQ 39914c8eb4 debug msg removed 2014-03-02 04:24:51 -05:00
KayenEQ 7133357b1a Revisions to how charm works.
Optional SQL for rules
2014-03-02 03:46:51 -05:00
KimLS 629f9863ae Merge branch 'master' into raycast 2014-03-01 17:49:21 -08:00
Michael Cook (mackal) be57c66256 Add FilteredMessage do nothing mob virtuals 2014-03-01 14:02:57 -05:00
Michael Cook (mackal) e0edd7a290 Added FilteredMessage functions that better use ServerFilters
These functions are currently unused, but should work nicely.
I didn't add overloads to separate them from the others for now
2014-03-01 00:16:37 -05:00
Michael Cook (mackal) d46912fcdf Fix issue with mob procing 2014-02-28 22:06:10 -05:00
Michael Cook (mackal) 5c7484cea2 Switched some heal messages to StringIDs 2014-02-28 17:43:37 -05:00
Michael Cook (mackal) d525d23217 Shielding now uses StringIDs 2014-02-28 02:57:43 -05:00
Michael Cook (mackal) c030cfe0ad Fix zone crash with TryWeaponProc 2014-02-28 02:56:36 -05:00
Michael Cook (mackal) cb633e4b6a Crit Spells to StringIDs
Some minor clean up
Fix an mlog message
2014-02-28 02:25:17 -05:00
cavedude00 16afa277de Exported TrainDisc to Lua.
Updated idle timer names.
2014-02-27 23:21:57 -08:00
Michael Cook c18e9d9503 Merge pull request #121 from Siroro/master
Added rule Merchant:EnableAltCurrencySell
2014-02-27 13:11:40 -05:00
Siroro a490b2ff22 Fixed augs having 100% proc rate 2014-02-27 12:00:06 +00:00
Siroro f32a30fb9a Merge remote-tracking branch 'remotes/Eqemu/master' 2014-02-27 11:44:52 +00:00
Siroro 0f60fb06e3 Added rule Merchant: EnableAltCurrencySell - defaults to true, allows servers to disable the ability to resell items to alternate currency merchants. 2014-02-27 09:41:57 +00:00
Michael Cook (mackal) 01bd8bd9fa Reworked Weapon Procing
Broke up the logic to be a bit easier to follow
Procs should happen in the order that they do on live
Proc rates for spell buff procs should be more consistent with live
2014-02-27 03:19:25 -05:00
Uleat 489a6ffd16 Fix for 'sqrt' failures on vs2010 clients 2014-02-26 21:27:30 -05:00
cavedude00 f89d783308 Corrected 2014_02_26_virulentvenomAA.sql 2014-02-26 18:20:16 -08:00
cavedude00 1d6bd3cc5e Better flee runspeed calculation.
Added two new NPC special_abilities, ALWAYS_FLEE and FLEE_PERCENT.
Fixed an issue where a NPC could get stuck on a single coord in a rectangular roambox.
Added mindelay to spawngroup to allow for greater control of the roambox delay. SQL is required.
2014-02-26 18:06:16 -08:00
Michael Cook ea31a29f8a Merge pull request #120 from KayenEQ/master
Spell effect addition / fixes
2014-02-26 14:15:17 -05:00
KayenEQ 205dd8a1e5 Clean up and revision of proc chance bonuses
Combat Effects and WeaponProc bonuses will no longer affect melee spell procs
2014-02-26 05:16:37 -05:00
KayenEQ 8caac162b2 Spell effect addition / fixes 2014-02-26 00:09:59 -05:00
Michael Cook (mackal) 970b30b467 Added entity_list::IsMobSpawnedByNpcTypeID
Exported to both lua and perl
2014-02-25 23:15:14 -05:00
Michael Cook 746569b471 Fix HOTs timer when they're in the song window 2014-02-24 17:25:49 -05:00
Michael Cook (mackal) 20869a0aec Mobs will now face their target they are casting on
Note: they do not switch their target, this is how live does it
2014-02-24 02:31:40 -05:00
Michael Cook (mackal) 88ec04e5ca Merge branch 'master' of github.com:EQEmu/Server 2014-02-24 01:25:03 -05:00
Michael Cook (mackal) 33a8a398fe Add SpellType_Root to EngagedCast check 2014-02-24 01:24:27 -05:00
sorvani d887c77a1b Updated GetUnusedInstanceID to not recycle instance ID's unless it has reached max (65535) 2014-02-24 00:20:18 -06:00
Michael Cook (mackal) 60c280a521 Debuff/Slow on random mob on hatelist 2014-02-24 00:43:24 -05:00
Michael Cook (mackal) 837c02ffd6 Mobs cast root on random person on hatelist 2014-02-24 00:37:38 -05:00
Michael Cook (mackal) 6b94e08404 Make the random addition to time_cancast actually useful
It was in ms so adding 0-4 ms doesn't really do much
2014-02-24 00:27:26 -05:00
Michael Cook (mackal) 1f471aa9f9 Remove dist in Mob casting AI for roots 2014-02-24 00:22:02 -05:00
KimLS 951c321ba6 Partial port of der's map rewrite, no new azone format yet but it's coming. Will convert legacy map formats on the fly atm. 2014-02-23 21:17:28 -08:00
KimLS eabea6ea16 RaycastMesh work der started I'm going to pick up... 2014-02-23 17:14:50 -08:00
SecretsOTheP 14649ce611 Exported the client object SendTargetCommand to Perl. 2014-02-23 19:48:46 -05:00
cavedude00 c6377b93d5 Merchants will now keep track of charges sold to them properly so it is no longer possible to recharge items using merchants. 2014-02-23 15:55:26 -08:00
KimLS 5a6c25887a Export of eq.clock(), os.clock() isn't a good option on unix 2014-02-22 15:26:18 -08:00
KimLS 0e44a3625c Merge branch 'master' of github.com:EQEmu/Server 2014-02-22 15:04:18 -08:00
KimLS 476dc6e783 SetDestructibleObject exported to lua 2014-02-22 15:04:01 -08:00
Michael Cook 4ad2e5f9b5 Merge pull request #118 from KayenEQ/master
Spell effects , buff table changes
2014-02-22 02:40:00 -05:00
KayenEQ 2a28e88bcf not_reflectable -> reflectable 2014-02-22 02:23:37 -05:00
KayenEQ 44c833fbe6 fixes
Re implemented deathsavechanceAA ect as ExtraDIChance
Confirmed on live that this effect persists even if caster not in zone.
2014-02-22 01:34:16 -05:00
Michael Cook 026f019f58 Changed SE_SingingSkill to SE_Amplificatoin
This effect will now stack with other singing spell/item mods
like it does on live.
2014-02-21 22:57:15 -05:00
Michael Cook (mackal) 451d422b8a Keep track of base spell id for SpellProcs/PermaProcs
This will fix numhits issue for procs from spells
2014-02-21 04:04:18 -05:00
Michael Cook (mackal) 808977f69a (Performance) Corpse drag will now fetch entity by ID 2014-02-20 01:35:59 -05:00
KayenEQ 402a10c488 change log 2014-02-20 01:05:44 -05:00
KayenEQ 0caa1fd40b new spell effects
buff struct/tables - required sql
Removed: death_save_chance and deathsave_aa_chance (no longer used)
Added: dot_rune, caston_x, caston_y, caston_z
minor fixes
2014-02-20 01:04:34 -05:00
Michael Cook (mackal) 754d70d513 Merge branch 'master' of github.com:EQEmu/Server 2014-02-19 20:37:26 -05:00
Michael Cook (mackal) eb3a11b49a NPC vs Client damage revamp
Shot list of things that changed:
AC Softcap is based on your defensive skill (the scaling factors
are based on at least previously stated dev quotes)
The over AC Softcap returns are now based on exact calculations
made with the Armor of Wisdom AA.
Shielding item bonus and Melee mitigation spell bonus (nerfs)
NPCs damage will now correctly follow the
"damage base + (damage interval * [1, 20])" formula.

These changes might seem a little weird but I didn't want to change
any of the other damage situations since they were fairly good, but
they still could use a revamp as well.

New rules:
RULE_BOOL ( Combat, OldACSoftcapRules, false) // use old softcaps
RULE_BOOL ( Combat, UseOldDamageIntervalRules, false) // use old damage formulas for everything
RULE_REAL ( Combat, WarACSoftcapReturn, 0.3448) // new AC returns
RULE_REAL ( Combat, ClrRngMnkBrdACSoftcapReturn, 0.3030)
RULE_REAL ( Combat, PalShdACSoftcapReturn, 0.3226)
RULE_REAL ( Combat, DruNecWizEncMagACSoftcapReturn, 0.2000)
RULE_REAL ( Combat, RogShmBstBerACSoftcapReturn, 0.2500)
RULE_REAL ( Combat, SoftcapFactor, 1.88)

If you want to use the old calculations only, set
Combat:OldACSoftcapRules and Combat:UseOldDamageIntervalRules to true
2014-02-19 20:29:19 -05:00
Michael Cook 916b33f714 Merge pull request #116 from KayenEQ/master
Spell Effect additions / Minor fixes
2014-02-18 23:38:03 -05:00
KayenEQ 58c5003ad5 fix 2014-02-18 23:26:09 -05:00
KayenEQ 0ca01641ff fix 2014-02-18 23:24:14 -05:00
KayenEQ 0fc7dade47 Spell Effect additions
Minor fixes
2014-02-18 21:59:33 -05:00
Michael Cook (mackal) ab4c9581ad Fix NPC rampage to be more in-line with live
New rules:
RuleI: Combat, DefaultRampageTargets
	Set to 1
	If the specatk db entry has no extra param it will use this
RuleB: Combat, RampageHitsTargets
	Defaults to false
	If true, if number hit is still less than RampageTargets, try tank

If you want the old behavior still set DefaultRampageTargets to 3 and
RampageHitsTargets to true
2014-02-18 18:22:19 -05:00
Michael Cook (mackal) 6e474f22a2 Added single target HalveAggro and DoubleAggro
Both exported to perl/lua
pass the target you wish to change their hate.
2014-02-18 16:52:51 -05:00
Michael Cook 068bd57fbc Merge pull request #115 from gpanula/patch-1
Update tblWorldServerRegistration.sql
2014-02-17 23:37:26 -05:00
gpanula d7f9cdf6b6 Update tblWorldServerRegistration.sql
login server expects a "ServerTrusted" column
2014-02-17 19:45:47 -06:00
Michael Cook (mackal) a503c1af97 Fix Mob double/triple/quad check to work if a lower one isn't set 2014-02-17 20:38:40 -05:00
Michael Cook (mackal) 53a14381ba Only build flurry attack opts on success 2014-02-17 19:38:37 -05:00
Michael Cook (mackal) 169b9161b9 Performance: Changed RampageArray to be a vector of IDs 2014-02-17 17:34:02 -05:00
Michael Cook (mackal) 85f2b46fe9 Fix mod_spell_resist to be no-op by default ... 2014-02-16 23:58:18 -05:00
SecretsOTheP 0dfa1e192d Merge branch 'master' of https://github.com/EQEmu/Server 2014-02-16 19:16:45 -05:00
SecretsOTheP 88eb0dcdfc potential crash issue involving backstab & missing primary weapons resolved. 2014-02-16 19:16:18 -05:00
Michael Cook (mackal) bb8a82030f Post-inc to pre-inc 2014-02-16 00:17:25 -05:00
Michael Cook 16a6fc7d2c Merge pull request #114 from KayenEQ/master
Numhits update, additional spell table fields utilized.
2014-02-16 00:07:24 -05:00
SecretsOTheP 1ebf88abbb Fixed a performance issue involving std::string and EQStream identification.
Fixed a denial-of-service exploit in EQStream.
2014-02-15 23:50:32 -05:00
KayenEQ 93e9f29c77 update 2014-02-15 23:25:09 -05:00
KayenEQ 1b7271359e fix for LimitCombatSkills
fix for Extended Inginuity table data
2014-02-15 22:34:48 -05:00
KayenEQ 49df0a5d33 fixes 2014-02-15 08:16:41 -05:00
SecretsOTheP 46f8723314 Fixed an order-of-operations crash within the Quest Parser classes 2014-02-14 12:30:50 -05:00
JJ 5f02de1c95 Remove db name from sql. 2014-02-13 21:14:05 -05:00
sorvani 9d938cdd58 Cleaned up GetUnusedInstanceID logic and renamed instance_lockout* tables to instance_list* 2014-02-13 11:24:54 -06:00
SecretsOTheP e5fd0f5d75 Merge branch 'master' of https://github.com/EQEmu/Server 2014-02-13 12:02:37 -05:00
SecretsOTheP a3f9d5e707 bot.cpp was missing nullptr instead of NULL, that is now fixed.
hate_list.cpp potential crash fix related to center being nullptr
2014-02-13 12:02:26 -05:00
KayenEQ 5344679c7c Fixes for numhits system
Implementation of new spell table fields
Update and further implemention of CastRestriction
2014-02-13 07:41:57 -05:00
KimLS e09adbd13d Added cmake options to alter eqstream settings if one would so wish. 2014-02-12 15:51:20 -08:00
KimLS 275f9d6aaf Changed SpecialAttacks to an array instead of a map. Basic access was causing a hotspot. Brief testing doesn't show any obvious bugs but let me know if any prop up. 2014-02-12 15:26:08 -08:00
Michael Cook 9461067fdb Merge pull request #113 from KayenEQ/master
Bot fixes
2014-02-12 02:56:02 -05:00
KayenEQ 7623770613 Bot fixes for previous update. 2014-02-11 22:47:57 -05:00
KayenEQ 584278bf20 change log change test 2014-02-11 22:34:00 -05:00
KimLS 1ec0add76f Make sure some strings coming from the client are actually null terminated. 2014-02-10 21:00:25 -08:00
sorvani 51dff22b93 fix for npcthis crash in new spawn condition case. 2014-02-10 15:13:54 -06:00
Michael Cook (mackal) c85c4a969d Fix corpse_list check in remove mob 2014-02-10 13:41:55 -05:00
Michael Cook (mackal) 6a8a6e530b Some clean up related to the entity_list changes 2014-02-10 12:16:14 -05:00
Michael Cook (mackal) ce4f4995b5 Merge with master 2014-02-10 12:04:35 -05:00
SecretsOTheP a4260e54fe Merge branch 'master' of https://github.com/EQEmu/Server 2014-02-10 10:39:48 -05:00
SecretsOTheP f074ead7f6 demonstar55's entity list changes (slightly modified) and a crash fix for the #repop command used in rapid succession. 2014-02-10 10:39:12 -05:00
sorvani b819137e35 Merge branch 'master' of https://github.com/EQEmu/Server 2014-02-10 09:24:04 -06:00
sorvani 4d653caca3 Typos in spawn condition log messages 2014-02-10 09:22:55 -06:00
SecretsOTheP 75663774fe Fix for crashes related to #repop force and not clearing quest timers, resulting in a zone crash. Quest timers are now cleared on zone repop. 2014-02-10 06:45:33 -05:00
SecretsOTheP 5ec5b398ac tasks crash fix 2014-02-09 12:05:47 -05:00
sorvani 24c70a04ca Enhanced spawn conditions with new onchange option DoRepopIfReady 2014-02-09 00:08:09 -06:00
Michael Cook a602f70bf4 Merge pull request #111 from af4t/master
Resolve SQL error on attempt to insert Consumption of the Soul values
2014-02-03 07:51:03 -08:00
af4t 5733124c40 Resolve "unknown identifiers" in Bot::GetActSpellDamage 2014-02-03 10:37:11 -05:00
af4t 5216532e96 Resolve SQL error on attempt to insert Consumption of the Soul values 2014-02-03 09:45:22 -05:00
Michael Cook c8bead6bdd Merge pull request #110 from KayenEQ/master
Revision to spell damage calculations
2014-02-02 20:54:50 -08:00
KayenEQ 72cec5608d Revision to spell damage calculations 2014-02-02 23:23:41 -05:00
KimLS 8b1262b198 Export clear_npctype_cache as both lua/perl general functions. 2014-02-01 14:55:51 -08:00
KimLS 6e0a214bcc Compiler option for playing with npctype_cache as was requested for a feature. Not entirely tested may need some work. Currently defaults to old behavior on #repop. 2014-01-31 20:38:32 -08:00
Michael Cook 1ab19920f4 Merge pull request #109 from KayenEQ/master
Hot fix for issue with numhits not fading
2014-01-28 19:29:52 -08:00
KayenEQ 751d51c4d0 Hot fix for issue with numhits not fading 2014-01-28 22:27:45 -05:00
Michael Cook (mackal) 4a54e262f6 Bash/Kick stun will respect UNSTUNABLE now 2014-01-28 22:14:31 -05:00
Michael Cook (mackal) bd0c325762 Revamped Kick/Bash stun a little
Before bash/kick's ability to stun was completely useless
at higher levels, it also never stunned for any duration.

Bash/Kick will always stun if the target is under the
base immunity level (kick the attacker needs to be over 55 as well)

If over base immunity, there is a chance to stun, defaults to
Combat:NPCBashKickStunChance  (15%)

A Kick/Bash stun will last for 0-2 seconds
2014-01-28 17:14:27 -05:00
Michael Cook (mackal) de55f99174 Send the stun effect that goes around their head 2014-01-28 00:42:48 -05:00
Michael Cook 044cf8da1a Fix aaid for new req SQL 2014-01-27 20:55:11 -05:00
Michael Cook aa57642103 Merge pull request #108 from KayenEQ/master
New spell effects
2014-01-27 17:54:32 -08:00
KayenEQ d98ed8f419 New spell effects 2014-01-27 05:17:52 -05:00
Michael Cook (mackal) 4b07f4ffc5 Use the first overwritten buff slot like live does
Very minor change, but some people can be rather anal
about their buff orders, so this should help them out,
and its more live like :P
2014-01-26 13:38:12 -05:00
Michael Cook 5a526a89aa Merge pull request #107 from KayenEQ/master
Revised how dispel works.
2014-01-26 10:00:19 -08:00
KayenEQ 3dbf863255 Revised how dispel works. 2014-01-26 04:41:45 -05:00
Michael Cook (mackal) 17f0cffca6 Do not trip hacker detection if target is on their XTargets 2014-01-24 18:48:47 -05:00
Michael Cook (mackal) d51e60cf8b Mostly cosmetic changes to CheckAggroAmount funcs
Also changed some silliness
2014-01-24 15:28:54 -05:00
Michael Cook (mackal) 85d6db1de1 Switched some things to StringID defines 2014-01-24 02:05:26 -05:00
Michael Cook (mackal) 1bf794c29f Create hate on immune to fear due to level 2014-01-24 01:28:09 -05:00
Michael Cook (mackal) 0e8f7a4542 Correct Fear level immunity message 2014-01-24 01:26:47 -05:00
Michael Cook (mackal) b72fe81e28 Correct CheckAggroAmount calls in IsImmumeToSpell 2014-01-24 01:24:08 -05:00
Michael Cook a76889959f Merge pull request #106 from KayenEQ/master
Minor fix to numhits update / + new spell effect
2014-01-23 18:51:09 -08:00
KayenEQ 0166486e07 Minor fix to numhits update
New spell effect
2014-01-23 21:34:47 -05:00
Michael Cook (mackal) bb793e5582 Moved Assisting Exemption check up
This is just so assisting to a client will clear the flag
2014-01-22 01:41:26 -05:00
Michael Cook (mackal) a55c095d1b Forgot to make m_AssistExemption default to 0 2014-01-22 01:08:42 -05:00
Michael Cook (mackal) 3d47d912fd Fix /assist to only care about range to assistee 2014-01-22 01:00:48 -05:00
Michael Cook (mackal) cc02d94bdf Implemented ST_TargetAETap 2014-01-21 14:50:22 -05:00
Michael Cook 5121cc25a4 Merge pull request #105 from KayenEQ/master
Numhits system revised
2014-01-20 19:03:05 -08:00
KayenEQ e78d91104c Removal of test msg 2014-01-20 21:46:13 -05:00
KayenEQ 38c5c79218 Numhits system revised 2014-01-20 21:27:53 -05:00
Michael Cook (mackal) b065f973c4 Updated changelog.txt 2014-01-20 16:26:51 -05:00
Michael Cook (mackal) 13609c4f09 Move Mez Mastery to DB 2014-01-20 16:24:17 -05:00
Michael Cook (mackal) a93116aa19 Merge branch 'master' of github.com:EQEmu/Server 2014-01-20 15:58:39 -05:00
Michael Cook (mackal) 95a5c7d4cc Move Spell Casting Reinforcement to aa_effects 2014-01-20 15:57:44 -05:00
cavedude00 5d0136a4b6 Merge branch 'master' of https://github.com/EQEmu/Server 2014-01-20 10:58:33 -08:00
cavedude00 2c74b4f1ac Forgot changelog.txt in previous commit. 2014-01-20 10:58:08 -08:00
Michael Cook (mackal) 6bb8d87225 Fix name of SQL file 2014-01-20 13:55:52 -05:00
Michael Cook (mackal) 935ce8f968 Implement not_extendable spell field 2014-01-20 13:34:18 -05:00
cavedude00 70f994cda5 Live-Like weather. Big thanks to Robregen for figuring out the system!
Included in the required SQL is weather data pulled from NewZone live packets for up to PoP. An update to EQExtractor will be made to grab the rest of the data from existing collects.

Please note: Until weather data is grabbed for zones later than PoP, weather will not work in those zones.
2014-01-20 10:10:39 -08:00
Michael Cook (mackal) 3970bb5955 Export death event variables to Perl (Kingly Krab)
http://www.eqemulator.org/forums/showpost.php?p=227770&postcount=9
2014-01-20 02:01:52 -05:00
Michael Cook (mackal) 3159453e75 Fix OP_MobEnduranceUpdate for UF 2014-01-19 16:18:38 -05:00
Michael Cook (mackal) a1cb8d7ae7 Turn on NPC charm casting 2014-01-19 00:45:50 -05:00
sorvani 4191c195c1 added GetCharactersInInstance 2014-01-18 23:34:16 -06:00
Michael Cook (mackal) b16ce6f809 Tweaked down SE_CurrentHP aggro from buffs 2014-01-17 22:09:41 -05:00
KimLS 88ba962a4c Merge branch 'master' of github.com:EQEmu/Server 2014-01-16 13:08:24 -08:00
KimLS 0315d15ce8 Reversed event_command return value, may cause visual issues if you already updated your code but easy to fix. Return 1 instead of return 0 on event_command dispatch 2014-01-16 13:08:04 -08:00
Michael Cook (mackal) 12681f4623 Improve feign_memory_list thanks to C++11 2014-01-15 21:06:18 -05:00
Michael Cook (mackal) a7a4f9373d Revert change to SE_LimitEffect
Also fix for SE_SummonItem for unstackable charged items
(Still need to verify on live though)
2014-01-15 17:10:15 -05:00
Michael Cook (mackal) d2e66214f4 Add numhitstype to the spell structure 2014-01-15 01:19:03 -05:00
Michael Cook (mackal) 0a6d98b5e1 Fix mod rods 2014-01-14 22:24:01 -05:00
Michael Cook 497c10e513 Updated URL 2014-01-14 15:16:29 -05:00
Michael Cook (mackal) 53765ebc62 Fix some potential null pointer dereferences
I don't think there were any instances of these causing problems
but it's better to be safe than sorry.
2014-01-14 02:38:49 -05:00
Michael Cook (mackal) 4216627604 Prefer prefix ++/-- on non-primitive types
Postfix ++/-- might cause the creation of a tmp instance
that might be optimized out. Mights are bad. Prefix doesn't
have this problem.
2014-01-13 22:14:02 -05:00
Michael Cook 47c33f3b31 Merge pull request #104 from KayenEQ/master
Spell effect updates
2014-01-13 10:35:15 -08:00
KayenEQ 32359da1cc Spell effect updates 2014-01-13 05:03:21 -05:00
Michael Cook (mackal) f4e085c121 Some clean up in questmgr.cpp 2014-01-12 21:26:31 -05:00
KimLS 7972937072 /MP now set by default on windows. Option to turn it off for people who want/need eg: people with slower lower core systems. 2014-01-12 14:54:58 -08:00
Michael Cook (mackal) 5a6f2467f8 Added fclose to ExportBaseData 2014-01-12 00:58:47 -05:00
Michael Cook (mackal) 1822347a46 Add lua_say_link overloads 2014-01-11 15:07:11 -05:00
Michael Cook (mackal) 821ba8b701 Change faction messages to use String IDs. 2014-01-11 13:20:01 -05:00
Michael Cook (mackal) fdced53be1 Add pet size preservation like live
Run the SQL!!
2014-01-09 14:25:29 -05:00
Michael Cook (mackal) a394bf25b2 SE_SummonItem and SE_SummonItemIntoBag should work like live now
This isn't exactly like live since they seem to use something
else to decide how many to summon, but this should act the same
as live currently does.
2014-01-08 16:11:29 -05:00
Michael Cook (mackal) f2c1c9f70e Added required SQL for previous changes 2014-01-08 14:06:39 -05:00
Michael Cook (mackal) 5199364091 Make use of the suspendable spell flag 2014-01-08 00:24:33 -05:00
Michael Cook (mackal) 50caef0086 Implement persist death spell field 2014-01-07 23:29:46 -05:00
Michael Cook 8a04d8e2b7 Moved pet target checking to the attack command, which is more live like
Also, probably a little better than attacking then backing off :P
2014-01-07 17:02:35 -05:00
Michael Cook (mackal) e7032bc2c2 Implemented SE_SongModCap
Bard AAs Ayonaes Tutelage and Echo of Taelosia implemented as bonuses
Remember to run the SQL!
2014-01-04 19:20:59 -05:00
Michael Cook (mackal) d128ef1b97 Forgot an unknown 2014-01-04 14:54:18 -05:00
Michael Cook (mackal) 0645908762 Renamed all Unknown Spell Effects based on live
Note: These are all still commented out and I did not check for
any collisions. Feel free to rename these as they're implemented
2014-01-04 14:42:13 -05:00
Michael Cook (mackal) abbd0558a0 Added links to full spell effect list from a dev 2014-01-04 13:41:41 -05:00
KimLS c725ee84bb Fix for a potential buffer overflow on login server under very rare circumstances via Rogean. Fix for perl parser not clearing errors via sorvani 2014-01-03 23:41:11 -08:00
Michael Cook (mackal) a9b4e7819f Add some overflow protection for emotes
Clients crash if the emote is too large, despite the client
using a 1024 char buffer...
2014-01-04 01:34:58 -05:00
Michael Cook (mackal) ae68deb4f8 Added overload to Lua entity list RemoveFromTargets 2014-01-03 19:20:52 -05:00
Michael Cook (mackal) e4108d089f Fix missing paren. 2014-01-02 18:19:59 -05:00
Michael Cook (mackal) 4d9d50c9ac Fix stuns from beneficial spells (ex. Harvest) 2014-01-02 03:08:59 -05:00
KimLS b727cbbfe9 Luabind updated to be able to be compiled with Lua 5.2. Didn't really test it with 5.2 though since I'm still on 5.1. In theory it should work now though. 2013-12-28 18:19:12 -08:00
Alex 864338a881 Merge pull request #102 from nhaggmark/FixLoH
LoH and Harm Touch Fix
2013-12-27 21:19:54 -08:00
Nicholas Haggmark 6dc444d2d1 Committing update to zone/client_packet.pp which fixes a bug with Lay
on Hands and Harm Touch. Basically what is happening is that because
LoH and Harm Touch come in on spell slot 9 (ABILITY_SLOT), and because
ABILITY_SLOT is handled in the same block of code as standard memorized
spells, it was failing the MAX_PP_MEMSPELL check and always getting
silently interrupted. I broke DISCIPLINE_SLOT and ABILITY_SLOT processing
out into separate blocks which not only resolves this problem, but also
cleans up that processing a little bit.
2013-12-27 22:28:54 -05:00
Michael Cook (mackal) 13fcccefd5 Added support for merchant item filtering by class
Added column classes_required to merchantlist to allow
the merchant to only sell items to specified classes

Ex. (only example I know from live) To only allow poison supplies
to be sell able to only rogues, you would set classes_required
to 256.
classes_required defaults to 65535 (all/any class)

Remember to run the new SQL!
2013-12-26 16:29:09 -05:00
KimLS 30e8eac46e Hopefully this is a fix for issue #100 -- Uninitialized alt currency variable causing db corruption. 2013-12-24 13:21:11 -08:00
KimLS 646e1f541c Added lua export for Client:PlayMP3 2013-12-24 00:27:57 -08:00
SecretsOTheP a7c15ef598 Secrets: Added functionality to Perl/Server for $client->PlayMP3("name of file"). 2013-12-24 01:28:32 -05:00
SecretsOTheP bddb03ba3b Akkadius: Perl $client->SilentMessage("Message"); addition, this is a pre-req for a Perl plugin I've shared with EQEmu. This function essentially mimics a player speaking with an NPC - which is used in popup window responses 2013-12-24 01:09:35 -05:00
KimLS 2ac1f37b02 More work on Client Marquee messages. 2013-12-23 17:35:58 -08:00
KimLS a96f10b6aa More work on OP_Marquee. Should be enough to implement a function with it. Anyone wants to fiddle around with the unknowns and get them better documented they are free to. 2013-12-23 15:42:13 -08:00
KimLS ccf6b5ff68 Added prelim work on OP_Marquee incase anyone else wants to also have a go at it. Packet and opcode for SoD client figured out partially. 2013-12-22 22:37:41 -08:00
Michael Cook (mackal) 0d661204ed Fix MakeRandomInt for flurry and extraattack 2013-12-20 18:45:33 -05:00
Michael Cook (mackal) b0e50f13c9 Switched some stuff that made sense to Mob::InFrontMob 2013-12-20 18:43:52 -05:00
Michael Cook (mackal) d3ad253b51 Switched bard check in auto attack to IsBardSong 2013-12-20 18:43:16 -05:00
Michael Cook (mackal) 5ac23a2f8f Added facing check to auto attack LoS code
The Mob::InFrontMob check uses 56 degrees which is where the
client will generate the "You cannon see your target." message.
There were still a few weird angles that I was able to still
attack, but in like 99% of the cases it should work ...
2013-12-20 17:47:28 -05:00
JJ 9fff694382 Update per discussion on bfb17a2fb5 2013-12-19 19:39:34 -05:00
JJ 4512326fe8 Merge pull request #98 from KayenEQ/fixes
Spell effect additions... (will update further per notes)
2013-12-19 16:30:11 -08:00
KayenEQ bfb17a2fb5 Kayen: Implemented SE_ArcheryDoubleAttack (Chance to do an extra archery attack)
Kayen: Implemented SE_ShieldEquipDmgMod (Increase damage in primary hand if shield equiped)
Kayen: Implemented SE_ShieldEquipHateMod (Increase hate generated if shield equiped)
Kayen: Implemented SE_TriggerOnAmountValue (Trigger spell if HP/Mana/End bellow X value or num pet on target)
2013-12-17 21:51:13 -05:00
Michael Cook 53c124526c Merge pull request #97 from KayenEQ/fixes
Fix SE_BlockNextSpellFocus
2013-12-15 23:17:21 -08:00
KayenEQ 8007097aae Kayen: Fix to SE_BlockNextSpellFocus to make it functional again. 2013-12-16 00:53:00 -05:00
Michael Cook (mackal) 32e5ed5ad8 Merge branch 'master' of github.com:KayenEQ/Server into KayenEQ-master
Conflicts:
	changelog.txt
2013-12-15 23:51:21 -05:00
Michael Cook 65afbd4147 Moved BlockedBuffs check down for spell effects 2013-12-15 18:44:45 -05:00
Michael Cook 81e04ee185 Fix some indentation 2013-12-15 03:21:57 -05:00
KayenEQ 52722dc0c8 Kayen: Implemented SE_ReduceHealing (Reduces amount of healing on target by X amount)
Kayen: Implemented SE_CastonFocusEffect (Triggers spell as part of a focus, when that focus effect is used)
Kayen: Implemented SE_IncreaseHitDmgTaken (Effect is triggered when X amount of damage is taken)
Kayen: More fixes for various spell triggers/procs to now properly use their resist modifier.
2013-12-15 03:15:39 -05:00
Michael Cook b9c270fab6 Merge branch 'master' of github.com:EQEmu/Server
Conflicts:
	changelog.txt
2013-12-14 16:44:04 -05:00
Michael Cook 48db481fbb Fix blocked buffs from failing
When a buff is blocked it should just fail to be applied
instead of interrupting. Mana should also be eaten.
2013-12-14 16:42:12 -05:00
JJ 37cacd27b1 Changed enable/disable recipe to confirm change made. 2013-12-14 09:55:46 -05:00
Alex 466f541798 Merge pull request #95 from KayenEQ/master
Spell Effect fixes and additions
2013-12-13 20:48:24 -08:00
KayenEQ 9781af5696 Merge branch 'master' of github.com:KayenEQ/Server
Conflicts:
	changelog.txt
2013-12-13 22:47:04 -05:00
KayenEQ f6d5e8031f Kayen: Implemented additional functionality for SE_CurrentHP utilizing base2 values. (ie limit to body type)
Kayen: Implemented SE_MitigateMeleeDamageSP (Partial Melee Rune that only is lowered if melee hits are over X amount of damage)
Kayen: Implemented SE_SpellOnAmtDmgTaken (Effect is triggered when X amount of damage is taken)
Kayen: Fix for various spell triggers/procs to now properly use their resist modifier.
Kayen: Fix to mob->ModSkillDmgTaken(skill_num, value), setting value to -1 will now properly effect all skills.
2013-12-13 21:29:35 -05:00
Michael Cook c70ea4a621 Fix haste caps
Before these were mostly guess work, now based on what clients report
since they do their own calculations so are most likely correct.
2013-12-11 15:44:59 -05:00
Michael Cook 76ec6e4da2 Fixed crippling blow issues with berserker frenzy
Also added two rules to control when to enter/exit berserker frenzy
2013-12-11 01:49:51 -05:00
Michael Cook (mackal) cd2825288d Fix issue with SpellType_Charm case in AICastSpell 2013-12-04 00:52:12 -05:00
Michael Cook d95fdda30f Fix procing off of unattackable things
This /might/ be a little restrictive, but it should prevent easy
farming of bone chips from Boneshear etc
2013-12-03 16:12:13 -05:00
Michael Cook 4fdcf604f2 Added #showspellslist command to show us a mob's spells 2013-12-03 15:57:50 -05:00
JJ 02c9007765 Bandaid fix to CopyCharacter function. 2013-12-02 22:20:46 -05:00
Michael Cook 0f54830bc5 Stacking issues should be resolved now
I have a feeling this could be slightly better, but it works correctly.
2013-11-29 18:32:30 -05:00
Michael Cook d329fe0c12 Revert "Fixed issue with SE_StackingCommand_Overwrite"
This reverts commit a7ce852ca5.
2013-11-29 15:35:51 -05:00
Michael Cook a7ce852ca5 Fixed issue with SE_StackingCommand_Overwrite
SE_StackingCommand_Overwite uses the calc to figure out the slot to check.
Seems that calc 202 is slot 1 and 201 is actually something special. It
could be any slot, but need further investigation, for now, just ignore it.
2013-11-27 16:05:09 -05:00
Michael Cook b4fce37c14 Quick fix to issue with self buffs
casting_spell_targetid isn't guaranteed to be correct at that point in the code
Quick fix for now
2013-11-27 14:38:03 -05:00
SecretsOTheP 51181c8c8b AA fixes for PEQ's reported crash 2013-11-23 21:42:22 -05:00
KimLS 1c07ae9172 Fix for non-standard eqemu options in cmake, please don't do this in the future. Thank you. 2013-11-23 17:26:41 -08:00
SecretsOTheP 2f8cbb3a9d Fixes to the following crashes seen on PEQ:
http://www.peqtgc.com/phpBB3/viewtopic.php?f=1&t=14293&p=67404#p67404
http://www.peqtgc.com/phpBB3/viewtopic.php?f=1&t=14293&p=67105#p67105
2013-11-22 15:32:02 -05:00
Alex 093af6af0b Merge pull request #92 from clucksoft/master
suspend/ban kick fix
2013-11-20 02:36:27 -08:00
Michael Cook 0567073ca0 Quick fix for dot issue introduced in 765b5ee8
This could probably be done better
2013-11-19 18:34:20 -05:00
Michael Cook e33eb9d7b0 Partially implement dot_stacking_exempt
When it is 1 the spell will block it from other casters
Not 100% sure on when it's -1 so not currently used
2013-11-19 17:43:40 -05:00
clucksoft fd10ddf86d suspend/ban kick fix 2013-11-19 12:48:59 -08:00
SecretsOTheP edd4d47929 Merge branch 'master' of https://github.com/EQEmu/Server 2013-11-19 09:58:18 -05:00
SecretsOTheP f31b9ad98b Made the variable for disabling the logging system always default to ON instead of OFF. Changed the wording so it's less confusing.
This means that the debug logging information will not display at all by default, but the GM command logging will display enabled. If you need to diagnose the logs, simply turn them on at the expense of added CPU/Disk I/O
2013-11-19 09:57:52 -05:00
Michael Cook (mackal) 10ee3ea346 Fixed shared memory read me 2013-11-19 00:09:41 -05:00
Michael Cook (mackal) 62b7eda9e9 Added read me to shared_memory 2013-11-19 00:08:22 -05:00
SecretsOTheP 8b7984cf7d Merge branch 'master' of https://github.com/EQEmu/Server 2013-11-18 23:56:11 -05:00
SecretsOTheP 4a0e07a54c Fixes to actually use the cmake defs added in the previous revision 2013-11-18 23:54:24 -05:00
SecretsOTheP 6e520c8476 Added options to CMake to disable GM command logging or disable logging entirely while keeping GM commands enabled.
Cleaned up some logging
2013-11-18 23:49:12 -05:00
Michael Cook (mackal) 917a8ed389 Fix some errors in comments 2013-11-18 16:21:10 -05:00
Sorvani 86bba4ff0e changed aggro_range to leach_range and tether_range appropriately 2013-11-18 13:53:21 -06:00
Michael Cook (mackal) 300799fdc8 Added npc_types.assistradius, defaults to npc_types.aggroradius if set to 0 2013-11-18 12:44:39 -05:00
Sorvani 65e36e02fb fixed leash and tether to correctly used specified range. 2013-11-17 20:55:44 -06:00
Michael Cook 09dd3c1b37 Fixed an issue that arose from 78ab3471
Reworked how Mob::_GetMovementSpeed worked to fix an issue of walking
with a sufficiently high movemod.

Added a rule Character:BaseRunSpeedCap (default 158) to control the
cap on runspeed from buffs. Hardcapped to 225 for sanity's sake.
2013-11-17 19:37:49 -05:00
Michael Cook (mackal) 36233538fd Some whitespace fixes in zone/spells.cpp 2013-11-17 00:34:58 -05:00
Michael Cook 3d5b3d1e8c Added Mob::DoCastingChecks() which checks for various casting fail conditions while casting 2013-11-17 00:31:17 -05:00
Michael Cook 3c2ae8250f Merge pull request #91 from Leere/drink_message
Fix for auto-consume drinking message
2013-11-15 19:23:02 -08:00
Leere 6a95abb01f Fix for auto-consume drinking message 2013-11-16 03:40:35 +01:00
JJ 4c6fce5d5c Add a little more debug info to MQGate hack detection. 2013-11-15 19:31:43 -05:00
Michael Cook 08b5225a13 Merge pull request #90 from Leere/stacking_issue
Fix for a stacking issue with SE_StackingCommand_Block for druid skins
2013-11-15 13:15:53 -08:00
Leere 765b5ee826 Fix for a stacking issue with SE_StackingCommand_Block for druid skins 2013-11-15 18:03:13 +01:00
Michael Cook a40a34d2e8 Fixed Mob::CalcFocusEffect()'s SE_LimitEffect 2013-11-15 01:17:27 -05:00
Michael Cook (mackal) 983ee2d39b Merge branch 'master' of github.com:EQEmu/Server 2013-11-14 20:28:01 -05:00
Michael Cook (mackal) e1255af708 Fix Spell level restrictions
I made an incorrect assumption, fixed now
2013-11-14 20:26:58 -05:00
JJ b99d476754 Change INSERT to REPLACE 2013-11-13 21:59:38 -05:00
Michael Cook 23ab896dfc Fix last commit .... 2013-11-13 18:04:11 -05:00
Michael Cook d094a09ded Implemented Singing/Instrument Mastery as an AA bonus
Don't forget to source the SQL file!
2013-11-13 18:03:08 -05:00
Michael Cook 3f8ee533d3 Implement bard song instrument mod caps
The maximum bard songs can be effected by instrument mods is 3.6.
This is set by the rule Character:BaseInstrumentSoftCap which defaults to 36
Also fix Echo of Taelosia and Ayonae's Tutelage to increase the mod cap.
2013-11-13 15:07:34 -05:00
Michael Cook 0c3c84d711 Merge branch 'master' of github.com:EQEmu/Server 2013-11-12 22:32:44 -05:00
Michael Cook 79c53a41a8 Add some sanity for bard songs in snares ... 2013-11-12 22:32:03 -05:00
cavedude00 2ffa13c993 Compile fix. 2013-11-12 16:08:31 -08:00
Ludwig 8af48bbe48 Merge pull request #89 from httm/master
Update exp.cpp
2013-11-12 15:22:47 -08:00
httm 65c0772d37 Update exp.cpp
Replaced elseif statements in group experience calculation with single if statement for calculation when membercount between 2 and 5
2013-11-12 18:06:24 -05:00
Michael Cook 78ab347171 Fix walk speed calculation
Walk speed should be calculated as a movement speed reduction that
stacks with snares so it's possible to snare a mob FD and have it
not be able to walk back.
2013-11-11 23:55:43 -05:00
Michael Cook d83b94d231 Revert "Fixed non-attacking related movement while mobs are snared"
Did some testing, this isn't exactly the case on live.

This reverts commit ed6c46f7ff.
2013-11-11 21:06:48 -05:00
Michael Cook (mackal) ed6c46f7ff Fixed non-attacking related movement while mobs are snared
On live a nec/shd normal splitting involved snaring the mob you want
and FDing after they moved enough. The non-snared mobs would return home
and the snared mob would just sit there until it was no longer snared.
There is even a nice flash video! http://www.dzert.com/downloads/eq/fd02.swf
This might need some tweaking, but I'm not sure of any instances where it would
break things...
2013-11-11 18:18:12 -05:00
Michael Cook (mackal) 925e19b15c Fix database scheme comments that got clobbered on nullptr conversion 2013-11-11 15:37:20 -05:00
Michael Cook 2be71fc2ec Cleaned up common/spdat.cpp
There was a lot of stuff that I found that the level of readability.
I cleaned up a lot of the stuff, no functionality should be changed
unless where noted below.

* IsPartialDeathSaveSpell is now generic and no longer uses a hardcoded spell id
* IsFullDeathSaveSpell is now generic and no longer uses a hardcoded spell id

If these functions were actually used in the spell effects it would probably
fix issues with newer spells (which there are on live)
2013-11-10 21:37:01 -05:00
Ludwig bc2ee8dce8 Merge pull request #88 from Leere/bardmana_fix
Fix for bard mana regen
2013-11-09 11:20:44 -08:00
Leere 1deef77f07 Fix for bard mana regen 2013-11-09 19:36:32 +01:00
KimLS e00c57bc47 Fix to changelog conflict in merge. 2013-11-07 12:44:13 -08:00
JJ da3ba12560 Fix for #npcedit qglobal 2013-11-06 21:12:57 -05:00
KimLS f68b89b7d9 Prerelease commit 2013-11-06 13:48:35 -08:00
KimLS c944aafb39 Merge branch 'master' into base_data 2013-11-06 13:18:20 -08:00
KimLS 0e6c9820cd Importing client files works now 2013-11-06 13:17:44 -08:00
JJ b8d1838dcc Added in-game commands to enable/disable tradeskill recipes
-Commands: #enablerecipe recipe_id, #disablerecipe recipe_id
-Perl: quest::enablerecipe(recipe_id), quest::disablerecipe(recipe_id)
-Lua: eq.enable_recipe(recipe_id), eq.disable_recipe(recipe_id)
2013-11-01 23:55:17 -04:00
JJ aba535b589 Merge pull request #87 from Leere/recipe_disable
Add the ability to disable a tradeskill recipe
2013-11-01 08:33:13 -07:00
Leere cf117b1a4d Add the ability to disable a tradeskill recipe 2013-10-31 17:58:44 +01:00
Uleat 1bae570b68 Merge pull request #86 from EQEmu/uleat_cleanup_1
Uleat cleanup 1 - Note: The player profile blob struct code has been changed, but it does not affect the actual database blob size or alignment. That said, it probably wouldn't be a bad idea to backup at least the character_ table.
2013-10-30 14:39:26 -07:00
Uleat 1f0e263b6e Fix for compile failure in deity.h - Thanks V! (I should write a book on gcc:vs differences..I have found almost all of them...) 2013-10-30 03:49:32 -04:00
Uleat 08706055af Final prep for extending skill use range - client patch and database are ready..just need the code in-between 2013-10-28 13:06:49 -04:00
Uleat 28bcf074fc Client patch prep work for extending usable skill range 2013-10-28 05:00:49 -04:00
Uleat 1c8aaf97bc Changelog entry clarification..did not explain the issue clearly... 2013-10-27 13:41:39 -04:00
Uleat a891597f4c Prepped the client patch files for larger skill buffer size (not active) 2013-10-27 13:30:45 -04:00
Uleat e3805d5920 Converted SkillType typedef enumeration to SkillUseTypes enumeration 2013-10-27 13:03:41 -04:00
Uleat 3e6be197e6 Changed ItemTypes to ItemUseTypes 2013-10-27 09:04:52 -04:00
Uleat 0d5fc26841 Converted MATERIAL defines to MaterialUseSlots enumeration 2013-10-27 08:01:37 -04:00
Uleat df47e17c8e Changed ItemClass enumeration to ItemClassTypes enumeration 2013-10-27 06:38:34 -04:00
Uleat e53fa1d873 Changed ItemUseType enumeration to ItemInstTypes enumeration - naming conflicted with definition 2013-10-27 05:45:52 -04:00
Uleat d5152a0e59 Moved and expanded Deity-related code 2013-10-27 05:08:53 -04:00
Uleat 78e04dee99 Enforced naming standard on my recent changes 2013-10-27 04:17:08 -04:00
Uleat b3d117f8c1 Improper skill in use allowing riposte fix (Archery and Throwing allowing riposte check..no known bug reports) 2013-10-27 03:25:27 -04:00
Uleat cab77e83da High level debug (12) compile failure fix - I searched for as many as I could find with GrepWin, so there may be a few out there still 2013-10-27 03:13:10 -04:00
Michael Cook b4068823ed Merge pull request #85 from vexyl/fix1
Fix for healing unconscious players.
2013-10-26 14:13:00 -07:00
vexyl a694cf3079 Fix for healing unconscious players. 2013-10-26 13:46:03 -07:00
Michael Cook 3c09613d01 Changed the MT_Shout to MT_SpellFailure in Mob::SpellOnTarget 2013-10-24 17:38:46 -04:00
Michael Cook 36d336e69c Fix some memory leaks in Mob::SpellOnTarget
This should fix the memory leak introduced in the last commit and
a few lingering memory leaks, don't think they should break anything
2013-10-24 17:35:21 -04:00
KimLS 4270d77692 Merge branch 'master' into base_data 2013-10-21 16:42:32 -07:00
KimLS ec6c5519a5 More work on importing... I need my escape stuff from other branch for this though 2013-10-21 16:41:34 -07:00
Michael Cook a06fe1d02e Implemented buff level restrictions
Higher level buffs can't be cast on lower level toons.
The formula was based on information found here: http://samanna.net/eq.general/buffs.shtml
This behavior is controlled by the rule Spells:BuffLevelRestrictions which defaults to true.
2013-10-21 19:13:55 -04:00
Michael Cook 56ba87577b GetMinLevel will now return 0 for more cases
For some reason EQ uses 127 (melee classes), 254 (some AAs), and 255
in the class level for spells a class doesn't have
2013-10-21 19:10:01 -04:00
KimLS cdb29be4f3 Merge branch 'master' into base_data 2013-10-18 21:44:18 -07:00
KimLS 4ef9732e37 Compile fix 2013-10-18 21:43:47 -07:00
KimLS f2f4e55818 Import/Export util start 2013-10-18 21:23:45 -07:00
Uleat 403ac53a9e Renamed/expanded 'BagTypes' enumeration 2013-10-18 20:33:41 -04:00
KimLS cdcda943be Base data for hp/mana/end calcs, mostly but not completely correct 2013-10-18 00:09:00 -07:00
KimLS 2c25241763 Fix for lua say links, other branch taking longer than thought so making this its own commit 2013-10-16 15:47:08 -07:00
Sorvani 17729365db Merge pull request #84 from clucksoft/master
Update to spell timers fix
2013-10-13 09:34:04 -07:00
clucksoft 5d5dc1b544 update to spell fix 2013-10-11 22:54:35 -07:00
badcaptain 244c7e019c Changed dates due to time of commit. 2013-10-12 00:52:02 -04:00
badcaptain a7fea4fc69 Merge branch 'master' of https://github.com/EQEmu/Server 2013-10-12 00:47:55 -04:00
badcaptain 809925dc3e Bots- added out of combat bard songs & #bot bardoutofcombat on|off command to turn them on/off. 2013-10-12 00:47:15 -04:00
Michael Cook 98c835e470 Fix Titanium clients from not being able to start in Tutorial zone. 2013-10-12 00:29:44 -04:00
badcaptain 8ac4845930 Merge branch 'master' of https://github.com/EQEmu/Server
Initial check-in of bard bot in combat song code.
2013-10-11 23:43:38 -04:00
badcaptain 765f23febc Initial check-in of bard bot in combat song code. 2013-10-11 23:37:46 -04:00
badcaptain f1b70b3340 Fix Merc crash bugs. 2013-10-11 23:27:55 -04:00
JJ 549dfc9781 Allow use of Go Home button when Tutorial still selected in RoF. 2013-10-11 22:40:49 -04:00
Michael Cook 2019379a42 bool* foo = false should probably be an error, GCC 4.8+ at least warns about it, clang I think fails on it. 2013-10-11 00:00:21 -04:00
Michael Cook 15335509c2 Merge branch 'master' of github.com:EQEmu/Server
Conflicts:
	changelog.txt
2013-10-10 23:45:15 -04:00
Michael Cook da401acdb2 Fix mana and timer being used on single target buffs failing
Single target buffs shouldn't have their mana consumed or their
reuse timers set if they fail the Mob::SpellOnTarget call in
Mob::SpellFinished. Ex. Night's Dark Terror not taking hold
(no free slots) or Target running out of range.
Debuffs do not get this nice behavior.
2013-10-10 23:17:02 -04:00
JJ 8327f22f6f Revert change to EnterWorldPacket introduced on 22 April 2013 to fix inability to enter Tutorial or Go Home from character select screen. 2013-10-10 22:38:23 -04:00
SecretsOTheP 6154cfce99 Fixed zone shutdown (or #reloadqst) reinitalization of Perl. This should allow for Perl 5.14 and later to work on Windows under the new quest system. 2013-10-10 05:15:38 -07:00
Michael Cook c13c039721 Merge pull request #83 from AMDmi3/patch-1
Simplify conditional linking with libdl
2013-10-09 08:33:27 -07:00
Dmitry Marakasov 7ee417ab05 Simplify conditional linking with libdl 2013-10-09 19:27:52 +04:00
Michael Cook 3a95f81196 Fixed more instances of AA timers being eaten
Every time I touch zone/AA.cpp to fix timers it gets uglier.
This should fix the bug reported here: http://www.peqtgc.com/phpBB3/viewtopic.php?f=17&t=14125
It should also fix AAs not being reset when it when you have no buff slots free (confirmed on live)
2013-10-09 02:00:49 -04:00
Michael Cook 9a19a00bdc Added IsBuffSpell(spell_id). This will return true if the spell would end up having a duration, which will mean it would end up in one of the many buff windows on the client. This just makes sure the spell has a buffduration or buffdurationformula, which means the calculation will return a duration
Replaced all instances of CalcBuffDuration being used to determine if a spell was a buff with IsBuffSpell
Removed Mob::HasBuffIcon since it does the same thing IsBuffSpell does in a more convoluted way and had a rather missing leading name
Fixed issues that arose from the 10/03/2013 changes
2013-10-08 17:24:07 -04:00
Sorvani 24308aec6c fixed issue with stackable items summoning with 0 charges 2013-10-05 21:55:21 -05:00
Michael Cook 6b4b259753 Fix when the random +1 tick is added to nerf extension focus effects to where they should be 2013-10-03 23:04:58 -04:00
Alex bf77bc47d1 Merge pull request #81 from vexyl/master
Fix for segfault in Database::CheckStatus() when using MariaDB.
2013-10-02 21:19:59 -07:00
Michael Cook 2bde0b40bb Fixed issue with #showstats window, should probably be refactored to completely use stringstream or to_string whenever VS2010 support is dropped 2013-09-30 22:17:34 -04:00
Sorvani 478f7b8e49 Changed SummonItem to no longer recharge 0 charge items 2013-09-30 20:57:12 -05:00
Vexyl f289dffc48 Fix for segfault in Database::CheckStatus() when using MariaDB. 2013-09-28 10:38:50 -07:00
Michael Cook (mackal) d119ed058b Add /pet hold on and /pet hold off support for UF/RoF 2013-09-13 15:20:45 -04:00
KimLS fdb6f0fe84 Fix for training skill bailout when you can train the skill but not at the current level. 2013-08-29 15:52:17 -07:00
KimLS bef02b3511 Merge branch 'master' of https://github.com/EQEmu/Server 2013-08-29 15:46:56 -07:00
KimLS fcd9b525a8 Removed Common Profiler and Zone Profiler. They're well past outdated status and are just code bloat. 2013-08-29 15:46:40 -07:00
Uleat 590d8f4043 Fix for bot pet spell buff corruption 2013-08-20 20:55:19 -04:00
KimLS 406e2f84eb Fix for special atk sql missing a type.
Fix for a crash in quest manager setanim.
Fix for pfs_list not compiling on x64 windows.
2013-08-10 14:17:06 -07:00
josheb 926e2f7939 Merge pull request #80 from josheb/master
Fixed a regression with level 10 and 20 hit caps.
Added rules for aggro and hunger as well as script commands for manipulating hunger.
2013-08-06 14:55:25 -07:00
Tabasco b92a009539 Fixed some lua stuff I bork. 2013-08-01 19:37:16 -05:00
Tabasco cfab1c4649 Removed redundant Innate Metabolism checks. 2013-08-01 19:34:27 -05:00
Tabasco fc03ee94e2 Added rules for what int mobs need to not attack red cons and how much food and drink is taken per stamina update.
Added mod hooks for food/drink values and mob aggro.
Added quest functions for getting/setting hunger and thirst.
2013-08-01 19:24:15 -05:00
Tabasco 936c8cce4b Fixed a regression with level 10 and 20 hit caps. 2013-08-01 14:41:27 -05:00
KimLS 1f2145a45d Fix for special_abilities crash dealing with std::string in struct that was then memcpyed 2013-07-18 00:24:43 -07:00
Uleat 2331678312 fix for tortoisegit commit and overlay issues in dependencies/.gitignore 2013-07-15 23:22:17 -04:00
Sorvani c216ece72c fir for lua get_spawn_condition 2013-07-15 00:35:46 -05:00
KimLS 36e12110d5 Memset SpecialAbility before putting it into map. 2013-07-14 14:47:22 -07:00
KimLS aa5ac1518b Changelog for lua_packet 2013-07-13 14:03:55 -07:00
KimLS d472c05f5d Lua packet handler dispatch 2013-07-13 13:53:41 -07:00
KimLS 485fc2b2b7 Fix for bot compile 2013-07-13 13:53:13 -07:00
KimLS bdc83f4f37 Basic lua packet api, and it works too. Exciting I must say. 2013-07-12 22:21:43 -07:00
KimLS da178c9fba Compile error in AA.cpp 2013-07-12 18:57:49 -07:00
KimLS a1dc390f49 Windows compile error again, why wasn't this fixed on the second pass. I brought it up last time grr 2013-07-12 15:01:12 -07:00
Alex dfe63f87c3 Merge pull request #78 from j883376/cleanups
Code cleanups, take two
2013-07-12 13:36:02 -07:00
KimLS 239d4afb13 NPC Special Attacks should all work right: also huge explanation in changelog.txt 2013-07-11 13:44:45 -07:00
KimLS ab2c184b54 Merge branch 'master' of https://github.com/EQEmu/Server 2013-07-10 14:33:06 -07:00
j883376 31ede315f2 Fix Database::GetZoneID() 2013-07-08 19:02:54 -04:00
KimLS 3992ac02bb Rampage, Area Rampage, Flurry got new customizable effects. Part of that was adding a new set of stuff to attack. 2013-07-08 14:37:01 -07:00
SecretsOTheP e6ad26f03c Logfile cleanups. See changelog.txt. 2013-07-07 21:44:31 -07:00
KimLS 2f335372a0 Few warning and lua fixes, fix for summon not working on new system. Need to look at enrage as it doesn't appear to work right either and think it's timing related 2013-07-07 15:22:20 -07:00
KimLS 63d678ce29 Replaced npcspecialatk with special_attacks, needs more testing also gotta export new api for it as I can't remove the legacy one. Too many quests rely on the legacy functionality. 2013-07-06 03:45:06 -07:00
KimLS 0c675c33e2 Changelog too 2013-07-05 13:25:19 -07:00
KimLS 3c8d83f2a8 Perl will now capture return values (lua style), yeah I said I wouldn't be improving much of perl from here on but I said if I found a way I'd do it. 2013-07-05 02:56:53 -07:00
KimLS b11ed32bcf Removed quest queue from perl parser, should do events properly recursively 2013-07-05 01:46:24 -07:00
KimLS 9a63ee65c9 Added functions to eq to get the internals of the current quest_manager quest, also bug fix to a lua client function 2013-07-05 00:33:45 -07:00
KimLS 8b8742b242 Fix for Spell(int) not working in lua... 2013-07-03 15:20:42 -07:00
KimLS bccbc0f064 Merge branch 'master' of https://github.com/EQEmu/Server 2013-07-02 14:20:04 -07:00
KimLS b7fcd5b02a eq.follow() and eq.stop_follow() 2013-07-02 14:16:16 -07:00
Alex 56b9dda60b Update README.md 2013-07-01 14:12:31 -07:00
KimLS 1868d0e7a3 Lua changelog entry 2013-07-01 14:06:20 -07:00
KimLS 38b3433406 Merge branch 'master' into lua 2013-07-01 13:32:47 -07:00
Michael Cook 6d21823959 Prevent Monster Summoning from summoning a portal in bothunder 2013-07-01 16:03:04 -04:00
Michael Cook 02eb56a696 Fix Monster Summoning related to giants/cyclops 2013-07-01 15:22:07 -04:00
KimLS 6fe5c06fa0 Fix for trade being retained on logout/zone 2013-06-29 12:18:40 -07:00
KimLS 2c68e813e9 More selective filtering of lua libs, seed random set for lua interpreter, Release Canidate 2013-06-29 01:43:56 -07:00
KimLS e42c7a38a5 eq.attack_npc(npc_id) and eq.attack_npc_type(npc_type) added. 2013-06-28 16:43:57 -07:00
KimLS 7b5b1b2583 Added eq.attack(client_name) to lua. 2013-06-28 16:30:27 -07:00
j883376 0578f45490 Revert "Revert "Merge pull request #77 from j883376/cleanups""
This reverts commit d25205d9d3.
2013-06-28 04:25:44 -04:00
KimLS f46f7bd528 event_death_complete 2013-06-27 15:07:28 -07:00
KimLS 945cc2117f Fix for perl not loading events if they're chained, fix for items not being removed from inventory at an intuitive time in event_trade 2013-06-27 14:14:10 -07:00
KimLS a5db4310c6 Merge branch 'master' into lua
Conflicts:
	zone/merc.cpp
2013-06-27 12:53:47 -07:00
KimLS d25205d9d3 Revert "Merge pull request #77 from j883376/cleanups"
This reverts commit 4ff2efea43, reversing
changes made to e811e3975b.
2013-06-27 12:50:20 -07:00
KimLS d12c700bbf missing lua mob function 2013-06-26 22:23:31 -07:00
KimLS db70ad37dd Fix for quest::depop and quest::respawn not functioning 2013-06-26 15:43:55 -07:00
KimLS 9e1115f899 Merge master, pretty close to RC atm 2013-06-26 12:52:00 -07:00
Alex 82f4b4ee53 Merge pull request #76 from Zaela/respawn
RespawnFromHover scriptable framework
2013-06-26 10:13:56 -07:00
Alex 4ff2efea43 Merge pull request #77 from j883376/cleanups
Various code cleanups
2013-06-26 10:06:07 -07:00
KimLS d2a3c051e5 Added custom find lua cmake module to make building on windows easier 2013-06-26 09:57:06 -07:00
KimLS 16d3825df4 Fixed translocate, dispatch event now returns values properly, embparser now stores errors (what few it has) 2013-06-26 09:26:19 -07:00
KimLS 602b17f0e8 Fix for msvc compile, lua_bit.cpp wont try to compile if lua isn't set to build 2013-06-26 08:05:36 -07:00
j883376 488b2888a8 Fix uses of uninitialized variables
- Replace unknown008 array with two separate variables in Object code

- Fix mismatched safe_delete() of an array
2013-06-25 23:40:05 -04:00
KimLS 1480b8911f Sorta hacky work around for doing nukeitem in item quests. Added lua bitop library. Made excluding io/os optional 2013-06-25 14:51:06 -07:00
Zaela 72ef7f6557 Made default-on-error a little less bad. 2013-06-25 11:05:03 -07:00
Zaela f35afed89a one eof newline 2013-06-25 10:45:07 -07:00
KimLS ffe6494147 Forgot a semicolon in an important spot. 2013-06-24 13:00:50 -07:00
KimLS 342a4c1b17 Fix for clickies not working, changed order of dispatch events to allow nuking items from regular item events. Changed the lua modules path. 2013-06-24 12:42:42 -07:00
KimLS b904689a98 Added Spawn object to lua and functions to manipulate them 2013-06-23 14:48:36 -07:00
KimLS 0dc66b3dd7 Added quest areas (only accessable in lua) which work similar to proximities except are not attached to any one npc. Also fixed up the proximity code a bit to comply and got rid of my stupid ass fix for the deleting lists thing 2013-06-22 20:47:11 -07:00
KimLS bb1282de30 encounter events can now watch all events by all npcs/items/quests by registering themselves to watch -1, fix #74 2013-06-22 14:23:07 -07:00
Zaela c5e4cf35c0 Reworked RespawnFromHover framework to allow future customization (scripting) of respawn options.
Added event_respawn to be triggered when a client respawns from hover into the current zone (may not be set up correctly!).
2013-06-22 08:35:33 -07:00
KimLS 2529a7700e Fix for luabind not compiling (jumbers), bunch of api upgrades for lua, changed where spells and items load quests from, removed some old code. etc etc. 2013-06-22 01:32:41 -07:00
j883376 7e2806119b Fix some improper uses of printf formats 2013-06-22 00:55:54 -04:00
j883376 536e31d771 Change binary output path to use CMake variable
Tools that use CMake's EXECUTABLE_OUTPUT_PATH variable to
determine which binary to launch for debugging may be confused
by a relative path, so use CMake variable PROJECT_BINARY_DIR
instead.
2013-06-21 23:21:57 -04:00
j883376 2a39449f6e Fix exit code values
- Change all exit codes to match the standard of 0 for success
and 1 for error

- Add empty shared folder to utils/defaults for shared_memory
2013-06-21 22:54:28 -04:00
KimLS 7af04798fb Augment item events 2013-06-21 14:20:30 -07:00
j883376 76e25f75fa Fix a few memory leaks
- Rewrite zonename_array to use std::map rather than a pointer to an array
of character pointers

- Properly delete ZoneConfig on Zone shutdown

- Delete AdventureTemplates in AdventureManager destructor
2013-06-21 17:09:46 -04:00
KimLS 7b894a7c61 Added direct inventory access, and event_loot for items and event_weapon_proc for items 2013-06-20 14:03:22 -07:00
KimLS d8a1d84a49 Regression fixes, support for new lua arguments for many events 2013-06-19 22:56:46 -07:00
KimLS bb8d11a57b Merge from master 2013-06-17 11:47:45 -07:00
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 c0d37b2e04 Many fixes to regressions in perl and cleaning up the final interface 2013-06-12 15:04:26 -07:00
KimLS 0dbd0478c0 Merge of hatebourne's stuff 2013-06-12 12:11:56 -07:00
KimLS 56b41c882b Redoing event item api 2013-06-07 02:26:17 -07:00
KimLS 8c3cce822a Added three new events 2013-06-06 14:29:45 -07:00
KimLS b87d4a3e5f Removed perl stuff from mod stuff 2013-06-05 17:00:59 -07:00
KimLS cec60feba9 Merge master 2013-06-05 16:58:11 -07:00
Alex 29c0c4801c Merge pull request #70 from josheb/master
Mod functions updates and fixes
2013-06-05 16:54:36 -07:00
KimLS a3738dc131 Changed EVENT_TRADE to pass iteminst instead of variable ids, perl will not have changed at all but lua now passes the iteminsts in the trade object. Also redid a bunch of the spell quest stuff 2013-06-05 16:47:49 -07:00
KimLS 6d0c0aee7d Last work to make lua parser feature complete, time to start fixing bugs and cleaning up design and maybe adding some features here and there. 2013-06-04 23:22:03 -07:00
KimLS 1b290b577d Fix for potential nullptr when using base lua class constructors in debug mode, also added eq.get_qglobals and removed automatic export of them (will do this for a lot of other automatic exports) 2013-06-04 16:48:32 -07:00
KimLS 85c7e1b059 Player event export plus lua_object api 2013-06-03 16:49:47 -07:00
root a8de7e9ffc Removed comments from mod_client.cpp for erroneous 255 stat cap. 2013-06-03 17:08:58 -05:00
KimLS bc82bff4b4 Lua doors api 2013-06-03 00:08:41 -07:00
Tabasco ff091e940c Lua corpse API 2013-06-02 19:05:40 -05:00
KimLS 55a964267e Raid/Group lua stuff, renamed corpses 2013-06-02 13:47:52 -07:00
KimLS d14608356d Added all lua objects i need for now, a ton of API too 2013-06-02 00:15:26 -07: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
KimLS a1080fdb2d Merge branch 'master' into lua 2013-05-31 16:41:44 -07:00
KimLS 344feb7484 Finished exporting lua general functions for now, also had to fix some const char* stuff 2013-05-31 16:40:55 -07: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
KimLS 69f1187722 Small amount of general lua functions 2013-05-28 13:12:42 -07: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
KimLS 49c3a81e18 More lua work, client should be completely exported barring any more bugs that crop up. Starting work on getting the rest of the general functions 2013-05-27 17:24:31 -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
KimLS 1e7c5bb9b7 Bug fix in event_trade export, exported augments too. Also need to fix overloads 2013-05-26 15:56:55 -07:00
KimLS 850fa5aecc Exported client functions to lua, going to work on npc next 2013-05-26 12:44:33 -07:00
KimLS 79a9d2112a Retransmit support added back in (stupid compile flags), prelim work on lua_client stuff, took out a few redundant or non-working functions 2013-05-25 01:08:30 -07:00
KimLS d25d8187b6 Failed merge on a specific file also fix for std and string changes in my embparser 2013-05-24 01:41:33 -07:00
KimLS e47de5deed Merge with master 2013-05-24 01:23:58 -07: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
KimLS a3e24b6854 Merge from master 2013-05-23 12:50:34 -07: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 ce63503bab Changed a bunch of lua stuff, as well as modified a bunch of generic item quest stuff 2013-05-23 12:43:21 -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
KimLS 1363d5d209 Lua fixes, need to get perl working again D= 2013-05-19 23:39:18 -07: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
KimLS 69bad31019 Cleanup of some lua code, initial work on encounter_quests 2013-05-19 12:13:44 -07:00
KimLS 17954dd8fe Exported a ton of functions to mob 2013-05-18 14:42:54 -07:00
Tabasco 7b21e3be72 Added server man quest events and command parsing. 2013-05-18 11:21:19 -05:00
KimLS 7adcf6d3e5 Some quest item and spell work, took out that stupid multiquesting code -> use your brains that's completely doable entirely in quests even perl 2013-05-17 17:10:38 -07:00
KimLS bec6acc01e Hatelist will now use a std::list so i can avoid a list copy when exporting it to quests. Cause frankly two copies was absurd 2013-05-17 10:48:59 -07: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
KimLS 1f265af1e7 Hate list stuff, need to make it more efficient 2013-05-17 09:49:02 -07:00
KimLS 3ddc61420b Added id to spells so i can export them to lua correctly. Also made the lua_classes less messy by having them all derive from Lua_Ptr instead of reimplementing functionality 2013-05-16 23:24:47 -07:00
KimLS b10de6f4e7 More work on lua parser - gonna get all events firing correctly by end of week also put all arguments into an event table object 2013-05-16 15:35:55 -07:00
Kemmler 7185ff25be Merge pull request #4 from EQEmu/master
Sync 2013-05-16
2013-05-16 05:11:13 -07:00
KimLS f2e0f9cca5 Changed a bunch of event names, made event_death returning more seamless and fixed up trading quests to have them always face target outside the parser 2013-05-15 18:43:06 -07:00
josheb 55c66022eb Merge pull request #6 from EQEmu/master
sync
2013-05-15 17:00:08 -07:00
KimLS b26df187e6 Merge from master terrible 2013-05-15 16:01:13 -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
KimLS 6887ae18ae Merge branch 'master' into lua 2013-05-15 13:07:30 -07:00
KimLS 2336aa0e4f Changed quests/templates to quests/global. Changed default location for plugins to quests/plugins instead of quests. Added a single interpreter for lua instead of multiple ones. 2013-05-15 13:00:46 -07:00
KimLS 3cc1065873 more lua, gonna work on single interpreter soon 2013-05-14 19:05:49 -07:00
KimLS 38521e0009 Lua - basic npc quests work and i need a damned break for a bit 2013-05-13 21:56:42 -07:00
KimLS 20fc585b5e Cleaned up lua glue macro a bit 2013-05-13 14:40:15 -07:00
KimLS 7b23c8dc75 Working on last of Mob:: that can be implemented atm, added safety checks to the lua functions that will be optional later in dev mode. Also changed quest return types to integers instead of doubles as that was non-intuitive 2013-05-13 14:29:50 -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
KimLS 2445576ae8 Merge branch 'master' into lua 2013-05-11 20:35:49 -07:00
KimLS 7648f071f1 More lua work - more mob implementation 2013-05-11 20:34:04 -07:00
KimLS 60c93595f5 Missed a file save 2013-05-11 16:39:22 -07:00
KimLS 70998d25e3 More lua work - changed how i get return values off the stack and do calls 2013-05-11 16:37:03 -07:00
KimLS fa908040ca Lua work on api - entity and mob, lots more to go 2013-05-11 13:51:57 -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
KimLS d1f7935ee2 ...trying out boost with luabind 2013-05-11 01:29:58 -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
KimLS dc045591e4 Lua work - loading works, I think checking for sub works. Calling subs is in the beginning stages and binding is starting 2013-05-10 20:13:35 -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
KimLS 43d0350870 Cleanup perl parsers 2013-05-09 21:25:50 -07: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
KimLS 0e4ac63b6b Perl parser works, still needs a little cleanup 2013-05-09 14:52:20 -07: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 b6c0e7c302 perl changes 2013-05-09 03:22:56 -07:00
KimLS bdcb9d0c00 Merge branch 'master' into lua 2013-05-08 21:04:02 -07:00
KimLS 7a93966158 VS2012 fix + return 0 fix 2013-05-08 21:03:35 -07:00
KimLS b8adbee4ee Parser stuff, fix for GetSpawnKillCount + item_tick 2013-05-08 21:01:15 -07:00
KimLS feae79b417 Merge from master 2013-05-08 20:22:40 -07:00
KimLS bcf9546b2d Partial perl parser rewrite, want to make it cleaner and have it match the interface 2013-05-08 20:18:39 -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
KimLS ac1d931b5e Merge from master 2013-05-06 00:05:50 -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
KimLS 6e9e81a890 Working on fixing up QuestInterface to make multiple parsers work together in harmony, need to fix up Embperl parser next 2013-05-05 23:36:15 -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
1169 changed files with 168304 additions and 70996 deletions
+264 -96
View File
@@ -15,96 +15,215 @@ PROJECT(EQEmu)
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles
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)
#Add our various windows definitions
IF(MSVC OR MINGW)
ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64)
ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64)
ENDIF(MSVC OR MINGW)
IF(MSVC)
#Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
ELSE(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
ENDIF(CMAKE_CL_64)
#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)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT)
#Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x64")
ELSE(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x86")
ENDIF(CMAKE_CL_64)
#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)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast)
ENDIF(EQEMU_FAST_FLOATINGPOINT)
#crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH)
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_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /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_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_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_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_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH)
#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)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var)
#crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH)
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_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /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_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_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_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_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH)
OPTION(EQEMU_BUILD_MSVC_MP "Enable build with multiple processes." TRUE)
IF(EQEMU_BUILD_MSVC_MP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF(EQEMU_BUILD_MSVC_MP)
#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)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var)
ADD_DEFINITIONS(-DNOMINMAX)
ELSE(MSVC)
#Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
#Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC)
#FreeBSD support
IF(UNIX)
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
ADD_DEFINITIONS(-DFREEBSD)
SET(FREEBSD TRUE)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
ADD_DEFINITIONS(-DDARWIN)
SET(DARWIN TRUE)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
ENDIF(UNIX)
#use stdint.h types if they exist for this platform (we have to guess otherwise)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
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:
0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status
4 - Moderate debug release errors and status
5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see"
0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status
4 - Moderate debug release errors and status
5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see"
)
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_STATUS EQEMU_LOG_LEVEL_NORMAL EQEMU_LOG_LEVEL_ERROR EQEMU_LOG_LEVEL_DEBUG EQEMU_LOG_LEVEL_QUEST EQEMU_LOG_LEVEL_COMMANDS EQEMU_LOG_LEVEL_CRASH)
SET(EQEMU_STREAM_SEND_RATE 1048576 CACHE STRING "Advanced: Base amount of data stream can send before throttle.")
SET(EQEMU_STREAM_DECAY_RATE 78642 CACHE STRING "Advanced: Base amount of data stream recovers per tic.")
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL 3.0 CACHE STRING "Advanced: Multiplier on retransmit timeout.")
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX 5000 CACHE STRING "Advanced: Max in ms for retransmit timeout timer.")
SET(EQEMU_STREAM_AVERAGE_DELTA_MAX 2500 CACHE STRING "Advanced: The maximum average delta in ms allowed.")
SET(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS TRUE CACHE BOOL "Advanced: Whether or not acked packets can be retransmitted")
MARK_AS_ADVANCED(EQEMU_STREAM_SEND_RATE EQEMU_STREAM_DECAY_RATE EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX EQEMU_STREAM_AVERAGE_DELTA_MAX EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
#NPC Types Cache Behavior
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
#Bots are a compile time option so on/off
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
#Disable entire _mlog system (excludes trade/command logs)
OPTION(EQEMU_DISABLE_LOGSYS "Disable Logging INI System" ON)
#Enable GM Command log system
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
IF(EQEMU_COMMANDS_LOGGING)
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING)
IF(EQEMU_DISABLE_LOGSYS)
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
ENDIF(EQEMU_DISABLE_LOGSYS)
IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS)
ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS)
#What to build
@@ -112,53 +231,102 @@ OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
OPTION(EQEMU_BUILD_AZONE "Build azone utility." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
OPTION(EQEMU_BUILD_LUA "Build Lua parser." OFF)
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Inport/Export Data Programs." ON)
IF(UNIX)
#Whether to build cleanipc or not (probably a good idea if you build server)
OPTION(EQEMU_BUILD_CLEANIPC "Build cleanipc." ON)
#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)
#C++11 stuff
IF(NOT MSVC)
ADD_DEFINITIONS(-std=c++0x)
ENDIF(NOT MSVC)
#Various definitions
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL)
IF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DLUA_EQEMU)
ENDIF(EQEMU_BUILD_LUA)
SET(EQEMU_MAP_DIR "./Maps" CACHE STRING "The dir that maps, water maps, and paths are located in.")
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DSHAREMEM)
ADD_DEFINITIONS(-DINVERSEXY)
ADD_DEFINITIONS(-DFIELD_ITEMS)
ADD_DEFINITIONS(-DMAP_DIR="./Maps")
ADD_DEFINITIONS(-DMAP_DIR="${EQEMU_MAP_DIR}")
ADD_DEFINITIONS(-DRATEBASE=${EQEMU_STREAM_SEND_RATE})
ADD_DEFINITIONS(-DDECAYBASE=${EQEMU_STREAM_DECAY_RATE})
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MULT=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL})
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MAX=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX})
ADD_DEFINITIONS(-DAVERAGE_DELTA_MAX=${EQEMU_STREAM_AVERAGE_DELTA_MAX})
ADD_DEFINITIONS(-DLOG_LEVEL_STATUS=${EQEMU_LOG_LEVEL_STATUS})
ADD_DEFINITIONS(-DLOG_LEVEL_NORMAL=${EQEMU_LOG_LEVEL_NORMAL})
ADD_DEFINITIONS(-DLOG_LEVEL_ERROR=${EQEMU_LOG_LEVEL_ERROR})
ADD_DEFINITIONS(-DLOG_LEVEL_DEBUG=${EQEMU_LOG_LEVEL_DEBUG})
ADD_DEFINITIONS(-DLOG_LEVEL_QUEST=${EQEMU_LOG_LEVEL_QUEST})
ADD_DEFINITIONS(-DLOG_LEVEL_COMMANDS=${EQEMU_LOG_LEVEL_COMMANDS})
ADD_DEFINITIONS(-DLOG_LEVEL_CRASH=${EQEMU_LOG_LEVEL_CRASH})
IF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=true)
ELSE(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=false)
ENDIF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
#Find everything we need
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(MySQL REQUIRED)
FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${PERL_INCLUDE_PATH}" "${MySQL_INCLUDE_DIR}")
IF(EQEMU_BUILD_PERL)
FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL)
IF(EQEMU_BUILD_LUA)
FIND_PACKAGE(EQLua51 REQUIRED)
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
SET(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/boost")
FIND_PACKAGE(Boost REQUIRED)
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}" "luabind")
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
IF(EQEMU_SANITIZE_LUA_LIBS)
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
ENDIF(EQEMU_BUILD_LUA)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/common/glm/glm")
IF(EQEMU_BUILD_LUA)
ADD_SUBDIRECTORY(luabind)
ENDIF(EQEMU_BUILD_LUA)
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(common)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(EMuShareMem)
ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch)
ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER)
IF(EQEMU_BUILD_LOGIN)
ADD_SUBDIRECTORY(loginserver)
ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN)
IF(EQEMU_BUILD_AZONE OR EQEMU_BUILD_CLEANIPC)
ADD_SUBDIRECTORY(utils)
ENDIF(EQEMU_BUILD_AZONE OR EQEMU_BUILD_CLEANIPC)
IF(EQEMU_BUILD_AZONE)
ADD_SUBDIRECTORY(utils)
ENDIF(EQEMU_BUILD_AZONE)
IF(EQEMU_BUILD_TESTS)
# Testing framework not quite ready for prime time.
# ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tests)
ENDIF(EQEMU_BUILD_TESTS)
IF(EQEMU_BUILD_CLIENT_FILES)
ADD_SUBDIRECTORY(client_files)
ENDIF(EQEMU_BUILD_CLIENT_FILES)
-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:
@@ -8,3 +8,5 @@ StackWalker - New BSD License
ZLib - ZLib License
MySQL - GPL
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
Dependencies can be obtained at http://eqemu.github.io
More Information: https://github.com/EQEmu/Server/wiki
+850
View File
@@ -1,5 +1,855 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 06/13/2014 ==
Kayen: For table 'npc_spell_effects_entries' setting se_max for damage shield effects (59) will now determine the DS Type (ie burning)
Setting se_max to 1 for SkillDamageTaken effects (127) will allow for stackable mitigation/weakness same as quest function ModSkillDmgTaken.
Kayen: Implemented SE_AlterNPCLevel (not currently used on live). Will +/- to NPC level. When fade will revert back to original level.
Kayen: Implemented 'special_abilities' 38 ALLOW_BENEFICIAL (Allows an NPC to recieve player buffs/heals)
Kayen: Implemented 'special_abilities' 39 DISABLE_MELEE (Prevents NPC from auto attacking, will still aggro)
Note: These two special abilities were previously implemented and still remain as quest functions. (SetDisableMelee() and SetAllowBeneficial())
== 06/8/2014 ==
KLS: Changed lua API: eq.get_globals(client, npc) has been removed. Use eq.get_globals(npc, client) instead.
There's a bug with something in gcc 4.6.3 (maybe other versions) on x86 that this is attempting to combat.
== 05/17/2014 ==
Secrets: Identified the opcode/struct for guild ranks in Rain of Fear+ clients.
Secrets: Implemented a work-around for Rain of Fear clients to have all guild permissions until proper database support is added for newer ranks.
== 05/14/2014 ==
Kayen: Rooted NPC's will no longer target players with Divine Aura effect if they are the closest target and other targets exist on the hate list.
== 05/12/2014 ==
Uleat: Re-arranged functions in Item.cpp to somewhat match the order they are declared in Item.h. Should make finding their location a little easier when using declarations as a guide. (This will facilitate readability of an upcoming change...)
== 05/07/2014 ==
Kayen: AA/Item/Spells that allow pets to critical and flurry will now work on the owners swarm pets consistent with live.
== 05/05/2014 ==
Uleat: Oops! Wrong state check (conn_state != client_state)
Uleat: Test fix to eliminate seemingly random crashes when an AE spell is being used. (Possible access to uninstantiated pointers during client connection process when someone casts a beneficial AE spell within range of a connecting client.)
== 04/29/2014 ==
KLS: Implemented new map code based on some of Derision's earlier work. Old maps still work with this system and don't need to be regenerated. We're still working on a new azone solution for better/more efficient maps.
== 04/27/2014 ==
Kayen: Implemented new table 'npc_spells_effects' and 'npc_spells_effects_entires'.
Implemented new field in 'npc_spell_effects_id' in npc_types.
These are used to directly apply spell effect bonuses to NPC's without requirings spells/buffs.
Example: Allow an npc to spawn with an innate 50 pt damage shield and a 5% chance to critical hit.
Please see the wiki page: http://wiki.eqemulator.org/p?npc_spell_effects_entries for details.
*NPC's can now do critical heals / damage spells if bonus is applied from table.
Required SQL: utils/sql/git/required/2014_04_27_AISpellEffects.sql
Note: 30 examples of spell effects have been included by default in this sql. Edited/removed as needed.
== 04/25/2014 ==
cavedude: Corrected a crash in spawn_conditions caused by NPCs on a one way path.
cavedude: Added strict column to spawn_events which will prevent an event from enabling if it's mid-cycle.
cavedude: Prevented disabled or strict spawn_events from enabling when the zone first boots.
cavedude: Fixed the quest function toggle_spawn_event under Perl.
If you're using the quest function toggle_spawn_event (worked on Lua only) it has changed syntax to:
toggle_spawn_event(int event_id, bool enable, bool strict, bool reset_base)
Required SQL: utils/sql/git/required/2014_04_25_spawn_events.sql
== 04/23/2014 ==
Kayen: Improved SE_LimitCombatSkills will now more accurately determine if a spell is a combat proc.
Kayen: SE_LimitInstant will now also work when set to include instant spells.
Optional SQL: utils/sql/git/optional/2014_04_23_FocusComabtProcs.sql
Note: Set to false, if enabled will allow all combat procs to receive spell focuses.
== 04/21/2014 ==
Secrets: Crash fix for more hatelist crashes.
Secrets: Hate list fixes, again.
Secrets: Revert of hatelist changes.
== 04/20/2014 ==
Secrets: Changed the functionality of EQDEBUG cmake flag. It now suppresses logs, but shows crashes in any scenario when set to 1. It will also now show crashes even if the log system is disabled.
KLS: Change to how quest signals work, signals with no delay will now be added to the signal queue. This addresses an odd timing issue where NPCs are in a state of life/death flux when a signal from event_death goes off.
KLS: Added cmake flags to define how logging behavior works for each different log type.
Secrets: Crash fix for Hatelist crash observed
== 04/18/2014 ==
Akkadius: Added #command error message suppression for those who don't want to see 'Command is not recognized' constantly
- You need to have rule 'Chat:SuppressCommandErrors' set to true, this is set to false by default
- Required SQL: 2014_04_18_Suppress_Command_Error.sql
== 04/15/2014 ==
Akkadius: Exported $client->SendMarqueeMessage(type, priority, fade_in, fade_out, duration, msg) - Will be available for simple plugin use
Akkadius: Exported $client->ExpeditionMessage(THIS, ExpdID, Message) - In use with custom expedition mod that will be released soon
== 04/12/2014 ==
Kayen: Fixed an with the slow mitigation code that would cause it to spam the message. Optimized the way the variable is handled for slow mitigation.
Required SQL: utils/sql/git/required/2014_04_12_SlowMitigation.sql
Note: This changes the variable type in the sql table from FLOAT to INT and updates your database.
(When setting slow mitigation 50 = 50%, 100 = 100% ect. You can also set > 100 which will cause slow to become haste now with appropriate in game msg given)
== 04/10/2014 ==
Kayen: Added 'no_target_hotkey' field to npc_types table. This will prevent the NPC from being targeted with F8 (Warning: Will also turn it's name YELLOW)
Kayen: Added a rule to make all (Player cast) Swarm Pets not targetable with F8 (nearest NPC) by default (Warning: Will also turn pets names YELLOW). This is semi-hack but it works.
Kayen: Player cast swarm pets can now be healed and buffed consistent with live.
Optional SQL: utils/sql/git/optional/2014_04_10_SwarmPetNotTargetableWithHotKey.sql
Required SQL: utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql
Note: For the required new npc_types field you DO NOT need to set values for swarm pets if you enable the above rule.
== 04/09/2014 ==
Kayen: Implemented ability to use the actual live spell projectile graphics that are defined in the modern spell file.
*This is disabled by default. Recommend enabling if your server uses an UF+ spell file AND most of your players use UF+ clients.
Kayen: Expanded the PERL ProjectileAnim(mob, item_id, [IsArrow?, speed, angle, tilt, arc, IDFile]) so you can now just set the weapon model graphic IT####
Example: ProjectileAnim($npc, 0, 0, 1, 0, 0, 0, "IT10747") This will shoot an SK 2.0 sword.
Kayen: Updated wizard innate critical damage modifier to be from 20-70% of base damage (based on live parses)
Optional SQL: utils/sql/git/optional/2014_04_09_SpellProjectileRule.sql
Note: This sql also contains a query to check if your spell file is compatible.
== 04/06/2014 ==
Uleat: Changed Mob::CanThisClassDualWield() behavior. This should let non-monk/beastlord dual-wielding classes attack with either fist as long as the other hand is occupied.
Notes:
See this thread for more information and to provide feedback: http://www.eqemulator.org/forums/showthread.php?p=229328#post229328
== 04/05/2014 ==
Akkadius: Fix for the Fix for the Fix: Rule Combat:OneProcPerWeapon was created so that you can revert to the original proc functionality
for custom servers that have balanced their content around having more than 1 aug proc on weapons. By having this rule set to 'false' you revert this functionality.
This rule is set to 'true' by default as the original functionality from Live was intended to be
Akkadius: (Performance Adjustment) Removed AsyncLoadVariables from InterserverTimer.Check() in both zone and world. By watching the MySQL general.log file on mass zone idle activity, you can
see that the query 'SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= timestamp' is called every 10 seconds. This function is loading
variables that are initially loaded on World and Zone bootup. When running a large amount of zone servers, the amount of MySQL chatter that is produced is enormous and
unnecessary. For example, if I ran 400 zone servers, I would see 3,456,000 unnecessary queries from all idle or active zone processes in a 24 hour interval.
Secrets: Added a rule to enable multiple procs from the same weapon's other slots if a proc is deemed to trigger, Defaults to true.
If Combat:OneProcPerWeapon is not enabled, we reset the try for that weapon regardless of if we procced or not.
This is for some servers that may want to have as many procs triggering from weapons as possible in a single round.
Optional SQL: utils/sql/git/optional/2014_04_05_ProcRules.sql
== 04/04/2014 ==
Kayen: Implemented 'Physical Resists' (Resist Type 9) to be consistent with live based on extensive parsing.
SQL will add new field to npc_types 'PhR' and fill in database with values consistent with observations.
Required SQL: utils/sql/git/optional/2014_04_04_PhysicalResists.sql
== 04/03/2014 ==
Kayen: Implemented live like spell projectiles (ie. Mage Bolts).
Optional SQL: utils/sql/git/optional/2014_04_03_SpellProjectileRules.sql
Note: The rules in this SQL are for setting the item id for the graphic used by the projectile on different clients.
== 04/01/2014 ==
demonstar55: Implemented ability for a merchant to open and close shop.
Lua quest functions: e.self:MerchantOpenShop() and e.self:MerchantCloseShop()
GM Commands: #merchant_open_shop (short: #open_shop) and #merchant_close_shop (short: #close_shop)
default to status 100, just in case you need to force the merchants status
Trevius: Fixed potential endless quest loop with EVENT_COMBAT and WipeHateList().
== 03/31/2014 ==
Uleat: Fix for unconscious skillups.
Uleat: Fix for crash issue with nullptr reference in recent Client::SummonItem() work.
Uleat: Added rule for GM Status check code in Client::SummonItem().
Note: Rule default is set to 250..but, implementation is on hold until load item code handles the database 'minstatus' field.
Uleat: Added RuleB(Bots, BotLevelsWithOwner). Bots will auto-update as their owner levels/de-levels. Appearance packets are sent to show the 'leveling effect' as well as updating client entities.
Trevius: Prevented an endless loop crash related to EVENT_TASK_STAGE_COMPLETE.
Optional Bot SQL: utils/sql/git/bot/optional/2014_03_31_BotLevelsWithOwnerRule.sql
Note: This sql is required to activate the optional behavior.
== 03/27/2014 ==
Kayen: SE_Gate will now use have a fail chance as defined by its base value in the spell data.
Kayen: SE_Succor will now have a baseline fail chance of (2%). Rule added to adjust this as needed.
Kayen: SE_FeignDeath will now have a fail chance as defined by its base value in the spell data.
Optional SQL: utils/sql/git/optional/2014_03_27_SuccorFailRule.sql
== 03/22/2014 ==
Uleat: Moved the existing 'load_bots' and 'drop_bots' sqls into the emu git repository for the time being. Look to the
/utils/sql/git/bots/ folder to find them. The 'load_bots' sql has been updated to include the below fix, as well as
collecting the multiple files into one. This should allow HeidiSQL to now run it properly. (You will still need to
search for the optional scripts for the time being.)
Uleat: Fixed bot guild script failure. For existing bot databases only, use this sql file to update the affected table and view.
Required Bot SQL: 2014_03_22_BotGuildMember_ScriptFailureFix.sql
== 03/19/2014 ==
Kayen: Further refinements to root, charm, mez and fear behaviors - See commit message for full details
New rule for 'Fear' break chance, and updates to default settings of various rules.
Optional SQL: utils/sql/git/optional/2014_03_19_RulesUpdates.sql
== 03/18/2014 ==
Uleat: Fixed the name/account discrepancy in the Client::SummonItem() code as well as the origin of the mistake (thanks K_K!)
Uleat: Condensed and rearranged certain snippets of code in SummonItem(). Added a 'augslotvisible' check to validation check.
Note: If you are experiencing issues with SummonItem, please enable 'INVENTORY_ERROR' logging if it not active on your server.
== 03/17/2014 ==
Uleat: Updated Client::SummonItem() to check for valid item combinations when augmentations are passed.
Uleat: Changed the return type of Client::SummonItem() from void to bool. Calling methods and APIs have not been update as yet.
Uleat: Fixed the RoF Item structure to properly pass the 'augrestrict' variable. RoF clients now show restrictions in the Item Information window.
Optional SQL: 2014/03/17_EnforceAugmentRules.sql
Note: This adds the rules Inventory:EnforceAugmentRestriction, Inventory:EnforceAugmentUsability and Inventory:EnforceAugmentWear.
If you run into script/recipe issues, running this sql file will set the default enforcement rules to false.
If you still run into issues, you may want to check that your scripts are not trying to augment non-common items.
Please post any failures as bugs and be sure to include the base item ID, as well as any augment IDs that you are using.
== 03/12/2014 ==
Kayen: Melee/Magic runes are now calculated as bonuses. Resolved issues with runes not working and not fading properly.
== 03/08/2014 ==
Kayen: Revision to lull/harmony/pacification code to be consistent with live based on extensive personal parsing.
*Lulls on initial cast do not check regular resists (MR ect) but only apply a flat ~7.5 % resist chance + level modifier
*If Lull is resisted, a second resistance check is made this time using regular resists and a charisma modifier (same as charm)
which if 'resisted' will cause the caster to gain aggro.
== 03/05/2014 ==
demonstar55: Corrected rogue's evade to be single target
sorvani: fixed crash issue 119
== 03/04/2014 ==
Sorvani: Created RemoveFromInstance and RemoveAllFromInstance to remove a single player or all players in an instance.
Sorvani: Exported to Lua as eq.remove_from_instance(instance_id) and eq.remove_all_from_instance(instance_id).
Kayen: Revision to root code to be consistent with live based on extensive personal parsing.
*ROOT has a 40% chance to do a resist check to break each buff tick.
*If multiple roots on target. Root in first slot will always and only be check to break from nukes.
*If multiple roots on target and broken by spell. Roots are removed ONE at a time in order of buff slot.
*Roots on beneficial spells can not be broken by spell damage.
Optional SQL: utils/sql/git/optional/2014_03_04_RootRule.sql
== 03/03/2014 ==
demonstar55: Implemented deadly strikes and gave rogues higher innate throwing crit chance
New rules: Combat:RogueCritThrowingChance, Combat:RogueDeadlyStrikeChance, Combat:RogueDeadlyStrikeMod
Defaults should give fairly close to live results
== 03/02/2014 ==
Kayen: Revision to charm code to be consistent with live based on extensive personal parsing.
*Charisma ONLY effects the initial resist check when charm is cast with 10 CHA = -1 Resist mod up to 200 CHA
*Charisma DOES NOT extend charm durations.
Optional SQL: utils/sql/git/optional/2014_03_02_CharmRules.sql
demonstar55: Melee Crits, HoTs, DoTs messages should now be filtered correctly on all clients.
Clients that also support seeing others DoTs will now see them if they don't filter them
note: some newer clients have a 'mine only' option for HoTs but it functions the same as show
== 02/27/2014 ==
cavedude: Exported TrainDisc to Lua.
== 02/26/2014 ==
Kayen: Implemented SE_FrenziedDevestation - increase critical spell chacnce and 2x mana cost for DD spells
Kayen: Fixed SE_SpellProcChance - Now works on spell dervived procs
cavedude: Added two new NPC special_abilities. ALWAYS_FLEE, which forces the NPC to always flee ignoring FleeIfNotAlone and FLEE_PERCENT which allows you to change the HP an individual NPC will flee at. If no value is set, the rule is used as normal.
cavedude: Fixed an issue where rectangular roamboxes could cause an NPC to get stuck on a single coord.
cavedude: Added a new roambox column, mindelay allowing you to have more control over the roambox delay.
Uleat: Fix for 'sqrt' failure on vs2010 clients
image: Added idle zone timer to save CPU cycles.
Required SQL: utils/sql/git/required/2014_02_26_roambox_update.sql
== 02/24/2014 ==
cavedude: Better flee runspeed calculation. Added rule Combat:FleeMultiplier to alter this behavior.
Sorvani: Updated GetUnusedInstanceID to not recycle instance ID's unless it has reached max (65535)
== 02/23/2014 ==
Secrets: Exported the client object SendTargetCommand to Perl.
cavedude: Merchants will now keep better track of charges.
== 02/20/2014 ==
Kayen: Implemented SE_MitigateDotDamage - dot spell mitigation rune with max value
Kayen: Implemented SE_DistanceRemoval - removed from target when target moves X amount of distance away from where initially hit.
Required SQL: utils/sql/git/2014_02_20_buff_updates.sql
== 02/18/2014 ==
Kayen: Implemented SE_TriggerOnReqCaster - triggers a spell which a certain criteria are met (below X amount of hp,mana,end, number of pets on hatelist)
Kayen: Implemented SE_ImprovedTaunt - Locks Aggro On Caster and Decrease other Players Aggro by X% on NPC targets below level Y
Kayen: Fixed an error where SE_ChangeAggro was adding its bonus x 2 for spell generated aggro. (this applies also to spell casting subtlety AA reduction)
== 02/14/2014 ==
Kayen: Fixes for buffs not fading under certain conditions in revised numhits system, and other fixes.
Kayen: Implemented support for spell_new field CastRestrictions (limits what type of targets spells can effect).
*A detailed list describing what the values used in this field do can be found in Mob::PassCastRestriction*
Kayen: Implemented support for spell_new field not_reflectable, no_partial_resists.
Required SQL: utils/sql/git/2014_02_13_spells_new_updates.sql
Names many unknown fields in the table.
== 02/13/2014 ==
Sorvani: Renamed the instance_lockout and instance_lockout_player tables to instance_list and instance_list_player. Cleaned up the Database::GetUnusedInstanceID logic.
Required SQL: utils/sql/git/2014_02_13_Rename_instance_lockout_tables.sql
== 02/10/2014 ==
demonstar55 (Secrets): Re-wrote the entity list to be a std::map. This should be used for direct entityID lookups and is noticably faster performance-wise. Also should result in less nil pointers potentially.
Secrets: Fixed a crash issue that could occur on #repop related to quest timers.
Kayen: Divine Arbiration and other similar spell effects will now utilize a spell range check.
Kayen: Revised how heal amount is calculated to properly incorporate all current focus effects/bonuses.
Kayen: Various updates/fixes/clean-ups to focus effect related code. Focus effect limits should now all work properly.
== 02/09/2014 ==
Sorvani: Added new spawn condition onchange action: DoRepopIfReady. Choosing this will not repop mobs when the spawn condition is enabled if they have an existing respawn timer. Additionally, this condition will not even attempt repop when the condition is is changed to disabled. Will be in use on PEQ for: Cragbeast Queen in Natimbi.
Secrets: Fixed a weird crash issue with deletion of pointers if task loading fails.
== 02/2/2014 ==
Kayen: Revised how spell/dot damage is calculated to properly incorporate all current focus effects/bonuses.
Required SQL: utils/sql/git/2014_02_02_SpellCriticalsAA.sql
== 01/27/2014 ==
Kayen: Implemented SE_CriticalMend (chance to critical monk mend)
Kayen: Implemented SE_IncreaseChanceMemwipe (increases the chance to wipe hate with memory blurr)
Kayen: Implemented SE_FcStunTimeMod (modify stun duration from casted spells)
Kayen: Implemented SE_StunBashChance (increase chance to stun from bash)
Required SQL: utils/sql/git/2014_01_27_CritcalMendAA.sql
== 01/26/2014 ==
Kayen: Revised 'dispel' type spell effects (ie cancel magic) to be consistent with live
== 01/23/2014 ==
Kayen: Implemented SE_FfLimitUseType (focus limit to numhits type)
== 01/20/2014 ==
cavedude: Live-Like weather system (Thanks to robregen for figuring it out!)
demonstar55: Implemented not_extendable spell flag
demonstar55: Moved Spell Casting Reinforcement to DB
demonstar55: Moved Mez Mastery to DB
Kayen: Complete revision of the numhits systems to utilize 'numhits type' field in spell file.
== 01/18/2014 ==
sorvani: Implemented for Lua eq.get_characters_in_instance(uint16 instance_id), return a Lua HashTable
demonstar55: NPCs will now cast their charms.
== 01/13/2014 ==
Kayen: Numerous minor fixes to spell effects.
Kayen: Changed SE_ArcheryDoubleAttack -> SE_DoubleRangedAttack (now works with throwing ect)
Kayen: Changed SE_IncreaseHitDmgTaken -> SE_TriggerMeleeThreshold (now only works on melee)
Kayen: Changed SE_MitigateMeleeDamageSP -> SE_MeleeThresholdGuard
Kayen: Implemented SE_SpellThresholdGuard (Partial Spell Rune that only is lowered if spell hits are over X amount of damage)
Kayen: Implemented SE_TriggerSpellThreshold (implemented Trigger effect on X amount of spell damage taken)
Kayen: Changed SE_ReduceHealing -> SE_FcHealAmtIncoming (focus limited Add/Remove amount of healing on target by X amount)
Kayen: Change SE_CriticalHealChance2 -> SE_CriticalHealDecay
Kayen: Change SE_CriticalHealOverTime2 -> SE_CriticalRegenDecay
Kayen: Implemented SE_CriticalDotDecay
Note: 'Decay' effects means the chance to critical decays based on the level of the spell using the effect (like focus decay)
Kayen: Implemented SE_FfLimitUseMin (focus limit to require a min amount of numhits value)
Kayen: Implemented SE_FcLimitUse (focus to increases numhits count by percent)
Kayen: Implemented SE_LimitRace (Limits to spells cast by a certain race)
Kayen: Implemented SE_FcMute (silences casting of spells that contain specific spell effects) ie silence only heals
== 01/09/2014 ==
demonstar55: Add pet size preservation like live (zone, camp, etc)
== 01/07/2014 ==
demonstar55: Moved pet can attack check to before it tries to attack, which is more live like.
== 01/03/2014 ==
demonstar55: Crash prevention for emote.
== 01/02/2014 ==
demonstar55: Stuns from beneficial spells (Harvest) ignore immunity
== 12/26/2013 ==
demonstar55: Added classes_required to merchantlist (same bitmask as items)
== 12/24/2013 ==
Secrets (Akkadius): Perl $client->SilentMessage("Message"); addition, this is a pre-req for a Perl plugin I've shared with EQEmu. This function essentially mimics a player speaking with an NPC - which is used in popup window responses
Secrets: Added functionality to Perl for $client->PlayMP3("name of file").
Usage varies, but typically you can place an MP3/WAV/XMI in the EQDir//sounds, pfs, s3d, or root client folder and it will play through this Perl function. Example, $client->PlayMP3("combattheme1.mp3") or $client->PlayMP3("TUTBTrade1.mp3")
All clients except Secrets of Faydwer and 6.2 have their opcodes identified for this function. The struct + supported params is the same throughout versions.
Use $client->PlayMP3 with an invalid sound file to stop playback or simply wait for it to end.
KLS: Added functionality to Lua for Client:PlayMP3(filename)
KLS: Added functionality to Lua for Client:SendMarqueeMessage(type, priority/opacity, fade_in_time_ms, fade_out_time_ms, duration_ms, msg)
== 12/16/2013 ==
Kayen: Implemented SE_ArcheryDoubleAttack (Chance to do an extra archery attack)
Kayen: Implemented SE_ShieldEquipDmgMod (Increase damage in primary hand if shield equiped)
Kayen: Implemented SE_ShieldEquipHateMod (Increase hate generated if shield equiped)
Kayen: Implemented SE_TriggerOnAmountValue (Trigger spell if HP/Mana/End bellow X value or num pet on target)
== 12/16/2013 ==
Kayen: Fix to SE_BlockNextSpellFocus to make it functional again.
== 12/15/2013 ==
demonstar55: Moved the blocked buff check down so we get spell effects like on live
Kayen: Implemented SE_ReduceHealing (Reduces amount of healing on target by X amount)
Kayen: Implemented SE_CastonFocusEffect (Triggers spell as part of a focus, when that focus effect is used)
Kayen: Implemented SE_IncreaseHitDmgTaken (Effect is triggered when X amount of damage is taken)
Kayen: More fixes for various spell triggers/procs to now properly use their resist modifier.
== 12/14/2013 ==
demonstar55: Blocked buffs shouldn't fail, they should just not be applied.
JJ: Changed enable/disable recipe to confirm change made.
== 12/13/2013 ==
Kayen: Implemented additional functionality for SE_CurrentHP utilizing base2 values. (ie limit to body type)
Kayen: Implemented SE_MitigateMeleeDamageSP (Partial Melee Rune that only is lowered if melee hits are over X amount of damage)
Kayen: Implemented SE_SpellOnAmtDmgTaken (Effect is triggered when X amount of damage is taken)
Kayen: Fix for various spell triggers/procs to now properly use their resist modifier.
Kayen: Fix to mob->ModSkillDmgTaken(skill_num, value), setting value to -1 will now properly effect all skills.
== 12/11/2013 ==
demonstar55: Fixed issue with crippling blow from berserker frenzy not actually doing anything
demonstar55: Fix haste caps
== 12/04/2013 ==
demonstar55: Fixed SpellType_Charm case in AICastSpell
== 12/03/2013 ==
demonstar55: Added #showspellslist to view a mobs spell list
demonstar55: Fix procing off of unattackable things
== 12/02/2013 ==
JJ: Bandaid fix to CopyCharacter function.
== 11/29/2013 ==
demonstar55: Stacking issues should be resolved now, probably could be optimized more, but went from 3 loops that do stuff to 3 where only 2 really does stuff and one breaks early in most cases, so slightly better
== 11/23/2013 ==
Secrets: Fixed an issue related to a zone crash where the count of the abilities in an AA was 0, leading to a size 0 buffer issue.
== 11/19/2013 ==
Secrets: Fixed an issue with two zone crashes reported on PEQ related to the buff restrictions code and AAs.
demonstar55: Partially make use of dot_stacking_exempt (case when it's 1 is implemented, -1 case isn't)
== 11/18/2013 ==
demonstar55: Added assistradius to npc_types, defaults to aggroradius if set to 0 (old behaviour)
== 11/17/2013 ==
Sorvani: fixed leash and tether special abilities to use the specified range correctly.
demonstar55: Rewrote the Mob::_GetMovementSpeed fix an issue that arose from the change on 11/11
- Added the rule Character:BaseRunSpeedCap (default 158) so people can customize what their runspeed cap is. Hardcapped to 225 so stuff doesn't get too crazy.
== 11/16/2013 ==
Leere: Fixed the drinking message for auto-consume, it will again correctly show up for forced consumption instead.
demonstar55: Added Mob::DoCastingChecks() which will check for various fail conditions while the casting bar is up. This is called after Mob::DoCastSpell() starts the casting and before it returns.
== 11/15/2013 ==
demonstar55: Fixed Mob::CalcFocusEffect()'s SE_LimitEffect
Leere: Fixed a stacking issue for SE_StackingCommand_Block
== 11/13/2013 ==
demonstar55: Implemented bard song effect cap. You can set the base cap with the rule Character:BaseInstrumentSoftCap, defaults to 36 or "3.6" as it is sometimes referred to.
demonstar55: Fix Echo of Taelosia and Ayonae's Tutelage to increase the mod cap instead of further improving the instrument mod
demonstar55: Implemented Singing/Instrument Mastery as an AA bonus.
== 11/11/2013 ==
demonstar55: Changed the way walk speed is calculated to allow mobs to have their walk speed equal a 100% movement reduction
== 11/09/2013 ==
Leere: Fixed Bard mana regen, they now only are affected by items and AA.
== 11/07/2013 ==
KLS: Added a system to use the BaseData system in the client.
KLS: Added an optional utility to import spells, skill caps and base data (will import from ./import and export to ./export).
Be sure to source the SQL and run shared_memory.
== 11/06/2013 ==
JJ: (Kingly_Krab) Fix for #npcedit qglobal command.
== 11/01/2013 ==
JJ: Added in-game commands to enable/disable tradeskill recipes
-Commands: #enablerecipe recipe_id, #disablerecipe recipe_id
-Perl: quest::enablerecipe(recipe_id), quest::disablerecipe(recipe_id)
-Lua: eq.enable_recipe(recipe_id), eq.disable_recipe(recipe_id)
== 10/31/2013 ==
Leere: Add the ability to disable a tradeskill recipe
== 10/28/2013 ==
Uleat: Client patch prep work for extending usable skill range (no apparent issues with Ti through RoF[12-10-2012] testing - i.e., clients showed proper skills and they didn't crash)
Uleat: This final patch aligns the existing server PlayerProfile_Struct with the previous changes. The pp_struct, as well as the character 'pp' blob, remains unchanged in size and alignment. The only difference is that the first trailing 100 bytes of the unknown array have been re-assigned to the skills array, and the unknown array decreased by the same amount.
Notes:
- The existing configuration will allow the use of any new skills up to 99
- Due to this new segment of the blob having never been written to properly, we may have erratic data there that needs to be cleared before use
- None of the new skills are coded to use these 'new' skill slots
- A per-client method will still need to be observed when coding for the new skill uses
== 10/27/2013 ==
Uleat: Attempted fix for high level (12) debug compile failures
Notes:
- Explicit Windows vs. Linux code was not changed due to my inability to compile Linux code
- Only CMake accessible flags were corrected if adding the 'std' namespace did not correct the issue
- the tag [CODEBUG] was added to failed code identifed by the above note
- If you are having compile issues after this patch is committed, look to the changes here first
Uleat: Changed riposte fail check to proper failure criteria - (x == a && x == b, where a != b) never passes, so skills a and b can riposte (discovery find, no known reported occurences)
Uleat: Enforced naming standard on my recent changes (Sorry for any inconviencies)
Uleat: Moved DeityTypes enumeration from eq_constants.h to deity.h (expanded utility of accessors, but are yet to be implemented)
Uleat: Changed ItemUseType to ItemInstTypes to better reflect the definition (also to free-up the namespace)
Uleat: Changed ItemClass to ItemClassTypes
Uleat: Converted MATERIAL defines to MaterialUseSlots enumeration - use of scripted 'Bracer' and 'Max' are deprecated
Uleat: Changed ItemTypes to ItemUseTypes - retained the 'ItemType' prefix to avoid too much confusion. Also adopted the '1H Piercing' model found in later clients
Uleat: Converted SkillType typedef enumeration to SkillUseTypes enumeration - Some prep work for adding the newer skills
Uleat: Prepped the client patch files for larger skill buffer size (not active)
== 10/24/2013 ==
demonstar55: Fix some memory leaks in Mob::SpellOnTarget
== 10/21/2013 ==
demonstar55: Changed GetMinLevel return 0 for more cases that EQ uses for some reason ...
demonstar55: Added buff level restrictions, set the Spells:BuffLevelRestrictions to false to have the old behavior.
== 10/18/2013 ==
Uleat: Expanded the 'Bag Type' enumeration to include all known values. Also, set in place additional 'Bag Type' to 'Skill Type' conversions. Some of these will need to be verified before activation.
Uleat: Cleaned up some unused enumerations to show a move towards standardization. More to come...
== 10/12/2013 ==
demonstar55: Allow Titanium and lower clients to enter Tutorial zone from character select
Bad_Captain: Fixed merc crash issue by updating special_abilities & vwMercNpcTypes (Sorvani).
Bad_Captain: Bots- added out of combat bard songs & #bot bardoutofcombat on|off command to turn them on/off.
== 10/11/2013 ==
JJ: (demonstar55) Allow use of Go Home button when Tutorial still selected in RoF.
== 10/10/2013 ==
Secrets: Fixed zone shutdown (or #reloadqst) reinitalization of Perl. This should allow for Perl 5.14 and later to work on Windows under the new quest system.
demonstar55: Beneficial single target buffs shouldn't have their mana/timers set if they fail to cast after the Mob::SpellOnTarget call in Mob::SpellFinished
JJ: Revert change to EnterWorldPacket introduced on 22 April 2013 to fix inability to enter Tutorial or Go Home from character select screen.
== 10/09/2013 ==
demonstar55: Fixed some more instances of the AA timer being eaten
== 10/08/2013 ==
demonstar55: Added IsBuffSpell(spell_id) that will return true if the spell has a duration, so would end up in effects/song/discs etc windows on the client
demonstar55: Replaced instances of using CalcBuffDuration to determine if a spell was a buff with IsBuffSpell
demonstar55: Removed Mob::HasBuffIcon since it was doing what IsBuffSpell does in a more convoluted way with a rather misleading name
demonstar55: Fixed issues that arose from the 10/03/2013 change
== 10/05/2013 ==
Sorvani: fixed issue with stackable items being created with 0 charges cause by fix to SummonItems
== 10/03/2013 ==
demonstar55: Fix when the random +1 tick is added to nerf extension focus effects to where they should be
== 09/30/2013 ==
Sorvani: Changed SummonItem to only summon an item with max charges when said default value is present and not on zero charges
demonstar55: Fixed issue with #showstats showing your level for a bunch of values
== 09/13/2013 ==
demonstar55: Add support for /pet hold on and /pet hold off (UF and RoF)
== 08/29/2013 ==
KLS: Removed Common Profiler and Zone Profiler. They're well past outdated status and are just code bloat.
KLS: Fix for reported issue on forums with skills that could potentially be trained before a player achieved the level to train.
== 08/20/2013 ==
Uleat: Fix for bot pet spell buff corruption (existing db issues will correct themselves through pet death attrition)
== 07/18/2013 ==
KLS: Fix for crash in special_abilities code due to existing use of some dangerous code we didn't catch before.
== 07/15/2013 ==
Sorvani: fix for lua_general.cpp funtion get_spawn_condition
Uleat: added non-extensioned wildcard filter to \\...\dependencies\.gitignore to fix tortoisegit inclusion errors (fixes commit and display overlay issues.)
== 07/13/2013 ==
KLS: Added packet class and helper functions to Lua.
KLS: Added quest event: event_unhandled_opcode
== 07/11/2013 ==
KLS: Added a few lua functions.
KLS: Redid the npcspecialatk system with a new system that is more flexible but a little more complicated (this will break any 3rd party tools that deal with them).
Instead of a string such as "ERS" to denote "Enrage Rampage Summon" abilities are indexed by their ability number, level and params separated by '^'.
It is stored in the following format: ability,level[,param0,param1,param2,param3,param4,param5,param6,param7] Params will be read until there are 8 total or a '^' is reached.
Eg: 'ERS' -> '2,1^3,1^1,1
Levels allow us to dictate how abilities behave that may be different even though they're the same ability.
Params allow us to further refine behaviors on a case by case basis. Passing 0 as a param will use the default value.
NOTE: Be sure to source 2013_07_11_NPC_Special_Abilities.sql. Also due to the large impact this has on a database it is very HIGHLY SUGGESTED to BACKUP YOUR DATABASE FIRST.
The following are the special abilities currently in the game as well as their levels and parameters currently in use:
SPECATK_SUMMON = 1
Level 1: Summon target to NPC
Level 2: Summon NPC to target
Param0: Cooldown in ms (default: 6000)
Param1: HP ratio required to summon (default: 97)
SPECATK_ENRAGE = 2
Param0: HP ratio required to enrage (default: rule NPC:StartEnrageValue)
Param1: Enrage duration in ms (default: 10000)
Param2: Enrage cooldown in ms (default: 360000)
SPECATK_RAMPAGE = 3
Param0: Proc chance (default: 20)
Param1: Rampage target count (default: rule Combat:MaxRampageTargets)
Param2: Percent of a normal attack damage to deal (default: 100)
Param3: Flat damage bonus to add to the rampage attack (default: 0)
Param4: Ignore % armor for this attack (default 0)
Param5: Ignore flat armor for this attack (default 0)
Param6: Percent of npc's natual crit that can go toward this rampage (default: 100)
Param7: Flat crit bonus on top of npc's natual crit that can go toward this attack (default 0)
SPECATK_AREA_RAMPAGE = 4
Param0: Proc chance (default: 20)
Param1: Rampage target count (default: 1)
Param2: Percent of a normal attack damage to deal (default: 100)
Param3: Flat damage bonus to add to the rampage attack (default: 0)
Param4: Ignore % armor for this attack (default 0)
Param5: Ignore flat armor for this attack (default 0)
Param6: Percent of npc's natual crit that can go toward this rampage (default: 100)
Param7: Flat crit bonus on top of npc's natual crit that can go toward this attack (default 0)
SPECATK_FLURRY = 5
Param0: Proc chance (default: rule Combat:NPCFlurryChance)
Param1: Flurry attack count (default: rule Combat:MaxFlurryHits)
Param2: Percent of a normal attack damage to deal (default: 100)
Param3: Flat damage bonus to add to the flurry attack (default: 0)
Param4: Ignore % armor for this attack (default 0)
Param5: Ignore flat armor for this attack (default 0)
Param6: Percent of npc's natual crit that can go toward this attack (default: 100)
Param7: Flat crit bonus on top of npc's natual crit that can go toward this attack (default 0)
Ex: Normal Flurry with 25% proc rate and 100% crit chance that ignores 500 armor.
5,1,25,0,0,0,0,500,0,100
SPECATK_TRIPLE = 6
SPECATK_QUAD = 7
SPECATK_INNATE_DW = 8
SPECATK_BANE = 9
SPECATK_MAGICAL = 10
SPECATK_RANGED_ATK = 11
UNSLOWABLE = 12
UNMEZABLE = 13
UNCHARMABLE = 14
UNSTUNABLE = 15
UNSNAREABLE = 16
UNFEARABLE = 17
UNDISPELLABLE = 18
IMMUNE_MELEE = 19
IMMUNE_MAGIC = 20
IMMUNE_FLEEING = 21
IMMUNE_MELEE_EXCEPT_BANE = 22
IMMUNE_MELEE_NONMAGICAL = 23
IMMUNE_AGGRO = 24
IMMUNE_AGGRO_ON = 25
IMMUNE_CASTING_FROM_RANGE = 26
IMMUNE_FEIGN_DEATH = 27
IMMUNE_TAUNT = 28
NPC_TUNNELVISION = 29
Param0: Aggro modifier on non-tanks (default: rule Aggro:TunnelVisionAggroMod)
NPC_NO_BUFFHEAL_FRIENDS = 30
IMMUNE_PACIFY = 31
LEASH = 32
Param0: Range (default: aggro range * aggro range)
TETHER = 33
Param0: Range (default: aggro range * aggro range)
DESTRUCTIBLE_OBJECT = 34
NO_HARM_FROM_CLIENT = 35
The following Lua API functions were added to deal with the new system:
Integer GetSpecialAbility(Integer ability);
Integer GetSpecialAbilityParam(Integer ability, Integer param);
Void SetSpecialAbility(Integer ability, Integer level);
Void SetSpecialAbilityParam(Integer ability, Integer param, Integer value);
Void ClearSpecialAbilities();
Void ProcessSpecialAbilities(String str);
The old API functions that worked with letters still exist for backwards compatibility reasons but wont be updated further.
== 07/08/2013 ==
Secrets: Cleanup of some log functions that did not have an 'off' function.**
Secrets: Unknown opcode messages only show on EQDEBUG* >= 5 or higher now. (including the dumped packet)
*NOTE: We recommend for debugging and feature development that you keep EQDEBUG to 5 or higher. For production environments, we recommend 1 to help with CPU performance on windows machines and disk I/O on all platforms.
**Affected filters:
NET__ERROR
NET__DEBUG
== 07/05/2013 ==
KLS: Added some lua functions
KLS: Fixed some lua functions
KLS: Perl now will (like lua) keep track of the values you return from EVENT_*. This allows perl to use the extra behavior in things like EVENT_DEATH. Now generally the perl system is now considered deprecated (in favor of lua in the long term) I felt this was too big a change to pass up adding when I got it working.
== 07/02/2013 ==
KLS: Exported eq.follow(entity_id, [distance]) and eq.stop_follow() to lua.
== 07/01/2013 ==
demonstar55: Fix Monster Summoning related to giants/cyclops
demonstar55: Prevent Monster Summoning from summoning a portal in bothunder
KLS: Merge of lua branch to master
See: http://www.eqemulator.org/forums/showthread.php?t=37008 for more detailed information on what is added.
Upgrade notes:
-'templates' quest folder needs to be renamed 'global'
-'items' quest folder needs to be moved into the 'global' folder
-'spells' quest folder needs to be moved into the 'global' folder
-EVENT_PROXIMITY_SAY needs to be enabled via quest before it will work, calling quest::enable_proximity_say() in EVENT_SPAWN will suffice.
-quest::handleturnin, quest::completehandin, quest::resethandin, and quest::clearhandin have been removed. Take a look at https://code.google.com/p/projecteqquests/source/browse/trunk/quests/plugins/check_handin.pl plugin::mq_process_items, plugin::check_mq_handin, plugin::clear_mq_handin for MQ viable replacements.
-Some spell quests that overwrote the effects from the spell they were cast on no longer function properly on perl, it's suggested you make the spells empty or rewrite the broken quests in lua and return a non-zero value.
-Some item quests have changed in a subtle way, though it's unlikely any quests are impacted and the thread has more information if you found any of your quests broke. As far as I know for example: PEQ didn't have to update any of its nearly 70 item quests.
-Cazic Touch (982) no longer shouts the name of the thing it is targeting without a script.
-EVENT_DEATH now triggers before the death is complete. For the old functionality you may use EVENT_DEATH_COMPLETE. It might be a good idea to replace all EVENT_DEATH with EVENT_DEATH_COMPLETE in existing spells.
We sought to minimize changes required but it's still a bit disruptive so take a few minutes when upgrading to make sure everything is correct. Most notably quest::clearhandin was used in some popular plugins to avoid a dupe involved with its code and now that it's gone those will not function if fixes are not applied.
== 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 ==
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
+4
View File
@@ -0,0 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
add_subdirectory(import)
add_subdirectory(export)
+36
View File
@@ -0,0 +1,36 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(export_sources
main.cpp
)
SET(export_headers
)
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(export_client_files Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC)
SET_TARGET_PROPERTIES(export_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
TARGET_LINK_LIBRARIES(export_client_files "Ws2_32.lib")
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(export_client_files "WS2_32")
ENDIF(MINGW)
IF(UNIX)
TARGET_LINK_LIBRARIES(export_client_files "${CMAKE_DL_LIBS}")
TARGET_LINK_LIBRARIES(export_client_files "z")
TARGET_LINK_LIBRARIES(export_client_files "m")
IF(NOT DARWIN)
TARGET_LINK_LIBRARIES(export_client_files "rt")
ENDIF(NOT DARWIN)
TARGET_LINK_LIBRARIES(export_client_files "pthread")
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
+203
View File
@@ -0,0 +1,203 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 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 <stdio.h>
#include "../../common/debug.h"
#include "../../common/shareddb.h"
#include "../../common/EQEmuConfig.h"
#include "../../common/platform.h"
#include "../../common/crash.h"
#include "../../common/rulesys.h"
#include "../../common/StringUtil.h"
void ExportSpells(SharedDatabase *db);
void ExportSkillCaps(SharedDatabase *db);
void ExportBaseData(SharedDatabase *db);
int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformClientExport);
set_exception_handler();
LogFile->write(EQEMuLog::Status, "Client Files Export Utility");
if(!EQEmuConfig::LoadConfig()) {
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
return 1;
}
const EQEmuConfig *config = EQEmuConfig::get();
if(!load_log_settings(config->LogSettingsFile.c_str())) {
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
}
SharedDatabase database;
LogFile->write(EQEMuLog::Status, "Connecting to database...");
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
"database connection");
return 1;
}
ExportSpells(&database);
ExportSkillCaps(&database);
ExportBaseData(&database);
return 0;
}
void ExportSpells(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Exporting Spells...");
FILE *f = fopen("export/spells_us.txt", "w");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open export/spells_us.txt to write, skipping.");
return;
}
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = "SELECT * FROM spells_new ORDER BY id";
MYSQL_RES *result;
MYSQL_ROW row;
if(db->RunQuery(query, strlen(query), errbuf, &result)) {
while(row = mysql_fetch_row(result)) {
std::string line;
unsigned int fields = mysql_num_fields(result);
for(unsigned int i = 0; i < fields; ++i) {
if(i != 0) {
line.push_back('^');
}
line += row[i];
}
fprintf(f, "%s\n", line.c_str());
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query, errbuf);
}
fclose(f);
}
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = nullptr;
MYSQL_RES *result;
MYSQL_ROW row;
bool res = false;
if(db->RunQuery(query, MakeAnyLenString(&query, "SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
class_id, skill_id), errbuf, &result)) {
if(row = mysql_fetch_row(result)) {
if(row[0] && atoi(row[0]) > 0) {
res = true;
}
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in skill_usable query '%s' %s", query, errbuf);
}
safe_delete_array(query);
return res;
}
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = nullptr;
MYSQL_RES *result;
MYSQL_ROW row;
int res = 0;
if(db->RunQuery(query, MakeAnyLenString(&query, "SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
class_id, skill_id, level), errbuf, &result)) {
if(row = mysql_fetch_row(result)) {
res = atoi(row[0]);
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in get_skill query '%s' %s", query, errbuf);
}
safe_delete_array(query);
return res;
}
void ExportSkillCaps(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Exporting Skill Caps...");
FILE *f = fopen("export/SkillCaps.txt", "w");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
return;
}
for(int cl = 1; cl <= 16; ++cl) {
for(int skill = 0; skill <= 77; ++skill) {
if(SkillUsable(db, skill, cl)) {
int previous_cap = 0;
for(int level = 1; level <= 100; ++level) {
int cap = GetSkill(db, skill, cl, level);
if(cap < previous_cap) {
cap = previous_cap;
}
fprintf(f, "%d^%d^%d^%d^0\n", cl, skill, level, cap);
previous_cap = cap;
}
}
}
}
fclose(f);
}
void ExportBaseData(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Exporting Base Data...");
FILE *f = fopen("export/BaseData.txt", "w");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open export/BaseData.txt to write, skipping.");
return;
}
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = "SELECT * FROM base_data ORDER BY level, class";
MYSQL_RES *result;
MYSQL_ROW row;
if(db->RunQuery(query, strlen(query), errbuf, &result)) {
while(row = mysql_fetch_row(result)) {
std::string line;
unsigned int fields = mysql_num_fields(result);
for(unsigned int i = 0; i < fields; ++i) {
if(i != 0) {
line.push_back('^');
}
line += row[i];
}
fprintf(f, "%s\n", line.c_str());
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in ExportBaseData query '%s' %s", query, errbuf);
}
fclose(f);
}
+36
View File
@@ -0,0 +1,36 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(import_sources
main.cpp
)
SET(import_headers
)
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(import_client_files Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC)
SET_TARGET_PROPERTIES(import_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
TARGET_LINK_LIBRARIES(import_client_files "Ws2_32.lib")
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(import_client_files "WS2_32")
ENDIF(MINGW)
IF(UNIX)
TARGET_LINK_LIBRARIES(import_client_files "${CMAKE_DL_LIBS}")
TARGET_LINK_LIBRARIES(import_client_files "z")
TARGET_LINK_LIBRARIES(import_client_files "m")
IF(NOT DARWIN)
TARGET_LINK_LIBRARIES(import_client_files "rt")
ENDIF(NOT DARWIN)
TARGET_LINK_LIBRARIES(import_client_files "pthread")
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
+237
View File
@@ -0,0 +1,237 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 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 "../../common/shareddb.h"
#include "../../common/EQEmuConfig.h"
#include "../../common/platform.h"
#include "../../common/crash.h"
#include "../../common/rulesys.h"
#include "../../common/StringUtil.h"
void ImportSpells(SharedDatabase *db);
void ImportSkillCaps(SharedDatabase *db);
void ImportBaseData(SharedDatabase *db);
int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformClientImport);
set_exception_handler();
LogFile->write(EQEMuLog::Status, "Client Files Import Utility");
if(!EQEmuConfig::LoadConfig()) {
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
return 1;
}
const EQEmuConfig *config = EQEmuConfig::get();
if(!load_log_settings(config->LogSettingsFile.c_str())) {
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
}
SharedDatabase database;
LogFile->write(EQEMuLog::Status, "Connecting to database...");
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
"database connection");
return 1;
}
ImportSpells(&database);
ImportSkillCaps(&database);
ImportBaseData(&database);
return 0;
}
int GetSpellColumns(SharedDatabase *db) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = "DESCRIBE spells_new";
MYSQL_RES *result;
MYSQL_ROW row;
int res = 0;
if(db->RunQuery(query, (uint32)strlen(query), errbuf, &result)) {
while(row = mysql_fetch_row(result)) {
++res;
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query, errbuf);
}
return res;
}
void ImportSpells(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Spells...");
FILE *f = fopen("import/spells_us.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/spells_us.txt to read, skipping.");
return;
}
std::string delete_sql = "DELETE FROM spells_new";
db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length());
int columns = GetSpellColumns(db);
int spells_imported = 0;
char buffer[2048];
while(fgets(buffer, 2048, f)) {
for(int i = 0; i < 2048; ++i) {
if(buffer[i] == '\n') {
buffer[i] = 0;
break;
}
}
std::string escaped = ::EscapeString(buffer);
auto split = SplitString(escaped, '^');
int line_columns = (int)split.size();
std::string sql;
if(line_columns >= columns) {
sql = "INSERT INTO spells_new VALUES(";
for(int i = 0; i < columns; ++i) {
if(i != 0) {
sql += ", '";
} else {
sql += "'";
}
sql += split[i];
sql += "'";
}
sql += ");";
} else {
int i = 0;
sql = "INSERT INTO spells_new VALUES(";
for(; i < line_columns; ++i) {
if(i != 0) {
sql += ", '";
} else {
sql += "'";
}
sql += split[i];
sql += "'";
}
for(; i < columns; ++i) {
sql += ", '0'";
}
sql += ");";
}
db->RunQuery(sql.c_str(), (uint32)sql.length());
spells_imported++;
if(spells_imported % 1000 == 0) {
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
}
}
if(spells_imported % 1000 != 0) {
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
}
fclose(f);
}
void ImportSkillCaps(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Skill Caps...");
FILE *f = fopen("import/SkillCaps.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
return;
}
std::string delete_sql = "DELETE FROM skill_caps";
db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length());
char buffer[2048];
while(fgets(buffer, 2048, f)) {
auto split = SplitString(buffer, '^');
if(split.size() < 4) {
continue;
}
std::string sql;
int class_id, skill_id, level, cap;
class_id = atoi(split[0].c_str());
skill_id = atoi(split[1].c_str());
level = atoi(split[2].c_str());
cap = atoi(split[3].c_str());
StringFormat(sql, "INSERT INTO skill_caps(class, skillID, level, cap) VALUES(%d, %d, %d, %d)",
class_id, skill_id, level, cap);
db->RunQuery(sql.c_str(), (uint32)sql.length());
}
fclose(f);
}
void ImportBaseData(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Base Data...");
FILE *f = fopen("import/BaseData.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/BaseData.txt to read, skipping.");
return;
}
std::string delete_sql = "DELETE FROM base_data";
db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length());
char buffer[2048];
while(fgets(buffer, 2048, f)) {
auto split = SplitString(buffer, '^');
if(split.size() < 10) {
continue;
}
std::string sql;
int level, class_id;
double hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac;
level = atoi(split[0].c_str());
class_id = atoi(split[1].c_str());
hp = atof(split[2].c_str());
mana = atof(split[3].c_str());
end = atof(split[4].c_str());
unk1 = atof(split[5].c_str());
unk2 = atof(split[6].c_str());
hp_fac = atof(split[7].c_str());
mana_fac = atof(split[8].c_str());
end_fac = atof(split[9].c_str());
StringFormat(sql, "INSERT INTO base_data(level, class, hp, mana, end, unk1, unk2, hp_fac, "
"mana_fac, end_fac) VALUES(%d, %d, %f, %f, %f, %f, %f, %f, %f, %f)",
level, class_id, hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac);
db->RunQuery(sql.c_str(), (uint32)sql.length());
}
fclose(f);
}
+124
View File
@@ -0,0 +1,124 @@
#CMake - Cross Platform Makefile Generator
#Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#
#* Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
#* Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#* Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This module defines
# LUA51_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
IF(LUA_ROOT)
FIND_PATH(LUA_INCLUDE_DIR
NAMES lua.h
HINTS
ENV LUA_DIR
PATHS
${LUA_ROOT}
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include src
)
FIND_LIBRARY(LUA_LIBRARY
NAMES lua51 lua5.1 lua-5.1 lua
HINTS
ENV LUA_DIR
PATHS
${LUA_ROOT}
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES lib bin
)
ELSE(LUA_ROOT)
FIND_PATH(LUA_INCLUDE_DIR
NAMES lua.h
HINTS
ENV LUA_DIR
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
)
FIND_LIBRARY(LUA_LIBRARY
NAMES lua51 lua5.1 lua-5.1 lua
HINTS
ENV LUA_DIR
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES lib bin
)
ENDIF(LUA_ROOT)
IF(LUA_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LUA_MATH_LIBRARY m)
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
ELSE()
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
ENDIF()
ENDIF()
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
UNSET(lua_version_str)
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
+48 -49
View File
@@ -4,65 +4,65 @@
#
# Find the native MySQL includes and library
#
# MySQL_INCLUDE_DIR - where to find mysql.h, etc.
# MySQL_LIBRARIES - List of libraries when using MySQL.
# MySQL_FOUND - True if MySQL found.
# The following can be used as a hint as to where to search:
# MYSQL_ROOT
# MySQL_INCLUDE_DIR - where to find mysql.h, etc.
# MySQL_LIBRARIES - List of libraries when using MySQL.
# MySQL_FOUND - True if MySQL found.
# The following can be used as a hint as to where to search:
# MYSQL_ROOT
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Already in cache, be silent
SET(MySQL_FIND_QUIETLY TRUE)
# Already in cache, be silent
SET(MySQL_FIND_QUIETLY TRUE)
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Include dir
IF(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h
PATHS ${MYSQL_ROOT}/include
PATH_SUFFIXES mysql
)
FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h
PATHS ${MYSQL_ROOT}/include
PATH_SUFFIXES mysql
)
ELSE(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h
PATH_SUFFIXES mysql
)
FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h
PATH_SUFFIXES mysql
)
ENDIF(MYSQL_ROOT)
# Library
SET(MySQL_NAMES mysqlclient_r mysqlclient)
IF(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
ELSE(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql
)
ENDIF(MYSQL_ROOT)
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND TRUE)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
SET(MySQL_FOUND TRUE)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND FALSE)
SET( MySQL_LIBRARIES )
SET(MySQL_FOUND FALSE)
SET( MySQL_LIBRARIES )
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)
IF(MySQL_FOUND)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE(MySQL_FOUND)
SET( MySQL_LIBRARIES )
SET( MySQL_LIBRARIES )
ENDIF(MySQL_FOUND)
MARK_AS_ADVANCED(
MySQL_LIBRARY_DEBUG
MySQL_LIBRARY_RELEASE
MySQL_INCLUDE_DIR
)
MySQL_LIBRARY_DEBUG
MySQL_LIBRARY_RELEASE
MySQL_INCLUDE_DIR
)
+20 -40
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "debug.h"
#include "BasePacket.h"
@@ -24,16 +24,17 @@
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
{
this->pBuffer=NULL;
this->pBuffer=nullptr;
this->size=0;
this->_wpos = 0;
this->_rpos = 0;
this->timestamp.tv_sec = 0;
if (len>0) {
this->size=len;
pBuffer= new unsigned char[len];
if (buf) {
memcpy(this->pBuffer,buf,len);
} else {
} else {
memset(this->pBuffer,0,len);
}
}
@@ -43,7 +44,7 @@ BasePacket::~BasePacket()
{
if (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);
}
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
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
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -107,7 +108,7 @@ void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
str[i - 1] = '\0';
}
}
void DumpPacketHex(const BasePacket* app)
{
@@ -123,24 +124,3 @@ void DumpPacketBin(const BasePacket* app) {
DumpPacketBin(app->pBuffer, app->size);
}
+16 -18
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 BASEPACKET_H_
#define BASEPACKET_H_
@@ -50,7 +50,7 @@ public:
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 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) {
return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec));
@@ -71,7 +71,7 @@ public:
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
uint32 GetWritePosition() { return _wpos; }
uint32 GetReadPosition() { return _rpos; }
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
@@ -79,7 +79,7 @@ public:
protected:
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);
};
@@ -89,5 +89,3 @@ extern void DumpPacketBin(const BasePacket* app);
#endif /*BASEPACKET_H_*/
+294 -286
View File
@@ -1,313 +1,321 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(common_sources
BasePacket.cpp
classes.cpp
Condition.cpp
crash.cpp
CRC16.cpp
crc32.cpp
database.cpp
dbasync.cpp
dbcore.cpp
DBMemLeak.cpp
debug.cpp
emu_opcodes.cpp
EMuShareMem.cpp
EmuTCPConnection.cpp
EmuTCPServer.cpp
EQDB.cpp
EQDBRes.cpp
EQEmuConfig.cpp
EQEMuError.cpp
EQPacket.cpp
EQStream.cpp
EQStreamFactory.cpp
EQStreamIdent.cpp
EQStreamProxy.cpp
eqtime.cpp
extprofile.cpp
guild_base.cpp
guilds.cpp
Item.cpp
logsys.cpp
logsys_eqemu.cpp
md5.cpp
misc.cpp
MiscFunctions.cpp
moremath.cpp
Mutex.cpp
opcode_map.cpp
opcodemgr.cpp
packet_dump.cpp
packet_dump_file.cpp
packet_functions.cpp
perl_EQDB.cpp
perl_EQDBRes.cpp
ProcLauncher.cpp
ptimer.cpp
races.cpp
rdtsc.cpp
rulesys.cpp
serverinfo.cpp
shareddb.cpp
SharedLibrary.cpp
StructStrategy.cpp
TCPConnection.cpp
TCPServer.cpp
timeoutmgr.cpp
timer.cpp
unix.cpp
worldconn.cpp
XMLParser.cpp
platform.cpp
patches/Client62.cpp
patches/patches.cpp
patches/SoD.cpp
patches/SoF.cpp
patches/RoF.cpp
patches/Titanium.cpp
patches/Underfoot.cpp
SocketLib/Base64.cpp
SocketLib/File.cpp
SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp
SocketLib/Mime.cpp
SocketLib/Parse.cpp
SocketLib/socket_include.cpp
SocketLib/Utility.cpp
StackWalker/StackWalker.cpp
tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp
BasePacket.cpp
classes.cpp
Condition.cpp
crash.cpp
CRC16.cpp
crc32.cpp
database.cpp
dbasync.cpp
dbcore.cpp
debug.cpp
emu_opcodes.cpp
EmuTCPConnection.cpp
EmuTCPServer.cpp
EQDB.cpp
EQDBRes.cpp
eqemu_exception.cpp
EQEmuConfig.cpp
EQEMuError.cpp
EQPacket.cpp
EQStream.cpp
EQStreamFactory.cpp
EQStreamIdent.cpp
EQStreamProxy.cpp
eqtime.cpp
extprofile.cpp
faction.cpp
guild_base.cpp
guilds.cpp
ipc_mutex.cpp
Item.cpp
logsys.cpp
logsys_eqemu.cpp
md5.cpp
memory_mapped_file.cpp
misc.cpp
MiscFunctions.cpp
moremath.cpp
Mutex.cpp
opcode_map.cpp
opcodemgr.cpp
packet_dump.cpp
packet_dump_file.cpp
packet_functions.cpp
perl_EQDB.cpp
perl_EQDBRes.cpp
ProcLauncher.cpp
ptimer.cpp
races.cpp
rdtsc.cpp
rulesys.cpp
serverinfo.cpp
shareddb.cpp
spdat.cpp
StringUtil.cpp
StructStrategy.cpp
TCPConnection.cpp
TCPServer.cpp
timeoutmgr.cpp
timer.cpp
unix.cpp
worldconn.cpp
XMLParser.cpp
platform.cpp
patches/Client62.cpp
patches/patches.cpp
patches/SoD.cpp
patches/SoF.cpp
patches/RoF.cpp
patches/Titanium.cpp
patches/Underfoot.cpp
SocketLib/Base64.cpp
SocketLib/File.cpp
SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp
SocketLib/Mime.cpp
SocketLib/Parse.cpp
SocketLib/socket_include.cpp
SocketLib/Utility.cpp
StackWalker/StackWalker.cpp
tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp
)
SET(common_headers
BasePacket.h
bodytypes.h
breakdowns.h
classes.h
common_profile.h
Condition.h
crash.h
CRC16.h
crc32.h
database.h
dbasync.h
dbcore.h
DBMemLeak.h
debug.h
deity.h
emu_opcodes.h
emu_oplist.h
EMuShareMem.h
EmuTCPConnection.h
EmuTCPServer.h
eq_constants.h
eq_opcodes.h
eq_packet_structs.h
EQDB.h
EQDBRes.h
EQEmuConfig.h
EQEmuConfig_elements.h
EQEMuError.h
EQPacket.h
EQStream.h
EQStreamFactory.h
EQStreamIdent.h
EQStreamIntf.h
EQStreamLocator.h
EQStreamProxy.h
EQStreamType.h
eqtime.h
errmsg.h
extprofile.h
guild_base.h
guilds.h
Item.h
item_fieldlist.h
item_struct.h
languages.h
linked_list.h
logsys.h
logtypes.h
mail_oplist.h
md5.h
misc.h
MiscFunctions.h
moremath.h
Mutex.h
op_codes.h
opcode_dispatch.h
opcodemgr.h
packet_dump.h
packet_dump_file.h
packet_functions.h
ProcLauncher.h
profiler.h
ptimer.h
queue.h
races.h
rdtsc.h
rulesys.h
ruletypes.h
seperator.h
serverinfo.h
servertalk.h
shareddb.h
SharedLibrary.h
skills.h
StructStrategy.h
TCPBasicServer.h
TCPConnection.h
TCPServer.h
timeoutmgr.h
timer.h
types.h
unix.h
useperl.h
version.h
worldconn.h
XMLParser.h
ZoneNumbers.h
platform.h
patches/Client62.h
patches/Client62_itemfields.h
patches/Client62_ops.h
patches/Client62_structs.h
patches/patches.h
patches/SoD.h
patches/SoD_itemfields.h
patches/SoD_ops.h
patches/SoD_structs.h
patches/SoF.h
patches/SoF_itemfields.h
patches/SoF_opcode_list.h
patches/SoF_ops.h
patches/SoF_structs.h
patches/SSDeclare.h
patches/SSDefine.h
patches/SSRegister.h
patches/RoF.h
patches/RoF_itemfields.h
patches/RoF_ops.h
patches/RoF_structs.h
patches/Titanium.h
patches/Titanium_itemfields.h
patches/Titanium_ops.h
patches/Titanium_structs.h
patches/Underfoot.h
patches/Underfoot_itemfields.h
patches/Underfoot_ops.h
patches/Underfoot_structs.h
SocketLib/Base64.h
SocketLib/File.h
SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h
SocketLib/IFile.h
SocketLib/MemFile.h
SocketLib/Mime.h
SocketLib/Parse.h
SocketLib/socket_include.h
SocketLib/Utility.h
StackWalker/StackWalker.h
tinyxml/tinystr.h
tinyxml/tinyxml.h
BasePacket.h
base_data.h
bodytypes.h
breakdowns.h
classes.h
Condition.h
crash.h
CRC16.h
crc32.h
database.h
dbasync.h
dbcore.h
debug.h
deity.h
emu_opcodes.h
emu_oplist.h
EmuTCPConnection.h
EmuTCPServer.h
eq_constants.h
eq_packet_structs.h
EQDB.h
EQDBRes.h
eqemu_exception.h
EQEmuConfig.h
EQEmuConfig_elements.h
EQEMuError.h
EQPacket.h
EQStream.h
EQStreamFactory.h
EQStreamIdent.h
EQStreamIntf.h
EQStreamLocator.h
EQStreamProxy.h
EQStreamType.h
eqtime.h
errmsg.h
extprofile.h
faction.h
features.h
fixed_memory_hash_set.h
fixed_memory_variable_hash_set.h
guild_base.h
guilds.h
ipc_mutex.h
Item.h
item_fieldlist.h
item_struct.h
languages.h
linked_list.h
logsys.h
logtypes.h
loottable.h
mail_oplist.h
md5.h
memory_mapped_file.h
misc.h
MiscFunctions.h
moremath.h
Mutex.h
op_codes.h
opcode_dispatch.h
opcodemgr.h
packet_dump.h
packet_dump_file.h
packet_functions.h
ProcLauncher.h
profiler.h
ptimer.h
queue.h
races.h
rdtsc.h
rulesys.h
ruletypes.h
seperator.h
serverinfo.h
servertalk.h
shareddb.h
skills.h
spdat.h
StringUtil.h
StructStrategy.h
TCPBasicServer.h
TCPConnection.h
TCPServer.h
timeoutmgr.h
timer.h
types.h
unix.h
useperl.h
version.h
worldconn.h
XMLParser.h
ZoneNumbers.h
platform.h
patches/Client62.h
patches/Client62_itemfields.h
patches/Client62_ops.h
patches/Client62_structs.h
patches/patches.h
patches/SoD.h
patches/SoD_itemfields.h
patches/SoD_ops.h
patches/SoD_structs.h
patches/SoF.h
patches/SoF_itemfields.h
patches/SoF_opcode_list.h
patches/SoF_ops.h
patches/SoF_structs.h
patches/SSDeclare.h
patches/SSDefine.h
patches/SSRegister.h
patches/RoF.h
patches/RoF_itemfields.h
patches/RoF_ops.h
patches/RoF_structs.h
patches/Titanium.h
patches/Titanium_itemfields.h
patches/Titanium_ops.h
patches/Titanium_structs.h
patches/Underfoot.h
patches/Underfoot_itemfields.h
patches/Underfoot_ops.h
patches/Underfoot_structs.h
SocketLib/Base64.h
SocketLib/File.h
SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h
SocketLib/IFile.h
SocketLib/MemFile.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
patches/Client62.h
patches/Client62_itemfields.h
patches/Client62_ops.h
patches/Client62_structs.h
patches/patches.h
patches/SoD.h
patches/SoD_itemfields.h
patches/SoD_ops.h
patches/SoD_structs.h
patches/SoF.h
patches/SoF_itemfields.h
patches/SoF_opcode_list.h
patches/SoF_ops.h
patches/SoF_structs.h
patches/SSDeclare.h
patches/SSDefine.h
patches/SSRegister.h
patches/RoF.h
patches/RoF_itemfields.h
patches/RoF_ops.h
patches/RoF_structs.h
patches/Titanium.h
patches/Titanium_itemfields.h
patches/Titanium_ops.h
patches/Titanium_structs.h
patches/Underfoot.h
patches/Underfoot_itemfields.h
patches/Underfoot_ops.h
patches/Underfoot_structs.h
patches/Client62.cpp
patches/patches.cpp
patches/SoD.cpp
patches/SoF.cpp
patches/RoF.cpp
patches/Titanium.cpp
patches/Underfoot.cpp
patches/Client62.h
patches/Client62_itemfields.h
patches/Client62_ops.h
patches/Client62_structs.h
patches/patches.h
patches/SoD.h
patches/SoD_itemfields.h
patches/SoD_ops.h
patches/SoD_structs.h
patches/SoF.h
patches/SoF_itemfields.h
patches/SoF_opcode_list.h
patches/SoF_ops.h
patches/SoF_structs.h
patches/SSDeclare.h
patches/SSDefine.h
patches/SSRegister.h
patches/RoF.h
patches/RoF_itemfields.h
patches/RoF_ops.h
patches/RoF_structs.h
patches/Titanium.h
patches/Titanium_itemfields.h
patches/Titanium_ops.h
patches/Titanium_structs.h
patches/Underfoot.h
patches/Underfoot_itemfields.h
patches/Underfoot_ops.h
patches/Underfoot_structs.h
patches/Client62.cpp
patches/patches.cpp
patches/SoD.cpp
patches/SoF.cpp
patches/RoF.cpp
patches/Titanium.cpp
patches/Underfoot.cpp
)
SOURCE_GROUP(SocketLib FILES
SocketLib/Base64.h
SocketLib/File.h
SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h
SocketLib/IFile.h
SocketLib/MemFile.h
SocketLib/Mime.h
SocketLib/Parse.h
SocketLib/socket_include.h
SocketLib/Utility.h
SocketLib/Base64.cpp
SocketLib/File.cpp
SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp
SocketLib/Mime.cpp
SocketLib/Parse.cpp
SocketLib/socket_include.cpp
SocketLib/Utility.cpp
SocketLib/Base64.h
SocketLib/File.h
SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h
SocketLib/IFile.h
SocketLib/MemFile.h
SocketLib/Mime.h
SocketLib/Parse.h
SocketLib/socket_include.h
SocketLib/Utility.h
SocketLib/Base64.cpp
SocketLib/File.cpp
SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp
SocketLib/Mime.cpp
SocketLib/Parse.cpp
SocketLib/socket_include.cpp
SocketLib/Utility.cpp
)
SOURCE_GROUP(StackWalker FILES
StackWalker/StackWalker.h
StackWalker/StackWalker.cpp
StackWalker/StackWalker.h
StackWalker/StackWalker.cpp
)
SOURCE_GROUP(TinyXML FILES
tinyxml/tinystr.h
tinyxml/tinyxml.h
tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp
tinyxml/tinystr.h
tinyxml/tinyxml.h
tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp
)
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
ADD_LIBRARY(Common ${common_sources} ${common_headers})
IF(UNIX)
ADD_DEFINITIONS(-fPIC)
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
ADD_DEFINITIONS(-fPIC)
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
ENDIF(UNIX)
SET(LIBRARY_OUTPUT_PATH ../Bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
+13 -344
View File
@@ -1,346 +1,15 @@
#include <stdio.h>
#include "crc32.h"
unsigned long IntArray[]={
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)
uint16 CRC16(const unsigned char *buf, int size, int key)
{
//printf("CRC16() key=%d\n",key);
/*
sub_0_10020760 proc near ; CODE XREF: sub_0_10008620+AEp
; sub_0_10022A90+14Fp ...
arg_0 = dword ptr 4
arg_4 = dword ptr 8
arg_8 = dword ptr 0Ch
*/
//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
*/
// This is computed as the lowest 16 bits of an Ethernet CRC32 checksum
// where the key is prepended to the data in little endian order.
uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
(uint8)((key >> 8) & 0xff),
(uint8)((key >> 16) & 0xff),
(uint8)((key >> 24) & 0xff)};
uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
crc = CRC32::Update(buf, size, crc);
return CRC32::Finish(crc) & 0xffff;
}
+2 -1
View File
@@ -1,6 +1,7 @@
#ifndef _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
+136 -141
View File
@@ -1,153 +1,148 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "debug.h"
#include "Condition.h"
#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
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
#include <errno.h>
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);
}
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,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);
return retcode!=ETIMEDOUT;
}
*/
Condition::~Condition()
{
pthread_mutex_lock(&mutex);
pthread_cond_destroy(&cond);
pthread_mutex_unlock(&mutex);
pthread_mutex_destroy(&mutex);
}
#endif
#ifdef _WINDOWS
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (NULL, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
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()
{
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 //!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
+13 -13
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 __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
+17 -20
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "debug.h"
#include "EQDB.h"
@@ -53,26 +53,23 @@ EQDBRes * EQDB::query(Const_char *q) {
return new EQDBRes(r);
} else {
//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!
Const_char *EQDB::escape_string(Const_char *from) {
int len = strlen(from);
char *res = new char[len*2+1];
mysql_real_escape_string(mysql_ref,res,from,len);
res[len*2] = '\0';
m_escapeBuffer = res;
delete[] res;
return(m_escapeBuffer.c_str());
}
+16 -16
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 EQDB_H_
#define EQDB_H_
@@ -32,10 +32,10 @@ public:
static EQDB *Singleton() { return(&s_EQDB); }
static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; }
//BEGIN PERL EXPORT
//NOTE: you must have a space after the * of a return value
unsigned int field_count();
unsigned long affected_rows();
unsigned long insert_id();
@@ -46,7 +46,7 @@ public:
//END PERL EXPORT
private:
string m_escapeBuffer;
std::string m_escapeBuffer;
static EQDB s_EQDB;
MYSQL *mysql_ref;
};
+23 -22
View File
@@ -1,29 +1,29 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "debug.h"
#include "EQDBRes.h"
#include <mysql.h>
vector<string> EQDBRes::fetch_row_array() {
vector<string> array;
if(res == NULL)
std::vector<std::string> EQDBRes::fetch_row_array() {
std::vector<std::string> array;
if(res == nullptr)
return(array);
int count=mysql_num_fields(res);
MYSQL_ROW row=mysql_fetch_row(res);
for (int i=0;i<count;i++)
@@ -32,16 +32,16 @@ vector<string> EQDBRes::fetch_row_array() {
return array;
}
map<string,string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash;
if(res == NULL)
std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
std::map<std::string,std::string> rowhash;
if(res == nullptr)
return(rowhash);
MYSQL_FIELD *fields;
MYSQL_ROW row;
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++) {
rowhash[fields[i].name]=(row[i] ? row[i] : "");
}
@@ -49,3 +49,4 @@ map<string,string> EQDBRes::fetch_row_hash() {
return rowhash;
}
+17 -17
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 EQDBRes_H_
#define EQDBRes_H_
@@ -30,14 +30,14 @@ class EQDBRes {
public:
EQDBRes(MYSQL_RES *r) { res=r; }
~EQDBRes() { finish(); }
//BEGIN PERL EXPORT
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
void DESTROY() { }
void finish() { if (res) mysql_free_result(res); res=NULL; };
vector<string> fetch_row_array();
map<string,string> fetch_row_hash();
void finish() { if (res) mysql_free_result(res); res=nullptr; };
std::vector<std::string> fetch_row_array();
std::map<std::string,std::string> fetch_row_hash();
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
//END PERL EXPORT
+14 -14
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef _WINDOWS
#include <windows.h>
@@ -71,7 +71,7 @@ void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
}
iterator.Advance();
}
char* tmp = new char[6];
tmp[0] = 1;
tmp[5] = 0;
+14 -14
View File
@@ -1,26 +1,26 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 EQEMuError_H
#define EQEMuError_H
#include "../common/types.h"
enum eEQEMuError { EQEMuError_NoError,
enum eEQEMuError { EQEMuError_NoError,
EQEMuError_Mysql_1405,
EQEMuError_Mysql_2003,
EQEMuError_Mysql_2005,
+66 -90
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "EQEmuConfig.h"
@@ -21,8 +21,8 @@
#include <iostream>
#include <sstream>
string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = NULL;
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) {
const char *text;
@@ -63,7 +63,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text=ParseTextBlock(sub_ele,"port",true);
if (text)
LoginPort=atoi(text);
text=ParseTextBlock(sub_ele,"account",true);
if (text)
LoginAccount=text;
@@ -97,15 +97,15 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
}
} while(sub_ele);
}
// Check for locked
sub_ele = ele->FirstChildElement("locked");
if (sub_ele != NULL)
if (sub_ele != nullptr)
Locked=true;
// Get the <tcp> element
sub_ele = ele->FirstChildElement("tcp");
if(sub_ele != NULL) {
if(sub_ele != nullptr) {
text = sub_ele->Attribute("ip");
if (text)
@@ -123,7 +123,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
// Get the <http> element
sub_ele = ele->FirstChildElement("http");
if(sub_ele != NULL) {
if(sub_ele != nullptr) {
// text = sub_ele->Attribute("ip");
// if (text)
@@ -140,7 +140,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text = sub_ele->Attribute("enabled");
if (text && !strcasecmp(text,"true"))
WorldHTTPEnabled=true;
}
}
@@ -155,7 +155,7 @@ void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
if (text)
ChatPort=atoi(text);
}
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
const char *text;
@@ -167,7 +167,7 @@ void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
if (text)
MailPort=atoi(text);
}
void EQEmuConfig::do_database(TiXmlElement *ele) {
const char *text;
@@ -192,7 +192,7 @@ void EQEmuConfig::do_database(TiXmlElement *ele) {
DatabaseDB=text;
}
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
const char *text;
@@ -228,7 +228,7 @@ void EQEmuConfig::do_zones(TiXmlElement *ele) {
// Get the <ports> element
sub_ele = ele->FirstChildElement("ports");
if(sub_ele != NULL) {
if(sub_ele != nullptr) {
text = sub_ele->Attribute("low");
if (text)
@@ -296,7 +296,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
// Get the <timers> element
sub_ele = ele->FirstChildElement("timers");
if(sub_ele != NULL) {
if(sub_ele != nullptr) {
text = sub_ele->Attribute("restart");
if (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")
return(ShortName);
if(var_name == "LongName")
@@ -405,68 +405,44 @@ string EQEmuConfig::GetByName(const string &var_name) const {
void EQEmuConfig::Dump() const
{
cout << "ShortName = " << ShortName << endl;
cout << "LongName = " << LongName << endl;
cout << "WorldAddress = " << WorldAddress << endl;
cout << "LoginHost = " << LoginHost << endl;
cout << "LoginAccount = " << LoginAccount << endl;
cout << "LoginPassword = " << LoginPassword << endl;
cout << "LoginPort = " << LoginPort << endl;
cout << "Locked = " << Locked << endl;
cout << "WorldTCPPort = " << WorldTCPPort << endl;
cout << "WorldIP = " << WorldIP << endl;
cout << "TelnetEnabled = " << TelnetEnabled << endl;
cout << "WorldHTTPPort = " << WorldHTTPPort << endl;
cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << endl;
cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << endl;
cout << "ChatHost = " << ChatHost << endl;
cout << "ChatPort = " << ChatPort << endl;
cout << "MailHost = " << MailHost << endl;
cout << "MailPort = " << MailPort << endl;
cout << "DatabaseHost = " << DatabaseHost << endl;
cout << "DatabaseUsername = " << DatabaseUsername << endl;
cout << "DatabasePassword = " << DatabasePassword << endl;
cout << "DatabaseDB = " << DatabaseDB << endl;
cout << "DatabasePort = " << DatabasePort << endl;
cout << "QSDatabaseHost = " << QSDatabaseHost << endl;
cout << "QSDatabaseUsername = " << QSDatabaseUsername << endl;
cout << "QSDatabasePassword = " << QSDatabasePassword << endl;
cout << "QSDatabaseDB = " << QSDatabaseDB << endl;
cout << "QSDatabasePort = " << QSDatabasePort << endl;
cout << "SpellsFile = " << SpellsFile << endl;
cout << "OpCodesFile = " << OpCodesFile << endl;
cout << "EQTimeFile = " << EQTimeFile << endl;
cout << "LogSettingsFile = " << LogSettingsFile << endl;
cout << "MapDir = " << MapDir << endl;
cout << "QuestDir = " << QuestDir << endl;
cout << "PluginDir = " << PluginDir << endl;
cout << "ZonePortLow = " << ZonePortLow << endl;
cout << "ZonePortHigh = " << ZonePortHigh << endl;
cout << "DefaultStatus = " << (int)DefaultStatus << endl;
// cout << "DynamicCount = " << DynamicCount << endl;
std::cout << "ShortName = " << ShortName << std::endl;
std::cout << "LongName = " << LongName << std::endl;
std::cout << "WorldAddress = " << WorldAddress << std::endl;
std::cout << "LoginHost = " << LoginHost << std::endl;
std::cout << "LoginAccount = " << LoginAccount << std::endl;
std::cout << "LoginPassword = " << LoginPassword << std::endl;
std::cout << "LoginPort = " << LoginPort << std::endl;
std::cout << "Locked = " << Locked << std::endl;
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
std::cout << "WorldIP = " << WorldIP << std::endl;
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
std::cout << "ChatHost = " << ChatHost << std::endl;
std::cout << "ChatPort = " << ChatPort << std::endl;
std::cout << "MailHost = " << MailHost << std::endl;
std::cout << "MailPort = " << MailPort << std::endl;
std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
std::cout << "DatabasePort = " << DatabasePort << std::endl;
std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
std::cout << "SpellsFile = " << SpellsFile << std::endl;
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
std::cout << "MapDir = " << MapDir << std::endl;
std::cout << "QuestDir = " << QuestDir << std::endl;
std::cout << "PluginDir = " << PluginDir << std::endl;
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
}
+62 -62
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 __EQEmuConfig_H
#define __EQEmuConfig_H
@@ -22,74 +22,74 @@
#include "linked_list.h"
struct LoginConfig {
string LoginHost;
string LoginAccount;
string LoginPassword;
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
};
class EQEmuConfig : public XMLParser {
public:
virtual string GetByName(const string &var_name) const;
virtual std::string GetByName(const std::string &var_name) const;
// From <world/>
string ShortName;
string LongName;
string WorldAddress;
string LocalAddress;
string LoginHost;
string LoginAccount;
string LoginPassword;
std::string ShortName;
std::string LongName;
std::string WorldAddress;
std::string LocalAddress;
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
uint32 LoginCount;
LinkedList<LoginConfig*> loginlist;
bool Locked;
uint16 WorldTCPPort;
string WorldIP;
std::string WorldIP;
bool TelnetEnabled;
int32 MaxClients;
bool WorldHTTPEnabled;
uint16 WorldHTTPPort;
string WorldHTTPMimeFile;
string SharedKey;
std::string WorldHTTPMimeFile;
std::string SharedKey;
// From <chatserver/>
string ChatHost;
std::string ChatHost;
uint16 ChatPort;
// From <mailserver/>
string MailHost;
std::string MailHost;
uint16 MailPort;
// From <database/>
string DatabaseHost;
string DatabaseUsername;
string DatabasePassword;
string DatabaseDB;
std::string DatabaseHost;
std::string DatabaseUsername;
std::string DatabasePassword;
std::string DatabaseDB;
uint16 DatabasePort;
// From <qsdatabase> // QueryServ
string QSDatabaseHost;
string QSDatabaseUsername;
string QSDatabasePassword;
string QSDatabaseDB;
std::string QSDatabaseHost;
std::string QSDatabaseUsername;
std::string QSDatabasePassword;
std::string QSDatabaseDB;
uint16 QSDatabasePort;
// From <files/>
string SpellsFile;
string OpCodesFile;
string EQTimeFile;
string LogSettingsFile;
std::string SpellsFile;
std::string OpCodesFile;
std::string EQTimeFile;
std::string LogSettingsFile;
// From <directories/>
string MapDir;
string QuestDir;
string PluginDir;
std::string MapDir;
std::string QuestDir;
std::string PluginDir;
// From <launcher/>
string LogPrefix;
string LogSuffix;
string ZoneExe;
std::string LogPrefix;
std::string LogSuffix;
std::string ZoneExe;
uint32 RestartWait;
uint32 TerminateWait;
uint32 InitialBootWait;
@@ -103,12 +103,12 @@ public:
// uint16 DynamicCount;
// map<string,uint16> StaticZones;
protected:
static EQEmuConfig *_config;
static string ConfigFile;
static std::string ConfigFile;
#define ELEMENT(name) \
void do_##name(TiXmlElement *ele);
@@ -168,7 +168,7 @@ protected:
MapDir="Maps";
QuestDir="quests";
PluginDir="plugins";
// Launcher
LogPrefix = "logs/zone-";
LogSuffix = ".log";
@@ -181,22 +181,22 @@ protected:
#else
ZoneExe = "./zone";
#endif
// Zones
ZonePortLow=7000;
ZonePortHigh=7999;
DefaultStatus=0;
// For where zones need to connect to.
WorldIP="127.0.0.1";
// Dynamics to start
//DynamicCount=5;
MaxClients=-1;
LoginCount=0;
}
virtual ~EQEmuConfig() {}
@@ -204,17 +204,17 @@ public:
// Produce a const singleton
static const EQEmuConfig *get() {
if (_config == NULL)
if (_config == nullptr)
LoadConfig();
return(_config);
}
// 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
static bool LoadConfig() {
if (_config != NULL)
if (_config != nullptr)
delete _config;
_config=new EQEmuConfig;
+45 -54
View File
@@ -1,21 +1,21 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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
*/
/*
/*
* EQStream classes, by Quagmire
*/
@@ -46,8 +46,6 @@
#include "../common/crc32.h"
#include "../common/eq_packet_structs.h"
using namespace std;
#define EQN_DEBUG 0
#define EQN_DEBUG_Error 0
#define EQN_DEBUG_Packet 0
@@ -60,18 +58,18 @@ using namespace std;
#define LOG_RAW_PACKETS_IN 0
//#define PRIORITYTEST
template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
template <typename type> // HI_LOSWAPlong
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
template <typename type> // HI_LOSWAPlong
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
EQStreamServer::EQStreamServer(uint16 iPort) {
RunLoop = false;
@@ -125,8 +123,8 @@ bool EQStreamServer::Open(uint16 iPort) {
unsigned long nonblocking = 1;
#endif
/* Setup internet address information.
This is used with the bind() call */
/* Setup internet address information.
This is used with the bind() call */
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_port = htons(pPort);
@@ -206,14 +204,14 @@ void EQStreamServer::Process() {
return;
}
uchar buffer[1518];
int status;
struct sockaddr_in from;
unsigned int fromlen;
uchar buffer[1518];
from.sin_family = AF_INET;
fromlen = sizeof(from);
int status;
struct sockaddr_in from;
unsigned int fromlen;
from.sin_family = AF_INET;
fromlen = sizeof(from);
while (1) {
#ifdef WIN32
@@ -230,26 +228,19 @@ void EQStreamServer::Process() {
}
}
map <string, EQStream*>::iterator connection;
for (connection = connection_list.begin( ); connection != connection_list.end( );)
{
if(!connection->second)
{
map <string, EQStream*>::iterator tmp=connection;
connection++;
connection_list.erase(tmp);
std::map <std::string, EQStream*>::iterator connection;
for (connection = connection_list.begin(); connection != connection_list.end();) {
if (!connection->second) {
connection = connection_list.erase(connection);
continue;
}
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection;
connection++;
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
safe_delete(eqs_data);
connection_list.erase(tmp);
}
else if(!eqs_data->RunLoop) {
connection = connection_list.erase(connection);
} else if (!eqs_data->RunLoop) {
eqs_data->Process(sock);
connection++;
++connection;
}
}
}
@@ -277,7 +268,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
cout << "Data from " << temp << endl;
EQStream* tmp = NULL;
map <string, EQStream*>::iterator connection;
std::map <std::string, EQStream*>::iterator connection;
if ((connection=connection_list.find(temp))!=connection_list.end())
tmp=connection->second;
if(tmp != NULL && tmp->GetrPort() == irPort)
@@ -285,13 +276,13 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
tmp->RecvData(data, size);
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());
return;
}
if (data[1]==0x01) {
if (data[1]==0x01) {
cout << "New EQStream Connection." << endl;
EQStream* tmp = new EQStream(irIP, irPort);
tmp->RecvData(data, size);
+13 -14
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 EQNETWORK_H
#define EQNETWORK_H
@@ -30,7 +30,6 @@
#include <map>
#include <list>
#include <queue>
using namespace std;
#include "../common/types.h"
#include "../common/timer.h"
@@ -114,8 +113,8 @@ private:
Mutex MNewQueue;
Mutex MOpen;
map<string,EQStream*> connection_list;
queue<EQStream *> NewQueue;
std::map<std::string,EQStream*> connection_list;
std::queue<EQStream *> NewQueue;
};
#endif
+68 -70
View File
@@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 Michael S. Finger
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 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
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.
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
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 "debug.h"
#include <stdio.h>
@@ -32,18 +32,16 @@
#include <cstdlib>
#include <cstring>
using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len),
emu_opcode(op)
: BasePacket(buf, len),
emu_opcode(op)
{
}
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
buffer += sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]\n", emu_opcode, size);
}
@@ -61,14 +59,14 @@ void EQPacket::build_header_dump(char *buffer) const {
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size);
}
@@ -76,7 +74,7 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
buffer += sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]\n",opcode,size);
}
@@ -95,14 +93,14 @@ void EQProtocolPacket::build_header_dump(char *buffer) const
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size);
}
@@ -110,7 +108,7 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
#ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else
@@ -137,14 +135,14 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else
@@ -156,7 +154,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
#ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else
@@ -183,14 +181,14 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else
@@ -200,7 +198,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
{
if (opcode>0xff) {
if (opcode>0xff) {
*(uint16 *)dest=opcode;
} else {
*(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)
: BasePacket(buf, len),
opcode(op)
: BasePacket(buf, len),
opcode(op)
{
uint32 offset;
@@ -248,7 +246,7 @@ uint32 offset;
memcpy(pBuffer,buf+offset,len-offset);
size=len-offset;
} else {
pBuffer=NULL;
pBuffer=nullptr;
size=0;
}
OpMgr=&RawOpcodeManager;
@@ -294,7 +292,7 @@ get running again... but might be a good thing some day.
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
{
uint32 newsize=0, offset=0;
unsigned char *tmpbuffer=NULL;
unsigned char *tmpbuffer=nullptr;
if (opcode!=OP_AppCombined) {
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);
@@ -345,7 +343,7 @@ bool valid=false;
uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2));
#ifdef EQN_DEBUG
if (packet_crc && comp_crc != packet_crc) {
cout << "CRC mismatch: comp=" << hex << comp_crc << ", packet=" << packet_crc << dec << endl;
std::cout << "CRC mismatch: comp=" << std::hex << comp_crc << ", packet=" << packet_crc << std::dec << std::endl;
}
#endif
valid = (!packet_crc || comp_crc == packet_crc);
@@ -364,7 +362,7 @@ uint32 flag_offset=0;
} else
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;
newbuf[newlen++]=buffer[length-2];
newbuf[newlen++]=buffer[length-1];
@@ -409,7 +407,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
buffer+=2;
size-=2;
int i;
int i;
for (i = 0 ; i+4 <= size ; i+=4)
{
int pt = (*(int*)&buffer[i])^(Key);
@@ -421,7 +419,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
{
test[i]=buffer[i]^KC;
}
memcpy(buffer,test,size);
memcpy(buffer,test,size);
free(test);
}
}
@@ -445,7 +443,7 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
{
test[i]=buffer[i]^KC;
}
memcpy(buffer,test,size);
memcpy(buffer,test,size);
free(test);
}
}
@@ -461,49 +459,49 @@ EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
}
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode)
: EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode)
{
}
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
{
if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf);
if(opcode == 0x0000)
{
if(len >= 3)
{
opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3;
safe_delete_array(pBuffer);
if(len >= 0)
{
size = packet_length;
pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size);
}
else
{
size = 0;
}
}
else
{
safe_delete_array(pBuffer);
size = 0;
}
}
} else {
opcode = *((const uint8 *) buf);
}
if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf);
if(opcode == 0x0000)
{
if(len >= 3)
{
opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3;
safe_delete_array(pBuffer);
if(len >= 0)
{
size = packet_length;
pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size);
}
else
{
size = 0;
}
}
else
{
safe_delete_array(pBuffer);
size = 0;
}
}
} else {
opcode = *((const uint8 *) buf);
}
}
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
if (iShowInfo) {
cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec;
cout << " size:" << app->size << endl;
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
std::cout << " size:" << app->size << std::endl;
}
DumpPacketHex(app->pBuffer, app->size);
// DumpPacketAscii(app->pBuffer, app->size);
+36 -38
View File
@@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 Michael S. Finger
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 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
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.
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
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 _EQPACKET_H
#define _EQPACKET_H
@@ -30,8 +30,6 @@
#include "emu_opcodes.h"
#endif
using namespace std;
class EQStream;
class EQStreamPair;
@@ -39,9 +37,9 @@ class EQPacket : public BasePacket {
friend class EQStream;
public:
virtual ~EQPacket() {}
uint32 Size() const { return size+2; }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
@@ -50,7 +48,7 @@ public:
void SetOpcode(EmuOpcode op) { emu_opcode = op; }
const EmuOpcode GetOpcode() const { return(emu_opcode); }
// const char *GetOpcodeName() const;
protected:
//this is just a cache so we dont look it up several times on Get()
//and it is mutable so we can store the cached copy even on a const object
@@ -58,7 +56,7 @@ protected:
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
// EQPacket(const EQPacket &p) { }
EQPacket() { emu_opcode=OP_Unknown; pBuffer=NULL; size=0; }
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
};
@@ -68,32 +66,32 @@ class EQProtocolPacket : public BasePacket {
friend class EQStream;
friend class EQStreamPair;
public:
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
// EQProtocolPacket(const unsigned char *buf, uint32 len);
bool combine(const EQProtocolPacket *rhs);
uint32 serialize (unsigned char *dest) const;
EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); }
EQRawApplicationPacket *MakeAppPacket() const;
bool acked;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key);
static uint32 Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
static uint32 Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
static void ChatDecode(unsigned char *buffer, int size, int DecodeKey);
static void ChatEncode(unsigned char *buffer, int size, int EncodeKey);
uint16 GetRawOpcode() const { return(opcode); }
uint32 Size() const { return size+2; }
//the actual raw EQ opcode
uint16 opcode;
};
@@ -102,25 +100,25 @@ class EQApplicationPacket : public EQPacket {
// friend class EQProtocolPacket;
friend class EQStream;
public:
EQApplicationPacket() : EQPacket(OP_Unknown,NULL,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,NULL,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,NULL,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
bool combine(const EQApplicationPacket *rhs);
uint32 serialize (uint16 opcode, unsigned char *dest) const;
uint32 Size() const { return size+app_opcode_size; }
virtual EQApplicationPacket *Copy() const;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
uint8 app_opcode_size;
@@ -135,17 +133,17 @@ class EQRawApplicationPacket : public EQApplicationPacket {
public:
EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len);
uint16 GetRawOpcode() const { return(opcode); }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
//the actual raw EQ opcode
uint16 opcode;
EQRawApplicationPacket(const unsigned char *buf, const uint32 len);
};
+322 -272
View File
File diff suppressed because it is too large Load Diff
+52 -43
View File
@@ -18,13 +18,32 @@
#include "../common/Condition.h"
#include "../common/timer.h"
using namespace std;
#define FLAG_COMPRESSED 0x01
#define FLAG_ENCODED 0x04
#define RATEBASE 1048576 // 1 MB
#define DECAYBASE 78642 // RATEBASE/10
#ifndef RATEBASE
#define RATEBASE 1048576
#endif
#ifndef DECAYBASE
#define DECAYBASE 78642
#endif
#ifndef RETRANSMIT_TIMEOUT_MULT
#define RETRANSMIT_TIMEOUT_MULT 3.0
#endif
#ifndef RETRANSMIT_TIMEOUT_MAX
#define RETRANSMIT_TIMEOUT_MAX 5000
#endif
#ifndef AVERAGE_DELTA_MAX
#define AVERAGE_DELTA_MAX 2500
#endif
#ifndef RETRANSMIT_ACKED_PACKETS
#define RETRANSMIT_ACKED_PACKETS true
#endif
#pragma pack(1)
struct SessionRequest {
@@ -55,13 +74,10 @@ struct SessionStats {
/*030*/ uint64 packets_received;
/*038*/
};
#pragma pack()
class OpcodeManager;
//extern OpcodeManager *EQNetworkOpcodeManager;
//class EQStreamFactory;
class OpcodeManager;
class EQStreamPair;
class EQRawApplicationPacket;
@@ -73,7 +89,7 @@ class EQStream : public EQStreamInterface {
SeqInOrder,
SeqFuture
} SeqOrder;
uint32 remote_ip;
uint16 remote_port;
uint8 buffer[8192];
@@ -89,7 +105,7 @@ class EQStream : public EQStreamInterface {
uint32 Session, Key;
uint16 NextInSeq;
uint32 MaxLen;
uint32 MaxLen;
uint16 MaxSends;
uint8 active_users; //how many things are actively using this
@@ -113,19 +129,19 @@ class EQStream : public EQStreamInterface {
Mutex MAcks;
// Packets waiting to be sent (all protected by MOutboundQueue)
queue<EQProtocolPacket *> NonSequencedQueue;
deque<EQProtocolPacket *> SequencedQueue;
std::queue<EQProtocolPacket *> NonSequencedQueue;
std::deque<EQProtocolPacket *> SequencedQueue;
uint16 NextOutSeq;
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue
Mutex MOutboundQueue;
//a buffer we use for compression/decompression
unsigned char _tempBuffer[2048];
// Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
std::vector<EQRawApplicationPacket *> InboundQueue;
std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
Mutex MInboundQueue;
static uint16 MaxWindowSize;
@@ -136,18 +152,16 @@ class EQStream : public EQStreamInterface {
int32 RateThreshold;
int32 DecayRate;
OpcodeManager **OpMgr;
// EQStreamFactory *const Factory;
EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p);
EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len);
EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len);
void SendPacket(uint16 opcode, EQApplicationPacket *p);
void SetState(EQStreamState state);
void SendSessionResponse();
void SendSessionRequest();
void SendAck(uint16 seq);
@@ -157,37 +171,34 @@ class EQStream : public EQStreamInterface {
void NonSequencedPush(EQProtocolPacket *p);
void SequencedPush(EQProtocolPacket *p);
void WritePacket(int fd,EQProtocolPacket *p);
uint32 GetKey() { return Key; }
void SetKey(uint32 k) { Key=k; }
void SetSession(uint32 s) { Session=s; }
void ProcessPacket(EQProtocolPacket *p);
// 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);
EQRawApplicationPacket *PeekPacket(); //for collector.
EQRawApplicationPacket *PopRawPacket(); //for collector.
void InboundQueueClear();
void OutboundQueueClear();
void PacketQueueClear();
void ProcessQueue();
EQProtocolPacket *RemoveQueue(uint16 seq);
void _SendDisconnect();
void init();
public:
EQStream() { init(); remote_ip = 0; remote_port = 0; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
EQStream(sockaddr_in addr) { init(); remote_ip=addr.sin_addr.s_addr; remote_port=addr.sin_port; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
virtual ~EQStream() { RemoveData(); SetState(CLOSED); }
// inline void SetFactory(EQStreamFactory *f) { Factory=f; }
void SetMaxLen(uint32 length) { MaxLen=length; }
//interface used by application (EQStreamInterface)
@@ -201,25 +212,23 @@ class EQStream : public EQStreamInterface {
virtual void RemoveData() { InboundQueueClear(); OutboundQueueClear(); PacketQueueClear(); /*if (CombinedAppPacket) delete CombinedAppPacket;*/ }
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
virtual std::string Describe() const { return("Direct EQStream"); }
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
void CheckTimeout(uint32 now, uint32 timeout=30);
bool HasOutgoingData();
void Process(const unsigned char *data, const uint32 length);
void SetLastPacketTime(uint32 t) {LastPacket=t;}
void Write(int eq_fd);
//
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
// static EQProtocolPacket *Read(int eq_fd, sockaddr_in *from);
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
// void Close() { SendDisconnect(); }
bool CheckActive() { return GetState()==ESTABLISHED; }
bool CheckClosed() { return GetState()==CLOSED; }
void SetOpcodeSize(uint8 s) { app_opcode_size = s; }
@@ -259,14 +268,14 @@ class EQStream : public EQStreamInterface {
return 0;
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
}
//used for dynamic stream identification
class Signature {
public:
//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;
uint32 first_length; //0=dont check length
uint32 first_length; //0=dont check length
};
typedef enum {
MatchNotReady,
@@ -274,8 +283,8 @@ class EQStream : public EQStreamInterface {
MatchFailed
} MatchState;
MatchState CheckSignature(const Signature *sig);
};
#endif
+53 -74
View File
@@ -19,44 +19,42 @@
#include "EQStream.h"
#include "logsys.h"
using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif
fs->ReaderLoop();
#ifndef WIN32
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
{
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif
fs->WriterLoop();
#ifndef WIN32
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout)
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout)
{
StreamType=type;
Port=port;
@@ -81,7 +79,7 @@ struct sockaddr_in address;
#ifndef WIN32
pthread_t t1,t2;
#endif
/* Setup internet address information.
/* Setup internet address information.
This is used with the bind() call */
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
@@ -106,22 +104,22 @@ struct sockaddr_in address;
fcntl(sock, F_SETFL, O_NONBLOCK);
#endif
//moved these because on windows the output was delayed and causing the console window to look bad
//cout << "Starting factory Reader" << endl;
//cout << "Starting factory Writer" << endl;
//std::cout << "Starting factory Reader" << std::endl;
//std::cout << "Starting factory Writer" << std::endl;
#ifdef _WINDOWS
_beginthread(EQStreamFactoryReaderLoop,0, this);
_beginthread(EQStreamFactoryWriterLoop,0, this);
#else
pthread_create(&t1,NULL,EQStreamFactoryReaderLoop,this);
pthread_create(&t2,NULL,EQStreamFactoryWriterLoop,this);
pthread_create(&t1,nullptr,EQStreamFactoryReaderLoop,this);
pthread_create(&t2,nullptr,EQStreamFactoryWriterLoop,this);
#endif
return true;
}
EQStream *EQStreamFactory::Pop()
{
EQStream *s=NULL;
//cout << "Pop():Locking MNewStreams" << endl;
EQStream *s=nullptr;
//std::cout << "Pop():Locking MNewStreams" << std::endl;
MNewStreams.lock();
if (NewStreams.size()) {
s=NewStreams.front();
@@ -129,24 +127,24 @@ EQStream *s=NULL;
s->PutInUse();
}
MNewStreams.unlock();
//cout << "Pop(): Unlocking MNewStreams" << endl;
//std::cout << "Pop(): Unlocking MNewStreams" << std::endl;
return s;
}
void EQStreamFactory::Push(EQStream *s)
{
//cout << "Push():Locking MNewStreams" << endl;
//std::cout << "Push():Locking MNewStreams" << std::endl;
MNewStreams.lock();
NewStreams.push(s);
MNewStreams.unlock();
//cout << "Push(): Unlocking MNewStreams" << endl;
//std::cout << "Push(): Unlocking MNewStreams" << std::endl;
}
void EQStreamFactory::ReaderLoop()
{
fd_set readset;
map<string,EQStream *>::iterator stream_itr;
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
int num;
int length;
unsigned char buffer[2048];
@@ -167,15 +165,15 @@ timeval sleep_time;
sleep_time.tv_sec=30;
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?
continue;
} else if (num==0)
continue;
if(sock == -1)
break; //somebody closed us while we were sleeping.
if (FD_ISSET(sock,&readset)) {
#ifdef _WINDOWS
if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2)
@@ -185,14 +183,13 @@ timeval sleep_time;
{
// What do we wanna do?
} else {
char temp[25];
sprintf(temp,"%u.%d",ntohl(from.sin_addr.s_addr),ntohs(from.sin_port));
MStreams.lock();
if ((stream_itr=Streams.find(temp))==Streams.end()) {
stream_itr=Streams.find(std::make_pair(from.sin_addr.s_addr, from.sin_port));
if (stream_itr == Streams.end()) {
if (buffer[1]==OP_SessionRequest) {
EQStream *s = new EQStream(from);
s->SetStreamType(StreamType);
Streams[temp]=s;
Streams[std::make_pair(from.sin_addr.s_addr, from.sin_port)]=s;
WriterWork.Signal();
Push(s);
s->AddBytesRecv(length);
@@ -204,11 +201,11 @@ timeval sleep_time;
EQStream *curstream = stream_itr->second;
//dont bother processing incoming packets for closed connections
if(curstream->CheckClosed())
curstream = NULL;
curstream = nullptr;
else
curstream->PutInUse();
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
if(curstream) {
curstream->AddBytesRecv(length);
curstream->Process(buffer,length);
@@ -225,26 +222,26 @@ void EQStreamFactory::CheckTimeout()
{
//lock streams the entire time were checking timeouts, it should be fast.
MStreams.lock();
unsigned long now=Timer::GetCurrentTime();
map<string,EQStream *>::iterator stream_itr;
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second;
s->CheckTimeout(now, stream_timeout);
EQStreamState state = s->GetState();
//not part of the else so we check it right away on state change
if (state==CLOSED) {
if (s->IsInUse()) {
//give it a little time for everybody to finish with it
} else {
//everybody is done, we can delete it now
//cout << "Removing connection" << endl;
map<string,EQStream *>::iterator temp=stream_itr;
stream_itr++;
//std::cout << "Removing connection" << std::endl;
std::map<std::pair<uint32, uint16>,EQStream *>::iterator temp=stream_itr;
++stream_itr;
//let whoever has the stream outside delete it
delete temp->second;
Streams.erase(temp);
@@ -252,22 +249,22 @@ void EQStreamFactory::CheckTimeout()
}
}
stream_itr++;
++stream_itr;
}
MStreams.unlock();
}
void EQStreamFactory::WriterLoop()
{
map<string,EQStream *>::iterator stream_itr;
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
bool havework=true;
vector<EQStream *> wants_write;
vector<EQStream *>::iterator cur,end;
std::vector<EQStream *> wants_write;
std::vector<EQStream *>::iterator cur,end;
bool decay=false;
uint32 stream_count;
Timer DecayTimer(20);
WriterRunning=true;
DecayTimer.Enable();
while(sock!=-1) {
@@ -278,26 +275,26 @@ Timer DecayTimer(20);
if (!WriterRunning)
break;
MWriterRunning.unlock();
havework = false;
wants_write.clear();
decay=DecayTimer.Check();
//copy streams into a seperate list so we dont have to keep
//MStreams locked while we are writting
MStreams.lock();
for(stream_itr=Streams.begin();stream_itr!=Streams.end();stream_itr++) {
for(stream_itr=Streams.begin();stream_itr!=Streams.end();++stream_itr) {
// If it's time to decay the bytes sent, then let's do it before we try to write
if (decay)
stream_itr->second->Decay();
//bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == NULL) {
fprintf(stderr, "ERROR: NULL Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i", stream_itr->first.first, stream_itr->first.second);
continue;
}
if (stream_itr->second->HasOutgoingData()) {
havework=true;
stream_itr->second->PutInUse();
@@ -305,15 +302,14 @@ Timer DecayTimer(20);
}
}
MStreams.unlock();
//do the actual writes
cur = wants_write.begin();
end = wants_write.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
(*cur)->Write(sock);
(*cur)->ReleaseFromUse();
}
Sleep(10);
@@ -321,27 +317,10 @@ Timer DecayTimer(20);
stream_count=Streams.size();
MStreams.unlock();
if (!stream_count) {
//cout << "No streams, waiting on condition" << endl;
//std::cout << "No streams, waiting on condition" << std::endl;
WriterWork.Wait();
//cout << "Awake from condition, must have a stream now" << endl;
//std::cout << "Awake from condition, must have a stream now" << std::endl;
}
}
}
+4 -4
View File
@@ -23,18 +23,18 @@ class EQStreamFactory : private Timeoutable {
Condition WriterWork;
EQStreamType StreamType;
queue<EQStream *> NewStreams;
std::queue<EQStream *> NewStreams;
Mutex MNewStreams;
map<string,EQStream *> Streams;
std::map<std::pair<uint32, uint16>,EQStream *> Streams;
Mutex MStreams;
virtual void CheckTimeout();
Timer *DecayTimer;
uint32 stream_timeout;
uint32 stream_timeout;
public:
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
+26 -62
View File
@@ -1,28 +1,25 @@
#include "debug.h"
#include "EQStreamIdent.h"
#include "EQStreamProxy.h"
#include "logsys.h"
using namespace std;
EQStreamIdentifier::~EQStreamIdentifier() {
while(!m_identified.empty()) {
m_identified.front()->ReleaseFromUse();
m_identified.pop();
}
vector<Record *>::iterator cur, end;
std::vector<Record *>::iterator cur, end;
cur = m_streams.begin();
end = m_streams.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
Record *r = *cur;
r->stream->ReleaseFromUse();
delete r;
}
vector<Patch *>::iterator curp, endp;
std::vector<Patch *>::iterator curp, endp;
curp = m_patches.begin();
endp = m_patches.end();
for(; curp != endp; curp++) {
for(; curp != endp; ++curp) {
delete *curp;
}
}
@@ -37,14 +34,14 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
}
void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp;
std::vector<Record *>::iterator cur;
std::vector<Patch *>::iterator curp, endp;
//foreach pending stream.
cur = m_streams.begin();
while(cur != m_streams.end()) {
Record *r = *cur;
//first see if this stream has expired
if(r->expire.Check(false)) {
//this stream has failed to match any pattern in our timeframe.
@@ -54,11 +51,12 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur);
continue;
}
//then make sure the stream is still active
//if stream hasn't finished initializing then continue;
if(r->stream->GetState() == UNESTABLISHED)
{
++cur;
continue;
}
if(r->stream->GetState() != ESTABLISHED) {
@@ -87,18 +85,18 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur);
continue;
}
//not expired, check against all patch signatures
bool found_one = false; //"we found a matching patch for this stream"
bool all_ready = true; //"all signatures were ready to check the stream"
//foreach possbile patch...
curp = m_patches.begin();
endp = m_patches.end();
for(; !found_one && curp != endp; curp++) {
for(; !found_one && curp != endp; ++curp) {
Patch *p = *curp;
//ask the stream to see if it matches the supplied signature
EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
switch(res) {
@@ -109,13 +107,13 @@ void EQStreamIdentifier::Process() {
break;
case EQStream::MatchSuccessful: {
//yay, a match.
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
//might want to do something less-specific here... some day..
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
m_identified.push(s);
found_one = true;
break;
}
@@ -125,75 +123,41 @@ void EQStreamIdentifier::Process() {
break;
}
}
//if we checked all patches and did not find a match.
if(all_ready && !found_one) {
//the stream cannot be identified.
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
r->stream->ReleaseFromUse();
}
//if we found a match, or were not able to identify it
if(found_one || all_ready) {
//cannot print ip/port here. r->stream is invalid.
delete r;
cur = m_streams.erase(cur);
} else {
cur++;
++cur;
}
} //end foreach stream
}
void EQStreamIdentifier::AddStream(EQStream *&eqs) {
m_streams.push_back(new Record(eqs));
eqs = NULL;
eqs = nullptr;
}
EQStreamInterface *EQStreamIdentifier::PopIdentified() {
if(m_identified.empty())
return(NULL);
return(nullptr);
EQStreamInterface *res = m_identified.front();
m_identified.pop();
return(res);
}
EQStreamIdentifier::Record::Record(EQStream *s)
: stream(s),
expire(STREAM_IDENT_WAIT_MS)
: stream(s),
expire(STREAM_IDENT_WAIT_MS)
{
}
+6 -6
View File
@@ -15,27 +15,27 @@ class StructStrategy;
class EQStreamIdentifier {
public:
~EQStreamIdentifier();
//registration interface.
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
//main processing interface
void Process();
void AddStream(EQStream *& eqs);
EQStreamInterface *PopIdentified();
protected:
//registered patches..
class Patch {
public:
std::string name;
EQStream::Signature signature;
EQStream::Signature signature;
OpcodeManager ** opcodes;
const StructStrategy *structs;
};
std::vector<Patch *> m_patches; //we own these objects.
//pending streams..
class Record {
public:
+1 -1
View File
@@ -19,7 +19,7 @@ class EQApplicationPacket;
class EQStreamInterface {
public:
virtual ~EQStreamInterface() {}
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
virtual EQApplicationPacket *PopPacket() = 0;
+27 -30
View File
@@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 EQEmulator Team
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 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
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.
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
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 _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 <string>
using namespace std;
class EQStreamInfo {
public:
@@ -66,7 +65,7 @@ if(res)
else
printf(": False\n");*/
if(l.src_ip != r.src_ip)
return(l.src_ip < r.src_ip);
if(l.dst_ip != r.dst_ip)
@@ -74,7 +73,7 @@ else
if(l.src_port != r.src_port)
return(l.src_port < r.src_port);
return(l.dst_port < r.dst_port);
/* //so, this turned out uglier than I had hoped
if(l.src_ip < r.src_ip)
return(true);
@@ -99,57 +98,57 @@ 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);
}
//Forces the pointer T thing so we can return NULL
//Forces the pointer T thing so we can return nullptr
template <class T>
class EQStreamLocator {
protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator;
typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
public:
void Clear() {
streams.clear();
}
void AddStream(const EQStreamInfo &i, T *o) {
//do we care to check if it exists?
//add this stream, and its inverse
streams[i] = o;
EQStreamInfo inv;
i.invert(inv);
streams[inv] = o;
}
//deletes this stream, and its inverse
void RemoveStream(const EQStreamInfo &i) {
iterator res;
res = streams.find(i);
if(res != streams.end())
streams.erase(res);
EQStreamInfo inv;
i.invert(inv);
res = streams.find(inv);
if(res != streams.end())
streams.erase(res);
}
//removes every occurance of this stream from the list
void RemoveStream(T *it) {
iterator cur, end;
cur = streams.begin();
end = streams.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
if(cur->second == it) {
streams.erase(cur);
//lazy recursive delete for now, since we have to redo
//lazy recursive delete for now, since we have to redo
//our iterators anyways
RemoveStream(it);
return;
}
}
}
T *GetStream(const EQStreamInfo &i) {
iterator res;
res = streams.find(i);
@@ -157,19 +156,17 @@ public:
//may not be a constant time operation in theory, and update our
//stored copy only on insert or delete
if(res == streams.end())
return(NULL);
return(nullptr);
return(res->second);
}
//allow people to iterate over the const struct
// typedef map<const EQStreamInfo, T *>::const_iterator iterator;
// inline iterator begin() const { return(streams.begin()); }
// inline iterator end() const { return(streams.end()); }
protected:
map<const EQStreamInfo, T *> streams;
std::map<const EQStreamInfo, T *> streams;
};
#endif
+10 -10
View File
@@ -6,11 +6,11 @@
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
: m_stream(stream),
m_structs(structs),
m_opcodes(opcodes)
: m_stream(stream),
m_structs(structs),
m_opcodes(opcodes)
{
stream = NULL; //take the stream.
stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes);
}
@@ -28,24 +28,24 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
}
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if(p == NULL)
if(p == nullptr)
return;
EQApplicationPacket *newp = p->Copy();
FastQueuePacket(&newp, ack_req);
}
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
if(p == NULL || *p == NULL)
if(p == nullptr || *p == nullptr)
return;
m_structs->Encode(p, m_stream, ack_req);
}
EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == NULL)
return(NULL);
if(pack == nullptr)
return(nullptr);
//pass this packet through the struct strategy.
m_structs->Decode(pack);
return(pack);
+4 -13
View File
@@ -15,7 +15,7 @@ public:
//takes ownership of the stream.
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
virtual ~EQStreamProxy();
//EQStreamInterface:
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
@@ -28,28 +28,19 @@ public:
virtual bool CheckState(EQStreamState state);
virtual std::string Describe() const;
virtual const EQClientVersion ClientVersion() const;
virtual const uint32 GetBytesSent() const;
virtual const uint32 GetBytesRecieved() const;
virtual const uint32 GetBytesSentPerSecond() const;
virtual const uint32 GetBytesRecvPerSecond() const;
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.
//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.
OpcodeManager **const m_opcodes; //we do not own this object.
OpcodeManager **const m_opcodes; //we do not own this object.
};
#endif /*EQSTREAMPROXY_H_*/
+65 -102
View File
@@ -1,56 +1,34 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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 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
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.
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
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
*/
/*
*
*
*
*
* 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 <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
#include "EmuTCPConnection.h"
#include "EmuTCPServer.h"
@@ -71,12 +49,12 @@ using namespace std;
//server side case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
: TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
id = 0;
Server = NULL;
Server = nullptr;
pOldFormat = iOldFormat;
#ifdef MINILOGIN
TCPMode = modePacket;
@@ -92,14 +70,14 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
RelayServer = false;
RelayCount = 0;
RemoteID = 0;
}
//client outgoing connection case (and client side relay)
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
: TCPConnection(),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
Server = iRelayServer;
if (Server)
@@ -113,29 +91,27 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
TCPMode = iMode;
PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #1 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
#endif
}
//server side relay case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
: TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
Server = iServer;
RelayLink = iRelayLink;
RelayServer = true;
RelayCount = 0;
RemoteID = iRemoteID;
if (!RemoteID)
ThrowError("Error: TCPConnection: RemoteID == 0 on RelayLink constructor");
pOldFormat = false;
ConnectionType = Incomming;
TCPMode = modePacket;
PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #3 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
#endif
}
@@ -143,7 +119,6 @@ EmuTCPConnection::~EmuTCPConnection() {
//the queues free their content right now I believe.
}
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
if (pack->compressed) {
@@ -196,7 +171,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in;
in.s_addr = GetrIP();
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" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -223,7 +198,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in;
in.s_addr = GetrIP();
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" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -248,7 +223,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
return false;
if (GetMode() != modePacket)
return false;
LockMutex lock(&MState);
eTCPMode tmp = GetMode();
if (tmp == modeTransition) {
@@ -262,10 +237,10 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
struct in_addr in;
in.s_addr = GetrIP();
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" << std::hex << std::setw(4) << std::setfill('0') << tnps->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
if (pOldFormat)
cout << " (OldFormat)";
cout << endl;
std::cout << " (OldFormat)";
std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2
if (tnps->size >= 32)
DumpPacket((uchar*) tnps, 32);
@@ -284,7 +259,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
ServerPacket* EmuTCPConnection::PopPacket() {
ServerPacket* ret;
if (!MOutQueueLock.trylock())
return NULL;
return nullptr;
ret = OutQueue.pop();
MOutQueueLock.unlock();
return ret;
@@ -307,7 +282,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
#if defined(GOTFRAGS) && 0
if (strcmp(line, "**CRASHME**") == 0) {
int i = 0;
cout << (5 / i) << endl;
std::cout << (5 / i) << std::endl;
}
#endif
if(line[0] == '*') {
@@ -393,13 +368,13 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
}
}
return(TCPConnection::LineOutQueuePush(line));
}
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
TCPConnection::Disconnect();
if (RelayLink) {
RelayLink->RemoveRelay(this, iSendRelayDisconnect);
RelayLink = 0;
@@ -409,7 +384,7 @@ void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
return(false);
MSendQueue.lock();
#ifdef MINILOGIN
TCPMode = modePacket;
@@ -455,35 +430,34 @@ bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
}
#endif
MSendQueue.unlock();
return(true);
}
void EmuTCPConnection::ClearBuffers() {
TCPConnection::ClearBuffers();
LockMutex lock2(&MOutQueueLock);
ServerPacket* pack = 0;
while ((pack = OutQueue.pop()))
safe_delete(pack);
EmuTCPNetPacket_Struct* tnps = 0;
while ((tnps = InModeQueue.pop()))
safe_delete(tnps);
keepalive_timer.Start();
timeout_timer.Start();
}
void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1
struct in_addr in;
in.s_addr = GetrIP();
cout "NetError: '";
std::cout "NetError: '";
if (reason)
cout << reason;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
std::cout << reason;
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif
ServerPacket* pack = new ServerPacket(0);
pack->size = 1;
@@ -546,7 +520,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
size = tnps->size;
if (size >= MaxTCPReceiveBuffferSize) {
#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);
#endif
if (errbuf)
@@ -586,13 +560,13 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
if (pack->opcode == 0) {
if (pack->size) {
#if TCPN_DEBUG >= 2
cout << "Received TCP Network layer packet" << endl;
std::cout << "Received TCP Network layer packet" << std::endl;
#endif
ProcessNetworkLayerPacket(pack);
}
#if TCPN_DEBUG >= 5
else {
cout << "Received TCP keepalive packet. (opcode=0)" << endl;
std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
}
#endif
// keepalive, no need to process
@@ -604,7 +578,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
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" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -620,7 +594,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
EmuTCPConnection* con = Server->FindConnection(pack->destination);
if (!con) {
#if TCPN_DEBUG >= 1
cout << "Error relaying packet: con = 0" << endl;
std::cout << "Error relaying packet: con = 0" << std::endl;
#endif
safe_delete(pack);
}
@@ -659,7 +633,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
memcpy(&size, &buffer[2], 2);
if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl;
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
#endif
if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
@@ -689,7 +663,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
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" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -750,7 +724,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 3
struct in_addr in;
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
RelayServer = true;
break;
@@ -798,10 +772,10 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 1
struct in_addr in;
in.s_addr = GetrIP();
cout "Received NetError: '";
std::cout "Received NetError: '";
if (pack->size > 1)
cout << (char*) data;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
std::cout << (char*) data;
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif
break;
}
@@ -812,7 +786,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
sent_something = false;
if(!TCPConnection::SendData(sent_something, errbuf))
return(false);
if(sent_something)
keepalive_timer.Start();
else if (TCPMode == modePacket && keepalive_timer.Check()) {
@@ -820,11 +794,11 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
SendPacket(pack);
safe_delete(pack);
#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
}
return(true);
}
return(true);
}
bool EmuTCPConnection::RecvData(char* errbuf) {
@@ -834,24 +808,13 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
else
return(false);
}
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
return false;
}
return(true);
}
+18 -18
View File
@@ -31,67 +31,67 @@ class EmuTCPConnection : public TCPConnection {
public:
enum eTCPMode { modeConsole, modeTransition, modePacket };
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false);
EmuTCPConnection(bool iOldFormat = false, EmuTCPServer* iRelayServer = 0, eTCPMode iMode = modePacket); // for outgoing connections
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
virtual ~EmuTCPConnection();
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
virtual void Disconnect(bool iSendRelayDisconnect = true);
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
ServerPacket* PopPacket(); // OutQueuePop()
void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
eTCPMode GetMode() const { return TCPMode; }
ePacketMode GetPacketMode() const { return(PacketMode); }
ePacketMode GetPacketMode() const { return(PacketMode); }
//relay crap:
inline bool IsRelayServer() const { return RelayServer; }
inline TCPConnection* GetRelayLink() const { return RelayLink; }
inline uint32 GetRemoteID() const { return RemoteID; }
protected:
void OutQueuePush(ServerPacket* pack);
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
void SendNetErrorPacket(const char* reason = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0);
virtual bool ProcessReceivedData(char* errbuf = 0);
bool ProcessReceivedDataAsPackets(char* errbuf = 0);
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
void ProcessNetworkLayerPacket(ServerPacket* pack);
virtual bool LineOutQueuePush(char* line);
virtual void ClearBuffers();
EmuTCPServer* Server;
eTCPMode TCPMode;
ePacketMode PacketMode;
bool pOldFormat;
Timer keepalive_timer;
Timer timeout_timer;
//relay crap:
EmuTCPConnection* RelayLink;
int32 RelayCount;
bool RelayServer;
uint32 RemoteID;
//input queue...
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
//output queue...
MyQueue<ServerPacket> OutQueue;
Mutex MOutQueueLock;
+5 -20
View File
@@ -1,14 +1,10 @@
#include "debug.h"
#include "EmuTCPServer.h"
#include "EmuTCPConnection.h"
EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
: TCPServer<EmuTCPConnection>(iPort),
pOldFormat(iOldFormat)
: TCPServer<EmuTCPConnection>(iPort),
pOldFormat(iOldFormat)
{
}
@@ -42,7 +38,7 @@ void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
MInQueue.lock();
m_InQueue.push(*tnps);
MInQueue.unlock();
tnps = NULL;
tnps = nullptr;
}
void EmuTCPServer::CheckInQueue() {
@@ -61,7 +57,7 @@ void EmuTCPServer::CheckInQueue() {
}
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
EmuTCPNetPacket_Struct* ret = NULL;
EmuTCPNetPacket_Struct* ret = nullptr;
MInQueue.lock();
if(!m_InQueue.empty()) {
ret = m_InQueue.front();
@@ -80,17 +76,6 @@ EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
if ((*cur)->GetID() == iID)
return *cur;
}
return(NULL);
return(nullptr);
}
+8 -8
View File
@@ -11,24 +11,24 @@ class EmuTCPServer : public TCPServer<EmuTCPConnection> {
public:
EmuTCPServer(uint16 iPort = 0, bool iOldFormat = false);
virtual ~EmuTCPServer();
//packet broadcast routines.
void SendPacket(ServerPacket* pack);
void SendPacket(EmuTCPNetPacket_Struct** tnps);
//special crap for relay management
EmuTCPConnection *FindConnection(uint32 iID);
//exposed for some crap we pull. Do not call from outside this object.
TCPServer<EmuTCPConnection>::AddConnection;
using TCPServer<EmuTCPConnection>::AddConnection;
protected:
virtual void Process();
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
bool pOldFormat;
//broadcast packet queue..
void CheckInQueue();
Mutex MInQueue;
+1284 -1248
View File
File diff suppressed because it is too large Load Diff
+162 -168
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 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 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
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.
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
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
*/
// @merth notes:
@@ -27,26 +27,27 @@ class ItemInst; // Item belonging to a client (contains info on item, dye, au
class ItemInstQueue; // Queue of ItemInst objects (i.e., cursor)
class Inventory; // Character inventory
class ItemParse; // Parses item packets
class EvoItemInst; // Extended item inst, for use with scaling/evolving items
class EvolveInfo; // Stores information about an evolving item family
#include <string>
#include <vector>
#include <map>
#include <list>
using namespace std;
#include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h"
#include "../common/item_struct.h"
#include "../common/timer.h"
// Helper typedefs
typedef list<ItemInst*>::const_iterator iter_queue;
typedef map<int16, ItemInst*>::const_iterator iter_inst;
typedef map<uint8, ItemInst*>::const_iterator iter_contents;
typedef std::list<ItemInst*>::const_iterator iter_queue;
typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
namespace ItemField {
enum {
source=0,
namespace ItemField
{
enum
{
source = 0,
#define F(x) x,
#include "item_fieldlist.h"
#undef F
@@ -70,10 +71,10 @@ namespace ItemField {
#define MAX_ITEMS_PER_BAG 10
// Specifies usage type for item inside ItemInst
enum ItemUseType
enum ItemInstTypes
{
ItemUseNormal,
ItemUseWorldContainer
ItemInstNormal = 0,
ItemInstWorldContainer
};
typedef enum {
@@ -86,7 +87,7 @@ typedef enum {
//FatherNitwit: location bits for searching specific
//places with HasItem() and HasItemByUse()
enum {
invWhereWorn = 0x01,
invWhereWorn = 0x01,
invWherePersonal = 0x02, //in the character's inventory
invWhereBank = 0x04,
invWhereSharedBank = 0x08,
@@ -105,23 +106,23 @@ public:
/////////////////////////
// Public Methods
/////////////////////////
inline iter_queue begin() { return m_list.begin(); }
inline iter_queue end() { return m_list.end(); }
void push(ItemInst* inst);
void push_front(ItemInst* inst);
ItemInst* pop();
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 Members
/////////////////////////
list<ItemInst*> m_list;
std::list<ItemInst*> m_list;
};
// ########################################
@@ -134,9 +135,12 @@ public:
///////////////////////////////
// Public Methods
///////////////////////////////
virtual ~Inventory();
~Inventory();
static void CleanDirty();
static void MarkDirty(ItemInst *inst);
// Retrieve a writeable item at specified slot
ItemInst* GetItem(int16 slot_id) const;
ItemInst* GetItem(int16 slot_id, uint8 bagidx) const;
@@ -144,16 +148,16 @@ public:
inline iter_queue cursor_begin() { return m_cursor.begin(); }
inline iter_queue cursor_end() { return m_cursor.end(); }
inline bool CursorEmpty() { return (m_cursor.size() == 0); }
// Retrieve a read-only item from inventory
inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); }
// Add item to inventory
int16 PutItem(int16 slot_id, const ItemInst& inst);
// Add item to cursor queue
int16 PushCursor(const ItemInst& inst);
// Swap items in inventory
bool SwapItem(int16 slot_a, int16 slot_b);
@@ -162,17 +166,17 @@ public:
// Checks All items in a bag for No Drop
bool CheckNoDrop(int16 slot_id);
// Remove item from inventory (and take control of memory)
ItemInst* PopItem(int16 slot_id);
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItem(uint32 item_id, uint8 quantity=0, uint8 where=0xFF);
// Check whether there is space for the specified number of the specified item.
bool HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity);
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItem(uint32 item_id, uint8 quantity = 0, uint8 where = 0xFF);
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF);
@@ -180,10 +184,10 @@ public:
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF);
// Locate an available inventory slot
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
// Calculate slot_id for an item within a bag
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag
@@ -195,40 +199,50 @@ public:
// Test whether a given slot can support a container item
static bool SupportsContainers(int16 slot_id);
int GetSlotByItemInst(ItemInst *inst);
void dumpEntireInventory();
void dumpWornItems();
void dumpInventory();
void dumpBankItems();
void dumpSharedBankItems();
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier);
protected:
///////////////////////////////
// Protected Methods
///////////////////////////////
int GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst);
void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it);
// 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
int16 _PutItem(int16 slot_id, ItemInst* inst);
// 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 _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 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory
map<int16, ItemInst*> m_bank; // Items in character bank
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_worn; // Items worn by character
std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
std::map<int16, ItemInst*> m_bank; // Items in character bank
std::map<int16, ItemInst*> m_shbank; // Items in character shared bank
std::map<int16, ItemInst*> m_trade; // Items in a trade session
ItemInstQueue m_cursor; // Items on cursor: FIFO
};
@@ -245,36 +259,29 @@ public:
/////////////////////////
// Methods
/////////////////////////
// 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(ItemUseType use_type) {
m_use_type = use_type;
m_item = NULL;
m_charges = 0;
m_price = 0;
m_instnodrop = false;
m_merchantslot = 0;
m_color = 0;
}
ItemInst(ItemInstTypes use_type);
ItemInst(const ItemInst& copy);
virtual ~ItemInst();
~ItemInst();
// Query item type
virtual bool IsType(ItemClass item_class) const;
bool IsType(ItemClassTypes item_class) const;
// Can item be stacked?
virtual bool IsStackable() const;
bool IsStackable() const;
bool IsCharged() const;
// Can item be equipped by/at?
virtual bool IsEquipable(uint16 race, uint16 class_) const;
virtual bool IsEquipable(int16 slot_id) const;
bool IsEquipable(uint16 race, uint16 class_) const;
bool IsEquipable(int16 slot_id) const;
//
// Augements
//
@@ -289,10 +296,10 @@ public:
// Contents
//
ItemInst* GetItem(uint8 slot) const;
virtual uint32 GetItemID(uint8 slot) const;
uint32 GetItemID(uint8 slot) const;
inline const ItemInst* operator[](uint8 slot) const { return GetItem(slot); }
void PutItem(uint8 slot, const ItemInst& inst);
void PutItem(SharedDatabase *db, uint8 slot, uint32 item_id);
void PutItem(SharedDatabase *db, uint8 slot, uint32 item_id) { return; } // not defined anywhere...
void DeleteItem(uint8 slot);
ItemInst* PopItem(uint8 index);
void Clear();
@@ -300,13 +307,13 @@ public:
uint8 FirstOpenSlot() const;
uint8 GetTotalItemCount() const;
bool IsNoneEmptyContainer();
map<uint8, ItemInst*>* GetContents() { return &m_contents; }
std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
//
// Augments
//
ItemInst* GetAugment(uint8 slot) const;
virtual uint32 GetAugmentItemID(uint8 slot) const;
uint32 GetAugmentItemID(uint8 slot) const;
void PutAugment(uint8 slot, const ItemInst& inst);
void PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id);
void DeleteAugment(uint8 slot);
@@ -314,21 +321,21 @@ public:
bool IsAugmented();
// Has attack/delay?
virtual bool IsWeapon() const;
virtual bool IsAmmo() const;
bool IsWeapon() const;
bool IsAmmo() const;
// Accessors
const uint32 GetID() const { return m_item->ID; }
const uint32 GetItemScriptID() const { return m_item->ScriptFileID; }
virtual const Item_Struct* GetItem() const { return m_item; }
void SetItem(const Item_Struct* item) { m_item = item; }
const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const;
int16 GetCharges() const { return m_charges; }
void SetCharges(int16 charges) { m_charges = charges; }
uint32 GetPrice() const { return m_price; }
void SetPrice(uint32 price) { m_price = price; }
void SetColor(uint32 color) { m_color = color; }
uint32 GetColor() const { return m_color; }
@@ -339,80 +346,33 @@ public:
void SetMerchantCount(int32 count) { m_merchantcount = count; }
int16 GetCurrentSlot() const { return m_currentslot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
// Is this item already attuned?
bool IsInstNoDrop() const { return m_instnodrop; }
void SetInstNoDrop(bool flag) { m_instnodrop=flag; }
std::string GetCustomDataString() const;
void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier);
std::string GetCustomDataString() const;
std::string GetCustomData(std::string identifier);
void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value);
void DeleteCustomData(std::string identifier);
// Allows treatment of this object as though it were a pointer to m_item
operator bool() const { return (m_item != NULL); }
operator bool() const { return (m_item != nullptr); }
// Compare inner Item_Struct of two ItemInst objects
bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); }
bool operator!=(const ItemInst& right) const { return (this->m_item != right.m_item); }
// Clone current item
virtual ItemInst* Clone() const;
ItemInst* Clone() const;
bool IsSlotAllowed(int16 slot_id) const;
virtual bool IsScaling() 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; }
inline int32 GetSerialNumber() const { return m_SerialNumber; }
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
protected:
//////////////////////////
// Protected Members
//////////////////////////
iter_contents _begin() { return m_contents.begin(); }
iter_contents _end() { return m_contents.end(); }
friend class Inventory;
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
ItemUseType m_use_type; // Usage type for item
const Item_Struct* m_item; // Ptr to item data
int16 m_charges; // # of charges for chargeable items
uint32 m_price; // Bazaar /trader price
uint32 m_color;
uint32 m_merchantslot;
int16 m_currentslot;
bool m_instnodrop;
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
//
// Items inside of this item (augs or contents);
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
map<std::string, std::string> m_custom_data;
};
class EvoItemInst: public ItemInst {
public:
// constructor and destructor
EvoItemInst(const EvoItemInst& copy);
EvoItemInst(const ItemInst& copy);
EvoItemInst(const Item_Struct* item = NULL, int16 charges = 0);
~EvoItemInst();
// accessors... a lot of these are for evolving items (not complete yet)
bool IsScaling() const { return (m_evolveLvl == -1); }
bool IsScaling() const { return m_scaling; }
bool IsEvolving() const { return (m_evolveLvl >= 1); }
uint32 GetExp() const { return m_exp; }
void SetExp(uint32 exp) { m_exp = exp; }
@@ -420,34 +380,68 @@ public:
bool IsActivated() { return m_activated; }
void SetActivated(bool activated) { m_activated = activated; }
int8 GetEvolveLvl() const { return m_evolveLvl; }
EvoItemInst* Clone() const;
const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const;
void Initialize(SharedDatabase *db = NULL);
void SetScaling(bool v) { m_scaling = v; }
void Initialize(SharedDatabase *db = nullptr);
void ScaleItem();
bool EvolveOnAllKills() const;
bool EvolveOnAllKills() const;
int8 GetMaxEvolveLvl() const;
uint32 GetKillsNeeded(uint8 currentlevel);
private:
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 void SetSerialNumber(int32 id) { m_SerialNumber = id; }
std::map<std::string, Timer>& GetTimers() { return m_timers; }
void SetTimer(std::string name, uint32 time);
void StopTimer(std::string name);
void ClearTimers();
protected:
//////////////////////////
// Protected Members
//////////////////////////
iter_contents _begin() { return m_contents.begin(); }
iter_contents _end() { return m_contents.end(); }
friend class Inventory;
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
ItemInstTypes m_use_type; // Usage type for item
const Item_Struct* m_item; // Ptr to item data
int16 m_charges; // # of charges for chargeable items
uint32 m_price; // Bazaar /trader price
uint32 m_color;
uint32 m_merchantslot;
int16 m_currentslot;
bool m_instnodrop;
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
uint32 m_exp;
int8 m_evolveLvl;
bool m_activated;
Item_Struct* m_scaledItem;
const EvolveInfo* m_evolveInfo;
EvolveInfo* m_evolveInfo;
bool m_scaling;
//
// Items inside of this item (augs or contents);
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
std::map<std::string, std::string> m_custom_data;
std::map<std::string, Timer> m_timers;
};
class EvolveInfo {
public:
friend class EvoItemInst;
friend class ItemInst;
//temporary
uint16 LvlKills[9];
uint32 FirstItem;
uint8 MaxLvl;
bool AllKills;
EvolveInfo();
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
~EvolveInfo();
+1558 -1559
View File
File diff suppressed because it is too large Load Diff
+117 -378
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 "MiscFunctions.h"
@@ -32,17 +32,12 @@
#include "../common/timer.h"
#include "../common/seperator.h"
using namespace std;
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#else
#include <stdlib.h>
#include <ctype.h>
@@ -50,19 +45,15 @@ using namespace std;
#include <sys/types.h>
#include <sys/time.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#include <sys/stat.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#endif
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
static bool WELLRNG_init = false;
static int state_i = 0;
static unsigned int STATE[R];
@@ -83,210 +74,15 @@ void CoutTimestamp(bool ms) {
time(&rawtime);
gmt_t = gmtime(&rawtime);
struct timeval read_time;
gettimeofday(&read_time,0);
struct timeval read_time;
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)
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000);
cout << " GMT";
std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
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) {
#ifdef _WINDOWS
@@ -314,14 +110,14 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0");
return 0;
}
struct sockaddr_in server_sin;
struct sockaddr_in server_sin;
#ifdef _WINDOWS
PHOSTENT phostent = NULL;
PHOSTENT phostent = nullptr;
#else
struct hostent *phostent = NULL;
struct hostent *phostent = nullptr;
#endif
server_sin.sin_family = AF_INET;
if ((phostent = gethostbyname(hostname)) == NULL) {
if ((phostent = gethostbyname(hostname)) == nullptr) {
#ifdef _WINDOWS
if (errbuf)
snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError());
@@ -383,20 +179,19 @@ const char * itoa(int num, char* a,int b) {
}
#endif
/*
/*
* generate a random integer in the range low-high this
* should be used instead of the rand()%limit method
*/
int MakeRandomInt(int low, int high)
{
_CP(MakeRandomInt);
if(low >= high)
return(low);
//return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) {
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) );
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
}
unsigned int randomnum = ((WELLRNG19937)());
@@ -407,14 +202,13 @@ int MakeRandomInt(int low, int high)
double MakeRandomFloat(double low, double high)
{
_CP(MakeRandomFloat);
if(low >= high)
return(low);
//return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) {
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) );
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
}
return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low);
@@ -422,41 +216,41 @@ double MakeRandomFloat(double low, double high)
uint32 rnd_hash( time_t t, clock_t c )
{
// Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
{
h1 *= 255 + 2U;
h1 += p[i];
}
uint32 h2 = 0;
p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j )
{
h2 *= 255 + 2U;
h2 += p[j];
}
return ( h1 + differ++ ) ^ h2;
// Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
{
h1 *= 255 + 2U;
h1 += p[i];
}
uint32 h2 = 0;
p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j )
{
h2 *= 255 + 2U;
h2 += p[j];
}
return ( h1 + differ++ ) ^ h2;
}
void oneseed( const uint32 seed )
{
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0;
STATE[j] = seed & 0xffffffffUL;
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0;
STATE[j] = seed & 0xffffffffUL;
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
@@ -472,117 +266,83 @@ void oneseed( const uint32 seed )
/* ***************************************************************************** */
unsigned int case_1 (void){
// state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1;
WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1;
WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_2 (void){
// state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0;
WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0;
WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_3 (void){
// state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M1 < R)
WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M1 < R)
WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_4 (void){
// state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M3 < R)
WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M3 < R)
WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_5 (void){
// state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M2 < R)
WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M2 < R)
WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_6 (void){
// 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i == 1)
WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i == 1)
WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
// 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)
{
@@ -627,24 +387,3 @@ float EQHtoFloat(int d)
{
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;
}
+36 -63
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 MISCFUNCTIONS_H
#define MISCFUNCTIONS_H
@@ -32,9 +32,9 @@
// 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.
//
#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_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; }
#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_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_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
#define VARSTRUCT_SKIP_TYPE(Type, Buffer) Buffer += sizeof(Type);
@@ -42,7 +42,7 @@
#define VERIFY_PACKET_LENGTH(OPCode, Packet, StructName) \
if(Packet->size != sizeof(StructName)) \
{ \
LogFile->write(EQEMuLog::Debug, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \
_log(NET__ERROR, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \
DumpPacket(Packet); \
return; \
}
@@ -63,62 +63,37 @@
#define MAT1(v) v
#define MAT3POS(t,v) (v>>t)
#define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2]
#define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2]
#define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R]
#define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R]
#define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1]
#define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1]
#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);
uint32 ResolveIP(const char* hostname, char* errbuf = 0);
bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0);
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);
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 NewEQ13toFloat(int d);
float EQ19toFloat(int d);
@@ -127,8 +102,6 @@ int FloatToEQ13(float d);
int NewFloatToEQ13(float d);
int FloatToEQ19(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) {
init(iVar, iSetTo);
}
AutoDelete() { pVar = NULL; }
AutoDelete() { pVar = nullptr; }
void init(T** iVar, T* iSetTo = 0)
{
pVar = iVar;
@@ -157,11 +130,11 @@ public:
*pVar = iSetTo;
}
~AutoDelete() {
if(pVar != NULL)
if(pVar != nullptr)
safe_delete(*pVar);
}
void ReallyClearIt() {
pVar = NULL;
pVar = nullptr;
}
private:
T** pVar;
+28 -52
View File
@@ -1,29 +1,28 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 "../common/Mutex.h"
#include <iostream>
using namespace std;
#define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1
#endif
#ifdef _WINDOWS
@@ -43,7 +42,7 @@ bool IsTryLockSupported() {
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl;
std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif
return false;
}
@@ -52,13 +51,13 @@ bool IsTryLockSupported() {
// Tests for Windows NT product family.
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() SUPPORTED" << endl;
std::cout << "Mutex::trylock() SUPPORTED" << std::endl;
#endif
return true;
}
else {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl;
std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif
return false;
}
@@ -66,43 +65,36 @@ bool IsTryLockSupported() {
#endif
Mutex::Mutex() {
#if DEBUG_MUTEX_CLASS >= 7
cout << "Constructing Mutex" << endl;
std::cout << "Constructing Mutex" << std::endl;
#endif
#ifdef _WINDOWS
InitializeCriticalSection(&CSMutex);
InitializeCriticalSection(&CSMutex);
#else
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
#if defined(__CYGWIN__) || defined(__APPLE__)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
#if defined(__CYGWIN__) || defined(__APPLE__) || defined(FREEBSD)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
pthread_mutex_init(&CSMutex, &attr);
pthread_mutexattr_destroy(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
pthread_mutex_init(&CSMutex, &attr);
pthread_mutexattr_destroy(&attr);
#endif
}
Mutex::~Mutex() {
#if DEBUG_MUTEX_CLASS >= 7
cout << "Deconstructing Mutex" << endl;
#endif
#ifdef _WINDOWS
DeleteCriticalSection(&CSMutex);
#else
// pthread_mutex_destroy(&CSMutex);
#endif
}
void Mutex::lock() {
_CP(Mutex_lock);
#if DEBUG_MUTEX_CLASS >= 9
cout << "Locking Mutex" << endl;
#endif
#if DEBUG_MUTEX_CLASS >= 5
if (!trylock()) {
cout << "Locking Mutex: Having to wait" << endl;
std::cout << "Locking Mutex: Having to wait" << std::endl;
#ifdef _WINDOWS
EnterCriticalSection(&CSMutex);
#else
@@ -119,9 +111,6 @@ void Mutex::lock() {
}
bool Mutex::trylock() {
#if DEBUG_MUTEX_CLASS >= 9
cout << "TryLocking Mutex" << endl;
#endif
#ifdef _WINDOWS
#if(_WIN32_WINNT >= 0x0400)
if (TrylockSupported)
@@ -140,9 +129,6 @@ bool Mutex::trylock() {
}
void Mutex::unlock() {
#if DEBUG_MUTEX_CLASS >= 9
cout << "Unlocking Mutex" << endl;
#endif
#ifdef _WINDOWS
LeaveCriticalSection(&CSMutex);
#else
@@ -187,7 +173,7 @@ MRMutex::MRMutex() {
MRMutex::~MRMutex() {
#ifdef _EQDEBUG
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
}
@@ -214,11 +200,6 @@ bool MRMutex::TryReadLock() {
void MRMutex::UnReadLock() {
MCounters.lock();
rl--;
#ifdef _EQDEBUG
if (rl < 0) {
ThrowError("rl < 0 in MRMutex::UnReadLock()");
}
#endif
MCounters.unlock();
}
@@ -261,11 +242,6 @@ bool MRMutex::TryWriteLock() {
void MRMutex::UnWriteLock() {
MCounters.lock();
wl--;
#ifdef _EQDEBUG
if (wl < 0) {
ThrowError("wl < 0 in MRMutex::UnWriteLock()");
}
#endif
MCounters.unlock();
}
+11 -11
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 MYMUTEX_H
#define MYMUTEX_H
+90 -103
View File
@@ -1,39 +1,41 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 <string>
#include <vector>
#include "debug.h"
#include "ProcLauncher.h"
#ifdef _WINDOWS
#include <windows.h>
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#endif
using namespace std;
ProcLauncher ProcLauncher::s_launcher;
#ifdef _WINDOWS
@@ -51,10 +53,9 @@ ProcLauncher::ProcLauncher()
#endif
}
void ProcLauncher::Process() {
#ifdef _WINDOWS
map<ProcRef, Spec *>::iterator cur, end, tmp;
std::map<ProcRef, Spec *>::iterator cur, end, tmp;
cur = m_running.begin();
end = m_running.end();
while(cur != end) {
@@ -71,7 +72,7 @@ void ProcLauncher::Process() {
//GetLastError();
TerminateProcess(cur->second->proc_info.hProcess, 1);
}
//if we get here, the current process died.
tmp = cur;
tmp++;
@@ -85,13 +86,13 @@ void ProcLauncher::Process() {
ProcRef died = waitpid(-1, &status, WNOHANG);
if(died == -1) {
//error waiting... shouldent really happen...
} else if(died == 0) {
//nothing pending...
break;
} else {
//one died...
map<ProcRef, Spec *>::iterator ref;
std::map<ProcRef, Spec *>::iterator ref;
ref = m_running.find(died);
if(ref == m_running.end()) {
//unable to find this process in our list...
@@ -102,14 +103,14 @@ void ProcLauncher::Process() {
}
}
#endif //!WIN32
}
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);
#ifdef _WINDOWS
CloseHandle(it->second->proc_info.hProcess);
#else //!WIN32
@@ -121,32 +122,32 @@ void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
//consume the pointer
Spec *it = to_launch;
to_launch = NULL;
to_launch = nullptr;
#ifdef _WINDOWS
STARTUPINFO siStartInfo;
BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
ZeroMemory( &it->proc_info, sizeof(PROCESS_INFORMATION) );
// Set up members of the STARTUPINFO structure.
// Set up members of the STARTUPINFO structure.
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.dwFlags = 0;
//handle output redirection.
HANDLE logOut = NULL;
HANDLE logOut = nullptr;
BOOL inherit_handles = FALSE;
if(it->logFile.length() > 0) {
inherit_handles = TRUE;
// Set up our log file to redirect output into.
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = NULL;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = nullptr;
logOut = CreateFile(
it->logFile.c_str(), //lpFileName
FILE_WRITE_DATA, //dwDesiredAccess
@@ -154,61 +155,61 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
&saAttr, //lpSecurityAttributes
CREATE_ALWAYS, //dwCreationDisposition
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
NULL ); //hTemplateFile
nullptr ); //hTemplateFile
//configure the startup info to redirect output appropriately.
siStartInfo.hStdError = logOut;
siStartInfo.hStdOutput = logOut;
siStartInfo.hStdInput = NULL;
siStartInfo.hStdInput = nullptr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
}
siStartInfo.dwFlags |= CREATE_NEW_CONSOLE;
// Create the child process.
// Create the child process.
//glue together all the nice command line arguments
string args(it->program);
vector<string>::iterator cur, end;
std::string args(it->program);
std::vector<std::string>::iterator cur, end;
cur = it->args.begin();
end = it->args.end();
for(; cur != end; cur++) {
args += " ";
args += *cur;
}
bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line
NULL, // process security attributes
NULL, // primary thread security attributes
inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION
bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line
nullptr, // process security attributes
nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
nullptr, // use parent's environment
nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION
if (bFuncRetn == 0) {
safe_delete(it);
//GetLastError()
return(ProcError);
}
//keep process handle open to get exit code
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.
ProcRef res = it->proc_info.dwProcessId;
//record this entry..
m_running[res] = it;
return(res);
#else //!WIN32
//build argv
char **argv = new char *[it->args.size()+2];
unsigned int r;
@@ -216,8 +217,8 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
for(r = 1; r <= it->args.size(); r++) {
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.
if(res == -1) {
//error forking... errno
@@ -225,10 +226,10 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
safe_delete_array(argv);
return(ProcError);
}
if(res == 0) {
//child... exec this bitch
//handle output redirection if requested.
if(it->logFile.length() > 0) {
//we will put their output directly into a file.
@@ -252,20 +253,20 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
write(outfd, err, strlen(err));
}
close(STDIN_FILENO);
close(outfd); //dont need this one, we have two more copies...
}
}
//call it...
execv(argv[0], argv);
_exit(1);
}
safe_delete_array(argv);
//record this entry..
m_running[res] = it;
return(res);
#endif //!WIN32
}
@@ -277,10 +278,10 @@ bool ProcLauncher::Terminate(const ProcRef &proc, bool graceful) {
std::map<ProcRef, Spec *>::iterator res = m_running.find(proc);
if(res == m_running.end())
return(false);
//we do not remove it from the list until we have been notified
//that they have been terminated.
#ifdef _WINDOWS
if(!TerminateProcess(res->second->proc_info.hProcess, 0)) {
return(false);
@@ -311,7 +312,7 @@ void ProcLauncher::TerminateAll(bool final) {
//kill each process and remove it from the list
std::map<ProcRef, Spec *> running(m_running);
m_running.clear();
std::map<ProcRef, Spec *>::iterator cur, end;
cur = running.begin();
end = running.end();
@@ -334,7 +335,7 @@ void ProcLauncher::HandleSigChild(int signum) {
ProcLauncher::Spec::Spec() {
handler = NULL;
handler = nullptr;
}
ProcLauncher::Spec::Spec(const Spec &other) {
@@ -352,17 +353,3 @@ ProcLauncher::Spec &ProcLauncher::Spec::operator=(const Spec &other) {
return(*this);
}
+24 -55
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 PROCLAUNCHER_H_
#define PROCLAUNCHER_H_
@@ -32,7 +32,7 @@ public:
//Singleton method
static ProcLauncher *get() { return(&s_launcher); }
static void ProcessInThisThread();
#ifdef WIN32
typedef DWORD ProcRef;
static const ProcRef ProcError;
@@ -47,7 +47,7 @@ public:
Spec();
Spec(const Spec &other);
Spec &operator=(const Spec &other);
std::string program;
std::vector<std::string> args;
//std::map<std::string,std::string> environment;
@@ -64,30 +64,23 @@ public:
virtual ~EventHandler() {}
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
/*
* The terminate method
*/
/* The terminate method */
bool Terminate(const ProcRef &proc, bool graceful = 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();
protected:
// std::vector<Spec *> m_specs;
//std::vector<Spec *> m_specs;
std::map<ProcRef, Spec *> m_running; //we own the pointers in this map
void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it);
private:
static ProcLauncher s_launcher;
#ifndef WIN32
@@ -96,29 +89,5 @@ private:
#endif
};
#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()
: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)
{
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)
{
COOKIE *c = NULL;
COOKIE *c = nullptr;
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
{
c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str()))
break;
c = NULL;
c = nullptr;
}
if (c)
@@ -126,14 +126,14 @@ void HttpdCookies::replacevalue(const std::string& name,int i)
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++)
{
c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str()))
break;
c = NULL;
c = nullptr;
}
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()
{
time_t t = time(NULL);
time_t t = time(nullptr);
struct tm * tp = gmtime(&t);
const char *days[7] = {"Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+10 -10
View File
@@ -47,7 +47,7 @@ namespace SOCKETS_NAMESPACE {
HttpdForm::HttpdForm(IFile *infil) : raw(false)
{
CGI *cgi = NULL;
CGI *cgi = nullptr;
char *c_t = getenv("CONTENT_TYPE");
char *c_l = getenv("CONTENT_LENGTH");
size_t extra = 2;
@@ -59,7 +59,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
if (c_t && !strncmp(c_t, "multipart/form-data",19))
{
Parse pa(c_t,";=");
char *tempcmp = NULL;
char *tempcmp = nullptr;
size_t tc = 0;
size_t l = 0;
std::string str = pa.getword();
@@ -80,7 +80,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
std::string content_type;
std::string current_name;
std::string current_filename;
char slask[200];
char slask[2000];
infil -> fgets(slask, 200);
while (!infil -> eof())
{
@@ -209,7 +209,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
#else
sprintf(fn,"/tmp/%s",current_filename.c_str());
#endif
if ((fil = fopen(fn, "wb")) != NULL)
if ((fil = fopen(fn, "wb")) != nullptr)
{
infil -> fread(&c,1,1);
while (!infil -> eof())
@@ -353,7 +353,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
{
CGI *cgi = NULL;
CGI *cgi = nullptr;
char slask[8888];
char name[200];
int i = 0;
@@ -424,7 +424,7 @@ HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
HttpdForm::~HttpdForm()
{
CGI *cgi = NULL; //,*tmp;
CGI *cgi = nullptr; //,*tmp;
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)
{
CGI *cgi = NULL;
CGI *cgi = nullptr;
int r = 0;
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;
if (cgi -> name == n)
break;
cgi = NULL;
cgi = nullptr;
}
if (cgi)
{
@@ -572,7 +572,7 @@ std::string HttpdForm::getvalue(const std::string& n)
size_t HttpdForm::getlength(const std::string& n)
{
CGI *cgi = NULL;
CGI *cgi = nullptr;
size_t l;
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;
if (cgi -> name == n)
break;
cgi = NULL;
cgi = nullptr;
}
l = cgi ? cgi -> value.size() : 0;
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)
: HTTPSocket(ID,in_socket,irIP,irPort)
,m_content_length(0)
,m_file(NULL)
,m_file(nullptr)
,m_received(0)
,m_request_id(++m_request_count)
,m_cookies(NULL)
,m_form(NULL)
,m_cookies(nullptr)
,m_form(nullptr)
{
m_http_date = datetime2httpdate(GetDate());
if (!m_start.size())
@@ -289,7 +289,7 @@ std::string HttpdSocket::datetime2httpdate(const std::string& dt)
std::string HttpdSocket::GetDate()
{
time_t t = time(NULL);
time_t t = time(nullptr);
struct tm* tp = localtime(&t);
char slask[40];
if (tp)
@@ -315,16 +315,16 @@ void HttpdSocket::Reset()
if (m_file)
{
delete m_file;
m_file = NULL;
m_file = nullptr;
}
m_received = 0;
m_request_id = ++m_request_count;
if (m_cookies)
delete m_cookies;
m_cookies = NULL;
m_cookies = nullptr;
if (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_temporary(false)
,m_base(m_files[path])
,m_current_read(NULL)
,m_current_write(NULL)
,m_current_read(nullptr)
,m_current_write(nullptr)
,m_read_ptr(0)
,m_write_ptr(0)
{
+1 -1
View File
@@ -48,7 +48,7 @@ public:
/** File block structure.
\ingroup file */
struct block_t {
block_t() : next(NULL) {}
block_t() : next(nullptr) {}
struct block_t *next;
char data[BLOCKSIZE];
};
+1 -1
View File
@@ -37,7 +37,7 @@ Mime::Mime(const std::string& filename) {
bool Mime::LoadMimeFile(const std::string& filename) {
FILE *fil;
if ((fil = fopen(filename.c_str(),"rt")) != NULL) {
if ((fil = fopen(filename.c_str(),"rt")) != nullptr) {
char * slask = new char[1000];
fgets(slask,1000,fil);
while (!feof(fil))
+84 -84
View File
@@ -104,7 +104,7 @@ typedef struct _tagSTACKFRAME64 {
ADDRESS64 AddrFrame; // frame pointer
ADDRESS64 AddrStack; // stack 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
BOOL Far; // WOW far call
BOOL Virtual; // is this a virtual frame?
@@ -187,44 +187,44 @@ public:
StackWalkerInternal(StackWalker *parent, HANDLE hProcess)
{
m_parent = parent;
m_hDbhHelp = NULL;
pSC = NULL;
m_hDbhHelp = nullptr;
pSC = nullptr;
m_hProcess = hProcess;
m_szSymPath = NULL;
pSFTA = NULL;
pSGLFA = NULL;
pSGMB = NULL;
pSGMI = NULL;
pSGO = NULL;
pSGSFA = NULL;
pSI = NULL;
pSLM = NULL;
pSSO = NULL;
pSW = NULL;
pUDSN = NULL;
pSGSP = NULL;
m_szSymPath = nullptr;
pSFTA = nullptr;
pSGLFA = nullptr;
pSGMB = nullptr;
pSGMI = nullptr;
pSGO = nullptr;
pSGSFA = nullptr;
pSI = nullptr;
pSLM = nullptr;
pSSO = nullptr;
pSW = nullptr;
pUDSN = nullptr;
pSGSP = nullptr;
}
~StackWalkerInternal()
{
if (pSC != NULL)
if (pSC != nullptr)
pSC(m_hProcess); // SymCleanup
if (m_hDbhHelp != NULL)
if (m_hDbhHelp != nullptr)
FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL;
m_parent = NULL;
if(m_szSymPath != NULL)
m_hDbhHelp = nullptr;
m_parent = nullptr;
if(m_szSymPath != nullptr)
free(m_szSymPath);
m_szSymPath = NULL;
m_szSymPath = nullptr;
}
BOOL Init(LPCSTR szSymPath)
{
if (m_parent == NULL)
if (m_parent == nullptr)
return FALSE;
// Dynamically load the Entry-Points for dbghelp.dll:
// First try to load the newsest one from
TCHAR szTemp[4096];
// 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"));
if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
@@ -240,7 +240,7 @@ public:
}
}
// 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"));
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") );
if (m_hDbhHelp == NULL)
if (m_hDbhHelp == nullptr)
return FALSE;
pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" );
pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" );
@@ -271,18 +271,18 @@ public:
pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" );
pSGSP =(tSGSP) GetProcAddress(m_hDbhHelp, "SymGetSearchPath" );
if ( pSC == NULL || pSFTA == NULL || pSGMB == NULL || pSGMI == NULL ||
pSGO == NULL || pSGSFA == NULL || pSI == NULL || pSSO == NULL ||
pSW == NULL || pUDSN == NULL || pSLM == NULL )
if ( pSC == nullptr || pSFTA == nullptr || pSGMB == nullptr || pSGMI == nullptr ||
pSGO == nullptr || pSGSFA == nullptr || pSI == nullptr || pSSO == nullptr ||
pSW == nullptr || pUDSN == nullptr || pSLM == nullptr )
{
FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL;
pSC = NULL;
m_hDbhHelp = nullptr;
pSC = nullptr;
return FALSE;
}
// SymInitialize
if (szSymPath != NULL)
if (szSymPath != nullptr)
m_szSymPath = _strdup(szSymPath);
if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE)
this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0);
@@ -295,7 +295,7 @@ public:
symOptions = this->pSSO(symOptions);
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)
this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0);
@@ -458,10 +458,10 @@ private:
// try both dlls...
const TCHAR *dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") };
HINSTANCE hToolhelp = NULL;
tCT32S pCT32S = NULL;
tM32F pM32F = NULL;
tM32N pM32N = NULL;
HINSTANCE hToolhelp = nullptr;
tCT32S pCT32S = nullptr;
tM32F pM32F = nullptr;
tM32N pM32N = nullptr;
HANDLE hSnap;
MODULEENTRY32 me;
@@ -472,18 +472,18 @@ private:
for (i = 0; i<(sizeof(dllname) / sizeof(dllname[0])); i++ )
{
hToolhelp = LoadLibrary( dllname[i] );
if (hToolhelp == NULL)
if (hToolhelp == nullptr)
continue;
pCT32S = (tCT32S) GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot");
pM32F = (tM32F) GetProcAddress(hToolhelp, "Module32First");
pM32N = (tM32N) GetProcAddress(hToolhelp, "Module32Next");
if ( (pCT32S != NULL) && (pM32F != NULL) && (pM32N != NULL) )
if ( (pCT32S != nullptr) && (pM32F != nullptr) && (pM32N != nullptr) )
break; // found the functions!
FreeLibrary(hToolhelp);
hToolhelp = NULL;
hToolhelp = nullptr;
}
if (hToolhelp == NULL)
if (hToolhelp == nullptr)
return FALSE;
hSnap = pCT32S( TH32CS_SNAPMODULE, pid );
@@ -534,20 +534,20 @@ private:
DWORD cbNeeded;
MODULEINFO mi;
HMODULE *hMods = 0;
char *tt = NULL;
char *tt2 = NULL;
char *tt = nullptr;
char *tt2 = nullptr;
const SIZE_T TTBUFLEN = 8096;
int cnt = 0;
hPsapi = LoadLibrary( _T("psapi.dll") );
if (hPsapi == NULL)
if (hPsapi == nullptr)
return FALSE;
pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" );
pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" );
pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" );
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
FreeLibrary(hPsapi);
@@ -557,7 +557,7 @@ private:
hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE));
tt = (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;
if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) )
@@ -590,10 +590,10 @@ private:
}
cleanup:
if (hPsapi != NULL) FreeLibrary(hPsapi);
if (tt2 != NULL) free(tt2);
if (tt != NULL) free(tt);
if (hMods != NULL) free(hMods);
if (hPsapi != nullptr) FreeLibrary(hPsapi);
if (tt2 != nullptr) free(tt2);
if (tt != nullptr) free(tt);
if (hMods != nullptr) free(hMods);
return cnt != 0;
} // GetModuleListPSAPI
@@ -603,7 +603,7 @@ private:
CHAR *szImg = _strdup(img);
CHAR *szMod = _strdup(mod);
DWORD result = ERROR_SUCCESS;
if ( (szImg == NULL) || (szMod == NULL) )
if ( (szImg == nullptr) || (szMod == nullptr) )
result = ERROR_NOT_ENOUGH_MEMORY;
else
{
@@ -611,25 +611,25 @@ private:
result = GetLastError();
}
ULONGLONG fileVersion = 0;
if ( (m_parent != NULL) && (szImg != NULL) )
if ( (m_parent != nullptr) && (szImg != nullptr) )
{
// try to retrive the file-version:
if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0)
{
VS_FIXEDFILEINFO *fInfo = NULL;
VS_FIXEDFILEINFO *fInfo = nullptr;
DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle);
if (dwSize > 0)
{
LPVOID vData = malloc(dwSize);
if (vData != NULL)
if (vData != nullptr)
{
if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
{
UINT len;
TCHAR szSubBlock[] = _T("\\");
if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
fInfo = NULL;
fInfo = nullptr;
else
{
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);
}
if (szImg != NULL) free(szImg);
if (szMod != NULL) free(szMod);
if (szImg != nullptr) free(szImg);
if (szMod != nullptr) free(szMod);
return result;
}
public:
@@ -695,7 +695,7 @@ public:
BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo)
{
if(this->pSGMI == NULL)
if(this->pSGMI == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE;
@@ -703,7 +703,7 @@ public:
// First try to use the larger ModuleInfo-Structure
// memset(pModuleInfo, 0, 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)
// return TRUE;
@@ -714,7 +714,7 @@ public:
// could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)...
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...
if (pData == NULL)
if (pData == nullptr)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -742,7 +742,7 @@ StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess)
this->m_hProcess = hProcess;
this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId;
this->m_szSymPath = NULL;
this->m_szSymPath = nullptr;
}
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_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId;
if (szSymPath != NULL)
if (szSymPath != nullptr)
{
this->m_szSymPath = _strdup(szSymPath);
this->m_options |= SymBuildPath;
}
else
this->m_szSymPath = NULL;
this->m_szSymPath = nullptr;
}
StackWalker::~StackWalker()
{
if (m_szSymPath != NULL)
if (m_szSymPath != nullptr)
free(m_szSymPath);
m_szSymPath = NULL;
if (this->m_sw != NULL)
m_szSymPath = nullptr;
if (this->m_sw != nullptr)
delete this->m_sw;
this->m_sw = NULL;
this->m_sw = nullptr;
}
BOOL StackWalker::LoadModules()
{
if (this->m_sw == NULL)
if (this->m_sw == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE;
@@ -781,19 +781,19 @@ BOOL StackWalker::LoadModules()
return TRUE;
// Build the sym-path:
char *szSymPath = NULL;
char *szSymPath = nullptr;
if ( (this->m_options & SymBuildPath) != 0)
{
const size_t nSymPathLen = 4096;
szSymPath = (char*) malloc(nSymPathLen);
if (szSymPath == NULL)
if (szSymPath == nullptr)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
szSymPath[0] = 0;
// 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, ";");
@@ -812,7 +812,7 @@ BOOL StackWalker::LoadModules()
}
// Now add the path for the main-module:
if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0)
if (GetModuleFileNameA(nullptr, szTemp, nTempLen) > 0)
{
szTemp[nTempLen-1] = 0;
for (char *p = (szTemp+strlen(szTemp)-1); p >= szTemp; --p)
@@ -870,7 +870,7 @@ BOOL StackWalker::LoadModules()
// First Init the whole stuff...
BOOL bRet = this->m_sw->Init(szSymPath);
if (szSymPath != NULL) free(szSymPath); szSymPath = NULL;
if (szSymPath != nullptr) free(szSymPath); szSymPath = nullptr;
if (bRet == FALSE)
{
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...
// 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
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL;
static LPVOID s_readMemoryFunction_UserData = NULL;
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = nullptr;
static LPVOID s_readMemoryFunction_UserData = nullptr;
BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData)
{
CONTEXT c;;
CallstackEntry csEntry;
IMAGEHLP_SYMBOL64 *pSym = NULL;
IMAGEHLP_SYMBOL64 *pSym = nullptr;
StackWalkerInternal::IMAGEHLP_MODULE64_V2 Module;
IMAGEHLP_LINE64 Line;
int frameNum;
@@ -904,7 +904,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
if (m_modulesLoaded == FALSE)
this->LoadModules(); // ignore the result...
if (this->m_sw->m_hDbhHelp == NULL)
if (this->m_sw->m_hDbhHelp == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE;
@@ -913,7 +913,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
s_readMemoryFunction = readMemoryFunction;
s_readMemoryFunction_UserData = pUserData;
if (context == NULL)
if (context == nullptr)
{
// If no context is provided, capture the context
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
// deeper frame could not be found.
// 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);
break;
@@ -1028,7 +1028,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
}
// show line number info, NT5.0-method (SymGetLineFromAddr64())
if (this->m_sw->pSGLFA != NULL )
if (this->m_sw->pSGLFA != nullptr )
{ // yes, we have SymGetLineFromAddr64()
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;
default:
//_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType );
csEntry.symTypeString = NULL;
csEntry.symTypeString = nullptr;
break;
}
@@ -1109,7 +1109,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
cleanup:
if (pSym) free( pSym );
if (context == NULL)
if (context == nullptr)
ResumeThread(hThread);
return TRUE;
@@ -1123,7 +1123,7 @@ BOOL __stdcall StackWalker::myReadProcMem(
LPDWORD lpNumberOfBytesRead
)
{
if (s_readMemoryFunction == NULL)
if (s_readMemoryFunction == nullptr)
{
SIZE_T st;
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);
+6 -6
View File
@@ -66,7 +66,7 @@ public:
StackWalker(
int options = OptionsAll, // 'int' is by design, to combine the enum-flags
LPCSTR szSymPath = NULL,
LPCSTR szSymPath = nullptr,
DWORD dwProcessId = GetCurrentProcessId(),
HANDLE hProcess = GetCurrentProcess()
);
@@ -86,9 +86,9 @@ public:
BOOL ShowCallstack(
HANDLE hThread = GetCurrentThread(),
const CONTEXT *context = NULL,
PReadProcessMemoryRoutine readMemoryFunction = NULL,
LPVOID pUserData = NULL // optional to identify some data in the 'readMemoryFunction'-callback
const CONTEXT *context = nullptr,
PReadProcessMemoryRoutine readMemoryFunction = nullptr,
LPVOID pUserData = nullptr // optional to identify some data in the 'readMemoryFunction'-callback
);
#if _MSC_VER >= 1300
@@ -157,11 +157,11 @@ protected:
#define GET_CURRENT_CONTEXT(c, contextFlags) \
do { \
memset(&c, 0, sizeof(CONTEXT)); \
EXCEPTION_POINTERS *pExp = NULL; \
EXCEPTION_POINTERS *pExp = nullptr; \
__try { \
throw 0; \
} __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
if (pExp != NULL) \
if (pExp != nullptr) \
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
c.ContextFlags = contextFlags; \
} while(0);
+386
View File
@@ -0,0 +1,386 @@
/*
* 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 <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(const char* num) {
if (num == nullptr)
return 0;
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(const char* num) {
if (num == nullptr)
return 0;
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(const char* iBool) {
if (iBool == nullptr)
return false;
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;
}
std::vector<std::string> SplitString(const std::string &str, char delim) {
std::vector<std::string> ret;
std::stringstream ss(str);
std::string item;
while(std::getline(ss, item, delim)) {
ret.push_back(item);
}
return ret;
}
std::string EscapeString(const std::string &s) {
std::string ret;
size_t sz = s.length();
for(size_t i = 0; i < sz; ++i) {
char c = s[i];
switch(c) {
case '\x00':
ret += "\\x00";
break;
case '\n':
ret += "\\n";
break;
case '\r':
ret += "\\r";
break;
case '\\':
ret += "\\\\";
break;
case '\'':
ret += "\\'";
break;
case '\"':
ret += "\\\"";
break;
case '\x1a':
ret += "\\x1a";
break;
default:
ret.push_back(c);
break;
}
}
return ret;
}
+54
View File
@@ -0,0 +1,54 @@
/*
* 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 <sstream>
#include <vector>
#include <cstdarg>
#include "types.h"
void vStringFormat(std::string& output, const char* format, va_list args);
void StringFormat(std::string& output, const char* format, ...);
std::string EscapeString(const std::string &s);
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(const char* num);
uint64 hextoi64(const char* num);
bool atobool(const 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);
std::vector<std::string> SplitString(const std::string &s, char delim);
#endif
+11 -11
View File
@@ -28,13 +28,13 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
proc(p);
}
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
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()));
delete p;
}
@@ -56,21 +56,21 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies;
static std::map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs;
}
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);
if(res == strategies.end())
return(NULL);
return(nullptr);
return(res->second);
}
};
+6 -6
View File
@@ -14,18 +14,18 @@ public:
typedef void (*Encoder)(EQApplicationPacket **p, EQStream *dest, bool ack_req);
//the decoder may only edit the supplied packet, producing a single packet for eqemu to consume.
typedef void (*Decoder)(EQApplicationPacket *p);
StructStrategy();
virtual ~StructStrategy() {}
//this method takes an eqemu struct, and enqueues the produced structs into the stream.
void Encode(EQApplicationPacket **p, EQStream *dest, bool ack_req) const;
//this method takes an EQ wire struct, and converts it into an eqemu struct
void Decode(EQApplicationPacket *p) const;
virtual std::string Describe() const = 0;
virtual const EQClientVersion ClientVersion() const = 0;
protected:
//some common coders:
//Print an error saying unknown struct/opcode and drop it
@@ -34,7 +34,7 @@ protected:
//pass the packet through without modification (emu == EQ) (default)
static void PassEncoder(EQApplicationPacket **p, EQStream *dest, bool ack_req);
static void PassDecoder(EQApplicationPacket *p);
Encoder encoders[_maxEmuOpcode];
Decoder decoders[_maxEmuOpcode];
};
@@ -42,7 +42,7 @@ protected:
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs);
//does NOT return ownership of the strategy.
const StructStrategy *FindPatch(EmuOpcode first_opcode);
};
+82 -96
View File
@@ -1,28 +1,26 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 <string.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
#include "TCPConnection.h"
#include "../common/servertalk.h"
@@ -32,6 +30,10 @@ using namespace std;
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#define MSG_NOSIGNAL 0
#endif
#ifdef DARWIN
#define MSG_NOSIGNAL SO_NOSIGPIPE // Corysia Taware - Sept. 27, 2013
// See http://lists.apple.com/archives/macnetworkprog/2002/Dec/msg00091.html
#endif // DARWIN
#ifdef _WINDOWS
InitWinsock winsock;
@@ -47,45 +49,45 @@ InitWinsock winsock;
//client version
TCPConnection::TCPConnection()
: ConnectionType(Outgoing),
connection_socket(0),
id(0),
rIP(0),
rPort(0)
: ConnectionType(Outgoing),
connection_socket(0),
id(0),
rIP(0),
rPort(0)
{
pState = TCPS_Ready;
pFree = false;
pEcho = false;
recvbuf = NULL;
sendbuf = NULL;
recvbuf = nullptr;
sendbuf = nullptr;
pRunLoop = false;
charAsyncConnect = 0;
pAsyncConnect = false;
m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl;
#endif
}
//server version
TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: ConnectionType(Incomming),
connection_socket(in_socket),
id(ID),
rIP(irIP),
rPort(irPort)
: ConnectionType(Incomming),
connection_socket(in_socket),
id(ID),
rIP(irIP),
rPort(irPort)
{
pState = TCPS_Connected;
pFree = false;
pEcho = false;
recvbuf = NULL;
sendbuf = NULL;
recvbuf = nullptr;
sendbuf = nullptr;
pRunLoop = false;
charAsyncConnect = 0;
pAsyncConnect = false;
m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on incoming TCP# " << GetID() << endl;
std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl;
#endif
}
@@ -99,12 +101,12 @@ TCPConnection::~TCPConnection() {
MLoopRunning.lock();
MLoopRunning.unlock();
#if TCPN_DEBUG_Memory >= 6
cout << "Deconstructor on outgoing TCP# " << GetID() << endl;
std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl;
#endif
}
#if TCPN_DEBUG_Memory >= 5
else {
cout << "Deconstructor on incomming TCP# " << GetID() << endl;
std::cout << "Deconstructor on incomming TCP# " << GetID() << std::endl;
}
#endif
safe_delete_array(recvbuf);
@@ -165,12 +167,6 @@ bool TCPConnection::GetSockName(char *host, uint16 *port)
}
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();
pFree = true;
}
@@ -186,7 +182,7 @@ bool TCPConnection::Send(const uchar* data, int32 size) {
void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) {
MSendQueue.lock();
if (sendbuf == NULL) {
if (sendbuf == nullptr) {
sendbuf = new uchar[size];
sendbuf_size = size;
sendbuf_used = 0;
@@ -362,7 +358,6 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems
// Crash and burn.
ThrowError("TCPConnection::AsyncConnect() call on a Incomming connection object!");
return;
}
if(!ConnectReady()) {
@@ -394,7 +389,7 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
_beginthread(TCPConnectionLoop, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this);
pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif
}
return;
@@ -423,7 +418,6 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems
// Crash and burn.
ThrowError("TCPConnection::Connect() call on a Incomming connection object!");
return false;
}
MState.lock();
@@ -441,13 +435,13 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
_beginthread(TCPConnectionLoop, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this);
pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif
}
connection_socket = INVALID_SOCKET;
struct sockaddr_in server_sin;
// struct in_addr in;
struct sockaddr_in server_sin;
//struct in_addr in;
if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) {
#ifdef _WINDOWS
@@ -498,7 +492,7 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
SetEcho(false);
ClearBuffers();
rIP = in_ip;
rPort = in_port;
SetState(TCPS_Connected);
@@ -512,7 +506,7 @@ void TCPConnection::ClearBuffers() {
LockMutex lock4(&MState);
safe_delete_array(recvbuf);
safe_delete_array(sendbuf);
char* line = 0;
while ((line = LineOutQueue.pop()))
safe_delete_array(line);
@@ -528,7 +522,7 @@ bool TCPConnection::CheckNetActive() {
return false;
}
/* This is always called from an IO thread. Either the server socket's thread, or a
/* This is always called from an IO thread. Either the server socket's thread, or a
* special thread we create when we make an outbound connection. */
bool TCPConnection::Process() {
char errbuf[TCPConnection_ErrorBufferSize];
@@ -543,18 +537,18 @@ bool TCPConnection::Process() {
}
}
return(true);
case TCPS_Connected:
// only receive data in the connected state, no others...
if (!RecvData(errbuf)) {
struct in_addr in;
struct in_addr in;
in.s_addr = GetrIP();
//cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
//std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
return false;
}
/* we break to do the send */
break;
case TCPS_Disconnecting: {
//waiting for any sending data to go out...
MSendQueue.lock();
@@ -570,7 +564,7 @@ bool TCPConnection::Process() {
MSendQueue.unlock();
}
/* Fallthrough */
case TCPS_Disconnected:
FinishDisconnect();
MRunLoop.lock();
@@ -578,27 +572,27 @@ bool TCPConnection::Process() {
MRunLoop.unlock();
// SetState(TCPS_Ready); //reset the state in case they want to use it again...
return(false);
case TCPS_Closing:
//I dont understand this state...
case TCPS_Error:
MRunLoop.lock();
pRunLoop = false;
MRunLoop.unlock();
return(false);
}
/* we get here in connected or disconnecting with more data to send */
bool sent_something = false;
if (!SendData(sent_something, errbuf)) {
struct in_addr in;
struct in_addr in;
in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
return false;
}
return true;
}
@@ -629,15 +623,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
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_IN == 2
int32 tmp = status;
if (tmp > 32)
@@ -650,7 +644,7 @@ bool TCPConnection::RecvData(char* errbuf) {
recvbuf_used += status;
if (!ProcessReceivedData(errbuf))
return false;
}
}
else if (status == SOCKET_ERROR) {
#ifdef _WINDOWS
if (!(WSAGetLastError() == WSAEWOULDBLOCK)) {
@@ -691,7 +685,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
return true;
#if TCPN_DEBUG_Console >= 4
if (recvbuf_used) {
cout << "Starting Processing: recvbuf=" << recvbuf_used << endl;
std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
#endif
@@ -723,13 +717,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
}
}
#if TCPN_DEBUG_Console >= 5
cout << "Removed 0x00" << endl;
std::cout << "Removed 0x00" << std::endl;
if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl;
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
else
cout << "recbuf left: None" << endl;
std::cout << "recbuf left: None" << std::endl;
#endif
m_previousLineEnd = false;
break;
@@ -737,7 +731,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
case 10:
case 13: // newline marker
{
char *line = NULL;
char *line = nullptr;
if (i==0) { // empty line
if(!m_previousLineEnd) {
//char right before this was NOT a CR, report the empty line.
@@ -756,7 +750,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
memset(line, 0, i+1);
memcpy(line, recvbuf, i);
#if TCPN_DEBUG_Console >= 3
cout << "Line Out: " << endl;
std::cout << "Line Out: " << std::endl;
DumpPacket((uchar*) line, i);
#endif
//line[i] = 0;
@@ -766,27 +760,27 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
recvbuf_echo -= i+1;
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
#if TCPN_DEBUG_Console >= 5
cout << "i+1=" << i+1 << endl;
std::cout << "i+1=" << i+1 << std::endl;
if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl;
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
else
cout << "recbuf left: None" << endl;
std::cout << "recbuf left: None" << std::endl;
#endif
safe_delete_array(tmpdel);
i = -1;
m_previousLineEnd = true;
}
if(line != NULL) {
if(line != nullptr) {
bool finish_proc = false;
finish_proc = LineOutQueuePush(line);
if(finish_proc)
return(true); //break early as requested by LineOutQueuePush
}
break;
}
case 8: // backspace
@@ -837,8 +831,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_OUT == 2
int32 tmp = status;
if (tmp > 32)
@@ -854,15 +848,14 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#endif
// 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
ServerSendQueuePushFront(&data[status], size - status);
}
else if (status > (signed)size) {
ThrowError("TCPConnection::SendData(): WTF! status > size");
return false;
}
// else if (status == size) {}
@@ -886,13 +879,13 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %s", strerror(errno));
#endif
}
//if we get an error while disconnecting, just jump to disconnected
MState.lock();
if(pState == TCPS_Disconnecting)
pState = TCPS_Disconnected;
MState.unlock();
return false;
}
}
@@ -905,8 +898,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif
if (tmp == 0) {
ThrowError("TCPConnectionLoop(): tmp = 0!");
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
TCPConnection* tcpc = (TCPConnection*) tmp;
#ifndef WIN32
@@ -916,9 +908,8 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
while (tcpc->RunLoop()) {
Sleep(LOOP_GRANULARITY);
if (!tcpc->ConnectReady()) {
_CP(TCPConnectionLoop);
if (!tcpc->Process()) {
//the processing loop has detecting an error..
//the processing loop has detecting an error..
//we want to drop the link immediately, so we clear buffers too.
tcpc->ClearBuffers();
tcpc->Disconnect();
@@ -926,7 +917,6 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
Sleep(1);
}
else if (tcpc->GetAsyncConnect()) {
_CP(TCPConnectionLoop);
if (tcpc->charAsyncConnect)
tcpc->Connect(tcpc->charAsyncConnect, tcpc->GetrPort());
else
@@ -937,12 +927,12 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
Sleep(10); //nothing to do.
}
tcpc->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
bool TCPConnection::RunLoop() {
@@ -953,7 +943,3 @@ bool TCPConnection::RunLoop() {
return ret;
}
+27 -32
View File
@@ -1,34 +1,31 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is 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
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.
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
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 TCP_CONNECTION_H
#define TCP_CONNECTION_H
/*
Parent classes for interserver TCP Communication.
-Quagmire
Parent classes for interserver TCP Communication.
-Quagmire
*/
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#include <process.h>
#else
@@ -75,15 +72,15 @@ protected:
TCPS_Closing = 250,
TCPS_Error = 255
} State_t;
public:
//socket created by a server (incoming)
TCPConnection(uint32 ID, SOCKET iSock, uint32 irIP, uint16 irPort);
//socket created to connect to a server (outgoing)
TCPConnection(); // for outgoing connections
virtual ~TCPConnection();
// Functions for outgoing connections
bool Connect(const char* irAddress, uint16 irPort, char* errbuf = 0);
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
@@ -92,7 +89,7 @@ public:
virtual void Disconnect();
bool Send(const uchar* data, int32 size);
char* PopLine(); //returns ownership of allocated byte array
inline uint32 GetrIP() const { return rIP; }
inline uint16 GetrPort() const { return rPort; }
@@ -106,7 +103,7 @@ public:
bool GetEcho();
void SetEcho(bool iValue);
bool GetSockName(char *host, uint16 *port);
//should only be used by TCPServer<T>:
bool CheckNetActive();
inline bool IsFree() const { return pFree; }
@@ -129,10 +126,10 @@ protected:
virtual bool ProcessReceivedData(char* errbuf = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0);
virtual void ClearBuffers();
bool m_previousLineEnd;
eConnectionType ConnectionType;
@@ -144,22 +141,22 @@ protected:
uint32 rIP;
uint16 rPort; // host byte order
bool pFree;
mutable Mutex MState;
State_t pState;
//text based line out queue.
Mutex MLineOutQueue;
virtual bool LineOutQueuePush(char* line); //this is really kinda a hack for the transition to packet mode. Returns true to stop processing the output.
MyQueue<char> LineOutQueue;
uchar* recvbuf;
int32 recvbuf_size;
int32 recvbuf_used;
int32 recvbuf_echo;
volatile bool pEcho;
Mutex MSendQueue;
uchar* sendbuf;
int32 sendbuf_size;
@@ -169,7 +166,7 @@ protected:
void ServerSendQueuePushEnd(const uchar* data, int32 size);
void ServerSendQueuePushEnd(uchar** data, int32 size);
void ServerSendQueuePushFront(uchar* data, int32 size);
private:
void FinishDisconnect();
};
@@ -177,5 +174,3 @@ private:
#endif
+22 -27
View File
@@ -1,5 +1,3 @@
#include "debug.h"
#include "TCPServer.h"
#include <stdio.h>
@@ -18,12 +16,8 @@
#define SOCKET_ERROR -1
#endif
#define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues
BaseTCPServer::BaseTCPServer(uint16 in_port) {
NextID = 1;
pPort = in_port;
@@ -33,7 +27,7 @@ BaseTCPServer::BaseTCPServer(uint16 in_port) {
_beginthread(BaseTCPServer::TCPServerLoop, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &BaseTCPServer::TCPServerLoop, this);
pthread_create(&thread, nullptr, &BaseTCPServer::TCPServerLoop, this);
#endif
}
@@ -67,28 +61,26 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif
if (tmp == 0) {
// ThrowError("BaseTCPServerLoop(): tmp = 0!");
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
BaseTCPServer* tcps = (BaseTCPServer*) tmp;
#ifndef WIN32
_log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self());
#endif
tcps->MLoopRunning.lock();
while (tcps->RunLoop()) {
_CP(BaseTCPServerLoop);
Sleep(SERVER_LOOP_GRANULARITY);
tcps->Process();
}
tcps->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(NULL);
THREAD_RETURN(nullptr);
}
void BaseTCPServer::Process() {
@@ -96,17 +88,21 @@ void BaseTCPServer::Process() {
}
void BaseTCPServer::ListenNewConnections() {
SOCKET tmpsock;
struct sockaddr_in from;
struct in_addr in;
unsigned int fromlen;
unsigned short port;
from.sin_family = AF_INET;
fromlen = sizeof(from);
SOCKET tmpsock;
struct sockaddr_in from;
struct in_addr in;
unsigned int fromlen;
unsigned short port;
from.sin_family = AF_INET;
fromlen = sizeof(from);
LockMutex lock(&MSock);
#ifndef DARWIN // Corysia - On OSX, 0 is a valid fd.
if (!sock)
return;
#else
if (sock == -1) return;
#endif
// Check for pending connects
#ifdef _WINDOWS
@@ -125,7 +121,7 @@ void BaseTCPServer::ListenNewConnections() {
setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
port = from.sin_port;
in.s_addr = from.sin_addr.s_addr;
// New TCP connection, this must consume the socket.
CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port));
}
@@ -152,7 +148,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
#endif
int reuse_addr = 1;
// Setup internet address information.
// Setup internet address information.
// This is used with the bind() call
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
@@ -212,7 +208,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
void BaseTCPServer::Close() {
StopLoopAndWait();
LockMutex lock(&MSock);
if (sock) {
#ifdef _WINDOWS
@@ -231,4 +227,3 @@ bool BaseTCPServer::IsOpen() {
return ret;
}
+17 -17
View File
@@ -22,17 +22,17 @@ public:
protected:
static ThreadReturnType TCPServerLoop(void* tmp);
//factory method:
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) = 0;
virtual void Process();
bool RunLoop();
Mutex MLoopRunning;
void StopLoopAndWait();
void ListenNewConnections();
uint32 NextID;
@@ -55,23 +55,23 @@ public:
TCPServer(uint16 iPort = 0)
: BaseTCPServer(iPort) {
}
virtual ~TCPServer() {
StopLoopAndWait();
//im not sure what the right thing to do here is...
//we are freeing a connection which somebody likely has a pointer to..
//but, we really shouldent ever get called anyhow..
vitr cur, end;
cur = m_list.begin();
end = m_list.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
delete *cur;
}
}
T * NewQueuePop() {
T * ret = NULL;
T * ret = nullptr;
MNewQueue.lock();
if(!m_NewQueue.empty()) {
ret = m_NewQueue.front();
@@ -80,40 +80,40 @@ public:
MNewQueue.unlock();
return ret;
}
protected:
virtual void Process() {
BaseTCPServer::Process();
vitr cur;
cur = m_list.begin();
while(cur != m_list.end()) {
T *data = *cur;
if (data->IsFree() && (!data->CheckNetActive())) {
#if EQN_DEBUG >= 4
cout << "TCPConnection Connection deleted." << endl;
std::cout << "TCPConnection Connection deleted." << std::endl;
#endif
delete data;
cur = m_list.erase(cur);
} else {
if (!data->Process())
data->Disconnect();
cur++;
++cur;
}
}
}
void AddConnection(T *con) {
m_list.push_back(con);
MNewQueue.lock();
m_NewQueue.push(con);
MNewQueue.unlock();
}
//queue of new connections, for the app to pull from
Mutex MNewQueue;
std::queue<T *> m_NewQueue;
vstore m_list;
};
+37 -37
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 "debug.h"
#include "XMLParser.h"
@@ -23,22 +23,22 @@ XMLParser::XMLParser() {
}
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 );
if(!doc.LoadFile()) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
return(false);
}
TiXmlElement *root = doc.FirstChildElement( root_ele );
if(root == NULL) {
if(root == nullptr) {
printf("Unable to find root '%s' in %s\n",root_ele, file);
return(false);
}
ParseOkay=true;
TiXmlNode *main_element = NULL;
TiXmlNode *main_element = nullptr;
while( (main_element = root->IterateChildren( main_element )) ) {
if(main_element->Type() != TiXmlNode::ELEMENT)
continue; //skip crap we dont care about
@@ -47,54 +47,54 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
handler=Handlers.find(ele->Value());
if (handler!=Handlers.end() && handler->second) {
ElementHandler h=handler->second;
/*
*
* This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance.
*
*
*/
*
* This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance.
*
*
*/
(this->*h)(ele);
} else {
//unhandled element.... do nothing for now
}
}
return(ParseOkay);
}
const char *XMLParser::ParseTextBlock(TiXmlNode *within, const char *name, bool optional) {
TiXmlElement * txt = within->FirstChildElement(name);
if(txt == NULL) {
if(txt == nullptr) {
if(!optional) {
printf("Unable to find a '%s' element on %s element at line %d\n", name, within->Value(), within->Row());
ParseOkay=false;
}
return(NULL);
return(nullptr);
}
TiXmlNode *contents = txt->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) {
if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional)
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());
}
const char *XMLParser::GetText(TiXmlNode *within, bool optional) {
TiXmlNode *contents = within->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) {
if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional) {
printf("Node was expected to be a text element in %s element at line %d\n", within->Value(), within->Row());
ParseOkay=false;
}
return(NULL);
return(nullptr);
}
return(contents->Value());
}
+20 -27
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* 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
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
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 XMLParser_H
#define XMLParser_H
@@ -24,36 +24,29 @@
#include <string>
#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 {
public:
typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele);
XMLParser();
virtual ~XMLParser() {}
bool ParseFile(const char *file, const char *root_ele);
bool ParseStatus() const { return ParseOkay; }
protected:
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false);
map<string,ElementHandler> Handlers;
std::map<std::string,ElementHandler> Handlers;
bool ParseOkay;
};
};
#endif

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