]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Ping pong
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 01:38:05 +0000 (11:38 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 01:38:05 +0000 (11:38 +1000)
qcsrc/common/mutators/mutator/social.qc

index 7ee332d266918a5866c4141dd328f077054e20ff..905dfcf9b70ccb118a7fa28dcdaf2f1afb7a85e2 100644 (file)
@@ -1,6 +1,8 @@
 #ifdef MENUQC
 REGISTER_MUTATOR(social, true);
 
+void Social_send(int to, string msg);
+
 void Social_parse(entity fh, entity pass, int status)
 {
        switch (status) {
@@ -16,19 +18,30 @@ void Social_parse(entity fh, entity pass, int status)
                    if (first == "") return;
                    int id = stoi(first);
                    printf("from player %d:\n", id);
-                       for (string input; (input = url_fgets(fh)); ) {
-                               print(input, "\n");
-                       }
+                   string cmd = url_fgets(fh);
+                   switch (cmd) {
+                       case "ping":
+                           Social_send(id, "pong");
+                       case "pong":
+                           printf("Player %d is online\n", id);
+                           break;
+                       case "msg":
+                           for (string input; (input = url_fgets(fh)); ) {
+                        print(input, "\n");
+                    }
+                    break;
+                       default:
+                    printf("Social_parse(): '%s'\n", cmd);
+                    break;
+                   }
                        url_fclose(fh);
                        break;
                }
                case URL_READY_CLOSED: break;
                case URL_READY_ERROR:
                default:
-               {
                        printf("Social_parse(): %s\n", ftos(status));
                        break;
-               }
        }
 }