diff --git a/dlls/engine/amxxapi.cpp b/dlls/engine/amxxapi.cpp index 1f260272..a250ac20 100755 --- a/dlls/engine/amxxapi.cpp +++ b/dlls/engine/amxxapi.cpp @@ -18,14 +18,14 @@ void ClearHooks() msgHooks[i].clear(); msgBlocks[i] = 0; } - for (i=0; iszKeyName = charA; - g_pkvd->szValue = charB; + const char *charA = STRING(ALLOC_STRING(char1)); + const char *charB = STRING(ALLOC_STRING(char2)); + g_pkvd->szKeyName = const_cast(charA); + g_pkvd->szValue = const_cast(charB); } return 1; } @@ -1259,10 +1257,7 @@ static cell AMX_NATIVE_CALL entity_set_model(AMX *amx, cell *params) edict_t *pEnt = INDEXENT2(iEnt); int iLen; char *szModel = MF_GetAmxString(amx, params[2], 0, &iLen); - char *szStatic = new char[iLen+1]; - - memset(szStatic, 0, iLen+1); - strcpy(szStatic, szModel); + const char *szStatic = STRING(ALLOC_STRING(szModel)); SET_MODEL(pEnt, szStatic); @@ -1495,7 +1490,7 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param */ { int index = params[1]; - char* szModel; + const char *szModel; CHECK_ENTITY(index); @@ -1506,10 +1501,8 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param * while (!FNullEnt(pentFind)) { if (pentFind->v.owner == pentOwner) { if (params[3]>0) { - szModel = new char[params[3]]; szModel = (char*)STRING(pentFind->v.model); MF_SetAmxString(amx, params[2], szModel, params[3]); - delete [] szModel; return ENTINDEX(pentFind); } } diff --git a/dlls/engine/messages.cpp b/dlls/engine/messages.cpp index cc4aca0e..906512f3 100755 --- a/dlls/engine/messages.cpp +++ b/dlls/engine/messages.cpp @@ -1,6 +1,6 @@ #include "engine.h" -CVector Msg; +CVector Msg; CVector msgHooks[256]; int msgBlocks[256] = {0}; int msgDest; @@ -114,13 +114,13 @@ void WriteByte(int iValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->iData = iValue; - p->type = arg_byte; + argMsg p; + p.iData = iValue; + p.type = arg_byte; Msg.push_back(p); } else { - Msg[msgCount-1]->iData = iValue; - Msg[msgCount-1]->type = arg_byte; + Msg[msgCount-1].iData = iValue; + Msg[msgCount-1].type = arg_byte; } RETURN_META(MRES_SUPERCEDE); } @@ -134,13 +134,13 @@ void WriteChar(int iValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->iData = iValue; - p->type = arg_char; + argMsg p; + p.iData = iValue; + p.type = arg_char; Msg.push_back(p); } else { - Msg[msgCount-1]->iData = iValue; - Msg[msgCount-1]->type = arg_char; + Msg[msgCount-1].iData = iValue; + Msg[msgCount-1].type = arg_char; } RETURN_META(MRES_SUPERCEDE); } @@ -154,13 +154,13 @@ void WriteShort(int iValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->iData = iValue; - p->type = arg_short; + argMsg p; + p.iData = iValue; + p.type = arg_short; Msg.push_back(p); } else { - Msg[msgCount-1]->iData = iValue; - Msg[msgCount-1]->type = arg_short; + Msg[msgCount-1].iData = iValue; + Msg[msgCount-1].type = arg_short; } RETURN_META(MRES_SUPERCEDE); } @@ -174,13 +174,13 @@ void WriteLong(int iValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->iData = iValue; - p->type = arg_long; + argMsg p; + p.iData = iValue; + p.type = arg_long; Msg.push_back(p); } else { - Msg[msgCount-1]->iData = iValue; - Msg[msgCount-1]->type = arg_long; + Msg[msgCount-1].iData = iValue; + Msg[msgCount-1].type = arg_long; } RETURN_META(MRES_SUPERCEDE); } @@ -194,13 +194,13 @@ void WriteAngle(float flValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->fData = flValue; - p->type = arg_angle; + argMsg p; + p.fData = flValue; + p.type = arg_angle; Msg.push_back(p); } else { - Msg[msgCount-1]->fData = flValue; - Msg[msgCount-1]->type = arg_angle; + Msg[msgCount-1].fData = flValue; + Msg[msgCount-1].type = arg_angle; } RETURN_META(MRES_SUPERCEDE); } @@ -214,13 +214,13 @@ void WriteCoord(float flValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->fData = flValue; - p->type = arg_coord; + argMsg p; + p.fData = flValue; + p.type = arg_coord; Msg.push_back(p); } else { - Msg[msgCount-1]->fData = flValue; - Msg[msgCount-1]->type = arg_coord; + Msg[msgCount-1].fData = flValue; + Msg[msgCount-1].type = arg_coord; } RETURN_META(MRES_SUPERCEDE); } @@ -234,13 +234,13 @@ void WriteString(const char *sz) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->cData.assign(sz); - p->type = arg_string; + argMsg p; + p.cData.assign(sz); + p.type = arg_string; Msg.push_back(p); } else { - Msg[msgCount-1]->cData.assign(sz); - Msg[msgCount-1]->type = arg_string; + Msg[msgCount-1].cData.assign(sz); + Msg[msgCount-1].type = arg_string; } RETURN_META(MRES_SUPERCEDE); } @@ -254,13 +254,13 @@ void WriteEntity(int iValue) RETURN_META(MRES_SUPERCEDE); } else if (inhook) { if (++msgCount > Msg.size()) { - argMsg *p = new argMsg(); - p->iData = iValue; - p->type = arg_entity; + argMsg p; + p.iData = iValue; + p.type = arg_entity; Msg.push_back(p); } else { - Msg[msgCount-1]->iData = iValue; - Msg[msgCount-1]->type = arg_entity; + Msg[msgCount-1].iData = iValue; + Msg[msgCount-1].type = arg_entity; } RETURN_META(MRES_SUPERCEDE); } @@ -292,8 +292,8 @@ void MessageEnd(void) } MESSAGE_BEGIN(msgDest, msgType, msgOrigin, msgpEntity); for (i=0; iSend(); - Msg[i]->Reset(); + Msg[i].Send(); + Msg[i].Reset(); } MESSAGE_END(); msgCount = 0; @@ -361,7 +361,7 @@ static cell AMX_NATIVE_CALL get_msg_argtype(AMX *amx, cell *params) return 0; } - return Msg[argn]->type; + return Msg[argn].type; } static cell AMX_NATIVE_CALL get_msg_arg_int(AMX *amx, cell *params) @@ -373,7 +373,7 @@ static cell AMX_NATIVE_CALL get_msg_arg_int(AMX *amx, cell *params) return 0; } - int iVal = Msg[argn]->iData; + int iVal = Msg[argn].iData; return iVal; } @@ -387,8 +387,8 @@ static cell AMX_NATIVE_CALL set_msg_arg_int(AMX *amx, cell *params) return 0; } - Msg[argn]->type = params[2]; - Msg[argn]->iData = params[3]; + Msg[argn].type = params[2]; + Msg[argn].iData = params[3]; return 1; } @@ -402,7 +402,7 @@ static cell AMX_NATIVE_CALL get_msg_arg_float(AMX *amx, cell *params) return 0; } - return amx_ftoc(Msg[argn]->fData); + return amx_ftoc(Msg[argn].fData); } static cell AMX_NATIVE_CALL set_msg_arg_float(AMX *amx, cell *params) @@ -416,7 +416,7 @@ static cell AMX_NATIVE_CALL set_msg_arg_float(AMX *amx, cell *params) REAL fVal = amx_ctof(params[2]); - Msg[argn]->fData = fVal; + Msg[argn].fData = fVal; return 1; } @@ -430,7 +430,7 @@ static cell AMX_NATIVE_CALL get_msg_arg_string(AMX *amx, cell *params) return 0; } - const char *szVal = Msg[argn]->cData.c_str(); + const char *szVal = Msg[argn].cData.c_str(); return MF_SetAmxString(amx, params[2], szVal?szVal:"", params[3]); } @@ -447,7 +447,7 @@ static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params) char *szVal = MF_GetAmxString(amx, params[2], 0, &iLen); - Msg[argn]->cData.assign(szVal); + Msg[argn].cData.assign(szVal); return 1; } diff --git a/dlls/engine/messages.h b/dlls/engine/messages.h index bbae64ee..9f1b3658 100755 --- a/dlls/engine/messages.h +++ b/dlls/engine/messages.h @@ -41,7 +41,7 @@ public: }; extern AMX_NATIVE_INFO msg_Natives[]; -extern CVector Msg; +extern CVector Msg; extern CVector msgHooks[256]; extern int msgBlocks[256];