]> jfr.im git - irc/gameservirc.git/blob - gameserv/aClient.cpp
Initial revision
[irc/gameservirc.git] / gameserv / aClient.cpp
1 #include "aClient.h"
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 aClient::aClient(char *n)
6 {
7 cout << "aClient created: "
8 << (n[0] == '\0' ? "NULL" : n) << endl;
9 strcpy(nick, n);
10 stats = NULL;
11 }
12
13 aClient::aClient(const aClient &right)
14 {
15 cout << "aClient created from another aClient: " << right.nick
16 << endl;
17 stats = NULL;
18 setData(&right);
19 }
20
21 aClient::aClient()
22 {
23 aClient("");
24 }
25
26 aClient::~aClient()
27 {
28 cout << "aClient deleted: " << *this;
29 if (stats)
30 {
31 cout << ' ' << stats->name;
32 delete stats;
33 }
34 cout << endl;
35 }
36
37 ostream &operator<<( ostream &out, const aClient &c )
38 {
39 out << (c.nick[0] == '\0' ? "NULL" : c.nick);
40 return out;
41 }
42
43 void aClient::setData(const aClient *right)
44 {
45 if (right != this)
46 {
47 strcpy(nick, right->nick);
48 if (right->stats)
49 {
50 if (!stats)
51 stats = new Player;
52
53 cout << "Should be setting data for " << right->stats->name << endl;
54 stats->setData(right->stats);
55 }
56 }
57 }