]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/ctf.qc
Merge remote branch 'origin/master' into terencehill/centerprint_stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / ctf.qc
index 8c0844b2246f26107bfccc482bfaed52909f65ce..8e93ab44a1aa13a6b7a5c994b409142277b27b34 100644 (file)
@@ -49,7 +49,7 @@ float ctf_captureshield_shielded(entity p)
 
        // player is in the worse half, if >= half the players are better than him, or consequently, if < half of the players are worse
        // use this rule here
-       
+
        if(players_worseeq >= players_total * captureshield_max_ratio)
                return FALSE;
 
@@ -66,12 +66,12 @@ void ctf_captureshield_update(entity p, float dir)
                {
                        if(should)
                        {
-                               centerprint_atprio(p, CENTERPRIO_SHIELDING, "^3You are now ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Make some defensive scores before trying again.");
+                               Send_CSQC_Centerprint_Generic(other, CPID_CTF_CAPTURESHIELD, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.", 5, 0);
                                // TODO csqc notifier for this
                        }
                        else
                        {
-                               centerprint_atprio(p, CENTERPRIO_SHIELDING, "^3You are now free.\n\n^3Feel free to ^1try to capture^3 the flag again\n^3if you think you will succeed.");
+                               Send_CSQC_Centerprint_Generic(p, CPID_CTF_CAPTURESHIELD, "^3You are now free.\n\n^3Feel free to ^1try to capture^3 the flag again\n^3if you think you will succeed.", 5, 0);
                                // TODO csqc notifier for this
                        }
                        p.ctf_captureshielded = should;
@@ -88,6 +88,7 @@ float ctf_captureshield_customize()
        return TRUE;
 }
 
+.float ctf_captureshield_touch_msgtime;
 void ctf_captureshield_touch()
 {
        if not(other.ctf_captureshielded)
@@ -99,7 +100,9 @@ void ctf_captureshield_touch()
        mymid = (self.absmin + self.absmax) * 0.5;
        othermid = (other.absmin + other.absmax) * 0.5;
        Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * captureshield_force);
-       centerprint_atprio(other, CENTERPRIO_SHIELDING, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.");
+       if (time - other.ctf_captureshield_touch_msgtime > 2)
+               Send_CSQC_Centerprint_Generic(other, CPID_CTF_CAPTURESHIELD, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.", 5, 0);
+       other.ctf_captureshield_touch_msgtime = time;
 }
 
 void ctf_flag_spawnstuff()
@@ -125,15 +128,9 @@ void ctf_flag_spawnstuff()
        self.basewaypoint = self.nearestwaypoint;
 
        if(self.team == COLOR_TEAM1)
-       {
-               WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 61', self, sprite);
-               WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM1 - 1, FALSE));
-       }
+               WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 61', self, sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM1 - 1, FALSE));
        else
-       {
-               WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 61', self, sprite);
-               WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM2 - 1, FALSE));
-       }
+               WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 61', self, sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM2 - 1, FALSE));
 }
 
 float ctf_score_value(string parameter)
@@ -150,7 +147,7 @@ void FakeTimeLimit(entity e, float t)
        WriteByte(MSG_ONE, 3); // svc_updatestat
        WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT
        if(t < 0)
-               WriteCoord(MSG_ONE, cvar("timelimit"));
+               WriteCoord(MSG_ONE, autocvar_timelimit);
        else
                WriteCoord(MSG_ONE, (t + 1) / 60);
 }
@@ -171,14 +168,9 @@ void place_flag()
                return;
        }
 
-       if(!self.t_width)
-               self.t_width = 0.1; // frame animation rate
-       if(!self.t_length)
-               self.t_length = 58; // maximum frame
-
        setattachment(self, world, "");
        self.mdl = self.model;
-       self.flags = FL_ITEM;
+       self.flags = FL_ITEM | FL_NOTARGET;
        self.solid = SOLID_TRIGGER;
        self.movetype = MOVETYPE_NONE;
        self.velocity = '0 0 0';
@@ -206,7 +198,7 @@ void place_flag()
 void LogCTF(string mode, float flagteam, entity actor)
 {
        string s;
-       if(!cvar("sv_eventlog"))
+       if(!autocvar_sv_eventlog)
                return;
        s = strcat(":ctf:", mode);
        s = strcat(s, ":", ftos(flagteam));
@@ -239,7 +231,7 @@ void RegenFlag(entity e)
        e.angles = e.mangle;
        e.cnt = FLAG_BASE;
        e.owner = world;
-       e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
+       e.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND and any other junk
 };
 
 void ReturnFlag(entity e)
