Merge pull request #370 from Arkshine/fix/cs_set_user_model

Fix a crash after cs_set_user_model is used with model_index parameter set.
This commit is contained in:
Vincent Herbet 2016-04-16 11:45:37 +02:00
commit 09e49439bc

View File

@ -862,16 +862,16 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
GET_OFFSET("CBasePlayer", m_modelIndexPlayer); GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
char model[260]; char modelpath[260];
ke::SafeSprintf(model, sizeof(model), "models/player/%s/%s.mdl", newModel, newModel); ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel);
for (size_t i = 0; i < HL_MODEL_MAX; ++i) for (size_t i = 0; i < HL_MODEL_MAX; ++i)
{ {
if (Server->model_precache[i] && !strcmp(Server->model_precache[i], model)) if (Server->model_precache[i] && !strcmp(Server->model_precache[i], modelpath))
{ {
if (pPlayer->v.modelindex != i) if (pPlayer->v.modelindex != i)
{ {
SET_MODEL(pPlayer, model); SET_MODEL(pPlayer, STRING(ALLOC_STRING(modelpath)));
} }
set_pdata<int>(pPlayer, m_modelIndexPlayer, i); set_pdata<int>(pPlayer, m_modelIndexPlayer, i);