DEADSOFTWARE

game: fix playermodel forcing
authorTerminalHash <lyashuk.voxx@gmail.com>
Wed, 26 Apr 2023 10:44:48 +0000 (13:44 +0300)
committerTerminalHash <lyashuk.voxx@gmail.com>
Wed, 26 Apr 2023 10:44:48 +0000 (13:44 +0300)
picked from https://github.com/Challenge9/doom2d-forever/commit/9575d93ae18fb2e7295fe44376f3621959a6463b
because the fork contains many changes that prevent the patch from being applied.

src/game/g_game.pas

index 4f6f82a0066413bcc989c3d57d915c0add00b696..34a387ab255c4a9fb8eefee58216c06dfca0a291 100644 (file)
@@ -5780,6 +5780,34 @@ begin
     begin
       a := StrToIntDef(p[1], 0);
       g_Force_Model_Set(a);
+      if (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
+      begin
+        for a := Low(gPlayers) to High(gPlayers) do
+        begin
+          if (gPlayers[a] <> nil) then
+          begin
+            if (gPlayers[a].UID = gPlayer1.UID) then
+              continue
+            else if (gPlayer2 <> nil) and (gPlayers[a].UID = gPlayer2.UID) then
+              continue;
+            gPlayers[a].setModel(g_Forced_Model_GetName());
+          end;
+        end
+      end
+      else if (g_Force_Model_Get() = 0) and (gPlayers <> nil) then
+      begin
+        for a := Low(gPlayers) to High(gPlayers) do
+        begin
+          if (gPlayers[a] <> nil) then
+          begin
+            if (gPlayers[a].UID = gPlayer1.UID) then
+              continue
+            else if (gPlayer2 <> nil) and (gPlayers[a].UID = gPlayer2.UID) then
+              continue;
+            gPlayers[a].setModel(gPlayers[a].FActualModelName);
+          end;
+        end
+      end
     end
   end
   else if cmd = 'g_force_model_name' then
@@ -5788,7 +5816,7 @@ begin
     begin
       cmd := b_Text_Unformat(P[1]);
       g_Forced_Model_SetName(cmd);
-      if (gGameSettings.GameType <> GT_SINGLE) and (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
+      if (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
       begin
         for a := Low(gPlayers) to High(gPlayers) do
         begin