sadger / CorsixTH

Open source clone of Theme Hospital
Other
1 stars 0 forks source link

Crash on vaccination attempt?? #4

Closed sadger closed 10 years ago

sadger commented 10 years ago

The game crashes with the output

Error in timer handler:
...orsixth\CorsixTH-epidemics\CorsixTH\Lua\epidemic.lua:598: attempt to index field 'entity_map' (a nil value)
stack traceback:
...orsixth\CorsixTH-epidemics\CorsixTH\Lua\epidemic.lua:598: in function <...orsixth\CorsixTH-epidemics\CorsixTH\Lua\epidemic.lua:590>
(tail call): ?
...orsixth\CorsixTH-epidemics\CorsixTH\Lua\epidemic.lua:555: in function 'createVaccinationActions'
...CorsixTH-epidemics\CorsixTH\Lua\calls_dispatcher.lua:249: in function <...CorsixTH-epidemics\CorsixTH\Lua\calls_dispatcher.lua:245>
(tail call): ?
...CorsixTH-epidemics\CorsixTH\Lua\calls_dispatcher.lua:436: in function 'executeCall'
...CorsixTH-epidemics\CorsixTH\Lua\calls_dispatcher.lua:358: in function 'answerCall'
...-epidemics\CorsixTH\Lua\humanoid_actions\meander.lua:32: in function '?'
...orsixTH-epidemics\CorsixTH\Lua\entities\humanoid.lua:550: in function 'Humanoid_startAction'
...orsixTH-epidemics\CorsixTH\Lua\entities\humanoid.lua:642: in function 'finishAction'
...xTH-epidemics\CorsixTH\Lua\humanoid_actions\idle.lua:31: in function 'timer_function'
...\corsixth\CorsixTH-epidemics\CorsixTH\Lua\entity.lua:178: in function 'tick'
...h\CorsixTH-epidemics\CorsixTH\Lua\entities\staff.lua:146: in function 'tick'
...p\corsixth\CorsixTH-epidemics\CorsixTH\Lua\world.lua:1039: in function 'onTick'
...top\corsixth\CorsixTH-epidemics\CorsixTH\Lua\app.lua:839: in function <...top\corsixth\CorsixTH-epidemics\CorsixTH\Lua\app.lua:836>
(tail call): ?
...top\corsixth\CorsixTH-epidemics\CorsixTH\Lua\app.lua:740: in function <...top\corsixth\CorsixTH-epidemics\CorsixTH\Lua\app.lua:735>

Is this from an old save - the reason is because the field entity_map doesn't exist and should be created in afterLoad in in either the world or hospital, if it did exist this crash shouldn't happen.

MarkL1961 commented 10 years ago

It would have been a new game. I have created a couple of saves which I am only using on testing epidemics as I know from past experience it can get complicated switching between different versions of the game.

MarkL1961 commented 10 years ago

Just been looking at this and I can now remember when this error came up I had just covered up an epidemic and had the compensation when this error came up. Was wondering whether the patient the nurse was looking for had left the hospital and this is why the value is nil?

MarkL1961 commented 10 years ago

Got this error while testing your latest changes. This is a new game although I have saved it a couple of times. The nurse was walking close to one of the two victims when she threw this error and froze.

Error in timer handler: ...xTH-experimental-epidemics\CorsixTH\Lua\epidemic.lua:633: attempt to index field 'entity_map' (a nil value) stack traceback: ...xTH-experimental-epidemics\CorsixTH\Lua\epidemic.lua:633: in function <...xTH-experimental-epidemics\CorsixTH\Lua\epidemic.lua:625> (tail call): ? ...xTH-experimental-epidemics\CorsixTH\Lua\epidemic.lua:590: in function 'createVaccinationActions' ...rimental-epidemics\CorsixTH\Lua\calls_dispatcher.lua:249: in function <...rimental-epidemics\CorsixTH\Lua\calls_dispatcher.lua:245> (tail call): ? ...rimental-epidemics\CorsixTH\Lua\calls_dispatcher.lua:436: in function 'executeCall' ...rimental-epidemics\CorsixTH\Lua\calls_dispatcher.lua:358: in function 'answerCall' ...-epidemics\CorsixTH\Lua\humanoid_actions\meander.lua:32: in function '?' ...imental-epidemics\CorsixTH\Lua\entities\humanoid.lua:550: in function 'Humanoid_startAction' ...imental-epidemics\CorsixTH\Lua\entities\humanoid.lua:642: in function 'finishAction' ...tal-epidemics\CorsixTH\Lua\humanoid_actions\walk.lua:152: in function 'timer_function' ...sixTH-experimental-epidemics\CorsixTH\Lua\entity.lua:178: in function 'tick' ...perimental-epidemics\CorsixTH\Lua\entities\staff.lua:146: in function 'tick' ...rsixTH-experimental-epidemics\CorsixTH\Lua\world.lua:1039: in function 'onTick' ...CorsixTH-experimental-epidemics\CorsixTH\Lua\app.lua:839: in function <...CorsixTH-experimental-epidemics\CorsixTH\Lua\app.lua:836> (tail call): ? ...CorsixTH-experimental-epidemics\CorsixTH\Lua\app.lua:740: in function <...CorsixTH-experimental-epidemics\CorsixTH\Lua\app.lua:735>

