]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
audit usage of player_localentnum and spectatee_status to also work with FTEQW
authorRudolf Polzer <divverent@xonotic.org>
Sun, 4 Dec 2011 14:42:03 +0000 (15:42 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 4 Dec 2011 14:42:34 +0000 (15:42 +0100)
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/ctf.qc [deleted file]
qcsrc/client/hud.qc
qcsrc/client/main.qh
qcsrc/client/progs.src
qcsrc/client/scoreboard.qc
qcsrc/client/shownames.qc
qcsrc/client/tturrets.qc
qcsrc/client/waypointsprites.qc

index a1a32404dd48ec7d57bdeb83eca8b624433f58fd..901380c1bb28e130df82c992a1a33a27f289892d 100644 (file)
@@ -28,7 +28,7 @@ entity                world;
 float          time;
 float          frametime;
 
-float          player_localentnum;     //the entnum
+float          player_localentnum;     //the entnum of the VIEW entity
 float          player_localnum;        //the playernum
 float          maxclients;     //a constant filled in by the engine. gah, portability eh?
 
index 90f1fcb334cf55c8813b9e89570e27321f588335..2252f6f61cec427d69ebe63d9a26eca8394955f3 100644 (file)
@@ -67,6 +67,11 @@ void CSQC_Init(void)
 
        float i;
 
+#ifdef COMPAT_XON050_ENGINE
+       // old engine lacks implementation of player_localnum
+       player_localnum = player_localentnum - 1;
+#endif
+
        binddb = db_create();
        tempdb = db_create();
        ClientProgsDB = db_load("client.db");
@@ -806,7 +811,7 @@ void Ent_ClientData()
        if(f & 2)
        {
                newspectatee_status = ReadByte();
-               if(newspectatee_status == player_localentnum)
+               if(newspectatee_status == player_localnum + 1)
                        newspectatee_status = -1; // observing
        }
        else
@@ -840,6 +845,8 @@ void Ent_ClientData()
                        prev_health = -1;
        }
        spectatee_status = newspectatee_status;
+
+       // non-COMPAT_XON050_ENGINE: we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
 }
 
 void Ent_Nagger()
@@ -1286,7 +1293,7 @@ void Net_ReadRace()
                                strunzone(grecordholder[pos-1]);
                        grecordholder[pos-1] = strzone(ReadString());
                        grecordtime[pos-1] = ReadInt24_t();
-                       if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
+                       if(grecordholder[pos-1] == GetPlayerName(player_localnum))
                                race_myrank = pos;
                        break;
                case RACE_NET_SERVER_STATUS:
index ca9841b53293760a08bef6df2d4a72369ddc8327..d9f6df7ee77281fdf2e52b650d25680dec5f72a9 100644 (file)
@@ -371,6 +371,7 @@ void CSQC_UpdateView(float w, float h)
        vector v;
        vector vf_size, vf_min;
        float a;
+
        hud = getstati(STAT_HUD);
 
        if(checkextension("DP_CSQC_MINFPS_QUALITY"))
@@ -407,9 +408,11 @@ void CSQC_UpdateView(float w, float h)
 
        WaypointSprite_Load();
 
+#ifdef COMPAT_XON050_ENGINE
        if(spectatee_status)
                myteam = GetPlayerColor(spectatee_status - 1);
        else
+#endif
                myteam = GetPlayerColor(player_localentnum - 1);
 
        ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
