]> jfr.im git - irc/gameservirc.git/commitdiff
Introduced the new mystring clas and attempted to use it in a list
authorkainazzzo <redacted>
Thu, 20 May 2004 01:07:40 +0000 (01:07 +0000)
committerkainazzzo <redacted>
Thu, 20 May 2004 01:07:40 +0000 (01:07 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@221 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/.depend
gameserv/TODO
gameserv/gameserv.cpp
gameserv/list.h
gameserv/myString.cpp
gameserv/myString.h
gameserv/tcpclient.cpp

index 8dcdd05b3513eafe4369fb84c703a091398881e4..049e310f28305930361dd84b1665a099bafb41e8 100644 (file)
@@ -8,7 +8,6 @@ gameserv.o: gameserv.cpp aClient.h options.h player.h pouch.h config.h \
   extern.h list.h listnode.h flags.h myString.h sockhelp.h
 log.o: log.cpp extern.h player.h aClient.h options.h pouch.h list.h \
   listnode.h config.h
-myString.o: myString.cpp myString.h
 player.o: player.cpp player.h aClient.h options.h pouch.h extern.h list.h \
   listnode.h config.h flags.h
 sockhelp.o: sockhelp.cpp sockhelp.h extern.h player.h aClient.h options.h \
index 390db414bad80bafcb890f364da9aa9dd5965833..5d22699036111e37dca96fdcd6cc247bb68986eb 100644 (file)
@@ -1,10 +1,12 @@
-* = Not finished
+* = Not Started
 - = Started
 X = Finsihed
 
+- Daily news (murders, kidnappings, level gains, red dragon slayings)
+
 * Add a function to check how long until gameserv refreshes
 
-- Gangs of people that can get together and fight other gangs in large 
+* Gangs of people that can get together and fight other gangs in large 
     group battles
     - gang names
     - gangs.dat file with numbers assigned to gangs
@@ -21,8 +23,6 @@ X = Finsihed
 
 * Change your name for a price :)
 
-* Daily news (murders, kidnappings, level gains, red dragon slayings)
-
 * Add a drop command for all(their own nick)/admin(any nick)
 
 * Rejoin the bot if kicked/killed
index 92fd917d5f56fb6c4fc096a3f3060b6278ed913c..d7a0f3117b507a9562095cbd84ffafc78d0d0584 100644 (file)
@@ -3,6 +3,7 @@
 #include "extern.h"
 #include "flags.h"
 #include "list.h"
+#include "myString.h"
 #include "sockhelp.h"
 
 #include <cctype>
@@ -224,6 +225,16 @@ void gameserv(char *source, char *buf)
        do_tavern(source);
     } else if (stricmp(cmd, "LIST") == 0) {
        do_list(source);
+    #ifdef DEBUGMODE
+    } else if (stricmp(cmd, "PRINT") == 0) {
+       List<myString> news;
+       myString *st;
+       st = new myString("This is a test");
+       cout << news.insertAtBack_RLN(st)->getData() << endl;
+       cout << st << endl;
+       news.print();
+       delete st;
+    #endif
     } else if (stricmp(cmd, "LOGOUT") == 0) {
        do_logout(source);
     } else if (stricmp(cmd, "REGISTER") == 0) {
index 4053e4ab56f9248e9c324cfdbbf5e800d3ff6391..838f8952f45e5858cf60b4ef19117c2b8b32ec85 100644 (file)
@@ -206,12 +206,15 @@ void List<T>::print() const
     currentPtr = firstPtr;
     while (currentPtr)
     {
+       /*
        cout << "aClient: " << *currentPtr->getData() << flush;
 
         if (currentPtr->getData()->stats)
            cout << "  Player Name: " << currentPtr->getData()->stats->name 
                 << "   Password: " << currentPtr->getData()->stats->password << flush;
        cout << endl;
+       */
+       cout << currentPtr->getData()->getString() << endl;
        currentPtr = currentPtr->next;
     }
 }
index ca2e5bdb0598433ee92a2e592d8d97291eff1bbe..ff2b9c6c7bc365803b26b00d35132edb809b62f8 100644 (file)
@@ -17,7 +17,10 @@ void myString::setString(char *s)
 {
     if (!s)
     {
-       ~myString();
+       if (string)
+           delete [] string;
+
+       string = NULL;
     }
     else
     {
index fb4660d9486a9579d96dae7873ccb82d12d5c4a0..dba92522586597bfda137b107d48c3a77346aad1 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef MYSTRING_H
 #define MYSTRING_H
+#include <string.h>
 
 class myString {
 public:
@@ -8,6 +9,7 @@ public:
     void setString(char *s);
     char *getString() { return string; };
     unsigned int len() { return strlen(string); };
+    bool isNULL() { return string == NULL; };
 
 private:
     char *string;
index 939e68f323a85d5f8e759ad28baece258930551d..dd56aafed62ba501f6e22f945c683325bc46ddea 100644 (file)
@@ -97,11 +97,13 @@ int main(int argc, char *argv[])
        delete []conf;
 
     // Turn into a daemon
+
     if (daemon(1,0) < 0)
     {
         perror("Could not turn into a daemon");
         exit(3);
     }
+
   init_masters();
   load_gs_dbase();