summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a9b641b)
raw | patch | inline | side by side (parent: a9b641b)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Thu, 6 May 2021 14:34:41 +0000 (17:34 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Thu, 6 May 2021 14:34:41 +0000 (17:34 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 8eaad1226f490e9620fcce2e42fed3a1029f9fc5..a6fa9c42e78673a7434f7cf500d22a601a5a5ee0 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
AddCommand('p2_color', PlayerSettingsCVars);
AddCommand('p1_model', PlayerSettingsCVars);
AddCommand('p2_model', PlayerSettingsCVars);
+ AddCommand('p1_team', PlayerSettingsCVars);
+ AddCommand('p2_team', PlayerSettingsCVars);
AddCommand('g_max_particles', GameCVars);
AddCommand('g_max_shells', GameCVars);
WriteLn(f, name, IfThen(LongBool(gsGameFlags and flag), 1, 0));
end;
+ function FormatTeam(team: Byte): string;
+ begin
+ if team = TEAM_BLUE then
+ result := 'blue'
+ else
+ result := 'red';
+ end;
+
begin
AssignFile(f, filename);
Rewrite(f);
WriteLn(f, 'p1_name ', QuoteStr(Name));
WriteLn(f, 'p1_color ', Color.R, ' ', Color.G, ' ', Color.B);
WriteLn(f, 'p1_model ', QuoteStr(Model));
+ WriteLn(f, 'p1_team ', FormatTeam(Team));
end;
with gPlayer2Settings do
begin
WriteLn(f, 'p2_name ', QuoteStr(Name));
WriteLn(f, 'p2_color ', Color.R, ' ', Color.G, ' ', Color.B);
WriteLn(f, 'p2_model ', QuoteStr(Model));
+ WriteLn(f, 'p2_team ', FormatTeam(Team));
end;
// all cvars
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 2cf72c1bcc17dc8ceb2cb1b7f2ef140a2500a803..1d5767065eaac6518d332b5e259be800d234f655 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure PlayerSettingsCVars(P: SSArray);
var
cmd: string;
+ team: Byte;
+
+ function ParseTeam(s: string): Byte;
+ begin
+ result := 0;
+ case s of
+ 'red', '1': result := TEAM_RED;
+ 'blue', '2': result := TEAM_BLUE;
+ else result := TEAM_NONE;
+ end;
+ end;
begin
cmd := LowerCase(P[0]);
case cmd of
end;
end;
end;
+ 'p1_team':
+ begin
+ // TODO: switch teams if in game or store this separately
+ if (Length(P) > 1) then
+ begin
+ team := ParseTeam(P[1]);
+ if team = TEAM_NONE then
+ g_Console_Add('expected ''red'', ''blue'', 1 or 2')
+ else if not gGameOn and not g_Game_IsNet then
+ gPlayer1Settings.Team := team
+ else
+ g_Console_Add(_lc[I_MSG_ONMAPCHANGE]);
+ end;
+ end;
+ 'p2_team':
+ begin
+ // TODO: switch teams if in game or store this separately
+ if (Length(P) > 1) then
+ begin
+ team := ParseTeam(P[1]);
+ if team = TEAM_NONE then
+ g_Console_Add('expected ''red'', ''blue'', 1 or 2')
+ else if not gGameOn and not g_Game_IsNet then
+ gPlayer2Settings.Team := team
+ else
+ g_Console_Add(_lc[I_MSG_ONMAPCHANGE]);
+ end;
+ end;
end;
end;