--- a/hedgewars/hwengine.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/hwengine.pas Thu Dec 03 23:59:06 2015 +0300
@@ -549,7 +549,7 @@
RunEngine:= HaltUsageError
else
begin
- SDL_CreateThread(@EngineThread, 'engine', nil);
+ t:= SDL_CreateThread(@EngineThread, 'engine', nil);
SDL_DetachThread(t);
RunEngine:= 0
end
--- a/hedgewars/uFLGameConfig.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLGameConfig.pas Thu Dec 03 23:59:06 2015 +0300
@@ -28,6 +28,8 @@
procedure netSetTemplate(template: LongInt);
procedure netSetAmmo(name: shortstring; definition: ansistring);
procedure netSetScheme(scheme: TScheme);
+procedure netAddTeam(team: TTeam);
+procedure netSetTeamColor(team: shortstring; color: Longword);
procedure updatePreviewIfNeeded;
procedure sendConfig(config: PGameConfig);
@@ -57,6 +59,7 @@
ipcToEngine('e$mapgen ' + intToStr(mapgen));
ipcToEngine('e$template_filter ' + intToStr(template));
ipcToEngine('e$feature_size ' + intToStr(featureSize));
+ ipcToEngine('e$maze_size ' + intToStr(mazeSize));
end;
gtLocal: begin
if script <> 'Normal' then
@@ -66,6 +69,7 @@
ipcToEngine('e$template_filter ' + intToStr(template));
ipcToEngine('e$feature_size ' + intToStr(featureSize));
ipcToEngine('e$theme ' + theme);
+ ipcToEngine('e$maze_size ' + intToStr(mazeSize));
sendSchemeConfig(scheme);
@@ -415,4 +419,61 @@
sendUI(mtScheme, @scheme.schemeName[1], length(scheme.schemeName))
end;
+procedure netAddTeam(team: TTeam);
+var msg: ansistring;
+ i, hn, hedgehogsNumber: Longword;
+ c: Longword;
+begin
+ with currentConfig do
+ begin
+ hedgehogsNumber:= 0;
+ i:= 0;
+
+ while (i < 8) and (teams[i].hogsNumber > 0) do
+ begin
+ inc(i);
+ inc(hedgehogsNumber, teams[i].hogsNumber)
+ end;
+
+ // no free space for a team - server bug???
+ if (i > 7) or (hedgehogsNumber >= 48) then exit;
+
+ c:= getUnusedColor;
+
+ teams[i]:= team;
+
+ if i = 0 then hn:= 4 else hn:= teams[i - 1].hogsNumber;
+ if hn > 48 - hedgehogsNumber then hn:= 48 - hedgehogsNumber;
+ teams[i].hogsNumber:= hn;
+
+ teams[i].color:= c;
+
+ msg:= '0' + #10 + team.teamName;
+ sendUI(mtAddPlayingTeam, @msg[1], length(msg));
+
+ msg:= team.teamName + #10 + colorsSet[teams[i].color];
+ sendUI(mtTeamColor, @msg[1], length(msg));
+ end
+end;
+
+procedure netSetTeamColor(team: shortstring; color: Longword);
+var i: Longword;
+ msg: ansistring;
+begin
+ with currentConfig do
+ begin
+ i:= 0;
+
+ while (i < 8) and (teams[i].teamName <> team) do
+ inc(i);
+ // team not found???
+ if (i > 7) then exit;
+
+ teams[i].color:= color mod 9;
+
+ msg:= team + #10 + colorsSet[teams[i].color];
+ sendUI(mtTeamColor, @msg[1], length(msg))
+ end
+end;
+
end.
--- a/hedgewars/uFLNet.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLNet.pas Thu Dec 03 23:59:06 2015 +0300
@@ -123,6 +123,18 @@
state.l:= 0
end;
+procedure handler_SS;
+var cmd: TCmdParamSS;
+begin
+ cmd.cmd:= state.cmd;
+ cmd.str1:= getShortString;
+ if cmd.str1[0] = #0 then exit;
+ cmd.str2:= getShortString;
+ if cmd.str2[0] = #0 then exit;
+ sendUI(mtNetData, @cmd, sizeof(cmd));
+ handleTail()
+end;
+
procedure handler__i;
var cmd: TCmdParami;
s: shortstring;
@@ -204,10 +216,10 @@
-15, 0, 0, 0, 0, -14, 20, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, -13, 0, 0, 0, 0,
0, -12, 8, 0, 0, 0, 0, 0, 0, -11, 0, -10);
const handlers: array[0..46] of PHandler = (@handler__UNKNOWN_, @handler_L,
- @handler_MS, @handler_S, @handler_SL, @handler_L, @handler_S, @handler_,
+ @handler_SS, @handler_S, @handler_SL, @handler_L, @handler_S, @handler_,
@handler_, @handler_MS, @handler_S, @handler_MS, @handler_MS, @handler_S,
@handler_i, @handler_MS, @handler_L, @handler_S, @handler_SL, @handler_MS,
- @handler_SL, @handler_, @handler_S, @handler_MS, @handler_MS, @handler_MS,
+ @handler_SL, @handler_, @handler_S, @handler_MS, @handler_MS, @handler_SS,
@handler_L, @handler_ML, @handler__i, @handler_SMS, @handler_SL, @handler_S,
@handler_i, @handler_S, @handler_S, @handler_MS, @handler_i, @handler_i,
@handler_S, @handler_ML, @handler_i, @handler_L, @handler_SL, @handler_SL,
--- a/hedgewars/uFLNetProtocol.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLNetProtocol.pas Thu Dec 03 23:59:06 2015 +0300
@@ -18,12 +18,52 @@
var isInRoom: boolean;
myNickname: shortstring;
+var teamIndex: LongInt;
+ tmpTeam: TTeam;
+
+const teamFields: array[0..22] of PShortstring = (
+ @tmpTeam.teamName
+ , @tmpTeam.grave
+ , @tmpTeam.fort
+ , @tmpTeam.voice
+ , @tmpTeam.flag
+ , @tmpTeam.owner
+ , nil
+ , @tmpTeam.hedgehogs[0].name
+ , @tmpTeam.hedgehogs[0].hat
+ , @tmpTeam.hedgehogs[1].name
+ , @tmpTeam.hedgehogs[1].hat
+ , @tmpTeam.hedgehogs[2].name
+ , @tmpTeam.hedgehogs[2].hat
+ , @tmpTeam.hedgehogs[3].name
+ , @tmpTeam.hedgehogs[3].hat
+ , @tmpTeam.hedgehogs[4].name
+ , @tmpTeam.hedgehogs[4].hat
+ , @tmpTeam.hedgehogs[5].name
+ , @tmpTeam.hedgehogs[5].hat
+ , @tmpTeam.hedgehogs[6].name
+ , @tmpTeam.hedgehogs[6].hat
+ , @tmpTeam.hedgehogs[7].name
+ , @tmpTeam.hedgehogs[7].hat
+ );
procedure handler_ADD_TEAM(var p: TCmdParam);
begin
+ teamIndex:= 0;
+ tmpTeam.extDriven:= true;
+ tmpTeam.color:= 0
end;
procedure handler_ADD_TEAM_s(var s: TCmdParamS);
begin
+ if teamIndex = 6 then
+ tmpTeam.botLevel:= strToInt(s.str1)
+ else if teamIndex < 23 then
+ teamFields[teamIndex]^:= s.str1;
+
+ if teamIndex = 22 then
+ netAddTeam(tmpTeam);
+
+ inc(teamIndex);
end;
procedure handler_ASKPASSWORD(var p: TCmdParamS);
@@ -251,11 +291,7 @@
sendUI(mtError, @p.str1[1], length(p.str1));
end;
-procedure handler_HH_NUM(var p: TCmdParam);
-begin
-end;
-
-procedure handler_HH_NUM_s(var s: TCmdParamS);
+procedure handler_HH_NUM(var p: TCmdParamSS);
begin
end;
@@ -431,12 +467,9 @@
begin
end;
-procedure handler_TEAM_COLOR(var p: TCmdParam);
+procedure handler_TEAM_COLOR(var p: TCmdParamSS);
begin
-end;
-
-procedure handler_TEAM_COLOR_s(var s: TCmdParamS);
-begin
+ netSetTeamColor(p.str1, StrToInt(p.str2));
end;
procedure handler_WARNING(var p: TCmdParamL);
@@ -457,10 +490,10 @@
PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT),
PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s),
PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s),
- PHandler(@handler_ERROR), PHandler(@handler_HH_NUM),
- PHandler(@handler_HH_NUM_s), PHandler(@handler_INFO), PHandler(@handler_INFO_s),
- PHandler(@handler_JOINED), PHandler(@handler_JOINED_s),
- PHandler(@handler_JOINING), PHandler(@handler_KICKED), PHandler(@handler_LEFT),
+ PHandler(@handler_ERROR), PHandler(@handler_HH_NUM), PHandler(@handler_INFO),
+ PHandler(@handler_INFO_s), PHandler(@handler_JOINED),
+ PHandler(@handler_JOINED_s), PHandler(@handler_JOINING),
+ PHandler(@handler_KICKED), PHandler(@handler_LEFT),
PHandler(@handler_LOBBY_JOINED), PHandler(@handler_LOBBY_JOINED_s),
PHandler(@handler_LOBBY_LEFT), PHandler(@handler_NICK),
PHandler(@handler_NOTICE), PHandler(@handler_PING), PHandler(@handler_PING_s),
@@ -472,7 +505,7 @@
PHandler(@handler_RUN_GAME), PHandler(@handler_SERVER_AUTH),
PHandler(@handler_SERVER_MESSAGE), PHandler(@handler_SERVER_VARS),
PHandler(@handler_TEAM_ACCEPTED), PHandler(@handler_TEAM_COLOR),
- PHandler(@handler_TEAM_COLOR_s), PHandler(@handler_WARNING));
+ PHandler(@handler_WARNING));
procedure passNetData(p: pointer); cdecl;
begin
--- a/hedgewars/uFLNetTypes.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLNetTypes.pas Thu Dec 03 23:59:06 2015 +0300
@@ -7,13 +7,13 @@
cmd_CFG_MAZE_SIZE, cmd_CFG_SCHEME, cmd_CFG_SCHEME_s, cmd_CFG_SCRIPT,
cmd_CFG_SEED, cmd_CFG_TEMPLATE, cmd_CFG_THEME, cmd_CHAT, cmd_CLIENT_FLAGS,
cmd_CLIENT_FLAGS_s, cmd_CONNECTED, cmd_EM, cmd_EM_s, cmd_ERROR, cmd_HH_NUM,
- cmd_HH_NUM_s, cmd_INFO, cmd_INFO_s, cmd_JOINED, cmd_JOINED_s, cmd_JOINING,
- cmd_KICKED, cmd_LEFT, cmd_LOBBY_JOINED, cmd_LOBBY_JOINED_s, cmd_LOBBY_LEFT,
- cmd_NICK, cmd_NOTICE, cmd_PING, cmd_PING_s, cmd_PROTO, cmd_REMOVE_TEAM,
- cmd_ROOMS, cmd_ROOMS_s, cmd_ROOM_ADD, cmd_ROOM_ADD_s, cmd_ROOM_DEL,
- cmd_ROOM_UPD, cmd_ROOM_UPD_s, cmd_ROUND_FINISHED, cmd_RUN_GAME, cmd_SERVER_AUTH,
+ cmd_INFO, cmd_INFO_s, cmd_JOINED, cmd_JOINED_s, cmd_JOINING, cmd_KICKED,
+ cmd_LEFT, cmd_LOBBY_JOINED, cmd_LOBBY_JOINED_s, cmd_LOBBY_LEFT, cmd_NICK,
+ cmd_NOTICE, cmd_PING, cmd_PING_s, cmd_PROTO, cmd_REMOVE_TEAM, cmd_ROOMS,
+ cmd_ROOMS_s, cmd_ROOM_ADD, cmd_ROOM_ADD_s, cmd_ROOM_DEL, cmd_ROOM_UPD,
+ cmd_ROOM_UPD_s, cmd_ROUND_FINISHED, cmd_RUN_GAME, cmd_SERVER_AUTH,
cmd_SERVER_MESSAGE, cmd_SERVER_VARS, cmd_TEAM_ACCEPTED, cmd_TEAM_COLOR,
- cmd_TEAM_COLOR_s, cmd_WARNING);
+ cmd_WARNING);
type TCmdParam = packed record
cmd: TCmdType;
@@ -31,6 +31,11 @@
str1: shortstring;
str2: string;
end;
+ type TCmdParamSS = packed record
+ cmd: TCmdType;
+ str1: shortstring;
+ str2: shortstring;
+ end;
type TCmdParami = packed record
cmd: TCmdType;
param1: LongInt;
--- a/hedgewars/uFLTeams.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLTeams.pas Thu Dec 03 23:59:06 2015 +0300
@@ -79,9 +79,9 @@
if copy(l, 1, 5) = 'Name=' then
team.teamName:= midStr(l, 6)
else if copy(l, 1, 6) = 'Grave=' then
- team.graveName:= midStr(l, 7)
+ team.grave:= midStr(l, 7)
else if copy(l, 1, 5) = 'Fort=' then
- team.fortName:= midStr(l, 6)
+ team.fort:= midStr(l, 6)
else if copy(l, 1, 5) = 'Flag=' then
team.flag:= midStr(l, 6)
end;
--- a/hedgewars/uFLTypes.pas Wed Dec 02 22:30:13 2015 +0300
+++ b/hedgewars/uFLTypes.pas Thu Dec 03 23:59:06 2015 +0300
@@ -30,11 +30,12 @@
hat: shortstring;
end;
TTeam = record
- teamName: shortstring;
- flag: shortstring;
- graveName: shortstring;
- fortName: shortstring;
- owner: shortstring;
+ teamName
+ , flag
+ , grave
+ , fort
+ , voice
+ , owner: shortstring;
color: Longword;
extDriven: boolean;
botLevel: Longword;
--- a/tools/protocolParser.hs Wed Dec 02 22:30:13 2015 +0300
+++ b/tools/protocolParser.hs Thu Dec 03 23:59:06 2015 +0300
@@ -71,8 +71,8 @@
, cmd1 "SERVER_AUTH" SS
, cmd1 "JOINING" SS
, cmd1 "TEAM_ACCEPTED" SS
- , cmd1 "HH_NUM" $ Many [SS]
- , cmd1 "TEAM_COLOR" $ Many [SS]
+ , cmd2 "HH_NUM" SS SS
+ , cmd2 "TEAM_COLOR" SS SS
, cmd1 "BANLIST" $ Many [SS]
, cmd1 "JOINED" $ Many [SS]
, cmd1 "LOBBY:JOINED" $ Many [SS]