Page 1 of 1
[0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 7:08 pm
by I_IBlackI_I
What did you do?
I Created a save-file with the (in this topic) included scenario, Main Menu -> Play -> Scenarios -> (under user-scenarios) FMMOTEST_Research_crash -> create.
(
)
What happened?
The game crashes to desktop.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
A new world would have been created
OR
An error in-game would have occured.
Code Explaination.
The file /locale/utils/modular_admin_ghosts creates a new force on line 25 on line 26 it calls the function research_all_technologies().
The file /locale/utils/force_mod has a event listener on line 303 this event resets all a force their bonusses and adds a user definable bonus on top.
Assumption:
On_research_finished gives a event.research back.
The LuaTechnology contains a force (LuaForce) this one is however read-only, which may cause the game to crash when I am modifying it.
Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 7:35 pm
by Rseding91
Thanks for the report however this looks like a case of "don't do that". One of the mods is listening to the "research completed" event and possibly the same or another is resetting all technology effects in the research completed event which again fires "research completed" in a never ending cycle.
I guess I could disallow calling reset technology effects during the research completed event but that starts to get into the realm of hand-holding and there are all kinds of places these checks would need to be put in place bloating the API and complicating it at the same time.
Unless this starts to be come a common thing I think for now I'm just going to say "don't do that"

Similar to calling "cancel deconstruction" during the "marked for deconstruction" event and then in the "deconstruction cancelled" calling "mark for deconstruction" you'd just end up in an infinite loop.
Currently the games way of letting you know you've done this is to crash to desktop

Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 7:44 pm
by I_IBlackI_I
Alright no worries. It just took quite a bit of time to find what is wrong. If possible I would suggest a error in the way of "Trying to modify read-only object on line: xxxxxxx"
I noticed it could be a crash because I messed it up, but because it was a crash to desktop I decided to report it anyway.
Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 9:02 pm
by Rseding91
I_IBlackI_I wrote:Alright no worries. It just took quite a bit of time to find what is wrong. If possible I would suggest a error in the way of "Trying to modify read-only object on line: xxxxxxx"
I noticed it could be a crash because I messed it up, but because it was a crash to desktop I decided to report it anyway.
It's not read only though. If it was read only you'd get an error about it being read only. There seems to be some misconceptions around what "read only" means in the Lua docs. I'll see if we can change them to clear it up.
You can read the object - you can't assign directly to it. You can however read it, and then change properties on the object you got back.
Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 9:26 pm
by I_IBlackI_I
Alright thank you very much for the response.
I now understand the way the read only works in the lua doc.
It however seems that I had misread your first reply.
I thought that the reset_technology_effects() would only reapply all the bonuses and recipes a technology gives. I didn't think the function would actually fire the research finished event, since it states it preserves the state of the technologies.
Code: Select all
reset_technology_effects()
Reapplies all possible research effects, including unlocked recipes. Any custom [u][b]chages [/b][/u]are lost. Preserves research state of technologies.
I will write a way around this current behavior. I would suggest stating that this function actually fires the event.
If it doesn't actually fire the event I got no clue where this code might crash the game.
PS: Any custom
chages are lost.
I think this sentence is incorrect and should probably be cha
nges.
Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Tue Aug 01, 2017 9:36 pm
by Rseding91
I_IBlackI_I wrote:PS: Any custom chages are lost.
I think this sentence is incorrect and should probably be changes.
Thanks for noticing

Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Wed Mar 14, 2018 7:57 am
by I_IBlackI_I
Re: [0.15.31] Crash on_research_finished research_all_technologi
Posted: Wed Mar 14, 2018 9:02 am
by Bilka
No, there the issue was different. I'll provide the desciprtion Rseding gave to bob:
Calling reset_technology_effects while the game was in the state of "researched finished, press T" would leave the research manager in a broken state.
Where it would say "I have just finished researching" but had no previous technology it researched saved.
So the GUI would attempt to show "XXXXXX finished, press T"