--- a/CMakeLists.txt Thu Oct 02 00:48:14 2014 +0400
+++ b/CMakeLists.txt Mon Oct 13 23:46:49 2014 +0400
@@ -27,7 +27,7 @@
option(LUA_SYSTEM "Use system lua (on)" ON)
endif()
-option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF)
+set(BUILD_ENGINE_LIBRARY ON)
option(ANDROID "Enable Android build (off)" OFF)
option(MINIMAL_FLAGS "Respect system flags as much as possible (off)" OFF)
--- a/gameServer/OfficialServer/checker.hs Thu Oct 02 00:48:14 2014 +0400
+++ b/gameServer/OfficialServer/checker.hs Mon Oct 13 23:46:49 2014 +0400
@@ -12,7 +12,7 @@
import Control.Concurrent
import Network
import Network.BSD
-import Network.Socket hiding (recv)
+import Network.Socket hiding (recv, sClose)
import Network.Socket.ByteString
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString as BW
--- a/hedgewars/uFLTeams.pas Thu Oct 02 00:48:14 2014 +0400
+++ b/hedgewars/uFLTeams.pas Mon Oct 13 23:46:49 2014 +0400
@@ -5,9 +5,18 @@
function createRandomTeam: TTeam;
procedure sendTeamConfig(var team: TTeam);
+function getTeamsList: PPChar; cdecl;
+procedure freeTeamsList;
implementation
-uses uFLUtils, uFLIPC;
+uses uFLUtils, uFLIPC, uPhysFSLayer;
+
+const MAX_TEAM_NAMES = 128;
+var
+ teamsList: PTeam;
+ teamsNumber: Longword;
+ listOfTeamNames: array[0..MAX_TEAM_NAMES] of PChar;
+
function createRandomTeam: TTeam;
var t: TTeam;
@@ -30,6 +39,7 @@
createRandomTeam:= t
end;
+
procedure sendTeamConfig(var team: TTeam);
var i: Longword;
begin
@@ -44,4 +54,109 @@
end
end;
+
+procedure loadTeam(var team: TTeam; fileName: shortstring);
+var f: PFSFile;
+ section: LongInt;
+ l: shortstring;
+begin
+ section:= -1;
+ f:= pfsOpenRead(fileName);
+
+ while (not pfsEOF(f)) do
+ begin
+ pfsReadLn(f, l);
+
+ if l = '' then
+ else if l = '[Team]' then
+ section:= 0
+ else if l[1] = '[' then
+ section:= -1
+ else if section = 0 then
+ begin // [Team]
+ 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)
+ else if copy(l, 1, 5) = 'Fort=' then
+ team.fortName:= midStr(l, 6)
+ else if copy(l, 1, 5) = 'Flag=' then
+ team.flag:= midStr(l, 6)
+ end;
+ // TODO: load hedgehogs and other stuff
+ end;
+
+ pfsClose(f)
+end;
+
+
+procedure loadTeams;
+var filesList, tmp: PPChar;
+ team: PTeam;
+ s: shortstring;
+ l: Longword;
+begin
+ filesList:= pfsEnumerateFiles('Teams');
+ teamsNumber:= 0;
+
+ tmp:= filesList;
+ while tmp^ <> nil do
+ begin
+ s:= shortstring(tmp^);
+ l:= length(s);
+ if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then inc(teamsNumber)
+ end;
+
+ // TODO: no teams at all?
+ teamsList:= GetMem(sizeof(teamsList^) * teamsNumber);
+
+ team:= teamsList;
+ tmp:= filesList;
+ while tmp^ <> nil do
+ begin
+ s:= shortstring(tmp^);
+ l:= length(s);
+ if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then
+ begin
+ loadTeam(team^, '/Config/Teams/' + s);
+ inc(team)
+ end;
+ end;
+
+ pfsFreeList(filesList)
+end;
+
+
+function getTeamsList: PPChar; cdecl;
+var i, t, l: Longword;
+ team: PTeam;
+begin
+ if teamsList = nil then
+ loadTeams;
+
+ t:= teamsNumber;
+ if t >= MAX_TEAM_NAMES then
+ t:= MAX_TEAM_NAMES;
+
+ team:= teamsList;
+ for i:= 0 to Pred(t) do
+ begin
+ l:= length(team^.teamName);
+ if l >= 255 then l:= 254;
+ team^.teamName[l + 1]:= #0;
+ listOfTeamNames[i]:= @team^.teamName[1]
+ end;
+
+ listOfTeamNames[t]:= nil;
+
+ getTeamsList:= listOfTeamNames
+end;
+
+
+procedure freeTeamsList;
+begin
+ if teamsList <> nil then
+ FreeMem(teamsList, sizeof(teamsList^) * teamsNumber)
+end;
+
end.
--- a/hedgewars/uFLTypes.pas Thu Oct 02 00:48:14 2014 +0400
+++ b/hedgewars/uFLTypes.pas Mon Oct 13 23:46:49 2014 +0400
@@ -29,7 +29,8 @@
botLevel: Longword;
hedgehogs: array[0..7] of THedgehog;
hogsNumber: Longword;
- end;
+ end;
+ PTeam = ^TTeam;
implementation
--- a/hedgewars/uFLUtils.pas Thu Oct 02 00:48:14 2014 +0400
+++ b/hedgewars/uFLUtils.pas Mon Oct 13 23:46:49 2014 +0400
@@ -3,6 +3,7 @@
function str2PChar(const s: shortstring): PChar;
function intToStr(n: LongInt): shortstring;
+function midStr(s: shortstring; pos: byte): shortstring;
implementation
@@ -25,4 +26,9 @@
str(n, intToStr)
end;
+function midStr(s: shortstring; pos: byte): shortstring;
+begin
+ midStr:= copy(s, pos, length(s) - pos + 1)
+end;
+
end.
--- a/qmlFrontend/flib.h Thu Oct 02 00:48:14 2014 +0400
+++ b/qmlFrontend/flib.h Mon Oct 13 23:46:49 2014 +0400
@@ -35,6 +35,8 @@
typedef void freeThemesList_t(char **list);
typedef uint32_t getThemeIcon_t(char * theme, char * buffer, uint32_t size);
+typedef char **getTeamsList_t();
+
#ifdef __cplusplus
}
#endif
--- a/qmlFrontend/themeiconprovider.cpp Thu Oct 02 00:48:14 2014 +0400
+++ b/qmlFrontend/themeiconprovider.cpp Mon Oct 13 23:46:49 2014 +0400
@@ -25,7 +25,8 @@
QByteArray buf;
buf.resize(65536);
- uint32_t fileSize = getThemeIcon(id.toUtf8().data(), buf.data(), buf.size());
+ char * bufptr = buf.data();
+ uint32_t fileSize = getThemeIcon(id.toUtf8().data(), bufptr, buf.size());
buf.truncate(fileSize);
qDebug() << "ThemeIconProvider file size = " << fileSize;