diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index d10937d93..b57f5d29c 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -817,6 +817,8 @@ KillSprite(int16_t SpriteNum) void ChangeState(short SpriteNum, STATEp statep) { USERp u = User[SpriteNum]; + if (u == nullptr) + return; u->Tics = 0; u->State = u->StateStart = statep; diff --git a/source/sw/src/track.cpp b/source/sw/src/track.cpp index 68935f81c..69390e316 100644 --- a/source/sw/src/track.cpp +++ b/source/sw/src/track.cpp @@ -642,7 +642,7 @@ TrackSetup(void) { int i, nexti; auto const sp = (uspritetype const *)&sprite[headspritestat[STAT_TRACK+ndx]]; - buildprintf("WARNING: Did not find first point of Track Number %d, x %d, y %d", ndx, sp->x, sp->y); + buildprintf("WARNING: Did not find first point of Track Number %d, x %d, y %d\n", ndx, sp->x, sp->y); for (i=headspritestat[STAT_TRACK+ndx]; i>=0; i=nexti) { // neuter the track's sprite list @@ -1598,6 +1598,12 @@ PlaceActorsOnTracks(void) NextActorTrackPoint(i); + if (Track[u->track].NumPoints == 0) + { + buildprintf("WARNING: Sprite %d (%d, %d) placed on track %d with no points!\n", i, TrackerCast(sp->x), TrackerCast(sp->y), u->track); + continue; + } + // check angle in the "forward" direction sp->ang = getangle((tpoint + u->point)->x - sp->x, (tpoint + u->point)->y - sp->y); } diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 34c83198a..3f273ba60 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -4949,8 +4949,11 @@ SetSuicide(short SpriteNum) SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; - SET(u->Flags, SPR_SUICIDE); - u->RotNum = 0; + if (u != nullptr) + { + SET(u->Flags, SPR_SUICIDE); + u->RotNum = 0; + } ChangeState(SpriteNum, s_Suicide); #else // this will NOT work because