]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'marin-t/fix' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 12 Aug 2019 10:54:26 +0000 (10:54 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 12 Aug 2019 10:54:26 +0000 (10:54 +0000)
Fix for hash change

See merge request xonotic/xonotic-data.pk3dir!678

qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh
qcsrc/common/t_items.qc
qcsrc/lib/counting.qh
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/sv_cmd.qh
qcsrc/server/command/vote.qc
qcsrc/server/constants.qh

index 4105f7ce8c53cc14eb544a5c7df59cedb484f4fe..0a8370899dea2bce50728c5f674b623240e446e9 100644 (file)
@@ -505,3 +505,9 @@ MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
        // most weapons arena
        if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "") M_ARGV(0, string) = "most";
 }
+
+MUTATOR_HOOKFUNCTION(ca, SV_ParseServerCommand)
+{
+       shuffleteams_on_reset_map = !allowed_to_spawn;
+       return false;
+}
index c4755feee9a32e9560a27321698fb0fdf0e6a99d..e383687fcf44dd2ed3a69efa5b4c357e1e91e746 100644 (file)
@@ -3,6 +3,7 @@
 #include <common/mutators/base.qh>
 #include <server/round_handler.qh>
 #include <server/miscfunctions.qh>
+#include <server/command/sv_cmd.qh>
 
 int autocvar_g_ca_point_limit;
 int autocvar_g_ca_point_leadlimit;
index c42c7443ba252a997d778f9c731132a292bc3857..2dfcf48112447ad1a5411a60b3c5f925e567b3b2 100644 (file)
@@ -361,7 +361,9 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
                        Unfreeze(frag_target, true);
                freezetag_count_alive_players();
-               return true; // let the player die so that he can respawn whenever he wants
+               frag_target.respawn_time = time;
+               frag_target.respawn_flags |= RESPAWN_FORCE;
+               return true;
        }
 
        // Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
@@ -608,6 +610,12 @@ MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(ft, SV_ParseServerCommand)
+{
+       shuffleteams_on_reset_map = !(round_handler_IsActive() && !round_handler_IsRoundStarted());
+       return false;
+}
+
 void freezetag_Initialize()
 {
        freezetag_teams = autocvar_g_freezetag_teams_override;
index d637ae46f6a52f934f2d806adc5c1cdb49334098..df138a93d84f011bf29a51f2cf6135872773e0bb 100644 (file)
@@ -1,6 +1,8 @@
 #pragma once
 
 #include <common/mutators/base.qh>
+#include <server/command/sv_cmd.qh>
+
 int autocvar_g_freezetag_point_limit;
 int autocvar_g_freezetag_point_leadlimit;
 bool autocvar_g_freezetag_team_spawns;
index 466b38311214c20d0aa66baefa1a7d35fcf93c98..a6b3f45ce80632e91b33d45dde7ae924bcad11e4 100644 (file)
@@ -927,6 +927,9 @@ void Item_Touch(entity this, entity toucher)
 
 LABEL(pickup)
 
+       if(this.target && this.target != "" && this.target != "###item###") // defrag support
+               SUB_UseTargets(this, toucher, NULL);
+
        STAT(LAST_PICKUP, toucher) = time;
 
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
@@ -1314,7 +1317,11 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                        || (def.instanceOfHealth && def != ITEM_HealthSmall)
                        || (def.instanceOfArmor && def != ITEM_ArmorSmall)
                        || (itemid & (IT_KEY1 | IT_KEY2))
-               ) this.target = "###item###"; // for finding the nearest item using findnearest
+               ) 
+               {
+                       if(!this.target || this.target == "")
+                               this.target = "###item###"; // for finding the nearest item using findnearest
+               }
 
                Item_ItemsTime_SetTime(this, 0);
        }
index b38ba9d05a9313f670f8fa8bdeede09c565ebf2c..c084b5efe3a417b557202228d2b19ad98bf06a41 100644 (file)
@@ -61,6 +61,7 @@
        _("CI_THI^%d seconds"), /* third */ \
        _("CI_MUL^%d seconds")) /* multi */
 
+// returns 1st, 2nd, 3rd, nth ordinal number from a cardinal number (integer)
 ERASEABLE
 string count_ordinal(int interval)
 {
@@ -68,23 +69,20 @@ string count_ordinal(int interval)
        // to accomodate all languages unless we do a specific function for each one...
        // and since that's not technically feasible/practical, this is all we've got folks.
 
-       // Basically, it just allows you to represent a number or count in different ways
-       // depending on the number... like, with count_ordinal you can provide integers
-       // and retrieve 1st, 2nd, 3rd, nth ordinal numbers in a clean and simple way.
-       if (floor((interval % 100) / 10) * 10 != 10)  // examples: 12th, 111th, 213th will not execute this block
+       int last2digits = interval % 100;
+
+       // numbers ending with 11, 12 and 13 don't follow the standard pattern
+       if (last2digits < 4 || last2digits > 20)
        {
-               // otherwise, check normally for 1st,2nd,3rd insertions
-               switch (interval % 10)
+               switch (last2digits % 10)
                {
                        case 1: return sprintf(_("%dst"), interval);
                        case 2: return sprintf(_("%dnd"), interval);
                        case 3: return sprintf(_("%drd"), interval);
-                       default: return sprintf(_("%dth"), interval);
                }
        }
-       else { return sprintf(_("%dth"), interval); }
 
-       return "";
+       return sprintf(_("%dth"), interval);
 }
 
 ERASEABLE