@@ -301,11 +293,11 @@ void DropFlag(entity e, entity penalty_receiver, entity attacker)
        ctf_captureshield_update(p, 0); // shield only
        e.playerid = attacker.playerid;
        e.ctf_droptime = time;
-       WaypointSprite_Spawn("flagdropped", 0, 0, e, '0 0 1' * 61, world, COLOR_TEAM1 + COLOR_TEAM2 - e.team, e, waypointsprite_attachedforcarrier, FALSE);
+       WaypointSprite_Spawn("flagdropped", 0, 0, e, '0 0 1' * 61, world, COLOR_TEAM1 + COLOR_TEAM2 - e.team, e, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAG, '0 1 1');
+       WaypointSprite_Ping(e.waypointsprite_attachedforcarrier);
        
        if(p.waypointsprite_attachedforcarrier)
        {
-               WaypointSprite_Ping(p.waypointsprite_attachedforcarrier);
                WaypointSprite_DetachCarrier(p);
        }
        else
@@ -314,24 +306,24 @@ void DropFlag(entity e, entity penalty_receiver, entity attacker)
                backtrace("Flag carrier had no flag sprite?!?");
        }
        LogCTF("dropped", p.team, p);
-       sound (self, CHAN_TRIGGER, self.noise4, VOL_BASE, ATTN_NONE);
+       sound (p, CH_TRIGGER, self.noise4, VOL_BASE, ATTN_NONE);
 
        setattachment(e, world, "");
-       e.damageforcescale = cvar("g_balance_ctf_damageforcescale");
+       e.damageforcescale = autocvar_g_balance_ctf_damageforcescale;
        e.takedamage = DAMAGE_YES;
 
        if (p.flagcarried == e)
                p.flagcarried = world;
        e.owner = world;
 
-       e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
+       e.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND and any other junk
        e.solid = SOLID_TRIGGER;
        e.movetype = MOVETYPE_TOSS;
        // setsize(e, '-16 -16 0', '16 16 74');
        setorigin(e, p.origin - '0 0 24' + '0 0 37');
        e.cnt = FLAG_DROPPED;
        e.velocity = '0 0 300';
-       e.pain_finished = time + cvar("g_ctf_flag_returntime");//30;
+       e.pain_finished = time + autocvar_g_ctf_flag_returntime;//30;
 
        trace_startsolid = FALSE;
        tracebox(e.origin, e.mins, e.maxs, e.origin, TRUE, e);
@@ -339,19 +331,6 @@ void DropFlag(entity e, entity penalty_receiver, entity attacker)
                dprint("FLAG FALLTHROUGH will happen SOON\n");
 };
 
-void AnimateFlag()
-{
-       if(self.delay > time)
-               return;
-       self.delay = time + self.t_width;
-       if(self.nextthink > self.delay)
-               self.nextthink = self.delay;
-
-       self.frame = self.frame + 1;
-       if(self.frame > self.t_length)
-               self.frame = 0;
-}
-
 void FlagThink()
 {
        local entity e;
@@ -373,8 +352,6 @@ void FlagThink()
                        ctf_captureshield_update(e, 1); // release shield only
        }
 
-       AnimateFlag();
-
        if(self.speedrunning)
        if(self.cnt == FLAG_CARRY)
        {
@@ -384,7 +361,7 @@ void FlagThink()
                {
                        bprint("The ", self.netname, " became impatient after ", ftos_decimals(flagcaptimerecord, 2), " seconds and returned itself\n");
 
-                       sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
+                       sound (self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTN_NONE);
                        self.owner.impulse = 141; // returning!
 
                        e = self;
@@ -411,7 +388,7 @@ void FlagThink()
                if (time > self.pain_finished)
                {
                        bprint("The ", self.netname, " has returned to base\n");
-                       sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
+                       sound (self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTN_NONE);
                        LogCTF("returned", self.team, world);
                        ReturnFlag(self);
                }
@@ -425,12 +402,18 @@ void FlagThink()
                DropFlag(self, world, world);
                return;
        }
-
-       if(cvar("g_ctf_allow_drop"))
-       if(e.BUTTON_USE)
-               DropFlag(self, e, world);
 };
 
