Compare commits

..
Author SHA1 Message Date
David Anderson 4acbd45a34 Removed tag sourcemod-1.3.8 2011-06-25 01:23:45 -07:00
David Anderson c46a4e0a41 Downgrade version to 1.3.8 for respin. 2011-06-24 23:38:15 -07:00
Nicholas Hastings 4916b99c1a Added tag sourcemod-1.3.8 for changeset fa2f05c3ae00 2011-06-24 19:47:07 -04:00
Nicholas Hastings 012d58cc29 Fixed TF2 identifiers and condition stocks (bug 4974, r=me). 2011-06-24 19:46:50 -04:00
David Anderson e7344c6b62 Bumped version to 1.3.9-dev. 2011-06-24 00:01:27 -07:00
David Anderson e41c7fddca Added tag sourcemod-1.3.8 for changeset 2726e2ec8c90 2011-06-23 23:58:40 -07:00
Nicholas Hastings 4b1d372004 Updated TF2 identifiers and condition stocks. 2011-06-24 02:01:10 -04:00
Nicholas Hastings d120789a23 Updated TF2 gamedata. 2011-06-24 00:54:20 -04:00
Fyren 154be77ccb Preemptively bump version for release 2011-06-23 17:17:53 -07:00
Fyren d5d620340d Preemptively update changelog.txt 2011-06-23 17:15:06 -07:00
Nicholas Hastings 4c29a78f56 Triggering build. 2011-06-23 19:28:29 -04:00
David Anderson f05b9ef600 Fixed crash on plugin unload when two cmds exist with same name, different casing (bug 4698, r=Fyren). 2011-06-20 13:30:14 -04:00
Nicholas Hastings 6a8e6837a7 Moved GetEntityClassname to end of entity.inc to fix plugin compile errors (bug 4798). 2011-06-18 14:30:06 -04:00
Fyren d9bfdd3ae4 Added gamedata for Eternal Silence (bug 4880). 2011-05-25 20:53:21 -04:00
Nicholas Hastings 0c29170bba Fixed invalid client errors from late-load of SourceTV (bug 4881, r=fyren). 2011-05-25 08:31:12 -04:00
Fyren 7f2765af9b Translator now properly falls back on bad server language (bug 4861, r=dvander). 2011-05-25 08:12:46 -04:00
Nicholas Hastings 51ae63bd78 Updated garrysmod gamedata. 2011-05-24 20:38:01 -04:00
Nicholas Hastings f37c188b5a Handle leak notice now prints to error log (as well as fatal) (bug 4929, r=dvander). 2011-05-24 18:54:43 -04:00
Fyren 34ae5da0cb Removed compiler double include check (bug 4863, r+a13=dvander). 2011-05-24 10:50:12 -04:00
Nicholas Hastings 365dee321f Fixed var names and docs for TF2_MakeBleed native (bug 4928, r=fyren). 2011-05-24 10:17:48 -04:00
FlaminSarge aea5ad1459 Added TF2 megaheal cond defines to tf2 incs (bug 4916, r=psychonic). 2011-05-12 11:33:50 -04:00
Nicholas Hastings 2aa592ae2f Merge. 2011-05-06 08:10:01 -04:00
Gareth Clarke fef508156b Updated ep2v SetUserCvar gamedata (bug 4904). 2011-05-06 08:08:48 -04:00
Scott Ehlert 9347be33c3 Moved -static-libgcc to linker flags. 2011-05-01 00:48:14 -05:00
Nicholas Hastings 52ed344653 Updated dinodday gamedata for today's game update. 2011-04-25 19:05:05 -04:00
Nicholas Hastings a25b9d4b53 Updated zps gamedata for today's game update. 2011-04-25 19:04:47 -04:00
Nicholas Hastings 9e0590e12f Updated Windows signature for GMod CreateEntityByName. 2011-04-17 16:13:54 -04:00
David Anderson f6b9b99abe Added tag sourcemod-1.3.7 for changeset 0f35d8b324ba 2011-04-15 22:52:22 -07:00
David Anderson 2b5bf29dfc Bumped version to 1.3.8-dev. 2011-04-15 22:51:07 -07:00
David Anderson ee7413bbdd Bumped version for release. 2011-04-15 13:41:58 -07:00
David Anderson 764d63a533 Updated changelog. 2011-04-15 13:40:44 -07:00
Nicholas Hastings bcbff0b2e9 Updated Garry's Mod gamedata. 2011-04-15 15:00:10 -04:00
Nicholas Hastings 35b74715d8 Added new param to CTFPlayerShared::Disguise call in TF2 ext (bug 4866, r=fyren). 2011-04-15 12:11:32 -04:00
Nicholas Hastings e0639de6a0 Shortened __ext name for ClientPrefs to avoid hitting symbol limit (bug 4839). 2011-04-15 02:07:17 -04:00
Nicholas Hastings f025fd8a05 Gamedata update for CS:S, TF2, DOD:S, and HL2DM. 2011-04-15 01:59:46 -04:00
Nicholas Hastings 625848b95d Triggering build. 2011-04-15 00:47:22 -04:00
Nicholas Hastings 2de9d5f9cb Merge. 2011-04-13 08:32:13 -04:00
Nicholas Hastings ab15436a7f SetEntProp now marks edict state as changed at offset (bug 4855, r=fyren). 2011-04-13 08:14:07 -04:00
Berni e507aa5025 Fix compiler hanging when #including a directory (bug 4822, r=dvander) 2011-04-13 04:04:44 -07:00
Nicholas Hastings 8b205b0d5d Removed gEntList failure notify on Windows. (bug 4832, r=fyren). 2011-04-11 22:30:03 -04:00
Nicholas Hastings e4e54510c8 Added gamedata for Dino D-Day. 2011-04-09 23:55:56 -04:00
Berni d706023c74 Added GetEntityClassname stock (bug 4798, r=dvander). 2011-04-09 00:29:46 -04:00
Nicholas Hastings 8df27acc1f Fixed some gamedata lookups requiring symbols on linux/mac (bug 4832, r=fyren). 2011-04-05 12:07:36 -04:00
Nicholas Hastings 4c5c2eae24 Added better cross-engine entity flag compatibility. (bug 4809, r=fyren). 2011-04-04 13:37:29 -04:00
Nicholas Hastings bc4eecae8f Mark clientprefs natives as optional when ext not required. (bug 4839, r=fyren). 2011-03-24 09:48:36 -04:00
Nicholas Hastings 218b9b1fab Changed some instances of LogMessage to LogAction. (bug 4649, r=fyren). 2011-03-20 19:50:56 -04:00
Nicholas Hastings 0750b93797 Merge. 2011-03-13 14:05:11 -04:00
Nicholas Hastings 41b0e7fc53 Added new TF2 condition defines (bug 4834, r=fyren). 2011-03-13 14:03:26 -04:00
David Anderson 801815b742 Fix symstore. 2011-03-12 22:38:38 -08:00
David Anderson 01a826268b Fix build. 2011-03-12 21:41:06 -08:00
David Anderson 55ec20b215 New symstore. 2011-03-12 20:30:06 -08:00
databomb dc550c25e5 Fix precedence of voice mute flag versus specific client overrides (bug 4826, r+a=fyren) 2011-03-08 12:38:43 -08:00
databomb ad842e4665 Fix mistaken unhooking of voice hooks (bug 4804, r+a=fyren) 2011-03-08 12:38:18 -08:00
GoD-Tony f7398119f4 Added new language natives (bug 4613, r+a13=dvander). 2011-03-08 08:35:35 -05:00
Asher Baker b21337c56d Added missing files to the spcomp project file (bug 4824, r=dvander). 2011-03-07 15:06:22 +07:00
Nicholas Hastings c1d040e153 Fixed SetTeamScore not updating score on client (bug 2736, r=fyren). 2011-02-28 19:40:21 -05:00
Nicholas Hastings 4c3fb52c69 Merge 2011-03-01 21:30:12 -05:00
Nicholas Hastings 31c29fb33e Backed out changeset: 7ad1ac7ca287 2011-03-01 21:30:08 -05:00
Nicholas Hastings 87af9af0f6 Fixed graphical glitches with funcommands effects in L4D1 (bug 3486, r=fyren). 2011-02-28 19:45:36 -05:00
Nicholas Hastings ebb26e6144 Added identifier for new TF2 flag event, 'returned' (bug 4808, r=fyren). 2011-02-28 19:44:41 -05:00
Nicholas Hastings 50c15f4f78 Updated TF2 condition idenifiers (bug 4801, r=fyren).
Added TFCond_InHealRadius (amputator glow) and fixed TFCond_Healing.
2011-02-28 19:43:08 -05:00
Nicholas Hastings e02bdca793 Fixed SetTeamScore not updating score on client (bug 2736, r=fyren). 2011-02-28 19:40:21 -05:00
Nicholas Hastings 8bcbe128e7 Updated Empires Mod gamedata for current version 2.31a. 2011-02-28 19:38:22 -05:00
Nicholas Hastings 68991bc733 Updated ZPS gamedata. 2011-02-07 15:50:37 -05:00
Nicholas Hastings d77d1de462 Asher Baker - Added defines for TF2 weapon slots (r=dvander). 2011-02-01 14:51:42 -05:00
Nicholas Hastings e1081c0a50 Updated CSPromod gamedata. 2011-02-01 14:47:50 -05:00
Nicholas Hastings 2b3f888712 Updated customkill and deathflag defines in tf2_stocks (bug 4799, r=dvander). 2011-01-16 20:26:42 -05:00
Nicholas Hastings b8e530ab7e Raised MAXPLAYERS from 64 to 65 (bug 4490, r=dvander). 2011-01-16 20:07:20 -05:00
Erik Minekus 274539cf49 Fixed bug in nominations that could cause "Unknown command" error (bug 4797, r=psychonic). 2011-01-16 20:01:39 -05:00
Nicholas Hastings 6e92d0df4f Removed tv_enable hook to fix rare max client count issue (bug 4791, r=fyren). 2011-01-12 19:01:32 -05:00
Asher Baker 1bb5f0e52b Added missing unhooking of ClientConnect in PlayerManager (bug 4749, r=fyren). 2010-12-31 20:02:51 -05:00
Zach Kanzler 1af3446593 Fixed namespace-related compile issue in INativeInvoker.h (bug 4750, r=fyren). 2010-12-31 20:00:23 -05:00
Nicholas Hastings b70b8cf0cb Updated Garry's Mod gamedata (bug 4762, r=fyren). 2010-12-19 14:12:10 -05:00
Nicholas Hastings 8dca4bf093 Updated TF2 includes with new weapon and condition identifiers (bug 4761, r=fyren). 2010-12-18 17:10:32 -05:00
Nicholas Hastings a7d170bf13 Updated HL2DM gamedata (bug 4756, r=fyren). 2010-12-18 00:14:34 -05:00
Nicholas Hastings f5865ee46f Updated DOD:S gamedata (bug 4755, r=fyren). 2010-12-18 00:06:56 -05:00
Nicholas Hastings adac0f17c4 Updated CS:S gamedata (bug 4754, r=fyren). 2010-12-18 00:05:02 -05:00
Nicholas Hastings b8b9e4db90 Updated TF2 gamedata (bug 4753, r=DS). 2010-12-17 23:13:53 -05:00
Nicholas Hastings 5fdb4d05fa Updated Goldeneye:Source gamedata (bug 4751, r=fyren). 2010-12-17 23:12:19 -05:00
Nicholas Hastings 93768cfd4d Updated Garry's Mod gamedata (bug 4747, r=fyren). 2010-12-15 21:33:14 -05:00
Nicholas Hastings 8cdd3faa89 Triggering build to fix bug 4729 on L4D1 now. 2010-12-13 15:38:50 -05:00
Nicholas Hastings 98dee0097a Merge. 2010-12-04 15:30:24 -05:00
Erik Minekus 090cc9f818 Fixed sm_rtv printing "unknown command" (bug 4730, r=psychonic). 2010-12-04 15:29:29 -05:00
Scott Ehlert 9abbe96a7f Triggering build to fix bug 4729. 2010-12-03 22:58:04 -08:00
Nicholas Hastings 3aeab98517 Updated TF2_GetPlayerConditionFlags to match Valve's current logic (bug 4726, r=fyren). 2010-12-03 17:14:00 -05:00
Jason Booth 11daaac1b4 Fixed profiler flush not clearing, added 'report' and 'clear' (bug 4674, r=dvander). 2010-11-30 13:08:30 -05:00
Nicholas Hastings 15c5ed1dd3 Fixed voting crash when client console, chat, and SourceTV are enabled (bug 4676, r=fyren). 2010-11-30 13:04:13 -05:00
Nicholas Hastings 1bb9adc767 Fixed CDetour crash in TF2 extension when last plugin using forward is unloaded (bug 4713, r=fyren). 2010-11-29 07:53:44 -05:00
Nicholas Hastings dd83c23cda Fixed TF2 GetHoliday Windows signature (bug 4714, r=fyren). 2010-11-24 20:57:19 -05:00
Nicholas Hastings e8a6040926 TF2 GetHoliday detour now detours UTIL_GetHoliday (bug 4700, r=fyren). 2010-11-09 21:12:38 -05:00
A.W. Stanley 5ff8ec62e0 Added TF2_IsPlayerInDuel native to TF2 extension (bug 4695, r=psychonic). 2010-11-07 19:09:34 -05:00
David Anderson 1f06a6951d Bumped version to 1.3.7-dev. 2010-10-30 17:43:40 -07:00
David Anderson d65f993c53 Added tag sourcemod-1.3.6 for changeset 8036343199ca 2010-10-30 17:43:18 -07:00
David Anderson c5e37e15e6 Strip -dev tags for release. 2010-10-30 16:09:37 -07:00
Scott Ehlert c4473acc4e Fixed sample ext makefiles for L4D Linux builds (bug 4681, r+a13=fyren). 2010-10-28 12:41:13 -07:00
Nicholas Hastings 8e845b0a33 Updated TF2 customkill defines (bug 4682, r=fyren). 2010-10-28 10:23:30 -04:00
Scott Ehlert 26c3193653 Fixed loading L4D on Linux (bug 4681, r+a13=dvander). 2010-10-27 22:07:40 -07:00
David Anderson ee19cf4045 Bumped version to 1.3.6-dev. 2010-10-17 14:51:25 -07:00
David Anderson fca7c4f4a3 Added tag sourcemod-1.3.5 for changeset 9de8baa40cc5 2010-10-17 14:49:42 -07:00
David Anderson b811336c1e Removed -dev tag for release. 2010-10-17 12:28:04 -07:00
David Anderson 3fc3ab4372 Updated credits. 2010-10-17 12:26:52 -07:00
David Anderson 6434cc7bf0 Updated changelog. 2010-10-17 12:25:29 -07:00
David Anderson d8e3e7e11d Follow-up fixes to database conf reading (bug 4286, r=fyren, a=blocking). 2010-10-16 22:27:34 -07:00
Fyren 061a958b9f Use SH strings for database configs (bug 4286, r=dvander) 2010-10-16 03:55:28 -07:00
Nicholas Hastings 294afcca2a Updated Gmod gamedata (bug 4652, r=fyren). 2010-10-07 18:36:47 -04:00
Nicholas Hastings e8834ed9cb Updated CSS/DODS/TF2/HL2DM CommitSuicide offset (bug 4650, r=fyren). 2010-10-06 20:48:40 -04:00
Scott Ehlert a37e6bbb8b Triggering build against L4D2 SDK changes.
This should fix sm_kick.
2010-10-05 23:30:42 -07:00
Scott Ehlert 4d007d6b2a Triggering build against L4D1 SDK changes. 2010-10-05 20:05:04 -07:00
Fyren 9527457ca0 Fixed 'sm plugins' public command skipping plugins in recommended listing (bug 4501, r=dvander). 2010-10-04 22:40:47 -04:00
Nicholas Hastings f7d3396001 Added one more missing enum value in tf2_stocks. 2010-10-01 15:24:50 -04:00
Nicholas Hastings 55508e0068 Fixed/updated TF2_DisguisePlayer (bug 4641, r=fyren). 2010-10-01 10:47:58 -04:00
Nicholas Hastings cc691da4d0 Updated more TF2 gamedata and fixed RemoveCondition call (bug 4641, r=fyren). 2010-10-01 09:10:44 -04:00
Nicholas Hastings d05d47139d Shortened names of some symbols in tf2_stocks (bug 4642, r=fyren). 2010-10-01 08:53:09 -04:00
Nicholas Hastings 47e02e0f6c Updated TF2 includes with more defined identifiers (bug 4640, r=dvander). 2010-09-30 23:42:31 -04:00
Nicholas Hastings 5202c1361f Updated HL2DM gamedata (bug 4636, r=fyren). 2010-09-30 20:14:01 -04:00
Nicholas Hastings 1d13430519 Updated DODS gamedata (bug 4638, r=fyren). 2010-09-30 17:29:05 -04:00
Nicholas Hastings 1852813741 Updated TF2 gamedata (bug 4635, r=fyren). 2010-09-30 17:28:28 -04:00
Nicholas Hastings d711c17534 Updated CSS gamedata (bug 4637, r=fyren). 2010-09-30 17:27:26 -04:00
Nicholas Hastings 717606deef forcing build since no good snapshot exists for cstrike 2010-09-08 17:06:31 -04:00
Nicholas Hastings 5d01407ad5 Updated cstrike ext gamedata for 2010-08-26 update (bug 4595, r=fyren). 2010-08-26 22:23:32 -04:00
Nicholas Hastings 41fcefad5f Updated Gmod gamedata, including linux support (bug 4569, r=fyren). 2010-08-24 19:24:09 -04:00
Scott Ehlert 01f912611e Added Alien Swarm build config for sample extension (bug 4530, r+a13=psychonic). 2010-08-20 10:44:03 -05:00
Nicholas Hastings f0ad0b110e Merge. 2010-08-19 21:59:11 -04:00
Nicholas Hastings fb35cf52f5 Fixed timeleft not getting reset on Game_Commencing in CS:S (bug 4557, r=fyren). 2010-08-19 21:57:33 -04:00
Scott Ehlert fe435ca0ab Disabled nextmap plugin on Alien Swarm (bug 4571, r+a13=fyren). 2010-08-16 15:49:47 -05:00
Nicholas Hastings f356cb78f9 Fixed typo in 13fd4d07f246 (bug 4542) 2010-08-05 19:25:07 -04:00
Nicholas Hastings e5d1e0b319 Added initial gamedata for Alien Swarm (bug 4530, r=ds). 2010-08-02 12:28:38 -04:00
Erik Minekus 9188e9f6a9 Fixed typos in some usage replies (bug 4552, r=dvander). 2010-08-02 09:45:35 -04:00
Nicholas Hastings 8e72f57333 Fixed Ignite crash on Fistful of Frags (bug 4556, r=fyren). 2010-08-02 09:37:39 -04:00
Nicholas Hastings df1e56e408 Fixed Firearms Source FireOutput signature (bug 4555, r=fyren). 2010-08-02 09:36:15 -04:00
Scott Ehlert 4afbf67ce1 Fixed potential crash with IMemUtils::FindPattern on Linux (bug 4554, r+a13=dvander). 2010-07-31 16:06:16 -05:00
Scott Ehlert 5c1efcb4d6 Fixed missing version string and compile date for MySQL extension (bug 4547, r+a13=dvander). 2010-07-28 14:51:58 -05:00
Scott Ehlert f3fb84d1d0 Added support for Alien Swarm (bug 4530, r=dvander). 2010-07-28 01:25:27 -05:00
Nicholas Hastings 6cae738f1c Added gamedata for Fistful of Frags (bug 3883, r=fyren). 2010-07-26 19:26:32 -04:00
pheadxdll bff4fe01e3 Added TF2_MakeBleed native to TF2 ext (bug 4542, r=fyren,psychonic). 2010-07-26 11:08:39 -04:00
Zach Callear 959c571fc6 Fixed living players hearing dead players if alltalk is disabled while deadtalk is on (bug 4533, r=fyren). 2010-07-26 08:23:49 -04:00
Nicholas Hastings c5c8b90262 Fixed errors and missing effects caused by missing sprites on L4D2 (bug 4512, r=fyren). 2010-07-26 08:15:52 -04:00
Erik Minekus 8744c1871d Added TF2 object stocks (bug 4536, r=psychonic). 2010-07-23 21:24:07 -04:00
Nicholas Hastings 98a1dc7757 Added gamedata for Firearms: Source (bug 4537 r=fyren). 2010-07-23 21:18:48 -04:00
Nicholas Hastings 4064c6f1c2 Added support for logical entities to gamedata for Synergy. (bug 4534, r=fyren) 2010-07-22 21:40:52 -04:00
Nicholas Hastings 04c2e47a5f Updated TF2 conditions enum and defines (bug 4526, r=fyren) 2010-07-20 11:21:37 -04:00
Nicholas Hastings 2f03f53ab1 Merge. 2010-07-18 15:52:28 -04:00
Nicholas Hastings 0d2819e3b5 Fixed PlayerRunCmd being hooked when not used. (bug 3990, r=fyren) 2010-07-18 15:43:56 -04:00
David Anderson 8d16ac2295 Bumped version to 1.3.5-dev. 2010-07-17 23:37:58 -07:00
David Anderson 714e71b6c3 Added tag sourcemod-1.3.4 for changeset 4d6afc42522c 2010-07-17 23:36:54 -07:00
David Anderson 0c16c6ebe9 Bump version from 1.3.4-dev to release. 2010-07-17 22:42:57 -07:00
David Anderson 1b9ce5f484 Updated changelog for 1.3.4. 2010-07-17 22:41:35 -07:00
Nicholas Hastings c4390478fc Fixed TF2 sigs that broke with recent update (bug 4506, r=fyren) 2010-07-08 21:11:39 -04:00
Scott Ehlert 7d97de8a10 Bleh, fixed compiler error in console.inc caused by previous changeset. 2010-07-07 02:29:23 -05:00
Scott Ehlert 51bee0f420 Added GetConVarDefault() native (bug 4502, r+a13=dvander). 2010-07-07 02:10:57 -05:00
Nicholas Hastings 04642a7cc0 Gmod gamedata update (bug 4489, r=fyren) 2010-07-06 07:31:58 -04:00
David Anderson 8a0a911d43 Fixed bogus assert about name lengths (bug 4486, r=fyren). 2010-07-02 18:12:31 -07:00
Scott Ehlert fae6673957 Added MSVC10 project file for sample extension (bug 4521, r+a13=dvander). 2010-07-15 15:21:43 -05:00
Scott Ehlert 63f50b1e73 Oh, fixed Linux build. 2010-07-15 01:04:52 -05:00
Nicholas Hastings f53746f720 Added forward/detour for TF2's GetHoliday function (bug 4462, r=pred, a13=dvander). 2010-07-15 00:58:42 -05:00
Scott Ehlert 5dd18eeaad Appended OS names to package archives (bug 4395, r+a13=dvander). 2010-07-14 23:45:01 -05:00
Scott Ehlert 7316b6255c Updated docs on replicate and notify params for SetConVar* and ResetConVar (bug 4517, r=pred, a13=dvander). 2010-07-14 20:29:53 -05:00
Scott Ehlert eb2605f1a3 Fixed replicate and notify params on SetConVar* and ResetConVar which didn't work on old engine games (bug 4516, r=pred, a13=dvander).
This also fixes an issue where clients could be notified of convar changes twice on newer engines (Orange Box and later).
2010-07-14 20:29:45 -05:00
Scott Ehlert 01a3a09d96 Made name param of GetConVarName() non-const (bug 4515, r=pred, a13=dvander). 2010-07-14 20:29:29 -05:00
Scott Ehlert 01e7fb463b Triggering a build to compile against L4D2 SDK changes (bug 4509). 2010-07-11 03:06:00 -05:00
Nicholas Hastings f8f6f2cf6c Merge. 2010-06-27 19:24:28 -04:00
_KaszpiR_ 99ae90ecc5 Added FindFlagChar native. (bug 3776, r=dvander) 2010-06-27 19:23:50 -04:00
David Anderson d64125ddd4 Added tag sourcemod-1.3.3 for changeset c5062ca82830 2010-06-24 01:42:39 -07:00
David Anderson 7fb3632fd7 Bumped version to 1.3.4-dev. 2010-06-24 01:25:25 -07:00
David Anderson 49e2303a5b Bumped version to 1.3.3 for release. 2010-06-23 23:44:14 -07:00
David Anderson fe0b9f7320 Updated changelog. 2010-06-23 23:43:09 -07:00
David Anderson b16c758f88 Removed code now dead from CS:S Orange Box move (bug 4399, r+a13=ds). 2010-06-23 23:35:28 -07:00
Nicholas Hastings da729c3c08 Removed cstrike ep1 and cstrike_beta builds and references. (bug 4399, r=dvander) 2010-06-23 23:53:16 -04:00
Erik Minekus f1bcb2ad3e Fixed lack of error checking on sm_motd. (bug 4460, r=dvander) 2010-06-23 23:42:22 -04:00
Nicholas Hastings 9270399eb1 Forcing (re)build(?) since Windows had a strange fail. 2010-06-23 10:33:51 -04:00
Nicholas Hastings 76e6edbad4 Cstrike ext now recognizes and loads on cstrike_beta (bug 4399, r=fyren) 2010-06-23 10:12:55 -04:00
devicenull 58ca1508bc Fixed inaccuracy in CommandListener documentation 2010-06-23 09:23:23 -04:00
Greyscale eed1df28ec Removed unnecessary tag from return value of SetArrayCell 2010-06-23 09:17:53 -04:00
Nicholas Hastings a602d7d107 Ep2v cstrike ext now gets added to package. 2010-06-23 09:02:04 -04:00
Nicholas Hastings 9a08986fd1 Silly AMBuild 2010-06-23 08:32:25 -04:00
Nicholas Hastings 5d1820853a Adding building of cstrike ext for ep2v (bug 4399, r=fyren) 2010-06-23 08:29:15 -04:00
Nicholas Hastings 753aced2a3 Added missing TF2 critcola condflag define (bug 4464, r=fyren) 2010-06-22 19:31:33 -04:00
Nicholas Hastings df47457321 Updated TF2 'Burn' signature (bug 4463, r=fyren) 2010-06-22 19:26:07 -04:00
Fyren d9e818e5d9 Possible dynamic array dimension fix (bug 4428, r=dvander) 2010-06-19 15:17:10 -07:00
Nicholas Hastings 47c840c9b4 Fixed outputname null pointer crash in sdktools (bug 4422, r=fyren) 2010-06-14 09:32:50 -04:00
David Anderson 2bfc5d3e1e Fixed switch case comparisons failing with large numbers (bug 4457, r=pred). 2010-06-13 20:26:58 -07:00
Nicholas Hastings 4307c57697 Added missing FireOutput and PlayerRunCmd gamedata for zombie_master (bug 4452, r=fyren) 2010-06-07 19:39:15 -04:00
Nicholas Hastings bff0faff52 Added new player condition (TFCond_CritCola) to tf2.inc. (bug 4447, r=fyren) 2010-06-06 20:55:25 -04:00
Matt Woodrow 749966ae66 Fixed clientprefs deleting cookies twice in rare cases (bug 4412, r=Fyren) 2010-06-07 10:30:33 +12:00
Nicholas Hastings 9f11132fb5 Fixed OnClientConnected forward not firing for bots (bug 4443, r=fyren) 2010-06-06 17:53:38 -04:00
Fyren 2dfbd1fc1f Fix sdktools voice memory corruption (bug 4415, r=dvander) 2010-06-05 23:21:33 -07:00
Nicholas Hastings 7c659837bf Updated Obsidian Conflict gamedata (bug 4439, r=fyren) 2010-06-02 07:54:15 -04:00
Nicholas Hastings 7cf342a1a7 Fixed tf2.inc incorrectly attempting to load tf2 ext on all games (bug 4197, r=fyren) 2010-05-31 16:36:10 -04:00
Scott Ehlert e8d6aab989 Triggering build. 2010-05-29 00:55:06 -05:00
Nicholas Hastings 0819278465 Updated/fixed SourceForts gamedata (bug 4429, r=fyren) 2010-05-28 13:29:13 -04:00
Nicholas Hastings d89c57ba79 Fixed SDKTools sm_dump_datamaps crash on improperly created entities (bug 4424, r=pred) 2010-05-26 08:31:48 -04:00
Nicholas Hastings 23b10fc559 Added gamedata for Resistance and Liberation (bug 4418, r=fyren) 2010-05-21 14:04:19 -04:00
Nicholas Hastings 36e8e881e8 Empires gamedata fixes (bug 4417, r=fyren). 2010-05-21 13:55:29 -04:00
Nicholas Hastings 67011834df Updated gamedata for ep2v cstrike(_beta) (bug 4399, r=fyren) 2010-05-11 20:40:14 -04:00
Scott Ehlert ed9f68814f Added missing -dev back to product.version. 2010-05-13 09:35:30 -05:00
Nicholas Hastings 79a8008280 Fixed TF2 natives not being marked optional when ext not required (bug 4389, r=fyren) 2010-05-10 18:18:34 -04:00
Nicholas Hastings 643dce8cb1 Updated Empires gamedata (bug 4390, r=fyren) 2010-05-08 21:39:50 -04:00
Scott Ehlert 3669b98986 Fixed SendConVarValue() on TF2, DOD:S, L4D, and L4D2 (bug 4273, r=dvander, a=blocking). 2010-05-04 22:49:46 -04:00
David Anderson e075b7b9b2 Bumped version to 1.3.3-dev. 2010-05-02 14:41:51 -07:00
David Anderson b95fda8342 Added tag sourcemod-1.3.2 for changeset a3e8f7a7fdf7 2010-05-02 14:39:43 -07:00
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
David Anderson b43c8c018b Warn user when adminmenu_custom is going to emit duplicate entries (bug 3894, r=pred). 2009-10-27 01:43:51 -07:00
David Anderson 38a5a4b97b Increase display lengths on custom menus (bug 3677, r=pred). 2009-10-27 01:37:19 -07:00
Matt Woodrow 73d70b6953 Fixed bug in entity output hooks (bug 3988, r=fyren). 2009-10-27 00:03:59 -07:00
David Anderson 6b06733192 Added better random number generator (bug 3831, r=fyren). 2009-10-26 23:59:59 -07:00
David Anderson 359146f60b Don't pass unconnected clients into OnClientCommand (bug 3732, r=fyren). 2009-10-26 23:51:39 -07:00
Fyren 0931c6a7e1 Fix OnConfigsExecuted() executing too early on EP1 with large config files (bug 3828, r=dvander). 2009-10-26 23:44:57 -07:00
Fyren f2049c5910 Fix menu population for sm_who (bug 4030, r=pred) 2009-10-20 15:48:56 -07:00
David Anderson de76827dd8 Fixed using war mode not load_unlocking before reloading (bug 3869, r=pred). 2009-09-27 02:25:32 -04:00
David Anderson 0cae3ac5a1 Use case-insensitive game folder matches for Windows (bug 3913, r=pred). 2009-09-27 02:19:17 -04:00
David Anderson 4fc378d3e2 Target filters now run for "@me" special target (bug 4000, r=pred). 2009-09-27 02:17:23 -04:00
Scott Ehlert e3e11d233c Merge. 2009-10-06 13:37:59 -05:00
Scott Ehlert fcfd5c7419 Fixed crash when a plugin was unloaded before a client convar query had returned results (bug 4044, r=dvander). 2009-10-06 13:37:30 -05:00
Erik Minekus be8c498aea Fix help message for sm cvars (bug 3994, r=dvander). 2009-10-06 03:15:10 -07:00
TESLA-X4 5528b9ba09 HL2DM support for OnPlayerRunCmd (bug 3914, r=dvander). 2009-10-06 03:13:44 -07:00
Nicholas Hastings c60877b6f2 GoldenEye:Source supports ShowMenu (bug 3747, r=dvander). 2009-10-06 03:06:02 -07:00
Scott Ehlert 07901946d0 Fixed building of libcurl on Linux when a build clobber is done. 2009-10-06 01:52:08 -05:00
Scott Ehlert 705ea18b2a Really fixed version.rc file problem by removing and recreating build OUTPUT directory when required (bug 4042, r=dvander). 2009-10-06 01:46:06 -05:00
Scott Ehlert 3277cc3675 Fixed case where version.rc files could have incorrect version number (bug 4042, r=dvander). 2009-10-04 00:52:53 -05:00
David Anderson c09b7bed34 Updated to latest GeoLite Country database (OCT-2009). 2009-10-02 05:08:14 -07:00
Fyren 83e633534d New L4D offset for SetUserCvar (bug 4033, r=dvander). 2009-10-02 04:59:47 -07:00
David Anderson 8a2c299653 Fixed rare crash involving hudtext code and maxclient shifts (bug 4016, r=fyren). 2009-10-02 04:30:46 -07:00
David Anderson 74dc2ed1f9 Re-enabled PDB files. 2009-10-02 03:47:42 -07:00
David Anderson dc0d6a9b4a Fixed crash when reloading blocked plugins fails (bug 4038, r+a=fyren). 2009-10-02 03:33:59 -07:00
David Anderson 3f264097a7 Removed unused files. 2009-10-02 03:30:54 -07:00
Nicholas Hastings e0c7b17bd5 Updated GiveNamedItem for latest L4D update (bug 4035, r=dvander). 2009-10-02 02:35:25 -07:00
Fyren d43b027c25 Fixed crash when block-loading more than 8 plugins (bug 4034, r=dvander). 2009-10-02 02:30:01 -07:00
Eric Minekus 85963cafe7 Fixed several plugins excluding the last client from loops (bug 3984, r=dvander). 2009-10-02 02:26:11 -07:00
Fyren d4deeb4edd Puuuuuush for SDK change (bug 4032) 2009-10-01 08:48:57 -07:00
David Anderson c72bfe3685 Another forgotten-file for bug 4015. Thanks mqueues. 2009-09-26 17:19:47 -04:00
David Anderson 90137f2263 Follow-up to bug 4015: apparently hg patch doesn't commit added files. 2009-09-26 17:14:50 -04:00
David Anderson d8474cfafa Added generic command hooking mechanism, to replace Reg*Cmd which is intended for command creation (bug 4015, r=pred). 2009-09-26 17:12:23 -04:00
Matt Schubert 493a756aaa Typo; missed a quotation mark 2009-09-17 13:08:18 -04:00
Matt Schubert 95d30ba4ec Fixed the Huntsman not firing CalcIsAttackCritical (bug 3927, r=dvander) 2009-09-17 12:42:58 -04:00
Matt Woodrow dbcb3e6192 Merge 2009-09-17 19:04:15 +12:00
Matt Woodrow 4228642b53 Rockthevote 'already voted' message now displays RTV progress (bug 4011, r=Fyren) 2009-09-17 18:55:40 +12:00
Matt Woodrow acba87ae46 Added voting output (bug 1997, r=dvander) 2009-09-17 18:54:40 +12:00
David Anderson 533f17b3b0 Block plugins from registering "sm" command (bug 4013, r=pred). 2009-09-16 22:37:20 -07:00
Matt Woodrow 77de71d79d Fixed gnprintf's translation parameter reordering (bug 4010, r=dvander) 2009-09-16 13:38:04 +12:00
David Anderson caadb7fa27 Fixed invalid array access in PluginSys (bug 3933, r=pred). 2009-09-07 21:29:18 -07:00
David Anderson 1dd862f83d Build fix, bug 3818 fallout. 2009-09-07 17:15:47 -07:00
Fyren 70bb4930f6 Respect clientside mutes and add fixed client listening API (bug 3818, r=pred,dvander). 2009-09-07 17:09:28 -07:00
David Anderson 852eb5c524 Fixed BanClient() crashing if called before certain callbacks (bug 3912, r=pred). 2009-09-07 16:21:48 -07:00
Matt Woodrow 3cfc45c4e8 Fixed TR_GetEntityIndex returning -1 for world ent hits (Logical entities bcompat break) 2009-09-05 19:36:12 +12:00
David Anderson db97c2a5b1 Thanks, Python. 2009-08-30 17:27:44 -07:00
David Anderson 70993256b9 Added -lpthread to sourcemod.logic binary. 2009-08-30 17:26:03 -07:00
David Anderson a439c3be3c Added sourcemod.logic to package script. 2009-08-30 12:06:32 -07:00
David Anderson 0a060982e3 Fixed extension version reporting. 2009-08-30 01:54:45 -07:00
David Anderson 7ffcc176cd Fixed build failure in profiler. 2009-08-30 01:43:05 -07:00
David Anderson 4a9650df80 Added missing version file. 2009-08-30 01:40:39 -07:00
David Anderson f1c6f09f98 Added missing configure script. 2009-08-30 01:38:28 -07:00
David Anderson f039c0636e More build fixes. 2009-08-30 01:34:24 -07:00
David Anderson a620e1490c Build fixes. 2009-08-30 01:19:32 -07:00
David Anderson d682361cfc More changes for new build system. 2009-08-30 00:46:56 -07:00
David Anderson d3f0a14867 Imported support for new build system. 2009-08-30 00:21:42 -07:00
David Anderson 83393f299a Removed auto folders (bug 3949). 2009-08-30 00:03:58 -07:00
Matt Woodrow bf1285567e Build fix 2009-08-24 09:41:53 +12:00
DaFox e315726001 Added PointOutsideWorld native to sdktools (bug 3906, r=dvander) 2009-08-24 09:19:42 +12:00
Erik Minekus 2f3e172162 Added "motd" chat trigger to basetriggers (bug 2694, r=dvander) 2009-08-24 09:13:37 +12:00
Kornelijus Survila d6cf9bd8ae Added manual extension reloading command to root console menu (bug 3934, r=dvander) 2009-08-24 09:11:42 +12:00
Zach Kanzler 5710a35388 Added Kick, Ban and IsInKickQueue to public extension API (bug 3907, r=dvander) 2009-08-24 09:05:54 +12:00
Mr E. Unknown 1156d00538 Fixed 'list' type custom menu entries overwriting admin restrictions (bug 3783, r=pred) 2009-08-24 09:02:10 +12:00
Downtown1 5707354a18 Added sm_resetcvar command to basecommands (bug 3636, r=pred) 2009-08-24 08:55:34 +12:00
Matt Schubert 155cc4573c Fixed ForceRespawn offset for TF2 2009-08-20 03:02:43 -04:00
Matt Woodrow 3288592d30 Fixed tf2 build configs 2009-08-17 11:07:14 +12:00
Matt Woodrow 886b683739 Makefile fix 2009-08-17 10:54:57 +12:00
Matt Woodrow 95cffca5f1 Forgot makefiles patch 2009-08-17 10:53:54 +12:00
Matt Woodrow 85cb592a7e Fixed typo in the build tool 2009-08-17 10:44:35 +12:00
Matt Woodrow 13b9deb5ef Merged the build fixes (hopefully) 2009-08-17 10:42:01 +12:00
Matt Woodrow c307c692a0 Copy of new tf engine changes from 1.2 branch 2009-08-17 10:03:53 +12:00
David Anderson 008e98d980 Fixed incorrect escaping in clientprefs SQLite queries (bug 3904, r+a12=pred). 2009-08-10 22:16:58 -04:00
Fyren b11f597521 Fix SetClientViewModel (bug 3941, r=pred) 2009-08-09 15:35:49 -07:00
Matt Woodrow 944c523a49 Fixed incparser for new functag format and added a sample Crimson Editor template 2009-08-09 14:03:50 +12:00
psychonic 3c365259cc Synergy gamedata updates (bug 3315, r=dvander) 2009-07-30 17:17:48 -07:00
David Anderson 98274d4b17 Linux build of pcre-7.9 (bug 3923). 2009-07-28 12:56:16 -05:00
David Anderson 12a1cb9e97 Check-in of pcre-7.9 source code and win32 static lib (bug 3923). 2009-07-28 17:51:34 -04:00
Matt Woodrow d273750849 Mergé 2009-07-28 15:06:57 +12:00
Matt Woodrow 75c54c6738 Fixed regression with sound natives (bug 3918, r=dvander) 2009-07-28 15:05:47 +12:00
Fyren ffd72fbb4d Improve non-admin to admin chat (bug 3844, r=pred) 2009-07-27 17:02:04 -07:00
Fyren 71dc3d4826 Make Insurgency use SayText for printing to chat (bug 3738, r=dvander) 2009-07-27 16:45:30 -07:00
psychonic b7757d71bf Insurgency gamedata updates (bug 3511, r=dvander) 2009-07-27 16:17:13 -07:00
psychonic 55338e731b ZM gamedata updates (bug 3746, r=dvander) 2009-07-27 16:16:33 -07:00
psychonic 097aa3fa16 Empires gamedata updates (bug 3500, r=dvander) 2009-07-27 16:13:55 -07:00
psychonic 935d6a7cf5 ZPS gamedata updates (bug 3877, r=dvander) 2009-07-27 16:04:43 -07:00
psychonic c69d1c7fb8 AoC gamedata updates (bug 3891, r=dvander) 2009-07-27 13:30:01 -07:00
Fyren b5152c0c48 Fix sm_corecfgfile for modified sm_basepaths (bug 3856, r=dvander) 2009-07-27 13:22:55 -07:00
Matt Woodrow ed02df113f A newline again? Really? 2009-07-24 13:17:26 +12:00
Matt Woodrow 2afdcf54ab I surrender GCC! Please? 2009-07-24 13:09:06 +12:00
Matt Woodrow 764fbe7fac A merge? 2009-07-24 12:59:13 +12:00
Matt Woodrow 0c9160ec8b More build fix attempts 2009-07-24 12:54:08 +12:00
Matt Woodrow 33bed487ac Please GCC? 2009-07-24 12:43:13 +12:00
Matt Woodrow 3e36382b58 Added support for logical (non-networked) entities using entity references - See http://wiki.alliedmods.net/Entity_References_%28SourceMod%29 (bug 2459, r=dvander) 2009-07-24 12:34:31 +12:00
Matt Schubert 7ec656db09 Fix RemoveDisguise Windows signature for TF2 2009-07-09 17:51:12 -04:00
Matt Schubert cf61779b08 Backed out changeset a42b24399f60 2009-07-09 17:49:26 -04:00
Matt Schubert 71600a4f37 Fix RemoveDisguise Windows signature for TF2 (bug 3892) 2009-07-09 17:45:20 -04:00
Fyren 14320f2155 Fix PlayerRunCmd offset for TF2 2009-06-16 19:41:44 -07:00
David Anderson 1923368353 Fixed build. 2009-05-30 20:04:55 -04:00
David Anderson 752bd78de5 Fixed compiler asserting when returning a string literal (bug 3836, r=fyren). 2009-05-30 20:03:56 -04:00
David Anderson c4b17855e5 Fixed compiler erroring when tagging functions for string return (bug 3837, r=fyren). 2009-05-30 20:03:01 -04:00
David Anderson a1543f79cb Fixed compiler not handling constant chained relational operators correctly (bug 3838, r=fyren). 2009-05-30 20:02:05 -04:00
David Anderson d4798ccaa5 Fixed revote bug and inflexibilities in RedrawClientVoteMenu (bug 3834, r=fyren). 2009-05-30 19:59:55 -04:00
Fyren c2c4ed1fe5 Fix crash when unloading a plugin with live user message hooks (bug 3817, r=dvander) 2009-05-25 18:12:26 -07:00
David Anderson 614188c82b Fixed compiler using NDEBUG in debug builds (bug 3815, r=fyren). 2009-05-24 12:08:27 -04:00
David Anderson 53e98c114a Fixed Plugin_Handled acting like a Stop in usermsg hooks (bug 3685, r=fyren). 2009-05-24 12:01:18 -04:00
Fyren 73c8246204 Preliminary TF2 gamedata changes 2009-05-21 20:43:22 -07:00
Matt Woodrow 58d98f8454 Fixed crash on client disconnect 2009-05-19 15:16:25 +12:00
Fyren 7605396e84 Add L4D handling to GuessSDKVersion() (bug 3842, r=dvander) 2009-05-16 16:32:21 -07:00
"David Anderson cec339552e Moved smn_functions to logic binary.
--HG--
rename : core/smn_functions.cpp => core/logic/smn_functions.cpp
2009-05-14 11:38:50 -04:00
"David Anderson fc003db139 Updated MSVC9 files. 2009-05-14 11:28:43 -04:00
"David Anderson caf434aef2 Moved profiler and adt_trie to logic binary.
--HG--
rename : core/Profiler.cpp => core/logic/Profiler.cpp
rename : core/Profiler.h => core/logic/Profiler.h
rename : core/smn_adt_trie.cpp => core/logic/smn_adt_trie.cpp
2009-05-14 11:24:07 -04:00
David Anderson 5261873f39 Fixed Linux build. 2009-05-13 22:07:11 -04:00
David Anderson 421b58f68e Import of core modularization plan (bug 3599). 2009-05-13 21:55:50 -04:00
Fyren 850dbd62c6 Fix pred's failed l2merge merge 2009-05-13 16:24:55 -07:00
David Anderson 2af45da0a8 Merge from 1.2 branch. 2009-05-12 19:43:21 -04:00
David Anderson 685e8bac22 DOS line endings to match 1.2 branch. 2009-05-12 19:43:02 -04:00
Fyren 47002f970d Fix bad bintools assert that will always fail in debug (r=pred) 2009-05-11 19:45:51 -07:00
Matt Woodrow f6fd395485 I dislike you GCC 2009-05-12 14:19:06 +12:00
Matt Woodrow 4f426dafef Merged, thanks Fyren 2009-05-12 13:56:00 +12:00
Matt Woodrow 7b6f2863a9 Added PlayerRunCmd hook to sdktools (bug 3289, r=dvander) 2009-05-12 13:54:06 +12:00
Fyren 834a9bc84d Some sdktools string and style changes (r=pred) 2009-05-11 18:46:19 -07:00
Matt Woodrow 7710a1fdb0 Merge from 1.2 branch 2009-05-11 11:45:08 +12:00
Matt Woodrow 4abdc29d9e l2merge Fyren 2009-04-24 18:20:55 +12:00
Fyren a4295d1e93 Add a warning to not edit SM's gamedata files; switched to UNIX line endings (bug 3728, r=dvander) 2009-04-07 09:59:21 -07:00
Fyren c9ff6be881 Fix CommitSuicide offset (bug 3726, r=Srdog) 2009-04-01 04:34:01 -07:00
David Anderson 40a8892cb7 Merge from sourcemod-1.2 branch. 2009-03-30 11:43:16 +02:00
Fyren 933b77e429 Fix sm exts info help message 2009-03-25 21:01:40 -07:00
Fyren ccc4386285 Let vtablecheck take class names instead of just vtable symbols (also fix line endings) 2009-03-21 18:17:43 -07:00
Fyren 4364ba46e2 Switch base plugins to APL2; disable nextmap for L4D, Dystopia, Synergy (bugs 3716, 3687, 3741; r=pred) 2009-03-18 22:10:39 -07:00
Fyren d7917a6a9a Add AskPluginLoad2() to allow silent failure, deprecate AskPluginLoad() (bug 3716, r=dvander) 2009-03-18 19:20:40 -07:00
Fyren 81e30e75c4 Merge: this'll teach me to not pull first 2009-03-18 19:15:40 -07:00
Fyren 7a94343dec Fix/restore TF2_IgnitePlayer (bug 3528, r=pred) 2009-03-18 18:50:31 -07:00
Fyren 9a77e6b3cc Gave OnClientAuthorized() its meds. 2009-03-18 18:34:46 -07:00
Fyren a1727cc047 vim syntax file and a perl script to generate a syntax file from the includes 2009-03-18 18:30:35 -07:00
Matt Woodrow 5b012b6509 Merge 2009-03-17 12:31:10 +13:00
Matt Woodrow c23ffa2ce5 Added GetClientCookieTime native (bug 3736, r=dvander) 2009-03-17 12:30:21 +13:00
Matt Woodrow ff68383732 Added GetClientCookieTime native (bug 3736, r=dvander) 2009-03-17 12:29:10 +13:00
Matt Woodrow bce2b2adb6 Added new playerhelpers interface 2009-03-17 12:28:37 +13:00
Matt Woodrow fa8c9a8418 Clientprefs now loads cookies for clients on late load (bug 3735, r=dvander) 2009-03-17 12:28:05 +13:00
Fyren f6bb6037f3 Allow spaces in compiler command line options (bug 3729, r=dvander) 2009-03-12 18:37:04 -07:00
Scott Ehlert 7fac7c8713 Pushing a build to test buildbot against mercurial 1.2. 2009-03-09 06:38:20 -05:00
David Anderson bdaef0b0dc Pushing build to test buildbot. 2009-03-09 01:21:01 -04:00
Liam 134cb68396 Removed the alive check from sm_rename. Added in additional support for CSS / OB engines. 2009-03-07 16:58:14 -05:00
David Anderson a299533508 Bumping merge node so buildbot doesn't puke. 2009-03-06 14:45:03 -05:00
David Anderson d4bcbc3771 Merge from 1.2 branch. 2009-03-06 14:44:25 -05:00
Scott Ehlert d8264fada7 Merge from 1.2 branch. 2009-03-05 15:48:38 -06:00
David Anderson 1f636bf7a9 Bumped trunk to 1.3.0. 2009-03-05 01:48:18 -05:00
507 changed files with 187551 additions and 7265 deletions
+8
View File
@@ -6,6 +6,7 @@
# Files generated by Visual Studio # Files generated by Visual Studio
\.aps$ \.aps$
\.ncb$ \.ncb$
\.sdf$
\.suo$ \.suo$
\.user$ \.user$
@@ -13,3 +14,10 @@
/CrazyDebug.* /CrazyDebug.*
/Debug.* /Debug.*
/Release.* /Release.*
# Files generated by Mac OS X Finder
(^|/)\.DS_Store$
# Files generated by Windows Explorer
(^|/)[dD]esktop\.ini$
(^|/)[tT]humbs\.db$
+13 -3
View File
@@ -3,6 +3,16 @@ e6ef5ecdf8d75740ca2685a709bf321f8873bc3b sourcemod-1.1.0
e877885fac80be71822641f7a9122cebc9812521 sourcemod-1.1.1 e877885fac80be71822641f7a9122cebc9812521 sourcemod-1.1.1
b3ffa8a4511c4eadaf533fc790aa6b14f7f0c6ea sourcemod-1.1.2 b3ffa8a4511c4eadaf533fc790aa6b14f7f0c6ea sourcemod-1.1.2
3a73bbf60f34befa9b66be03fa5974b394bb3411 sourcemod-1.2.0 3a73bbf60f34befa9b66be03fa5974b394bb3411 sourcemod-1.2.0
3c30a59c2296a13284a9f4eb42863b47db645adf sourcemod-1.2.1 a71318396392e3c6d0ff31e069a60fbde59e0cea sourcemod-1.3.0
f55c735efeefe68863b96713fcd55a7774d8ceab sourcemod-1.2.2 3f33d01fcc28b509bed30f7be07ed215cc000538 sourcemod-1.3.1
236a032c2a4da8f0af24b56b0539b1c574379be8 sourcemod-1.2.3 a3e8f7a7fdf7f012dd02ad491a2e1ccdad151687 sourcemod-1.3.2
c5062ca8283033cf33f45da6f19e486ca10835ff sourcemod-1.3.3
4d6afc42522c8f416dc45be7af7b145507b00630 sourcemod-1.3.4
9de8baa40cc593d8ca5f976a3357772e804ae9e8 sourcemod-1.3.5
8036343199caaf2812b21bb24f1fa84bf5a9e2ef sourcemod-1.3.6
0f35d8b324ba8f6272dac3e473f056b451a13b54 sourcemod-1.3.7
2726e2ec8c90bfc547753c5a2a160b726587ecde sourcemod-1.3.8
2726e2ec8c90bfc547753c5a2a160b726587ecde sourcemod-1.3.8
fa2f05c3ae003a01cc0d65df8998fcb1a936328e sourcemod-1.3.8
fa2f05c3ae003a01cc0d65df8998fcb1a936328e sourcemod-1.3.8
0000000000000000000000000000000000000000 sourcemod-1.3.8
+53 -18
View File
@@ -17,26 +17,32 @@ class SM:
'name': 'ORANGEBOXVALVE'} 'name': 'ORANGEBOXVALVE'}
self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '5', self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '5',
'name': 'LEFT4DEAD'} 'name': 'LEFT4DEAD'}
self.sdkInfo['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '6',
'name': 'LEFT4DEAD2'}
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':
self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2',
'name': 'DARKMESSIAH'} 'name': 'DARKMESSIAH'}
self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '7',
'name': 'ALIENSWARM'}
if AMBuild.mode == 'config': if AMBuild.mode == 'config':
#Detect compilers #Detect compilers
self.compiler.DetectAll(AMBuild) self.compiler.DetectAll(AMBuild)
#Detect variables #Detect variables
envvars = { 'MMSOURCE17': 'mmsource-1.7', envvars = { 'MMSOURCE18': 'mmsource-1.8',
'HL2SDK': 'hl2sdk', 'HL2SDK': 'hl2sdk',
'HL2SDKOB': 'hl2sdk-ob', 'HL2SDKOB': 'hl2sdk-ob',
'HL2SDKL4D': 'hl2sdk-l4d', 'HL2SDKL4D': 'hl2sdk-l4d',
'HL2SDKOBVALVE': 'hl2sdk-ob-valve', 'HL2SDKOBVALVE': 'hl2sdk-ob-valve',
'HL2SDKL4D2': 'hl2sdk-l4d2',
'MYSQL5': 'mysql-5.0' 'MYSQL5': 'mysql-5.0'
} }
#Dark Messiah is Windows-only #Dark Messiah is Windows-only
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':
envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm' envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
#Must have a path for each envvar (file a bug if you don't like this) #Must have a path for each envvar (file a bug if you don't like this)
for i in envvars: for i in envvars:
@@ -46,12 +52,14 @@ class SM:
raise Exception('Path for {0} was not found: {1}'.format(i, path)) raise Exception('Path for {0} was not found: {1}'.format(i, path))
else: else:
head = os.getcwd() head = os.getcwd()
while head != None and head != '/': oldhead = None
while head != None and head != oldhead:
path = os.path.join(head, envvars[i]) path = os.path.join(head, envvars[i])
if os.path.isdir(path): if os.path.isdir(path):
break break
oldhead = head
head, tail = os.path.split(head) head, tail = os.path.split(head)
if head == None or head == '/': if head == None or head == oldhead:
raise Exception('Could not find a valid path for {0}'.format(i)) raise Exception('Could not find a valid path for {0}'.format(i))
AMBuild.cache.CacheVariable(i, path) AMBuild.cache.CacheVariable(i, path)
@@ -76,7 +84,7 @@ class SM:
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse') self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-msse') self.compiler.AddToListVar('CFLAGS', '-msse')
self.compiler.AddToListVar('CFLAGS', '-m32') self.compiler.AddToListVar('CFLAGS', '-m32')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc') self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc')
self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions') self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti') self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics') self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
@@ -86,6 +94,7 @@ class SM:
self.vendor = 'msvc' self.vendor = 'msvc'
if AMBuild.options.debug == '1': if AMBuild.options.debug == '1':
self.compiler.AddToListVar('CFLAGS', '/MTd') self.compiler.AddToListVar('CFLAGS', '/MTd')
self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt')
else: else:
self.compiler.AddToListVar('CFLAGS', '/MT') self.compiler.AddToListVar('CFLAGS', '/MT')
self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE') self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE')
@@ -119,8 +128,9 @@ class SM:
if self.vendor == 'gcc': if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-O3') self.compiler.AddToListVar('CFLAGS', '-O3')
elif self.vendor == 'msvc': elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Ot') self.compiler.AddToListVar('CFLAGS', '/Ox')
self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF') self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF')
self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF')
#Debugging #Debugging
if AMBuild.options.debug == '1': if AMBuild.options.debug == '1':
@@ -154,7 +164,9 @@ class SM:
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':
self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'public')) self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'public'))
self.mmsPath = AMBuild.cache['MMSOURCE17'] self.compiler.AddToListVar('RCINCLUDES',
os.path.join(AMBuild.outputFolder, 'includes'))
self.mmsPath = AMBuild.cache['MMSOURCE18']
def DefaultCompiler(self): def DefaultCompiler(self):
return self.compiler.Clone() return self.compiler.Clone()
@@ -181,7 +193,7 @@ class SM:
def AutoVersion(self, folder, binary): def AutoVersion(self, folder, binary):
if AMBuild.target['platform'] != 'windows': if AMBuild.target['platform'] != 'windows':
return return
env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"']} env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'SM_GENERATED_BUILD']}
binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env) binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env)
def PreSetupHL2Job(self, job, builder, sdk): def PreSetupHL2Job(self, job, builder, sdk):
@@ -193,15 +205,27 @@ class SM:
else: else:
staticLibs = os.path.join(sdkPath, 'lib', 'linux') staticLibs = os.path.join(sdkPath, 'lib', 'linux')
workFolder = os.path.join(AMBuild.outputFolder, job.workFolder) workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
for i in ['tier1_i486.a', 'mathlib_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']: if sdk in ['ep2v', 'l4d', 'l4d2']:
link = os.path.join(workFolder, i) for i in ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.so', 'libtier0.so']:
target = os.path.join(staticLibs, i) link = os.path.join(workFolder, i)
try: target = os.path.join(staticLibs, i)
os.lstat(link) try:
except: os.lstat(link)
job.AddCommand(SymlinkCommand(link, target)) except:
job.AddCommand(SymlinkCommand(link, target))
else:
for i in ['tier1_i486.a', 'mathlib_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']:
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': elif AMBuild.target['platform'] == 'windows':
for lib in ['tier0', 'tier1', 'vstdlib', 'mathlib']: libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
if sdk == 'swarm':
libs.append('interfaces')
for lib in libs:
libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib' libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib'
builder.RebuildIfNewer(libPath) builder.RebuildIfNewer(libPath)
builder['POSTLINKFLAGS'].append(libPath) builder['POSTLINKFLAGS'].append(libPath)
@@ -222,14 +246,17 @@ class SM:
info = self.sdkInfo info = self.sdkInfo
compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info]) compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info])
compiler['CDEFINES'].append('SE_DARKMESSIAH=2') if AMBuild.target['platform'] != 'windows':
compiler['CDEFINES'].extend(['SE_DARKMESSIAH=2', 'SE_ALIENSWARM=7'])
paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'], paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],
['public', 'tier0'], ['public', 'tier1']] ['public', 'tier0'], ['public', 'tier1']]
if sdk == 'ep1' or sdk == 'darkm': if sdk == 'ep1' or sdk == 'darkm':
paths.append(['public', 'dlls']) paths.append(['public', 'dlls'])
paths.append(['game_shared'])
else: else:
paths.append(['public', 'game', 'server']) paths.append(['public', 'game', 'server'])
paths.append(['game', 'shared'])
paths.append(['common']) paths.append(['common'])
info = self.sdkInfo[sdk] info = self.sdkInfo[sdk]
@@ -237,6 +264,9 @@ class SM:
compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def']) 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 sdk == 'ep1':
if AMBuild.target['platform'] == 'linux': if AMBuild.target['platform'] == 'linux':
staticLibs = os.path.join(sdkPath, 'linux_sdk') staticLibs = os.path.join(sdkPath, 'linux_sdk')
@@ -250,8 +280,12 @@ class SM:
if not noLink: if not noLink:
if AMBuild.target['platform'] == 'linux': if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'][0:0] = ['-lm'] compiler['POSTLINKFLAGS'][0:0] = ['-lm']
compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so'] if sdk in ['ep2v', 'l4d', 'l4d2']:
compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so'] 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']
return compiler return compiler
@@ -265,6 +299,7 @@ AMBuild.Include(os.path.join('tools', 'buildbot', 'Versioning'), globals)
FileList = [ FileList = [
['loader', 'AMBuilder'], ['loader', 'AMBuilder'],
['core', 'AMBuilder'], ['core', 'AMBuilder'],
['core', 'logic', 'AMBuilder'],
['extensions', 'bintools', 'AMBuilder'], ['extensions', 'bintools', 'AMBuilder'],
['extensions', 'clientprefs', 'AMBuilder'], ['extensions', 'clientprefs', 'AMBuilder'],
['extensions', 'cstrike', 'AMBuilder'], ['extensions', 'cstrike', 'AMBuilder'],
+235
View File
@@ -1,5 +1,240 @@
SourceMod Changelog SourceMod Changelog
-----------------------------
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]
URL: http://wiki.alliedmods.net/SourceMod_1.3.2_Release_Notes
User Changes:
- Support for recent TF, DoD, and L4D2 updates (bug 4356, bug 4361, bug 4371, bug 4374, bug 4375).
- Fixed rare crash when replicating cvars to clients (bug 4315).
- Lots of extra game support for Insurgency, ZPS, CSProMod, PVKII, and FortressForever (thanks
Nicholas "psychonic" hastings).
Developer Changes:
- Added TF functions for stunning, conditions, regeneration, and power play (bug 4166, bug 4331).
----------------------------
SourceMod 1.3.1 [2010-02-09]
URL: http://wiki.alliedmods.net/SourceMod_1.3.1_Release_Notes
User Changes:
- Added extended support for CSProMod (bug 4255).
- Fixed client disconnect crash on many third party games (bug 4231).
- Improved support for Battlegrounds 2 (bug 4146).
- Improved support for Insurgency (bug 4180).
- Improved support for Garry's Mod (bug 4230, bug 4268).
- Improved support for Synergy (bug 4235).
- Updated Day of Defeat support for 20010123 update (bug 4262).
- Fixed Webternet extension not loading on Windows 2000 (bug 4234).
Developer Changes:
- Fixed compiler complaints when using |any| tag on array arguments (bug 4274).
- Fixed GetClientCookieTime not being exported (bug 4237).
- Fixed potential crash in entity handling code (bug 4249).
----------------------------
SourceMod 1.3.0 [2010-01-15]
URL: http://wiki.alliedmods.net/SourceMod_1.3.0_Release_Notes
Major Features:
* Left 4 Dead 2 support
* Non-networked entity support
User Changes:
- Added Left 4 Dead 2 support (bug 4075).
- Added much richer voting progress feedback (bug 1997).
- Improved support for various third-party games (Nicholas "psychonic" Hastings).
- Added @spec target (bug 2718).
- Added sm_resetcvar command (bug 3636).
- Added "motd" chat trigger (bug 2694).
- Updated GeoIP to OCT-2009.
- Fixed rare map vote error (bug 3905).
- Fixed small leak in the nominations plugin (bug 4104).
- Fixed last client being excluded from some command effects (bug 3984).
- Fixed crashes in plugin [|un|re]loading (bug 4034, bug 4038, bug 4044, bug 4153).
- Special target "@me" is now filtered for certain statuses properly (bug 4000).
- Improved non-admin to admin chat (bug 3844).
- Removed "auto.*" extension folders (bug 3949).
Developer Changes:
- Added non-networked entity support (bug 2459).
- Added improved random number generator (bug 3831).
- Added GetClientCookieTime native (bug 3736).
- Added AskPluginLoad2 callback (bug 3716).
- Added PlayerRunCmd callback (bug 3289).
- Added PointOutsideWorld native (bug 3906).
- Added API for "blanket" command hooks (bug 4015).
- Added ability to test for SourceMod features (bug 4021).
- Added ability to change broadcast status on hooked events (bug 3886).
- OnClientCommand no longer receives unconnected clients (bug 3732).
- Fixed various bugs in client listening API (bug 3818).
- Fixed crash in BanClient (bug 3912).
- Fixed various crashes in self-removing callbacks (bug 4059).
- Fixed rare HUD text crash on TF (bug 4016).
- Fixed OnConfigsExecuted not running on EP1 games with large configs (bug 3828).
- Fixed entity output hooks not working (bug 3988).
- Gamedata folder matches are now case-insensitive (bug 3913).
- Blocked plugins from hooking "sm" command (bug 4013).
---------------------------- ----------------------------
SourceMod 1.2.4 [2009-10-03] SourceMod 1.2.4 [2009-10-03]
+1
View File
@@ -1,6 +1,7 @@
//This file unloads all plugins, re-loads a few "safe" ones, and then prevents //This file unloads all plugins, re-loads a few "safe" ones, and then prevents
//any more plugins from being loaded. //any more plugins from being loaded.
sm plugins unload_all sm plugins unload_all
sm plugins load_unlock
sm plugins load basebans.smx sm plugins load basebans.smx
sm plugins load basecommands.smx sm plugins load basecommands.smx
sm plugins load admin-flatfile.smx sm plugins load admin-flatfile.smx
+28 -3
View File
@@ -80,21 +80,21 @@ sm_reserve_type 0
sm_reserved_slots 0 sm_reserved_slots 0
// Specifies whether or not reserved slots will be hidden (subtracted from max // Specifies whether or not reserved slots will be hidden (subtracted from max
// slot count). Valid values are 0 (visible) or 1 (hidden). // slot count). Valid values are 0 (Visible) or 1 (Hidden).
// -- // --
// Requires: reservedslots.smx // Requires: reservedslots.smx
// Default: 0 // Default: 0
sm_hide_slots 0 sm_hide_slots 0
// Specifies whether or not non-admins can send messages to admins using // Specifies whether or not non-admins can send messages to admins using
// say_team @<message>. Valid values are 0 (disabled) or 1 (enabled) // say_team @<message>. Valid values are 0 (Disabled) or 1 (Enabled)
// -- // --
// Requires: basechat.smx // Requires: basechat.smx
// Default: 1 // Default: 1
sm_chat_mode 1 sm_chat_mode 1
// Specifies whether or not "timeleft" will automaticly be triggered every // Specifies whether or not "timeleft" will automaticly be triggered every
// x seconds. Valid values are 0 (disabled) to 1800 seconds. // x seconds. Valid values are 0 (Disabled) to 1800 seconds.
// -- // --
// Requires: basetriggers.smx // Requires: basetriggers.smx
// Default: 0 // Default: 0
@@ -107,3 +107,28 @@ sm_timeleft_interval 0
// Requires: basetriggers.smx // Requires: basetriggers.smx
// Default: 1 // Default: 1
sm_trigger_show 1 sm_trigger_show 1
// Specifies whether or not to display vote progress to clients in the
// "hint" box (near the bottom of the screen in most games).
// Valid values are 0 (Disabled) or 1 (Enabled).
// --
// Default: 0
sm_vote_progress_hintbox 0
// Specifies whether or not to display vote progress to clients in the
// chat area. Valid values are 0 (Disabled) or 1 (Enabled).
// --
// Default: 0
sm_vote_progress_chat 0
// Specifies whether or not to display vote progress in the server console.
// Valid values are 0 (Disabled) or 1 (Enabled).
// --
// Default: 0
sm_vote_progress_console 0
// Specifies whether or not to display vote progress to clients in the
// client console. Valid values are 0 (Disabled) or 1 (Enabled).
// --
// Default: 0
sm_vote_progress_client_console 0
+2 -20
View File
@@ -6,9 +6,6 @@ for i in SM.sdkInfo:
name = 'sourcemod.' + sdk['ext'] name = 'sourcemod.' + sdk['ext']
compiler = SM.DefaultHL2Compiler('core', i) compiler = SM.DefaultHL2Compiler('core', i)
compiler['CDEFINES'].append('SM_DEFAULT_THREADER')
if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'].append('-lpthread')
extension = AMBuild.AddJob(name) extension = AMBuild.AddJob(name)
binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
@@ -18,8 +15,8 @@ for i in SM.sdkInfo:
'ExtensionSys.cpp', 'ExtensionSys.cpp',
'MenuStyle_Valve.cpp', 'MenuStyle_Valve.cpp',
'sm_crc32.cpp', 'sm_crc32.cpp',
'logic_bridge.cpp',
'smn_entities.cpp', 'smn_entities.cpp',
'smn_maplists.cpp',
'sm_stringutil.cpp', 'sm_stringutil.cpp',
'ADTFactory.cpp', 'ADTFactory.cpp',
'ForwardSys.cpp', 'ForwardSys.cpp',
@@ -38,24 +35,16 @@ for i in SM.sdkInfo:
'ChatTriggers.cpp', 'ChatTriggers.cpp',
'GameConfigs.cpp', 'GameConfigs.cpp',
'NativeOwner.cpp', 'NativeOwner.cpp',
'smn_adt_array.cpp',
'smn_filesystem.cpp', 'smn_filesystem.cpp',
'smn_player.cpp', 'smn_player.cpp',
'sourcemod.cpp', 'sourcemod.cpp',
'concmd_cleaner.cpp', 'concmd_cleaner.cpp',
'HalfLife2.cpp', 'HalfLife2.cpp',
'NextMap.cpp', 'NextMap.cpp',
'smn_adt_stack.cpp',
'smn_float.cpp',
'smn_profiler.cpp', 'smn_profiler.cpp',
'TextParsers.cpp',
'ConCmdManager.cpp', 'ConCmdManager.cpp',
'HandleSys.cpp', 'HandleSys.cpp',
'PhraseCollection.cpp', 'PhraseCollection.cpp',
'smn_adt_trie.cpp',
'smn_functions.cpp',
'smn_sorting.cpp',
'ThreadSupport.cpp',
'ConVarManager.cpp', 'ConVarManager.cpp',
'LibrarySys.cpp', 'LibrarySys.cpp',
'PlayerManager.cpp', 'PlayerManager.cpp',
@@ -68,7 +57,6 @@ for i in SM.sdkInfo:
'PluginInfoDatabase.cpp', 'PluginInfoDatabase.cpp',
'smn_bitbuffer.cpp', 'smn_bitbuffer.cpp',
'smn_halflife.cpp', 'smn_halflife.cpp',
'smn_textparse.cpp',
'Translator.cpp', 'Translator.cpp',
'MemoryUtils.cpp', 'MemoryUtils.cpp',
'PluginSys.cpp', 'PluginSys.cpp',
@@ -78,7 +66,6 @@ for i in SM.sdkInfo:
'UserMessages.cpp', 'UserMessages.cpp',
'Database.cpp', 'Database.cpp',
'MenuManager.cpp', 'MenuManager.cpp',
'Profiler.cpp',
'smn_core.cpp', 'smn_core.cpp',
'smn_hudtext.cpp', 'smn_hudtext.cpp',
'smn_usermsgs.cpp', 'smn_usermsgs.cpp',
@@ -94,13 +81,8 @@ for i in SM.sdkInfo:
'smn_datapacks.cpp', 'smn_datapacks.cpp',
'smn_lang.cpp', 'smn_lang.cpp',
'sm_srvcmds.cpp', 'sm_srvcmds.cpp',
'thread/ThreadWorker.cpp', 'ConsoleDetours.cpp'
'thread/BaseWorker.cpp'
] ]
if AMBuild.target['platform'] == 'windows':
files.append('thread/WinThreads.cpp')
else:
files.append('thread/PosixThreads.cpp')
binary.AddSourceFiles('core', files) binary.AddSourceFiles('core', files)
SM.PostSetupHL2Job(extension, binary, i) SM.PostSetupHL2Job(extension, binary, i)
SM.AutoVersion('core', binary) SM.AutoVersion('core', binary)
+36 -39
View File
@@ -226,30 +226,38 @@ void ConCmdManager::SetCommandClient(int client)
m_CmdClient = client + 1; 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) ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
{ {
ConCmdInfo *pInfo; ConCmdInfo *pInfo;
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) if ((pInfo = FindInTrie(cmd)) == NULL)
{ {
List<ConCmdInfo *>::iterator iter; ConCmdList::iterator item = FindInList(cmd);
if (item == m_CmdList.end())
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; return type;
} pInfo = *item;
} }
cell_t result = type; cell_t result = type;
@@ -314,35 +322,20 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
*/ */
const char *cmd = g_HL2.CurrentCommandName(); const char *cmd = g_HL2.CurrentCommandName();
ConCmdInfo *pInfo; ConCmdInfo *pInfo = FindInTrie(cmd);
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) if (pInfo == NULL)
{ {
/* Unfortunately, we now have to do a slow lookup because Valve made client commands /* Unfortunately, we now have to do a slow lookup because Valve made client commands
* case-insensitive. We can't even use our sortedness. * case-insensitive. We can't even use our sortedness.
*/ */
if (client == 0 && !engine->IsDedicatedServer()) if (client == 0 && !engine->IsDedicatedServer())
{
return; return;
}
List<ConCmdInfo *>::iterator iter; ConCmdList::iterator item = FindInList(cmd);
if (item == m_CmdList.end())
return;
pInfo = NULL; pInfo = *item;
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 /* This is a hack to prevent say triggers from firing on messages that were
@@ -916,6 +909,10 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
ConCmdInfo *pInfo; ConCmdInfo *pInfo;
if (!sm_trie_retrieve(m_pCmds, name, (void **)&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(); pInfo = new ConCmdInfo();
/* Find the commandopan */ /* Find the commandopan */
ConCommand *pCmd = FindCommand(name); ConCommand *pCmd = FindCommand(name);
+10 -1
View File
@@ -92,6 +92,8 @@ struct ConCmdInfo
bool is_admin_set; /**< Whether or not admin info is set */ bool is_admin_set; /**< Whether or not admin info is set */
}; };
typedef List<ConCmdInfo *> ConCmdList;
class ConCmdManager : class ConCmdManager :
public SMGlobalClass, public SMGlobalClass,
public IRootConsoleCommand, public IRootConsoleCommand,
@@ -139,6 +141,12 @@ private:
void RemoveConCmds(List<CmdHook *> &cmdlist); void RemoveConCmds(List<CmdHook *> &cmdlist);
void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext); void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext);
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin); 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: public:
inline int GetCommandClient() inline int GetCommandClient()
{ {
@@ -151,7 +159,7 @@ public:
private: private:
Trie *m_pCmds; /* command lookup */ Trie *m_pCmds; /* command lookup */
Trie *m_pCmdGrps; /* command group lookup */ Trie *m_pCmdGrps; /* command group lookup */
List<ConCmdInfo *> m_CmdList; /* command list */ ConCmdList m_CmdList; /* command list */
int m_CmdClient; /* current client */ int m_CmdClient; /* current client */
BaseStringTable m_Strings; /* string table */ BaseStringTable m_Strings; /* string table */
}; };
@@ -159,3 +167,4 @@ private:
extern ConCmdManager g_ConCmds; extern ConCmdManager g_ConCmds;
#endif // _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_ #endif // _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
+89
View File
@@ -0,0 +1,89 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 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_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;
};
#else
class ConCommandBaseIterator
{
public:
inline ConCommandBaseIterator()
{
iter = icvar->GetCommands();
}
inline bool IsValid()
{
return iter != NULL;
}
inline void Next()
{
iter = const_cast<ConCommandBase *>(iter->GetNext());
}
inline ConCommandBase *Get()
{
return iter;
}
private:
ConCommandBase *iter;
};
#endif
#endif /* _INCLUDE_SOURCEMOD_CON_COMMAND_BASE_ITERATOR_H_ */
+57 -7
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -25,8 +25,6 @@
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/ */
#include "ConVarManager.h" #include "ConVarManager.h"
@@ -60,6 +58,40 @@ const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String}
typedef List<const ConVar *> ConVarList; typedef List<const ConVar *> ConVarList;
KTrie<ConVarInfo *> convar_cache; KTrie<ConVarInfo *> convar_cache;
class ConVarReentrancyGuard
{
ConVar *cvar;
ConVarReentrancyGuard *up;
public:
static ConVarReentrancyGuard *chain;
ConVarReentrancyGuard(ConVar *cvar)
: cvar(cvar), up(chain)
{
chain = this;
}
~ConVarReentrancyGuard()
{
assert(chain == this);
chain = up;
}
static bool IsCvarInChain(ConVar *cvar)
{
ConVarReentrancyGuard *guard = chain;
while (guard != NULL)
{
if (guard->cvar == cvar)
return true;
guard = guard->up;
}
return false;
}
};
ConVarReentrancyGuard *ConVarReentrancyGuard::chain = NULL;
ConVarManager::ConVarManager() : m_ConVarType(0), m_bIsDLLQueryHooked(false), m_bIsVSPQueryHooked(false) ConVarManager::ConVarManager() : m_ConVarType(0), m_bIsDLLQueryHooked(false), m_bIsVSPQueryHooked(false)
{ {
} }
@@ -96,6 +128,8 @@ void ConVarManager::OnSourceModAllInitialized()
SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false);
g_PluginSys.AddPluginsListener(this);
/* Add the 'convars' option to the 'sm' console command */ /* Add the 'convars' option to the 'sm' console command */
g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this);
} }
@@ -162,6 +196,8 @@ void ConVarManager::OnSourceModShutdown()
/* Remove the 'convars' option from the 'sm' console command */ /* Remove the 'convars' option from the 'sm' console command */
g_RootMenu.RemoveRootConsoleCommand("cvars", this); g_RootMenu.RemoveRootConsoleCommand("cvars", this);
g_PluginSys.RemovePluginsListener(this);
/* Remove the 'ConVar' handle type */ /* Remove the 'ConVar' handle type */
g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent); g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent);
} }
@@ -180,7 +216,7 @@ void ConVarManager::OnSourceModVSPReceived()
} }
/* For later MM:S versions, use the updated API, since it's cleaner. */ /* For later MM:S versions, use the updated API, since it's cleaner. */
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
int engine = g_SMAPI->GetSourceEngineBuild(); int engine = g_SMAPI->GetSourceEngineBuild();
if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2) if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2)
{ {
@@ -252,12 +288,23 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
void ConVarManager::OnPluginUnloaded(IPlugin *plugin) void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
{ {
ConVarList *pConVarList; ConVarList *pConVarList;
List<ConVarQuery>::iterator iter;
/* If plugin has a convar list, free its memory */ /* If plugin has a convar list, free its memory */
if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true)) if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true))
{ {
delete pConVarList; delete pConVarList;
} }
/* Remove convar queries for this plugin that haven't returned results yet */
for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++)
{
ConVarQuery &query = (*iter);
if (query.pCallback->GetParentRuntime() == plugin->GetRuntime())
{
m_ConVarQueries.erase(iter);
}
}
} }
void ConVarManager::OnHandleDestroy(HandleType_t type, void *object) void ConVarManager::OnHandleDestroy(HandleType_t type, void *object)
@@ -315,7 +362,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
} }
/* Display usage of subcommand */ /* Display usage of subcommand */
g_RootMenu.ConsolePrint("[SM] Usage: sm convars <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) 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)
@@ -523,7 +570,8 @@ void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFuncti
} }
/* If the forward now has 0 functions in it... */ /* If the forward now has 0 functions in it... */
if (pForward->GetFunctionCount() == 0) if (pForward->GetFunctionCount() == 0 &&
!ConVarReentrancyGuard::IsCvarInChain(pConVar))
{ {
/* Free this forward */ /* Free this forward */
g_Forwards.ReleaseForward(pForward); g_Forwards.ReleaseForward(pForward);
@@ -634,6 +682,8 @@ void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue)
if (pForward != NULL) if (pForward != NULL)
{ {
ConVarReentrancyGuard guard(pConVar);
/* Now call forwards in plugins that have hooked this */ /* Now call forwards in plugins that have hooked this */
pForward->PushCell(pInfo->handle); pForward->PushCell(pInfo->handle);
pForward->PushString(oldValue); pForward->PushString(oldValue);
+742
View File
@@ -0,0 +1,742 @@
/**
* 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$
*/
/**
* On SourceHook v4.3 or lower, there are no DVP hooks. Very sad, right?
* Only do this on newer versions. For the older code, we'll do an incredibly
* hacky detour.
*
* The idea of the "non-hacky" (yeah... no) code is that every unique
* ConCommand vtable gets its own DVP hook. We watch for unloading and
* loading commands to remove stale hooks from SH.
*/
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "Logger.h"
#include "compat_wrappers.h"
#include "ConsoleDetours.h"
#include "GameConfigs.h"
#include "sm_stringutil.h"
#include "ConCmdManager.h"
#include "HalfLife2.h"
#include "ConCommandBaseIterator.h"
#include "ShareSys.h"
#if defined PLATFORM_LINUX
# include <dlfcn.h>
# include <sys/mman.h>
# include <stdint.h>
# include <unistd.h>
#endif
#if SH_IMPL_VERSION >= 5
# if SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
# else
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
# endif
#else
# if SH_IMPL_VERSION >= 4
extern int __SourceHook_FHVPAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>,bool);
extern int __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
# else
extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
# endif
extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
#endif
#if SH_IMPL_VERSION >= 4
class GenericCommandHooker : public IConCommandLinkListener
{
struct HackInfo
{
void **vtable;
int hook;
unsigned int refcount;
};
CVector<HackInfo> vtables;
bool enabled;
SourceHook::MemFuncInfo dispatch;
inline void **GetVirtualTable(ConCommandBase *pBase)
{
return *reinterpret_cast<void***>(reinterpret_cast<char*>(pBase) +
dispatch.thisptroffs +
dispatch.vtbloffs);
}
inline bool FindVtable(void **ptr, size_t& index)
{
for (size_t i = 0; i < vtables.size(); i++)
{
if (vtables[i].vtable == ptr)
{
index = i;
return true;
}
}
return false;
}
void MakeHookable(ConCommandBase *pBase)
{
if (!pBase->IsCommand())
return;
ConCommand *cmd = (ConCommand*)pBase;
void **vtable = GetVirtualTable(cmd);
size_t index;
if (!FindVtable(vtable, index))
{
HackInfo hack;
hack.vtable = vtable;
hack.hook = SH_ADD_VPHOOK(ConCommand, Dispatch, cmd, SH_MEMBER(this, &GenericCommandHooker::Dispatch), false);
hack.refcount = 1;
vtables.push_back(hack);
}
else
{
vtables[index].refcount++;
}
}
# if SOURCE_ENGINE >= SE_ORANGEBOX
void Dispatch(const CCommand& args)
# else
void Dispatch()
# endif
{
cell_t res = ConsoleDetours::Dispatch(META_IFACEPTR(ConCommand)
# if SOURCE_ENGINE >= SE_ORANGEBOX
, args
# endif
);
if (res >= Pl_Handled)
RETURN_META(MRES_SUPERCEDE);
}
void ReparseCommandList()
{
for (size_t i = 0; i < vtables.size(); i++)
vtables[i].refcount = 0;
for (ConCommandBaseIterator iter; iter.IsValid(); iter.Next())
MakeHookable(iter.Get());
CVector<HackInfo>::iterator iter = vtables.begin();
while (iter != vtables.end())
{
if ((*iter).refcount)
{
iter++;
continue;
}
/* Damn it. This event happens AFTER the plugin has unloaded!
* There's two options. Remove the hook now and hope SH's memory
* protection will prevent a crash. Otherwise, we can wait until
* the server shuts down and more likely crash then.
*
* This situation only arises if:
* 1) Someone has used AddCommandFilter()
* 2) ... on a Dark Messiah server (mm:s new api)
* 3) ... and another MM:S plugin that uses ConCommands has unloaded.
*
* Even though the impact is really small, we'll wait until the
* server shuts down, so normal operation isn't interrupted.
*
* See bug 4018.
*/
iter = vtables.erase(iter);
}
}
void UnhookCommand(ConCommandBase *pBase)
{
if (!pBase->IsCommand())
return;
ConCommand *cmd = (ConCommand*)pBase;
void **vtable = GetVirtualTable(cmd);
size_t index;
if (!FindVtable(vtable, index))
{
g_Logger.LogError("Console detour tried to unhook command \"%s\" but it wasn't found", pBase->GetName());
return;
}
assert(vtables[index].refcount > 0);
vtables[index].refcount--;
if (vtables[index].refcount == 0)
{
SH_REMOVE_HOOK_ID(vtables[index].hook);
vtables.erase(vtables.iterAt(index));
}
}
public:
GenericCommandHooker() : enabled(false)
{
}
bool Enable()
{
SourceHook::GetFuncInfo(&ConCommand::Dispatch, dispatch);
if (dispatch.thisptroffs < 0)
{
g_Logger.LogError("Command filter could not determine ConCommand layout");
return false;
}
for (ConCommandBaseIterator iter; iter.IsValid(); iter.Next())
MakeHookable(iter.Get());
if (!vtables.size())
{
g_Logger.LogError("Command filter could not find any cvars!");
return false;
}
enabled = true;
return true;
}
void Disable()
{
for (size_t i = 0; i < vtables.size(); i++)
SH_REMOVE_HOOK_ID(vtables[i].hook);
vtables.clear();
}
virtual void OnLinkConCommand(ConCommandBase *pBase)
{
if (!enabled)
return;
MakeHookable(pBase);
}
virtual void OnUnlinkConCommand(ConCommandBase *pBase)
{
if (!enabled)
return;
if (pBase == NULL)
ReparseCommandList();
else
UnhookCommand(pBase);
}
};
/**
* END DVP HOOK VERSION
*/
#else /* SH_IMPL_VERSION >= 4 */
/**
* BEGIN ENGINE DETOUR VERSION
*/
# include <jit/jit_helpers.h>
# include <jit/x86/x86_macros.h>
class GenericCommandHooker
{
struct Patch
{
Patch() : applied(false)
{
}
bool applied;
void *base;
unsigned char search[16];
size_t search_len;
size_t offset;
size_t saveat;
int regparam;
void *detour;
};
Patch ces;
Patch cgc;
public:
static void DelayedActivation(void *inparam)
{
GenericCommandHooker *cdtrs = reinterpret_cast<GenericCommandHooker*>(inparam);
/* Safe to re-enter because the frame queue is lock+swapped. */
if ((!cdtrs->ces.applied || !cdtrs->cgc.applied) &&
g_HL2.PeekCommandStack() != NULL)
{
g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, cdtrs);
return;
}
if (!cdtrs->ces.applied)
cdtrs->ApplyPatch(&cdtrs->ces);
if (!cdtrs->cgc.applied)
cdtrs->ApplyPatch(&cdtrs->cgc);
}
bool Enable()
{
const char *platform = NULL;
# if defined(PLATFORM_WINDOWS)
platform = "Windows";
# else
void *addrInBase = (void *)g_SMAPI->GetEngineFactory(false);
Dl_info info;
if (!dladdr(addrInBase, &info))
{
g_Logger.LogError("Command filter could not find engine name");
return false;
}
if (strstr(info.dli_fname, "engine_i486"))
{
platform = "Linux_486";
}
else if (strstr(info.dli_fname, "engine_i686"))
{
platform = "Linux_686";
}
else if (strstr(info.dli_fname, "engine_amd"))
{
platform = "Linux_AMD";
}
else
{
g_Logger.LogError("Command filter could not determine engine (%s)", info.dli_fname);
return false;
}
# endif
if (!PrepPatch("Cmd_ExecuteString", "CES", platform, &ces))
return false;
if (!PrepPatch("CGameClient::ExecuteString", "CGC", platform, &cgc))
return false;
if (g_HL2.PeekCommandStack() != NULL)
{
g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, this);
return true;
}
ApplyPatch(&ces);
ApplyPatch(&cgc);
return true;
}
void Disable()
{
UndoPatch(&ces);
UndoPatch(&cgc);
}
private:
# if !defined PLATFORM_WINDOWS
# define PAGE_READWRITE PROT_READ|PROT_WRITE
# define PAGE_EXECUTE_READ PROT_READ|PROT_EXEC
static inline uintptr_t AddrToPage(uintptr_t address)
{
return (address & ~(uintptr_t(sysconf(_SC_PAGE_SIZE) - 1)));
}
# endif
void Protect(void *addr, size_t length, int prot)
{
# if defined PLATFORM_WINDOWS
DWORD ignore;
VirtualProtect(addr, length, prot, &ignore);
# else
uintptr_t startPage = AddrToPage(uintptr_t(addr));
length += (uintptr_t(addr) - startPage);
mprotect((void*)startPage, length, prot);
# endif
}
void UndoPatch(Patch *patch)
{
if (!patch->applied || patch->detour == NULL)
return;
g_pSourcePawn->FreePageMemory(patch->detour);
unsigned char *source = (unsigned char *)patch->base + patch->offset;
Protect(source, patch->search_len, PAGE_READWRITE);
for (size_t i = 0; i < patch->search_len; i++)
source[i] = patch->search[i];
Protect(source, patch->search_len, PAGE_EXECUTE_READ);
}
void ApplyPatch(Patch *patch)
{
assert(!patch->applied);
size_t length = 0;
void *callback = (void*)&ConsoleDetours::Dispatch;
/* Bogus assignment to make compiler is doing the right thing. */
patch->detour = callback;
/* Assemgle the detour. */
JitWriter writer;
writer.outbase = NULL;
writer.outptr = NULL;
do
{
/* Need a specific register, or value on stack? */
if (patch->regparam != -1)
IA32_Push_Reg(&writer, patch->regparam);
/* Call real function. */
IA32_Write_Jump32_Abs(&writer, IA32_Call_Imm32(&writer, 0), callback);
/* Restore stack. */
if (patch->regparam != -1)
IA32_Pop_Reg(&writer, patch->regparam);
/* Copy any saved bytes */
if (patch->saveat)
{
for (size_t i = patch->saveat; i < patch->search_len; i++)
{
writer.write_ubyte(patch->search[i]);
}
}
/* Jump back to the caller. */
unsigned char *target = (unsigned char *)patch->base + patch->offset + patch->search_len;
IA32_Jump_Imm32_Abs(&writer, target);
/* Assemble, if we can. */
if (writer.outbase == NULL)
{
length = writer.outptr - writer.outbase;
patch->detour = g_pSourcePawn->AllocatePageMemory(length);
if (patch->detour == NULL)
{
g_Logger.LogError("Ran out of memory!");
return;
}
g_pSourcePawn->SetReadWrite(patch->detour);
writer.outbase = (jitcode_t)patch->detour;
writer.outptr = writer.outbase;
}
else
{
break;
}
} while (true);
g_pSourcePawn->SetReadExecute(patch->detour);
unsigned char *source = (unsigned char *)patch->base + patch->offset;
Protect(source, 6, PAGE_READWRITE);
source[0] = 0xFF;
source[1] = 0x25;
*(void **)&source[2] = &patch->detour;
Protect(source, 6, PAGE_EXECUTE_READ);
patch->applied = true;
}
bool PrepPatch(const char *signature, const char *name, const char *platform, Patch *patch)
{
/* Get the base address of the function. */
if (!g_pGameConf->GetMemSig(signature, &patch->base) || patch->base == NULL)
{
g_Logger.LogError("Command filter could not find signature: %s", signature);
return false;
}
const char *value;
char keyname[255];
/* Get the verification bytes that will be written over. */
UTIL_Format(keyname, sizeof(keyname), "%s_Patch_%s", name, platform);
if ((value = g_pGameConf->GetKeyValue(keyname)) == NULL)
{
g_Logger.LogError("Command filter could not find key: %s", keyname);
return false;
}
patch->search_len = UTIL_DecodeHexString(patch->search, sizeof(patch->search), value);
if (patch->search_len < 6)
{
g_Logger.LogError("Error decoding %s value, or not long enough", keyname);
return false;
}
/* Get the offset into the function. */
UTIL_Format(keyname, sizeof(keyname), "%s_Offset_%s", name, platform);
if ((value = g_pGameConf->GetKeyValue(keyname)) == NULL)
{
g_Logger.LogError("Command filter could not find key: %s", keyname);
return false;
}
patch->offset = atoi(value);
if (patch->offset > 20000)
{
g_Logger.LogError("Command filter %s value is bogus", keyname);
return false;
}
/* Get the number of bytes to save from what was written over. */
patch->saveat = 0;
UTIL_Format(keyname, sizeof(keyname), "%s_Save_%s", name, platform);
if ((value = g_pGameConf->GetKeyValue(keyname)) != NULL)
{
patch->saveat = atoi(value);
if (patch->saveat >= patch->search_len)
{
g_Logger.LogError("Command filter %s value is too large", keyname);
return false;
}
}
/* Get register for parameter, if any. */
patch->regparam = -1;
UTIL_Format(keyname, sizeof(keyname), "%s_Reg_%s", name, platform);
if ((value = g_pGameConf->GetKeyValue(keyname)) != NULL)
{
patch->regparam = atoi(value);
}
/* Everything loaded from gamedata, make sure the patch will succeed. */
unsigned char *address = (unsigned char *)patch->base + patch->offset;
for (size_t i = 0; i < patch->search_len; i++)
{
if (address[i] != patch->search[i])
{
g_Logger.LogError("Command filter %s has changed (byte %x is not %x sub-offset %d)",
name, address[i], patch->search[i], i);
return false;
}
}
return true;
}
};
static bool dummy_hook_set = false;
void DummyHook()
{
if (dummy_hook_set)
{
dummy_hook_set = false;
RETURN_META(MRES_SUPERCEDE);
}
}
#endif
/**
* BEGIN THE ACTUALLY GENERIC CODE.
*/
#define FEATURECAP_COMMANDLISTENER "command listener"
static GenericCommandHooker s_GenericHooker;
ConsoleDetours g_ConsoleDetours;
ConsoleDetours::ConsoleDetours() : status(FeatureStatus_Unknown)
{
}
void ConsoleDetours::OnSourceModAllInitialized()
{
m_pForward = g_Forwards.CreateForwardEx("OnAnyCommand", ET_Hook, 3, NULL, Param_Cell,
Param_String, Param_Cell);
g_ShareSys.AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER);
}
void ConsoleDetours::OnSourceModShutdown()
{
List<Listener*>::iterator iter = m_Listeners.begin();
while (iter != m_Listeners.end())
{
Listener *listener = (*iter);
g_Forwards.ReleaseForward(listener->forward);
delete listener;
iter = m_Listeners.erase(iter);
}
g_Forwards.ReleaseForward(m_pForward);
s_GenericHooker.Disable();
}
FeatureStatus ConsoleDetours::GetFeatureStatus(FeatureType type, const char *name)
{
return GetStatus();
}
FeatureStatus ConsoleDetours::GetStatus()
{
if (status == FeatureStatus_Unknown)
{
status = s_GenericHooker.Enable() ? FeatureStatus_Available : FeatureStatus_Unavailable;
}
return status;
}
bool ConsoleDetours::AddListener(IPluginFunction *fun, const char *command)
{
if (GetStatus() != FeatureStatus_Available)
return false;
if (command == NULL)
{
m_pForward->AddFunction(fun);
}
else
{
const char *str = UTIL_ToLowerCase(command);
Listener *listener;
Listener **plistener = m_CmdLookup.retrieve(str);
if (plistener == NULL)
{
listener = new Listener;
listener->forward = g_Forwards.CreateForwardEx(NULL, ET_Hook, 3, NULL, Param_Cell,
Param_String, Param_Cell);
m_CmdLookup.insert(str, listener);
}
else
{
listener = *plistener;
}
listener->forward->AddFunction(fun);
delete [] str;
}
return true;
}
bool ConsoleDetours::RemoveListener(IPluginFunction *fun, const char *command)
{
if (command == NULL)
{
return m_pForward->RemoveFunction(fun);
}
else
{
const char *str = UTIL_ToLowerCase(command);
Listener *listener;
Listener **plistener = m_CmdLookup.retrieve(str);
delete [] str;
if (plistener == NULL)
return false;
listener = *plistener;
return listener->forward->RemoveFunction(fun);
}
}
cell_t ConsoleDetours::InternalDispatch(int client, const CCommand& args)
{
char name[255];
const char *realname = args.Arg(0);
size_t len = strlen(realname);
for (size_t i = 0; i < len; i++)
{
if (realname[i] >= 'A' && realname[i] <= 'Z')
name[i] = tolower(realname[i]);
else
name[i] = realname[i];
}
name[len] = '\0';
cell_t result = Pl_Continue;
m_pForward->PushCell(client);
m_pForward->PushString(name);
m_pForward->PushCell(args.ArgC() - 1);
m_pForward->Execute(&result, NULL);
/* Don't let plugins block this. */
if (strcmp(name, "sm") == 0)
result = Pl_Continue;
if (result >= Pl_Stop)
return result;
Listener **plistener = m_CmdLookup.retrieve(name);
if (plistener == NULL)
return result;
Listener *listener = *plistener;
if (listener->forward->GetFunctionCount() == 0)
return result;
cell_t result2 = Pl_Continue;
listener->forward->PushCell(client);
listener->forward->PushString(name);
listener->forward->PushCell(args.ArgC() - 1);
listener->forward->Execute(&result2, NULL);
if (result2 > result)
result = result2;
/* "sm" should not have flown through the above. */
assert(strcmp(name, "sm") != 0 || result == Pl_Continue);
return result;
}
#if SOURCE_ENGINE >= SE_ORANGEBOX
cell_t ConsoleDetours::Dispatch(ConCommand *pBase, const CCommand& args)
{
#else
cell_t ConsoleDetours::Dispatch(ConCommand *pBase)
{
CCommand args;
#endif
g_HL2.PushCommandStack(&args);
cell_t res = g_ConsoleDetours.InternalDispatch(g_ConCmds.GetCommandClient(), args);
g_HL2.PopCommandStack();
#if SH_IMPL_VERSION < 4
if (res >= Pl_Handled)
{
/* See bug 4020 - we can't optimize this because looking at the vtable
* is probably more expensive, since there's no SH_GET_ORIG_VFNPTR_ENTRY.
*/
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pBase, DummyHook, false);
dummy_hook_set = true;
pBase->Dispatch();
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pBase, DummyHook, false);
}
else
{
/* Make sure the command gets invoked. See bug 4019 on making this better. */
pBase->Dispatch();
}
#endif
return res;
}
+83
View File
@@ -0,0 +1,83 @@
/**
* 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_CONSOLE_DETOURS_H_
#define _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_
#include "sm_globals.h"
#include "sourcemm_api.h"
#include "ForwardSys.h"
#include <sm_trie_tpl.h>
class ConsoleDetours :
public SMGlobalClass,
public IFeatureProvider
{
friend class PlayerManager;
friend class GenericCommandHooker;
struct Listener
{
IChangeableForward *forward;
};
public:
ConsoleDetours();
public: //SMGlobalClass
void OnSourceModAllInitialized();
void OnSourceModShutdown();
public: //IFeatureProvider
FeatureStatus GetFeatureStatus(FeatureType type, const char *name);
public:
bool AddListener(IPluginFunction *fun, const char *command);
bool RemoveListener(IPluginFunction *fun, const char *command);
private:
cell_t InternalDispatch(int client, const CCommand& args);
#if SOURCE_ENGINE >= SE_ORANGEBOX
static cell_t Dispatch(ConCommand *pBase, const CCommand& args);
#else
static cell_t Dispatch(ConCommand *pBase);
#endif
public:
FeatureStatus GetStatus();
bool IsEnabled()
{
return status == FeatureStatus_Available;
}
private:
FeatureStatus status;
IChangeableForward *m_pForward;
KTrie<Listener*> m_CmdLookup;
List<Listener*> m_Listeners;
};
extern ConsoleDetours g_ConsoleDetours;
#endif /* _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_ */
+24 -10
View File
@@ -68,7 +68,11 @@ void Hook_ExecDispatchPre(const CCommand &cmd)
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false); SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
void Hook_ExecDispatchPre() void Hook_ExecDispatchPre()
#else #else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); # if SH_IMPL_VERSION >= 4
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
# else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
# endif
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
void Hook_ExecDispatchPre() void Hook_ExecDispatchPre()
#endif #endif
@@ -103,11 +107,7 @@ void CheckAndFinalizeConfigs()
{ {
if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart) if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart)
{ {
#if SOURCE_ENGINE >= SE_ORANGEBOX
g_PendingInternalPush = true; g_PendingInternalPush = true;
#else
SM_InternalCmdTrigger();
#endif
} }
} }
@@ -214,14 +214,28 @@ void CoreConfig::Initialize()
/* Try to get command line value of core config convar */ /* Try to get command line value of core config convar */
const char *corecfg = icvar->GetCommandLineValue("sm_corecfgfile"); const char *corecfg = icvar->GetCommandLineValue("sm_corecfgfile");
/* If sm_corecfgfile not specified on command line, use default value */ /* If sm_corecfgfile is on the command line, use that
if (!corecfg) * If sm_corecfgfile isn't there, check sm_basepath on the command line and build the path off that
* If sm_basepath isn't there, just use the default path for the cfg
*/
if (corecfg)
{ {
corecfg = sm_corecfgfile.GetDefault(); g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
} }
else
{
const char *basepath = icvar->GetCommandLineValue("sm_basepath");
/* Format path to config file */ /* Format path to config file */
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg); if (basepath)
{
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s/%s", g_SourceMod.GetGamePath(), basepath, "configs/core.cfg");
}
else
{
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), sm_corecfgfile.GetDefault());
}
}
/* Reset cached key values */ /* Reset cached key values */
m_KeyValues.clear(); m_KeyValues.clear();
+41 -32
View File
@@ -37,7 +37,7 @@
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include <stdlib.h> #include <stdlib.h>
#include "ThreadSupport.h" #include <IThreader.h>
#define DBPARSE_LEVEL_NONE 0 #define DBPARSE_LEVEL_NONE 0
#define DBPARSE_LEVEL_MAIN 1 #define DBPARSE_LEVEL_MAIN 1
@@ -47,7 +47,7 @@ DBManager g_DBMan;
static bool s_OneTimeThreaderErrorMsg = false; static bool s_OneTimeThreaderErrorMsg = false;
DBManager::DBManager() DBManager::DBManager()
: m_StrTab(512), m_ParseLevel(0), m_ParseState(0), m_pDefault(NULL) : m_ParseLevel(0), m_ParseState(0), m_pDefault(NULL)
{ {
} }
@@ -104,6 +104,7 @@ void DBManager::OnSourceModShutdown()
m_pQueueLock->DestroyThis(); m_pQueueLock->DestroyThis();
g_HandleSys.RemoveType(m_DatabaseType, g_pCoreIdent); g_HandleSys.RemoveType(m_DatabaseType, g_pCoreIdent);
g_HandleSys.RemoveType(m_DriverType, g_pCoreIdent); g_HandleSys.RemoveType(m_DriverType, g_pCoreIdent);
ClearConfigs();
} }
unsigned int DBManager::GetInterfaceVersion() unsigned int DBManager::GetInterfaceVersion()
@@ -133,13 +134,20 @@ void DBManager::OnHandleDestroy(HandleType_t type, void *object)
void DBManager::ReadSMC_ParseStart() void DBManager::ReadSMC_ParseStart()
{ {
m_confs.clear(); ClearConfigs();
m_ParseLevel = 0; m_ParseLevel = 0;
m_ParseState = DBPARSE_LEVEL_NONE; m_ParseState = DBPARSE_LEVEL_NONE;
m_StrTab.Reset();
m_DefDriver.clear(); 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; ConfDbInfo s_CurInfo;
SMCResult DBManager::ReadSMC_NewSection(const SMCStates *states, const char *name) SMCResult DBManager::ReadSMC_NewSection(const SMCStates *states, const char *name)
{ {
@@ -159,7 +167,7 @@ SMCResult DBManager::ReadSMC_NewSection(const SMCStates *states, const char *nam
} }
} else if (m_ParseState == DBPARSE_LEVEL_MAIN) { } else if (m_ParseState == DBPARSE_LEVEL_MAIN) {
s_CurInfo = ConfDbInfo(); s_CurInfo = ConfDbInfo();
s_CurInfo.name = m_StrTab.AddString(name); s_CurInfo.name = name;
m_ParseState = DBPARSE_LEVEL_DATABASE; m_ParseState = DBPARSE_LEVEL_DATABASE;
} else if (m_ParseState == DBPARSE_LEVEL_DATABASE) { } else if (m_ParseState == DBPARSE_LEVEL_DATABASE) {
m_ParseLevel++; m_ParseLevel++;
@@ -186,16 +194,16 @@ SMCResult DBManager::ReadSMC_KeyValue(const SMCStates *states, const char *key,
{ {
if (strcmp(value, "default") != 0) if (strcmp(value, "default") != 0)
{ {
s_CurInfo.driver = m_StrTab.AddString(value); s_CurInfo.driver = value;
} }
} else if (strcmp(key, "database") == 0) { } else if (strcmp(key, "database") == 0) {
s_CurInfo.database = m_StrTab.AddString(value); s_CurInfo.database = value;
} else if (strcmp(key, "host") == 0) { } else if (strcmp(key, "host") == 0) {
s_CurInfo.host = m_StrTab.AddString(value); s_CurInfo.host = value;
} else if (strcmp(key, "user") == 0) { } else if (strcmp(key, "user") == 0) {
s_CurInfo.user = m_StrTab.AddString(value); s_CurInfo.user = value;
} else if (strcmp(key, "pass") == 0) { } else if (strcmp(key, "pass") == 0) {
s_CurInfo.pass = m_StrTab.AddString(value); s_CurInfo.pass = value;
} else if (strcmp(key, "timeout") == 0) { } else if (strcmp(key, "timeout") == 0) {
s_CurInfo.info.maxTimeout = atoi(value); s_CurInfo.info.maxTimeout = atoi(value);
} else if (strcmp(key, "port") == 0) { } else if (strcmp(key, "port") == 0) {
@@ -206,13 +214,6 @@ SMCResult DBManager::ReadSMC_KeyValue(const SMCStates *states, const char *key,
return SMCResult_Continue; 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) SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
{ {
if (m_ParseLevel) if (m_ParseLevel)
@@ -223,17 +224,26 @@ SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
if (m_ParseState == DBPARSE_LEVEL_DATABASE) if (m_ParseState == DBPARSE_LEVEL_DATABASE)
{ {
/* Set all of the info members to either a blank string ConfDbInfo *cdb = new ConfDbInfo();
* or the string pointer from the string table.
*/ cdb->name = s_CurInfo.name;
ASSIGN_VAR(driver); cdb->driver = s_CurInfo.driver;
ASSIGN_VAR(database); cdb->host = s_CurInfo.host;
ASSIGN_VAR(host); cdb->user = s_CurInfo.user;
ASSIGN_VAR(user); cdb->pass = s_CurInfo.pass;
ASSIGN_VAR(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();
/* Save it.. */ /* Save it.. */
m_confs.push_back(s_CurInfo); m_confs.push_back(cdb);
/* Go up one level */ /* Go up one level */
m_ParseState = DBPARSE_LEVEL_MAIN; m_ParseState = DBPARSE_LEVEL_MAIN;
@@ -244,7 +254,6 @@ SMCResult DBManager::ReadSMC_LeavingSection(const SMCStates *states)
return SMCResult_Continue; return SMCResult_Continue;
} }
#undef ASSIGN_VAR
void DBManager::ReadSMC_ParseEnd(bool halted, bool failed) void DBManager::ReadSMC_ParseEnd(bool halted, bool failed)
{ {
@@ -333,10 +342,10 @@ void DBManager::RemoveDriver(IDBDriver *pDriver)
} }
/* Make sure NOTHING references this! */ /* Make sure NOTHING references this! */
List<ConfDbInfo>::iterator iter; List<ConfDbInfo *>::iterator iter;
for (iter=m_confs.begin(); iter!=m_confs.end(); iter++) for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
{ {
ConfDbInfo &db = (*iter); ConfDbInfo &db = *(*iter);
if (db.realDriver == pDriver) if (db.realDriver == pDriver)
{ {
db.realDriver = NULL; db.realDriver = NULL;
@@ -448,12 +457,12 @@ const DatabaseInfo *DBManager::FindDatabaseConf(const char *name)
ConfDbInfo *DBManager::GetDatabaseConf(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++) for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
{ {
ConfDbInfo &conf = (*iter); ConfDbInfo &conf = *(*iter);
if (strcmp(m_StrTab.GetString(conf.name), name) == 0) if (conf.name == name)
{ {
return &conf; return &conf;
} }
+9 -10
View File
@@ -47,16 +47,15 @@ using namespace SourceHook;
struct ConfDbInfo struct ConfDbInfo
{ {
ConfDbInfo() : name(-1), driver(-1), host(-1), user(-1), pass(-1), ConfDbInfo() : realDriver(NULL)
database(-1), realDriver(NULL)
{ {
} }
int name; String name;
int driver; String driver;
int host; String host;
int user; String user;
int pass; String pass;
int database; String database;
IDBDriver *realDriver; IDBDriver *realDriver;
DatabaseInfo info; DatabaseInfo info;
}; };
@@ -121,6 +120,7 @@ public:
return m_DatabaseType; return m_DatabaseType;
} }
private: private:
void ClearConfigs();
void KillWorkerThread(); void KillWorkerThread();
private: private:
CVector<IDBDriver *> m_drivers; CVector<IDBDriver *> m_drivers;
@@ -134,11 +134,10 @@ private:
IMutex *m_pQueueLock; /* Queue safety lock */ IMutex *m_pQueueLock; /* Queue safety lock */
IMutex *m_pThinkLock; /* Think-queue lock */ IMutex *m_pThinkLock; /* Think-queue lock */
List<ConfDbInfo> m_confs; List<ConfDbInfo *> m_confs;
HandleType_t m_DriverType; HandleType_t m_DriverType;
HandleType_t m_DatabaseType; HandleType_t m_DatabaseType;
String m_DefDriver; String m_DefDriver;
BaseStringTable m_StrTab;
char m_Filename[PLATFORM_MAX_PATH]; char m_Filename[PLATFORM_MAX_PATH];
unsigned int m_ParseLevel; unsigned int m_ParseLevel;
unsigned int m_ParseState; unsigned int m_ParseState;
+36 -3
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -42,6 +42,20 @@ SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *,
const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell}; const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell};
typedef List<EventHook *> EventHookList; typedef List<EventHook *> EventHookList;
class EventForwardFilter : public IForwardFilter
{
EventInfo *pEventInfo;
public:
EventForwardFilter(EventInfo *pEventInfo) : pEventInfo(pEventInfo)
{
}
void Preprocess(IPluginFunction *fun, FwdParamInfo *params)
{
params[2].val = pEventInfo->bDontBroadcast ? 1 : 0;
}
};
EventManager::EventManager() : m_EventType(0) EventManager::EventManager() : m_EventType(0)
{ {
/* Create an event lookup trie */ /* Create an event lookup trie */
@@ -147,6 +161,13 @@ void EventManager::FireGameEvent(IGameEvent *pEvent)
Just need to add ourselves as a listener to make our hook on IGameEventManager2::FireEvent work */ 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) EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode)
{ {
EventHook *pHook; EventHook *pHook;
@@ -327,6 +348,7 @@ EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name,
pInfo->pEvent = pEvent; pInfo->pEvent = pEvent;
pInfo->pOwner = pContext->GetIdentity(); pInfo->pOwner = pContext->GetIdentity();
pInfo->bDontBroadcast = false;
return pInfo; return pInfo;
} }
@@ -365,6 +387,7 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
IChangeableForward *pForward; IChangeableForward *pForward;
const char *name; const char *name;
cell_t res = Pl_Continue; cell_t res = Pl_Continue;
bool broadcast = bDontBroadcast;
/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */ /* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
if (!pEvent) if (!pEvent)
@@ -390,10 +413,16 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
HandleSecurity sec(NULL, g_pCoreIdent); HandleSecurity sec(NULL, g_pCoreIdent);
Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL); Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
info.bDontBroadcast = bDontBroadcast;
EventForwardFilter filter(&info);
pForward->PushCell(hndl); pForward->PushCell(hndl);
pForward->PushString(name); pForward->PushString(name);
pForward->PushCell(bDontBroadcast); pForward->PushCell(bDontBroadcast);
pForward->Execute(&res, NULL); pForward->Execute(&res, &filter);
broadcast = info.bDontBroadcast;
g_HandleSys.FreeHandle(hndl, &sec); g_HandleSys.FreeHandle(hndl, &sec);
} }
@@ -414,6 +443,9 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
m_EventStack.push(NULL); m_EventStack.push(NULL);
} }
if (broadcast != bDontBroadcast)
RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, true, &IGameEventManager2::FireEvent, (pEvent, broadcast));
RETURN_META_VALUE(MRES_IGNORED, true); RETURN_META_VALUE(MRES_IGNORED, true);
} }
@@ -441,6 +473,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
{ {
if (pHook->postCopy) if (pHook->postCopy)
{ {
info.bDontBroadcast = bDontBroadcast;
info.pEvent = m_EventCopies.front(); info.pEvent = m_EventCopies.front();
info.pOwner = NULL; info.pOwner = NULL;
hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL); hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
+5 -1
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -53,6 +53,7 @@ struct EventInfo
} }
IGameEvent *pEvent; IGameEvent *pEvent;
IdentityToken_t *pOwner; IdentityToken_t *pOwner;
bool bDontBroadcast;
}; };
struct EventHook struct EventHook
@@ -104,6 +105,9 @@ public: // IPluginsListener
void OnPluginUnloaded(IPlugin *plugin); void OnPluginUnloaded(IPlugin *plugin);
public: // IGameEventListener2 public: // IGameEventListener2
void FireGameEvent(IGameEvent *pEvent); void FireGameEvent(IGameEvent *pEvent);
#if SOURCE_ENGINE >= SE_LEFT4DEAD
int GetEventDebugID();
#endif
public: public:
/** /**
* Get the 'GameEvent' handle type ID. * Get the 'GameEvent' handle type ID.
+9 -5
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -63,6 +63,10 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE == SE_LEFT4DEAD
#define GAMEFIX "2.l4d" #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 #elif SOURCE_ENGINE == SE_ORANGEBOX
#define GAMEFIX "2.ep2" #define GAMEFIX "2.ep2"
#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE #elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
@@ -71,7 +75,7 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena
#define GAMEFIX "2.darkm" #define GAMEFIX "2.darkm"
#else #else
#define GAMEFIX "2.ep1" #define GAMEFIX "2.ep1"
#endif //SOURCE_ENGINE == SE_LEFT4DEAD #endif //(SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
#else //METAMOD_PLAPI_VERSION #else //METAMOD_PLAPI_VERSION
#define GAMEFIX "1.ep1" #define GAMEFIX "1.ep1"
#endif //METAMOD_PLAPI_VERSION #endif //METAMOD_PLAPI_VERSION
@@ -986,7 +990,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>"); g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
return; return;
} }
@@ -994,7 +998,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
unsigned int id = atoi(sId); unsigned int id = atoi(sId);
if (id <= 0) if (id <= 0)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>"); g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
return; return;
} }
@@ -1071,7 +1075,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm unload <#> [code]"); g_RootMenu.ConsolePrint("[SM] Usage: sm exts unload <#> [code]");
return; return;
} }
+14 -8
View File
@@ -1,5 +1,5 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@@ -255,6 +255,7 @@ CForward *CForward::CreateForward(const char *name, ExecType et, unsigned int nu
} }
CForward *pForward = g_Forwards.ForwardMake(); CForward *pForward = g_Forwards.ForwardMake();
pForward->m_IterGuard = NULL;
pForward->m_curparam = 0; pForward->m_curparam = 0;
pForward->m_ExecType = et; pForward->m_ExecType = et;
snprintf(pForward->m_name, FORWARDS_NAME_MAX, "%s", name ? name : ""); snprintf(pForward->m_name, FORWARDS_NAME_MAX, "%s", name ? name : "");
@@ -294,7 +295,7 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
cell_t high_result = 0; cell_t high_result = 0;
cell_t low_result = 0; cell_t low_result = 0;
int err; int err;
unsigned int failed=0, success=0; unsigned int success=0;
unsigned int num_params = m_curparam; unsigned int num_params = m_curparam;
FwdParamInfo temp_info[SP_MAX_EXEC_PARAMS]; FwdParamInfo temp_info[SP_MAX_EXEC_PARAMS];
FwdParamInfo *param; FwdParamInfo *param;
@@ -304,10 +305,15 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
memcpy(temp_info, m_params, sizeof(m_params)); memcpy(temp_info, m_params, sizeof(m_params));
m_curparam = 0; m_curparam = 0;
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++) FuncIteratorGuard guard(&m_IterGuard, &iter);
while (iter != m_functions.end())
{ {
func = (*iter); func = (*iter);
if (filter)
filter->Preprocess(func, temp_info);
for (unsigned int i=0; i<num_params; i++) for (unsigned int i=0; i<num_params; i++)
{ {
int err = SP_ERROR_PARAM; int err = SP_ERROR_PARAM;
@@ -359,11 +365,7 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
} }
/* Call the function and deal with the return value. */ /* Call the function and deal with the return value. */
if ((err=func->Execute(&cur_result)) != SP_ERROR_NONE) if ((err=func->Execute(&cur_result)) == SP_ERROR_NONE)
{
failed++;
}
else
{ {
success++; success++;
switch (m_ExecType) switch (m_ExecType)
@@ -403,6 +405,9 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
} }
} }
} }
if (!guard.Triggered())
iter++;
} }
done: done:
@@ -682,6 +687,7 @@ bool CForward::RemoveFunction(IPluginFunction *func)
{ {
if ((*iter) == func) if ((*iter) == func)
{ {
m_IterGuard->FixIteratorChain(iter);
found = true; found = true;
lst->erase(iter); lst->erase(iter);
break; break;
+53
View File
@@ -61,6 +61,58 @@ struct FwdParamInfo
ParamType pushedas; ParamType pushedas;
}; };
class SourceMod::IForwardFilter
{
public:
virtual void Preprocess(IPluginFunction *fun, FwdParamInfo *params)
{
}
};
class FuncIteratorGuard
{
bool triggered;
FuncIteratorGuard **pprev;
FuncIter *iter;
FuncIteratorGuard *next;
public:
FuncIteratorGuard(FuncIteratorGuard **pprev, FuncIter *iter)
: triggered(false), pprev(pprev), iter(iter), next(*pprev)
{
*pprev = this;
}
~FuncIteratorGuard()
{
*pprev = next;
}
inline bool Triggered()
{
bool t = triggered;
triggered = false;
return t;
}
/**
* This should not read from |this| before the NULL check, because FwdSys
* can call (NULL)->FixIteratorChain().
*/
void FixIteratorChain(FuncIter &other)
{
FuncIteratorGuard *guard = this;
while (guard != NULL)
{
if (*guard->iter == other)
{
*(guard->iter) = ++(*(guard->iter));
guard->triggered = true;
}
guard = guard->next;
}
}
};
class CForward : public IChangeableForward class CForward : public IChangeableForward
{ {
public: //ICallable public: //ICallable
@@ -103,6 +155,7 @@ protected:
*/ */
mutable List<IPluginFunction *> m_functions; mutable List<IPluginFunction *> m_functions;
mutable List<IPluginFunction *> m_paused; mutable List<IPluginFunction *> m_paused;
FuncIteratorGuard *m_IterGuard;
/* Type and name information */ /* Type and name information */
FwdParamInfo m_params[SP_MAX_EXEC_PARAMS]; FwdParamInfo m_params[SP_MAX_EXEC_PARAMS];
+17 -34
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -25,8 +25,6 @@
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/ */
#include <string.h> #include <string.h>
@@ -92,7 +90,11 @@ bool s_ServerBinCRC_Ok = false;
static bool DoesGameMatch(const char *value) static bool DoesGameMatch(const char *value)
{ {
#if defined PLATFORM_WINDOWS
if (strcasecmp(value, g_Game) == 0 ||
#else
if (strcmp(value, g_Game) == 0 || if (strcmp(value, g_Game) == 0 ||
#endif
strcmp(value, g_GameDesc) == 0 || strcmp(value, g_GameDesc) == 0 ||
strcmp(value, g_GameName) == 0) strcmp(value, g_GameName) == 0)
{ {
@@ -113,6 +115,10 @@ static bool DoesEngineMatch(const char *value)
if (strcmp(value, "orangebox_valve") == 0) if (strcmp(value, "orangebox_valve") == 0)
#elif SOURCE_ENGINE == SE_LEFT4DEAD #elif SOURCE_ENGINE == SE_LEFT4DEAD
if (strcmp(value, "left4dead") == 0) if (strcmp(value, "left4dead") == 0)
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
if (strcmp(value, "left4dead2") == 0)
#elif SOURCE_ENGINE == SE_ALIENSWARM
if (strcmp(value, "alienswarm") == 0)
#else #else
#error "Unknown engine type" #error "Unknown engine type"
#endif #endif
@@ -500,7 +506,11 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
void *handle = dlopen(info.dli_fname, RTLD_NOW); void *handle = dlopen(info.dli_fname, RTLD_NOW);
if (handle) if (handle)
{ {
#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
final_addr = g_MemUtils.ResolveSymbol(handle, &s_TempSig.sig[1]);
#else
final_addr = dlsym(handle, &s_TempSig.sig[1]); final_addr = dlsym(handle, &s_TempSig.sig[1]);
#endif
dlclose(handle); dlclose(handle);
} else { } else {
g_Logger.LogError("[SM] Unable to load library \"%s\" (gameconf \"%s\")", g_Logger.LogError("[SM] Unable to load library \"%s\" (gameconf \"%s\")",
@@ -519,45 +529,18 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
} }
#endif #endif
/* First, preprocess the signature */ /* First, preprocess the signature */
char real_sig[511]; unsigned char real_sig[511];
size_t real_bytes; size_t real_bytes;
size_t length; size_t length;
real_bytes = 0; real_bytes = 0;
length = strlen(s_TempSig.sig); length = strlen(s_TempSig.sig);
for (size_t i=0; i<length; i++) real_bytes = UTIL_DecodeHexString(real_sig, sizeof(real_sig), s_TempSig.sig);
{
if (real_bytes >= sizeof(real_sig))
{
break;
}
real_sig[real_bytes++] = s_TempSig.sig[i];
if (s_TempSig.sig[i] == '\\'
&& s_TempSig.sig[i+1] == 'x')
{
if (i + 3 >= length)
{
continue;
}
/* Get the hex part */
char s_byte[3];
int r_byte;
s_byte[0] = s_TempSig.sig[i+2];
s_byte[1] = s_TempSig.sig[i+3];
s_byte[2] = '\0';
/* Read it as an integer */
sscanf(s_byte, "%x", &r_byte);
/* Save the value */
real_sig[real_bytes-1] = r_byte;
/* Adjust index */
i += 3;
}
}
if (real_bytes >= 1) if (real_bytes >= 1)
{ {
final_addr = g_MemUtils.FindPattern(addrInBase, real_sig, real_bytes); final_addr = g_MemUtils.FindPattern(addrInBase, (char*)real_sig, real_bytes);
} }
} }
-1
View File
@@ -39,7 +39,6 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "sm_memtable.h" #include "sm_memtable.h"
#include "sm_trie_tpl.h" #include "sm_trie_tpl.h"
#include "ThreadSupport.h"
using namespace SourceMod; using namespace SourceMod;
using namespace SourceHook; using namespace SourceHook;
+270 -5
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -37,10 +37,14 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "GameConfigs.h" #include "GameConfigs.h"
#include <compat_wrappers.h> #include <compat_wrappers.h>
#include <Logger.h>
CHalfLife2 g_HL2; CHalfLife2 g_HL2;
ConVar *sv_lan = NULL; ConVar *sv_lan = NULL;
static void *g_EntList = NULL;
static int entInfoOffset = -1;
namespace SourceHook namespace SourceHook
{ {
template<> template<>
@@ -92,14 +96,16 @@ CHalfLife2::~CHalfLife2()
CSharedEdictChangeInfo *g_pSharedChangeInfo = NULL; CSharedEdictChangeInfo *g_pSharedChangeInfo = NULL;
#endif #endif
#if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool is_original_engine = false; bool is_original_engine = false;
#endif
void CHalfLife2::OnSourceModStartup(bool late) void CHalfLife2::OnSourceModStartup(bool late)
{ {
#if SOURCE_ENGINE != SE_DARKMESSIAH #if SOURCE_ENGINE != SE_DARKMESSIAH
/* The Ship currently is the only known game to use an older version of the engine */ /* The Ship currently is the only known game to use an older version of the engine */
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL) if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL)
#else #else
if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0) if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0)
@@ -123,7 +129,73 @@ void CHalfLife2::OnSourceModAllInitialized()
g_ShareSys.AddInterface(NULL, this); g_ShareSys.AddInterface(NULL, this);
} }
#if !defined METAMOD_PLAPI_VERSION void CHalfLife2::OnSourceModAllInitialized_Post()
{
char *addr = NULL;
/*
* 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))
{
#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
}
if (!g_EntList)
{
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);
}
if (!g_EntList)
{
g_Logger.LogError("Failed lookup of gEntList - Reverting to networkable entities only");
return;
}
if (!g_pGameConf->GetOffset("EntInfo", &entInfoOffset))
{
g_Logger.LogError("Logical Entities not supported by this mod (EntInfo) - Reverting to networkable entities only");
return;
}
}
#if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool CHalfLife2::IsOriginalEngine() bool CHalfLife2::IsOriginalEngine()
{ {
return is_original_engine; return is_original_engine;
@@ -388,6 +460,26 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
return true; return true;
} }
bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg)
{
bf_write *pBitBuf = NULL;
if ((pBitBuf = g_UserMsgs.StartMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
{
return false;
}
const char *pre_byte = g_pGameConf->GetKeyValue("HintTextPreByte");
if (pre_byte != NULL && strcmp(pre_byte, "yes") == 0)
{
pBitBuf->WriteByte(1);
}
pBitBuf->WriteString(msg);
g_UserMsgs.EndMessage();
return true;
}
bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show) bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show)
{ {
bf_write *pBitBuf = NULL; bf_write *pBitBuf = NULL;
@@ -474,7 +566,7 @@ bool CHalfLife2::IsLANServer()
bool CHalfLife2::KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID) bool CHalfLife2::KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID)
{ {
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL) if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL)
#else #else
if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0) if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0)
@@ -599,7 +691,10 @@ edict_t *CHalfLife2::GetHandleEntity(CBaseHandle &hndl)
edict_t *pStoredEdict; edict_t *pStoredEdict;
CBaseEntity *pStoredEntity; CBaseEntity *pStoredEntity;
pStoredEdict = GetEntity(index, &pStoredEntity); if (!IndexToAThings(index, &pStoredEntity, &pStoredEdict))
{
return NULL;
}
if (pStoredEdict == NULL || pStoredEntity == NULL) if (pStoredEdict == NULL || pStoredEntity == NULL)
{ {
@@ -642,3 +737,173 @@ void CHalfLife2::ServerCommand(const char *buffer)
{ {
engine->ServerCommand(buffer); engine->ServerCommand(buffer);
} }
cell_t CHalfLife2::EntityToReference(CBaseEntity *pEntity)
{
IServerUnknown *pUnknown = (IServerUnknown *)pEntity;
CBaseHandle hndl = pUnknown->GetRefEHandle();
return (hndl.ToInt() | (1<<31));
}
CBaseEntity *CHalfLife2::ReferenceToEntity(cell_t entRef)
{
CEntInfo *pInfo = NULL;
if (entRef & (1<<31))
{
/* Proper ent reference */
int hndlValue = entRef & ~(1<<31);
CBaseHandle hndl(hndlValue);
pInfo = LookupEntity(hndl.GetEntryIndex());
if (pInfo->m_SerialNumber != hndl.GetSerialNumber())
{
return NULL;
}
}
else
{
/* Old style index only */
pInfo = LookupEntity(entRef);
}
if (!pInfo)
{
return NULL;
}
IServerUnknown *pUnk = static_cast<IServerUnknown *>(pInfo->m_pEntity);
if (pUnk)
{
return pUnk->GetBaseEntity();
}
return NULL;
}
/**
* Retrieves the CEntInfo pointer from g_EntList for a given entity index
*/
CEntInfo *CHalfLife2::LookupEntity(int entIndex)
{
if (!g_EntList || entInfoOffset == -1)
{
/* Attempt to use engine interface instead */
static CEntInfo tempInfo;
tempInfo.m_pNext = NULL;
tempInfo.m_pPrev = NULL;
edict_t *pEdict = PEntityOfEntIndex(entIndex);
if (!pEdict)
{
return NULL;
}
IServerUnknown *pUnk = pEdict->GetUnknown();
if (!pUnk)
{
return NULL;
}
tempInfo.m_pEntity = pUnk;
tempInfo.m_SerialNumber = pUnk->GetRefEHandle().GetSerialNumber();
return &tempInfo;
}
CEntInfo *pArray = (CEntInfo *)(((unsigned char *)g_EntList) + entInfoOffset);
return &pArray[entIndex];
}
/**
SERIAL_MASK = 0x7fff (15 bits)
#define MAX_EDICT_BITS 11
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
m_Index = iEntry | (iSerialNumber << NUM_ENT_ENTRY_BITS);
Top 5 bits of a handle are unused.
Bit 31 - Our 'reference' flag indicator
*/
cell_t CHalfLife2::IndexToReference(int entIndex)
{
CBaseEntity *pEnt = ReferenceToEntity(entIndex);
if (!pEnt)
{
return INVALID_EHANDLE_INDEX;
}
return EntityToReference(pEnt);
}
int CHalfLife2::ReferenceToIndex(cell_t entRef)
{
if ((unsigned)entRef == INVALID_EHANDLE_INDEX)
{
return INVALID_EHANDLE_INDEX;
}
if (entRef & (1<<31))
{
/* Proper ent reference */
int hndlValue = entRef & ~(1<<31);
CBaseHandle hndl(hndlValue);
CEntInfo *pInfo = LookupEntity(hndl.GetEntryIndex());
if (pInfo->m_SerialNumber != hndl.GetSerialNumber())
{
return INVALID_EHANDLE_INDEX;
}
return hndl.GetEntryIndex();
}
return entRef;
}
cell_t CHalfLife2::EntityToBCompatRef(CBaseEntity *pEntity)
{
if (pEntity == NULL)
{
return INVALID_EHANDLE_INDEX;
}
IServerUnknown *pUnknown = (IServerUnknown *)pEntity;
CBaseHandle hndl = pUnknown->GetRefEHandle();
if (hndl.GetEntryIndex() >= MAX_EDICTS)
{
return (hndl.ToInt() | (1<<31));
}
else
{
return hndl.GetEntryIndex();
}
}
cell_t CHalfLife2::ReferenceToBCompatRef(cell_t entRef)
{
if ((unsigned)entRef == INVALID_EHANDLE_INDEX)
{
return INVALID_EHANDLE_INDEX;
}
int hndlValue = entRef & ~(1<<31);
CBaseHandle hndl(hndlValue);
if (hndl.GetEntryIndex() < MAX_EDICTS)
{
return hndl.GetEntryIndex();
}
return entRef;
}
void *CHalfLife2::GetGlobalEntityList()
{
return g_EntList;
}
+22 -2
View File
@@ -43,6 +43,7 @@
#include <KeyValues.h> #include <KeyValues.h>
#include <server_class.h> #include <server_class.h>
#include <datamap.h> #include <datamap.h>
#include <ihandleentity.h>
class CCommand; class CCommand;
@@ -86,6 +87,15 @@ struct DelayedKickInfo
char buffer[384]; char buffer[384];
}; };
class CEntInfo
{
public:
IHandleEntity *m_pEntity;
int m_SerialNumber;
CEntInfo *m_pPrev;
CEntInfo *m_pNext;
};
class CHalfLife2 : class CHalfLife2 :
public SMGlobalClass, public SMGlobalClass,
public IGameHelpers public IGameHelpers
@@ -96,6 +106,7 @@ public:
public: public:
void OnSourceModStartup(bool late); void OnSourceModStartup(bool late);
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
void OnSourceModAllInitialized_Post();
/*void OnSourceModAllShutdown();*/ /*void OnSourceModAllShutdown();*/
public: //IGameHelpers public: //IGameHelpers
SendProp *FindInSendTable(const char *classname, const char *offset); SendProp *FindInSendTable(const char *classname, const char *offset);
@@ -106,6 +117,7 @@ public: //IGameHelpers
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset); void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
bool TextMsg(int client, int dest, const char *msg); bool TextMsg(int client, int dest, const char *msg);
bool HintTextMsg(int client, const char *msg); bool HintTextMsg(int client, const char *msg);
bool HintTextMsg(cell_t *players, int count, const char *msg);
bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show); bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
bool IsLANServer(); bool IsLANServer();
bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL); bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
@@ -115,6 +127,14 @@ public: //IGameHelpers
void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt); void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt);
const char *GetCurrentMap(); const char *GetCurrentMap();
void ServerCommand(const char *buffer); void ServerCommand(const char *buffer);
CBaseEntity *ReferenceToEntity(cell_t entRef);
cell_t EntityToReference(CBaseEntity *pEntity);
cell_t IndexToReference(int entIndex);
int ReferenceToIndex(cell_t entRef);
cell_t ReferenceToBCompatRef(cell_t entRef);
CEntInfo *LookupEntity(int entIndex);
cell_t EntityToBCompatRef(CBaseEntity *pEntity);
void *GetGlobalEntityList();
public: public:
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd); void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
void ProcessFakeCliCmdQueue(); void ProcessFakeCliCmdQueue();
@@ -125,7 +145,7 @@ public:
const char *CurrentCommandName(); const char *CurrentCommandName();
void AddDelayedKick(int client, int userid, const char *msg); void AddDelayedKick(int client, int userid, const char *msg);
void ProcessDelayedKicks(); void ProcessDelayedKicks();
#if !defined METAMOD_PLAPI_VERSION #if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool IsOriginalEngine(); bool IsOriginalEngine();
#endif #endif
private: private:
@@ -146,6 +166,6 @@ private:
extern CHalfLife2 g_HL2; extern CHalfLife2 g_HL2;
edict_t *GetEntity(cell_t num, CBaseEntity **pData); bool IndexToAThings(cell_t, CBaseEntity **pEntData, edict_t **pEdictData);
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_ #endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_
+7 -3
View File
@@ -950,6 +950,10 @@ bool HandleSystem::InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHa
return true; return true;
} }
#define HANDLE_LOG_VERY_BAD(message, ...) \
g_Logger.LogFatal(message, ##__VA_ARGS__); \
g_Logger.LogError(message, ##__VA_ARGS__);
bool HandleSystem::TryAndFreeSomeHandles() bool HandleSystem::TryAndFreeSomeHandles()
{ {
IPluginIterator *pl_iter = g_PluginSys.GetPluginIterator(); IPluginIterator *pl_iter = g_PluginSys.GetPluginIterator();
@@ -995,9 +999,9 @@ bool HandleSystem::TryAndFreeSomeHandles()
return false; return false;
} }
g_Logger.LogFatal("[SM] MEMORY LEAK DETECTED IN PLUGIN (file \"%s\")", highest_owner->GetFilename()); HANDLE_LOG_VERY_BAD("[SM] MEMORY LEAK DETECTED IN PLUGIN (file \"%s\")", highest_owner->GetFilename());
g_Logger.LogFatal("[SM] Unloading plugin to free %d handles.", highest_handle_count); HANDLE_LOG_VERY_BAD("[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); HANDLE_LOG_VERY_BAD("[SM] Contact the author(s) of this plugin to correct this error.", highest_handle_count);
highest_owner->GetBaseContext()->ThrowNativeErrorEx(SP_ERROR_MEMACCESS, "Memory leak"); highest_owner->GetBaseContext()->ThrowNativeErrorEx(SP_ERROR_MEMACCESS, "Memory leak");
+10 -5
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -378,6 +378,14 @@ print_error:
} }
void Logger::LogError(const char *vafmt, ...) void Logger::LogError(const char *vafmt, ...)
{
va_list ap;
va_start(ap, vafmt);
LogErrorEx(vafmt, ap);
va_end(ap);
}
void Logger::LogErrorEx(const char *vafmt, va_list ap)
{ {
if (!m_Active) if (!m_Active)
{ {
@@ -408,10 +416,7 @@ void Logger::LogError(const char *vafmt, ...)
fprintf(fp, "L %s: Info (map \"%s\") (file \"errors_%04d%02d%02d.log\")\n", date, m_CurMapName.c_str(), curtime->tm_year + 1900, curtime->tm_mon + 1, curtime->tm_mday); fprintf(fp, "L %s: Info (map \"%s\") (file \"errors_%04d%02d%02d.log\")\n", date, m_CurMapName.c_str(), curtime->tm_year + 1900, curtime->tm_mon + 1, curtime->tm_mday);
m_ErrMapStart = true; m_ErrMapStart = true;
} }
va_list ap;
va_start(ap, vafmt);
LogToOpenFileEx(fp, vafmt, ap); LogToOpenFileEx(fp, vafmt, ap);
va_end(ap);
fclose(fp); fclose(fp);
} }
else else
+1
View File
@@ -75,6 +75,7 @@ public:
void DisableLogging(); void DisableLogging();
void LogMessage(const char *msg, ...); void LogMessage(const char *msg, ...);
void LogError(const char *msg, ...); void LogError(const char *msg, ...);
void LogErrorEx(const char *msg, va_list ap);
void LogFatal(const char *msg, ...); void LogFatal(const char *msg, ...);
void LogToOpenFile(FILE *fp, const char *msg, ...); void LogToOpenFile(FILE *fp, const char *msg, ...);
void LogToOpenFileEx(FILE *fp, const char *msg, va_list ap); void LogToOpenFileEx(FILE *fp, const char *msg, va_list ap);
+35 -17
View File
@@ -7,7 +7,8 @@ HL2SDK_ORIG = ../../hl2sdk
HL2SDK_OB = ../../hl2sdk-ob HL2SDK_OB = ../../hl2sdk-ob
HL2SDK_OB_VALVE = ../../hl2sdk-ob-valve HL2SDK_OB_VALVE = ../../hl2sdk-ob-valve
HL2SDK_L4D = ../../hl2sdk-l4d HL2SDK_L4D = ../../hl2sdk-l4d
MMSOURCE17 = ../../mmsource-1.7 HL2SDK_L4D2 = ../../hl2sdk-l4d2
MMSOURCE17 = ../../mmsource-central
##################################### #####################################
### EDIT BELOW FOR OTHER PROJECTS ### ### EDIT BELOW FOR OTHER PROJECTS ###
@@ -15,19 +16,19 @@ MMSOURCE17 = ../../mmsource-1.7
OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \
Database.cpp DebugReporter.cpp EventManager.cpp GameConfigs.cpp HalfLife2.cpp Logger.cpp \ Database.cpp DebugReporter.cpp EventManager.cpp GameConfigs.cpp HalfLife2.cpp Logger.cpp \
MemoryUtils.cpp PlayerManager.cpp TextParsers.cpp TimerSys.cpp Translator.cpp UserMessages.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 \ 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 \ sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \
MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp sm_crc32.cpp \ MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp sm_crc32.cpp \
frame_hooks.cpp concmd_cleaner.cpp Profiler.cpp PhraseCollection.cpp NextMap.cpp \ frame_hooks.cpp concmd_cleaner.cpp PhraseCollection.cpp NextMap.cpp \
NativeOwner.cpp NativeOwner.cpp logic_bridge.cpp ConsoleDetours.cpp
OBJECTS += smn_admin.cpp smn_bitbuffer.cpp smn_console.cpp smn_core.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_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
smn_filesystem.cpp smn_float.cpp smn_functions.cpp smn_gameconfigs.cpp smn_halflife.cpp \ smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp smn_maplists.cpp \ smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp \
smn_lang.cpp smn_player.cpp smn_string.cpp smn_sorting.cpp smn_textparse.cpp smn_timers.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_adt_array.cpp \ smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \
smn_adt_trie.cpp smn_hudtext.cpp smn_adt_stack.cpp smn_nextmap.cpp smn_hudtext.cpp smn_nextmap.cpp
OBJECTS += ExtensionSys.cpp \ OBJECTS += ExtensionSys.cpp \
ForwardSys.cpp \ ForwardSys.cpp \
HandleSys.cpp \ HandleSys.cpp \
@@ -36,7 +37,6 @@ OBJECTS += ExtensionSys.cpp \
PluginSys.cpp \ PluginSys.cpp \
ShareSys.cpp \ ShareSys.cpp \
NativeInvoker.cpp NativeInvoker.cpp
OBJECTS += thread/ThreadWorker.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp ThreadSupport.cpp
############################################## ##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
@@ -77,7 +77,7 @@ ifeq "$(ENGINE)" "orangeboxvalve"
HL2LIB = $(HL2SDK)/lib/linux HL2LIB = $(HL2SDK)/lib/linux
CFLAGS += -DSOURCE_ENGINE=4 CFLAGS += -DSOURCE_ENGINE=4
METAMOD = $(MMSOURCE17)/core METAMOD = $(MMSOURCE17)/core
INCLUDE += -I$(HL2SDK)/public/game/server INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common
SRCDS = $(SRCDS_BASE)/orangebox SRCDS = $(SRCDS_BASE)/orangebox
BINARY = sourcemod.2.ep2v.so BINARY = sourcemod.2.ep2v.so
override ENGSET = true override ENGSET = true
@@ -93,11 +93,27 @@ ifeq "$(ENGINE)" "left4dead"
BINARY = sourcemod.2.l4d.so BINARY = sourcemod.2.l4d.so
override ENGSET = true override ENGSET = true
endif endif
ifeq "$(ENGINE)" "left4dead2"
HL2SDK = $(HL2SDK_L4D2)
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/lib/linux
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
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6
ifeq "$(ENGINE)" "left4dead2"
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a libvstdlib.so \
libtier0.so -static-libgcc
else
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so \ LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so \
tier0_i486.so -lpthread -static-libgcc tier0_i486.so -static-libgcc
endif
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \ 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 \ -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \
@@ -136,10 +152,14 @@ $(BIN_DIR)/%.o: %.c
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
all: check all: check
mkdir -p $(BIN_DIR)/systems mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/thread 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/vstdlib_i486.so vstdlib_i486.so;
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so;
endif
$(MAKE) -f Makefile sourcemod $(MAKE) -f Makefile sourcemod
check: check:
@@ -158,6 +178,4 @@ default: all
clean: check clean: check
rm -rf $(BIN_DIR)/*.o rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/systems/*.o
rm -rf $(BIN_DIR)/thread/*.o
rm -rf $(BIN_DIR)/$(BINARY) rm -rf $(BIN_DIR)/$(BINARY)
+173 -9
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -25,15 +25,17 @@
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/ */
#include "MemoryUtils.h" #include "MemoryUtils.h"
#include "ShareSys.h" #include "ShareSys.h"
#ifdef PLATFORM_LINUX #ifdef PLATFORM_LINUX
#include <string.h> #include <fcntl.h>
#include <elf.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 #endif
MemoryUtils g_MemUtils; MemoryUtils g_MemUtils;
@@ -56,6 +58,17 @@ MemoryUtils::MemoryUtils()
} }
#endif #endif
MemoryUtils::~MemoryUtils()
{
#ifdef PLATFORM_LINUX
for (size_t i = 0; i < m_SymTables.size(); i++)
{
delete m_SymTables[i];
}
m_SymTables.clear();
#endif
}
void MemoryUtils::OnSourceModAllInitialized() void MemoryUtils::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); g_ShareSys.AddInterface(NULL, this);
@@ -98,6 +111,149 @@ void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t l
return NULL; 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;
#endif
}
bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib) bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
{ {
unsigned long baseAddr; unsigned long baseAddr;
@@ -201,14 +357,22 @@ bool MemoryUtils::GetLibraryInfo(const void *libPtr, DynLibInfo &lib)
phdrCount = file->e_phnum; phdrCount = file->e_phnum;
phdr = reinterpret_cast<Elf32_Phdr *>(baseAddr + file->e_phoff); 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++) for (uint16_t i = 0; i < phdrCount; i++)
{ {
Elf32_Phdr &hdr = phdr[i]; Elf32_Phdr &hdr = phdr[i];
if (hdr.p_type == PT_LOAD) /* We only really care about the segment with executable code */
if (hdr.p_type == PT_LOAD && hdr.p_flags == (PF_X|PF_R))
{ {
lib.memorySize += hdr.p_memsz; /* 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;
} }
} }
+27 -5
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -25,8 +25,6 @@
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/ */
#ifndef _INCLUDE_SOURCEMOD_MEMORYUTILS_H_ #ifndef _INCLUDE_SOURCEMOD_MEMORYUTILS_H_
@@ -34,6 +32,12 @@
#include <IMemoryUtils.h> #include <IMemoryUtils.h>
#include "sm_globals.h" #include "sm_globals.h"
#ifdef PLATFORM_LINUX
#include <sh_vector.h>
#include "sm_symtable.h"
using namespace SourceHook;
#endif
using namespace SourceMod; using namespace SourceMod;
@@ -43,16 +47,34 @@ struct DynLibInfo
size_t memorySize; size_t memorySize;
}; };
#ifdef PLATFORM_LINUX
typedef uint32_t Elf32_Addr;
struct LibSymbolTable
{
SymbolTable table;
Elf32_Addr lib_base;
uint32_t last_pos;
};
#endif
class MemoryUtils : class MemoryUtils :
public IMemoryUtils, public IMemoryUtils,
public SMGlobalClass public SMGlobalClass
{ {
public:
~MemoryUtils();
public: // SMGlobalClass public: // SMGlobalClass
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
public: // IMemoryUtils public: // IMemoryUtils
void *FindPattern(const void *libPtr, const char *pattern, size_t len); void *FindPattern(const void *libPtr, const char *pattern, size_t len);
private: void *ResolveSymbol(void *handle, const char *symbol);
public:
bool GetLibraryInfo(const void *libPtr, DynLibInfo &lib); bool GetLibraryInfo(const void *libPtr, DynLibInfo &lib);
#ifdef PLATFORM_LINUX
private:
CVector<LibSymbolTable *> m_SymTables;
#endif
}; };
extern MemoryUtils g_MemUtils; extern MemoryUtils g_MemUtils;
+200 -8
View File
@@ -34,9 +34,55 @@
#include "MenuVoting.h" #include "MenuVoting.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include <sourcemod.h>
#include <Logger.h>
#include <HalfLife2.h>
#include <mathlib.h>
#include <const.h>
#include <Translator.h>
float g_next_vote = 0.0f; float g_next_vote = 0.0f;
#define VOTE_NOT_VOTING -2
#define VOTE_PENDING -1
ConVar sm_vote_hintbox("sm_vote_progress_hintbox",
"0",
0,
"Show current vote progress in a hint box",
true,
0.0,
true,
1.0);
ConVar sm_vote_chat("sm_vote_progress_chat",
"0",
0,
"Show current vote progress as chat messages",
true,
0.0,
true,
1.0);
ConVar sm_vote_console("sm_vote_progress_console",
"0",
0,
"Show current vote progress as console messages",
true,
0.0,
true,
1.0);
ConVar sm_vote_client_console("sm_vote_progress_client_console",
"0",
0,
"Show current vote progress as console messages to clients",
true,
0.0,
true,
1.0);
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
void OnVoteDelayChange(IConVar *cvar, const char *value, float flOldValue); void OnVoteDelayChange(IConVar *cvar, const char *value, float flOldValue);
#else #else
@@ -117,7 +163,7 @@ void VoteMenuHandler::OnClientDisconnected(int client)
* newly connected client is not allowed to vote. * newly connected client is not allowed to vote.
*/ */
int item; int item;
if ((item = m_ClientVotes[client]) >= -1) if ((item = m_ClientVotes[client]) >= VOTE_PENDING)
{ {
if (item >= 0) if (item >= 0)
{ {
@@ -125,7 +171,7 @@ void VoteMenuHandler::OnClientDisconnected(int client)
assert(m_Votes[item] > 0); assert(m_Votes[item] > 0);
m_Votes[item]--; m_Votes[item]--;
} }
m_ClientVotes[client] = -2; m_ClientVotes[client] = VOTE_NOT_VOTING;
} }
} }
@@ -189,13 +235,13 @@ bool VoteMenuHandler::IsClientInVotePool(int client)
return false; return false;
} }
return (m_ClientVotes[client] > -2); return (m_ClientVotes[client] > VOTE_NOT_VOTING);
} }
bool VoteMenuHandler::GetClientVoteChoice(int client, unsigned int *pItem) bool VoteMenuHandler::GetClientVoteChoice(int client, unsigned int *pItem)
{ {
if (!IsClientInVotePool(client) if (!IsClientInVotePool(client)
|| m_ClientVotes[client] == -1) || m_ClientVotes[client] == VOTE_PENDING)
{ {
return false; return false;
} }
@@ -223,7 +269,9 @@ bool VoteMenuHandler::RedrawToClient(int client, bool revotes)
assert((unsigned)m_ClientVotes[client] < m_Items); assert((unsigned)m_ClientVotes[client] < m_Items);
assert(m_Votes[m_ClientVotes[client]] > 0); assert(m_Votes[m_ClientVotes[client]] > 0);
m_Votes[m_ClientVotes[client]]--; m_Votes[m_ClientVotes[client]]--;
m_ClientVotes[client] = -1; m_ClientVotes[client] = VOTE_PENDING;
m_Revoting[client] = true;
m_NumVotes--;
} }
if (m_nMenuTime == MENU_TIME_FOREVER) if (m_nMenuTime == MENU_TIME_FOREVER)
@@ -259,7 +307,8 @@ bool VoteMenuHandler::InitializeVoting(IBaseMenu *menu,
/* Mark all clients as not voting */ /* Mark all clients as not voting */
for (int i=1; i<=gpGlobals->maxClients; i++) for (int i=1; i<=gpGlobals->maxClients; i++)
{ {
m_ClientVotes[i] = -2; m_ClientVotes[i] = VOTE_NOT_VOTING;
m_Revoting[i] = false;
} }
m_Items = menu->GetItemCount(); m_Items = menu->GetItemCount();
@@ -303,6 +352,8 @@ void VoteMenuHandler::StartVoting()
m_pHandler->OnMenuVoteStart(m_pCurMenu); m_pHandler->OnMenuVoteStart(m_pCurMenu);
m_displayTimer = g_Timers.CreateTimer(this, 1.0, NULL, TIMER_FLAG_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
/* By now we know how many clients were set. /* By now we know how many clients were set.
* If there are none, we should end IMMEDIATELY. * If there are none, we should end IMMEDIATELY.
*/ */
@@ -310,6 +361,8 @@ void VoteMenuHandler::StartVoting()
{ {
EndVoting(); EndVoting();
} }
m_TotalClients = m_Clients;
} }
void VoteMenuHandler::DecrementPlayerCount() void VoteMenuHandler::DecrementPlayerCount()
@@ -346,6 +399,11 @@ void VoteMenuHandler::EndVoting()
g_next_vote = gpGlobals->curtime + fVoteDelay; g_next_vote = gpGlobals->curtime + fVoteDelay;
} }
if (m_displayTimer)
{
g_Timers.KillTimer(m_displayTimer);
}
if (m_bCancelled) if (m_bCancelled)
{ {
/* If we were cancelled, don't bother tabulating anything. /* If we were cancelled, don't bother tabulating anything.
@@ -392,7 +450,7 @@ void VoteMenuHandler::EndVoting()
/* Build the client list */ /* Build the client list */
for (int i=1; i<=gpGlobals->maxClients; i++) for (int i=1; i<=gpGlobals->maxClients; i++)
{ {
if (m_ClientVotes[i] >= -1) if (m_ClientVotes[i] >= VOTE_PENDING)
{ {
client_vote[vote.num_clients].client = i; client_vote[vote.num_clients].client = i;
client_vote[vote.num_clients].item = m_ClientVotes[i]; client_vote[vote.num_clients].item = m_ClientVotes[i];
@@ -436,7 +494,7 @@ void VoteMenuHandler::OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason
void VoteMenuHandler::OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display) void VoteMenuHandler::OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display)
{ {
m_ClientVotes[client] = -1; m_ClientVotes[client] = VOTE_PENDING;
m_pHandler->OnMenuDisplay(menu, client, display); m_pHandler->OnMenuDisplay(menu, client, display);
} }
@@ -458,6 +516,55 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
m_ClientVotes[client] = item; m_ClientVotes[client] = item;
m_Votes[item]++; m_Votes[item]++;
m_NumVotes++; m_NumVotes++;
if (sm_vote_chat.GetBool() || sm_vote_console.GetBool())
{
static char buffer[1024];
ItemDrawInfo dr;
menu->GetItemInfo(item, &dr);
if (sm_vote_console.GetBool())
{
int target = SOURCEMOD_SERVER_LANGUAGE;
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", &target, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
Engine_LogPrintWrapper(buffer);
}
if (sm_vote_chat.GetBool() || sm_vote_client_console.GetBool())
{
int maxclients = g_Players.GetMaxClients();
for (int i=1; i<=maxclients; i++)
{
CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
assert(pPlayer);
if (pPlayer->IsInGame() && !pPlayer->IsFakeClient())
{
if (m_Revoting[client])
{
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Changed Vote", &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
}
else
{
CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display);
}
if (sm_vote_chat.GetBool())
{
g_HL2.TextMsg(i, HUD_PRINTTALK, buffer);
}
if (sm_vote_client_console.GetBool())
{
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
}
}
}
}
}
BuildVoteLeaders();
DrawHintProgress();
} }
m_pHandler->OnMenuSelect(menu, client, item); m_pHandler->OnMenuSelect(menu, client, item);
@@ -480,6 +587,9 @@ void VoteMenuHandler::InternalReset()
m_NumVotes = 0; m_NumVotes = 0;
m_bCancelled = false; m_bCancelled = false;
m_pHandler = NULL; m_pHandler = NULL;
m_leaderList[0] = '\0';
m_displayTimer = NULL;
m_TotalClients = 0;
} }
void VoteMenuHandler::CancelVoting() void VoteMenuHandler::CancelVoting()
@@ -502,3 +612,85 @@ bool VoteMenuHandler::IsCancelling()
return m_bCancelled; return m_bCancelled;
} }
void VoteMenuHandler::DrawHintProgress()
{
if (!sm_vote_hintbox.GetBool())
{
return;
}
static char buffer[1024];
float timeRemaining = (m_fStartTime + m_nMenuTime) - gpGlobals->curtime;
if (timeRemaining < 0)
{
timeRemaining = 0.0;
}
int iTimeRemaining = RoundFloatToInt(timeRemaining);
int maxclients = g_Players.GetMaxClients();
for (int i=1; i<=maxclients; i++)
{
if (g_Players.GetPlayerByIndex(i)->IsInGame())
{
CoreTranslate(buffer, sizeof(buffer), "%T%s", 6, NULL, "Vote Count", &i, &m_NumVotes, &m_TotalClients, &iTimeRemaining, &m_leaderList);
g_HL2.HintTextMsg(i, buffer);
}
}
}
void VoteMenuHandler::BuildVoteLeaders()
{
if (m_NumVotes == 0 || !sm_vote_hintbox.GetBool())
{
return;
}
menu_vote_result_t vote;
menu_vote_result_t::menu_item_vote_t item_vote[256];
memset(&vote, 0, sizeof(vote));
/* Build the item list */
for (unsigned int i=0; i<m_Items; i++)
{
if (m_Votes[i] > 0)
{
item_vote[vote.num_items].count = m_Votes[i];
item_vote[vote.num_items].item = i;
vote.num_votes += m_Votes[i];
vote.num_items++;
}
}
vote.item_list = item_vote;
assert(vote.num_votes);
/* Sort the item list descending */
qsort(item_vote,
vote.num_items,
sizeof(menu_vote_result_t::menu_item_vote_t),
SortVoteItems);
/* Take the top 3 (if applicable) and draw them */
int len = 0;
for (unsigned int i=0; i<vote.num_items && i<3; i++)
{
int curItem = vote.item_list[i].item;
ItemDrawInfo dr;
m_pCurMenu->GetItemInfo(curItem, &dr);
len += g_SourceMod.Format(m_leaderList + len, sizeof(m_leaderList) - len, "\n%i. %s: (%i)", i+1, dr.display, vote.item_list[i].count);
}
}
SourceMod::ResultType VoteMenuHandler::OnTimer(ITimer *pTimer, void *pData)
{
DrawHintProgress();
return Pl_Continue;
}
void VoteMenuHandler::OnTimerEnd(ITimer *pTimer, void *pData)
{
m_displayTimer = NULL;
}
+12 -1
View File
@@ -36,6 +36,7 @@
#include <IPlayerHelpers.h> #include <IPlayerHelpers.h>
#include <sh_vector.h> #include <sh_vector.h>
#include "sm_globals.h" #include "sm_globals.h"
#include <TimerSys.h>
using namespace SourceHook; using namespace SourceHook;
using namespace SourceMod; using namespace SourceMod;
@@ -43,7 +44,8 @@ using namespace SourceMod;
class VoteMenuHandler : class VoteMenuHandler :
public IMenuHandler, public IMenuHandler,
public SMGlobalClass, public SMGlobalClass,
public IClientListener public IClientListener,
public ITimedEvent
{ {
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
@@ -61,6 +63,9 @@ public: //IMenuHandler
void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason); void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason);
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr); unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr);
public: //ITimedEvent
ResultType OnTimer(ITimer *pTimer, void *pData);
void OnTimerEnd(ITimer *pTimer, void *pData);
public: public:
bool StartVote(IBaseMenu *menu, bool StartVote(IBaseMenu *menu,
unsigned int num_clients, unsigned int num_clients,
@@ -85,9 +90,12 @@ private:
unsigned int time, unsigned int time,
unsigned int flags); unsigned int flags);
void StartVoting(); void StartVoting();
void DrawHintProgress();
void BuildVoteLeaders();
private: private:
IMenuHandler *m_pHandler; IMenuHandler *m_pHandler;
unsigned int m_Clients; unsigned int m_Clients;
unsigned int m_TotalClients;
unsigned int m_Items; unsigned int m_Items;
CVector<unsigned int> m_Votes; CVector<unsigned int> m_Votes;
IBaseMenu *m_pCurMenu; IBaseMenu *m_pCurMenu;
@@ -99,6 +107,9 @@ private:
float m_fStartTime; float m_fStartTime;
unsigned int m_nMenuTime; unsigned int m_nMenuTime;
int m_ClientVotes[256+1]; int m_ClientVotes[256+1];
bool m_Revoting[256+1];
char m_leaderList[1024];
ITimer *m_displayTimer;
}; };
#endif //_INCLUDE_SOURCEMOD_MENUVOTING_H_ #endif //_INCLUDE_SOURCEMOD_MENUVOTING_H_
+5 -1
View File
@@ -49,7 +49,11 @@ SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &)
#elif SOURCE_ENGINE == SE_DARKMESSIAH #elif SOURCE_ENGINE == SE_DARKMESSIAH
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false); SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
#else #else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); # if SH_IMPL_VERSION >= 4
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
# else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
#endif
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
#endif #endif
+79 -36
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -48,13 +48,14 @@
#include "GameConfigs.h" #include "GameConfigs.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include <sourcemod_version.h> #include <sourcemod_version.h>
#include "ConsoleDetours.h"
PlayerManager g_Players; PlayerManager g_Players;
bool g_OnMapStarted = false; bool g_OnMapStarted = false;
IForward *PreAdminCheck = NULL; IForward *PreAdminCheck = NULL;
IForward *PostAdminCheck = NULL; IForward *PostAdminCheck = NULL;
IForward *PostAdminFilter = NULL; IForward *PostAdminFilter = NULL;
IForward *OnClientConnected = NULL;
const unsigned int *g_NumPlayersToAuth = NULL; const unsigned int *g_NumPlayersToAuth = NULL;
int lifestate_offset = -1; int lifestate_offset = -1;
List<ICommandTargetProcessor *> target_processors; List<ICommandTargetProcessor *> target_processors;
@@ -75,7 +76,11 @@ SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &)
#elif SOURCE_ENGINE == SE_DARKMESSIAH #elif SOURCE_ENGINE == SE_DARKMESSIAH
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false); SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
#else #else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); # if SH_IMPL_VERSION >= 4
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
# else
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
# endif
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>); extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
#endif #endif
@@ -137,6 +142,7 @@ void PlayerManager::OnSourceModAllInitialized()
ParamType p2[] = {Param_Cell}; ParamType p2[] = {Param_Cell};
m_clconnect = g_Forwards.CreateForward("OnClientConnect", ET_LowEvent, 3, p1); 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_clputinserver = g_Forwards.CreateForward("OnClientPutInServer", ET_Ignore, 1, p2);
m_cldisconnect = g_Forwards.CreateForward("OnClientDisconnect", 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); m_cldisconnect_post = g_Forwards.CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2);
@@ -145,7 +151,6 @@ void PlayerManager::OnSourceModAllInitialized()
m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); 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_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL);
m_onActivate2 = g_Forwards.CreateForward("OnMapStart", 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); PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
@@ -154,8 +159,6 @@ void PlayerManager::OnSourceModAllInitialized()
m_bIsListenServer = !engine->IsDedicatedServer(); m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0; m_ListenClient = 0;
g_ConVarManager.AddConVarChangeListener("tv_enable", this);
ConCommand *pCmd = FindCommand("maxplayers"); ConCommand *pCmd = FindCommand("maxplayers");
if (pCmd != NULL) if (pCmd != NULL)
{ {
@@ -167,6 +170,7 @@ void PlayerManager::OnSourceModAllInitialized()
void PlayerManager::OnSourceModShutdown() void PlayerManager::OnSourceModShutdown()
{ {
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect, false); 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, 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, false);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect_Post, true); SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect_Post, true);
@@ -176,6 +180,7 @@ void PlayerManager::OnSourceModShutdown()
/* Release forwards */ /* Release forwards */
g_Forwards.ReleaseForward(m_clconnect); g_Forwards.ReleaseForward(m_clconnect);
g_Forwards.ReleaseForward(m_clconnect_post);
g_Forwards.ReleaseForward(m_clputinserver); g_Forwards.ReleaseForward(m_clputinserver);
g_Forwards.ReleaseForward(m_cldisconnect); g_Forwards.ReleaseForward(m_cldisconnect);
g_Forwards.ReleaseForward(m_cldisconnect_post); g_Forwards.ReleaseForward(m_cldisconnect_post);
@@ -184,7 +189,6 @@ void PlayerManager::OnSourceModShutdown()
g_Forwards.ReleaseForward(m_clauth); g_Forwards.ReleaseForward(m_clauth);
g_Forwards.ReleaseForward(m_onActivate); g_Forwards.ReleaseForward(m_onActivate);
g_Forwards.ReleaseForward(m_onActivate2); g_Forwards.ReleaseForward(m_onActivate2);
g_Forwards.ReleaseForward(OnClientConnected);
g_Forwards.ReleaseForward(PreAdminCheck); g_Forwards.ReleaseForward(PreAdminCheck);
g_Forwards.ReleaseForward(PostAdminCheck); g_Forwards.ReleaseForward(PostAdminCheck);
@@ -192,8 +196,6 @@ void PlayerManager::OnSourceModShutdown()
delete [] m_Players; delete [] m_Players;
g_ConVarManager.RemoveConVarChangeListener("tv_enable", this);
if (maxplayersCmd != NULL) if (maxplayersCmd != NULL)
{ {
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, maxplayersCmd, CmdMaxplayersCallback, true); SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, maxplayersCmd, CmdMaxplayersCallback, true);
@@ -233,7 +235,10 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
if (!m_FirstPass) if (!m_FirstPass)
{ {
/* Initialize all players */ /* Initialize all players */
m_maxClients = clientMax;
// clientMax will not necessarily be correct here (such as on late SourceTV enable)
m_maxClients = gpGlobals->maxClients;
m_PlayerCount = 0; m_PlayerCount = 0;
m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1]; m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1]; m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1];
@@ -461,7 +466,7 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
pListener->OnClientConnected(client); pListener->OnClientConnected(client);
if (!pPlayer->IsConnected()) if (!pPlayer->IsConnected())
{ {
break; return true;
} }
} }
@@ -473,8 +478,8 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
} }
cell_t res; cell_t res;
OnClientConnected->PushCell(client); m_clconnect_post->PushCell(client);
OnClientConnected->Execute(&res, NULL); m_clconnect_post->Execute(&res, NULL);
} }
else else
{ {
@@ -515,6 +520,11 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
return; return;
} }
} }
cell_t res;
m_clconnect_post->PushCell(client);
m_clconnect_post->Execute(&res, NULL);
/* Now do authorization */ /* Now do authorization */
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
{ {
@@ -689,7 +699,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
ClientConsolePrint(pEntity, ClientConsolePrint(pEntity,
" David \"BAILOPAN\" Anderson, Borja \"faluco\" Ferrer"); " David \"BAILOPAN\" Anderson, Borja \"faluco\" Ferrer");
ClientConsolePrint(pEntity, ClientConsolePrint(pEntity,
" Scott \"Damaged Soul\" Ehlert, Matt \"pRED\" Woodrow"); " Scott \"DS\" Ehlert, Matt \"pRED\" Woodrow");
ClientConsolePrint(pEntity, ClientConsolePrint(pEntity,
" Michael \"ferret\" McKoy, Pavol \"PM OnoTo\" Marko"); " Michael \"ferret\" McKoy, Pavol \"PM OnoTo\" Marko");
ClientConsolePrint(pEntity, ClientConsolePrint(pEntity,
@@ -725,10 +735,27 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
} }
} }
if (g_ConsoleDetours.IsEnabled())
{
cell_t res2 = g_ConsoleDetours.InternalDispatch(client, args);
if (res2 >= Pl_Stop)
{
g_HL2.PopCommandStack();
RETURN_META(MRES_SUPERCEDE);
}
else if (res2 > res)
{
res = res2;
}
}
cell_t res2 = Pl_Continue; cell_t res2 = Pl_Continue;
m_clcommand->PushCell(client); if (pPlayer->IsInGame())
m_clcommand->PushCell(argcount); {
m_clcommand->Execute(&res2, NULL); m_clcommand->PushCell(client);
m_clcommand->PushCell(argcount);
m_clcommand->Execute(&res2, NULL);
}
if (res2 > res) if (res2 > res)
{ {
@@ -1153,10 +1180,18 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
if (strcmp(info->pattern, "@me") == 0 && info->admin != 0) if (strcmp(info->pattern, "@me") == 0 && info->admin != 0)
{ {
info->targets[0] = info->admin; info->reason = FilterCommandTarget(pAdmin, pAdmin, info->flags);
info->num_targets = 1; if (info->reason == COMMAND_TARGET_VALID)
strncopy(info->target_name, pAdmin->GetName(), info->target_name_maxlength); {
info->target_name_style = COMMAND_TARGETNAME_RAW; info->targets[0] = info->admin;
info->num_targets = 1;
strncopy(info->target_name, pAdmin->GetName(), info->target_name_maxlength);
info->target_name_style = COMMAND_TARGETNAME_RAW;
}
else
{
info->num_targets = 0;
}
return; return;
} }
@@ -1308,18 +1343,6 @@ 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 ) void PlayerManager::OnSourceModMaxPlayersChanged( int newvalue )
{ {
m_maxClients = newvalue; m_maxClients = newvalue;
@@ -1411,6 +1434,7 @@ CPlayer::CPlayer()
m_TempAdmin = false; m_TempAdmin = false;
m_Info = NULL; m_Info = NULL;
m_bAdminCheckSignalled = false; m_bAdminCheckSignalled = false;
m_UserId = -1;
m_bIsInKickQueue = false; m_bIsInKickQueue = false;
m_LastPassword.clear(); m_LastPassword.clear();
m_LangId = SOURCEMOD_LANGUAGE_ENGLISH; m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
@@ -1588,8 +1612,22 @@ void CPlayer::Kick(const char *str)
{ {
MarkAsBeingKicked(); MarkAsBeingKicked();
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex)); INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler()); if (pNetChan == NULL)
pClient->Disconnect("%s", str); {
/* What does this even mean? Hell if I know. */
int userid = GetUserId();
if (userid > 0)
{
char buffer[255];
UTIL_Format(buffer, sizeof(buffer), "kickid %d %s\n", userid, str);
engine->ServerCommand(buffer);
}
}
else
{
IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler());
pClient->Disconnect("%s", str);
}
} }
void CPlayer::Authorize_Post() void CPlayer::Authorize_Post()
@@ -1731,6 +1769,11 @@ unsigned int CPlayer::GetLanguageId()
return m_LangId; return m_LangId;
} }
void CPlayer::SetLanguageId(unsigned int id)
{
m_LangId = id;
}
int CPlayer::GetUserId() int CPlayer::GetUserId()
{ {
if (m_UserId == -1) if (m_UserId == -1)
+4 -5
View File
@@ -79,15 +79,16 @@ public:
void SetAdminId(AdminId id, bool temporary); void SetAdminId(AdminId id, bool temporary);
AdminId GetAdminId(); AdminId GetAdminId();
void Kick(const char *str); void Kick(const char *str);
bool IsInKickQueue();
IPlayerInfo *GetPlayerInfo(); IPlayerInfo *GetPlayerInfo();
unsigned int GetLanguageId(); unsigned int GetLanguageId();
void SetLanguageId(unsigned int id);
int GetUserId(); int GetUserId();
bool RunAdminCacheChecks(); bool RunAdminCacheChecks();
void NotifyPostAdminChecks(); void NotifyPostAdminChecks();
unsigned int GetSerial(); unsigned int GetSerial();
public: public:
void DoBasicAdminChecks(); void DoBasicAdminChecks();
bool IsInKickQueue();
void MarkAsBeingKicked(); void MarkAsBeingKicked();
int GetLifeState(); int GetLifeState();
private: private:
@@ -123,8 +124,7 @@ private:
class PlayerManager : class PlayerManager :
public SMGlobalClass, public SMGlobalClass,
public IPlayerManager, public IPlayerManager
public IConVarChangeListener
{ {
friend class CPlayer; friend class CPlayer;
public: public:
@@ -169,8 +169,6 @@ public: //IPlayerManager
void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler); void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
void ProcessCommandTarget(cmd_target_info_t *info); void ProcessCommandTarget(cmd_target_info_t *info);
int GetClientFromSerial(unsigned int serial); int GetClientFromSerial(unsigned int serial);
public: // IConVarChangeListener
void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
public: public:
inline int MaxClients() inline int MaxClients()
{ {
@@ -197,6 +195,7 @@ private:
private: private:
List<IClientListener *> m_hooks; List<IClientListener *> m_hooks;
IForward *m_clconnect; IForward *m_clconnect;
IForward *m_clconnect_post;
IForward *m_cldisconnect; IForward *m_cldisconnect;
IForward *m_cldisconnect_post; IForward *m_cldisconnect_post;
IForward *m_clputinserver; IForward *m_clputinserver;
+63 -26
View File
@@ -37,7 +37,6 @@
#include "ForwardSys.h" #include "ForwardSys.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sourcemod.h" #include "sourcemod.h"
#include "TextParsers.h"
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
@@ -57,9 +56,10 @@ CPlugin::CPlugin(const char *file)
m_type = PluginType_Private; m_type = PluginType_Private;
m_status = Plugin_Uncompiled; m_status = Plugin_Uncompiled;
m_bSilentlyFailed = false;
m_serial = ++MySerial; m_serial = ++MySerial;
m_pRuntime = NULL; m_pRuntime = NULL;
m_errormsg[256] = '\0'; m_errormsg[sizeof(m_errormsg) - 1] = '\0';
UTIL_Format(m_filename, sizeof(m_filename), "%s", file); UTIL_Format(m_filename, sizeof(m_filename), "%s", file);
m_handle = 0; m_handle = 0;
m_ident = NULL; m_ident = NULL;
@@ -386,22 +386,27 @@ void CPlugin::Call_OnAllPluginsLoaded()
} }
} }
bool CPlugin::Call_AskPluginLoad(char *error, size_t maxlength) APLRes CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
{ {
if (m_status != Plugin_Created) if (m_status != Plugin_Created)
{ {
return false; return APLRes_Failure;
} }
m_status = Plugin_Loaded; m_status = Plugin_Loaded;
int err; int err;
cell_t result; cell_t result;
IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad"); bool haveNewAPL = false;
IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad2");
if (!pFunction) if (pFunction)
{ {
return true; haveNewAPL = true;
}
else if (!(pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad")))
{
return APLRes_Success;
} }
pFunction->PushCell(m_handle); pFunction->PushCell(m_handle);
@@ -410,15 +415,21 @@ bool CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
pFunction->PushCell(maxlength); pFunction->PushCell(maxlength);
if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE) if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE)
{ {
return false; return APLRes_Failure;
} }
if (!result || m_status != Plugin_Loaded) if (haveNewAPL)
{ {
return false; return (APLRes)result;
}
else if (result)
{
return APLRes_Success;
}
else
{
return APLRes_Failure;
} }
return true;
} }
void *CPlugin::GetPluginStructure() void *CPlugin::GetPluginStructure()
@@ -470,6 +481,11 @@ PluginStatus CPlugin::GetStatus()
return m_status; return m_status;
} }
bool CPlugin::IsSilentlyFailed()
{
return m_bSilentlyFailed;
}
bool CPlugin::IsDebugging() bool CPlugin::IsDebugging()
{ {
if (m_pRuntime == NULL) if (m_pRuntime == NULL)
@@ -480,6 +496,11 @@ bool CPlugin::IsDebugging()
return true; return true;
} }
void CPlugin::SetSilentlyFailed(bool sf)
{
m_bSilentlyFailed = sf;
}
void CPlugin::LibraryActions(bool dropping) void CPlugin::LibraryActions(bool dropping)
{ {
List<String>::iterator iter; List<String>::iterator iter;
@@ -1004,20 +1025,31 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
} }
} }
LoadRes loadFailure = LoadRes_Failure;
/* Get the status */ /* Get the status */
if (pPlugin->GetStatus() == Plugin_Created) if (pPlugin->GetStatus() == Plugin_Created)
{ {
/* First native pass - add anything from Core */ /* First native pass - add anything from Core */
g_ShareSys.BindNativesToPlugin(pPlugin, true); g_ShareSys.BindNativesToPlugin(pPlugin, true);
pPlugin->InitIdentity(); pPlugin->InitIdentity();
if (pPlugin->Call_AskPluginLoad(error, maxlength)) APLRes result = pPlugin->Call_AskPluginLoad(error, maxlength);
switch (result)
{ {
case APLRes_Success:
/* Autoload any modules */ /* Autoload any modules */
LoadOrRequireExtensions(pPlugin, 1, error, maxlength); LoadOrRequireExtensions(pPlugin, 1, error, maxlength);
} break;
else case APLRes_Failure:
{
pPlugin->SetErrorState(Plugin_Failed, "%s", error); pPlugin->SetErrorState(Plugin_Failed, "%s", error);
loadFailure = LoadRes_Failure;
break;
case APLRes_SilentFailure:
pPlugin->SetErrorState(Plugin_Failed, "%s", error);
loadFailure = LoadRes_SilentFailure;
pPlugin->SetSilentlyFailed(true);
break;
default:
assert(false);
} }
} }
@@ -1030,7 +1062,7 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
*_plugin = pPlugin; *_plugin = pPlugin;
} }
return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : LoadRes_Failure; return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : loadFailure;
} }
IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t maxlength, bool *wasloaded) IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t maxlength, bool *wasloaded)
@@ -1093,12 +1125,12 @@ void CPluginManager::LoadAutoPlugin(const char *plugin)
{ {
g_Logger.LogError("[SM] Failed to load plugin \"%s\": %s", plugin, error); g_Logger.LogError("[SM] Failed to load plugin \"%s\": %s", plugin, error);
pl->SetErrorState( pl->SetErrorState(
pl->GetStatus() == Plugin_BadLoad ? Plugin_BadLoad : Plugin_Failed, pl->GetStatus() <= Plugin_Created ? Plugin_BadLoad : pl->GetStatus(),
"%s", "%s",
error); error);
} }
if (res == LoadRes_Successful || res == LoadRes_Failure) if (res == LoadRes_Successful || res == LoadRes_Failure || res == LoadRes_SilentFailure)
{ {
AddPlugin(pl); AddPlugin(pl);
} }
@@ -1954,7 +1986,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
assert(pl->GetStatus() != Plugin_Created); assert(pl->GetStatus() != Plugin_Created);
int len = 0; int len = 0;
const sm_plugininfo_t *info = pl->GetPublicInfo(); const sm_plugininfo_t *info = pl->GetPublicInfo();
if (pl->GetStatus() != Plugin_Running) if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed())
{ {
len += UTIL_Format(buffer, sizeof(buffer), " %02d <%s>", id, GetStatusText(pl->GetStatus())); len += UTIL_Format(buffer, sizeof(buffer), " %02d <%s>", id, GetStatusText(pl->GetStatus()));
@@ -1970,6 +2002,8 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
} }
if (pl->GetStatus() < Plugin_Created) if (pl->GetStatus() < Plugin_Created)
{ {
if (pl->IsSilentlyFailed())
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " Disabled:");
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename()); len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
if (IS_STR_FILLED(info->version)) if (IS_STR_FILLED(info->version))
{ {
@@ -2018,7 +2052,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
char pluginfile[256]; char pluginfile[256];
const char *ext = g_LibSys.GetFileExtension(filename) ? "" : ".smx"; const char *ext = g_LibSys.GetFileExtension(filename) ? "" : ".smx";
UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", filename, ext); g_SourceMod.BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", filename, ext);
IPlugin *pl = LoadPlugin(pluginfile, false, PluginType_MapUpdated, error, sizeof(error), &wasloaded); IPlugin *pl = LoadPlugin(pluginfile, false, PluginType_MapUpdated, error, sizeof(error), &wasloaded);
@@ -2065,7 +2099,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
{ {
char pluginfile[256]; char pluginfile[256];
const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx"; const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext); g_SourceMod.BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
{ {
@@ -2155,7 +2189,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
{ {
char pluginfile[256]; char pluginfile[256];
const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx"; const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext); g_SourceMod.BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
{ {
@@ -2276,7 +2310,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
{ {
char pluginfile[256]; char pluginfile[256];
const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx"; const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext); g_SourceMod.BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
{ {
@@ -2287,7 +2321,10 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c
char name[PLATFORM_MAX_PATH]; char name[PLATFORM_MAX_PATH];
const sm_plugininfo_t *info = pl->GetPublicInfo(); const sm_plugininfo_t *info = pl->GetPublicInfo();
strcpy(name, (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename()); if (pl->GetStatus() <= Plugin_Paused)
strcpy(name, (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
else
strcpy(name, pl->GetFilename());
if (ReloadPlugin(pl)) if (ReloadPlugin(pl))
{ {
@@ -2704,6 +2741,6 @@ void CPluginManager::ListPluginsToClient(CPlayer *player, const CCommand &args)
/* Do we actually have more plugins? */ /* Do we actually have more plugins? */
if (iter != m_plugins.end()) if (iter != m_plugins.end())
{ {
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id + 1); ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
} }
} }
+16 -3
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -47,7 +47,9 @@
#include "sm_trie.h" #include "sm_trie.h"
#include "sourcemod.h" #include "sourcemod.h"
#include <IRootConsoleMenu.h> #include <IRootConsoleMenu.h>
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE == SE_ALIENSWARM
#include "convar_sm_swarm.h"
#elif (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
#include "convar_sm_l4d.h" #include "convar_sm_l4d.h"
#elif (SOURCE_ENGINE == SE_ORANGEBOX) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE) #elif (SOURCE_ENGINE == SE_ORANGEBOX) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE)
#include "convar_sm_ob.h" #include "convar_sm_ob.h"
@@ -117,9 +119,17 @@ enum LoadRes
LoadRes_Successful, LoadRes_Successful,
LoadRes_AlreadyLoaded, LoadRes_AlreadyLoaded,
LoadRes_Failure, LoadRes_Failure,
LoadRes_SilentFailure,
LoadRes_NeverLoad LoadRes_NeverLoad
}; };
enum APLRes
{
APLRes_Success,
APLRes_Failure,
APLRes_SilentFailure
};
struct AutoConfig struct AutoConfig
{ {
String autocfg; String autocfg;
@@ -146,6 +156,8 @@ public:
const char *GetFilename(); const char *GetFilename();
bool IsDebugging(); bool IsDebugging();
PluginStatus GetStatus(); PluginStatus GetStatus();
bool IsSilentlyFailed();
void SetSilentlyFailed(bool sf);
const sm_plugininfo_t *GetPublicInfo(); const sm_plugininfo_t *GetPublicInfo();
bool SetPauseState(bool paused); bool SetPauseState(bool paused);
unsigned int GetSerial(); unsigned int GetSerial();
@@ -183,7 +195,7 @@ public:
* *
* If the error buffer is NULL, the error message is cached locally. * If the error buffer is NULL, the error message is cached locally.
*/ */
bool Call_AskPluginLoad(char *error, size_t maxlength); APLRes Call_AskPluginLoad(char *error, size_t maxlength);
/** /**
* Calls the OnPluginStart function. * Calls the OnPluginStart function.
@@ -247,6 +259,7 @@ private:
PluginType m_type; PluginType m_type;
char m_filename[PLATFORM_MAX_PATH]; char m_filename[PLATFORM_MAX_PATH];
PluginStatus m_status; PluginStatus m_status;
bool m_bSilentlyFailed;
unsigned int m_serial; unsigned int m_serial;
sm_plugininfo_t m_info; sm_plugininfo_t m_info;
char m_errormsg[256]; char m_errormsg[256];
+82
View File
@@ -527,3 +527,85 @@ NativeEntry *ShareSystem::AddFakeNative(IPluginFunction *pFunc, const char *name
return pEntry; return pEntry;
} }
void ShareSystem::AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name)
{
if (m_caps.retrieve(name) != NULL)
return;
Capability cap;
cap.ext = myself;
cap.provider = provider;
m_caps.insert(name, cap);
}
void ShareSystem::DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name)
{
Capability *pCap = m_caps.retrieve(name);
if (pCap == NULL)
return;
if (pCap->ext != myself || pCap->provider != provider)
return;
m_caps.remove(name);
}
FeatureStatus ShareSystem::TestFeature(IPluginRuntime *pRuntime, FeatureType feature,
const char *name)
{
switch (feature)
{
case FeatureType_Native:
return TestNative(pRuntime, name);
case FeatureType_Capability:
return TestCap(name);
default:
break;
}
return FeatureStatus_Unknown;
}
FeatureStatus ShareSystem::TestNative(IPluginRuntime *pRuntime, const char *name)
{
uint32_t index;
if (pRuntime->FindNativeByName(name, &index) == SP_ERROR_NONE)
{
sp_native_t *native;
if (pRuntime->GetNativeByIndex(index, &native) == SP_ERROR_NONE)
{
if (native->status == SP_NATIVE_BOUND)
return FeatureStatus_Available;
else
return FeatureStatus_Unknown;
}
}
NativeEntry *entry = FindNative(name);
if (entry == NULL)
return FeatureStatus_Unknown;
if ((entry->replacement.owner != NULL || entry->owner != NULL) &&
(entry->replacement.func != NULL || entry->func != NULL))
{
return FeatureStatus_Available;
}
else
{
return FeatureStatus_Unavailable;
}
}
FeatureStatus ShareSystem::TestCap(const char *name)
{
Capability *cap = m_caps.retrieve(name);
if (cap == NULL)
return FeatureStatus_Unknown;
return cap->provider->GetFeatureStatus(FeatureType_Capability, name);
}
+15 -1
View File
@@ -87,7 +87,13 @@ struct NativeEntry
FakeNative *fake; FakeNative *fake;
}; };
class ShareSystem : struct Capability
{
IExtension *ext;
IFeatureProvider *provider;
};
class ShareSystem :
public IShareSys, public IShareSys,
public SMGlobalClass, public SMGlobalClass,
public IHandleTypeDispatch public IHandleTypeDispatch
@@ -110,6 +116,10 @@ public: //IShareSys
void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload); void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload);
void RegisterLibrary(IExtension *myself, const char *name); void RegisterLibrary(IExtension *myself, const char *name);
void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives); void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives);
void AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name);
void DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name);
public: //SMGlobalClass public: //SMGlobalClass
/* Pre-empt in case anything tries to register idents early */ /* Pre-empt in case anything tries to register idents early */
void Initialize(); void Initialize();
@@ -119,6 +129,9 @@ public: //IHandleTypeDispatch
public: public:
IdentityToken_t *CreateCoreIdentity(); IdentityToken_t *CreateCoreIdentity();
void RemoveInterfaces(IExtension *pExtension); void RemoveInterfaces(IExtension *pExtension);
FeatureStatus TestFeature(IPluginRuntime *pRuntime, FeatureType feature, const char *name);
FeatureStatus TestNative(IPluginRuntime *pRuntime, const char *name);
FeatureStatus TestCap(const char *name);
public: public:
inline IdentityToken_t *GetIdentRoot() inline IdentityToken_t *GetIdentRoot()
{ {
@@ -143,6 +156,7 @@ private:
HandleType_t m_IfaceType; HandleType_t m_IfaceType;
IdentityType_t m_CoreType; IdentityType_t m_CoreType;
KTrie<NativeEntry *> m_NtvCache; KTrie<NativeEntry *> m_NtvCache;
KTrie<Capability> m_caps;
}; };
extern ShareSystem g_ShareSys; extern ShareSystem g_ShareSys;
+4 -2
View File
@@ -887,8 +887,10 @@ void Translator::RebuildLanguageDatabase(const char *lang_header_file)
strncopy(m_InitialLang, "en", sizeof(m_InitialLang)); strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
m_ServerLang = SOURCEMOD_LANGUAGE_ENGLISH; m_ServerLang = SOURCEMOD_LANGUAGE_ENGLISH;
} }
else
m_ServerLang = reinterpret_cast<unsigned int>(serverLang); {
m_ServerLang = reinterpret_cast<unsigned int>(serverLang);
}
if (!m_Languages.size()) if (!m_Languages.size())
{ {
+7 -7
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -34,7 +34,7 @@
UserMessages g_UserMsgs; UserMessages g_UserMsgs;
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int, const char *); SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int, const char *);
#else #else
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int); 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 (m_CurFlags & USERMSG_BLOCKHOOKS)
{ {
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id)); buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id));
#else #else
buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id); buffer = ENGINE_CALL(UserMessageBegin)(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id);
#endif #endif
} else { } else {
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id)); buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id));
#else #else
buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id); 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
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name) bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
#else #else
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type) 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); RETURN_META_VALUE(MRES_IGNORED, NULL);
} }
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name) bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
#else #else
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type) bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type)
@@ -500,7 +500,7 @@ void UserMessages::OnMessageEnd_Pre()
{ {
bf_write *engine_bfw; bf_write *engine_bfw;
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId, g_SMAPI->GetUserMessage(m_CurId)); engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId, g_SMAPI->GetUserMessage(m_CurId));
#else #else
engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId); engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId);
+2 -2
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -79,7 +79,7 @@ public: //IUserMessages
IUserMessageListener *pListener, IUserMessageListener *pListener,
bool intercept=false); bool intercept=false);
public: public:
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_LEFT4DEAD
bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name); 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); bf_write *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
#else #else
+31 -2
View File
@@ -39,6 +39,9 @@
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *); SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
#else
SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *);
#endif #endif
using namespace SourceHook; using namespace SourceHook;
@@ -51,29 +54,55 @@ struct ConCommandInfo
}; };
List<ConCommandInfo *> tracked_bases; List<ConCommandInfo *> tracked_bases;
IConCommandLinkListener *IConCommandLinkListener::head = NULL;
ConCommandBase *FindConCommandBase(const char *name); ConCommandBase *FindConCommandBase(const char *name);
class ConCommandCleaner : public SMGlobalClass class ConCommandCleaner : public SMGlobalClass
{ {
public: public:
#if SOURCE_ENGINE >= SE_ORANGEBOX
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_ADD_HOOK_MEMFUNC(ICvar, UnregisterConCommand, icvar, this, &ConCommandCleaner::UnlinkConCommandBase, false); SH_ADD_HOOK_MEMFUNC(ICvar, UnregisterConCommand, icvar, this, &ConCommandCleaner::UnlinkConCommandBase, false);
SH_ADD_HOOK_MEMFUNC(ICvar, RegisterConCommand, icvar, this, &ConCommandCleaner::LinkConCommandBase, false);
#else
SH_ADD_HOOK_MEMFUNC(ICvar, RegisterConCommandBase, icvar, this, &ConCommandCleaner::LinkConCommandBase, false);
#endif
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_REMOVE_HOOK_MEMFUNC(ICvar, UnregisterConCommand, icvar, this, &ConCommandCleaner::UnlinkConCommandBase, false); SH_REMOVE_HOOK_MEMFUNC(ICvar, UnregisterConCommand, icvar, this, &ConCommandCleaner::UnlinkConCommandBase, false);
} SH_REMOVE_HOOK_MEMFUNC(ICvar, RegisterConCommand, icvar, this, &ConCommandCleaner::LinkConCommandBase, false);
#else
SH_REMOVE_HOOK_MEMFUNC(ICvar, RegisterConCommandBase, icvar, this, &ConCommandCleaner::LinkConCommandBase, false);
#endif #endif
}
void LinkConCommandBase(ConCommandBase *pBase)
{
IConCommandLinkListener *listener = IConCommandLinkListener::head;
while (listener)
{
listener->OnLinkConCommand(pBase);
listener = listener->next;
}
}
void UnlinkConCommandBase(ConCommandBase *pBase) void UnlinkConCommandBase(ConCommandBase *pBase)
{ {
ConCommandInfo *pInfo; ConCommandInfo *pInfo;
List<ConCommandInfo *>::iterator iter = tracked_bases.begin(); List<ConCommandInfo *>::iterator iter = tracked_bases.begin();
IConCommandLinkListener *listener = IConCommandLinkListener::head;
while (listener)
{
listener->OnUnlinkConCommand(pBase);
listener = listener->next;
}
if (pBase) if (pBase)
{ {
while (iter != tracked_bases.end()) while (iter != tracked_bases.end())
+22
View File
@@ -42,4 +42,26 @@ void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
void UntrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me); void UntrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
void Global_OnUnlinkConCommandBase(ConCommandBase *pBase); void Global_OnUnlinkConCommandBase(ConCommandBase *pBase);
class IConCommandLinkListener
{
friend class ConCommandCleaner;
static IConCommandLinkListener *head;
IConCommandLinkListener *next;
public:
IConCommandLinkListener()
{
next = head;
head = this;
}
virtual void OnLinkConCommand(ConCommandBase *pBase)
{
}
virtual void OnUnlinkConCommand(ConCommandBase *pBase)
{
}
};
#endif //_INCLUDE_CONCMD_TRACKER_H_ #endif //_INCLUDE_CONCMD_TRACKER_H_
+6
View File
@@ -386,6 +386,9 @@ public:
virtual void SetValue( const char *value ); virtual void SetValue( const char *value );
virtual void SetValue( float value ); virtual void SetValue( float value );
virtual void SetValue( int value ); virtual void SetValue( int value );
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
virtual void SetValue( Color value );
#endif
// Reset to default value // Reset to default value
void Revert( void ); void Revert( void );
@@ -401,6 +404,9 @@ private:
// For CVARs marked FCVAR_NEVER_AS_STRING // For CVARs marked FCVAR_NEVER_AS_STRING
virtual void InternalSetFloatValue( float fNewValue ); virtual void InternalSetFloatValue( float fNewValue );
virtual void InternalSetIntValue( int nValue ); virtual void InternalSetIntValue( int nValue );
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
virtual void InternalSetColorValue( Color value );
#endif
virtual bool ClampValue( float& value ); virtual bool ClampValue( float& value );
virtual void ChangeStringValue( const char *tempVal, float flOldValue ); virtual void ChangeStringValue( const char *tempVal, float flOldValue );
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -37,7 +37,7 @@
#include "PlayerManager.h" #include "PlayerManager.h"
#include "CoreConfig.h" #include "CoreConfig.h"
#include <sm_queue.h> #include <sm_queue.h>
#include "ThreadSupport.h" #include <IThreader.h>
static IMutex *frame_mutex; static IMutex *frame_mutex;
static Queue<FrameAction> *frame_queue; static Queue<FrameAction> *frame_queue;
+41
View File
@@ -0,0 +1,41 @@
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
compiler = SM.DefaultCompiler()
base = AMBuild.sourceFolder
compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook'))
compiler['CXXINCLUDES'].append(os.path.join(base, 'core', 'logic'))
compiler['CXXINCLUDES'].append(os.path.join(base, 'public'))
compiler['CXXINCLUDES'].append(os.path.join(base, 'public', 'sourcepawn'))
compiler['CDEFINES'].append('SM_DEFAULT_THREADER')
compiler['CDEFINES'].append('SM_LOGIC')
if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'].append('-lpthread')
extension = AMBuild.AddJob('sourcemod.logic')
binary = Cpp.LibraryBuilder('sourcemod.logic', AMBuild, extension, compiler)
files = [
'common_logic.cpp',
'smn_adt_array.cpp',
'smn_sorting.cpp',
'smn_maplists.cpp',
'smn_adt_stack.cpp',
'thread/ThreadWorker.cpp',
'thread/BaseWorker.cpp',
'ThreadSupport.cpp',
'smn_float.cpp',
'TextParsers.cpp',
'smn_textparse.cpp',
'smn_adt_trie.cpp',
'Profiler.cpp',
'smn_functions.cpp'
]
if AMBuild.target['platform'] == 'windows':
files.append('thread/WinThreads.cpp')
else:
files.append('thread/PosixThreads.cpp')
binary.AddSourceFiles('core/logic', files)
SM.AutoVersion('core/logic', binary)
binary.SendToJob()
@@ -29,6 +29,9 @@
* Version: $Id$ * Version: $Id$
*/ */
#ifndef _INCLUDE_SOURCEMOD_CELLARRAY_H_
#define _INCLUDE_SOURCEMOD_CELLARRAY_H_
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -204,3 +207,6 @@ private:
size_t m_AllocSize; size_t m_AllocSize;
size_t m_Size; size_t m_Size;
}; };
#endif /* _INCLUDE_SOURCEMOD_CELLARRAY_H_ */
+92
View File
@@ -0,0 +1,92 @@
# (C)2004-2008 SourceMod Development Team
# Makefile written by David "BAILOPAN" Anderson
SMSDK = ../..
MMSOURCE17 = ../../../mmsource-1.7
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
BINARY = sourcemod.logic.so
OBJECTS = \
common_logic.cpp \
smn_adt_array.cpp \
smn_sorting.cpp \
smn_maplists.cpp \
smn_adt_stack.cpp \
thread/ThreadWorker.cpp \
thread/BaseWorker.cpp \
thread/PosixThreads.cpp \
ThreadSupport.cpp \
smn_float.cpp \
TextParsers.cpp \
smn_textparse.cpp \
smn_adt_trie.cpp \
Profiler.cpp \
smn_functions.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
LINK += -lpthread -static-libgcc
INCLUDE += -I. -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \
-Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSM_DEFAULT_THREADER -m32 \
-DSM_LOGIC
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS += $(C_OPT_FLAGS)
endif
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
$(BIN_DIR)/%.o: %.c
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
all:
mkdir -p $(BIN_DIR)/thread
$(MAKE) -f Makefile sourcemod
sourcemod: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o $(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile all DEBUG=true
default: all
clean:
rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/thread/*.o
rm -rf $(BIN_DIR)/$(BINARY)
+399
View File
@@ -0,0 +1,399 @@
// MersenneTwister.h
// Mersenne Twister random number generator -- a C++ class MTRand
// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
// Richard J. Wagner v1.0 15 May 2003 [email protected]
// The Mersenne Twister is an algorithm for generating random numbers. It
// was designed with consideration of the flaws in various other generators.
// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
// are far greater. The generator is also fast; it avoids multiplication and
// division, and it benefits from caches and pipelines. For more information
// see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
// Reference
// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
// Copyright (C) 2000 - 2003, Richard J. Wagner
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// The original code included the following notice:
//
// When you use this, send an email to: [email protected]
// with an appropriate reference to your work.
//
// It would be nice to CC: [email protected] and [email protected]
// when you write.
#ifndef MERSENNETWISTER_H
#define MERSENNETWISTER_H
// Not thread safe (unless auto-initialization is avoided and each thread has
// its own MTRand object)
#include <limits.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
class MTRand {
// Data
public:
typedef unsigned long uint32; // unsigned integer type, at least 32 bits
enum { N = 624 }; // length of state vector
enum { SAVE = N + 1 }; // length of array for save()
protected:
enum { M = 397 }; // period parameter
uint32 state[N]; // internal state
uint32 *pNext; // next value to get from state
int left; // number of values left before reload needed
//Methods
public:
MTRand( const uint32& oneSeed ); // initialize with a simple uint32
MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or an array
MTRand(); // auto-initialize with /dev/urandom or time() and clock()
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned
// values together, otherwise the generator state can be learned after
// reading 624 consecutive values.
// Access to 32-bit random numbers
double rand(); // real number in [0,1]
double rand( const double& n ); // real number in [0,n]
double randExc(); // real number in [0,1)
double randExc( const double& n ); // real number in [0,n)
double randDblExc(); // real number in (0,1)
double randDblExc( const double& n ); // real number in (0,n)
uint32 randInt(); // integer in [0,2^32-1]
uint32 randInt( const uint32& n ); // integer in [0,n] for n < 2^32
double operator()() { return rand(); } // same as rand()
// Access to 53-bit random numbers (capacity of IEEE double precision)
double rand53(); // real number in [0,1)
// Access to nonuniform random number distributions
double randNorm( const double& mean = 0.0, const double& variance = 0.0 );
// Re-seeding functions with same behavior as initializers
void seed( const uint32 oneSeed );
void seed( uint32 *const bigSeed, const uint32 seedLength = N );
void seed();
// Saving and loading generator state
void save( uint32* saveArray ) const; // to array of size SAVE
void load( uint32 *const loadArray ); // from such array
protected:
void initialize( const uint32 oneSeed );
void reload();
uint32 hiBit( const uint32& u ) const { return u & 0x80000000UL; }
uint32 loBit( const uint32& u ) const { return u & 0x00000001UL; }
uint32 loBits( const uint32& u ) const { return u & 0x7fffffffUL; }
uint32 mixBits( const uint32& u, const uint32& v ) const
{ return hiBit(u) | loBits(v); }
uint32 twist( const uint32& m, const uint32& s0, const uint32& s1 ) const
{ return m ^ (mixBits(s0,s1)>>1) ^ (-loBit(s1) & 0x9908b0dfUL); }
static uint32 hash( time_t t, clock_t c );
};
inline MTRand::MTRand( const uint32& oneSeed )
{ seed(oneSeed); }
inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength )
{ seed(bigSeed,seedLength); }
inline MTRand::MTRand()
{ seed(); }
inline double MTRand::rand()
{ return double(randInt()) * (1.0/4294967295.0); }
inline double MTRand::rand( const double& n )
{ return rand() * n; }
inline double MTRand::randExc()
{ return double(randInt()) * (1.0/4294967296.0); }
inline double MTRand::randExc( const double& n )
{ return randExc() * n; }
inline double MTRand::randDblExc()
{ return ( double(randInt()) + 0.5 ) * (1.0/4294967296.0); }
inline double MTRand::randDblExc( const double& n )
{ return randDblExc() * n; }
inline double MTRand::rand53()
{
uint32 a = randInt() >> 5, b = randInt() >> 6;
return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0); // by Isaku Wada
}
inline double MTRand::randNorm( const double& mean, const double& variance )
{
// Return a real number from a normal (Gaussian) distribution with given
// mean and variance by Box-Muller method
double r = sqrt( -2.0 * log( 1.0-randDblExc()) ) * variance;
double phi = 2.0 * 3.14159265358979323846264338328 * randExc();
return mean + r * cos(phi);
}
inline MTRand::uint32 MTRand::randInt()
{
// Pull a 32-bit integer from the generator state
// Every other access function simply transforms the numbers extracted here
if( left == 0 ) reload();
--left;
register uint32 s1;
s1 = *pNext++;
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9d2c5680UL;
s1 ^= (s1 << 15) & 0xefc60000UL;
return ( s1 ^ (s1 >> 18) );
}
inline MTRand::uint32 MTRand::randInt( const uint32& n )
{
// Find which bits are used in n
// Optimized by Magnus Jonsson ([email protected])
uint32 used = n;
used |= used >> 1;
used |= used >> 2;
used |= used >> 4;
used |= used >> 8;
used |= used >> 16;
// Draw numbers until one is found in [0,n]
uint32 i;
do
i = randInt() & used; // toss unused bits to shorten search
while( i > n );
return i;
}
inline void MTRand::seed( const uint32 oneSeed )
{
// Seed the generator with a simple uint32
initialize(oneSeed);
reload();
}
inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
{
// Seed the generator with an array of uint32's
// There are 2^19937-1 possible initial states. This function allows
// all of those to be accessed by providing at least 19937 bits (with a
// default seed length of N = 624 uint32's). Any bits above the lower 32
// in each element are discarded.
// Just call seed() if you want to get array from /dev/urandom
initialize(19650218UL);
register int i = 1;
register uint32 j = 0;
register int k = ( N > seedLength ? N : seedLength );
for( ; k; --k )
{
state[i] =
state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1664525UL );
state[i] += ( bigSeed[j] & 0xffffffffUL ) + j;
state[i] &= 0xffffffffUL;
++i; ++j;
if( i >= N ) { state[0] = state[N-1]; i = 1; }
if( j >= seedLength ) j = 0;
}
for( k = N - 1; k; --k )
{
state[i] =
state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL );
state[i] -= i;
state[i] &= 0xffffffffUL;
++i;
if( i >= N ) { state[0] = state[N-1]; i = 1; }
}
state[0] = 0x80000000UL; // MSB is 1, assuring non-zero initial array
reload();
}
inline void MTRand::seed()
{
// Seed the generator with an array from /dev/urandom if available
// Otherwise use a hash of time() and clock() values
// First try getting an array from /dev/urandom
FILE* urandom = fopen( "/dev/urandom", "rb" );
if( urandom )
{
uint32 bigSeed[N];
register uint32 *s = bigSeed;
register int i = N;
register bool success = true;
while( success && i-- )
success = fread( s++, sizeof(uint32), 1, urandom );
fclose(urandom);
if( success ) { seed( bigSeed, N ); return; }
}
// Was not successful, so use time() and clock() instead
seed( hash( time(NULL), clock() ) );
}
inline void MTRand::initialize( const uint32 seed )
{
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register uint32 *s = state;
register uint32 *r = state;
register int i = 1;
*s++ = seed & 0xffffffffUL;
for( ; i < N; ++i )
{
*s++ = ( 1812433253UL * ( *r ^ (*r >> 30) ) + i ) & 0xffffffffUL;
r++;
}
}
inline void MTRand::reload()
{
// Generate N new values in state
// Made clearer and faster by Matthew Bellew ([email protected])
register uint32 *p = state;
register int i;
for( i = N - M; i--; ++p )
*p = twist( p[M], p[0], p[1] );
for( i = M; --i; ++p )
*p = twist( p[M-N], p[0], p[1] );
*p = twist( p[M-N], p[0], state[0] );
left = N, pNext = state;
}
inline MTRand::uint32 MTRand::hash( time_t t, clock_t c )
{
// Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby ([email protected])
static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
{
h1 *= UCHAR_MAX + 2U;
h1 += p[i];
}
uint32 h2 = 0;
p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j )
{
h2 *= UCHAR_MAX + 2U;
h2 += p[j];
}
return ( h1 + differ++ ) ^ h2;
}
inline void MTRand::save( uint32* saveArray ) const
{
register uint32 *sa = saveArray;
register const uint32 *s = state;
register int i = N;
for( ; i--; *sa++ = *s++ ) {}
*sa = left;
}
inline void MTRand::load( uint32 *const loadArray )
{
register uint32 *s = state;
register uint32 *la = loadArray;
register int i = N;
for( ; i--; *s++ = *la++ ) {}
left = *la;
pNext = &state[N-left];
}
#endif // MERSENNETWISTER_H
// Change log:
//
// v0.1 - First release on 15 May 2000
// - Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
// - Translated from C to C++
// - Made completely ANSI compliant
// - Designed convenient interface for initialization, seeding, and
// obtaining numbers in default or user-defined ranges
// - Added automatic seeding from /dev/urandom or time() and clock()
// - Provided functions for saving and loading generator state
//
// v0.2 - Fixed bug which reloaded generator one step too late
//
// v0.3 - Switched to clearer, faster reload() code from Matthew Bellew
//
// v0.4 - Removed trailing newline in saved generator format to be consistent
// with output format of built-in types
//
// v0.5 - Improved portability by replacing static const int's with enum's and
// clarifying return values in seed(); suggested by Eric Heimburg
// - Removed MAXINT constant; use 0xffffffffUL instead
//
// v0.6 - Eliminated seed overflow when uint32 is larger than 32 bits
// - Changed integer [0,n] generator to give better uniformity
//
// v0.7 - Fixed operator precedence ambiguity in reload()
// - Added access for real numbers in (0,1) and (0,n)
//
// v0.8 - Included time.h header to properly support time_t and clock_t
//
// v1.0 - Revised seeding to match 26 Jan 2002 update of Nishimura and Matsumoto
// - Allowed for seeding with arrays of any length
// - Added access for real numbers in [0,1) with 53-bit resolution
// - Added access for real numbers from normal (Gaussian) distributions
// - Increased overall speed by optimizing twist()
// - Doubled speed of integer [0,n] generation
// - Fixed out-of-range number generation on 64-bit machines
// - Improved portability by substituting literal constants for long enum's
// - Changed license from GNU LGPL to BSD
+51 -21
View File
@@ -30,13 +30,12 @@
*/ */
#include "Profiler.h" #include "Profiler.h"
#include "PluginSys.h" #include <ISourceMod.h>
#include "sm_stringutil.h"
#include "Logger.h"
#if defined PLATFORM_POSIX #if defined PLATFORM_POSIX
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#endif #endif
#include <IPluginSys.h>
ProfileEngine g_Profiler; ProfileEngine g_Profiler;
IProfiler *sm_profiler = &g_Profiler; IProfiler *sm_profiler = &g_Profiler;
@@ -314,43 +313,74 @@ void ProfileEngine::Clear()
void ProfileEngine::OnSourceModAllInitialized() void ProfileEngine::OnSourceModAllInitialized()
{ {
g_RootMenu.AddRootConsoleCommand("profiler", "Profiler commands", this); rootmenu->AddRootConsoleCommand2("profiler", "Profiler commands", this);
} }
void ProfileEngine::OnSourceModShutdown() void ProfileEngine::OnSourceModShutdown()
{ {
g_RootMenu.RemoveRootConsoleCommand("profiler", this); rootmenu->RemoveRootConsoleCommand("profiler", this);
} }
void ProfileEngine::OnRootConsoleCommand(const char *cmdname, const CCommand &command) void ProfileEngine::OnRootConsoleCommand2(const char *cmdname, const ICommandArgs *command)
{ {
if (command.ArgC() >= 3) if (command->ArgC() >= 3)
{ {
if (strcmp(command.Arg(2), "flush") == 0) if (strcmp(command->Arg(2), "flush") == 0)
{ {
FILE *fp; FILE *fp;
char path[256]; char path[256];
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "logs/profile_%d.xml", (int)time(NULL)); g_pSM->BuildPath(Path_SM, path, sizeof(path), "logs/profile_%d.xml", (int)time(NULL));
if ((fp = fopen(path, "wt")) == NULL) if ((fp = fopen(path, "wt")) == NULL)
{ {
g_RootMenu.ConsolePrint("Failed, could not open file for writing: %s", path); rootmenu->ConsolePrint("Failed, could not open file for writing: %s", path);
return; return;
} }
GenerateReport(fp); GenerateReport(fp);
fclose(fp); fclose(fp);
Clear();
g_RootMenu.ConsolePrint("Profiler report generated as: %s\n", path); rootmenu->ConsolePrint("Profiler report generated as: %s\n", path);
return; 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;
}
} }
g_RootMenu.ConsolePrint("Profiler commands:"); rootmenu->ConsolePrint("Profiler commands:");
g_RootMenu.DrawGenericOption("flush", "Flushes statistics to disk and starts over"); 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) bool ProfileEngine::GenerateReport(FILE *fp)
@@ -387,9 +417,9 @@ void ProfileEngine::WriteReport(FILE *fp, ProfileReport *report, const char *nam
{ {
ar = report->GetReport(i); ar = report->GetReport(i);
strncopy(new_name, ar->atom_name, sizeof(new_name)); smcore.strncopy(new_name, ar->atom_name, sizeof(new_name));
UTIL_ReplaceAll(new_name, sizeof(new_name), "<", "&lt;"); smcore.ReplaceAll(new_name, sizeof(new_name), "<", "&lt;", true);
UTIL_ReplaceAll(new_name, sizeof(new_name), ">", "&gt;"); smcore.ReplaceAll(new_name, sizeof(new_name), ">", "&gt;", true);
fprintf(fp, " <item name=\"%s\" numcalls=\"%d\" mintime=\"%f\" maxtime=\"%f\" totaltime=\"%f\"/>\n", fprintf(fp, " <item name=\"%s\" numcalls=\"%d\" mintime=\"%f\" maxtime=\"%f\" totaltime=\"%f\"/>\n",
new_name, new_name,
@@ -438,20 +468,20 @@ void ProfileReport::SaveAtom(const prof_atom_t &atom)
if (atom.atom_type == SP_PROF_NATIVES) if (atom.atom_type == SP_PROF_NATIVES)
{ {
strncopy(full_name, atom.name, sizeof(full_name)); smcore.strncopy(full_name, atom.name, sizeof(full_name));
} }
else else
{ {
CPlugin *pl; IPlugin *pl;
const char *file; const char *file;
file = "unknown"; file = "unknown";
if ((pl = g_PluginSys.GetPluginByCtx(atom.ctx)) != NULL) if ((pl = pluginsys->FindPluginByContext(atom.ctx)) != NULL)
{ {
file = pl->GetFilename(); file = pl->GetFilename();
} }
UTIL_Format(full_name, sizeof(full_name), "%s!%s", file, atom.name); smcore.Format(full_name, sizeof(full_name), "%s!%s", file, atom.name);
} }
atom_time = CalcAtomTime(atom); atom_time = CalcAtomTime(atom);
@@ -460,7 +490,7 @@ void ProfileReport::SaveAtom(const prof_atom_t &atom)
{ {
report = new prof_atom_report_t; report = new prof_atom_report_t;
strncopy(report->atom_name, full_name, sizeof(report->atom_name)); smcore.strncopy(report->atom_name, full_name, sizeof(report->atom_name));
report->max_time = atom_time; report->max_time = atom_time;
report->min_time = atom_time; report->min_time = atom_time;
report->num_calls = 1; report->num_calls = 1;
+4 -4
View File
@@ -38,8 +38,8 @@
#include <sh_vector.h> #include <sh_vector.h>
#include <sh_stack.h> #include <sh_stack.h>
#include <stdio.h> #include <stdio.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sm_srvcmds.h" #include <IRootConsoleMenu.h>
using namespace SourcePawn; using namespace SourcePawn;
using namespace SourceHook; using namespace SourceHook;
@@ -103,7 +103,7 @@ public: //SMGlobalClass
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
void OnSourceModShutdown(); void OnSourceModShutdown();
public: //IRootConsoleCommand public: //IRootConsoleCommand
void OnRootConsoleCommand(const char *cmdname, const CCommand &command); void OnRootConsoleCommand2(const char *cmdname, const ICommandArgs *command);
public: //IProfiler public: //IProfiler
void OnNativeBegin(IPluginContext *pContext, sp_native_t *native); void OnNativeBegin(IPluginContext *pContext, sp_native_t *native);
void OnNativeEnd() ; void OnNativeEnd() ;
@@ -126,6 +126,6 @@ private:
prof_point_t m_ProfStart; prof_point_t m_ProfStart;
}; };
extern ProfileEngine g_Profiler; extern IProfiler *sm_profiler;
#endif //_INCLUDE_SOURCEMOD_PLUGIN_PROFILER_H_ #endif //_INCLUDE_SOURCEMOD_PLUGIN_PROFILER_H_
@@ -36,9 +36,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "TextParsers.h" #include "TextParsers.h"
#include "ShareSys.h" #include <ILibrarySys.h>
#include "sm_stringutil.h"
#include "LibrarySys.h"
TextParsers g_TextParser; TextParsers g_TextParser;
ITextParsers *textparsers = &g_TextParser; ITextParsers *textparsers = &g_TextParser;
@@ -71,7 +69,7 @@ TextParsers::TextParsers()
void TextParsers::OnSourceModAllInitialized() void TextParsers::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
unsigned int TextParsers::GetUTF8CharBytes(const char *stream) unsigned int TextParsers::GetUTF8CharBytes(const char *stream)
@@ -135,8 +133,8 @@ SMCError TextParsers::ParseSMCFile(const char *file,
states->line = 0; states->line = 0;
states->col = 0; states->col = 0;
} }
g_LibSys.GetPlatformError(error, sizeof(error)); libsys->GetPlatformError(error, sizeof(error));
UTIL_Format(buffer, maxsize, "File could not be opened: %s", error); smcore.Format(buffer, maxsize, "File could not be opened: %s", error);
return SMCError_StreamOpen; return SMCError_StreamOpen;
} }
@@ -145,7 +143,7 @@ SMCError TextParsers::ParseSMCFile(const char *file,
fclose(fp); fclose(fp);
errstr = GetSMCErrorString(result); errstr = GetSMCErrorString(result);
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error"); smcore.Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
return result; return result;
} }
@@ -196,7 +194,7 @@ SMCError TextParsers::ParseSMCStream(const char *stream,
result = ParseStream_SMC(&rs, RawStreamReader, smc_listener, states); result = ParseStream_SMC(&rs, RawStreamReader, smc_listener, states);
const char *errstr = GetSMCErrorString(result); const char *errstr = GetSMCErrorString(result);
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error"); smcore.Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
return result; return result;
} }
@@ -33,7 +33,7 @@
#define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_ #define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
#include <ITextParsers.h> #include <ITextParsers.h>
#include "sm_globals.h" #include "common_logic.h"
using namespace SourceMod; using namespace SourceMod;
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -28,10 +28,9 @@
* *
* Version: $Id$ * Version: $Id$
*/ */
#include <sm_platform.h>
#include "ThreadSupport.h" #include "ThreadSupport.h"
#include "sm_globals.h" #include "common_logic.h"
#include "ShareSys.h"
#if defined PLATFORM_POSIX #if defined PLATFORM_POSIX
#include "thread/PosixThreads.h" #include "thread/PosixThreads.h"
@@ -47,6 +46,7 @@ class RegThreadStuff : public SMGlobalClass
public: public:
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, g_pThreader); sharesys->AddInterface(NULL, g_pThreader);
} }
} s_RegThreadStuff; } s_RegThreadStuff;
+124
View File
@@ -0,0 +1,124 @@
/**
* vim: set ts=4 sw=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$
*/
#include <new>
#include <stdlib.h>
#include <sm_platform.h>
#include <string.h>
#include "common_logic.h"
#include "ThreadSupport.h"
#include "TextParsers.h"
#include "Profiler.h"
sm_core_t smcore;
IHandleSys *handlesys;
IdentityToken_t *g_pCoreIdent;
SMGlobalClass *SMGlobalClass::head = NULL;
ISourceMod *g_pSM;
ILibrarySys *libsys;
ITextParsers *textparser = &g_TextParser;
IVEngineServer *engine;
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
static sm_logic_t logic =
{
NULL,
g_pThreader,
sm_profiler
};
static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
{
logic.head = SMGlobalClass::head;
memcpy(&smcore, core, sizeof(sm_core_t));
memcpy(_logic, &logic, sizeof(sm_logic_t));
handlesys = core->handlesys;
libsys = core->libsys;
engine = core->engine;
g_pCoreIdent = core->core_ident;
g_pSM = core->sm;
sharesys = core->sharesys;
rootmenu = core->rootmenu;
pluginsys = core->pluginsys;
forwardsys = core->forwardsys;
}
PLATFORM_EXTERN_C ITextParsers *get_textparsers()
{
return &g_TextParser;
}
PLATFORM_EXTERN_C LogicInitFunction logic_load(uint32_t magic)
{
if (magic != SM_LOGIC_MAGIC)
{
return NULL;
}
return logic_init;
}
void CoreNativesToAdd::OnSourceModAllInitialized()
{
smcore.AddNatives(m_NativeList);
}
/* Overload a few things to prevent libstdc++ linking */
#if defined __linux__ || defined __APPLE__
extern "C" void __cxa_pure_virtual(void)
{
}
void *operator new(size_t size)
{
return malloc(size);
}
void *operator new[](size_t size)
{
return malloc(size);
}
void operator delete(void *ptr)
{
free(ptr);
}
void operator delete[](void * ptr)
{
free(ptr);
}
#endif
+52
View File
@@ -0,0 +1,52 @@
/**
* vim: set ts=4 :
* =============================================================================
* 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_LOGIC_H_
#define _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_
#include <IHandleSys.h>
#include "../sm_globals.h"
#include "intercom.h"
extern sm_core_t smcore;
extern IHandleSys *handlesys;
extern ISourceMod *g_pSM;
extern ILibrarySys *libsys;
extern ITextParsers *textparser;
extern IVEngineServer *engine;
extern IShareSys *sharesys;
extern IRootConsole *rootmenu;
extern IPluginManager *pluginsys;
extern IForwardManager *forwardsys;
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */
+106
View File
@@ -0,0 +1,106 @@
/**
* vim: set ts=4 :
* =============================================================================
* 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 <sp_vm_api.h>
#include <IHandleSys.h>
#include <IShareSys.h>
#ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_
#define _INCLUDE_SOURCEMOD_INTERCOM_H_
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 - 2)
#if defined SM_LOGIC
class IVEngineServer
#else
class IVEngineServer_Logic
#endif
{
public:
virtual bool IsMapValid(const char *map) = 0;
};
namespace SourceMod
{
class ISourceMod;
class ILibrarySys;
class ITextParsers;
class IThreader;
class IRootConsole;
class IPluginManager;
class IForwardManager;
}
class IVEngineServer;
class ConVar;
struct sm_core_t
{
/* Objects */
IHandleSys *handlesys;
IdentityToken_t *core_ident;
ISourceMod *sm;
ILibrarySys *libsys;
IVEngineServer *engine;
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
/* Functions */
void (*AddNatives)(sp_nativeinfo_t* nlist);
ConVar * (*FindConVar)(const char*);
unsigned int (*strncopy)(char*, const char*, size_t);
char * (*TrimWhitespace)(char *, size_t &);
void (*LogError)(const char*, ...);
const char * (*GetCvarString)(ConVar*);
size_t (*Format)(char*, size_t, const char*, ...);
unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool);
};
struct sm_logic_t
{
SMGlobalClass *head;
IThreader *threader;
IProfiler *profiler;
};
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
typedef ITextParsers *(*GetITextParsers)();
#endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "logic.vcproj", "{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
+323
View File
@@ -0,0 +1,323 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="logic"
ProjectGUID="{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}"
RootNamespace="jitx86"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
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"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\sourcepawn.jit.x86.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;&quot;$(MMSOURCE17)\core\sourcehook&quot;;..\..\..\public;..\..\..\public\sourcepawn"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_LOGIC;SM_DEFAULT_THREADER"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\sourcemod.logic.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\smn_functions.cpp"
>
</File>
<File
RelativePath="..\smn_adt_trie.cpp"
>
</File>
<File
RelativePath="..\Profiler.cpp"
>
</File>
<File
RelativePath="..\common_logic.cpp"
>
</File>
<File
RelativePath="..\smn_adt_array.cpp"
>
</File>
<File
RelativePath="..\smn_adt_stack.cpp"
>
</File>
<File
RelativePath="..\smn_float.cpp"
>
</File>
<File
RelativePath="..\smn_maplists.cpp"
>
</File>
<File
RelativePath="..\smn_sorting.cpp"
>
</File>
<File
RelativePath="..\smn_textparse.cpp"
>
</File>
<File
RelativePath="..\TextParsers.cpp"
>
</File>
<File
RelativePath="..\ThreadSupport.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\CellArray.h"
>
</File>
<File
RelativePath="..\common_logic.h"
>
</File>
<File
RelativePath="..\intercom.h"
>
</File>
<File
RelativePath="..\svn_version.h"
>
</File>
<File
RelativePath="..\TextParsers.h"
>
</File>
<File
RelativePath="..\ThreadSupport.h"
>
</File>
<File
RelativePath="..\Profiler.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\svn_version.tpl"
>
</File>
<File
RelativePath="..\version.rc"
>
</File>
</Filter>
<Filter
Name="Threads"
>
<Filter
Name="Header Files"
>
<File
RelativePath="..\thread\BaseWorker.h"
>
</File>
<File
RelativePath="..\thread\ThreadWorker.h"
>
</File>
<File
RelativePath="..\thread\WinThreads.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\thread\BaseWorker.cpp"
>
</File>
<File
RelativePath="..\thread\ThreadWorker.cpp"
>
</File>
<File
RelativePath="..\thread\WinThreads.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -30,10 +30,8 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sm_stringutil.h"
#include "CellArray.h" #include "CellArray.h"
#include "HandleSys.h"
HandleType_t htCellArray; HandleType_t htCellArray;
@@ -44,11 +42,11 @@ class CellArrayHelpers :
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
htCellArray = g_HandleSys.CreateType("CellArray", this, 0, NULL, NULL, g_pCoreIdent, NULL); htCellArray = handlesys->CreateType("CellArray", this, 0, NULL, NULL, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(htCellArray, g_pCoreIdent); handlesys->RemoveType(htCellArray, g_pCoreIdent);
} }
public: //IHandleTypeDispatch public: //IHandleTypeDispatch
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
@@ -78,7 +76,7 @@ static cell_t CreateArray(IPluginContext *pContext, const cell_t *params)
array->resize(params[2]); array->resize(params[2]);
} }
Handle_t hndl = g_HandleSys.CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (!hndl) if (!hndl)
{ {
delete array; delete array;
@@ -93,7 +91,7 @@ static cell_t ClearArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -110,7 +108,7 @@ static cell_t ResizeArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -130,7 +128,7 @@ static cell_t GetArraySize(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -145,7 +143,7 @@ static cell_t PushArrayCell(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -168,7 +166,7 @@ static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -183,7 +181,7 @@ static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params)
char *str; char *str;
pContext->LocalToString(params[2], &str); pContext->LocalToString(params[2], &str);
strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t)); smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
return (cell_t)(array->size() - 1); return (cell_t)(array->size() - 1);
} }
@@ -194,7 +192,7 @@ static cell_t PushArrayArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -226,7 +224,7 @@ static cell_t GetArrayCell(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -265,7 +263,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -291,7 +289,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -324,7 +322,7 @@ static cell_t SetArrayCell(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -363,7 +361,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -380,7 +378,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
char *str; char *str;
pContext->LocalToString(params[3], &str); pContext->LocalToString(params[3], &str);
return strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t)); return smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
} }
static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params) static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
@@ -389,7 +387,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -422,7 +420,7 @@ static cell_t ShiftArrayUp(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -445,7 +443,7 @@ static cell_t RemoveFromArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -468,7 +466,7 @@ static cell_t SwapArrayItems(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -496,7 +494,7 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -504,7 +502,7 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params)
CellArray *array = oldArray->clone(); CellArray *array = oldArray->clone();
Handle_t hndl = g_HandleSys.CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (!hndl) if (!hndl)
{ {
delete array; delete array;
@@ -519,7 +517,7 @@ static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -546,7 +544,7 @@ static cell_t FindValueInArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -30,10 +30,8 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sm_stringutil.h"
#include "CellArray.h" #include "CellArray.h"
#include "HandleSys.h"
HandleType_t htCellStack; HandleType_t htCellStack;
@@ -44,11 +42,11 @@ class CellStackHelpers :
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
htCellStack = g_HandleSys.CreateType("CellStack", this, 0, NULL, NULL, g_pCoreIdent, NULL); htCellStack = handlesys->CreateType("CellStack", this, 0, NULL, NULL, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(htCellStack, g_pCoreIdent); handlesys->RemoveType(htCellStack, g_pCoreIdent);
} }
public: //IHandleTypeDispatch public: //IHandleTypeDispatch
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
@@ -73,7 +71,7 @@ static cell_t CreateStack(IPluginContext *pContext, const cell_t *params)
CellArray *array = new CellArray(params[1]); CellArray *array = new CellArray(params[1]);
Handle_t hndl = g_HandleSys.CreateHandle(htCellStack, array, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(htCellStack, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (!hndl) if (!hndl)
{ {
delete array; delete array;
@@ -88,7 +86,7 @@ static cell_t PushStackCell(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -111,7 +109,7 @@ static cell_t PushStackString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -126,7 +124,7 @@ static cell_t PushStackString(IPluginContext *pContext, const cell_t *params)
char *str; char *str;
pContext->LocalToString(params[2], &str); pContext->LocalToString(params[2], &str);
strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t)); smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
return 1; return 1;
} }
@@ -137,7 +135,7 @@ static cell_t PushStackArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -171,7 +169,7 @@ static cell_t PopStackCell(IPluginContext *pContext, const cell_t *params)
cell_t *blk, *buffer; cell_t *blk, *buffer;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -217,7 +215,7 @@ static cell_t PopStackString(IPluginContext *pContext, const cell_t *params)
cell_t *blk, *pWritten; cell_t *blk, *pWritten;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -248,7 +246,7 @@ static cell_t PopStackArray(IPluginContext *pContext, const cell_t *params)
CellArray *array; CellArray *array;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -281,7 +279,7 @@ static cell_t IsStackEmpty(IPluginContext *pContext, const cell_t *params)
CellArray *array; CellArray *array;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -30,10 +30,8 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sm_stringutil.h" #include <sm_trie_tpl.h>
#include "HandleSys.h"
#include "sm_trie_tpl.h"
HandleType_t htCellTrie; HandleType_t htCellTrie;
@@ -85,11 +83,11 @@ class TrieHelpers :
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
htCellTrie = g_HandleSys.CreateType("Trie", this, 0, NULL, NULL, g_pCoreIdent, NULL); htCellTrie = handlesys->CreateType("Trie", this, 0, NULL, NULL, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(htCellTrie, g_pCoreIdent); handlesys->RemoveType(htCellTrie, g_pCoreIdent);
} }
public: //IHandleTypeDispatch public: //IHandleTypeDispatch
static void DestroySmartTrieNode(SmartTrieNode *pNode) static void DestroySmartTrieNode(SmartTrieNode *pNode)
@@ -119,7 +117,7 @@ static cell_t CreateTrie(IPluginContext *pContext, const cell_t *params)
pTrie->mem_usage = 0; pTrie->mem_usage = 0;
if ((hndl = g_HandleSys.CreateHandle(htCellTrie, pTrie, pContext->GetIdentity(), g_pCoreIdent, NULL)) if ((hndl = handlesys->CreateHandle(htCellTrie, pTrie, pContext->GetIdentity(), g_pCoreIdent, NULL))
== BAD_HANDLE) == BAD_HANDLE)
{ {
delete pTrie; delete pTrie;
@@ -191,7 +189,7 @@ static cell_t SetTrieValue(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -227,7 +225,7 @@ static cell_t SetTrieArray(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -275,7 +273,7 @@ static cell_t SetTrieString(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -317,7 +315,7 @@ static cell_t RemoveFromTrie(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -347,7 +345,7 @@ static cell_t ClearTrie(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -368,7 +366,7 @@ static cell_t GetTrieValue(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -403,7 +401,7 @@ static cell_t GetTrieArray(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -460,7 +458,7 @@ static cell_t GetTrieString(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -507,7 +505,7 @@ static cell_t GetTrieSize(IPluginContext *pContext, const cell_t *params)
hndl = params[1]; hndl = params[1];
if ((err = g_HandleSys.ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie)) if ((err = handlesys->ReadHandle(hndl, htCellTrie, &sec, (void **)&pTrie))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -1,5 +1,5 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@@ -32,7 +32,9 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "sm_globals.h" #include "common_logic.h"
#include "MersenneTwister.h"
#include <IPluginSys.h>
/**************************************** /****************************************
* * * *
@@ -285,6 +287,68 @@ static cell_t sm_FloatRound(IPluginContext *pCtx, const cell_t *params)
} }
#endif #endif
class RandomHelpers :
public SMGlobalClass,
public IPluginsListener
{
public:
void OnSourceModAllInitialized()
{
pluginsys->AddPluginsListener(this);
}
void OnSourceModShutdown()
{
pluginsys->RemovePluginsListener(this);
}
void OnPluginDestroyed(IPlugin *plugin)
{
MTRand *mtrand;
if (plugin->GetProperty("core.logic.mtrand", (void**)&mtrand, true))
{
delete mtrand;
}
}
MTRand *RandObjForPlugin(IPluginContext *ctx)
{
IPlugin *plugin = pluginsys->FindPluginByContext(ctx->GetContext());
MTRand *mtrand;
if (!plugin->GetProperty("core.logic.mtrand", (void**)&mtrand))
{
mtrand = new MTRand();
plugin->SetProperty("core.logic.mtrand", mtrand);
}
return mtrand;
}
} s_RandHelpers;
static cell_t GetURandomInt(IPluginContext *ctx, const cell_t *params)
{
MTRand *randobj = s_RandHelpers.RandObjForPlugin(ctx);
/* Note the sign bit must be stripped off because cell_t is signed,
* and this guarantees a range of [0,max_int]
*/
return randobj->randInt() & 0x7FFFFFFF;
}
static cell_t GetURandomFloat(IPluginContext *ctx, const cell_t *params)
{
MTRand *randobj = s_RandHelpers.RandObjForPlugin(ctx);
return sp_ftoc((float)randobj->rand());
}
static cell_t SetURandomSeed(IPluginContext *ctx, const cell_t *params)
{
MTRand *randobj = s_RandHelpers.RandObjForPlugin(ctx);
cell_t *addr;
ctx->LocalToPhysAddr(params[1], &addr);
/* We're 32-bit only. */
randobj->seed((MTRand::uint32*)addr, params[2]);
return 1;
}
REGISTER_NATIVES(floatnatives) REGISTER_NATIVES(floatnatives)
{ {
{"float", sm_float}, {"float", sm_float},
@@ -310,5 +374,9 @@ REGISTER_NATIVES(floatnatives)
{"ArcCosine", sm_ArcCosine}, {"ArcCosine", sm_ArcCosine},
{"ArcSine", sm_ArcSine}, {"ArcSine", sm_ArcSine},
{"ArcTangent2", sm_ArcTangent2}, {"ArcTangent2", sm_ArcTangent2},
{"GetURandomInt", GetURandomInt},
{"GetURandomFloat", GetURandomFloat},
{"SetURandomSeed", SetURandomSeed},
{NULL, NULL} {NULL, NULL}
}; };
@@ -29,10 +29,10 @@
* Version: $Id$ * Version: $Id$
*/ */
#include "sm_globals.h" #include "common_logic.h"
#include "PluginSys.h" #include <IPluginSys.h>
#include "ForwardSys.h" #include <IHandleSys.h>
#include "HandleSys.h" #include <IForwardSys.h>
HandleType_t g_GlobalFwdType = 0; HandleType_t g_GlobalFwdType = 0;
HandleType_t g_PrivateFwdType = 0; HandleType_t g_PrivateFwdType = 0;
@@ -52,36 +52,36 @@ public:
HandleAccess sec; HandleAccess sec;
/* Set GlobalFwd handle access security */ /* Set GlobalFwd handle access security */
g_HandleSys.InitAccessDefaults(NULL, &sec); handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Read] = 0; sec.access[HandleAccess_Read] = 0;
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER; sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER;
/* Create 'GlobalFwd' handle type */ /* Create 'GlobalFwd' handle type */
g_GlobalFwdType = g_HandleSys.CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL); g_GlobalFwdType = handlesys->CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL);
/* Private forwards are cloneable */ /* Private forwards are cloneable */
sec.access[HandleAccess_Clone] = 0; sec.access[HandleAccess_Clone] = 0;
/* Create 'PrivateFwd' handle type */ /* Create 'PrivateFwd' handle type */
g_PrivateFwdType = g_HandleSys.CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL); g_PrivateFwdType = handlesys->CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(g_PrivateFwdType, g_pCoreIdent); handlesys->RemoveType(g_PrivateFwdType, g_pCoreIdent);
g_HandleSys.RemoveType(g_GlobalFwdType, g_pCoreIdent); handlesys->RemoveType(g_GlobalFwdType, g_pCoreIdent);
} }
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
{ {
IForward *pForward = static_cast<IForward *>(object); IForward *pForward = static_cast<IForward *>(object);
g_Forwards.ReleaseForward(pForward); forwardsys->ReleaseForward(pForward);
} }
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
{ {
*pSize = sizeof(CForward) + (((IForward *)object)->GetFunctionCount() * 12); *pSize = sizeof(IForward*) + (((IForward *)object)->GetFunctionCount() * 12);
return true; return true;
} }
} g_ForwardNativeHelpers; } g_ForwardNativeHelpers;
@@ -112,9 +112,9 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
if (hndl == 0) if (hndl == 0)
{ {
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else { } else {
pPlugin = g_PluginSys.PluginFromHandle(hndl, &err); pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin) if (!pPlugin)
{ {
@@ -155,9 +155,9 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
forwardParams[i - 3] = static_cast<ParamType>(*addr); forwardParams[i - 3] = static_cast<ParamType>(*addr);
} }
IForward *pForward = g_Forwards.CreateForward(name, static_cast<ExecType>(params[2]), count - 2, forwardParams); IForward *pForward = forwardsys->CreateForward(name, static_cast<ExecType>(params[2]), count - 2, forwardParams);
return g_HandleSys.CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
} }
static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params) static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
@@ -177,9 +177,9 @@ static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
forwardParams[i - 2] = static_cast<ParamType>(*addr); forwardParams[i - 2] = static_cast<ParamType>(*addr);
} }
IChangeableForward *pForward = g_Forwards.CreateForwardEx(NULL, static_cast<ExecType>(params[1]), count - 1, forwardParams); IChangeableForward *pForward = forwardsys->CreateForwardEx(NULL, static_cast<ExecType>(params[1]), count - 1, forwardParams);
return g_HandleSys.CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
} }
static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t *params) static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t *params)
@@ -188,7 +188,7 @@ static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t
HandleError err; HandleError err;
IForward *pForward; IForward *pForward;
if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward)) if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
@@ -205,7 +205,7 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
IChangeableForward *pForward; IChangeableForward *pForward;
IPlugin *pPlugin; IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward)) if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err); return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -213,9 +213,9 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
if (plHandle == 0) if (plHandle == 0)
{ {
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else { } else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err); pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin) if (!pPlugin)
{ {
@@ -241,7 +241,7 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
IChangeableForward *pForward; IChangeableForward *pForward;
IPlugin *pPlugin; IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward)) if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err); return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -249,9 +249,9 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
if (plHandle == 0) if (plHandle == 0)
{ {
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else { } else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err); pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin) if (!pPlugin)
{ {
@@ -277,7 +277,7 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
IChangeableForward *pForward; IChangeableForward *pForward;
IPlugin *pPlugin; IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward)) if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err); return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -285,9 +285,9 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
if (plHandle == 0) if (plHandle == 0)
{ {
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else { } else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err); pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin) if (!pPlugin)
{ {
@@ -310,9 +310,9 @@ static cell_t sm_CallStartFunction(IPluginContext *pContext, const cell_t *param
if (hndl == 0) if (hndl == 0)
{ {
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else { } else {
pPlugin = g_PluginSys.PluginFromHandle(hndl, &err); pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin) if (!pPlugin)
{ {
@@ -344,7 +344,7 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
hndl = static_cast<Handle_t>(params[1]); hndl = static_cast<Handle_t>(params[1]);
if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward)) if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
@@ -30,17 +30,12 @@
*/ */
#include <sh_list.h> #include <sh_list.h>
#include "sm_globals.h" #include <sm_trie_tpl.h>
#include "sm_trie_tpl.h" #include "common_logic.h"
#include "CellArray.h" #include "CellArray.h"
#include "convar.h" #include <ILibrarySys.h>
#include "sourcemm_api.h" #include <ITextParsers.h>
#include "LibrarySys.h" #include <ISourceMod.h>
#include "TextParsers.h"
#include "sm_stringutil.h"
#include "sourcemod.h"
#include "Logger.h"
#include "HandleSys.h"
using namespace SourceHook; using namespace SourceHook;
@@ -77,7 +72,7 @@ public:
} }
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
g_SourceMod.BuildPath(Path_SM, m_ConfigFile, sizeof(m_ConfigFile), "configs/maplists.cfg"); g_pSM->BuildPath(Path_SM, m_ConfigFile, sizeof(m_ConfigFile), "configs/maplists.cfg");
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
@@ -94,13 +89,9 @@ public:
pMapList->bIsCompat = true; pMapList->bIsCompat = true;
pMapList->bIsPath = true; pMapList->bIsPath = true;
pMapList->last_modified_time = 0; pMapList->last_modified_time = 0;
strncopy(pMapList->name, name, sizeof(pMapList->name)); smcore.strncopy(pMapList->name, name, sizeof(pMapList->name));
pMapList->pArray = NULL; pMapList->pArray = NULL;
g_SourceMod.BuildPath(Path_Game, g_pSM->BuildPath(Path_Game, pMapList->path, sizeof(pMapList->path), "%s", file);
pMapList->path,
sizeof(pMapList->path),
"%s",
file);
pMapList->serial = 0; pMapList->serial = 0;
m_ListLookup.insert(name, pMapList); m_ListLookup.insert(name, pMapList);
m_MapLists.push_back(pMapList); m_MapLists.push_back(pMapList);
@@ -115,11 +106,7 @@ public:
return; return;
} }
g_SourceMod.BuildPath(Path_Game, g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
path,
sizeof(path),
"%s",
file);
/* If the path matches, don't reset the serial/time */ /* If the path matches, don't reset the serial/time */
if (strcmp(path, pMapList->path) == 0) if (strcmp(path, pMapList->path) == 0)
@@ -127,7 +114,7 @@ public:
return; return;
} }
strncopy(pMapList->path, path, sizeof(pMapList->path)); smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
pMapList->bIsPath = true; pMapList->bIsPath = true;
pMapList->last_modified_time = 0; pMapList->last_modified_time = 0;
pMapList->serial = 0; pMapList->serial = 0;
@@ -139,7 +126,7 @@ public:
time_t fileTime; time_t fileTime;
SMCStates states = {0, 0}; SMCStates states = {0, 0};
fileFound = g_LibSys.FileTime(m_ConfigFile, FileTime_LastChange, &fileTime); fileFound = libsys->FileTime(m_ConfigFile, FileTime_LastChange, &fileTime);
/* If the file is found and hasn't changed, bail out now. */ /* If the file is found and hasn't changed, bail out now. */
if (fileFound && fileTime == m_ConfigLastChanged) if (fileFound && fileTime == m_ConfigLastChanged)
@@ -156,7 +143,7 @@ public:
return; return;
} }
m_pMapCycleFile = icvar->FindVar("mapcyclefile"); m_pMapCycleFile = smcore.FindConVar("mapcyclefile");
/* Dump everything we know about. */ /* Dump everything we know about. */
List<maplist_info_t *> compat; List<maplist_info_t *> compat;
@@ -166,12 +153,12 @@ public:
maplist_info_t *pDefList = new maplist_info_t; maplist_info_t *pDefList = new maplist_info_t;
pDefList->bIsPath = true; pDefList->bIsPath = true;
strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name)); smcore.strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name));
g_SourceMod.BuildPath(Path_Game, g_pSM->BuildPath(Path_Game,
pDefList->path, pDefList->path,
sizeof(pDefList->path), sizeof(pDefList->path),
"%s", "%s",
m_pMapCycleFile ? m_pMapCycleFile->GetString() : "mapcycle.txt"); m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt");
pDefList->last_modified_time = 0; pDefList->last_modified_time = 0;
pDefList->pArray = NULL; pDefList->pArray = NULL;
pDefList->serial = 0; pDefList->serial = 0;
@@ -182,19 +169,16 @@ public:
/* Now parse the config file even if we don't know about it. /* Now parse the config file even if we don't know about it.
* This will give us a nice error message. * This will give us a nice error message.
*/ */
if ((error = g_TextParser.ParseFile_SMC(m_ConfigFile, this, &states)) if ((error = textparser->ParseFile_SMC(m_ConfigFile, this, &states))
!= SMCError_Okay) != SMCError_Okay)
{ {
const char *errmsg = g_TextParser.GetSMCErrorString(error); const char *errmsg = textparser->GetSMCErrorString(error);
if (errmsg == NULL) if (errmsg == NULL)
{ {
errmsg = "Unknown error"; errmsg = "Unknown error";
} }
g_Logger.LogError("[SM] Could not parse file \"%s\"", m_ConfigFile); smcore.LogError("[SM] Could not parse file \"%s\"", m_ConfigFile);
g_Logger.LogError("[SM] Error on line %d (col %d): %s", smcore.LogError("[SM] Error on line %d (col %d): %s", states.line, states.col, errmsg);
states.line,
states.col,
errmsg);
} }
else else
{ {
@@ -249,7 +233,7 @@ public:
m_pCurMapList = new maplist_info_t; m_pCurMapList = new maplist_info_t;
memset(m_pCurMapList, 0, sizeof(maplist_info_t)); memset(m_pCurMapList, 0, sizeof(maplist_info_t));
strncopy(m_pCurMapList->name, name, sizeof(m_pCurMapList->name)); smcore.strncopy(m_pCurMapList->name, name, sizeof(m_pCurMapList->name));
m_CurState = MPS_MAPLIST; m_CurState = MPS_MAPLIST;
} }
@@ -269,7 +253,7 @@ public:
if (strcmp(key, "file") == 0) if (strcmp(key, "file") == 0)
{ {
g_SourceMod.BuildPath(Path_Game, g_pSM->BuildPath(Path_Game,
m_pCurMapList->path, m_pCurMapList->path,
sizeof(m_pCurMapList->path), sizeof(m_pCurMapList->path),
"%s", "%s",
@@ -278,7 +262,7 @@ public:
} }
else if (strcmp(key, "target") == 0) else if (strcmp(key, "target") == 0)
{ {
strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path)); smcore.strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
m_pCurMapList->bIsPath = false; m_pCurMapList->bIsPath = false;
} }
@@ -369,9 +353,9 @@ public:
pNewArray = new CellArray(64); pNewArray = new CellArray(64);
free_new_array = true; free_new_array = true;
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "maps"); g_pSM->BuildPath(Path_Game, path, sizeof(path), "maps");
if ((pDir = g_LibSys.OpenDirectory(path)) != NULL) if ((pDir = libsys->OpenDirectory(path)) != NULL)
{ {
char *ptr; char *ptr;
cell_t *blk; cell_t *blk;
@@ -386,7 +370,7 @@ public:
pDir->NextEntry(); pDir->NextEntry();
continue; continue;
} }
strncopy(buffer, pDir->GetEntryName(), sizeof(buffer)); smcore.strncopy(buffer, pDir->GetEntryName(), sizeof(buffer));
if ((ptr = strstr(buffer, ".bsp")) == NULL || ptr[4] != '\0') if ((ptr = strstr(buffer, ".bsp")) == NULL || ptr[4] != '\0')
{ {
pDir->NextEntry(); pDir->NextEntry();
@@ -403,10 +387,10 @@ public:
pDir->NextEntry(); pDir->NextEntry();
continue; continue;
} }
strncopy((char *)blk, buffer, 255); smcore.strncopy((char *)blk, buffer, 255);
pDir->NextEntry(); pDir->NextEntry();
} }
g_LibSys.CloseDirectory(pDir); libsys->CloseDirectory(pDir);
} }
/* Remove the array if there were no items. */ /* Remove the array if there were no items. */
@@ -461,7 +445,7 @@ public:
{ {
blk_dst = pUseArray->push(); blk_dst = pUseArray->push();
blk_src = pNewArray->at(i); blk_src = pNewArray->at(i);
strncopy((char *)blk_dst, (char *)blk_src, pUseArray->blocksize() * sizeof(cell_t)); smcore.strncopy((char *)blk_dst, (char *)blk_src, pUseArray->blocksize() * sizeof(cell_t));
} }
/* Free resources if necessary. */ /* Free resources if necessary. */
@@ -501,20 +485,20 @@ private:
if (m_pMapCycleFile != NULL && strcmp(name, "mapcyclefile") == 0) if (m_pMapCycleFile != NULL && strcmp(name, "mapcyclefile") == 0)
{ {
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_Game, g_pSM->BuildPath(Path_Game,
path, path,
sizeof(path), sizeof(path),
"%s", "%s",
m_pMapCycleFile ? m_pMapCycleFile->GetString() : "mapcycle.txt"); m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt");
if (strcmp(path, pMapList->path) != 0) if (strcmp(path, pMapList->path) != 0)
{ {
strncopy(pMapList->path, path, sizeof(pMapList->path)); smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
pMapList->last_modified_time = 0; pMapList->last_modified_time = 0;
} }
} }
if (!g_LibSys.FileTime(pMapList->path, FileTime_LastChange, &last_time) if (!libsys->FileTime(pMapList->path, FileTime_LastChange, &last_time)
|| last_time > pMapList->last_modified_time) || last_time > pMapList->last_modified_time)
{ {
/* Reparse */ /* Reparse */
@@ -533,7 +517,7 @@ private:
while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL) while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
{ {
size_t len = strlen(buffer); size_t len = strlen(buffer);
char *ptr = UTIL_TrimWhitespace(buffer, len); char *ptr = smcore.TrimWhitespace(buffer, len);
if (*ptr == '\0' if (*ptr == '\0'
|| *ptr == ';' || *ptr == ';'
|| strncmp(ptr, "//", 2) == 0) || strncmp(ptr, "//", 2) == 0)
@@ -546,7 +530,7 @@ private:
} }
if ((blk = pMapList->pArray->push()) != NULL) if ((blk = pMapList->pArray->push()) != NULL)
{ {
strncopy((char *)blk, ptr, 255); smcore.strncopy((char *)blk, ptr, 255);
} }
} }
@@ -616,7 +600,7 @@ static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(hndl, htCellArray, &sec, (void **)&pArray)) if ((err = handlesys->ReadHandle(hndl, htCellArray, &sec, (void **)&pArray))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
@@ -635,7 +619,7 @@ static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
/* If the user wanted a new array, create it now. */ /* If the user wanted a new array, create it now. */
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
if ((hndl = g_HandleSys.CreateHandle(htCellArray, pNewArray, pContext->GetIdentity(), g_pCoreIdent, NULL)) if ((hndl = handlesys->CreateHandle(htCellArray, pNewArray, pContext->GetIdentity(), g_pCoreIdent, NULL))
== BAD_HANDLE) == BAD_HANDLE)
{ {
*addr = -1; *addr = -1;
@@ -29,11 +29,10 @@
* Version: $Id$ * Version: $Id$
*/ */
#include "sm_globals.h"
#include <IHandleSys.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "HandleSys.h" #include <time.h>
#include "common_logic.h"
#include "CellArray.h" #include "CellArray.h"
/*********************************** /***********************************
@@ -448,7 +447,7 @@ static cell_t sm_SortADTArray(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -535,7 +534,7 @@ static cell_t sm_SortADTArrayCustom(IPluginContext *pContext, const cell_t *para
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray)) if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
@@ -29,9 +29,9 @@
* Version: $Id$ * Version: $Id$
*/ */
#include "sm_globals.h" #include "common_logic.h"
#include <ITextParsers.h> #include <ITextParsers.h>
#include "HandleSys.h" #include <ISourceMod.h>
HandleType_t g_TypeSMC = 0; HandleType_t g_TypeSMC = 0;
@@ -152,16 +152,16 @@ public:
/* These cannot be cloned, because they are locked to a specific plugin. /* These cannot be cloned, because they are locked to a specific plugin.
* However, we let anyone read them because we don't care. * However, we let anyone read them because we don't care.
*/ */
g_HandleSys.InitAccessDefaults(NULL, &sec); handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY; sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY;
sec.access[HandleAccess_Read] = 0; sec.access[HandleAccess_Read] = 0;
g_TypeSMC = g_HandleSys.CreateType("SMCParser", this, 0, NULL, &sec, g_pCoreIdent, NULL); g_TypeSMC = handlesys->CreateType("SMCParser", this, 0, NULL, &sec, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(g_TypeSMC, g_pCoreIdent); handlesys->RemoveType(g_TypeSMC, g_pCoreIdent);
} }
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
@@ -183,7 +183,7 @@ static cell_t SMC_CreateParser(IPluginContext *pContext, const cell_t *params)
{ {
ParseInfo *pInfo = new ParseInfo(); ParseInfo *pInfo = new ParseInfo();
Handle_t hndl = g_HandleSys.CreateHandle(g_TypeSMC, pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(g_TypeSMC, pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL);
/* Should never happen */ /* Should never happen */
if (!hndl) if (!hndl)
@@ -203,7 +203,7 @@ static cell_t SMC_SetParseStart(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
ParseInfo *parse; ParseInfo *parse;
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse)) if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@@ -220,7 +220,7 @@ static cell_t SMC_SetParseEnd(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
ParseInfo *parse; ParseInfo *parse;
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse)) if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@@ -237,7 +237,7 @@ static cell_t SMC_SetReaders(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
ParseInfo *parse; ParseInfo *parse;
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse)) if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@@ -256,7 +256,7 @@ static cell_t SMC_SetRawLine(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
ParseInfo *parse; ParseInfo *parse;
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse)) if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@@ -273,7 +273,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
ParseInfo *parse; ParseInfo *parse;
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse)) if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@@ -283,7 +283,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[2], &file); pContext->LocalToString(params[2], &file);
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file); g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
SMCStates states; SMCStates states;
SMCError p_err = textparsers->ParseFile_SMC(path, parse, &states); SMCError p_err = textparsers->ParseFile_SMC(path, parse, &states);
+104
View File
@@ -0,0 +1,104 @@
// Microsoft Visual C++ generated resource script.
//
//#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#include <sourcemod_version.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION SM_FILE_VERSION
PRODUCTVERSION SM_FILE_VERSION
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "SourceMod"
VALUE "FileDescription", "SourceMod Core Logic"
VALUE "FileVersion", SM_FULL_VERSION
VALUE "InternalName", "sourcemod"
VALUE "LegalCopyright", "Copyright (c) 2004-2009, AlliedModders LLC"
VALUE "OriginalFilename", "sourcemod.logic.dll"
VALUE "ProductName", "SourceMod"
VALUE "ProductVersion", SM_FULL_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+176
View File
@@ -0,0 +1,176 @@
/**
* vim: set ts=4 sw=4 :
* =============================================================================
* 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 <stdio.h>
#include <assert.h>
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "sm_globals.h"
#include "NativeOwner.h"
#include "sm_autonatives.h"
#include "logic/intercom.h"
#include "LibrarySys.h"
#include "HandleSys.h"
#include "sm_stringutil.h"
#include "Logger.h"
#include "ShareSys.h"
#include "sm_srvcmds.h"
#include "ForwardSys.h"
static ILibrary *g_pLogic = NULL;
static LogicInitFunction logic_init_fn;
IThreader *g_pThreader;
ITextParsers *textparsers;
class VEngineServer_Logic : public IVEngineServer_Logic
{
public:
virtual bool IsMapValid(const char *map)
{
return engine->IsMapValid(map);
}
};
static VEngineServer_Logic logic_engine;
static void add_natives(sp_nativeinfo_t *natives)
{
g_pCoreNatives->AddNatives(natives);
}
static ConVar *find_convar(const char *name)
{
return icvar->FindVar(name);
}
static void log_error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
g_Logger.LogErrorEx(fmt, ap);
va_end(ap);
}
static const char *get_cvar_string(ConVar* cvar)
{
return cvar->GetString();
}
static sm_core_t core_bridge =
{
/* Objects */
&g_HandleSys,
NULL,
&g_SourceMod,
&g_LibSys,
reinterpret_cast<IVEngineServer*>(&logic_engine),
&g_ShareSys,
&g_RootMenu,
&g_PluginSys,
&g_Forwards,
/* Functions */
add_natives,
find_convar,
strncopy,
UTIL_TrimWhitespace,
log_error,
get_cvar_string,
UTIL_Format,
UTIL_ReplaceAll
};
void InitLogicBridge()
{
sm_logic_t logic;
core_bridge.core_ident = g_pCoreIdent;
logic_init_fn(&core_bridge, &logic);
/* Add SMGlobalClass instances */
SMGlobalClass* glob = SMGlobalClass::head;
while (glob->m_pGlobalClassNext != NULL)
{
glob = glob->m_pGlobalClassNext;
}
assert(glob->m_pGlobalClassNext == NULL);
glob->m_pGlobalClassNext = logic.head;
g_pThreader = logic.threader;
g_pSourcePawn2->SetProfiler(logic.profiler);
}
bool StartLogicBridge(char *error, size_t maxlength)
{
char file[PLATFORM_MAX_PATH];
/* Now it's time to load the logic binary */
g_SMAPI->PathFormat(file,
sizeof(file),
"%s/bin/sourcemod.logic." PLATFORM_LIB_EXT,
g_SourceMod.GetSourceModPath());
char myerror[255];
g_pLogic = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
if (!g_pLogic)
{
if (error && maxlength)
{
UTIL_Format(error, maxlength, "failed to load %s: %s", file, myerror);
}
return false;
}
LogicLoadFunction llf = (LogicLoadFunction)g_pLogic->GetSymbolAddress("logic_load");
if (llf == NULL)
{
g_pLogic->CloseLibrary();
if (error && maxlength)
{
UTIL_Format(error, maxlength, "could not find logic_load function");
}
return false;
}
GetITextParsers getitxt = (GetITextParsers)g_pLogic->GetSymbolAddress("get_textparsers");
textparsers = getitxt();
logic_init_fn = llf(SM_LOGIC_MAGIC);
return true;
}
void ShutdownLogicBridge()
{
g_pLogic->CloseLibrary();
}
+39
View File
@@ -0,0 +1,39 @@
/**
* vim: set ts=4 sw=4 :
* =============================================================================
* 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_LOGIC_BRIDGE_H_
#define _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_
void InitLogicBridge();
bool StartLogicBridge(char *error, size_t maxlength);
void ShutdownLogicBridge();
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */
+9
View File
@@ -7,18 +7,21 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32 CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32
CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|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 - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32
CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32
CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32 CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32
CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32
Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32
Debug - Episode 1|Win32 = Debug - Episode 1|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 - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32 Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32
Release - Episode 1|Win32 = Release - Episode 1|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 - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32
Release - Old Metamod|Win32 = Release - Old Metamod|Win32 Release - Old Metamod|Win32 = Release - Old Metamod|Win32
Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32
@@ -29,6 +32,8 @@ Global
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = 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.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 - 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.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 - 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.ActiveCfg = CrazyDebug - Old Metamod|Win32
@@ -41,6 +46,8 @@ Global
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = 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.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 - 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.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 - 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.ActiveCfg = Debug - Old Metamod|Win32
@@ -53,6 +60,8 @@ Global
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = 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.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 - 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.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 - 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.ActiveCfg = Release - Old Metamod|Win32
+309 -92
View File
@@ -60,6 +60,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -142,6 +143,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -223,6 +225,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -307,6 +310,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -389,6 +393,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -470,6 +475,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -554,6 +560,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -636,6 +643,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -717,6 +725,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -801,6 +810,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -883,6 +893,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -964,6 +975,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1048,6 +1060,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1130,6 +1143,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1211,6 +1225,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1295,6 +1310,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1377,6 +1393,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1448,6 +1465,7 @@
EnableEnhancedInstructionSet="0" EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false" RuntimeTypeInfo="false"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
AssemblerOutput="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="false" Detect64BitPortabilityProblems="false"
DebugInformationFormat="3" DebugInformationFormat="3"
@@ -1458,6 +1476,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;" PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
@@ -1498,6 +1517,256 @@
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration
Name="CrazyDebug - Left 4 Dead 2|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
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"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="&quot;$(HL2SDKL4D2)\lib\public\tier0.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\tier1.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\mathlib.lib&quot; dbghelp.lib &quot;Wsock32.lib&quot;"
OutputFile="$(OutDir)\sourcemod.2.l4d2.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug - Left 4 Dead 2|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
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"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="&quot;$(HL2SDKL4D2)\lib\public\tier0.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\tier1.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\mathlib.lib&quot; &quot;Wsock32.lib&quot;"
OutputFile="$(OutDir)\sourcemod.2.l4d2.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release - Left 4 Dead 2|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
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"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="BINARY_NAME=\&quot;$(TargetFileName)\&quot;"
AdditionalIncludeDirectories="..\..\public"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="&quot;$(HL2SDKL4D2)\lib\public\tier0.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\tier1.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDKL4D2)\lib\public\mathlib.lib&quot; &quot;Wsock32.lib&quot;"
OutputFile="$(OutDir)\sourcemod.2.l4d2.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
@@ -1531,6 +1800,10 @@
RelativePath="..\ConCmdManager.cpp" RelativePath="..\ConCmdManager.cpp"
> >
</File> </File>
<File
RelativePath="..\ConsoleDetours.cpp"
>
</File>
<File <File
RelativePath="..\ConVarManager.cpp" RelativePath="..\ConVarManager.cpp"
> >
@@ -1638,6 +1911,22 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Debug - Left 4 Dead 2|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release - Left 4 Dead 2|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\Database.cpp" RelativePath="..\Database.cpp"
@@ -1683,6 +1972,10 @@
RelativePath="..\Logger.cpp" RelativePath="..\Logger.cpp"
> >
</File> </File>
<File
RelativePath="..\logic_bridge.cpp"
>
</File>
<File <File
RelativePath="..\MemoryUtils.cpp" RelativePath="..\MemoryUtils.cpp"
> >
@@ -1735,10 +2028,6 @@
RelativePath="..\PluginSys.cpp" RelativePath="..\PluginSys.cpp"
> >
</File> </File>
<File
RelativePath="..\Profiler.cpp"
>
</File>
<File <File
RelativePath="..\ShareSys.cpp" RelativePath="..\ShareSys.cpp"
> >
@@ -1775,14 +2064,6 @@
RelativePath="..\sourcemod.cpp" RelativePath="..\sourcemod.cpp"
> >
</File> </File>
<File
RelativePath="..\TextParsers.cpp"
>
</File>
<File
RelativePath="..\ThreadSupport.cpp"
>
</File>
<File <File
RelativePath="..\TimerSys.cpp" RelativePath="..\TimerSys.cpp"
> >
@@ -1837,6 +2118,14 @@
RelativePath="..\ConCmdManager.h" RelativePath="..\ConCmdManager.h"
> >
</File> </File>
<File
RelativePath="..\ConCommandBaseIterator.h"
>
</File>
<File
RelativePath="..\ConsoleDetours.h"
>
</File>
<File <File
RelativePath="..\ConVarManager.h" RelativePath="..\ConVarManager.h"
> >
@@ -1889,6 +2178,10 @@
RelativePath="..\Logger.h" RelativePath="..\Logger.h"
> >
</File> </File>
<File
RelativePath="..\logic_bridge.h"
>
</File>
<File <File
RelativePath="..\MemoryUtils.h" RelativePath="..\MemoryUtils.h"
> >
@@ -1941,10 +2234,6 @@
RelativePath="..\PluginSys.h" RelativePath="..\PluginSys.h"
> >
</File> </File>
<File
RelativePath="..\Profiler.h"
>
</File>
<File <File
RelativePath="..\ShareSys.h" RelativePath="..\ShareSys.h"
> >
@@ -1989,6 +2278,10 @@
RelativePath="..\sm_stringutil.h" RelativePath="..\sm_stringutil.h"
> >
</File> </File>
<File
RelativePath="..\sm_symtable.h"
>
</File>
<File <File
RelativePath="..\sm_trie.h" RelativePath="..\sm_trie.h"
> >
@@ -2013,14 +2306,6 @@
RelativePath="..\sourcemod.h" RelativePath="..\sourcemod.h"
> >
</File> </File>
<File
RelativePath="..\TextParsers.h"
>
</File>
<File
RelativePath="..\ThreadSupport.h"
>
</File>
<File <File
RelativePath="..\TimerSys.h" RelativePath="..\TimerSys.h"
> >
@@ -2169,18 +2454,6 @@
RelativePath="..\smn_admin.cpp" RelativePath="..\smn_admin.cpp"
> >
</File> </File>
<File
RelativePath="..\smn_adt_array.cpp"
>
</File>
<File
RelativePath="..\smn_adt_stack.cpp"
>
</File>
<File
RelativePath="..\smn_adt_trie.cpp"
>
</File>
<File <File
RelativePath="..\smn_banning.cpp" RelativePath="..\smn_banning.cpp"
> >
@@ -2221,14 +2494,6 @@
RelativePath="..\smn_filesystem.cpp" RelativePath="..\smn_filesystem.cpp"
> >
</File> </File>
<File
RelativePath="..\smn_float.cpp"
>
</File>
<File
RelativePath="..\smn_functions.cpp"
>
</File>
<File <File
RelativePath="..\smn_gameconfigs.cpp" RelativePath="..\smn_gameconfigs.cpp"
> >
@@ -2253,10 +2518,6 @@
RelativePath="..\smn_lang.cpp" RelativePath="..\smn_lang.cpp"
> >
</File> </File>
<File
RelativePath="..\smn_maplists.cpp"
>
</File>
<File <File
RelativePath="..\smn_menus.cpp" RelativePath="..\smn_menus.cpp"
> >
@@ -2273,18 +2534,10 @@
RelativePath="..\smn_profiler.cpp" RelativePath="..\smn_profiler.cpp"
> >
</File> </File>
<File
RelativePath="..\smn_sorting.cpp"
>
</File>
<File <File
RelativePath="..\smn_string.cpp" RelativePath="..\smn_string.cpp"
> >
</File> </File>
<File
RelativePath="..\smn_textparse.cpp"
>
</File>
<File <File
RelativePath="..\smn_timers.cpp" RelativePath="..\smn_timers.cpp"
> >
@@ -2308,42 +2561,6 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="Threader"
>
<Filter
Name="Header Files"
>
<File
RelativePath="..\thread\BaseWorker.h"
>
</File>
<File
RelativePath="..\thread\ThreadWorker.h"
>
</File>
<File
RelativePath="..\thread\WinThreads.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\thread\BaseWorker.cpp"
>
</File>
<File
RelativePath="..\thread\ThreadWorker.cpp"
>
</File>
<File
RelativePath="..\thread\WinThreads.cpp"
>
</File>
</Filter>
</Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
+18 -4
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -76,7 +76,11 @@ class SMGlobalClass
friend class CExtensionManager; friend class CExtensionManager;
friend class PlayerManager; friend class PlayerManager;
public: public:
SMGlobalClass(); SMGlobalClass()
{
m_pGlobalClassNext = SMGlobalClass::head;
SMGlobalClass::head = this;
}
public: public:
/** /**
* @brief Called when SourceMod is initially loading * @brief Called when SourceMod is initially loading
@@ -184,7 +188,7 @@ public:
virtual void OnSourceModMaxPlayersChanged(int newvalue) virtual void OnSourceModMaxPlayersChanged(int newvalue)
{ {
} }
private: public:
SMGlobalClass *m_pGlobalClassNext; SMGlobalClass *m_pGlobalClassNext;
static SMGlobalClass *head; static SMGlobalClass *head;
}; };
@@ -193,6 +197,16 @@ extern ISourcePawnEngine *g_pSourcePawn;
extern ISourcePawnEngine2 *g_pSourcePawn2; extern ISourcePawnEngine2 *g_pSourcePawn2;
extern IdentityToken_t *g_pCoreIdent; extern IdentityToken_t *g_pCoreIdent;
namespace SourceMod
{
class IThreader;
class ITextParsers;
}
extern IThreader *g_pThreader;
extern ITextParsers *textparsers;
#include "sm_autonatives.h" #include "sm_autonatives.h"
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_ #endif //_INCLUDE_SOURCEMOD_GLOBALS_H_
+86 -27
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -116,14 +116,25 @@ void RootConsoleMenu::ConsolePrint(const char *fmt, ...)
} }
bool RootConsoleMenu::AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) bool RootConsoleMenu::AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler)
{
return _AddRootConsoleCommand(cmd, text, pHandler, false);
}
bool RootConsoleMenu::AddRootConsoleCommand2(const char *cmd, const char *text, IRootConsoleCommand *pHandler)
{
return _AddRootConsoleCommand(cmd, text, pHandler, true);
}
bool RootConsoleMenu::_AddRootConsoleCommand(const char *cmd,
const char *text,
IRootConsoleCommand *pHandler,
bool version2)
{ {
if (sm_trie_retrieve(m_pCommands, cmd, NULL)) if (sm_trie_retrieve(m_pCommands, cmd, NULL))
{ {
return false; return false;
} }
sm_trie_insert(m_pCommands, cmd, pHandler);
/* Sort this into the menu */ /* Sort this into the menu */
List<ConsoleEntry *>::iterator iter = m_Menu.begin(); List<ConsoleEntry *>::iterator iter = m_Menu.begin();
ConsoleEntry *pEntry; ConsoleEntry *pEntry;
@@ -136,6 +147,9 @@ bool RootConsoleMenu::AddRootConsoleCommand(const char *cmd, const char *text, I
ConsoleEntry *pNew = new ConsoleEntry; ConsoleEntry *pNew = new ConsoleEntry;
pNew->command.assign(cmd); pNew->command.assign(cmd);
pNew->description.assign(text); pNew->description.assign(text);
pNew->version2 = version2;
pNew->cmd = pHandler;
sm_trie_insert(m_pCommands, cmd, pNew);
m_Menu.insert(iter, pNew); m_Menu.insert(iter, pNew);
inserted = true; inserted = true;
break; break;
@@ -148,6 +162,9 @@ bool RootConsoleMenu::AddRootConsoleCommand(const char *cmd, const char *text, I
ConsoleEntry *pNew = new ConsoleEntry; ConsoleEntry *pNew = new ConsoleEntry;
pNew->command.assign(cmd); pNew->command.assign(cmd);
pNew->description.assign(text); pNew->description.assign(text);
pNew->version2 = version2;
pNew->cmd = pHandler;
sm_trie_insert(m_pCommands, cmd, pNew);
m_Menu.push_back(pNew); m_Menu.push_back(pNew);
} }
@@ -156,18 +173,6 @@ bool RootConsoleMenu::AddRootConsoleCommand(const char *cmd, const char *text, I
bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler)
{ {
/* Sanity tests */
IRootConsoleCommand *object;
if (sm_trie_retrieve(m_pCommands, cmd, (void **)&object))
{
if (object != pHandler)
{
return false;
}
} else {
return false;
}
sm_trie_delete(m_pCommands, cmd); sm_trie_delete(m_pCommands, cmd);
List<ConsoleEntry *>::iterator iter; List<ConsoleEntry *>::iterator iter;
@@ -214,6 +219,49 @@ unsigned int RootConsoleMenu::GetInterfaceVersion()
return SMINTERFACE_ROOTCONSOLE_VERSION; return SMINTERFACE_ROOTCONSOLE_VERSION;
} }
#if SOURCE_ENGINE==SE_EPISODEONE || SOURCE_ENGINE==SE_DARKMESSIAH
class CCommandArgs : public ICommandArgs
{
public:
CCommandArgs(const CCommand& _cmd)
{
}
const char *Arg(int n) const
{
return engine->Cmd_Argv(n);
}
int ArgC() const
{
return engine->Cmd_Argc();
}
const char *ArgS() const
{
return engine->Cmd_Args();
}
};
#else
class CCommandArgs : public ICommandArgs
{
const CCommand *cmd;
public:
CCommandArgs(const CCommand& _cmd) : cmd(&_cmd)
{
}
const char *Arg(int n) const
{
return cmd->Arg(n);
}
int ArgC() const
{
return cmd->ArgC();
}
const char *ArgS() const
{
return cmd->ArgS();
}
};
#endif
void RootConsoleMenu::GotRootCmd(const CCommand &cmd) void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
{ {
unsigned int argnum = cmd.ArgC(); unsigned int argnum = cmd.ArgC();
@@ -241,10 +289,19 @@ void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
return; return;
} }
IRootConsoleCommand *pHandler; CCommandArgs ocmd(cmd);
if (sm_trie_retrieve(m_pCommands, cmdname, (void **)&pHandler))
ConsoleEntry *entry;
if (sm_trie_retrieve(m_pCommands, cmdname, (void **)&entry))
{ {
pHandler->OnRootConsoleCommand(cmdname, cmd); if (entry->version2)
{
entry->cmd->OnRootConsoleCommand2(cmdname, &ocmd);
}
else
{
entry->cmd->OnRootConsoleCommand(cmdname, cmd);
}
return; return;
} }
} }
@@ -267,14 +324,15 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &
{ {
ConsolePrint(" SourceMod was developed by AlliedModders, LLC."); ConsolePrint(" SourceMod was developed by AlliedModders, LLC.");
ConsolePrint(" Development would not have been possible without the following people:"); ConsolePrint(" Development would not have been possible without the following people:");
ConsolePrint(" David \"BAILOPAN\" Anderson, lead developer"); ConsolePrint(" David \"BAILOPAN\" Anderson");
ConsolePrint(" Borja \"faluco\" Ferrer, core developer"); ConsolePrint(" Matt \"pRED\" Woodrow");
ConsolePrint(" Scott \"Damaged Soul\" Ehlert, core developer"); ConsolePrint(" Scott \"DS\" Ehlert");
ConsolePrint(" Matt \"pRED\" Woodrow, core developer"); ConsolePrint(" Fyren");
ConsolePrint(" Michael \"ferret\" McKoy, plugin developer"); ConsolePrint(" Nicholas \"psychonic\" Hastings");
ConsolePrint(" Pavol \"PM OnoTo\" Marko, SourceHook developer"); ConsolePrint(" Borja \"faluco\" Ferrer");
ConsolePrint(" Special thanks to Viper of GameConnect"); ConsolePrint(" Pavol \"PM OnoTo\" Marko");
ConsolePrint(" Special thanks to Mani of Mani-Admin-Plugin"); ConsolePrint(" Special thanks to Liam, ferret, and Mani");
ConsolePrint(" Special thanks to Viper and SteamFriends");
ConsolePrint(" http://www.sourcemod.net/"); ConsolePrint(" http://www.sourcemod.net/");
} }
else if (strcmp(cmdname, "version") == 0) else if (strcmp(cmdname, "version") == 0)
@@ -357,3 +415,4 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
g_HandleSys.Dump(write_handles_to_game); g_HandleSys.Dump(write_handles_to_game);
} }
} }
+11 -2
View File
@@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 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 * This program is free software; you can redistribute it and/or modify it under
@@ -48,6 +48,8 @@ struct ConsoleEntry
{ {
String command; String command;
String description; String description;
bool version2;
IRootConsoleCommand *cmd;
}; };
class RootConsoleMenu : class RootConsoleMenu :
@@ -75,6 +77,13 @@ public: //IRootConsole
bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler); bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler);
void ConsolePrint(const char *fmt, ...); void ConsolePrint(const char *fmt, ...);
void DrawGenericOption(const char *cmd, const char *text); void DrawGenericOption(const char *cmd, const char *text);
bool AddRootConsoleCommand2(const char *cmd,
const char *text,
IRootConsoleCommand *pHandler);
bool _AddRootConsoleCommand(const char *cmd,
const char *text,
IRootConsoleCommand *pHandler,
bool version2);
public: public:
void GotRootCmd(const CCommand &cmd); void GotRootCmd(const CCommand &cmd);
private: private:
+47
View File
@@ -1580,3 +1580,50 @@ char *UTIL_TrimWhitespace(char *str, size_t &len)
return str; 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);
char *buffer = new char[len + 1];
for (size_t i = 0; i < len; i++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
buffer[i] = tolower(str[i]);
else
buffer[i] = str[i];
}
buffer[len] = '\0';
return buffer;
}
+3
View File
@@ -60,5 +60,8 @@ char *sm_strdup(const char *str);
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive = true); 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_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); 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_ #endif // _INCLUDE_SOURCEMOD_STRINGUTIL_H_
+231
View File
@@ -0,0 +1,231 @@
/**
* 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>.
*/
#ifndef _INCLUDE_SOURCEMOD_CORE_SYMBOLTABLE_H_
#define _INCLUDE_SOURCEMOD_CORE_SYMBOLTABLE_H_
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define KESTRING_TABLE_START_SIZE 65536
struct Symbol
{
size_t length;
uint32_t hash;
void *address;
Symbol *tbl_next;
inline char *buffer()
{
return reinterpret_cast<char *>(this + 1);
}
};
class SymbolTable
{
public:
~SymbolTable()
{
for (uint32_t i = 0; i < nbuckets; i++)
{
Symbol *sym = buckets[i];
while (sym != NULL)
{
Symbol *next = sym->tbl_next;
free(sym);
sym = next;
}
}
free(buckets);
}
bool Initialize()
{
buckets = (Symbol **)malloc(sizeof(Symbol *) * KESTRING_TABLE_START_SIZE);
if (buckets == NULL)
{
return false;
}
memset(buckets, 0, sizeof(Symbol *) * KESTRING_TABLE_START_SIZE);
nbuckets = KESTRING_TABLE_START_SIZE;
nused = 0;
bucketmask = KESTRING_TABLE_START_SIZE - 1;
return true;
}
static inline uint32_t HashString(const char *data, size_t len)
{
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
#define get16bits(d) (*((const uint16_t *) (d)))
#endif
#if !defined (get16bits)
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
+(uint32_t)(((const uint8_t *)(d))[0]) )
#endif
uint32_t hash = len, tmp;
int rem;
if (len <= 0 || data == NULL)
{
return 0;
}
rem = len & 3;
len >>= 2;
/* Main loop */
for (;len > 0; len--) {
hash += get16bits (data);
tmp = (get16bits (data+2) << 11) ^ hash;
hash = (hash << 16) ^ tmp;
data += 2 * sizeof (uint16_t);
hash += hash >> 11;
}
/* Handle end cases */
switch (rem) {
case 3: hash += get16bits (data);
hash ^= hash << 16;
hash ^= data[sizeof (uint16_t)] << 18;
hash += hash >> 11;
break;
case 2: hash += get16bits (data);
hash ^= hash << 11;
hash += hash >> 17;
break;
case 1: hash += *data;
hash ^= hash << 10;
hash += hash >> 1;
}
/* Force "avalanching" of final 127 bits */
hash ^= hash << 3;
hash += hash >> 5;
hash ^= hash << 4;
hash += hash >> 17;
hash ^= hash << 25;
hash += hash >> 6;
return hash;
#undef get16bits
}
Symbol **FindSymbolBucket(const char *str, size_t len, uint32_t hash)
{
uint32_t bucket = hash & bucketmask;
Symbol **pkvs = &buckets[bucket];
Symbol *kvs = *pkvs;
while (kvs != NULL)
{
if (len == kvs->length && memcmp(str, kvs->buffer(), len * sizeof(char)) == 0)
{
return pkvs;
}
pkvs = &kvs->tbl_next;
kvs = *pkvs;
}
return pkvs;
}
void ResizeSymbolTable()
{
uint32_t xnbuckets = nbuckets * 2;
Symbol **xbuckets = (Symbol **)malloc(sizeof(Symbol *) * xnbuckets);
if (xbuckets == NULL)
{
return;
}
memset(xbuckets, 0, sizeof(Symbol *) * xnbuckets);
uint32_t xbucketmask = xnbuckets - 1;
for (uint32_t i = 0; i < nbuckets; i++)
{
Symbol *sym = buckets[i];
while (sym != NULL)
{
Symbol *next = sym->tbl_next;
uint32_t bucket = sym->hash & xbucketmask;
sym->tbl_next = xbuckets[bucket];
xbuckets[bucket] = sym;
sym = next;
}
}
free(buckets);
buckets = xbuckets;
nbuckets = xnbuckets;
bucketmask = xbucketmask;
}
Symbol *FindSymbol(const char *str, size_t len)
{
uint32_t hash = HashString(str, len);
Symbol **pkvs = FindSymbolBucket(str, len, hash);
return *pkvs;
}
Symbol *InternSymbol(const char* str, size_t len, void *address)
{
uint32_t hash = HashString(str, len);
Symbol **pkvs = FindSymbolBucket(str, len, hash);
if (*pkvs != NULL)
{
return *pkvs;
}
Symbol *kvs = (Symbol *)malloc(sizeof(Symbol) + sizeof(char) * (len + 1));
kvs->length = len;
kvs->hash = hash;
kvs->address = address;
kvs->tbl_next = NULL;
memcpy(kvs + 1, str, sizeof(char) * (len + 1));
*pkvs = kvs;
nused++;
if (nused > nbuckets && nbuckets <= INT_MAX / 2)
{
ResizeSymbolTable();
}
return kvs;
}
private:
uint32_t nbuckets;
uint32_t nused;
uint32_t bucketmask;
Symbol **buckets;
};
#endif //_INCLUDE_SOURCEMOD_CORE_SYMBOLTABLE_H_
+17
View File
@@ -505,6 +505,22 @@ static cell_t FindFlagByChar(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t FindFlagChar(IPluginContext *pContext, const cell_t *params)
{
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
char flagchar;
if (!g_Admins.FindFlagChar((AdminFlag)params[1], &flagchar))
{
return 0;
}
*addr = (cell_t)flagchar;
return 1;
}
static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params) static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params)
{ {
char *flag; char *flag;
@@ -561,6 +577,7 @@ REGISTER_NATIVES(adminNatives)
{"CreateAuthMethod", CreateAuthMethod}, {"CreateAuthMethod", CreateAuthMethod},
{"FindFlagByName", FindFlagByName}, {"FindFlagByName", FindFlagByName},
{"FindFlagByChar", FindFlagByChar}, {"FindFlagByChar", FindFlagByChar},
{"FindFlagChar", FindFlagChar},
{"ReadFlagString", ReadFlagString}, {"ReadFlagString", ReadFlagString},
{"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel}, {"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel},
{"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel}, {"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel},
+3 -3
View File
@@ -248,7 +248,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
char *ban_reason, *ban_cmd; char *ban_reason, *ban_cmd;
int client, ban_flags, ban_source, ban_time; int client, ban_flags, ban_source, ban_time;
client = params[1]; client = g_HL2.ReferenceToIndex(params[1]);
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client); CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer || !pPlayer->IsConnected()) if (!pPlayer || !pPlayer->IsConnected())
@@ -377,7 +377,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
/* Kick, then ban */ /* Kick, then ban */
if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK) if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK)
{ {
pPlayer->Kick(kick_message); g_HL2.AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
} }
engine->ServerCommand(command); engine->ServerCommand(command);
@@ -390,7 +390,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
} }
else if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK) else if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK)
{ {
pPlayer->Kick(kick_message); g_HL2.AddDelayedKick(client, pPlayer->GetUserId(), kick_message);
} }
+12 -2
View File
@@ -33,6 +33,7 @@
#include "HandleSys.h" #include "HandleSys.h"
#include <bitbuf.h> #include <bitbuf.h>
#include <vector.h> #include <vector.h>
#include <HalfLife2.h>
static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params) static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params)
{ {
@@ -226,7 +227,14 @@ static cell_t smn_BfWriteEntity(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
} }
pBitBuf->WriteShort(params[2]); int index = g_HL2.ReferenceToIndex(params[2]);
if (index == -1)
{
return 0;
}
pBitBuf->WriteShort(index);
return 1; return 1;
} }
@@ -523,7 +531,9 @@ static cell_t smn_BfReadEntity(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
} }
return pBitBuf->ReadShort(); int ref = g_HL2.IndexToReference(pBitBuf->ReadShort());
return g_HL2.ReferenceToBCompatRef(ref);
} }
static cell_t smn_BfReadAngle(IPluginContext *pCtx, const cell_t *params) static cell_t smn_BfReadAngle(IPluginContext *pCtx, const cell_t *params)
+103 -61
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -43,8 +43,17 @@
#include <inetchannel.h> #include <inetchannel.h>
#include <bitbuf.h> #include <bitbuf.h>
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include "Logger.h"
#include "ConsoleDetours.h"
#include "ConCommandBaseIterator.h"
#if SOURCE_ENGINE == SE_LEFT4DEAD #if SOURCE_ENGINE >= SE_ORANGEBOXVALVE
#define NETMSG_BITS 6
#else
#define NETMSG_BITS 5
#endif
#if SOURCE_ENGINE >= SE_LEFT4DEAD
#define NET_SETCONVAR 6 #define NET_SETCONVAR 6
#else #else
#define NET_SETCONVAR 5 #define NET_SETCONVAR 5
@@ -65,15 +74,6 @@ struct GlobCmdIter
List<ConCmdInfo *>::iterator iter; List<ConCmdInfo *>::iterator iter;
}; };
struct ConCmdIter
{
#if SOURCE_ENGINE == SE_LEFT4DEAD
ICvarIteratorInternal *pLast;
#else
const ConCommandBase *pLast;
#endif
};
class ConsoleHelpers : class ConsoleHelpers :
public SMGlobalClass, public SMGlobalClass,
public IHandleTypeDispatch public IHandleTypeDispatch
@@ -100,11 +100,7 @@ public:
} }
else if (type == htConCmdIter) else if (type == htConCmdIter)
{ {
ConCmdIter *iter = (ConCmdIter * )object; ConCommandBaseIterator *iter = (ConCommandBaseIterator * )object;
#if SOURCE_ENGINE == SE_LEFT4DEAD
// ICvarIteratorInternal has no virtual destructor
g_pMemAlloc->Free(iter->pLast);
#endif
delete iter; delete iter;
} }
} }
@@ -112,7 +108,7 @@ public:
{ {
if (type == htConCmdIter) if (type == htConCmdIter)
{ {
*pSize = sizeof(ConCmdIter); *pSize = sizeof(ConCommandBaseIterator);
return true; return true;
} }
else if (type == hCmdIterType) else if (type == hCmdIterType)
@@ -179,7 +175,7 @@ private:
KTrie<ConCommandBase *> m_CmdFlags; KTrie<ConCommandBase *> m_CmdFlags;
} s_CommandFlagsHelper; } s_CommandFlagsHelper;
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE < SE_ORANGEBOX
static void ReplicateConVar(ConVar *pConVar) static void ReplicateConVar(ConVar *pConVar)
{ {
int maxClients = g_Players.GetMaxClients(); int maxClients = g_Players.GetMaxClients();
@@ -187,7 +183,7 @@ static void ReplicateConVar(ConVar *pConVar)
char data[256]; char data[256];
bf_write buffer(data, sizeof(data)); bf_write buffer(data, sizeof(data));
buffer.WriteUBitLong(NET_SETCONVAR, 5); buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
buffer.WriteByte(1); buffer.WriteByte(1);
buffer.WriteString(pConVar->GetName()); buffer.WriteString(pConVar->GetName());
buffer.WriteString(pConVar->GetString()); buffer.WriteString(pConVar->GetString());
@@ -198,8 +194,8 @@ static void ReplicateConVar(ConVar *pConVar)
if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient()) if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient())
{ {
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i)); if (INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i)))
netchan->SendData(buffer); netchan->SendData(buffer);
} }
} }
} }
@@ -353,7 +349,7 @@ static cell_t sm_SetConVarNum(IPluginContext *pContext, const cell_t *params)
pConVar->SetValue(params[2]); pConVar->SetValue(params[2]);
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE < SE_ORANGEBOX
/* Should we replicate it? */ /* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{ {
@@ -402,7 +398,7 @@ static cell_t sm_SetConVarFloat(IPluginContext *pContext, const cell_t *params)
float value = sp_ctof(params[2]); float value = sp_ctof(params[2]);
pConVar->SetValue(value); pConVar->SetValue(value);
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE < SE_ORANGEBOX
/* Should we replicate it? */ /* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{ {
@@ -453,7 +449,7 @@ static cell_t sm_SetConVarString(IPluginContext *pContext, const cell_t *params)
pConVar->SetValue(value); pConVar->SetValue(value);
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE < SE_ORANGEBOX
/* Should we replicate it? */ /* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{ {
@@ -484,7 +480,7 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params)
pConVar->Revert(); pConVar->Revert();
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE < SE_ORANGEBOX
/* Should we replicate it? */ /* Should we replicate it? */
if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
{ {
@@ -501,6 +497,24 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params)
return 1; 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) static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params)
{ {
Handle_t hndl = static_cast<Handle_t>(params[1]); Handle_t hndl = static_cast<Handle_t>(params[1]);
@@ -668,6 +682,7 @@ static cell_t sm_RegServerCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0) if (strcasecmp(name, "sm") == 0)
{ {
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0; return 0;
} }
@@ -696,6 +711,7 @@ static cell_t sm_RegConsoleCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0) if (strcasecmp(name, "sm") == 0)
{ {
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0; return 0;
} }
@@ -727,6 +743,7 @@ static cell_t sm_RegAdminCmd(IPluginContext *pContext, const cell_t *params)
if (strcasecmp(name, "sm") == 0) if (strcasecmp(name, "sm") == 0)
{ {
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0; return 0;
} }
@@ -1173,7 +1190,7 @@ static cell_t GetCommandFlags(IPluginContext *pContext, const cell_t *params)
static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params) static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params)
{ {
Handle_t hndl; Handle_t hndl;
ConCmdIter *pIter; ConCommandBaseIterator *pIter;
cell_t *pIsCmd, *pFlags; cell_t *pIsCmd, *pFlags;
const ConCommandBase *pConCmd; const ConCommandBase *pConCmd;
const char *desc; const char *desc;
@@ -1181,21 +1198,15 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
pContext->LocalToPhysAddr(params[3], &pIsCmd); pContext->LocalToPhysAddr(params[3], &pIsCmd);
pContext->LocalToPhysAddr(params[4], &pFlags); pContext->LocalToPhysAddr(params[4], &pFlags);
#if SOURCE_ENGINE == SE_LEFT4DEAD pIter = new ConCommandBaseIterator();
ICvarIteratorInternal *cvarIter = icvar->FactoryInternalIterator();
cvarIter->SetFirst(); if (!pIter->IsValid())
if (!cvarIter->IsValid())
{ {
delete pIter;
return BAD_HANDLE; return BAD_HANDLE;
} }
pConCmd = cvarIter->Get();
#else pConCmd = pIter->Get();
pConCmd = icvar->GetCommands();
if (pConCmd == NULL)
{
return BAD_HANDLE;
}
#endif
pContext->StringToLocalUTF8(params[1], params[2], pConCmd->GetName(), NULL); pContext->StringToLocalUTF8(params[1], params[2], pConCmd->GetName(), NULL);
*pIsCmd = pConCmd->IsCommand() ? 1 : 0; *pIsCmd = pConCmd->IsCommand() ? 1 : 0;
@@ -1207,13 +1218,6 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
pContext->StringToLocalUTF8(params[5], params[6], (desc && desc[0]) ? desc : "", NULL); pContext->StringToLocalUTF8(params[5], params[6], (desc && desc[0]) ? desc : "", NULL);
} }
pIter = new ConCmdIter;
#if SOURCE_ENGINE == SE_LEFT4DEAD
pIter->pLast = cvarIter;
#else
pIter->pLast = pConCmd;
#endif
if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL)) if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL))
== BAD_HANDLE) == BAD_HANDLE)
{ {
@@ -1227,7 +1231,7 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params) static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ConCmdIter *pIter; ConCommandBaseIterator *pIter;
cell_t *pIsCmd, *pFlags; cell_t *pIsCmd, *pFlags;
const char *desc; const char *desc;
const ConCommandBase *pConCmd; const ConCommandBase *pConCmd;
@@ -1238,27 +1242,17 @@ static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
} }
if (pIter->pLast == NULL) if (!pIter->IsValid())
{ {
return 0; return 0;
} }
#if SOURCE_ENGINE == SE_LEFT4DEAD pIter->Next();
ICvarIteratorInternal *cvarIter = pIter->pLast; if (!pIter->IsValid())
cvarIter->Next();
if (!cvarIter->IsValid())
{ {
return 0; return 0;
} }
pConCmd = cvarIter->Get(); pConCmd = pIter->Get();
#else
pConCmd = pIter->pLast->GetNext();
if (pConCmd == NULL)
{
return 0;
}
pIter->pLast = pConCmd;
#endif
pContext->LocalToPhysAddr(params[4], &pIsCmd); pContext->LocalToPhysAddr(params[4], &pIsCmd);
pContext->LocalToPhysAddr(params[5], &pFlags); pContext->LocalToPhysAddr(params[5], &pFlags);
@@ -1294,7 +1288,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
char data[256]; char data[256];
bf_write buffer(data, sizeof(data)); bf_write buffer(data, sizeof(data));
buffer.WriteUBitLong(NET_SETCONVAR, 5); buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
buffer.WriteByte(1); buffer.WriteByte(1);
buffer.WriteString(pConVar->GetName()); buffer.WriteString(pConVar->GetName());
buffer.WriteString(value); buffer.WriteString(value);
@@ -1317,6 +1311,11 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
} }
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1])); INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
if (netchan == NULL)
{
return 0;
}
netchan->SendData(buffer); netchan->SendData(buffer);
return 1; return 1;
@@ -1332,6 +1331,46 @@ static cell_t RemoveServerTag(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
static cell_t AddCommandListener(IPluginContext *pContext, const cell_t *params)
{
char *name;
IPluginFunction *pFunction;
pContext->LocalToString(params[2], &name);
if (strcasecmp(name, "sm") == 0)
{
g_Logger.LogError("Request to register \"sm\" command denied.");
return 0;
}
pFunction = pContext->GetFunctionById(params[1]);
if (!pFunction)
return pContext->ThrowNativeError("Invalid function id (%X)", params[1]);
if (!g_ConsoleDetours.AddListener(pFunction, name[0] == '\0' ? NULL : name))
return pContext->ThrowNativeError("This game does not support command listeners");
return 1;
}
static cell_t RemoveCommandListener(IPluginContext *pContext, const cell_t *params)
{
char *name;
IPluginFunction *pFunction;
pContext->LocalToString(params[2], &name);
pFunction = pContext->GetFunctionById(params[1]);
if (!pFunction)
return pContext->ThrowNativeError("Invalid function id (%X)", params[1]);
if (!g_ConsoleDetours.RemoveListener(pFunction, name[0] == '\0' ? NULL : name))
return pContext->ThrowNativeError("No matching callback was registered");
return 1;
}
REGISTER_NATIVES(consoleNatives) REGISTER_NATIVES(consoleNatives)
{ {
{"CreateConVar", sm_CreateConVar}, {"CreateConVar", sm_CreateConVar},
@@ -1353,6 +1392,7 @@ REGISTER_NATIVES(consoleNatives)
{"GetConVarBounds", sm_GetConVarBounds}, {"GetConVarBounds", sm_GetConVarBounds},
{"SetConVarBounds", sm_SetConVarBounds}, {"SetConVarBounds", sm_SetConVarBounds},
{"QueryClientConVar", sm_QueryClientConVar}, {"QueryClientConVar", sm_QueryClientConVar},
{"GetConVarDefault", GetConVarDefault},
{"RegServerCmd", sm_RegServerCmd}, {"RegServerCmd", sm_RegServerCmd},
{"RegConsoleCmd", sm_RegConsoleCmd}, {"RegConsoleCmd", sm_RegConsoleCmd},
{"GetCmdArgString", sm_GetCmdArgString}, {"GetCmdArgString", sm_GetCmdArgString},
@@ -1381,5 +1421,7 @@ REGISTER_NATIVES(consoleNatives)
{"SendConVarValue", SendConVarValue}, {"SendConVarValue", SendConVarValue},
{"AddServerTag", AddServerTag}, {"AddServerTag", AddServerTag},
{"RemoveServerTag", RemoveServerTag}, {"RemoveServerTag", RemoveServerTag},
{"AddCommandListener", AddCommandListener},
{"RemoveCommandListener", RemoveCommandListener},
{NULL, NULL} {NULL, NULL}
}; };
+45
View File
@@ -42,6 +42,7 @@
#include "ForwardSys.h" #include "ForwardSys.h"
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include <sm_trie_tpl.h>
#if defined PLATFORM_WINDOWS #if defined PLATFORM_WINDOWS
#include <windows.h> #include <windows.h>
@@ -491,6 +492,11 @@ static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params)
char *str; char *str;
pContext->LocalToString(params[1], &str); pContext->LocalToString(params[1], &str);
if (strcmp(str, "__CanTestFeatures__") == 0)
{
return 1;
}
if (g_PluginSys.LibraryExists(str)) if (g_PluginSys.LibraryExists(str))
{ {
return 1; return 1;
@@ -630,6 +636,43 @@ static cell_t VerifyCoreVersion(IPluginContext *pContext, const cell_t *params)
return 4; return 4;
} }
static cell_t GetFeatureStatus(IPluginContext *pContext, const cell_t *params)
{
FeatureType type = (FeatureType)params[1];
char *name;
pContext->LocalToString(params[2], &name);
return g_ShareSys.TestFeature(pContext->GetRuntime(),type, name);
}
static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
{
FeatureType type = (FeatureType)params[1];
char *name;
pContext->LocalToString(params[2], &name);
if (g_ShareSys.TestFeature(pContext->GetRuntime(),type, name) != FeatureStatus_Available)
{
char buffer[255];
char *msg = buffer;
char default_message[255];
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3);
if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0')
{
UTIL_Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name);
msg = default_message;
}
pPlugin->SetErrorState(Plugin_Error, "%s", msg);
return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", msg);
}
return 1;
}
REGISTER_NATIVES(coreNatives) REGISTER_NATIVES(coreNatives)
{ {
{"AutoExecConfig", AutoExecConfig}, {"AutoExecConfig", AutoExecConfig},
@@ -654,6 +697,8 @@ REGISTER_NATIVES(coreNatives)
{"GetExtensionFileStatus", GetExtensionFileStatus}, {"GetExtensionFileStatus", GetExtensionFileStatus},
{"FindPluginByNumber", FindPluginByNumber}, {"FindPluginByNumber", FindPluginByNumber},
{"VerifyCoreVersion", VerifyCoreVersion}, {"VerifyCoreVersion", VerifyCoreVersion},
{"GetFeatureStatus", GetFeatureStatus},
{"RequireFeature", RequireFeature},
{NULL, NULL}, {NULL, NULL},
}; };
+495 -182
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -348,6 +348,23 @@ static cell_t sm_SetEventString(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t sm_SetEventBroadcast(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
}
pInfo->bDontBroadcast = params[2] ? true : false;
return 1;
}
REGISTER_NATIVES(gameEventNatives) REGISTER_NATIVES(gameEventNatives)
{ {
{"HookEvent", sm_HookEvent}, {"HookEvent", sm_HookEvent},
@@ -365,5 +382,7 @@ REGISTER_NATIVES(gameEventNatives)
{"SetEventInt", sm_SetEventInt}, {"SetEventInt", sm_SetEventInt},
{"SetEventFloat", sm_SetEventFloat}, {"SetEventFloat", sm_SetEventFloat},
{"SetEventString", sm_SetEventString}, {"SetEventString", sm_SetEventString},
{"SetEventBroadcast", sm_SetEventBroadcast},
{NULL, NULL} {NULL, NULL}
}; };
+47 -16
View File
@@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@@ -73,7 +73,12 @@ static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params)
static cell_t GetEngineTime(IPluginContext *pContext, const cell_t *params) static cell_t GetEngineTime(IPluginContext *pContext, const cell_t *params)
{ {
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
float fTime = Plat_FloatTime();
#else
float fTime = engine->Time(); float fTime = engine->Time();
#endif
return sp_ftoc(fTime); return sp_ftoc(fTime);
} }
@@ -438,28 +443,31 @@ static cell_t smn_IsPlayerAlive(IPluginContext *pContext, const cell_t *params)
static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params) static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
{ {
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
int version = g_SMAPI->GetSourceEngineBuild(); int version = g_SMAPI->GetSourceEngineBuild();
if (version == SOURCE_ENGINE_ORIGINAL) switch (version)
{ {
case SOURCE_ENGINE_ORIGINAL:
return 10; return 10;
} case SOURCE_ENGINE_EPISODEONE:
else if (version == SOURCE_ENGINE_DARKMESSIAH)
{
return 15;
}
else if (version == SOURCE_ENGINE_EPISODEONE)
{
return 20; return 20;
}
else if (version == SOURCE_ENGINE_ORANGEBOX) # if defined METAMOD_PLAPI_VERSION
{ /* Newer games. */
case SOURCE_ENGINE_DARKMESSIAH:
return 15;
case SOURCE_ENGINE_ORANGEBOX:
return 30; return 30;
} case SOURCE_ENGINE_ORANGEBOXVALVE:
else if (version == SOURCE_ENGINE_LEFT4DEAD) return 35;
{ case SOURCE_ENGINE_LEFT4DEAD:
return 40; return 40;
case SOURCE_ENGINE_LEFT4DEAD2:
return 50;
case SOURCE_ENGINE_ALIENSWARM:
return 60;
# endif
} }
#else #else
if (g_HL2.IsOriginalEngine()) if (g_HL2.IsOriginalEngine())
@@ -475,6 +483,26 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
static cell_t IndexToReference(IPluginContext *pContext, const cell_t *params)
{
if (params[1] >= NUM_ENT_ENTRIES || params[1] < 0)
{
return pContext->ThrowNativeError("Invalid entity index %i", params[1]);
}
return g_HL2.IndexToReference(params[1]);
}
static cell_t ReferenceToIndex(IPluginContext *pContext, const cell_t *params)
{
return g_HL2.ReferenceToIndex(params[1]);
}
static cell_t ReferenceToBCompatRef(IPluginContext *pContext, const cell_t *params)
{
return g_HL2.ReferenceToBCompatRef(params[1]);
}
REGISTER_NATIVES(halflifeNatives) REGISTER_NATIVES(halflifeNatives)
{ {
{"CreateFakeClient", CreateFakeClient}, {"CreateFakeClient", CreateFakeClient},
@@ -505,5 +533,8 @@ REGISTER_NATIVES(halflifeNatives)
{"ShowVGUIPanel", ShowVGUIPanel}, {"ShowVGUIPanel", ShowVGUIPanel},
{"IsPlayerAlive", smn_IsPlayerAlive}, {"IsPlayerAlive", smn_IsPlayerAlive},
{"GuessSDKVersion", GuessSDKVersion}, {"GuessSDKVersion", GuessSDKVersion},
{"EntIndexToEntRef", IndexToReference},
{"EntRefToEntIndex", ReferenceToIndex},
{"MakeCompatEntRef", ReferenceToBCompatRef},
{NULL, NULL}, {NULL, NULL},
}; };
+43
View File
@@ -104,6 +104,46 @@ static cell_t sm_GetLanguageInfo(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *params)
{
CPlayer *player = g_Players.GetPlayerByIndex(params[1]);
if (!player || !player->IsInGame())
{
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) REGISTER_NATIVES(langNatives)
{ {
{"LoadTranslations", sm_LoadTranslations}, {"LoadTranslations", sm_LoadTranslations},
@@ -112,5 +152,8 @@ REGISTER_NATIVES(langNatives)
{"GetServerLanguage", sm_GetServerLanguage}, {"GetServerLanguage", sm_GetServerLanguage},
{"GetLanguageCount", sm_GetLanguageCount}, {"GetLanguageCount", sm_GetLanguageCount},
{"GetLanguageInfo", sm_GetLanguageInfo}, {"GetLanguageInfo", sm_GetLanguageInfo},
{"SetClientLanguage", sm_SetClientLanguage},
{"GetLanguageByCode", sm_GetLanguageByCode},
{"GetLanguageByName", sm_GetLanguageByName},
{NULL, NULL}, {NULL, NULL},
}; };
+37
View File
@@ -720,6 +720,10 @@ static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return 0;
}
return sp_ftoc(pInfo->GetTimeConnected()); return sp_ftoc(pInfo->GetTimeConnected());
} }
@@ -739,6 +743,10 @@ static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return 0;
}
return pInfo->GetDataRate(); return pInfo->GetDataRate();
} }
@@ -758,6 +766,10 @@ static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return 1;
}
return pInfo->IsTimingOut() ? 1 : 0; return pInfo->IsTimingOut() ? 1 : 0;
} }
@@ -782,6 +794,10 @@ static cell_t GetLatency(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return sp_ftoc(-1);
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
@@ -815,6 +831,10 @@ static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return sp_ftoc(-1);
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
@@ -848,6 +868,10 @@ static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return sp_ftoc(-1);
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
@@ -881,6 +905,10 @@ static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return sp_ftoc(-1);
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
@@ -914,6 +942,10 @@ static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params)
} }
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return 0;
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
@@ -948,6 +980,11 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
if (pInfo == NULL)
{
return 0;
}
if (params[2] == MAX_FLOWS) if (params[2] == MAX_FLOWS)
{ {
value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING); value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING);

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