The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: inkelyad on September 20, 2010, 07:40:42 pm

Title: [9.x bug] Teleporting ships.
Post by: inkelyad on September 20, 2010, 07:40:42 pm
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 20, 2010, 09:14:05 pm
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 20, 2010, 09:22:56 pm
Signed/unsigned conversions is a pain.  We really must remove all unnecessary unsigned types from code.
Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 20, 2010, 10:16:36 pm
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 20, 2010, 10:35:53 pm
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)
Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 20, 2010, 11:36:00 pm
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?
Title: Re: [9.x bug] Teleporting ships.
Post by: VS on September 21, 2010, 07:23:37 am
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... :)
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 21, 2010, 08:14:38 am
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 21, 2010, 10:31:37 pm
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 22, 2010, 03:12:03 am
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.
Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 26, 2010, 07:56:12 pm
Inkelyad,

having some trouble merging the Experimental version: I get compile errors with this line in simvehikel.h:

Code: [Select]
static sint32 speed_unlimited() {return std::numeric_limits<sint32>::max(); }

Code: [Select]
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 : '::'
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 26, 2010, 08:15:30 pm
Your compiler think it is max(a,b) macro.
use
Code: [Select]
(std::numeric_limits<sint32>::max)()

Title: Re: [9.x bug] Teleporting ships.
Post by: jamespetts on September 26, 2010, 08:18:12 pm
Will that work with all compilers?
Title: Re: [9.x bug] Teleporting ships.
Post by: inkelyad on September 26, 2010, 08:55:52 pm
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.