From f74380b3e9f6dcd32157ef13bfead8e84a3aea16 Mon Sep 17 00:00:00 2001 From: Fyren Date: Sun, 3 May 2009 11:23:12 -0700 Subject: [PATCH 1/7] Fix casting problems in TextParsers breaking TrimString for non-ASCII (bug 3800, r+a12=dvander) --- core/TextParsers.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/TextParsers.cpp b/core/TextParsers.cpp index 9cc6c231..87b68311 100644 --- a/core/TextParsers.cpp +++ b/core/TextParsers.cpp @@ -48,7 +48,7 @@ static int g_ws_chartable[255] = {0}; bool TextParsers::IsWhitespace(const char *stream) { - return g_ws_chartable[(unsigned)*stream] == 1; + return g_ws_chartable[(unsigned char)*stream] == 1; } TextParsers::TextParsers() @@ -508,7 +508,7 @@ SMCError TextParsers::ParseStream_SMC(void *stream, else { /* Check if we're whitespace or not */ - if (!g_ws_chartable[(unsigned)c]) + if (!g_ws_chartable[(unsigned char)c]) { bool restage = false; /* Check various special tokens: @@ -823,7 +823,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene ***************************************************/ /* First strip beginning whitespace */ - while (*ptr != '\0' && g_ws_chartable[(unsigned)*ptr] != 0) + while (*ptr != '\0' && g_ws_chartable[(unsigned char)*ptr] != 0) { ptr++; } @@ -876,7 +876,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene /* Lastly, strip ending whitespace off */ for (size_t i=len-1; i>=0 && i Date: Thu, 7 May 2009 20:15:32 -0700 Subject: [PATCH 2/7] Fix sdktools MSVC9 project file (and sm_slap) for EP1 games (bug 3768) --- extensions/sdktools/msvc9/sdktools.vcproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 5b982d28..699e6419 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -125,7 +125,7 @@ AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" @@ -369,7 +369,7 @@ AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -451,7 +451,7 @@ AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" From 7fd6b308f86446ac6f5e3a34463a169522ab9305 Mon Sep 17 00:00:00 2001 From: Fyren Date: Fri, 8 May 2009 00:10:12 -0700 Subject: [PATCH 3/7] Fix Windows L4D CreateFakeClient signature (bug 3792) --- gamedata/sdktools.games/engine.l4d.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamedata/sdktools.games/engine.l4d.txt b/gamedata/sdktools.games/engine.l4d.txt index 1f723871..1b0a0901 100644 --- a/gamedata/sdktools.games/engine.l4d.txt +++ b/gamedata/sdktools.games/engine.l4d.txt @@ -176,7 +176,7 @@ * the expected code. A pointer to sv (IServer interface) is used * here. */ - "CreateFakeClient_Windows" "\x55\x8B\xEC\x83\xEC\x08\x89\x4D\xF8\x8B\x45\x08\x50\xB9\x2A\x2A\x2A\x2A\xE8" + "CreateFakeClient_Windows" "\x8B\x44\x24\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8" } "Offsets" @@ -184,7 +184,7 @@ /* Offset into IVEngineServer::CreateFakeClient */ "sv" { - "windows" "14" + "windows" "6" } } From bf8c57c669a71077844c8885f47b861a0b9141b5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 9 May 2009 09:21:14 -0400 Subject: [PATCH 4/7] Fixed compiler choosing whether to emit stradjust.pri on dynamic arrays based on uninitialized memory (bug 3810, r=fyren,pred, a12=blocking). --- sourcepawn/compiler/sc1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index af7c1ef9..5df0aea5 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -2303,12 +2303,13 @@ static int declloc(int fstatic) if (matchtoken(']')) { idxtag[numdim] = 0; dim[numdim] = 0; - numdim++; + numdim++; continue; } dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { all_constant = 0; + dim[numdim] = 0; } else if (dim_ident == iCONSTEXPR) { dim[numdim] = dim_val.constval; /* :TODO: :URGENT: Make sure this still works */ @@ -2323,7 +2324,7 @@ static int declloc(int fstatic) error(29); /* invalid expression, assumed 0 */ } numdim++; - needtoken(']'); + needtoken(']'); } while (matchtoken('[')); if (all_constant) { /* Change the last dimension to be based on chars instead if we have a string */ @@ -2335,7 +2336,7 @@ static int declloc(int fstatic) ident = iARRAY; stgdel(_index, _code); } else { - if (tag == pc_tag_string && numdim && dim[numdim-1]) { + if (tag == pc_tag_string && numdim) { stradjust(sPRI); } pushreg(sPRI); From 211c5dcfcd376baf651ab4f135799fdfc5233e5a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 10 May 2009 11:01:19 -0400 Subject: [PATCH 5/7] Fixed compiler reading uninitialized strings while processing varargs (bug 3811, r=fyren,pred, a12=blocking). --- sourcepawn/compiler/sc3.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 6018082f..1b365730 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -2422,8 +2422,6 @@ static int nesting=0; if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval) && !checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag)) error(213); - if (lval.tag!=0) - append_constval(&taglst,arg[argidx].name,lval.tag,0); break; case iVARIABLE: if (lval.ident==iLABEL || lval.ident==iFUNCTN || lval.ident==iREFFUNC From bd97bdd3787be8b4d6d3eb96d1f69bcf6fdb3241 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 11 May 2009 11:32:59 +1200 Subject: [PATCH 6/7] Fixed unhook event crash (bug 3814, r=dvander) --- core/EventManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 04888f3b..a95e78c9 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -194,7 +194,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct } /* Cache the name for post hooks */ - pHook->name = strdup(name); + pHook->name = sm_strdup(name); /* Increase reference count */ pHook->refCount++; @@ -300,7 +300,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun sm_trie_delete(m_EventHooks, name); /* Free the cached name */ - free(pHook->name); + delete pHook->name; /* And finally free structure memory */ delete pHook; @@ -472,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast) assert(pHook->pPostHook == NULL); assert(pHook->pPreHook == NULL); sm_trie_delete(m_EventHooks, pHook->name); - free(pHook->name); + delete pHook->name; delete pHook; } } From 834a9bc84d568e0dcf1d89e8a5e5c223380951d4 Mon Sep 17 00:00:00 2001 From: Fyren Date: Mon, 11 May 2009 18:46:19 -0700 Subject: [PATCH 7/7] Some sdktools string and style changes (r=pred) --- extensions/sdktools/vnatives.cpp | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 5fc75b66..7fb4c59f 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -128,7 +128,7 @@ static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"RemovePlayerItem\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"RemovePlayerItem\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"RemovePlayerItem\" wrapper failed to initialize"); } } @@ -153,7 +153,7 @@ static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialize"); } } @@ -190,7 +190,7 @@ static cell_t GetPlayerWeaponSlot(IPluginContext *pContext, const cell_t *params { return pContext->ThrowNativeError("\"Weapon_GetSlot\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"Weapon_GetSlot\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Weapon_GetSlot\" wrapper failed to initialize"); } } @@ -229,7 +229,7 @@ static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"Ignite\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize"); } } @@ -261,7 +261,7 @@ static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"Ignite\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize"); } } @@ -289,7 +289,7 @@ static cell_t ExtinguishEntity(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialize"); } } @@ -313,7 +313,7 @@ static cell_t TeleportEntity(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"Teleport\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"Teleport\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Teleport\" wrapper failed to initialize"); } } @@ -343,7 +343,7 @@ static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params) } else if (!pCall) { - return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialize"); } } @@ -365,7 +365,7 @@ static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialize"); } } @@ -667,7 +667,7 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para { return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialize"); } } @@ -707,7 +707,7 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialize"); } } @@ -745,7 +745,7 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialize"); } } @@ -782,7 +782,7 @@ static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"DispatchSpawn\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"DispatchSpawn\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"DispatchSpawn\" wrapper failed to initialize"); } } @@ -807,7 +807,7 @@ static cell_t DispatchKeyValue(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"DispatchKeyValue\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"DispatchKeyValue\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"DispatchKeyValue\" wrapper failed to initialize"); } } @@ -818,7 +818,7 @@ static cell_t DispatchKeyValue(IPluginContext *pContext, const cell_t *params) DECODE_VALVE_PARAM(3, vparams, 1); FINISH_CALL_SIMPLE(&ret); - return (ret) ? 1 : 0; + return ret ? 1 : 0; } static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *params) @@ -834,7 +834,7 @@ static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *para { return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" wrapper failed to initialize"); } } @@ -845,7 +845,7 @@ static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *para DECODE_VALVE_PARAM(3, vparams, 1); FINISH_CALL_SIMPLE(&ret); - return (ret) ? 1 : 0; + return ret ? 1 : 0; } static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *params) @@ -865,7 +865,7 @@ static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *par { return pContext->ThrowNativeError("\"DispatchKeyValueVector\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"DispatchKeyValueVector\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"DispatchKeyValueVector\" wrapper failed to initialize"); } } @@ -876,7 +876,7 @@ static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *par DECODE_VALVE_PARAM(3, vparams, 1); FINISH_CALL_SIMPLE(&ret); - return (ret) ? 1 : 0; + return ret ? 1 : 0; } static cell_t sm_GetClientAimTarget(IPluginContext *pContext, const cell_t *params) @@ -907,7 +907,7 @@ static cell_t sm_SetEntityModel(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"SetEntityModel\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"SetEntityModel\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"SetEntityModel\" wrapper failed to initialize"); } } @@ -976,7 +976,7 @@ static cell_t WeaponEquip(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("\"WeaponEquip\" not supported by this mod"); } else if (!pCall) { - return pContext->ThrowNativeError("\"WeaponEquip\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"WeaponEquip\" wrapper failed to initialize"); } } @@ -999,7 +999,7 @@ static cell_t ActivateEntity(IPluginContext *pContext, const cell_t *params) } else if (!pCall) { - return pContext->ThrowNativeError("\"Activate\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"Activate\" wrapper failed to initialize"); } } @@ -1042,7 +1042,7 @@ static cell_t SetClientInfo(IPluginContext *pContext, const cell_t *params) } else if (!pCall) { - return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialize"); } } @@ -1057,7 +1057,7 @@ static cell_t SetClientInfo(IPluginContext *pContext, const cell_t *params) } else if (!pUpdateSettings) { - return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialized"); + return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialize"); } } #else