Compare commits
126
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cb5a022b8 | ||
|
|
d715e22162 | ||
|
|
0ffe92c346 | ||
|
|
b01b855992 | ||
|
|
91ea38fa54 | ||
|
|
8c36966d89 | ||
|
|
299a17cd26 | ||
|
|
3edc824bc2 | ||
|
|
22ec5c2e71 | ||
|
|
c337bc512c | ||
|
|
42f01878f4 | ||
|
|
995a0545a9 | ||
|
|
59b64ff19f | ||
|
|
f1f4b3df44 | ||
|
|
af813cc71c | ||
|
|
65a98212a7 | ||
|
|
8ad1cb0b8c | ||
|
|
32f2680181 | ||
|
|
f7a8e4ceb1 | ||
|
|
415df6545b | ||
|
|
e216bf49d9 | ||
|
|
77737d319f | ||
|
|
13e620ec81 | ||
|
|
b383d8c89e | ||
|
|
227a604ab1 | ||
|
|
f153937038 | ||
|
|
3d1fa83197 | ||
|
|
0a4a60fe08 | ||
|
|
6c0325d7d8 | ||
|
|
55058ab0c7 | ||
|
|
1cf0b2c35b | ||
|
|
48bf766075 | ||
|
|
e04d7f6b0c | ||
|
|
505687f748 | ||
|
|
d2cfd39f80 | ||
|
|
a628f370e4 | ||
|
|
78567bda2f | ||
|
|
8cb946cf59 | ||
|
|
c3065f7535 | ||
|
|
d56da0c3da | ||
|
|
3e244fcab2 | ||
|
|
c5e7e1fa5d | ||
|
|
aadf4f137b | ||
|
|
eb6296b0c8 | ||
|
|
64e0403cd5 | ||
|
|
68eeff311b | ||
|
|
05fa9268a3 | ||
|
|
05044032da | ||
|
|
abf0a4f508 | ||
|
|
4a98a25b75 | ||
|
|
eec65697a7 | ||
|
|
64d2ad9679 | ||
|
|
58d6a6793f | ||
|
|
b2cc0869a5 | ||
|
|
950300dffe | ||
|
|
1eaa48f978 | ||
|
|
4fe1c93e68 | ||
|
|
6bdb12f4bb | ||
|
|
c5cb4834f4 | ||
|
|
0bd4474729 | ||
|
|
dabf9f3810 | ||
|
|
927e8b0ec9 | ||
|
|
f47fd11453 | ||
|
|
96f8590fda | ||
|
|
b7cc3b7670 | ||
|
|
7d524e4179 | ||
|
|
485e56906a | ||
|
|
611cf15433 | ||
|
|
443f5b16e3 | ||
|
|
a465569b22 | ||
|
|
cc207eae51 | ||
|
|
1a21832cbb | ||
|
|
00b81f343a | ||
|
|
b7ae818e7c | ||
|
|
75e673d6ff | ||
|
|
b7edc558b3 | ||
|
|
40046d8248 | ||
|
|
b51b34fbf4 | ||
|
|
e6f854b760 | ||
|
|
4d46aa34e9 | ||
|
|
d0182a01ac | ||
|
|
57d5a67a95 | ||
|
|
993b3f62e4 | ||
|
|
a82c86a7b6 | ||
|
|
bbb73091ed | ||
|
|
7e5e57cad1 | ||
|
|
7849f4df20 | ||
|
|
73b77549cc | ||
|
|
2341a8e756 | ||
|
|
73888b137d | ||
|
|
aff4431eea | ||
|
|
be8146364f | ||
|
|
b1b2da3cb8 | ||
|
|
f1c1d305d8 | ||
|
|
a2470215ed | ||
|
|
bfb49a3c1b | ||
|
|
61121914bc | ||
|
|
b75a4d07be | ||
|
|
e956248f29 | ||
|
|
c434cd646a | ||
|
|
0da38e0f04 | ||
|
|
c437c6e01e | ||
|
|
d0cab7b717 | ||
|
|
f58728c0a8 | ||
|
|
83682230c0 | ||
|
|
888a1432f2 | ||
|
|
a0833bfd10 | ||
|
|
2c74333d47 | ||
|
|
d52cf9bcc3 | ||
|
|
ba3ff06236 | ||
|
|
228029b20f | ||
|
|
6e542f51f0 | ||
|
|
54754f9e83 | ||
|
|
0b731c9bc0 | ||
|
|
37d72420e4 | ||
|
|
064f57e321 | ||
|
|
bcb9bc988f | ||
|
|
1f071f7c80 | ||
|
|
52fdc87325 | ||
|
|
aa5f1c4f03 | ||
|
|
adbd79633b | ||
|
|
1e1ebc981a | ||
|
|
44065ac939 | ||
|
|
3ecd914647 | ||
|
|
54b49dafbf | ||
|
|
23c2f9b54e |
@@ -1,15 +0,0 @@
|
|||||||
# Binaries
|
|
||||||
\.dll$
|
|
||||||
\.exe$
|
|
||||||
\.so$
|
|
||||||
|
|
||||||
# Files generated by Visual Studio
|
|
||||||
\.aps$
|
|
||||||
\.ncb$
|
|
||||||
\.suo$
|
|
||||||
\.user$
|
|
||||||
|
|
||||||
# Build directories
|
|
||||||
/CrazyDebug.*
|
|
||||||
/Debug.*
|
|
||||||
/Release.*
|
|
||||||
+33
-3
@@ -1,6 +1,36 @@
|
|||||||
|
We now use svn:keywords "Id" on all .c/.cpp/.h/.inc/.sp/ files.
|
||||||
|
Please make sure your client is configured properly.
|
||||||
|
|
||||||
CONFIGURE YOUR IDENTITY FOR MERCURIAL!
|
WINDOWS:
|
||||||
IF YOU ARE A DEVELOPER WITH PUSH ACCESS, DO IT NOW KPLZTHX.
|
- Open your Application Data directory.
|
||||||
|
Windows XP/2000: C:\Documents and Settings\<user>\Application Data
|
||||||
|
Windows Vista: C:\Users\<user>\AppData\Roaming
|
||||||
|
|
||||||
http://wiki.alliedmods.net/Mercurial_Tutorial#Identity
|
- Now go to the Subversion directory.
|
||||||
|
- Open the "config" file with a text editor.
|
||||||
|
|
||||||
|
LINUX:
|
||||||
|
- Open ~/.subversion/config with your favorite text editor.
|
||||||
|
|
||||||
|
Under [miscellany], uncomment this line:
|
||||||
|
# enable-auto-props = yes
|
||||||
|
|
||||||
|
Under [auto-props], add these lines:
|
||||||
|
*.c = svn:keywords=Id
|
||||||
|
*.cpp = svn:keywords=Id
|
||||||
|
*.h = svn:keywords=Id
|
||||||
|
*.inc = svn:keywords=Id
|
||||||
|
*.sp = svn:keywords=Id
|
||||||
|
|
||||||
|
|
||||||
|
If you find a file with one of the above extensions that does not have the svn:keywords property...
|
||||||
|
|
||||||
|
TORTOISE SVN:
|
||||||
|
- Right click on the file(s) that do not have the property.
|
||||||
|
- In the context menu that appears, select TortoiseSVN -> Properties.
|
||||||
|
- A properties window should appear. Click the Add button.
|
||||||
|
- Select "svn:keywords" from the "Property name" combo box and type "Id" in the "Property value" text area.
|
||||||
|
- Click OK on both windows and commit the change(s).
|
||||||
|
|
||||||
|
CLI SVN CLIENT:
|
||||||
|
- Execute the following command: svn propset svn:keywords Id <files>
|
||||||
|
|||||||
@@ -2,82 +2,6 @@ SourceMod Changelog
|
|||||||
|
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
SourceMod 1.1.0 [2008-12-28]
|
|
||||||
|
|
||||||
URL: http://wiki.alliedmods.net/SourceMod_1.1.0_Release_Notes
|
|
||||||
|
|
||||||
Major features:
|
|
||||||
* New map management plugins.
|
|
||||||
* New reserved slot type.
|
|
||||||
* GameData updates are retrieved remotely
|
|
||||||
* Client Preferences extension for per-client "cookies"
|
|
||||||
* New incremental and independent JIT
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
|
|
||||||
- Added new client preferences extension (API in clientprefs.inc, bug 1925).
|
|
||||||
- Added new gamedata auto-update functionality (bug 2602).
|
|
||||||
- Revamped and greatly expanded map management plugins and their functionality (bug 2201).
|
|
||||||
- Debug mode is now always on; as there is no longer a performance loss, there is no non-debug mode.
|
|
||||||
- The timeleft trigger can now handle mp_winlimit, mp_fraglimit, and mp_maxrounds (bug 2344).
|
|
||||||
- Translations can now be in separate files and placed in language-unique folders.
|
|
||||||
- The leading "STEAM_0:" or "STEAM_1:" in SteamIDs can now be omitted from admin files.
|
|
||||||
- Added sm_revote command so clients can participate in a vote that fell off their screen (bug 2156).
|
|
||||||
- Added Core API for creating stack structures (adt_stack.inc, bug 2441).
|
|
||||||
- Added API for extending mapchooser (mapchooser.inc, bug 2201).
|
|
||||||
- Added Core API for map transition control and history (nextmap.inc).
|
|
||||||
- Added TF2 forward for overriding how critical hits are calculated.
|
|
||||||
- Added SetClientInfo() native for modifying how a server sees a client's setinfo properties.
|
|
||||||
- Added CreateDirectory() native (bug 3253).
|
|
||||||
- Added "magic" MaxClients variable to replace slower GetMaxClients() call.
|
|
||||||
- Added support for three-letter language codes (bug 3526).
|
|
||||||
- Functions to control client versus client mic listening now work as described (bug 2498).
|
|
||||||
- Fixed SDKTools not being reloadable, and fixed a related bug in Handle type removal (bug 2753).
|
|
||||||
- Rewrote internal translation handling. Extensions now have access to an ITranslator API (bug 2535).
|
|
||||||
- Rewrote internal handling of dependencies (especially relating to native providers) (bug 2466).
|
|
||||||
- Added user config hooks to IGameConfigManager, for parsing user-defined sections.
|
|
||||||
- Revamped SourcePawn API. Removed and deprecated many structures and functions accidentally exposed publicly.
|
|
||||||
- Revamped SourcePawn structure, it is now separable from SourceMod for other projects.
|
|
||||||
- Renamed basefuncommands.phrases.txt to funcommands.phrases.txt (bug 2485).
|
|
||||||
- Renamed basefunvotes.phrases.txt to funvotes.phrases.txt (bug 2485).
|
|
||||||
- Added IDBDriver API call for extensions to handle IDBDriver dependencies properly.
|
|
||||||
- Usermessage natives now validate clients to prevent crashing.
|
|
||||||
- Fixed OnConfigsExecuted not working on listen servers.
|
|
||||||
- Fixed out-of-handle conditions in CreateTimer() causing crashes (bug 3381).
|
|
||||||
- Fixed accessing invalid Handles causing crashes (bug 3359).
|
|
||||||
- Fixed memory corruption with MySQL + FetchString (bug 3352).
|
|
||||||
- Fixed ReadFileString ignoring its fourth parameter (bug 3459).
|
|
||||||
- Fixed sm_sql_addadmin reading the immunity field as a password (bug 3395).
|
|
||||||
- Fixed ReadFile sign-extending instead of zero-extending (bug 3449).
|
|
||||||
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
SourceMod 1.0.4 [2008-09-14]
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
|
|
||||||
- Fixed amb1986: Format() with very long strings could crash if the input and output buffers overlapped.
|
|
||||||
- Fixed amb1938: The compiler ate too many characters in preprocessor macros.
|
|
||||||
- Fixed amb1935: Topmenu child names were not uncached when a category was deleted.
|
|
||||||
- Fixed amb1929: Banning via the console threw a runtime error.
|
|
||||||
- Fixed amb1918: Ban menu should compare userids, not client indexes
|
|
||||||
- Fixed amb1916: Threaded query delay is now 50ms instead of 500ms.
|
|
||||||
- Fixed amb1899: Duplicate maps in auto generated maplists.
|
|
||||||
- Fixed amb1891: Basechat didn't check for blank message in private says.
|
|
||||||
- Fixed amb1853: Ternary operators with string assignments could chop strings off.
|
|
||||||
- Fixed amb1815: Custom admin menu wasn't escaping input.
|
|
||||||
- Fixed amb1808: KickClient() is now delayed to prevent crashes, use KickClientEx for old functionality.
|
|
||||||
- Fixed amb1802: Possible crash when a client disconnected.
|
|
||||||
- Fixed amb1801: Improved bot detection, and fixed bots crashing if inside an OrangeBox server.cfg.
|
|
||||||
- Fixed amb1780: admin-sql-threaded had a debug spew turned on.
|
|
||||||
- Fixed amb1779: Crash in GetTeamName() on mods that don't support it.
|
|
||||||
- Fixed amb1763: Function call status is now cleared on a new function call.
|
|
||||||
- Fixed amb1749: Updated and improved DoD:S SDKTools coverage.
|
|
||||||
- Fixed team native crashes in SDKTools for mods like Insurgency.
|
|
||||||
- Fixed various file handle leaks.
|
|
||||||
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
SourceMod 1.0.3 [2008-06-21]
|
SourceMod 1.0.3 [2008-06-21]
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
"Commands"
|
"Commands"
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,35 +88,4 @@
|
|||||||
* "off" - Translate using default server's language
|
* "off" - Translate using default server's language
|
||||||
*/
|
*/
|
||||||
"AllowClLanguageVar" "On"
|
"AllowClLanguageVar" "On"
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or Disables SourceMod's automatic gamedata updating.
|
|
||||||
*
|
|
||||||
* The default value is "no". A value of "yes" will block the Auto Updater.
|
|
||||||
*/
|
|
||||||
"DisableAutoUpdate" "no"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If set to yes, a successful gamedata update will attempt to restart SourceMod.
|
|
||||||
* SourceMod is unloaded and reloaded, and the map is changed to the current map.
|
|
||||||
* Since gamedata updates occur when the server loads, impact should be minimal.
|
|
||||||
* But to be safe, this option is disabled by default.
|
|
||||||
*/
|
|
||||||
"ForceRestartAfterUpdate" "no"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the server to connect to for auotmatic gamedata updates.
|
|
||||||
*/
|
|
||||||
"AutoUpdateServer" "smupdate.alliedmods.net"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the port to connect to on the AutoUpdateServer server
|
|
||||||
*/
|
|
||||||
"AutoUpdatePort" "6500"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to show debug spew.
|
|
||||||
* Currently this will log details about the gamedata updating process.
|
|
||||||
*/
|
|
||||||
"DebugSpew" "no"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,4 @@
|
|||||||
"driver" "sqlite"
|
"driver" "sqlite"
|
||||||
"database" "sourcemod-local"
|
"database" "sourcemod-local"
|
||||||
}
|
}
|
||||||
|
|
||||||
"clientprefs"
|
|
||||||
{
|
|
||||||
"driver" "sqlite"
|
|
||||||
"host" "localhost"
|
|
||||||
"database" "clientprefs-sqlite"
|
|
||||||
"user" "root"
|
|
||||||
"pass" ""
|
|
||||||
//"timeout" "0"
|
|
||||||
//"port" "0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"Languages"
|
"Languages"
|
||||||
{
|
{
|
||||||
"en" "English"
|
"en" "English"
|
||||||
|
"es" "Español"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,4 @@
|
|||||||
{
|
{
|
||||||
"target" "default"
|
"target" "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For the "nominations" plugin */
|
|
||||||
"nominations"
|
|
||||||
{
|
|
||||||
"target" "default"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,14 @@
|
|||||||
* Available properties for plugins are:
|
* Available properties for plugins are:
|
||||||
* "pause" - Whether or not the plugin should load paused - "yes" or "no" (default)
|
* "pause" - Whether or not the plugin should load paused - "yes" or "no" (default)
|
||||||
* "lifetime" - Lifetime of the plugin. Options:
|
* "lifetime" - Lifetime of the plugin. Options:
|
||||||
* "mapsync" - Plugins should be reloaded on mapchange if changed (default)
|
* "mapsync" - Plugins should be reloaded on mapchange if changed (default)
|
||||||
* "global" - Plugin will never be unloaded or updated
|
* "global" - Plugin will never be unloaded or updated
|
||||||
* "blockload" - Plugin will always be blocked from loading. Implicit (automatic) loads
|
* "blockload" - Plugin will always be blocked from loading. Implicit (automatic) loads
|
||||||
* produce no error, but explicit (manual) loads will show an error message.
|
* produce no error, but explicit (manual) loads will show an error message.
|
||||||
* (Options are one of "yes" or "no")
|
* (Options are one of "yes" or "no")
|
||||||
*
|
*
|
||||||
* You can also have an "Options" section declaring options to pass onto the JIT:
|
* You can also have an "Options" section declaring options to pass onto the JIT:
|
||||||
|
* "debug" - Whether or not to load the plugin in debug mode
|
||||||
* "profile" - Bit flags for profiling level. Add flags together to reach a value.
|
* "profile" - Bit flags for profiling level. Add flags together to reach a value.
|
||||||
* WARNING: Profiler is _ALPHA_ software! Use it at your own risk for
|
* WARNING: Profiler is _ALPHA_ software! Use it at your own risk for
|
||||||
* development cycles only (not production setups).
|
* development cycles only (not production setups).
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
|
|
||||||
"Options"
|
"Options"
|
||||||
{
|
{
|
||||||
|
"debug" "no"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
CREATE TABLE sm_cookies
|
|
||||||
(
|
|
||||||
id INTEGER unsigned NOT NULL auto_increment,
|
|
||||||
name varchar(30) NOT NULL UNIQUE,
|
|
||||||
description varchar(255),
|
|
||||||
access INTEGER,
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE sm_cookie_cache
|
|
||||||
(
|
|
||||||
player varchar(65) NOT NULL,
|
|
||||||
cookie_id int(10) NOT NULL,
|
|
||||||
value varchar(100),
|
|
||||||
timestamp int NOT NULL,
|
|
||||||
PRIMARY KEY (player, cookie_id)
|
|
||||||
);
|
|
||||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
CREATE TABLE sm_cookies
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
name varchar(30) NOT NULL UNIQUE,
|
|
||||||
description varchar(255),
|
|
||||||
access INTEGER
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE sm_cookie_cache
|
|
||||||
(
|
|
||||||
player varchar(65) NOT NULL,
|
|
||||||
cookie_id int(10) NOT NULL,
|
|
||||||
value varchar(100),
|
|
||||||
timestamp int,
|
|
||||||
PRIMARY KEY (player, cookie_id)
|
|
||||||
);
|
|
||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+2
-12
@@ -162,6 +162,8 @@ private:
|
|||||||
|
|
||||||
c -= (unsigned)'a';
|
c -= (unsigned)'a';
|
||||||
|
|
||||||
|
assert(c >= 0 && c < 26);
|
||||||
|
|
||||||
if (!g_Admins.FindFlag(key, &g_FlagLetters[c]))
|
if (!g_Admins.FindFlag(key, &g_FlagLetters[c]))
|
||||||
{
|
{
|
||||||
ParseError(states, "Unrecognized admin level \"%s\"", key);
|
ParseError(states, "Unrecognized admin level \"%s\"", key);
|
||||||
@@ -1182,12 +1184,6 @@ bool AdminCache::BindAdminIdentity(AdminId id, const char *auth, const char *ide
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the id was a steam id strip off the STEAM_*: part */
|
|
||||||
if (strcmp(auth, "steam") == 0 && strncmp(ident, "STEAM_", 6) == 0)
|
|
||||||
{
|
|
||||||
ident += 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sm_trie_retrieve(pTable, ident, NULL))
|
if (sm_trie_retrieve(pTable, ident, NULL))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1210,12 +1206,6 @@ AdminId AdminCache::FindAdminByIdentity(const char *auth, const char *identity)
|
|||||||
return INVALID_ADMIN_ID;
|
return INVALID_ADMIN_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the id was a steam id strip off the STEAM_*: part */
|
|
||||||
if (strcmp(auth, "steam") == 0 && strncmp(identity, "STEAM_", 6) == 0)
|
|
||||||
{
|
|
||||||
identity += 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *object;
|
void *object;
|
||||||
if (!sm_trie_retrieve(pTable, identity, &object))
|
if (!sm_trie_retrieve(pTable, identity, &object))
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -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-2007 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
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "CDataPack.h"
|
#include "CDataPack.h"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+3
-13
@@ -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-2007 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
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern HandleType_t htCellArray;
|
extern HandleType_t htCellArray;
|
||||||
@@ -40,17 +40,14 @@ public:
|
|||||||
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~CellArray()
|
~CellArray()
|
||||||
{
|
{
|
||||||
free(m_Data);
|
free(m_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size() const
|
size_t size() const
|
||||||
{
|
{
|
||||||
return m_Size;
|
return m_Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell_t *push()
|
cell_t *push()
|
||||||
{
|
{
|
||||||
if (!GrowIfNeeded(1))
|
if (!GrowIfNeeded(1))
|
||||||
@@ -61,22 +58,18 @@ public:
|
|||||||
m_Size++;
|
m_Size++;
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell_t *at(size_t b) const
|
cell_t *at(size_t b) const
|
||||||
{
|
{
|
||||||
return &m_Data[b * m_BlockSize];
|
return &m_Data[b * m_BlockSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t blocksize() const
|
size_t blocksize() const
|
||||||
{
|
{
|
||||||
return m_BlockSize;
|
return m_BlockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
m_Size = 0;
|
m_Size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool swap(size_t item1, size_t item2)
|
bool swap(size_t item1, size_t item2)
|
||||||
{
|
{
|
||||||
/* Make sure there is extra space available */
|
/* Make sure there is extra space available */
|
||||||
@@ -97,7 +90,6 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(size_t index)
|
void remove(size_t index)
|
||||||
{
|
{
|
||||||
/* If we're at the end, take the easy way out */
|
/* If we're at the end, take the easy way out */
|
||||||
@@ -115,7 +107,6 @@ public:
|
|||||||
|
|
||||||
m_Size--;
|
m_Size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell_t *insert_at(size_t index)
|
cell_t *insert_at(size_t index)
|
||||||
{
|
{
|
||||||
/* Make sure it'll fit */
|
/* Make sure it'll fit */
|
||||||
@@ -133,7 +124,6 @@ public:
|
|||||||
|
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool resize(size_t count)
|
bool resize(size_t count)
|
||||||
{
|
{
|
||||||
if (count <= m_Size)
|
if (count <= m_Size)
|
||||||
@@ -142,7 +132,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GrowIfNeeded(count - m_Size))
|
if(!GrowIfNeeded(count - m_Size))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+13
-8
@@ -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-2007 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
|
||||||
@@ -57,6 +57,7 @@ extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegat
|
|||||||
|
|
||||||
ChatTriggers g_ChatTriggers;
|
ChatTriggers g_ChatTriggers;
|
||||||
bool g_bSupressSilentFails = false;
|
bool g_bSupressSilentFails = false;
|
||||||
|
CPhraseFile *g_pFloodPhrases = NULL;
|
||||||
|
|
||||||
ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false),
|
ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false),
|
||||||
m_bTriggerWasSilent(false), m_ReplyTo(SM_REPLY_CONSOLE)
|
m_bTriggerWasSilent(false), m_ReplyTo(SM_REPLY_CONSOLE)
|
||||||
@@ -113,7 +114,10 @@ void ChatTriggers::OnSourceModAllInitialized()
|
|||||||
|
|
||||||
void ChatTriggers::OnSourceModAllInitialized_Post()
|
void ChatTriggers::OnSourceModAllInitialized_Post()
|
||||||
{
|
{
|
||||||
g_pCorePhrases->AddPhraseFile("antiflood.phrases");
|
unsigned int file_id;
|
||||||
|
|
||||||
|
file_id = g_Translator.FindOrAddPhraseFile("antiflood.phrases.txt");
|
||||||
|
g_pFloodPhrases = g_Translator.GetFileByIndex(file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatTriggers::OnSourceModGameInitialized()
|
void ChatTriggers::OnSourceModGameInitialized()
|
||||||
@@ -212,14 +216,15 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
|
||||||
if (!CoreTranslate(
|
/* :TODO: log an error? */
|
||||||
buffer,
|
if (g_Translator.CoreTransEx(g_pFloodPhrases,
|
||||||
|
client,
|
||||||
|
buffer,
|
||||||
sizeof(buffer),
|
sizeof(buffer),
|
||||||
"%T",
|
|
||||||
2,
|
|
||||||
NULL,
|
|
||||||
"Flooding the server",
|
"Flooding the server",
|
||||||
&client))
|
NULL,
|
||||||
|
NULL)
|
||||||
|
!= Trans_Okay)
|
||||||
{
|
{
|
||||||
UTIL_Format(buffer, sizeof(buffer), "You are flooding the server!");
|
UTIL_Format(buffer, sizeof(buffer), "You are flooding the server!");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+3
-27
@@ -296,32 +296,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
|
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
|
||||||
{
|
{
|
||||||
/* Unfortunately, we now have to do a slow lookup because Valve made client commands
|
return;
|
||||||
* case-insensitive. We can't even use our sortedness.
|
|
||||||
*/
|
|
||||||
if (client == 0 && !engine->IsDedicatedServer())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ConCmdInfo *>::iterator iter;
|
|
||||||
|
|
||||||
pInfo = NULL;
|
|
||||||
iter = m_CmdList.begin();
|
|
||||||
while (iter != m_CmdList.end())
|
|
||||||
{
|
|
||||||
if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
|
|
||||||
{
|
|
||||||
pInfo = (*iter);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pInfo == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
@@ -519,7 +494,8 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
|
|||||||
|
|
||||||
/* If we got here, the command failed... */
|
/* If we got here, the command failed... */
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
if (!CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
|
if (g_Translator.CoreTrans(client, buffer, sizeof(buffer), "No Access", NULL, NULL)
|
||||||
|
!= Trans_Okay)
|
||||||
{
|
{
|
||||||
UTIL_Format(buffer, sizeof(buffer), "You do not have access to this command");
|
UTIL_Format(buffer, sizeof(buffer), "You do not have access to this command");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+10
-26
@@ -40,11 +40,10 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
#include "ForwardSys.h"
|
#include "ForwardSys.h"
|
||||||
#include "frame_hooks.h"
|
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
|
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
|
||||||
#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
|
#elif defined PLATFORM_LINUX
|
||||||
ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, "SourceMod core configuration file");
|
ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, "SourceMod core configuration file");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -103,11 +102,9 @@ void CheckAndFinalizeConfigs()
|
|||||||
if ((g_bServerExecd || g_ServerCfgFile == NULL)
|
if ((g_bServerExecd || g_ServerCfgFile == NULL)
|
||||||
&& g_bGotServerStart)
|
&& g_bGotServerStart)
|
||||||
{
|
{
|
||||||
#if defined ORANGEBOX_BUILD
|
/* Order is important here. We need to buffer things before we send the command out. */
|
||||||
g_PendingInternalPush = true;
|
g_pOnAutoConfigsBuffered->Execute(NULL);
|
||||||
#else
|
engine->ServerCommand("sm internal 1\n");
|
||||||
SM_InternalCmdTrigger();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,15 +137,7 @@ void CoreConfig::OnSourceModLevelChange(const char *mapName)
|
|||||||
|
|
||||||
if (!already_checked)
|
if (!already_checked)
|
||||||
{
|
{
|
||||||
if (engine->IsDedicatedServer())
|
g_ServerCfgFile = icvar->FindVar("servercfgfile");
|
||||||
{
|
|
||||||
g_ServerCfgFile = icvar->FindVar("servercfgfile");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_ServerCfgFile = icvar->FindVar("lservercfgfile");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ServerCfgFile != NULL)
|
if (g_ServerCfgFile != NULL)
|
||||||
{
|
{
|
||||||
ConCommandBase *pBase = icvar->GetCommands();
|
ConCommandBase *pBase = icvar->GetCommands();
|
||||||
@@ -275,7 +264,7 @@ inline bool IsPathSepChar(char c)
|
|||||||
{
|
{
|
||||||
#if defined PLATFORM_WINDOWS
|
#if defined PLATFORM_WINDOWS
|
||||||
return (c == '\\' || c == '/');
|
return (c == '\\' || c == '/');
|
||||||
#elif defined PLATFORM_LINUX || defined PLATFORM_POSIX
|
#elif defined PLATFORM_LINUX
|
||||||
return (c == '/');
|
return (c == '/');
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -513,6 +502,10 @@ void SM_ExecuteAllConfigs()
|
|||||||
}
|
}
|
||||||
iter->Release();
|
iter->Release();
|
||||||
|
|
||||||
|
#if defined ORANGEBOX_BUILD
|
||||||
|
engine->ServerExecute();
|
||||||
|
#endif
|
||||||
|
|
||||||
g_bGotServerStart = true;
|
g_bGotServerStart = true;
|
||||||
CheckAndFinalizeConfigs();
|
CheckAndFinalizeConfigs();
|
||||||
}
|
}
|
||||||
@@ -529,12 +522,3 @@ void SM_ConfigsExecuted_Global()
|
|||||||
g_pOnServerCfg->Execute(NULL);
|
g_pOnServerCfg->Execute(NULL);
|
||||||
g_pOnConfigsExecuted->Execute(NULL);
|
g_pOnConfigsExecuted->Execute(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SM_InternalCmdTrigger()
|
|
||||||
{
|
|
||||||
/* Order is important here. We need to buffer things before we send the command out. */
|
|
||||||
g_pOnAutoConfigsBuffered->Execute(NULL);
|
|
||||||
engine->ServerCommand("sm internal 1\n");
|
|
||||||
g_PendingInternalPush = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -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-2007 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
|
||||||
@@ -68,7 +68,6 @@ extern void SM_ExecuteAllConfigs();
|
|||||||
extern void SM_ExecuteForPlugin(IPluginContext *ctx);
|
extern void SM_ExecuteForPlugin(IPluginContext *ctx);
|
||||||
extern void SM_ConfigsExecuted_Global();
|
extern void SM_ConfigsExecuted_Global();
|
||||||
extern void SM_ConfigsExecuted_Plugin(unsigned int serial);
|
extern void SM_ConfigsExecuted_Plugin(unsigned int serial);
|
||||||
extern void SM_InternalCmdTrigger();
|
|
||||||
|
|
||||||
extern CoreConfig g_CoreConfig;
|
extern CoreConfig g_CoreConfig;
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -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-2007 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
|
||||||
@@ -717,9 +717,3 @@ const char *DBManager::GetDefaultDriverName()
|
|||||||
{
|
{
|
||||||
return m_DefDriver.c_str();
|
return m_DefDriver.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBManager::AddDependency(IExtension *myself, IDBDriver *driver)
|
|
||||||
{
|
|
||||||
g_Extensions.AddRawDependency(myself, driver->GetIdentity(), driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -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-2007 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
|
||||||
@@ -92,7 +92,6 @@ public: //IDBManager
|
|||||||
Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken);
|
Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken);
|
||||||
HandleError ReadHandle(Handle_t hndl, DBHandleType type, void **ptr);
|
HandleError ReadHandle(Handle_t hndl, DBHandleType type, void **ptr);
|
||||||
HandleError ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token);
|
HandleError ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token);
|
||||||
void AddDependency(IExtension *myself, IDBDriver *driver);
|
|
||||||
public: //ITextListener_SMC
|
public: //ITextListener_SMC
|
||||||
void ReadSMC_ParseStart();
|
void ReadSMC_ParseStart();
|
||||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
||||||
|
|||||||
+9
-16
@@ -36,23 +36,16 @@
|
|||||||
|
|
||||||
DebugReport g_DbgReporter;
|
DebugReport g_DbgReporter;
|
||||||
|
|
||||||
|
/* I'm really lazy. This should probably be exported to ISourcePawnEngine someday,
|
||||||
|
* but we need to make sure the JIT will deal with the version bump.
|
||||||
|
*/
|
||||||
|
extern const char *GetSourcePawnErrorMessage(int error);
|
||||||
|
|
||||||
void DebugReport::OnSourceModAllInitialized()
|
void DebugReport::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
g_pSourcePawn->SetDebugListener(this);
|
g_pSourcePawn->SetDebugListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugReport::OnDebugSpew(const char *msg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char buffer[512];
|
|
||||||
|
|
||||||
va_start(ap, msg);
|
|
||||||
UTIL_FormatArgs(buffer, sizeof(buffer), msg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
g_Logger.LogMessage("[SM] %s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...)
|
void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -63,7 +56,7 @@ void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, c
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
|
const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
|
||||||
const char *error = g_pSourcePawn2->GetErrorString(err);
|
const char *error = GetSourcePawnErrorMessage(err);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
@@ -80,7 +73,7 @@ void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, c
|
|||||||
{
|
{
|
||||||
func_idx >>= 1;
|
func_idx >>= 1;
|
||||||
sp_public_t *function;
|
sp_public_t *function;
|
||||||
if (ctx->GetRuntime()->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE)
|
if (ctx->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name);
|
g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name);
|
||||||
}
|
}
|
||||||
@@ -98,7 +91,7 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
const char *plname = g_PluginSys.FindPluginByContext(pContext->GetContext())->GetFilename();
|
const char *plname = g_PluginSys.FindPluginByContext(pContext->GetContext())->GetFilename();
|
||||||
const char *error = g_pSourcePawn2->GetErrorString(err);
|
const char *error = GetSourcePawnErrorMessage(err);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
@@ -110,7 +103,7 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr
|
|||||||
g_Logger.LogError("[SM] %s", buffer);
|
g_Logger.LogError("[SM] %s", buffer);
|
||||||
|
|
||||||
IPluginDebugInfo *pDebug;
|
IPluginDebugInfo *pDebug;
|
||||||
if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL)
|
if ((pDebug = pContext->GetDebugInfo()) == NULL)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname);
|
g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname);
|
||||||
g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
|
g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
|
||||||
|
|||||||
@@ -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-2007 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,6 @@ public: // SMGlobalClass
|
|||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
public: // IDebugListener
|
public: // IDebugListener
|
||||||
void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error);
|
void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error);
|
||||||
void OnDebugSpew(const char *msg, ...);
|
|
||||||
public:
|
|
||||||
void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...);
|
void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...);
|
||||||
void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...);
|
void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...);
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-82
@@ -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-2007 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,7 +42,6 @@
|
|||||||
#include "LibrarySys.h"
|
#include "LibrarySys.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
#include "sm_crc32.h"
|
#include "sm_crc32.h"
|
||||||
#include "GameDataFetcher.h"
|
|
||||||
|
|
||||||
#if defined PLATFORM_LINUX
|
#if defined PLATFORM_LINUX
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
@@ -65,7 +64,6 @@ char g_GameName[256] = {'$', '\0'};
|
|||||||
#define PSTATE_GAMEDEFS_SIGNATURES_SIG 8
|
#define PSTATE_GAMEDEFS_SIGNATURES_SIG 8
|
||||||
#define PSTATE_GAMEDEFS_CRC 9
|
#define PSTATE_GAMEDEFS_CRC 9
|
||||||
#define PSTATE_GAMEDEFS_CRC_BINARY 10
|
#define PSTATE_GAMEDEFS_CRC_BINARY 10
|
||||||
#define PSTATE_GAMEDEFS_CUSTOM 11
|
|
||||||
|
|
||||||
#if defined PLATFORM_WINDOWS
|
#if defined PLATFORM_WINDOWS
|
||||||
#define PLATFORM_NAME "windows"
|
#define PLATFORM_NAME "windows"
|
||||||
@@ -73,9 +71,6 @@ char g_GameName[256] = {'$', '\0'};
|
|||||||
#elif defined PLATFORM_LINUX
|
#elif defined PLATFORM_LINUX
|
||||||
#define PLATFORM_NAME "linux"
|
#define PLATFORM_NAME "linux"
|
||||||
#define PLATFORM_SERVER_BINARY "server_i486.so"
|
#define PLATFORM_SERVER_BINARY "server_i486.so"
|
||||||
#elif defined PLATFORM_APPLE
|
|
||||||
#define PLATFORM_NAME "undef"
|
|
||||||
#define PLATFORM_SERVER_BINARY "undef.dylib"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TempSigInfo
|
struct TempSigInfo
|
||||||
@@ -100,9 +95,6 @@ CGameConfig::CGameConfig(const char *file)
|
|||||||
m_pSigs = sm_trie_create();
|
m_pSigs = sm_trie_create();
|
||||||
m_pStrings = new BaseStringTable(512);
|
m_pStrings = new BaseStringTable(512);
|
||||||
m_RefCount = 0;
|
m_RefCount = 0;
|
||||||
|
|
||||||
m_CustomLevel = 0;
|
|
||||||
m_CustomHandler = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameConfig::~CGameConfig()
|
CGameConfig::~CGameConfig()
|
||||||
@@ -179,17 +171,6 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ITextListener_SMC **pListen = g_GameConfigs.m_customHandlers.retrieve(name);
|
|
||||||
|
|
||||||
if (pListen != NULL)
|
|
||||||
{
|
|
||||||
m_CustomLevel = 0;
|
|
||||||
m_ParseState = PSTATE_GAMEDEFS_CUSTOM;
|
|
||||||
m_CustomHandler = *pListen;
|
|
||||||
m_CustomHandler->ReadSMC_ParseStart();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_IgnoreLevel++;
|
m_IgnoreLevel++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -239,7 +220,6 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
s_ServerBinCRC = UTIL_CRC32(buffer, size);
|
s_ServerBinCRC = UTIL_CRC32(buffer, size);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
s_ServerBinCRC_Ok = true;
|
s_ServerBinCRC_Ok = true;
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error[0] != '\0')
|
if (error[0] != '\0')
|
||||||
@@ -252,12 +232,6 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSTATE_GAMEDEFS_CUSTOM:
|
|
||||||
{
|
|
||||||
m_CustomLevel++;
|
|
||||||
return m_CustomHandler->ReadSMC_NewSection(states, name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* No sub-sections allowed:
|
/* No sub-sections allowed:
|
||||||
case PSTATE_GAMEDEFS_OFFSETS_OFFSET:
|
case PSTATE_GAMEDEFS_OFFSETS_OFFSET:
|
||||||
case PSTATE_GAMEDEFS_KEYS:
|
case PSTATE_GAMEDEFS_KEYS:
|
||||||
@@ -325,8 +299,6 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
bShouldBeReadingDefault = true;
|
bShouldBeReadingDefault = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM) {
|
|
||||||
return m_CustomHandler->ReadSMC_KeyValue(states, key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SMCResult_Continue;
|
return SMCResult_Continue;
|
||||||
@@ -340,13 +312,6 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
|
|||||||
return SMCResult_Continue;
|
return SMCResult_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CustomLevel)
|
|
||||||
{
|
|
||||||
m_CustomLevel--;
|
|
||||||
m_CustomHandler->ReadSMC_LeavingSection(states);
|
|
||||||
return SMCResult_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (m_ParseState)
|
switch (m_ParseState)
|
||||||
{
|
{
|
||||||
case PSTATE_GAMES:
|
case PSTATE_GAMES:
|
||||||
@@ -359,12 +324,6 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
|
|||||||
m_ParseState = PSTATE_GAMES;
|
m_ParseState = PSTATE_GAMES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSTATE_GAMEDEFS_CUSTOM:
|
|
||||||
{
|
|
||||||
m_ParseState = PSTATE_GAMEDEFS;
|
|
||||||
m_CustomHandler->ReadSMC_ParseEnd(false, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PSTATE_GAMEDEFS_KEYS:
|
case PSTATE_GAMEDEFS_KEYS:
|
||||||
case PSTATE_GAMEDEFS_OFFSETS:
|
case PSTATE_GAMEDEFS_OFFSETS:
|
||||||
{
|
{
|
||||||
@@ -563,15 +522,6 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
|
|||||||
state.line,
|
state.line,
|
||||||
state.col,
|
state.col,
|
||||||
msg ? msg : "Unknown error");
|
msg ? msg : "Unknown error");
|
||||||
|
|
||||||
if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM)
|
|
||||||
{
|
|
||||||
//error occurred while parsing a custom section
|
|
||||||
m_CustomHandler->ReadSMC_ParseEnd(true, true);
|
|
||||||
m_CustomHandler = NULL;
|
|
||||||
m_CustomLevel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,13 +630,6 @@ void GameConfigManager::OnSourceModAllShutdown()
|
|||||||
|
|
||||||
bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pConfig, char *error, size_t maxlength)
|
bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pConfig, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
/* A crash was detected during last load - We block the gamedata loading so it hopefully won't happen again */
|
|
||||||
if (g_blockGameDataLoad)
|
|
||||||
{
|
|
||||||
UTIL_Format(error, maxlength, "GameData loaded blocked due to detected crash");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGameConfig *pConfig;
|
CGameConfig *pConfig;
|
||||||
|
|
||||||
if (sm_trie_retrieve(m_pLookup, file, (void **)&pConfig))
|
if (sm_trie_retrieve(m_pLookup, file, (void **)&pConfig))
|
||||||
@@ -741,27 +684,3 @@ IGameConfig *GameConfigManager::ReadHandle(Handle_t hndl, IdentityToken_t *ident
|
|||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameConfigManager::AddUserConfigHook( const char *sectionname, ITextListener_SMC *listener )
|
|
||||||
{
|
|
||||||
m_customHandlers.insert(sectionname, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameConfigManager::RemoveUserConfigHook( const char *sectionname, ITextListener_SMC *listener )
|
|
||||||
{
|
|
||||||
ITextListener_SMC **pListener = m_customHandlers.retrieve(sectionname);
|
|
||||||
|
|
||||||
if (pListener == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*pListener != listener)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_customHandlers.remove(sectionname);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-10
@@ -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-2007 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
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "sm_trie.h"
|
#include "sm_trie.h"
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
#include "sm_trie_tpl.h"
|
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
@@ -83,10 +82,6 @@ private:
|
|||||||
char m_offset[64];
|
char m_offset[64];
|
||||||
char m_Game[256];
|
char m_Game[256];
|
||||||
bool bShouldBeReadingDefault;
|
bool bShouldBeReadingDefault;
|
||||||
|
|
||||||
/* Custom Sections */
|
|
||||||
unsigned int m_CustomLevel;
|
|
||||||
ITextListener_SMC *m_CustomHandler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameConfigManager :
|
class GameConfigManager :
|
||||||
@@ -102,8 +97,6 @@ public: //IGameConfigManager
|
|||||||
IGameConfig *ReadHandle(Handle_t hndl,
|
IGameConfig *ReadHandle(Handle_t hndl,
|
||||||
IdentityToken_t *ident,
|
IdentityToken_t *ident,
|
||||||
HandleError *err);
|
HandleError *err);
|
||||||
void AddUserConfigHook(const char *sectionname, ITextListener_SMC *listener);
|
|
||||||
void RemoveUserConfigHook(const char *sectionname, ITextListener_SMC *listener);
|
|
||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
void OnSourceModStartup(bool late);
|
void OnSourceModStartup(bool late);
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
@@ -111,8 +104,6 @@ public: //SMGlobalClass
|
|||||||
private:
|
private:
|
||||||
List<CGameConfig *> m_cfgs;
|
List<CGameConfig *> m_cfgs;
|
||||||
Trie *m_pLookup;
|
Trie *m_pLookup;
|
||||||
public:
|
|
||||||
KTrie<ITextListener_SMC *> m_customHandlers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GameConfigManager g_GameConfigs;
|
extern GameConfigManager g_GameConfigs;
|
||||||
|
|||||||
@@ -1,909 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GameDataFetcher.h"
|
|
||||||
#include "bitbuf.h"
|
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
|
||||||
#include <winsock2.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#define INVALID_SOCKET -1
|
|
||||||
#define closesocket close
|
|
||||||
#define WSAGetLastError() errno
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sh_vector.h"
|
|
||||||
#include "sh_string.h"
|
|
||||||
#include "sm_version.h"
|
|
||||||
|
|
||||||
#ifdef ORANGEBOX_BUILD
|
|
||||||
#include "convar_sm_ob.h"
|
|
||||||
#else
|
|
||||||
#include "convar_sm.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sourcemm_api.h"
|
|
||||||
#include "time.h"
|
|
||||||
#include "TimerSys.h"
|
|
||||||
#include "compat_wrappers.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
#include "md5.h"
|
|
||||||
#include "frame_hooks.h"
|
|
||||||
|
|
||||||
#define QUERY_MAX_LENGTH 1024
|
|
||||||
|
|
||||||
static BuildMD5ableBuffer g_MD5Builder;
|
|
||||||
static FetcherThread g_FetchThread;
|
|
||||||
|
|
||||||
static FILE *logfile = NULL;
|
|
||||||
|
|
||||||
bool g_disableGameDataUpdate = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note on this. If we issue a reload and changelevel, my srcds.exe will emit
|
|
||||||
* Assertion Failed: !m_bServiceStarted
|
|
||||||
* on quit. This seems like a non-issue, because before we just terminated the
|
|
||||||
* server anyway. If anyone notices and files a bug, we can look into it further.
|
|
||||||
*/
|
|
||||||
bool g_restartAfterUpdate = false;
|
|
||||||
|
|
||||||
static bool was_level_started = false;
|
|
||||||
static int g_serverPort = 6500;
|
|
||||||
static char g_serverAddress[100] = "smupdate.alliedmods.net";
|
|
||||||
|
|
||||||
static void _ForceRestart(void *data)
|
|
||||||
{
|
|
||||||
char cmd[300];
|
|
||||||
g_Logger.LogMessage("Automatically restarting SourceMod after a successful gamedata update.");
|
|
||||||
UTIL_Format(cmd, sizeof(cmd), "meta unload %d\n", g_PLID);
|
|
||||||
engine->ServerCommand(cmd);
|
|
||||||
UTIL_Format(cmd, sizeof(cmd), "changelevel \"%s\"\n", STRING(gpGlobals->mapname));
|
|
||||||
engine->ServerCommand(cmd);
|
|
||||||
UTIL_Format(cmd, sizeof(cmd), "echo SourceMod restarted after gamedata update.\n");
|
|
||||||
engine->ServerCommand(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ForceRestart()
|
|
||||||
{
|
|
||||||
FrameAction action;
|
|
||||||
|
|
||||||
action.action = _ForceRestart;
|
|
||||||
action.data = NULL;
|
|
||||||
AddFrameAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FetcherThread::RunThread(IThreadHandle *pHandle)
|
|
||||||
{
|
|
||||||
char lock_path[PLATFORM_MAX_PATH];
|
|
||||||
g_SourceMod.BuildPath(Path_SM, lock_path, sizeof(lock_path), "data/temp");
|
|
||||||
g_LibSys.CreateFolder(lock_path);
|
|
||||||
|
|
||||||
g_SourceMod.BuildPath(Path_SM, lock_path, sizeof(lock_path), "data/temp/gamedata.lock");
|
|
||||||
|
|
||||||
char log_path[PLATFORM_MAX_PATH];
|
|
||||||
g_SourceMod.BuildPath(Path_SM, log_path, sizeof(log_path), "logs/gamedata");
|
|
||||||
|
|
||||||
g_LibSys.CreateFolder(log_path);
|
|
||||||
|
|
||||||
time_t t;
|
|
||||||
GetAdjustedTime(&t);
|
|
||||||
tm *curtime = localtime(&t);
|
|
||||||
|
|
||||||
g_SourceMod.BuildPath(Path_SM,
|
|
||||||
log_path,
|
|
||||||
sizeof(log_path),
|
|
||||||
"logs/gamedata/L%04d%02d%02d.log",
|
|
||||||
curtime->tm_year + 1900,
|
|
||||||
curtime->tm_mon + 1,
|
|
||||||
curtime->tm_mday);
|
|
||||||
|
|
||||||
logfile = fopen(log_path, "at");
|
|
||||||
|
|
||||||
if (!logfile)
|
|
||||||
{
|
|
||||||
/* :( */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create a blank lock file
|
|
||||||
FILE *fp = fopen(lock_path, "w");
|
|
||||||
if (fp)
|
|
||||||
{
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
char query[QUERY_MAX_LENGTH];
|
|
||||||
|
|
||||||
/* Check for updated gamedata files */
|
|
||||||
int len = BuildGameDataQuery(query, QUERY_MAX_LENGTH);
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
{
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Could not build gamedata query!");
|
|
||||||
fclose(logfile);
|
|
||||||
unlink(lock_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We check this late so we have the MD5 sums available. This may change in the future. */
|
|
||||||
if (g_disableGameDataUpdate)
|
|
||||||
{
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Skipping gamedata fetcher (DisableAutoUpdate set)");
|
|
||||||
fclose(logfile);
|
|
||||||
unlink(lock_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a new socket for this connection */
|
|
||||||
int socketDescriptor = ConnectSocket();
|
|
||||||
|
|
||||||
if (socketDescriptor == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
fclose(logfile);
|
|
||||||
unlink(lock_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sent = SendData(socketDescriptor, query, len);
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Sent gamedata query");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
if (sent == 0)
|
|
||||||
{
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Failed to send gamedata query data to remote host");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
closesocket(socketDescriptor);
|
|
||||||
fclose(logfile);
|
|
||||||
unlink(lock_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessGameDataQuery(socketDescriptor);
|
|
||||||
|
|
||||||
/* And we're done! */
|
|
||||||
closesocket(socketDescriptor);
|
|
||||||
fclose(logfile);
|
|
||||||
unlink(lock_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FetcherThread::OnTerminate(IThreadHandle *pHandle, bool cancel)
|
|
||||||
{
|
|
||||||
g_blockGameDataLoad = false;
|
|
||||||
|
|
||||||
if (cancel)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wasSuccess)
|
|
||||||
{
|
|
||||||
HandleUpdateStatus(updateStatus, build);
|
|
||||||
|
|
||||||
if (needsRestart)
|
|
||||||
{
|
|
||||||
if (g_restartAfterUpdate)
|
|
||||||
{
|
|
||||||
if (was_level_started)
|
|
||||||
{
|
|
||||||
ForceRestart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_Logger.LogMessage("Your gamedata files have been updated, please restart your server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!g_disableGameDataUpdate)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("An error occurred in the gamedata fetcher, see your gamedata log files for more information.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int FetcherThread::BuildGameDataQuery(char *buffer, int maxlen)
|
|
||||||
{
|
|
||||||
char gamedata_path[PLATFORM_MAX_PATH];
|
|
||||||
g_SourceMod.BuildPath(Path_SM, gamedata_path, sizeof(gamedata_path), "gamedata");
|
|
||||||
|
|
||||||
IDirectory *dir = g_LibSys.OpenDirectory(gamedata_path);
|
|
||||||
|
|
||||||
if (dir == NULL)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bf_write Writer = bf_write("GameDataQuery", buffer, maxlen);
|
|
||||||
|
|
||||||
Writer.WriteByte('A'); //Generic Header char
|
|
||||||
Writer.WriteByte('G'); //G for gamedata query, or green, like my hat.
|
|
||||||
|
|
||||||
short build[4] = { SVN_FILE_VERSION };
|
|
||||||
|
|
||||||
Writer.WriteBytes(&build[0], 8);
|
|
||||||
|
|
||||||
Writer.WriteByte(0); // Initialize the file counter - Index 10
|
|
||||||
|
|
||||||
while (dir->MoreFiles())
|
|
||||||
{
|
|
||||||
if (dir->IsEntryFile())
|
|
||||||
{
|
|
||||||
const char *name = dir->GetEntryName();
|
|
||||||
size_t len = strlen(name);
|
|
||||||
if (len >= 4 && strcmp(&name[len-4], ".txt") == 0)
|
|
||||||
{
|
|
||||||
MD5 md5;
|
|
||||||
SMCError err;
|
|
||||||
SMCStates states;
|
|
||||||
unsigned char raw[16];
|
|
||||||
char file[PLATFORM_MAX_PATH];
|
|
||||||
|
|
||||||
g_LibSys.PathFormat(file, sizeof(file), "%s/%s", gamedata_path, name);
|
|
||||||
|
|
||||||
g_MD5Builder.checksum = &md5;
|
|
||||||
if ((err = g_TextParser.ParseFile_SMC(file, &g_MD5Builder, &states)) == SMCError_Okay)
|
|
||||||
{
|
|
||||||
md5.raw_digest(raw);
|
|
||||||
(uint8_t)buffer[10]++; //Increment the file counter
|
|
||||||
Writer.WriteBytes(raw, 16);
|
|
||||||
|
|
||||||
FileData *data = new FileData();
|
|
||||||
data->filename = new SourceHook::String(file);
|
|
||||||
md5.hex_digest(data->checksum);
|
|
||||||
filenames.push_back(data);
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Parsed file: %s as %s", file, data->checksum);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
const char *error = g_TextParser.GetSMCErrorString(err);
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Parsing of file %s failed: %s", file, error);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dir->NextEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Writer.GetNumBytesWritten();
|
|
||||||
}
|
|
||||||
|
|
||||||
int FetcherThread::ConnectSocket()
|
|
||||||
{
|
|
||||||
#if defined PLATFORM_WINDOWS
|
|
||||||
WSADATA wsaData;
|
|
||||||
WSAStartup(0x0101, &wsaData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct protoent *ptrp;
|
|
||||||
|
|
||||||
if ((ptrp = getprotobyname("tcp")) == NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Error: Failed to find TCP protocol");
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
int socketDescriptor = socket(AF_INET, SOCK_STREAM, ptrp->p_proto);
|
|
||||||
|
|
||||||
if (socketDescriptor == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
char error[255];
|
|
||||||
g_LibSys.GetPlatformErrorEx(WSAGetLastError(), error, sizeof(error));
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Error: Failed to create socket: %s", error);
|
|
||||||
closesocket(socketDescriptor);
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct hostent *he;
|
|
||||||
struct sockaddr_in local_addr;
|
|
||||||
|
|
||||||
local_addr.sin_family = AF_INET;
|
|
||||||
local_addr.sin_port = htons((u_short)g_serverPort);
|
|
||||||
|
|
||||||
he = gethostbyname(g_serverAddress);
|
|
||||||
|
|
||||||
if (!he)
|
|
||||||
{
|
|
||||||
if ((local_addr.sin_addr.s_addr = inet_addr(g_serverAddress)) == INADDR_NONE)
|
|
||||||
{
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Couldn't locate address: %s", g_serverAddress);
|
|
||||||
closesocket(socketDescriptor);
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(&local_addr.sin_addr, (struct in_addr *)he->h_addr, he->h_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connect(socketDescriptor, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0)
|
|
||||||
{
|
|
||||||
char error[255];
|
|
||||||
g_LibSys.GetPlatformErrorEx(WSAGetLastError(), error, sizeof(error));
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Couldn't connect to %s: %s", g_serverAddress, error);
|
|
||||||
closesocket(socketDescriptor);
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return socketDescriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FetcherThread::ProcessGameDataQuery(int socketDescriptor)
|
|
||||||
{
|
|
||||||
char buffer[50];
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Waiting for reply!");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
//Read in the header bytes
|
|
||||||
int returnLen = RecvData(socketDescriptor, buffer, 12);
|
|
||||||
|
|
||||||
|
|
||||||
if (returnLen == 0)
|
|
||||||
{
|
|
||||||
char error[255];
|
|
||||||
g_LibSys.GetPlatformErrorEx(WSAGetLastError(), error, sizeof(error));
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Did not receive reply: %s", error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Received Header!");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
bf_read Reader = bf_read("GameDataQuery", buffer, 12);
|
|
||||||
|
|
||||||
if (Reader.ReadByte() != 'A' || Reader.ReadByte() != 'G')
|
|
||||||
{
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Unknown Query Response");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStatus = (UpdateStatus)Reader.ReadByte();
|
|
||||||
|
|
||||||
build[0] = Reader.ReadShort();
|
|
||||||
build[1] = Reader.ReadShort();
|
|
||||||
build[2] = Reader.ReadShort();
|
|
||||||
build[3] = Reader.ReadShort();
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile,
|
|
||||||
"Update Status: %i - Latest %i.%i.%i.%i",
|
|
||||||
updateStatus,
|
|
||||||
build[0],
|
|
||||||
build[1],
|
|
||||||
build[2],
|
|
||||||
build[3]);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
int changedFiles = Reader.ReadByte();
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Files to download: %i", changedFiles);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
for (int i=0; i<changedFiles; i++)
|
|
||||||
{
|
|
||||||
//Read in the file index and byte count
|
|
||||||
returnLen = RecvData(socketDescriptor, buffer, 5);
|
|
||||||
|
|
||||||
if (returnLen == 0)
|
|
||||||
{
|
|
||||||
/* Timeout or fail? */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reader.StartReading(buffer, 5);
|
|
||||||
|
|
||||||
int index = Reader.ReadByte();
|
|
||||||
int tempLen = Reader.ReadUBitLong(32);
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "File index %i and length %i", index, tempLen);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
void *memPtr;
|
|
||||||
memtable->CreateMem(tempLen+1, &memPtr);
|
|
||||||
|
|
||||||
//Read the contents of our file into the memtable
|
|
||||||
returnLen = RecvData(socketDescriptor, (char *)memPtr, tempLen);
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Received %i bytes", returnLen);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
if (returnLen == 0)
|
|
||||||
{
|
|
||||||
/* Timeout or fail? */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((unsigned char *)memPtr)[tempLen] = '\0';
|
|
||||||
|
|
||||||
FileData *data = filenames.at(index);
|
|
||||||
const char *filename;
|
|
||||||
if (data != NULL)
|
|
||||||
{
|
|
||||||
filename = data->filename->c_str();
|
|
||||||
|
|
||||||
FILE *fp = fopen(filename, "w");
|
|
||||||
|
|
||||||
if (fp)
|
|
||||||
{
|
|
||||||
fprintf(fp, "%s", (const char *)memPtr);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Failed to open file \"%s\" for writing", filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filename = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
memtable->Reset();
|
|
||||||
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Updated file: %s", filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "File Downloads Completed!");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
needsRestart = false;
|
|
||||||
|
|
||||||
if (changedFiles > 0)
|
|
||||||
{
|
|
||||||
needsRestart = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Read changed file count
|
|
||||||
returnLen = RecvData(socketDescriptor, buffer, 1);
|
|
||||||
|
|
||||||
if (returnLen == 0)
|
|
||||||
{
|
|
||||||
char error[255];
|
|
||||||
g_LibSys.GetPlatformErrorEx(WSAGetLastError(), error, sizeof(error));
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Did not receive count reply: %s", error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reader.StartReading(buffer, 1);
|
|
||||||
|
|
||||||
changedFiles = Reader.ReadByte();
|
|
||||||
|
|
||||||
if (changedFiles < 1)
|
|
||||||
{
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "No unknown files. We're all done");
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *changedFileIndexes = new char[changedFiles];
|
|
||||||
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "%i files were unknown", changedFiles);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
|
|
||||||
returnLen = RecvData(socketDescriptor, changedFileIndexes, changedFiles);
|
|
||||||
|
|
||||||
if (returnLen == 0)
|
|
||||||
{
|
|
||||||
char error[255];
|
|
||||||
g_LibSys.GetPlatformErrorEx(WSAGetLastError(), error, sizeof(error));
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Did not receive list reply: %s", error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reader.StartReading(changedFileIndexes, changedFiles);
|
|
||||||
|
|
||||||
for (int i=0; i<changedFiles; i++)
|
|
||||||
{
|
|
||||||
int index = Reader.ReadByte();
|
|
||||||
char fileName[30];
|
|
||||||
|
|
||||||
FileData *data = filenames.at(index);
|
|
||||||
const char* pathname;
|
|
||||||
if (data != NULL)
|
|
||||||
{
|
|
||||||
pathname = data->filename->c_str();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pathname = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
g_LibSys.GetFileFromPath(fileName, sizeof(fileName), pathname);
|
|
||||||
IF_DEBUG_SPEW
|
|
||||||
g_Logger.LogToFileOnly(logfile, "Unknown File %i : %s", index, fileName);
|
|
||||||
ENDIF_DEBUG_SPEW
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] changedFileIndexes;
|
|
||||||
|
|
||||||
wasSuccess = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FetcherThread::RecvData(int socketDescriptor, char *buffer, int len)
|
|
||||||
{
|
|
||||||
fd_set fds;
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
/* Create a 10 Second Timeout */
|
|
||||||
tv.tv_sec = 10;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
int bytesReceivedTotal = 0;
|
|
||||||
|
|
||||||
while (bytesReceivedTotal < len)
|
|
||||||
{
|
|
||||||
/* Add our socket to a socket set */
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(socketDescriptor, &fds);
|
|
||||||
|
|
||||||
/* Wait max of 10 seconds for recv to become available */
|
|
||||||
select(socketDescriptor+1, &fds, NULL, NULL, &tv);
|
|
||||||
|
|
||||||
int bytesReceived = 0;
|
|
||||||
|
|
||||||
/* Is there a limit on how much we can receive? Some site said 1024 bytes, which will be well short of a file */
|
|
||||||
if (FD_ISSET(socketDescriptor, &fds))
|
|
||||||
{
|
|
||||||
bytesReceived = recv(socketDescriptor, buffer+bytesReceivedTotal, len-bytesReceivedTotal, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytesReceived == 0 || bytesReceived == -1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesReceivedTotal += bytesReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bytesReceivedTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FetcherThread::SendData(int socketDescriptor, char *buffer, int len)
|
|
||||||
{
|
|
||||||
fd_set fds;
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
tv.tv_sec = 10;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
int sentBytesTotal = 0;
|
|
||||||
|
|
||||||
while (sentBytesTotal < len)
|
|
||||||
{
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(socketDescriptor, &fds);
|
|
||||||
|
|
||||||
select(socketDescriptor+1, NULL, &fds, NULL, &tv);
|
|
||||||
|
|
||||||
int sentBytes = 0;
|
|
||||||
|
|
||||||
if (FD_ISSET(socketDescriptor, &fds))
|
|
||||||
{
|
|
||||||
sentBytes = send(socketDescriptor, buffer+sentBytesTotal, len-sentBytesTotal, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sentBytes == 0 || sentBytes == -1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sentBytesTotal += sentBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sentBytesTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FetcherThread::HandleUpdateStatus(UpdateStatus status, short version[4])
|
|
||||||
{
|
|
||||||
switch (status)
|
|
||||||
{
|
|
||||||
case Update_Unknown:
|
|
||||||
case Update_Current:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Update_NewBuild:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Update_MinorAvailable:
|
|
||||||
{
|
|
||||||
g_Logger.LogMessage("SourceMod Update: A new release of SourceMod is now available from sourcemod.net");
|
|
||||||
g_Logger.LogMessage("Current Version: %i.%i.%i Available: %i.%i.%i", version[0], version[1], version[2], version[0], version[1], version[2]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Update_MajorAvailable:
|
|
||||||
{
|
|
||||||
g_Logger.LogMessage("SourceMod Update: An major release of SourceMod is now available from sourcemod.net");
|
|
||||||
g_Logger.LogMessage("Current Version: %i.%i.%i Available: %i.%i.%i", version[0], version[1], version[2], version[0], version[1], version[2]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Update_CriticalAvailable:
|
|
||||||
{
|
|
||||||
g_Logger.LogError("SourceMod Update: A critical SourceMod release is available from sourcemod.net. It is strongly recommended that you update!");
|
|
||||||
g_Logger.LogMessage("Current Version: %i.%i.%i Available: %i.%i.%i", version[0], version[1], version[2], version[0], version[1], version[2]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool g_blockGameDataLoad = false;
|
|
||||||
static IThreadHandle *fetch_thread_hndl;
|
|
||||||
|
|
||||||
class InitFetch : public SMGlobalClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void OnSourceModAllInitialized_Post()
|
|
||||||
{
|
|
||||||
char lock_path[PLATFORM_MAX_PATH];
|
|
||||||
g_SourceMod.BuildPath(Path_SM, lock_path, sizeof(lock_path), "data/temp/gamedata.lock");
|
|
||||||
|
|
||||||
if (g_LibSys.IsPathFile(lock_path) && g_LibSys.PathExists(lock_path))
|
|
||||||
{
|
|
||||||
g_Logger.LogError("sourcemod/data/temp/gamedata.lock file detected. This is most likely due to a crash during GameData updating - Blocking GameData loading");
|
|
||||||
g_Logger.LogError("If this error persists delete the file manually");
|
|
||||||
g_blockGameDataLoad = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadParams fetchThreadParams = ThreadParams();
|
|
||||||
fetchThreadParams.prio = ThreadPrio_Low;
|
|
||||||
fetch_thread_hndl = g_pThreader->MakeThread(&g_FetchThread, &fetchThreadParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSourceModShutdown()
|
|
||||||
{
|
|
||||||
fetch_thread_hndl->WaitForThread();
|
|
||||||
fetch_thread_hndl->DestroyThis();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSourceModLevelActivated()
|
|
||||||
{
|
|
||||||
was_level_started = true;
|
|
||||||
|
|
||||||
if (g_restartAfterUpdate &&
|
|
||||||
g_FetchThread.wasSuccess &&
|
|
||||||
g_FetchThread.needsRestart)
|
|
||||||
{
|
|
||||||
ForceRestart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSourceModLevelEnd()
|
|
||||||
{
|
|
||||||
was_level_started = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigResult OnSourceModConfigChanged(const char *key,
|
|
||||||
const char *value,
|
|
||||||
ConfigSource source,
|
|
||||||
char *error,
|
|
||||||
size_t maxlength)
|
|
||||||
{
|
|
||||||
if (strcasecmp(key, "DisableAutoUpdate") == 0)
|
|
||||||
{
|
|
||||||
if (strcasecmp(value, "yes") == 0)
|
|
||||||
{
|
|
||||||
g_disableGameDataUpdate = true;
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
else if (strcasecmp(value, "no") == 0)
|
|
||||||
{
|
|
||||||
g_disableGameDataUpdate = false;
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConfigResult_Reject;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(key, "ForceRestartAfterUpdate") == 0)
|
|
||||||
{
|
|
||||||
if (strcasecmp(value, "yes") == 0)
|
|
||||||
{
|
|
||||||
g_restartAfterUpdate = true;
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
else if (strcasecmp(value, "no") == 0)
|
|
||||||
{
|
|
||||||
g_restartAfterUpdate = false;
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConfigResult_Reject;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(key, "AutoUpdateServer") == 0)
|
|
||||||
{
|
|
||||||
UTIL_Format(g_serverAddress, sizeof(g_serverAddress), "%s", value);
|
|
||||||
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(key, "AutoUpdatePort") == 0)
|
|
||||||
{
|
|
||||||
int port = atoi(value);
|
|
||||||
|
|
||||||
if (!port)
|
|
||||||
{
|
|
||||||
return ConfigResult_Reject;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_serverPort = port;
|
|
||||||
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConfigResult_Ignore;
|
|
||||||
}
|
|
||||||
} g_InitFetch;
|
|
||||||
|
|
||||||
BuildMD5ableBuffer::BuildMD5ableBuffer()
|
|
||||||
{
|
|
||||||
stringTable = new BaseStringTable(2048);
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildMD5ableBuffer::~BuildMD5ableBuffer()
|
|
||||||
{
|
|
||||||
delete stringTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildMD5ableBuffer::ReadSMC_ParseStart()
|
|
||||||
{
|
|
||||||
stringTable->Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
SMCResult BuildMD5ableBuffer::ReadSMC_KeyValue(const SMCStates *states,
|
|
||||||
const char *key,
|
|
||||||
const char *value)
|
|
||||||
{
|
|
||||||
stringTable->AddString(key);
|
|
||||||
stringTable->AddString(value);
|
|
||||||
|
|
||||||
return SMCResult_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMCResult BuildMD5ableBuffer::ReadSMC_NewSection(const SMCStates *states, const char *name)
|
|
||||||
{
|
|
||||||
stringTable->AddString(name);
|
|
||||||
|
|
||||||
return SMCResult_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildMD5ableBuffer::ReadSMC_ParseEnd(bool halted, bool failed)
|
|
||||||
{
|
|
||||||
if (halted || failed)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *data = stringTable->GetMemTable()->GetAddress(0);
|
|
||||||
|
|
||||||
if (data != NULL)
|
|
||||||
{
|
|
||||||
checksum->update((unsigned char *)data, stringTable->GetMemTable()->GetActualMemUsed());
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum->finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
CON_COMMAND(sm_gamedata_md5, "Checks the MD5 sum for a given gamedata file")
|
|
||||||
{
|
|
||||||
#if !defined ORANGEBOX_BUILD
|
|
||||||
CCommand args;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (args.ArgC() < 2)
|
|
||||||
{
|
|
||||||
g_SMAPI->ConPrint("Usage: sm_gamedata_md5 <file>\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *file = args.Arg(1);
|
|
||||||
if (!file || file[0] == '\0')
|
|
||||||
{
|
|
||||||
g_SMAPI->ConPrint("Usage: sm_gamedata_md5 <file>\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceHook::CVector<FileData *>::iterator iter = g_FetchThread.filenames.begin();
|
|
||||||
|
|
||||||
FileData *curData;
|
|
||||||
|
|
||||||
while (iter != g_FetchThread.filenames.end())
|
|
||||||
{
|
|
||||||
curData = (*iter);
|
|
||||||
|
|
||||||
char fileName[30];
|
|
||||||
|
|
||||||
g_LibSys.GetFileFromPath(fileName, sizeof(fileName), curData->filename->c_str());
|
|
||||||
|
|
||||||
if (strcmpi(fileName, file) == 0)
|
|
||||||
{
|
|
||||||
g_SMAPI->ConPrintf("MD5 Sum: %s\n", curData->checksum);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_SMAPI->ConPrint("File not found!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
FetcherThread::~FetcherThread()
|
|
||||||
{
|
|
||||||
SourceHook::CVector<FileData *>::iterator iter = filenames.begin();
|
|
||||||
|
|
||||||
FileData *curData;
|
|
||||||
|
|
||||||
while (iter != filenames.end())
|
|
||||||
{
|
|
||||||
curData = (*iter);
|
|
||||||
delete curData->filename;
|
|
||||||
delete curData;
|
|
||||||
iter = filenames.erase(iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FetcherThread::FetcherThread()
|
|
||||||
{
|
|
||||||
memtable = new BaseMemTable(4096);
|
|
||||||
wasSuccess = false;
|
|
||||||
needsRestart = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
|
||||||
#define _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
|
||||||
|
|
||||||
#include "sourcemod.h"
|
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "IThreader.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
#include "LibrarySys.h"
|
|
||||||
#include "ThreadSupport.h"
|
|
||||||
#include "sm_memtable.h"
|
|
||||||
#include <sh_string.h>
|
|
||||||
#include <sh_list.h>
|
|
||||||
|
|
||||||
enum UpdateStatus
|
|
||||||
{
|
|
||||||
Update_Unknown = 0, /* Version wasn't recognised or version querying is unsupported */
|
|
||||||
Update_Current = 1, /* Server is running latest version */
|
|
||||||
Update_NewBuild = 2, /* Server is on a svn release and a newer version is available */
|
|
||||||
Update_MinorAvailable = 3, /* Server is on a release and a minor release has superceeded it */
|
|
||||||
Update_MajorAvailable = 4, /* Server is on a release and a major release has superceeded it */
|
|
||||||
Update_CriticalAvailable = 5, /* A critical update has been released (security fixes etc) */
|
|
||||||
};
|
|
||||||
|
|
||||||
class MD5;
|
|
||||||
|
|
||||||
class BuildMD5ableBuffer : public ITextListener_SMC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BuildMD5ableBuffer();
|
|
||||||
~BuildMD5ableBuffer();
|
|
||||||
void ReadSMC_ParseStart();
|
|
||||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
|
||||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
|
||||||
void ReadSMC_ParseEnd(bool halted, bool failed);
|
|
||||||
public:
|
|
||||||
MD5 *checksum;
|
|
||||||
private:
|
|
||||||
BaseStringTable *stringTable;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FileData
|
|
||||||
{
|
|
||||||
SourceHook::String *filename;
|
|
||||||
char checksum[33];
|
|
||||||
};
|
|
||||||
|
|
||||||
class FetcherThread : public IThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FetcherThread();
|
|
||||||
~FetcherThread();
|
|
||||||
public:
|
|
||||||
void RunThread(IThreadHandle *pHandle);
|
|
||||||
void OnTerminate(IThreadHandle *pHandle, bool cancel);
|
|
||||||
private:
|
|
||||||
int BuildGameDataQuery(char *buffer, int maxlen);
|
|
||||||
void ProcessGameDataQuery(int SocketDescriptor);
|
|
||||||
int RecvData(int socketDescriptor, char *buffer, int len);
|
|
||||||
int SendData(int socketDescriptor, char *buffer, int len);
|
|
||||||
int ConnectSocket();
|
|
||||||
void HandleUpdateStatus(UpdateStatus status, short version[4]);
|
|
||||||
public:
|
|
||||||
SourceHook::CVector<FileData *> filenames;
|
|
||||||
bool needsRestart;
|
|
||||||
bool wasSuccess;
|
|
||||||
private:
|
|
||||||
UpdateStatus updateStatus;
|
|
||||||
BaseMemTable *memtable;
|
|
||||||
short build[4];
|
|
||||||
};
|
|
||||||
|
|
||||||
extern bool g_blockGameDataLoad;
|
|
||||||
|
|
||||||
#endif // _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
|
||||||
|
|
||||||
+1
-29
@@ -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-2007 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
|
||||||
@@ -511,31 +511,3 @@ const char *CHalfLife2::CurrentCommandName()
|
|||||||
return m_CommandStack.front().cmd;
|
return m_CommandStack.front().cmd;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHalfLife2::AddDelayedKick(int client, int userid, const char *msg)
|
|
||||||
{
|
|
||||||
DelayedKickInfo kick;
|
|
||||||
|
|
||||||
kick.client = client;
|
|
||||||
kick.userid = userid;
|
|
||||||
UTIL_Format(kick.buffer, sizeof(kick.buffer), "%s", msg);
|
|
||||||
|
|
||||||
m_DelayedKicks.push(kick);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHalfLife2::ProcessDelayedKicks()
|
|
||||||
{
|
|
||||||
while (!m_DelayedKicks.empty())
|
|
||||||
{
|
|
||||||
DelayedKickInfo info = m_DelayedKicks.first();
|
|
||||||
m_DelayedKicks.pop();
|
|
||||||
|
|
||||||
CPlayer *player = g_Players.GetPlayerByIndex(info.client);
|
|
||||||
if (player == NULL || player->GetUserId() != info.userid)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
player->Kick(info.buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-11
@@ -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-2007 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,13 +79,6 @@ struct CachedCommandInfo
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DelayedKickInfo
|
|
||||||
{
|
|
||||||
int userid;
|
|
||||||
int client;
|
|
||||||
char buffer[384];
|
|
||||||
};
|
|
||||||
|
|
||||||
class CHalfLife2 :
|
class CHalfLife2 :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
public IGameHelpers
|
public IGameHelpers
|
||||||
@@ -117,8 +110,6 @@ public:
|
|||||||
void PopCommandStack();
|
void PopCommandStack();
|
||||||
const CCommand *PeekCommandStack();
|
const CCommand *PeekCommandStack();
|
||||||
const char *CurrentCommandName();
|
const char *CurrentCommandName();
|
||||||
void AddDelayedKick(int client, int userid, const char *msg);
|
|
||||||
void ProcessDelayedKicks();
|
|
||||||
#if !defined METAMOD_PLAPI_VERSION
|
#if !defined METAMOD_PLAPI_VERSION
|
||||||
bool IsOriginalEngine();
|
bool IsOriginalEngine();
|
||||||
#endif
|
#endif
|
||||||
@@ -134,7 +125,6 @@ private:
|
|||||||
Queue<DelayedFakeCliCmd *> m_CmdQueue;
|
Queue<DelayedFakeCliCmd *> m_CmdQueue;
|
||||||
CStack<DelayedFakeCliCmd *> m_FreeCmds;
|
CStack<DelayedFakeCliCmd *> m_FreeCmds;
|
||||||
CStack<CachedCommandInfo> m_CommandStack;
|
CStack<CachedCommandInfo> m_CommandStack;
|
||||||
Queue<DelayedKickInfo> m_DelayedKicks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CHalfLife2 g_HL2;
|
extern CHalfLife2 g_HL2;
|
||||||
|
|||||||
+2
-35
@@ -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-2007 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 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "LibrarySys.h"
|
#include "systems/LibrarySys.h"
|
||||||
#include "TimerSys.h"
|
#include "TimerSys.h"
|
||||||
#include "sm_version.h"
|
#include "sm_version.h"
|
||||||
|
|
||||||
@@ -245,19 +245,6 @@ void Logger::LogToOpenFile(FILE *fp, const char *msg, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::LogToFileOnly(FILE *fp, const char *msg, ...)
|
|
||||||
{
|
|
||||||
if (!m_Active)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, msg);
|
|
||||||
LogToFileOnlyEx(fp, msg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::LogToOpenFileEx(FILE *fp, const char *msg, va_list ap)
|
void Logger::LogToOpenFileEx(FILE *fp, const char *msg, va_list ap)
|
||||||
{
|
{
|
||||||
if (!m_Active)
|
if (!m_Active)
|
||||||
@@ -278,26 +265,6 @@ void Logger::LogToOpenFileEx(FILE *fp, const char *msg, va_list ap)
|
|||||||
g_SMAPI->ConPrintf("L %s: %s\n", date, buffer);
|
g_SMAPI->ConPrintf("L %s: %s\n", date, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::LogToFileOnlyEx(FILE *fp, const char *msg, va_list ap)
|
|
||||||
{
|
|
||||||
if (!m_Active)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buffer[3072];
|
|
||||||
UTIL_FormatArgs(buffer, sizeof(buffer), msg, ap);
|
|
||||||
|
|
||||||
char date[32];
|
|
||||||
time_t t;
|
|
||||||
GetAdjustedTime(&t);
|
|
||||||
tm *curtime = localtime(&t);
|
|
||||||
strftime(date, sizeof(date), "%m/%d/%Y - %H:%M:%S", curtime);
|
|
||||||
|
|
||||||
fprintf(fp, "L %s: %s\n", date, buffer);
|
|
||||||
fflush(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::LogMessage(const char *vafmt, ...)
|
void Logger::LogMessage(const char *vafmt, ...)
|
||||||
{
|
{
|
||||||
if (!m_Active)
|
if (!m_Active)
|
||||||
|
|||||||
+1
-4
@@ -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-2007 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
|
||||||
@@ -78,9 +78,6 @@ public:
|
|||||||
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);
|
||||||
/* This version does not print to console, and is thus thread-safe */
|
|
||||||
void LogToFileOnly(FILE *fp, const char *msg, ...);
|
|
||||||
void LogToFileOnlyEx(FILE *fp, const char *msg, va_list ap);
|
|
||||||
void MapChange(const char *mapname);
|
void MapChange(const char *mapname);
|
||||||
const char *GetLogFileName(LogType type) const;
|
const char *GetLogFileName(LogType type) const;
|
||||||
LoggingMode GetLoggingMode() const;
|
LoggingMode GetLoggingMode() const;
|
||||||
|
|||||||
+30
-18
@@ -5,7 +5,8 @@ SMSDK = ..
|
|||||||
SRCDS_BASE = ~/srcds
|
SRCDS_BASE = ~/srcds
|
||||||
HL2SDK_ORIG = ../../hl2sdk
|
HL2SDK_ORIG = ../../hl2sdk
|
||||||
HL2SDK_OB = ../../hl2sdk-ob
|
HL2SDK_OB = ../../hl2sdk-ob
|
||||||
MMSOURCE17 = ../../mmsource-1.7
|
SOURCEMM14 = ../../sourcemm-1.4
|
||||||
|
SOURCEMM16 = ../../sourcemm-1.6
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
@@ -17,23 +18,22 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC
|
|||||||
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 Profiler.cpp
|
||||||
NativeOwner.cpp GameDataFetcher.cpp md5.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_float.cpp smn_functions.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_maplists.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_sorting.cpp smn_textparse.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_array.cpp \
|
||||||
smn_adt_trie.cpp smn_hudtext.cpp smn_adt_stack.cpp smn_nextmap.cpp
|
smn_adt_trie.cpp smn_hudtext.cpp
|
||||||
OBJECTS += ExtensionSys.cpp \
|
OBJECTS += systems/ExtensionSys.cpp systems/ForwardSys.cpp systems/HandleSys.cpp \
|
||||||
ForwardSys.cpp \
|
systems/LibrarySys.cpp systems/PluginInfoDatabase.cpp systems/PluginSys.cpp \
|
||||||
HandleSys.cpp \
|
systems/ShareSys.cpp vm/sp_vm_basecontext.cpp vm/sp_vm_engine.cpp \
|
||||||
LibrarySys.cpp \
|
vm/sp_vm_function.cpp
|
||||||
PluginInfoDatabase.cpp \
|
|
||||||
PluginSys.cpp \
|
|
||||||
ShareSys.cpp
|
|
||||||
OBJECTS += thread/ThreadWorker.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp ThreadSupport.cpp
|
OBJECTS += thread/ThreadWorker.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp ThreadSupport.cpp
|
||||||
|
OBJECTS += zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/gzio.c \
|
||||||
|
zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/trees.c \
|
||||||
|
zlib/uncompr.c zlib/zutil.c
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||||
@@ -43,14 +43,14 @@ C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
|||||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||||
C_GCC4_FLAGS = -fvisibility=hidden
|
C_GCC4_FLAGS = -fvisibility=hidden
|
||||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||||
CPP = gcc
|
CPP = gcc-4.1
|
||||||
|
|
||||||
override ENGSET = false
|
override ENGSET = false
|
||||||
ifeq "$(ENGINE)" "original"
|
ifeq "$(ENGINE)" "original"
|
||||||
HL2SDK = $(HL2SDK_ORIG)
|
HL2SDK = $(HL2SDK_ORIG)
|
||||||
HL2PUB = $(HL2SDK_ORIG)/public
|
HL2PUB = $(HL2SDK_ORIG)/public
|
||||||
HL2LIB = $(HL2SDK_ORIG)/linux_sdk
|
HL2LIB = $(HL2SDK_ORIG)/linux_sdk
|
||||||
METAMOD = $(MMSOURCE17)/core-legacy
|
METAMOD = $(SOURCEMM14)
|
||||||
INCLUDE += -I$(HL2SDK)/public/dlls
|
INCLUDE += -I$(HL2SDK)/public/dlls
|
||||||
SRCDS = $(SRCDS_BASE)
|
SRCDS = $(SRCDS_BASE)
|
||||||
BINARY = sourcemod.1.ep1.so
|
BINARY = sourcemod.1.ep1.so
|
||||||
@@ -59,9 +59,9 @@ endif
|
|||||||
ifeq "$(ENGINE)" "orangebox"
|
ifeq "$(ENGINE)" "orangebox"
|
||||||
HL2SDK = $(HL2SDK_OB)
|
HL2SDK = $(HL2SDK_OB)
|
||||||
HL2PUB = $(HL2SDK_OB)/public
|
HL2PUB = $(HL2SDK_OB)/public
|
||||||
HL2LIB = $(HL2SDK_OB)/lib/linux
|
HL2LIB = $(HL2SDK_OB)/linux_sdk
|
||||||
CFLAGS += -DORANGEBOX_BUILD
|
CFLAGS += -DORANGEBOX_BUILD
|
||||||
METAMOD = $(MMSOURCE17)/core
|
METAMOD = $(SOURCEMM16)
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
SRCDS = $(SRCDS_BASE)/orangebox
|
SRCDS = $(SRCDS_BASE)/orangebox
|
||||||
BINARY = sourcemod.2.ep2.so
|
BINARY = sourcemod.2.ep2.so
|
||||||
@@ -70,10 +70,14 @@ endif
|
|||||||
|
|
||||||
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 -lpthread -static-libgcc
|
||||||
|
|
||||||
|
INCLUDE_SMSDK = -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
||||||
|
|
||||||
|
INCLUDE_SM16 = -I. -I.. -I$(SOURCEMM16)/sourcehook $(INCLUDE_SMSDK)
|
||||||
|
|
||||||
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 \
|
||||||
-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
-I$(METAMOD)/sourcemm -Isystems $(INCLUDE_SMSDK)
|
||||||
|
|
||||||
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
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 \
|
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \
|
||||||
@@ -98,9 +102,13 @@ ifeq "$(GCC_VERSION)" "4"
|
|||||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
OBJ_LINUX := $(OBJECTS:%vm_engine.cpp=$(BIN_DIR)/%vm_engine.o)
|
||||||
|
OBJ_LINUX := $(OBJ_LINUX:%.cpp=$(BIN_DIR)/%.o)
|
||||||
OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o)
|
OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o)
|
||||||
|
|
||||||
|
$(BIN_DIR)/%vm_engine.o: %vm_engine.cpp
|
||||||
|
$(CPP) $(INCLUDE_SM16) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
$(BIN_DIR)/%.o: %.cpp
|
$(BIN_DIR)/%.o: %.cpp
|
||||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
@@ -109,13 +117,15 @@ $(BIN_DIR)/%.o: %.c
|
|||||||
|
|
||||||
all: check
|
all: check
|
||||||
mkdir -p $(BIN_DIR)/systems
|
mkdir -p $(BIN_DIR)/systems
|
||||||
|
mkdir -p $(BIN_DIR)/vm
|
||||||
|
mkdir -p $(BIN_DIR)/zlib
|
||||||
mkdir -p $(BIN_DIR)/thread
|
mkdir -p $(BIN_DIR)/thread
|
||||||
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;
|
||||||
$(MAKE) -f Makefile sourcemod
|
$(MAKE) -f Makefile sourcemod
|
||||||
|
|
||||||
check:
|
check:
|
||||||
if [ "$(ENGSET)" = "false" ]; then \
|
if [ "$(ENGSET)" == "false" ]; then \
|
||||||
echo "You must supply ENGINE=orangebox or ENGINE=original"; \
|
echo "You must supply ENGINE=orangebox or ENGINE=original"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
@@ -131,5 +141,7 @@ 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)/systems/*.o
|
||||||
|
rm -rf $(BIN_DIR)/zlib/*.o
|
||||||
|
rm -rf $(BIN_DIR)/vm/*.o
|
||||||
rm -rf $(BIN_DIR)/thread/*.o
|
rm -rf $(BIN_DIR)/thread/*.o
|
||||||
rm -rf $(BIN_DIR)/$(BINARY)
|
rm -rf $(BIN_DIR)/$(BINARY)
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+5
-28
@@ -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-2007 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
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "Translator.h"
|
|
||||||
|
|
||||||
MenuManager g_Menus;
|
MenuManager g_Menus;
|
||||||
VoteMenuHandler s_VoteHandler;
|
VoteMenuHandler s_VoteHandler;
|
||||||
@@ -586,20 +585,14 @@ skip_search:
|
|||||||
{
|
{
|
||||||
if (exitBackButton)
|
if (exitBackButton)
|
||||||
{
|
{
|
||||||
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
|
CorePlayerTranslate(client, text, sizeof(text), "Back", NULL);
|
||||||
{
|
|
||||||
UTIL_Format(text, sizeof(text), "Back");
|
|
||||||
}
|
|
||||||
dr.style = ITEMDRAW_CONTROL;
|
dr.style = ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
slots[position].type = ItemSel_ExitBack;
|
slots[position].type = ItemSel_ExitBack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
|
CorePlayerTranslate(client, text, sizeof(text), "Previous", NULL);
|
||||||
{
|
|
||||||
UTIL_Format(text, sizeof(text), "Previous");
|
|
||||||
}
|
|
||||||
dr.style = (displayPrev ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
dr.style = (displayPrev ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
slots[position].type = ItemSel_Back;
|
slots[position].type = ItemSel_Back;
|
||||||
@@ -617,10 +610,7 @@ skip_search:
|
|||||||
/* NEXT */
|
/* NEXT */
|
||||||
if (displayNext || canDrawDisabled)
|
if (displayNext || canDrawDisabled)
|
||||||
{
|
{
|
||||||
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
|
CorePlayerTranslate(client, text, sizeof(text), "Next", NULL);
|
||||||
{
|
|
||||||
UTIL_Format(text, sizeof(text), "Next");
|
|
||||||
}
|
|
||||||
dr.style = (displayNext ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
dr.style = (displayNext ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
slots[position].type = ItemSel_Next;
|
slots[position].type = ItemSel_Next;
|
||||||
@@ -648,10 +638,7 @@ skip_search:
|
|||||||
/* EXIT */
|
/* EXIT */
|
||||||
if (exitButton)
|
if (exitButton)
|
||||||
{
|
{
|
||||||
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
|
CorePlayerTranslate(client, text, sizeof(text), "Exit", NULL);
|
||||||
{
|
|
||||||
UTIL_Format(text, sizeof(text), "Exit");
|
|
||||||
}
|
|
||||||
dr.style = ITEMDRAW_CONTROL;
|
dr.style = ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
slots[position].type = ItemSel_Exit;
|
slots[position].type = ItemSel_Exit;
|
||||||
@@ -790,13 +777,3 @@ unsigned int MenuManager::GetRemainingVoteDelay()
|
|||||||
{
|
{
|
||||||
return s_VoteHandler.GetRemainingVoteDelay();
|
return s_VoteHandler.GetRemainingVoteDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuManager::IsClientInVotePool(int client)
|
|
||||||
{
|
|
||||||
return s_VoteHandler.IsClientInVotePool(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MenuManager::RedrawClientVoteMenu(int client)
|
|
||||||
{
|
|
||||||
return s_VoteHandler.RedrawToClient(client);
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-3
@@ -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-2007 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
|
||||||
@@ -89,8 +89,6 @@ public:
|
|||||||
bool IsVoteInProgress();
|
bool IsVoteInProgress();
|
||||||
void CancelVoting();
|
void CancelVoting();
|
||||||
unsigned int GetRemainingVoteDelay();
|
unsigned int GetRemainingVoteDelay();
|
||||||
bool IsClientInVotePool(int client);
|
|
||||||
bool RedrawClientVoteMenu(int client);
|
|
||||||
public: //IHandleTypeDispatch
|
public: //IHandleTypeDispatch
|
||||||
void OnHandleDestroy(HandleType_t type, void *object);
|
void OnHandleDestroy(HandleType_t type, void *object);
|
||||||
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
|
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+11
-89
@@ -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-2007 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
|
||||||
@@ -113,19 +113,14 @@ void VoteMenuHandler::OnClientDisconnected(int client)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wipe out their vote if they had one. We have to make sure the the the
|
/* Wipe out their vote if they had one */
|
||||||
* newly connected client is not allowed to vote.
|
|
||||||
*/
|
|
||||||
int item;
|
int item;
|
||||||
if ((item = m_ClientVotes[client]) >= -1)
|
if ((item = m_ClientVotes[client]) >= 0)
|
||||||
{
|
{
|
||||||
if (item >= 0)
|
assert((unsigned)item < m_Items);
|
||||||
{
|
assert(m_Votes[item] > 0);
|
||||||
assert((unsigned)item < m_Items);
|
m_Votes[item]--;
|
||||||
assert(m_Votes[item] > 0);
|
m_ClientVotes[client] = -1;
|
||||||
m_Votes[item]--;
|
|
||||||
}
|
|
||||||
m_ClientVotes[client] = -2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,28 +129,18 @@ bool VoteMenuHandler::IsVoteInProgress()
|
|||||||
return (m_pCurMenu != NULL);
|
return (m_pCurMenu != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoteMenuHandler::StartVote(IBaseMenu *menu,
|
bool VoteMenuHandler::StartVote(IBaseMenu *menu, unsigned int num_clients, int clients[], unsigned int max_time, unsigned int flags/* =0 */)
|
||||||
unsigned int num_clients,
|
|
||||||
int clients[],
|
|
||||||
unsigned int max_time,
|
|
||||||
unsigned int flags/* =0 */)
|
|
||||||
{
|
{
|
||||||
if (!InitializeVoting(menu, menu->GetHandler(), max_time, flags))
|
if (!InitializeVoting(menu, menu->GetHandler(), max_time, flags))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: we can use game time and not universal time because
|
|
||||||
* if we're voting then players are in-game.
|
|
||||||
*/
|
|
||||||
|
|
||||||
float fVoteDelay = sm_vote_delay.GetFloat();
|
float fVoteDelay = sm_vote_delay.GetFloat();
|
||||||
if (fVoteDelay < 1.0)
|
if (fVoteDelay < 1.0)
|
||||||
{
|
{
|
||||||
g_next_vote = 0.0;
|
g_next_vote = 0.0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This little trick breaks for infinite votes!
|
/* This little trick breaks for infinite votes!
|
||||||
* However, we just ignore that since those 1) shouldn't exist and
|
* However, we just ignore that since those 1) shouldn't exist and
|
||||||
* 2) people must be checking IsVoteInProgress() beforehand anyway.
|
* 2) people must be checking IsVoteInProgress() beforehand anyway.
|
||||||
@@ -163,15 +148,8 @@ bool VoteMenuHandler::StartVote(IBaseMenu *menu,
|
|||||||
g_next_vote = gpGlobals->curtime + fVoteDelay + (float)max_time;
|
g_next_vote = gpGlobals->curtime + fVoteDelay + (float)max_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fStartTime = gpGlobals->curtime;
|
|
||||||
m_nMenuTime = max_time;
|
|
||||||
|
|
||||||
for (unsigned int i=0; i<num_clients; i++)
|
for (unsigned int i=0; i<num_clients; i++)
|
||||||
{
|
{
|
||||||
if (clients[i] < 1 || clients[i] > 256)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
menu->Display(clients[i], max_time, this);
|
menu->Display(clients[i], max_time, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,58 +158,6 @@ bool VoteMenuHandler::StartVote(IBaseMenu *menu,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoteMenuHandler::IsClientInVotePool(int client)
|
|
||||||
{
|
|
||||||
if (client < 1
|
|
||||||
|| client > g_Players.MaxClients()
|
|
||||||
|| m_pCurMenu == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (m_ClientVotes[client] > -2);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VoteMenuHandler::GetClientVoteChoice(int client, unsigned int *pItem)
|
|
||||||
{
|
|
||||||
if (!IsClientInVotePool(client)
|
|
||||||
|| m_ClientVotes[client] == -1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pItem = m_ClientVotes[client];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VoteMenuHandler::RedrawToClient(int client)
|
|
||||||
{
|
|
||||||
unsigned int time_limit;
|
|
||||||
|
|
||||||
if (!IsClientInVotePool(client))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_nMenuTime == MENU_TIME_FOREVER)
|
|
||||||
{
|
|
||||||
time_limit = m_nMenuTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
time_limit = (int)((float)m_nMenuTime - (gpGlobals->curtime - m_fStartTime));
|
|
||||||
|
|
||||||
/* Make sure this doesn't round to zero */
|
|
||||||
if (time_limit == MENU_TIME_FOREVER)
|
|
||||||
{
|
|
||||||
time_limit = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_pCurMenu->Display(client, time_limit, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VoteMenuHandler::InitializeVoting(IBaseMenu *menu,
|
bool VoteMenuHandler::InitializeVoting(IBaseMenu *menu,
|
||||||
IMenuHandler *handler,
|
IMenuHandler *handler,
|
||||||
unsigned int time,
|
unsigned int time,
|
||||||
@@ -261,9 +187,7 @@ bool VoteMenuHandler::InitializeVoting(IBaseMenu *menu,
|
|||||||
m_Votes[i] = 0;
|
m_Votes[i] = 0;
|
||||||
}
|
}
|
||||||
m_Votes.resize(m_Items, 0);
|
m_Votes.resize(m_Items, 0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i=0; i<m_Items; i++)
|
for (unsigned int i=0; i<m_Items; i++)
|
||||||
{
|
{
|
||||||
m_Votes[i] = 0;
|
m_Votes[i] = 0;
|
||||||
@@ -328,9 +252,7 @@ void VoteMenuHandler::EndVoting()
|
|||||||
if (fVoteDelay < 1.0)
|
if (fVoteDelay < 1.0)
|
||||||
{
|
{
|
||||||
g_next_vote = 0.0;
|
g_next_vote = 0.0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
g_next_vote = gpGlobals->curtime + fVoteDelay;
|
g_next_vote = gpGlobals->curtime + fVoteDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-6
@@ -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-2007 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
|
||||||
@@ -72,9 +72,6 @@ public:
|
|||||||
IBaseMenu *GetCurrentMenu();
|
IBaseMenu *GetCurrentMenu();
|
||||||
bool IsCancelling();
|
bool IsCancelling();
|
||||||
unsigned int GetRemainingVoteDelay();
|
unsigned int GetRemainingVoteDelay();
|
||||||
bool IsClientInVotePool(int client);
|
|
||||||
bool GetClientVoteChoice(int client, unsigned int *pItem);
|
|
||||||
bool RedrawToClient(int client);
|
|
||||||
private:
|
private:
|
||||||
void Reset(IMenuHandler *mh);
|
void Reset(IMenuHandler *mh);
|
||||||
void DecrementPlayerCount();
|
void DecrementPlayerCount();
|
||||||
@@ -96,8 +93,6 @@ private:
|
|||||||
unsigned int m_NumVotes;
|
unsigned int m_NumVotes;
|
||||||
unsigned int m_VoteTime;
|
unsigned int m_VoteTime;
|
||||||
unsigned int m_VoteFlags;
|
unsigned int m_VoteFlags;
|
||||||
float m_fStartTime;
|
|
||||||
unsigned int m_nMenuTime;
|
|
||||||
int m_ClientVotes[256+1];
|
int m_ClientVotes[256+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,144 +0,0 @@
|
|||||||
#include "NativeOwner.h"
|
|
||||||
#include "ShareSys.h"
|
|
||||||
#include "PluginSys.h"
|
|
||||||
|
|
||||||
CNativeOwner::CNativeOwner() : m_nMarkSerial(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::SetMarkSerial(unsigned int serial)
|
|
||||||
{
|
|
||||||
m_nMarkSerial = serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CNativeOwner::GetMarkSerial()
|
|
||||||
{
|
|
||||||
return m_nMarkSerial;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::AddDependent(CPlugin *pPlugin)
|
|
||||||
{
|
|
||||||
m_Dependents.push_back(pPlugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::AddWeakRef(const WeakNative & ref)
|
|
||||||
{
|
|
||||||
m_WeakRefs.push_back(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives)
|
|
||||||
{
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; natives[i].func != NULL && natives[i].name != NULL; i++)
|
|
||||||
{
|
|
||||||
if ((pEntry = g_ShareSys.AddNativeToCache(this, &natives[i])) == NULL)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Natives.push_back(pEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::PropogateMarkSerial(unsigned int serial)
|
|
||||||
{
|
|
||||||
CNativeOwner *pOwner;
|
|
||||||
List<CPlugin *>::iterator iter;
|
|
||||||
|
|
||||||
for (iter = m_Dependents.begin();
|
|
||||||
iter != m_Dependents.end();
|
|
||||||
iter++)
|
|
||||||
{
|
|
||||||
pOwner = (*iter);
|
|
||||||
pOwner->SetMarkSerial(serial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::UnbindWeakRef(const WeakNative & ref)
|
|
||||||
{
|
|
||||||
sp_native_t *native;
|
|
||||||
IPluginContext *pContext;
|
|
||||||
|
|
||||||
pContext = ref.pl->GetBaseContext();
|
|
||||||
if ((pContext->GetNativeByIndex(ref.idx, &native)) == SP_ERROR_NONE)
|
|
||||||
{
|
|
||||||
/* If there is no reference, the native must be unbound */
|
|
||||||
if (ref.entry == NULL)
|
|
||||||
{
|
|
||||||
native->status = SP_NATIVE_UNBOUND;
|
|
||||||
native->pfn = NULL;
|
|
||||||
}
|
|
||||||
/* If we've cached a reference, it's a core native we can
|
|
||||||
* rebind back to its original (this was a replacement).
|
|
||||||
*/
|
|
||||||
else
|
|
||||||
{
|
|
||||||
native->pfn = ref.entry->func;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::DropEverything()
|
|
||||||
{
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
List<WeakNative>::iterator iter;
|
|
||||||
List<NativeEntry *>::iterator ntv_iter;
|
|
||||||
|
|
||||||
/* Unbind and remove all weak references to us */
|
|
||||||
iter = m_WeakRefs.begin();
|
|
||||||
while (iter != m_WeakRefs.end())
|
|
||||||
{
|
|
||||||
UnbindWeakRef((*iter));
|
|
||||||
iter = m_WeakRefs.erase(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unmark our replacement natives */
|
|
||||||
ntv_iter = m_ReplacedNatives.begin();
|
|
||||||
while (ntv_iter != m_ReplacedNatives.end())
|
|
||||||
{
|
|
||||||
pEntry = (*ntv_iter);
|
|
||||||
pEntry->replacement.func = NULL;
|
|
||||||
pEntry->replacement.owner = NULL;
|
|
||||||
ntv_iter = m_ReplacedNatives.erase(ntv_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Strip all of our natives from the cache */
|
|
||||||
ntv_iter = m_Natives.begin();
|
|
||||||
while (ntv_iter != m_Natives.end())
|
|
||||||
{
|
|
||||||
g_ShareSys.ClearNativeFromCache(this, (*ntv_iter)->name);
|
|
||||||
ntv_iter = m_Natives.erase(ntv_iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::DropWeakRefsTo(CPlugin *pPlugin)
|
|
||||||
{
|
|
||||||
List<WeakNative>::iterator iter;
|
|
||||||
|
|
||||||
iter = m_WeakRefs.begin();
|
|
||||||
while (iter != m_WeakRefs.end())
|
|
||||||
{
|
|
||||||
WeakNative & ref = (*iter);
|
|
||||||
|
|
||||||
if (ref.pl == pPlugin)
|
|
||||||
{
|
|
||||||
iter = m_WeakRefs.erase(iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::DropRefsTo(CPlugin *pPlugin)
|
|
||||||
{
|
|
||||||
m_Dependents.remove(pPlugin);
|
|
||||||
DropWeakRefsTo(pPlugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNativeOwner::AddReplacedNative(NativeEntry *pEntry)
|
|
||||||
{
|
|
||||||
m_ReplacedNatives.push_back(pEntry);
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|
|
||||||
#define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|
|
||||||
|
|
||||||
#include <sp_vm_types.h>
|
|
||||||
#include <sh_list.h>
|
|
||||||
|
|
||||||
class CPlugin;
|
|
||||||
struct NativeEntry;
|
|
||||||
|
|
||||||
struct WeakNative
|
|
||||||
{
|
|
||||||
WeakNative(CPlugin *plugin, uint32_t index) :
|
|
||||||
pl(plugin), idx(index), entry(NULL)
|
|
||||||
{
|
|
||||||
pl = plugin;
|
|
||||||
idx = index;
|
|
||||||
}
|
|
||||||
WeakNative(CPlugin *plugin, uint32_t index, NativeEntry *pEntry) :
|
|
||||||
pl(plugin), idx(index), entry(pEntry)
|
|
||||||
{
|
|
||||||
pl = plugin;
|
|
||||||
idx = index;
|
|
||||||
}
|
|
||||||
CPlugin *pl;
|
|
||||||
uint32_t idx;
|
|
||||||
NativeEntry *entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
class CNativeOwner
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CNativeOwner();
|
|
||||||
public:
|
|
||||||
virtual void DropEverything();
|
|
||||||
public:
|
|
||||||
void AddNatives(const sp_nativeinfo_t *info);
|
|
||||||
public:
|
|
||||||
void SetMarkSerial(unsigned int serial);
|
|
||||||
unsigned int GetMarkSerial();
|
|
||||||
void PropogateMarkSerial(unsigned int serial);
|
|
||||||
public:
|
|
||||||
void AddDependent(CPlugin *pPlugin);
|
|
||||||
void AddWeakRef(const WeakNative & ref);
|
|
||||||
void DropRefsTo(CPlugin *pPlugin);
|
|
||||||
void AddReplacedNative(NativeEntry *pEntry);
|
|
||||||
private:
|
|
||||||
void DropWeakRefsTo(CPlugin *pPlugin);
|
|
||||||
void UnbindWeakRef(const WeakNative & ref);
|
|
||||||
protected:
|
|
||||||
List<CPlugin *> m_Dependents;
|
|
||||||
unsigned int m_nMarkSerial;
|
|
||||||
List<WeakNative> m_WeakRefs;
|
|
||||||
List<NativeEntry *> m_Natives;
|
|
||||||
List<NativeEntry *> m_ReplacedNatives;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "NextMap.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
#include "sourcemm_api.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
#include "sourcehook.h"
|
|
||||||
#include "sm_srvcmds.h"
|
|
||||||
|
|
||||||
NextMapManager g_NextMap;
|
|
||||||
|
|
||||||
SH_DECL_HOOK2_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *);
|
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
|
||||||
#else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConCommand *changeLevelCmd = NULL;
|
|
||||||
|
|
||||||
ConVar sm_nextmap("sm_nextmap", "", FCVAR_NOTIFY);
|
|
||||||
|
|
||||||
bool g_forcedChange = false;
|
|
||||||
|
|
||||||
void NextMapManager::OnSourceModAllInitialized_Post()
|
|
||||||
{
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
|
||||||
#else
|
|
||||||
SH_ADD_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConCommandBase *pBase = icvar->GetCommands();
|
|
||||||
ConCommand *pCmd = NULL;
|
|
||||||
while (pBase)
|
|
||||||
{
|
|
||||||
if (strcmp(pBase->GetName(), "changelevel") == 0)
|
|
||||||
{
|
|
||||||
/* Don't want to return convar with same name */
|
|
||||||
if (!pBase->IsCommand())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCmd = (ConCommand *)pBase;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pBase = const_cast<ConCommandBase *>(pBase->GetNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pCmd != NULL)
|
|
||||||
{
|
|
||||||
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdChangeLevelCallback, false);
|
|
||||||
changeLevelCmd = pCmd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NextMapManager::OnSourceModShutdown()
|
|
||||||
{
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
|
||||||
#else
|
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (changeLevelCmd != NULL)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, changeLevelCmd, CmdChangeLevelCallback, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceHook::List<MapChangeData *>::iterator iter;
|
|
||||||
iter = m_mapHistory.begin();
|
|
||||||
|
|
||||||
while (iter != m_mapHistory.end())
|
|
||||||
{
|
|
||||||
delete (MapChangeData *)*iter;
|
|
||||||
iter = m_mapHistory.erase(iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *NextMapManager::GetNextMap()
|
|
||||||
{
|
|
||||||
return sm_nextmap.GetString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NextMapManager::SetNextMap(const char *map)
|
|
||||||
{
|
|
||||||
if (!engine->IsMapValid(map))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sm_nextmap.SetValue(map);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
|
|
||||||
{
|
|
||||||
if (g_forcedChange)
|
|
||||||
{
|
|
||||||
g_Logger.LogMessage("[SM] Changed map to \"%s\"", map);
|
|
||||||
RETURN_META(MRES_IGNORED);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *newmap = sm_nextmap.GetString();
|
|
||||||
|
|
||||||
if (newmap[0] == 0 || !engine->IsMapValid(newmap))
|
|
||||||
{
|
|
||||||
RETURN_META(MRES_IGNORED);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_Logger.LogMessage("[SM] Changed map to \"%s\"", newmap);
|
|
||||||
|
|
||||||
UTIL_Format(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), newmap);
|
|
||||||
UTIL_Format(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), "Normal level change");
|
|
||||||
|
|
||||||
RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown));
|
|
||||||
}
|
|
||||||
|
|
||||||
void NextMapManager::OnSourceModLevelChange( const char *mapName )
|
|
||||||
{
|
|
||||||
/* Skip the first 'mapchange' when the server starts up */
|
|
||||||
if (m_tempChangeInfo.startTime != 0)
|
|
||||||
{
|
|
||||||
if (strcmp(mapName, m_tempChangeInfo.m_mapName) == 0)
|
|
||||||
{
|
|
||||||
/* The map change was as we expected */
|
|
||||||
m_mapHistory.push_back(new MapChangeData(lastMap, m_tempChangeInfo.m_changeReason, m_tempChangeInfo.startTime));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Something intercepted the mapchange */
|
|
||||||
char newReason[255];
|
|
||||||
UTIL_Format(newReason, sizeof(newReason), "%s (Map overridden)", m_tempChangeInfo.m_changeReason);
|
|
||||||
m_mapHistory.push_back(new MapChangeData(lastMap, newReason, m_tempChangeInfo.startTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Should this be customizable? */
|
|
||||||
if (m_mapHistory.size() > 20)
|
|
||||||
{
|
|
||||||
SourceHook::List<MapChangeData *>::iterator iter;
|
|
||||||
iter = m_mapHistory.begin();
|
|
||||||
|
|
||||||
delete (MapChangeData *)*iter;
|
|
||||||
|
|
||||||
m_mapHistory.erase(iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_tempChangeInfo.m_mapName[0] ='\0';
|
|
||||||
m_tempChangeInfo.m_changeReason[0] = '\0';
|
|
||||||
m_tempChangeInfo.startTime = time(NULL);
|
|
||||||
UTIL_Format(lastMap, sizeof(lastMap), mapName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeReason )
|
|
||||||
{
|
|
||||||
/* Store the mapname and reason */
|
|
||||||
UTIL_Format(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), mapName);
|
|
||||||
UTIL_Format(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), changeReason);
|
|
||||||
|
|
||||||
/* Change level and skip our hook */
|
|
||||||
g_forcedChange = true;
|
|
||||||
engine->ChangeLevel(mapName, NULL);
|
|
||||||
g_forcedChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NextMapManager::NextMapManager()
|
|
||||||
{
|
|
||||||
m_tempChangeInfo = MapChangeData();
|
|
||||||
m_mapHistory = SourceHook::List<MapChangeData *>();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
void CmdChangeLevelCallback(const CCommand &command)
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
void CmdChangeLevelCallback()
|
|
||||||
{
|
|
||||||
CCommand command;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (command.ArgC() < 2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_NextMap.m_tempChangeInfo.m_mapName[0] == '\0')
|
|
||||||
{
|
|
||||||
UTIL_Format(g_NextMap.m_tempChangeInfo.m_mapName, sizeof(g_NextMap.m_tempChangeInfo.m_mapName), command.Arg(1));
|
|
||||||
UTIL_Format(g_NextMap.m_tempChangeInfo.m_changeReason, sizeof(g_NextMap.m_tempChangeInfo.m_changeReason), "changelevel Command");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMOD_NEXTMAP_H_
|
|
||||||
#define _INCLUDE_SOURCEMOD_NEXTMAP_H_
|
|
||||||
|
|
||||||
#include "sm_globals.h"
|
|
||||||
#include "eiface.h"
|
|
||||||
#include "sh_list.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
|
|
||||||
struct MapChangeData
|
|
||||||
{
|
|
||||||
MapChangeData(const char *mapName, const char *changeReason, time_t time)
|
|
||||||
{
|
|
||||||
UTIL_Format(m_mapName, sizeof(m_mapName), mapName);
|
|
||||||
UTIL_Format(m_changeReason, sizeof(m_changeReason), changeReason);
|
|
||||||
startTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapChangeData()
|
|
||||||
{
|
|
||||||
m_mapName[0] = '\0';
|
|
||||||
m_changeReason[0] = '\0';
|
|
||||||
startTime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char m_mapName[32];
|
|
||||||
char m_changeReason[100];
|
|
||||||
time_t startTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
void CmdChangeLevelCallback(const CCommand &command);
|
|
||||||
#else
|
|
||||||
void CmdChangeLevelCallback();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class NextMapManager : public SMGlobalClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NextMapManager();
|
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
friend void CmdChangeLevelCallback(const CCommand &command);
|
|
||||||
#else
|
|
||||||
friend void CmdChangeLevelCallback();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void OnSourceModAllInitialized_Post();
|
|
||||||
void OnSourceModShutdown();
|
|
||||||
void OnSourceModLevelChange(const char *mapName);
|
|
||||||
|
|
||||||
const char *GetNextMap();
|
|
||||||
bool SetNextMap(const char *map);
|
|
||||||
|
|
||||||
void ForceChangeLevel(const char *mapName, const char* changeReason);
|
|
||||||
|
|
||||||
void HookChangeLevel(const char *map, const char *unknown);
|
|
||||||
|
|
||||||
public:
|
|
||||||
SourceHook::List<MapChangeData *> m_mapHistory;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MapChangeData m_tempChangeInfo;
|
|
||||||
char lastMap[32];
|
|
||||||
};
|
|
||||||
|
|
||||||
extern NextMapManager g_NextMap;
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_NEXTMAP_H_
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "PhraseCollection.h"
|
|
||||||
#include "Translator.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
|
|
||||||
CPhraseCollection::CPhraseCollection()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CPhraseCollection::~CPhraseCollection()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPhraseCollection::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPhraseFile *CPhraseCollection::AddPhraseFile(const char *filename)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
unsigned int fid;
|
|
||||||
IPhraseFile *pFile;
|
|
||||||
char full_name[PLATFORM_MAX_PATH];
|
|
||||||
|
|
||||||
/* No compat shim here. The user should have read the doc. */
|
|
||||||
UTIL_Format(full_name, sizeof(full_name), "%s.txt", filename);
|
|
||||||
|
|
||||||
fid = g_Translator.FindOrAddPhraseFile(full_name);
|
|
||||||
pFile = g_Translator.GetFileByIndex(fid);
|
|
||||||
|
|
||||||
for (i = 0; i < m_Files.size(); i++)
|
|
||||||
{
|
|
||||||
if (m_Files[i] == pFile)
|
|
||||||
{
|
|
||||||
return pFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Files.push_back(pFile);
|
|
||||||
|
|
||||||
return pFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CPhraseCollection::GetFileCount()
|
|
||||||
{
|
|
||||||
return (unsigned int)m_Files.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPhraseFile *CPhraseCollection::GetFile(unsigned int file)
|
|
||||||
{
|
|
||||||
if (file >= m_Files.size())
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_Files[file];
|
|
||||||
}
|
|
||||||
|
|
||||||
TransError CPhraseCollection::FindTranslation(const char *key, unsigned int langid, Translation *pTrans)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < m_Files.size(); i++)
|
|
||||||
{
|
|
||||||
if (m_Files[i]->GetTranslation(key, langid, pTrans) == Trans_Okay)
|
|
||||||
{
|
|
||||||
return Trans_Okay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Trans_BadPhrase;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CPhraseCollection::FormatString(char *buffer,
|
|
||||||
size_t maxlength,
|
|
||||||
const char *format,
|
|
||||||
void **params,
|
|
||||||
unsigned int numparams,
|
|
||||||
size_t *pOutLength,
|
|
||||||
const char **pFailPhrase)
|
|
||||||
{
|
|
||||||
unsigned int arg;
|
|
||||||
|
|
||||||
arg = 0;
|
|
||||||
if (!gnprintf(buffer, maxlength, format, this, params, numparams, arg, pOutLength, pFailPhrase))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg != numparams)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMOD_PHRASECOLLECTION_H_
|
|
||||||
#define _INCLUDE_SOURCEMOD_PHRASECOLLECTION_H_
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <sh_vector.h>
|
|
||||||
#include <ITranslator.h>
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
using namespace SourceMod;
|
|
||||||
|
|
||||||
class CPhraseCollection : public IPhraseCollection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CPhraseCollection();
|
|
||||||
~CPhraseCollection();
|
|
||||||
public:
|
|
||||||
IPhraseFile *AddPhraseFile(const char *filename);
|
|
||||||
unsigned int GetFileCount();
|
|
||||||
IPhraseFile *GetFile(unsigned int file);
|
|
||||||
void Destroy();
|
|
||||||
TransError FindTranslation(const char *key, unsigned int langid, Translation *pTrans);
|
|
||||||
bool FormatString(
|
|
||||||
char *buffer,
|
|
||||||
size_t maxlength,
|
|
||||||
const char *format,
|
|
||||||
void **params,
|
|
||||||
unsigned int numparams,
|
|
||||||
size_t *pOutLength,
|
|
||||||
const char **pFailPhrase);
|
|
||||||
private:
|
|
||||||
CVector<IPhraseFile *> m_Files;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_PHRASECOLLECTION_H_
|
|
||||||
+65
-203
@@ -46,14 +46,13 @@
|
|||||||
#include <inetchannel.h>
|
#include <inetchannel.h>
|
||||||
#include <iclient.h>
|
#include <iclient.h>
|
||||||
#include "GameConfigs.h"
|
#include "GameConfigs.h"
|
||||||
#include "ExtensionSys.h"
|
#include "systems/ExtensionSys.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;
|
||||||
@@ -69,15 +68,6 @@ SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *)
|
|||||||
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
|
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
|
||||||
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
|
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
|
||||||
#else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConCommand *maxplayersCmd = NULL;
|
|
||||||
|
|
||||||
class KickPlayerTimer : public ITimedEvent
|
class KickPlayerTimer : public ITimedEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -131,7 +121,7 @@ void PlayerManager::OnSourceModAllInitialized()
|
|||||||
ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
|
ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
|
||||||
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_Event, 3, p1);
|
||||||
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);
|
||||||
@@ -140,7 +130,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);
|
||||||
@@ -148,32 +137,6 @@ void PlayerManager::OnSourceModAllInitialized()
|
|||||||
|
|
||||||
m_bIsListenServer = !engine->IsDedicatedServer();
|
m_bIsListenServer = !engine->IsDedicatedServer();
|
||||||
m_ListenClient = 0;
|
m_ListenClient = 0;
|
||||||
|
|
||||||
g_ConVarManager.AddConVarChangeListener("tv_enable", this);
|
|
||||||
|
|
||||||
ConCommandBase *pBase = icvar->GetCommands();
|
|
||||||
ConCommand *pCmd = NULL;
|
|
||||||
while (pBase)
|
|
||||||
{
|
|
||||||
if (strcmp(pBase->GetName(), "maxplayers") == 0)
|
|
||||||
{
|
|
||||||
/* Don't want to return convar with same name */
|
|
||||||
if (!pBase->IsCommand())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCmd = (ConCommand *)pBase;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pBase = const_cast<ConCommandBase *>(pBase->GetNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pCmd != NULL)
|
|
||||||
{
|
|
||||||
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdMaxplayersCallback, true);
|
|
||||||
maxplayersCmd = pCmd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::OnSourceModShutdown()
|
void PlayerManager::OnSourceModShutdown()
|
||||||
@@ -196,20 +159,12 @@ 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);
|
||||||
g_Forwards.ReleaseForward(PostAdminFilter);
|
g_Forwards.ReleaseForward(PostAdminFilter);
|
||||||
|
|
||||||
delete [] m_Players;
|
delete [] m_Players;
|
||||||
|
|
||||||
g_ConVarManager.RemoveConVarChangeListener("tv_enable", this);
|
|
||||||
|
|
||||||
if (maxplayersCmd != NULL)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, maxplayersCmd, CmdMaxplayersCallback, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
|
ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
|
||||||
@@ -247,15 +202,13 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
|||||||
/* Initialize all players */
|
/* Initialize all players */
|
||||||
m_maxClients = clientMax;
|
m_maxClients = clientMax;
|
||||||
m_PlayerCount = 0;
|
m_PlayerCount = 0;
|
||||||
m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
|
m_Players = new CPlayer[m_maxClients + 1];
|
||||||
m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1];
|
m_AuthQueue = new unsigned int[m_maxClients + 1];
|
||||||
m_FirstPass = true;
|
m_FirstPass = true;
|
||||||
|
|
||||||
memset(m_AuthQueue, 0, sizeof(unsigned int) * (ABSOLUTE_PLAYER_LIMIT + 1));
|
memset(m_AuthQueue, 0, sizeof(unsigned int) * (m_maxClients + 1));
|
||||||
|
|
||||||
g_NumPlayersToAuth = &m_AuthQueue[0];
|
g_NumPlayersToAuth = &m_AuthQueue[0];
|
||||||
|
|
||||||
g_PluginSys.SyncMaxClients(clientMax);
|
|
||||||
}
|
}
|
||||||
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax);
|
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax);
|
||||||
m_onActivate->Execute(NULL);
|
m_onActivate->Execute(NULL);
|
||||||
@@ -272,13 +225,6 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
|||||||
|
|
||||||
g_OnMapStarted = true;
|
g_OnMapStarted = true;
|
||||||
|
|
||||||
SMGlobalClass *cls = SMGlobalClass::head;
|
|
||||||
while (cls)
|
|
||||||
{
|
|
||||||
cls->OnSourceModLevelActivated();
|
|
||||||
cls = cls->m_pGlobalClassNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
SM_ExecuteAllConfigs();
|
SM_ExecuteAllConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +288,7 @@ void PlayerManager::RunAuthChecks()
|
|||||||
unsigned int removed = 0;
|
unsigned int removed = 0;
|
||||||
for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
|
for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
|
||||||
{
|
{
|
||||||
pPlayer = &m_Players[m_AuthQueue[i]];
|
pPlayer = GetPlayerByIndex(m_AuthQueue[i]);
|
||||||
authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
|
authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
|
||||||
if (authstr && authstr[0] != '\0'
|
if (authstr && authstr[0] != '\0'
|
||||||
&& (strcmp(authstr, "STEAM_ID_PENDING") != 0))
|
&& (strcmp(authstr, "STEAM_ID_PENDING") != 0))
|
||||||
@@ -416,7 +362,6 @@ void PlayerManager::RunAuthChecks()
|
|||||||
bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
|
bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
|
||||||
{
|
{
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
|
||||||
|
|
||||||
List<IClientListener *>::iterator iter;
|
List<IClientListener *>::iterator iter;
|
||||||
IClientListener *pListener = NULL;
|
IClientListener *pListener = NULL;
|
||||||
@@ -431,29 +376,26 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
|
|||||||
|
|
||||||
cell_t res = 1;
|
cell_t res = 1;
|
||||||
|
|
||||||
pPlayer->Initialize(pszName, pszAddress, pEntity);
|
m_Players[client].Initialize(pszName, pszAddress, pEntity);
|
||||||
m_clconnect->PushCell(client);
|
m_clconnect->PushCell(client);
|
||||||
m_clconnect->PushStringEx(reject, maxrejectlen, SM_PARAM_STRING_UTF8, SM_PARAM_COPYBACK);
|
m_clconnect->PushStringEx(reject, maxrejectlen, SM_PARAM_STRING_UTF8, SM_PARAM_COPYBACK);
|
||||||
m_clconnect->PushCell(maxrejectlen);
|
m_clconnect->PushCell(maxrejectlen);
|
||||||
m_clconnect->Execute(&res);
|
m_clconnect->Execute(&res, NULL);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
if (!pPlayer->IsAuthorized())
|
if (!m_Players[client].IsAuthorized())
|
||||||
{
|
{
|
||||||
m_AuthQueue[++m_AuthQueue[0]] = client;
|
m_AuthQueue[++m_AuthQueue[0]] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!pPlayer->IsFakeClient())
|
RETURN_META_VALUE(MRES_SUPERCEDE, false);
|
||||||
{
|
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +403,7 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
|
|||||||
{
|
{
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
bool orig_value = META_RESULT_ORIG_RET(bool);
|
bool orig_value = META_RESULT_ORIG_RET(bool);
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
CPlayer *pPlayer = GetPlayerByIndex(client);
|
||||||
|
|
||||||
if (orig_value)
|
if (orig_value)
|
||||||
{
|
{
|
||||||
@@ -476,21 +418,13 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pPlayer->IsFakeClient()
|
|
||||||
&& m_bIsListenServer
|
|
||||||
&& strncmp(pszAddress, "127.0.0.1", 9) == 0)
|
|
||||||
{
|
|
||||||
m_ListenClient = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
cell_t res;
|
|
||||||
OnClientConnected->PushCell(client);
|
|
||||||
OnClientConnected->Execute(&res, NULL);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!pPlayer->IsFakeClient()
|
||||||
|
&& m_bIsListenServer
|
||||||
|
&& strncmp(pszAddress, "127.0.0.1", 9) == 0)
|
||||||
{
|
{
|
||||||
InvalidatePlayer(pPlayer);
|
m_ListenClient = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -500,8 +434,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
|||||||
{
|
{
|
||||||
cell_t res;
|
cell_t res;
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
|
||||||
|
|
||||||
|
CPlayer *pPlayer = GetPlayerByIndex(client);
|
||||||
/* If they're not connected, they're a bot */
|
/* If they're not connected, they're a bot */
|
||||||
if (!pPlayer->IsConnected())
|
if (!pPlayer->IsConnected())
|
||||||
{
|
{
|
||||||
@@ -509,7 +443,6 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
|||||||
char error[255];
|
char error[255];
|
||||||
const char *authid = engine->GetPlayerNetworkIDString(pEntity);
|
const char *authid = engine->GetPlayerNetworkIDString(pEntity);
|
||||||
pPlayer->Authorize(authid);
|
pPlayer->Authorize(authid);
|
||||||
pPlayer->m_bFakeClient = true;
|
|
||||||
if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
|
if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
|
||||||
{
|
{
|
||||||
/* :TODO: kick the bot if it's rejected */
|
/* :TODO: kick the bot if it's rejected */
|
||||||
@@ -561,7 +494,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pPlayer->Connect();
|
m_Players[client].Connect();
|
||||||
m_PlayerCount++;
|
m_PlayerCount++;
|
||||||
|
|
||||||
List<IClientListener *>::iterator iter;
|
List<IClientListener *>::iterator iter;
|
||||||
@@ -575,9 +508,9 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
|||||||
m_clputinserver->PushCell(client);
|
m_clputinserver->PushCell(client);
|
||||||
m_clputinserver->Execute(&res, NULL);
|
m_clputinserver->Execute(&res, NULL);
|
||||||
|
|
||||||
if (pPlayer->IsAuthorized())
|
if (m_Players[client].IsAuthorized())
|
||||||
{
|
{
|
||||||
pPlayer->DoPostConnectAuthorization();
|
m_Players[client].DoPostConnectAuthorization();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,9 +531,8 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
|
|||||||
{
|
{
|
||||||
cell_t res;
|
cell_t res;
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
|
||||||
|
|
||||||
if (pPlayer->IsConnected())
|
if (m_Players[client].IsConnected())
|
||||||
{
|
{
|
||||||
m_cldisconnect->PushCell(client);
|
m_cldisconnect->PushCell(client);
|
||||||
m_cldisconnect->Execute(&res, NULL);
|
m_cldisconnect->Execute(&res, NULL);
|
||||||
@@ -611,7 +543,7 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPlayer->WasCountedAsInGame())
|
if (m_Players[client].WasCountedAsInGame())
|
||||||
{
|
{
|
||||||
m_PlayerCount--;
|
m_PlayerCount--;
|
||||||
}
|
}
|
||||||
@@ -624,7 +556,29 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
|
|||||||
pListener->OnClientDisconnecting(client);
|
pListener->OnClientDisconnecting(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidatePlayer(pPlayer);
|
/**
|
||||||
|
* Remove client from auth queue if necessary
|
||||||
|
*/
|
||||||
|
if (!m_Players[client].IsAuthorized())
|
||||||
|
{
|
||||||
|
for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
|
||||||
|
{
|
||||||
|
if (m_AuthQueue[i] == (unsigned)client)
|
||||||
|
{
|
||||||
|
/* Move everything ahead of us back by one */
|
||||||
|
for (unsigned int j=i+1; j<=m_AuthQueue[0]; j++)
|
||||||
|
{
|
||||||
|
m_AuthQueue[j-1] = m_AuthQueue[j];
|
||||||
|
}
|
||||||
|
/* Remove us and break */
|
||||||
|
m_AuthQueue[0]--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Players[client].Disconnect();
|
||||||
|
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = 0;
|
||||||
|
|
||||||
if (m_ListenClient == client)
|
if (m_ListenClient == client)
|
||||||
{
|
{
|
||||||
@@ -659,9 +613,9 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
|
|||||||
#endif
|
#endif
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
cell_t res = Pl_Continue;
|
cell_t res = Pl_Continue;
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
|
||||||
|
|
||||||
if (!pPlayer->IsConnected())
|
CPlayer *pPlayer = GetPlayerByIndex(client);
|
||||||
|
if (!pPlayer || !pPlayer->IsConnected())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -713,9 +667,8 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
|
|||||||
{
|
{
|
||||||
cell_t res;
|
cell_t res;
|
||||||
int client = engine->IndexOfEdict(pEntity);
|
int client = engine->IndexOfEdict(pEntity);
|
||||||
CPlayer *pPlayer = &m_Players[client];
|
|
||||||
|
|
||||||
if (!pPlayer->IsConnected())
|
if (!m_Players[client].IsConnected())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -723,42 +676,42 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
|
|||||||
m_clinfochanged->PushCell(engine->IndexOfEdict(pEntity));
|
m_clinfochanged->PushCell(engine->IndexOfEdict(pEntity));
|
||||||
m_clinfochanged->Execute(&res, NULL);
|
m_clinfochanged->Execute(&res, NULL);
|
||||||
|
|
||||||
IPlayerInfo *info = pPlayer->GetPlayerInfo();
|
IPlayerInfo *info = m_Players[client].GetPlayerInfo();
|
||||||
const char *new_name = info ? info->GetName() : engine->GetClientConVarValue(client, "name");
|
const char *new_name = info ? info->GetName() : engine->GetClientConVarValue(client, "name");
|
||||||
const char *old_name = pPlayer->m_Name.c_str();
|
const char *old_name = m_Players[client].m_Name.c_str();
|
||||||
|
|
||||||
if (strcmp(old_name, new_name) != 0)
|
if (strcmp(old_name, new_name) != 0)
|
||||||
{
|
{
|
||||||
AdminId id = g_Admins.FindAdminByIdentity("name", new_name);
|
AdminId id = g_Admins.FindAdminByIdentity("name", new_name);
|
||||||
if (id != INVALID_ADMIN_ID && pPlayer->GetAdminId() != id)
|
if (id != INVALID_ADMIN_ID && m_Players[client].GetAdminId() != id)
|
||||||
{
|
{
|
||||||
if (!CheckSetAdminName(client, pPlayer, id))
|
if (!CheckSetAdminName(client, &m_Players[client], id))
|
||||||
{
|
{
|
||||||
pPlayer->Kick("Your name is reserved by SourceMod; set your password to use it.");
|
m_Players[client].Kick("Your name is reserved by SourceMod; set your password to use it.");
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
} else if ((id = g_Admins.FindAdminByIdentity("name", old_name)) != INVALID_ADMIN_ID) {
|
} else if ((id = g_Admins.FindAdminByIdentity("name", old_name)) != INVALID_ADMIN_ID) {
|
||||||
if (id == pPlayer->GetAdminId())
|
if (id == m_Players[client].GetAdminId())
|
||||||
{
|
{
|
||||||
/* This player is changing their name; force them to drop admin privileges! */
|
/* This player is changing their name; force them to drop admin privileges! */
|
||||||
pPlayer->SetAdminId(INVALID_ADMIN_ID, false);
|
m_Players[client].SetAdminId(INVALID_ADMIN_ID, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pPlayer->SetName(new_name);
|
m_Players[client].SetName(new_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_PassInfoVar.size() > 0)
|
if (m_PassInfoVar.size() > 0)
|
||||||
{
|
{
|
||||||
/* Try for a password change */
|
/* Try for a password change */
|
||||||
const char *old_pass = pPlayer->m_LastPassword.c_str();
|
const char *old_pass = m_Players[client].m_LastPassword.c_str();
|
||||||
const char *new_pass = engine->GetClientConVarValue(client, m_PassInfoVar.c_str());
|
const char *new_pass = engine->GetClientConVarValue(client, m_PassInfoVar.c_str());
|
||||||
if (strcmp(old_pass, new_pass) != 0)
|
if (strcmp(old_pass, new_pass) != 0)
|
||||||
{
|
{
|
||||||
pPlayer->m_LastPassword.assign(new_pass);
|
m_Players[client].m_LastPassword.assign(new_pass);
|
||||||
if (pPlayer->IsInGame() && pPlayer->IsAuthorized())
|
if (m_Players[client].IsInGame() && m_Players[client].IsAuthorized())
|
||||||
{
|
{
|
||||||
/* If there is already an admin id assigned, this will just bail out. */
|
/* If there is already an admin id assigned, this will just bail out. */
|
||||||
pPlayer->DoBasicAdminChecks();
|
m_Players[client].DoBasicAdminChecks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -909,33 +862,6 @@ void PlayerManager::UnregisterCommandTargetProcessor(ICommandTargetProcessor *pH
|
|||||||
target_processors.remove(pHandler);
|
target_processors.remove(pHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::InvalidatePlayer(CPlayer *pPlayer)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Remove client from auth queue if necessary
|
|
||||||
*/
|
|
||||||
if (!pPlayer->IsAuthorized())
|
|
||||||
{
|
|
||||||
for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
|
|
||||||
{
|
|
||||||
if (m_AuthQueue[i] == (unsigned)pPlayer->m_iIndex)
|
|
||||||
{
|
|
||||||
/* Move everything ahead of us back by one */
|
|
||||||
for (unsigned int j=i+1; j<=m_AuthQueue[0]; j++)
|
|
||||||
{
|
|
||||||
m_AuthQueue[j-1] = m_AuthQueue[j];
|
|
||||||
}
|
|
||||||
/* Remove us and break */
|
|
||||||
m_AuthQueue[0]--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_UserIdLookUp[engine->GetPlayerUserId(pPlayer->m_pEdict)] = 0;
|
|
||||||
pPlayer->Disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
int PlayerManager::InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags)
|
int PlayerManager::InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags)
|
||||||
{
|
{
|
||||||
if ((flags & COMMAND_FILTER_CONNECTED) == COMMAND_FILTER_CONNECTED
|
if ((flags & COMMAND_FILTER_CONNECTED) == COMMAND_FILTER_CONNECTED
|
||||||
@@ -1261,68 +1187,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 )
|
|
||||||
{
|
|
||||||
m_maxClients = newvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ )
|
|
||||||
{
|
|
||||||
if (newvalue == -1)
|
|
||||||
{
|
|
||||||
newvalue = gpGlobals->maxClients;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newvalue == MaxClients())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Notify the rest of core */
|
|
||||||
SMGlobalClass *pBase = SMGlobalClass::head;
|
|
||||||
while (pBase)
|
|
||||||
{
|
|
||||||
pBase->OnSourceModMaxPlayersChanged(newvalue);
|
|
||||||
pBase = pBase->m_pGlobalClassNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Notify Extensions */
|
|
||||||
List<IClientListener *>::iterator iter;
|
|
||||||
IClientListener *pListener = NULL;
|
|
||||||
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
|
||||||
{
|
|
||||||
pListener = (*iter);
|
|
||||||
if (pListener->GetClientListenerVersion() >= 8)
|
|
||||||
{
|
|
||||||
pListener->OnMaxPlayersChanged(newvalue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
void CmdMaxplayersCallback(const CCommand &command)
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
void CmdMaxplayersCallback()
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_Players.MaxPlayersChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
*** PLAYER CODE ***
|
*** PLAYER CODE ***
|
||||||
*******************/
|
*******************/
|
||||||
@@ -1339,8 +1203,7 @@ CPlayer::CPlayer()
|
|||||||
m_bAdminCheckSignalled = false;
|
m_bAdminCheckSignalled = false;
|
||||||
m_bIsInKickQueue = false;
|
m_bIsInKickQueue = false;
|
||||||
m_LastPassword.clear();
|
m_LastPassword.clear();
|
||||||
m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
m_LangId = LANGUAGE_ENGLISH;
|
||||||
m_bFakeClient = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||||
@@ -1408,7 +1271,6 @@ void CPlayer::Disconnect()
|
|||||||
m_bAdminCheckSignalled = false;
|
m_bAdminCheckSignalled = false;
|
||||||
m_UserId = -1;
|
m_UserId = -1;
|
||||||
m_bIsInKickQueue = false;
|
m_bIsInKickQueue = false;
|
||||||
m_bFakeClient = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::SetName(const char *name)
|
void CPlayer::SetName(const char *name)
|
||||||
@@ -1473,7 +1335,7 @@ IPlayerInfo *CPlayer::GetPlayerInfo()
|
|||||||
|
|
||||||
bool CPlayer::IsFakeClient()
|
bool CPlayer::IsFakeClient()
|
||||||
{
|
{
|
||||||
return m_bFakeClient;
|
return (strcmp(m_AuthID.c_str(), "BOT") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::SetAdminId(AdminId id, bool temporary)
|
void CPlayer::SetAdminId(AdminId id, bool temporary)
|
||||||
@@ -1639,7 +1501,7 @@ void CPlayer::DoBasicAdminChecks()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check steam id */
|
/* Check IP address */
|
||||||
if ((id = g_Admins.FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID)
|
if ((id = g_Admins.FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID)
|
||||||
{
|
{
|
||||||
if (g_Players.CheckSetAdmin(client, this, id))
|
if (g_Players.CheckSetAdmin(client, this, id))
|
||||||
|
|||||||
+1
-15
@@ -41,7 +41,6 @@
|
|||||||
#include <sh_string.h>
|
#include <sh_string.h>
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
#include <sh_vector.h>
|
#include <sh_vector.h>
|
||||||
#include "ConVarManager.h"
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
|
||||||
@@ -106,13 +105,11 @@ private:
|
|||||||
int m_iIndex;
|
int m_iIndex;
|
||||||
unsigned int m_LangId;
|
unsigned int m_LangId;
|
||||||
int m_UserId;
|
int m_UserId;
|
||||||
bool m_bFakeClient;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerManager :
|
class PlayerManager :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
public IPlayerManager,
|
public IPlayerManager
|
||||||
public IConVarChangeListener
|
|
||||||
{
|
{
|
||||||
friend class CPlayer;
|
friend class CPlayer;
|
||||||
public:
|
public:
|
||||||
@@ -123,7 +120,6 @@ public: //SMGlobalClass
|
|||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
void OnSourceModLevelEnd();
|
void OnSourceModLevelEnd();
|
||||||
ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
|
ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
|
||||||
void OnSourceModMaxPlayersChanged(int newvalue);
|
|
||||||
public:
|
public:
|
||||||
CPlayer *GetPlayerByIndex(int client) const;
|
CPlayer *GetPlayerByIndex(int client) const;
|
||||||
void RunAuthChecks();
|
void RunAuthChecks();
|
||||||
@@ -156,8 +152,6 @@ public: //IPlayerManager
|
|||||||
void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
|
void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
|
||||||
void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
|
void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
|
||||||
void ProcessCommandTarget(cmd_target_info_t *info);
|
void ProcessCommandTarget(cmd_target_info_t *info);
|
||||||
public: // IConVarChangeListener
|
|
||||||
void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
|
|
||||||
public:
|
public:
|
||||||
inline int MaxClients()
|
inline int MaxClients()
|
||||||
{
|
{
|
||||||
@@ -177,10 +171,8 @@ public:
|
|||||||
void RecheckAnyAdmins();
|
void RecheckAnyAdmins();
|
||||||
unsigned int GetReplyTo();
|
unsigned int GetReplyTo();
|
||||||
unsigned int SetReplyTo(unsigned int reply);
|
unsigned int SetReplyTo(unsigned int reply);
|
||||||
void MaxPlayersChanged(int newvalue = -1);
|
|
||||||
private:
|
private:
|
||||||
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
void InvalidatePlayer(CPlayer *pPlayer);
|
|
||||||
private:
|
private:
|
||||||
List<IClientListener *> m_hooks;
|
List<IClientListener *> m_hooks;
|
||||||
IForward *m_clconnect;
|
IForward *m_clconnect;
|
||||||
@@ -204,12 +196,6 @@ private:
|
|||||||
int m_ListenClient;
|
int m_ListenClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
|
||||||
void CmdMaxplayersCallback(const CCommand &command);
|
|
||||||
#else
|
|
||||||
void CmdMaxplayersCallback();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern PlayerManager g_Players;
|
extern PlayerManager g_Players;
|
||||||
extern bool g_OnMapStarted;
|
extern bool g_OnMapStarted;
|
||||||
extern const unsigned int *g_NumPlayersToAuth;
|
extern const unsigned int *g_NumPlayersToAuth;
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
@@ -1,529 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ShareSys.h"
|
|
||||||
#include "HandleSys.h"
|
|
||||||
#include "ExtensionSys.h"
|
|
||||||
#include "LibrarySys.h"
|
|
||||||
#include "PluginSys.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
|
|
||||||
ShareSystem g_ShareSys;
|
|
||||||
static unsigned int g_mark_serial = 0;
|
|
||||||
|
|
||||||
ShareSystem::ShareSystem()
|
|
||||||
{
|
|
||||||
m_IdentRoot.ident = 0;
|
|
||||||
m_TypeRoot = 0;
|
|
||||||
m_IfaceType = 0;
|
|
||||||
m_CoreType = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentityToken_t *ShareSystem::CreateCoreIdentity()
|
|
||||||
{
|
|
||||||
if (!m_CoreType)
|
|
||||||
{
|
|
||||||
m_CoreType = CreateIdentType("CORE");
|
|
||||||
}
|
|
||||||
|
|
||||||
return CreateIdentity(m_CoreType, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::Initialize()
|
|
||||||
{
|
|
||||||
TypeAccess sec;
|
|
||||||
|
|
||||||
g_HandleSys.InitAccessDefaults(&sec, NULL);
|
|
||||||
sec.ident = GetIdentRoot();
|
|
||||||
|
|
||||||
m_TypeRoot = g_HandleSys.CreateType("Identity", this, 0, &sec, NULL, NULL, NULL);
|
|
||||||
m_IfaceType = g_HandleSys.CreateType("Interface", this, 0, NULL, NULL, GetIdentRoot(), NULL);
|
|
||||||
|
|
||||||
/* Initialize our static identity handle */
|
|
||||||
m_IdentRoot.ident = g_HandleSys.CreateHandle(m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL);
|
|
||||||
|
|
||||||
/* Add the Handle System and others... they are too innocent and pure to do it themselves */
|
|
||||||
AddInterface(NULL, &g_HandleSys);
|
|
||||||
AddInterface(NULL, &g_LibSys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::OnSourceModShutdown()
|
|
||||||
{
|
|
||||||
if (m_CoreType)
|
|
||||||
{
|
|
||||||
g_HandleSys.RemoveType(m_CoreType, GetIdentRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
g_HandleSys.RemoveType(m_IfaceType, GetIdentRoot());
|
|
||||||
g_HandleSys.RemoveType(m_TypeRoot, GetIdentRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentityType_t ShareSystem::FindIdentType(const char *name)
|
|
||||||
{
|
|
||||||
HandleType_t type;
|
|
||||||
|
|
||||||
if (g_HandleSys.FindHandleType(name, &type))
|
|
||||||
{
|
|
||||||
if (g_HandleSys.TypeCheck(type, m_TypeRoot))
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentityType_t ShareSystem::CreateIdentType(const char *name)
|
|
||||||
{
|
|
||||||
if (!m_TypeRoot)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_HandleSys.CreateType(name, this, m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::OnHandleDestroy(HandleType_t type, void *object)
|
|
||||||
{
|
|
||||||
/* THIS WILL NEVER BE CALLED FOR ANYTHING WITH THE IDENTITY TYPE */
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentityToken_t *ShareSystem::CreateIdentity(IdentityType_t type, void *ptr)
|
|
||||||
{
|
|
||||||
if (!m_TypeRoot)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* :TODO: Cache? */
|
|
||||||
IdentityToken_t *pToken = new IdentityToken_t;
|
|
||||||
|
|
||||||
HandleSecurity sec;
|
|
||||||
sec.pOwner = sec.pIdentity = GetIdentRoot();
|
|
||||||
|
|
||||||
pToken->ident = g_HandleSys.CreateHandleInt(type, NULL, &sec, NULL, NULL, true);
|
|
||||||
pToken->ptr = ptr;
|
|
||||||
pToken->type = type;
|
|
||||||
|
|
||||||
return pToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShareSystem::AddInterface(IExtension *myself, SMInterface *iface)
|
|
||||||
{
|
|
||||||
if (!iface)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IfaceInfo info;
|
|
||||||
|
|
||||||
info.owner = myself;
|
|
||||||
info.iface = iface;
|
|
||||||
|
|
||||||
m_Interfaces.push_back(info);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShareSystem::RequestInterface(const char *iface_name,
|
|
||||||
unsigned int iface_vers,
|
|
||||||
IExtension *myself,
|
|
||||||
SMInterface **pIface)
|
|
||||||
{
|
|
||||||
/* See if the interface exists */
|
|
||||||
List<IfaceInfo>::iterator iter;
|
|
||||||
SMInterface *iface;
|
|
||||||
IExtension *iface_owner;
|
|
||||||
bool found = false;
|
|
||||||
for (iter=m_Interfaces.begin(); iter!=m_Interfaces.end(); iter++)
|
|
||||||
{
|
|
||||||
IfaceInfo &info = (*iter);
|
|
||||||
iface = info.iface;
|
|
||||||
if (strcmp(iface->GetInterfaceName(), iface_name) == 0)
|
|
||||||
{
|
|
||||||
if (iface->GetInterfaceVersion() == iface_vers
|
|
||||||
|| iface->IsVersionCompatible(iface_vers))
|
|
||||||
{
|
|
||||||
iface_owner = info.owner;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add a dependency node */
|
|
||||||
if (iface_owner)
|
|
||||||
{
|
|
||||||
IfaceInfo info;
|
|
||||||
info.iface = iface;
|
|
||||||
info.owner = iface_owner;
|
|
||||||
g_Extensions.BindDependency(myself, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIface)
|
|
||||||
{
|
|
||||||
*pIface = iface;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::AddNatives(IExtension *myself, const sp_nativeinfo_t *natives)
|
|
||||||
{
|
|
||||||
CNativeOwner *pOwner;
|
|
||||||
|
|
||||||
pOwner = g_Extensions.GetNativeOwner(myself);
|
|
||||||
|
|
||||||
pOwner->AddNatives(natives);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::DestroyIdentity(IdentityToken_t *identity)
|
|
||||||
{
|
|
||||||
HandleSecurity sec;
|
|
||||||
|
|
||||||
sec.pOwner = GetIdentRoot();
|
|
||||||
sec.pIdentity = GetIdentRoot();
|
|
||||||
|
|
||||||
g_HandleSys.FreeHandle(identity->ident, &sec);
|
|
||||||
delete identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::DestroyIdentType(IdentityType_t type)
|
|
||||||
{
|
|
||||||
g_HandleSys.RemoveType(type, GetIdentRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::RemoveInterfaces(IExtension *pExtension)
|
|
||||||
{
|
|
||||||
List<IfaceInfo>::iterator iter = m_Interfaces.begin();
|
|
||||||
|
|
||||||
while (iter != m_Interfaces.end())
|
|
||||||
{
|
|
||||||
if ((*iter).owner == pExtension)
|
|
||||||
{
|
|
||||||
iter = m_Interfaces.erase(iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::AddDependency(IExtension *myself, const char *filename, bool require, bool autoload)
|
|
||||||
{
|
|
||||||
g_Extensions.AddDependency(myself, filename, require, autoload);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::RegisterLibrary(IExtension *myself, const char *name)
|
|
||||||
{
|
|
||||||
g_Extensions.AddLibrary(myself, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
CNativeOwner *pOwner;
|
|
||||||
|
|
||||||
pOwner = g_Extensions.GetNativeOwner(myself);
|
|
||||||
|
|
||||||
for (i = 0; natives[i].func != NULL && natives[i].name != NULL; i++)
|
|
||||||
{
|
|
||||||
if ((pEntry = FindNative(natives[i].name)) == NULL)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry->owner != g_pCoreNatives)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry->replacement.owner != NULL)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now it's safe to add the override */
|
|
||||||
pEntry->replacement.func = natives[i].func;
|
|
||||||
pEntry->replacement.owner = pOwner;
|
|
||||||
pOwner->AddReplacedNative(pEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeEntry *ShareSystem::FindNative(const char *name)
|
|
||||||
{
|
|
||||||
NativeEntry **ppEntry;
|
|
||||||
|
|
||||||
if ((ppEntry = m_NtvCache.retrieve(name)) == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *ppEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
|
|
||||||
{
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
sp_native_t *native;
|
|
||||||
uint32_t i, native_count;
|
|
||||||
IPluginContext *pContext;
|
|
||||||
|
|
||||||
pContext = pPlugin->GetBaseContext();
|
|
||||||
|
|
||||||
/* Generate a new serial ID, mark our dependencies with it. */
|
|
||||||
g_mark_serial++;
|
|
||||||
pPlugin->PropogateMarkSerial(g_mark_serial);
|
|
||||||
|
|
||||||
native_count = pContext->GetNativesNum();
|
|
||||||
for (i = 0; i < native_count; i++)
|
|
||||||
{
|
|
||||||
if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we're bound, check if there is a replacement available.
|
|
||||||
* If not, this native is totally finalized.
|
|
||||||
*/
|
|
||||||
if (native->status == SP_NATIVE_BOUND)
|
|
||||||
{
|
|
||||||
pEntry = (NativeEntry *)native->user;
|
|
||||||
assert(pEntry != NULL);
|
|
||||||
if (pEntry->replacement.owner == NULL
|
|
||||||
|| (pEntry->replacement.owner != NULL
|
|
||||||
&& pEntry->replacement.func == native->pfn))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Otherwise, the native must be in our cache. */
|
|
||||||
else if ((pEntry = FindNative(native->name)) == NULL)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bCoreOnly && pEntry->owner != g_pCoreNatives)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
BindNativeToPlugin(pPlugin, native, i, pEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, NativeEntry *pEntry)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
sp_native_t *native;
|
|
||||||
IPluginContext *pContext;
|
|
||||||
|
|
||||||
pContext = pPlugin->GetBaseContext();
|
|
||||||
|
|
||||||
if (pContext->FindNativeByName(pEntry->name, &i) != SP_ERROR_NONE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (native->status == SP_NATIVE_BOUND)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BindNativeToPlugin(pPlugin, native, i, pEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin,
|
|
||||||
sp_native_t *native,
|
|
||||||
uint32_t index,
|
|
||||||
NativeEntry *pEntry)
|
|
||||||
{
|
|
||||||
/* Mark as bound... we do the rest next. */
|
|
||||||
native->status = SP_NATIVE_BOUND;
|
|
||||||
native->user = pEntry;
|
|
||||||
|
|
||||||
/* See if a replacement is available. */
|
|
||||||
if (pEntry->replacement.owner != NULL)
|
|
||||||
{
|
|
||||||
/* Perform a replacement bind. */
|
|
||||||
native->pfn = pEntry->replacement.func;
|
|
||||||
pEntry->replacement.owner->AddWeakRef(WeakNative(pPlugin, index, pEntry));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Perform a normal bind. */
|
|
||||||
native->pfn = pEntry->func;
|
|
||||||
|
|
||||||
/* We don't bother with dependency crap if the owner is Core. */
|
|
||||||
if (pEntry->owner != g_pCoreNatives)
|
|
||||||
{
|
|
||||||
/* The native is optional, this is a special case */
|
|
||||||
if ((native->flags & SP_NTVFLAG_OPTIONAL) == SP_NTVFLAG_OPTIONAL)
|
|
||||||
{
|
|
||||||
/* Only add if there is a valid owner. */
|
|
||||||
if (pEntry->owner != NULL)
|
|
||||||
{
|
|
||||||
pEntry->owner->AddWeakRef(WeakNative(pPlugin, index));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
native->status = SP_NATIVE_UNBOUND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Otherwise, we're a strong dependent and not a weak one */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* See if this has already been marked as a dependent.
|
|
||||||
* If it has, it means this relationship has already occurred,
|
|
||||||
* and there is no reason to do it again.
|
|
||||||
*/
|
|
||||||
if (pEntry->owner != pPlugin
|
|
||||||
&& pEntry->owner->GetMarkSerial() != g_mark_serial)
|
|
||||||
{
|
|
||||||
/* This has not been marked as a dependency yet */
|
|
||||||
//pPlugin->AddDependency(pEntry->owner);
|
|
||||||
pEntry->owner->AddDependent(pPlugin);
|
|
||||||
pEntry->owner->SetMarkSerial(g_mark_serial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeEntry *ShareSystem::AddNativeToCache(CNativeOwner *pOwner, const sp_nativeinfo_t *ntv)
|
|
||||||
{
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
|
|
||||||
if ((pEntry = FindNative(ntv->name)) == NULL)
|
|
||||||
{
|
|
||||||
pEntry = new NativeEntry;
|
|
||||||
|
|
||||||
pEntry->owner = pOwner;
|
|
||||||
pEntry->name = ntv->name;
|
|
||||||
pEntry->func = ntv->func;
|
|
||||||
pEntry->replacement.func = NULL;
|
|
||||||
pEntry->replacement.owner = NULL;
|
|
||||||
pEntry->fake = NULL;
|
|
||||||
|
|
||||||
m_NtvCache.insert(ntv->name, pEntry);
|
|
||||||
|
|
||||||
return pEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry->owner != NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry->owner = pOwner;
|
|
||||||
pEntry->func = ntv->func;
|
|
||||||
pEntry->name = ntv->name;
|
|
||||||
|
|
||||||
return pEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareSystem::ClearNativeFromCache(CNativeOwner *pOwner, const char *name)
|
|
||||||
{
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
|
|
||||||
if ((pEntry = FindNative(name)) == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry->owner != pOwner)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry->fake != NULL)
|
|
||||||
{
|
|
||||||
g_pSourcePawn2->DestroyFakeNative(pEntry->func);
|
|
||||||
delete pEntry->fake;
|
|
||||||
pEntry->fake = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry->func = NULL;
|
|
||||||
pEntry->name = NULL;
|
|
||||||
pEntry->owner = NULL;
|
|
||||||
pEntry->replacement.func = NULL;
|
|
||||||
pEntry->replacement.owner = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeEntry *ShareSystem::AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKENATIVE_FUNC func)
|
|
||||||
{
|
|
||||||
FakeNative *pFake;
|
|
||||||
NativeEntry *pEntry;
|
|
||||||
SPVM_NATIVE_FUNC gate;
|
|
||||||
|
|
||||||
if ((pEntry = FindNative(name)) != NULL && pEntry->owner != NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pFake = new FakeNative;
|
|
||||||
|
|
||||||
if ((gate = g_pSourcePawn2->CreateFakeNative(func, pFake)) == NULL)
|
|
||||||
{
|
|
||||||
delete pFake;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEntry == NULL)
|
|
||||||
{
|
|
||||||
pEntry = new NativeEntry;
|
|
||||||
m_NtvCache.insert(name, pEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
pFake->call = pFunc;
|
|
||||||
pFake->ctx = pFunc->GetParentContext();
|
|
||||||
strncopy(pFake->name, name, sizeof(pFake->name));
|
|
||||||
|
|
||||||
pEntry->fake = pFake;
|
|
||||||
pEntry->func = gate;
|
|
||||||
pEntry->name = pFake->name;
|
|
||||||
pEntry->owner = g_PluginSys.GetPluginByCtx(pFake->ctx->GetContext());
|
|
||||||
pEntry->replacement.func = NULL;
|
|
||||||
pEntry->replacement.owner = NULL;
|
|
||||||
|
|
||||||
return pEntry;
|
|
||||||
}
|
|
||||||
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+91
-179
@@ -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-2007 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
|
||||||
@@ -38,11 +38,9 @@
|
|||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "PhraseCollection.h"
|
|
||||||
#include "ShareSys.h"
|
|
||||||
|
|
||||||
Translator g_Translator;
|
Translator g_Translator;
|
||||||
IPhraseCollection *g_pCorePhrases = NULL;
|
CPhraseFile *g_pCorePhrases = NULL;
|
||||||
unsigned int g_pCorePhraseID = 0;
|
unsigned int g_pCorePhraseID = 0;
|
||||||
|
|
||||||
struct trans_t
|
struct trans_t
|
||||||
@@ -103,7 +101,7 @@ void CPhraseFile::ParseWarning(const char *message, ...)
|
|||||||
m_FileLogged = true;
|
m_FileLogged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Logger.LogError("[SM] %s", buffer);
|
g_Logger.LogError("[SM] %s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPhraseFile::ReparseFile()
|
void CPhraseFile::ReparseFile()
|
||||||
@@ -152,45 +150,6 @@ void CPhraseFile::ReparseFile()
|
|||||||
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
|
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
|
||||||
g_Logger.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
|
g_Logger.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *code;
|
|
||||||
for (unsigned int i = 1; i < m_LangCount; i++)
|
|
||||||
{
|
|
||||||
if (!m_pTranslator->GetLanguageInfo(i, &code, NULL))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_SourceMod.BuildPath(Path_SM,
|
|
||||||
path,
|
|
||||||
PLATFORM_MAX_PATH,
|
|
||||||
"translations/%s/%s",
|
|
||||||
code,
|
|
||||||
m_File.c_str());
|
|
||||||
|
|
||||||
/* Speculatively load these. */
|
|
||||||
if (!g_LibSys.PathExists(path))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err=textparsers->ParseFile_SMC(path, this, &states)) != SMCError_Okay)
|
|
||||||
{
|
|
||||||
const char *msg = textparsers->GetSMCErrorString(err);
|
|
||||||
if (!msg)
|
|
||||||
{
|
|
||||||
msg = m_ParseError.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s/%s\"",
|
|
||||||
code,
|
|
||||||
m_File.c_str());
|
|
||||||
g_Logger.LogError("[SM] Error (line %d, column %d): %s",
|
|
||||||
states.line,
|
|
||||||
states.col,
|
|
||||||
msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPhraseFile::ReadSMC_ParseStart()
|
void CPhraseFile::ReadSMC_ParseStart()
|
||||||
@@ -217,21 +176,21 @@ SMCResult CPhraseFile::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
m_ParseState = PPS_InPhrase;
|
m_ParseState = PPS_InPhrase;
|
||||||
recognized = true;
|
recognized = true;
|
||||||
|
|
||||||
void *value;
|
phrase_t *pPhrase;
|
||||||
if (sm_trie_retrieve(m_pPhraseLookup, name, &value))
|
m_CurPhrase = m_pMemory->CreateMem(sizeof(phrase_t), (void **)&pPhrase);
|
||||||
{
|
|
||||||
m_CurPhrase = reinterpret_cast<int>(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
phrase_t *pPhrase;
|
|
||||||
|
|
||||||
m_CurPhrase = m_pMemory->CreateMem(sizeof(phrase_t), (void **)&pPhrase);
|
|
||||||
sm_trie_insert(m_pPhraseLookup, name, reinterpret_cast<void *>(m_CurPhrase));
|
|
||||||
|
|
||||||
|
/* Create the reverse lookup */
|
||||||
|
if (!sm_trie_insert(m_pPhraseLookup, name, reinterpret_cast<void *>(m_CurPhrase)))
|
||||||
|
{
|
||||||
|
ParseWarning("Skipping duplicate phrase \"%s\" on line %d.", name, states->line);
|
||||||
|
/* :IDEA: prevent memory waste by seeking backwards in memtable? */
|
||||||
|
m_CurPhrase = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* Initialize new phrase */
|
/* Initialize new phrase */
|
||||||
trans_t *pTrans;
|
trans_t *pTrans;
|
||||||
|
|
||||||
pPhrase->fmt_count = 0;
|
pPhrase->fmt_count = 0;
|
||||||
pPhrase->fmt_list = -1;
|
pPhrase->fmt_list = -1;
|
||||||
|
|
||||||
@@ -241,14 +200,13 @@ SMCResult CPhraseFile::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
|
|
||||||
pPhrase->translations = 0;
|
pPhrase->translations = 0;
|
||||||
pPhrase->fmt_bytes = 0;
|
pPhrase->fmt_bytes = 0;
|
||||||
|
|
||||||
for (unsigned int i=0; i<m_LangCount; i++)
|
for (unsigned int i=0; i<m_LangCount; i++)
|
||||||
{
|
{
|
||||||
pTrans[i].stridx = -1;
|
pTrans[i].stridx = -1;
|
||||||
}
|
}
|
||||||
|
m_LastPhraseString.assign(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LastPhraseString.assign(name);
|
|
||||||
}
|
}
|
||||||
else if (m_ParseState == PPS_InPhrase)
|
else if (m_ParseState == PPS_InPhrase)
|
||||||
{
|
{
|
||||||
@@ -273,12 +231,15 @@ SMCResult CPhraseFile::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
}
|
}
|
||||||
|
|
||||||
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(m_CurPhrase);
|
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(m_CurPhrase);
|
||||||
|
|
||||||
/* Duplicate format keys get silently ignored. */
|
if (key[0] == '#' && strcmp(key, "#format") == 0)
|
||||||
if (key[0] == '#'
|
|
||||||
&& strcmp(key, "#format") == 0
|
|
||||||
&& pPhrase->fmt_list == -1)
|
|
||||||
{
|
{
|
||||||
|
if (pPhrase->fmt_list != -1)
|
||||||
|
{
|
||||||
|
ParseWarning("Ignoring duplicated #format property on line %d", states->line);
|
||||||
|
return SMCResult_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pPhrase->translations > 0)
|
if (pPhrase->translations > 0)
|
||||||
{
|
{
|
||||||
ParseWarning("#format property should come before translations on line %d, ignoring", states->line);
|
ParseWarning("#format property should come before translations on line %d, ignoring", states->line);
|
||||||
@@ -487,7 +448,7 @@ SMCResult CPhraseFile::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t len = strlen(key);
|
size_t len = strlen(key);
|
||||||
if (len < 2 || len > 3)
|
if (len != 2)
|
||||||
{
|
{
|
||||||
ParseWarning("Ignoring translation to invalid language \"%s\" on line %d.", key, states->line);
|
ParseWarning("Ignoring translation to invalid language \"%s\" on line %d.", key, states->line);
|
||||||
return SMCResult_Continue;
|
return SMCResult_Continue;
|
||||||
@@ -702,7 +663,7 @@ const char *CPhraseFile::GetFilename()
|
|||||||
** MAIN TRANSLATOR CODE **
|
** MAIN TRANSLATOR CODE **
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
Translator::Translator() : m_ServerLang(SOURCEMOD_LANGUAGE_ENGLISH)
|
Translator::Translator() : m_ServerLang(LANGUAGE_ENGLISH)
|
||||||
{
|
{
|
||||||
m_pStringTab = new BaseStringTable(2048);
|
m_pStringTab = new BaseStringTable(2048);
|
||||||
m_pLCodeLookup = sm_trie_create();
|
m_pLCodeLookup = sm_trie_create();
|
||||||
@@ -766,15 +727,11 @@ void Translator::OnSourceModAllInitialized()
|
|||||||
{
|
{
|
||||||
AddLanguage("en", "English");
|
AddLanguage("en", "English");
|
||||||
|
|
||||||
g_pCorePhrases = CreatePhraseCollection();
|
unsigned int id;
|
||||||
g_pCorePhrases->AddPhraseFile("core.phrases");
|
|
||||||
|
|
||||||
g_ShareSys.AddInterface(NULL, this);
|
id = FindOrAddPhraseFile("core.phrases.txt");
|
||||||
}
|
g_pCorePhraseID = id;
|
||||||
|
g_pCorePhrases = GetFileByIndex(id);
|
||||||
void Translator::OnSourceModShutdown()
|
|
||||||
{
|
|
||||||
g_pCorePhrases->Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Translator::GetLanguageByCode(const char *code, unsigned int *index)
|
bool Translator::GetLanguageByCode(const char *code, unsigned int *index)
|
||||||
@@ -885,7 +842,7 @@ void Translator::RebuildLanguageDatabase(const char *lang_header_file)
|
|||||||
g_Logger.LogError("Server language was set to bad language \"%s\" -- reverting to English", m_InitialLang);
|
g_Logger.LogError("Server language was set to bad language \"%s\" -- reverting to English", m_InitialLang);
|
||||||
|
|
||||||
strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
|
strncopy(m_InitialLang, "en", sizeof(m_InitialLang));
|
||||||
m_ServerLang = SOURCEMOD_LANGUAGE_ENGLISH;
|
m_ServerLang = LANGUAGE_ENGLISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ServerLang = reinterpret_cast<unsigned int>(serverLang);
|
m_ServerLang = reinterpret_cast<unsigned int>(serverLang);
|
||||||
@@ -936,7 +893,7 @@ SMCResult Translator::ReadSMC_KeyValue(const SMCStates *states, const char *key,
|
|||||||
{
|
{
|
||||||
size_t len = strlen(key);
|
size_t len = strlen(key);
|
||||||
|
|
||||||
if (len < 2 || len > 3)
|
if (len != 2)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Warning encountered parsing languages.cfg file.");
|
g_Logger.LogError("[SM] Warning encountered parsing languages.cfg file.");
|
||||||
g_Logger.LogError("[SM] Invalid language code \"%s\" is being ignored.", key);
|
g_Logger.LogError("[SM] Invalid language code \"%s\" is being ignored.", key);
|
||||||
@@ -957,7 +914,9 @@ bool Translator::AddLanguage(const char *langcode, const char *description)
|
|||||||
Language *pLanguage = new Language;
|
Language *pLanguage = new Language;
|
||||||
unsigned int idx = m_Languages.size();
|
unsigned int idx = m_Languages.size();
|
||||||
|
|
||||||
UTIL_Format(pLanguage->m_code2, sizeof(pLanguage->m_code2), "%s", langcode);
|
pLanguage->m_code2[0] = langcode[0];
|
||||||
|
pLanguage->m_code2[1] = langcode[1];
|
||||||
|
pLanguage->m_code2[2] = langcode[2];
|
||||||
pLanguage->m_FullName = m_pStringTab->AddString(description);
|
pLanguage->m_FullName = m_pStringTab->AddString(description);
|
||||||
|
|
||||||
sm_trie_insert(m_pLCodeLookup, langcode, reinterpret_cast<void *>(idx));
|
sm_trie_insert(m_pLCodeLookup, langcode, reinterpret_cast<void *>(idx));
|
||||||
@@ -977,6 +936,61 @@ CPhraseFile *Translator::GetFileByIndex(unsigned int index)
|
|||||||
return m_Files[index];
|
return m_Files[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Translator::Translate(char *buffer, size_t maxlength, void **params, const Translation *pTrans)
|
||||||
|
{
|
||||||
|
void *new_params[MAX_TRANSLATE_PARAMS];
|
||||||
|
|
||||||
|
/* Rewrite the parameter order */
|
||||||
|
for (unsigned int i=0; i<pTrans->fmt_count; i++)
|
||||||
|
{
|
||||||
|
new_params[i] = params[pTrans->fmt_order[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return gnprintf(buffer, maxlength, pTrans->szPhrase, new_params);
|
||||||
|
}
|
||||||
|
|
||||||
|
TransError Translator::CoreTransEx(CPhraseFile *pFile,
|
||||||
|
int client,
|
||||||
|
char *buffer,
|
||||||
|
size_t maxlength,
|
||||||
|
const char *phrase,
|
||||||
|
void **params,
|
||||||
|
size_t *outlen)
|
||||||
|
{
|
||||||
|
Translation trans;
|
||||||
|
TransError err;
|
||||||
|
|
||||||
|
/* Using server lang temporarily until client lang stuff is implemented */
|
||||||
|
if ((err = pFile->GetTranslation(phrase, m_ServerLang, &trans)) != Trans_Okay)
|
||||||
|
{
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t len = Translate(buffer, maxlength, params, &trans);
|
||||||
|
|
||||||
|
if (outlen)
|
||||||
|
{
|
||||||
|
*outlen = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Trans_Okay;
|
||||||
|
}
|
||||||
|
|
||||||
|
TransError Translator::CoreTrans(int client,
|
||||||
|
char *buffer,
|
||||||
|
size_t maxlength,
|
||||||
|
const char *phrase,
|
||||||
|
void **params,
|
||||||
|
size_t *outlen)
|
||||||
|
{
|
||||||
|
if (!g_pCorePhrases)
|
||||||
|
{
|
||||||
|
return Trans_BadPhraseFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CoreTransEx(g_pCorePhrases, client, buffer, maxlength, phrase, params, outlen);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int Translator::GetServerLanguage()
|
unsigned int Translator::GetServerLanguage()
|
||||||
{
|
{
|
||||||
return m_ServerLang;
|
return m_ServerLang;
|
||||||
@@ -1007,105 +1021,3 @@ bool Translator::GetLanguageInfo(unsigned int number, const char **code, const c
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Translator::GetInterfaceName()
|
|
||||||
{
|
|
||||||
return SMINTERFACE_TRANSLATOR_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Translator::GetInterfaceVersion()
|
|
||||||
{
|
|
||||||
return SMINTERFACE_TRANSLATOR_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPhraseCollection *Translator::CreatePhraseCollection()
|
|
||||||
{
|
|
||||||
return new CPhraseCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Translator::SetGlobalTarget(int index)
|
|
||||||
{
|
|
||||||
return g_SourceMod.SetGlobalTarget(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Translator::GetGlobalTarget() const
|
|
||||||
{
|
|
||||||
return g_SourceMod.GetGlobalTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CoreTranslate(char *buffer,
|
|
||||||
size_t maxlength,
|
|
||||||
const char *format,
|
|
||||||
unsigned int numparams,
|
|
||||||
size_t *pOutLength,
|
|
||||||
...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
unsigned int i;
|
|
||||||
const char *fail_phrase;
|
|
||||||
void *params[MAX_TRANSLATE_PARAMS];
|
|
||||||
|
|
||||||
if (numparams > MAX_TRANSLATE_PARAMS)
|
|
||||||
{
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(ap, pOutLength);
|
|
||||||
for (i = 0; i < numparams; i++)
|
|
||||||
{
|
|
||||||
params[i] = va_arg(ap, void *);
|
|
||||||
}
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
if (!g_pCorePhrases->FormatString(buffer,
|
|
||||||
maxlength,
|
|
||||||
format,
|
|
||||||
params,
|
|
||||||
numparams,
|
|
||||||
pOutLength,
|
|
||||||
&fail_phrase))
|
|
||||||
{
|
|
||||||
if (fail_phrase != NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("[SM] Could not find core phrase: %s", fail_phrase);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_Logger.LogError("[SM] Unknown fatal error while translating a core phrase.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Translator::FormatString(char *buffer,
|
|
||||||
size_t maxlength,
|
|
||||||
const char *format,
|
|
||||||
IPhraseCollection *pPhrases,
|
|
||||||
void **params,
|
|
||||||
unsigned int numparams,
|
|
||||||
size_t *pOutLength,
|
|
||||||
const char **pFailPhrase)
|
|
||||||
{
|
|
||||||
unsigned int arg;
|
|
||||||
|
|
||||||
arg = 0;
|
|
||||||
if (!gnprintf(buffer, maxlength, format, pPhrases, params, numparams, arg, pOutLength, pFailPhrase))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg != numparams)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
+38
-40
@@ -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-2007 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
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
#include "ITextParsers.h"
|
#include "ITextParsers.h"
|
||||||
#include <ITranslator.h>
|
|
||||||
|
|
||||||
#define MAX_TRANSLATE_PARAMS 32
|
#define MAX_TRANSLATE_PARAMS 32
|
||||||
#define CORELANG_ENGLISH 0
|
#define CORELANG_ENGLISH 0
|
||||||
@@ -57,13 +56,29 @@ enum PhraseParseState
|
|||||||
|
|
||||||
struct Language
|
struct Language
|
||||||
{
|
{
|
||||||
char m_code2[4];
|
char m_code2[3];
|
||||||
int m_FullName;
|
int m_FullName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPhraseFile :
|
struct Translation
|
||||||
public ITextListener_SMC,
|
{
|
||||||
public IPhraseFile
|
const char *szPhrase; /**< Translated phrase. */
|
||||||
|
unsigned int fmt_count; /**< Number of format parameters. */
|
||||||
|
int *fmt_order; /**< Format phrase order. */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LANGUAGE_ENGLISH 0
|
||||||
|
|
||||||
|
enum TransError
|
||||||
|
{
|
||||||
|
Trans_Okay = 0,
|
||||||
|
Trans_BadLanguage = 1,
|
||||||
|
Trans_BadPhrase = 2,
|
||||||
|
Trans_BadPhraseLanguage = 3,
|
||||||
|
Trans_BadPhraseFile = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPhraseFile : public ITextListener_SMC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPhraseFile(Translator *pTranslator, const char *file);
|
CPhraseFile(Translator *pTranslator, const char *file);
|
||||||
@@ -97,8 +112,7 @@ private:
|
|||||||
|
|
||||||
class Translator :
|
class Translator :
|
||||||
public ITextListener_SMC,
|
public ITextListener_SMC,
|
||||||
public SMGlobalClass,
|
public SMGlobalClass
|
||||||
public ITranslator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Translator();
|
Translator();
|
||||||
@@ -111,7 +125,6 @@ public: // SMGlobalClass
|
|||||||
size_t maxlength);
|
size_t maxlength);
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModLevelChange(const char *mapName);
|
void OnSourceModLevelChange(const char *mapName);
|
||||||
void OnSourceModShutdown();
|
|
||||||
public: // ITextListener_SMC
|
public: // ITextListener_SMC
|
||||||
void ReadSMC_ParseStart();
|
void ReadSMC_ParseStart();
|
||||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
||||||
@@ -125,30 +138,23 @@ public:
|
|||||||
bool GetLanguageInfo(unsigned int number, const char **code, const char **name);
|
bool GetLanguageInfo(unsigned int number, const char **code, const char **name);
|
||||||
bool GetLanguageByCode(const char *code, unsigned int *index);
|
bool GetLanguageByCode(const char *code, unsigned int *index);
|
||||||
bool GetLanguageByName(const char *name, unsigned int *index);
|
bool GetLanguageByName(const char *name, unsigned int *index);
|
||||||
|
size_t Translate(char *buffer, size_t maxlength, void **params, const Translation *pTrans);
|
||||||
CPhraseFile *GetFileByIndex(unsigned int index);
|
CPhraseFile *GetFileByIndex(unsigned int index);
|
||||||
public: //ITranslator
|
TransError CoreTransEx(CPhraseFile *pFile,
|
||||||
unsigned int GetServerLanguage();
|
int client,
|
||||||
unsigned int GetClientLanguage(int client);
|
|
||||||
const char *GetInterfaceName();
|
|
||||||
unsigned int GetInterfaceVersion();
|
|
||||||
IPhraseCollection *CreatePhraseCollection();
|
|
||||||
int SetGlobalTarget(int index);
|
|
||||||
int GetGlobalTarget() const;
|
|
||||||
size_t FormatString(
|
|
||||||
char *buffer,
|
char *buffer,
|
||||||
size_t maxlength,
|
size_t maxlength,
|
||||||
SourcePawn::IPluginContext *pContext,
|
const char *phrase,
|
||||||
const cell_t *params,
|
void **params,
|
||||||
unsigned int param);
|
size_t *outlen=NULL);
|
||||||
bool FormatString(
|
TransError CoreTrans(int client,
|
||||||
char *buffer,
|
char *buffer,
|
||||||
size_t maxlength,
|
size_t maxlength,
|
||||||
const char *format,
|
const char *phrase,
|
||||||
IPhraseCollection *pPhrases,
|
void **params,
|
||||||
void **params,
|
size_t *outlen=NULL);
|
||||||
unsigned int numparams,
|
unsigned int GetServerLanguage();
|
||||||
size_t *pOutLength,
|
unsigned int GetClientLanguage(int client);
|
||||||
const char **pFailPhrase);
|
|
||||||
private:
|
private:
|
||||||
bool AddLanguage(const char *langcode, const char *description);
|
bool AddLanguage(const char *langcode, const char *description);
|
||||||
private:
|
private:
|
||||||
@@ -159,18 +165,10 @@ private:
|
|||||||
bool m_InLanguageSection;
|
bool m_InLanguageSection;
|
||||||
String m_CustomError;
|
String m_CustomError;
|
||||||
unsigned int m_ServerLang;
|
unsigned int m_ServerLang;
|
||||||
char m_InitialLang[4];
|
char m_InitialLang[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Nice little wrapper to handle error logging and whatnot */
|
extern CPhraseFile *g_pCorePhrases;
|
||||||
bool CoreTranslate(char *buffer,
|
|
||||||
size_t maxlength,
|
|
||||||
const char *format,
|
|
||||||
unsigned int numparams,
|
|
||||||
size_t *pOutLength,
|
|
||||||
...);
|
|
||||||
|
|
||||||
extern IPhraseCollection *g_pCorePhrases;
|
|
||||||
extern unsigned int g_pCorePhraseID;
|
extern unsigned int g_pCorePhraseID;
|
||||||
extern Translator g_Translator;
|
extern Translator g_Translator;
|
||||||
|
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+3
-63
@@ -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-2007 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
|
||||||
@@ -35,75 +35,15 @@
|
|||||||
#include "MenuStyle_Valve.h"
|
#include "MenuStyle_Valve.h"
|
||||||
#include "MenuStyle_Radio.h"
|
#include "MenuStyle_Radio.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "CoreConfig.h"
|
|
||||||
#include <sm_queue.h>
|
|
||||||
#include "ThreadSupport.h"
|
|
||||||
|
|
||||||
static IMutex *frame_mutex;
|
float g_LastMenuTime = 0.0f;
|
||||||
static Queue<FrameAction> *frame_queue;
|
float g_LastAuthCheck = 0.0f;
|
||||||
static Queue<FrameAction> *frame_actions;
|
|
||||||
static float g_LastMenuTime = 0.0f;
|
|
||||||
static float g_LastAuthCheck = 0.0f;
|
|
||||||
bool g_PendingInternalPush = false;
|
|
||||||
|
|
||||||
class FrameActionInit : public SMGlobalClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void OnSourceModAllInitialized()
|
|
||||||
{
|
|
||||||
frame_queue = new Queue<FrameAction>();
|
|
||||||
frame_actions = new Queue<FrameAction>();
|
|
||||||
frame_mutex = g_pThreader->MakeMutex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSourceModShutdown()
|
|
||||||
{
|
|
||||||
delete frame_queue;
|
|
||||||
delete frame_actions;
|
|
||||||
frame_mutex->DestroyThis();
|
|
||||||
}
|
|
||||||
} s_FrameActionInit;
|
|
||||||
|
|
||||||
void AddFrameAction(const FrameAction & action)
|
|
||||||
{
|
|
||||||
frame_mutex->Lock();
|
|
||||||
frame_queue->push(action);
|
|
||||||
frame_mutex->Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunFrameHooks(bool simulating)
|
void RunFrameHooks(bool simulating)
|
||||||
{
|
{
|
||||||
/* It's okay if this check races. */
|
|
||||||
if (frame_queue->size())
|
|
||||||
{
|
|
||||||
Queue<FrameAction> *temp;
|
|
||||||
|
|
||||||
/* Very quick lock to move queue/actions back and forth */
|
|
||||||
frame_mutex->Lock();
|
|
||||||
temp = frame_queue;
|
|
||||||
frame_queue = frame_actions;
|
|
||||||
frame_actions = temp;
|
|
||||||
frame_mutex->Unlock();
|
|
||||||
|
|
||||||
/* The server will now be adding to the other queue, so we can process events. */
|
|
||||||
while (!frame_actions->empty())
|
|
||||||
{
|
|
||||||
FrameAction &item = frame_actions->first();
|
|
||||||
frame_actions->pop();
|
|
||||||
item.action(item.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Frame based hooks */
|
/* Frame based hooks */
|
||||||
g_DBMan.RunFrame();
|
g_DBMan.RunFrame();
|
||||||
g_HL2.ProcessFakeCliCmdQueue();
|
g_HL2.ProcessFakeCliCmdQueue();
|
||||||
g_HL2.ProcessDelayedKicks();
|
|
||||||
|
|
||||||
if (g_PendingInternalPush)
|
|
||||||
{
|
|
||||||
SM_InternalCmdTrigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_SourceMod.ProcessGameFrameHooks(simulating);
|
g_SourceMod.ProcessGameFrameHooks(simulating);
|
||||||
|
|
||||||
float curtime = *g_pUniversalTime;
|
float curtime = *g_pUniversalTime;
|
||||||
|
|||||||
+1
-12
@@ -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-2007 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
|
||||||
@@ -32,17 +32,6 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
#ifndef _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
||||||
#define _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
#define _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
||||||
|
|
||||||
typedef void (*FRAMEACTION)(void *data);
|
|
||||||
|
|
||||||
struct FrameAction
|
|
||||||
{
|
|
||||||
void *data;
|
|
||||||
FRAMEACTION action;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern bool g_PendingInternalPush;
|
|
||||||
|
|
||||||
void AddFrameAction(const FrameAction & action);
|
|
||||||
void RunFrameHooks(bool simulating);
|
void RunFrameHooks(bool simulating);
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
#endif //_INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
|
||||||
|
|||||||
-476
@@ -1,476 +0,0 @@
|
|||||||
// MD5.CC - source code for the C++/object oriented translation and
|
|
||||||
// modification of MD5.
|
|
||||||
|
|
||||||
// Translation and modification (c) 1995 by Mordechai T. Abzug
|
|
||||||
|
|
||||||
// This translation/ modification is provided "as is," without express or
|
|
||||||
// implied warranty of any kind.
|
|
||||||
|
|
||||||
// The translator/ modifier does not claim (1) that MD5 will do what you think
|
|
||||||
// it does; (2) that this translation/ modification is accurate; or (3) that
|
|
||||||
// this software is "merchantible." (Language for this disclaimer partially
|
|
||||||
// copied from the disclaimer below).
|
|
||||||
|
|
||||||
/* based on:
|
|
||||||
|
|
||||||
MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
|
||||||
MDDRIVER.C - test driver for MD2, MD4 and MD5
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
|
||||||
rights reserved.
|
|
||||||
|
|
||||||
License to copy and use this software is granted provided that it
|
|
||||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
|
||||||
Algorithm" in all material mentioning or referencing this software
|
|
||||||
or this function.
|
|
||||||
|
|
||||||
License is also granted to make and use derivative works provided
|
|
||||||
that such works are identified as "derived from the RSA Data
|
|
||||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
||||||
mentioning or referencing the derived work.
|
|
||||||
|
|
||||||
RSA Data Security, Inc. makes no representations concerning either
|
|
||||||
the merchantability of this software or the suitability of this
|
|
||||||
software for any particular purpose. It is provided "as is"
|
|
||||||
without express or implied warranty of any kind.
|
|
||||||
|
|
||||||
These notices must be retained in any copies of any part of this
|
|
||||||
documentation and/or software.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "md5.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// MD5 simple initialization method
|
|
||||||
|
|
||||||
MD5::MD5(){
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MD5 block update operation. Continues an MD5 message-digest
|
|
||||||
// operation, processing another message block, and updating the
|
|
||||||
// context.
|
|
||||||
|
|
||||||
void MD5::update (uint1 *input, uint4 input_length) {
|
|
||||||
|
|
||||||
uint4 input_index, buffer_index;
|
|
||||||
uint4 buffer_space; // how much space is left in buffer
|
|
||||||
|
|
||||||
if (finalized){ // so we can't update!
|
|
||||||
/*cerr << "MD5::update: Can't update a finalized digest!" << endl;*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute number of bytes mod 64
|
|
||||||
buffer_index = (unsigned int)((count[0] >> 3) & 0x3F);
|
|
||||||
|
|
||||||
// Update number of bits
|
|
||||||
if ( (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) )
|
|
||||||
count[1]++;
|
|
||||||
|
|
||||||
count[1] += ((uint4)input_length >> 29);
|
|
||||||
|
|
||||||
|
|
||||||
buffer_space = 64 - buffer_index; // how much space is left in buffer
|
|
||||||
|
|
||||||
// Transform as many times as possible.
|
|
||||||
if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
|
|
||||||
// fill the rest of the buffer and transform
|
|
||||||
memcpy (buffer + buffer_index, input, buffer_space);
|
|
||||||
transform (buffer);
|
|
||||||
|
|
||||||
// now, transform each 64-byte piece of the input, bypassing the buffer
|
|
||||||
for (input_index = buffer_space; input_index + 63 < input_length;
|
|
||||||
input_index += 64)
|
|
||||||
transform (input+input_index);
|
|
||||||
|
|
||||||
buffer_index = 0; // so we can buffer remaining
|
|
||||||
}
|
|
||||||
else
|
|
||||||
input_index=0; // so we can buffer the whole input
|
|
||||||
|
|
||||||
|
|
||||||
// and here we do the buffering:
|
|
||||||
memcpy(buffer+buffer_index, input+input_index, input_length-input_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// MD5 update for files.
|
|
||||||
// Like above, except that it works on files (and uses above as a primitive.)
|
|
||||||
|
|
||||||
void MD5::update(FILE *file){
|
|
||||||
|
|
||||||
unsigned char buffer[1024];
|
|
||||||
int len;
|
|
||||||
|
|
||||||
while ((len=fread(buffer, 1, 1024, file)))
|
|
||||||
update(buffer, len);
|
|
||||||
|
|
||||||
fclose (file);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MD5 finalization. Ends an MD5 message-digest operation, writing the
|
|
||||||
// the message digest and zeroizing the context.
|
|
||||||
|
|
||||||
|
|
||||||
void MD5::finalize (){
|
|
||||||
|
|
||||||
unsigned char bits[8];
|
|
||||||
unsigned int index, padLen;
|
|
||||||
static uint1 PADDING[64]={
|
|
||||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
if (finalized){
|
|
||||||
/* cerr << "MD5::finalize: Already finalized this digest!" << endl;*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save number of bits
|
|
||||||
encode (bits, count, 8);
|
|
||||||
|
|
||||||
// Pad out to 56 mod 64.
|
|
||||||
index = (uint4) ((count[0] >> 3) & 0x3f);
|
|
||||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
|
||||||
update (PADDING, padLen);
|
|
||||||
|
|
||||||
// Append length (before padding)
|
|
||||||
update (bits, 8);
|
|
||||||
|
|
||||||
// Store state in digest
|
|
||||||
encode (digest, state, 16);
|
|
||||||
|
|
||||||
// Zeroize sensitive information
|
|
||||||
memset (buffer, 0, sizeof(*buffer));
|
|
||||||
|
|
||||||
finalized=1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MD5::MD5(FILE *file){
|
|
||||||
|
|
||||||
init(); // must be called be all constructors
|
|
||||||
update(file);
|
|
||||||
finalize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *MD5::raw_digest(){
|
|
||||||
|
|
||||||
uint1 *s = new uint1[16];
|
|
||||||
|
|
||||||
if (!finalized){
|
|
||||||
/* cerr << "MD5::raw_digest: Can't get digest if you haven't "<<
|
|
||||||
"finalized the digest!" <<endl;*/
|
|
||||||
return ( (unsigned char*) "");
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(s, digest, 16);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *MD5::raw_digest(unsigned char buffer[16])
|
|
||||||
{
|
|
||||||
if (!finalized)
|
|
||||||
{
|
|
||||||
return ( (unsigned char*) "");
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(buffer, digest, 16);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *MD5::hex_digest(){
|
|
||||||
|
|
||||||
int i;
|
|
||||||
char *s= new char[33];
|
|
||||||
|
|
||||||
assert(finalized);
|
|
||||||
|
|
||||||
for (i=0; i<16; i++)
|
|
||||||
sprintf(s+i*2, "%02x", digest[i]);
|
|
||||||
|
|
||||||
s[32]='\0';
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *MD5::hex_digest(char buffer[33]){
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
assert(finalized);
|
|
||||||
|
|
||||||
for (i=0; i<16; i++)
|
|
||||||
sprintf(buffer+i*2, "%02x", digest[i]);
|
|
||||||
|
|
||||||
buffer[32]='\0';
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// PRIVATE METHODS:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MD5::init(){
|
|
||||||
finalized=0; // we just started!
|
|
||||||
|
|
||||||
// Nothing counted, so count=0
|
|
||||||
count[0] = 0;
|
|
||||||
count[1] = 0;
|
|
||||||
|
|
||||||
// Load magic initialization constants.
|
|
||||||
state[0] = 0x67452301;
|
|
||||||
state[1] = 0xefcdab89;
|
|
||||||
state[2] = 0x98badcfe;
|
|
||||||
state[3] = 0x10325476;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Constants for MD5Transform routine.
|
|
||||||
// Although we could use C++ style constants, defines are actually better,
|
|
||||||
// since they let us easily evade scope clashes.
|
|
||||||
|
|
||||||
#define S11 7
|
|
||||||
#define S12 12
|
|
||||||
#define S13 17
|
|
||||||
#define S14 22
|
|
||||||
#define S21 5
|
|
||||||
#define S22 9
|
|
||||||
#define S23 14
|
|
||||||
#define S24 20
|
|
||||||
#define S31 4
|
|
||||||
#define S32 11
|
|
||||||
#define S33 16
|
|
||||||
#define S34 23
|
|
||||||
#define S41 6
|
|
||||||
#define S42 10
|
|
||||||
#define S43 15
|
|
||||||
#define S44 21
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// MD5 basic transformation. Transforms state based on block.
|
|
||||||
void MD5::transform (uint1 block[64]){
|
|
||||||
|
|
||||||
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
|
||||||
|
|
||||||
decode (x, block, 64);
|
|
||||||
|
|
||||||
assert(!finalized); // not just a user error, since the method is private
|
|
||||||
|
|
||||||
/* Round 1 */
|
|
||||||
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
|
|
||||||
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
|
|
||||||
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
|
|
||||||
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
|
|
||||||
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
|
|
||||||
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
|
|
||||||
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
|
|
||||||
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
|
|
||||||
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
|
|
||||||
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
|
|
||||||
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
|
||||||
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
|
||||||
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
|
||||||
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
|
||||||
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
|
||||||
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
|
||||||
|
|
||||||
/* Round 2 */
|
|
||||||
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
|
|
||||||
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
|
|
||||||
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
|
||||||
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
|
|
||||||
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
|
|
||||||
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
|
||||||
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
|
||||||
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
|
|
||||||
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
|
|
||||||
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
|
||||||
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
|
|
||||||
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
|
|
||||||
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
|
||||||
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
|
|
||||||
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
|
|
||||||
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
|
||||||
|
|
||||||
/* Round 3 */
|
|
||||||
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
|
|
||||||
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
|
|
||||||
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
|
||||||
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
|
||||||
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
|
|
||||||
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
|
|
||||||
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
|
|
||||||
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
|
||||||
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
|
||||||
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
|
|
||||||
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
|
|
||||||
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
|
|
||||||
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
|
|
||||||
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
|
||||||
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
|
||||||
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
|
|
||||||
|
|
||||||
/* Round 4 */
|
|
||||||
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
|
|
||||||
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
|
|
||||||
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
|
||||||
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
|
|
||||||
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
|
||||||
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
|
|
||||||
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
|
||||||
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
|
|
||||||
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
|
|
||||||
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
|
||||||
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
|
|
||||||
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
|
||||||
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
|
|
||||||
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
|
||||||
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
|
|
||||||
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
|
|
||||||
|
|
||||||
state[0] += a;
|
|
||||||
state[1] += b;
|
|
||||||
state[2] += c;
|
|
||||||
state[3] += d;
|
|
||||||
|
|
||||||
// Zeroize sensitive information.
|
|
||||||
memset ( (uint1 *) x, 0, sizeof(x));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Encodes input (UINT4) into output (unsigned char). Assumes len is
|
|
||||||
// a multiple of 4.
|
|
||||||
void MD5::encode (uint1 *output, uint4 *input, uint4 len) {
|
|
||||||
|
|
||||||
unsigned int i, j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
|
||||||
output[j] = (uint1) (input[i] & 0xff);
|
|
||||||
output[j+1] = (uint1) ((input[i] >> 8) & 0xff);
|
|
||||||
output[j+2] = (uint1) ((input[i] >> 16) & 0xff);
|
|
||||||
output[j+3] = (uint1) ((input[i] >> 24) & 0xff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Decodes input (unsigned char) into output (UINT4). Assumes len is
|
|
||||||
// a multiple of 4.
|
|
||||||
void MD5::decode (uint4 *output, uint1 *input, uint4 len){
|
|
||||||
|
|
||||||
unsigned int i, j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
|
||||||
output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
|
|
||||||
(((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Note: Replace "for loop" with standard memcpy if possible.
|
|
||||||
void MD5::memcpy (uint1 *output, uint1 *input, uint4 len){
|
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
output[i] = input[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Note: Replace "for loop" with standard memset if possible.
|
|
||||||
void MD5::memset (uint1 *output, uint1 value, uint4 len){
|
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
output[i] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ROTATE_LEFT rotates x left n bits.
|
|
||||||
|
|
||||||
inline unsigned int MD5::rotate_left (uint4 x, uint4 n){
|
|
||||||
return (x << n) | (x >> (32-n)) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// F, G, H and I are basic MD5 functions.
|
|
||||||
|
|
||||||
inline unsigned int MD5::F (uint4 x, uint4 y, uint4 z){
|
|
||||||
return (x & y) | (~x & z);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned int MD5::G (uint4 x, uint4 y, uint4 z){
|
|
||||||
return (x & z) | (y & ~z);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned int MD5::H (uint4 x, uint4 y, uint4 z){
|
|
||||||
return x ^ y ^ z;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned int MD5::I (uint4 x, uint4 y, uint4 z){
|
|
||||||
return y ^ (x | ~z);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
|
||||||
// Rotation is separate from addition to prevent recomputation.
|
|
||||||
|
|
||||||
|
|
||||||
inline void MD5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac){
|
|
||||||
a += F(b, c, d) + x + ac;
|
|
||||||
a = rotate_left (a, s) +b;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MD5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac){
|
|
||||||
a += G(b, c, d) + x + ac;
|
|
||||||
a = rotate_left (a, s) +b;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MD5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac){
|
|
||||||
a += H(b, c, d) + x + ac;
|
|
||||||
a = rotate_left (a, s) +b;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MD5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac){
|
|
||||||
a += I(b, c, d) + x + ac;
|
|
||||||
a = rotate_left (a, s) +b;
|
|
||||||
}
|
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
// MD5.CC - source code for the C++/object oriented translation and
|
|
||||||
// modification of MD5.
|
|
||||||
|
|
||||||
// Translation and modification (c) 1995 by Mordechai T. Abzug
|
|
||||||
|
|
||||||
// This translation/ modification is provided "as is," without express or
|
|
||||||
// implied warranty of any kind.
|
|
||||||
|
|
||||||
// The translator/ modifier does not claim (1) that MD5 will do what you think
|
|
||||||
// it does; (2) that this translation/ modification is accurate; or (3) that
|
|
||||||
// this software is "merchantible." (Language for this disclaimer partially
|
|
||||||
// copied from the disclaimer below).
|
|
||||||
|
|
||||||
/* based on:
|
|
||||||
|
|
||||||
MD5.H - header file for MD5C.C
|
|
||||||
MDDRIVER.C - test driver for MD2, MD4 and MD5
|
|
||||||
|
|
||||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
|
||||||
rights reserved.
|
|
||||||
|
|
||||||
License to copy and use this software is granted provided that it
|
|
||||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
|
||||||
Algorithm" in all material mentioning or referencing this software
|
|
||||||
or this function.
|
|
||||||
|
|
||||||
License is also granted to make and use derivative works provided
|
|
||||||
that such works are identified as "derived from the RSA Data
|
|
||||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
||||||
mentioning or referencing the derived work.
|
|
||||||
|
|
||||||
RSA Data Security, Inc. makes no representations concerning either
|
|
||||||
the merchantability of this software or the suitability of this
|
|
||||||
software for any particular purpose. It is provided "as is"
|
|
||||||
without express or implied warranty of any kind.
|
|
||||||
|
|
||||||
These notices must be retained in any copies of any part of this
|
|
||||||
documentation and/or software.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
//#include <fstream.h>
|
|
||||||
//#include <iostream.h>
|
|
||||||
|
|
||||||
class MD5 {
|
|
||||||
|
|
||||||
public:
|
|
||||||
// methods for controlled operation:
|
|
||||||
MD5 (); // simple initializer
|
|
||||||
void update (unsigned char *input, unsigned int input_length);
|
|
||||||
void update (FILE *file);
|
|
||||||
void finalize ();
|
|
||||||
|
|
||||||
// constructors for special circumstances. All these constructors finalize
|
|
||||||
// the MD5 context.
|
|
||||||
MD5 (unsigned char *string); // digest string, finalize
|
|
||||||
MD5 (FILE *file); // digest file, close, finalize
|
|
||||||
|
|
||||||
// methods to acquire finalized result
|
|
||||||
unsigned char *raw_digest (); // digest as a 16-byte binary array
|
|
||||||
unsigned char *raw_digest(unsigned char buffer[16]);
|
|
||||||
char * hex_digest (); // digest as a 33-byte ascii-hex string
|
|
||||||
char * hex_digest (char buffer[33]); //same as above, passing buffer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// first, some types:
|
|
||||||
typedef unsigned int uint4; // assumes integer is 4 words long
|
|
||||||
typedef unsigned short int uint2; // assumes short integer is 2 words long
|
|
||||||
typedef unsigned char uint1; // assumes char is 1 word long
|
|
||||||
|
|
||||||
// next, the private data:
|
|
||||||
uint4 state[4];
|
|
||||||
uint4 count[2]; // number of *bits*, mod 2^64
|
|
||||||
uint1 buffer[64]; // input buffer
|
|
||||||
uint1 digest[16];
|
|
||||||
uint1 finalized;
|
|
||||||
|
|
||||||
// last, the private methods, mostly static:
|
|
||||||
void init (); // called by all constructors
|
|
||||||
void transform (uint1 *buffer); // does the real update work. Note
|
|
||||||
// that length is implied to be 64.
|
|
||||||
|
|
||||||
static void encode (uint1 *dest, uint4 *src, uint4 length);
|
|
||||||
static void decode (uint4 *dest, uint1 *src, uint4 length);
|
|
||||||
static void memcpy (uint1 *dest, uint1 *src, uint4 length);
|
|
||||||
static void memset (uint1 *start, uint1 val, uint4 length);
|
|
||||||
|
|
||||||
static inline uint4 rotate_left (uint4 x, uint4 n);
|
|
||||||
static inline uint4 F (uint4 x, uint4 y, uint4 z);
|
|
||||||
static inline uint4 G (uint4 x, uint4 y, uint4 z);
|
|
||||||
static inline uint4 H (uint4 x, uint4 y, uint4 z);
|
|
||||||
static inline uint4 I (uint4 x, uint4 y, uint4 z);
|
|
||||||
static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac);
|
|
||||||
static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac);
|
|
||||||
static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac);
|
|
||||||
static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
|
|
||||||
uint4 s, uint4 ac);
|
|
||||||
|
|
||||||
};
|
|
||||||
+291
-151
@@ -39,8 +39,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -57,14 +58,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" dbghelp.lib "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" dbghelp.lib"
|
||||||
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -121,8 +121,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -139,14 +140,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions="/MP"
|
AdditionalOptions="/MP"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
@@ -221,14 +221,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.1.ep1.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||||
@@ -287,8 +286,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -305,14 +305,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib" dbghelp.lib "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib" dbghelp.lib"
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -369,8 +368,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -387,14 +387,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -454,8 +453,8 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions="/MP"
|
AdditionalOptions="/MP"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD;ENABLE_CRAZYDEBUGGING"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
RuntimeTypeInfo="false"
|
RuntimeTypeInfo="false"
|
||||||
@@ -469,14 +468,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib" "$(HL2SDKOB)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep2.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||||
@@ -535,8 +533,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -553,14 +552,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" dbghelp.lib "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" dbghelp.lib"
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -617,8 +615,9 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -635,14 +634,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||||
@@ -702,7 +700,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions="/MP"
|
AdditionalOptions="/MP"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook""
|
AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
@@ -717,14 +715,13 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
PreprocessorDefinitions="BINARY_NAME=\"$(TargetFileName)\""
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib" "Wsock32.lib""
|
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib" "$(HL2SDK)\lib\public\mathlib.lib""
|
||||||
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
OutputFile="$(OutDir)\sourcemod.2.ep1.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||||
@@ -864,14 +861,6 @@
|
|||||||
RelativePath="..\EventManager.cpp"
|
RelativePath="..\EventManager.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ExtensionSys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ForwardSys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\frame_hooks.cpp"
|
RelativePath="..\frame_hooks.cpp"
|
||||||
>
|
>
|
||||||
@@ -880,30 +869,14 @@
|
|||||||
RelativePath="..\GameConfigs.cpp"
|
RelativePath="..\GameConfigs.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\GameDataFetcher.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\HalfLife2.cpp"
|
RelativePath="..\HalfLife2.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\HandleSys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\LibrarySys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Logger.cpp"
|
RelativePath="..\Logger.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\md5.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\MemoryUtils.cpp"
|
RelativePath="..\MemoryUtils.cpp"
|
||||||
>
|
>
|
||||||
@@ -928,38 +901,14 @@
|
|||||||
RelativePath="..\MenuVoting.cpp"
|
RelativePath="..\MenuVoting.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\NativeOwner.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\NextMap.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\PhraseCollection.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\PlayerManager.cpp"
|
RelativePath="..\PlayerManager.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\PluginInfoDatabase.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\PluginSys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Profiler.cpp"
|
RelativePath="..\Profiler.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ShareSys.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\sm_autonatives.cpp"
|
RelativePath="..\sm_autonatives.cpp"
|
||||||
>
|
>
|
||||||
@@ -1074,14 +1023,6 @@
|
|||||||
RelativePath="..\EventManager.h"
|
RelativePath="..\EventManager.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ExtensionSys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ForwardSys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\frame_hooks.h"
|
RelativePath="..\frame_hooks.h"
|
||||||
>
|
>
|
||||||
@@ -1090,30 +1031,14 @@
|
|||||||
RelativePath="..\GameConfigs.h"
|
RelativePath="..\GameConfigs.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\GameDataFetcher.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\HalfLife2.h"
|
RelativePath="..\HalfLife2.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\HandleSys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\LibrarySys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Logger.h"
|
RelativePath="..\Logger.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\md5.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\MemoryUtils.h"
|
RelativePath="..\MemoryUtils.h"
|
||||||
>
|
>
|
||||||
@@ -1138,38 +1063,14 @@
|
|||||||
RelativePath="..\MenuVoting.h"
|
RelativePath="..\MenuVoting.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\NativeOwner.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\NextMap.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\PhraseCollection.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\PlayerManager.h"
|
RelativePath="..\PlayerManager.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\PluginInfoDatabase.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\PluginSys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Profiler.h"
|
RelativePath="..\Profiler.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ShareSys.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\sm_autonatives.h"
|
RelativePath="..\sm_autonatives.h"
|
||||||
>
|
>
|
||||||
@@ -1331,39 +1232,286 @@
|
|||||||
RelativePath="..\..\public\ITimerSystem.h"
|
RelativePath="..\..\public\ITimerSystem.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\public\ITranslator.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\public\IUserMessages.h"
|
RelativePath="..\..\public\IUserMessages.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Systems"
|
||||||
|
UniqueIdentifier="{63775418-DF3F-4198-BFB1-738B19EE3EE0}"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{7D3AB33D-C1AD-46ee-B505-FEA8B6EF18E4}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ExtensionSys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ForwardSys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\HandleSys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\LibrarySys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\PluginInfoDatabase.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\PluginSys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ShareSys.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{D1864A10-FF5F-4672-A70E-57C9F7486F92}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ExtensionSys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ForwardSys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\HandleSys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\LibrarySys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\PluginInfoDatabase.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\PluginSys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\systems\ShareSys.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="SourcePawn"
|
Name="SourcePawn"
|
||||||
UniqueIdentifier="{C3C3DC6E-E392-4916-B893-7ACB92192DE0}"
|
UniqueIdentifier="{C3C3DC6E-E392-4916-B893-7ACB92192DE0}"
|
||||||
>
|
>
|
||||||
<File
|
<Filter
|
||||||
RelativePath="..\..\public\sourcepawn\sp_file_headers.h"
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{D06F7D18-C940-4200-990B-2D0CF72F91AB}"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
<File
|
RelativePath="..\vm\sp_vm_basecontext.h"
|
||||||
RelativePath="..\..\public\sourcepawn\sp_typeutil.h"
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\vm\sp_vm_engine.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\vm\sp_vm_function.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{605A5261-30CD-4cca-BBE2-23BB190DA44E}"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
<File
|
RelativePath="..\vm\sp_vm_basecontext.cpp"
|
||||||
RelativePath="..\..\public\sourcepawn\sp_vm_api.h"
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\vm\sp_vm_engine.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="CrazyDebug - Old Metamod|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(SOURCEMM16)\sourcehook""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug - Old Metamod|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(SOURCEMM16)\sourcehook""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release - Old Metamod|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(SOURCEMM16)\sourcehook""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="CrazyDebug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(SOURCEMM16)\sourcehook""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\vm\sp_vm_function.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="SDK"
|
||||||
|
UniqueIdentifier="{A76160D7-4623-42c7-9587-62049792B924}"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
<File
|
RelativePath="..\..\public\sourcepawn\sp_file_headers.h"
|
||||||
RelativePath="..\..\public\sourcepawn\sp_vm_base.h"
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\public\sourcepawn\sp_typeutil.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\public\sourcepawn\sp_vm_api.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\public\sourcepawn\sp_vm_base.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\public\sourcepawn\sp_vm_types.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="zlib"
|
||||||
|
UniqueIdentifier="{27E223C9-0208-4c7d-BBAA-DE4BF1745020}"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{65A17C3B-0B6E-450f-96B8-661D47876D4B}"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
<File
|
RelativePath="..\zlib\crc32.h"
|
||||||
RelativePath="..\..\public\sourcepawn\sp_vm_types.h"
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\deflate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inffast.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inffixed.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inflate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inftrees.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\trees.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\zconf.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\zlib.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\zutil.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{9279E65A-C154-4296-AE23-949EB8C62BEB}"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
|
RelativePath="..\zlib\adler32.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\compress.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\crc32.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\deflate.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\gzio.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\infback.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inffast.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inflate.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\inftrees.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\trees.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\uncompr.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\zlib\zutil.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="HL2SDK"
|
Name="HL2SDK"
|
||||||
@@ -1386,10 +1534,6 @@
|
|||||||
RelativePath="..\smn_adt_array.cpp"
|
RelativePath="..\smn_adt_array.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\smn_adt_stack.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\smn_adt_trie.cpp"
|
RelativePath="..\smn_adt_trie.cpp"
|
||||||
>
|
>
|
||||||
@@ -1474,10 +1618,6 @@
|
|||||||
RelativePath="..\smn_menus.cpp"
|
RelativePath="..\smn_menus.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\smn_nextmap.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\smn_player.cpp"
|
RelativePath="..\smn_player.cpp"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
|
||||||
# Visual Studio 2008
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32
|
|
||||||
CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32
|
|
||||||
CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32
|
|
||||||
Debug - Episode 1|Win32 = Debug - Episode 1|Win32
|
|
||||||
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
|
|
||||||
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
|
|
||||||
Release - Episode 1|Win32 = Release - Episode 1|Win32
|
|
||||||
Release - Old Metamod|Win32 = Release - Old Metamod|Win32
|
|
||||||
Release - Orange Box|Win32 = Release - Orange Box|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{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 - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - 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 - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - 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 - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
|
|
||||||
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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-2007 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
|
||||||
@@ -31,13 +31,8 @@
|
|||||||
|
|
||||||
#include "sm_autonatives.h"
|
#include "sm_autonatives.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
#include "NativeOwner.h"
|
|
||||||
|
|
||||||
CNativeOwner g_CoreNatives;
|
|
||||||
|
|
||||||
CNativeOwner *g_pCoreNatives = &g_CoreNatives;
|
|
||||||
|
|
||||||
void CoreNativesToAdd::OnSourceModAllInitialized()
|
void CoreNativesToAdd::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
g_CoreNatives.AddNatives(m_NativeList);
|
g_PluginSys.RegisterNativesFromCore(m_NativeList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
@@ -50,8 +50,4 @@ public:
|
|||||||
sp_nativeinfo_t *m_NativeList;
|
sp_nativeinfo_t *m_NativeList;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CNativeOwner;
|
|
||||||
|
|
||||||
extern CNativeOwner *g_pCoreNatives;
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_CORE_AUTONATIVES_H_
|
#endif //_INCLUDE_SOURCEMOD_CORE_AUTONATIVES_H_
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+2
-19
@@ -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-2007 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
|
||||||
@@ -74,7 +74,6 @@ class SMGlobalClass
|
|||||||
friend class SourceModBase;
|
friend class SourceModBase;
|
||||||
friend class CoreConfig;
|
friend class CoreConfig;
|
||||||
friend class CExtensionManager;
|
friend class CExtensionManager;
|
||||||
friend class PlayerManager;
|
|
||||||
public:
|
public:
|
||||||
SMGlobalClass();
|
SMGlobalClass();
|
||||||
public:
|
public:
|
||||||
@@ -134,13 +133,6 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Called when the level has activated.
|
|
||||||
*/
|
|
||||||
virtual void OnSourceModLevelActivated()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the level ends.
|
* @brief Called when the level ends.
|
||||||
*/
|
*/
|
||||||
@@ -175,22 +167,13 @@ public:
|
|||||||
virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
|
virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Called when the server maxplayers changes
|
|
||||||
*
|
|
||||||
* @param newvalue New maxplayers value.
|
|
||||||
*/
|
|
||||||
virtual void OnSourceModMaxPlayersChanged(int newvalue)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
SMGlobalClass *m_pGlobalClassNext;
|
SMGlobalClass *m_pGlobalClassNext;
|
||||||
static SMGlobalClass *head;
|
static SMGlobalClass *head;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ISourcePawnEngine *g_pSourcePawn;
|
extern ISourcePawnEngine *g_pSourcePawn;
|
||||||
extern ISourcePawnEngine2 *g_pSourcePawn2;
|
extern IVirtualMachine *g_pVM;
|
||||||
extern IdentityToken_t *g_pCoreIdent;
|
extern IdentityToken_t *g_pCoreIdent;
|
||||||
|
|
||||||
#include "sm_autonatives.h"
|
#include "sm_autonatives.h"
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <malloc.h>
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
|
|
||||||
BaseMemTable::BaseMemTable(unsigned int init_size)
|
BaseMemTable::BaseMemTable(unsigned int init_size)
|
||||||
|
|||||||
+1
-6
@@ -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-2007 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,11 +63,6 @@ public:
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int GetActualMemUsed()
|
|
||||||
{
|
|
||||||
return tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char *membase;
|
unsigned char *membase;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|||||||
+2
-2
@@ -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-2007 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
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#define _INCLUDE_SM_QUEUE_H
|
#define _INCLUDE_SM_QUEUE_H
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdlib.h>
|
#include <malloc.h>
|
||||||
#include <sh_stack.h>
|
#include <sh_stack.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
|||||||
@@ -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-2007 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
|
||||||
|
|||||||
+2
-3
@@ -281,10 +281,9 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &
|
|||||||
{
|
{
|
||||||
ConsolePrint(" SourceMod Version Information:");
|
ConsolePrint(" SourceMod Version Information:");
|
||||||
ConsolePrint(" SourceMod Version: %s", SVN_FULL_VERSION);
|
ConsolePrint(" SourceMod Version: %s", SVN_FULL_VERSION);
|
||||||
ConsolePrint(" SourcePawn Engine: %s (build %s)", g_pSourcePawn2->GetEngineName(), g_pSourcePawn2->GetVersionString());
|
ConsolePrint(" JIT Version: %s, %s", g_pVM->GetVMName(), g_pVM->GetVersionString());
|
||||||
ConsolePrint(" SourcePawn API: v1 = %d, v2 = %d", g_pSourcePawn->GetEngineAPIVersion(), g_pSourcePawn2->GetAPIVersion());
|
ConsolePrint(" JIT Settings: %s", g_pVM->GetCPUOptimizations());
|
||||||
ConsolePrint(" Compiled on: %s %s", __DATE__, __TIME__);
|
ConsolePrint(" Compiled on: %s %s", __DATE__, __TIME__);
|
||||||
ConsolePrint(" Build ID: %s", SM_BUILD_UNIQUEID);
|
|
||||||
ConsolePrint(" http://www.sourcemod.net/");
|
ConsolePrint(" http://www.sourcemod.net/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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-2007 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
|
||||||
|
|||||||
+56
-263
@@ -50,6 +50,43 @@
|
|||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t CorePlayerTranslate(int client, char *buffer, size_t maxlength, const char *phrase, void **params)
|
||||||
|
{
|
||||||
|
Translation pTrans;
|
||||||
|
TransError err;
|
||||||
|
|
||||||
|
err = g_pCorePhrases->GetTranslation(phrase, g_Translator.GetClientLanguage(client), &pTrans);
|
||||||
|
if (err != Trans_Okay)
|
||||||
|
{
|
||||||
|
err = g_pCorePhrases->GetTranslation(phrase, g_Translator.GetServerLanguage(), &pTrans);
|
||||||
|
if (err != Trans_Okay && g_Translator.GetServerLanguage() != CORELANG_ENGLISH)
|
||||||
|
{
|
||||||
|
err = g_pCorePhrases->GetTranslation(phrase, CORELANG_ENGLISH, &pTrans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err != Trans_Okay)
|
||||||
|
{
|
||||||
|
return UTIL_Format(buffer, maxlength, "%s", phrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_Translator.Translate(buffer, maxlength, params, &pTrans);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryTranslation(CPlugin *pl, const char *key, unsigned int langid, unsigned int langcount, Translation *pTrans)
|
||||||
|
{
|
||||||
|
TransError err = Trans_BadLanguage;
|
||||||
|
CPhraseFile *phrfl;
|
||||||
|
|
||||||
|
for (size_t i=0; i<langcount && err!=Trans_Okay; i++)
|
||||||
|
{
|
||||||
|
phrfl = g_Translator.GetFileByIndex(pl->GetLangFileByIndex(i));
|
||||||
|
err = phrfl->GetTranslation(key, langid, pTrans);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (err == Trans_Okay) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void ReorderTranslationParams(const Translation *pTrans, cell_t *params)
|
inline void ReorderTranslationParams(const Translation *pTrans, cell_t *params)
|
||||||
{
|
{
|
||||||
cell_t new_params[MAX_TRANSLATE_PARAMS];
|
cell_t new_params[MAX_TRANSLATE_PARAMS];
|
||||||
@@ -73,13 +110,11 @@ size_t Translate(char *buffer,
|
|||||||
*error = false;
|
*error = false;
|
||||||
Translation pTrans;
|
Translation pTrans;
|
||||||
CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
|
CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
|
||||||
|
size_t langcount = pl->GetLangFileCount();
|
||||||
unsigned int max_params = 0;
|
unsigned int max_params = 0;
|
||||||
IPhraseCollection *pPhrases;
|
|
||||||
|
|
||||||
pPhrases = pl->GetPhrases();
|
|
||||||
|
|
||||||
try_serverlang:
|
try_serverlang:
|
||||||
if (target == SOURCEMOD_SERVER_LANGUAGE)
|
if (target == LANG_SERVER)
|
||||||
{
|
{
|
||||||
langid = g_Translator.GetServerLanguage();
|
langid = g_Translator.GetServerLanguage();
|
||||||
}
|
}
|
||||||
@@ -93,16 +128,16 @@ try_serverlang:
|
|||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPhrases->FindTranslation(key, langid, &pTrans) != Trans_Okay)
|
if (!TryTranslation(pl, key, langid, langcount, &pTrans))
|
||||||
{
|
{
|
||||||
if (target != SOURCEMOD_SERVER_LANGUAGE && langid != g_Translator.GetServerLanguage())
|
if (target != LANG_SERVER && langid != g_Translator.GetServerLanguage())
|
||||||
{
|
{
|
||||||
target = SOURCEMOD_SERVER_LANGUAGE;
|
target = LANG_SERVER;
|
||||||
goto try_serverlang;
|
goto try_serverlang;
|
||||||
}
|
}
|
||||||
else if (langid != SOURCEMOD_LANGUAGE_ENGLISH)
|
else if (langid != LANGUAGE_ENGLISH)
|
||||||
{
|
{
|
||||||
if (pPhrases->FindTranslation(key, SOURCEMOD_LANGUAGE_ENGLISH, &pTrans) != Trans_Okay)
|
if (!TryTranslation(pl, key, LANGUAGE_ENGLISH, langcount, &pTrans))
|
||||||
{
|
{
|
||||||
pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language phrase \"%s\" not found", key);
|
pCtx->ThrowNativeErrorEx(SP_ERROR_PARAM, "Language phrase \"%s\" not found", key);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
@@ -540,32 +575,11 @@ void AddHex(char **buf_p, size_t &maxlen, unsigned int val, int width, int flags
|
|||||||
*buf_p = buf;
|
*buf_p = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gnprintf(char *buffer,
|
size_t gnprintf(char *buffer, size_t maxlen, const char *format, void **args)
|
||||||
size_t maxlen,
|
|
||||||
const char *format,
|
|
||||||
IPhraseCollection *pPhrases,
|
|
||||||
void **params,
|
|
||||||
unsigned int numparams,
|
|
||||||
unsigned int &curparam,
|
|
||||||
size_t *pOutLength,
|
|
||||||
const char **pFailPhrase)
|
|
||||||
{
|
{
|
||||||
if (!buffer || !maxlen)
|
if (!buffer || !maxlen)
|
||||||
{
|
{
|
||||||
if (pOutLength != NULL)
|
return 0;
|
||||||
{
|
|
||||||
*pOutLength = 0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numparams > MAX_TRANSLATE_PARAMS)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int arg = 0;
|
int arg = 0;
|
||||||
@@ -654,16 +668,7 @@ reswitch:
|
|||||||
{
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (curparam >= numparams)
|
char *c = (char *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char *c = (char *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
*buf_p++ = *c;
|
*buf_p++ = *c;
|
||||||
llen--;
|
llen--;
|
||||||
arg++;
|
arg++;
|
||||||
@@ -671,16 +676,7 @@ reswitch:
|
|||||||
}
|
}
|
||||||
case 'b':
|
case 'b':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
int *value = (int *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int *value = (int *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddBinary(&buf_p, llen, *value, width, flags);
|
AddBinary(&buf_p, llen, *value, width, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
@@ -688,224 +684,35 @@ reswitch:
|
|||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
int *value = (int *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int *value = (int *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddInt(&buf_p, llen, *value, width, flags);
|
AddInt(&buf_p, llen, *value, width, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
unsigned int *value = (unsigned int *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned int *value = (unsigned int *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddUInt(&buf_p, llen, *value, width, flags);
|
AddUInt(&buf_p, llen, *value, width, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
float *value = (float *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
float *value = (float *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddFloat(&buf_p, llen, *value, width, prec, flags);
|
AddFloat(&buf_p, llen, *value, width, prec, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
case 's':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
const char *str = (const char *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const char *str = (const char *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddString(&buf_p, llen, str, width, prec);
|
AddString(&buf_p, llen, str, width, prec);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'T':
|
|
||||||
case 't':
|
|
||||||
{
|
|
||||||
int target;
|
|
||||||
const char *key;
|
|
||||||
size_t out_length;
|
|
||||||
Translation trans;
|
|
||||||
unsigned int lang_id;
|
|
||||||
|
|
||||||
if (curparam >= numparams)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
key = (const char *)(params[curparam]);
|
|
||||||
curparam++;
|
|
||||||
|
|
||||||
if (ch == 'T')
|
|
||||||
{
|
|
||||||
if (curparam >= numparams)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
target = *((int *)(params[curparam]));
|
|
||||||
curparam++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target = g_Translator.GetGlobalTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
try_again:
|
|
||||||
if (target == SOURCEMOD_SERVER_LANGUAGE)
|
|
||||||
{
|
|
||||||
lang_id = g_Translator.GetServerLanguage();
|
|
||||||
}
|
|
||||||
else if (target >= 1 && target <= g_Players.GetMaxClients())
|
|
||||||
{
|
|
||||||
lang_id = g_Translator.GetClientLanguage(target);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lang_id = g_Translator.GetServerLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pPhrases == NULL)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = key;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pPhrases->FindTranslation(key, lang_id, &trans) != Trans_Okay)
|
|
||||||
{
|
|
||||||
if (target != SOURCEMOD_SERVER_LANGUAGE && lang_id != g_Translator.GetServerLanguage())
|
|
||||||
{
|
|
||||||
target = SOURCEMOD_SERVER_LANGUAGE;
|
|
||||||
goto try_again;
|
|
||||||
}
|
|
||||||
else if (lang_id != SOURCEMOD_LANGUAGE_ENGLISH)
|
|
||||||
{
|
|
||||||
if (pPhrases->FindTranslation(key, SOURCEMOD_LANGUAGE_ENGLISH, &trans) != Trans_Okay)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = key;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = key;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trans.fmt_count)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
void *new_params[MAX_TRANSLATE_PARAMS];
|
|
||||||
|
|
||||||
if (curparam + trans.fmt_count > numparams)
|
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the array and re-order the stack */
|
|
||||||
memcpy(new_params, params, sizeof(void *) * numparams);
|
|
||||||
for (i = 0; i < trans.fmt_count; i++)
|
|
||||||
{
|
|
||||||
new_params[i] = const_cast<void *>(params[curparam + trans.fmt_order[i]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gnprintf(buf_p,
|
|
||||||
llen,
|
|
||||||
trans.szPhrase,
|
|
||||||
pPhrases,
|
|
||||||
new_params,
|
|
||||||
numparams,
|
|
||||||
curparam,
|
|
||||||
&out_length,
|
|
||||||
pFailPhrase))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!gnprintf(buf_p,
|
|
||||||
llen,
|
|
||||||
trans.szPhrase,
|
|
||||||
pPhrases,
|
|
||||||
params,
|
|
||||||
numparams,
|
|
||||||
curparam,
|
|
||||||
&out_length,
|
|
||||||
pFailPhrase))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf_p += out_length;
|
|
||||||
llen -= out_length;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'X':
|
case 'X':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
unsigned int *value = (unsigned int *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned int *value = (unsigned int *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
flags |= UPPERDIGITS;
|
flags |= UPPERDIGITS;
|
||||||
AddHex(&buf_p, llen, *value, width, flags);
|
AddHex(&buf_p, llen, *value, width, flags);
|
||||||
arg++;
|
arg++;
|
||||||
@@ -913,16 +720,7 @@ try_again:
|
|||||||
}
|
}
|
||||||
case 'x':
|
case 'x':
|
||||||
{
|
{
|
||||||
if (curparam >= numparams)
|
unsigned int *value = (unsigned int *)args[arg];
|
||||||
{
|
|
||||||
if (pFailPhrase != NULL)
|
|
||||||
{
|
|
||||||
*pFailPhrase = NULL;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned int *value = (unsigned int *)params[curparam];
|
|
||||||
curparam++;
|
|
||||||
AddHex(&buf_p, llen, *value, width, flags);
|
AddHex(&buf_p, llen, *value, width, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
@@ -963,12 +761,7 @@ try_again:
|
|||||||
done:
|
done:
|
||||||
*buf_p = '\0';
|
*buf_p = '\0';
|
||||||
|
|
||||||
if (pOutLength != NULL)
|
return (maxlen - llen - 1);
|
||||||
{
|
|
||||||
*pOutLength = (maxlen - llen - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param)
|
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param)
|
||||||
@@ -1385,7 +1178,7 @@ unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search
|
|||||||
* NOTE: Do not edit this for the love of god unless you have
|
* NOTE: Do not edit this for the love of god unless you have
|
||||||
* read the test cases and understand the code behind each one.
|
* read the test cases and understand the code behind each one.
|
||||||
* While I don't guarantee there aren't mistakes, I do guarantee
|
* While I don't guarantee there aren't mistakes, I do guarantee
|
||||||
* that plugins will end up relying on tiny idiosyncrasies of this
|
* that plugins will end up relying on tiny idiosyncracies of this
|
||||||
* function, just like they did with AMX Mod X.
|
* function, just like they did with AMX Mod X.
|
||||||
*
|
*
|
||||||
* There are explicitly more cases than the AMX Mod X version because
|
* There are explicitly more cases than the AMX Mod X version because
|
||||||
|
|||||||
+7
-14
@@ -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-2007 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
|
||||||
@@ -33,30 +33,23 @@
|
|||||||
#define _INCLUDE_SOURCEMOD_STRINGUTIL_H_
|
#define _INCLUDE_SOURCEMOD_STRINGUTIL_H_
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <sp_vm_api.h>
|
#include "sp_vm_api.h"
|
||||||
#include <sp_typeutil.h>
|
#include "sp_typeutil.h"
|
||||||
#include <ITranslator.h>
|
|
||||||
|
|
||||||
using namespace SourcePawn;
|
using namespace SourcePawn;
|
||||||
using namespace SourceMod;
|
|
||||||
|
#define LANG_SERVER 0
|
||||||
|
|
||||||
#define IS_STR_FILLED(var) (var[0] != '\0')
|
#define IS_STR_FILLED(var) (var[0] != '\0')
|
||||||
|
|
||||||
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param);
|
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param);
|
||||||
const char *stristr(const char *str, const char *substr);
|
const char *stristr(const char *str, const char *substr);
|
||||||
unsigned int strncopy(char *dest, const char *src, size_t count);
|
unsigned int strncopy(char *dest, const char *src, size_t count);
|
||||||
bool gnprintf(char *buffer,
|
size_t gnprintf(char *buffer, size_t maxlen, const char *format, void **args);
|
||||||
size_t maxlen,
|
|
||||||
const char *format,
|
|
||||||
IPhraseCollection *pPhrases,
|
|
||||||
void **params,
|
|
||||||
unsigned int numparams,
|
|
||||||
unsigned int &curparam,
|
|
||||||
size_t *pOutLength,
|
|
||||||
const char **pFailPhrase);
|
|
||||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
|
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
|
||||||
char *sm_strdup(const char *str);
|
char *sm_strdup(const char *str);
|
||||||
|
size_t CorePlayerTranslate(int client, char *buffer, size_t maxlength, const char *phrase, void **params);
|
||||||
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace);
|
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace);
|
||||||
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen);
|
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen);
|
||||||
char *UTIL_TrimWhitespace(char *str, size_t &len);
|
char *UTIL_TrimWhitespace(char *str, size_t &len);
|
||||||
|
|||||||
+2
-4
@@ -40,9 +40,7 @@
|
|||||||
* @file Contains SourceMod version information.
|
* @file Contains SourceMod version information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SM_BUILD_STRING ""
|
#define SVN_FULL_VERSION "1.0.3"
|
||||||
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
|
#define SVN_FILE_VERSION 1,0,3,2276
|
||||||
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
|
|
||||||
#define SVN_FILE_VERSION 1,1,0,0
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_VERSION_H_
|
#endif //_INCLUDE_SOURCEMOD_VERSION_H_
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user