From: TimePath Date: Wed, 26 Aug 2015 07:42:51 +0000 (+1000) Subject: Game invites X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cf5ab00ede186b406765bc34cdcf1efc7bd92731;p=xonotic%2Fxonotic-data.pk3dir.git Game invites --- diff --git a/qcsrc/common/mutators/mutator/social.qc b/qcsrc/common/mutators/mutator/social.qc index 905dfcf9b..c9b462213 100644 --- a/qcsrc/common/mutators/mutator/social.qc +++ b/qcsrc/common/mutators/mutator/social.qc @@ -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; diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index c72db26bb..e6d6bb35a 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -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) {