]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
P10 is now functional. The game is playable, but it does not display text nicknames...
[irc/gameservirc.git] / gameserv / gameserv.cpp
index 9a98f4574deddf254a929b1a369b1af3f1bc4b9a..b711e28696e3b0feccbb5d95c65749a9a0cf1234 100644 (file)
@@ -22,6 +22,7 @@ using std::ofstream;
 #endif
 
 List<aClient> players;
+
 Monster *monsters[LEVELS][MONSTERS];   // Monsters per level. Total = MONSTERS * LEVELS
 
 Monster *masters[LEVELS];              // A master for each level
@@ -136,8 +137,12 @@ void gameserv(char *source, char *buf)
     char *cmd;
     cmd = strtok(buf, " ");
 
-    source++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
-    cmd++;    // Get rid of that : at the beginning of the :text  (command)
+    #ifndef P10
+        source++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
+    #endif
+
+    if (cmd[0] == ':')
+        cmd++;    // Get rid of that : at the beginning of the :text  (command)
 
     #ifdef DEBUGMODE
        log("Source: %s  Command: %s", source, cmd);
@@ -195,6 +200,13 @@ 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) {
+       cout << "Printing the clients list:" << endl;
+       clients.print();
+       cout << "\nPrinting the players list:" << endl;
+       players.print();
+    #endif
     } else if (stricmp(cmd, "REGISTER") == 0) {
        do_register(source);
     } else if (stricmp(cmd, "IDENTIFY") == 0) {
@@ -420,11 +432,23 @@ void notice(const char *source, const char *dest, const char *fmt, ...)
     if (dest[0] == ':')
     {
        dest++;
+
+      #if !defined(P10)
        sprintf(input, ":%s NOTICE %s :", source, dest);
+      #else
+       sprintf(input, "%s O %s :", gsnum, dest);
+      #endif
+
        dest--;
     }
     else
+    {
+      #if !defined(P10)
        sprintf(input, ":%s NOTICE %s :", source, dest);
+      #else
+       sprintf(input, "%s O %s :", gsnum, dest);
+      #endif
+    }
 
     for (; *t; t++)
     {
@@ -513,8 +537,9 @@ void do_list(char *u)
 
 void do_register(char *u)
 {
-    char *password;
+    char *password, *name;
     aClient *user, *p;
+    name = strtok(NULL, " ");
     password = strtok(NULL, " ");
 
     static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
@@ -524,9 +549,13 @@ void do_register(char *u)
     salt[1] = saltChars[rand() % strlen(saltChars)];
     salt[2] = '\0';
 
-    if (!password)
+    if (!name)
+    {
+       notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
+    }
+    else if (!password)
     {
-       notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER PASSWORD");
+       notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
     }
     else if ((user = find(u)))
     {
@@ -536,6 +565,7 @@ void do_register(char *u)
            user->stats = new Player(user);
            user->stats->user = user; // Set the backwards pointer
            strcpy(user->stats->password, crypt(password, salt));
+           strcpy(user->stats->name, name);
            players.insertAtBack(user);
            notice(s_GameServ, u, "Player %s registered with password %s.", user->stats->name, password);
            notice(s_GameServ, u, "Write this password down. If you lose it, there is no way to retrieve it!");