1

Topic: air_friction 0.94

Someone told me that there was something wrong with his server, because he could not jump as far as he used to.
It took me a while to figure out where the problem was.

Anyway, the default value for air_friction is 0.95.
The config contained the following line:
tune air_friction 0.95

This shouldn't do anything because it is already the default.
But surprisingly tune_dump showed 0.94 instead of 0.95.
When changing the value during running it says that it is changed to 0.95, but it is still 0.94.

I tested a bit and found out that it does only occure when the 32 bit version is running. The 64 bit server works fine.
I tested on a 64 bit Debian Linux with ia32-libs installed.

It is confusing.

2

Re: air_friction 0.94

The tuning is saved as an integer (Tuning x 100), therefore there are rounding errors when it is converted back to the normal tuning.

3 (edited by TeePhoenix 2012-06-10 16:35:49)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

4

Re: air_friction 0.94

TeePhoenix wrote:

But why isnt it integer from the beginning?

It looks better to have 0.95 than 95 as it's a ratio. Even if the air_friction was 0.94 I highly doubt that would ruin the gameplay.

Not Luck, Just Magic.

5 (edited by TeePhoenix 2012-06-10 16:35:43)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

6

Re: air_friction 0.94

when im wrong, tell me but.. isnt a float 4bytes like a normal integer?! (i mean the ufloat if its there lol)

7 (edited by TeePhoenix 2012-06-10 16:35:38)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

8

Re: air_friction 0.94

yes i meant unsigned flout. Dont know if there is one. i know there is uint and ulong (oO dont know).
this means the first bit isnt taken for - / +.

9 (edited by TeePhoenix 2012-06-10 16:35:09)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

10

Re: air_friction 0.94

i think int is used because the tuning params are sent as int. Well this isnt a problem though... even when using float for the tunings u can still just send it as int.
I just tried it and it works great smile

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

11

Re: air_friction 0.94

Sushi Tee wrote:

i think int is used because the tuning params are sent as int. Well this isnt a problem though... even when using float for the tunings u can still just send it as int.
I just tried it and it works great smile

I don't know whether the C standard guarantees the storage of floats, if not, the server might have problems to send the floats to a client with a different type of floats.

(what I ment is: be careful, do some research before introducing such network stuff)

12

Re: air_friction 0.94

i tested in 32 bit and 64 bit windows (cl) and in 32 bit and 64 bit linux (gcc)... was always 32bit long... the same for int. i guess its fine for all systems tw runs on smile

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

13 (edited by TeePhoenix 2012-06-10 16:26:44)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

14

Re: air_friction 0.94

Sushi Tee wrote:

i tested in 32 bit and 64 bit windows (cl) and in 32 bit and 64 bit linux (gcc)... was always 32bit long... the same for int. i guess its fine for all systems tw runs on smile

It's more about cpu architectures than about compilers - and the trial and error does not work here, if the C standard doesn't guarantee it, it shouldn't be used (that's probably why matricks sent the tunings as ints) - because you could miss a platform teeworlds runs on. You for example missed 'ppc' (if that's an architecture, found it in bam.lua)

TeePhoenix wrote:

As far as I know, should float be always the standardized IEEE 754 single precision floating point number (maybe except of some really special compilers), which is always 32 bit long.

Except some really special compilers (or rather cpu architectures) - that's the exact problem I mentioned, this would result in very strange errors. Please do some research before posting, as far as I know it's also always 32bit, but I don't know for sure, that's why I wrote that one has to do some research about it, your answer didn't help at all.

TeePhoenix wrote:

There should Sushi be right, but int isnt always 32 bit! Just have a look at this: http://en.cppreference.com/w/cpp/language/types Even if it is in most cases 32 bits long, you should consider to use uint32_t instead of int, because then you will get always an 32 bit int.
The only problem I see, that could happen is that big and little endian problem, that also would affect all integers (so it should still be solved somewhere else).

Thanks captain obvious... - You're talking to programmers. sad

15 (edited by TeePhoenix 2012-06-10 16:26:39)

Re: air_friction 0.94

Deleted.

The face of terrorism is called United States of America!

16

Re: air_friction 0.94

What i did is converting the float value to int by simple casting it to float without changing the bits then send it via normal netmasage as int and then cast it back to float. Its surely not nice but seems to work quite well in all archtectures tw runs on. Ofc we could just do some new netmessage to send floats. This would be maybe the best. int values get packed/compressed before sending as far as possible. With the values we get due to casting the floats to ints its more or less useless so maybe its a good idea to create a new net message for sending floats... if u know what i mean. but anyway... the int thingy seems to work pretty well xD

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^