+float ctf_usekey()
+{
+       if(self.flagcarried)
+       {
+               DropFlag(self.flagcarried, self, world);
+               return TRUE;
+       }
+       return FALSE;
+}
+
 void flag_cap_ring_spawn(vector org)
 {
        shockwave_spawn("models/ctf/shockwavetransring.md3", org - '0 0 15', -0.8, 0, 1);
@@ -460,7 +443,7 @@ void FlagTouch()
                {
                        return;
                }
-               if(cvar("g_ctf_captimerecord_always") || player_count - currentbots <= 1) // at most one human
+               if(autocvar_g_ctf_captimerecord_always || player_count - currentbots <= 1) // at most one human
                {
                        t = time - other.flagcarried.flagpickuptime;
                        s = ftos_decimals(t, 2);
@@ -502,7 +485,7 @@ void FlagTouch()
                // give credit to the individual player
                UpdateFrags(other, ctf_score_value("score_capture"));
 
-               if (cvar("g_ctf_flag_capture_effects")) {
+               if (autocvar_g_ctf_flag_capture_effects) {
                        if (other.team == COLOR_TEAM1) { // red team scores effect
                                pointparticles(particleeffectnum("red_ground_quake"), self.origin, '0 0 0', 1);
                                flag_cap_ring_spawn(self.origin);
@@ -513,7 +496,7 @@ void FlagTouch()
                        }
                }
 
-               sound (other, CHAN_AUTO, self.noise2, VOL_BASE, ATTN_NONE);
+               sound (other, CH_TRIGGER, self.noise2, VOL_BASE, ATTN_NONE);
                WaypointSprite_DetachCarrier(other);
                if(self.speedrunning)
                        FakeTimeLimit(other, -1);
@@ -529,10 +512,10 @@ void FlagTouch()
        {
                if (other.next_take_time > time)
                        return;
-                       
-               if (cvar("g_ctf_flag_pickup_effects")) // pickup effect
+
+               if (autocvar_g_ctf_flag_pickup_effects) // pickup effect
                        pointparticles(particleeffectnum("smoke_ring"), 0.5 * (self.absmin + self.absmax), '0 0 0', 1);
-                       
+
                // pick up
                self.flagpickuptime = time; // used for timing runs
                self.speedrunning = other.speedrunning; // if speedrunning, flag will self-return and teleport the owner back after the record
@@ -551,7 +534,7 @@ void FlagTouch()
                self.dropperid = other.playerid;
                PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
                LogCTF("steal", self.team, other);
-               sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
+               sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
 
                FOR_EACH_PLAYER(player)
                        if(player.team == self.team)
@@ -560,8 +543,7 @@ void FlagTouch()
                self.movetype = MOVETYPE_NONE;
                setorigin(self, FLAG_CARRY_POS);
                setattachment(self, other, "");
-               WaypointSprite_AttachCarrier("flagcarrier", other);
-               WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
+               WaypointSprite_AttachCarrier("flagcarrier", other, RADARICON_FLAGCARRIER, '1 1 0');
                WaypointSprite_Ping(self.sprite);
 
                return;
@@ -569,7 +551,7 @@ void FlagTouch()
 
        if (self.cnt == FLAG_DROPPED)
        {
-               self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
+               self.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND and any other junk
                if (other.team == self.team || (other.team != COLOR_TEAM1 && other.team != COLOR_TEAM2))
                {
                        // return flag
@@ -607,17 +589,17 @@ void FlagTouch()
                        }
                        PlayerScore_Add(other, SP_CTF_RETURNS, 1);
                        LogCTF("return", self.team, other);
-                       sound (other, CHAN_AUTO, self.noise1, VOL_BASE, ATTN_NONE);
+                       sound (other, CH_TRIGGER, self.noise1, VOL_BASE, ATTN_NONE);
                        ReturnFlag(self);
                }
-               else if (!other.flagcarried && (other.playerid != self.dropperid || time > self.ctf_droptime + cvar("g_balance_ctf_delay_collect")))
+               else if (!other.flagcarried && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_balance_ctf_delay_collect))
                {
                        if(self.waypointsprite_attachedforcarrier)
                                WaypointSprite_DetachCarrier(self);
 
-                       if (cvar("g_ctf_flag_pickup_effects")) // field pickup effect
+                       if (autocvar_g_ctf_flag_pickup_effects) // field pickup effect
                                pointparticles(particleeffectnum("smoke_ring"), 0.5 * (self.absmin + self.absmax), '0 0 0', 1);
-                       
+
                        // pick up
                        self.solid = SOLID_NOT;
                        setorigin(self, self.origin); // relink
@@ -628,7 +610,7 @@ void FlagTouch()
                        //bprint(other.netname, "^7 picked up the ", self.netname, "\n");
 
                        float f;
-                       f = bound(0, (self.pain_finished - time) / cvar("g_ctf_flag_returntime"), 1);
+                       f = bound(0, (self.pain_finished - time) / autocvar_g_ctf_flag_returntime, 1);
                        //print("factor is ", ftos(f), "\n");
                        f = ctf_score_value("score_pickup_dropped_late") * (1-f)
                          + ctf_score_value("score_pickup_dropped_early") * f;
@@ -639,7 +621,7 @@ void FlagTouch()
                        UpdateFrags(other, f);
                        PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
                        LogCTF("pickup", self.team, other);
-                       sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
+                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
 
                        FOR_EACH_PLAYER(player)
                                if(player.team == self.team)
@@ -650,8 +632,7 @@ void FlagTouch()
                        setattachment(self, other, "");
                        self.damageforcescale = 0;
                        self.takedamage = DAMAGE_NO;
-                       WaypointSprite_AttachCarrier("flagcarrier", other);
-                       WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
+                       WaypointSprite_AttachCarrier("flagcarrier", other, RADARICON_FLAGCARRIER, '1 1 0');
                }
        }
 };
@@ -747,7 +728,7 @@ void item_flag_postspawn()
 { // Check CTF Item Flag Post Spawn
 
        // Flag Glow Trail Support
-       if(cvar("g_ctf_flag_glowtrails"))
+       if(autocvar_g_ctf_flag_glowtrails)
        { // Provide Flag Glow Trail
                if(self.team == COLOR_TEAM1)
                        // Red
@@ -756,7 +737,7 @@ void item_flag_postspawn()
                if(self.team == COLOR_TEAM2)
                        // Blue
                        self.glow_color = 210;
-                       
+
                self.glow_size = 25;
                self.glow_trail = 1;
        }
@@ -795,9 +776,6 @@ void spawnfunc_item_flag_team1()
                return;
        }
 
-       //if(!cvar("teamplay"))
-       //      cvar_set("teamplay", "3");
-
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
        ctf_worldflaglist = self;
@@ -815,11 +793,11 @@ void spawnfunc_item_flag_team1()
        }
        self.netname = "^1RED^7 flag";
        self.target = "###item###";
