Teleporting ships are back in commit eeb274b8590c0e0795e1cd6c89d1cb6ea30cdf0f
Fix in my github (http://github.com/inkelyad/simutrans-experimental) repository.
A know it is wrong. But i am not able to hunt down all uint/sint conversions yet.
Thank you very much for the fix, which I have tested and found to work - most helpful. What I can't understand is how the bug got back in the code in the first place.
Signed/unsigned conversions is a pain. We really must remove all unnecessary unsigned types from code.
Unnecessary unsigned types? Simutrans tends to use unsigned types by default as far as I can see, and use signed types only when negative numbers are expressly required.
And it is bad. Any integer expression where we use '-' is source of errors.
Really, why max_speed is uint32? Just plain 'long int' (signed,>=32bit) should be enough. Or even plain 'int' (signed, >=16bit)
Hmm - these are things that will need to be dealt with in Standard, as I am very keen not to have any non-functional differences in the code-bases between the two, as it makes merging unnecessarily hard. Perhaps you could propose a patch for Standard that makes more use of signed integers?
inkeylad: To answer partially your question - no, nothing can be a "plain int", because all data transmitted between "sessions" (savegames, network) must have defined size. This caused huge problems with mac and later 64bit compatibility. (And it's all been fixed.) Questioning signed/unsigned is fair game though, as far as I can tell... :)
And it's all been fixed. --- so you use some code to convert data between network and host endian mode. In some place you can convert to network/host data size. No need to use fixed length datatypes internally. Where it was discussed?
And i think Experimental is not 64bit clean. There is places where INT_MAX used with uint32 variables.
That's not good - the problem is that I don't have a 64-bit platform to test. Can you find the relevant examples? I can change them to the appropriate hard-coded number.
I will deal with Standard part first. See my 'signed/unsigned int cleanup. (http://forum.simutrans.com/index.php?topic=5973.0)' topic.
Edit: My patch in Standard now (http://github.com/aburch/simutrans/commit/7ad6ad0b84436fd6af1f0aa08b0268fe3a6f3716).
Edit: Merged code in my int_cleanup (http://github.com/inkelyad/simutrans-experimental/tree/int_cleanup) branch.
Inkelyad,
having some trouble merging the Experimental version: I get compile errors with this line in simvehikel.h:
static sint32 speed_unlimited() {return std::numeric_limits<sint32>::max(); }
1>f:\my documents\development\simutrans\simutrans-experimental-sources\vehicle/simvehikel.h(412): warning C4003: not enough actual parameters for macro 'max'
1>f:\my documents\development\simutrans\simutrans-experimental-sources\vehicle/simvehikel.h(412): error C2589: '(' : illegal token on right side of '::'
1>f:\my documents\development\simutrans\simutrans-experimental-sources\vehicle/simvehikel.h(412): error C2059: syntax error : '::'
Your compiler think it is max(a,b) macro.
use
(std::numeric_limits<sint32>::max)()
Will that work with all compilers?
It is already used in my city generation code. No problems was reported.
GCC understand it as it is. So i just forgot it is problem for MSVC.