Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.tw/irclogs/ Connected with DDNet's IRC channel, Matrix room and GitHub repositories — IRC: #ddnet on Quakenet | Matrix: #ddnet-developer:matrix.org GitHub: https://github.com/ddnet
Between 2020-04-03 00:00:00Z and 2020-04-04 00:00:00Z
Avatar
Update: The final solution in this article has been updated based on feedback from nanofortnight on Hacker News. This change, while not solving the complexity of what it means to work with C++ templates, does help significantly with the readability of this solution. Update 2: ...
Avatar
interesting read, ty 👍
Avatar
unique_ptrs are great
10:52
IMHO they don't need the extra layer of abstraction though
Avatar
@heinrich5991 Hey, where do I get client version from as a 0.7 server? I wnat to do what you discourage here https://github.com/teeworlds/teeworlds/pull/2430#issuecomment-578539436 ^^ (edited)
This addresses #2389 Replacing the NetBool with NetEnum works because RECORDTYPE_NONE maps to 0 and RECORDTYPE_PLAYER to 1. The modder has to ensure that RECORDTYPE_MAP is only sent to 0.7.5 client...
Avatar
@Learath2 the article or unique_ptr?
Avatar
well the article adds a layer of abstraction to unique_ptrs, which I don't think they need
Avatar
@timakro ah, slightly misunderstood the protocol change
Avatar
yeah i guess, but i dont see how to get client version in 0.7
Avatar
you can, but don't
11:37
maybe you could adjust the protocol so it uses an extra bool instead of another enum variable
11:37
so that it's automatically backward-compatible
Avatar
@timakro what are you trying to do anyway? compatibility hack?
Avatar
he's trying to make a race server that sends the correct message to <0.7.4 and >=0.7.5
11:39
the problem is that I slightly misunderstood the protocol change in that pull request
Avatar
adding another bool is smart
11:39
0.7.6 is not yet released, right
Avatar
0.7.5
Avatar
so better make that PR soon 😛
Avatar
what is the extra bool for anyway?
Avatar
it indicates whether it was not only personal best but also global best
Avatar
I see
11:41
Do you think the SDL people would accept a patch with a new event type that'd only be used on macOS?
Avatar
I'd guess so
11:41
can't you map it to an existing one?
Avatar
the accent menu doesnt give any indication that it's started nor does it give an indication that it's ended, so I can't make it into a SDL_TEXTEDITING event without hooking into some internal stuff, which I think they'd hate more
11:43
I could maybe add a new field to SDL_TEXTINPUT
Avatar
I mean the best way forward would be to have some sort of communication channel to them
11:43
do you have something like that?
Avatar
I guess I could file a bug report for discussion on the subject
Avatar
do you know their response times to issues? ^^
Avatar
freenode has a #sdl i think
Avatar
SDL Enthusiasts sounds a bit inofficial
11:45
do you know whether it is official?
Avatar
i dont think its official but maybe someone important is there
11:46
there is always the freenode #sdl
Avatar
There is a guy who answers blazing fast to bugs, but he is the only one that quick
Avatar
could that guy be https://twitter.com/icculus
I build things that help you build games. Contribute to me building things at https://patreon.com/icculus !
Tweets
17728
Followers
9798
11:46
?
Avatar
freenode #SDL doesn't have any of the people familiar with macOS internals
11:47
yeah icculus is the macOS guy
11:47
my last patch is still awaiting his feedback
Avatar
icculus is like the lead dev i think
11:49
Avatar
Why does it always end like this? I start out fixing a teeworlds bug, due to some mess macOS created I start fixing an SDL bug which inevitably leads to disassembling AppKit with it's 100 years worth of compatibility hacks
Avatar
@Learath2 its cuz i care to much about macOS :D
11:52
you**
Avatar
well it's the only machine I have access to right now
Avatar
cant u just install linux there
Avatar
don't have the storage for it
Avatar
i mean, remove completly macos
Avatar
I do have a small virtual machine for compiling though
Avatar
I need macOS to write iOS apps
Avatar
do it through a vm then
11:53
how often do u write ios apps
Avatar
whats tw sever tickspeed? 60 hz?
Avatar
@Ryozuki not much anymore tbh
11:54
xd
11:54
whats this
Avatar
it's a watergun because american people think emojis dictate societal rules
Avatar
anybody knows how float precision works? how big can the number go until i loose 0.001 precision? (edited)
Avatar
@timakro floats are more precise the closer you are to 0
Avatar
i know that much xD
11:56
i mean how big does it have to be when the 3rd decimal becomes inaccurate
11:57
and can i reach that with tickspeed
11:57
of teeworlds
11:58
wait are they? floats always confuse me
11:59
The number of places of precision for float is the same no matter what the size of the number. Data type float can represent numbers as big as about 3.4E+38. But the precision of these large numbers will also be about 7 decimal digits.
Avatar
As numbers get larger and larger you'll use less and less of the mantissa for precision
Avatar
i dont think thats how floats work
Avatar
well I don't see any other way of them working
12:01
for a 32 bit float you have a sign bit, 8 bits for exponent, that leaves 23 bits for the mantissa
12:02
the larger the exponent, the less of the mantissa will be after the decimal point, hence smaller the precision
Avatar
from the wikipedia article it seems you are right
Avatar
Problem with calculating 0.001 precision is that the number is stored in base2 not 10
Avatar
i dont need to know exactly
12:06
just if its possible to reach that point or not
12:06
with 50hz
12:06
like in a month or so idk
12:06
or a year
12:07
and where does this 7 decimal places come from you can find everywhere
12:07
8 bits exponent, 27 bits significant
Avatar
Think it might be something like 0.001 x 2^23
Avatar
7 digits is easy
Avatar
The number of digits of precision a floating point variable has depends on both the size (floats have less precision than doubles) and the particular value being stored (some values have more precision than others). Float values have between 6 and 9 digits of precision, with most float values having at least 7 significant digits.
Avatar
10^7 ~ 2^23, you have 23 bits for the mantissa
12:12
to lose 10^-3 ~ 2^-10 of precision you need to lose about 10 bits
12:12
so for exponents < -10 you won't have 0.001 of precision
Avatar
exponents < -10 would be a small number?
Avatar
that doesn't sound right, I mean you need 10 bits to be after the "binary point" so 23 - 10 = 13, so numbers smaller then 2^-13
12:14
pretty small number
12:15
Sorry, I haven't worked with float internals for like 2-3 years now
12:17
If you use 13 bits before the point, you'll have 10 left for after the point and that's still enough for 0.001 precision, 14 bits and you no longer have enough
Avatar
but that would be 2^14 = 16384, you are saying for numbers >16384 you dont have 0.001 precision?
12:19
sounds way off
Avatar
@heinrich5991 adding a bool for the race thing might indeed be better However the client would drop packets which are missing the new bool. The client needs some backward compatibility for the protocol first, e.g. using a default value if a field is missing
Avatar
got 16383
12:21
exponent > 140 cant represent accurately enough
12:22
take exponent 140 and tick all the boxes in the mantissa
12:22
(for 16383)
Avatar
wow this actually seems true
12:24
and i saved the player start time in ticks as a float on my race server 😩
Avatar
yep any bigger then 2^13 and you lose the 0.001
Avatar
i dont wanna know when i loose 0.01
Avatar
o.o 5:27 until you lose that precision
12:26
(0.001)
Avatar
yeah not race time, server run time
Avatar
you lose 0.001 ~= 2^-6.6 at ~2^17 I think
12:27
0.01*
12:28
that's quite a bit more
Avatar
thats 45 minutes xD
Avatar
looks like 131071
Avatar
use a double?
12:29
that gives a lot more
Avatar
maybe the error cancels out with short race times xD
12:29
tbh i might just store ticks*10 in an integer
Avatar
what about just using integer milliseconds?
Avatar
yep that
12:30
ticks*20 i guess
Avatar
why not just ticks?
Avatar
well the plan was to have more precision
12:31
but i messed that up
Avatar
@heinrich5991 @redix is right, when we just add a bool new clients won't be compatible with old servers. So tell me the secret to get client version :D can't find it in the protocol. my server code is beyond hacky anyways
Avatar
i think right now there is no server which supports new map records anyway
12:43
for now just use the new personal record value
Avatar
why this client addition if you cant use it ...
12:44
and my sever does
12:44
i just tried to implement it
Avatar
There are high precision timers in most OSs maybe just sample that instead of ticks
Avatar
for the next version 😄 when the protocol gets backward compatibility, we could use a new bool, so the protocol might change before a new version
Avatar
oh please god stop hammering out new versions
12:46
i just made a server that supports 0.6 and 0.7 clients
Avatar
well tw release cycle is already slow
Avatar
if only we can get some extensible protocol into teeworlds that'd be the last major update requiring this much work
Avatar
yea you can wait another 10 years :D
Avatar
but in general... it would be better to rely on a stable version. i think there are already incompatibilities with the chat commands because people use the dev version =\
Avatar
people as in fokkonaut 😛
Avatar
so tell me how to detect client version already xD
12:49
is this black magic or am i just missing a field in the protocol?
Avatar
well it was only an example 😄 demos were also broken in some clients
12:50
@timakro Server()->GetClientVersion(ID)
Avatar
@timakro the client sends it in NETMSG_INFO
Avatar
The 0.7 client sends it there
12:51
what about 0.6?
12:51
i couldnt find it there
Avatar
0.6 vanilla clients don't send version
Avatar
ddnet uses NETMSGTYPE_CL_ISDDNET
Avatar
And ddnet clients only send it in cl_isddnet?
12:52
yea
12:54
I need a way to keep track of whether we are inputting text at a global scale
12:55
I'm having trouble imagining how
12:56
(rendering happens after input update and because of imgui it's information that doesn't exist before rendering)
12:56
@heinrich5991 this sounds like some CS problem you might have seen before 😛
Avatar
@timakro the pull request you mentioned was not included in 0.7.4. The latest dev version still uses 0x0704 as client version, so right now the client version does not tell you whether a client supports it or not =\
Avatar
@timakro you can detect my F-Client, which is afaik the only client that uses the new chat system
think_bot 1
🤖 1
13:11
its version is 0x0f2030 (edited)
13:14
@timakro you can set the timer precisiom serverside
13:14
if you send GAMEFLAG_RACE
13:14
Gamecontroller has a snap object, GameDataRace
13:15
DDNet port to TW 0.7. Contribute to ddnet/ddnet7 development by creating an account on GitHub.
13:17
(if that was what you were looking for earlier)
Avatar
@timakro why won't it work with old server new client?
13:41
okay, I'm going to write the PR I guess
Avatar
client will drop the packets because of a missing field
Avatar
okay, need a default value if the field isn't present
13:42
@timakro please don't do version detection, it's evil 😦
Avatar
@heinrich5991 old server will send 1 byte, new client will try to unpack 2 byte
Avatar
yes, I'll do the PR with the forward and backward-compatible message
Avatar
nice :)
Avatar
@timakro you can use -1 as score. sorting in the scoreboard works then 🙂
Avatar
what where
Avatar
0.7 can display score as time. right now you use 0 if someone did not finish yet
Avatar
ok, thx
Avatar
if you use -1 they will be at the bottom and the client will not display a time at all
Avatar
Also add defaults for ints later introduced in the protocol. This allows introducing new fields in the network protocol without breaking backward compatibility (new client -- old server scenario).
Avatar
looks good
Avatar
That's a nice fix, how about you help me come up with a nice fix for my problem aswell so we can have good IME in teeworlds for once? 😛
16:59
the gun damage indicator is not perfect :D. this is a straight up shot, and its not centered correctly :p
Avatar
It looks like even the space between stars isn't same
Avatar
maybe that, or the screenshot was just not nice enough
Avatar
I don't think they are even supposed to be lined up properly
Avatar
you can see though, the right side doesnt touch the block, the left side is on it a bit
Avatar
there is randomness to it
Avatar
@Learath2 i think it was ment to be lined up
Avatar
are u sure there is randomness?
Avatar
well i don't remember, take a look at the code, someone would have to mess up really bad for this to be this bad
Avatar
doesnt look like its random
17:02
17:02
these are multiple shots now
17:02
(i just shot like 5 time in a row or so)
17:03
i guess its because the amount is 10, and thats even.
17:03
looks like adding an 11th star on the right would balance it out again
17:04
i remember, i had this issue for my spread gun, when it was even i needed to shift all projectile directions, so its center
17:04
centered again*
Avatar
weird, the server sends the angle but the client seems to ignore it, how does the client decide what side the stars should be displayed on?
Avatar
doesnt the server send the stars too
Avatar
help posting in the ddnet forum doesnt work
17:32
gives http error 500
Avatar
what r u doing? applying for mod?
Avatar
@Learath2 the server sends 10 objects
18:13
10 stars
18:13
in 0.7 its different, but for 0.6
Avatar
oh one per location
Avatar
in 0.7 the angle is ignored
Avatar
wait 0.7 still sends all the stars one by one?
18:14
in 0.7 this is not possible anymore
18:14
thats why i only send 1 star for ddnet7
Avatar
and how does the client know which way the stars go?
Avatar
it calculates based on whether there is another one next to it i guess, because if i keep shooting, it will perform a circle
18:15
but thats not the problem right now :D
18:15
we are still here for the 0.6 thing
Avatar
NETEVENTTYPE_DAMAGEIND
18:15
in 0.6 each star is added to the snapshot with this type
Avatar
in 0.6 the server loops through the amount of stars we want, does its math and then sends the angle with the object to the client
Avatar
@heinrich5991 What do i need to send now after your fix?
18:55
Hmm the new clients will accept both msgs with 2 booleans and with 1 bool
18:55
right?
18:57
If I send just the short one I can't get the map record message. If I send just the long one old clients don't get the message. If I send both new clients get two messages.
Avatar
@timakro old clients will just ignore the extra bool
Avatar
old clients cant be changed
19:02
oh they will right now
Avatar
cb33678 Add donation by kill the tee - def-
Exported 239 message(s)