From: Challenge9 Date: Tue, 25 Apr 2023 16:25:40 +0000 (+0300) Subject: Add client-side model override option X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=d89c8f47a07275c25006502fe98e9428be12d788;p=d2df-sdl.git Add client-side model override option --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 7f1d7b2..53e8656 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -1071,6 +1071,8 @@ begin AddCommand('g_max_shells', GameCVars); AddCommand('g_max_gibs', GameCVars); AddCommand('g_max_corpses', GameCVars); + AddCommand('g_force_model', GameCVars); + AddCommand('g_force_model_name', GameCVars); AddCommand('g_gamemode', GameCVars); AddCommand('g_friendlyfire', GameCVars); AddCommand('g_friendly_hit_trace', GameCVars); @@ -2186,6 +2188,8 @@ begin WriteLn(f, 'g_max_shells ', g_Shells_GetMax()); WriteLn(f, 'g_max_gibs ', g_Gibs_GetMax()); WriteLn(f, 'g_max_corpses ', g_Corpses_GetMax()); + WriteLn(f, 'g_force_model ', g_Force_Model_Get()); + WriteLn(f, 'g_force_model_name ', g_Forced_Model_GetName()); WriteLn(f, 'sv_intertime ', gDefInterTime); // gameplay settings diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 7ec1317..ebe0144 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -5761,6 +5761,36 @@ begin e_LogWritefln('usage: %s ', [cmd]) end end + else if cmd = 'g_force_model' then + begin + if Length(p) = 2 then + begin + a := StrToIntDef(p[1], 0); + g_Force_Model_Set(a); + end + end + else if cmd = 'g_force_model_name' then + begin + if (Length(P) > 1) then + 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 + 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 + end + end else if cmd = 'g_scorelimit' then begin if Length(P) > 1 then diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 1d63ec0..e41eafe 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -463,6 +463,8 @@ begin SetWeaponPrefs(TmpPrefArray); SwitchToEmpty := SwitchEmpty; SkipFist := SkipF; + if (g_Force_Model_Get() <> 0) then + SetModel(g_Forced_Model_GetName()); Reset(True); end; @@ -762,6 +764,8 @@ begin Pl.Name := TmpName; end; + if (g_Force_Model_Get() <> 0) then + TmpModel := g_Forced_Model_GetName(); if TmpModel <> Pl.Model.Name then Pl.SetModel(TmpModel); @@ -2395,6 +2399,8 @@ begin if (PID <> NetPlrUID1) and (PID <> NetPlrUID2) then begin if (Pl <> nil) then Exit; + if (g_Force_Model_Get() <> 0) then + Model := g_Forced_Model_GetName(); DID := g_Player_Create(Model, Color, T, False); with g_Player_Get(DID) do begin @@ -2689,6 +2695,7 @@ procedure MC_RECV_PlayerSettings(var M: TMsg); var TmpName: string; TmpModel: string; + CheckModel: string; TmpColor: TRGB; TmpTeam: Byte; Pl: TPlayer; @@ -2722,6 +2729,8 @@ begin Pl.Name := TmpName; end; + if (g_Force_Model_Get() <> 0) then + TmpModel := g_Forced_Model_GetName(); if TmpModel <> Pl.Model.Name then Pl.SetModel(TmpModel); end; diff --git a/src/game/g_player.pas b/src/game/g_player.pas index f926798..92e2902 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -600,6 +600,10 @@ procedure g_Gibs_SetMax(Count: Word); function g_Gibs_GetMax(): Word; procedure g_Corpses_SetMax(Count: Word); function g_Corpses_GetMax(): Word; +procedure g_Force_Model_Set(Mode: Word); +function g_Force_Model_Get(): Word; +procedure g_Forced_Model_SetName(Model: String); +function g_Forced_Model_GetName(): String; procedure g_Shells_SetMax(Count: Word); function g_Shells_GetMax(): Word; @@ -729,6 +733,8 @@ var MaxGibs: Word = 150; MaxCorpses: Word = 20; MaxShells: Word = 300; + ForceModel: Word = 0; + ForcedModelName: String = STD_PLAYER_MODEL; CurrentGib: Integer = 0; CurrentShell: Integer = 0; BotNames: Array of String; @@ -796,6 +802,26 @@ begin Result := MaxCorpses; end; +procedure g_Force_Model_Set(Mode: Word); +begin + ForceModel := Mode; +end; + +function g_Force_Model_Get(): Word; +begin + Result := ForceModel; +end; + +procedure g_Forced_Model_SetName(Model: String); +begin + ForcedModelName := Model; +end; + +function g_Forced_Model_GetName(): String; +begin + Result := ForcedModelName; +end; + function g_Player_Create(ModelName: String; Color: TRGB; Team: Byte; Bot: Boolean): Word; var a: Integer;