From 0b131d6864549b419e6aa5ae5180fc74704f0828 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Sun, 13 Jul 2014 13:56:47 +0200 Subject: [PATCH 01/15] Pause dependent plugins on SetFailState (bug 6120) When a plugin calls SetFailState it is paused and all natives it registered are unavailable. Other plugins, which depend on those natives keep running and error whenever they try to call those natives. This correctly sets the dependent plugins to an error state as if the plugin which called SetFailState was unloaded. --- core/logic/PluginSys.cpp | 31 +++++++++++++++++++------------ core/logic/smn_core.cpp | 8 ++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index c53d4fe3..a22544df 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -195,15 +195,20 @@ IPluginRuntime *CPlugin::GetRuntime() void CPlugin::SetErrorState(PluginStatus status, const char *error_fmt, ...) { - PluginStatus old_status = m_status; - m_status = status; - - if (old_status == Plugin_Running) + if (m_status == Plugin_Running) { /* Tell everyone we're now paused */ - g_PluginSys._SetPauseState(this, true); + SetPauseState(true); + /* If we won't recover from this error, drop everything and pause dependent plugins too! */ + if (status == Plugin_Failed) + { + DropEverything(); + } } + /* SetPauseState sets the status to Plugin_Paused, but we might want to see some other status set. */ + m_status = status; + va_list ap; va_start(ap, error_fmt); smcore.FormatArgs(m_errormsg, sizeof(m_errormsg), error_fmt, ap); @@ -531,7 +536,8 @@ bool CPlugin::SetPauseState(bool paused) if (paused && GetStatus() != Plugin_Running) { return false; - } else if (!paused && GetStatus() != Plugin_Paused) { + } + else if (!paused && GetStatus() != Plugin_Paused && GetStatus() != Plugin_Error) { return false; } @@ -539,6 +545,12 @@ bool CPlugin::SetPauseState(bool paused) { LibraryActions(LibraryAction_Removed); } + else + { + // Set to running again BEFORE trying to call OnPluginPauseChange ;) + m_status = Plugin_Running; + m_pRuntime->SetPauseState(false); + } IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("OnPluginPauseChange"); if (pFunction) @@ -552,9 +564,6 @@ bool CPlugin::SetPauseState(bool paused) { m_status = Plugin_Paused; m_pRuntime->SetPauseState(true); - } else { - m_status = Plugin_Running; - m_pRuntime->SetPauseState(false); } g_PluginSys._SetPauseState(this, paused); @@ -1496,11 +1505,9 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin) if (pPlugin->GetStatus() == Plugin_Error) { /* If we got here, all natives are okay again! */ - pPlugin->m_status = Plugin_Running; if (pPlugin->m_pRuntime->IsPaused()) { - pPlugin->m_pRuntime->SetPauseState(false); - _SetPauseState(pPlugin, false); + pPlugin->SetPauseState(false); } } } diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 50eb0e5d..c595ebab 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -380,7 +380,7 @@ static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) if (params[0] == 1) { - pPlugin->SetErrorState(Plugin_Error, "%s", str); + pPlugin->SetErrorState(Plugin_Failed, "%s", str); return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); } @@ -391,12 +391,12 @@ static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - pPlugin->SetErrorState(Plugin_Error, "%s", str); + pPlugin->SetErrorState(Plugin_Failed, "%s", str); return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "Formatting error (%s)", str); } else { - pPlugin->SetErrorState(Plugin_Error, "%s", buffer); + pPlugin->SetErrorState(Plugin_Failed, "%s", buffer); return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer); } } @@ -774,4 +774,4 @@ REGISTER_NATIVES(coreNatives) {"LoadFromAddress", LoadFromAddress}, {"StoreToAddress", StoreToAddress}, {NULL, NULL}, -}; \ No newline at end of file +}; From 9b2e77711aedf663cb753a97f8a53bcd4aec5804 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Wed, 29 Oct 2014 17:13:43 +0100 Subject: [PATCH 02/15] Plugin_Failed == "An unrecoverable error" Change the meaning of Plugin_Failed status to indicate, that the plugin can't recover from the error. Make sure those previously loaded plugins are shown correctly in sm plugins info x. --- core/logic/PluginSys.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index a22544df..ae7935f1 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -1147,7 +1147,7 @@ void CPluginManager::LoadAll_SecondPass() if (!RunSecondPass(pPlugin, error, sizeof(error))) { g_Logger.LogError("[SM] Unable to load plugin \"%s\": %s", pPlugin->GetFilename(), error); - pPlugin->SetErrorState(Plugin_Failed, "%s", error); + pPlugin->SetErrorState(Plugin_BadLoad, "%s", error); } } } @@ -2224,7 +2224,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c const sm_plugininfo_t *info = pl->GetPublicInfo(); rootmenu->ConsolePrint(" Filename: %s", pl->GetFilename()); - if (pl->GetStatus() <= Plugin_Error) + if (pl->GetStatus() <= Plugin_Error || pl->GetStatus() == Plugin_Failed) { if (IS_STR_FILLED(info->name)) { @@ -2247,7 +2247,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c { rootmenu->ConsolePrint(" URL: %s", info->url); } - if (pl->GetStatus() == Plugin_Error) + if (pl->GetStatus() == Plugin_Error || pl->GetStatus() == Plugin_Failed) { rootmenu->ConsolePrint(" Error: %s", pl->m_errormsg); } From 4a9dffd3e14afedef7e66d8505d6946f349e09db Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 29 Dec 2014 11:56:07 -0500 Subject: [PATCH 03/15] Change sm_trigger_show default value to 0 / disabled. --- plugins/basetriggers.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/basetriggers.sp b/plugins/basetriggers.sp index 8753a408..20a574c8 100644 --- a/plugins/basetriggers.sp +++ b/plugins/basetriggers.sp @@ -71,7 +71,7 @@ public OnPluginStart() LoadTranslations("common.phrases"); LoadTranslations("basetriggers.phrases"); - g_Cvar_TriggerShow = CreateConVar("sm_trigger_show", "1", "Display triggers message to all players? (0 off, 1 on, def. 1)", 0, true, 0.0, true, 1.0); + g_Cvar_TriggerShow = CreateConVar("sm_trigger_show", "0", "Display triggers message to all players? (0 off, 1 on, def. 0)", 0, true, 0.0, true, 1.0); g_Cvar_TimeleftInterval = CreateConVar("sm_timeleft_interval", "0.0", "Display timeleft every x seconds. Default 0.", 0, true, 0.0, true, 1800.0); g_Cvar_FriendlyFire = FindConVar("mp_friendlyfire"); From 7f0edd441e7ee4ec4fb0d2fbddcc00e4061b5938 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 30 Dec 2014 08:36:35 -0500 Subject: [PATCH 04/15] Add offset printing to datamap dumps. --- extensions/sdktools/vhelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/sdktools/vhelpers.cpp b/extensions/sdktools/vhelpers.cpp index d6a41753..9207dcba 100644 --- a/extensions/sdktools/vhelpers.cpp +++ b/extensions/sdktools/vhelpers.cpp @@ -822,11 +822,11 @@ void UTIL_DrawDataTable(FILE *fp, datamap_t *pMap, int level) if (externalname == NULL) { - fprintf(fp,"%s- %s (%s)(%i Bytes)\n", spaces, pMap->dataDesc[i].fieldName, flags, pMap->dataDesc[i].fieldSizeInBytes); + fprintf(fp, "%s- %s (Offset %d) (%s)(%i Bytes)\n", spaces, pMap->dataDesc[i].fieldName, GetTypeDescOffs(&pMap->dataDesc[i]), flags, pMap->dataDesc[i].fieldSizeInBytes); } else { - fprintf(fp,"%s- %s (%s)(%i Bytes) - %s\n", spaces, pMap->dataDesc[i].fieldName, flags, pMap->dataDesc[i].fieldSizeInBytes, externalname); + fprintf(fp, "%s- %s (Offset %d) (%s)(%i Bytes) - %s\n", spaces, pMap->dataDesc[i].fieldName, GetTypeDescOffs(&pMap->dataDesc[i]), flags, pMap->dataDesc[i].fieldSizeInBytes, externalname); } } } From 6d1a2b0d8627cdfcc0e8c6b158e2726174d33be5 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 30 Dec 2014 11:38:06 -0500 Subject: [PATCH 05/15] Expose Message_DetermineMulticastRecipients as GetClientsInRange native. --- core/smn_halflife.cpp | 42 ++++++++++++++++++++++++++++++++++++ plugins/include/halflife.inc | 18 ++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index b27a7e4f..c49c6431 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -572,6 +572,47 @@ static cell_t ReferenceToBCompatRef(IPluginContext *pContext, const cell_t *para return g_HL2.ReferenceToBCompatRef(params[1]); } +// Must match ClientRangeType enum in halflife.inc +enum class ClientRangeType : cell_t +{ + Visibility = 0, + Audibility, +}; + +static cell_t GetClientsInRange(IPluginContext *pContext, const cell_t *params) +{ + cell_t *origin; + pContext->LocalToPhysAddr(params[1], &origin); + + Vector vOrigin(sp_ctof(origin[0]), sp_ctof(origin[1]), sp_ctof(origin[2])); + + ClientRangeType rangeType = (ClientRangeType) params[2]; + + CBitVec players; + engine->Message_DetermineMulticastRecipients(rangeType == ClientRangeType::Audibility, vOrigin, players); + + cell_t *outPlayers; + pContext->LocalToPhysAddr(params[3], &outPlayers); + + int maxPlayers = params[4]; + int curPlayers = 0; + + int index = players.FindNextSetBit(0); + while (index > -1 && curPlayers < maxPlayers) + { + int entidx = index + 1; + CPlayer *pPlayer = g_Players.GetPlayerByIndex(entidx); + if (pPlayer && pPlayer->IsInGame()) + { + outPlayers[curPlayers++] = entidx; + } + + index = players.FindNextSetBit(index + 1); + } + + return curPlayers; +} + REGISTER_NATIVES(halflifeNatives) { {"CreateFakeClient", CreateFakeClient}, @@ -607,5 +648,6 @@ REGISTER_NATIVES(halflifeNatives) {"EntIndexToEntRef", IndexToReference}, {"EntRefToEntIndex", ReferenceToIndex}, {"MakeCompatEntRef", ReferenceToBCompatRef}, + {"GetClientsInRange", GetClientsInRange}, {NULL, NULL}, }; diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index 22cc9d30..4514bb08 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -624,3 +624,21 @@ native EntRefToEntIndex(ref); */ native MakeCompatEntRef(ref); + +enum ClientRangeType +{ + RangeType_Visibility = 0, + RangeType_Audibility, +} + +/** + * Find clients that are potentially in range of a position. + * + * @param origin Coordinates from which to test range. + * @param rangeType Range type to use for filtering clients. + * @param clients Array to which found client indexes will be written. + * @param size Maximum size of clients array. + * @return Number of client indexes written to clients array. + */ +native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] clients, int size); + From 5961ed2e4afee6e34e292847d909af60a3309998 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 30 Dec 2014 17:23:52 -0500 Subject: [PATCH 06/15] More gamedata cleanup. --- gamedata/core.games/engine.sdk2013.txt | 43 ++------------------------ 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/gamedata/core.games/engine.sdk2013.txt b/gamedata/core.games/engine.sdk2013.txt index 4912944c..d5f6764d 100644 --- a/gamedata/core.games/engine.sdk2013.txt +++ b/gamedata/core.games/engine.sdk2013.txt @@ -29,13 +29,6 @@ "windows" "11" "linux" "13" } - - "EntInfo" - { - "windows" "4" - "linux" "4" - "mac" "4" - } } "Signatures" @@ -54,24 +47,15 @@ } } - /* CGlobalEntityList */ "#default" { - /* These games do have symbols in the linux binaries */ - "#supported" + "Keys" { - "game" "fof" - "game" "nmrih" + "UseInvalidUniverseInSteam2IDs" "1" } "Offsets" { - /* Offset into LevelShutdown */ - "gEntList" - { - "windows" "11" - } - "EntInfo" { "windows" "4" @@ -79,28 +63,5 @@ "mac" "4" } } - - "Signatures" - { - "LevelShutdown" - { - "library" "server" - "windows" "\xE8\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\xE8" - } - "gEntList" - { - "library" "server" - "linux" "@gEntList" - "mac" "@gEntList" - } - } - } - - "#default" - { - "Keys" - { - "UseInvalidUniverseInSteam2IDs" "1" - } } } From aa38226337ef08b3ea38c4e7a4684b3840c2e796 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 30 Dec 2014 20:56:28 -0500 Subject: [PATCH 07/15] Fix SDKHooks causing crash on plugin load/unload or player connect/disconnect if missing gamedata. --- extensions/sdkhooks/extension.cpp | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index d24c1527..1cfd27ab 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -219,6 +219,26 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) return false; } + buffer[0] = '\0'; + if (!gameconfs->LoadGameConfigFile("sdkhooks.games", &g_pGameConf, buffer, sizeof(buffer))) + { + if (buffer[0]) + { + g_pSM->Format(error, maxlength, "Could not read sdkhooks.games gamedata: %s", buffer); + } + + return false; + } + + CUtlVector *entListeners = EntListeners(); + if (!entListeners) + { + g_pSM->Format(error, maxlength, "Failed to setup entity listeners"); + return false; + } + + entListeners->AddToTail(this); + sharesys->AddDependency(myself, "bintools.ext", true, true); sharesys->AddNatives(myself, g_Natives); sharesys->RegisterLibrary(myself, "sdkhooks"); @@ -237,26 +257,6 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) #endif g_pOnLevelInit = forwards->CreateForward("OnLevelInit", ET_Hook, 2, NULL, Param_String, Param_String); - buffer[0] = '\0'; - if (!gameconfs->LoadGameConfigFile("sdkhooks.games", &g_pGameConf, buffer, sizeof(buffer))) - { - if (buffer[0]) - { - g_pSM->Format(error, maxlength, "Could not read sdkhooks.games gamedata: %s", buffer); - } - - return false; - } - - CUtlVector *entListeners = EntListeners(); - if (!entListeners) - { - g_pSM->Format(error, maxlength, "Failed to setup entity listeners"); - return false; - } - - entListeners->AddToTail(this); - SetupHooks(); #if SOURCE_ENGINE >= SE_ORANGEBOX From 3e65d308a81ae83652db36e20453003d86233b6b Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 1 Jan 2015 14:56:37 -0500 Subject: [PATCH 08/15] Don't looks for IServerTools on ep1 games. (We don't use it and it doesn't exist on most.) --- core/sourcemm_api.cpp | 4 ++++ core/sourcemm_api.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 902a241e..8daeb2e0 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -51,7 +51,9 @@ IPlayerInfoManager *playerinfo = NULL; IBaseFileSystem *basefilesystem = NULL; IFileSystem *filesystem = NULL; IEngineSound *enginesound = NULL; +#if SOURCE_ENGINE >= SE_ORANGEBOX IServerTools *servertools = NULL; +#endif IServerPluginHelpers *serverpluginhelpers = NULL; IServerPluginCallbacks *vsp_interface = NULL; int vsp_version = 0; @@ -70,7 +72,9 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION); GET_V_IFACE_CURRENT(GetFileSystemFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION); GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION); +#if SOURCE_ENGINE >= SE_ORANGEBOX GET_V_IFACE_CURRENT(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION); +#endif #if SOURCE_ENGINE != SE_DOTA GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); #endif diff --git a/core/sourcemm_api.h b/core/sourcemm_api.h index 29815005..c813f27e 100644 --- a/core/sourcemm_api.h +++ b/core/sourcemm_api.h @@ -102,7 +102,9 @@ extern IPlayerInfoManager *playerinfo; extern IBaseFileSystem *basefilesystem; extern IFileSystem *filesystem; extern IEngineSound *enginesound; +#if SOURCE_ENGINE >= SE_ORANGEBOX extern IServerTools *servertools; +#endif extern IServerPluginHelpers *serverpluginhelpers; extern IServerPluginCallbacks *vsp_interface; extern int vsp_version; From ff9ae0782ea9652b80cd170a40f99f481d80f999 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Sat, 3 Jan 2015 19:45:27 +0100 Subject: [PATCH 09/15] Fix missing params in OnTakeDamagePost typedef Looks like the |weapon| parameter went missing during the switch to the transitional syntax. There was no -Post typedef including the |damagecustom| bit at all too. --- plugins/include/sdkhooks.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/include/sdkhooks.inc b/plugins/include/sdkhooks.inc index e47e2fc6..44a448a2 100644 --- a/plugins/include/sdkhooks.inc +++ b/plugins/include/sdkhooks.inc @@ -264,7 +264,9 @@ typeset SDKHookCB // OnTakeDamagePost // OnTakeDamageAlivePost function void (int victim, int attacker, int inflictor, float damage, int damagetype); - function void (int victim, int attacker, int inflictor, float damage, int damagetype, const float damageForce[3], const float damagePosition[3]); + function void (int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, const float damageForce[3], const float damagePosition[3]); + function void (int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, + const float damageForce[3], const float damagePosition[3], int damagecustom); // FireBulletsPost function void (int client, int shots, const char[] weaponname); From 822501b8a1127a3acd72b3a5ec329d02606327c1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 3 Jan 2015 11:38:51 -0800 Subject: [PATCH 10/15] Fix typos in dbi.inc transitional syntax. --- plugins/include/dbi.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/include/dbi.inc b/plugins/include/dbi.inc index 71ca686d..7c2325bd 100644 --- a/plugins/include/dbi.inc +++ b/plugins/include/dbi.inc @@ -477,13 +477,13 @@ stock Database SQLite_UseDatabase(const char[] database, char[] error, maxlength) { - new Handle kv, Handle db; + Handle kv, db; kv = CreateKeyValues(""); KvSetString(kv, "driver", "sqlite"); KvSetString(kv, "database", database); - db = SQL_ConnectCustom(kv, error, int maxlength, false); + db = SQL_ConnectCustom(kv, error, maxlength, false); CloseHandle(kv); @@ -641,7 +641,7 @@ stock bool SQL_QuoteString(Handle database, maxlength, &written=0) { - return SQL_EscapeString(database, string, buffer, int maxlength, written); + return SQL_EscapeString(database, string, buffer, maxlength, written); } /** From 4ec992474e37429a8b1c652125263578824cd18b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 3 Jan 2015 11:41:37 -0800 Subject: [PATCH 11/15] Remove some heinous preprocessor directives. Gone: - #emit (bah-roken!) - #pragma compress (useless) - #pragma library (useless) --- sourcepawn/compiler/sc.h | 1 - sourcepawn/compiler/sc2.cpp | 126 +----------------------------------- 2 files changed, 1 insertion(+), 126 deletions(-) diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index a6ed6ec1..29ad5c4b 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -487,7 +487,6 @@ enum TokenKind { tpDEFINE, tpELSE, /* #else */ tpELSEIF, /* #elseif */ - tpEMIT, tpENDIF, tpENDINPUT, tpENDSCRPT, diff --git a/sourcepawn/compiler/sc2.cpp b/sourcepawn/compiler/sc2.cpp index df0cdeea..b2856877 100644 --- a/sourcepawn/compiler/sc2.cpp +++ b/sourcepawn/compiler/sc2.cpp @@ -1036,10 +1036,6 @@ static int command(void) } /* if */ if (!cp_set(name)) error(FATAL_ERROR_NO_CODEPAGE); - } else if (strcmp(str,"compress")==0) { - cell val; - preproc_expr(&val,NULL); - sc_compress=(int)val; /* switch code packing on/off */ } else if (strcmp(str,"ctrlchar")==0) { while (*lptr<=' ' && *lptr!='\0') lptr++; @@ -1059,70 +1055,6 @@ static int command(void) lptr=(unsigned char*)strchr((char*)lptr,'\0'); /* skip to end (ignore "extra characters on line") */ } else if (strcmp(str,"dynamic")==0) { preproc_expr(&pc_stksize,NULL); - } else if (!strcmp(str,"library") - ||!strcmp(str,"reqclass") - ||!strcmp(str,"loadlib") - ||!strcmp(str,"explib") - ||!strcmp(str,"expclass") - ||!strcmp(str,"defclasslib")) { - char name[sNAMEMAX+1],sname[sNAMEMAX+1]; - const char *prefix=""; - sname[0]='\0'; - sname[1]='\0'; - if (!strcmp(str,"library")) - prefix="??li_"; - else if (!strcmp(str,"reqclass")) - prefix="??rc_"; - else if (!strcmp(str,"loadlib")) - prefix="??f_"; - else if (!strcmp(str,"explib")) - prefix="??el_"; - else if (!strcmp(str,"expclass")) - prefix="??ec_"; - else if (!strcmp(str,"defclasslib")) - prefix="??d_"; - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (*lptr=='"') { - lptr=getstring((unsigned char*)name,sizeof name,lptr); - } else { - int i; - for (i=0; iident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0)) { - error(17,str); /* undefined symbol */ - } else { - outval(sym->addr,FALSE); - /* mark symbol as "used", unknown whether for read or write */ - markusage(sym,uREAD | uWRITTEN); - code_idx+=opargs(1); - } /* if */ - break; - default: { - char s2[20]; - extern const char *sc_tokens[];/* forward declaration */ - if (tok<256) - sprintf(s2,"%c",(char)tok); - else - strcpy(s2,sc_tokens[tok-tFIRST]); - error(1,sc_tokens[tSYMBOL-tFIRST],s2); - break; - } /* case */ - } /* switch */ - } /* if */ - stgwrite("\n"); - check_empty(lptr); - break; - } /* case */ -#endif #if !defined NO_DEFINE case tpDEFINE: { ret=CMD_DEFINE; @@ -2047,7 +1923,7 @@ const char *sc_tokens[] = { "volatile", "while", "with", - "#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput", + "#assert", "#define", "#else", "#elseif", "#endif", "#endinput", "#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma", "#tryinclude", "#undef", ";", ";", "-integer value-", "-rational value-", "-identifier-", From 3929ff1f2721239a046ac8ce07c8e6deff9f9f33 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 4 Jan 2015 11:58:44 -0500 Subject: [PATCH 12/15] Fix typo on ArrayList.Erase native. --- core/logic/smn_adt_array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index 954b58cb..299c85a9 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -597,7 +597,7 @@ REGISTER_NATIVES(cellArrayNatives) {"ArrayList.Set", SetArrayCell}, {"ArrayList.SetString", SetArrayString}, {"ArrayList.SetArray", SetArrayArray}, - {"ArrayList.Erease", RemoveFromArray}, + {"ArrayList.Erase", RemoveFromArray}, {"ArrayList.ShiftUp", ShiftArrayUp}, {"ArrayList.SwapAt", SwapArrayItems}, {"ArrayList.Clone", CloneArray}, From 3e012e7f79b926d3058c0bcbc16f0c6baac67959 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 4 Jan 2015 12:28:38 -0500 Subject: [PATCH 13/15] Fix ArrayList.Clear func name. --- plugins/include/adt_array.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/include/adt_array.inc b/plugins/include/adt_array.inc index c16934e0..3bd3378d 100644 --- a/plugins/include/adt_array.inc +++ b/plugins/include/adt_array.inc @@ -67,7 +67,7 @@ methodmap ArrayList < Handle { public native ArrayList(int blocksize=1, int startsize=0); // Clears an array of all entries. This is the same as Resize(0). - public native void ClearArray(); + public native void Clear(); // Clones an array, returning a new handle with the same size and data. // This should NOT be confused with CloneHandle. This is a completely new From 491036a1e68a4df459a7c5b3801974c0909beaf4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 4 Jan 2015 12:04:29 -0800 Subject: [PATCH 14/15] Allow "stock static" in addition to "static stock". --- sourcepawn/compiler/sc1.cpp | 31 +++++++++++++++---- .../compiler/tests/ok-static-stocks-1.sp | 5 +++ .../compiler/tests/ok-static-stocks-2.sp | 7 +++++ 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 sourcepawn/compiler/tests/ok-static-stocks-1.sp create mode 100644 sourcepawn/compiler/tests/ok-static-stocks-2.sp diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 0cc07861..0db9c615 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -1445,12 +1445,25 @@ static void dodecl(const token_t *tok) return; } - int fpublic = (tok->id == tPUBLIC); - int fstock = (tok->id == tSTOCK); - int fstatic = (tok->id == tSTATIC); + int fpublic = FALSE, fstock = FALSE, fstatic = FALSE, fconst = FALSE; + switch (tok->id) { + case tPUBLIC: + fpublic = TRUE; + break; + case tSTOCK: + fstock = TRUE; + if (matchtoken(tSTATIC)) + fstatic = TRUE; + break; + case tSTATIC: + fstatic = TRUE; - if (fstatic && matchtoken(tSTOCK)) - fstock = TRUE; + // For compatibility, we must include this case. Though "stock" should + // come first. + if (matchtoken(tSTOCK)) + fstock = TRUE; + break; + } int flags = DECLFLAG_MAYBE_FUNCTION | DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT; if (tok->id == tNEW) @@ -1462,7 +1475,13 @@ static void dodecl(const token_t *tok) decl.type.tag = 0; } - if (!decl.opertok && (tok->id == tNEW || decl.type.has_postdims || !lexpeek('('))) { + // Hacky bag o' hints as to whether this is a variable decl. + bool probablyVariable = tok->id == tNEW || + decl.type.has_postdims || + !lexpeek('(') || + ((decl.type.usage & uCONST) == uCONST); + + if (!decl.opertok && probablyVariable) { if (tok->id == tNEW && decl.type.is_new) error(143); if (decl.type.tag & STRUCTTAG) { diff --git a/sourcepawn/compiler/tests/ok-static-stocks-1.sp b/sourcepawn/compiler/tests/ok-static-stocks-1.sp new file mode 100644 index 00000000..bf523238 --- /dev/null +++ b/sourcepawn/compiler/tests/ok-static-stocks-1.sp @@ -0,0 +1,5 @@ +static stock const X = 5; +stock static const Y = 6; + +public main() +{} diff --git a/sourcepawn/compiler/tests/ok-static-stocks-2.sp b/sourcepawn/compiler/tests/ok-static-stocks-2.sp new file mode 100644 index 00000000..2ced8743 --- /dev/null +++ b/sourcepawn/compiler/tests/ok-static-stocks-2.sp @@ -0,0 +1,7 @@ +static stock const X = 5; +stock static const Y = 6; + +public main() +{ + return X + Y; +} From bded4f91425e86232947a287ad2aa913be105b07 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 4 Jan 2015 12:12:16 -0800 Subject: [PATCH 15/15] Fix uninitialized variable in decl_enum(). --- sourcepawn/compiler/sc1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 0db9c615..ec76e3d3 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -4647,9 +4647,9 @@ static void decl_enum(int vclass) char *str; int tag,explicittag; cell increment,multiplier; - constvalue *enumroot; LayoutSpec spec; symbol *enumsym = nullptr; + constvalue *enumroot = nullptr; /* get an explicit tag, if any (we need to remember whether an explicit * tag was passed, even if that explicit tag was "_:", so we cannot call