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-01-04 00:00:00Z and 2020-01-05 00:00:00Z
Avatar
Fun bug xd
Avatar
As reported by Im 'corneum on Discord: https://www.youtube.com/watch?v=MsTZj097sMs The drawing happens in players.cpp, see m_Emoticon. Not sure why they get rendered so weirdly, but it's easy to reproduce.
Avatar
@Im 'corneum thanks, found the issue
Avatar
@deen do you happen to be here by luck?
11:48
or @heinrich5991
Avatar
@Learath2 now am
Avatar
@heinrich5991 do you happen to be familiar with STL?
Avatar
no, ask your question 🙂
12:27
@Learath2 no question? :/
Avatar
Oh sorry, no highlight so I missed it 😛
12:28
I'm retro-fitting a rb tree implementation I have to behave more like an STL container, the objective is to learn a little more modern C++
12:28
Do you happen to know how one is supposed to do allocations and implement iterators in an STL container?
Avatar
no, not really
12:34
I guess the cppreference website could help: https://en.cppreference.com/w/cpp/memory/allocator, etc.
Avatar
@heinrich5991 still here?
Avatar
was about to leave
14:25
but it's not so easy to read, so you should just leave 😛
Avatar
what data structure is this? a binary tree?
Avatar
yep a binary search tree
Avatar
node takes T by value?
Avatar
node allocates storage for it
Avatar
but the constructor, does it take T by value?
Avatar
I updated the gist to show the entire thing
14:26
It takes a reference to T no (edited)
Avatar
doesn't do anything with its parameter though
Avatar
The constructor?
Avatar
yes
Avatar
Oh yeah forgot to set it, there should be a *m_pData = Data; there
Avatar
or rather new(m_pData) T(Data), is that a thing? you could also use c++'s new move operator if you'd like
Avatar
Oh I think that is a thing in C++ yeah
Avatar
has this thing compiled already?
Avatar
Move operator I'm not sure about
Avatar
node **pRoot = m_pRoot; this looks like a type error
14:28
next line declares the same thing again 😄
14:29
other than that, looks kinda good
Avatar
@heinrich5991 it doesn't compile because of some allocator thing I'm trying to figure out
Avatar
except that it goes into an endless loop if you insert an element that is neither < nor >, I think
14:30
I think node **pRoot = m_pRoot; should be node **pRoot = &m_pRoot;
Avatar
Oh, then I guess it doesn't compile, even if I fix the allocator
Avatar
the loop condition is also useless, never fulfilled
14:31
wait a second
14:32
more type errors, pRoot = (*pRoot)->m_pLeft; should also have a & operator
Avatar
@heinrich5991 updated the gist again
14:34
Fixed all the trivial errors and got it compiling
Avatar
if(!(*pRoot)) never triggers due to the loop condition
Avatar
Uff, I'm so rusty
14:39
@heinrich5991 can you take a look again?
Avatar
you slightly changed behavior, now duplicate nodes will be inserted
14:41
other than that, the last thing that I see is that new doesn't return nullptr on failure, but throws std::bad_alloc
Avatar
idk a good way to deal with duplicate nodes
14:42
what is the convention?
Avatar
in a set? don't insert them
14:42
I think
14:43
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
Avatar
One last thing, do you see a nice way to not insert that node without making the code ugly? 😛
Avatar
else if(*(*pRoot)->m_pData > Data) { … } else { delete t; return; }
Avatar
oh, that should work, I'm retarded
Avatar
afk for a bit
14:46
feel free to ask questions, will be back in a bit
Avatar
@heinrich5991 do you know of a way to visualize a binary tree easily?
Avatar
no
15:17
idea: print a tree-like structure to the terminal
15:17
but not sure if good
15:17
if you have a good solution to this, please tell me
15:17
I also needed it at some point
Avatar
Do you know of a way to quickly verify the tree is fine from the inorder representation?
15:18
it's quite some work to implement it properly is the problem
Avatar
walk the tree in the inorder representation?
Avatar
I walk the tree, I'm not sure if it's correct just from that walk though
Avatar
hm
15:19
dunno, and have to leave4
15:19
bye, see you later
Avatar
This removes code duplication and D can never be negative: template inline T distance(const vector2_base &a, const vector2_base &b) { return length(a-b); } inline float length(const vector2_base &a) { return sqrtf(a.x*a.x + a.y*a.y); }
Avatar
e2b252b Distance can't be negative - fokkonaut 19779cc Merge #2027 - bors[bot]
Exported 80 message(s)