Fix broken cs_set_user_model update_index parameter for the default engine (#450)

This commit is contained in:
Vincent Herbet 2017-07-29 17:01:34 +02:00 committed by GitHub
parent 4fcfc913d3
commit 304e992942
2 changed files with 21 additions and 30 deletions

View File

@ -37,30 +37,6 @@ int AmxxCheckGame(const char *game)
return AMXX_GAME_BAD; return AMXX_GAME_BAD;
} }
void SV_ActivateServer_RH(IRehldsHook_SV_ActivateServer *chain, int runPhysics)
{
chain->callNext(runPhysics);
auto numResources = RehldsData->GetResourcesNum();
if (!numResources)
{
return;
}
ModelsList.clear();
for (auto i = 0; i < numResources; ++i) // Saves all the precached models into a list.
{
auto resource = RehldsData->GetResource(i);
if (resource->type == t_model)
{
ModelsList.insert(resource->szFileName, i);
}
}
}
void OnAmxxAttach() void OnAmxxAttach()
{ {
MF_AddNatives(CstrikeNatives); MF_AddNatives(CstrikeNatives);
@ -85,11 +61,6 @@ void OnAmxxAttach()
} }
InitializeHacks(); InitializeHacks();
if (HasReHlds)
{
RehldsHookchains->SV_ActivateServer()->registerHook(SV_ActivateServer_RH);
}
} }
void OnPluginsLoaded() void OnPluginsLoaded()
@ -131,6 +102,8 @@ void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
ToggleHook_BuyCommands(HasOnBuyForward); ToggleHook_BuyCommands(HasOnBuyForward);
ToggleHook_GiveDefaultItems(false); ToggleHook_GiveDefaultItems(false);
ModelsList.clear();
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }

View File

@ -856,12 +856,30 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
if (*params / sizeof(cell) >= 3 && params[3] != 0) if (*params / sizeof(cell) >= 3 && params[3] != 0)
{ {
if (!Server) if (!HasReHlds && !Server)
{ {
MF_Log("cs_set_user_model is disabled with update_index parameter set"); MF_Log("cs_set_user_model is disabled with update_index parameter set");
return 0; return 0;
} }
if (!ModelsList.elements())
{
auto numResources = HasReHlds ? RehldsData->GetResourcesNum() : Server->num_resources;
if (numResources)
{
for (auto i = 0; i < numResources; ++i) // Saves all the precached models into a list.
{
auto resource = HasReHlds ? RehldsData->GetResource(i) : &Server->resourcelist[i];
if (resource->type == t_model)
{
ModelsList.insert(resource->szFileName, resource->nIndex);
}
}
}
}
GET_OFFSET("CBasePlayer", m_modelIndexPlayer); GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
char modelpath[260]; char modelpath[260];