Skip to content

Commit

Permalink
Add an important clarification to the native rg_create_entity comment…
Browse files Browse the repository at this point in the history
… about cannot use a hash table for an entity with mutable class name otherwise, it will cause a memory leak
  • Loading branch information
s1lentq committed Sep 3, 2023
1 parent 2bceff9 commit 30c1964
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ native rg_update_teamscores(const iCtsWins = 0, const iTsWins = 0, const bool:bA
*
* @param classname Entity classname
* @param useHashTable Use this only for known game entities
*
* @note: Do not use this if you use a custom classname
* @note: Do not use this if you plan to change custom classname an entity after creation,
* otherwise it will never be release from hash table even if an entity was destroyed,
* and that to lead table to inflate/memory leaks
*
* @return Index of the created entity or 0 otherwise
*/
Expand Down
13 changes: 7 additions & 6 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ cell AMX_NATIVE_CALL rg_update_teamscores(AMX *amx, cell *params)
*
* @param classname Entity classname
* @param useHashTable Use this only for known game entities
*
* @note: Do not use this if you use a custom classname
* @note: Do not use this if you plan to change custom classname an entity after creation,
* otherwise it will never be release from hash table even if an entity was destroyed,
* and that to lead table to inflate/memory leaks
*
* @return Index of the created entity or 0 otherwise
*
Expand Down Expand Up @@ -1259,7 +1260,7 @@ cell AMX_NATIVE_CALL rg_give_defusekit(AMX *amx, cell *params)
if (CSGameRules() != nullptr && !CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->m_bMapHasBombZone) {
return FALSE;
}

if (pPlayer->m_iTeam != CT) {
return FALSE;
}
Expand Down Expand Up @@ -2734,7 +2735,7 @@ cell AMX_NATIVE_CALL rh_drop_client(AMX *amx, cell *params)
*
* @param output Buffer to copy the ip address
* @param len Maximum buffer size
*
*
* @noreturn
*
* native rh_get_net_from(output[], len);
Expand All @@ -2747,7 +2748,7 @@ cell AMX_NATIVE_CALL rh_get_net_from(AMX* amx, cell* params)
char *addr = NET_AdrToString(*g_RehldsData->GetNetFrom());

setAmxString(dest, addr, params[arg_maxlen]);

return TRUE;
}

Expand All @@ -2772,7 +2773,7 @@ cell AMX_NATIVE_CALL rh_get_client_connect_time(AMX *amx, cell *params)
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
return FALSE;
}

return (cell)(g_RehldsFuncs->GetRealTime() - pClient->netchan.connect_time);
}

Expand Down

0 comments on commit 30c1964

Please sign in to comment.