Skip to main content
Topic: [9.x bug] Teleporting ships. (Read 7279 times) previous topic - next topic

[9.x bug] Teleporting ships.

Teleporting ships are back in commit eeb274b8590c0e0795e1cd6c89d1cb6ea30cdf0f

Fix in my github repository.

A know it is wrong. But i am not able to hunt down all uint/sint conversions yet.

Re: [9.x bug] Teleporting ships.

Reply #1
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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #2
Signed/unsigned conversions is a pain.  We really must remove all unnecessary unsigned types from code.

Re: [9.x bug] Teleporting ships.

Reply #3
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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #4
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)

Re: [9.x bug] Teleporting ships.

Reply #5
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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #6
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... :)

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Re: [9.x bug] Teleporting ships.

Reply #7
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.

Re: [9.x bug] Teleporting ships.

Reply #8
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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #9
I will deal with Standard part first. See my 'signed/unsigned int cleanup.' topic.

Edit: My patch in Standard now.
Edit: Merged code in my int_cleanup branch.

Re: [9.x bug] Teleporting ships.

Reply #10
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 : '::'
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #11
Your compiler think it is max(a,b) macro.
use
Code: [Select]
(std::numeric_limits<sint32>::max)()


Re: [9.x bug] Teleporting ships.

Reply #12
Will that work with all compilers?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Re: [9.x bug] Teleporting ships.

Reply #13
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.