]> jfr.im git - irc/gameservirc.git/blob - gameserv/aClient.cpp
P10 is now functional. The game is playable, but it does not display text nicknames...
[irc/gameservirc.git] / gameserv / aClient.cpp
1 #include "aClient.h"
2 #include "options.h"
3 #include "extern.h"
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 aClient::aClient(char *n)
8 {
9 #ifdef DEBUGMODE
10 log("aClient created: %s", (n[0] == '\0' ? "NULL" : n));
11 #endif
12 strcpy(nick, n);
13 stats = NULL;
14 flags = 0;
15 }
16
17 aClient::aClient(const aClient &right)
18 {
19 #ifdef DEBUGMODE
20 log("aClient created from another aClient: %s\n", right.nick);
21 #endif
22
23 stats = NULL;
24 flags = 0;
25 setData(&right);
26 }
27
28 aClient::aClient()
29 {
30 aClient("");
31 flags = 0;
32 }
33
34 aClient::~aClient()
35 {
36 if (stats)
37 {
38 #ifdef DEBUGMODE
39 log("aClient deleted: %s %s %s", nick, stats->name, stats->password);
40 #endif
41
42 delete stats;
43 }
44 #ifdef DEBUGMODE
45 else
46 {
47 log("aClient deleted: %s", nick);
48 }
49 #endif
50
51 flags = 0;
52 }
53
54 ostream &operator<<( ostream &out, const aClient &c )
55 {
56 out << (c.nick[0] == '\0' ? "NULL" : c.nick);
57 return out;
58 }
59
60 void aClient::setData(const aClient *right)
61 {
62 if (right != this)
63 {
64 strcpy(nick, right->nick);
65 if (right->stats)
66 {
67 if (!stats)
68 stats = new Player;
69 #ifdef DEBUGMODE
70 log("Should be setting data for %s", right->stats->name);
71 #endif
72
73 stats->setData(right->stats);
74 }
75 }
76 }
77
78 long int aClient::setFlags(long int newflags)
79 {
80 flags = newflags;
81 return getFlags();
82 }
83
84 long int aClient::addFlag(long int flag)
85 {
86 flags |= flag;
87 return getFlags();
88 }
89
90 long int aClient::remFlag(long int flag)
91 {
92 flags &= ~flag;
93 return getFlags();
94 }