]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/Main.qc
fix bugs in last change :)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / Main.qc
index af7787c0fc67797ea1c0c904976be2c996b5f414..fd8afe117c49d2354e0768f3406eabd67b49fdf0 100644 (file)
@@ -4,27 +4,6 @@
 
 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
 
-void cvar_clientsettemp(string cv, string val)
-{
-       entity e;
-       for(e = world; (e = find(e, classname, "saved_cvar_value")); )
-               if(e.netname == cv)
-                       goto saved;
-       e = spawn();
-       e.classname = "saved_cvar_value";
-       e.netname = strzone(cv);
-       e.message = strzone(cvar_string(cv));
-:saved
-       cvar_set(cv, val);
-}
-
-void cvar_clientsettemp_restore()
-{
-       entity e;
-       for(e = world; (e = find(e, classname, "saved_cvar_value")); )
-                       cvar_set(e.netname, e.message);
-}
-
 void menu_show_error()
 {
        drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
@@ -43,7 +22,6 @@ float __engine_check;
 
 void precache_playermodel(string m)
 {
-       float globhandle, i, n;
        string f;
 
        if(substring(m, -9,5) == "_lod1")
@@ -59,6 +37,7 @@ void precache_playermodel(string m)
                precache_model(f);
 
        /*
+       float globhandle, i, n;
        globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
        if (globhandle < 0)
                return;
@@ -116,6 +95,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");
@@ -171,7 +155,9 @@ void CSQC_Init(void)
 
        GetTeam(COLOR_SPECTATOR, true); // add specs first
 
+       // needs to be done so early because of the constants they create
        RegisterWeapons();
+       RegisterGametypes();
 
        WaypointSprite_Load();
 
@@ -229,7 +215,7 @@ void CSQC_Init(void)
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
-void CSQC_Shutdown(void)
+void Shutdown(void)
 {
 #ifdef USE_FTE
 #pragma TARGET id
@@ -250,8 +236,6 @@ void CSQC_Shutdown(void)
                db_save(ClientProgsDB, "client.db");
        db_close(ClientProgsDB);
 
-       cvar_clientsettemp_restore();
-
        if(camera_active)
                cvar_set("chase_active",ftos(chase_active_backup));
 
@@ -542,7 +526,6 @@ void GameCommand(string msg)
        if(argv(0) == "help" || argc == 0)
        {
                print(_("Usage: cl_cmd COMMAND..., where possible commands are:\n"));
-               print(_("  settemp cvar value\n"));
                print(_("  scoreboard_columns_set ...\n"));
                print(_("  scoreboard_columns_help\n"));
                GameCommand_Generic("help");
@@ -564,9 +547,6 @@ void GameCommand(string msg)
                else
                        hud_panel_radar_maximized = (stof(argv(1)) != 0);
        }
-       else if(cmd == "settemp") {
-               cvar_clientsettemp(argv(1), argv(2));
-       }
        else if(cmd == "scoreboard_columns_set") {
                Cmd_HUD_SetFields(argc);
        }
@@ -864,7 +844,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
@@ -898,6 +878,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()
@@ -1067,7 +1049,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
                case ENT_CLIENT_TURRET: ent_turret(); break; 
-               case ENT_CLIENT_MODEL: CSQCModel_Read(); break; 
+               case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break; 
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
@@ -1102,7 +1084,7 @@ void Gamemode_Init()
 {
        if not(isdemo())
        {
-               localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), "\n");
+               localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
                calledhooks |= HOOK_START;
        }
 }
@@ -1138,7 +1120,7 @@ void Ent_ScoresInfo()
 {
        float i;
        self.classname = "ent_client_scores_info";
-       gametype = ReadByte();
+       gametype = ReadInt24_t();
        for(i = 0; i < MAX_SCORE; ++i)
        {
                scores_label[i] = strzone(ReadString());
@@ -1345,7 +1327,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: