]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Game invites
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 07:42:51 +0000 (17:42 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 07:42:51 +0000 (17:42 +1000)
qcsrc/common/mutators/mutator/social.qc
qcsrc/menu/xonotic/serverlist.qc

index 905dfcf9b70ccb118a7fa28dcdaf2f1afb7a85e2..c9b46221355ad661b31f698eee2c02e0161bf9dd 100644 (file)
@@ -3,6 +3,8 @@ REGISTER_MUTATOR(social, true);
 
 void Social_send(int to, string msg);
 
+string Social_invite_accept;
+
 void Social_parse(entity fh, entity pass, int status)
 {
        switch (status) {
@@ -30,6 +32,12 @@ void Social_parse(entity fh, entity pass, int status)
                         print(input, "\n");
                     }
                     break;
+                case "invite": {
+                    string s = url_fgets(fh);
+                    printf("Player %d has invited you to %s; `menu_cmd saccept` to join\n", id, s);
+                    Social_invite_accept = sprintf("\nconnect %s\n", s);
+                    break;
+                }
                        default:
                     printf("Social_parse(): '%s'\n", cmd);
                     break;
@@ -80,6 +88,15 @@ MUTATOR_HOOKFUNCTION(social, GameCommand) {
         Social_send(to, msg);
         return true;
     }
+    if (cmd_name == "sinvite" && cmd_argc == 2) {
+        int to = stoi(argv(1));
+        Social_send(to, sprintf("%s\n%s", "invite", g_server));
+        return true;
+    }
+    if (cmd_name == "saccept") {
+        ServerList_Connect(Social_invite_accept);
+        return true;
+    }
     if (cmd_name == "srecv") {
         Social_recv();
         return true;
index c72db26bbae9ab7c1730bbd2426714772e64352c..e6d6bb35a06f6e569e62aa3a71269f695bd60629 100644 (file)
@@ -66,6 +66,8 @@ CLASS(XonoticServerList, XonoticListBox)
 ENDCLASS(XonoticServerList)
 entity makeXonoticServerList();
 
+string g_server;
+
 #ifndef IMPLEMENTATION
 float autocvar_menu_slist_categories;
 float autocvar_menu_slist_categories_onlyifmultiple;
@@ -948,13 +950,16 @@ void XonoticServerList_resizeNotify(entity me, vector relOrigin, vector relSize,
                me.setSortOrder(me, f, me.currentSortOrder); // force resetting the sort order
        }
 }
+void ServerList_Connect(string s)
+{
+       g_server = s;
+       localcmd(sprintf("connect %s\n", g_server));
+}
 void ServerList_Connect_Click(entity btn, entity me)
 {
-       localcmd(sprintf("connect %s\n",
-               ((me.ipAddressBox.text != "") ?
-                       me.ipAddressBox.text : me.selectedServer
-               )
-       ));
+       ServerList_Connect((me.ipAddressBox.text != "")
+                               ? me.ipAddressBox.text
+                               : me.selectedServer);
 }
 void ServerList_Favorite_Click(entity btn, entity me)
 {