]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'z411/speed_unit' into 'master'
authorterencehill <piuntn@gmail.com>
Sun, 19 Mar 2023 11:07:04 +0000 (11:07 +0000)
committerterencehill <piuntn@gmail.com>
Sun, 19 Mar 2023 11:07:04 +0000 (11:07 +0000)
Make the speed unit a global, consistent setting

Closes #2804

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

1  2 
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/main.qc

index 174426e910b7555069bc8654afb502b1c8cdc397,cd176345fc060fa42b4428902eb3d88a611cf6ea..484968a9c39a20ebf3b380c1d90e98d6b87dbb29
@@@ -169,7 -169,7 +169,7 @@@ bool scoreboard_ui_disabling
  void HUD_Scoreboard_UI_Disable()
  {
        scoreboard_ui_disabling = true;
 -      scoreboard_showscores = false;
 +      sb_showscores = false;
  }
  
  void HUD_Scoreboard_UI_Disable_Instantly()
@@@ -1564,7 -1564,7 +1564,7 @@@ bool Scoreboard_WouldDraw(
                return false;
        else if (HUD_Radar_Clickable())
                return false;
 -      else if (scoreboard_showscores)
 +      else if (sb_showscores) // set by +showscores engine command
                return true;
        else if (intermission == 1)
                return true;
@@@ -2301,10 -2301,7 +2301,10 @@@ void Scoreboard_Draw(
                }
                drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right
                // map name and player count
 -              str = sprintf(_("^5%d^7/^5%d ^7players"), numplayers, srv_maxplayers ? srv_maxplayers : maxclients);
 +              if (campaign)
 +                      str = "";
 +              else
 +                      str = sprintf(_("^5%d^7/^5%d ^7players"), numplayers, srv_maxplayers ? srv_maxplayers : maxclients);
                str = strcat("^7", _("Map:"), " ^2", mi_shortname, "    ", str); // reusing "Map:" translatable string
                drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
        }
  
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
-               string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
+               string unit = GetSpeedUnit(autocvar_hud_speed_unit);
+               float conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
                if(race_speedaward_alltimebest)
                {
                        string name;
                        if(race_speedaward)
                        {
                                name = textShortenToWidth(ColorTranslateRGB(race_speedaward_holder), namesize, hud_fontsize, stringwidth_colors);
-                               str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, name);
+                               str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward * conversion_factor, unit, name);
                                str = strcat(str, " / ");
                        }
                        name = textShortenToWidth(ColorTranslateRGB(race_speedaward_alltimebest_holder), namesize, hud_fontsize, stringwidth_colors);
-                       str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, name));
+                       str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest * conversion_factor, unit, name));
                        drawcolorcodedstring(pos, str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        pos.y += 1.25 * hud_fontsize.y; // line height + line spacing
                }
diff --combined qcsrc/client/main.qc
index 689618fd116712f79ca9bc09191949d7a190e479,8f10bd7574043f95fe64b0751a5461b55eb3eaed..ce7f51e1d9356619f63a09ca14282f72e23fdea2
@@@ -709,6 -709,7 +709,6 @@@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool 
  NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
  {
        make_pure(this);
 -      int i, j, b, f;
  
        int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
  
                strcpy(vote_called_vote, ReadString());
        }
  
 -      if(nags & 1)
 -      {
 -              for(j = 0; j < maxclients; ++j)
 -                      if(playerslots[j])
 -                              playerslots[j].ready = true;
 -              for(i = 1; i <= maxclients; i += 8)
 -              {
 -                      f = ReadByte();
 -                      for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j)
 -                              if (!(f & b))
 -                                      if(playerslots[j])
 -                                              playerslots[j].ready = false;
 -              }
 -      }
 +      if(nags & BIT(0))
 +              for(int i = 0; i < maxclients;)
 +                      for(int f = ReadByte(), b = 0; b < 8 && i < maxclients; ++b, ++i)
 +                              if(playerslots[i])
 +                                      playerslots[i].ready = f & BIT(b);
  
        return = true;
  
@@@ -1244,11 -1254,11 +1244,11 @@@ NET_HANDLE(TE_CSQC_RACE, bool isNew
                        race_server_record = ReadInt24_t();
                        break;
                case RACE_NET_SPEED_AWARD:
-                       race_speedaward = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
+                       race_speedaward = ReadInt24_t();
                        strcpy(race_speedaward_holder, ReadString());
                        break;
                case RACE_NET_SPEED_AWARD_BEST:
-                       race_speedaward_alltimebest = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
+                       race_speedaward_alltimebest = ReadInt24_t();
                        strcpy(race_speedaward_alltimebest_holder, ReadString());
                        break;
                case RACE_NET_RANKINGS_CNT:
@@@ -1394,7 -1404,7 +1394,7 @@@ string GetVersionMessage(string hostver
  
  bool net_handle_ServerWelcome()
  {
 -      bool campaign = ReadByte();
 +      campaign = ReadByte();
        if (campaign)
        {
                string campaign_title = ReadString();