Merged, thanks Fyren

This commit is contained in:
Matt Woodrow 2009-05-12 13:56:00 +12:00
commit 4f426dafef
5 changed files with 39 additions and 40 deletions

View File

@ -194,7 +194,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
} }
/* Cache the name for post hooks */ /* Cache the name for post hooks */
pHook->name = strdup(name); pHook->name = sm_strdup(name);
/* Increase reference count */ /* Increase reference count */
pHook->refCount++; pHook->refCount++;
@ -300,7 +300,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
sm_trie_delete(m_EventHooks, name); sm_trie_delete(m_EventHooks, name);
/* Free the cached name */ /* Free the cached name */
free(pHook->name); delete pHook->name;
/* And finally free structure memory */ /* And finally free structure memory */
delete pHook; delete pHook;
@ -472,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
assert(pHook->pPostHook == NULL); assert(pHook->pPostHook == NULL);
assert(pHook->pPreHook == NULL); assert(pHook->pPreHook == NULL);
sm_trie_delete(m_EventHooks, pHook->name); sm_trie_delete(m_EventHooks, pHook->name);
free(pHook->name); delete pHook->name;
delete pHook; delete pHook;
} }
} }

View File

@ -48,7 +48,7 @@ static int g_ws_chartable[255] = {0};
bool TextParsers::IsWhitespace(const char *stream) bool TextParsers::IsWhitespace(const char *stream)
{ {
return g_ws_chartable[(unsigned)*stream] == 1; return g_ws_chartable[(unsigned char)*stream] == 1;
} }
TextParsers::TextParsers() TextParsers::TextParsers()
@ -508,7 +508,7 @@ SMCError TextParsers::ParseStream_SMC(void *stream,
else else
{ {
/* Check if we're whitespace or not */ /* Check if we're whitespace or not */
if (!g_ws_chartable[(unsigned)c]) if (!g_ws_chartable[(unsigned char)c])
{ {
bool restage = false; bool restage = false;
/* Check various special tokens: /* Check various special tokens:
@ -823,7 +823,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
***************************************************/ ***************************************************/
/* First strip beginning whitespace */ /* First strip beginning whitespace */
while (*ptr != '\0' && g_ws_chartable[(unsigned)*ptr] != 0) while (*ptr != '\0' && g_ws_chartable[(unsigned char)*ptr] != 0)
{ {
ptr++; ptr++;
} }
@ -876,7 +876,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
/* Lastly, strip ending whitespace off */ /* Lastly, strip ending whitespace off */
for (size_t i=len-1; i>=0 && i<len; i--) for (size_t i=len-1; i>=0 && i<len; i--)
{ {
if (g_ws_chartable[(unsigned)ptr[i]]) if (g_ws_chartable[(unsigned char)ptr[i]])
{ {
ptr[i] = '\0'; ptr[i] = '\0';
len--; len--;
@ -917,7 +917,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
i += _GetUTF8CharBytes(&ptr[i]) - 1; i += _GetUTF8CharBytes(&ptr[i]) - 1;
} }
} else { } else {
alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned)c] != 0); alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned char)c] != 0);
} }
if (!alnum) if (!alnum)
{ {
@ -970,12 +970,12 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
i += _GetUTF8CharBytes(&ptr[i]) - 1; i += _GetUTF8CharBytes(&ptr[i]) - 1;
} }
} else { } else {
alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned)c] != 0); alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned char)c] != 0);
} }
if (!alnum) if (!alnum)
{ {
if (g_ws_chartable[(unsigned)c]) if (g_ws_chartable[(unsigned char)c])
{ {
/* if it's a space, keep track of the first occurring space */ /* if it's a space, keep track of the first occurring space */
if (!first_space) if (!first_space)
@ -1014,7 +1014,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
if (val_ptr) if (val_ptr)
{ {
/* eat up spaces! there shouldn't be any h*/ /* eat up spaces! there shouldn't be any h*/
while ((*val_ptr != '\0') && g_ws_chartable[(unsigned)*val_ptr] != 0) while ((*val_ptr != '\0') && g_ws_chartable[(unsigned char)*val_ptr] != 0)
{ {
val_ptr++; val_ptr++;
} }

View File

@ -128,7 +128,7 @@ static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
{ {
return pContext->ThrowNativeError("\"RemovePlayerItem\" not supported by this mod"); return pContext->ThrowNativeError("\"RemovePlayerItem\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"Weapon_GetSlot\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"Teleport\" not supported by this mod");
} else if (!pCall) { } 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) 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"); return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"DispatchSpawn\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"DispatchKeyValue\" not supported by this mod");
} else if (!pCall) { } 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); DECODE_VALVE_PARAM(3, vparams, 1);
FINISH_CALL_SIMPLE(&ret); FINISH_CALL_SIMPLE(&ret);
return (ret) ? 1 : 0; return ret ? 1 : 0;
} }
static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *params) 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"); return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" not supported by this mod");
} else if (!pCall) { } 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); DECODE_VALVE_PARAM(3, vparams, 1);
FINISH_CALL_SIMPLE(&ret); FINISH_CALL_SIMPLE(&ret);
return (ret) ? 1 : 0; return ret ? 1 : 0;
} }
static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *params) 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"); return pContext->ThrowNativeError("\"DispatchKeyValueVector\" not supported by this mod");
} else if (!pCall) { } 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); DECODE_VALVE_PARAM(3, vparams, 1);
FINISH_CALL_SIMPLE(&ret); FINISH_CALL_SIMPLE(&ret);
return (ret) ? 1 : 0; return ret ? 1 : 0;
} }
static cell_t sm_GetClientAimTarget(IPluginContext *pContext, const cell_t *params) 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"); return pContext->ThrowNativeError("\"SetEntityModel\" not supported by this mod");
} else if (!pCall) { } 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"); return pContext->ThrowNativeError("\"WeaponEquip\" not supported by this mod");
} else if (!pCall) { } 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) 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) 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) else if (!pUpdateSettings)
{ {
return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialized"); return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialize");
} }
} }
#else #else

