]>
Commit | Line | Data |
---|---|---|
85ce9d3e | 1 | #include "aClient.h" |
9f8c2acc | 2 | #include "options.h" |
3 | #include "extern.h" | |
85ce9d3e | 4 | #include <stdlib.h> |
5 | #include <stdio.h> | |
6 | ||
7 | aClient::aClient(char *n) | |
8 | { | |
9f8c2acc | 9 | #ifdef DEBUGMODE |
10 | log("aClient created: %s", (n[0] == '\0' ? "NULL" : n)); | |
11 | #endif | |
85ce9d3e | 12 | strcpy(nick, n); |
13 | stats = NULL; | |
96f71fee | 14 | flags = 0; |
85ce9d3e | 15 | } |
16 | ||
17 | aClient::aClient(const aClient &right) | |
18 | { | |
9f8c2acc | 19 | #ifdef DEBUGMODE |
20 | log("aClient created from another aClient: %s\n", right.nick); | |
21 | #endif | |
22 | ||
85ce9d3e | 23 | stats = NULL; |
96f71fee | 24 | flags = 0; |
85ce9d3e | 25 | setData(&right); |
26 | } | |
27 | ||
28 | aClient::aClient() | |
29 | { | |
30 | aClient(""); | |
96f71fee | 31 | flags = 0; |
85ce9d3e | 32 | } |
33 | ||
34 | aClient::~aClient() | |
35 | { | |
85ce9d3e | 36 | if (stats) |
37 | { | |
9f8c2acc | 38 | #ifdef DEBUGMODE |
39 | log("aClient deleted: %s %s %s", nick, stats->name, stats->password); | |
40 | #endif | |
41 | ||
85ce9d3e | 42 | delete stats; |
43 | } | |
9f8c2acc | 44 | #ifdef DEBUGMODE |
45 | else | |
46 | { | |
47 | log("aClient deleted: %s", nick); | |
48 | } | |
49 | #endif | |
50 | ||
96f71fee | 51 | flags = 0; |
85ce9d3e | 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; | |
9f8c2acc | 69 | #ifdef DEBUGMODE |
70 | log("Should be setting data for %s", right->stats->name); | |
71 | #endif | |
85ce9d3e | 72 | |
85ce9d3e | 73 | stats->setData(right->stats); |
74 | } | |
75 | } | |
76 | } | |
96f71fee | 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 | } |