index e8fc1b13f1bbd5b5e897060ebd402ae5eec457da..5ff2d3472ae22ebbf2d3d898e0ecbd5f4ae4c910 100644 (file)
@@ -1274,50 +1274,61 @@ void GameCommand_setbots(int request, int argc)
        }
 }
 
+void shuffleteams()
+{
+       if (!teamplay)
+       {
+               LOG_INFO("Can't shuffle teams when currently not playing a team game.");
+               return;
+       }
+
+       FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
+               if (Player_HasRealForcedTeam(it)) {
+                       // we could theoretically assign forced players to their teams
+                       // and shuffle the rest to fill the empty spots but in practise
+                       // either all players or none are gonna have forced teams
+                       LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
+                       return;
+               }
+       });
+
+       int number_of_teams = 0;
+       entity balance = TeamBalance_CheckAllowedTeams(NULL);
+       for (int i = 1; i <= NUM_TEAMS; ++i)
+       {
+               if (TeamBalance_IsTeamAllowed(balance, i))
+               {
+                       number_of_teams = max(i, number_of_teams);
+               }
+       }
+       TeamBalance_Destroy(balance);
+
+       int team_index = 0;
+       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
+               int target_team_index = team_index + 1;
+               if (Entity_GetTeamIndex(it) != target_team_index)
+               {
+                       MoveToTeam(it, target_team_index, 6);
+               }
+               team_index = (team_index + 1) % number_of_teams;
+       });
+
+       bprint("Successfully shuffled the players around randomly.\n");
+}
+
 void GameCommand_shuffleteams(int request)
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if (!teamplay)
+                       if (shuffleteams_on_reset_map)
                        {
-                               LOG_INFO("Can't shuffle teams when currently not playing a team game.");
-                               return;
+                               bprint("Players will be shuffled when this round is over.\n");
+                               shuffleteams_on_reset_map = true;
                        }
-
-                       FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
-                               if (Player_HasRealForcedTeam(it)) {
-                                       // we could theoretically assign forced players to their teams
-                                       // and shuffle the rest to fill the empty spots but in practise
-                                       // either all players or none are gonna have forced teams
-                                       LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
-                                       return;
-                               }
-                       });
-
-                       int number_of_teams = 0;
-                       entity balance = TeamBalance_CheckAllowedTeams(NULL);
-                       for (int i = 1; i <= NUM_TEAMS; ++i)
-                       {
-                               if (TeamBalance_IsTeamAllowed(balance, i))
-                               {
-                                       number_of_teams = max(i, number_of_teams);
-                               }
-                       }
-                       TeamBalance_Destroy(balance);
-
-                       int team_index = 0;
-                       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
-                               int target_team_index = team_index + 1;
-                               if (Entity_GetTeamIndex(it) != target_team_index)
-                               {
-                                       MoveToTeam(it, target_team_index, 6);
-                               }
-                               team_index = (team_index + 1) % number_of_teams;
-                       });
-
-                       bprint("Successfully shuffled the players around randomly.\n");
+                       else
+                               shuffleteams();
                        return;
                }
 
index 00e216c921855757b9a5aa87c23cfe5362fdbf9b..bf0dafa9cfffe0698723624f29088e4fc2c37c74 100644 (file)
@@ -4,6 +4,9 @@
 //  Declarations for server side game commands
 // =================================================
 
+bool shuffleteams_on_reset_map;
+void shuffleteams();
+
 string GotoMap(string m);
 
 void race_deleteTime(string map, float pos);
index 51cf55ce3a1de3ee3c83cc027348ae803f7e072e..d79c2418d7adec421473ee7534ea01b9fe553c8c 100644 (file)
@@ -345,6 +345,11 @@ void reset_map(bool dorespawn)
                        round_handler_Reset(game_starttime);
        }
 
+       if (shuffleteams_on_reset_map)
+       {
+               shuffleteams();
+               shuffleteams_on_reset_map = false;
+       }
        MUTATOR_CALLHOOK(reset_map_global);
 
        FOREACH_ENTITY_FLOAT_ORDERED(pure_data, false,
index f98d586fb504cf389b764fb704360713d5a2148f..62a15f680c1cb8117c68385a5f6e4119a50c16d3 100644 (file)
@@ -10,9 +10,9 @@ const int FL_PICKUPITEMS = BIT(19);
 
 const int SVC_SETVIEW = 5;
 
-const int RESPAWN_FORCE = 1;
-const int RESPAWN_SILENT = 2;
-const int RESPAWN_DENY = 4;
+const int RESPAWN_FORCE = BIT(0);
+const int RESPAWN_SILENT = BIT(1);
+const int RESPAWN_DENY = BIT(2);
 
 #define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT)