DEADSOFTWARE

add p?_model commands; clean up p?_color and p?_name
authorfgsfds <pvt.fgsfds@gmail.com>
Mon, 24 Feb 2020 16:21:27 +0000 (19:21 +0300)
committerfgsfds <pvt.fgsfds@gmail.com>
Mon, 24 Feb 2020 16:21:27 +0000 (19:21 +0300)
src/game/g_console.pas
src/game/g_game.pas

index 94b65318a091c51e78dfa8f2fcfc268c489a8aa3..cde25fedb4c279a6a55cb17da39a41b5019aa45c 100644 (file)
@@ -910,6 +910,8 @@ begin
   AddCommand('p2_name', GameCVars);
   AddCommand('p1_color', GameCVars);
   AddCommand('p2_color', GameCVars);
+  AddCommand('p1_model', GameCVars);
+  AddCommand('p2_model', GameCVars);
   AddCommand('r_showscore', GameCVars);
   AddCommand('r_showlives', GameCVars);
   AddCommand('r_showstat', GameCVars);
index 0395bf4c9f05bae2fc2a68023d795d51d2867c05..8453f05fd1d87ca28799b7f40c2f4e4f1dfef560 100644 (file)
@@ -5708,87 +5708,93 @@ begin
   end
   else if cmd = 'p1_name' then
   begin
-    if (Length(P) > 1) and gGameOn then
+    if (Length(P) > 1) then
     begin
+      gPlayer1Settings.Name := b_Text_Unformat(P[1]);
       if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer1 <> nil) then
       begin
-        gPlayer1Settings.Name := b_Text_Unformat(P[1]);
-        MC_SEND_PlayerSettings;
-      end
-      else
-        if gPlayer1 <> nil then
-        begin
-          gPlayer1.Name := b_Text_Unformat(P[1]);
-          if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
-        end
-        else
-          gPlayer1Settings.Name := b_Text_Unformat(P[1]);
+        gPlayer1.Name := b_Text_Unformat(P[1]);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
+      end;
     end;
   end
   else if cmd = 'p2_name' then
   begin
-    if (Length(P) > 1) and gGameOn then
+    if (Length(P) > 1) then
     begin
+      gPlayer2Settings.Name := b_Text_Unformat(P[1]);
       if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer2 <> nil) then
       begin
-        gPlayer2Settings.Name := b_Text_Unformat(P[1]);
-        MC_SEND_PlayerSettings;
-      end
-      else
-        if gPlayer2 <> nil then
-        begin
-          gPlayer2.Name := b_Text_Unformat(P[1]);
-          if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
-        end
-        else
-          gPlayer2Settings.Name := b_Text_Unformat(P[1]);
+        gPlayer2.Name := b_Text_Unformat(P[1]);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
+      end;
     end;
   end
   else if cmd = 'p1_color' then
   begin
     if Length(P) > 3 then
+    begin
+      gPlayer1Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
+                                     EnsureRange(StrToIntDef(P[2], 0), 0, 255),
+                                     EnsureRange(StrToIntDef(P[3], 0), 0, 255));
       if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer1 <> nil) then
       begin
-        gPlayer1Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                       EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                       EnsureRange(StrToIntDef(P[3], 0), 0, 255));
-        MC_SEND_PlayerSettings;
-      end
-      else
-        if gPlayer1 <> nil then
-        begin
-          gPlayer1.Model.SetColor(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                  EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                  EnsureRange(StrToIntDef(P[3], 0), 0, 255));
-          if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
-        end
-        else
-          gPlayer1Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                         EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                         EnsureRange(StrToIntDef(P[3], 0), 0, 255));
+        gPlayer1.SetColor(gPlayer1Settings.Color);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
+      end;
+    end;
   end
-  else if (cmd = 'p2_color') and not g_Game_IsNet then
+  else if cmd = 'p2_color' then
   begin
     if Length(P) > 3 then
+    begin
+      gPlayer2Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
+                                     EnsureRange(StrToIntDef(P[2], 0), 0, 255),
+                                     EnsureRange(StrToIntDef(P[3], 0), 0, 255));
       if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer2 <> nil) then
       begin
-        gPlayer2Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                       EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                       EnsureRange(StrToIntDef(P[3], 0), 0, 255));
-        MC_SEND_PlayerSettings;
-      end
-      else
-        if gPlayer2 <> nil then
-        begin
-          gPlayer2.Model.SetColor(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                  EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                  EnsureRange(StrToIntDef(P[3], 0), 0, 255));
-          if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
-        end
-        else
-          gPlayer2Settings.Color := _RGB(EnsureRange(StrToIntDef(P[1], 0), 0, 255),
-                                         EnsureRange(StrToIntDef(P[2], 0), 0, 255),
-                                         EnsureRange(StrToIntDef(P[3], 0), 0, 255));
+        gPlayer2.SetColor(gPlayer2Settings.Color);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
+      end;
+    end;
+  end
+  else if cmd = 'p1_model' then
+  begin
+    if (Length(P) > 1) then
+    begin
+      gPlayer1Settings.Model := P[1];
+      if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer1 <> nil) then
+      begin
+        gPlayer1.FActualModelName := gPlayer1Settings.Model;
+        gPlayer1.SetModel(gPlayer1Settings.Model);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
+      end;
+    end;
+  end
+  else if cmd = 'p2_model' then
+  begin
+    if (Length(P) > 1) then
+    begin
+      gPlayer2Settings.Model := P[1];
+      if g_Game_IsClient then
+        MC_SEND_PlayerSettings
+      else if gGameOn and (gPlayer2 <> nil) then
+      begin
+        gPlayer2.FActualModelName := gPlayer2Settings.Model;
+        gPlayer2.SetModel(gPlayer2Settings.Model);
+        if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
+      end;
+    end;
   end
   else if gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT] then
   begin