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 2018-05-15 00:00:00Z and 2018-05-16 00:00:00Z
Avatar
is using #pragma once instead of headerguards a bad practice or wathsoever?
12:25
http://prntscr.com/ji4rb0 seems widely supported
12:26
It is not standard and it is not portable. It injects the hosting machine's filesystem semantics into your program, in addition to locking you down to a vendor. hmm
Avatar
@Ryozuki it's not standard
12:50
I wouldn't use it
Avatar
aslong you dont write for embedded system just use it
Avatar
why though?
12:54
because it saves some typing?
Avatar
it looks better, it doesnt define anything, and depending on, if your IDE/whatever creates such things when creating the file header, yes it saves typing xd
12:59
and it's directly clear what you want.. pragma once = include once
13:01
visual studio adds them (edited)
Avatar
@Deleted User the other variant (preprocessor defines) also has some upsides. e.g. if you copy a header file, it still works.
Avatar
isnt that more an argument for pragma once
13:04
you can just copy files
13:04
xD
Avatar
essentially it boils down to "is #include the same a pasting the text there"?
13:05
e.g. there are some header libraries that get compiled by concatenating all of their headers
13:05
before #pragma once, just copying the header into your program is the same as #including it
13:05
not with #pragma once
Avatar
well sure i sometimes use defines too, especially if i want it to be includuded by a specific file but often you just include
Avatar
anyway. I don't think one should deviate from the standard just to save typing
Avatar
i would say the standard just needs an update
Avatar
then push for it 😛
13:08
but I don't think it'll go into the standard because it has some unclear semantics
13:09
e.g. what happens with symlinks, or hardlinks
13:09
suppose one file has #include <freetype/freetype.h> and the other has #include <freetype.h>
13:10
and /usr/include/freetype symlinks to /usr/include
13:10
does the file get included twice? or once? if it has #pragma once at the start
Avatar
once
13:11
if the pos is the same
Avatar
but what does that mean? "pos is the same"?
13:11
what happens if you hardlink header files?
Avatar
well i actually more mean in an absolute path, and for hardlinks it would resolve the pos
Avatar
the point is that "file identiy" is a not really defined property
13:12
hardlinks are just two names for the same file
13:13
there's two "absolute paths" for a hardlink
13:13
e.g. if I hardlink a to b, then afterwards, a and b are completely equivalent
13:13
I can delete b or I can delete a, and the other one will still be ok
Avatar
indeed, then i would say the actual pos on hardware if you want xD
13:13
i mean gcc probably solved this havent they
Avatar
we can look at their approximation 😄
Avatar
good luck :D but if you have two different freetype headers, it also doesnt garantuee you to what to use
13:15
i mean with defines
Avatar
if they have the same content and were just copied into two places for installation, then the macro solution just works™
Avatar
but does that save you anyhting
13:15
if the content is the same anyway
Avatar
yes. we won't get duplicate definition errors
13:16
(the reason we have header guards in the first place)
Avatar
ah ok, you mean like completly same files ok
13:17
but then i'd say again gcc probably saved this issue
Avatar
I doubt that they "solve" this
13:17
this would mean they detect equal contents of source files
Avatar
yes
13:18
no
13:18
they just make it unique by some kind of name
Avatar
Header files are stupid anyway, C++ modules ftw: https://clang.llvm.org/docs/Modules.html
Avatar
anyway, since the STL or something does not garantuee to use the same define for your header, you might want to create a vector.h and define the same definition STL does on some system
13:24
so it's 1:1
13:24
xD
Avatar
no, STL isn't allowed to define arbitrary macros
13:26
they have __identifier and _Identifier reserved for them
Avatar
then some libs idc
Avatar
this is the same problem as for symbols then
13:26
a library might define function and you also want to define function
13:27
the idea there is to prefix all your public stuff with your library name
13:27
meh. needs some enforced namespacing!
Avatar
ok then other topic, what is your argument for a pointer not be handled as an own datatype in c++, if typdef is possible to be used on it
13:30
thats another thing i dont really like on c++ syntax
Avatar
is this a "heinrich5991 must surely like every feature of c++"? 😮
Avatar
no, but you seem to like it
13:32
maybe you have arguments i dont know
13:32
like int *a,b; since pointers arent an "own" datatype
Avatar
(where did I seem like I like c++ particularly in that discussion?)
Avatar
i am more refering to teeworlds code now
13:33
i know you like rust or smth
Avatar
^^
13:34
mh. I'm not exactly exactly sure about that one
13:34
it would probably look weird with the other rules concerning variable declarations
13:35
e.g. int (*a), b; is equivalent
13:35
I think
13:35
yup, it is
Avatar
i just dislike that this is possible: typdef int* int_ptr; int_ptr a,b;
13:35
then it seems like you are allowed to make a ptr a datatype
Avatar
yup, you are
13:36
it would look weird for arrays if it were to apply to both definitions
13:36
but you can mix arrays and pointers
13:36
int a[10], b; would be weird if b were an array in that declaration
13:38
but int (*a)[10], b; is the way to declare a pointer to an array, and int (*a), b is equivalent to int *a, b ­– it would be weird if it weren't
13:38
because then the only possible parantheses for int *a, b; would change something. hmm.
13:38
maybe one could formulate it in a way that (int *)a, b; was possible (but that looks like a typecast) (edited)
Avatar
you are right arrays are some kind of a problem, since they are actually just a pointer, except that the compiler can use it as an array too. But stilll then i would just forbid array declaration like that, or make it int[] a[10].
Avatar
no, arrays are not just a pointer, they have very different semantics
Avatar
yes, but only for the compiler
Avatar
struct A { int a[10]; }; is 10 ints big, struct B { int *b; }; is one pointer wide
Avatar
sizeof and stuff like that
Avatar
no, it's only in the compiler that they're treated somewhat the same, because arrays can decay (be implicitly converted) to pointers to the first element
Avatar
yeah but what is that in asm? a new operand? the compiler just creates 10 *sizeof(int) bytes rest is up to the user
13:44
even if the compiler warns you if you "buffer overflow" it you can do it if you want
Avatar
in asm, you basically have 10 variables of type width sizeof(int)
13:46
if you declare a pointer, you have one variable of pointer width, that may point to some memory location containing some ints
Avatar
that's why i said, then it has to be operand int[]. But should be unique as a datatype
Avatar
mh?
13:47
I don't understand your last sentence
Avatar
int a[10], b; shouldn't be allowed for the same reason pointers can be declared as datatypes
Avatar
ah
13:48
that'd be possible
13:49
would forbid declaring multiple arrays at once though
Avatar
why tho? int[] a[10], b[20]
Avatar
(couldn't do char aBuf[128], aBuf2[256];)
13:49
oh
13:49
you want a different syntax there
Avatar
yes, because i don't see a reason this isn't a new datatype
Avatar
how would you distinguish int (*a)[10] and int *(a[10]) in your new syntax?
Avatar
an array of pointers?
Avatar
a pointer to an array vs an array of pointers
Avatar
int*[] array of pointer_int, int[]* ptr of an array_int (edited)
13:51
there were stars <.<
13:53
pretty much reading from left to right int_ptr_array
Avatar
yea, I think there are languages that do it this way, although they reverse the entire declaration you give
Avatar
mhh, probably
Avatar
e.g. x: *const u8 in rust 😛
13:54
for a constant (raw) pointer to a byte
Avatar
yeah rust is pretty nice, only thing i dislike is this unsafe thing. I just can't imagine, if you are really able to write low level code without this
Avatar
I think rust's argument is: you can keep your unsafes isolated in a module
13:56
that it's possible to code in rust can be seen by the fact that firefox includes rust code
Avatar
yeah, but on mobile i get many crashes still xD
13:57
but since the rust version is out i use firefox alot more, it just runs better than before
13:57
if ppl would learn rust instead of java, the world would be a better place, rip
Avatar
AFAIK the mobile version doesn't use rust yet
Avatar
ok, strange that exactly with that update the crashes came
Avatar
Well in embedded scenarios C will always shine so why bother with a new language, lets just teach everyone how to code competently in C \o/
Avatar
well in embedded scenarios ASM will always shine so why bother with a new language, let's just teach everyone how to code competently in ASM \o/ (edited)
Avatar
typdef int* int_ptr;
15:15
windows api does things like this
15:16
Avatar
ASM shines in nothing silly man, it's just for exotic platforms where there is no libc (albeit there arent many left because C is amazing)
Avatar
you and your C fanatism xD
Avatar
No libc as in no C implementation before you argue semantics 🙂
15:19
@Ryozuki drink the koolaid join me and Ill show u the way
Avatar
show me da way
🇺🇬 2
15:20
@Learath2 what you think about dlang
Avatar
Is more in the right direction imho but I havent had much chance to experiment with it in an actual project
Avatar
rust!
Avatar
rust!
Avatar
arnold-c!
Avatar
pascal
Avatar
small question: why do i only get max 24 players when i send the SERVERBROWSE_GETINFO_64_LEGACY packet?
19:15
validation of the response: if ($data === false || $datalen < 15 || substr($data, 0, 15) !== "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffdtsf5") { continue 2; }
19:16
$data = explode("\x00", $data); for ($i = 11; isset($data[$i + 4]); $i += 5) { $player['name'] = (string)$data[$i]; $player['clan'] = (string)$data[$i + 1]; $player['country'] = (int)$data[$i + 2]; $player['score'] = (int)$data[$i + 3]; $player['ingame'] = (bool)$data[$i + 4]; $connection[1]['players'][] = $player; } (edited)
19:16
since it cancels me the copypaste with the \x00 a screenshot of the data https://i.imgur.com/Nb1aXIs.png (edited)
19:18
parsing works but I only get max 24 players instead of the currently 25(was the same when there were 31 online) online players (edited)
Avatar
why don't you use SERVERBROWSE_GETINFO_64? 😛
19:23
ah
19:23
and SERVERBROWSE_GETINFO_64_LEGACY only sends 24 players per packet
19:23
you should receive two of them
19:25
there isn't one without legacy (edited)
Avatar
send SERVERBROWSE_GETINFO with some special bytes in the front, let me check the source
19:33
@Peekabooo "xe\0\0\0\0\xff\xff\xff\xffinf3"
Avatar
thanks a lot, the 2nd packet worked too https://i.imgur.com/jJ5iHU0.png
19:36
will update it to the default packet with the special bytes nonetheless though xD
19:36
thanks a lot
Avatar
@Peekabooo the good thing about the new packet is that you can send it to all servers. new servers supporting it respond with the new info packet, servers not supporting it respond with the old response
Avatar
there are still 2 packets instead of only 1 like from the server not supporting it though or?
Avatar
you send this packet I gave you
19:41
if a server supports the new protocol, it will respond with all players in an appropriate number of packets
Avatar
ah ok
Avatar
if a server doesn't support the new protocol (and likely does not support 64 players), then it will respond with the vanilla response
Avatar
yep already figured that out, thanks again^^
19:43
but should be xe\0\0\0\0\xff\xff\xff\xffgie3 instead of the xe\0\0\0\0\xff\xff\xff\xffinf3 or? (edited)
Avatar
teeworlds-server-info - Acquire server info from teeworlds servers
19:46
timakro done this
Avatar
@Peekabooo yes
19:50
@Ryozuki directly ignores the spec 😦 $data = "xe" . $server['_extratoken'] . "xD" . "\xff\xff\xff\xffgie3" . $server['_token'];
19:50
the "xD" is supposed to be "\0\0"
Avatar
it works
Avatar
yes. but it's not forward-compatible
Avatar
fordward compatible with what
Avatar
with whatever we need next
Avatar
we specifically said these bytes ought to be zeroed (edited)
19:51
where
Avatar
in the initial PR
Avatar
what pr
Avatar
that added this info type
19:52
(the code in ddnet also does that)
Avatar
well idc
19:52
contact timakro or smth
19:52
or make a pr
Avatar
well, or don't recommend that library until someone fixes it
Avatar
i will recommend it
Avatar
these kind of things make software not work
Avatar
like i did right now
Avatar
these kinds of things are the reason why TLS 1.3 has low adoption
19:53
because someone thought it would be a good idea to only accept TLS <= 1.2
19:53
because that was "all that was out at the time"
Avatar
i dont want to sound rude but i dont care
Avatar
cool. I care about robust software
Avatar
This means that we have a reliable and fast way to query for extended info, while also not wasting network bandwidth. The protocol is designed to be extensible, there's four bytes space for enc...
Avatar
yeah documentation in a old pr
19:54
and a external repo
19:54
this is good work
Avatar
or the reference implementation
19:54
which also does this
Avatar
a good way to contributing in reliably software
19:55
not having docs
Avatar
well, I wrote some docs and if someone wanted to find them, they would
Avatar
what I don't really understand either why he is inserting 2 random bytes into the packet though aka his extratoken
Avatar
you can do that to get a longer token from the ddnet server
19:55
you should probably do that
Avatar
but good to see the structure of the packets, never checked the ddnet code before so got kinda lost in it a bit
Avatar
xe<TWORANDOMBYTES>\0\0\xff\xff\xff\xffinf3
19:56
@Peekabooo ^
19:56
eh.
Avatar
ah ok will do that then
Avatar
gie3
19:57
evil idea: we could probably get you to care, by dropping info requests with "xD" in the bytes that should be zeroed
Avatar
go ahead
19:59
you should drop all packets with extra bytes
19:59
reliably software
Avatar
GLSL!
20:00
MATH
Avatar
[quakenet] <Learath2> Ryozuki, you are why we have bad software :*(
20:18
[quakenet] <Learath2> @DaRealFreak it takes decades to dig through the mess that is the ddnet/teeworlds source, we spend hours meditating on it just to find where things go
20:19
[quakenet] <Learath2> heinrich5991: I'd be okay with merging a patch that drops invalid packets
Avatar
Learath2: the problem would be that this would defeat the purpose of the forward-compatibility field
20:20
😦
Avatar
[quakenet] <Learath2> i meant just xD :)
Avatar
ah also a general question: had the cron task to update all player/server data on 5 minutes before, but like 50% of the servers refused to send me information back, anyone knows the exact number since 10 minutes is kinda meh sometimes(all servers I've gotten from the master server are sending me the information in 10 minute intervals, 50% refuse it in 5 minute intervals) (edited)
Avatar
might just be packet loss
Avatar
Learath2 oh im rly sry then :)
Avatar
[quakenet] <Learath2> no you arer not, you said you don't care :( software terrorist
20:43
🔫
Avatar
@Peekabooo I think 5min should be enough pause
22:23
do you send all your udp packets at once?
22:23
maybe they get dropped because your uplink can't handle all of them?
22:26
sudo iptables -A INPUT -p udp \! -f -m u32 --u32 "26&0xffff=0x7865 && 32=0x7844ffff && 36=0xffff6769 && 38&0xffff=0x6533" -j REJECT
Avatar
... i planned to send them in chunks but my sleep was in the wrong block apparently...
23:49
god I'm dumb
Exported 249 message(s)