diff --git a/qcsrc/client/ctf.qc b/qcsrc/client/ctf.qc
deleted file mode 100644 (file)
index 5bf6639..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-#ifdef CTF_EXAMPLE
-
-// NOTE: This file contains lots of debugging stuff
-// it is not really used... can be seen as another sample...
-
-string STR_PLAYER = "player";
-#define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; )
-
-string ctf_temp_1;
-float order_page;
-
-void menu_close()
-{
-       menu_visible = false;
-       menu_show = menu_show_error;
-       menu_action = menu_sub_null;
-       
-       /*if(ctf_temp_1)
-         strunzone(ctf_temp_1);*/
-       
-       localcmd("\nin_bindmap 0 0;");
-}
-
-void order_menu_render()
-{
-       vector ps, po;
-       float i, p, n;
-       string frags, color;
-       ps = '0 200 0';
-       po = '0 8 0';
-
-       color = getplayerkeyvalue(player_localentnum-1, "topcolor");
-       
-       if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
-               drawstring(ps, _("----- Order Menu -----"), '8 8 0', '1 1 0', 1, 0); ps += po;
-               drawstring(ps, sprintf(_("Order: %s"), ctf_temp_1), '8 8 0', '1 1 0', 1, 0); ps += po;
-               drawcolorcodedstring(ps, _("1) ^3previous page"), '8 8 0', 1, 0); ps += po;
-               drawcolorcodedstring(ps, _("2) ^3next page"), '8 8 0', 1, 0); ps += po;
-               for((n = 2), (p = i = 0); i < maxclients && n > 0; ++i) {
-                       frags = getplayerkeyvalue(i, "frags");
-                       if(!frags || (i+1) == player_localentnum)
-                               continue;
-                       if(frags == "-666" || getplayerkeyvalue(i, "topcolor") != color) // FIXME use GetPlayerTeam
-                               continue;
-                       ++p;
-                       if(p > (8*order_page))
-                       {
-                               // only render current page
-                               ++n;
-                               if(n == 10)
-                                       n = 0;
-                               drawcolorcodedstring(ps, strcat(ftos(n), ") ", GetPlayerName(i), " : ", ftos(getstatf(STAT_CTF_STATE))), '8 8 0', 1, 0); ps += po;
-                       }
-               }
-               drawstring(ps, _("ESC) Exit Menu"), '8 8 0', '1 1 0', 1, 0); ps += po;
-       } else {
-               menu_close();
-       }
-}
-
-float order_menu_action(float bInputType, float nPrimary, float nSecondary)
-{
-       string arg;
-       float p, i, n, chose;
-       string frags, color;
-       if(bInputType != 0) // key down wanted
-               return FALSE;
-       
-       arg = chr2str(nSecondary);
-       chose = stof(chr2str(nPrimary));
-       //str2chr
-       if(arg == "1") {
-               color = getplayerkeyvalue(player_localentnum-1, "topcolor");
-               ++order_page;
-               for(p = i = 0; i < maxclients; ++i) {
-                       frags = getplayerkeyvalue(i, "frags");
-                       if(!frags || (i+1) == player_localentnum)
-                               continue;
-                       if(frags == "-666" || getplayerkeyvalue(i, "topcolor") != color) // FIXME use GetPlayerTeam
-                               continue;
-                       ++p;
-               }
-               if(p <= (8*order_page)) // no ppl on page
-                       order_page = 0;
-       } else if(arg == "2") {
-               color = getplayerkeyvalue(player_localentnum-1, "topcolor");
-               --order_page;
-               if(order_page < 0) {
-                       for(p = i = 0; i < maxclients; ++i) {
-                               frags = getplayerkeyvalue(i, "frags");
-                               if(!frags || (i+1) == player_localentnum)
-                                       continue;
-                               if(frags == "-666" || getplayerkeyvalue(i, "topcolor") != color) // FIXME use GetPlayerTeam
-                                       continue;
-                               ++p;
-                       }
-                       order_page = floor(p/8);
-               }
-       } else if(chose >= 3 && chose <= 9 || arg == "0") { // the 10 needs extra checking, assuming that stof(astring) returns 0
-               if(chose == 0)
-                       chose = 10;
-               n = 2;
-               color = getplayerkeyvalue(player_localentnum-1, "topcolor");
-               for(p = i = 0; i < maxclients && n > 0; ++i) {
-                       frags = getplayerkeyvalue(i, "frags");
-                       if(!frags || (i+1) == player_localentnum)
-                               continue;
-                       if(frags == "-666" || getplayerkeyvalue(i, "topcolor") != color) // FIXME use GetPlayerTeam
-                               continue;
-                       ++p;
-                       if(p > (8*order_page))
-                       {
-                               // only render current page
-                               ++n;
-                               if(n == chose) {
-                                       n = 0;
-                                       break;
-                               }
-                       }
-               }
-               if(n == 0) {
-                       //print(sprintf(_("Issuing order to: %d\n"), i+1));
-                       //print(strcat("cmd order #", ftos(i+1), " ", ctf_temp_1, ";\n"));
-                       localcmd(strcat("\ncmd order #", ftos(i+1), " ", ctf_temp_1, ";"));
-               } else {
-                       print(sprintf(_("Couldn't find player %d\n"), chose));
-               }
-               return TRUE;
-       } else if(nSecondary == K_ESCAPE) {
-               strunzone(ctf_temp_1);
-               menu_close();
-       } else {
-               //print(sprintf(_("Menu action %s does not exist.\n"), arg));
-               return FALSE;
-       }
-       return TRUE;
-}
-
-void order_menu_show()
-{
-       order_page = 0;
-       menu_show = order_menu_render;
-       menu_action = order_menu_action;
-}
-
-
-void ctf_menu_render()
-{
-       vector ps, po;
-       ps = '0 200 0';
-       po = '0 8 0';
-       
-       if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
-               drawstring(ps, _("----- Command Menu -----"), '8 8 0', '1 1 0', 1, 0); ps += po;
-               drawstring(ps, _("Issue orders:"), '8 8 0', '1 1 0', 1, 0); ps += po;
-               drawstring(ps, _(" 1) Attack"), '8 8 0', '1 1 0', 1, 0);
-               drawstring(ps + '80 0 0', " \x0F", '8 8 0', '1 1 1', 1, 0); ps += po;
-               drawstring(ps, strcat(_(" 2) Defend"), " \x0E"), '8 8 0', '1 1 0', 1, 0); ps += po;
-               ps += po;
-               drawstring(ps, _("3) Resign from command."), '8 8 0', '1 1 0', 1, 0); ps += po;
-               drawstring(ps, _("ESC) Exit Menu"), '8 8 0', '1 1 0', 1, 0); ps += po;
-       } else {
-               menu_close();
-       }
-}
-
-float ctf_menu_action(float bInputType, float nPrimary, float nSecondary)
-{
-       string arg;
-       if(bInputType != 0) // key down wanted
-               return FALSE;
-       
-       arg = chr2str(nSecondary);
-
-       if(arg == "1") {
-               ctf_temp_1 = strzone("attack");
-               order_menu_show();
-       } else if(arg == "2") {
-               ctf_temp_1 = strzone("defend");
-               order_menu_show();
-       } else if(arg == "3") {
-               localcmd("\ncmd order resign;");
-               menu_close();
-       } else if(nSecondary == K_ESCAPE) {
-               menu_close();
-       } else {
-               //print(strcat("Menu action ", arg, " does not exist.\n"));
-               return FALSE;
-       }
-       return TRUE;
-}
-
-void ctf_menu_show()
-{
-       if(getstati(STAT_CTF_STATE) < 0)
-               return;
-       menu_show = ctf_menu_render;
-       menu_action = ctf_menu_action;
-       menu_visible = TRUE;
-       //menu_default_binds();
-}
-
-void ctf_view()
-{
-       float stat;
-       stat = getstati(STAT_CTF_STATE);
-       if(stat == CTF_STATE_ATTACK) {
-               drawpic('0 0 0', "gfx/ctf_ic_atk.tga", '64 64 0', '1 1 1', 1, 0);
-       } else if(stat == CTF_STATE_DEFEND) {
-               drawpic('0 0 0', "gfx/ctf_ic_def.tga", '64 64 0', '1 1 1', 1, 0);
-       } else if(stat == CTF_STATE_COMMANDER) {
-               drawstring('0 0 0', _("You're commander!"), '8 8 0', '1 1 1', 1, 0);
-       } else if(stat < 0) {
-       } else {
-               drawstring('0 0 0', _("Awaiting orders..."), '8 8 0', '1 1 1', 0.5, 0);
-       }
-}
-
-#endif
index e2cdbab6ff2a6a0a9d4aeec96e88ff8b3e471430..86b49761e5ca59cd34e978073f82e79ad9ddf395 100644 (file)
@@ -2694,7 +2694,11 @@ void HUD_Score(void)
        string sign;
        vector distribution_color;
        entity tm, pl, me;
