EFX/env_sound: Add bound checks for legacy roomtypes.

This commit is contained in:
Marco Cawthorne 2021-04-22 11:44:53 +02:00
parent f09f5833e0
commit ead2ab6a6b
2 changed files with 12 additions and 3 deletions

View file

@ -156,9 +156,13 @@ EFX_Load(string efx_file)
void
EFX_SetEnvironment(int id)
{
if (g_iEFX == id) {
/* out of bounds... MAP BUG! */
if (id >= g_efx_count)
return;
/* same as before, skip */
if (g_iEFX == id)
return;
}
g_iEFXold = g_iEFX;
g_iEFX = id;

View file

@ -94,7 +94,12 @@ env_sound::SpawnKey(string strField, string strKey)
/* GoldSrc, legacy */
case "roomtype":
int efx_alias = stoi(strKey);
m_iRoomType = EFX_Load(g_hlefx[efx_alias]);
if (efx_alias >= g_hlefx.length) {
print("^1env_sound::SpawnKey: Invalid roomtype!\n");
m_iRoomType = 0;
} else
m_iRoomType = EFX_Load(g_hlefx[efx_alias]);
break;
default:
CBaseEntity::SpawnKey(strField, strKey);