I already tried to do it before, just didn't manage to do it properly. This time I did: 1) I made all the variables in the class Camps static, it is all in the very beginning; 2) I also used a variable for search() at 240 (before) / 236 (after).
Before:
https://github.com/rbcat/returbot/blob/9...ontrol.txt
After:
https://github.com/rbcat/returbot/blob/1...ontrol.txt
With the second change, I do not catch "illegal object" error anymore. Apparently, something must be wrong with search() instruction, because this is not the first case when it throws "illegal object" error in a running program after you load a savegame, while radar() instruction never caused such error. I'm still not 100% sure, but if it's indeed a thing, then it should be reported as an issue to github of Colobot. If it wasn't already, of course.
With the first change, conditions in which the game crashes became different. I load a savegame, clear just one camp, triggering respawn for that one camp, and the game doesn't crashes anymore, it works all the way fine. But then, when I clear another one camp and trigger respawn for it, the game crashes. Now you need to trigger respawn for two camps instead of just one to cause the game to crash... NOW I'm confused, because what the heck, that just doesn't makes a sense for me. Note: as it appears, it doesn't matters which camps I choose to clear.
https://github.com/rbcat/returbot/blob/m...ontrol.txt
The problem in it is most likely with Camps class which contains all the static data.
There are three functions that access Camps class: Spawn, Rdata_set and LvlCntlr_main. The problem here is either in LvlCntlr_main or Rdata_set or both, because both are being called all the time while Spawn() is only called when a new spider should spawned. The game crashes immediately right as I load a savegame with respawn already running. Rdata_set is being called by the spiders themselves and they have a little delay in their programs. On the other hand, LvlCntlr_main is the main program of the controller which runs all the time and never stops looking through static data of Camps class, but what is important, it does it even before respawn is triggered. That's all complicated.
Your suggestion might or might not work. Accessing private static objects via that function might indeed work bona fide where accessing public static objects directly causes the game to crash. Now I've got only to try and find out myself.
UPD: I also realized that it might be that there are too many instances of Camps being created over the time. Just now I added destruction of it at the end of Rdata_set, but it didn't help, of course. Though, it should be destroyed automatically.
Before:
https://github.com/rbcat/returbot/blob/9...ontrol.txt
After:
https://github.com/rbcat/returbot/blob/1...ontrol.txt
With the second change, I do not catch "illegal object" error anymore. Apparently, something must be wrong with search() instruction, because this is not the first case when it throws "illegal object" error in a running program after you load a savegame, while radar() instruction never caused such error. I'm still not 100% sure, but if it's indeed a thing, then it should be reported as an issue to github of Colobot. If it wasn't already, of course.
With the first change, conditions in which the game crashes became different. I load a savegame, clear just one camp, triggering respawn for that one camp, and the game doesn't crashes anymore, it works all the way fine. But then, when I clear another one camp and trigger respawn for it, the game crashes. Now you need to trigger respawn for two camps instead of just one to cause the game to crash... NOW I'm confused, because what the heck, that just doesn't makes a sense for me. Note: as it appears, it doesn't matters which camps I choose to clear.
Quote:Where is the thing you think the problem is located? ^^'You mean the program? If so, history versions are above in this post and original one is here:
https://github.com/rbcat/returbot/blob/m...ontrol.txt
The problem in it is most likely with Camps class which contains all the static data.
There are three functions that access Camps class: Spawn, Rdata_set and LvlCntlr_main. The problem here is either in LvlCntlr_main or Rdata_set or both, because both are being called all the time while Spawn() is only called when a new spider should spawned. The game crashes immediately right as I load a savegame with respawn already running. Rdata_set is being called by the spiders themselves and they have a little delay in their programs. On the other hand, LvlCntlr_main is the main program of the controller which runs all the time and never stops looking through static data of Camps class, but what is important, it does it even before respawn is triggered. That's all complicated.
Your suggestion might or might not work. Accessing private static objects via that function might indeed work bona fide where accessing public static objects directly causes the game to crash. Now I've got only to try and find out myself.
UPD: I also realized that it might be that there are too many instances of Camps being created over the time. Just now I added destruction of it at the end of Rdata_set, but it didn't help, of course. Though, it should be destroyed automatically.