Compare commits

..
Author SHA1 Message Date
David Anderson 5abec70579 Bumped for release. 2010-05-02 14:16:34 -07:00
Nicholas Hastings 8800d5311c Added TF2_StunPlayer native and TF2_GetPlayerConditionFlags stock to TF2 ext. (bug 4331, r=pred) 2010-03-31 08:51:25 -04:00
Nicholas Hastings 3705210879 Added 4 new natives to TF2 ext. (bug 4166, r=pred)
Added natives for Regenerate, add/remove condition, and SetPlayerPowerPlay. Also updated TF2 test plugin.
2010-03-18 11:35:05 -04:00
Scott Ehlert 5f4befcb6a Argh, really fixed HookEntityOutput() crash on TF2 (bug 4375). 2010-04-30 10:54:34 -04:00
Scott Ehlert 314011f118 Fixed HookEntityOutput() crash with recent updates to TF2 and L4D2 (bug 4375, r=pred, a=blocking). 2010-04-30 03:51:01 -04:00
Fyren a9b7a5dc5c Triggering build 2010-04-29 20:55:16 -07:00
Scott Ehlert 9b78c68b1b Updated sample extension makefiles to compile against latest changes for L4D2 and TF2 (bug 4374, r=dvander). 2010-04-29 16:04:47 -04:00
Nicholas Hastings 328109be1f Fixed SetUserCvar offset for ep2v (bug 4371, r=fyren) 2010-04-29 14:17:44 -04:00
Nicholas Hastings aba0f29666 ep2v gamedata (bug 4371, r=fyren) 2010-04-28 23:48:26 -07:00
Fyren bdefb58e5f ep2v build changes (bug 4371, r=dvander) 2010-04-28 19:44:20 -07:00
David Anderson 7ad3a57c47 Check return value of GetPlayerNetInfo (bug 4315, r=fyren). 2010-04-27 23:40:04 -07:00
Nicholas Hastings 5a2f3cf433 Fixed entity output hooks not working in Insurgency (bug 4365, r=fyren) 2010-04-24 21:10:15 -04:00
Nicholas Hastings fffc27a348 Added obsidian to list of games which support tempents with ep2 gamedata (thread 75480, r=me). 2010-04-24 21:08:13 -04:00
Nicholas Hastings cecb7cb6a2 Fixed functions.inc not having double-include prevention (bug 4342, r=fyren) 2010-04-24 21:05:48 -04:00
Zach Kanzler f5cc5eb757 Fixed IGamePlayer->GetUserId() returning junk (bug 3916, r=fyren) 2010-04-24 21:02:40 -04:00
Nicholas Hastings 689406744b Updated L4D2 gamedata for The Passing update (bug 4361, r=pending) 2010-04-23 12:11:49 -04:00
Nicholas Hastings 603da899b7 Updated Insurgency gamedata for Insurgency 2010-04-19 update (bug 4356, r=fyren) 2010-04-23 10:38:37 -04:00
Fyren 9b4d1f6972 Build stuff for L4D2 DLC (bug 4361, r=what's a review?) 2010-04-23 07:33:58 -07:00
David Anderson d56b222637 Merge backout. 2010-04-23 02:31:15 -04:00
David Anderson dfefda81e1 Backed out changeset 6b5fa86c1a0d (bug 4315). 2010-04-23 02:31:07 -04:00
David Anderson 0c463b1f86 Merge. 2010-04-22 17:55:55 -04:00
David Anderson bf345eea8c Attempting fix for SendConVarValue crash (bug 4315, r=fyren, a13=me). 2010-04-22 17:55:35 -04:00
Nicholas Hastings 5328447b74 Merge 2010-04-19 11:15:51 -04:00
Nicholas Hastings db6881b7e3 Updated Empires gamedata for Empires 2.25a release (bug 4108, r=fyren) 2010-04-19 10:38:50 -04:00
David Anderson 3e96b1617a Added obsidian to list of games which need menu redraws (thread 123237, r=me). 2010-04-04 23:51:20 -07:00
Nicholas Hastings 7ef8b415bb Added Gamerules SDKCall support to CSPromod gamedata (bug 4320, r=pred) 2010-03-23 19:42:58 -04:00
Nicholas Hastings 9a5d6957b9 Fixed bad caller crash with HookEntityOutput (bug 4311, r=fyren) 2010-03-20 11:08:48 -04:00
Nicholas Hastings b5a2ec7a5e Added missing core voting cvars to sourcemod.cfg (bug 4309, r=fyren) 2010-03-11 22:01:11 -05:00
Nicholas Hastings 373136af4e Added missing core voting cvars to sourcemod.cfg (bug 4224, r=pred) 2010-03-11 17:44:41 -05:00
Nicholas Hastings 8673c11341 Fixed incorrect DispatchSpawn signature for ZPS and added ShowMenu and Hudtext support (bug 4279, r=Fyren) 2010-03-09 20:40:06 -05:00
Nicholas Hastings 8c082de148 Re-enabled ShowMenu support for FortressForever (bug 4028, r=dvander) 2010-03-09 18:50:57 -05:00
Nicholas Hastings e62d47a85e Fixed FireOutput signature for FortressForever (bug 4062, r=dvander) 2010-03-09 18:48:03 -05:00
Nicholas Hastings 2d32c587ba Fixed sm_rename on L4D2 on Windows (bug 4131, r=dvander) 2010-03-09 18:44:28 -05:00
Nicholas Hastings 31e29ee94c Fixed inaccurate description for sm_unban (bug 4245, r=dvander) 2010-03-09 18:41:43 -05:00
Nicholas Hastings e95e453258 Fixed CSPromod SDKTools Support (bug 4255, r=dvander) 2010-03-09 18:36:51 -05:00
Nicholas Hastings 48b0f61551 Updated PVKII support for PVKII 2.3 (bug 4276, r=dvander) 2010-03-09 18:30:15 -05:00
Nicholas Hastings ef88fc21a1 Fixed CreateGameRulesObject sig for ZPS (bug 4285, r=dvander). 2010-03-09 18:15:23 -05:00
Erik Minekus 558c8c9745 Fixed Insurgency gamedata file (bug 4282, r+a13=dvander). 2010-02-24 23:41:06 -08:00
Fyren 2f60680cfb maxClients -> MaxClients in sdktools_sound.inc (fix bug 3985, r=psychonicsux) 2010-02-10 10:53:54 -08:00
David Anderson 1ffcf7a664 Bumped version to 1.3.2-dev. 2010-02-09 22:00:28 -08:00
David Anderson c00b688ab7 Added tag sourcemod-1.3.1 for changeset 3f33d01fcc28 2010-02-09 21:59:41 -08:00
David Anderson 4169e25451 Removed -dev tag for release. 2010-02-09 21:12:39 -08:00
David Anderson 85fc65bae5 Updated changelog for 1.3.1. 2010-02-08 20:58:15 -08:00
Nicholas Hastings aed62d5670 Added missing file for Battlegrounds support (bug 4146). 2010-02-08 20:47:51 -08:00
Nicholas Hastings 01d46b8c9c Added SDKTools support for CSProMod (bug 4255, r+a13=dvander) 2010-02-08 20:25:11 -08:00
Nicholas Hastings f70b48276e Fixed base plugins using GetMaxClients() instead of MaxClients (bug 3985, r+a13=dvander). 2010-02-08 20:14:52 -08:00
Nicholas Hastings f0070e45a0 Fixed CreateEntityByName for Insurgency (bug 4180, r+a13=dvander). 2010-02-08 20:10:24 -08:00
Nicholas Hastings 11782cee90 Updated Garry's Mod offsets (bug 4230, r+a13=dvander). 2010-02-08 20:08:14 -08:00
Nicholas Hastings 24b86584a2 Fixed nextmap errors on Garry's Mod (bug 4268, r+a13=dvander). 2010-02-08 20:06:48 -08:00
Fyren 01b3eee1b8 Compiler confused |any| tag with |String| on array arguments (bug 4274, r=dvander, a13=blocking). 2010-02-08 20:00:06 -08:00
David Anderson 2fb3f8ab0f Fixed GetClientCookieTime not being exported (bug 4237, r=fyren, a13=blocking). 2010-02-08 19:58:36 -08:00
Nicholas Hastings 2c7b0e04e9 Fixed FindEntityByClassname crash in Synergy (bug 4235, r=dvander, a13=blocking). 2010-02-08 19:57:20 -08:00
Fyren 9f3e9a2ff4 Fixed NULL-deref in entity handling code (bug 4249, r=dvander, a13=blocking). 2010-02-08 19:55:14 -08:00
Nicholas Hastings d9d5b65f2c Fixed Day of Defeat offsets for 20100203 update (bug 4262, r=dvander, a13=blocking). 2010-02-04 19:28:06 -06:00
Scott Ehlert 90cc2d6c37 Webternet and Updater extensions now load on Windows 2000 (bug 4234, r+a13=dvander). 2010-01-20 15:11:13 -06:00
David Anderson 1ab5403f9f Fixed accidental hook against garbage offset (bug 4231, r=fyren, a13=blocking). 2010-01-20 04:03:46 -08:00
David Anderson 4d03a4ef60 Added PlayerRunCmd offset for DoD:s (bug 4231 mitigation, r=me). 2010-01-20 04:01:39 -08:00
Scott Ehlert 46b714108a Updated .hgignore for Explorer files beginning with a lowercase letter (argh!) 2010-01-20 02:39:52 -06:00
David Anderson 242e1c99e2 Bumped version to 1.3.1-dev. 2010-01-14 23:34:20 -08:00
David Anderson 3d0e661cd6 Added tag sourcemod-1.3.0 for changeset a71318396392 2010-01-14 23:33:20 -08:00
David Anderson d076aca9ea Forgotten file needed version bump. 2010-01-14 22:26:57 -08:00
David Anderson f824a53f21 Another credits update. 2010-01-14 03:34:26 -08:00
David Anderson 87ca5e6e05 Prep for release. 2010-01-14 03:30:20 -08:00
David Anderson 23af5357c0 Updated credits for 1.3 release. 2010-01-14 03:29:16 -08:00
David Anderson d6b82d5dcc Updated changelog. 2010-01-14 03:26:16 -08:00
David Anderson 664da97c42 Registering "sm" logs an error, but will not throw. 2010-01-14 01:11:38 -08:00
Greyscale b6507b12d4 Fixed missing #endif in adminmenu.inc (bug 4216, r+a13=dvander). 2010-01-14 00:22:45 -08:00
David Anderson a5ab381c0a Fixed command listener spew on server shutdown (bug 4198, r=fyren, a13=blocking). 2010-01-13 21:48:51 -08:00
David Anderson 8ec5e42c7a Merge. 2010-01-11 20:10:57 -08:00
David Anderson 006423dcf2 Triggering build. 2010-01-11 20:10:38 -08:00
Nicholas Hastings d0f4d943b6 Added missing SDK define for L4D2 (bug 4209, r+a13=dvander). 2010-01-10 17:38:03 -08:00
Nicholas Hastings 2fd9674e09 Follow-up to bug 4194 (r=dvander). 2010-01-10 17:29:32 -08:00
David Anderson 23fca5e645 Merge. 2010-01-10 17:17:22 -08:00
David Anderson 4beb7fe869 Backed out changeset f8861500d3bc (bug 4211). 2010-01-10 17:17:16 -08:00
David Anderson 2e832f2d01 Fixed reentrancy problems with iterators, forwards, and function removals (bug
4059, r=fyren, a13=blocking).
2010-01-10 16:58:17 -08:00
Fyren 43602da743 Fixed GuessSDKVersion() not working on ep2v (bug 4194, r=dvander, a13=blocking). 2010-01-09 11:33:19 -08:00
Nicholas Hastings 763b73b9c5 Fixed SetUserCvar (sm_rename) on TF/DoD Linux (bug 4196, r=dvander, a13=blocking). 2010-01-07 01:26:01 -08:00
Nicholas Hastings ffb6e84b45 Add Insurgency to list of games that support HUD messages (bug 4136, r+a13=dvander). 2009-12-19 20:42:32 -08:00
David Anderson 025f216e09 Fixed crashes from rare plugin loading errors (bug 4153, r=ds). 2009-12-19 18:19:28 -08:00
David Anderson 603ac75a08 Fixed SourceMod crashing after flushing the profiler (bug 4149, r=ds). 2009-12-19 18:18:17 -08:00
David Anderson 1b07722848 Add ability to change dontBroadcast status on hooked events (bug 3886, r=ds). 2009-12-19 18:16:41 -08:00
Nicholas Hastings 4de8d67e27 Another TF2 gamedata fix (bug 4151, r=dvander). 2009-12-19 12:57:26 -08:00
Nicholas Hastings 83baabe00a Battlegrounds 2 gamedata support (bug 4146, r+a13=dvander). 2009-12-19 00:03:57 -08:00
Nicholas Hastings 3080ca1ccb TF2 gamedata updates (bug 4147, r=dvander). 2009-12-18 22:01:41 -08:00
David Anderson c3b0f8a4d2 Fixed infinite loop in Windows build failure path (bug 4144, r=ds). 2009-12-14 23:07:54 -08:00
David Anderson 726ee43736 Fixed profiler being set to NULL (bug 4143, r=fyren). 2009-12-14 23:08:15 -08:00
Fyren 8e1f37a5d2 Improve/fix GetEntity (bug 4092, r=pred) 2009-12-15 23:13:53 -08:00
Dog ce342ef6fc Fixed CommitSuicide offset on DoD:S (bug 4109, r=dvander). 2009-12-14 20:26:45 -08:00
Nicholas Hastings 0a6acda737 Fixed CreateEntityByName for Insurgency (bug 4046, r+a13=dvander). 2009-12-14 20:31:16 -08:00
Nicholas Hastings c907c723c3 Updated Synergy gamedata (bug 3987, r=dvander). 2009-12-14 20:30:44 -08:00
Nicholas Hastings 479815911d Added HudText support for Zombie Master (bug 4004, r+a13=dvander). 2009-12-14 20:30:04 -08:00
Nicholas Hastings 29954ec122 Added Neotokyo support (bug 4126, r+a13=dvander). 2009-12-14 20:29:23 -08:00
David Anderson 75455b65da Fixed basecomm description spelling (bug 4112, r=me). 2009-12-14 20:27:26 -08:00
Fyren 5688eb55ec Fix wonky handling of path separators for "sm plugins" commands (bug 3857, r=dvander) 2009-11-23 02:27:24 -08:00
Scott Ehlert 2e4aae95db Updated .hgignore to ignore some Windows and OS X files. 2009-11-22 01:39:29 -06:00
Scott Ehlert cc43b63508 Updated sample_ext and mms_sample_ext for Orange Box Valve and Left 4 Dead 2 (bug 4118, r=pred). 2009-11-22 01:33:08 -06:00
David Anderson 59593a2d5f Use GetVSPInfo() from MM:S 1.8 legacy API (bug 4081, r=ds). 2009-11-20 15:18:58 -06:00
Fyren e3f5d5b6cf Fix leak in nominations plugin (bug 4104, r=pred) 2009-11-18 15:44:51 -08:00
Fyren 6085125367 Fix rare basevotes map vote problem (bug 3905, r=dvander) 2009-11-18 15:42:21 -08:00
Scott Ehlert 27805463e3 Added IMemoryUtils::ResolveSymbol() for resolving symbols hidden via GCC's -fvisibility=hidden (bug 4091, r=dvander,pred).
Right now, this is only used on L4D2 where it is needed.
2009-11-06 16:24:40 -06:00
David Anderson 45f2b9f8ca Clarified handle invariants in clientprefs.inc (no bug, r=me). 2009-11-04 13:52:12 -05:00
Fyren 2bd979d62e Don't call edict_t::StateChanged(ushort) on L4D2 (bug 4090, r=dvander) 2009-11-01 02:53:34 -08:00
Scott Ehlert e434c43e28 Use SOURCE_ENGINE_ORANGEBOXVALVE constant from MM:S 1.8 (bug 4087, r=dvander). 2009-10-30 14:04:43 -05:00
Fyren 02922df1cd More L4D2 gamedata changes 2009-10-30 01:24:55 -07:00
Scott Ehlert 035875f5c1 Fixed Windows build, I think. 2009-10-30 00:03:54 -05:00
Fyren e3a3dda1d8 Typo fix 2009-10-29 20:34:00 -07:00
Scott Ehlert 7187dde64d Changed name in credits. 2009-10-29 17:35:00 -05:00
Matt Woodrow fd09d7b176 New sdk uses _linux for vstdlib/tier0 2009-10-30 15:20:48 +13:00
Matt Woodrow 4e8fc2749b AMBuild updated to use new MM:S version 2009-10-30 14:58:17 +13:00
Fyren 8b362700ff Updated GuessSDKVersion 2009-10-30 14:34:34 +13:00
Matt Woodrow e926a3b94b SourceMod MSVC project files updated, windows tested and loading, gamedata fix. 2009-10-30 14:29:45 +13:00
Matt Woodrow 83d1fc9abe L4D2 gamedata updates 2009-10-30 13:27:05 +13:00
Matt Woodrow d6a5d99e55 AMBuild updated for new L4D2 engine 2009-10-30 13:27:19 +13:00
Fyren 6322a711c2 Inital SM fixes for l4d2 and linux makefile updates 2009-10-30 13:26:13 +13:00
David Anderson e024871b50 Use GetSourceEngineBuild() from MM:S 1.8 legacy API (bug 4083, r=ds). 2009-10-29 01:33:57 -07:00
David Anderson b4e939e273 Let SourceMod use OnUnlinkConCommandBase from MM:S 1.8 legacy API (bug 4080, r=ds). 2009-10-29 00:53:31 -07:00
David Anderson 13743376ee Build against MM:S 1.8 with core-legacy (bug 4076, r=ds). 2009-10-28 23:30:52 -07:00
David Anderson 69cfd36054 Fix iloop race when using AddCommandListener and SourceMod unloads (bug 4077, r=pred). 2009-10-29 00:07:15 -07:00
David Anderson 7d15ec4d15 Fixed crash when activating command listeners on EP1 while inside a command callback (bug 4072, r=pred). 2009-10-28 00:50:48 -07:00
David Anderson b52a10f28b Added feature testing functionality (bug 4021, r=pred). 2009-10-28 00:37:34 -07:00
David Anderson da7c65f0e3 Fix maphistory command not returning a value (bug 4069, r=pred, a13=blocking). 2009-10-28 01:55:42 -07:00
David Anderson a5d2945fc5 Added @spec target (bug 2718, r=fyren). 2009-10-27 03:41:36 -07:00
383 changed files with 4552 additions and 30137 deletions
-4
View File
@@ -1,15 +1,11 @@
# Binaries
\.dll$
\.dylib$
\.exe$
\.so$
# Files generated by Visual Studio
\.aps$
\.ipch$
\.ncb$
\.opensdf$
\.sdf$
\.suo$
\.user$
+2 -1
View File
@@ -3,4 +3,5 @@ e6ef5ecdf8d75740ca2685a709bf321f8873bc3b sourcemod-1.1.0
e877885fac80be71822641f7a9122cebc9812521 sourcemod-1.1.1
b3ffa8a4511c4eadaf533fc790aa6b14f7f0c6ea sourcemod-1.1.2
3a73bbf60f34befa9b66be03fa5974b394bb3411 sourcemod-1.2.0
ddd707c3454c382db5db9d28148cd19227f44759 sourcemod-1.4.0
a71318396392e3c6d0ff31e069a60fbde59e0cea sourcemod-1.3.0
3f33d01fcc28b509bed30f7be07ed215cc000538 sourcemod-1.3.1
+37 -124
View File
@@ -8,27 +8,20 @@ class SM:
self.compiler = Cpp.Compiler()
#Build SDK info
self.possibleSdks = { }
self.possibleSdks['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1',
'name': 'EPISODEONE', 'platform': ['windows', 'linux']}
self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3',
'name': 'ORANGEBOX', 'platform': ['windows', 'linux']}
self.possibleSdks['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '6',
'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']}
self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '7',
'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin']}
self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '8',
'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin']}
self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2',
'name': 'DARKMESSIAH', 'platform': ['windows']}
self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '9',
'name': 'ALIENSWARM', 'platform': ['windows']}
self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4',
'name': 'BLOODYGOODTIME', 'platform': ['windows']}
self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5',
'name': 'EYE', 'platform': ['windows']}
self.sdkInfo = { }
self.sdkInfo['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1',
'name': 'EPISODEONE'}
self.sdkInfo['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3',
'name': 'ORANGEBOX'}
self.sdkInfo['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '4',
'name': 'ORANGEBOXVALVE'}
self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '5',
'name': 'LEFT4DEAD'}
self.sdkInfo['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '6',
'name': 'LEFT4DEAD2'}
if AMBuild.target['platform'] == 'windows':
self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2',
'name': 'DARKMESSIAH'}
if AMBuild.mode == 'config':
#Detect compilers
@@ -36,39 +29,24 @@ class SM:
#Detect variables
envvars = { 'MMSOURCE18': 'mmsource-1.8',
'HL2SDKOBVALVE': 'hl2sdk-ob-valve',
'HL2SDK': 'hl2sdk',
'HL2SDKOB': 'hl2sdk-ob',
'HL2SDKL4D': 'hl2sdk-l4d',
'HL2SDKL4D2': 'hl2sdk-l4d2',
'HL2SDKOBVALVE': 'hl2sdk-ob-valve',
'HL2SDKL4D2': 'hl2sdk-l4d2',
'MYSQL5': 'mysql-5.0'
}
if AMBuild.target['platform'] != 'darwin':
envvars['HL2SDK'] = 'hl2sdk'
envvars['HL2SDKOB'] = 'hl2sdk-ob'
#Dark Messiah is Windows-only
if AMBuild.target['platform'] == 'windows':
envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
envvars['HL2SDK-BGT'] = 'hl2sdk-bgt'
envvars['HL2SDK-EYE'] = 'hl2sdk-eye'
# Finds if a dict with `key` set to `value` is present on the dict of dicts `dictionary`
def findDictByKey(dictionary, key, value):
for index in dictionary:
elem = dictionary[index]
if elem[key] == value:
return (elem, index)
return None
#Must have a path for each envvar (file a bug if you don't like this)
for i in envvars:
if i in os.environ:
path = os.environ[i]
if not os.path.isdir(path):
raise Exception('Path for {0} was not found: {1}'.format(i, path))
elif i.startswith('HL2SDK'):
(info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
self.sdkInfo[sdk] = info
else:
head = os.getcwd()
oldhead = None
@@ -78,32 +56,21 @@ class SM:
break
oldhead = head
head, tail = os.path.split(head)
if i.startswith('HL2SDK'):
(info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
self.sdkInfo[sdk] = info
elif head == None or head == oldhead:
if head == None or head == oldhead:
raise Exception('Could not find a valid path for {0}'.format(i))
AMBuild.cache.CacheVariable(i, path)
if len(self.sdkInfo) < 1:
raise Exception('At least one SDK must be available.')
AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
#Set up defines
cxx = self.compiler.cxx
if isinstance(cxx, Cpp.CompatGCC):
if isinstance(cxx, Cpp.GCC):
self.vendor = 'gcc'
elif isinstance(cxx, Cpp.Clang):
self.vendor = 'clang'
if isinstance(cxx, Cpp.GCC):
self.vendor = 'gcc'
self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
self.compiler.AddToListVar('CFLAGS', '-pipe')
self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
if cxx.majorVersion >= 4:
self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
self.compiler.AddToListVar('CFLAGS', '-Wall')
@@ -111,23 +78,19 @@ class SM:
self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized')
self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-msse')
self.compiler.AddToListVar('CFLAGS', '-m32')
self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc')
self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H')
self.compiler.AddToListVar('CDEFINES', 'GNUC')
if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
elif isinstance(cxx, Cpp.MSVC):
self.vendor = 'msvc'
if AMBuild.options.debug == '1':
self.compiler.AddToListVar('CFLAGS', '/MTd')
self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt')
else:
self.compiler.AddToListVar('CFLAGS', '/MT')
self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE')
@@ -158,18 +121,17 @@ class SM:
#Optimization
if AMBuild.options.opt == '1':
self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
if self.vendor == 'gcc' or self.vendor == 'clang':
if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-O3')
elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Ox')
self.compiler.AddToListVar('CFLAGS', '/Ot')
self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF')
self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF')
#Debugging
if AMBuild.options.debug == '1':
self.compiler.AddToListVar('CDEFINES', 'DEBUG')
self.compiler.AddToListVar('CDEFINES', '_DEBUG')
if self.vendor == 'gcc' or self.vendor == 'clang':
if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-g3')
elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Od')
@@ -178,29 +140,6 @@ class SM:
#Platform-specifics
if AMBuild.target['platform'] == 'linux':
self.compiler.AddToListVar('CDEFINES', '_LINUX')
if self.vendor == 'gcc':
self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc')
if self.vendor == 'clang':
self.compiler.AddToListVar('POSTLINKFLAGS', '-lgcc_eh')
elif AMBuild.target['platform'] == 'darwin':
self.compiler.AddToListVar('CFLAGS', ['-isysroot',
'/Developer/SDKs/MacOSX10.5.sdk'])
self.compiler.AddToListVar('POSTLINKFLAGS', '-mmacosx-version-min=10.5')
self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'i386'])
self.compiler.AddToListVar('POSTLINKFLAGS', '-lstdc++')
# For OS X dylib versioning
import re
productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
productContents = productFile.read()
productFile.close()
m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
if m == None:
self.version = '1.0.0'
else:
major, minor, release = m.groups()
self.version = '{0}.{1}.{2}'.format(major, minor, release)
AMBuild.cache.CacheVariable('version', self.version)
elif AMBuild.target['platform'] == 'windows':
self.compiler.AddToListVar('CDEFINES', 'WIN32')
self.compiler.AddToListVar('CDEFINES', '_WINDOWS')
@@ -215,7 +154,6 @@ class SM:
self.targetMap = { }
AMBuild.cache.CacheVariable('targetMap', self.targetMap)
else:
self.sdkInfo = AMBuild.cache['sdkInfo']
self.compiler.FromConfig(AMBuild, 'compiler')
self.targetMap = AMBuild.cache['targetMap']
@@ -248,14 +186,10 @@ class SM:
return compiler
def AutoVersion(self, folder, binary):
if AMBuild.target['platform'] == 'windows':
env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'SM_GENERATED_BUILD']}
binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env)
elif AMBuild.target['platform'] == 'darwin' and isinstance(binary, Cpp.LibraryBuilder):
binary.compiler['POSTLINKFLAGS'].extend(['-compatibility_version', '1.0.0'])
binary.compiler['POSTLINKFLAGS'].extend(['-current_version', AMBuild.cache['version']])
else:
if AMBuild.target['platform'] != 'windows':
return
env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'SM_GENERATED_BUILD']}
binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env)
def PreSetupHL2Job(self, job, builder, sdk):
info = self.sdkInfo[sdk]
@@ -266,7 +200,7 @@ class SM:
else:
staticLibs = os.path.join(sdkPath, 'lib', 'linux')
workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
if sdk in ['ep2v', 'l4d', 'l4d2']:
if sdk == 'ep2v' or sdk == 'l4d2':
for i in ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.so', 'libtier0.so']:
link = os.path.join(workFolder, i)
target = os.path.join(staticLibs, i)
@@ -282,27 +216,14 @@ class SM:
os.lstat(link)
except:
job.AddCommand(SymlinkCommand(link, target))
elif AMBuild.target['platform'] == 'darwin':
staticLibs = os.path.join(sdkPath, 'lib', 'mac')
workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
for i in ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.dylib', 'libtier0.dylib']:
link = os.path.join(workFolder, i)
target = os.path.join(staticLibs, i)
try:
os.lstat(link)
except:
job.AddCommand(SymlinkCommand(link, target))
elif AMBuild.target['platform'] == 'windows':
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
if sdk == 'swarm':
libs.append('interfaces')
for lib in libs:
for lib in ['tier0', 'tier1', 'vstdlib', 'mathlib']:
libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib'
builder.RebuildIfNewer(libPath)
builder['POSTLINKFLAGS'].append(libPath)
def PostSetupHL2Job(self, job, builder, sdk):
if AMBuild.target['platform'] in ['linux', 'darwin']:
if AMBuild.target['platform'] == 'linux':
builder.AddObjectFiles(['tier1_i486.a', 'mathlib_i486.a'])
def DefaultHL2Compiler(self, path, sdk, noLink = False, oldMms = '-legacy'):
@@ -315,8 +236,9 @@ class SM:
compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms))
compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms, 'sourcehook'))
info = self.possibleSdks
info = self.sdkInfo
compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info])
compiler['CDEFINES'].append('SE_DARKMESSIAH=2')
paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],
['public', 'tier0'], ['public', 'tier1']]
@@ -325,7 +247,6 @@ class SM:
paths.append(['game_shared'])
else:
paths.append(['public', 'game', 'server'])
paths.append(['public', 'toolframework'])
paths.append(['game', 'shared'])
paths.append(['common'])
@@ -334,17 +255,12 @@ class SM:
compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def'])
if sdk == 'swarm' and AMBuild.target['platform'] == 'windows':
compiler['CDEFINES'].extend(['COMPILER_MSVC', 'COMPILER_MSVC32'])
if sdk == 'ep1':
if AMBuild.target['platform'] == 'linux':
staticLibs = os.path.join(sdkPath, 'linux_sdk')
else:
if AMBuild.target['platform'] == 'linux':
staticLibs = os.path.join(sdkPath, 'lib', 'linux')
elif AMBuild.target['platform'] == 'darwin':
staticLibs = os.path.join(sdkPath, 'lib', 'mac')
for i in paths:
compiler['CXXINCLUDES'].append(os.path.join(sdkPath, *i))
@@ -352,15 +268,12 @@ class SM:
if not noLink:
if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'][0:0] = ['-lm']
if sdk in ['ep2v', 'l4d', 'l4d2']:
if sdk == 'ep2v' or sdk == 'l4d2':
compiler['POSTLINKFLAGS'][0:0] = ['libtier0.so']
compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.so']
else:
compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so']
compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so']
elif AMBuild.target['platform'] == 'darwin':
compiler['POSTLINKFLAGS'][0:0] = ['libtier0.dylib']
compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.dylib']
compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so']
return compiler
+1
View File
@@ -3,3 +3,4 @@ CONFIGURE YOUR IDENTITY FOR MERCURIAL!
IF YOU ARE A DEVELOPER WITH PUSH ACCESS, DO IT NOW KPLZTHX.
http://wiki.alliedmods.net/Mercurial_Tutorial#Identity
-251
View File
@@ -1,256 +1,5 @@
SourceMod Changelog
-----------------------------
SourceMod 1.4.1 [2011-12-07]
URL: http://wiki.alliedmods.net/SourceMod_1.4.1_Release_Notes
User Changes:
- Updated support for latest OrangeBox engine changes (CS:S, DoD:S, TF2, HL2DM, GMod).
- Added gamedata for Adrenaline Gamer 2 and No More Room in Hell.
- Fixed "not connected" error in reserve slots plugin (bug 5158) (ostrel).
- Fixed ff trigger output printing to all in triggerer's language (rather than viewer's language) (bug 5161).
- Fixed typo in one of basebans ban reasons (bug 5188).
- Fixed formatting error in Swedish "Vote Count" phrase (bug 5174).
Developer Changes:
- Fixed sp MaxClients not being updated on map changes after load (bug 5160).
- Removed GLIBC_2.7 dependency from spcomp.
- Increased buffer for sm_rcon command to fit larger responses (bug 5169).
- BaseComm now properly registers a library allowing it to be required by other plugins (bug 5156).
- Fixed TFHoliday enum values (bug 5155).
- Updated TF2_OnIsHolidayActive ret behavior to match doc (bug 5155).
- Added new TF2 deathflag and dmg custom defines (bug 5157).
-----------------------------
SourceMod 1.4.0 [2011-10-28]
URL: http://wiki.alliedmods.net/SourceMod_1.4.0_Release_Notes
User Changes:
- Added support for Max OS X (bug 4392).
- Added support for Bloody Good Time (bug 4780).
- Added support for E.Y.E Divine Cybermancy (bug 5035).
- Added gamedata for Nuclear Dawn.
- Added gamedata for International Online Soccer: Source (bug 5019).
- Added gamedata for Half-Life 2 Capture the Flag (bug 5114).
- Updated mapchooser and other base plugins with Nuclear Dawn specific fixes (bug 5117).
- Fixed ServerLang value not being read properly on startup (bug 4675).
- Added support for aliases in languages.cfg (bug 4858).
- Added output display to sm_rcon command (bug 5018).
- Flood protection bypass access can now be overridden with command name sm_flood_access (bug 4584).
- Added a reset argument to sm cvars command to revset cvar values to default (bug 5043).
- Fixed incorrect language identifiers for Chinese (both Trad. and Simplified) and Brazilian Portuguese not matching cl_language values (bug 5067).
- Added translation support for Bulgarian (bg).
- Fixed incorrect number of slots being hidden for reserve with sm_hideslots on Source 2009 with SourceTV or replay (bug 5094).
- sm_hideslots changes now take effect immediately instead of waiting until a client joins or leaves (bug 5094).
- Fixed sv_visiblemaxplayers getting stuck at previous max clients in some cases with reserves and SourceTV or replay (bug 5094).
- Removed error logging if an optional extension is not found (bug 5112).
- Fixed bots with semicolon in name being unkickable (bug 5120).
- Changed strings in ice-related funcommands to be translatable (bug 4540).
- Changed Bintools extension to use a single build for every engine (bug 4548).
Developer Changes:
- Provided native interface for basecomm (bug 2594).
- Client language detection is too late. (bug 3714) (Tony A. "GoD-Tony").
- Added ServerCommandEx native to execute server command and retrieve output (bug 3873).
- Added ability to update clientprefs cookies values on clients not currently connected (bug 3882) (databomb).
- Added library "matchmaking_ds" support to gamedata lookups (bug 4158).
- Rooted menu handles to callbacks (bug 4353).
- Fixed corner cases with ExplodeString (bug 4629). (Michael "LumiStance").
- Fixed return omission with else-after-return (bug 4852).
- Added OnConditionAdded and OnConditionRemoved forwards to TF2 extension (bug 4851).
- Added new natives and forward to the cstrike extension (bug 4732, bug 4985) (Dr!fter).
- Added WaitingForPlayers forwards to the TF2 extension (bug 4704) (CrimsonGT).
- Updated and added more TF2 condition, weapon, and damagecustom defines (multiple bug#s).
- Fixed TF2_RemoveCondition not always removing conditions (bug 4981).
- Fixed MaxClients not being updated correctly in some places with SourceTV or replay active (bug 4986).
- Fixed some vars not being marked for init on first compile pass (bug 4643).
- Increased symbol name limit to 63 characters (bug 4564) (javalia).
- Fixed crash when dynamic arrays run out of memory (bug 4632).
- Fixed a crash that could happen from looking up out-of-bounds edict or entity indexes (bug 5080).
- Fixed client serials not getting cleared on disconnect (bug 5121).
- Added error on declaring arrays that the compiler is too buggy to handle (bug 4977).
- Removed reliance on gamedata for multiple SDKTools functions in ep2 and later (bug 4899).
- Added InvalidateClient and ReconnectClient natives to SDKTools (bug 4931) (Brian "Afronanny" Simon).
- Added ability to lookup and set values on the gamerules class (bug 4983.
- BaseComm now uses AddCommandListener for chat hooks (bug 4991).
- Fixed shutdown bug in SDKTools (bug 5063).
- Fixed MM-enabled extensions continuing to load after failing MM attach (bug 5042).
- Added GetDistGainFromSoundLevel native to SDKTools (bug 5066) (javalia).
- Added CheckAccess native to check an AdminId's command access (bug 5083).
- Fixed GetEntProp not sign-extending unsigned values less than 32 bits (bug 5105).
- Fixed crashing when calling CreateEntityByName or CreateFakeClient when no map is running (now errors) (bug 5119).
- Fixed erring in kick function (e. bad translation) causing client to become unkickable until disconnect (bug 5120).
- Fixed KickClientEx not immediately kicking client if client was in kick queue (bug 5120).
- Added IsClientSourceTV and IsClientReplay natives (bug 5124).
- Added support for getting and setting individual array elements with Get/Set EntProp functions (bug 4160).
- Added support for threaded query handles to SQL_GetInsertId and SQL_GetAffectedRows (bug 4699) (Nephyrin).
- Added a GetGameRules function to ISDKTools for extensions to easily get the GameRules class pointer (bug 4707).
- Added GetMessageName to IUserMessages (bug 4573) (Zach "theY4Kman" Kanzler)
- Added HintTextMsg to IGameHelpers (bug 4950).
- Added ProcessTargetString simple filter API (bug 4404).
- Moved much functionality from core bins to logic bin (bug 4406, bug 4402).
- Fixed bogus asserts in sp compiler (bug 4486, bug 4487).
- Greatly improved sp compiler performance (~5x overall speedup) (bug 3820, bug 4493, bug 4495).
- Changed entity output detours to use CDetour (bug 4416).
- Enhanced nominations API (bug 4677) (CrimsonGT).
- Added Linux support for profiling natives (bug 4927).
- Added a new ValveCallType that allows for arbitrary |this| parameters, as well as associated features in gamedata and for reading/writing memory (bug 3520) (Downtown1).
- Updated TF2 extension to handle Valve's changes to the "holiday" system (bug 5150).
-----------------------------
SourceMod 1.3.8 [2011-06-23]
URL: http://wiki.alliedmods.net/SourceMod_1.3.8_Release_Notes
User Changes:
- Updated support for latest OrangeBox engine changes (CS:S, DoD:S, TF2, HL2DM, GMod).
- Updated support for various games, including Garry's Mod, Zombie Panic, and Dino D-Day.
- Added gamedata for Eternal Silence.
- Fixed libgcc_s.so.1 load error present on some systems (bug 4876).
- Handle leak notices now print to error log (in addition fatal log) (bug 4929).
- Translator now properly falls back on bad server language (bug 4861).
- Fixed invalid client errors from bad MaxClients value when SourceTV is late-loaded (bug 4881).
- Fixed crash on plugin unload when two commands exist with same name, different casing (bug 4698).
Developer Changes:
- Updated TF2 condition defines (bug 4916).
- Fixed var names and docs for TF2_MakeBleed native (bug 4928).
- Removed compiler double include check (bug 4863).
- Fixed plugin compile errors when using GetEntityClassname (bug 4798).
---------------------------
SourceMod 1.3.7 [2011-04-15]
URL: http://wiki.alliedmods.net/SourceMod_1.3.7_Release_Notes
User Changes:
- Updated support for latest OrangeBox engine changes (CS:S, DoD:S, TF2, HL2DM, GMod).
- Updated support for various games, including Zombie Panic, CS ProMod, Empires, and GoldenEye: Source.
- Added gamedata for Dino D-Day.
- Fix precedence of voice mute flag versus specific client overrides (bug 4826).
- Fix mistaken unhooking of voice hooks (bug 4804).
- Fixed graphical glitches with funcommands effects in L4D1 (bug 3486).
- Fixed bug in nominations that could cause "Unknown command" error (bug 4797).
- Removed tv_enable hook to fix rare max client count issue (bug 4791).
- Added missing unhooking of ClientConnect in PlayerManager (bug 4749).
- Fixed sm_rtv printing "unknown command" (bug 4730).
- Fixed voting crash when client console, chat, and SourceTV are enabled (bug 4676).
- Fixed CDetour crash in TF2 extension when last plugin using forward is unloaded (bug 4713).
Developer Changes:
- SetEntProp now marks edict state as changed (bug 4855).
- Added GetEntityClassname stock (bug 4798).
- Fix compiler hanging when #including a directory (bug 4822).
- Added GetEntityFlags and SetEntityFlags natives for better cross-engine compatibility. (bug 4809).
- Fixed ClientPrefs natives not being marked optional when REQUIRE_EXTENSIONS not defined (bug 4839).
- Changed some instances of LogMessage to LogAction (bug 4649).
- Added some new language natives (bug 4613).
- Fixed SetTeamScore not updating score on client (bug 2736).
- Raised MAXPLAYERS from 64 to 65 (bug 4490).
- Added and updated many TF2-specific defines in tf2.inc and tf2_stocks.inc.
- Fixed TF2_GetPlayerConditionFlags no longer necessarily returning all set flags (bug 4726).
- Fixed profiler flush not clearing, added 'report' and 'clear' (bug 4674).
- Fixed GetPlayerDecalFile crash on L4D and L4D2 (bug 4729).
- Fixed TF2_OnGetHoliday detour no longer firing under all circumstances (bug 4700).
- Added TF2_IsPlayerInDuel native to TF2 extension (bug 4695).
----------------------------
SourceMod 1.3.6 [2010-10-31]
URL: http://wiki.alliedmods.net/SourceMod_1.3.6_Release_Notes
User Changes:
- Updated support for latest Left 4 Dead 1 (bug 4681).
Developer Changes:
- Updated TF2 custom kill defines (bug 4682).
----------------------------
SourceMod 1.3.5 [2010-10-17]
URL: http://wiki.alliedmods.net/SourceMod_1.3.5_Release_Notes
User Changes:
- Updated support for CS:S, Garry's Mod, DoD:S, TF2, HL2DM.
- Added support for Firearms: Source (bug 4537).
- Added support for Fistful of Frags (bug 3883).
- Added support for Alien Swarm (bug 4530).
- Fixed living players hearing dead players if alltalk is disabled while deadtalk is on (bug 4533, thanks Zach Callear).
- Fixed timeleft not getting reset on Game_Commencing in CS:S (bug 4557).
- Fixed PlayerRunCmd being hooked when not used (bug 3990).
- Fixed errors and missing effects caused by missing sprites on L4D2 (bug 4512).
- Fixed 'sm plugins' public command skipping plugins in recommended listing (bug 4501).
- Fixed corruption with large database.cfg files (bug 4286).
Developer Changes:
- Added TF2 object stocks (bug 4536).
- Added TF2_MakeBleed native to TF2 ext (bug 4542).
- Added support for logical entities in Synergy (bug 4534).
- Updated TF2 conditions enum and defines (bug 4526).
- Fixed potential crash with IMemUtils::FindPattern on Linux (bug 4554).
----------------------------
SourceMod 1.3.4 [2010-07-18]
URL: http://wiki.alliedmods.net/SourceMod_1.3.4_Release_Notes
User Changes:
- Support for latest TF update (bug 4506).
- Support for latest L4D2 update (bug 4509).
Developer Changes:
- Added FindFlagChar native (bug 3776).
- Added GetConVarDefault native (bug 4502).
- Added forward for TF's GetHoliday function (bug 4462).
----------------------------
SourceMod 1.3.3 [2010-06-23]
URL: http://wiki.alliedmods.net/SourceMod_1.3.3_Release_Notes
User Changes:
- Added support for CS:S on Orange Box
- Added gamedata for Resistance and Liberation (bug 4418).
- Updated gamedata for SourceForts, Empires, Obsidian Conflict, Zombie Master.
- Fixed memory corruption and leaks with some voice functionality (bug 4415).
- Fixed UI bug in sm_motd (bug 4460).
Developer Changes:
- Added new player condition (TFCond_CritCola, bug 4447).
- Fixed clientprefs deleting cookies twice in rare cases (bug 4412).
- Fixed OnClientConnected forward not firing for bots (bug 4443).
- Fixed sm_dump_datamaps crash (bug 4424).
- Fixed switch case comparisons failing with large numbers (bug 4457).
- Fixed rare crash in output hooks (bug 4422).
- Fixed bug with dynamically sized arrays being sliced (bug 4428).
- Fixed SendConVarValue() on TF2, DOD:S, L4D, and L4D2 (bug 4273).
- Fixed TF2 natives not being marked optional (bug 4389).
----------------------------
SourceMod 1.3.2 [2010-05-02]
-2
View File
@@ -2,8 +2,6 @@
{
"driver_default" "mysql"
// When specifying "host", you may use an IP address, a hostname, or a socket file path
"default"
{
"driver" "default"
+15 -3
View File
@@ -3,9 +3,6 @@ import os
for i in SM.sdkInfo:
sdk = SM.sdkInfo[i]
if AMBuild.target['platform'] not in sdk['platform']:
continue
name = 'sourcemod.' + sdk['ext']
compiler = SM.DefaultHL2Compiler('core', i)
@@ -17,22 +14,26 @@ for i in SM.sdkInfo:
'AdminCache.cpp',
'ExtensionSys.cpp',
'MenuStyle_Valve.cpp',
'sm_crc32.cpp',
'logic_bridge.cpp',
'smn_entities.cpp',
'sm_stringutil.cpp',
'ADTFactory.cpp',
'ForwardSys.cpp',
'MenuVoting.cpp',
'sm_memtable.cpp',
'smn_events.cpp',
'smn_menus.cpp',
'sm_trie.cpp',
'CDataPack.cpp',
'frame_hooks.cpp',
'NativeInvoker.cpp',
'smn_admin.cpp',
'smn_fakenatives.cpp',
'smn_nextmap.cpp',
'sourcemm_api.cpp',
'ChatTriggers.cpp',
'GameConfigs.cpp',
'NativeOwner.cpp',
'smn_filesystem.cpp',
'smn_player.cpp',
@@ -40,19 +41,28 @@ for i in SM.sdkInfo:
'concmd_cleaner.cpp',
'HalfLife2.cpp',
'NextMap.cpp',
'smn_profiler.cpp',
'ConCmdManager.cpp',
'HandleSys.cpp',
'PhraseCollection.cpp',
'ConVarManager.cpp',
'LibrarySys.cpp',
'PlayerManager.cpp',
'smn_banning.cpp',
'smn_gameconfigs.cpp',
'smn_string.cpp',
'TimerSys.cpp',
'CoreConfig.cpp',
'Logger.cpp',
'PluginInfoDatabase.cpp',
'smn_bitbuffer.cpp',
'smn_halflife.cpp',
'Translator.cpp',
'MemoryUtils.cpp',
'PluginSys.cpp',
'smn_console.cpp',
'smn_handles.cpp',
'smn_timers.cpp',
'UserMessages.cpp',
'Database.cpp',
'MenuManager.cpp',
@@ -68,6 +78,8 @@ for i in SM.sdkInfo:
'EventManager.cpp',
'MenuStyle_Radio.cpp',
'sm_autonatives.cpp',
'smn_datapacks.cpp',
'smn_lang.cpp',
'sm_srvcmds.cpp',
'ConsoleDetours.cpp'
]
+2 -2
View File
@@ -1719,7 +1719,7 @@ bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
}
}
return g_ConCmds.CheckClientCommandAccess(client, cmd, bits);
return g_ConCmds.CheckCommandAccess(client, cmd, bits);
}
unsigned int AdminCache::SetGroupImmunityLevel(GroupId gid, unsigned int level)
@@ -1794,7 +1794,7 @@ bool AdminCache::CheckAccess(int client, const char *cmd, FlagBits flags, bool o
GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckClientCommandAccess(client, cmd, bits) ? 1 : 0;
return g_ConCmds.CheckCommandAccess(client, cmd, bits) ? 1 : 0;
}
void iterator_glob_basic_override(Trie *pTrie, const char *key, void **value, void *data)
+12 -3
View File
@@ -34,8 +34,8 @@
#include "sm_stringutil.h"
#include "ConCmdManager.h"
#include "PlayerManager.h"
#include "Translator.h"
#include "HalfLife2.h"
#include "logic_bridge.h"
/* :HACKHACK: We can't SH_DECL here because ConCmdManager.cpp does.
* While the OB build only runs on MM:S 1.6.0+ (SH 5+), the older one
@@ -113,7 +113,7 @@ void ChatTriggers::OnSourceModAllInitialized()
void ChatTriggers::OnSourceModAllInitialized_Post()
{
logicore.AddCorePhraseFile("antiflood.phrases");
g_pCorePhrases->AddPhraseFile("antiflood.phrases");
}
void ChatTriggers::OnSourceModGameInitialized()
@@ -189,8 +189,17 @@ void ChatTriggers::OnSayCommand_Pre()
{
char buffer[128];
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "Flooding the server", &client))
if (!CoreTranslate(
buffer,
sizeof(buffer),
"%T",
2,
NULL,
"Flooding the server",
&client))
{
UTIL_Format(buffer, sizeof(buffer), "You are flooding the server!");
}
/* :TODO: we should probably kick people who spam too much. */
+44 -45
View File
@@ -34,9 +34,9 @@
#include "AdminCache.h"
#include "sm_stringutil.h"
#include "PlayerManager.h"
#include "Translator.h"
#include "HalfLife2.h"
#include "ChatTriggers.h"
#include "logic_bridge.h"
ConCmdManager g_ConCmds;
@@ -226,38 +226,30 @@ void ConCmdManager::SetCommandClient(int client)
m_CmdClient = client + 1;
}
ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
{
ConCmdInfo *pInfo;
if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
return NULL;
return pInfo;
}
ConCmdList::iterator ConCmdManager::FindInList(const char *cmd)
{
List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
while (iter != m_CmdList.end())
{
if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
break;
iter++;
}
return iter;
}
ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
{
ConCmdInfo *pInfo;
if ((pInfo = FindInTrie(cmd)) == NULL)
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
{
ConCmdList::iterator item = FindInList(cmd);
if (item == m_CmdList.end())
List<ConCmdInfo *>::iterator iter;
pInfo = NULL;
iter = m_CmdList.begin();
while (iter != m_CmdList.end())
{
if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
{
pInfo = (*iter);
break;
}
iter++;
}
if (pInfo == NULL)
{
return type;
pInfo = *item;
}
}
cell_t result = type;
@@ -322,20 +314,35 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
*/
const char *cmd = g_HL2.CurrentCommandName();
ConCmdInfo *pInfo = FindInTrie(cmd);
if (pInfo == NULL)
ConCmdInfo *pInfo;
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
{
/* Unfortunately, we now have to do a slow lookup because Valve made client commands
* case-insensitive. We can't even use our sortedness.
*/
if (client == 0 && !engine->IsDedicatedServer())
{
return;
}
ConCmdList::iterator item = FindInList(cmd);
if (item == m_CmdList.end())
return;
List<ConCmdInfo *>::iterator iter;
pInfo = *item;
pInfo = NULL;
iter = m_CmdList.begin();
while (iter != m_CmdList.end())
{
if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
{
pInfo = (*iter);
break;
}
iter++;
}
if (pInfo == NULL)
{
return;
}
}
/* This is a hack to prevent say triggers from firing on messages that were
@@ -450,7 +457,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
}
}
bool ConCmdManager::CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags)
bool ConCmdManager::CheckCommandAccess(int client, const char *cmd, FlagBits cmdflags)
{
if (cmdflags == 0 || client == 0)
{
@@ -471,11 +478,7 @@ bool ConCmdManager::CheckClientCommandAccess(int client, const char *cmd, FlagBi
return false;
}
return CheckAdminCommandAccess(player->GetAdminId(), cmd, cmdflags);
}
bool ConCmdManager::CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits cmdflags)
{
AdminId adm = player->GetAdminId();
if (adm != INVALID_ADMIN_ID)
{
FlagBits bits = g_Admins.GetAdminFlags(adm, Access_Effective);
@@ -528,7 +531,7 @@ bool ConCmdManager::CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBi
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
{
if (CheckClientCommandAccess(client, cmd, pAdmin->eflags))
if (CheckCommandAccess(client, cmd, pAdmin->eflags))
{
return true;
}
@@ -537,7 +540,7 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
/* If we got here, the command failed... */
char buffer[128];
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
if (!CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
{
UTIL_Format(buffer, sizeof(buffer), "You do not have access to this command");
}
@@ -913,10 +916,6 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
ConCmdInfo *pInfo;
if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
{
ConCmdList::iterator item = FindInList(name);
if (item != m_CmdList.end())
return *item;
pInfo = new ConCmdInfo();
/* Find the commandopan */
ConCommand *pCmd = FindCommand(name);
+2 -11
View File
@@ -92,8 +92,6 @@ struct ConCmdInfo
bool is_admin_set; /**< Whether or not admin info is set */
};
typedef List<ConCmdInfo *> ConCmdList;
class ConCmdManager :
public SMGlobalClass,
public IRootConsoleCommand,
@@ -130,8 +128,7 @@ public:
void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits, bool remove);
bool LookForSourceModCommand(const char *cmd);
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
bool CheckClientCommandAccess(int client, const char *cmd, FlagBits flags);
bool CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits flags);
bool CheckCommandAccess(int client, const char *cmd, FlagBits flags);
private:
void InternalDispatch(const CCommand &command);
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
@@ -142,12 +139,6 @@ private:
void RemoveConCmds(List<CmdHook *> &cmdlist);
void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext);
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
// Case insensitive
ConCmdList::iterator FindInList(const char *name);
// Case sensitive
ConCmdInfo *FindInTrie(const char *name);
public:
inline int GetCommandClient()
{
@@ -160,7 +151,7 @@ public:
private:
Trie *m_pCmds; /* command lookup */
Trie *m_pCmdGrps; /* command group lookup */
ConCmdList m_CmdList; /* command list */
List<ConCmdInfo *> m_CmdList; /* command list */
int m_CmdClient; /* current client */
BaseStringTable m_Strings; /* string table */
};
+36 -36
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -31,59 +31,59 @@
#ifndef _INCLUDE_SOURCEMOD_CON_COMMAND_BASE_ITERATOR_H_
#define _INCLUDE_SOURCEMOD_CON_COMMAND_BASE_ITERATOR_H_
#if SOURCE_ENGINE >= SE_LEFT4DEAD
class ConCommandBaseIterator
{
public:
inline ConCommandBaseIterator() : iter(icvar)
{
iter.SetFirst();
}
inline bool IsValid()
{
return iter.IsValid();
}
inline void Next()
{
iter.Next();
}
inline ConCommandBase *Get()
{
return iter.Get();
}
private:
ICvar::Iterator iter;
};
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
ICvarIteratorInternal *cvarIter;
#else
class ConCommandBaseIterator
{
ConCommandBase *cvarIter;
#endif
public:
inline ConCommandBaseIterator()
ConCommandBaseIterator()
{
iter = icvar->GetCommands();
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
cvarIter = icvar->FactoryInternalIterator();
cvarIter->SetFirst();
#else
cvarIter = icvar->GetCommands();
#endif
}
~ConCommandBaseIterator()
{
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
g_pMemAlloc->Free(cvarIter);
#endif
}
inline bool IsValid()
{
return iter != NULL;
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
return cvarIter->IsValid();
#else
return cvarIter != NULL;
#endif
}
inline void Next()
{
iter = const_cast<ConCommandBase *>(iter->GetNext());
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
cvarIter->Next();
#else
cvarIter = const_cast<ConCommandBase*>(cvarIter->GetNext());
#endif
}
inline ConCommandBase *Get()
{
return iter;
}
private:
ConCommandBase *iter;
};
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
return cvarIter->Get();
#else
return cvarIter;
#endif
}
};
#endif /* _INCLUDE_SOURCEMOD_CON_COMMAND_BASE_ITERATOR_H_ */
+7 -27
View File
@@ -322,15 +322,8 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
int argcount = command.ArgC();
if (argcount >= 3)
{
bool wantReset = false;
/* Get plugin index that was passed */
const char *arg = command.Arg(2);
if (argcount >= 4 && strcmp(arg, "reset") == 0)
{
wantReset = true;
arg = command.Arg(3);
}
/* Get plugin object */
CPlugin *plugin = g_PluginSys.FindPluginByConsoleArg(arg);
@@ -355,34 +348,21 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
return;
}
if (!wantReset)
{
g_RootMenu.ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
g_RootMenu.ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
}
/* Iterate convar list and display/reset each one */
g_RootMenu.ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
g_RootMenu.ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
/* Iterate convar list and display each one */
for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
{
/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
if (!wantReset)
{
g_RootMenu.ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
} else {
pConVar->Revert();
}
}
if (wantReset)
{
g_RootMenu.ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
const ConVar *pConVar = (*iter);
g_RootMenu.ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
}
return;
}
/* Display usage of subcommand */
g_RootMenu.ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
g_RootMenu.ConsolePrint("[SM] Usage: sm cvars <plugin #>");
}
Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *description, int flags, bool hasMin, float min, bool hasMax, float max)
+2 -2
View File
@@ -44,14 +44,14 @@
#include "Logger.h"
#include "compat_wrappers.h"
#include "ConsoleDetours.h"
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include "sm_stringutil.h"
#include "ConCmdManager.h"
#include "HalfLife2.h"
#include "ConCommandBaseIterator.h"
#include "ShareSys.h"
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
# include <dlfcn.h>
# include <sys/mman.h>
# include <stdint.h>
+31 -40
View File
@@ -47,7 +47,7 @@ DBManager g_DBMan;
static bool s_OneTimeThreaderErrorMsg = false;
DBManager::DBManager()
: m_ParseLevel(0), m_ParseState(0), m_pDefault(NULL)
: m_StrTab(512), m_ParseLevel(0), m_ParseState(0), m_pDefault(NULL)
{
}
@@ -104,7 +104,6 @@ void DBManager::OnSourceModShutdown()
m_pQueueLock->DestroyThis();
g_HandleSys.RemoveType(m_DatabaseType, g_pCoreIdent);
g_HandleSys.RemoveType(m_DriverType, g_pCoreIdent);
ClearConfigs();
}
unsigned int DBManager::GetInterfaceVersion()
@@ -134,20 +133,13 @@ void DBManager::OnHandleDestroy(HandleType_t type, void *object)
void DBManager::ReadSMC_ParseStart()
{
ClearConfigs();
m_confs.clear();
m_ParseLevel = 0;
m_ParseState = DBPARSE_LEVEL_NONE;
m_StrTab.Reset();
m_DefDriver.clear();
}
void DBManager::ClearConfigs()
{
List<ConfDbInfo *>::iterator iter;
for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
delete (*iter);
m_confs.clear();
}
ConfDbInfo s_CurInfo;
SMCResult DBManager::ReadSMC_NewSection(const SMCStates *states, const char *name)
{
@@ -167,7 +159,7 @@ SMCResult DBManager::ReadSMC_NewSection(const SMCStates *states, const char *nam
}
} else if (m_ParseState == DBPARSE_LEVEL_MAIN) {
s_CurInfo = ConfDbInfo();
s_CurInfo.name = name;
s_CurInfo.name = m_StrTab.AddString(name);
m_ParseState = DBPARSE_LEVEL_DATABASE;
} else if (m_ParseState == DBPARSE_LEVEL_DATABASE) {
m_ParseLevel++;
@@ -194,16 +186,16 @@ SMCResult DBManager::ReadSMC_KeyValue(const SMCStates *states, const char *key,
{
if (strcmp(value, "default") != 0)
{
s_CurInfo.driver = value;
s_CurInfo.driver = m_StrTab.AddString(value);
}
} else if (strcmp(key, "database") == 0) {
s_CurInfo.database = value;
s_CurInfo.database = m_StrTab.AddString(value);
} else if (strcmp(key, "host") == 0) {
s_CurInfo.host = value;
s_CurInfo.host = m_StrTab.AddString(value);
} else if (strcmp(key, "user") == 0) {
s_CurInfo.user = value;
s_CurInfo.user = m_StrTab.AddString(value);
} else if (strcmp(key, "pass") == 0) {
s_CurInfo.pass = value;
s_CurInfo.pass = m_StrTab.AddString(value);
} else if (strcmp(key, "timeout") == 0) {
s_CurInfo.info.maxTimeout = atoi(value);
} else if (strcmp(key, "port") == 0) {
@@ -214,6 +206,13 @@ SMCResult DBManager::ReadSMC_KeyValue(const SMCStates *states, const char *key,
return SMCResult_Continue;
}
#define ASSIGN_VAR(var) \
if (s_CurInfo.var == -1) { \
s_CurInfo.info.var = ""; \
} else { \
s_CurInfo.info.var = m_StrTab.GetString(s_CurInfo.var); \
}
SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
{
if (m_ParseLevel)
@@ -224,26 +223,17 @@ SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
if (m_ParseState == DBPARSE_LEVEL_DATABASE)
{
ConfDbInfo *cdb = new ConfDbInfo();
cdb->name = s_CurInfo.name;
cdb->driver = s_CurInfo.driver;
cdb->host = s_CurInfo.host;
cdb->user = s_CurInfo.user;
cdb->pass = s_CurInfo.pass;
cdb->database = s_CurInfo.database;
cdb->realDriver = s_CurInfo.realDriver;
cdb->info.maxTimeout = s_CurInfo.info.maxTimeout;
cdb->info.port = s_CurInfo.info.port;
cdb->info.driver = cdb->driver.c_str();
cdb->info.database = cdb->database.c_str();
cdb->info.host = cdb->host.c_str();
cdb->info.user = cdb->user.c_str();
cdb->info.pass = cdb->pass.c_str();
/* Set all of the info members to either a blank string
* or the string pointer from the string table.
*/
ASSIGN_VAR(driver);
ASSIGN_VAR(database);
ASSIGN_VAR(host);
ASSIGN_VAR(user);
ASSIGN_VAR(pass);
/* Save it.. */
m_confs.push_back(cdb);
m_confs.push_back(s_CurInfo);
/* Go up one level */
m_ParseState = DBPARSE_LEVEL_MAIN;
@@ -254,6 +244,7 @@ SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
return SMCResult_Continue;
}
#undef ASSIGN_VAR
void DBManager::ReadSMC_ParseEnd(bool halted, bool failed)
{
@@ -342,10 +333,10 @@ void DBManager::RemoveDriver(IDBDriver *pDriver)
}
/* Make sure NOTHING references this! */
List<ConfDbInfo *>::iterator iter;
List<ConfDbInfo>::iterator iter;
for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
{
ConfDbInfo &db = *(*iter);
ConfDbInfo &db = (*iter);
if (db.realDriver == pDriver)
{
db.realDriver = NULL;
@@ -457,12 +448,12 @@ const DatabaseInfo *DBManager::FindDatabaseConf(const char *name)
ConfDbInfo *DBManager::GetDatabaseConf(const char *name)
{
List<ConfDbInfo *>::iterator iter;
List<ConfDbInfo>::iterator iter;
for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
{
ConfDbInfo &conf = *(*iter);
if (conf.name == name)
ConfDbInfo &conf = (*iter);
if (strcmp(m_StrTab.GetString(conf.name), name) == 0)
{
return &conf;
}
+10 -9
View File
@@ -47,15 +47,16 @@ using namespace SourceHook;
struct ConfDbInfo
{
ConfDbInfo() : realDriver(NULL)
ConfDbInfo() : name(-1), driver(-1), host(-1), user(-1), pass(-1),
database(-1), realDriver(NULL)
{
}
String name;
String driver;
String host;
String user;
String pass;
String database;
int name;
int driver;
int host;
int user;
int pass;
int database;
IDBDriver *realDriver;
DatabaseInfo info;
};
@@ -120,7 +121,6 @@ public:
return m_DatabaseType;
}
private:
void ClearConfigs();
void KillWorkerThread();
private:
CVector<IDBDriver *> m_drivers;
@@ -134,10 +134,11 @@ private:
IMutex *m_pQueueLock; /* Queue safety lock */
IMutex *m_pThinkLock; /* Think-queue lock */
List<ConfDbInfo *> m_confs;
List<ConfDbInfo> m_confs;
HandleType_t m_DriverType;
HandleType_t m_DatabaseType;
String m_DefDriver;
BaseStringTable m_StrTab;
char m_Filename[PLATFORM_MAX_PATH];
unsigned int m_ParseLevel;
unsigned int m_ParseState;
+2 -7
View File
@@ -56,16 +56,11 @@ void DebugReport::OnDebugSpew(const char *msg, ...)
void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...)
{
va_list ap;
char buffer[512];
va_start(ap, message);
GenerateErrorVA(ctx, func_idx, err, message, ap);
va_end(ap);
}
void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap)
{
char buffer[512];
UTIL_FormatArgs(buffer, sizeof(buffer), message, ap);
va_end(ap);
const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
const char *error = g_pSourcePawn2->GetErrorString(err);
-1
View File
@@ -46,7 +46,6 @@ public: // IDebugListener
void OnDebugSpew(const char *msg, ...);
public:
void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...);
void GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap);
void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...);
private:
int _GetPluginIndex(IPluginContext *ctx);
+1 -8
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -161,13 +161,6 @@ void EventManager::FireGameEvent(IGameEvent *pEvent)
Just need to add ourselves as a listener to make our hook on IGameEventManager2::FireEvent work */
}
#if SOURCE_ENGINE >= SE_LEFT4DEAD
int EventManager::GetEventDebugID()
{
return EVENT_DEBUG_ID_INIT;
}
#endif
EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode)
{
EventHook *pHook;
+1 -4
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -105,9 +105,6 @@ public: // IPluginsListener
void OnPluginUnloaded(IPlugin *plugin);
public: // IGameEventListener2
void FireGameEvent(IGameEvent *pEvent);
#if SOURCE_ENGINE >= SE_LEFT4DEAD
int GetEventDebugID();
#endif
public:
/**
* Get the 'GameEvent' handle type ID.
+7 -51
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -65,14 +65,8 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena
#define GAMEFIX "2.l4d"
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
#define GAMEFIX "2.l4d2"
#elif SOURCE_ENGINE == SE_ALIENSWARM
#define GAMEFIX "2.swarm"
#elif SOURCE_ENGINE == SE_ORANGEBOX
#define GAMEFIX "2.ep2"
#elif SOURCE_ENGINE == SE_BLOODYGOODTIME
#define GAMEFIX "2.bgt"
#elif SOURCE_ENGINE == SE_EYE
#define GAMEFIX "2.eye"
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
#define GAMEFIX "2.ep2v"
#elif SOURCE_ENGINE == SE_DARKMESSIAH
@@ -91,12 +85,6 @@ CLocalExtension::CLocalExtension(const char *filename)
char path[PLATFORM_MAX_PATH];
/* Special case for new bintools binary */
if (strcmp(filename, "bintools.ext") == 0)
{
goto normal;
}
/* Zeroth, see if there is an engine specific build in the new place. */
g_SourceMod.BuildPath(Path_SM,
path,
@@ -116,7 +104,6 @@ CLocalExtension::CLocalExtension(const char *filename)
"extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT,
filename);
normal:
/* Try the "normal" version */
if (!g_LibSys.IsPathFile(path))
{
@@ -184,28 +171,6 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
{
bool already;
m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength);
// Check the plugin didn't refuse load
Pl_Status status;
#ifndef METAMOD_PLAPI_VERSION
const char *file;
PluginId source;
#endif
if (!m_PlId || (
#ifndef METAMOD_PLAPI_VERSION
g_pMMPlugins->Query(m_PlId, file, status, source)
#else
g_pMMPlugins->Query(m_PlId, NULL, &status, NULL)
#endif
&& status < Pl_Paused))
{
m_pLib->CloseLibrary();
m_pLib = NULL;
m_pAPI = NULL;
return false;
}
}
if (!CExtension::Load(error, maxlength))
@@ -372,11 +337,6 @@ const char *CExtension::GetFilename()
return m_RealFile.c_str();
}
const char *CExtension::GetPath() const
{
return m_Path.c_str();
}
IdentityToken_t *CExtension::GetIdentity()
{
return m_pIdentToken;
@@ -585,7 +545,7 @@ void CExtensionManager::TryAutoload()
}
}
IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing)
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{
/* Remove platform extension if it's there. Compat hack. */
const char *ext = g_LibSys.GetFileExtension(path);
@@ -594,7 +554,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn
char path2[PLATFORM_MAX_PATH];
UTIL_Format(path2, sizeof(path2), "%s", path);
path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadAutoExtension(path2, bErrorOnMissing);
return LoadAutoExtension(path2);
}
IExtension *pAlready;
@@ -613,11 +573,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn
if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
{
if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath()))
{
g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
}
g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
p->SetError(error);
}
@@ -1032,7 +988,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{
if (argcount < 4)
{
g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>");
return;
}
@@ -1040,7 +996,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
unsigned int id = atoi(sId);
if (id <= 0)
{
g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>");
return;
}
@@ -1117,7 +1073,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{
if (argcount < 4)
{
g_RootMenu.ConsolePrint("[SM] Usage: sm exts unload <#> [code]");
g_RootMenu.ConsolePrint("[SM] Usage: sm unload <#> [code]");
return;
}
+1 -2
View File
@@ -66,7 +66,6 @@ public:
public: //IExtension
IExtensionInterface *GetAPI();
const char *GetFilename();
const char *GetPath() const;
IdentityToken_t *GetIdentity();
ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
@@ -164,7 +163,7 @@ public: //IPluginsListener
public: //IRootConsoleCommand
void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
public:
IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true);
IExtension *LoadAutoExtension(const char *path);
void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
void AddInterface(IExtension *pOwner, SMInterface *pInterface);
void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin);
@@ -27,28 +27,24 @@
* or <http://www.sourcemod.net/license.php>.
*/
#include "common_logic.h"
#include <string.h>
#include <stdlib.h>
#include <sh_list.h>
#include <sh_string.h>
#include "GameConfigs.h"
#include "stringutil.h"
#include <IGameHelpers.h>
#include <ILibrarySys.h>
#include <IHandleSys.h>
#include <IMemoryUtils.h>
#include <ISourceMod.h>
#include "common_logic.h"
#include "sm_crc32.h"
#include "sm_stringutil.h"
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "HalfLife2.h"
#include "Logger.h"
#include "ShareSys.h"
#include "MemoryUtils.h"
#include "LibrarySys.h"
#include "HandleSys.h"
#include "sm_crc32.h"
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
#include <dlfcn.h>
#endif
using namespace SourceHook;
GameConfigManager g_GameConfigs;
IGameConfig *g_pGameConf = NULL;
static char g_Game[256];
@@ -67,9 +63,6 @@ static char g_GameName[256] = {'$', '\0'};
#define PSTATE_GAMEDEFS_CRC 9
#define PSTATE_GAMEDEFS_CRC_BINARY 10
#define PSTATE_GAMEDEFS_CUSTOM 11
#define PSTATE_GAMEDEFS_ADDRESSES 12
#define PSTATE_GAMEDEFS_ADDRESSES_ADDRESS 13
#define PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ 14
#if defined PLATFORM_WINDOWS
#define PLATFORM_NAME "windows"
@@ -78,8 +71,8 @@ static char g_GameName[256] = {'$', '\0'};
#define PLATFORM_NAME "linux"
#define PLATFORM_SERVER_BINARY "server_i486.so"
#elif defined PLATFORM_APPLE
#define PLATFORM_NAME "mac"
#define PLATFORM_SERVER_BINARY "server.dylib"
#define PLATFORM_NAME "undef"
#define PLATFORM_SERVER_BINARY "undef.dylib"
#endif
struct TempSigInfo
@@ -112,13 +105,34 @@ static bool DoesGameMatch(const char *value)
static bool DoesEngineMatch(const char *value)
{
return strcmp(value, smcore.GetSourceEngineName()) == 0;
#if SOURCE_ENGINE == SE_EPISODEONE
if (strcmp(value, "original") == 0)
#elif SOURCE_ENGINE == SE_DARKMESSIAH
if (strcmp(value, "darkmessiah") == 0)
#elif SOURCE_ENGINE == SE_ORANGEBOX
if (strcmp(value, "orangebox") == 0)
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
if (strcmp(value, "orangebox_valve") == 0)
#elif SOURCE_ENGINE == SE_LEFT4DEAD
if (strcmp(value, "left4dead") == 0)
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
if (strcmp(value, "left4dead2") == 0)
#else
#error "Unknown engine type"
#endif
{
return true;
}
return false;
}
CGameConfig::CGameConfig(const char *file)
{
strncopy(m_File, file, sizeof(m_File));
m_pAddresses = new KTrie<AddressConf>();
m_pOffsets = sm_trie_create();
m_pProps = sm_trie_create();
m_pKeys = sm_trie_create();
m_pSigs = sm_trie_create();
m_pStrings = new BaseStringTable(512);
m_RefCount = 0;
@@ -128,7 +142,10 @@ CGameConfig::CGameConfig(const char *file)
CGameConfig::~CGameConfig()
{
delete m_pAddresses;
sm_trie_destroy(m_pOffsets);
sm_trie_destroy(m_pProps);
sm_trie_destroy(m_pKeys);
sm_trie_destroy(m_pSigs);
delete m_pStrings;
}
@@ -195,10 +212,6 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
m_ParseState = PSTATE_GAMEDEFS_CRC;
bShouldBeReadingDefault = false;
}
else if (strcmp(name, "Addresses") == 0)
{
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES;
}
else
{
ITextListener_SMC **pListen = g_GameConfigs.m_customHandlers.retrieve(name);
@@ -237,17 +250,17 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
error[0] = '\0';
if (strcmp(name, "server") != 0)
{
smcore.Format(error, sizeof(error), "Unrecognized library \"%s\"", name);
UTIL_Format(error, sizeof(error), "Unrecognized library \"%s\"", name);
}
else if (!s_ServerBinCRC_Ok)
{
FILE *fp;
char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_Game, path, sizeof(path), "bin/" PLATFORM_SERVER_BINARY);
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "bin/" PLATFORM_SERVER_BINARY);
if ((fp = fopen(path, "rb")) == NULL)
{
smcore.Format(error, sizeof(error), "Could not open binary: %s", path);
UTIL_Format(error, sizeof(error), "Could not open binary: %s", path);
} else {
size_t size;
void *buffer;
@@ -267,8 +280,8 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
if (error[0] != '\0')
{
m_IgnoreLevel = 1;
smcore.LogError("[SM] Error while parsing CRC section for \"%s\" (%s):", m_Game, m_CurFile);
smcore.LogError("[SM] %s", error);
g_Logger.LogError("[SM] Error while parsing CRC section for \"%s\" (%s):", m_Game, m_CurFile);
g_Logger.LogError("[SM] %s", error);
} else {
m_ParseState = PSTATE_GAMEDEFS_CRC_BINARY;
}
@@ -280,41 +293,12 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
return m_CustomHandler->ReadSMC_NewSection(states, name);
break;
}
case PSTATE_GAMEDEFS_ADDRESSES:
{
m_Address[0] = '\0';
m_AddressSignature[0] = '\0';
m_AddressReadCount = 0;
strncopy(m_Address, name, sizeof(m_Address));
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES_ADDRESS;
break;
}
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS:
{
if (strcmp(name, PLATFORM_NAME) == 0)
{
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ;
}
else
{
if (strcmp(name, "linux") != 0 && strcmp(name, "windows") != 0 && strcmp(name, "mac") != 0)
{
smcore.LogError("[SM] Error while parsing Address section for \"%s\" (%s):", m_Address, m_CurFile);
smcore.LogError("[SM] Unrecognized platform \"%s\"", name);
}
m_IgnoreLevel = 1;
}
break;
}
/* No sub-sections allowed:
case PSTATE_GAMEDEFS_OFFSETS_OFFSET:
case PSTATE_GAMEDEFS_KEYS:
case PSTATE_GAMEDEFS_SUPPORTED:
case PSTATE_GAMEDEFS_SIGNATURES_SIG:
case PSTATE_GAMEDEFS_CRC_BINARY:
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ:
*/
default:
{
@@ -342,10 +326,12 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
} else if (strcmp(key, "prop") == 0) {
strncopy(m_Prop, value, sizeof(m_Prop));
} else if (strcmp(key, PLATFORM_NAME) == 0) {
m_Offsets.replace(m_offset, atoi(value));
int val = atoi(value);
sm_trie_replace(m_pOffsets, m_offset, (void *)val);
}
} else if (m_ParseState == PSTATE_GAMEDEFS_KEYS) {
m_Keys.replace(key, m_pStrings->AddString(value));
int id = m_pStrings->AddString(value);
sm_trie_replace(m_pKeys, key, (void *)id);
} else if (m_ParseState == PSTATE_GAMEDEFS_SUPPORTED) {
if (strcmp(key, "game") == 0)
{
@@ -390,21 +376,6 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
bShouldBeReadingDefault = true;
}
}
} else if (m_ParseState == PSTATE_GAMEDEFS_ADDRESSES_ADDRESS || m_ParseState == PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ) {
if (strcmp(key, "read") == 0) {
int limit = sizeof(m_AddressRead)/sizeof(m_AddressRead[0]);
if (m_AddressReadCount < limit)
{
m_AddressRead[m_AddressReadCount] = atoi(value);
m_AddressReadCount++;
}
else
{
smcore.LogError("[SM] Error parsing Address \"%s\", does not support more than %d read offsets (gameconf \"%s\")", m_Address, limit, m_CurFile);
}
} else if (strcmp(key, "signature") == 0) {
strncopy(m_AddressSignature, value, sizeof(m_AddressSignature));
}
} else if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM) {
return m_CustomHandler->ReadSMC_KeyValue(states, key, value);
}
@@ -457,18 +428,18 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
if (m_Class[0] != '\0'
&& m_Prop[0] != '\0')
{
SendProp *pProp = gamehelpers->FindInSendTable(m_Class, m_Prop);
SendProp *pProp = g_HL2.FindInSendTable(m_Class, m_Prop);
if (pProp)
{
int val = gamehelpers->GetSendPropOffset(pProp);
m_Offsets.replace(m_offset, val);
m_Props.replace(m_offset, pProp);
int val = pProp->GetOffset();
sm_trie_replace(m_pOffsets, m_offset, (void *)val);
sm_trie_replace(m_pProps, m_offset, pProp);
} else {
/* Check if it's a non-default game and no offsets exist */
if (((strcmp(m_Game, "*") != 0) && strcmp(m_Game, "#default") != 0)
&& (!m_Offsets.retrieve(m_offset)))
&& (!sm_trie_retrieve(m_pOffsets, m_offset, NULL)))
{
smcore.LogError("[SM] Unable to find property %s.%s (file \"%s\") (mod \"%s\")",
g_Logger.LogError("[SM] Unable to find property %s.%s (file \"%s\") (mod \"%s\")",
m_Class,
m_Prop,
m_CurFile,
@@ -512,20 +483,18 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
void *addrInBase = NULL;
if (strcmp(s_TempSig.library, "server") == 0)
{
addrInBase = smcore.serverFactory;
addrInBase = (void *)g_SMAPI->GetServerFactory(false);
} else if (strcmp(s_TempSig.library, "engine") == 0) {
addrInBase = smcore.engineFactory;
} else if (strcmp(s_TempSig.library, "matchmaking_ds") == 0) {
addrInBase = smcore.matchmakingDSFactory;
addrInBase = (void *)g_SMAPI->GetEngineFactory(false);
}
void *final_addr = NULL;
if (addrInBase == NULL)
{
smcore.LogError("[SM] Unrecognized library \"%s\" (gameconf \"%s\")",
g_Logger.LogError("[SM] Unrecognized library \"%s\" (gameconf \"%s\")",
s_TempSig.library,
m_CurFile);
} else {
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
if (s_TempSig.sig[0] == '@')
{
Dl_info info;
@@ -535,18 +504,19 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
void *handle = dlopen(info.dli_fname, RTLD_NOW);
if (handle)
{
if (smcore.SymbolsAreHidden())
final_addr = g_MemUtils.ResolveSymbol(handle, &s_TempSig.sig[1]);
else
final_addr = dlsym(handle, &s_TempSig.sig[1]);
#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
final_addr = g_MemUtils.ResolveSymbol(handle, &s_TempSig.sig[1]);
#else
final_addr = dlsym(handle, &s_TempSig.sig[1]);
#endif
dlclose(handle);
} else {
smcore.LogError("[SM] Unable to load library \"%s\" (gameconf \"%s\")",
g_Logger.LogError("[SM] Unable to load library \"%s\" (gameconf \"%s\")",
s_TempSig.library,
m_File);
}
} else {
smcore.LogError("[SM] Unable to find library \"%s\" in memory (gameconf \"%s\")",
g_Logger.LogError("[SM] Unable to find library \"%s\" in memory (gameconf \"%s\")",
s_TempSig.library,
m_File);
}
@@ -572,42 +542,12 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
}
}
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
skip_find:
#endif
m_Sigs.replace(m_offset, final_addr);
sm_trie_replace(m_pSigs, m_offset, final_addr);
m_ParseState = PSTATE_GAMEDEFS_SIGNATURES;
break;
}
case PSTATE_GAMEDEFS_ADDRESSES:
{
m_ParseState = PSTATE_GAMEDEFS;
break;
}
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS:
{
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES;
if (m_Address[0] == '\0')
{
smcore.LogError("[SM] Address sections must have names (gameconf \"%s\")", m_CurFile);
break;
}
if (m_AddressSignature[0] == '\0')
{
smcore.LogError("[SM] Address section for \"%s\" did not specify a signature (gameconf \"%s\")", m_Address, m_CurFile);
break;
}
AddressConf addrConf(m_AddressSignature, sizeof(m_AddressSignature), m_AddressReadCount, m_AddressRead);
m_pAddresses->replace(m_Address, addrConf);
break;
}
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ:
{
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES_ADDRESS;
break;
}
}
@@ -746,19 +686,18 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
{
/* Reset cached data */
m_pStrings->Reset();
m_Offsets.clear();
m_Props.clear();
m_Keys.clear();
m_pAddresses->clear();
sm_trie_clear(m_pOffsets);
sm_trie_clear(m_pProps);
sm_trie_clear(m_pKeys);
char path[PLATFORM_MAX_PATH];
/* See if we can use the extended gamedata format. */
g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/master.games.txt", m_File);
if (!libsys->PathExists(path))
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/master.games.txt", m_File);
if (!g_LibSys.PathExists(path))
{
/* Nope, use the old mechanism. */
smcore.Format(path, sizeof(path), "%s.txt", m_File);
UTIL_Format(path, sizeof(path), "%s.txt", m_File);
return EnterFile(path, error, maxlength);
}
@@ -773,8 +712,8 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
{
const char *msg = textparsers->GetSMCErrorString(err);
smcore.LogError("[SM] Error parsing master gameconf file \"%s\":", path);
smcore.LogError("[SM] Error %d on line %d, col %d: %s",
g_Logger.LogError("[SM] Error parsing master gameconf file \"%s\":", path);
g_Logger.LogError("[SM] Error %d on line %d, col %d: %s",
err,
state.line,
state.col,
@@ -786,7 +725,7 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
List<String>::iterator iter;
for (iter = fileList.begin(); iter != fileList.end(); iter++)
{
smcore.Format(path, sizeof(path), "%s/%s", m_File, (*iter).c_str());
UTIL_Format(path, sizeof(path), "%s/%s", m_File, (*iter).c_str());
if (!EnterFile(path, error, maxlength))
{
return false;
@@ -794,8 +733,8 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
}
/* Parse the contents of the 'custom' directory */
g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/custom", m_File);
IDirectory *customDir = libsys->OpenDirectory(path);
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/custom", m_File);
IDirectory *customDir = g_LibSys.OpenDirectory(path);
if (!customDir)
{
@@ -820,17 +759,17 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
continue;
}
smcore.Format(path, sizeof(path), "%s/custom/%s", m_File, curFile);
UTIL_Format(path, sizeof(path), "%s/custom/%s", m_File, curFile);
if (!EnterFile(path, error, maxlength))
{
libsys->CloseDirectory(customDir);
g_LibSys.CloseDirectory(customDir);
return false;
}
customDir->NextEntry();
}
libsys->CloseDirectory(customDir);
g_LibSys.CloseDirectory(customDir);
return true;
}
@@ -839,7 +778,7 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength)
SMCError err;
SMCStates state = {0, 0};
g_pSM->BuildPath(Path_SM, m_CurFile, sizeof(m_CurFile), "gamedata/%s", file);
g_SourceMod.BuildPath(Path_SM, m_CurFile, sizeof(m_CurFile), "gamedata/%s", file);
/* Initialize parse states */
m_IgnoreLevel = 0;
@@ -853,8 +792,8 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength)
msg = textparsers->GetSMCErrorString(err);
smcore.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile);
smcore.LogError("[SM] Error %d on line %d, col %d: %s",
g_Logger.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile);
g_Logger.LogError("[SM] Error %d on line %d, col %d: %s",
err,
state.line,
state.col,
@@ -876,91 +815,43 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength)
bool CGameConfig::GetOffset(const char *key, int *value)
{
int *pvalue;
if ((pvalue = m_Offsets.retrieve(key)) == NULL)
return false;
void *obj;
*value = *pvalue;
if (!sm_trie_retrieve(m_pOffsets, key, &obj))
{
return false;
}
*value = (int)obj;
return true;
}
const char *CGameConfig::GetKeyValue(const char *key)
{
int *pkey;
if ((pkey = m_Keys.retrieve(key)) == NULL)
void *obj;
if (!sm_trie_retrieve(m_pKeys, key, &obj))
{
return NULL;
return m_pStrings->GetString(*pkey);
}
//memory addresses below 0x10000 are automatically considered invalid for dereferencing
#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
bool CGameConfig::GetAddress(const char *key, void **retaddr)
{
AddressConf *addrConf;
addrConf = m_pAddresses->retrieve(key);
if (!addrConf)
{
*retaddr = NULL;
return false;
}
void *addr;
if (!GetMemSig(addrConf->signatureName, &addr))
{
*retaddr = NULL;
return false;
}
for (int i = 0; i < addrConf->readCount; ++i)
{
int offset = addrConf->read[i];
//NULLs in the middle of an indirection chain are bad, end NULL is ok
if (addr == NULL || reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
*retaddr = NULL;
return false;
}
addr = *(reinterpret_cast<void**>(reinterpret_cast<uint8_t*>(addr) + offset));
}
*retaddr = addr;
return true;
}
static inline unsigned minOf(unsigned a, unsigned b)
{
return a <= b ? a : b;
}
CGameConfig::AddressConf::AddressConf(char *sigName, unsigned sigLength, unsigned readCount, int *read)
{
unsigned readLimit = minOf(readCount, sizeof(this->read) / sizeof(this->read[0]));
strncopy(signatureName, sigName, sizeof(signatureName) / sizeof(signatureName[0]));
this->readCount = readLimit;
memcpy(&this->read[0], read, sizeof(this->read[0])*readLimit);
return m_pStrings->GetString((int)obj);
}
SendProp *CGameConfig::GetSendProp(const char *key)
{
SendProp **pProp;
SendProp *pProp;
if ((pProp = m_Props.retrieve(key)) == NULL)
if (!sm_trie_retrieve(m_pProps, key, (void **)&pProp))
{
return NULL;
}
return *pProp;
return pProp;
}
bool CGameConfig::GetMemSig(const char *key, void **addr)
{
void **paddr;
if ((paddr = m_Sigs.retrieve(key)) == NULL)
return false;
*addr = *paddr;
return true;
return sm_trie_retrieve(m_pSigs, key, addr);
}
void CGameConfig::IncRefCount()
@@ -976,19 +867,31 @@ unsigned int CGameConfig::DecRefCount()
GameConfigManager::GameConfigManager()
{
m_pLookup = sm_trie_create();
}
GameConfigManager::~GameConfigManager()
{
sm_trie_destroy(m_pLookup);
}
void GameConfigManager::OnSourceModStartup(bool late)
{
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
strncopy(g_Game, g_pSM->GetGameFolderName(), sizeof(g_Game));
strncopy(g_GameDesc + 1, smcore.GetGameDescription(), sizeof(g_GameDesc) - 1);
smcore.GetGameName(g_GameName + 1, sizeof(g_GameName) - 1);
strncopy(g_Game, g_SourceMod.GetGameFolderName(), sizeof(g_Game));
strncopy(g_GameDesc + 1, SERVER_CALL(GetGameDescription)(), sizeof(g_GameDesc) - 1);
KeyValues *pGameInfo = new KeyValues("GameInfo");
if (g_HL2.KVLoadFromFile(pGameInfo, basefilesystem, "gameinfo.txt"))
{
const char *str;
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
{
strncopy(g_GameName + 1, str, sizeof(g_GameName) - 1);
}
}
pGameInfo->deleteThis();
}
void GameConfigManager::OnSourceModAllInitialized()
@@ -1002,7 +905,7 @@ void GameConfigManager::OnSourceModAllInitialized()
/* :TODO: log */
}
sharesys->AddInterface(NULL, this);
g_ShareSys.AddInterface(NULL, this);
}
void GameConfigManager::OnSourceModAllShutdown()
@@ -1022,11 +925,9 @@ bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pCon
#endif
CGameConfig *pConfig;
CGameConfig **ppConfig;
if ((ppConfig = m_Lookup.retrieve(file)) != NULL)
if (sm_trie_retrieve(m_pLookup, file, (void **)&pConfig))
{
pConfig = *ppConfig;
pConfig->IncRefCount();
*_pConfig = pConfig;
return true;
@@ -1042,7 +943,7 @@ bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pCon
}
m_cfgs.push_back(pConfig);
m_Lookup.insert(file, pConfig);
sm_trie_insert(m_pLookup, file, pConfig);
pConfig->IncRefCount();
@@ -1057,18 +958,18 @@ void GameConfigManager::CloseGameConfigFile(IGameConfig *cfg)
if (pConfig->DecRefCount() == 0)
{
m_Lookup.remove(pConfig->m_File);
sm_trie_delete(m_pLookup, pConfig->m_File);
delete pConfig;
}
}
extern Handle_t g_GameConfigsType;
extern HandleType_t g_GameConfigsType;
IGameConfig *GameConfigManager::ReadHandle(Handle_t hndl, IdentityToken_t *ident, HandleError *err)
{
HandleSecurity sec(ident, g_pCoreIdent);
IGameConfig *conf = NULL;
HandleError _err = handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&conf);
HandleError _err = g_HandleSys.ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&conf);
if (err)
{
@@ -32,12 +32,13 @@
#ifndef _INCLUDE_SOURCEMOD_CGAMECONFIGS_H_
#define _INCLUDE_SOURCEMOD_CGAMECONFIGS_H_
#include "common_logic.h"
#include <IGameConfigs.h>
#include <ITextParsers.h>
#include <sh_list.h>
#include "sm_trie.h"
#include "sm_globals.h"
#include "sm_memtable.h"
#include <sm_trie_tpl.h>
#include "sm_trie_tpl.h"
using namespace SourceMod;
using namespace SourceHook;
@@ -64,7 +65,6 @@ public: //IGameConfig
bool GetOffset(const char *key, int *value);
SendProp *GetSendProp(const char *key);
bool GetMemSig(const char *key, void **addr);
bool GetAddress(const char *key, void **addr);
public:
void IncRefCount();
unsigned int DecRefCount();
@@ -72,10 +72,10 @@ private:
BaseStringTable *m_pStrings;
char m_File[PLATFORM_MAX_PATH];
char m_CurFile[PLATFORM_MAX_PATH];
KTrie<int> m_Offsets;
KTrie<SendProp *> m_Props;
KTrie<int> m_Keys;
KTrie<void *> m_Sigs;
Trie *m_pOffsets;
Trie *m_pProps;
Trie *m_pKeys;
Trie *m_pSigs;
unsigned int m_RefCount;
/* Parse states */
int m_ParseState;
@@ -93,24 +93,6 @@ private:
/* Custom Sections */
unsigned int m_CustomLevel;
ITextListener_SMC *m_CustomHandler;
/* Support for reading Addresses */
struct AddressConf
{
char signatureName[64];
int readCount;
int read[8];
AddressConf(char *sigName, unsigned sigLength, unsigned readCount, int *read);
AddressConf() {}
};
char m_Address[64];
char m_AddressSignature[64];
int m_AddressReadCount;
int m_AddressRead[8];
KTrie<AddressConf> *m_pAddresses;
};
class GameConfigManager :
@@ -136,7 +118,7 @@ public: //SMGlobalClass
void OnSourceModAllShutdown();
private:
List<CGameConfig *> m_cfgs;
KTrie<CGameConfig *> m_Lookup;
Trie *m_pLookup;
public:
KTrie<ITextListener_SMC *> m_customHandlers;
};
+28 -60
View File
@@ -35,10 +35,9 @@
#include "UserMessages.h"
#include "PlayerManager.h"
#include "sm_stringutil.h"
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include <compat_wrappers.h>
#include <Logger.h>
#include "logic_bridge.h"
CHalfLife2 g_HL2;
ConVar *sv_lan = NULL;
@@ -133,61 +132,40 @@ void CHalfLife2::OnSourceModAllInitialized()
void CHalfLife2::OnSourceModAllInitialized_Post()
{
char *addr = NULL;
#ifdef PLATFORM_WINDOWS
int offset;
/*
* gEntList and/or g_pEntityList
*
* First try to lookup pointer directly for platforms with symbols.
* If symbols aren't present (Windows or stripped Linux/Mac),
* attempt find via LevelShutdown + offset
*/
if (g_pGameConf->GetMemSig("gEntList", (void **)&addr))
/* gEntList and/or g_pEntityList */
if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr))
{
#if !defined PLATFORM_WINDOWS
if (!addr)
{
// Key exists so notify if lookup fails, but try other method.
g_Logger.LogError("Failed lookup of gEntList directly - Reverting to lookup via LevelShutdown");
}
else
{
#endif
g_EntList = reinterpret_cast<void *>(addr);
#if !defined PLATFORM_WINDOWS
}
#endif
g_Logger.LogError("Logical Entities not supported by this mod (LevelShutdown) - Reverting to networkable entities only");
return;
}
if (!g_EntList)
if (!addr)
{
if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr))
{
g_Logger.LogError("Logical Entities not supported by this mod (LevelShutdown) - Reverting to networkable entities only");
return;
}
if (!addr)
{
g_Logger.LogError("Failed lookup of LevelShutdown - Reverting to networkable entities only");
return;
}
int offset;
if (!g_pGameConf->GetOffset("gEntList", &offset))
{
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
return;
}
g_EntList = *reinterpret_cast<void **>(addr + offset);
g_Logger.LogError("Failed lookup of LevelShutdown - Reverting to networkable entities only");
return;
}
if (!g_EntList)
if (!g_pGameConf->GetOffset("gEntList", &offset))
{
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
return;
}
g_EntList = *reinterpret_cast<void **>(addr + offset);
#elif defined PLATFORM_LINUX
/* gEntList and/or g_pEntityList */
if (!g_pGameConf->GetMemSig("gEntList", (void **)&addr))
{
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
return;
}
if (!addr)
{
g_Logger.LogError("Failed lookup of gEntList - Reverting to networkable entities only");
return;
}
g_EntList = reinterpret_cast<void *>(addr);
#endif
if (!g_pGameConf->GetOffset("EntInfo", &entInfoOffset))
{
@@ -381,11 +359,13 @@ void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset)
#if SOURCE_ENGINE != SE_DARKMESSIAH
if (g_pSharedChangeInfo != NULL)
{
#if SOURCE_ENGINE != SE_LEFT4DEAD2
if (offset)
{
pEdict->StateChanged(offset);
}
else
#endif
{
pEdict->StateChanged();
}
@@ -787,12 +767,6 @@ CBaseEntity *CHalfLife2::ReferenceToEntity(cell_t entRef)
*/
CEntInfo *CHalfLife2::LookupEntity(int entIndex)
{
// Make sure that our index is within the bounds of the global ent array
if (entIndex < 0 || entIndex >= NUM_ENT_ENTRIES)
{
return NULL;
}
if (!g_EntList || entInfoOffset == -1)
{
/* Attempt to use engine interface instead */
@@ -914,9 +888,3 @@ void *CHalfLife2::GetGlobalEntityList()
{
return g_EntList;
}
int CHalfLife2::GetSendPropOffset(SendProp *prop)
{
return prop->GetOffset();
}
-1
View File
@@ -135,7 +135,6 @@ public: //IGameHelpers
CEntInfo *LookupEntity(int entIndex);
cell_t EntityToBCompatRef(CBaseEntity *pEntity);
void *GetGlobalEntityList();
int GetSendPropOffset(SendProp *prop);
public:
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
void ProcessFakeCliCmdQueue();
+3 -44
View File
@@ -620,43 +620,6 @@ HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, Iden
return CloneHandle(pHandle, index, newhandle, newOwner);
}
Handle_t HandleSystem::FastCloneHandle(QHandle *pHandle, unsigned int index)
{
if (pHandle->clone)
return FastCloneHandle(&m_Handles[pHandle->clone], pHandle->clone);
Handle_t hndl;
if (CloneHandle(pHandle, index, &hndl, g_pCoreIdent) != HandleError_None)
return BAD_HANDLE;
return hndl;
}
Handle_t HandleSystem::FastCloneHandle(Handle_t hndl)
{
QHandle *pHandle;
unsigned int index;
GetHandleUnchecked(hndl, pHandle, index);
return FastCloneHandle(pHandle, index);
}
void HandleSystem::GetHandleUnchecked(Handle_t hndl, QHandle *& pHandle, unsigned int &index)
{
#ifndef NDEBUG
unsigned int serial = (hndl >> 16);
#endif
index = (hndl & HANDLESYS_HANDLE_MASK);
assert(index != 0 && index <= m_HandleTail && index < HANDLESYS_MAX_HANDLES);
pHandle = &m_Handles[index];
assert(pHandle->set && pHandle->set != HandleSet_Freed);
assert(pHandle->serial == serial);
}
HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index)
{
QHandleType *pType = &m_Types[pHandle->type];
@@ -987,10 +950,6 @@ bool HandleSystem::InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHa
return true;
}
#define HANDLE_LOG_VERY_BAD(message, ...) \
g_Logger.LogFatal(message, ##__VA_ARGS__); \
g_Logger.LogError(message, ##__VA_ARGS__);
bool HandleSystem::TryAndFreeSomeHandles()
{
IPluginIterator *pl_iter = g_PluginSys.GetPluginIterator();
@@ -1036,9 +995,9 @@ bool HandleSystem::TryAndFreeSomeHandles()
return false;
}
HANDLE_LOG_VERY_BAD("[SM] MEMORY LEAK DETECTED IN PLUGIN (file \"%s\")", highest_owner->GetFilename());
HANDLE_LOG_VERY_BAD("[SM] Unloading plugin to free %d handles.", highest_handle_count);
HANDLE_LOG_VERY_BAD("[SM] Contact the author(s) of this plugin to correct this error.", highest_handle_count);
g_Logger.LogFatal("[SM] MEMORY LEAK DETECTED IN PLUGIN (file \"%s\")", highest_owner->GetFilename());
g_Logger.LogFatal("[SM] Unloading plugin to free %d handles.", highest_handle_count);
g_Logger.LogFatal("[SM] Contact the author(s) of this plugin to correct this error.", highest_handle_count);
highest_owner->GetBaseContext()->ThrowNativeErrorEx(SP_ERROR_MEMACCESS, "Memory leak");
-29
View File
@@ -160,9 +160,6 @@ public: //IHandleSystem
HandleError *err);
void Dump(HANDLE_REPORTER rep);
/* Bypasses security checks. */
Handle_t FastCloneHandle(Handle_t hndl);
protected:
/**
* Decodes a handle with sanity and security checking.
@@ -173,9 +170,6 @@ protected:
unsigned int *index,
bool ignoreFree=false);
Handle_t FastCloneHandle(QHandle *pHandle, unsigned int index);
void GetHandleUnchecked(Handle_t hndl, QHandle *& pHandle, unsigned int &index);
/**
* Creates a basic handle and sets its reference count to 1.
* Does not do any type or security checking.
@@ -228,27 +222,4 @@ private:
extern HandleSystem g_HandleSys;
struct AutoHandleRooter
{
public:
AutoHandleRooter(Handle_t hndl)
{
if (hndl != BAD_HANDLE)
this->hndl = g_HandleSys.FastCloneHandle(hndl);
else
this->hndl = BAD_HANDLE;
}
~AutoHandleRooter()
{
if (hndl != BAD_HANDLE)
{
HandleSecurity sec(g_pCoreIdent, g_pCoreIdent);
g_HandleSys.FreeHandle(hndl, &sec);
}
}
private:
Handle_t hndl;
};
#endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_H_
+2 -2
View File
@@ -241,7 +241,7 @@ bool LibrarySystem::IsPathDirectory(const char *path)
return true;
}
#elif defined PLATFORM_POSIX
#elif defined PLATFORM_LINUX
struct stat s;
if (stat(path, &s) != 0)
@@ -410,7 +410,7 @@ size_t LibrarySystem::GetFileFromPath(char *buffer, size_t maxlength, const char
size_t length = strlen(path);
for (size_t i = length - 1;
i <= length - 1;
i >= 0 && i <= length - 1;
i--)
{
if (path[i] == '/'
+51 -55
View File
@@ -2,30 +2,32 @@
# Makefile written by David "BAILOPAN" Anderson
SMSDK = ..
SRCDS_BASE = ~/srcds
HL2SDK_ORIG = ../../hl2sdk
HL2SDK_OB = ../../hl2sdk-ob
HL2SDK_OB_VALVE = ../../hl2sdk-ob-valve
HL2SDK_L4D = ../../hl2sdk-l4d
HL2SDK_L4D2 = ../../hl2sdk-l4d2
MMSOURCE = ../../mmsource-central
MMSOURCE17 = ../../mmsource-central
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \
Database.cpp DebugReporter.cpp EventManager.cpp HalfLife2.cpp Logger.cpp \
PlayerManager.cpp TimerSys.cpp UserMessages.cpp \
sm_autonatives.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \
Database.cpp DebugReporter.cpp EventManager.cpp GameConfigs.cpp HalfLife2.cpp Logger.cpp \
MemoryUtils.cpp PlayerManager.cpp TimerSys.cpp Translator.cpp UserMessages.cpp \
sm_autonatives.cpp sm_memtable.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \
sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \
MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp \
frame_hooks.cpp concmd_cleaner.cpp NextMap.cpp \
MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp sm_crc32.cpp \
frame_hooks.cpp concmd_cleaner.cpp PhraseCollection.cpp NextMap.cpp \
NativeOwner.cpp logic_bridge.cpp ConsoleDetours.cpp
OBJECTS += smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
smn_filesystem.cpp smn_halflife.cpp \
smn_keyvalues.cpp smn_player.cpp \
smn_usermsgs.cpp smn_menus.cpp smn_vector.cpp \
OBJECTS += smn_admin.cpp smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp \
smn_lang.cpp smn_player.cpp smn_string.cpp smn_timers.cpp \
smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \
smn_hudtext.cpp smn_nextmap.cpp
OBJECTS += ExtensionSys.cpp \
ForwardSys.cpp \
@@ -47,81 +49,71 @@ CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
override ENGSET = false
ifneq (,$(filter original orangebox orangeboxvalve left4dead left4dead2,$(ENGINE)))
override ENGSET = true
endif
ifeq "$(ENGINE)" "original"
HL2SDK = $(HL2SDK_ORIG)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/linux_sdk
CFLAGS += -DSOURCE_ENGINE=1
METAMOD = $(MMSOURCE)/core-legacy
METAMOD = $(MMSOURCE17)/core-legacy
INCLUDE += -I$(HL2SDK)/public/dlls
SRCDS = $(SRCDS_BASE)
BINARY = sourcemod.1.ep1.so
override ENGSET = true
endif
ifeq "$(ENGINE)" "orangebox"
HL2SDK = $(HL2SDK_OB)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/lib/linux
CFLAGS += -DSOURCE_ENGINE=3
METAMOD = $(MMSOURCE)/core
METAMOD = $(MMSOURCE17)/core
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/orangebox
BINARY = sourcemod.2.ep2.so
override ENGSET = true
endif
ifeq "$(ENGINE)" "orangeboxvalve"
HL2SDK = $(HL2SDK_OB_VALVE)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/lib/linux
CFLAGS += -DSOURCE_ENGINE=6
METAMOD = $(MMSOURCE)/core
INCLUDE += -I$(HL2SDK)/public/game/server
#-I$(HL2SDK)/common
CFLAGS += -DSOURCE_ENGINE=4
METAMOD = $(MMSOURCE17)/core
INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common
SRCDS = $(SRCDS_BASE)/orangebox
BINARY = sourcemod.2.ep2v.so
override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead"
HL2SDK = $(HL2SDK_L4D)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/lib/linux
CFLAGS += -DSOURCE_ENGINE=7
METAMOD = $(MMSOURCE)/core
CFLAGS += -DSOURCE_ENGINE=5
METAMOD = $(MMSOURCE17)/core
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/l4d
BINARY = sourcemod.2.l4d.so
override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead2"
HL2SDK = $(HL2SDK_L4D2)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/lib/linux
CFLAGS += -DSOURCE_ENGINE=8
METAMOD = $(MMSOURCE)/core
CFLAGS += -DSOURCE_ENGINE=6
METAMOD = $(MMSOURCE17)/core
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/left4dead2
BINARY = sourcemod.2.l4d2.so
override ENGSET = true
endif
HL2PUB = $(HL2SDK)/public
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6
OS := $(shell uname -s)
ifeq "$(OS)" "Darwin"
LIB_EXT = dylib
HL2LIB = $(HL2SDK)/lib/mac
ifeq "$(ENGINE)" "left4dead2"
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a libvstdlib.so \
libtier0.so -static-libgcc
else
LIB_EXT = so
ifeq "$(ENGINE)" "original"
HL2LIB = $(HL2SDK)/linux_sdk
else
HL2LIB = $(HL2SDK)/lib/linux
endif
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so \
tier0_i486.so -static-libgcc
endif
ifneq (,$(filter original orangebox left4dead,$(ENGINE)))
LIB_SUFFIX = _i486.$(LIB_EXT)
else
LIB_PREFIX = lib
LIB_SUFFIX = .$(LIB_EXT)
endif
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \
-DSE_ORANGEBOXVALVE=6 -DSE_LEFT4DEAD=7 -DSE_LEFT4DEAD2=8 -DSE_ALIENSWARM=9
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) \
$(LIB_PREFIX)tier0$(LIB_SUFFIX) -static-libgcc
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \
@@ -161,14 +153,18 @@ $(BIN_DIR)/%.o: %.c
all: check
mkdir -p $(BIN_DIR)
ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX)
ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX)
ifeq "$(ENGINE)" "left4dead2"
ln -sf $(SRCDS)/bin/libvstdlib.so libvstdlib.so;
ln -sf $(SRCDS)/bin/libtier0.so libtier0.so;
else
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so;
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so;
endif
$(MAKE) -f Makefile sourcemod
check:
if [ "$(ENGSET)" = "false" ]; then \
echo "You must supply one of the following values for ENGINE:"; \
echo "left4dead2, left4dead, orangeboxvalve, orangebox, or original"; \
echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \
exit 1; \
fi
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -28,39 +28,36 @@
*/
#include "MemoryUtils.h"
#include "ShareSys.h"
#ifdef PLATFORM_LINUX
#include <fcntl.h>
#include <link.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
#define PAGE_ALIGN_UP(x) ((x + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
#endif
#ifdef PLATFORM_APPLE
#include <mach-o/dyld_images.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#endif
//MemoryUtils g_MemUtils;
MemoryUtils g_MemUtils;
#if 0
MemoryUtils::MemoryUtils()
{
#ifdef PLATFORM_APPLE
#ifdef PLATFORM_WINDOWS
/* Get pointer to struct that describes all loaded mach-o images in process */
struct nlist list[2];
memset(list, 0, sizeof(list));
list[0].n_un.n_name = (char *)"_dyld_all_image_infos";
nlist("/usr/lib/dyld", list);
m_ImageList = (struct dyld_all_image_infos *)list[0].n_value;
SYSTEM_INFO info;
GetSystemInfo(&info);
m_PageSize = info.dwPageSize;
#elif defined PLATFORM_POSIX
m_PageSize = sysconf(_SC_PAGE_SIZE);
#endif
}
#endif
MemoryUtils::~MemoryUtils()
{
#if defined PLATFORM_LINUX || defined PLATFORM_APPLE
#ifdef PLATFORM_LINUX
for (size_t i = 0; i < m_SymTables.size(); i++)
{
delete m_SymTables[i];
@@ -69,10 +66,10 @@ MemoryUtils::~MemoryUtils()
#endif
}
/*void MemoryUtils::OnSourceModAllInitialized()
void MemoryUtils::OnSourceModAllInitialized()
{
sharesys->AddInterface(NULL, this);
}*/
g_ShareSys.AddInterface(NULL, this);
}
void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t len)
{
@@ -116,7 +113,7 @@ void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
#ifdef PLATFORM_WINDOWS
return GetProcAddress((HMODULE)handle, symbol);
#elif defined PLATFORM_LINUX
struct link_map *dlmap;
@@ -131,14 +128,12 @@ void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
uint32_t symbol_count;
LibSymbolTable *libtable;
SymbolTable *table;
AddrTable *table2;
Symbol *symbol_entry;
dlmap = (struct link_map *)handle;
symtab_hdr = NULL;
strtab_hdr = NULL;
table = NULL;
table2 = NULL;
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
@@ -147,7 +142,6 @@ void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
if (libtable->lib_base == dlmap->l_addr)
{
table = &libtable->table;
table2 = &libtable->table2;
break;
}
}
@@ -157,11 +151,9 @@ void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->table2.Initialize();
libtable->lib_base = dlmap->l_addr;
libtable->last_pos = 0;
table = &libtable->table;
table2 = &libtable->table2;
m_SymTables.push_back(libtable);
}
@@ -245,173 +237,23 @@ void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
/* Caching symbols as we go along */
cur_sym = table->InternSymbol(sym_name, strlen(sym_name), (void *)(dlmap->l_addr + sym.st_value));
table2->InternSymbol(sym_name, strlen(sym_name), (void *)(dlmap->l_addr + sym.st_value));
if (strcmp(symbol, sym_name) == 0)
{
symbol_entry = cur_sym;
libtable->last_pos = ++i;
// break;
break;
}
}
libtable->last_pos = symbol_count;
munmap(file_hdr, dlstat.st_size);
return symbol_entry ? symbol_entry->address : NULL;
#elif defined PLATFORM_APPLE
uintptr_t dlbase, linkedit_addr;
uint32_t image_count;
struct mach_header *file_hdr;
struct load_command *loadcmds;
struct segment_command *linkedit_hdr;
struct symtab_command *symtab_hdr;
struct nlist *symtab;
const char *strtab;
uint32_t loadcmd_count;
uint32_t symbol_count;
LibSymbolTable *libtable;
SymbolTable *table;
Symbol *symbol_entry;
dlbase = 0;
image_count = m_ImageList->infoArrayCount;
linkedit_hdr = NULL;
symtab_hdr = NULL;
table = NULL;
/* Loop through mach-o images in process.
* We can skip index 0 since that is just the executable.
*/
for (uint32_t i = 1; i < image_count; i++)
{
const struct dyld_image_info &info = m_ImageList->infoArray[i];
/* "Load" each one until we get a matching handle */
void *h = dlopen(info.imageFilePath, RTLD_NOLOAD);
if (h == handle)
{
dlbase = (uintptr_t)info.imageLoadAddress;
dlclose(h);
break;
}
dlclose(h);
}
if (!dlbase)
{
/* Uh oh, we couldn't find a matching handle */
return NULL;
}
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlbase)
{
table = &libtable->table;
break;
}
}
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlbase;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
/* See if the symbol is already cached in our table */
symbol_entry = table->FindSymbol(symbol, strlen(symbol));
if (symbol_entry != NULL)
{
return symbol_entry->address;
}
/* If symbol isn't in our table, then we have to locate it in memory */
file_hdr = (struct mach_header *)dlbase;
loadcmds = (struct load_command *)(dlbase + sizeof(struct mach_header));
loadcmd_count = file_hdr->ncmds;
/* Loop through load commands until we find the ones for the symbol table */
for (uint32_t i = 0; i < loadcmd_count; i++)
{
if (loadcmds->cmd == LC_SEGMENT && !linkedit_hdr)
{
struct segment_command *seg = (struct segment_command *)loadcmds;
if (strcmp(seg->segname, "__LINKEDIT") == 0)
{
linkedit_hdr = seg;
if (symtab_hdr)
{
break;
}
}
}
else if (loadcmds->cmd == LC_SYMTAB)
{
symtab_hdr = (struct symtab_command *)loadcmds;
if (linkedit_hdr)
{
break;
}
}
/* Load commands are not of a fixed size which is why we add the size */
loadcmds = (struct load_command *)((uintptr_t)loadcmds + loadcmds->cmdsize);
}
if (!linkedit_hdr || !symtab_hdr || !symtab_hdr->symoff || !symtab_hdr->stroff)
{
/* Uh oh, no symbol table */
return NULL;
}
linkedit_addr = dlbase + linkedit_hdr->vmaddr;
symtab = (struct nlist *)(linkedit_addr + symtab_hdr->symoff - linkedit_hdr->fileoff);
strtab = (const char *)(linkedit_addr + symtab_hdr->stroff - linkedit_hdr->fileoff);
symbol_count = symtab_hdr->nsyms;
/* Iterate symbol table starting from the position we were at last time */
for (uint32_t i = libtable->last_pos; i < symbol_count; i++)
{
struct nlist &sym = symtab[i];
/* Ignore the prepended underscore on all symbols, so +1 here */
const char *sym_name = strtab + sym.n_un.n_strx + 1;
Symbol *cur_sym;
/* Skip symbols that are undefined */
if (sym.n_sect == NO_SECT)
{
continue;
}
/* Caching symbols as we go along */
cur_sym = table->InternSymbol(sym_name, strlen(sym_name), (void *)(dlbase + sym.n_value));
if (strcmp(symbol, sym_name) == 0)
{
symbol_entry = cur_sym;
libtable->last_pos = ++i;
break;
}
}
return symbol_entry ? symbol_entry->address : NULL;
#endif
}
bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
{
uintptr_t baseAddr;
unsigned long baseAddr;
if (libPtr == NULL)
{
@@ -431,7 +273,7 @@ bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
return false;
}
baseAddr = reinterpret_cast<uintptr_t>(info.AllocationBase);
baseAddr = reinterpret_cast<unsigned long>(info.AllocationBase);
/* All this is for our insane sanity checks :o */
dos = reinterpret_cast<IMAGE_DOS_HEADER *>(baseAddr);
@@ -480,7 +322,7 @@ bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
}
/* This is for our insane sanity checks :o */
baseAddr = reinterpret_cast<uintptr_t>(info.dli_fbase);
baseAddr = reinterpret_cast<unsigned long>(info.dli_fbase);
file = reinterpret_cast<Elf32_Ehdr *>(baseAddr);
/* Check ELF magic */
@@ -511,105 +353,21 @@ bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
phdrCount = file->e_phnum;
phdr = reinterpret_cast<Elf32_Phdr *>(baseAddr + file->e_phoff);
/* Add up the memory sizes of segments marked as PT_LOAD as those are the only ones that should be in memory */
for (uint16_t i = 0; i < phdrCount; i++)
{
Elf32_Phdr &hdr = phdr[i];
/* We only really care about the segment with executable code */
if (hdr.p_type == PT_LOAD && hdr.p_flags == (PF_X|PF_R))
if (hdr.p_type == PT_LOAD)
{
/* From glibc, elf/dl-load.c:
* c->mapend = ((ph->p_vaddr + ph->p_filesz + GLRO(dl_pagesize) - 1)
* & ~(GLRO(dl_pagesize) - 1));
*
* In glibc, the segment file size is aligned up to the nearest page size and
* added to the virtual address of the segment. We just want the size here.
*/
lib.memorySize = PAGE_ALIGN_UP(hdr.p_filesz);
break;
lib.memorySize += hdr.p_memsz;
}
}
#elif defined PLATFORM_APPLE
Dl_info info;
struct mach_header *file;
struct segment_command *seg;
uint32_t cmd_count;
if (!dladdr(libPtr, &info))
{
return false;
}
if (!info.dli_fbase || !info.dli_fname)
{
return false;
}
/* This is for our insane sanity checks :o */
baseAddr = (uintptr_t)info.dli_fbase;
file = (struct mach_header *)baseAddr;
/* Check Mach-O magic */
if (file->magic != MH_MAGIC)
{
return false;
}
/* Check architecture (32-bit/x86) */
if (file->cputype != CPU_TYPE_I386 || file->cpusubtype != CPU_SUBTYPE_I386_ALL)
{
return false;
}
/* For our purposes, this must be a dynamic library */
if (file->filetype != MH_DYLIB)
{
return false;
}
cmd_count = file->ncmds;
seg = (struct segment_command *)(baseAddr + sizeof(struct mach_header));
/* Add up memory sizes of mapped segments */
for (uint32_t i = 0; i < cmd_count; i++)
{
if (seg->cmd == LC_SEGMENT)
{
lib.memorySize += seg->vmsize;
}
seg = (struct segment_command *)((uintptr_t)seg + seg->cmdsize);
}
#endif
lib.baseAddress = reinterpret_cast<void *>(baseAddr);
return true;
}
const char* MemoryUtils::ResolveAddr(void *handle, void* addr)
{
struct link_map *dlmap;
dlmap = (struct link_map *)handle;
LibSymbolTable *libtable;
AddrTable *table2;
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlmap->l_addr)
{
table2 = &libtable->table2;
break;
}
}
if (table2 == NULL) return NULL;
Symbol *sym = table2->FindAddr(addr);
return sym ? sym->buffer() : NULL;
}
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2000 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -30,9 +30,9 @@
#ifndef _INCLUDE_SOURCEMOD_MEMORYUTILS_H_
#define _INCLUDE_SOURCEMOD_MEMORYUTILS_H_
#include "common_logic.h"
#include <IMemoryUtils.h>
#if defined PLATFORM_LINUX || defined PLATFORM_APPLE
#include "sm_globals.h"
#ifdef PLATFORM_LINUX
#include <sh_vector.h>
#include "sm_symtable.h"
@@ -41,21 +41,19 @@ using namespace SourceHook;
using namespace SourceMod;
#ifdef PLATFORM_APPLE
#include <CoreServices/CoreServices.h>
#endif
struct DynLibInfo
{
void *baseAddress;
size_t memorySize;
};
#if defined PLATFORM_LINUX || defined PLATFORM_APPLE
#ifdef PLATFORM_LINUX
typedef uint32_t Elf32_Addr;
struct LibSymbolTable
{
SymbolTable table;
uintptr_t lib_base;
Elf32_Addr lib_base;
uint32_t last_pos;
};
#endif
@@ -65,7 +63,6 @@ class MemoryUtils :
public SMGlobalClass
{
public:
MemoryUtils();
~MemoryUtils();
public: // SMGlobalClass
void OnSourceModAllInitialized();
@@ -74,14 +71,9 @@ public: // IMemoryUtils
void *ResolveSymbol(void *handle, const char *symbol);
public:
bool GetLibraryInfo(const void *libPtr, DynLibInfo &lib);
#if defined PLATFORM_LINUX || defined PLATFORM_APPLE
#ifdef PLATFORM_LINUX
private:
CVector<LibSymbolTable *> m_SymTables;
#ifdef PLATFORM_APPLE
struct dyld_all_image_infos *m_ImageList;
SInt32 m_OSXMajor;
SInt32 m_OSXMinor;
#endif
#endif
};
+5 -25
View File
@@ -41,7 +41,7 @@
#include "ShareSys.h"
#include "HandleSys.h"
#include "sourcemm_api.h"
#include "logic_bridge.h"
#include "Translator.h"
MenuManager g_Menus;
VoteMenuHandler s_VoteHandler;
@@ -231,7 +231,6 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
unsigned int pgn = menu->GetPagination();
unsigned int maxItems = style->GetMaxPageItems();
bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT;
bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE;
if (pgn != MENU_NO_PAGINATION)
{
@@ -242,11 +241,6 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
maxItems--;
}
if (novoteButton)
{
maxItems--;
}
/* This is very not allowed! */
if (maxItems < 2)
{
@@ -442,20 +436,6 @@ skip_search:
/* Draw the item according to the order */
menu_slots_t *slots = md.slots;
unsigned int position = 0; /* Keep track of the last position */
if (novoteButton)
{
char text[50];
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "No Vote", &client))
{
UTIL_Format(text, sizeof(text), "No Vote");
}
ItemDrawInfo dr(text, 0);
position = panel->DrawItem(dr);
slots[position].type = ItemSel_Exit;
position++;
}
if (order == ItemOrder_Ascending)
{
md.item_on_page = drawItems[0].position;
@@ -606,7 +586,7 @@ skip_search:
{
if (exitBackButton)
{
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
{
UTIL_Format(text, sizeof(text), "Back");
}
@@ -616,7 +596,7 @@ skip_search:
}
else
{
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
{
UTIL_Format(text, sizeof(text), "Previous");
}
@@ -637,7 +617,7 @@ skip_search:
/* NEXT */
if (displayNext || canDrawDisabled)
{
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
{
UTIL_Format(text, sizeof(text), "Next");
}
@@ -668,7 +648,7 @@ skip_search:
/* EXIT */
if (exitButton)
{
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
{
UTIL_Format(text, sizeof(text), "Exit");
}
-3
View File
@@ -377,9 +377,6 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
RemoveClientFromWatch(client);
}
Handle_t hndl = menu ? menu->GetHandle() : BAD_HANDLE;
AutoHandleRooter ahr(hndl);
if (cancel)
{
mh->OnMenuCancel(menu, client, reason);
+1 -2
View File
@@ -32,12 +32,11 @@
#include "MenuStyle_Radio.h"
#include "sm_stringutil.h"
#include "UserMessages.h"
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include "PlayerManager.h"
#if defined MENU_DEBUG
#include "Logger.h"
#endif
#include "logic_bridge.h"
extern const char *g_RadioNumTable[];
CRadioStyle g_RadioMenuStyle;
+1
View File
@@ -32,6 +32,7 @@
#include "sm_stringutil.h"
#include "PlayerManager.h"
#include "MenuStyle_Valve.h"
#include "Translator.h"
#include "PlayerManager.h"
#include "ConCmdManager.h"
+6 -11
View File
@@ -39,8 +39,7 @@
#include <HalfLife2.h>
#include <mathlib.h>
#include <const.h>
#include <ITranslator.h>
#include "logic_bridge.h"
#include <Translator.h>
float g_next_vote = 0.0f;
@@ -527,8 +526,7 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
if (sm_vote_console.GetBool())
{
int target = SOURCEMOD_SERVER_LANGUAGE;
logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For",
&target, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", &target, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
Engine_LogPrintWrapper(buffer);
}
@@ -540,17 +538,15 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
assert(pPlayer);
if (pPlayer->IsInGame() && !pPlayer->IsFakeClient())
if (pPlayer->IsInGame())
{
if (m_Revoting[client])
{
logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Changed Vote",
&i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Changed Vote", &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
}
else
{
logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For",
&i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
}
if (sm_vote_chat.GetBool())
@@ -638,8 +634,7 @@ void VoteMenuHandler::DrawHintProgress()
{
if (g_Players.GetPlayerByIndex(i)->IsInGame())
{
logicore.CoreTranslate(buffer, sizeof(buffer), "%T%s", 6, NULL, "Vote Count",
&i, &m_NumVotes, &m_TotalClients, &iTimeRemaining, &m_leaderList);
CoreTranslate(buffer, sizeof(buffer), "%T%s", 6, NULL, "Vote Count", &i, &m_NumVotes, &m_TotalClients, &iTimeRemaining, &m_leaderList);
g_HL2.HintTextMsg(i, buffer);
}
}
@@ -29,9 +29,9 @@
* Version: $Id$
*/
#include "common_logic.h"
#include "PhraseCollection.h"
#include "Translator.h"
#include "sm_stringutil.h"
CPhraseCollection::CPhraseCollection()
{
@@ -54,7 +54,7 @@ IPhraseFile *CPhraseCollection::AddPhraseFile(const char *filename)
char full_name[PLATFORM_MAX_PATH];
/* No compat shim here. The user should have read the doc. */
smcore.Format(full_name, sizeof(full_name), "%s.txt", filename);
UTIL_Format(full_name, sizeof(full_name), "%s.txt", filename);
fid = g_Translator.FindOrAddPhraseFile(full_name);
pFile = g_Translator.GetFileByIndex(fid);
@@ -113,7 +113,7 @@ bool CPhraseCollection::FormatString(char *buffer,
unsigned int arg;
arg = 0;
if (!smcore.gnprintf(buffer, maxlength, format, this, params, numparams, arg, pOutLength, pFailPhrase))
if (!gnprintf(buffer, maxlength, format, this, params, numparams, arg, pOutLength, pFailPhrase))
{
return false;
}
+47 -125
View File
@@ -39,24 +39,23 @@
#include "sm_stringutil.h"
#include "CoreConfig.h"
#include "TimerSys.h"
#include "Translator.h"
#include "Logger.h"
#include "ChatTriggers.h"
#include "HalfLife2.h"
#include <inetchannel.h>
#include <iclient.h>
#include <tier0/icommandline.h>
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include "ExtensionSys.h"
#include <sourcemod_version.h>
#include "ConsoleDetours.h"
#include "logic_bridge.h"
PlayerManager g_Players;
bool g_OnMapStarted = false;
IForward *PreAdminCheck = NULL;
IForward *PostAdminCheck = NULL;
IForward *PostAdminFilter = NULL;
IForward *OnClientConnected = NULL;
const unsigned int *g_NumPlayersToAuth = NULL;
int lifestate_offset = -1;
List<ICommandTargetProcessor *> target_processors;
@@ -114,9 +113,6 @@ PlayerManager::PlayerManager()
m_FirstPass = false;
m_maxClients = 0;
m_SourceTVUserId = -1;
m_ReplayUserId = -1;
m_UserIdLookUp = new int[USHRT_MAX+1];
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
}
@@ -146,7 +142,6 @@ void PlayerManager::OnSourceModAllInitialized()
ParamType p2[] = {Param_Cell};
m_clconnect = g_Forwards.CreateForward("OnClientConnect", ET_LowEvent, 3, p1);
m_clconnect_post = g_Forwards.CreateForward("OnClientConnected", ET_Ignore, 1, p2);
m_clputinserver = g_Forwards.CreateForward("OnClientPutInServer", ET_Ignore, 1, p2);
m_cldisconnect = g_Forwards.CreateForward("OnClientDisconnect", ET_Ignore, 1, p2);
m_cldisconnect_post = g_Forwards.CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2);
@@ -155,6 +150,7 @@ void PlayerManager::OnSourceModAllInitialized()
m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String);
m_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL);
m_onActivate2 = g_Forwards.CreateForward("OnMapStart", ET_Ignore, 0, NULL);
OnClientConnected = g_Forwards.CreateForward("OnClientConnected", ET_Ignore, 1, p2);
PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
@@ -163,6 +159,8 @@ void PlayerManager::OnSourceModAllInitialized()
m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0;
g_ConVarManager.AddConVarChangeListener("tv_enable", this);
ConCommand *pCmd = FindCommand("maxplayers");
if (pCmd != NULL)
{
@@ -174,7 +172,6 @@ void PlayerManager::OnSourceModAllInitialized()
void PlayerManager::OnSourceModShutdown()
{
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect, false);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect_Post, true);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverClients, this, &PlayerManager::OnClientPutInServer, true);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect, false);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect_Post, true);
@@ -184,7 +181,6 @@ void PlayerManager::OnSourceModShutdown()
/* Release forwards */
g_Forwards.ReleaseForward(m_clconnect);
g_Forwards.ReleaseForward(m_clconnect_post);
g_Forwards.ReleaseForward(m_clputinserver);
g_Forwards.ReleaseForward(m_cldisconnect);
g_Forwards.ReleaseForward(m_cldisconnect_post);
@@ -193,6 +189,7 @@ void PlayerManager::OnSourceModShutdown()
g_Forwards.ReleaseForward(m_clauth);
g_Forwards.ReleaseForward(m_onActivate);
g_Forwards.ReleaseForward(m_onActivate2);
g_Forwards.ReleaseForward(OnClientConnected);
g_Forwards.ReleaseForward(PreAdminCheck);
g_Forwards.ReleaseForward(PostAdminCheck);
@@ -200,6 +197,8 @@ void PlayerManager::OnSourceModShutdown()
delete [] m_Players;
g_ConVarManager.RemoveConVarChangeListener("tv_enable", this);
if (maxplayersCmd != NULL)
{
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, maxplayersCmd, CmdMaxplayersCallback, true);
@@ -236,25 +235,10 @@ ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
static ConVar *tv_enable = icvar->FindVar("tv_enable");
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
static ConVar *replay_enable = icvar->FindVar("replay_enable");
#endif
// clientMax will not necessarily be correct here (such as on late SourceTV enable)
m_maxClients = gpGlobals->maxClients;
m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && CommandLine()->FindParm("-nohltv") == 0);
m_bIsReplayActive = false;
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
m_bIsReplayActive = (replay_enable && replay_enable->GetBool());
#endif
m_PlayersSinceActive = 0;
if (!m_FirstPass)
{
/* Initialize all players */
m_maxClients = clientMax;
m_PlayerCount = 0;
m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1];
@@ -263,13 +247,10 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
memset(m_AuthQueue, 0, sizeof(unsigned int) * (ABSOLUTE_PLAYER_LIMIT + 1));
g_NumPlayersToAuth = &m_AuthQueue[0];
g_PluginSys.SyncMaxClients(clientMax);
}
g_PluginSys.SyncMaxClients(m_maxClients);
g_OnMapStarted = true;
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, m_maxClients);
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax);
m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL);
@@ -278,10 +259,12 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
{
if ((*iter)->GetClientListenerVersion() >= 5)
{
(*iter)->OnServerActivated(m_maxClients);
(*iter)->OnServerActivated(clientMax);
}
}
g_OnMapStarted = true;
SMGlobalClass *cls = SMGlobalClass::head;
while (cls)
{
@@ -427,23 +410,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
{
int client = IndexOfEdict(pEntity);
CPlayer *pPlayer = &m_Players[client];
++m_PlayersSinceActive;
pPlayer->Initialize(pszName, pszAddress, pEntity);
/* Get the client's language */
if (m_QueryLang)
{
const char *name;
if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
{
unsigned int langid;
pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
} else {
pPlayer->m_LangId = translator->GetServerLanguage();
}
}
List<IClientListener *>::iterator iter;
IClientListener *pListener = NULL;
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
@@ -457,6 +424,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
cell_t res = 1;
pPlayer->Initialize(pszName, pszAddress, pEntity);
m_clconnect->PushCell(client);
m_clconnect->PushStringEx(reject, maxrejectlen, SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
m_clconnect->PushCell(maxrejectlen);
@@ -498,7 +466,7 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
pListener->OnClientConnected(client);
if (!pPlayer->IsConnected())
{
return true;
break;
}
}
@@ -510,8 +478,8 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
}
cell_t res;
m_clconnect_post->PushCell(client);
m_clconnect_post->Execute(&res, NULL);
OnClientConnected->PushCell(client);
OnClientConnected->Execute(&res, NULL);
}
else
{
@@ -535,40 +503,6 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
const char *authid = engine->GetPlayerNetworkIDString(pEntity);
pPlayer->Authorize(authid);
pPlayer->m_bFakeClient = true;
/*
* While we're already filtered to just bots, we'll do other checks to
* make sure that the requisite services are enabled and that the bots
* have joined at the expected time.
*
* Checking playerinfo's IsHLTV and IsReplay would be better and less
* error-prone but will always show false until later in the frame,
* after PutInServer and Activate, and we want it now!
*/
// This doesn't actually get incremented until OnClientConnect. Fake it to check.
int newCount = m_PlayersSinceActive + 1;
int userId = engine->GetPlayerUserId(pEntity);
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
if (m_bIsReplayActive && newCount == 1
&& (m_ReplayUserId == userId || strcmp(playername, "Replay") == 0))
{
pPlayer->m_bIsReplay = true;
m_ReplayUserId = userId;
}
#endif
if (m_bIsSourceTVActive
&& ((!m_bIsReplayActive && newCount == 1)
|| (m_bIsReplayActive && newCount == 2))
&& (m_SourceTVUserId == userId || strcmp(playername, "SourceTV") == 0)
)
{
pPlayer->m_bIsSourceTV = true;
m_SourceTVUserId = userId;
}
if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
{
/* :TODO: kick the bot if it's rejected */
@@ -586,11 +520,6 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
return;
}
}
cell_t res;
m_clconnect_post->PushCell(client);
m_clconnect_post->Execute(&res, NULL);
/* Now do authorization */
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
{
@@ -612,6 +541,19 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
pPlayer->m_Info = playerinfo->GetPlayerInfo(pEntity);
}
/* Get the client's language */
if (m_QueryLang)
{
const char *name;
if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
{
unsigned int langid;
pPlayer->m_LangId = (g_Translator.GetLanguageByName(name, &langid)) ? langid : g_Translator.GetServerLanguage();
} else {
pPlayer->m_LangId = g_Translator.GetServerLanguage();
}
}
pPlayer->Connect();
m_PlayerCount++;
@@ -889,17 +831,6 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
}
}
}
/* Notify Extensions */
List<IClientListener *>::iterator iter;
IClientListener *pListener = NULL;
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
{
pListener = (*iter);
if (pListener->GetClientListenerVersion() >= 13)
{
pListener->OnClientSettingsChanged(client);
}
}
}
int PlayerManager::GetMaxClients()
@@ -1369,7 +1300,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
continue;
}
if (logicore.stristr(pTarget->GetName(), info->pattern) != NULL)
if (stristr(pTarget->GetName(), info->pattern) != NULL)
{
if (found_client)
{
@@ -1407,6 +1338,18 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
}
}
void PlayerManager::OnConVarChanged( ConVar *pConVar, const char *oldValue, float flOldValue )
{
if (pConVar->GetBool() && !atoi(oldValue))
{
MaxPlayersChanged(gpGlobals->maxClients + 1);
}
else
{
MaxPlayersChanged();
}
}
void PlayerManager::OnSourceModMaxPlayersChanged( int newvalue )
{
m_maxClients = newvalue;
@@ -1503,9 +1446,6 @@ CPlayer::CPlayer()
m_LastPassword.clear();
m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
m_bFakeClient = false;
m_bIsSourceTV = false;
m_bIsReplay = false;
m_Serial.value = -1;
}
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
@@ -1515,7 +1455,7 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
m_Ip.assign(ip);
m_pEdict = pEntity;
m_iIndex = IndexOfEdict(pEntity);
m_LangId = translator->GetServerLanguage();
m_LangId = g_Translator.GetServerLanguage();
m_Serial.bits.index = m_iIndex;
m_Serial.bits.serial = g_PlayerSerialCount++;
@@ -1577,9 +1517,6 @@ void CPlayer::Disconnect()
m_UserId = -1;
m_bIsInKickQueue = false;
m_bFakeClient = false;
m_bIsSourceTV = false;
m_bIsReplay = false;
m_Serial.value = -1;
}
void CPlayer::SetName(const char *name)
@@ -1647,16 +1584,6 @@ bool CPlayer::IsFakeClient()
return m_bFakeClient;
}
bool CPlayer::IsSourceTV() const
{
return m_bIsSourceTV;
}
bool CPlayer::IsReplay() const
{
return m_bIsReplay;
}
void CPlayer::SetAdminId(AdminId id, bool temporary)
{
if (!m_IsConnected)
@@ -1849,11 +1776,6 @@ unsigned int CPlayer::GetLanguageId()
return m_LangId;
}
void CPlayer::SetLanguageId(unsigned int id)
{
m_LangId = id;
}
int CPlayer::GetUserId()
{
if (m_UserId == -1)
+4 -12
View File
@@ -76,15 +76,12 @@ public:
bool IsConnected();
bool IsAuthorized();
bool IsFakeClient();
bool IsSourceTV() const;
bool IsReplay() const;
void SetAdminId(AdminId id, bool temporary);
AdminId GetAdminId();
void Kick(const char *str);
bool IsInKickQueue();
IPlayerInfo *GetPlayerInfo();
unsigned int GetLanguageId();
void SetLanguageId(unsigned int id);
int GetUserId();
bool RunAdminCacheChecks();
void NotifyPostAdminChecks();
@@ -121,14 +118,13 @@ private:
unsigned int m_LangId;
int m_UserId;
bool m_bFakeClient;
bool m_bIsSourceTV;
bool m_bIsReplay;
serial_t m_Serial;
};
class PlayerManager :
public SMGlobalClass,
public IPlayerManager
public IPlayerManager,
public IConVarChangeListener
{
friend class CPlayer;
public:
@@ -173,6 +169,8 @@ public: //IPlayerManager
void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
void ProcessCommandTarget(cmd_target_info_t *info);
int GetClientFromSerial(unsigned int serial);
public: // IConVarChangeListener
void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
public:
inline int MaxClients()
{
@@ -199,7 +197,6 @@ private:
private:
List<IClientListener *> m_hooks;
IForward *m_clconnect;
IForward *m_clconnect_post;
IForward *m_cldisconnect;
IForward *m_cldisconnect_post;
IForward *m_clputinserver;
@@ -212,17 +209,12 @@ private:
int *m_UserIdLookUp;
int m_maxClients;
int m_PlayerCount;
int m_PlayersSinceActive;
bool m_FirstPass;
unsigned int *m_AuthQueue;
String m_PassInfoVar;
bool m_QueryLang;
bool m_bIsListenServer;
int m_ListenClient;
bool m_bIsSourceTVActive;
bool m_bIsReplayActive;
int m_SourceTVUserId;
int m_ReplayUserId;
};
#if SOURCE_ENGINE >= SE_ORANGEBOX
+5 -6
View File
@@ -44,7 +44,7 @@
#include "ConCmdManager.h"
#include "PlayerManager.h"
#include "CoreConfig.h"
#include "logic_bridge.h"
#include "Translator.h"
CPluginManager g_PluginSys;
HandleType_t g_PluginType = 0;
@@ -67,7 +67,7 @@ CPlugin::CPlugin(const char *file)
m_FakeNativesMissing = false;
m_LibraryMissing = false;
m_bGotAllLoaded = false;
m_pPhrases = translator->CreatePhraseCollection();
m_pPhrases = g_Translator.CreatePhraseCollection();
m_MaxClientsVar = NULL;
}
@@ -372,7 +372,7 @@ void CPlugin::Call_OnAllPluginsLoaded()
pFunction->Execute(&result);
}
if (g_SourceMod.IsMapRunning())
if (g_OnMapStarted)
{
if ((pFunction = m_pRuntime->GetFunctionByName("OnMapStart")) != NULL)
{
@@ -1308,8 +1308,7 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
if (ext->autoload)
{
g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
bool bErrorOnMissing = ext->required ? true : false;
g_Extensions.LoadAutoExtension(path, bErrorOnMissing);
g_Extensions.LoadAutoExtension(path);
}
}
else if (pass == 2)
@@ -2742,6 +2741,6 @@ void CPluginManager::ListPluginsToClient(CPlayer *player, const CCommand &args)
/* Do we actually have more plugins? */
if (iter != m_plugins.end())
{
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id + 1);
}
}
+3 -6
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -47,11 +47,9 @@
#include "sm_trie.h"
#include "sourcemod.h"
#include <IRootConsoleMenu.h>
#if SOURCE_ENGINE == SE_ALIENSWARM
#include "convar_sm_swarm.h"
#elif (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
#include "convar_sm_l4d.h"
#elif (SOURCE_ENGINE == SE_ORANGEBOX) || (SOURCE_ENGINE == SE_BLOODYGOODTIME) || (SOURCE_ENGINE == SE_EYE) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE)
#elif (SOURCE_ENGINE == SE_ORANGEBOX) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE)
#include "convar_sm_ob.h"
#else
#include "convar_sm.h"
@@ -475,4 +473,3 @@ private:
extern CPluginManager g_PluginSys;
#endif //_INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_
+1 -1
View File
@@ -78,11 +78,11 @@ public: //ITimerSystem
float GetTickedTime();
void NotifyOfGameStart(float offset /* = 0.0f */);
bool GetMapTimeLeft(float *pTime);
IMapTimer *GetMapTimer();
public:
void RunFrame();
void RemoveMapChangeTimers();
void GameFrame(bool simulating);
IMapTimer *GetMapTimer();
private:
List<ITimer *> m_SingleTimers;
List<ITimer *> m_LoopTimers;
+107 -110
View File
@@ -29,24 +29,22 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <sm_platform.h>
#include "Translator.h"
#include <IPlayerHelpers.h>
#include <ISourceMod.h>
#include <ILibrarySys.h>
#include "Logger.h"
#include "LibrarySys.h"
#include "sm_stringutil.h"
#include "sourcemod.h"
#include "PlayerManager.h"
#include "PhraseCollection.h"
#include "stringutil.h"
#include "ShareSys.h"
Translator g_Translator;
IPhraseCollection *g_pCorePhrases = NULL;
unsigned int g_pCorePhraseID = 0;
using namespace SourceMod;
struct trans_t
{
int stridx;
@@ -69,10 +67,15 @@ CPhraseFile::CPhraseFile(Translator *pTranslator, const char *file)
m_LangCount = pTranslator->GetLanguageCount();
m_File.assign(file);
m_pTranslator = pTranslator;
m_pPhraseLookup = NULL;
}
CPhraseFile::~CPhraseFile()
{
if (m_pPhraseLookup)
{
sm_trie_destroy(m_pPhraseLookup);
}
}
void CPhraseFile::ParseError(const char *message, ...)
@@ -96,16 +99,20 @@ void CPhraseFile::ParseWarning(const char *message, ...)
if (!m_FileLogged)
{
smcore.LogError("[SM] Warning(s) encountered in translation file \"%s\"", m_File.c_str());
g_Logger.LogError("[SM] Warning(s) encountered in translation file \"%s\"", m_File.c_str());
m_FileLogged = true;
}
smcore.LogError("[SM] %s", buffer);
g_Logger.LogError("[SM] %s", buffer);
}
void CPhraseFile::ReparseFile()
{
m_PhraseLookup.clear();
if (m_pPhraseLookup)
{
sm_trie_destroy(m_pPhraseLookup);
}
m_pPhraseLookup = sm_trie_create();
m_LangCount = m_pTranslator->GetLanguageCount();
@@ -116,19 +123,19 @@ void CPhraseFile::ReparseFile()
SMCError err;
char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "translations/%s", m_File.c_str());
g_SourceMod.BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "translations/%s", m_File.c_str());
//backwards compatibility shim
/* :HACKHACK: Change .cfg/.txt and vice versa for compatibility */
if (!libsys->PathExists(path))
if (!g_LibSys.PathExists(path))
{
if (m_File.compare("common.cfg") == 0)
{
UTIL_ReplaceAll(path, sizeof(path), "common.cfg", "common.phrases.txt", true);
UTIL_ReplaceAll(path, sizeof(path), "common.cfg", "common.phrases.txt");
} else if (strstr(path, ".cfg")) {
UTIL_ReplaceAll(path, sizeof(path), ".cfg", ".txt", true);
UTIL_ReplaceAll(path, sizeof(path), ".cfg", ".txt");
} else if (strstr(path, ".txt")) {
UTIL_ReplaceAll(path, sizeof(path), ".txt", ".cfg", true);
UTIL_ReplaceAll(path, sizeof(path), ".txt", ".cfg");
}
}
@@ -142,8 +149,8 @@ void CPhraseFile::ReparseFile()
msg = m_ParseError.c_str();
}
smcore.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
smcore.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
g_Logger.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
}
const char *code;
@@ -154,7 +161,7 @@ void CPhraseFile::ReparseFile()
continue;
}
g_pSM->BuildPath(Path_SM,
g_SourceMod.BuildPath(Path_SM,
path,
PLATFORM_MAX_PATH,
"translations/%s/%s",
@@ -162,7 +169,7 @@ void CPhraseFile::ReparseFile()
m_File.c_str());
/* Speculatively load these. */
if (!libsys->PathExists(path))
if (!g_LibSys.PathExists(path))
{
continue;
}
@@ -175,10 +182,10 @@ void CPhraseFile::ReparseFile()
msg = m_ParseError.c_str();
}
smcore.LogError("[SM] Fatal error encountered parsing translation file \"%s/%s\"",
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s/%s\"",
code,
m_File.c_str());
smcore.LogError("[SM] Error (line %d, column %d): %s",
g_Logger.LogError("[SM] Error (line %d, column %d): %s",
states.line,
states.col,
msg);
@@ -210,17 +217,17 @@ SMCResult CPhraseFile::ReadSMC_NewSection(const SMCStates *states, const char *n
m_ParseState = PPS_InPhrase;
recognized = true;
int *pvalue;
if ((pvalue = m_PhraseLookup.retrieve(name)) != NULL)
void *value;
if (sm_trie_retrieve(m_pPhraseLookup, name, &value))
{
m_CurPhrase = *pvalue;
m_CurPhrase = reinterpret_cast<int>(value);
}
else
{
phrase_t *pPhrase;
m_CurPhrase = m_pMemory->CreateMem(sizeof(phrase_t), (void **)&pPhrase);
m_PhraseLookup.insert(name, m_CurPhrase);
sm_trie_insert(m_pPhraseLookup, name, reinterpret_cast<void *>(m_CurPhrase));
/* Initialize new phrase */
trans_t *pTrans;
@@ -632,7 +639,9 @@ SMCResult CPhraseFile::ReadSMC_LeavingSection(const SMCStates *states)
if (m_ParseState == PPS_InPhrase)
{
if (m_CurPhrase == -1 && m_LastPhraseString.size())
m_PhraseLookup.remove(m_LastPhraseString.c_str());
{
sm_trie_delete(m_pPhraseLookup, m_LastPhraseString.c_str());
}
m_CurPhrase = -1;
m_ParseState = PPS_Phrases;
m_LastPhraseString.assign("");
@@ -649,7 +658,9 @@ void CPhraseFile::ReadSMC_ParseEnd(bool halted, bool failed)
{
/* Check to see if we have any dangling phrases that weren't completed, and scrap them */
if ((halted || failed) && m_LastPhraseString.size())
m_PhraseLookup.remove(m_LastPhraseString.c_str());
{
sm_trie_delete(m_pPhraseLookup, m_LastPhraseString.c_str());
}
}
TransError CPhraseFile::GetTranslation(const char *szPhrase, unsigned int lang_id, Translation *pTrans)
@@ -659,11 +670,13 @@ TransError CPhraseFile::GetTranslation(const char *szPhrase, unsigned int lang_i
return Trans_BadLanguage;
}
int *pvalue;
if ((pvalue = m_PhraseLookup.retrieve(szPhrase)) == NULL)
void *object;
if (!sm_trie_retrieve(m_pPhraseLookup, szPhrase, &object))
{
return Trans_BadPhrase;
}
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(*pvalue);
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(reinterpret_cast<int>(object));
trans_t *trans = (trans_t *)m_pMemory->GetAddress(pPhrase->trans_tbl);
trans = &trans[lang_id];
@@ -692,6 +705,7 @@ const char *CPhraseFile::GetFilename()
Translator::Translator() : m_ServerLang(SOURCEMOD_LANGUAGE_ENGLISH)
{
m_pStringTab = new BaseStringTable(2048);
m_pLCodeLookup = sm_trie_create();
strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
}
@@ -707,6 +721,8 @@ Translator::~Translator()
delete m_Languages[i];
}
sm_trie_destroy(m_pLCodeLookup);
delete m_pStringTab;
}
@@ -723,13 +739,13 @@ ConfigResult Translator::OnSourceModConfigChanged(const char *key,
unsigned int index;
if (!GetLanguageByCode(value, &index))
{
smcore.Format(error, maxlength, "Language code \"%s\" is not registered", value);
UTIL_Format(error, maxlength, "Language code \"%s\" is not registered", value);
return ConfigResult_Reject;
}
m_ServerLang = index;
} else {
smcore.strncopy(m_InitialLang, value, sizeof(m_InitialLang));
strncopy(m_InitialLang, value, sizeof(m_InitialLang));
}
return ConfigResult_Accept;
@@ -742,7 +758,7 @@ void Translator::OnSourceModLevelChange(const char *mapName)
{
/* Refresh language stuff */
char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_SM, path, sizeof(path), "configs/languages.cfg");
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "configs/languages.cfg");
RebuildLanguageDatabase(path);
}
@@ -750,16 +766,10 @@ void Translator::OnSourceModAllInitialized()
{
AddLanguage("en", "English");
const char* lang = smcore.GetCoreConfigValue("ServerLang");
if (lang)
{
strncpy(m_InitialLang, lang, sizeof(m_InitialLang));
}
g_pCorePhrases = CreatePhraseCollection();
g_pCorePhrases->AddPhraseFile("core.phrases");
sharesys->AddInterface(NULL, this);
g_ShareSys.AddInterface(NULL, this);
}
void Translator::OnSourceModShutdown()
@@ -769,38 +779,43 @@ void Translator::OnSourceModShutdown()
bool Translator::GetLanguageByCode(const char *code, unsigned int *index)
{
unsigned int *pindex;
void *_index;
if ((pindex = m_LCodeLookup.retrieve(code)) == NULL)
if (!sm_trie_retrieve(m_pLCodeLookup, code, &_index))
{
return false;
}
if (index)
*index = *pindex;
{
*index = reinterpret_cast<unsigned int>(_index);
}
return true;
}
bool Translator::GetLanguageByName(const char *name, unsigned int *index)
{
char lower[256];
size_t len = strlen(name);
if (len > 255) len = 255;
for (size_t i = 0; i < len; i++)
CVector<Language *>::iterator iter;
unsigned int id = 0;
for (iter=m_Languages.begin(); iter!=m_Languages.end(); iter++, id++)
{
if (name[i] >= 'A' && name[i] <= 'Z')
lower[i] = tolower(name[i]);
else
lower[i] = name[i];
if (strcasecmp(m_pStringTab->GetString((*iter)->m_FullName), name) == 0)
{
break;
}
}
lower[len] = '\0';
unsigned int *pIndex;
if ((pIndex = m_LAliases.retrieve(lower)) == NULL)
if (iter == m_Languages.end())
{
return false;
}
if (index)
*index = *pIndex;
{
*index = id;
}
return true;
}
@@ -838,8 +853,8 @@ unsigned int Translator::FindOrAddPhraseFile(const char *phrase_file)
void Translator::RebuildLanguageDatabase(const char *lang_header_file)
{
/* Erase everything we have */
m_LCodeLookup.clear();
m_LAliases.clear();
sm_trie_destroy(m_pLCodeLookup);
m_pLCodeLookup = sm_trie_create();
m_pStringTab->Reset();
for (size_t i=0; i<m_Languages.size(); i++)
@@ -859,27 +874,25 @@ void Translator::RebuildLanguageDatabase(const char *lang_header_file)
str_err = m_CustomError.c_str();
}
smcore.LogError("[SM] Failed to parse language header file: \"%s\"", lang_header_file);
smcore.LogError("[SM] Parse error (line %d, column %d): %s", states.line, states.col, str_err);
g_Logger.LogError("[SM] Failed to parse language header file: \"%s\"", lang_header_file);
g_Logger.LogError("[SM] Parse error (line %d, column %d): %s", states.line, states.col, str_err);
}
unsigned int *pServerLang;
void *serverLang;
if ((pServerLang = m_LCodeLookup.retrieve(m_InitialLang)) == NULL)
if (!sm_trie_retrieve(m_pLCodeLookup, m_InitialLang, &serverLang))
{
smcore.LogError("Server language was set to bad language \"%s\" -- reverting to English", m_InitialLang);
g_Logger.LogError("Server language was set to bad language \"%s\" -- reverting to English", m_InitialLang);
smcore.strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
m_ServerLang = SOURCEMOD_LANGUAGE_ENGLISH;
}
else
{
m_ServerLang = *pServerLang;
}
m_ServerLang = reinterpret_cast<unsigned int>(serverLang);
if (!m_Languages.size())
{
smcore.LogError("[SM] Fatal error, no languages found! Translation will not work.");
g_Logger.LogError("[SM] Fatal error, no languages found! Translation will not work.");
}
for (size_t i=0; i<m_Files.size(); i++)
@@ -906,7 +919,7 @@ SMCResult Translator::ReadSMC_NewSection(const SMCStates *states, const char *na
if (!m_InLanguageSection)
{
smcore.LogError("[SM] Warning: Unrecognized section \"%s\" in languages.cfg", name);
g_Logger.LogError("[SM] Warning: Unrecognized section \"%s\" in languages.cfg", name);
}
return SMCResult_Continue;
@@ -925,8 +938,8 @@ SMCResult Translator::ReadSMC_KeyValue(const SMCStates *states, const char *key,
if (len < 2 || len > 3)
{
smcore.LogError("[SM] Warning encountered parsing languages.cfg file.");
smcore.LogError("[SM] Invalid language code \"%s\" is being ignored.", key);
g_Logger.LogError("[SM] Warning encountered parsing languages.cfg file.");
g_Logger.LogError("[SM] Invalid language code \"%s\" is being ignored.", key);
}
AddLanguage(key, value);
@@ -936,40 +949,20 @@ SMCResult Translator::ReadSMC_KeyValue(const SMCStates *states, const char *key,
bool Translator::AddLanguage(const char *langcode, const char *description)
{
char lower[256];
size_t len = strlen(description);
if (len > 255) len = 255;
for (size_t i = 0; i < len; i++)
if (sm_trie_retrieve(m_pLCodeLookup, langcode, NULL))
{
if (description[i] >= 'A' && description[i] <= 'Z')
lower[i] = tolower(description[i]);
else
lower[i] = description[i];
}
lower[len] = '\0';
if (m_LAliases.retrieve(lower))
return false;
unsigned int idx;
if (unsigned int *pIdx = m_LCodeLookup.retrieve(langcode))
{
idx = *pIdx;
}
else
{
Language *pLanguage = new Language;
idx = m_Languages.size();
smcore.Format(pLanguage->m_code2, sizeof(pLanguage->m_code2), "%s", langcode);
pLanguage->m_CanonicalName = m_pStringTab->AddString(lower);
Language *pLanguage = new Language;
unsigned int idx = m_Languages.size();
m_LCodeLookup.insert(langcode, idx);
UTIL_Format(pLanguage->m_code2, sizeof(pLanguage->m_code2), "%s", langcode);
pLanguage->m_FullName = m_pStringTab->AddString(description);
m_Languages.push_back(pLanguage);
}
m_LAliases.insert(lower, idx);
sm_trie_insert(m_pLCodeLookup, langcode, reinterpret_cast<void *>(idx));
m_Languages.push_back(pLanguage);
return true;
}
@@ -991,7 +984,7 @@ unsigned int Translator::GetServerLanguage()
unsigned int Translator::GetClientLanguage(int client)
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
return pPlayer->GetLanguageId();
}
@@ -1009,7 +1002,7 @@ bool Translator::GetLanguageInfo(unsigned int number, const char **code, const c
}
if (name)
{
*name = m_pStringTab->GetString(l->m_CanonicalName);
*name = m_pStringTab->GetString(l->m_FullName);
}
return true;
@@ -1032,16 +1025,20 @@ IPhraseCollection *Translator::CreatePhraseCollection()
int Translator::SetGlobalTarget(int index)
{
return g_pSM->SetGlobalTarget(index);
return g_SourceMod.SetGlobalTarget(index);
}
int Translator::GetGlobalTarget() const
{
return g_pSM->GetGlobalTarget();
return g_SourceMod.GetGlobalTarget();
}
bool CoreTranslate(char *buffer, size_t maxlength, const char *format, unsigned int numparams,
size_t *pOutLength, ...)
bool CoreTranslate(char *buffer,
size_t maxlength,
const char *format,
unsigned int numparams,
size_t *pOutLength,
...)
{
va_list ap;
unsigned int i;
@@ -1071,11 +1068,11 @@ bool CoreTranslate(char *buffer, size_t maxlength, const char *format, unsigned
{
if (fail_phrase != NULL)
{
smcore.LogError("[SM] Could not find core phrase: %s", fail_phrase);
g_Logger.LogError("[SM] Could not find core phrase: %s", fail_phrase);
}
else
{
smcore.LogError("[SM] Unknown fatal error while translating a core phrase.");
g_Logger.LogError("[SM] Unknown fatal error while translating a core phrase.");
}
return false;
@@ -1096,7 +1093,7 @@ bool Translator::FormatString(char *buffer,
unsigned int arg;
arg = 0;
if (!smcore.gnprintf(buffer, maxlength, format, pPhrases, params, numparams, arg, pOutLength, pFailPhrase))
if (!gnprintf(buffer, maxlength, format, pPhrases, params, numparams, arg, pOutLength, pFailPhrase))
{
return false;
}
@@ -32,14 +32,17 @@
#ifndef _INCLUDE_SOURCEMOD_TRANSLATOR_H_
#define _INCLUDE_SOURCEMOD_TRANSLATOR_H_
#include "common_logic.h"
#include <sm_trie_tpl.h>
#include "sm_trie.h"
#include <sh_string.h>
#include <sh_vector.h>
#include "sm_globals.h"
#include "sm_memtable.h"
#include "ITextParsers.h"
#include <ITranslator.h>
#define MAX_TRANSLATE_PARAMS 32
#define CORELANG_ENGLISH 0
/* :TODO: write a templatized version of tries? */
using namespace SourceHook;
@@ -55,7 +58,7 @@ enum PhraseParseState
struct Language
{
char m_code2[4];
int m_CanonicalName;
int m_FullName;
};
class CPhraseFile :
@@ -79,7 +82,7 @@ private:
void ParseError(const char *message, ...);
void ParseWarning(const char *message, ...);
private:
KTrie<int> m_PhraseLookup;
Trie *m_pPhraseLookup;
String m_File;
Translator *m_pTranslator;
PhraseParseState m_ParseState;
@@ -152,8 +155,7 @@ private:
CVector<Language *> m_Languages;
CVector<CPhraseFile *> m_Files;
BaseStringTable *m_pStringTab;
KTrie<unsigned int> m_LCodeLookup;
KTrie<unsigned int> m_LAliases;
Trie *m_pLCodeLookup;
bool m_InLanguageSection;
String m_CustomError;
unsigned int m_ServerLang;
@@ -173,4 +175,3 @@ extern unsigned int g_pCorePhraseID;
extern Translator g_Translator;
#endif //_INCLUDE_SOURCEMOD_TRANSLATOR_H_
+7 -7
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -34,7 +34,7 @@
UserMessages g_UserMsgs;
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int, const char *);
#else
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
@@ -168,13 +168,13 @@ bf_write *UserMessages::StartMessage(int msg_id, const cell_t players[], unsigne
if (m_CurFlags & USERMSG_BLOCKHOOKS)
{
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id));
#else
buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id);
#endif
} else {
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id));
#else
buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id);
@@ -316,7 +316,7 @@ void UserMessages::_DecRefCounter()
}
}
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
#else
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type)
@@ -346,7 +346,7 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ
RETURN_META_VALUE(MRES_IGNORED, NULL);
}
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
#else
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type)
@@ -500,7 +500,7 @@ void UserMessages::OnMessageEnd_Pre()
{
bf_write *engine_bfw;
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId, g_SMAPI->GetUserMessage(m_CurId));
#else
engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId);
+2 -2
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -79,7 +79,7 @@ public: //IUserMessages
IUserMessageListener *pListener,
bool intercept=false);
public:
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name);
bf_write *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
#else
+2 -5
View File
@@ -24,7 +24,7 @@
#ifdef _WIN32
#define FORCEINLINE_CVAR FORCEINLINE
#elif defined _LINUX || defined __APPLE__
#elif _LINUX
#define FORCEINLINE_CVAR inline
#else
#error "implement me"
@@ -386,7 +386,7 @@ public:
virtual void SetValue( const char *value );
virtual void SetValue( float value );
virtual void SetValue( int value );
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
#if SOURCE_ENGINE == SE_LEFT4DEAD2
virtual void SetValue( Color value );
#endif
@@ -404,9 +404,6 @@ private:
// For CVARs marked FCVAR_NEVER_AS_STRING
virtual void InternalSetFloatValue( float fNewValue );
virtual void InternalSetIntValue( int nValue );
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
virtual void InternalSetColorValue( Color value );
#endif
virtual bool ClampValue( float& value );
virtual void ChangeStringValue( const char *tempVal, float flOldValue );
+1 -1
View File
@@ -24,7 +24,7 @@
#ifdef _WIN32
#define FORCEINLINE_CVAR FORCEINLINE
#elif defined _LINUX || defined __APPLE__
#elif _LINUX
#define FORCEINLINE_CVAR inline
#else
#error "implement me"
File diff suppressed because it is too large Load Diff
+1 -19
View File
@@ -12,8 +12,6 @@ compiler['CDEFINES'].append('SM_LOGIC')
if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'].append('-lpthread')
if AMBuild.target['platform'] == 'darwin':
compiler['POSTLINKFLAGS'].extend(['-framework', 'CoreServices'])
extension = AMBuild.AddJob('sourcemod.logic')
binary = Cpp.LibraryBuilder('sourcemod.logic', AMBuild, extension, compiler)
@@ -31,23 +29,7 @@ files = [
'smn_textparse.cpp',
'smn_adt_trie.cpp',
'Profiler.cpp',
'smn_functions.cpp',
'smn_timers.cpp',
'smn_players.cpp',
'MemoryUtils.cpp',
'smn_admin.cpp',
'smn_banning.cpp',
'stringutil.cpp',
'Translator.cpp',
'PhraseCollection.cpp',
'smn_lang.cpp',
'smn_string.cpp',
'smn_handles.cpp',
'smn_datapacks.cpp',
'smn_gameconfigs.cpp',
'GameConfigs.cpp',
'sm_crc32.cpp',
'smn_profiler.cpp'
'smn_functions.cpp'
]
if AMBuild.target['platform'] == 'windows':
files.append('thread/WinThreads.cpp')
-92
View File
@@ -1,92 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_
#define _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_
#include "common_logic.h"
#include <IHandleSys.h>
class AutoHandleRooter
{
public:
AutoHandleRooter(Handle_t hndl)
{
if (hndl != BAD_HANDLE)
this->hndl = handlesys->FastCloneHandle(hndl);
else
this->hndl = BAD_HANDLE;
}
~AutoHandleRooter()
{
if (hndl != BAD_HANDLE)
{
HandleSecurity sec(g_pCoreIdent, g_pCoreIdent);
handlesys->FreeHandle(hndl, &sec);
}
}
Handle_t getHandle()
{
return hndl;
}
private:
Handle_t hndl;
};
class AutoHandleCloner
{
Handle_t original;
HandleSecurity sec;
AutoHandleRooter ahr;
public:
AutoHandleCloner(Handle_t original, HandleSecurity sec)
: original(original), sec(sec), ahr(original)
{
}
~AutoHandleCloner()
{
if (original != BAD_HANDLE)
{
handlesys->FreeHandle(original, &sec);
}
}
Handle_t getClone()
{
return ahr.getHandle();
}
};
#endif /* _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_ */
+1 -16
View File
@@ -25,22 +25,7 @@ OBJECTS = \
smn_textparse.cpp \
smn_adt_trie.cpp \
Profiler.cpp \
smn_functions.cpp \
sm_crc32.cpp \
smn_timers.cpp \
MemoryUtils.cpp \
smn_admin.cpp \
smn_banning.cpp \
stringutil.cpp \
Translator.cpp \
PhraseCollection.cpp \
smn_lang.cpp \
smn_string.cpp \
smn_handles.cpp \
smn_datapacks.cpp \
smn_gameconfigs.cpp \
GameConfigs.cpp \
smn_players.cpp
smn_functions.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
-612
View File
@@ -1,612 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*/
#include "MemoryUtils.h"
#ifdef PLATFORM_LINUX
#include <fcntl.h>
#include <link.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
#define PAGE_ALIGN_UP(x) ((x + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
#endif
#ifdef PLATFORM_APPLE
#include <AvailabilityMacros.h>
#include <mach/task.h>
#include <mach-o/dyld_images.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
/* Define things from 10.6 SDK for older SDKs */
#ifndef MAC_OS_X_VERSION_10_6
struct task_dyld_info
{
mach_vm_address_t all_image_info_addr;
mach_vm_size_t all_image_info_size;
};
typedef struct task_dyld_info task_dyld_info_data_t;
#define TASK_DYLD_INFO 17
#define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t))
#endif // MAC_OS_X_VERSION_10_6
#endif // PLATFORM_APPLE
MemoryUtils g_MemUtils;
MemoryUtils::MemoryUtils()
{
#ifdef PLATFORM_APPLE
Gestalt(gestaltSystemVersionMajor, &m_OSXMajor);
Gestalt(gestaltSystemVersionMinor, &m_OSXMinor);
/* Get pointer to struct that describes all loaded mach-o images in process */
if ((m_OSXMajor == 10 && m_OSXMinor >= 6) || m_OSXMajor > 10)
{
task_dyld_info_data_t dyld_info;
mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &count);
m_ImageList = (struct dyld_all_image_infos *)dyld_info.all_image_info_addr;
}
else
{
struct nlist list[2];
memset(list, 0, sizeof(list));
list[0].n_un.n_name = (char *)"_dyld_all_image_infos";
nlist("/usr/lib/dyld", list);
m_ImageList = (struct dyld_all_image_infos *)list[0].n_value;
}
#endif
}
MemoryUtils::~MemoryUtils()
{
#if defined PLATFORM_LINUX || defined PLATFORM_APPLE
for (size_t i = 0; i < m_SymTables.size(); i++)
{
delete m_SymTables[i];
}
m_SymTables.clear();
#endif
}
void MemoryUtils::OnSourceModAllInitialized()
{
sharesys->AddInterface(NULL, this);
}
void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t len)
{
DynLibInfo lib;
bool found;
char *ptr, *end;
memset(&lib, 0, sizeof(DynLibInfo));
if (!GetLibraryInfo(libPtr, lib))
{
return NULL;
}
ptr = reinterpret_cast<char *>(lib.baseAddress);
end = ptr + lib.memorySize;
while (ptr < end)
{
found = true;
for (register size_t i = 0; i < len; i++)
{
if (pattern[i] != '\x2A' && pattern[i] != ptr[i])
{
found = false;
break;
}
}
if (found)
return ptr;
ptr++;
}
return NULL;
}
void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
{
#ifdef PLATFORM_WINDOWS
return GetProcAddress((HMODULE)handle, symbol);
#elif defined PLATFORM_LINUX
struct link_map *dlmap;
struct stat dlstat;
int dlfile;
uintptr_t map_base;
Elf32_Ehdr *file_hdr;
Elf32_Shdr *sections, *shstrtab_hdr, *symtab_hdr, *strtab_hdr;
Elf32_Sym *symtab;
const char *shstrtab, *strtab;
uint16_t section_count;
uint32_t symbol_count;
LibSymbolTable *libtable;
SymbolTable *table;
Symbol *symbol_entry;
dlmap = (struct link_map *)handle;
symtab_hdr = NULL;
strtab_hdr = NULL;
table = NULL;
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlmap->l_addr)
{
table = &libtable->table;
break;
}
}
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlmap->l_addr;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
/* See if the symbol is already cached in our table */
symbol_entry = table->FindSymbol(symbol, strlen(symbol));
if (symbol_entry != NULL)
{
return symbol_entry->address;
}
/* If symbol isn't in our table, then we have open the actual library */
dlfile = open(dlmap->l_name, O_RDONLY);
if (dlfile == -1 || fstat(dlfile, &dlstat) == -1)
{
close(dlfile);
return NULL;
}
/* Map library file into memory */
file_hdr = (Elf32_Ehdr *)mmap(NULL, dlstat.st_size, PROT_READ, MAP_PRIVATE, dlfile, 0);
map_base = (uintptr_t)file_hdr;
if (file_hdr == MAP_FAILED)
{
close(dlfile);
return NULL;
}
close(dlfile);
if (file_hdr->e_shoff == 0 || file_hdr->e_shstrndx == SHN_UNDEF)
{
munmap(file_hdr, dlstat.st_size);
return NULL;
}
sections = (Elf32_Shdr *)(map_base + file_hdr->e_shoff);
section_count = file_hdr->e_shnum;
/* Get ELF section header string table */
shstrtab_hdr = &sections[file_hdr->e_shstrndx];
shstrtab = (const char *)(map_base + shstrtab_hdr->sh_offset);
/* Iterate sections while looking for ELF symbol table and string table */
for (uint16_t i = 0; i < section_count; i++)
{
Elf32_Shdr &hdr = sections[i];
const char *section_name = shstrtab + hdr.sh_name;
if (strcmp(section_name, ".symtab") == 0)
{
symtab_hdr = &hdr;
}
else if (strcmp(section_name, ".strtab") == 0)
{
strtab_hdr = &hdr;
}
}
/* Uh oh, we don't have a symbol table or a string table */
if (symtab_hdr == NULL || strtab_hdr == NULL)
{
munmap(file_hdr, dlstat.st_size);
return NULL;
}
symtab = (Elf32_Sym *)(map_base + symtab_hdr->sh_offset);
strtab = (const char *)(map_base + strtab_hdr->sh_offset);
symbol_count = symtab_hdr->sh_size / symtab_hdr->sh_entsize;
/* Iterate symbol table starting from the position we were at last time */
for (uint32_t i = libtable->last_pos; i < symbol_count; i++)
{
Elf32_Sym &sym = symtab[i];
unsigned char sym_type = ELF32_ST_TYPE(sym.st_info);
const char *sym_name = strtab + sym.st_name;
Symbol *cur_sym;
/* Skip symbols that are undefined or do not refer to functions or objects */
if (sym.st_shndx == SHN_UNDEF || (sym_type != STT_FUNC && sym_type != STT_OBJECT))
{
continue;
}
/* Caching symbols as we go along */
cur_sym = table->InternSymbol(sym_name, strlen(sym_name), (void *)(dlmap->l_addr + sym.st_value));
if (strcmp(symbol, sym_name) == 0)
{
symbol_entry = cur_sym;
libtable->last_pos = ++i;
break;
}
}
munmap(file_hdr, dlstat.st_size);
return symbol_entry ? symbol_entry->address : NULL;
#elif defined PLATFORM_APPLE
uintptr_t dlbase, linkedit_addr;
uint32_t image_count;
struct mach_header *file_hdr;
struct load_command *loadcmds;
struct segment_command *linkedit_hdr;
struct symtab_command *symtab_hdr;
struct nlist *symtab;
const char *strtab;
uint32_t loadcmd_count;
uint32_t symbol_count;
LibSymbolTable *libtable;
SymbolTable *table;
Symbol *symbol_entry;
dlbase = 0;
image_count = m_ImageList->infoArrayCount;
linkedit_hdr = NULL;
symtab_hdr = NULL;
table = NULL;
/* Loop through mach-o images in process.
* We can skip index 0 since that is just the executable.
*/
for (uint32_t i = 1; i < image_count; i++)
{
const struct dyld_image_info &info = m_ImageList->infoArray[i];
/* "Load" each one until we get a matching handle */
void *h = dlopen(info.imageFilePath, RTLD_NOLOAD);
if (h == handle)
{
dlbase = (uintptr_t)info.imageLoadAddress;
dlclose(h);
break;
}
dlclose(h);
}
if (!dlbase)
{
/* Uh oh, we couldn't find a matching handle */
return NULL;
}
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlbase)
{
table = &libtable->table;
break;
}
}
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlbase;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
/* See if the symbol is already cached in our table */
symbol_entry = table->FindSymbol(symbol, strlen(symbol));
if (symbol_entry != NULL)
{
return symbol_entry->address;
}
/* If symbol isn't in our table, then we have to locate it in memory */
file_hdr = (struct mach_header *)dlbase;
loadcmds = (struct load_command *)(dlbase + sizeof(struct mach_header));
loadcmd_count = file_hdr->ncmds;
/* Loop through load commands until we find the ones for the symbol table */
for (uint32_t i = 0; i < loadcmd_count; i++)
{
if (loadcmds->cmd == LC_SEGMENT && !linkedit_hdr)
{
struct segment_command *seg = (struct segment_command *)loadcmds;
if (strcmp(seg->segname, "__LINKEDIT") == 0)
{
linkedit_hdr = seg;
if (symtab_hdr)
{
break;
}
}
}
else if (loadcmds->cmd == LC_SYMTAB)
{
symtab_hdr = (struct symtab_command *)loadcmds;
if (linkedit_hdr)
{
break;
}
}
/* Load commands are not of a fixed size which is why we add the size */
loadcmds = (struct load_command *)((uintptr_t)loadcmds + loadcmds->cmdsize);
}
if (!linkedit_hdr || !symtab_hdr || !symtab_hdr->symoff || !symtab_hdr->stroff)
{
/* Uh oh, no symbol table */
return NULL;
}
linkedit_addr = dlbase + linkedit_hdr->vmaddr;
symtab = (struct nlist *)(linkedit_addr + symtab_hdr->symoff - linkedit_hdr->fileoff);
strtab = (const char *)(linkedit_addr + symtab_hdr->stroff - linkedit_hdr->fileoff);
symbol_count = symtab_hdr->nsyms;
/* Iterate symbol table starting from the position we were at last time */
for (uint32_t i = libtable->last_pos; i < symbol_count; i++)
{
struct nlist &sym = symtab[i];
/* Ignore the prepended underscore on all symbols, so +1 here */
const char *sym_name = strtab + sym.n_un.n_strx + 1;
Symbol *cur_sym;
/* Skip symbols that are undefined */
if (sym.n_sect == NO_SECT)
{
continue;
}
/* Caching symbols as we go along */
cur_sym = table->InternSymbol(sym_name, strlen(sym_name), (void *)(dlbase + sym.n_value));
if (strcmp(symbol, sym_name) == 0)
{
symbol_entry = cur_sym;
libtable->last_pos = ++i;
break;
}
}
return symbol_entry ? symbol_entry->address : NULL;
#endif
}
bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
{
uintptr_t baseAddr;
if (libPtr == NULL)
{
return false;
}
#ifdef PLATFORM_WINDOWS
MEMORY_BASIC_INFORMATION info;
IMAGE_DOS_HEADER *dos;
IMAGE_NT_HEADERS *pe;
IMAGE_FILE_HEADER *file;
IMAGE_OPTIONAL_HEADER *opt;
if (!VirtualQuery(libPtr, &info, sizeof(MEMORY_BASIC_INFORMATION)))
{
return false;
}
baseAddr = reinterpret_cast<uintptr_t>(info.AllocationBase);
/* All this is for our insane sanity checks :o */
dos = reinterpret_cast<IMAGE_DOS_HEADER *>(baseAddr);
pe = reinterpret_cast<IMAGE_NT_HEADERS *>(baseAddr + dos->e_lfanew);
file = &pe->FileHeader;
opt = &pe->OptionalHeader;
/* Check PE magic and signature */
if (dos->e_magic != IMAGE_DOS_SIGNATURE || pe->Signature != IMAGE_NT_SIGNATURE || opt->Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
{
return false;
}
/* Check architecture, which is 32-bit/x86 right now
* Should change this for 64-bit if Valve gets their act together
*/
if (file->Machine != IMAGE_FILE_MACHINE_I386)
{
return false;
}
/* For our purposes, this must be a dynamic library */
if ((file->Characteristics & IMAGE_FILE_DLL) == 0)
{
return false;
}
/* Finally, we can do this */
lib.memorySize = opt->SizeOfImage;
#elif defined PLATFORM_LINUX
Dl_info info;
Elf32_Ehdr *file;
Elf32_Phdr *phdr;
uint16_t phdrCount;
if (!dladdr(libPtr, &info))
{
return false;
}
if (!info.dli_fbase || !info.dli_fname)
{
return false;
}
/* This is for our insane sanity checks :o */
baseAddr = reinterpret_cast<uintptr_t>(info.dli_fbase);
file = reinterpret_cast<Elf32_Ehdr *>(baseAddr);
/* Check ELF magic */
if (memcmp(ELFMAG, file->e_ident, SELFMAG) != 0)
{
return false;
}
/* Check ELF version */
if (file->e_ident[EI_VERSION] != EV_CURRENT)
{
return false;
}
/* Check ELF architecture, which is 32-bit/x86 right now
* Should change this for 64-bit if Valve gets their act together
*/
if (file->e_ident[EI_CLASS] != ELFCLASS32 || file->e_machine != EM_386 || file->e_ident[EI_DATA] != ELFDATA2LSB)
{
return false;
}
/* For our purposes, this must be a dynamic library/shared object */
if (file->e_type != ET_DYN)
{
return false;
}
phdrCount = file->e_phnum;
phdr = reinterpret_cast<Elf32_Phdr *>(baseAddr + file->e_phoff);
for (uint16_t i = 0; i < phdrCount; i++)
{
Elf32_Phdr &hdr = phdr[i];
/* We only really care about the segment with executable code */
if (hdr.p_type == PT_LOAD && hdr.p_flags == (PF_X|PF_R))
{
/* From glibc, elf/dl-load.c:
* c->mapend = ((ph->p_vaddr + ph->p_filesz + GLRO(dl_pagesize) - 1)
* & ~(GLRO(dl_pagesize) - 1));
*
* In glibc, the segment file size is aligned up to the nearest page size and
* added to the virtual address of the segment. We just want the size here.
*/
lib.memorySize = PAGE_ALIGN_UP(hdr.p_filesz);
break;
}
}
#elif defined PLATFORM_APPLE
Dl_info info;
struct mach_header *file;
struct segment_command *seg;
uint32_t cmd_count;
if (!dladdr(libPtr, &info))
{
return false;
}
if (!info.dli_fbase || !info.dli_fname)
{
return false;
}
/* This is for our insane sanity checks :o */
baseAddr = (uintptr_t)info.dli_fbase;
file = (struct mach_header *)baseAddr;
/* Check Mach-O magic */
if (file->magic != MH_MAGIC)
{
return false;
}
/* Check architecture (32-bit/x86) */
if (file->cputype != CPU_TYPE_I386 || file->cpusubtype != CPU_SUBTYPE_I386_ALL)
{
return false;
}
/* For our purposes, this must be a dynamic library */
if (file->filetype != MH_DYLIB)
{
return false;
}
cmd_count = file->ncmds;
seg = (struct segment_command *)(baseAddr + sizeof(struct mach_header));
/* Add up memory sizes of mapped segments */
for (uint32_t i = 0; i < cmd_count; i++)
{
if (seg->cmd == LC_SEGMENT)
{
lib.memorySize += seg->vmsize;
}
seg = (struct segment_command *)((uintptr_t)seg + seg->cmdsize);
}
#endif
lib.baseAddress = reinterpret_cast<void *>(baseAddr);
return true;
}
+3 -35
View File
@@ -36,7 +36,6 @@
#include <time.h>
#endif
#include <IPluginSys.h>
#include "stringutil.h"
ProfileEngine g_Profiler;
IProfiler *sm_profiler = &g_Profiler;
@@ -342,46 +341,15 @@ void ProfileEngine::OnRootConsoleCommand2(const char *cmdname, const ICommandArg
GenerateReport(fp);
fclose(fp);
Clear();
rootmenu->ConsolePrint("Profiler report generated as: %s\n", path);
return;
}
else if (strcmp(command->Arg(2), "report") == 0)
{
FILE *fp;
char path[256];
g_pSM->BuildPath(Path_SM, path, sizeof(path), "logs/profile_%d.xml", (int)time(NULL));
if ((fp = fopen(path, "wt")) == NULL)
{
rootmenu->ConsolePrint("Failed, could not open file for writing: %s", path);
return;
}
GenerateReport(fp);
fclose(fp);
rootmenu->ConsolePrint("Profiler report generated as: %s\n", path);
return;
}
else if (strcmp(command->Arg(2), "clear") == 0)
{
Clear();
rootmenu->ConsolePrint("Profiler statistics cleared.\n");
return;
}
}
rootmenu->ConsolePrint("Profiler commands:");
rootmenu->DrawGenericOption("flush", "Flushes statistics to disk and starts over");
rootmenu->DrawGenericOption("report", "Flushes statistics to disk");
rootmenu->DrawGenericOption("clear", "Clears statistics");
}
bool ProfileEngine::GenerateReport(FILE *fp)
@@ -418,9 +386,9 @@ void ProfileEngine::WriteReport(FILE *fp, ProfileReport *report, const char *nam
{
ar = report->GetReport(i);
strncopy(new_name, ar->atom_name, sizeof(new_name));
UTIL_ReplaceAll(new_name, sizeof(new_name), "<", "&lt;", true);
UTIL_ReplaceAll(new_name, sizeof(new_name), ">", "&gt;", true);
smcore.strncopy(new_name, ar->atom_name, sizeof(new_name));
smcore.ReplaceAll(new_name, sizeof(new_name), "<", "&lt;", true);
smcore.ReplaceAll(new_name, sizeof(new_name), ">", "&gt;", true);
fprintf(fp, " <item name=\"%s\" numcalls=\"%d\" mintime=\"%f\" maxtime=\"%f\" totaltime=\"%f\"/>\n",
new_name,
+1 -1
View File
@@ -872,7 +872,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
ptr = save_ptr;
/* Lastly, strip ending whitespace off */
for (size_t i=len-1; i<len; i--)
for (size_t i=len-1; i>=0 && i<len; i--)
{
if (g_ws_chartable[(unsigned char)ptr[i]])
{
+2 -35
View File
@@ -33,14 +33,9 @@
#include <sm_platform.h>
#include <string.h>
#include "common_logic.h"
#include "ThreadSupport.h"
#include "TextParsers.h"
#include "Profiler.h"
#include "sm_crc32.h"
#include "MemoryUtils.h"
#include "stringutil.h"
#include "ThreadSupport.h"
#include "Translator.h"
#include "GameConfigs.h"
sm_core_t smcore;
IHandleSys *handlesys;
@@ -54,35 +49,12 @@ IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
ITimerSystem *timersys;
ServerGlobals serverGlobals;
IPlayerManager *playerhelpers;
IAdminSystem *adminsys;
IGameHelpers *gamehelpers;
static void AddCorePhraseFile(const char *filename)
{
g_pCorePhrases->AddPhraseFile("antiflood.phrases");
}
static IGameConfig *GetCoreGameConfig()
{
return g_pGameConf;
}
static sm_logic_t logic =
{
NULL,
g_pThreader,
sm_profiler,
&g_Translator,
stristr,
CoreTranslate,
AddCorePhraseFile,
UTIL_ReplaceAll,
UTIL_ReplaceEx,
UTIL_DecodeHexString,
GetCoreGameConfig
sm_profiler
};
static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
@@ -91,7 +63,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
memcpy(&smcore, core, sizeof(sm_core_t));
memcpy(_logic, &logic, sizeof(sm_logic_t));
memcpy(&serverGlobals, core->serverGlobals, sizeof(ServerGlobals));
handlesys = core->handlesys;
libsys = core->libsys;
@@ -102,10 +73,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
rootmenu = core->rootmenu;
pluginsys = core->pluginsys;
forwardsys = core->forwardsys;
timersys = core->timersys;
playerhelpers = core->playerhelpers;
adminsys = core->adminsys;
gamehelpers = core->gamehelpers;
}
PLATFORM_EXTERN_C ITextParsers *get_textparsers()
-5
View File
@@ -47,11 +47,6 @@ extern IShareSys *sharesys;
extern IRootConsole *rootmenu;
extern IPluginManager *pluginsys;
extern IForwardManager *forwardsys;
extern ITimerSystem *timersys;
extern ServerGlobals serverGlobals;
extern IPlayerManager *playerhelpers;
extern IAdminSystem *adminsys;
extern IGameHelpers *gamehelpers;
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */
+2 -42
View File
@@ -42,7 +42,7 @@ using namespace SourceMod;
* Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries
*/
#define SM_LOGIC_MAGIC (0x0F47C0DE - 17)
#define SM_LOGIC_MAGIC (0x0F47C0DE - 2)
#if defined SM_LOGIC
class IVEngineServer
@@ -52,7 +52,6 @@ class IVEngineServer_Logic
{
public:
virtual bool IsMapValid(const char *map) = 0;
virtual void ServerCommand(const char *cmd) = 0;
};
namespace SourceMod
@@ -64,25 +63,11 @@ namespace SourceMod
class IRootConsole;
class IPluginManager;
class IForwardManager;
class ITimerSystem;
class IPlayerManager;
class IAdminSystem;
class IGameHelpers;
class IPhraseCollection;
class ITranslator;
class IGameConfig;
}
class IVEngineServer;
class ConVar;
struct ServerGlobals
{
const double *universalTime;
float *interval_per_tick;
float *frametime;
};
struct sm_core_t
{
/* Objects */
@@ -95,10 +80,6 @@ struct sm_core_t
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
ITimerSystem *timersys;
IPlayerManager *playerhelpers;
IAdminSystem *adminsys;
IGameHelpers *gamehelpers;
/* Functions */
void (*AddNatives)(sp_nativeinfo_t* nlist);
ConVar * (*FindConVar)(const char*);
@@ -107,20 +88,7 @@ struct sm_core_t
void (*LogError)(const char*, ...);
const char * (*GetCvarString)(ConVar*);
size_t (*Format)(char*, size_t, const char*, ...);
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
bool (*gnprintf)(char *, size_t, const char *, IPhraseCollection *, void **,
unsigned int, unsigned int &, size_t *, const char **);
size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *);
bool (*GetGameName)(char *buffer, size_t maxlength);
const char * (*GetGameDescription)();
const char * (*GetSourceEngineName)();
bool (*SymbolsAreHidden)();
const char * (*GetCoreConfigValue)(const char*);
/* Data */
ServerGlobals *serverGlobals;
void * serverFactory;
void * engineFactory;
void * matchmakingDSFactory;
unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool);
};
struct sm_logic_t
@@ -128,14 +96,6 @@ struct sm_logic_t
SMGlobalClass *head;
IThreader *threader;
IProfiler *profiler;
ITranslator *translator;
const char *(*stristr)(const char *, const char *);
bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...);
void (*AddCorePhraseFile)(const char *filename);
unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool);
char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool);
size_t (*DecodeHexString)(unsigned char *, size_t, const char *);
IGameConfig * (*GetCoreGameConfig)();
};
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
-19
View File
@@ -1,19 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "logic.vcxproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
-159
View File
@@ -1,159 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}</ProjectGuid>
<RootNamespace>jitx86</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..;$(MMSOURCE18)\core\sourcehook;..\..\..\public;..\..\..\public\sourcepawn;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_DEFAULT_THREADER;SM_LOGIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)sourcemod.logic.dll</OutputFile>
<IgnoreSpecificDefaultLibraries>LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..;$(MMSOURCE17)\core\sourcehook;..\..\..\public;..\..\..\public\sourcepawn;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_LOGIC;SM_DEFAULT_THREADER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)sourcemod.logic.dll</OutputFile>
<IgnoreSpecificDefaultLibraries>LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common_logic.cpp" />
<ClCompile Include="..\GameConfigs.cpp" />
<ClCompile Include="..\MemoryUtils.cpp" />
<ClCompile Include="..\PhraseCollection.cpp" />
<ClCompile Include="..\Profiler.cpp" />
<ClCompile Include="..\sm_crc32.cpp" />
<ClCompile Include="..\smn_admin.cpp" />
<ClCompile Include="..\smn_adt_array.cpp" />
<ClCompile Include="..\smn_adt_stack.cpp" />
<ClCompile Include="..\smn_adt_trie.cpp" />
<ClCompile Include="..\smn_banning.cpp" />
<ClCompile Include="..\smn_datapacks.cpp" />
<ClCompile Include="..\smn_float.cpp" />
<ClCompile Include="..\smn_functions.cpp" />
<ClCompile Include="..\smn_gameconfigs.cpp" />
<ClCompile Include="..\smn_handles.cpp" />
<ClCompile Include="..\smn_lang.cpp" />
<ClCompile Include="..\smn_maplists.cpp" />
<ClCompile Include="..\smn_players.cpp" />
<ClCompile Include="..\smn_sorting.cpp" />
<ClCompile Include="..\smn_string.cpp" />
<ClCompile Include="..\smn_textparse.cpp" />
<ClCompile Include="..\smn_timers.cpp" />
<ClCompile Include="..\stringutil.cpp" />
<ClCompile Include="..\TextParsers.cpp" />
<ClCompile Include="..\ThreadSupport.cpp" />
<ClCompile Include="..\Translator.cpp" />
<ClCompile Include="..\thread\BaseWorker.cpp" />
<ClCompile Include="..\thread\ThreadWorker.cpp" />
<ClCompile Include="..\thread\WinThreads.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\AutoHandleRooter.h" />
<ClInclude Include="..\CellArray.h" />
<ClInclude Include="..\common_logic.h" />
<ClInclude Include="..\GameConfigs.h" />
<ClInclude Include="..\intercom.h" />
<ClInclude Include="..\MemoryUtils.h" />
<ClInclude Include="..\MersenneTwister.h" />
<ClInclude Include="..\PhraseCollection.h" />
<ClInclude Include="..\Profiler.h" />
<ClInclude Include="..\sm_crc32.h" />
<ClInclude Include="..\sm_memtable.h" />
<ClInclude Include="..\sm_symtable.h" />
<ClInclude Include="..\stringutil.h" />
<ClInclude Include="..\svn_version.h" />
<ClInclude Include="..\TextParsers.h" />
<ClInclude Include="..\ThreadSupport.h" />
<ClInclude Include="..\thread\BaseWorker.h" />
<ClInclude Include="..\thread\ThreadWorker.h" />
<ClInclude Include="..\thread\WinThreads.h" />
<ClInclude Include="..\Translator.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-188
View File
@@ -1,188 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
<Filter Include="Threads">
<UniqueIdentifier>{67c1ebce-c1f8-4d2c-9ef4-33f0ef6343e9}</UniqueIdentifier>
</Filter>
<Filter Include="Threads\Header Files">
<UniqueIdentifier>{c6e2ebb3-4869-4453-9b83-e49f70cb8a05}</UniqueIdentifier>
</Filter>
<Filter Include="Threads\Source Files">
<UniqueIdentifier>{e6d8a9af-1c1b-4f0c-ae06-a9ebd5cd32e4}</UniqueIdentifier>
</Filter>
<Filter Include="Natives">
<UniqueIdentifier>{126462f2-e517-4854-8a94-759e56787536}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common_logic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\GameConfigs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MemoryUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\PhraseCollection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Profiler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_crc32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\stringutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\TextParsers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ThreadSupport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Translator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\thread\BaseWorker.cpp">
<Filter>Threads\Source Files</Filter>
</ClCompile>
<ClCompile Include="..\thread\ThreadWorker.cpp">
<Filter>Threads\Source Files</Filter>
</ClCompile>
<ClCompile Include="..\thread\WinThreads.cpp">
<Filter>Threads\Source Files</Filter>
</ClCompile>
<ClCompile Include="..\smn_admin.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_timers.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_adt_array.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_adt_stack.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_adt_trie.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_banning.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_datapacks.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_float.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_functions.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_gameconfigs.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_handles.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_lang.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_maplists.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_players.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_sorting.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_string.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_textparse.cpp">
<Filter>Natives</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\CellArray.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\common_logic.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\intercom.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Profiler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\svn_version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\TextParsers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ThreadSupport.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\thread\BaseWorker.h">
<Filter>Threads\Header Files</Filter>
</ClInclude>
<ClInclude Include="..\thread\ThreadWorker.h">
<Filter>Threads\Header Files</Filter>
</ClInclude>
<ClInclude Include="..\thread\WinThreads.h">
<Filter>Threads\Header Files</Filter>
</ClInclude>
<ClInclude Include="..\AutoHandleRooter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\GameConfigs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MemoryUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MersenneTwister.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PhraseCollection.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_crc32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_memtable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_symtable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\stringutil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Translator.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
+13 -69
View File
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..;&quot;$(MMSOURCE17)\core\sourcehook&quot;;..\..\..\public;..\..\..\public\sourcepawn"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_DEFAULT_THREADER;SM_LOGIC"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_DEFAULT_THREADER"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\sourcemod.logic.dll"
OutputFile="$(OutDir)\sourcepawn.jit.x86.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
GenerateDebugInformation="true"
@@ -185,19 +185,11 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\common_logic.cpp"
RelativePath="..\smn_functions.cpp"
>
</File>
<File
RelativePath="..\GameConfigs.cpp"
>
</File>
<File
RelativePath="..\MemoryUtils.cpp"
>
</File>
<File
RelativePath="..\PhraseCollection.cpp"
RelativePath="..\smn_adt_trie.cpp"
>
</File>
<File
@@ -205,11 +197,7 @@
>
</File>
<File
RelativePath="..\sm_crc32.cpp"
>
</File>
<File
RelativePath="..\smn_admin.cpp"
RelativePath="..\common_logic.cpp"
>
</File>
<File
@@ -220,66 +208,22 @@
RelativePath="..\smn_adt_stack.cpp"
>
</File>
<File
RelativePath="..\smn_adt_trie.cpp"
>
</File>
<File
RelativePath="..\smn_banning.cpp"
>
</File>
<File
RelativePath="..\smn_datapacks.cpp"
>
</File>
<File
RelativePath="..\smn_float.cpp"
>
</File>
<File
RelativePath="..\smn_functions.cpp"
>
</File>
<File
RelativePath="..\smn_gameconfigs.cpp"
>
</File>
<File
RelativePath="..\smn_handles.cpp"
>
</File>
<File
RelativePath="..\smn_lang.cpp"
>
</File>
<File
RelativePath="..\smn_maplists.cpp"
>
</File>
<File
RelativePath="..\smn_players.cpp"
>
</File>
<File
RelativePath="..\smn_sorting.cpp"
>
</File>
<File
RelativePath="..\smn_string.cpp"
>
</File>
<File
RelativePath="..\smn_textparse.cpp"
>
</File>
<File
RelativePath="..\smn_timers.cpp"
>
</File>
<File
RelativePath="..\stringutil.cpp"
>
</File>
<File
RelativePath="..\TextParsers.cpp"
>
@@ -288,10 +232,6 @@
RelativePath="..\ThreadSupport.cpp"
>
</File>
<File
RelativePath="..\Translator.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
@@ -310,10 +250,6 @@
RelativePath="..\intercom.h"
>
</File>
<File
RelativePath="..\Profiler.h"
>
</File>
<File
RelativePath="..\svn_version.h"
>
@@ -326,6 +262,10 @@
RelativePath="..\ThreadSupport.h"
>
</File>
<File
RelativePath="..\Profiler.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
@@ -336,6 +276,10 @@
RelativePath="..\svn_version.tpl"
>
</File>
<File
RelativePath="..\version.rc"
>
</File>
</Filter>
<Filter
Name="Threads"
-163
View File
@@ -1,163 +0,0 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
#include <stdlib.h>
#include <string.h>
class BaseMemTable
{
public:
BaseMemTable(unsigned int init_size)
{
membase = (unsigned char *)malloc(init_size);
size = init_size;
tail = 0;
}
~BaseMemTable()
{
free(membase);
membase = NULL;
}
public:
/**
* Allocates 'size' bytes of memory.
* Optionally outputs the address through 'addr'.
* Returns an index >= 0 on success, < 0 on failure.
*/
int CreateMem(unsigned int addsize, void **addr)
{
int idx = (int)tail;
while (tail + addsize >= size) {
size *= 2;
membase = (unsigned char *)realloc(membase, size);
}
tail += addsize;
if (addr)
*addr = (void *)&membase[idx];
return idx;
}
/**
* Given an index into the memory table, returns its address.
* Returns NULL if invalid.
*/
void *GetAddress(int index)
{
if (index < 0 || (unsigned int)index >= tail)
return NULL;
return &membase[index];
}
/**
* Scraps the memory table. For caching purposes, the memory
* is not freed, however subsequent calls to CreateMem() will
* begin at the first index again.
*/
void Reset()
{
tail = 0;
}
inline unsigned int GetMemUsage()
{
return size;
}
inline unsigned int GetActualMemUsed()
{
return tail;
}
private:
unsigned char *membase;
unsigned int size;
unsigned int tail;
};
class BaseStringTable
{
public:
BaseStringTable(unsigned int init_size) : m_table(init_size)
{
}
public:
/**
* Adds a string to the string table and returns its index.
*/
int AddString(const char *string)
{
size_t len = strlen(string) + 1;
int idx;
char *addr;
idx = m_table.CreateMem(len, (void **)&addr);
strcpy(addr, string);
return idx;
}
/**
* Given an index into the string table, returns the associated string.
*/
inline const char *GetString(int str)
{
return (const char *)m_table.GetAddress(str);
}
/**
* Scraps the string table. For caching purposes, the memory
* is not freed, however subsequent calls to AddString() will
* begin at the first index again.
*/
void Reset()
{
m_table.Reset();
}
/**
* Returns the parent BaseMemTable that this string table uses.
*/
inline BaseMemTable *GetMemTable()
{
return &m_table;
}
private:
BaseMemTable m_table;
};
#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
-235
View File
@@ -1,235 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "common_logic.h"
#include <IPluginSys.h>
#include <IPlayerHelpers.h>
#include <sh_string.h>
#include <sh_list.h>
#include "AutoHandleRooter.h"
#include "CellArray.h"
using namespace SourceHook;
using namespace SourceMod;
class PlayerLogicHelpers :
public SMGlobalClass,
public IPluginsListener,
public ICommandTargetProcessor
{
struct SimpleMultiTargetFilter
{
IPlugin *plugin;
SourceHook::String pattern;
IPluginFunction *fun;
SourceHook::String phrase;
bool phraseIsML;
SimpleMultiTargetFilter(IPlugin *plugin, const char *pattern, IPluginFunction *fun,
const char *phrase, bool phraseIsML)
: plugin(plugin), pattern(pattern), fun(fun), phrase(phrase), phraseIsML(phraseIsML)
{
}
};
List<SimpleMultiTargetFilter *> simpleMultis;
bool filterEnabled;
public:
void AddMultiTargetFilter(IPlugin *plugin, const char *pattern, IPluginFunction *fun,
const char *phrase, bool phraseIsML)
{
SimpleMultiTargetFilter *smtf = new SimpleMultiTargetFilter(plugin, pattern, fun, phrase,
phraseIsML);
simpleMultis.push_back(smtf);
if (!filterEnabled) {
playerhelpers->RegisterCommandTargetProcessor(this);
filterEnabled = true;
}
}
void RemoveMultiTargetFilter(const char *pattern, IPluginFunction *fun)
{
List<SimpleMultiTargetFilter *>::iterator iter = simpleMultis.begin();
while (iter != simpleMultis.end()) {
if ((*iter)->fun == fun && strcmp((*iter)->pattern.c_str(), pattern) == 0) {
delete (*iter);
iter = simpleMultis.erase(iter);
break;
}
iter++;
}
}
PlayerLogicHelpers()
: filterEnabled(false)
{
}
public: //ICommandTargetProcessor
bool ProcessCommandTarget(cmd_target_info_t *info)
{
List<SimpleMultiTargetFilter *>::iterator iter;
for (iter = simpleMultis.begin(); iter != simpleMultis.end(); iter++) {
SimpleMultiTargetFilter *smtf = (*iter);
if (strcmp(smtf->pattern.c_str(), info->pattern) == 0) {
CellArray *array = new CellArray(1);
HandleSecurity sec(g_pCoreIdent, g_pCoreIdent);
Handle_t hndl = handlesys->CreateHandleEx(htCellArray, array, &sec, NULL, NULL);
AutoHandleCloner ahc(hndl, sec);
if (ahc.getClone() == BAD_HANDLE) {
smcore.LogError("[SM] Could not allocate a handle (%s, %d)", __FILE__, __LINE__);
delete array;
return false;
}
smtf->fun->PushString(info->pattern);
smtf->fun->PushCell(ahc.getClone());
cell_t result = 0;
if (smtf->fun->Execute(&result) != SP_ERROR_NONE || !result)
return false;
IGamePlayer *pAdmin = info->admin
? playerhelpers->GetGamePlayer(info->admin)
: NULL;
info->num_targets = 0;
for (size_t i = 0; i < array->size(); i++) {
cell_t client = *array->at(i);
IGamePlayer *pClient = playerhelpers->GetGamePlayer(client);
if (pClient == NULL || !pClient->IsConnected())
continue;
if (playerhelpers->FilterCommandTarget(pAdmin, pClient, info->flags) ==
COMMAND_TARGET_VALID)
{
info->targets[info->num_targets++] = client;
if (info->num_targets >= unsigned(info->max_targets))
break;
}
}
info->reason = info->num_targets > 0
? COMMAND_TARGET_VALID
: COMMAND_TARGET_EMPTY_FILTER;
if (info->num_targets) {
smcore.strncopy(info->target_name, smtf->phrase.c_str(), info->target_name_maxlength);
info->target_name_style = smtf->phraseIsML
? COMMAND_TARGETNAME_ML
: COMMAND_TARGETNAME_RAW;
}
return true;
}
}
return false;
}
public: //SMGlobalClass
void OnSourceModAllInitialized()
{
pluginsys->AddPluginsListener(this);
}
void OnSourceModShutdown()
{
pluginsys->RemovePluginsListener(this);
if (filterEnabled) {
playerhelpers->UnregisterCommandTargetProcessor(this);
filterEnabled = false;
}
}
public: //IPluginsListener
void OnPluginDestroyed(IPlugin *plugin)
{
List<SimpleMultiTargetFilter *>::iterator iter = simpleMultis.begin();
while (iter != simpleMultis.end()) {
if ((*iter)->plugin != plugin) {
iter++;
} else {
delete (*iter);
iter = simpleMultis.erase(iter);
}
}
}
} s_PlayerLogicHelpers;
static cell_t
AddMultiTargetFilter(IPluginContext *ctx, const cell_t *params)
{
IPluginFunction *fun = ctx->GetFunctionById(funcid_t(params[2]));
if (fun == NULL)
return ctx->ThrowNativeError("Invalid function id (%X)", params[2]);
char *pattern;
char *phrase;
ctx->LocalToString(params[1], &pattern);
ctx->LocalToString(params[3], &phrase);
bool phraseIsML = !!params[4];
IPlugin *plugin = pluginsys->FindPluginByContext(ctx->GetContext());
s_PlayerLogicHelpers.AddMultiTargetFilter(plugin, pattern, fun, phrase, phraseIsML);
return 1;
}
static cell_t
RemoveMultiTargetFilter(IPluginContext *ctx, const cell_t *params)
{
IPluginFunction *fun = ctx->GetFunctionById(funcid_t(params[2]));
if (fun == NULL)
return ctx->ThrowNativeError("Invalid function id (%X)", params[2]);
char *pattern;
ctx->LocalToString(params[1], &pattern);
s_PlayerLogicHelpers.RemoveMultiTargetFilter(pattern, fun);
return 1;
}
REGISTER_NATIVES(playernatives)
{
{"AddMultiTargetFilter", AddMultiTargetFilter},
{"RemoveMultiTargetFilter", RemoveMultiTargetFilter},
{NULL, NULL}
};
-305
View File
@@ -1,305 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 et :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <sm_platform.h>
#include "stringutil.h"
const char *stristr(const char *str, const char *substr)
{
if (!*substr)
{
return ((char *)str);
}
char *needle = (char *)substr;
char *prevloc = (char *)str;
char *haystack = (char *)str;
while (*haystack)
{
if (tolower(*haystack) == tolower(*needle))
{
haystack++;
if (!*++needle)
{
return prevloc;
}
}
else
{
haystack = ++prevloc;
needle = (char *)substr;
}
}
return NULL;
}
unsigned int strncopy(char *dest, const char *src, size_t count)
{
if (!count)
{
return 0;
}
char *start = dest;
while ((*src) && (--count))
{
*dest++ = *src++;
}
*dest = '\0';
return (dest - start);
}
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive)
{
size_t searchLen = strlen(search);
size_t replaceLen = strlen(replace);
char *ptr = subject;
unsigned int total = 0;
while ((ptr = UTIL_ReplaceEx(ptr, maxlength, search, searchLen, replace, replaceLen, caseSensitive)) != NULL)
{
total++;
if (*ptr == '\0')
{
break;
}
}
return total;
}
/**
* NOTE: Do not edit this for the love of god unless you have
* read the test cases and understand the code behind each one.
* While I don't guarantee there aren't mistakes, I do guarantee
* that plugins will end up relying on tiny idiosyncrasies of this
* function, just like they did with AMX Mod X.
*
* There are explicitly more cases than the AMX Mod X version because
* we're not doing a blind copy. Each case is specifically optimized
* for what needs to be done. Even better, we don't have to error on
* bad buffer sizes. Instead, this function will smartly cut off the
* string in a way that pushes old data out.
*/
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive)
{
char *ptr = subject;
size_t browsed = 0;
size_t textLen = strlen(subject);
/* It's not possible to search or replace */
if (searchLen > textLen)
{
return NULL;
}
/* Handle the case of one byte replacement.
* It's only valid in one case.
*/
if (maxLen == 1)
{
/* If the search matches and the replace length is 0,
* we can just terminate the string and be done.
*/
if ((caseSensitive ? strcmp(subject, search) : strcasecmp(subject, search)) == 0 && replaceLen == 0)
{
*subject = '\0';
return subject;
}
else
{
return NULL;
}
}
/* Subtract one off the maxlength so we can include the null terminator */
maxLen--;
while (*ptr != '\0' && (browsed <= textLen - searchLen))
{
/* See if we get a comparison */
if ((caseSensitive ? strncmp(ptr, search, searchLen) : strncasecmp(ptr, search, searchLen)) == 0)
{
if (replaceLen > searchLen)
{
/* First, see if we have enough space to do this operation */
if (maxLen - textLen < replaceLen - searchLen)
{
/* First, see if the replacement length goes out of bounds. */
if (browsed + replaceLen >= maxLen)
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDDDDDDDD
* OUTPUT : AADDDDDDDDD
* POSITION: ^
*/
/* If it does, we'll just bound the length and do a strcpy. */
replaceLen = maxLen - browsed;
/* Note, we add one to the final result for the null terminator */
strncopy(ptr, replace, replaceLen+1);
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDDDDD
* OUTPUT : AADDDDDDDCC
* POSITION: ^
*/
/* We're going to have some bytes left over... */
size_t origBytesToCopy = (textLen - (browsed + searchLen)) + 1;
size_t realBytesToCopy = (maxLen - (browsed + replaceLen)) + 1;
char *moveFrom = ptr + searchLen + (origBytesToCopy - realBytesToCopy);
char *moveTo = ptr + replaceLen;
/* First, move our old data out of the way. */
memmove(moveTo, moveFrom, realBytesToCopy);
/* Now, do our replacement. */
memcpy(ptr, replace, replaceLen);
}
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDD
* OUTPUT : AADDDDCCC
* POSITION: ^
*/
/* Yes, we have enough space. Do a normal move operation. */
char *moveFrom = ptr + searchLen;
char *moveTo = ptr + replaceLen;
/* First move our old data out of the way. */
size_t bytesToCopy = (textLen - (browsed + searchLen)) + 1;
memmove(moveTo, moveFrom, bytesToCopy);
/* Now do our replacement. */
memcpy(ptr, replace, replaceLen);
}
}
else if (replaceLen < searchLen)
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: D
* OUTPUT : AADCCC
* POSITION: ^
*/
/* If the replacement does not grow the string length, we do not
* need to do any fancy checking at all. Yay!
*/
char *moveFrom = ptr + searchLen; /* Start after the search pointer */
char *moveTo = ptr + replaceLen; /* Copy to where the replacement ends */
/* Copy our replacement in, if any */
if (replaceLen)
{
memcpy(ptr, replace, replaceLen);
}
/* Figure out how many bytes to move down, including null terminator */
size_t bytesToCopy = (textLen - (browsed + searchLen)) + 1;
/* Move the rest of the string down */
memmove(moveTo, moveFrom, bytesToCopy);
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDD
* OUTPUT : AADDDCCC
* POSITION: ^
*/
/* We don't have to move anything around, just do a straight copy */
memcpy(ptr, replace, replaceLen);
}
return ptr + replaceLen;
}
ptr++;
browsed++;
}
return NULL;
}
size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr)
{
size_t written = 0;
size_t length = strlen(hexstr);
for (size_t i = 0; i < length; i++)
{
if (written >= maxlength)
break;
buffer[written++] = hexstr[i];
if (hexstr[i] == '\\' && hexstr[i + 1] == 'x')
{
if (i + 3 >= length)
continue;
/* Get the hex part. */
char s_byte[3];
int r_byte;
s_byte[0] = hexstr[i + 2];
s_byte[1] = hexstr[i + 3];
s_byte[2] = '\0';
/* Read it as an integer */
sscanf(s_byte, "%x", &r_byte);
/* Save the value */
buffer[written - 1] = r_byte;
/* Adjust index */
i += 3;
}
}
return written;
}
-44
View File
@@ -1,44 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 et :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_
#define _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_
const char *stristr(const char *str, const char *substr);
unsigned int strncopy(char *dest, const char *src, size_t count);
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search,
const char *replace, bool caseSensitive = true);
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen,
const char *replace, size_t replaceLen, bool caseSensitive = true);
size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr);
#endif /* _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_ */
+7 -137
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -43,36 +43,12 @@
#include "ShareSys.h"
#include "sm_srvcmds.h"
#include "ForwardSys.h"
#include "TimerSys.h"
#include "logic_bridge.h"
#include "DebugReporter.h"
#include "PlayerManager.h"
#include "AdminCache.h"
#include "HalfLife2.h"
#include "CoreConfig.h"
#if defined _WIN32
#define MATCHMAKINGDS_SUFFIX ""
#define MATCHMAKINGDS_EXT "dll"
#elif defined __APPLE__
#define MATCHMAKINGDS_SUFFIX ""
#define MATCHMAKINGDS_EXT "dylib"
#elif defined __linux__
#if SOURCE_ENGINE < SE_LEFT4DEAD2
#define MATCHMAKINGDS_SUFFIX "_i486"
#else
#define MATCHMAKINGDS_SUFFIX ""
#endif
#define MATCHMAKINGDS_EXT "so"
#endif
static ILibrary *g_pLogic = NULL;
static LogicInitFunction logic_init_fn;
IThreader *g_pThreader;
ITextParsers *textparsers;
sm_logic_t logicore;
ITranslator *translator;
class VEngineServer_Logic : public IVEngineServer_Logic
{
@@ -81,11 +57,6 @@ public:
{
return engine->IsMapValid(map);
}
virtual void ServerCommand(const char *cmd)
{
engine->ServerCommand(cmd);
}
};
static VEngineServer_Logic logic_engine;
@@ -109,83 +80,11 @@ static void log_error(const char *fmt, ...)
va_end(ap);
}
static void generate_error(IPluginContext *ctx, cell_t func_idx, int err, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
g_DbgReporter.GenerateErrorVA(ctx, func_idx, err, fmt, ap);
va_end(ap);
}
static const char *get_cvar_string(ConVar* cvar)
{
return cvar->GetString();
}
static bool get_game_name(char *buffer, size_t maxlength)
{
KeyValues *pGameInfo = new KeyValues("GameInfo");
if (g_HL2.KVLoadFromFile(pGameInfo, basefilesystem, "gameinfo.txt"))
{
const char *str;
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
{
strncopy(buffer, str, maxlength);
return true;
}
}
pGameInfo->deleteThis();
return false;
}
static const char *get_game_description()
{
return SERVER_CALL(GetGameDescription)();
}
static const char *get_source_engine_name()
{
#if !defined SOURCE_ENGINE
# error "Unknown engine type"
#endif
#if SOURCE_ENGINE == SE_EPISODEONE
return "original";
#elif SOURCE_ENGINE == SE_DARKMESSIAH
return "darkmessiah";
#elif SOURCE_ENGINE == SE_ORANGEBOX
return "orangebox";
#elif SOURCE_ENGINE == SE_BLOODYGOODTIME
return "bloodygoodtime";
#elif SOURCE_ENGINE == SE_EYE
return "eye";
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
return "orangebox_valve";
#elif SOURCE_ENGINE == SE_LEFT4DEAD
return "left4dead";
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
return "left4dead2";
#elif SOURCE_ENGINE == SE_ALIENSWARM
return "alienswarm";
#endif
}
static bool symbols_are_hidden()
{
#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
return true;
#else
return false;
#endif
}
static const char* get_core_config_value(const char* key)
{
return g_CoreConfig.GetCoreConfigValue(key);
}
static ServerGlobals serverGlobals;
static sm_core_t core_bridge =
{
/* Objects */
@@ -198,10 +97,6 @@ static sm_core_t core_bridge =
&g_RootMenu,
&g_PluginSys,
&g_Forwards,
&g_Timers,
&g_Players,
&g_Admins,
&g_HL2,
/* Functions */
add_natives,
find_convar,
@@ -210,39 +105,15 @@ static sm_core_t core_bridge =
log_error,
get_cvar_string,
UTIL_Format,
generate_error,
gnprintf,
atcprintf,
get_game_name,
get_game_description,
get_source_engine_name,
symbols_are_hidden,
get_core_config_value,
&serverGlobals
UTIL_ReplaceAll
};
void InitLogicBridge()
{
serverGlobals.universalTime = g_pUniversalTime;
serverGlobals.frametime = &gpGlobals->frametime;
serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick;
sm_logic_t logic;
core_bridge.core_ident = g_pCoreIdent;
core_bridge.engineFactory = (void *)g_SMAPI->GetEngineFactory(false);
core_bridge.serverFactory = (void *)g_SMAPI->GetServerFactory(false);
ILibrary *mmlib;
char path[PLATFORM_MAX_PATH];
g_LibSys.PathFormat(path, sizeof(path), "%s/bin/matchmaking_ds%s.%s", g_SMAPI->GetBaseDir(), MATCHMAKINGDS_SUFFIX, MATCHMAKINGDS_EXT);
if ((mmlib = g_LibSys.OpenLibrary(path, NULL, 0)))
{
core_bridge.matchmakingDSFactory = mmlib->GetSymbolAddress("CreateInterface");
mmlib->CloseLibrary();
}
logic_init_fn(&core_bridge, &logicore);
logic_init_fn(&core_bridge, &logic);
/* Add SMGlobalClass instances */
SMGlobalClass* glob = SMGlobalClass::head;
@@ -251,11 +122,10 @@ void InitLogicBridge()
glob = glob->m_pGlobalClassNext;
}
assert(glob->m_pGlobalClassNext == NULL);
glob->m_pGlobalClassNext = logicore.head;
glob->m_pGlobalClassNext = logic.head;
g_pThreader = logicore.threader;
g_pSourcePawn2->SetProfiler(logicore.profiler);
translator = logicore.translator;
g_pThreader = logic.threader;
g_pSourcePawn2->SetProfiler(logic.profiler);
}
bool StartLogicBridge(char *error, size_t maxlength)
-8
View File
@@ -31,17 +31,9 @@
#ifndef _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_
#define _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_
#include "logic/intercom.h"
void InitLogicBridge();
bool StartLogicBridge(char *error, size_t maxlength);
void ShutdownLogicBridge();
struct sm_logic_t;
extern sm_logic_t logicore;
extern ITranslator *translator;
extern IGameConfig *g_pGameConf;
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */
-77
View File
@@ -1,77 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcxproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32
CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32
CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32
CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32
CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32
CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32
CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32
Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32
Debug - Episode 1|Win32 = Debug - Episode 1|Win32
Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32
Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32
Release - Episode 1|Win32 = Release - Episode 1|Win32
Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32
Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32
Release - Old Metamod|Win32 = Release - Old Metamod|Win32
Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32
Release - Orange Box|Win32 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-467
View File
@@ -1,467 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Interfaces">
<UniqueIdentifier>{10C69360-9E8E-4a43-BCEF-E9373B3641BC}</UniqueIdentifier>
</Filter>
<Filter Include="SourcePawn">
<UniqueIdentifier>{C3C3DC6E-E392-4916-B893-7ACB92192DE0}</UniqueIdentifier>
</Filter>
<Filter Include="HL2SDK">
<UniqueIdentifier>{80B56842-7A9F-4d5d-8149-767C285D0EB4}</UniqueIdentifier>
</Filter>
<Filter Include="Natives">
<UniqueIdentifier>{052D6D9B-7B50-4c3c-9B82-32CA908DEF24}</UniqueIdentifier>
</Filter>
<Filter Include="Resources">
<UniqueIdentifier>{2A750240-7C10-455f-A900-B9A9D362356C}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\AdminCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ADTFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\CDataPack.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ChatTriggers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\concmd_cleaner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ConCmdManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ConsoleDetours.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ConVarManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\CoreConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\CrazyDebugger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Database.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\DebugReporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\EventManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ExtensionSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ForwardSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\frame_hooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\HalfLife2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\HandleSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\LibrarySys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Logger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\logic_bridge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MenuManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MenuStyle_Base.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MenuStyle_Radio.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MenuStyle_Valve.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MenuVoting.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NativeInvoker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NativeOwner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NextMap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\PlayerManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\PluginInfoDatabase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\PluginSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ShareSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_autonatives.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_srvcmds.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_stringutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_trie.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sourcemm_api.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sourcemod.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\TimerSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\UserMessages.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\smn_bitbuffer.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_console.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_core.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_database.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_entities.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_events.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_fakenatives.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_filesystem.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_halflife.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_hudtext.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_keyvalues.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_menus.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_nextmap.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_player.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_usermsgs.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_vector.cpp">
<Filter>Natives</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\AdminCache.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ADTFactory.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CDataPack.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CellArray.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CellRecipientFilter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ChatTriggers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\public\compat_wrappers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\concmd_cleaner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ConCmdManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ConCommandBaseIterator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ConsoleDetours.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ConVarManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CoreConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Database.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\DebugReporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\EventManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ExtensionSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ForwardSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\frame_hooks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\GameConfigs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\HalfLife2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\HandleSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\LibrarySys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Logger.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\logic_bridge.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MemoryUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MenuManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MenuStyle_Base.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MenuStyle_Radio.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MenuStyle_Valve.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MenuVoting.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NativeInvoker.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NativeOwner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NextMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PhraseCollection.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PlayerManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PluginInfoDatabase.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PluginSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ShareSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_autonatives.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_fastlink.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_globals.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_memtable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sm_platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_queue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_simple_prioqueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_srvcmds.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_stringutil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_symtable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_trie.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sm_trie_tpl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\smn_usermsgs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sourcemm_api.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sourcemod.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\TimerSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Translator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\UserMessages.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IAdminSystem.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IADTFactory.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IDataPack.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IDBDriver.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IExtensionSys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IForwardSys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IGameConfigs.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IGameHelpers.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IHandleSys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\ILibrarySys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IMemoryUtils.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IMenuManager.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\INativeInvoker.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IPlayerHelpers.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IPluginSys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IRootConsoleMenu.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IShareSys.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\ISourceMod.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\ITextParsers.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\ITimerSystem.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\ITranslator.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\IUserMessages.h">
<Filter>Interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sourcepawn\sp_file_headers.h">
<Filter>SourcePawn</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sourcepawn\sp_typeutil.h">
<Filter>SourcePawn</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sourcepawn\sp_vm_api.h">
<Filter>SourcePawn</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sourcepawn\sp_vm_base.h">
<Filter>SourcePawn</Filter>
</ClInclude>
<ClInclude Include="..\..\public\sourcepawn\sp_vm_types.h">
<Filter>SourcePawn</Filter>
</ClInclude>
<ClInclude Include="..\convar_sm.h">
<Filter>HL2SDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resources</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
+103 -39
View File
@@ -40,9 +40,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core-legacy&quot;;&quot;$(MMSOURCE18)\core-legacy\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core-legacy&quot;;&quot;$(MMSOURCE17)\core-legacy\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -123,9 +123,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core-legacy&quot;;&quot;$(MMSOURCE18)\core-legacy\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core-legacy&quot;;&quot;$(MMSOURCE17)\core-legacy\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -207,9 +207,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core-legacy&quot;;&quot;$(MMSOURCE18)\core-legacy\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core-legacy&quot;;&quot;$(MMSOURCE17)\core-legacy\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -290,9 +290,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -373,9 +373,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -457,9 +457,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK-DARKM)\public&quot;;&quot;$(HL2SDK-DARKM)\public\dlls&quot;;&quot;$(HL2SDK-DARKM)\public\engine&quot;;&quot;$(HL2SDK-DARKM)\public\mathlib&quot;;&quot;$(HL2SDK-DARKM)\public\tier0&quot;;&quot;$(HL2SDK-DARKM)\public\tier1&quot;;&quot;$(HL2SDK-DARKM)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -540,9 +540,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -623,9 +623,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -707,9 +707,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -790,9 +790,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -873,9 +873,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -957,9 +957,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\dlls&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -1040,9 +1040,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -1123,9 +1123,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -1207,9 +1207,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D)\public&quot;;&quot;$(HL2SDKL4D)\public\engine&quot;;&quot;$(HL2SDKL4D)\public\game\server&quot;;&quot;$(HL2SDKL4D)\public\mathlib&quot;;&quot;$(HL2SDKL4D)\public\tier0&quot;;&quot;$(HL2SDKL4D)\public\tier1&quot;;&quot;$(HL2SDKL4D)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -1290,9 +1290,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -1373,9 +1373,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -1457,9 +1457,9 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKOBVALVE)\public&quot;;&quot;$(HL2SDKOBVALVE)\public\engine&quot;;&quot;$(HL2SDKOBVALVE)\public\game\server&quot;;&quot;$(HL2SDKOBVALVE)\public\mathlib&quot;;&quot;$(HL2SDKOBVALVE)\public\tier0&quot;;&quot;$(HL2SDKOBVALVE)\public\tier1&quot;;&quot;$(HL2SDKOBVALVE)\public\vstdlib&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
@@ -1541,7 +1541,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8 /D SE_LEFT4DEAD2=6"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5 /D SE_LEFT4DEAD2=6"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D2)\public&quot;;&quot;$(HL2SDKL4D2)\public\engine&quot;;&quot;$(HL2SDKL4D2)\public\game\server&quot;;&quot;$(HL2SDKL4D2)\public\mathlib&quot;;&quot;$(HL2SDKL4D2)\public\tier0&quot;;&quot;$(HL2SDKL4D2)\public\tier1&quot;;&quot;$(HL2SDKL4D2)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6"
@@ -1624,7 +1624,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8 /D SE_LEFT4DEAD2=6"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5 /D SE_LEFT4DEAD2=6"
Optimization="0"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D2)\public&quot;;&quot;$(HL2SDKL4D2)\public\engine&quot;;&quot;$(HL2SDKL4D2)\public\game\server&quot;;&quot;$(HL2SDKL4D2)\public\mathlib&quot;;&quot;$(HL2SDKL4D2)\public\tier0&quot;;&quot;$(HL2SDKL4D2)\public\tier1&quot;;&quot;$(HL2SDKL4D2)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6"
@@ -1708,7 +1708,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_ORANGEBOXVALVE=5 /D SE_LEFT4DEAD=6 /D SE_LEFT4DEAD2=7 /D SE_ALIENSWARM=8 /D SE_LEFT4DEAD2=6"
AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5 /D SE_LEFT4DEAD2=6"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;&quot;$(HL2SDKL4D2)\public&quot;;&quot;$(HL2SDKL4D2)\public\engine&quot;;&quot;$(HL2SDKL4D2)\public\game\server&quot;;&quot;$(HL2SDKL4D2)\public\mathlib&quot;;&quot;$(HL2SDKL4D2)\public\tier0&quot;;&quot;$(HL2SDKL4D2)\public\tier1&quot;;&quot;$(HL2SDKL4D2)\public\vstdlib&quot;;&quot;$(MMSOURCE18)\core&quot;;&quot;$(MMSOURCE18)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6"
@@ -1952,6 +1952,10 @@
RelativePath="..\frame_hooks.cpp"
>
</File>
<File
RelativePath="..\GameConfigs.cpp"
>
</File>
<File
RelativePath="..\HalfLife2.cpp"
>
@@ -1972,6 +1976,10 @@
RelativePath="..\logic_bridge.cpp"
>
</File>
<File
RelativePath="..\MemoryUtils.cpp"
>
</File>
<File
RelativePath="..\MenuManager.cpp"
>
@@ -2004,6 +2012,10 @@
RelativePath="..\NextMap.cpp"
>
</File>
<File
RelativePath="..\PhraseCollection.cpp"
>
</File>
<File
RelativePath="..\PlayerManager.cpp"
>
@@ -2024,6 +2036,14 @@
RelativePath="..\sm_autonatives.cpp"
>
</File>
<File
RelativePath="..\sm_crc32.cpp"
>
</File>
<File
RelativePath="..\sm_memtable.cpp"
>
</File>
<File
RelativePath="..\sm_srvcmds.cpp"
>
@@ -2048,6 +2068,10 @@
RelativePath="..\TimerSys.cpp"
>
</File>
<File
RelativePath="..\Translator.cpp"
>
</File>
<File
RelativePath="..\UserMessages.cpp"
>
@@ -2218,6 +2242,10 @@
RelativePath="..\sm_autonatives.h"
>
</File>
<File
RelativePath="..\sm_crc32.h"
>
</File>
<File
RelativePath="..\sm_fastlink.h"
>
@@ -2422,6 +2450,14 @@
Name="Natives"
UniqueIdentifier="{052D6D9B-7B50-4c3c-9B82-32CA908DEF24}"
>
<File
RelativePath="..\smn_admin.cpp"
>
</File>
<File
RelativePath="..\smn_banning.cpp"
>
</File>
<File
RelativePath="..\smn_bitbuffer.cpp"
>
@@ -2438,6 +2474,10 @@
RelativePath="..\smn_database.cpp"
>
</File>
<File
RelativePath="..\smn_datapacks.cpp"
>
</File>
<File
RelativePath="..\smn_entities.cpp"
>
@@ -2454,10 +2494,18 @@
RelativePath="..\smn_filesystem.cpp"
>
</File>
<File
RelativePath="..\smn_gameconfigs.cpp"
>
</File>
<File
RelativePath="..\smn_halflife.cpp"
>
</File>
<File
RelativePath="..\smn_handles.cpp"
>
</File>
<File
RelativePath="..\smn_hudtext.cpp"
>
@@ -2466,6 +2514,10 @@
RelativePath="..\smn_keyvalues.cpp"
>
</File>
<File
RelativePath="..\smn_lang.cpp"
>
</File>
<File
RelativePath="..\smn_menus.cpp"
>
@@ -2478,6 +2530,18 @@
RelativePath="..\smn_player.cpp"
>
</File>
<File
RelativePath="..\smn_profiler.cpp"
>
</File>
<File
RelativePath="..\smn_string.cpp"
>
</File>
<File
RelativePath="..\smn_timers.cpp"
>
</File>
<File
RelativePath="..\smn_usermsgs.cpp"
>
@@ -1,8 +1,8 @@
/**
* vim: set ts=4 sw=4 tw=99 noet:
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -25,6 +25,8 @@
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "sm_crc32.h"
+3 -1
View File
@@ -1,5 +1,5 @@
/**
* vim: set ts=4 sw=4 tw=99 noet:
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@@ -25,6 +25,8 @@
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_CRC32_H_
+1
View File
@@ -37,6 +37,7 @@
template <typename T>
class FastLink
{
friend class iterator;
public:
struct FastLinkNode
{
@@ -1,7 +1,7 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Team Fortress 2 Extension
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
@@ -29,51 +29,84 @@
* Version: $Id$
*/
#include "holiday.h"
#include <string.h>
#include <stdlib.h>
#include "sm_memtable.h"
CDetour *isHolidayDetour = NULL;
IForward *g_isHolidayForward = NULL;
DETOUR_DECL_STATIC1(IsHolidayActive, bool, int, holiday)
BaseMemTable::BaseMemTable(unsigned int init_size)
{
bool actualres = DETOUR_STATIC_CALL(IsHolidayActive)(holiday);
if (!g_isHolidayForward)
{
g_pSM->LogMessage(myself, "Invalid Forward");
return actualres;
}
cell_t result = 0;
cell_t newres = actualres ? 1 : 0;
g_isHolidayForward->PushCell(holiday);
g_isHolidayForward->PushCellByRef(&newres);
g_isHolidayForward->Execute(&result);
if (result > Pl_Continue)
{
return (newres == 0) ? false : true;
}
return actualres;
membase = (unsigned char *)malloc(init_size);
size = init_size;
tail = 0;
}
bool InitialiseIsHolidayDetour()
BaseMemTable::~BaseMemTable()
{
isHolidayDetour = DETOUR_CREATE_STATIC(IsHolidayActive, "IsHolidayActive");
free(membase);
membase = NULL;
}
if (isHolidayDetour != NULL)
int BaseMemTable::CreateMem(unsigned int addsize, void **addr)
{
int idx = (int)tail;
while (tail + addsize >= size)
{
isHolidayDetour->EnableDetour();
return true;
size *= 2;
membase = (unsigned char *)realloc(membase, size);
}
g_pSM->LogError(myself, "IsHolidayActive detour failed");
return false;
tail += addsize;
if (addr)
{
*addr = (void *)&membase[idx];
}
return idx;
}
void RemoveIsHolidayDetour()
void *BaseMemTable::GetAddress(int index)
{
isHolidayDetour->Destroy();
if (index < 0 || (unsigned int)index >= tail)
{
return NULL;
}
return &membase[index];
}
void BaseMemTable::Reset()
{
tail = 0;
}
BaseStringTable::BaseStringTable(unsigned int init_size) : m_table(init_size)
{
}
BaseStringTable::~BaseStringTable()
{
}
int BaseStringTable::AddString(const char *string)
{
size_t len = strlen(string) + 1;
int idx;
char *addr;
idx = m_table.CreateMem(len, (void **)&addr);
strcpy(addr, string);
return idx;
}
/*const char *BaseStringTable::GetString(int str)
{
return (const char *)m_table.GetAddress(str);
}*/
void BaseStringTable::Reset()
{
m_table.Reset();
}
+9 -58
View File
@@ -32,65 +32,31 @@
#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
#include <stdlib.h>
#include <string.h>
class BaseMemTable
{
public:
BaseMemTable(unsigned int init_size)
{
membase = (unsigned char *)malloc(init_size);
size = init_size;
tail = 0;
}
~BaseMemTable()
{
free(membase);
membase = NULL;
}
BaseMemTable(unsigned int init_size);
~BaseMemTable();
public:
/**
* Allocates 'size' bytes of memory.
* Optionally outputs the address through 'addr'.
* Returns an index >= 0 on success, < 0 on failure.
*/
int CreateMem(unsigned int addsize, void **addr)
{
int idx = (int)tail;
while (tail + addsize >= size) {
size *= 2;
membase = (unsigned char *)realloc(membase, size);
}
tail += addsize;
if (addr)
*addr = (void *)&membase[idx];
return idx;
}
int CreateMem(unsigned int size, void **addr);
/**
* Given an index into the memory table, returns its address.
* Returns NULL if invalid.
*/
void *GetAddress(int index)
{
if (index < 0 || (unsigned int)index >= tail)
return NULL;
return &membase[index];
}
void *GetAddress(int index);
/**
* Scraps the memory table. For caching purposes, the memory
* is not freed, however subsequent calls to CreateMem() will
* begin at the first index again.
*/
void Reset()
{
tail = 0;
}
void Reset();
inline unsigned int GetMemUsage()
{
@@ -111,24 +77,13 @@ private:
class BaseStringTable
{
public:
BaseStringTable(unsigned int init_size) : m_table(init_size)
{
}
BaseStringTable(unsigned int init_size);
~BaseStringTable();
public:
/**
* Adds a string to the string table and returns its index.
*/
int AddString(const char *string)
{
size_t len = strlen(string) + 1;
int idx;
char *addr;
idx = m_table.CreateMem(len, (void **)&addr);
strcpy(addr, string);
return idx;
}
int AddString(const char *string);
/**
* Given an index into the string table, returns the associated string.
@@ -143,10 +98,7 @@ public:
* is not freed, however subsequent calls to AddString() will
* begin at the first index again.
*/
void Reset()
{
m_table.Reset();
}
void Reset();
/**
* Returns the parent BaseMemTable that this string table uses.
@@ -160,4 +112,3 @@ private:
};
#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
+1 -2
View File
@@ -328,10 +328,9 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &
ConsolePrint(" Matt \"pRED\" Woodrow");
ConsolePrint(" Scott \"DS\" Ehlert");
ConsolePrint(" Fyren");
ConsolePrint(" Nicholas \"psychonic\" Hastings");
ConsolePrint(" Borja \"faluco\" Ferrer");
ConsolePrint(" Pavol \"PM OnoTo\" Marko");
ConsolePrint(" Special thanks to asherkin, Liam, ferret, and Mani");
ConsolePrint(" Special thanks to Liam, psychonic, ferret, and Mani");
ConsolePrint(" Special thanks to Viper and SteamFriends");
ConsolePrint(" http://www.sourcemod.net/");
}
+260 -9
View File
@@ -35,8 +35,8 @@
#include "sm_stringutil.h"
#include "Logger.h"
#include "PluginSys.h"
#include "Translator.h"
#include "PlayerManager.h"
#include "logic_bridge.h"
#define LADJUST 0x00000004 /* left adjustment */
#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
@@ -81,11 +81,11 @@ size_t Translate(char *buffer,
try_serverlang:
if (target == SOURCEMOD_SERVER_LANGUAGE)
{
langid = translator->GetServerLanguage();
langid = g_Translator.GetServerLanguage();
}
else if ((target >= 1) && (target <= g_Players.GetMaxClients()))
{
langid = translator->GetClientLanguage(target);
langid = g_Translator.GetClientLanguage(target);
}
else
{
@@ -95,7 +95,7 @@ try_serverlang:
if (pPhrases->FindTranslation(key, langid, &pTrans) != Trans_Okay)
{
if (target != SOURCEMOD_SERVER_LANGUAGE && langid != translator->GetServerLanguage())
if (target != SOURCEMOD_SERVER_LANGUAGE && langid != g_Translator.GetServerLanguage())
{
target = SOURCEMOD_SERVER_LANGUAGE;
goto try_serverlang;
@@ -785,21 +785,21 @@ reswitch:
}
else
{
target = translator->GetGlobalTarget();
target = g_Translator.GetGlobalTarget();
}
try_again:
if (target == SOURCEMOD_SERVER_LANGUAGE)
{
lang_id = translator->GetServerLanguage();
lang_id = g_Translator.GetServerLanguage();
}
else if (target >= 1 && target <= g_Players.GetMaxClients())
{
lang_id = translator->GetClientLanguage(target);
lang_id = g_Translator.GetClientLanguage(target);
}
else
{
lang_id = translator->GetServerLanguage();
lang_id = g_Translator.GetServerLanguage();
}
if (pPhrases == NULL)
@@ -813,7 +813,7 @@ try_again:
if (pPhrases->FindTranslation(key, lang_id, &trans) != Trans_Okay)
{
if (target != SOURCEMOD_SERVER_LANGUAGE && lang_id != translator->GetServerLanguage())
if (target != SOURCEMOD_SERVER_LANGUAGE && lang_id != g_Translator.GetServerLanguage())
{
target = SOURCEMOD_SERVER_LANGUAGE;
goto try_again;
@@ -1274,6 +1274,37 @@ done:
return (maxlen - llen - 1);
}
const char *stristr(const char *str, const char *substr)
{
if (!*substr)
{
return ((char *)str);
}
char *needle = (char *)substr;
char *prevloc = (char *)str;
char *haystack = (char *)str;
while (*haystack)
{
if (tolower(*haystack) == tolower(*needle))
{
haystack++;
if (!*++needle)
{
return prevloc;
}
}
else
{
haystack = ++prevloc;
needle = (char *)substr;
}
}
return NULL;
}
unsigned int strncopy(char *dest, const char *src, size_t count)
{
if (!count)
@@ -1331,6 +1362,194 @@ char *sm_strdup(const char *str)
return ptr;
}
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive)
{
size_t searchLen = strlen(search);
size_t replaceLen = strlen(replace);
char *ptr = subject;
unsigned int total = 0;
while ((ptr = UTIL_ReplaceEx(ptr, maxlength, search, searchLen, replace, replaceLen, caseSensitive)) != NULL)
{
total++;
if (*ptr == '\0')
{
break;
}
}
return total;
}
/**
* NOTE: Do not edit this for the love of god unless you have
* read the test cases and understand the code behind each one.
* While I don't guarantee there aren't mistakes, I do guarantee
* that plugins will end up relying on tiny idiosyncrasies of this
* function, just like they did with AMX Mod X.
*
* There are explicitly more cases than the AMX Mod X version because
* we're not doing a blind copy. Each case is specifically optimized
* for what needs to be done. Even better, we don't have to error on
* bad buffer sizes. Instead, this function will smartly cut off the
* string in a way that pushes old data out.
*/
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive)
{
char *ptr = subject;
size_t browsed = 0;
size_t textLen = strlen(subject);
/* It's not possible to search or replace */
if (searchLen > textLen)
{
return NULL;
}
/* Handle the case of one byte replacement.
* It's only valid in one case.
*/
if (maxLen == 1)
{
/* If the search matches and the replace length is 0,
* we can just terminate the string and be done.
*/
if ((caseSensitive ? strcmp(subject, search) : strcasecmp(subject, search)) == 0 && replaceLen == 0)
{
*subject = '\0';
return subject;
}
else
{
return NULL;
}
}
/* Subtract one off the maxlength so we can include the null terminator */
maxLen--;
while (*ptr != '\0' && (browsed <= textLen - searchLen))
{
/* See if we get a comparison */
if ((caseSensitive ? strncmp(ptr, search, searchLen) : strncasecmp(ptr, search, searchLen)) == 0)
{
if (replaceLen > searchLen)
{
/* First, see if we have enough space to do this operation */
if (maxLen - textLen < replaceLen - searchLen)
{
/* First, see if the replacement length goes out of bounds. */
if (browsed + replaceLen >= maxLen)
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDDDDDDDD
* OUTPUT : AADDDDDDDDD
* POSITION: ^
*/
/* If it does, we'll just bound the length and do a strcpy. */
replaceLen = maxLen - browsed;
/* Note, we add one to the final result for the null terminator */
strncopy(ptr, replace, replaceLen+1);
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDDDDD
* OUTPUT : AADDDDDDDCC
* POSITION: ^
*/
/* We're going to have some bytes left over... */
size_t origBytesToCopy = (textLen - (browsed + searchLen)) + 1;
size_t realBytesToCopy = (maxLen - (browsed + replaceLen)) + 1;
char *moveFrom = ptr + searchLen + (origBytesToCopy - realBytesToCopy);
char *moveTo = ptr + replaceLen;
/* First, move our old data out of the way. */
memmove(moveTo, moveFrom, realBytesToCopy);
/* Now, do our replacement. */
memcpy(ptr, replace, replaceLen);
}
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDDD
* OUTPUT : AADDDDCCC
* POSITION: ^
*/
/* Yes, we have enough space. Do a normal move operation. */
char *moveFrom = ptr + searchLen;
char *moveTo = ptr + replaceLen;
/* First move our old data out of the way. */
size_t bytesToCopy = (textLen - (browsed + searchLen)) + 1;
memmove(moveTo, moveFrom, bytesToCopy);
/* Now do our replacement. */
memcpy(ptr, replace, replaceLen);
}
}
else if (replaceLen < searchLen)
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: D
* OUTPUT : AADCCC
* POSITION: ^
*/
/* If the replacement does not grow the string length, we do not
* need to do any fancy checking at all. Yay!
*/
char *moveFrom = ptr + searchLen; /* Start after the search pointer */
char *moveTo = ptr + replaceLen; /* Copy to where the replacement ends */
/* Copy our replacement in, if any */
if (replaceLen)
{
memcpy(ptr, replace, replaceLen);
}
/* Figure out how many bytes to move down, including null terminator */
size_t bytesToCopy = (textLen - (browsed + searchLen)) + 1;
/* Move the rest of the string down */
memmove(moveTo, moveFrom, bytesToCopy);
}
else
{
/* EXAMPLE CASE:
* Subject: AABBBCCC
* Buffer : 12 bytes
* Search : BBB
* Replace: DDD
* OUTPUT : AADDDCCC
* POSITION: ^
*/
/* We don't have to move anything around, just do a straight copy */
memcpy(ptr, replace, replaceLen);
}
return ptr + replaceLen;
}
ptr++;
browsed++;
}
return NULL;
}
char *UTIL_TrimWhitespace(char *str, size_t &len)
{
char *end = str + len - 1;
@@ -1361,6 +1580,38 @@ char *UTIL_TrimWhitespace(char *str, size_t &len)
return str;
}
size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr)
{
size_t written = 0;
size_t length = strlen(hexstr);
for (size_t i = 0; i < length; i++)
{
if (written >= maxlength)
break;
buffer[written++] = hexstr[i];
if (hexstr[i] == '\\' && hexstr[i + 1] == 'x')
{
if (i + 3 >= length)
continue;
/* Get the hex part. */
char s_byte[3];
int r_byte;
s_byte[0] = hexstr[i + 2];
s_byte[1] = hexstr[i + 3];
s_byte[2] = '\0';
/* Read it as an integer */
sscanf(s_byte, "%x", &r_byte);
/* Save the value */
buffer[written - 1] = r_byte;
/* Adjust index */
i += 3;
}
}
return written;
}
char *UTIL_ToLowerCase(const char *str)
{
size_t len = strlen(str);
+4
View File
@@ -43,6 +43,7 @@ using namespace SourceMod;
#define IS_STR_FILLED(var) (var[0] != '\0')
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param);
const char *stristr(const char *str, const char *substr);
unsigned int strncopy(char *dest, const char *src, size_t count);
bool gnprintf(char *buffer,
size_t maxlen,
@@ -56,7 +57,10 @@ bool gnprintf(char *buffer,
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
char *sm_strdup(const char *str);
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive = true);
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive = true);
char *UTIL_TrimWhitespace(char *str, size_t &len);
size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr);
char *UTIL_ToLowerCase(const char *str);
#endif // _INCLUDE_SOURCEMOD_STRINGUTIL_H_
+48 -67
View File
@@ -29,15 +29,13 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <IAdminSystem.h>
#include <IForwardSys.h>
using namespace SourceMod;
#include "sm_globals.h"
#include "AdminCache.h"
#include "ForwardSys.h"
static cell_t DumpAdminCache(IPluginContext *pContext, const cell_t *params)
{
adminsys->DumpAdminCache((AdminCachePart)params[1], (params[2] == 1) ? true : false);
g_Admins.DumpAdminCache((AdminCachePart)params[1], (params[2] == 1) ? true : false);
return 1;
}
@@ -46,7 +44,7 @@ static cell_t AddCommandOverride(IPluginContext *pContext, const cell_t *params)
char *str;
pContext->LocalToString(params[1], &str);
adminsys->AddCommandOverride(str, (OverrideType)params[2], (AdminFlag)params[3]);
g_Admins.AddCommandOverride(str, (OverrideType)params[2], (AdminFlag)params[3]);
return 1;
}
@@ -58,7 +56,7 @@ static cell_t GetCommandOverride(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[1], &cmd);
if (!adminsys->GetCommandOverride(cmd, (OverrideType)params[2], &flags))
if (!g_Admins.GetCommandOverride(cmd, (OverrideType)params[2], &flags))
{
return 0;
}
@@ -77,7 +75,7 @@ static cell_t UnsetCommandOverride(IPluginContext *pContext, const cell_t *param
pContext->LocalToString(params[1], &cmd);
adminsys->UnsetCommandOverride(cmd, (OverrideType)params[2]);
g_Admins.UnsetCommandOverride(cmd, (OverrideType)params[2]);
return 1;
}
@@ -88,7 +86,7 @@ static cell_t CreateAdmGroup(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[1], &str);
return adminsys->AddGroup(str);
return g_Admins.AddGroup(str);
}
static cell_t FindAdmGroup(IPluginContext *pContext, const cell_t *params)
@@ -97,7 +95,7 @@ static cell_t FindAdmGroup(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[1], &str);
return adminsys->FindGroupByName(str);
return g_Admins.FindGroupByName(str);
}
static cell_t SetAdmGroupAddFlag(IPluginContext *pContext, const cell_t *params)
@@ -106,7 +104,7 @@ static cell_t SetAdmGroupAddFlag(IPluginContext *pContext, const cell_t *params)
AdminFlag flag = (AdminFlag)params[2];
bool enabled = params[3] ? 1 : 0;
adminsys->SetGroupAddFlag(id, flag, enabled);
g_Admins.SetGroupAddFlag(id, flag, enabled);
return 1;
}
@@ -116,7 +114,7 @@ static cell_t GetAdmGroupAddFlag(IPluginContext *pContext, const cell_t *params)
GroupId id = (GroupId)params[1];
AdminFlag flag = (AdminFlag)params[2];
return adminsys->GetGroupAddFlag(id, flag) ? 1 : 0;
return g_Admins.GetGroupAddFlag(id, flag) ? 1 : 0;
}
static cell_t SetAdmGroupImmunity(IPluginContext *pContext, const cell_t *params)
@@ -125,7 +123,7 @@ static cell_t SetAdmGroupImmunity(IPluginContext *pContext, const cell_t *params
ImmunityType type = (ImmunityType)params[2];
bool enabled = params[3] ? 1 : 0;
adminsys->SetGroupGenericImmunity(id, type, enabled);
g_Admins.SetGroupGenericImmunity(id, type, enabled);
return 1;
}
@@ -135,7 +133,7 @@ static cell_t GetAdmGroupImmunity(IPluginContext *pContext, const cell_t *params
GroupId id = (GroupId)params[1];
ImmunityType type = (ImmunityType)params[2];
return adminsys->GetGroupGenericImmunity(id, type) ? 1 : 0;
return g_Admins.GetGroupGenericImmunity(id, type) ? 1 : 0;
}
static cell_t SetAdmGroupImmuneFrom(IPluginContext *pContext, const cell_t *params)
@@ -143,7 +141,7 @@ static cell_t SetAdmGroupImmuneFrom(IPluginContext *pContext, const cell_t *para
GroupId id = (GroupId)params[1];
GroupId other_id = (GroupId)params[2];
adminsys->AddGroupImmunity(id, other_id);
g_Admins.AddGroupImmunity(id, other_id);
return 1;
}
@@ -152,14 +150,14 @@ static cell_t GetAdmGroupImmuneCount(IPluginContext *pContext, const cell_t *par
{
GroupId id = (GroupId)params[1];
return adminsys->GetGroupImmunityCount(id);
return g_Admins.GetGroupImmunityCount(id);
}
static cell_t GetAdmGroupImmuneFrom(IPluginContext *pContext, const cell_t *params)
{
GroupId id = (GroupId)params[1];
return adminsys->GetGroupImmunity(id, params[2]);
return g_Admins.GetGroupImmunity(id, params[2]);
}
static cell_t AddAdmGroupCmdOverride(IPluginContext *pContext, const cell_t *params)
@@ -171,7 +169,7 @@ static cell_t AddAdmGroupCmdOverride(IPluginContext *pContext, const cell_t *par
pContext->LocalToString(params[2], &cmd);
adminsys->AddGroupCommandOverride(id, cmd, type, rule);
g_Admins.AddGroupCommandOverride(id, cmd, type, rule);
return 1;
}
@@ -185,7 +183,7 @@ static cell_t GetAdmGroupCmdOverride(IPluginContext *pContext, const cell_t *par
pContext->LocalToString(params[2], &cmd);
if (!adminsys->GetGroupCommandOverride(id, cmd, type, &rule))
if (!g_Admins.GetGroupCommandOverride(id, cmd, type, &rule))
{
return 0;
}
@@ -200,7 +198,7 @@ static cell_t GetAdmGroupCmdOverride(IPluginContext *pContext, const cell_t *par
static cell_t GetAdmGroupAddFlags(IPluginContext *pContext, const cell_t *params)
{
GroupId id = (GroupId)params[1];
return adminsys->GetGroupAddFlags(id);
return g_Admins.GetGroupAddFlags(id);
}
static cell_t RegisterAuthIdentType(IPluginContext *pContext, const cell_t *params)
@@ -208,7 +206,7 @@ static cell_t RegisterAuthIdentType(IPluginContext *pContext, const cell_t *para
char *type;
pContext->LocalToString(params[1], &type);
adminsys->RegisterAuthIdentType(type);
g_Admins.RegisterAuthIdentType(type);
return 1;
}
@@ -223,14 +221,14 @@ static cell_t CreateAdmin(IPluginContext *pContext, const cell_t *params)
admin = NULL;
}
return adminsys->CreateAdmin(admin);
return g_Admins.CreateAdmin(admin);
}
static cell_t GetAdminUsername(IPluginContext *pContext, const cell_t *params)
{
AdminId id = params[1];
size_t written;
const char *name = adminsys->GetAdminName(id);
const char *name = g_Admins.GetAdminName(id);
if (!name)
{
@@ -250,7 +248,7 @@ static cell_t BindAdminIdentity(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[2], &auth);
pContext->LocalToString(params[3], &ident);
return adminsys->BindAdminIdentity(id, auth, ident);
return g_Admins.BindAdminIdentity(id, auth, ident);
}
static cell_t SetAdminFlag(IPluginContext *pContext, const cell_t *params)
@@ -259,7 +257,7 @@ static cell_t SetAdminFlag(IPluginContext *pContext, const cell_t *params)
AdminFlag flag = (AdminFlag)params[2];
bool enabled = params[3] ? true : false;
adminsys->SetAdminFlag(id, flag, enabled);
g_Admins.SetAdminFlag(id, flag, enabled);
return 1;
}
@@ -270,7 +268,7 @@ static cell_t GetAdminFlag(IPluginContext *pContext, const cell_t *params)
AdminFlag flag = (AdminFlag)params[2];
AccessMode mode = (AccessMode)params[3];
return adminsys->GetAdminFlag(id, flag, mode);
return g_Admins.GetAdminFlag(id, flag, mode);
}
static cell_t GetAdminFlags(IPluginContext *pContext, const cell_t *params)
@@ -278,7 +276,7 @@ static cell_t GetAdminFlags(IPluginContext *pContext, const cell_t *params)
AdminId id = params[1];
AccessMode mode = (AccessMode)params[2];
return adminsys->GetAdminFlags(id, mode);
return g_Admins.GetAdminFlags(id, mode);
}
static cell_t AdminInheritGroup(IPluginContext *pContext, const cell_t *params)
@@ -286,14 +284,14 @@ static cell_t AdminInheritGroup(IPluginContext *pContext, const cell_t *params)
AdminId id = params[1];
GroupId gid = params[2];
return adminsys->AdminInheritGroup(id, gid);
return g_Admins.AdminInheritGroup(id, gid);
}
static cell_t GetAdminGroupCount(IPluginContext *pContext, const cell_t *params)
{
AdminId id = params[1];
return adminsys->GetAdminGroupCount(id);
return g_Admins.GetAdminGroupCount(id);
}
static cell_t GetAdminGroup(IPluginContext *pContext, const cell_t *params)
@@ -303,7 +301,7 @@ static cell_t GetAdminGroup(IPluginContext *pContext, const cell_t *params)
const char *name;
GroupId gid;
if ((gid=adminsys->GetAdminGroup(id, index, &name)) == INVALID_GROUP_ID)
if ((gid=g_Admins.GetAdminGroup(id, index, &name)) == INVALID_GROUP_ID)
{
return gid;
}
@@ -325,7 +323,7 @@ static cell_t SetAdminPassword(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[2], &password);
adminsys->SetAdminPassword(id, password);
g_Admins.SetAdminPassword(id, password);
return 1;
}
@@ -333,7 +331,7 @@ static cell_t SetAdminPassword(IPluginContext *pContext, const cell_t *params)
static cell_t GetAdminPassword(IPluginContext *pContext, const cell_t *params)
{
AdminId id = params[1];
const char *password = adminsys->GetAdminPassword(id);
const char *password = g_Admins.GetAdminPassword(id);
if (!password)
{
@@ -352,14 +350,14 @@ static cell_t FindAdminByIdentity(IPluginContext *pContext, const cell_t *params
pContext->LocalToString(params[1], &auth);
pContext->LocalToString(params[2], &ident);
return adminsys->FindAdminByIdentity(auth, ident);
return g_Admins.FindAdminByIdentity(auth, ident);
}
static cell_t RemoveAdmin(IPluginContext *pContext, const cell_t *params)
{
AdminId id = params[1];
return adminsys->InvalidateAdmin(id);
return g_Admins.InvalidateAdmin(id);
}
static cell_t FlagBitsToBitArray(IPluginContext *pContext, const cell_t *params)
@@ -367,7 +365,7 @@ static cell_t FlagBitsToBitArray(IPluginContext *pContext, const cell_t *params)
FlagBits bits = (FlagBits)params[1];
bool array[AdminFlags_TOTAL];
cell_t *addr;
unsigned int numWr = adminsys->FlagBitsToBitArray(bits, array, AdminFlags_TOTAL);
unsigned int numWr = g_Admins.FlagBitsToBitArray(bits, array, AdminFlags_TOTAL);
pContext->LocalToPhysAddr(params[2], &addr);
@@ -393,7 +391,7 @@ static cell_t FlagBitArrayToBits(IPluginContext *pContext, const cell_t *params)
array[i] = addr[i] ? true : false;
}
return adminsys->FlagBitArrayToBits(array, num);
return g_Admins.FlagBitArrayToBits(array, num);
}
static cell_t FlagArrayToBits(IPluginContext *pContext, const cell_t *params)
@@ -403,7 +401,7 @@ static cell_t FlagArrayToBits(IPluginContext *pContext, const cell_t *params)
if (sizeof(AdminFlag) == sizeof(cell_t))
{
return adminsys->FlagArrayToBits((const AdminFlag *)addr, params[2]);
return g_Admins.FlagArrayToBits((const AdminFlag *)addr, params[2]);
} else {
AdminFlag flags[AdminFlags_TOTAL];
unsigned int num = ((unsigned)params[2] > AdminFlags_TOTAL ? AdminFlags_TOTAL : params[2]);
@@ -412,7 +410,7 @@ static cell_t FlagArrayToBits(IPluginContext *pContext, const cell_t *params)
{
flags[i] = (AdminFlag)addr[i];
}
return adminsys->FlagArrayToBits(flags, num);
return g_Admins.FlagArrayToBits(flags, num);
}
}
@@ -423,11 +421,11 @@ static cell_t FlagBitsToArray(IPluginContext *pContext, const cell_t *params)
if (sizeof(AdminFlag) == sizeof(cell_t))
{
return adminsys->FlagBitsToArray(params[1], (AdminFlag *)addr, params[3]);
return g_Admins.FlagBitsToArray(params[1], (AdminFlag *)addr, params[3]);
} else {
AdminFlag flags[AdminFlags_TOTAL];
unsigned int num = ((unsigned)params[2] > AdminFlags_TOTAL ? AdminFlags_TOTAL : params[2]);
num = adminsys->FlagBitsToArray(params[1], flags, num);
num = g_Admins.FlagBitsToArray(params[1], flags, num);
for (unsigned int i=0; i<num; i++)
{
@@ -440,36 +438,36 @@ static cell_t FlagBitsToArray(IPluginContext *pContext, const cell_t *params)
static cell_t CanAdminTarget(IPluginContext *pContext, const cell_t *params)
{
return adminsys->CanAdminTarget(params[1], params[2]) ? 1 : 0;
return g_Admins.CanAdminTarget(params[1], params[2]) ? 1 : 0;
}
static cell_t CreateAuthMethod(IPluginContext *pContext, const cell_t *params)
{
char *name;
pContext->LocalToString(params[1], &name);
adminsys->RegisterAuthIdentType(name);
g_Admins.RegisterAuthIdentType(name);
return 1;
}
static cell_t SetAdmGroupImmunityLevel(IPluginContext *pContext, const cell_t *params)
{
return adminsys->SetGroupImmunityLevel(params[1], params[2]);
return g_Admins.SetGroupImmunityLevel(params[1], params[2]);
}
static cell_t GetAdmGroupImmunityLevel(IPluginContext *pContext, const cell_t *params)
{
return adminsys->GetGroupImmunityLevel(params[1]);
return g_Admins.GetGroupImmunityLevel(params[1]);
}
static cell_t SetAdminImmunityLevel(IPluginContext *pContext, const cell_t *params)
{
return adminsys->SetAdminImmunityLevel(params[1], params[2]);
return g_Admins.SetAdminImmunityLevel(params[1], params[2]);
}
static cell_t GetAdminImmunityLevel(IPluginContext *pContext, const cell_t *params)
{
return adminsys->GetAdminImmunityLevel(params[1]);
return g_Admins.GetAdminImmunityLevel(params[1]);
}
static cell_t FindFlagByName(IPluginContext *pContext, const cell_t *params)
@@ -481,7 +479,7 @@ static cell_t FindFlagByName(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &addr);
AdminFlag admflag;
if (!adminsys->FindFlag(flag, &admflag))
if (!g_Admins.FindFlag(flag, &admflag))
{
return 0;
}
@@ -497,7 +495,7 @@ static cell_t FindFlagByChar(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &addr);
AdminFlag admflag;
if (!adminsys->FindFlag((char)params[1], &admflag))
if (!g_Admins.FindFlag((char)params[1], &admflag))
{
return 0;
}
@@ -507,22 +505,6 @@ static cell_t FindFlagByChar(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t FindFlagChar(IPluginContext *pContext, const cell_t *params)
{
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
char flagchar;
if (!adminsys->FindFlagChar((AdminFlag)params[1], &flagchar))
{
return 0;
}
*addr = (cell_t)flagchar;
return 1;
}
static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params)
{
char *flag;
@@ -532,7 +514,7 @@ static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &addr);
const char *end = flag;
FlagBits bits = adminsys->ReadFlagString(flag, &end);
FlagBits bits = g_Admins.ReadFlagString(flag, &end);
*addr = end - flag;
@@ -579,7 +561,6 @@ REGISTER_NATIVES(adminNatives)
{"CreateAuthMethod", CreateAuthMethod},
{"FindFlagByName", FindFlagByName},
{"FindFlagByChar", FindFlagByChar},
{"FindFlagChar", FindFlagChar},
{"ReadFlagString", ReadFlagString},
{"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel},
{"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel},
@@ -29,12 +29,11 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <string.h>
#include <IGameHelpers.h>
#include <IPlayerHelpers.h>
#include <IForwardSys.h>
#include "stringutil.h"
#include "sm_globals.h"
#include "sm_stringutil.h"
#include "HalfLife2.h"
#include "PlayerManager.h"
#include "ForwardSys.h"
#define BANFLAG_AUTO (1<<0) /**< Auto-detects whether to ban by steamid or IP */
#define BANFLAG_IP (1<<1) /**< Always ban by IP address */
@@ -51,7 +50,7 @@ class BanNativeHelpers : public SMGlobalClass
public:
void OnSourceModAllInitialized()
{
g_pOnBanClient = forwardsys->CreateForward(
g_pOnBanClient = g_Forwards.CreateForward(
"OnBanClient",
ET_Event,
7,
@@ -63,7 +62,7 @@ public:
Param_String,
Param_String,
Param_Cell);
g_pOnBanIdentity = forwardsys->CreateForward(
g_pOnBanIdentity = g_Forwards.CreateForward(
"OnBanIdentity",
ET_Event,
6,
@@ -74,7 +73,7 @@ public:
Param_String,
Param_String,
Param_Cell);
g_pOnRemoveBan = forwardsys->CreateForward(
g_pOnRemoveBan = g_Forwards.CreateForward(
"OnRemoveBan",
ET_Event,
4,
@@ -86,9 +85,9 @@ public:
}
void OnSourceModShutdown()
{
forwardsys->ReleaseForward(g_pOnBanClient);
forwardsys->ReleaseForward(g_pOnBanIdentity);
forwardsys->ReleaseForward(g_pOnRemoveBan);
g_Forwards.ReleaseForward(g_pOnBanClient);
g_Forwards.ReleaseForward(g_pOnBanIdentity);
g_Forwards.ReleaseForward(g_pOnRemoveBan);
g_pOnBanClient = NULL;
g_pOnBanIdentity = NULL;
@@ -119,7 +118,7 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
/* Sanitize the input */
char identity[64];
strncopy(identity, r_identity, sizeof(identity));
UTIL_ReplaceAll(identity, sizeof(identity), ";", "", true);
UTIL_ReplaceAll(identity, sizeof(identity), ";", "");
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnBanIdentity->GetFunctionCount() > 0)
@@ -140,7 +139,7 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
char command[256];
if (ban_by_ip)
{
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"addip %d %s\n",
@@ -153,9 +152,9 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
engine->ServerCommand("writeip\n");
}
}
else if (!gamehelpers->IsLANServer())
else if (!g_HL2.IsLANServer())
{
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"banid %d %s\n",
@@ -196,7 +195,7 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
char identity[64];
strncopy(identity, r_identity, sizeof(identity));
UTIL_ReplaceAll(identity, sizeof(identity), ";", "", true);
UTIL_ReplaceAll(identity, sizeof(identity), ";", "");
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnRemoveBan->GetFunctionCount() > 0)
@@ -213,7 +212,7 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
{
if (!handled)
{
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"removeip %s\n",
@@ -222,11 +221,11 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
engine->ServerCommand("writeip\n");
}
}
else if (!gamehelpers->IsLANServer())
else if (!g_HL2.IsLANServer())
{
if (!handled)
{
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"removeid %s\n",
@@ -249,9 +248,9 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
char *ban_reason, *ban_cmd;
int client, ban_flags, ban_source, ban_time;
client = gamehelpers->ReferenceToIndex(params[1]);
client = g_HL2.ReferenceToIndex(params[1]);
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer || !pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client index %d is invalid", client);
@@ -269,16 +268,11 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
ban_flags = params[3];
ban_source = params[7];
#if SOURCE_ENGINE != SE_DARKMESSIAH
/* Check how we should ban the player */
if (!strcmp(smcore.GetSourceEngineName(), "darkmessiah"))
if ((ban_flags & BANFLAG_AUTO) == BANFLAG_AUTO)
{
/* Dark Messiah doesn't have Steam IDs so there is only one ban method to choose */
ban_flags |= BANFLAG_IP;
ban_flags &= ~BANFLAG_AUTHID;
}
else if ((ban_flags & BANFLAG_AUTO) == BANFLAG_AUTO)
{
if (gamehelpers->IsLANServer() || !pPlayer->IsAuthorized())
if (g_HL2.IsLANServer() || !pPlayer->IsAuthorized())
{
ban_flags |= BANFLAG_IP;
ban_flags &= ~BANFLAG_AUTHID;
@@ -310,6 +304,11 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
{
return pContext->ThrowNativeError("No valid ban method flags specified");
}
#else
/* Dark Messiah doesn't have Steam IDs so there is only one ban method to choose */
ban_flags |= BANFLAG_IP;
ban_flags &= ~BANFLAG_AUTHID;
#endif
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnBanClient->GetFunctionCount() > 0)
@@ -336,7 +335,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
{
/* Get the IP address and strip the port */
char ip[24], *ptr;
smcore.strncopy(ip, pPlayer->GetIPAddress(), sizeof(ip));
strncopy(ip, pPlayer->GetIPAddress(), sizeof(ip));
if ((ptr = strchr(ip, ':')) != NULL)
{
*ptr = '\0';
@@ -344,7 +343,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
/* Tell the server to ban the ip */
char command[256];
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"addip %d %s\n",
@@ -368,7 +367,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
{
/* Tell the server to ban the auth string */
char command[256];
smcore.Format(
UTIL_Format(
command,
sizeof(command),
"banid %d %s\n",
@@ -378,7 +377,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
/* Kick, then ban */
if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK)
{
gamehelpers->AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
g_HL2.AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
}
engine->ServerCommand(command);
@@ -391,7 +390,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
}
else if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK)
{
gamehelpers->AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
g_HL2.AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
}
+67 -196
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -43,18 +43,10 @@
#include <inetchannel.h>
#include <bitbuf.h>
#include <sm_trie_tpl.h>
#include <tier0/dbg.h>
#include "Logger.h"
#include "ConsoleDetours.h"
#include "ConCommandBaseIterator.h"
#if SOURCE_ENGINE >= SE_EYE
#define NETMSG_BITS 6
#else
#define NETMSG_BITS 5
#endif
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
#define NET_SETCONVAR 6
#else
#define NET_SETCONVAR 5
@@ -75,6 +67,15 @@ struct GlobCmdIter
List<ConCmdInfo *>::iterator iter;
};
struct ConCmdIter
{
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
ICvarIteratorInternal *pLast;
#else
const ConCommandBase *pLast;
#endif
};
class ConsoleHelpers :
public SMGlobalClass,
public IHandleTypeDispatch
@@ -101,7 +102,11 @@ public:
}
else if (type == htConCmdIter)
{
ConCommandBaseIterator *iter = (ConCommandBaseIterator * )object;
ConCmdIter *iter = (ConCmdIter * )object;
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
// ICvarIteratorInternal has no virtual destructor
g_pMemAlloc->Free(iter->pLast);
#endif
delete iter;
}
}
@@ -109,7 +114,7 @@ public:
{
if (type == htConCmdIter)
{
*pSize = sizeof(ConCommandBaseIterator);
*pSize = sizeof(ConCmdIter);
return true;
}
else if (type == hCmdIterType)
@@ -176,7 +181,7 @@ private:
KTrie<ConCommandBase *> m_CmdFlags;
} s_CommandFlagsHelper;
#if SOURCE_ENGINE < SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
static void ReplicateConVar(ConVar *pConVar)
{
int maxClients = g_Players.GetMaxClients();
@@ -184,7 +189,7 @@ static void ReplicateConVar(ConVar *pConVar)
char data[256];
bf_write buffer(data, sizeof(data));
buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
buffer.WriteUBitLong(NET_SETCONVAR, 5);
buffer.WriteByte(1);
buffer.WriteString(pConVar->GetName());
buffer.WriteString(pConVar->GetString());
@@ -350,7 +355,7 @@ static cell_t sm_SetConVarNum(IPluginContext *pContext, const cell_t *params)
pConVar->SetValue(params[2]);
#if SOURCE_ENGINE < SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
/* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{
@@ -399,7 +404,7 @@ static cell_t sm_SetConVarFloat(IPluginContext *pContext, const cell_t *params)
float value = sp_ctof(params[2]);
pConVar->SetValue(value);
#if SOURCE_ENGINE < SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
/* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{
@@ -450,7 +455,7 @@ static cell_t sm_SetConVarString(IPluginContext *pContext, const cell_t *params)
pConVar->SetValue(value);
#if SOURCE_ENGINE < SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
/* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{
@@ -481,7 +486,7 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params)
pConVar->Revert();
#if SOURCE_ENGINE < SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
/* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{
@@ -498,24 +503,6 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t GetConVarDefault(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
ConVar *pConVar;
if ((err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err);
}
size_t bytes;
pContext->StringToLocalUTF8(params[2], params[3], pConVar->GetDefault(), &bytes);
return bytes;
}
static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
@@ -683,7 +670,8 @@ static cell_t sm_RegServerCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0)
{
return pContext->ThrowNativeError("Cannot register \"sm\" command");
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0;
}
pContext->LocalToString(params[3], &help);
@@ -711,7 +699,8 @@ static cell_t sm_RegConsoleCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0)
{
return pContext->ThrowNativeError("Cannot register \"sm\" command");
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0;
}
pContext->LocalToString(params[3], &help);
@@ -742,7 +731,8 @@ static cell_t sm_RegAdminCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0)
{
return pContext->ThrowNativeError("Cannot register \"sm\" command");
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0;
}
pContext->LocalToString(params[4], &help);
@@ -902,124 +892,6 @@ static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params)
return 1;
}
char *g_ServerCommandBuffer = NULL;
cell_t g_ServerCommandBufferLength;
bool g_ShouldCatchSpew = false;
#if SOURCE_ENGINE < SE_LEFT4DEAD2
SpewOutputFunc_t g_OriginalSpewOutputFunc = NULL;
SpewRetval_t SourcemodSpewOutputFunc(SpewType_t spewType, tchar const *pMsg)
{
if (g_ServerCommandBuffer)
{
V_strcat(g_ServerCommandBuffer, pMsg, g_ServerCommandBufferLength);
}
if (g_OriginalSpewOutputFunc)
{
return g_OriginalSpewOutputFunc(spewType, pMsg);
} else {
return SPEW_CONTINUE;
}
}
#else
class CSourcemodLoggingListener: public ILoggingListener
{
public:
void Log(const LoggingContext_t *pContext, const tchar *pMessage)
{
if (g_ServerCommandBuffer)
{
V_strcat(g_ServerCommandBuffer, pMessage, g_ServerCommandBufferLength);
}
}
} g_SourcemodLoggingListener;
#endif
CON_COMMAND(sm_conhook_start, "")
{
if (!g_ShouldCatchSpew)
{
Warning("You shouldn't run this command!\n");
return;
}
#if SOURCE_ENGINE < SE_LEFT4DEAD2
g_OriginalSpewOutputFunc = GetSpewOutputFunc();
SpewOutputFunc(SourcemodSpewOutputFunc);
#else
#if SOURCE_ENGINE < SE_ALIENSWARM
LoggingSystem_PushLoggingState(false);
#else
LoggingSystem_PushLoggingState(false, false);
#endif
LoggingSystem_RegisterLoggingListener(&g_SourcemodLoggingListener);
#endif
}
CON_COMMAND(sm_conhook_stop, "")
{
if (!g_ShouldCatchSpew)
{
Warning("You shouldn't run this command!\n");
return;
}
#if SOURCE_ENGINE < SE_LEFT4DEAD2
SpewOutputFunc(g_OriginalSpewOutputFunc);
#else
LoggingSystem_PopLoggingState(false);
#endif
g_ShouldCatchSpew = false;
}
static cell_t sm_ServerCommandEx(IPluginContext *pContext, const cell_t *params)
{
g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 3);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* One byte for null terminator, one for newline */
buffer[len++] = '\n';
buffer[len] = '\0';
pContext->LocalToString(params[1], &g_ServerCommandBuffer);
g_ServerCommandBufferLength = params[2];
if (g_ServerCommandBufferLength > 0)
{
g_ServerCommandBuffer[0] = '\0';
}
engine->ServerExecute();
g_ShouldCatchSpew = true;
engine->ServerCommand("sm_conhook_start\n");
engine->ServerCommand(buffer);
engine->ServerCommand("sm_conhook_stop\n");
engine->ServerExecute();
if (g_ServerCommandBufferLength > 0)
{
g_ServerCommandBuffer[g_ServerCommandBufferLength-1] = '\0';
}
g_ServerCommandBuffer = NULL;
g_ServerCommandBufferLength = 0;
return 1;
}
static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
@@ -1265,7 +1137,7 @@ static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
/* Auto-detect a command if we can */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
@@ -1278,28 +1150,7 @@ static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
g_Admins.GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckClientCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t CheckAccess(IPluginContext *pContext, const cell_t *params)
{
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = g_ConCmds.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
g_Admins.GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckAdminCommandAccess(params[1], cmd, bits) ? 1 : 0;
return g_ConCmds.CheckCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
@@ -1327,7 +1178,7 @@ static cell_t GetCommandFlags(IPluginContext *pContext, const cell_t *params)
static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl;
ConCommandBaseIterator *pIter;
ConCmdIter *pIter;
cell_t *pIsCmd, *pFlags;
const ConCommandBase *pConCmd;
const char *desc;
@@ -1335,15 +1186,21 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
pContext->LocalToPhysAddr(params[3], &pIsCmd);
pContext->LocalToPhysAddr(params[4], &pFlags);
pIter = new ConCommandBaseIterator();
if (!pIter->IsValid())
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
ICvarIteratorInternal *cvarIter = icvar->FactoryInternalIterator();
cvarIter->SetFirst();
if (!cvarIter->IsValid())
{
delete pIter;
return BAD_HANDLE;
}
pConCmd = pIter->Get();
pConCmd = cvarIter->Get();
#else
pConCmd = icvar->GetCommands();
if (pConCmd == NULL)
{
return BAD_HANDLE;
}
#endif
pContext->StringToLocalUTF8(params[1], params[2], pConCmd->GetName(), NULL);
*pIsCmd = pConCmd->IsCommand() ? 1 : 0;
@@ -1355,6 +1212,13 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
pContext->StringToLocalUTF8(params[5], params[6], (desc && desc[0]) ? desc : "", NULL);
}
pIter = new ConCmdIter;
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
pIter->pLast = cvarIter;
#else
pIter->pLast = pConCmd;
#endif
if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL))
== BAD_HANDLE)
{
@@ -1368,7 +1232,7 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params)
{
HandleError err;
ConCommandBaseIterator *pIter;
ConCmdIter *pIter;
cell_t *pIsCmd, *pFlags;
const char *desc;
const ConCommandBase *pConCmd;
@@ -1379,17 +1243,27 @@ static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
}
if (!pIter->IsValid())
if (pIter->pLast == NULL)
{
return 0;
}
pIter->Next();
if (!pIter->IsValid())
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
ICvarIteratorInternal *cvarIter = pIter->pLast;
cvarIter->Next();
if (!cvarIter->IsValid())
{
return 0;
}
pConCmd = pIter->Get();
pConCmd = cvarIter->Get();
#else
pConCmd = pIter->pLast->GetNext();
if (pConCmd == NULL)
{
return 0;
}
pIter->pLast = pConCmd;
#endif
pContext->LocalToPhysAddr(params[4], &pIsCmd);
pContext->LocalToPhysAddr(params[5], &pFlags);
@@ -1425,7 +1299,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
char data[256];
bf_write buffer(data, sizeof(data));
buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
buffer.WriteUBitLong(NET_SETCONVAR, 5);
buffer.WriteByte(1);
buffer.WriteString(pConVar->GetName());
buffer.WriteString(value);
@@ -1529,7 +1403,6 @@ REGISTER_NATIVES(consoleNatives)
{"GetConVarBounds", sm_GetConVarBounds},
{"SetConVarBounds", sm_SetConVarBounds},
{"QueryClientConVar", sm_QueryClientConVar},
{"GetConVarDefault", GetConVarDefault},
{"RegServerCmd", sm_RegServerCmd},
{"RegConsoleCmd", sm_RegConsoleCmd},
{"GetCmdArgString", sm_GetCmdArgString},
@@ -1539,7 +1412,6 @@ REGISTER_NATIVES(consoleNatives)
{"PrintToConsole", sm_PrintToConsole},
{"RegAdminCmd", sm_RegAdminCmd},
{"ServerCommand", sm_ServerCommand},
{"ServerCommandEx", sm_ServerCommandEx},
{"InsertServerCommand", sm_InsertServerCommand},
{"ServerExecute", sm_ServerExecute},
{"ClientCommand", sm_ClientCommand},
@@ -1550,7 +1422,6 @@ REGISTER_NATIVES(consoleNatives)
{"GetCommandIterator", GetCommandIterator},
{"ReadCommandIterator", ReadCommandIterator},
{"CheckCommandAccess", CheckCommandAccess},
{"CheckAccess", CheckAccess},
{"FakeClientCommandEx", FakeClientCommandEx},
{"IsChatTrigger", IsChatTrigger},
{"SetCommandFlags", SetCommandFlags},
+5 -75
View File
@@ -46,7 +46,7 @@
#if defined PLATFORM_WINDOWS
#include <windows.h>
#elif defined PLATFORM_POSIX
#elif defined PLATFORM_LINUX
#include <limits.h>
#include <unistd.h>
#include <sys/times.h>
@@ -407,7 +407,7 @@ static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params)
{
#if defined PLATFORM_WINDOWS
return (cell_t)GetTickCount();
#elif defined PLATFORM_POSIX
#elif defined PLATFORM_LINUX
tms tm;
clock_t ticks = times(&tm);
long ticks_per_sec = sysconf(_SC_CLK_TCK);
@@ -419,6 +419,9 @@ static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params)
fticks -= r;
}
return (cell_t)fticks;
#elif defined PLATFORM_APPLE
assert(false);
return 0;
#endif
}
@@ -670,77 +673,6 @@ static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
return 1;
}
enum NumberType
{
NumberType_Int8,
NumberType_Int16,
NumberType_Int32
};
//memory addresses below 0x10000 are automatically considered invalid for dereferencing
#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params)
{
void *addr = reinterpret_cast<void*>(params[1]);
if (addr == NULL)
{
pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
NumberType size = static_cast<NumberType>(params[2]);
switch(size)
{
case NumberType_Int8:
return *reinterpret_cast<uint8_t*>(addr);
case NumberType_Int16:
return *reinterpret_cast<uint16_t*>(addr);
case NumberType_Int32:
return *reinterpret_cast<uint32_t*>(addr);
default:
pContext->ThrowNativeError("Invalid number types %d", size);
}
return 1;
}
static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
{
void *addr = reinterpret_cast<void*>(params[1]);
if (addr == NULL)
{
pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
cell_t data = params[2];
NumberType size = static_cast<NumberType>(params[3]);
switch(size)
{
case NumberType_Int8:
*reinterpret_cast<uint8_t*>(addr) = data;
case NumberType_Int16:
*reinterpret_cast<uint16_t*>(addr) = data;
case NumberType_Int32:
*reinterpret_cast<uint32_t*>(addr) = data;
default:
pContext->ThrowNativeError("Invalid number types %d", size);
}
return 1;
}
REGISTER_NATIVES(coreNatives)
{
{"AutoExecConfig", AutoExecConfig},
@@ -767,8 +699,6 @@ REGISTER_NATIVES(coreNatives)
{"VerifyCoreVersion", VerifyCoreVersion},
{"GetFeatureStatus", GetFeatureStatus},
{"RequireFeature", RequireFeature},
{"LoadFromAddress", LoadFromAddress},
{"StoreToAddress", StoreToAddress},
{NULL, NULL},
};
+21 -81
View File
@@ -36,15 +36,9 @@
#include "PluginSys.h"
#include "sm_stringutil.h"
HandleType_t hQueryType;
HandleType_t hStmtType;
HandleType_t hCombinedQueryType;
typedef struct
{
IQuery *query;
IDatabase *db;
} CombinedQuery;
class DatabaseHelpers :
public SMGlobalClass,
public IHandleTypeDispatch
@@ -63,23 +57,22 @@ public:
g_HandleSys.InitAccessDefaults(&tacc, NULL);
tacc.ident = g_pCoreIdent;
hCombinedQueryType = g_HandleSys.CreateType("IQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL);
hStmtType = g_HandleSys.CreateType("IPreparedQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL);
hQueryType = g_HandleSys.CreateType("IQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL);
hStmtType = g_HandleSys.CreateType("IPreparedQuery", this, hQueryType, &tacc, &acc, g_pCoreIdent, NULL);
}
virtual void OnSourceModShutdown()
{
g_HandleSys.RemoveType(hStmtType, g_pCoreIdent);
g_HandleSys.RemoveType(hCombinedQueryType, g_pCoreIdent);
g_HandleSys.RemoveType(hQueryType, g_pCoreIdent);
}
virtual void OnHandleDestroy(HandleType_t type, void *object)
{
if (type == hCombinedQueryType)
if (type == hQueryType)
{
CombinedQuery *combined = (CombinedQuery *)object;
combined->query->Destroy();
delete combined;
IQuery *query = (IQuery *)object;
query->Destroy();
} else if (type == hStmtType) {
IPreparedQuery *query = (IPreparedQuery *)object;
query->Destroy();
@@ -91,37 +84,10 @@ public:
inline HandleError ReadQueryHndl(Handle_t hndl, IPluginContext *pContext, IQuery **query)
{
HandleSecurity sec;
CombinedQuery *c;
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
HandleError ret;
if ((ret = g_HandleSys.ReadHandle(hndl, hStmtType, &sec, (void **)query)) != HandleError_None)
{
ret = g_HandleSys.ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c);
if (ret == HandleError_None)
{
*query = c->query;
}
}
return ret;
}
inline HandleError ReadQueryAndDbHndl(Handle_t hndl, IPluginContext *pContext, IQuery **query, IDatabase **db)
{
HandleSecurity sec;
CombinedQuery *c;
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
HandleError ret = g_HandleSys.ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c);
if (ret == HandleError_None)
{
*query = c->query;
*db = c->db;
}
return ret;
return g_HandleSys.ReadHandle(hndl, hQueryType, &sec, (void **)query);
}
inline HandleError ReadStmtHndl(Handle_t hndl, IPluginContext *pContext, IPreparedQuery **query)
@@ -226,17 +192,12 @@ public:
if (m_pQuery)
{
CombinedQuery *c = new CombinedQuery;
c->query = m_pQuery;
c->db = m_pDatabase;
qh = g_HandleSys.CreateHandle(hCombinedQueryType, c, me->GetIdentity(), g_pCoreIdent, NULL);
qh = g_HandleSys.CreateHandle(hQueryType, m_pQuery, me->GetIdentity(), g_pCoreIdent, NULL);
if (qh != BAD_HANDLE)
{
m_pQuery = NULL;
} else {
UTIL_Format(error, sizeof(error), "Could not alloc handle");
delete c;
}
}
@@ -576,59 +537,42 @@ static cell_t SQL_GetAffectedRows(IPluginContext *pContext, const cell_t *params
{
IDatabase *db = NULL;
IPreparedQuery *stmt = NULL;
IQuery *query = NULL;
HandleError err;
if (((err = ReadDbOrStmtHndl(params[1], pContext, &db, &stmt)) != HandleError_None)
&& ((err = ReadQueryAndDbHndl(params[1], pContext, &query, &db)) != HandleError_None))
if ((err = ReadDbOrStmtHndl(params[1], pContext, &db, &stmt)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid statement, db, or query Handle %x (error: %d)", params[1], err);
return pContext->ThrowNativeError("Invalid statement or db Handle %x (error: %d)", params[1], err);
}
if (stmt)
{
return stmt->GetAffectedRows();
}
else if (query)
{
return db->GetAffectedRowsForQuery(query);
}
else if (db)
if (db)
{
return db->GetAffectedRows();
} else if (stmt) {
return stmt->GetAffectedRows();
}
return pContext->ThrowNativeError("Unknown error reading db/stmt/query handles");
return pContext->ThrowNativeError("Unknown error reading db/stmt handles");
}
static cell_t SQL_GetInsertId(IPluginContext *pContext, const cell_t *params)
{
IDatabase *db = NULL;
IQuery *query = NULL;
IPreparedQuery *stmt = NULL;
HandleError err;
if (((err = ReadDbOrStmtHndl(params[1], pContext, &db, &stmt)) != HandleError_None)
&& ((err = ReadQueryAndDbHndl(params[1], pContext, &query, &db)) != HandleError_None))
if ((err = ReadDbOrStmtHndl(params[1], pContext, &db, &stmt)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid statement, db, or query Handle %x (error: %d)", params[1], err);
return pContext->ThrowNativeError("Invalid statement or db Handle %x (error: %d)", params[1], err);
}
if (query)
{
return db->GetInsertIDForQuery(query);
}
else if (db)
if (db)
{
return db->GetInsertID();
}
else if (stmt)
{
} else if (stmt) {
return stmt->GetInsertID();
}
return pContext->ThrowNativeError("Unknown error reading db/stmt/query handles");
return pContext->ThrowNativeError("Unknown error reading db/stmt handles");
}
static cell_t SQL_GetError(IPluginContext *pContext, const cell_t *params)
@@ -738,14 +682,10 @@ static cell_t SQL_Query(IPluginContext *pContext, const cell_t *params)
return BAD_HANDLE;
}
CombinedQuery *c = new CombinedQuery;
c->query = qr;
c->db = db;
Handle_t hndl = g_HandleSys.CreateHandle(hCombinedQueryType, c, pContext->GetIdentity(), g_pCoreIdent, NULL);
Handle_t hndl = g_HandleSys.CreateHandle(hQueryType, qr, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE)
{
qr->Destroy();
delete c;
return BAD_HANDLE;
}
@@ -1,8 +1,8 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -29,10 +29,9 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <IHandleSys.h>
#include <IDataPack.h>
#include <ISourceMod.h>
#include "sm_globals.h"
#include "HandleSys.h"
#include "CDataPack.h"
HandleType_t g_DataPackType;
@@ -46,35 +45,35 @@ public:
HandleAccess hacc;
TypeAccess tacc;
handlesys->InitAccessDefaults(&tacc, &hacc);
g_HandleSys.InitAccessDefaults(&tacc, &hacc);
tacc.access[HTypeAccess_Create] = true;
tacc.access[HTypeAccess_Inherit] = true;
tacc.ident = g_pCoreIdent;
hacc.access[HandleAccess_Read] = HANDLE_RESTRICT_OWNER;
g_DataPackType = handlesys->CreateType("DataPack", this, 0, &tacc, &hacc, g_pCoreIdent, NULL);
g_DataPackType = g_HandleSys.CreateType("DataPack", this, 0, &tacc, &hacc, g_pCoreIdent, NULL);
}
void OnSourceModShutdown()
{
handlesys->RemoveType(g_DataPackType, g_pCoreIdent);
g_HandleSys.RemoveType(g_DataPackType, g_pCoreIdent);
g_DataPackType = 0;
}
void OnHandleDestroy(HandleType_t type, void *object)
{
g_pSM->FreeDataPack(reinterpret_cast<IDataPack *>(object));
g_SourceMod.FreeDataPack(reinterpret_cast<IDataPack *>(object));
}
};
static cell_t smn_CreateDataPack(IPluginContext *pContext, const cell_t *params)
{
IDataPack *pDataPack = g_pSM->CreateDataPack();
IDataPack *pDataPack = g_SourceMod.CreateDataPack();
if (!pDataPack)
{
return 0;
}
return handlesys->CreateHandle(g_DataPackType, pDataPack, pContext->GetIdentity(), g_pCoreIdent, NULL);
return g_HandleSys.CreateHandle(g_DataPackType, pDataPack, pContext->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t smn_WritePackCell(IPluginContext *pContext, const cell_t *params)
@@ -87,7 +86,7 @@ static cell_t smn_WritePackCell(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -108,7 +107,7 @@ static cell_t smn_WritePackFloat(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -130,7 +129,7 @@ static cell_t smn_WritePackString(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -158,7 +157,7 @@ static cell_t smn_ReadPackCell(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -182,7 +181,7 @@ static cell_t smn_ReadPackFloat(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -206,7 +205,7 @@ static cell_t smn_ReadPackString(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -233,7 +232,7 @@ static cell_t smn_ResetPack(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -258,7 +257,7 @@ static cell_t smn_GetPackPosition(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -277,7 +276,7 @@ static cell_t smn_SetPackPosition(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@@ -301,7 +300,7 @@ static cell_t smn_IsPackReadable(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
+129 -586
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -34,47 +34,8 @@
#include "sourcemm_api.h"
#include "PlayerManager.h"
#include "HalfLife2.h"
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include "sm_stringutil.h"
#include "logic_bridge.h"
// These values need to mirror the values in entity_prop_stocks
#define ENTFLAG_ONGROUND (1 << 0)
#define ENTFLAG_DUCKING (1 << 1)
#define ENTFLAG_WATERJUMP (1 << 2)
#define ENTFLAG_ONTRAIN (1 << 3)
#define ENTFLAG_INRAIN (1 << 4)
#define ENTFLAG_FROZEN (1 << 5)
#define ENTFLAG_ATCONTROLS (1 << 6)
#define ENTFLAG_CLIENT (1 << 7)
#define ENTFLAG_FAKECLIENT (1 << 8)
#define ENTFLAG_INWATER (1 << 9)
#define ENTFLAG_FLY (1 << 10)
#define ENTFLAG_SWIM (1 << 11)
#define ENTFLAG_CONVEYOR (1 << 12)
#define ENTFLAG_NPC (1 << 13)
#define ENTFLAG_GODMODE (1 << 14)
#define ENTFLAG_NOTARGET (1 << 15)
#define ENTFLAG_AIMTARGET (1 << 16)
#define ENTFLAG_PARTIALGROUND (1 << 17)
#define ENTFLAG_STATICPROP (1 << 18)
#define ENTFLAG_GRAPHED (1 << 19)
#define ENTFLAG_GRENADE (1 << 20)
#define ENTFLAG_STEPMOVEMENT (1 << 21)
#define ENTFLAG_DONTTOUCH (1 << 22)
#define ENTFLAG_BASEVELOCITY (1 << 23)
#define ENTFLAG_WORLDBRUSH (1 << 24)
#define ENTFLAG_OBJECT (1 << 25)
#define ENTFLAG_KILLME (1 << 26)
#define ENTFLAG_ONFIRE (1 << 27)
#define ENTFLAG_DISSOLVING (1 << 28)
#define ENTFLAG_TRANSRAGDOLL (1 << 29)
#define ENTFLAG_UNBLOCKABLE_BY_PLAYER (1 << 30)
#define ENTFLAG_FREEZING (1 << 31)
#define ENTFLAG_EP2V_UNKNOWN1 (1 << 31)
// Not defined in the sdk as we have no clue what it is
#define FL_EP2V_UNKNOWN (1 << 2)
enum PropType
{
@@ -898,7 +859,7 @@ static cell_t FindDataMapOffs(IPluginContext *pContext, const cell_t *params)
}
}
return GetTypeDescOffs(td);
return td->fieldOffset[TD_OFFSET_NORMAL];
}
static cell_t GetEntDataString(IPluginContext *pContext, const cell_t *params)
@@ -967,94 +928,21 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
class_name); \
}
#define CHECK_SET_PROP_DATA_OFFSET() \
if (element < 0 || element >= td->fieldSize) \
{ \
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).", \
element, \
prop, \
td->fieldSize); \
} \
\
offset = GetTypeDescOffs(td) + (element * (td->fieldSizeInBytes / td->fieldSize));
#define FIND_PROP_SEND(type, type_name) \
sm_sendprop_info_t info;\
#define FIND_PROP_SEND(pProp) \
IServerUnknown *pUnk = (IServerUnknown *)pEntity; \
IServerNetworkable *pNet = pUnk->GetNetworkable(); \
if (!pNet) \
{ \
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]); \
} \
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info)) \
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, pProp)) \
{ \
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)", \
prop, \
params[1], \
class_name); \
} \
\
offset = info.actual_offset; \
bit_count = info.prop->m_nBits; \
\
switch (info.prop->GetType()) \
{ \
case type: \
{ \
if (element != 0) \
{ \
return pContext->ThrowNativeError("SendProp %s is not an array. Element %d is invalid.", \
prop, \
element); \
} \
break; \
} \
case DPT_DataTable: \
{ \
SendProp *pProp; \
FIND_PROP_SEND_IN_SENDTABLE(info, pProp, element, type, type_name); \
\
offset += pProp->GetOffset(); \
bit_count = pProp->m_nBits; \
break; \
} \
default: \
{ \
return pContext->ThrowNativeError("SendProp %s type is not " type_name " (%d != %d)", \
prop, \
info.prop->GetType(), \
type); \
} \
} \
#define FIND_PROP_SEND_IN_SENDTABLE(info, pProp, element, type, type_name) \
SendTable *pTable = info.prop->GetDataTable(); \
if (!pTable) \
{ \
return pContext->ThrowNativeError("Error looking up DataTable for prop %s", \
prop); \
} \
\
int elementCount = pTable->GetNumProps(); \
if (element < 0 || element >= elementCount) \
{ \
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).", \
element, \
prop, \
elementCount); \
} \
\
pProp = pTable->GetProp(element); \
if (pProp->GetType() != type) \
{ \
return pContext->ThrowNativeError("SendProp %s type is not " type_name " ([%d,%d] != %d)", \
prop, \
info.prop->GetType(), \
info.prop->m_nBits, \
type); \
}
inline int MatchFieldAsInteger(int field_type)
{
switch (field_type)
@@ -1078,75 +966,6 @@ inline int MatchFieldAsInteger(int field_type)
return 0;
}
static cell_t GetEntPropArraySize(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity;
char *prop;
const char *class_name;
edict_t *pEdict;
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
{
class_name = "";
}
pContext->LocalToString(params[3], &prop);
switch (params[2])
{
case Prop_Data:
{
typedescription_t *td;
FIND_PROP_DATA(td);
return td->fieldSize;
}
case Prop_Send:
{
sm_sendprop_info_t info;
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!pNet)
{
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
{
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
prop,
params[1],
class_name);
}
if (info.prop->GetType() != DPT_DataTable)
{
return 0;
}
SendTable *pTable = info.prop->GetDataTable();
if (!pTable)
{
return pContext->ThrowNativeError("Error looking up DataTable for prop %s", prop);
}
return pTable->GetNumProps();
}
default:
{
return pContext->ThrowNativeError("Invalid Property type %d", params[2]);
}
}
return 1;
}
static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity;
@@ -1155,13 +974,6 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
const char *class_name;
edict_t *pEdict;
int bit_count;
bool is_unsigned = false;
int element = 0;
if (params[0] >= 5)
{
element = params[5];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
@@ -1191,14 +1003,26 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
td->fieldType);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Int, "integer");
is_unsigned = ((info.prop->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED);
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Int)
{
return pContext->ThrowNativeError("SendProp %s is not an integer ([%d,%d] != %d)",
prop,
info.prop->GetType(),
info.prop->m_nBits,
DPT_Int);
}
bit_count = info.prop->m_nBits;
offset = info.actual_offset;
break;
}
default:
@@ -1218,25 +1042,11 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
}
else if (bit_count >= 9)
{
if (is_unsigned)
{
return *(uint16_t *)((uint8_t *)pEntity + offset);
}
else
{
return *(int16_t *)((uint8_t *)pEntity + offset);
}
return *(int16_t *)((uint8_t *)pEntity + offset);
}
else if (bit_count >= 2)
{
if (is_unsigned)
{
return *(uint8_t *)((uint8_t *)pEntity + offset);
}
else
{
return *(int8_t *)((uint8_t *)pEntity + offset);
}
return *(int8_t *)((uint8_t *)pEntity + offset);
}
else
{
@@ -1255,12 +1065,6 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params)
edict_t *pEdict;
int bit_count;
int element = 0;
if (params[0] >= 6)
{
element = params[6];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
@@ -1288,13 +1092,26 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params)
td->fieldType);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Int, "integer");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Int)
{
return pContext->ThrowNativeError("SendProp %s is not an integer ([%d,%d] != %d)",
prop,
info.prop->GetType(),
info.prop->m_nBits,
DPT_Int);
}
bit_count = info.prop->m_nBits;
offset = info.actual_offset;
break;
}
default:
@@ -1324,11 +1141,6 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params)
{
*(bool *)((uint8_t *)pEntity + offset) = params[4] ? true : false;
}
if (params[2] == Prop_Send && (pEdict != NULL))
{
g_HL2.SetEdictStateChanged(pEdict, offset);
}
return 0;
}
@@ -1338,16 +1150,9 @@ static cell_t GetEntPropFloat(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 4)
{
element = params[4];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
@@ -1378,13 +1183,24 @@ static cell_t GetEntPropFloat(IPluginContext *pContext, const cell_t *params)
FIELD_TIME);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Float, "float");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Float)
{
return pContext->ThrowNativeError("SendProp %s is not a float (%d != %d)",
prop,
info.prop->GetType(),
DPT_Float);
}
offset = info.actual_offset;
break;
}
default:
@@ -1403,16 +1219,9 @@ static cell_t SetEntPropFloat(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 5)
{
element = params[5];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
@@ -1443,13 +1252,24 @@ static cell_t SetEntPropFloat(IPluginContext *pContext, const cell_t *params)
FIELD_TIME);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Float, "float");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Float)
{
return pContext->ThrowNativeError("SendProp %s is not a float (%d != %d)",
prop,
info.prop->GetType(),
DPT_Float);
}
offset = info.actual_offset;
break;
}
default:
@@ -1473,16 +1293,9 @@ static cell_t GetEntPropEnt(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 4)
{
element = params[4];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
@@ -1511,13 +1324,24 @@ static cell_t GetEntPropEnt(IPluginContext *pContext, const cell_t *params)
FIELD_EHANDLE);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Int, "integer");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Int)
{
return pContext->ThrowNativeError("SendProp %s is not an integer (%d != %d)",
prop,
info.prop->GetType(),
DPT_Int);
}
offset = info.actual_offset;
break;
}
default:
@@ -1537,16 +1361,9 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 5)
{
element = params[5];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
@@ -1575,13 +1392,24 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
FIELD_EHANDLE);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Int, "integer");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Int)
{
return pContext->ThrowNativeError("SendProp %s is not an integer (%d != %d)",
prop,
info.prop->GetType(),
DPT_Int);
}
offset = info.actual_offset;
break;
}
default:
@@ -1622,15 +1450,8 @@ static cell_t GetEntPropVector(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 5)
{
element = params[5];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
@@ -1662,13 +1483,24 @@ static cell_t GetEntPropVector(IPluginContext *pContext, const cell_t *params)
FIELD_POSITION_VECTOR);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Vector, "vector");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Vector)
{
return pContext->ThrowNativeError("SendProp %s is not a vector (%d != %d)",
prop,
info.prop->GetType(),
DPT_Vector);
}
offset = info.actual_offset;
break;
}
default:
@@ -1694,15 +1526,8 @@ static cell_t SetEntPropVector(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pEntity;
char *prop;
int offset;
int bit_count;
const char *class_name;
edict_t *pEdict;
int element = 0;
if (params[0] >= 5)
{
element = params[5];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
@@ -1734,13 +1559,24 @@ static cell_t SetEntPropVector(IPluginContext *pContext, const cell_t *params)
FIELD_POSITION_VECTOR);
}
CHECK_SET_PROP_DATA_OFFSET();
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
FIND_PROP_SEND(DPT_Vector, "vector");
sm_sendprop_info_t info;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_Vector)
{
return pContext->ThrowNativeError("SendProp %s is not a vector (%d != %d)",
prop,
info.prop->GetType(),
DPT_Vector);
}
offset = info.actual_offset;
break;
}
default:
@@ -1774,12 +1610,6 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params)
const char *class_name;
edict_t *pEdict;
bool bIsStringIndex;
int element = 0;
if (params[0] >= 6)
{
element = params[6];
}
if (!IndexToAThings(params[1], &pEntity, &pEdict))
{
@@ -1816,46 +1646,14 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params)
bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
if (bIsStringIndex && (element < 0 || element >= td->fieldSize))
{
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).",
element,
prop,
td->fieldSize);
}
else if (element != 0)
{
return pContext->ThrowNativeError("Prop %s is not an array. Element %d is invalid.",
prop,
element);
}
offset = GetTypeDescOffs(td);
if (bIsStringIndex)
{
offset += (element * (td->fieldSizeInBytes / td->fieldSize));
}
offset = td->fieldOffset[TD_OFFSET_NORMAL];
break;
}
case Prop_Send:
{
sm_sendprop_info_t info;
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!pNet)
{
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
{
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
prop,
params[1],
class_name);
}
offset = info.actual_offset;
FIND_PROP_SEND(&info);
if (info.prop->GetType() != DPT_String)
{
@@ -1864,13 +1662,9 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params)
info.prop->GetType(),
DPT_String);
}
else if (element != 0)
{
return pContext->ThrowNativeError("SendProp %s is not an array. Element %d is invalid.",
prop,
element);
}
offset = info.actual_offset;
break;
break;
}
default:
@@ -1931,7 +1725,7 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params)
{
return pContext->ThrowNativeError("Property \"%s\" is not a valid string", prop);
}
offset = GetTypeDescOffs(td);
offset = td->fieldOffset[TD_OFFSET_NORMAL];
maxlen = td->fieldSize;
break;
}
@@ -1978,254 +1772,6 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params)
return len;
}
static int32_t SDKEntFlagToSMEntFlag(int flag)
{
switch (flag)
{
case FL_ONGROUND:
return ENTFLAG_ONGROUND;
case FL_DUCKING:
return ENTFLAG_DUCKING;
case FL_WATERJUMP:
return ENTFLAG_WATERJUMP;
case FL_ONTRAIN:
return ENTFLAG_ONTRAIN;
case FL_INRAIN:
return ENTFLAG_INRAIN;
case FL_FROZEN:
return ENTFLAG_FROZEN;
case FL_ATCONTROLS:
return ENTFLAG_ATCONTROLS;
case FL_CLIENT:
return ENTFLAG_CLIENT;
case FL_FAKECLIENT:
return ENTFLAG_FAKECLIENT;
case FL_INWATER:
return ENTFLAG_INWATER;
case FL_FLY:
return ENTFLAG_FLY;
case FL_SWIM:
return ENTFLAG_SWIM;
case FL_CONVEYOR:
return ENTFLAG_CONVEYOR;
case FL_NPC:
return ENTFLAG_NPC;
case FL_GODMODE:
return ENTFLAG_GODMODE;
case FL_NOTARGET:
return ENTFLAG_NOTARGET;
case FL_AIMTARGET:
return ENTFLAG_AIMTARGET;
case FL_PARTIALGROUND:
return ENTFLAG_PARTIALGROUND;
case FL_STATICPROP:
return ENTFLAG_STATICPROP;
case FL_GRAPHED:
return ENTFLAG_GRAPHED;
case FL_GRENADE:
return ENTFLAG_GRENADE;
case FL_STEPMOVEMENT:
return ENTFLAG_STEPMOVEMENT;
case FL_DONTTOUCH:
return ENTFLAG_DONTTOUCH;
case FL_BASEVELOCITY:
return ENTFLAG_BASEVELOCITY;
case FL_WORLDBRUSH:
return ENTFLAG_WORLDBRUSH;
case FL_OBJECT:
return ENTFLAG_OBJECT;
case FL_KILLME:
return ENTFLAG_KILLME;
case FL_ONFIRE:
return ENTFLAG_ONFIRE;
case FL_DISSOLVING:
return ENTFLAG_DISSOLVING;
case FL_TRANSRAGDOLL:
return ENTFLAG_TRANSRAGDOLL;
case FL_UNBLOCKABLE_BY_PLAYER:
return ENTFLAG_UNBLOCKABLE_BY_PLAYER;
#if SOURCE_ENGINE == SE_ALIENSWARM
case FL_FREEZING:
return ENTFLAG_FREEZING;
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
case FL_EP2V_UNKNOWN:
return ENTFLAG_EP2V_UNKNOWN1;
#endif
default:
return 0;
}
}
static int32_t SMEntFlagToSDKEntFlag(int32_t flag)
{
switch (flag)
{
case ENTFLAG_ONGROUND:
return FL_ONGROUND;
case ENTFLAG_DUCKING:
return FL_DUCKING;
case ENTFLAG_WATERJUMP:
return FL_WATERJUMP;
case ENTFLAG_ONTRAIN:
return FL_ONTRAIN;
case ENTFLAG_INRAIN:
return FL_INRAIN;
case ENTFLAG_FROZEN:
return FL_FROZEN;
case ENTFLAG_ATCONTROLS:
return FL_ATCONTROLS;
case ENTFLAG_CLIENT:
return FL_CLIENT;
case ENTFLAG_FAKECLIENT:
return FL_FAKECLIENT;
case ENTFLAG_INWATER:
return FL_INWATER;
case ENTFLAG_FLY:
return FL_FLY;
case ENTFLAG_SWIM:
return FL_SWIM;
case ENTFLAG_CONVEYOR:
return FL_CONVEYOR;
case ENTFLAG_NPC:
return FL_NPC;
case ENTFLAG_GODMODE:
return FL_GODMODE;
case ENTFLAG_NOTARGET:
return FL_NOTARGET;
case ENTFLAG_AIMTARGET:
return FL_AIMTARGET;
case ENTFLAG_PARTIALGROUND:
return FL_PARTIALGROUND;
case ENTFLAG_STATICPROP:
return FL_STATICPROP;
case ENTFLAG_GRAPHED:
return FL_GRAPHED;
case ENTFLAG_GRENADE:
return FL_GRENADE;
case ENTFLAG_STEPMOVEMENT:
return FL_STEPMOVEMENT;
case ENTFLAG_DONTTOUCH:
return FL_DONTTOUCH;
case ENTFLAG_BASEVELOCITY:
return FL_BASEVELOCITY;
case ENTFLAG_WORLDBRUSH:
return FL_WORLDBRUSH;
case ENTFLAG_OBJECT:
return FL_OBJECT;
case ENTFLAG_KILLME:
return FL_KILLME;
case ENTFLAG_ONFIRE:
return FL_ONFIRE;
case ENTFLAG_DISSOLVING:
return FL_DISSOLVING;
case ENTFLAG_TRANSRAGDOLL:
return FL_TRANSRAGDOLL;
case ENTFLAG_UNBLOCKABLE_BY_PLAYER:
return FL_UNBLOCKABLE_BY_PLAYER;
#if SOURCE_ENGINE == SE_ALIENSWARM
case ENTFLAG_FREEZING:
return FL_FREEZING;
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
case ENTFLAG_EP2V_UNKNOWN1:
return FL_EP2V_UNKNOWN;
#endif
default:
return 0;
}
}
static cell_t GetEntityFlags(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity = g_HL2.ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
const char *prop = g_pGameConf->GetKeyValue("m_fFlags");
if (!prop)
{
return pContext->ThrowNativeError("Could not find m_fFlags prop in gamedata");
}
typedescription_t *td;
datamap_t *pMap;
if ((pMap = CBaseEntity_GetDataDescMap(pEntity)) == NULL)
{
return pContext->ThrowNativeError("Could not retrieve datamap");
}
if ((td = g_HL2.FindInDataMap(pMap, prop)) == NULL)
{
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d)",
prop,
params[1]);
}
int offset = GetTypeDescOffs(td);
int32_t actual_flags = *(int32_t *)((uint8_t *)pEntity + offset);
int32_t sm_flags = 0;
for (int32_t i = 0; i < 32; i++)
{
int32_t flag = (1<<i);
if ((actual_flags & flag) == flag)
{
sm_flags |= SDKEntFlagToSMEntFlag(flag);
}
}
return sm_flags;
}
static cell_t SetEntityFlags(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity = g_HL2.ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
const char *prop = g_pGameConf->GetKeyValue("m_fFlags");
if (!prop)
{
return pContext->ThrowNativeError("Could not find m_fFlags prop in gamedata");
}
typedescription_t *td;
datamap_t *pMap;
if ((pMap = CBaseEntity_GetDataDescMap(pEntity)) == NULL)
{
return pContext->ThrowNativeError("Could not retrieve datamap");
}
if ((td = g_HL2.FindInDataMap(pMap, prop)) == NULL)
{
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d)",
prop,
params[1]);
}
int offset = GetTypeDescOffs(td);
int32_t sm_flags = params[2];
int32_t actual_flags = 0;
for (int32_t i = 0; i < 32; i++)
{
int32_t flag = (1<<i);
if ((sm_flags & flag) == flag)
{
actual_flags |= SMEntFlagToSDKEntFlag(flag);
}
}
*(int32_t *)((uint8_t *)pEntity + offset) = actual_flags;
return 0;
}
REGISTER_NATIVES(entityNatives)
{
{"ChangeEdictState", ChangeEdictState},
@@ -2242,13 +1788,11 @@ REGISTER_NATIVES(entityNatives)
{"GetEntDataString", GetEntDataString},
{"GetEntDataVector", GetEntDataVector},
{"GetEntProp", GetEntProp},
{"GetEntPropArraySize", GetEntPropArraySize},
{"GetEntPropEnt", GetEntPropEnt},
{"GetEntPropFloat", GetEntPropFloat},
{"GetEntPropString", GetEntPropString},
{"GetEntPropVector", GetEntPropVector},
{"GetEntityCount", GetEntityCount},
{"GetEntityFlags", GetEntityFlags},
{"GetEntityNetClass", GetEntityNetClass},
{"GetMaxEntities", GetMaxEntities},
{"IsEntNetworkable", IsEntNetworkable},
@@ -2262,7 +1806,6 @@ REGISTER_NATIVES(entityNatives)
{"SetEntDataFloat", SetEntDataFloat},
{"SetEntDataVector", SetEntDataVector},
{"SetEntDataString", SetEntDataString},
{"SetEntityFlags", SetEntityFlags},
{"SetEntProp", SetEntProp},
{"SetEntPropEnt", SetEntPropEnt},
{"SetEntPropFloat", SetEntPropFloat},
@@ -29,24 +29,24 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <IHandleSys.h>
#include "sourcemod.h"
#include "HandleSys.h"
#include "GameConfigs.h"
HandleType_t g_GameConfigsType;
class GameConfigsNatives :
public IHandleTypeDispatch,
public SMGlobalClass
public SourceModBase
{
public:
void OnSourceModAllInitialized()
{
g_GameConfigsType = handlesys->CreateType("GameConfigs", this, 0, NULL, NULL, g_pCoreIdent, NULL);
g_GameConfigsType = g_HandleSys.CreateType("GameConfigs", this, 0, NULL, NULL, g_pCoreIdent, NULL);
}
void OnSourceModShutdown()
{
handlesys->RemoveType(g_GameConfigsType, g_pCoreIdent);
g_HandleSys.RemoveType(g_GameConfigsType, g_pCoreIdent);
g_GameConfigsType = 0;
}
void OnHandleDestroy(HandleType_t type, void *object)
@@ -67,7 +67,7 @@ static cell_t smn_LoadGameConfigFile(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Unable to open %s: %s", filename, error);
}
return handlesys->CreateHandle(g_GameConfigsType, gc, pCtx->GetIdentity(), g_pCoreIdent, NULL);
return g_HandleSys.CreateHandle(g_GameConfigsType, gc, pCtx->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t smn_GameConfGetOffset(IPluginContext *pCtx, const cell_t *params)
@@ -80,7 +80,7 @@ static cell_t smn_GameConfGetOffset(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc))
if ((herr=g_HandleSys.ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid game config handle %x (error %d)", hndl, herr);
@@ -108,7 +108,7 @@ static cell_t smn_GameConfGetKeyValue(IPluginContext *pCtx, const cell_t *params
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc))
if ((herr=g_HandleSys.ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid game config handle %x (error %d)", hndl, herr);
@@ -128,33 +128,6 @@ static cell_t smn_GameConfGetKeyValue(IPluginContext *pCtx, const cell_t *params
return 1;
}
static cell_t smn_GameConfGetAddress(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
IGameConfig *gc;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid game config handle %x (error %d)", hndl, herr);
}
char *key;
void* val;
pCtx->LocalToString(params[2], &key);
if (!gc->GetAddress(key, &val))
return 0;
return (cell_t)val;
}
static GameConfigsNatives s_GameConfigsNatives;
REGISTER_NATIVES(gameconfignatives)
@@ -162,6 +135,5 @@ REGISTER_NATIVES(gameconfignatives)
{"LoadGameConfigFile", smn_LoadGameConfigFile},
{"GameConfGetOffset", smn_GameConfGetOffset},
{"GameConfGetKeyValue", smn_GameConfGetKeyValue},
{"GameConfGetAddress", smn_GameConfGetAddress},
{NULL, NULL}
};
+2 -13
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -73,7 +73,7 @@ static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params)
static cell_t GetEngineTime(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
#if SOURCE_ENGINE == SE_LEFT4DEAD2
float fTime = Plat_FloatTime();
#else
float fTime = engine->Time();
@@ -89,11 +89,6 @@ static cell_t GetGameTime(IPluginContext *pContext, const cell_t *params)
static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params)
{
if (!g_SourceMod.IsMapRunning())
{
return pContext->ThrowNativeError("Cannot create fakeclient when no map is active");
}
char *netname;
pContext->LocalToString(params[1], &netname);
@@ -464,18 +459,12 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
return 15;
case SOURCE_ENGINE_ORANGEBOX:
return 30;
case SOURCE_ENGINE_BLOODYGOODTIME:
return 32;
case SOURCE_ENGINE_EYE:
return 33;
case SOURCE_ENGINE_ORANGEBOXVALVE:
return 35;
case SOURCE_ENGINE_LEFT4DEAD:
return 40;
case SOURCE_ENGINE_LEFT4DEAD2:
return 50;
case SOURCE_ENGINE_ALIENSWARM:
return 60;
# endif
}
#else
@@ -29,17 +29,15 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <IHandleSys.h>
#include <IPluginSys.h>
using namespace SourceMod;
#include "sm_globals.h"
#include "HandleSys.h"
#include "PluginSys.h"
static cell_t sm_IsValidHandle(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err = handlesys->ReadHandle(hndl, 0, NULL, NULL);
HandleError err = g_HandleSys.ReadHandle(hndl, 0, NULL, NULL);
if (err != HandleError_Access
&& err != HandleError_None)
@@ -58,7 +56,7 @@ static cell_t sm_CloseHandle(IPluginContext *pContext, const cell_t *params)
sec.pIdentity = NULL;
sec.pOwner = pContext->GetIdentity();
HandleError err = handlesys->FreeHandle(hndl, &sec);
HandleError err = g_HandleSys.FreeHandle(hndl, &sec);
if (err == HandleError_None)
{
@@ -82,7 +80,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params)
pNewOwner = pContext->GetIdentity();
} else {
Handle_t hPlugin = static_cast<Handle_t>(params[2]);
IPlugin *pPlugin = pluginsys->PluginFromHandle(hPlugin, &err);
IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hPlugin, &err);
if (!pPlugin)
{
return pContext->ThrowNativeError("Plugin handle %x is invalid (error %d)", hndl, err);
@@ -90,7 +88,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params)
pNewOwner = pPlugin->GetIdentity();
}
err = handlesys->CloneHandle(hndl, &new_hndl, pNewOwner, NULL);
err = g_HandleSys.CloneHandle(hndl, &new_hndl, pNewOwner, NULL);
if (err == HandleError_Access)
{
@@ -104,7 +102,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params)
static cell_t sm_GetMyHandle(IPluginContext *pContext, const cell_t *params)
{
IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
return pPlugin->GetMyHandle();
}
+1 -2
View File
@@ -30,12 +30,11 @@
*/
#include "sm_globals.h"
#include <IGameConfigs.h>
#include "GameConfigs.h"
#include "UserMessages.h"
#include "TimerSys.h"
#include "PlayerManager.h"
#include "HandleSys.h"
#include "logic_bridge.h"
#define MAX_HUD_CHANNELS 6
+8 -51
View File
@@ -29,20 +29,20 @@
* Version: $Id$
*/
#include "common_logic.h"
#include "PluginSys.h"
#include "Translator.h"
#include <IPlayerHelpers.h>
#include <IPluginSys.h>
#include <ISourceMod.h>
#include "LibrarySys.h"
#include "sm_stringutil.h"
#include "PlayerManager.h"
static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
{
char *filename, *ext;
char buffer[PLATFORM_MAX_PATH];
IPlugin *pl = pluginsys->FindPluginByContext(pCtx->GetContext());
CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
pCtx->LocalToString(params[1], &filename);
smcore.Format(buffer, sizeof(buffer), "%s", filename);
UTIL_Format(buffer, sizeof(buffer), "%s", filename);
/* Make sure there is no extension */
if ((ext = strstr(buffer, ".txt")) != NULL
@@ -62,14 +62,14 @@ static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
static cell_t sm_SetGlobalTransTarget(IPluginContext *pContext, const cell_t *params)
{
g_pSM->SetGlobalTarget(params[1]);
g_SourceMod.SetGlobalTarget(params[1]);
return 1;
}
static cell_t sm_GetClientLanguage(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
CPlayer *player = g_Players.GetPlayerByIndex(params[1]);
if (!player || !player->IsConnected())
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
@@ -104,46 +104,6 @@ static cell_t sm_GetLanguageInfo(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
if (!player || !player->IsConnected())
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
}
player->SetLanguageId(params[2]);
return 1;
}
static cell_t sm_GetLanguageByCode(IPluginContext *pContext, const cell_t *params)
{
char *code;
unsigned int langid;
pContext->LocalToString(params[1], &code);
if (g_Translator.GetLanguageByCode(code, &langid))
return langid;
return -1;
}
static cell_t sm_GetLanguageByName(IPluginContext *pContext, const cell_t *params)
{
char *name;
unsigned int langid;
pContext->LocalToString(params[1], &name);
if (g_Translator.GetLanguageByName(name, &langid))
return langid;
return -1;
}
REGISTER_NATIVES(langNatives)
{
{"LoadTranslations", sm_LoadTranslations},
@@ -152,8 +112,5 @@ REGISTER_NATIVES(langNatives)
{"GetServerLanguage", sm_GetServerLanguage},
{"GetLanguageCount", sm_GetLanguageCount},
{"GetLanguageInfo", sm_GetLanguageInfo},
{"SetClientLanguage", sm_SetClientLanguage},
{"GetLanguageByCode", sm_GetLanguageByCode},
{"GetLanguageByName", sm_GetLanguageByName},
{NULL, NULL},
};
-27
View File
@@ -948,32 +948,6 @@ static cell_t SetMenuExitButton(IPluginContext *pContext, const cell_t *params)
return (flags == new_flags);
}
static cell_t SetMenuNoVoteButton(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
unsigned int flags = menu->GetMenuOptionFlags();
if (params[2])
{
flags |= MENUFLAG_BUTTON_NOVOTE;
} else {
flags &= ~MENUFLAG_BUTTON_NOVOTE;
}
menu->SetMenuOptionFlags(flags);
unsigned int new_flags = menu->GetMenuOptionFlags();
return (flags == new_flags);
}
static cell_t SetMenuExitBackButton(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
@@ -1603,7 +1577,6 @@ REGISTER_NATIVES(menuNatives)
{"SetPanelKeys", SetPanelKeys},
{"SetVoteResultCallback", SetVoteResultCallback},
{"VoteMenu", VoteMenu},
{"SetMenuNoVoteButton", SetMenuNoVoteButton},
{NULL, NULL},
};
+28 -45
View File
@@ -200,40 +200,6 @@ static cell_t sm_IsClientFakeClient(IPluginContext *pCtx, const cell_t *params)
return (pPlayer->IsFakeClient()) ? 1 : 0;
}
static cell_t sm_IsClientSourceTV(IPluginContext *pCtx, const cell_t *params)
{
int index = params[1];
if ((index < 1) || (index > g_Players.GetMaxClients()))
{
return pCtx->ThrowNativeError("Client index %d is invalid", index);
}
CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
if (!pPlayer->IsConnected())
{
return pCtx->ThrowNativeError("Client %d is not connected", index);
}
return (pPlayer->IsSourceTV()) ? 1 : 0;
}
static cell_t sm_IsClientReplay(IPluginContext *pCtx, const cell_t *params)
{
int index = params[1];
if ((index < 1) || (index > g_Players.GetMaxClients()))
{
return pCtx->ThrowNativeError("Client index %d is invalid", index);
}
CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
if (!pPlayer->IsConnected())
{
return pCtx->ThrowNativeError("Client %d is not connected", index);
}
return (pPlayer->IsReplay()) ? 1 : 0;
}
static cell_t IsClientObserver(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
@@ -1341,6 +1307,17 @@ static cell_t KickClient(IPluginContext *pContext, const cell_t *params)
return 1;
}
pPlayer->MarkAsBeingKicked();
if (pPlayer->IsFakeClient())
{
char kickcmd[40];
UTIL_Format(kickcmd, sizeof(kickcmd), "kick %s\n", pPlayer->GetName());
engine->ServerCommand(kickcmd);
return 1;
}
g_SourceMod.SetGlobalTarget(client);
char buffer[256];
@@ -1351,15 +1328,6 @@ static cell_t KickClient(IPluginContext *pContext, const cell_t *params)
return 0;
}
if (pPlayer->IsFakeClient())
{
// Kick uses the kickid command for bots. It is already delayed
// until the next frame unless someone flushes command buffer
pPlayer->Kick(buffer);
return 1;
}
pPlayer->MarkAsBeingKicked();
g_HL2.AddDelayedKick(client, pPlayer->GetUserId(), buffer);
return 1;
@@ -1379,6 +1347,23 @@ static cell_t KickClientEx(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Client %d is not connected", client);
}
/* Ignore duplicate kicks */
if (pPlayer->IsInKickQueue())
{
return 1;
}
pPlayer->MarkAsBeingKicked();
if (pPlayer->IsFakeClient())
{
char kickcmd[40];
UTIL_Format(kickcmd, sizeof(kickcmd), "kick %s\n", pPlayer->GetName());
engine->ServerCommand(kickcmd);
return 1;
}
g_SourceMod.SetGlobalTarget(client);
char buffer[256];
@@ -1639,8 +1624,6 @@ REGISTER_NATIVES(playernatives)
{"IsClientAuthorized", sm_IsClientAuthorized},
{"IsClientConnected", sm_IsClientConnected},
{"IsFakeClient", sm_IsClientFakeClient},
{"IsClientSourceTV", sm_IsClientSourceTV},
{"IsClientReplay", sm_IsClientReplay},
{"IsClientInGame", sm_IsClientInGame},
{"IsClientObserver", IsClientObserver},
{"RemoveUserFlags", RemoveUserFlags},
@@ -29,13 +29,12 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <IHandleSys.h>
#if !defined PLATFORM_WINDOWS
#include <stddef.h>
#include <stdint.h>
#include <sys/time.h>
#endif
#include "sm_globals.h"
#include "HandleSys.h"
//Note: Do not add this to Linux yet, i haven't done the HPET timing research (if even available)
//nonetheless we need accurate counting
#if !defined PLATFORM_LINUX
struct Profiler
{
@@ -48,9 +47,6 @@ struct Profiler
LARGE_INTEGER start;
LARGE_INTEGER end;
double freq;
#else
struct timeval start;
struct timeval end;
#endif
bool started;
bool stopped;
@@ -65,11 +61,11 @@ class ProfilerHelpers :
public:
void OnSourceModAllInitialized()
{
g_ProfilerType = handlesys->CreateType("Profiler", this, 0, NULL, NULL, g_pCoreIdent, NULL);
g_ProfilerType = g_HandleSys.CreateType("Profiler", this, 0, NULL, NULL, g_pCoreIdent, NULL);
}
void OnSourceModShutdown()
{
handlesys->RemoveType(g_ProfilerType, g_pCoreIdent);
g_HandleSys.RemoveType(g_ProfilerType, g_pCoreIdent);
}
void OnHandleDestroy(HandleType_t type, void *object)
{
@@ -88,7 +84,7 @@ static cell_t CreateProfiler(IPluginContext *pContext, const cell_t *params)
p->freq = 1.0 / (double)(qpf.QuadPart);
#endif
Handle_t hndl = handlesys->CreateHandle(g_ProfilerType, p, pContext->GetIdentity(), g_pCoreIdent, NULL);
Handle_t hndl = g_HandleSys.CreateHandle(g_ProfilerType, p, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE)
{
delete p;
@@ -104,7 +100,7 @@ static cell_t StartProfiling(IPluginContext *pContext, const cell_t *params)
HandleError err;
Profiler *prof;
if ((err = handlesys->ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
if ((err = g_HandleSys.ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -112,8 +108,6 @@ static cell_t StartProfiling(IPluginContext *pContext, const cell_t *params)
#if defined PLATFORM_WINDOWS
QueryPerformanceCounter(&prof->start);
#else
gettimeofday(&prof->start, NULL);
#endif
prof->started = true;
@@ -129,7 +123,7 @@ static cell_t StopProfiling(IPluginContext *pContext, const cell_t *params)
HandleError err;
Profiler *prof;
if ((err = handlesys->ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
if ((err = g_HandleSys.ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -142,8 +136,6 @@ static cell_t StopProfiling(IPluginContext *pContext, const cell_t *params)
#if defined PLATFORM_WINDOWS
QueryPerformanceCounter(&prof->end);
#else
gettimeofday(&prof->end, NULL);
#endif
prof->started = false;
@@ -159,7 +151,7 @@ static cell_t GetProfilerTime(IPluginContext *pContext, const cell_t *params)
HandleError err;
Profiler *prof;
if ((err = handlesys->ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
if ((err = g_HandleSys.ReadHandle(hndl, g_ProfilerType, &sec, (void **)&prof))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -176,10 +168,6 @@ static cell_t GetProfilerTime(IPluginContext *pContext, const cell_t *params)
LONGLONG diff = prof->end.QuadPart - prof->start.QuadPart;
double seconds = diff * prof->freq;
fTime = (float)seconds;
#else
int64_t start_us = int64_t(prof->start.tv_sec) * 1000000 + prof->start.tv_usec;
int64_t stop_us = int64_t(prof->end.tv_sec) * 1000000 + prof->end.tv_usec;
fTime = double((stop_us - start_us) / 1000) / 1000.0;
#endif
return sp_ftoc(fTime);
@@ -193,4 +181,5 @@ REGISTER_NATIVES(profilerNatives)
{"StopProfiling", StopProfiling},
{NULL, NULL},
};
#endif
@@ -1,5 +1,5 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@@ -29,12 +29,12 @@
* Version: $Id$
*/
#include "common_logic.h"
#include <string.h>
#include <stdlib.h>
#include "sm_globals.h"
#include "sm_stringutil.h"
#include <ITextParsers.h>
#include <ctype.h>
#include "stringutil.h"
inline const char *_strstr(const char *str, const char *substr)
{
@@ -141,7 +141,7 @@ static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params)
{
char *str;
pCtx->LocalToString(params[2], &str);
size_t res = smcore.Format(str, params[3], "%d", params[1]);
size_t res = UTIL_Format(str, params[3], "%d", params[1]);
return static_cast<cell_t>(res);
}
@@ -174,7 +174,7 @@ static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params)
{
char *str;
pCtx->LocalToString(params[2], &str);
size_t res = smcore.Format(str, params[3], "%f", sp_ctof(params[1]));
size_t res = UTIL_Format(str, params[3], "%f", sp_ctof(params[1]));
return static_cast<cell_t>(res);
}
@@ -187,7 +187,7 @@ static cell_t sm_formatex(IPluginContext *pCtx, const cell_t *params)
pCtx->LocalToString(params[1], &buf);
pCtx->LocalToString(params[3], &fmt);
res = smcore.atcprintf(buf, static_cast<size_t>(params[2]), fmt, pCtx, params, &arg);
res = atcprintf(buf, static_cast<size_t>(params[2]), fmt, pCtx, params, &arg);
return static_cast<cell_t>(res);
}
@@ -256,7 +256,7 @@ static cell_t sm_format(IPluginContext *pCtx, const cell_t *params)
}
buf = (copy) ? __copy_buf : destbuf;
res = smcore.atcprintf(buf, maxlen, fmt, pCtx, params, &arg);
res = atcprintf(buf, maxlen, fmt, pCtx, params, &arg);
if (copy)
{
@@ -306,7 +306,7 @@ static cell_t sm_vformat(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[3], &format);
size_t total = smcore.atcprintf(destination, maxlen, format, pContext, local_params, &vargPos);
size_t total = atcprintf(destination, maxlen, format, pContext, local_params, &vargPos);
/* Perform copy-on-write if we need to */
if (copy)

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