--- a/gameServer/OfficialServer/checker.hs Sat Aug 17 14:10:09 2013 -0400
+++ b/gameServer/OfficialServer/checker.hs Tue Aug 06 00:26:07 2013 +0400
@@ -30,7 +30,7 @@
deriving Show
serverAddress = "netserver.hedgewars.org"
-protocolNumber = "43"
+protocolNumber = "45"
getLines :: Handle -> IO [String]
getLines h = g
@@ -45,14 +45,16 @@
return $ fromJust l : lst
-engineListener :: Chan Message -> Handle -> IO ()
-engineListener coreChan h = do
+engineListener :: Chan Message -> Handle -> String -> IO ()
+engineListener coreChan h fileName = do
output <- getLines h
debugM "Engine" $ show output
if isNothing $ L.find start output then
writeChan coreChan $ CheckFailed "No stats msg"
else
writeChan coreChan $ CheckSuccess []
+
+ removeFile fileName
where
start = flip L.elem ["WINNERS", "DRAW"]
@@ -65,18 +67,16 @@
hFlush h
hClose h
- (_, Just hOut, _, _) <- createProcess (proc "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.18/bin/hwengine"
- ["/usr/home/unC0Rr/.hedgewars"
- , "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.18/share/hedgewars/Data"
- , fileName
- , "--set-audio"
- , "0"
- , "0"
- , "0"
+ (_, Just hOut, _, _) <- createProcess (proc "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.19/bin/hwengine"
+ [fileName
+ , "--user-prefix", "/usr/home/unC0Rr/.hedgewars"
+ , "--prefix", "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.19/share/hedgewars/Data"
+ , "--nomusic"
+ , "--nosound"
])
{std_out = CreatePipe}
hSetBuffering hOut LineBuffering
- void $ forkIO $ engineListener coreChan hOut
+ void $ forkIO $ engineListener coreChan hOut fileName
takePacks :: State B.ByteString [[B.ByteString]]
--- a/hedgewars/uScript.pas Sat Aug 17 14:10:09 2013 -0400
+++ b/hedgewars/uScript.pas Tue Aug 06 00:26:07 2013 +0400
@@ -1894,6 +1894,17 @@
ScriptLoad(lua_tostring(L, 1));
lc_hedgewarsscriptload:= 0;
end;
+
+
+function lc_declareachievement(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+ if lua_gettop(L) <> 3 then
+ LuaError('Lua: Wrong number of parameters passed to DeclareAchievement!')
+ else
+ declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tointeger(L, 3));
+ lc_declareachievement:= 0
+end;
///////////////////
procedure ScriptPrintStack;
@@ -2513,6 +2524,7 @@
lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear);
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload);
+lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement);
ScriptClearStack; // just to be sure stack is empty
--- a/hedgewars/uStats.pas Sat Aug 17 14:10:09 2013 -0400
+++ b/hedgewars/uStats.pas Tue Aug 06 00:26:07 2013 +0400
@@ -35,9 +35,10 @@
procedure TurnReaction;
procedure SendStats;
procedure hedgehogFlight(Gear: PGear; time: Longword);
+procedure declareAchievement(id, teamname: shortstring; value: LongInt);
implementation
-uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug, uMisc, uConsole;
+uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug, uMisc, uConsole, uScript;
var DamageClan : Longword = 0;
DamageTotal : Longword = 0;
@@ -300,13 +301,23 @@
if winnersClan <> nil then
begin
WriteLnToConsole('WINNERS');
+ WriteLnToConsole(inttostr(winnersClan^.TeamsNumber));
for t:= 0 to winnersClan^.TeamsNumber - 1 do
WriteLnToConsole(winnersClan^.Teams[t]^.TeamName);
end
else
WriteLnToConsole('DRAW');
+
+ ScriptCall('onAchievementsDeclaration');
+end;
- WriteLnToConsole('');
+procedure declareAchievement(id, teamname: shortstring; value: LongInt);
+begin
+ if (length(id) = 0) or (length(teamname) = 0) then exit;
+ WriteLnToConsole('ACHIEVEMENT');
+ WriteLnToConsole(id);
+ WriteLnToConsole(teamname);
+ WriteLnToConsole(inttostr(value));
end;
procedure initModule;
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua Sat Aug 17 14:10:09 2013 -0400
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua Tue Aug 06 00:26:07 2013 +0400
@@ -162,3 +162,9 @@
--
-- end
--end
+
+function onAchievementsDeclaration()
+ if besthog ~= nil then
+ DeclareAchievement("rope race", GetHogTeamName(besthog), besttime)
+ end
+end