changing time in worldtime component of DaggerfallUnity entity while game is running makes unity freeze

Discuss coding questions, pull requests, and implementation details.
R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: changing time in worldtime component of DaggerfallUnity entity while game is running makes unity freeze

Post by R.D. »

I'm sure this is caused by the stuff I've added. As you guys said the problem is the current time becoming less than the last tracked game minute, so (lastGameMinute - currentGameMinute) becomes negative, causing problems. There are lots of game events that happen in classic on a game minute basis, which I've been recreating in PlayerEntity.cs (should probably be re-organized somehow, but it's easy to just do it all there for now), but I didn't think about time going backwards (other than when loading a saved game, which is accounted for). Another problem that probably happens: if you raised time by a large amount while in an area where random encounters can appear, a horde of enemies would get spawned because of the large change in game minutes from the last tracked minute. This is already prevented from happening for normal in-game time changes such as when traveling or resting.

If this is a problem, maybe we can force these game minute events to only fire for time moving forward to solve the "changing time backwards causes freezing" bug. For time moving forward, though, it might be more difficult. One idea is to always advance time by game minute units, running the game minute update event each time a unit passes. So instead of raising time all at once for rest or travel and then taking the difference in time and doing updates for all the in-between minutes or days (which is what happens now), we could raise by a minute at a time, calling the events each passed minute. This would be less efficient than what we are doing now (might not make a difference performance-wise, though). But, for example, we could prevent problems from raising time in the console by only allowing these update events to fire a single time when the game minute has changed, or by only allowing them to run if the difference in game minutes passed is 1, or something.
Last edited by R.D. on Sat May 26, 2018 8:30 am, edited 1 time in total.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: changing time in worldtime component of DaggerfallUnity entity while game is running makes unity freeze

Post by Interkarma »

I'm completely ok with it mate. There's no circumstance where a player can change time outside of loading a save (which is fine as you know), and with my little change the problem stops existing for developers at runtime as well.

I don't see much need to fix this one right now. :)

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: changing time in worldtime component of DaggerfallUnity entity while game is running makes unity freeze

Post by R.D. »

with my little change the problem stops existing for developers at runtime as well.
Oh I must have skipped over that bit, I didn't see that you had put in a fix. Then I agree, let's not worry about it.

Post Reply