+#ifdef COMPAT_XON050_ENGINE
        me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
+#else
+       me = playerslots[player_localentnum - 1];
+#endif
 
        if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
                string timer, distrtimer;
@@ -3569,7 +3573,7 @@ void HUD_Mod_Race(vector pos, vector mySize)
 {
        mod_active = 1; // race should never hide the mod icons panel
        entity me;
-       me = playerslots[player_localentnum - 1];
+       me = playerslots[player_localnum];
        float t, score;
        float f; // yet another function has this
        score = me.(scores[ps_primary]);
@@ -3677,7 +3681,7 @@ void HUD_Mod_Race(vector pos, vector mySize)
                drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
        } else if(race_status == 2) {
-               if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
+               if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
                        drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                else
                        drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
@@ -4123,7 +4127,11 @@ void HUD_InfoMessages(void)
                        if(spectatee_status == -1)
                                s = _("^1Observing");
                        else
+#ifdef COMPAT_XON050_ENGINE
                                s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
+#else
+                               s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
+#endif
                        drawInfoMessage(s)
 
                        if(spectatee_status == -1)
@@ -4146,7 +4154,7 @@ void HUD_InfoMessages(void)
                        else if(gametype == GAME_LMS)
                        {
                                entity sk;
-                               sk = playerslots[player_localentnum - 1];
+                               sk = playerslots[player_localnum];
                                if(sk.(scores[ps_primary]) >= 666)
                                        s = _("^1Match has already begun");
                                else if(sk.(scores[ps_primary]) > 0)
@@ -4885,7 +4893,11 @@ void HUD_Main (void)
                        drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
        }
 
+#ifdef COMPAT_XON050_ENGINE
     current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
+#else
+    current_player = player_localentnum;
+#endif
 
        // draw the dock
        if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
index 499e84b6ee0aa0b88a6c51372adf5b3ffe348e18..bd9ffe64c58967841650baf971d1ec65fbad948f 100644 (file)
@@ -17,14 +17,6 @@ float menu_visible;
 var void() menu_show;
 var float(float bInputType, float nPrimary, float nSecondary) menu_action;
 
-// --------------------------------------------------------------------------
-// CTF
-
-#ifdef CTF_EXAMPLE
-void() ctf_menu_show;
-string ctf_temp_1;
-#endif
-
 // --------------------------------------------------------------------------
 // Onslaught
 
index a4d8b70b1c4e3cf9c83e0ac98a27e1049bf495ca..06b3e8b7b751469e5d126a7aeb22bb9f3cb8e552 100644 (file)
@@ -42,8 +42,6 @@ sortlist.qc
 miscfunctions.qc
 teamplay.qc
 
-ctf.qc
-
 teamradar.qc
 hud_config.qc
 hud.qc
index d4c2043e6c66fb05c99ab17090b82a702492d7af..3124b4b9b4d68056f968c4ca87f15c993edf8c99 100644 (file)
@@ -894,7 +894,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team != tm.team)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
+                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -903,7 +903,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team == COLOR_SPECTATOR)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
+                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -1147,7 +1147,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
                        continue;
                n = grecordholder[i];
                p = race_PlaceName(i+1);
