mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
Fixed a crash with A_ClearOverlays
This commit is contained in:
parent
39042dc4bf
commit
e482a54389
1 changed files with 11 additions and 22 deletions
|
@ -1171,50 +1171,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearOverlays)
|
|||
PARAM_INT_OPT(stop) { stop = 0; }
|
||||
PARAM_BOOL_OPT(safety) { safety = true; }
|
||||
|
||||
if (!self->player)
|
||||
if (self->player == nullptr)
|
||||
ACTION_RETURN_INT(0);
|
||||
|
||||
player_t *player = self->player;
|
||||
if (!start && !stop)
|
||||
{
|
||||
start = INT_MIN;
|
||||
stop = safety ? PSP_TARGETCENTER - 1 : INT_MAX;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
DPSprite *pspr = player->psprites;
|
||||
int startID = (pspr != nullptr) ? pspr->GetID() : start;
|
||||
bool first = true;
|
||||
while (pspr != nullptr)
|
||||
{
|
||||
if (pspr->GetID() == startID)
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
break;
|
||||
}
|
||||
int id = pspr->GetID();
|
||||
unsigned int count = 0;
|
||||
int id;
|
||||
|
||||
//Do not wipe out layer 0. Ever.
|
||||
if (!id || id < start)
|
||||
for (DPSprite *pspr = self->player->psprites; pspr != nullptr; pspr = pspr->GetNext())
|
||||
{
|
||||
id = pspr->GetID();
|
||||
|
||||
if (id < start || id == 0)
|
||||
continue;
|
||||
if (id > stop)
|
||||
else if (id > stop)
|
||||
break;
|
||||
|
||||
if (safety)
|
||||
{
|
||||
if (id >= PSP_TARGETCENTER)
|
||||
break;
|
||||
else if ((id >= PSP_STRIFEHANDS && id <= PSP_WEAPON) || (id == PSP_FLASH))
|
||||
else if (id == PSP_STRIFEHANDS || id == PSP_WEAPON || id == PSP_FLASH)
|
||||
continue;
|
||||
}
|
||||
|
||||
// [MC]Don't affect non-hardcoded layers unless it's really desired.
|
||||
pspr->SetState(nullptr);
|
||||
count++;
|
||||
pspr = pspr->GetNext();
|
||||
}
|
||||
|
||||
ACTION_RETURN_INT(count);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue