]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merged master.
authorLyberta <lyberta@lyberta.net>
Sat, 5 Aug 2017 09:57:41 +0000 (12:57 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 5 Aug 2017 09:57:41 +0000 (12:57 +0300)
1  2 
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/sv_cmd.qc
qcsrc/server/player.qc

diff --combined qcsrc/server/client.qc
index 513a79678075668f3753857df65fd0716ee1a961,14b854bc6eb5f35cc279db18b12bf70634b45d94..e255174c008c32fb715ef65de6cee1d98ac3fa33
@@@ -151,7 -151,7 +151,7 @@@ void ClientData_Touch(entity e
        CS(e).clientdata.SendFlags = 1;
  
        // make it spectatable
-       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, LAMBDA(CS(it).clientdata.SendFlags = 1));
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, { CS(it).clientdata.SendFlags = 1; });
  }
  
  void SetSpectatee(entity this, entity spectatee);
@@@ -267,9 -267,7 +267,9 @@@ void PutObserverInServer(entity this
        if (mutator_returnvalue) {
            // mutator prevents resetting teams+score
        } else {
 +              int oldteam = this.team;
                this.team = -1;  // move this as it is needed to log the player spectating in eventlog
 +              MUTATOR_CALLHOOK(Player_ChangedTeam, this, oldteam, this.team);
          this.frags = FRAGS_SPECTATOR;
          PlayerScore_Clear(this);  // clear scores when needed
      }
@@@ -661,7 -659,7 +661,7 @@@ void PutPlayerInServer(entity this
        target_voicescript_clear(this);
  
        // reset fields the weapons may use
-       FOREACH(Weapons, true, LAMBDA(
+       FOREACH(Weapons, true, {
                it.wr_resetplayer(it, this);
                        // reload all reloadable weapons
                if (it.spawnflags & WEP_FLAG_RELOADABLE) {
                                this.(weaponentity).weapon_load[it.m_id] = it.reloading_ammo;
                        }
                }
-       ));
+       });
  
        {
                string s = spot.target;
@@@ -893,10 -891,8 +893,10 @@@ void ClientKill_Now(entity this
        if(CS(this).killindicator_teamchange)
                ClientKill_Now_TeamChange(this);
  
 -      if(!IS_SPEC(this) && !IS_OBSERVER(this))
 +      if (!IS_SPEC(this) && !IS_OBSERVER(this) && MUTATOR_CALLHOOK(ClientKill_Now, this) == false)
 +      {
                Damage(this, this, this, 100000, DEATH_KILL.m_id, this.origin, '0 0 0');
 +      }
  
        // now I am sure the player IS dead
  }
@@@ -2013,13 -2009,13 +2013,13 @@@ int nJoinAllowed(entity this, entity ig
        // TODO simplify this
        int totalClients = 0;
        int currentlyPlaying = 0;
-       FOREACH_CLIENT(true, LAMBDA(
+       FOREACH_CLIENT(true, {
                if(it != ignore)
                        ++totalClients;
                if(IS_REAL_CLIENT(it))
                if(IS_PLAYER(it) || it.caplayer)
                        ++currentlyPlaying;
-       ));
+       });
  
        float free_slots = 0;
        if (!autocvar_g_maxplayers)
diff --combined qcsrc/server/client.qh
index dff602b9c4868581e83cd99d07563f5793ffea23,ee00c60ca6f97f4603c1572ec34099a1cb800e46..2928aae1c927bd5685acd4f576b629719c14a953
@@@ -148,7 -148,7 +148,7 @@@ CLASS(Spectator, Client
  ENDCLASS(Spectator)
  
  CLASS(Player, Client)
-     
      // custom
  
      ATTRIB(Player, dual_weapons, vector, this.dual_weapons); // TODO: actually WepSet!
@@@ -189,6 -189,8 +189,6 @@@ METHOD(Client, m_unwind, bool(Client th
      return false;
  }
  
 -float c1, c2, c3, c4;
 -
  void play_countdown(entity this, float finished, Sound samp);
  
  float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit);
index dba41cc9cee11d5897f58d569ff60695000b3878,0bc47c0acf67fcdb2d81234429b5ef1a585a7836..4687403d2a0006124861a204f9e8914bf8081244
@@@ -193,11 -193,11 +193,11 @@@ void GameCommand_allspec(float request
                {
                        string reason = argv(1);
                        int n = 0;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
                                if (it.caplayer) it.caplayer = 0;
                                PutObserverInServer(it);
                                ++n;
-                       ));
+                       });
                        if (n)   bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n"));
                        else   LOG_INFO("No players found to spectate.\n");
                        return;
@@@ -563,11 -563,11 +563,11 @@@ void GameCommand_defer_clear_all(float 
                        int n = 0;
                        float argc;
  
-                       FOREACH_CLIENT(true, LAMBDA(
+                       FOREACH_CLIENT(true, {
                                argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
                                GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc);
                                ++n;
-                       ));
+                       });
                        if (n)   LOG_INFO(strcat("Successfully stuffed defer clear to all clients (", ftos(n), ")\n"));  // should a message be added if no players were found?
                        return;
                }
@@@ -1091,15 -1091,9 +1091,15 @@@ void GameCommand_moveplayer(float reque
  
                                                                // If so, lets continue and finally move the player
                                                                client.team_forced = 0;
 -                                                              MoveToTeam(client, team_id, 6);
 -                                                              successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
 -                                                              LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.\n");
 +                                                              if (MoveToTeam(client, team_id, 6))
 +                                                              {
 +                                                                      successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
 +                                                                      LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.\n");
 +                                                              }
 +                                                              else
 +                                                              {
 +                                                                      LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ")");
 +                                                              }
                                                                continue;
                                                        }
                                                        else
