]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a temp entity to avoid linking kh_controller to the world with setmodel
authorterencehill <piuntn@gmail.com>
Mon, 20 Feb 2023 18:09:12 +0000 (19:09 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 20 Feb 2023 18:09:12 +0000 (19:09 +0100)
qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc

index eaed7508981f2598b05ee4792276e9f4d63cd917..1553bf5b4bc90f5f1319ae98a24519cac7108733 100644 (file)
@@ -979,27 +979,24 @@ void kh_Initialize()  // sets up th KH environment
                kh_teams = cvar("g_keyhunt_teams"); // read the cvar directly as it gets written earlier in the same frame
        kh_teams = BITS(bound(2, kh_teams, 4));
 
-       // make a KH entity for controlling the game
-       kh_controller = new_pure(kh_controller);
-       setthink(kh_controller, kh_Controller_Think);
-       kh_Controller_SetThink(0, kh_WaitForPlayers);
+       // use a temp entity to avoid linking kh_controller to the world with setmodel
+       entity tmp_ent = spawn();
+       setmodel(tmp_ent, MDL_KH_KEY);
+       kh_key_dropped = tmp_ent.modelindex;
 
-       setmodel(kh_controller, MDL_KH_KEY);
-       kh_key_dropped = kh_controller.modelindex;
-       /*
-       dprint(vtos(kh_controller.mins));
-       dprint(vtos(kh_controller.maxs));
-       dprint("\n");
-       */
 #ifdef KH_PLAYER_USE_CARRIEDMODEL
-       setmodel(kh_controller, MDL_KH_KEY_CARRIED);
-       kh_key_carried = kh_controller.modelindex;
+       setmodel(tmp_ent, MDL_KH_KEY_CARRIED);
+       kh_key_carried = tmp_ent.modelindex;
 #else
        kh_key_carried = kh_key_dropped;
 #endif
 
-       kh_controller.model = "";
-       kh_controller.modelindex = 0;
+       delete(tmp_ent);
+
+       // make a KH entity for controlling the game
+       kh_controller = new_pure(kh_controller);
+       setthink(kh_controller, kh_Controller_Think);
+       kh_Controller_SetThink(0, kh_WaitForPlayers);
 
        kh_ScoreRules(kh_teams);
 }