View File

@ -2312,12 +2312,13 @@ static int declloc(int fstatic)
if (matchtoken(']')) { if (matchtoken(']')) {
idxtag[numdim] = 0; idxtag[numdim] = 0;
dim[numdim] = 0; dim[numdim] = 0;
numdim++; numdim++;
continue; continue;
} }
dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val);
if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) {
all_constant = 0; all_constant = 0;
dim[numdim] = 0;
} else if (dim_ident == iCONSTEXPR) { } else if (dim_ident == iCONSTEXPR) {
dim[numdim] = dim_val.constval; dim[numdim] = dim_val.constval;
/* :TODO: :URGENT: Make sure this still works */ /* :TODO: :URGENT: Make sure this still works */
@ -2332,7 +2333,7 @@ static int declloc(int fstatic)
error(29); /* invalid expression, assumed 0 */ error(29); /* invalid expression, assumed 0 */
} }
numdim++; numdim++;
needtoken(']'); needtoken(']');
} while (matchtoken('[')); } while (matchtoken('['));
if (all_constant) { if (all_constant) {
/* Change the last dimension to be based on chars instead if we have a string */ /* Change the last dimension to be based on chars instead if we have a string */
@ -2344,7 +2345,7 @@ static int declloc(int fstatic)
ident = iARRAY; ident = iARRAY;
stgdel(_index, _code); stgdel(_index, _code);
} else { } else {
if (tag == pc_tag_string && numdim && dim[numdim-1]) { if (tag == pc_tag_string && numdim) {
stradjust(sPRI); stradjust(sPRI);
} }
pushreg(sPRI); pushreg(sPRI);

View File

@ -2422,8 +2422,6 @@ static int nesting=0;
if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval) if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval)
&& !checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag)) && !checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag))
error(213); error(213);
if (lval.tag!=0)
append_constval(&taglst,arg[argidx].name,lval.tag,0);
break; break;
case iVARIABLE: case iVARIABLE:
if (lval.ident==iLABEL || lval.ident==iFUNCTN || lval.ident==iREFFUNC if (lval.ident==iLABEL || lval.ident==iFUNCTN || lval.ident==iREFFUNC