The good news is that the infection did spread to someone this time :)

MarkL1961 commented 10 years ago

Oh, I just reloaded the autosave to avoid the error and realise now the second victim was spawned that way, so it didn't spread after all. :(

sadger commented 10 years ago

Hmm seems to be a similar issue i'll look into it. In my own saves I have seen spreading so I know it works in some cases. If you don't see any spreading I would think that the patients don't meet the condition for being infected.

MarkL1961 commented 10 years ago

In this game it was only my second epidemic, I have since adjusted the level file as I noticed most were visual - lets see what happens.

As for the error, not sure if this is relevant but each time this happened I had just hired a new nurse to wander the corridors. After this happening three times on the fourth time I hired the nurse before I got the fax and that time no error.

sadger commented 10 years ago

I just realised if you have a nil entity_map you won't get any infections either as it also depends on it, which goes to explain a lot. Your saves can't be invoking the after load from hospital.lua which populates the map on old saves. Ive had this issue before as it should execute after load but doesn't. I'll take a look after Christmas, let me know if you have any ideas about it.

MarkL1961 commented 10 years ago

I am not using old saves though, each game has only ever been played with this branch and I have started new games when you made changes. I do save them and do reload the saves, but only ever when I take a break. Is this entity map thing persisting between save and load? Did you up the save game version number in app.lua, it is 80 and the if old in hospital for self.future_epidemics_pool is 81?

sadger commented 10 years ago

Maybe the save version is the issue indeed. I should have realised this sooner. Maybe it's not working for the new saves for whatever reason. Fixing it should help a lot of your issues. Still even with it working I saw very little spreading on my saves. Apologies if my slow fixing is holding up testing

MarkL1961 commented 10 years ago

I think the reason it does not work on new saves is that if I save and then reload, my save is version 80 and the afterload in hospital at <81 is then clearing the table for self.future_epidemics_pool ? I have upped it now in app.lua, so see what happens later in testing. Don't worry about the slow fixing, we knew it needed a lot of testing and it's better this way than getting a load of issues later.

sadger commented 10 years ago

I don't think future epidemic pool is the issue as it isn't currently used, it's more the initialisation of entity_map it shouldn't be nil at all at any point. It tracks the coordinates of entities so you can find who occupies which map tile.

MarkL1961 commented 10 years ago

Where does it get called from?

MarkL1961 commented 10 years ago

Okay found where, in world the if old < 80 ought to be <81 and the same in app This will be why it does not get populated I reckon as version 80 is the current version and it should be 81 to take account of your additions. Have you added any other variables?

MarkL1961 commented 10 years ago

Are the spawned infected patients meant to be spawned on the helipad? I know that is where they do for the cheat, but I am also seeing this happen without the cheat.

sadger commented 10 years ago

Any other variables will be explicitly declared in the top of the file, if you get another cannot access a variable crash it is probably of the same issue but hopefully your version changing fixes that issue, manual versioning is a constant effort! Oh, they shouldn't spawn on the helipad can you make a new issue of this? I'm on my phone at the moment and it's a bit of effort. I'll try push the fix for the version number later on today if you can confirm it works nicely. Remember to get some rest over Christmas won't you! :D

sadger commented 10 years ago

This should be fixed now the entity_map should never be nil even on new saves.