-               if(grecordholder[i] == GetPlayerName(player_localentnum - 1))
+               if(grecordholder[i] == GetPlayerName(player_localnum))
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
                else if(!mod(i, 2) && scoreboard_highlight)
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
@@ -1296,7 +1296,7 @@ void HUD_DrawScoreboard()
                if(pl.team != COLOR_SPECTATOR)
                        continue;
                pos_y += 1.25 * hud_fontsize_y;
-               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
+               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), specs);
                ++specs;
        }
 
index 21e8bcd420799ac3688e938abcefcc780cf67fd4..d5e24888d34a79e03d2de8db4a8c19ca22c8219f 100644 (file)
@@ -13,7 +13,11 @@ void Draw_ShowNames(entity ent)
        if(!autocvar_hud_shownames)
                return;
        
+#ifdef COMPAT_XON050_ENGINE
        if((ent.sv_entnum == player_localentnum) || (ent.sv_entnum == spectatee_status)) // ent is me or person i'm spectating
+#else
+       if(ent.sv_entnum == player_localentnum) // ent is me or person i'm spectating
+#endif
                if not (autocvar_hud_shownames_self && autocvar_chase_active) 
                        return;
 
index f4a53ca199563b18495dce544fce2af04a7537df..89f1be7fa826d008d2cf2795408a3385ee37e375 100644 (file)
@@ -264,7 +264,7 @@ void turret_draw2d()
         return;
 
        string spriteimage = self.netname;
-       float t = (GetPlayerColor(player_localentnum - 1) + 1); 
+       float t = (GetPlayerColor(player_localnum) + 1);        
        float a = self.alpha * autocvar_hud_panel_fg_alpha;
        vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
 
index ac85f8c65638bfda0385f1a7718cfe35ba4c998f..6d9b0ee8bd7fee0f2112cf77686f6a25111dce6b 100644 (file)
@@ -403,7 +403,7 @@ void Draw_WaypointSprite()
 
        InterpolateOrigin_Do();
 
-       t = GetPlayerColor(player_localentnum - 1) + 1;
+       t = GetPlayerColor(player_localnum) + 1;
 
        spriteimage = "";