1
0

Updated to V6 - "Stop" and "Progress report" functionality

git-svn-id: http://mc-server.googlecode.com/svn/trunk@807 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
tau.tihon@gmail.com 2012-08-30 15:54:51 +00:00
parent d2469d857a
commit d5f8701f63
2 changed files with 233 additions and 190 deletions

View File

@ -5,6 +5,7 @@ OPERATION_CODE = 0 -- 0 = generation
CX = 0
CZ = 0
CURRENT = 0
TOTAL = 0
-- AREA Variables
AreaStartX = -10
AreaStartZ = -10
@ -23,7 +24,7 @@ function Initialize(Plugin)
PLUGIN = Plugin
PLUGIN:SetName("ChunkWorx")
PLUGIN:SetVersion(5)
PLUGIN:SetVersion(6)
PluginManager = cRoot:Get():GetPluginManager()
PluginManager:AddHook(PLUGIN, cPluginManager.E_PLUGIN_TICK)
@ -95,8 +96,8 @@ function Tick( DeltaTime )
CURRENT = 0
if (WW_instance == nil) then
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED")
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED")
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
GENERATION_STATE = 0
end
end
@ -108,6 +109,7 @@ function Tick( DeltaTime )
and WW_instance:GetLightingQueueLength() < 200
and (WW_instance:GetStorageSaveQueueLength() + WW_instance:GetStorageLoadQueueLength()) < 80) then
local chunk_sum = (1+ AreaEndX - AreaStartX) * (1+ AreaEndZ - AreaStartZ)
TOTAL = chunk_sum
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": PROCESSING 100 chunks, (" .. CURRENT .. "/" .. chunk_sum .. ")")
for C = 1, 100 do
if (GENERATION_STATE == 2) then WW_instance:GenerateChunk(CX, CZ) end

View File

@ -8,7 +8,38 @@ end
function HandleRequest_Generation( Request )
local Content = ""
if (Request.PostParams["AGHRRRR"] ~= nil) then
GENERATION_STATE = 0
WW_instance:SaveAllChunks()
WW_instance:UnloadUnusedChunks()
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
end
--Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
-- PROCESSING
--------------------------------------------------------------------------------------------------
local function ProcessingContent()
local _small_content = ""
_small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
_small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD
if (OPERATION_CODE == 0) then
_small_content = _small_content .. "<h4>Operation:</h4>Generation"
elseif (OPERATION_CODE == 1) then
_small_content = _small_content .. "<h4>Operation:</h4>Regeneration"
end
_small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]"
_small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL
_small_content = _small_content .. "<br>"
_small_content = _small_content .. "<form method='POST'>"
_small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>"
_small_content = _small_content .. "</form>"
return _small_content
end
if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
Content = ProcessingContent()
return Content
end
-- SELECTING
--------------------------------------------------------------------------------------------------
if ( Request.PostParams["FormSetWorld"] ) then
WORK_WORLD = Request.PostParams["FormWorldName"]
WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
@ -53,6 +84,8 @@ function HandleRequest_Generation( Request )
GENERATION_STATE = 3
end
PLUGIN.IniFile:WriteFile()
Content = ProcessingContent()
return Content
end
end
if( Request.PostParams["FormRadialX"] ~= nil
@ -80,6 +113,8 @@ function HandleRequest_Generation( Request )
GENERATION_STATE = 3
end
PLUGIN.IniFile:WriteFile()
Content = ProcessingContent()
return Content
end
end
-- POINT REGEN!
@ -92,6 +127,8 @@ function HandleRequest_Generation( Request )
AreaEndX = AreaStartX
AreaEndZ = AreaStartZ
GENERATION_STATE = 3
Content = ProcessingContent()
return Content
end
-- 3x3
if ( Request.PostParams["Point3x3"] ~= nil) then
@ -100,6 +137,8 @@ function HandleRequest_Generation( Request )
AreaEndX = AreaStartX + 2
AreaEndZ = AreaStartZ + 2
GENERATION_STATE = 3
Content = ProcessingContent()
return Content
end
end
@ -115,6 +154,8 @@ function HandleRequest_Generation( Request )
AreaEndX = AreaStartX
AreaEndZ = AreaStartZ
GENERATION_STATE = 3
Content = ProcessingContent()
return Content
end
if( Request.PostParams["Player3x3"] ~= nil
and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
@ -124,6 +165,8 @@ function HandleRequest_Generation( Request )
AreaEndX = AreaStartX + 2
AreaEndZ = AreaStartZ + 2
GENERATION_STATE = 3
Content = ProcessingContent()
return Content
end
end
@ -210,7 +253,5 @@ function HandleRequest_Generation( Request )
end
Content = Content .. "</table>"
Content = Content .. "<br>"
return Content
end