View Issue Details

IDProjectCategoryView StatusLast Update
0001395FSSCPgameplaypublic2007-08-15 10:58
ReporterCP5670 Assigned ToGoober5000  
PrioritynormalSeveritymajorReproducibilityrandom
Status resolvedResolutionno change required 
Product Version3.6.9 
Summary0001395: every-time-argument does not work consistently
DescriptionThe every-time-argument operator doesn't work reliably. This is something system-specific and is hard to reproduce, but enough people have complained about it now that I think it may be a game bug of some sort.

This specifically concerns mission 13 of The Procyon Insurgency, where two every-time-argument events are used to automatically add and remove fighters from the escort list according to their proximity from the player. I've played this mission many times on two different computers and have never had these events fail to work, but a number of people on the forums are reporting that they only work some of the time, which would make the mission almost impossible.

I believe the frequency of every-time/every-time-argument is dependent on the framerate, which varies between computers, so it may have something to do with that.
TagsNo tags attached.

Activities

karajorma

2007-05-13 23:42

administrator   ~0008077

Yep. You should never do anything frame rate dependent with either every-time or every-time argument (Or with when and a repeat delay of 0 for that matter).

CP5670

2007-05-13 23:58

reporter   ~0008081

Last edited: 2007-05-13 23:59

The operators need to be changed to work at some fixed rate in that case, since they are pretty useless if they do in fact work differently on every computer.

That being said, I can't see any obvious connection between their framerate dependancy and the particular events I'm using them in. In this situation, the events would still fire hundreds of times even if the framerate is low, so something must be wrong if they still won't always work for some people.

taylor

2007-05-14 07:10

administrator   ~0008082

The engine is single-threaded, so it's ALL framerate dependant.

Most everything is executed once per frame, which means that anything happens, at most, 120 times per second. But if you are only getting 20 FPS, then things can only execute 20 times per second. Outside of just making every-time execute on a timer 10-20 times per second (the timer is also going to be linked to some extent to the framerate), so that you have a more predictable execution time, there is nothing to do here.

Making the engine multi-threaded, though the only real fix, is a massive undertaking and that isn't going to happen any time soon.

Goober5000

2007-05-25 04:46

administrator   ~0008133

I'd go for the timer method. Ten times a second sounds good to me.

CP5670

2007-05-25 09:42

reporter   ~0008136

That's what I had in mind too. I may have been able to find a workaround in the particular case I mentioned earlier (still not really sure if it works for others), but in general, debugging missions becomes very complicated if there is any possibility of the mission behavior being different depending on the machine. A smaller interval should make things work more consistently across a variety of computers.

taylor

2007-05-25 09:47

administrator   ~0008137

Ok, I'll go with a 10 FPS timer, as soon as I figure out how. ;)

karajorma

2007-05-25 12:10

administrator   ~0008138

Unless you make all the other SEXPs dependant on the same timer, please don't.

Suppose I have a situation like this

Event 1
-every-time
--Case A
-Modify variable to YES

Event 2
-when
--And
---Case B
---Variable = YES
-Do something

Event 3
-every-time
--Variable = YES
-Modify variable to NO

That little situation works perfectly well under current conditions but if you change every-time to working on a timer independent of when the When SEXP triggers you open up all kinds of race conditions. Firstly is Event 3 going to trigger every time that Event 1 does? Or is there the possibility of it falling out of phase and giving event 2 several chances to trigger erroneously? Even if all every-time SEXPs are synced to the same clock then you still have issues with the when SEXP not going off at the right time. The Every-time might correct something that when missed causes a 4th event to go off incorrectly.

If you're going to have a timer driven SEXP either all of them have to work that way or it has to be a new SEXP. I can see all kinds of problems if you change the way it works now.

CP5670

2007-05-25 12:53

reporter   ~0008139

Last edited: 2007-05-25 12:54

I don't know if your event 2 will work consistently even with the existing setup. In fact, that is just the sort of thing that seems to be machine-dependent. The event 2 stuff should be merged into event 1 to ensure that it works every time.

I see your point though, and I think the best way to maintain backward compatibility is to add an extension to every-time/every-time-argument (similar to what was done with is-event-true-delay) that specifies how often it should be checked. That would essentially leave it in the hands of the mission designer.

Goober5000

2007-05-25 22:49

administrator   ~0008140

I had never intended for every-time to be used as much as it is now. It's quite computation-intensive, and it's verging on a hack anyway.

That said, I just remembered something that might make the timer thing completely irrelevant: When and every-time use exactly the same code. The difference is that when stops being evaluated as soon as it comes true, while every-time immediately forgets that it was ever evaluated (causing it to be checked again on each subsequent frame).

In summary, when and every-time have the exact same framerate dependency. So why are we seeing bugs with every-time that we don't see with when?

karajorma

2007-05-26 11:07

administrator   ~0008143

I don't think we are. If this is a frame rate problem it would appear with use of repeated when with a 0 delay too.

In fact that's probably what he should be using.

Goober5000

2007-08-15 10:58

administrator   ~0008377

Closing as a choice-of-sexp problem, not a code problem.

Issue History

Date Modified Username Field Change
2007-05-12 19:25 CP5670 New Issue
2007-05-13 23:42 karajorma Note Added: 0008077
2007-05-13 23:58 CP5670 Note Added: 0008081
2007-05-13 23:59 CP5670 Note Edited: 0008081
2007-05-14 07:10 taylor Note Added: 0008082
2007-05-25 04:46 Goober5000 Note Added: 0008133
2007-05-25 04:46 Goober5000 Assigned To => Goober5000
2007-05-25 04:46 Goober5000 Status new => assigned
2007-05-25 09:42 CP5670 Note Added: 0008136
2007-05-25 09:47 taylor Note Added: 0008137
2007-05-25 12:10 karajorma Note Added: 0008138
2007-05-25 12:53 CP5670 Note Added: 0008139
2007-05-25 12:54 CP5670 Note Edited: 0008139
2007-05-25 22:49 Goober5000 Note Added: 0008140
2007-05-26 11:07 karajorma Note Added: 0008143
2007-08-15 10:58 Goober5000 Note Added: 0008377
2007-08-15 10:58 Goober5000 Status assigned => resolved
2007-08-15 10:58 Goober5000 Resolution open => no change required