Skip to content

Commit

Permalink
Add sanity check for script timers when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed Jul 19, 2016
1 parent c045a13 commit 02908e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scene/ChangeLevel.cpp
Expand Up @@ -2140,7 +2140,14 @@ static Entity * ARX_CHANGELEVEL_Pop_IO(const std::string & idString, EntityInsta
scr_timer[num].pos = ats->pos;
// TODO if the script has changed since the last save, this position may be invalid

const unsigned long remaining = checked_range_cast<unsigned long>(ats->remaining);
unsigned long remaining = checked_range_cast<unsigned long>(ats->remaining);
if(remaining > (unsigned long)ats->interval) {
LogWarning << "Found bad script timer " << scr_timer[num].name
<< " for entity " << io->idString() << " in save file: remaining time ("
<< remaining << "ms) > interval (" << ats->interval << "ms) " << ats->flags;
remaining = ats->interval;
}

const ArxInstant tt = (ARX_CHANGELEVEL_DesiredTime + remaining) - ats->interval;
scr_timer[num].start = tt;

Expand Down

0 comments on commit 02908e3

Please sign in to comment.