--- a/hedgewars/uFLAmmo.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLAmmo.pas Tue Dec 01 23:37:10 2015 +0300
@@ -129,6 +129,7 @@
ipcToEngine('eammprob ' + ammo.b);
ipcToEngine('eammdelay ' + ammo.c);
ipcToEngine('eammreinf ' + ammo.d);
+ ipcToEngine('eammstore');
end
end;
--- a/hedgewars/uFLGameConfig.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLGameConfig.pas Tue Dec 01 23:37:10 2015 +0300
@@ -26,6 +26,7 @@
procedure netSetMap(map: shortstring);
procedure netSetMazeSize(mazesize: LongInt);
procedure netSetTemplate(template: LongInt);
+procedure netSetAmmo(name: shortstring; definition: ansistring);
procedure updatePreviewIfNeeded;
procedure sendConfig(config: PGameConfig);
@@ -70,9 +71,8 @@
i:= 0;
while (i < 8) and (teams[i].hogsNumber > 0) do
begin
+ sendTeamConfig(teams[i]);
sendAmmoConfig(config^.ammo);
- ipcToEngine('eammstore');
- sendTeamConfig(teams[i]);
inc(i)
end;
end;
@@ -257,7 +257,7 @@
procedure changeTeamColor(teamName: PChar; dir: LongInt); cdecl;
var i, dc: Longword;
tn: shortstring;
- msg: ansistring;
+ msg: ansistring;
begin
with currentConfig do
begin
@@ -393,4 +393,19 @@
getPreview
end;
+procedure netSetAmmo(name: shortstring; definition: ansistring);
+var ammo: TAmmo;
+ i: LongInt;
+begin
+ ammo.ammoName:= name;
+ i:= length(definition) div 4;
+ ammo.a:= copy(definition, 1, i);
+ ammo.b:= copy(definition, i + 1, i);
+ ammo.c:= copy(definition, i * 2 + 1, i);
+ ammo.d:= copy(definition, i * 3 + 1, i);
+
+ currentConfig.ammo:= ammo;
+ sendUI(mtAmmo, @name[1], length(name))
+end;
+
end.
--- a/hedgewars/uFLNet.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLNet.pas Tue Dec 01 23:37:10 2015 +0300
@@ -11,7 +11,7 @@
implementation
uses SDLh, uFLIPC, uFLTypes, uFLUICallback, uFLNetTypes, uFLUtils;
-const endCmd: string = #10 + #10;
+const endCmd: shortstring = #10 + #10;
function getNextChar: char; forward;
function getCurrChar: char; forward;
@@ -31,6 +31,7 @@
procedure handleTail; forward;
function getShortString: shortstring; forward;
+function getLongString: ansistring; forward;
procedure handler_;
begin
@@ -42,8 +43,8 @@
var cmd: TCmdParamL;
begin
cmd.cmd:= state.cmd;
- cmd.str1:= getShortString; // FIXME long line
- if cmd.str1[0] = #0 then exit;
+ cmd.str1:= getLongString;
+ if length(cmd.str1) = 0 then exit;
sendUI(mtNetData, @cmd, sizeof(cmd));
handleTail()
end;
@@ -57,7 +58,7 @@
cmd.cmd:= Succ(state.cmd);
repeat
- cmd.str1:= getShortString; // FIXME long line
+ cmd.str1:= getLongString;
f:= cmd.str1[0] <> #0;
if f then
sendUI(mtNetData, @cmd, sizeof(cmd));
@@ -97,7 +98,7 @@
cmd.cmd:= state.cmd;
cmd.str1:= getShortString;
if cmd.str1[0] = #0 then exit;
- cmd.str2:= getShortString; // FIXME should be long string
+ cmd.str2:= getLongString;
if cmd.str2[0] = #0 then exit;
sendUI(mtNetData, @cmd, sizeof(cmd));
handleTail()
@@ -331,6 +332,30 @@
getShortString:= s
end;
+function getLongString: ansistring;
+var s: shortstring;
+ l: ansistring;
+ c: char;
+begin
+ l:= '';
+
+ repeat
+ s[0]:= #0;
+ repeat
+ inc(s[0]);
+ c:= getNextChar;
+ s[byte(s[0])]:= c
+ until (s[0] = #255) or (c = #10) or (c = #0);
+
+ if s[byte(s[0])] = #10 then
+ dec(s[0]);
+
+ l:= l + s
+ until (c = #10) or (c = #0);
+
+ getLongString:= l
+end;
+
procedure netSendCallback(p: pointer; msg: PChar; len: Longword);
begin
// W A R N I N G: totally thread-unsafe due to use of sock variable
--- a/hedgewars/uFLNetProtocol.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLNetProtocol.pas Tue Dec 01 23:37:10 2015 +0300
@@ -45,6 +45,7 @@
procedure handler_CFG_AMMO(var p: TCmdParamSL);
begin
+ netSetAmmo(p.str1, p.str2)
end;
procedure handler_CFG_DRAWNMAP(var p: TCmdParamL);
--- a/hedgewars/uFLTeams.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLTeams.pas Tue Dec 01 23:37:10 2015 +0300
@@ -86,7 +86,7 @@
team.flag:= midStr(l, 6)
end;
// TODO: load hedgehogs and other stuff
- team.botLevel:= 1
+ team.botLevel:= 0
end;
pfsClose(f)
--- a/hedgewars/uFLTypes.pas Tue Dec 01 19:49:59 2015 +0300
+++ b/hedgewars/uFLTypes.pas Tue Dec 01 23:37:10 2015 +0300
@@ -11,7 +11,7 @@
, mtRemoveRoomClient, mtRoomChatLine, mtAddRoom, mtUpdateRoom
, mtRemoveRoom, mtError, mtWarning, mtMoveToLobby, mtMoveToRoom
, mtNickname, mtSeed, mtTheme, mtScript, mtFeatureSize, mtMapGen
- , mtMap, mtMazeSize, mtTemplate);
+ , mtMap, mtMazeSize, mtTemplate, mtAmmo);
TFLIBEvent = (flibGameFinished);
--- a/qmlFrontend/flib.h Tue Dec 01 19:49:59 2015 +0300
+++ b/qmlFrontend/flib.h Tue Dec 01 23:37:10 2015 +0300
@@ -41,6 +41,7 @@
, MSG_MAP
, MSG_MAZESIZE
, MSG_TEMPLATE
+ , MSG_AMMO
};
typedef union string255_
--- a/qmlFrontend/hwengine.cpp Tue Dec 01 19:49:59 2015 +0300
+++ b/qmlFrontend/hwengine.cpp Tue Dec 01 23:37:10 2015 +0300
@@ -206,6 +206,8 @@
}
case MSG_REMOVELOBBYCLIENT: {
QStringList l = QString::fromUtf8(msg).split('\n');
+ if(l.size() < 2)
+ l.append("");
emit lobbyClientRemoved(l[0], l[1]);
break;
}
@@ -296,6 +298,10 @@
emit templateChanged(msg.toInt());
break;
}
+ case MSG_AMMO: {
+ emit ammoChanged(QString::fromUtf8(msg));
+ break;
+ }
}
}
--- a/qmlFrontend/hwengine.h Tue Dec 01 19:49:59 2015 +0300
+++ b/qmlFrontend/hwengine.h Tue Dec 01 23:37:10 2015 +0300
@@ -79,6 +79,7 @@
void mapChanged(const QString & map);
void mazeSizeChanged(int mazeSize);
void templateChanged(int templ);
+ void ammoChanged(const QString & ammo);
void roomAdded(quint32 flags
, const QString & name
--- a/qmlFrontend/qml/qmlFrontend/GameConfig.qml Tue Dec 01 19:49:59 2015 +0300
+++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml Tue Dec 01 23:37:10 2015 +0300
@@ -57,11 +57,11 @@
HWEngine.setTheme(themeName.text)
}
}
+ }
- Connections {
- target: HWEngine
- onThemeChanged: cbTheme.showItem({"iconSource" : "image://theme/" + theme, "text" : theme});
- }
+ Connections {
+ target: HWEngine
+ onThemeChanged: cbTheme.showItem({"iconSource" : "image://theme/" + theme, "text" : theme});
}
}
@@ -92,10 +92,10 @@
HWEngine.setScript(scriptName.text)
}
}
- Connections {
- target: HWEngine
- onScriptChanged: cbScript.showItem({"iconSource" : "", "text" : script});
- }
+ }
+ Connections {
+ target: HWEngine
+ onScriptChanged: cbScript.showItem({"iconSource" : "", "text" : script});
}
}
@@ -158,6 +158,10 @@
}
}
}
+ Connections {
+ target: HWEngine
+ onAmmoChanged: cbAmmo.showItem({"iconSource" : "", "text" : ammo});
+ }
}
}