b-casey / OpenSMACX

A project to decompile SMAC/X to C++ with the long term goal of creating a full open source clone.
GNU General Public License v3.0
52 stars 4 forks source link

When gifting energy credits, response message (GAVEENERGY) isn't displayed #20

Open b-casey opened 4 years ago

b-casey commented 4 years ago

When a player gifts energy credits to another faction, there is a script response that should be displayed based on certain conditions: GAVEENERGY, GAVEENERGY1, or GAVEENERGY2. The bug happens because of an incorrect call order where a shared string global gets set to a non-existent script id.

Function with bug: 00547C10 ; void __cdecl make_gift(uint32_t factionID, uint32_t factionIDRecipient) Bug locations: 0054814D call diplomacy_caption(int,int) # changes stringTemp from GAVEENERGY to non-existent id ... 005481B5 push offset stringTemp ; char 005481BA call X_pops(char const ,int,Sprite ,int ()(void)) # passes incorrect script id

I had a quick look at all the other references to diplomacy_caption() and this seems to be the only instance of this particular bug. I'm going to add in some debug handling to log other potential errors like this where the game fails to find a script reference.