Box swapping bug

Randomsheep

Warlord
Joined
Oct 19, 2017
Messages
121
Please could someone confirm this::

Start a new game and build a colony straight away. Select your city then select governor then click imports.

I choose train oil as an example so choose that and then set the left box to a value (I chose 20). Don't bother ticking the checkboxes.

Click OK.

Reselect imports and notice how the value is now in the right box. Click OK and reopen imports and notice it is back in the left box.

Thanks
 
To explain the issue here in a simple way, the issue here is that two 16 bit ints needs to be merged into one 32 bit int, transmitted on the network and then split again. This is done by accessing individual bits in the 32 bit variable, which is a severely outdated approach from before computers had plenty of memory. Judging from the comments and code, the programmer writing the code in question never tried this approach before, got confused and the result is hard to read and buggy code. It's not the first bug in this specific part of the code.

I have now given up on this specific part of the code and plan on a rewrite to make it clean, readable and bugfree. Luckily I do have experience in accessing individual bits and know how this should have been done from the start.

The reason I mention network code is because technically speaking, singleplayer is a one player network game. As a result, modders will only have to write network code and then it will work in both network and singleplayer.
 
Thanks Nightinggale for that explanation.

The bug is NOT there in 2.6.

The bug is there in 2.7 and all following 2.7 betas.

Why does the code need to be changed and not reverted to 2.6? Whatever change for 2.7 has caused this behaviour.

EDIT:

Nightinggale just ignore whatever I say because I know nothing.

All I want is the mod to be as good as it can be, and if you can fix it then words can't describe how much love will be coming your way.
 
Last edited:
It looks like the bug was in the very same line as the last bug related to colony import/export setup. That's a strong hint that the code itself isn't as easy to read as the rest of the DLL. I rewrote this part of the code to make it very clear what goes on and not try to do more than one thing at a time and this time I think the bugs are gone for good.
 
Top Bottom