Skip to content

Commit

Permalink
Crash fixes for 3D text get natives
Browse files Browse the repository at this point in the history
  • Loading branch information
kurta999 committed May 29, 2014
1 parent c24924f commit baa34e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ static cell AMX_NATIVE_CALL n_IsValid3DTextLabel( AMX* amx, cell* params )
CHECK_PARAMS(1, "IsValid3DTextLabel");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

return pNetGame->p3DTextPool->m_bIsCreated[id];
}
Expand All @@ -2380,7 +2380,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelText( AMX* amx, cell* params )
CHECK_PARAMS(3, "Get3DTextLabelText");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

const char *szText = (pNetGame->p3DTextPool->m_bIsCreated[id]) ? pNetGame->p3DTextPool->m_TextLabels[id].text : '\0';
return set_amxstring(amx, params[2], szText, params[3]);
Expand All @@ -2392,7 +2392,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelColor( AMX* amx, cell* params )
CHECK_PARAMS(1, "Get3DTextLabelColor");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2406,7 +2406,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelPos( AMX* amx, cell* params )
CHECK_PARAMS(4, "Get3DTextLabelPos");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2427,7 +2427,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelDrawDistance( AMX* amx, cell* params
CHECK_PARAMS(1, "Get3DTextLabelDrawDistance");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2441,7 +2441,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelLOS( AMX* amx, cell* params )
CHECK_PARAMS(1, "Get3DTextLabelLOS");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2455,7 +2455,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelVirtualWorld( AMX* amx, cell* params
CHECK_PARAMS(1, "Get3DTextLabelVirtualWorld");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2469,7 +2469,7 @@ static cell AMX_NATIVE_CALL n_Get3DTextLabelAttachedData( AMX* amx, cell* params
CHECK_PARAMS(3, "Get3DTextLabelAttachedData");

int id = (int)params[1];
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_GLOBAL) return 0;

if(!pNetGame->p3DTextPool->m_bIsCreated[id]) return 0;
C3DText p3DText = pNetGame->p3DTextPool->m_TextLabels[id];
Expand All @@ -2491,7 +2491,7 @@ static cell AMX_NATIVE_CALL n_IsValidPlayer3DTextLabel( AMX* amx, cell* params )
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

return pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id];
}
Expand All @@ -2509,7 +2509,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelText( AMX* amx, cell* params )
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;

Expand All @@ -2526,7 +2526,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelColor( AMX* amx, cell* params
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;

Expand All @@ -2543,7 +2543,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelPos( AMX* amx, cell* params )
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;
C3DText p3DText = pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->TextLabels[id];
Expand All @@ -2567,7 +2567,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelDrawDist( AMX* amx, cell* para
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;

Expand All @@ -2584,7 +2584,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelLOS( AMX* amx, cell* params )
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;

Expand All @@ -2601,7 +2601,7 @@ static cell AMX_NATIVE_CALL n_GetPlayer3DTextLabelVirtualW( AMX* amx, cell* para
int id = (int)params[1];

if(!IsPlayerConnected(playerid)) return 0;
if(id >= MAX_3DTEXT_GLOBAL) return 0;
if(0 < id || id >= MAX_3DTEXT_PLAYER) return 0;

if(!pNetGame->pPlayerPool->pPlayer[playerid]->p3DText->isCreated[id]) return 0;

Expand Down
1 change: 1 addition & 0 deletions Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CGangZonePool;
#define MAX_TEXT_DRAWS 2048
#define MAX_PLAYER_TEXT_DRAWS 256
#define MAX_3DTEXT_GLOBAL 1024
#define MAX_3DTEXT_PLAYER 1024
#define MAX_MENUS 128
#define INVALID_PLAYER_ID 65535
#define MAX_FILTER_SCRIPTS 16
Expand Down

0 comments on commit baa34e3

Please sign in to comment.