]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port allowed_timeouts and active_minigame to ClientStatus, also fix a CS() call after...
authorMario <mario@smbclan.net>
Sat, 15 Jul 2017 21:26:46 +0000 (07:26 +1000)
committerMario <mario@smbclan.net>
Sat, 15 Jul 2017 21:26:46 +0000 (07:26 +1000)
qcsrc/common/minigames/sv_minigames.qc
qcsrc/common/models/all.inc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/common.qc
qcsrc/server/command/vote.qc
qcsrc/server/player.qc

index 033a524fb3cf896b7c26e928a3634cb75637b625..4f1cd5dc2d9975bff6419159559e7ece0f3cf2e4 100644 (file)
@@ -3,7 +3,7 @@
 
 void player_clear_minigame(entity player)
 {
-       player.active_minigame = NULL;
+       CS(player).active_minigame = NULL;
        player.minigame_players = NULL;
        if ( IS_PLAYER(player) )
                set_movetype(player, MOVETYPE_WALK);
@@ -124,11 +124,11 @@ bool minigame_CheckSend(entity this, entity client)
 
 int minigame_addplayer(entity minigame_session, entity player)
 {
-       if ( player.active_minigame )
+       if ( CS(player).active_minigame )
        {
-               if ( player.active_minigame == minigame_session )
+               if ( CS(player).active_minigame == minigame_session )
                        return 0;
-               minigame_rmplayer(player.active_minigame,player);
+               minigame_rmplayer(CS(player).active_minigame,player);
        }
        entity player_pointer = new(minigame_player);
        int mgteam = minigame_session.minigame_event(minigame_session,"join",player,player_pointer);
@@ -140,7 +140,7 @@ int minigame_addplayer(entity minigame_session, entity player)
                player_pointer.team = mgteam;
                player_pointer.list_next = minigame_session.minigame_players;
                minigame_session.minigame_players = player_pointer;
-               player.active_minigame = minigame_session;
+               CS(player).active_minigame = minigame_session;
                player.minigame_players = player_pointer;
                setcefc(player_pointer, minigame_CheckSend);
                Net_LinkEntity(player_pointer, false, 0, minigame_SendEntity);
@@ -215,7 +215,7 @@ entity join_minigame(entity player, string game_id )
 
 void part_minigame(entity player )
 {
-       entity minig = player.active_minigame;
+       entity minig = CS(player).active_minigame;
 
        if ( minig && minig.classname == "minigame" )
                minigame_rmplayer(minig,player);
@@ -262,19 +262,19 @@ void end_minigames()
 
 string invite_minigame(entity inviter, entity player)
 {
-       if ( !inviter || !inviter.active_minigame )
+       if ( !inviter || !CS(inviter).active_minigame )
                return "Invalid minigame";
        if ( VerifyClientEntity(player, true, false) <= 0 )
                return "Invalid player";
        if ( inviter == player )
                return "You can't invite yourself";
-       if ( player.active_minigame == inviter.active_minigame )
+       if ( CS(player).active_minigame == CS(inviter).active_minigame )
                return strcat(player.netname," is already playing");
 
        Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_MINIGAME_INVITE,
-               inviter.active_minigame.netname, inviter.netname );
+               CS(inviter).active_minigame.netname, inviter.netname );
 
-       GameLogEcho(strcat(":minigame:invite:",inviter.active_minigame.netname,":",
+       GameLogEcho(strcat(":minigame:invite:",CS(inviter).active_minigame.netname,":",
                ftos(etof(player)),":",player.netname));
 
        return "";
@@ -282,10 +282,10 @@ string invite_minigame(entity inviter, entity player)
 
 entity minigame_find_player(entity client)
 {
-       if ( ! client.active_minigame )
+       if ( ! CS(client).active_minigame )
                return NULL;
        entity e;
-       for ( e = client.active_minigame.minigame_players; e; e = e.list_next )
+       for ( e = CS(client).active_minigame.minigame_players; e; e = e.list_next )
                if ( e.minigame_players == client )
                        return e;
        return NULL;
@@ -293,11 +293,11 @@ entity minigame_find_player(entity client)
 
 bool MinigameImpulse(entity this, int imp)
 {
-       if (!this.active_minigame) return false;
+       if (!CS(this).active_minigame) return false;
        entity e = minigame_find_player(this);
-       if ( imp && this.active_minigame && e )
+       if ( imp && CS(this).active_minigame && e )
        {
-               return this.active_minigame.minigame_event(this.active_minigame,"impulse",e,imp);
+               return CS(this).active_minigame.minigame_event(CS(this).active_minigame,"impulse",e,imp);
        }
        return false;
 }
@@ -350,7 +350,7 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command
                }
                else if ( minig_cmd == "end" || minig_cmd == "part" )
                {
-                       if ( caller.active_minigame )
+                       if ( CS(caller).active_minigame )
                        {
                                part_minigame(caller);
                                sprint(caller,"Left minigame session\n");
@@ -361,14 +361,14 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command
                }
                else if ( minig_cmd == "invite" && argc > 2 )
                {
-                       if ( caller.active_minigame )
+                       if ( CS(caller).active_minigame )
                        {
                                entity client = GetIndexedEntity(argc, 2);
                                string error = invite_minigame(caller,client);
                                if ( error == "" )
                                {
                                        sprint(caller,"You have invited ",client.netname,
-                                               " to join your game of ", caller.active_minigame.descriptor.message, "\n");
+                                               " to join your game of ", CS(caller).active_minigame.descriptor.message, "\n");
                                }
                                else
                                        sprint(caller,"Could not invite: ", error, ".\n");
@@ -377,12 +377,12 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command
                                sprint(caller,"You aren't playing any minigame...\n");
                        return;
                }
-               else if ( caller.active_minigame )
+               else if ( CS(caller).active_minigame )
                {
                        entity e = minigame_find_player(caller);
                        string subcommand = substring(command,argv_end_index(0),-1);
                        int arg_c = tokenize_console(subcommand);
-                       if ( caller.active_minigame.minigame_event(caller.active_minigame,"cmd",e,arg_c,subcommand) )
+                       if ( CS(caller).active_minigame.minigame_event(CS(caller).active_minigame,"cmd",e,arg_c,subcommand) )
                                return;
 
                }
index f47d8e7c5afdd76ea2ce79630d28a11e4ee608e6..eb95d7c28260d2a81ad306a1a37b00c97b4802ca 100644 (file)
@@ -335,6 +335,7 @@ MODEL(VEH_SPIDERBOT_TOP,                "models/vehicles/spiderbot_top.dpm");
 MODEL(VEH_SPIDERBOT_VIEW,               "models/vehicles/spiderbot_cockpit.dpm");
 
 MODEL(CHAT,                             "models/misc/chatbubble.spr");
+MODEL(CHAT_MINIGAME,                    "models/sprites/minigame_busy.iqm");
 
 MODEL(0,                                "models/sprites/0.spr32");
 MODEL(1,                                "models/sprites/1.spr32");
index b1059ca49f523a26e99cbd296f9fc3a7f370b25e..296e8c03f26f612beb71f8c4c3de11dad7a8f6f1 100644 (file)
@@ -1229,7 +1229,7 @@ void ClientConnect(entity this)
        }
 
        CS(this).jointime = time;
-       this.allowed_timeouts = autocvar_sv_timeout_number;
+       CS(this).allowed_timeouts = autocvar_sv_timeout_number;
 
        if (IS_REAL_CLIENT(this))
        {
@@ -1286,7 +1286,7 @@ void ClientDisconnect(entity this)
 
        PlayerStats_GameReport_FinalizePlayer(this);
        if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE);
-       if (this.active_minigame) part_minigame(this);
+       if (CS(this).active_minigame) part_minigame(this);
        if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
 
        if (autocvar_sv_eventlog)
@@ -1299,6 +1299,7 @@ void ClientDisconnect(entity this)
 
     MUTATOR_CALLHOOK(ClientDisconnect, this);
 
+       if (CS(this).netname_previous) strunzone(CS(this).netname_previous); // needs to be before the CS entity is removed!
        ClientState_detach(this);
 
        Portal_ClearAll(this);
@@ -1318,7 +1319,6 @@ void ClientDisconnect(entity this)
 
        bot_relinkplayerlist();
 
-       if (CS(this).netname_previous) strunzone(CS(this).netname_previous);
        if (this.clientstatus) strunzone(this.clientstatus);
        if (this.weaponorder_byimpulse) strunzone(this.weaponorder_byimpulse);
        if (this.personal) delete(this.personal);
@@ -1345,7 +1345,7 @@ void ChatBubbleThink(entity this)
 
        if ( !IS_DEAD(this.owner) && IS_PLAYER(this.owner) )
        {
-               if ( this.owner.active_minigame )
+               if ( CS(this.owner).active_minigame )
                        this.mdl = "models/sprites/minigame_busy.iqm";
                else if (PHYS_INPUT_BUTTON_CHAT(this.owner))
                        this.mdl = "models/misc/chatbubble.spr";
index 660cb7c1e4e1af82e44687e74f7609b3628d8d6c..b6f3abd69f6e1155194e31bf19f6bf81297ed472 100644 (file)
@@ -85,6 +85,8 @@ CLASS(Client, Object)
     ATTRIB(Client, spectatortime, float, this.spectatortime);
     ATTRIB(Client, version_nagtime, float, this.version_nagtime);
     ATTRIB(Client, netname_previous, string, this.netname_previous);
+    ATTRIB(Client, allowed_timeouts, int, this.allowed_timeouts);
+    ATTRIB(Client, active_minigame, entity, this.active_minigame);
 
     METHOD(Client, m_unwind, bool(Client this));
 
index 936858ce46158ffb232b8974e2a25fb6aa1d3829..84366ea6b27b72b9f65e6fc5c6bab97090465e48 100644 (file)
@@ -721,7 +721,7 @@ void CommonCommand_timeout(float request, entity caller)  // DEAR GOD THIS COMMA
                                {
                                        print_to(caller, "^7Error: You can not call a timeout while the map is being restarted.");
                                }
-                               else if (caller && (caller.allowed_timeouts < 1))
+                               else if (caller && (CS(caller).allowed_timeouts < 1))
                                {
                                        print_to(caller, "^7Error: You already used all your timeout calls for this map.");
                                }
@@ -736,9 +736,9 @@ void CommonCommand_timeout(float request, entity caller)  // DEAR GOD THIS COMMA
 
                                else  // everything should be okay, proceed with starting the timeout
                                {
-                                       if (caller)   caller.allowed_timeouts -= 1;
+                                       if (caller)   CS(caller).allowed_timeouts -= 1;
                                        // write a bprint who started the timeout (and how many they have left)
-                                       bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n");
+                                       bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(CS(caller).allowed_timeouts), " timeout(s) left)") : ""), "!\n");
 
                                        timeout_status = TIMEOUT_LEADTIME;
                                        timeout_caller = caller;
index f8ab3a44032996e91509bf1603d434f12dca52ed..fda3adc409d5515ea355d3059b1228a51d68b156 100644 (file)
@@ -456,7 +456,7 @@ void ReadyRestart_force()
        // after a restart every players number of allowed timeouts gets reset, too
        if (autocvar_sv_timeout)
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(it.allowed_timeouts = autocvar_sv_timeout_number));
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(CS(it).allowed_timeouts = autocvar_sv_timeout_number));
        }
     // reset map immediately if this cvar is not set
     if (!autocvar_sv_ready_restart_after_countdown) reset_map(true);
index 2ee4960654c2e99a641751b2b06812c152ef1f10..e3201c4e50769dcc5f949320ee52a57f43ec629d 100644 (file)
@@ -994,11 +994,11 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                                        centerprint(privatesay, cmsgstr);
                        }
                }
-               else if ( teamsay && source.active_minigame )
+               else if ( teamsay && CS(source).active_minigame )
                {
                        sprint(source, sourcemsgstr);
                        dedicated_print(msgstr); // send to server console too
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr));
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && CS(it).active_minigame == CS(source).active_minigame && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr));
                }
                else if(teamsay > 0) // team message, only sent to team mates
                {