News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[9.x bug] Teleporting ships.

Started by inkelyad, September 20, 2010, 07:40:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

inkelyad

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.

jamespetts

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.

inkelyad

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

jamespetts

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.

inkelyad

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

jamespetts

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.

VS

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!

inkelyad

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

jamespetts

Quote from: inkelyad on September 21, 2010, 08:14:38 AM
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.

inkelyad

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

jamespetts

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 : '::'
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.

inkelyad

Your compiler think it is max(a,b) macro.
use

(std::numeric_limits<sint32>::max)()



jamespetts

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.

inkelyad

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.

jamespetts

The fix for this has been implemented in 9.0. Thank you, Inkelyad!
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.