@@@ -1147,13 -1141,13 +1147,13 @@@ void GameCommand_nospectators(float req
                {
                        blockSpectators = 1;
                        // give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, LAMBDA(
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
                                if(!it.caplayer)
                                {
                                        CS(it).spectatortime = time;
                                        Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
                                }
-                       ));
+                       });
                        bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
                        return;
                }
@@@ -1351,7 -1345,7 +1351,7 @@@ void GameCommand_shuffleteams(float req
                                return;
                        }
  
-                       FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, LAMBDA(
+                       FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
                                if (it.team_forced) {
                                        // we could theoretically assign forced players to their teams
                                        // and shuffle the rest to fill the empty spots but in practise
                                        LOG_INFO("Can't shuffle teams because at least one player has a forced team.\n");
                                        return;
                                }
-                       ));
+                       });
  
                        int number_of_teams = 0;
                        CheckAllowedTeams(NULL);
                        if (c4 >= 0) number_of_teams = max(4, number_of_teams);
  
                        int team_index = 0;
-                       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, LAMBDA(
+                       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
                                int target_team_number = Team_NumberToTeam(team_index + 1);
                                if (it.team != target_team_number) MoveToTeam(it, target_team_number, 6);
                                team_index = (team_index + 1) % number_of_teams;
-                       ));
+                       });
  
                        bprint("Successfully shuffled the players around randomly.\n");
                        return;
@@@ -1737,32 -1731,32 +1737,32 @@@ SERVER_COMMAND(warp, "Choose different 
  
  void GameCommand_macro_help()
  {
-       FOREACH(SERVER_COMMANDS, true, LAMBDA(LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description)));
+       FOREACH(SERVER_COMMANDS, true, { LOG_INFOF("  ^2%s^7: %s\n", it.m_name, it.m_description); });
  }
  
  float GameCommand_macro_command(float argc, string command)
  {
        string c = strtolower(argv(0));
-       FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(SERVER_COMMANDS, it.m_name == c, {
                it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
                return true;
-       ));
+       });
        return false;
  }
  
  float GameCommand_macro_usage(float argc)
  {
        string c = strtolower(argv(1));
-       FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA(
+       FOREACH(SERVER_COMMANDS, it.m_name == c, {
                it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
                return true;
-       ));
+       });
        return false;
  }
  
  void GameCommand_macro_write_aliases(float fh)
  {
-       FOREACH(SERVER_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description)));
+       FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
  }
  
  
diff --combined qcsrc/server/player.qc
index cd6c23edb2f764ec325af110c56c55a598ac2294,d70210feab5b3726645b74706ca34afebcaa4131..e41bf931b7cf1d1402fcf74aedad0aca9d4193f7
@@@ -235,10 -235,10 +235,10 @@@ void calculate_player_respawn_time(enti
        float pcount = 1;  // Include myself whether or not team is already set right and I'm a "player".
        if (teamplay)
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
                        if(it.team == this.team)
                                ++pcount;
-               ));
+               });
                if (sdelay_small_count == 0)
                        sdelay_small_count = 1;
                if (sdelay_large_count == 0)
        }
        else
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
                        ++pcount;
-               ));
+               });
                if (sdelay_small_count == 0)
                {
                        if (IS_INDEPENDENT_PLAYER(this))
@@@ -667,19 -667,15 +667,19 @@@ void PlayerDamage(entity this, entity i
        }
  }
  
 -void MoveToTeam(entity client, int team_colour, int type)
 +bool MoveToTeam(entity client, int team_colour, int type)
  {
        int lockteams_backup = lockteams;  // backup any team lock
        lockteams = 0;  // disable locked teams
        TeamchangeFrags(client);  // move the players frags
 -      SetPlayerColors(client, team_colour - 1);  // set the players colour
 +      if (!SetPlayerTeamSimple(client, team_colour))
 +      {
 +              return false;
 +      }
        Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE.m_id, client.origin, '0 0 0');  // kill the player
        lockteams = lockteams_backup;  // restore the team lock
        LogTeamchange(client.playerid, client.team, type);
 +      return true;
  }
  
  /** print(), but only print if the server is not local */