Chuck Norris is nobody next to you
OK, so ignore the whole review above, it's obsolete.
I reviewed the code you have pasted here on June 3rd or 4th (I copied it from this post on Sunday morning, just before I went on vacation)... and said was definitely final and 100% working... thanks for wasting my time.
I'm not gonna review (yet another) new version again...
Btw. you've posted many pastebin links on IRC earlier, and amended source code pasted here on forum at least once (hard to check how many times it was actually)... and EACH time you say now it's 100% working... thanks, but no thanks.
Jeah that code was more then a headache...
I found some wrong boolean checks in it, which i corrected.
And yes maybe i can improve the check in isResearchAvailable.
But regarding performance, it only enters the getAvailableResearchProjects, when you actually open the Research menu on a base.
As you can see
hereIt will only perform the checks then, to begin with.
Actually i also did some testing on the DOS Version and it just keeps alive aliens by default available, if the give results or not. So we could just go and check if a researchprojects is a alive alien and directly return true, to always keep them available.
My idea was to remove alive aliens from the research list (and also Items with getOneFree) once the player can not learn anything from them anymore, thats why i check for their "unlocks" and "getOneFree".
Which would help players, especially when they play big mods, like FMP, Piratez, Area51 or my own Mod.
The current still active code of for the research in the current main branch, doesn't do that.
In this regard it is actually bugged, since stuff isn't correctly handled, even if you just wanna replicate vanilla behaviour.
Feel free to test the DOS Version in this regard yourself, it just keeps alive aliens open for research forever, of course researching them removes them from the alien containment.
About my post above, i was in my lunch break and had to return to work. I did not want to be rude or so.
Now a small explanation on how the reworked research code actually works:
- first we check if the topic is in the unlocked list, if not we skip and move directly to the next topic
- after that we check if a topic has fulfilled dependencies, if not we skip all the other test.
- a alive alien will be tested if he has something to discover for the player or not, if so it will be shown in the research list.
- after this we check if all the "requires" of the research are met, if not we skip all the rest of the function and move to the next topic.
This process is then used to fill the list of the research menu and to remove already discovered topics.
Best is you read the comments in the code on github, i tried to as plain as possible.
Kind regards hellrazor.