-       self.skin = cvar("g_ctf_flag_red_skin");
+       self.skin = autocvar_g_ctf_flag_red_skin;
        if(self.spawnflags & 1)
                self.noalign = 1;
        if (!self.model)
-               self.model = cvar_string("g_ctf_flag_red_model");
+               self.model = autocvar_g_ctf_flag_red_model;
        if (!self.noise)
                self.noise = "ctf/red_taken.wav";
        if (!self.noise1)
@@ -849,9 +827,9 @@ void spawnfunc_item_flag_team1()
        //      self.glow_size = 50;
 
        self.effects = self.effects | EF_LOWPRECISION;
-       if(cvar("g_ctf_fullbrightflags"))
+       if(autocvar_g_ctf_fullbrightflags)
                self.effects |= EF_FULLBRIGHT;
-       if(cvar("g_ctf_dynamiclights"))
+       if(autocvar_g_ctf_dynamiclights)
                self.effects |= EF_RED;
 
        // From Spidflisk
@@ -895,8 +873,6 @@ void spawnfunc_item_flag_team2()
                remove(self);
                return;
        }
-       //if(!cvar("teamplay"))
-       //      cvar_set("teamplay", "3");
 
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
@@ -915,11 +891,11 @@ void spawnfunc_item_flag_team2()
        }
        self.netname = "^4BLUE^7 flag";
        self.target = "###item###";
-       self.skin = cvar("g_ctf_flag_blue_skin");
+       self.skin = autocvar_g_ctf_flag_blue_skin;
        if(self.spawnflags & 1)
                self.noalign = 1;
        if (!self.model)
-               self.model = cvar_string("g_ctf_flag_blue_model");
+               self.model = autocvar_g_ctf_flag_blue_model;
        if (!self.noise)
                self.noise = "ctf/blue_taken.wav";
        if (!self.noise1)
@@ -949,9 +925,9 @@ void spawnfunc_item_flag_team2()
        //      self.glow_size = 50;
 
        self.effects = self.effects | EF_LOWPRECISION;
-       if(cvar("g_ctf_fullbrightflags"))
+       if(autocvar_g_ctf_fullbrightflags)
                self.effects |= EF_FULLBRIGHT;
-       if(cvar("g_ctf_dynamiclights"))
+       if(autocvar_g_ctf_dynamiclights)
                self.effects |= EF_BLUE;
 
        // From Spidflisk
@@ -1030,9 +1006,14 @@ void ctf_init()
        InitializeEntity(world, ctf_delayedinit, INITPRIO_GAMETYPE);
        flagcaptimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
 
