]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/aClient.cpp
updated the Change log w/ new additions
[irc/gameservirc.git] / gameserv / aClient.cpp
index 64884d39117cdb276351894edf446954ab348abd..8de6b3567170b0c262d149a3f562b91e4f7c938e 100644 (file)
@@ -1,20 +1,42 @@
 #include "aClient.h"
+#include "options.h"
+#include "extern.h"
 #include <stdlib.h>
 #include <stdio.h>
 
 aClient::aClient(char *n)
 {
-    cout << "aClient created: " 
-        << (n[0] == '\0' ? "NULL" : n) << endl;
+    #ifdef DEBUGMODE
+       log("aClient created: %s", (n[0] == '\0' ? "NULL" : n));
+    #endif
     strcpy(nick, n);
+
+    #ifdef P10
+       strcpy(realnick, n);
+    #endif
+
+    stats = NULL;
+    flags = 0;
+}
+#ifdef P10
+aClient::aClient(char *n, char *rn)
+{
+    #ifdef DEBUGMODE
+       log("aClient created: %s", (n[0] == '\0' ? "NULL" : n));
+    #endif
+    strcpy(nick, n);
+    strcpy(realnick, rn);
     stats = NULL;
     flags = 0;
 }
+#endif
 
 aClient::aClient(const aClient &right)
 {
-    cout << "aClient created from another aClient: " << right.nick 
-        << endl;
+    #ifdef DEBUGMODE
+       log("aClient created from another aClient: %s\n", right.nick);
+    #endif
+
     stats = NULL;
     flags = 0;
     setData(&right);
@@ -23,19 +45,43 @@ aClient::aClient(const aClient &right)
 aClient::aClient()
 {
     aClient("");
-    flags = 0;
 }
 
 aClient::~aClient()
 {
-    cout << "aClient deleted: " << *this << flush;
     if (stats)
     {
-       cout << ' ' << stats->name << ' ' << stats->password << endl << flush;
+       #ifdef DEBUGMODE
+           log("aClient deleted: %s %s %s", nick, stats->getName().c_str(), stats->getPassword().c_str()); 
+       #endif
+
        delete stats;
     }
+  #ifdef DEBUGMODE
+    else
+    {
+       log("aClient deleted: %s", nick);
+    }
+  #endif
+
     flags = 0;
-    cout << endl << flush;
+}
+
+bool aClient::operator!=(const aClient &right)
+{
+  return !(*this == right);
+}
+
+bool aClient::operator==(const aClient &right)
+{
+  if (strcmp(nick, right.nick) == 0 && stats == right.stats)
+       {
+         return true;
+       }
+  else
+       {
+         return false;
+       }
 }
 
 ostream &operator<<( ostream &out, const aClient &c )
@@ -46,17 +92,22 @@ ostream &operator<<( ostream &out, const aClient &c )
 
 void aClient::setData(const aClient *right)
 {
-    if (right != this)
+  if (right != this)
     {
-       strcpy(nick, right->nick);
-       if (right->stats)
-       {
-           if (!stats)
-               stats = new Player;
-
-           cout << "Should be setting data for " << right->stats->name << endl;
-           stats->setData(right->stats);
-       }
+         strcpy(nick, right->nick);
+#ifdef P10
+         strcpy(realnick, right->realnick);
+#endif
+         if (right->stats)
+               {
+                 if (!stats)
+                       stats = new Player;
+#ifdef DEBUGMODE
+                 log("Should be setting data for %s", right->stats->getName().c_str());
+#endif
+                 
+                 stats->setData(right->stats);
+               }
     }
 }