File: consoleevent.cpp

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (88 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#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()
    );
}