From c542227de368462d2ff3ddc0d25b982b65461f6a Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 23 Jun 2015 19:51:57 -0400 Subject: [PATCH] Fix potential infinite loop if a timed starts another timer --- src/boe.specials.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 0b98c26d0..c4e1e9003 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -1785,7 +1785,7 @@ void push_things() { } void special_increase_age(long length, bool queue) { - unsigned short i; + size_t i; short s1,s2,s3; bool redraw = false,stat_area = false; location trigger_loc; @@ -1876,13 +1876,14 @@ void special_increase_age(long length, bool queue) { redraw = true; } univ.party.age = current_age; - for(i = 0; i < univ.party.party_event_timers.size(); i++) { - if(univ.party.party_event_timers[i].time <= length) { - univ.party.age = age_before + univ.party.party_event_timers[i].time; - short which_type = univ.party.party_event_timers[i].node_type; + auto party_timers = univ.party.party_event_timers; + for(i = 0; i < party_timers.size(); i++) { + if(party_timers[i].time <= length) { + univ.party.age = age_before + party_timers[i].time; + short which_type = party_timers[i].node_type; if(queue) - queue_special(eSpecCtx::PARTY_TIMER, which_type, univ.party.party_event_timers[i].node, trigger_loc); - else run_special(eSpecCtx::PARTY_TIMER,which_type,univ.party.party_event_timers[i].node,trigger_loc,&s1,&s2,&s3); + queue_special(eSpecCtx::PARTY_TIMER, which_type, party_timers[i].node, trigger_loc); + else run_special(eSpecCtx::PARTY_TIMER, which_type, party_timers[i].node, trigger_loc, &s1, &s2, &s3); univ.party.party_event_timers[i].time = 0; univ.party.party_event_timers[i].node = -1; stat_area = true;