]> jfr.im git - irc/gameservirc.git/blame - gameserv/aClient.cpp
Added flags to the aClient structure to keep track of given client attributes. Switch...
[irc/gameservirc.git] / gameserv / aClient.cpp
CommitLineData
85ce9d3e 1#include "aClient.h"
2#include <stdlib.h>
3#include <stdio.h>
4
5aClient::aClient(char *n)
6{
7 cout << "aClient created: "
8 << (n[0] == '\0' ? "NULL" : n) << endl;
9 strcpy(nick, n);
10 stats = NULL;
96f71fee 11 flags = 0;
85ce9d3e 12}
13
14aClient::aClient(const aClient &right)
15{
16 cout << "aClient created from another aClient: " << right.nick
17 << endl;
18 stats = NULL;
96f71fee 19 flags = 0;
85ce9d3e 20 setData(&right);
21}
22
23aClient::aClient()
24{
25 aClient("");
96f71fee 26 flags = 0;
85ce9d3e 27}
28
29aClient::~aClient()
30{
cbf6551f 31 cout << "aClient deleted: " << *this << flush;
85ce9d3e 32 if (stats)
33 {
cbf6551f 34 cout << ' ' << stats->name << ' ' << stats->password << endl << flush;
85ce9d3e 35 delete stats;
36 }
96f71fee 37 flags = 0;
cbf6551f 38 cout << endl << flush;
85ce9d3e 39}
40
41ostream &operator<<( ostream &out, const aClient &c )
42{
43 out << (c.nick[0] == '\0' ? "NULL" : c.nick);
44 return out;
45}
46
47void aClient::setData(const aClient *right)
48{
49 if (right != this)
50 {
51 strcpy(nick, right->nick);
52 if (right->stats)
53 {
54 if (!stats)
55 stats = new Player;
56
57 cout << "Should be setting data for " << right->stats->name << endl;
58 stats->setData(right->stats);
59 }
60 }
61}
96f71fee 62
63long int aClient::setFlags(long int newflags)
64{
65 flags = newflags;
66 return getFlags();
67}
68
69long int aClient::addFlag(long int flag)
70{
71 flags |= flag;
72 return getFlags();
73}
74
75long int aClient::remFlag(long int flag)
76{
77 flags &= ~flag;
78 return getFlags();
79}