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-05-11 00:00:00Z and 2020-05-12 00:00:00Z
Avatar
@heinrich5991 Can you think of a good way to refcount entities? I'm trying to avoid >c++03 because I'm hoping maybe I can get some of this in vanilla
Avatar
can you give an example of refcounting entities?
Avatar
Currently when a world is destructed all of it's entities are deleted, however now I have multiple worlds and it's possible now for an entity to not be part of a world. So I want to delete the entity only when no pointers to it remain
Avatar
ah
13:28
you could put the refcount into the CEntity itself
13:28
as long as you don't start threading stuff, that should work out fine
Avatar
Hm, so a member function in CEntity to get a reference?
13:30
CEntity::reference with a constructor that increases the refcount and a destructor that decreases it is what I was thinking
13:31
Or maybe I should just use a shared_ptr, not likely that vanilla will accept my patch to allow multiple worlds anyway
13:34
Or even a unique_ptr, other functions can just use a weak reference to the entity
Avatar
unique_ptr doesn't really have weak references
Avatar
yeah, but I can just get a raw pointer to the thing it's controlling
13:41
actually that is just asking for trouble
13:45
Hm, moving a unique_ptr is supposed to be cheap, but it doesn't sound right to transfer ownership when just giving out a reference
Avatar
moving a unique_ptr invalidates the source
Avatar
@heinrich5991 I'm not good with the newfangled smart pointers, do you think a shared_ptr is more suitable here, even though only one world should own the entity at any point
Avatar
the pointer graph of entities is pretty complicated with all these intrusive linked lists
13:48
I don't know where to put the smart pointer
Avatar
I was thinking the gameworld should have a list of unique_ptrs to the entities it owns
Avatar
yea, that would work
Avatar
but there are functions like CGameWorld::ClosestEntity that hands out pointers to entities
13:50
how am I supposed to handle that?
13:51
It doesn't sound right for the caller of ClosestEntity to take ownership of the entities but returning a raw pointer to the entities also sound like asking for trouble
Avatar
you can't give ownership on stuff like ClosestEntity
13:56
you should probably hand out a raw pointer in that case, for c++
Avatar
Oh, now that I think about it, does the world really own the entity alone? In a sense the player owns the character entity
14:04
And the player owns it's CProjectiles (we don't maintain this pointer anyway, but still it could be useful, like when moving a character from one world to another move all it's projectiles too)
14:05
.s/player/character/
Avatar
depends on the business logic there
14:07
if you teleport between worlds, you probably wouldn't wnat to teleport your projectiles as well
Avatar
it was just an example
14:08
but the player -> character is a relationship we do use, not sure how to handle that one
Avatar
short: I have no experience mapping complex pointer graph into an ownership model in c++
Avatar
well I don't like ownership models to begin with
14:15
I'm just fine with my raw pointers
14:16
the more I try to step into the future, the more I see the future isn't all that bright 😛
Avatar
well, you're not asking c++ experts right now 😛
Avatar
##c++ would tell me to just fork teeworlds and use boost
Avatar
very helpful
Avatar
that channel is like an ad agency for boost
Avatar
have you tried showing the factorio blog post to them?
14:17
the one where they say why they got rid of boost
Avatar
haven't even read the blog post
14:18
finally an actual example I can show people
Avatar
Belt fast replace improvements Dominik is our new programmer in for a testing period. He was given the task to add support for fast-replacing splitters and belts in a reasonable way, and he ended up extending the functionality a little. Adding a belt junction: Remov...
Avatar
when I say I don't want to use boost I'm just asking for trouble and I should just use boost
Avatar
removed two boost headers, halved compile times of a large project
Avatar
YES, this plagues all of C++
14:20
no one gives a shit about compile times
14:21
I don't remember the talk but one google engineer described how they spent a couple weeks implementing something like modules in clang to stop the exponential growth of the 99% percentile compile times
14:21
exponential growth...
Avatar
nice
Avatar
Hm, I wonder if there is an adapter that is able to store both unique or shared_ptr
Avatar
that sounds like asking the wrong question
14:24
or programming more generically than you need it
Avatar
Well there are some entities that I want multiple ownership semantics for, and some entities that I want unique ownership semantics for
Avatar
just go for shared_ptr everywhere? it incurs paying for non-existing threads unfortunately…
Avatar
well shared_ptr has an atomic refcount which is more expensive then unique_ptr
14:30
I guess std::move can help with the atomic refcount
Avatar
yes, there's no non-atomic refcounted pointer in c++
Avatar
As long as I use std::move to move between the worlds that should be plenty optimized
Avatar
have you heard about c++20 modules? i think they reduce dramatically compile times
Avatar
@Ryozuki that's exactly what google tried to emulate
14:32
They managed to get the 99% percentile compile times down drastically indeed
14:35
oh, I forgot entities are allocated in a weird way
Avatar
Is there any url encoder and decoder function that doesnt use curl? I dont wanna include curl just for that. ChillerDragon and me tried something but couldnt achive anything good
Avatar
I also had that problem, the best I could figure out was to parse the URL myself
Avatar
I dont want to use it for URLs, just for saving special characters in a txt file
Avatar
You can save special characters in a txt file without urlencoding them
17:48
txt files don't have a set encoding, you can just use utf8
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 17:51:08Z
@Learath2 you sure unfiltered strings can cause no problems? Because i noticed some inconviences. There are some characters that seem to make trouble.
Avatar
yes, files can contain arbitrary bytes on all platforms
17:52
e.g. map files also contain all these bytes
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 17:52:30Z
yes but thats binary
17:52
i mean a txt file and reading it as txt used to cause problems for me. When parsing it with bash or displaying it in web.
17:53
It fails to count lines for example.
Avatar
bash has a hard time with 0 bytes, I think
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 17:53:57Z
yea i want to avoid hard times and possible bugs when using a different parser
17:54
doubt it was a 0 byte tho wouldnt that also terminate the string in teeworlds?
Avatar
utf8 avoids null bytes for a reason
Avatar
utf8 encodes the null character as a null byte
17:56
and as it's a char < 128, no other representation may match it
17:56
there's a modified utf-8 which avoids the null byte there
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 17:57:06Z
how would a nullbyte not be a string terminator?
Avatar
C terminates strings with null bytes
17:58
other languages do not, and have no problems with internal null bytes
Avatar
I guess if you want to save all possible binary strings AND be human readable you could use QP encoding
Avatar
or you could use JSON's string encoding
17:59
ah no, that doesn't match well with binary strings
17:59
only utf-8
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 17:59:59Z
I just want to save teeworlds user strings coming from nicknames or chat next to normal text without causing any possible problems. And teeworlds chat or nicknames can not contain a string terminator as far as i know.
Avatar
text in teeworlds should be all fine to store as utf8
Avatar
no, vanilla doesn't sanitize strings to utf8
18:01
only ddnet does, by droppign all non-utf8 messages with strings
Avatar
really? vanilla allows arbitrary binary sequences?
Avatar
no, it drops some bytes
18:01
e.g. <0x20
18:01
but it doesn't drop non-utf8 stirngs
Avatar
There are some decisions taken by vanilla that baffle me
Avatar
it wasn't an explicit decision so far, but I can imagine them taking it
Avatar
I guess it is simpler to drop <0x20 but that's just so janky
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:03:21Z
Also I have seen clan names with line breaks in my teeworlds scoreboard so I assume that to be problematic when parsing line by line
Avatar
line breaks should be stripped out
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:04:05Z
not like '\n' but the nasty ones
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:04:15Z
nah
18:04
arent there also characters in other languages that change the direction of the text
18:04
or delete or what ever
Avatar
oh the weird utf8 stuff that abuses positioning?
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:04:40Z
yea something like that
Avatar
we don't implement that
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:04:51Z
idk about this topic i just have seen some things
Avatar
it could probably confuse the font renderer though, it's not very smart
Avatar
but if you parse line by line, it should be fine
18:05
splitting by \n
18:05
because that character is not legal in teeworlds nicknames/clans
Avatar
Ṃ̸̛̺ḛ̵̡̼m̷̧̯ē̵͙͎ț̷̛̪ę̴̢̛x̸̛̺t̷̢̡
18:06
Heh, discord sanitizes it too
Avatar
zalgo
Avatar
w̵̨̢ţ̷̨̨f̵̢̢
18:06
How does the tw font renderer react to zalgo?
Avatar
I doubt we support it
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:07:18Z
Avatar
probably by just putting the accents after the letters
Avatar
looks like you opened the file with the wrong encoding
Avatar
yup
18:07
post the file pls
18:09
I usually dont manually chose a encoding on opening a txt file
Avatar
chillerdragon thinks that some of these weird characters cause the issue with my server not finding 0.7 masters after rcon login. I cant see how it should be related, but without accounts on his VPS it works... On my local server with all these accounts it works too, I am lost
Avatar
this looks messed up as utf8 aswell, what is this even encoded as?
Avatar
This account seems to be old, as there is a ' missing at the end of the lines, I had this bug because my buffer was too small for that message. Its fixed long ago, but I guess this is just a cut off character?
Avatar
>>> ftfy.ftfy("»ĸαzo") '»ĸαzo'
Avatar
@heinrich5991 so what is the encoding?
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:18:17Z
I have the feeling you guys are suggesting not to encode and just save unfiltered tw input in a text file?
Avatar
"»ĸαzo".encode("windows-1252").decode()
18:19
so it's utf-8, read as windows-1252 again, and encoded as utf-8 again
18:20
also known as "double utf-8" I think
Avatar
Ah forgot windows-1252 is even a thing
18:21
I wonder how that happens
Avatar
you treat bytes as unicode characters and encode them as utf-8 again, I'd guess
Avatar
must be simpler than that, I doubt @ChillerDragon would do that on purpose
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:28:23Z
i do nothing its @fokkonaut's server i am just hosting it idk he probably edited the account file on a windows machine
Avatar
I guess one could restrict oneself to ascii to make sure that all editors round-trip the data
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:35:04Z
thats what I am trying to say
18:35
But to support special characters in names there has to be some encoding
Avatar
UTF-7 (7-bit Unicode Transformation Format) is a variable-length character encoding for representing Unicode text using a stream of ASCII characters. It was originally intended to provide a means of encoding Unicode text for use in Internet E-mail messages that was more effici...
18:35
is probably what you want, then
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:37:32Z
do you have a c implementation of that?
18:37
and whats wrong with url encode i really like that one
Avatar
well, but urlencode can also be written in C very easily
18:45
then fix my code pls ;D
18:46
I mean it encodes correctly but it does not feel good also the source gets changed.
18:46
How can I do pSrc++ without chaning the src.
Avatar
wdym, changing the source?
18:47
pSrc + 1?
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:47:32Z
at the bottom u can see the output
18:47
i expect "buf '♪ x x'" but get "buf 'x'"
Avatar
int char_allowed(char c) { return ('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '-' || c == '.' || c == '_' || c == '~'; }
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:50:23Z
yea go pr that to curl but that part works fine
18:50
A command line tool and library for transferring data with URL syntax, supporting HTTP, HTTPS, FTP, FTPS, GOPHER, TFTP, SCP, SFTP, SMB, TELNET, DICT, LDAP, LDAPS, MQTT, FILE, IMAP, SMTP, POP3, RTSP...
Avatar
if you copy that from curl, you have to credit them btw 😉
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:51:11Z
in my experimental snippet?
Avatar
in the experimental snippet that is likely to get into some of your code bases
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:51:57Z
I guess you know i credit all code i publish
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:52:28Z
i feel like you keep doding my questions today ;D you come up with solutions for problems i never had
Avatar
anyway
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:53:04Z
yea thats my test playground and the paste is not published
Avatar
now I'll dodge you some more, have to go away from the computer for a sec
Avatar
[quakenet] ChillerDragon BOT 2020-05-11 18:56:08Z
yea its fine ill just close irc now thanks for the input anyways @fokkonaut the code works but there is no warranty
18:56
make sure to credit curl if you put that in ur mod ;D
Avatar
ah back
19:19
ChillerDragon gone?
Avatar
Why can't you see others dj (with the blue white stuff) without pause anymore since a few versions btw?
Exported 177 message(s)