Fixed another sdktools team native crash, if m_szTeamName wasn't available (bug amb1779, r=pred).
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402530
This commit is contained in:
parent
514fc7dfe8
commit
29d1246b8d
@ -109,6 +109,7 @@ static cell_t GetTeamCount(IPluginContext *pContext, const cell_t *params)
|
|||||||
return g_Teams.size();
|
return g_Teams.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int g_teamname_offset = -1;
|
||||||
static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
|
static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
int teamindex = params[1];
|
int teamindex = params[1];
|
||||||
@ -117,8 +118,25 @@ static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
|
|||||||
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
|
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int offset = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_szTeamname")->GetOffset();
|
if (g_teamname_offset == 0)
|
||||||
char *name = (char *)((unsigned char *)g_Teams[teamindex].pEnt + offset);
|
{
|
||||||
|
return pContext->ThrowNativeError("Team names are not available on this game.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_teamname_offset == -1)
|
||||||
|
{
|
||||||
|
SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_szTeamname");
|
||||||
|
|
||||||
|
if (prop == NULL)
|
||||||
|
{
|
||||||
|
g_teamname_offset = 0;
|
||||||
|
return pContext->ThrowNativeError("Team names are not available on this game.");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_teamname_offset = prop->GetOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
char *name = (char *)((unsigned char *)g_Teams[teamindex].pEnt + g_teamname_offset);
|
||||||
|
|
||||||
pContext->StringToLocalUTF8(params[2], params[3], name, NULL);
|
pContext->StringToLocalUTF8(params[2], params[3], name, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user