Dump best time ghost on console
authorunc0rr
Tue, 23 Feb 2016 13:45:49 +0300
changeset 11569 294ce0fa65d0
parent 11568 e9ee87b28e17
child 11570 fba0c7a5aaf4
Dump best time ghost on console
hedgewars/uScript.pas
hedgewars/uStats.pas
share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
--- a/hedgewars/uScript.pas	Tue Feb 23 00:41:18 2016 +0100
+++ b/hedgewars/uScript.pas	Tue Feb 23 13:45:49 2016 +0300
@@ -2526,6 +2526,20 @@
     lc_declareachievement:= 0
 end;
 
+function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl;
+begin
+    if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then
+        startGhostPoints(lua_tointeger(L, 1));
+    lc_startghostpoints:= 0
+end;
+
+function lc_dumppoint(L : Plua_State) : LongInt; Cdecl;
+begin
+    if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then
+        dumpPoint(lua_tointeger(L, 1), lua_tointeger(L, 2));
+    lc_dumppoint:= 0
+end;
+
 
 procedure ScriptFlushPoints();
 begin
@@ -3342,6 +3356,8 @@
 lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints);
 lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload);
 lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement);
+lua_register(luaState, _P'StartGhostPoints', @lc_startghostpoints);
+lua_register(luaState, _P'DumpPoint', @lc_dumppoint);
 
 ScriptSetInteger('TEST_SUCCESSFUL'   , HaltTestSuccess);
 ScriptSetInteger('TEST_FAILED'       , HaltTestFailed);
--- a/hedgewars/uStats.pas	Tue Feb 23 00:41:18 2016 +0100
+++ b/hedgewars/uStats.pas	Tue Feb 23 13:45:49 2016 +0300
@@ -36,6 +36,8 @@
 procedure SendStats;
 procedure hedgehogFlight(Gear: PGear; time: Longword);
 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
+procedure startGhostPoints(n: LongInt);
+procedure dumpPoint(x, y: LongInt);
 
 implementation
 uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uMisc, uConsole, uScript;
@@ -323,8 +325,32 @@
     WriteLnToConsole(inttostr(value));
 end;
 
+procedure startGhostPoints(n: LongInt);
+begin
+    WriteLnToConsole('GHOST_POINTS');
+    WriteLnToConsole(inttostr(n));
+end;
+
+procedure dumpPoint(x, y: LongInt);
+begin
+    WriteLnToConsole(inttostr(x));
+    WriteLnToConsole(inttostr(y));
+end;
+
 procedure initModule;
 begin
+    DamageClan  := 0;
+    DamageTotal := 0;
+    DamageTurn  := 0;
+    KillsClan   := 0;
+    Kills       := 0;
+    KillsTotal  := 0;
+    AmmoUsedCount := 0;
+    AmmoDamagingUsed := false;
+    SkippedTurns:= 0;
+    isTurnSkipped:= false;
+    vpHurtSameClan:= nil;
+    vpHurtEnemy:= nil;
     TotalRounds:= -1;
     FinishedTurnsTotal:= -1;
 end;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Tue Feb 23 00:41:18 2016 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Tue Feb 23 13:45:49 2016 +0300
@@ -792,4 +792,12 @@
             DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i])
         end
     end
+
+    if fastCount > 0 then
+        StartGhostPoints(fastCount)
+
+        for i = 0, (fastCount - 1) do
+            DumpPoint(fastX[i], fastY[i])
+        end
+    end
 end
--- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Tue Feb 23 00:41:18 2016 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Tue Feb 23 13:45:49 2016 +0300
@@ -1288,6 +1288,15 @@
             DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i])
         end
     end
+
+    if fastCount > 0 then
+        StartGhostPoints(fastCount)
+
+        for i = 0, (fastCount - 1) do
+            DumpPoint(fastX[i], fastY[i])
+        end
+    end
+
 end
 
 function onAmmoStoreInit()