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 2019-05-25 00:00:00Z and 2019-05-26 00:00:00Z
Avatar
you didn't have to, I just asked whether if it was a problem 😄
Avatar
It was kinda needed
07:54
Because when the recorder was recording for a long time like 15 mins and then you wanna save a replay you would have a big freeze like 1-2 seconds and the longer is the recording the longer the freeze would be
07:55
So I tought why not do that in a separate thread to fix that problem and its working well ^^
Avatar
@Learath2 "I highly doubt this call is safe from a thread." wym?
Avatar
[quakenet] Learath2 BOT 2019-05-25 10:35:05Z
you call into the demoeditor from a thread
10:35
the demoeditor has no lock
10:35
so i feel you could break something if this thread ends up using the demoeditor at the same time as the main client
Avatar
hmmm
Avatar
[quakenet] Learath2 BOT 2019-05-25 10:36:18Z
(i'm not sure though, for all I know Slice could be not using any members)
Avatar
what can I do to be sure that this will work without potentially breaking anything? xd
10:38
Slice is creating a demorecorder and a demoplayer within the function
Avatar
It'd definitely be safe if you create a new demoeditor
Avatar
Each time i call the SaveReplay function? or a "global" demoeditor for the replays?
Avatar
either should work just fine
10:41
I'd probably create one when spawning the thread
10:41
and destroying it afterwards
Avatar
Alright thanks for that review ^^
Avatar
you can destroy it in the destructor of the CJob
10:44
That Notice isn't entirely safe either, but we do that one all the time, so w/e 😛
10:44
the sql code is full of calls into cgamecontext that aren't safe
Avatar
xd
Avatar
the correct way would be to have a threadsafe queue of notices
Avatar
hmm
10:45
a queue of notices
Avatar
The threads append to the queue
Avatar
yeah
Avatar
And the main client just renders them out when its time
Avatar
so i should do another task for notifications?
10:52
I'd just leave it as is tbh
Avatar
yea
Avatar
we don't have a threadsafe queue in the codebase, so you'd also need to code one
Avatar
ah xd
Avatar
interesting idea in demo to put numbers too warp time in demo 1-9 , but this is glitch
Avatar
Is there any convention to create an instance of a class as there is multiple ways to do so?
Avatar
not really
11:24
but in this case I guess you could have a unique_ptr in your CJob
11:25
actually unique_ptr wasn't c++11 iirc
11:25
or is it?
11:26
it is c++11, make_unique isn't
11:27
anyways, you can just have a unique_ptr and initialize it with new
Avatar
yeah but i mean for the demorecorder
11:55
I did that
11:56
// Create a DemoEditor to do the job CDemoEditor *DemoEditor = new CDemoEditor(); DemoEditor->Init(m_pGameClient->NetVersion(), &m_SnapshotDelta, m_pConsole, m_pStorage);
Avatar
that doesn't look like a unique_ptr, but I guess it's fine either way
Avatar
^^
Avatar
rememer to free the demoeditor
Avatar
delete m_pDemoEditor; does that right?
Avatar
should, yes
Avatar
good
Avatar
lol no
16:46
use free()
16:46
xd
16:46
ah well
16:46
its the same
Avatar
yea xd
Avatar
@archimede67 do u really need a pointer there
Avatar
yes
Avatar
if you allocate it with new, free it with delete, if you allocate it with malloc free it with free
23:27
If you use a unique_ptr there it'd free itself when it goes out of scope
23:28
and no, you don't really need a pointer there, you could have a CDemoEditor m_Editor; as a member in the CJob then initialize the editor in the constructor of the job
Exported 63 message(s)