openmohaa/code/fgame/consoleevent.cpp
smallmodel 5b82cc4f11
Made Event::ErrorInternal const
Fixed ProcessEvent() not handling exceptions
2023-08-19 21:00:04 +02:00

87 lines
1.5 KiB
C++

#include "consoleevent.h"
#include "g_local.h"
//===============================
// ConsoleEvent
//===============================
MEM_BlockAlloc<ConsoleEvent> ConsoleEvent_allocator;
CLASS_DECLARATION(Event, ConsoleEvent, NULL)
{
{ NULL, NULL }
};
/*
=======================
new ConsoleEvent
=======================
*/
void* ConsoleEvent::operator new(size_t size)
{
return ConsoleEvent_allocator.Alloc();
}
/*
=======================
delete ptr
=======================
*/
void ConsoleEvent::operator delete(void* ptr)
{
ConsoleEvent_allocator.Free(ptr);
}
/*
=======================
ConsoleEvent
=======================
*/
ConsoleEvent::ConsoleEvent(void)
{
m_consoleedict = NULL;
}
/*
=======================
SetConsoleEdict
=======================
*/
void ConsoleEvent::SetConsoleEdict(gentity_t* edict)
{
m_consoleedict = edict;
}
/*
=======================
GetConsoleEdict
=======================
*/
gentity_t* ConsoleEvent::GetConsoleEdict(void) const
{
if (m_consoleedict)
return m_consoleedict;
return g_entities;
}
/*
=======================
ErrorInternal
=======================
*/
void ConsoleEvent::ErrorInternal(Listener* l, str text) const
{
gentity_t* edict = GetConsoleEdict();
str eventname = getName();
gi.DPrintf("^~^~^ Game ( Event '%s', Client '%s' ) : %s\n",
eventname.c_str(),
edict->client ? edict->client->pers.netname : "",
text.c_str());
gi.SendServerCommand(GetConsoleEdict() - g_entities,
"print \"Console: '%s' : %s\n\"",
eventname.c_str(),
text.c_str());
}