-       captureshield_min_negscore = cvar("g_ctf_shield_min_negscore");
-       captureshield_max_ratio = cvar("g_ctf_shield_max_ratio");
-       captureshield_force = cvar("g_ctf_shield_force");
+       captureshield_min_negscore = autocvar_g_ctf_shield_min_negscore;
+       captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
+       captureshield_force = autocvar_g_ctf_shield_force;
+
+
+//#NO AUTOCVARS START
+       g_ctf_win_mode = cvar("g_ctf_win_mode");
+//#NO AUTOCVARS END
 };
 
 void ctf_setstatus2(entity flag, float shift)
@@ -1058,42 +1039,40 @@ void ctf_setstatus()
        self.items &~= IT_BLUE_FLAG_LOST;
        self.items &~= IT_CTF_SHIELDED;
 
-       if (g_ctf) {
-               local entity flag;
-               float redflags, blueflags;
+       local entity flag;
+       float redflags, blueflags;
 
-               if(self.ctf_captureshielded)
-                       self.items |= IT_CTF_SHIELDED;
+       if(self.ctf_captureshielded)
+               self.items |= IT_CTF_SHIELDED;
 
-               redflags = 0;
-               blueflags = 0;
+       redflags = 0;
+       blueflags = 0;
 
-               for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
-               {
-                       if(flag.items & IT_KEY2) // blue
-                               ++redflags;
-                       else if(flag.items & IT_KEY1) // red
-                               ++blueflags;
-               }
+       for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
+       {
+               if(flag.items & IT_KEY2) // blue
+                       ++redflags;
+               else if(flag.items & IT_KEY1) // red
+                       ++blueflags;
+       }
 
-               // blinking magic: if there is more than one flag, show one of these in a clever way
-               if(redflags)
-                       redflags = mod(floor(time * redflags * 0.75), redflags);
-               if(blueflags)
-                       blueflags = mod(floor(time * blueflags * 0.75), blueflags);
+       // blinking magic: if there is more than one flag, show one of these in a clever way
+       if(redflags)
+               redflags = mod(floor(time * redflags * 0.75), redflags);
+       if(blueflags)
+               blueflags = mod(floor(time * blueflags * 0.75), blueflags);
 
-               for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
+       for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
+       {
+               if(flag.items & IT_KEY2) // blue
                {
-                       if(flag.items & IT_KEY2) // blue
-                       {
-                               if(--redflags == -1) // happens exactly once (redflags is in 0..count-1, and will --'ed count times)
-                                       ctf_setstatus2(flag, IT_RED_FLAG_TAKEN);
-                       }
-                       else if(flag.items & IT_KEY1) // red
-                       {
-                               if(--blueflags == -1) // happens exactly once
-                                       ctf_setstatus2(flag, IT_BLUE_FLAG_TAKEN);
-                       }
+                       if(--redflags == -1) // happens exactly once (redflags is in 0..count-1, and will --'ed count times)
+                               ctf_setstatus2(flag, IT_RED_FLAG_TAKEN);
+               }
+               else if(flag.items & IT_KEY1) // red
+               {
+                       if(--blueflags == -1) // happens exactly once
+                               ctf_setstatus2(flag, IT_BLUE_FLAG_TAKEN);
                }
        }
 };
@@ -1103,7 +1082,7 @@ entity(float cteam) ctf_team_has_commander =
        entity pl;
        if(cteam != COLOR_TEAM1 || cteam != COLOR_TEAM2)
                return world;
-       
+
        FOR_EACH_REALPLAYER(pl) {
                if(pl.team == cteam && pl.iscommander) {
                        return pl;
@@ -1121,7 +1100,7 @@ void(entity e, float st) ctf_setstate =
 void(float cteam) ctf_new_commander =
 {
        entity pl, plmax;
-       
+
        plmax = world;
        FOR_EACH_REALPLAYER(pl) {
                if(pl.team == cteam) {
@@ -1146,14 +1125,14 @@ void(float cteam) ctf_new_commander =
 void() ctf_clientconnect =
 {
        self.iscommander = FALSE;
-       
+
        if(!self.team || self.classname != "player") {
                ctf_setstate(self, -1);
        } else
                ctf_setstate(self, 0);
 
        self.team_saved = self.team;
-       
+
        if(self.team != 0 && self.classname == "player" && !ctf_team_has_commander(self.team)) {
                ctf_new_commander(self.team);
        }
@@ -1178,9 +1157,9 @@ void() ctf_playerchanged =
                        ctf_setstate(self, -1);
                ctf_new_commander(self.team_saved);
        }
-       
+
        self.team_saved = self.team;
-       
+
        ctf_new_commander(self.team);
 };