Quote:
Originally Posted by BAILOPAN
I hate to tell you but there is no such word as "reverved." You used it like three times. Did you mean reserve? Or reverse?
HL2 is generally not thread safe.
|
lol yes i mistake the word
is reserve sorry
about events things:
i think im using the best way to safe fire events out of thread functions:
Code:
void fireQueuedEvents()
{
for(int i = 0; i < queueEvent.Count(); i++)
{
IGameEvent *event = gameeventmanager2->CreateEvent("event_name");
if(event)
{
event->SetString("source", queueEvent[i].srcFile);
// ...
// ...
if(!gameeventmanager2->FireEvent(event))
Warning(""PLUGIN_TAG_LONG" Problems on fire event 'event_name', skipping that!\n");
}
else
Warning(""PLUGIN_TAG_LONG" Couldn't initalize event 'event_name', skipping that!\n");
queueEvent.Remove(i);
}
}
Code:
void CServerToolsPlugin::GameFrame( bool simulating )
{
//Msg("Tick: %f - %f\n", gpGlobals->curtime, engine->Time());
fireQueuedEvents();
float curtime = engine->Time();
if (fLastCurtime == 0)
{
fLastCurtime = curtime;
return;
}
if ((curtime - fLastCurtime) >= st_gameframe.GetFloat())
{
fLastCurtime = curtime;
//Msg("In gameframe after 2s\n");
}
}
After inside thread function i AddTo tail
Code:
event_struct fakeEvent;
fakeEvent.srcFile = srcFile;
...
...
queueEvent.AddToTail(fakeEvent);
is that correct? or should i fire event directly from threaded func?
--
and about reserve a file?