Creating an NRaas project Attn C# Devs: Overwatch

Talk nerdy to us here.
User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Attn C# Devs: Overwatch

Post by JunJayMdM » January 23rd, 2014, 11:15 am

The current version of Overwatch in the Testing section, which is V113, has a particular new addition Twallan made before abandoning it. Basically, there's an alarm that gets added after the World is loaded, which is a function to yield all alarms in the game. The note I added in the <a href="http://nraas.wikispaces.com/Overwatch+T ... >Overwatch Testing</a> page is exactly what he noted in the project and that worries me a little.
Now, I don't know what "yielding" means in EA's world, but if it's anything like the traditional yield, it recreates the alarm and replaces the old one with a new one? If that's the case, I understand why it may cause problems when running at high speed for long durations, but still, what are we talking about here? Does anyone have more knowledge about it? If you want to look at the code, it's in NRaas.OverwatchSpace.Loadup+YieldAllAlarms .

I had the game running at high speed for a couple of Sim Days, but there were no side-effects, besides I don't really know what he meant with "long durations".

This is something that definitely should be looked into.

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7568
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Post by Chain_Reaction » January 23rd, 2014, 12:52 pm

I have no idea about that unfortunately. There were new features added to ErrorTrap that I reverted out because I wasn't aware if they were something he was trying and didn't release it yet for a reason. I didn't want to cause any more issues considering the patch was already enough source of confusion. I saved the code so I may add it back in later. I suppose this is just one of those things we have to keep an eye on to see if it explodes. :)

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 23rd, 2014, 12:58 pm

Well, it's in testing for now, I'll run more tests and see if I can understand something about it, it can be pulled out anytime, or even better, I was thinking about making it an option and set it disabled by default, with a warning if enabled.

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 23rd, 2014, 1:04 pm

Come to think of it, it's a Loadup function, making it an option won't be right... oh well let's see how it goes for now

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 23rd, 2014, 1:18 pm

Ok, this is what yielding will do :

<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> AlarmManager.AlarmOneShot alarmOneShot = new AlarmManager.AlarmOneShot(this, timer, callback);<br/> Simulator.AddObject(alarmOneShot);<br/> if (this.mAlarmOneShotList == null)<br/> {<br/> this.mAlarmOneShotList = new List&lt;AlarmManager.AlarmOneShot&gt;();<br/> }<br/> this.mAlarmOneShotList.Add(alarmOneShot);</pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

-->
</style><pre class="text"> AlarmManager.AlarmOneShot alarmOneShot = new AlarmManager.AlarmOneShot(this, timer, callback);
Simulator.AddObject(alarmOneShot);
if (this.mAlarmOneShotList == null)
{
this.mAlarmOneShotList = new List<AlarmManager.AlarmOneShot>();
}
this.mAlarmOneShotList.Add(alarmOneShot);</pre>


So, instead of using the AlarmTimerCallback delegate, it adds the alarm to the Simulator as a OneShotFunction. This means that when there's too much data to process, the alarms will start delaying and that's why it may lead to unexpected side-effects. Running at high speed will just make it worse, cos the delay will add up and cause even more trouble.
I'll see if I can add some mechanism to avoid this problem, suggestions are of course welcome :)

User avatar
Nirar22
Reactions:
Posts: 144
Joined: December 28th, 2011, 6:00 pm

Post by Nirar22 » January 23rd, 2014, 2:00 pm

@JunJay---I'm pretty clueless when it comes to all of that stuff, so sorry if this is a silly suggestion---but since it is a Loadup function, and as such can't be made into an option---could it be made into a tuning file? Somewhat like [URL=https://wwww.nraas.net/community/ErrorT ... rorTrap</a>, it has a bunch of different tuning files: <a href="http://nraas.wikispaces.com/ErrorTrap+Tuning]ErrorTrap Tuning[/URL]

Ah well--back to lurking in these threads that I find interesting to read but WAY over my head, lol =)

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 23rd, 2014, 2:11 pm

@Nirar Yes that's one alternative. I'll take it into consideration eventually, but I'd rather try to make this thing safer first. Thanks for the suggestion :)

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 23rd, 2014, 2:28 pm

@SimAd The good thing about the Simulator is that it lets you run functions on a separate thread without overloading the stack. The downside is that by running on a separate thread, you have no control and it may end up being fired at the wrong time. You can specify to pause on Modal though, probably SP doesn't have that and that's why you will see it there when you're saving. Still, if in the code there's a function that depends on the result of one alarm, if that alarm is run on the Simulator, the function might run too early or too late and not necessarily right after the alarm. Kinda like invoking delegates asynchronously because they use a common list or dictionary, which prevents throwing an Invalid Operation Exception

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » January 24th, 2014, 6:41 am

Ok, this is the best I could come up with :

<!-- ws:start:WikiTextCodeRule:0:
<pre class="text">bool yieldRequired = (Sims3.Gameplay.Gameflow.CurrentGameSpeed &lt;= Sims3.Gameplay.Gameflow.GameSpeed.Normal);<br/> <br/>AlarmManager manager = AlarmManager.Global;<br/><br/>foreach (object item in manager.mTimerQueue)<br/>{<br/> AlarmManager.Timer timer = item as AlarmManager.Timer;<br/> if (timer == null) continue;<br/> <br/> timer.YieldRequired = yieldRequired;<br/> }</pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

-->
</style><pre class="text">bool yieldRequired = (Sims3.Gameplay.Gameflow.CurrentGameSpeed <= Sims3.Gameplay.Gameflow.GameSpeed.Normal);
&nbsp;
AlarmManager manager = AlarmManager.Global;
&nbsp;
foreach (object item in manager.mTimerQueue)
{
AlarmManager.Timer timer = item as AlarmManager.Timer;
if (timer == null) continue;
&nbsp;
timer.YieldRequired = yieldRequired;
}</pre>


It kinda defeats the purpose, but this could be the safest route to go. It might still need some adjustments, cos not all alarms are supposed to be set to "non-yield", so probably I should cache the original value just to be safe.

Post Reply