Avoid redundant per-frame calls to getDbProp in outpost.xml and outpost.lua

This commit is contained in:
kaetemi 2013-07-28 08:55:28 +02:00
parent 160cf4c1c3
commit 28fb8d779e
2 changed files with 6 additions and 12 deletions

View file

@ -62,18 +62,11 @@ end
------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------
function game:outpostUpdateTimeZone() function game:outpostUpdateTimeZone()
-- update time zone auto?
local tzAuto= getDbProp('UI:SAVE:OUTPOST:TIME_ZONE_AUTO');
if(tzAuto==0) then
return;
end
-- every 5 seconds?
local curTick = getDbProp('UI:VARIABLES:CURRENT_SERVER_TICK'); local curTick = getDbProp('UI:VARIABLES:CURRENT_SERVER_TICK');
if(curTick - game.Outpost.LastTimeZoneUpdate > 50) then setDbProp('UI:TEMP:OUTPOST:TIME_ZONE_NEXT_UPDATE', curTick + 50);
game.Outpost.LastTimeZoneUpdate = curTick; game.Outpost.LastTimeZoneUpdate = curTick;
runAH(nil,'outpost_update_time_zone_auto',''); runAH(nil,'outpost_update_time_zone_auto','');
end end
end
------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------
function game:outpostIsStatusWar(status) function game:outpostIsStatusWar(status)

View file

@ -21,8 +21,9 @@
<!-- Save the Time Zone config --> <!-- Save the Time Zone config -->
<variable entry="UI:SAVE:OUTPOST:TIME_ZONE" type="sint32" value="0" /> <variable entry="UI:SAVE:OUTPOST:TIME_ZONE" type="sint32" value="0" />
<variable entry="UI:SAVE:OUTPOST:TIME_ZONE_AUTO" type="sint32" value="1" /> <variable entry="UI:SAVE:OUTPOST:TIME_ZONE_AUTO" type="sint32" value="1" />
<variable entry="UI:TEMP:OUTPOST:TIME_ZONE_NEXT_UPDATE" type="sint32" value="0" />
<!-- just a script called at init and every 5 seconds, to setup TIME_ZONE, if time_zone is auto--> <!-- just a script called at init and every 5 seconds, to setup TIME_ZONE, if time_zone is auto-->
<link expr="depends(@UI:SAVE:OUTPOST:TIME_ZONE_AUTO, @UI:VARIABLES:CURRENT_SERVER_TICK)" action="lua:game:outpostUpdateTimeZone()" /> <link expr="depends(@UI:SAVE:OUTPOST:TIME_ZONE_AUTO, @UI:VARIABLES:CURRENT_SERVER_TICK)" cond="and(eq(@UI:SAVE:OUTPOST:TIME_ZONE_AUTO, 1), ge(@UI:VARIABLES:CURRENT_SERVER_TICK, @UI:TEMP:OUTPOST:TIME_ZONE_NEXT_UPDATE))" action="lua:game:outpostUpdateTimeZone()" />
<!-- Temp Variables --> <!-- Temp Variables -->