1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2025-02-03 13:01:24 +02:00

Standardized on log() for debug printing.

This commit is contained in:
Oarcinae 2019-03-26 16:56:59 -04:00
parent aa6e2a27db
commit b7bfadf784
6 changed files with 39 additions and 39 deletions

View File

@ -171,7 +171,7 @@ function DelayedSiloCreationOnTick(surface)
-- Delay the creation of the silos so we place them on already generated lands.
if (not global.oarc_silos_generated and (game.tick >= SILO_NUM_SPAWNS*10*TICKS_PER_SECOND)) then
DebugPrint("Frontier silos generated!")
log("Frontier silos generated!")
global.oarc_silos_generated = true
GenerateAllSilos(surface)
end

View File

@ -143,7 +143,7 @@ function GameOptionsGuiClick(event)
local banPlayer = event.element.parent.ban_players_dropdown.get_item(pIndex)
if (game.players[banPlayer]) then
game.ban_player(banPlayer, "Banned from admin panel.")
DebugPrint("Banning " .. banPlayer)
log("Banning " .. banPlayer)
end
end
end
@ -155,7 +155,7 @@ function GameOptionsGuiClick(event)
local resetPlayer = event.element.parent.ban_players_dropdown.get_item(pIndex)
if (game.players[resetPlayer]) then
SeparateSpawnsPlayerCreated(resetPlayer)
DebugPrint("Resetting " .. resetPlayer)
log("Resetting " .. resetPlayer)
end
end
end

View File

@ -263,7 +263,7 @@ function GetRandomVector()
randVec.x = math.random(-3,3)
randVec.y = math.random(-3,3)
end
DebugPrint("direction: x=" .. randVec.x .. ", y=" .. randVec.y)
log("direction: x=" .. randVec.x .. ", y=" .. randVec.y)
return randVec
end
@ -329,7 +329,7 @@ function FindMapEdge(directionVec, surface)
end
end
-- DebugPrint("spawn: x=" .. position.x .. ", y=" .. position.y)
-- log("spawn: x=" .. position.x .. ", y=" .. position.y)
return position
end
@ -354,7 +354,7 @@ function FindUngeneratedCoordinates(minDistChunks, maxDistChunks, surface)
-- Enforce a max number of tries
tryCounter = tryCounter + 1
if (tryCounter > maxTries) then
DebugPrint("FindUngeneratedCoordinates - Max Tries Hit!")
log("FindUngeneratedCoordinates - Max Tries Hit!")
break
-- Check that the distance is within the min,max specified
@ -369,7 +369,7 @@ function FindUngeneratedCoordinates(minDistChunks, maxDistChunks, surface)
end
end
DebugPrint("spawn: x=" .. position.x .. ", y=" .. position.y)
log("spawn: x=" .. position.x .. ", y=" .. position.y)
return position
end
@ -543,7 +543,7 @@ function RemoveWormsInArea(surface, area, small, medium, big, behemoth)
entity.destroy()
end
else
DebugPrint("RemoveWormsInArea had empty worm_types list!")
log("RemoveWormsInArea had empty worm_types list!")
end
end

View File

@ -98,7 +98,7 @@ end
function OarcRegrowthCheckChunkEmpty(event)
if ((event.entity.force ~= nil) and (event.entity.force ~= "neutral") and (event.entity.force ~= "enemy")) then
if CheckChunkEmpty(event.entity.position) then
DebugPrint("Resetting chunk timer."..event.entity.position.x.." "..event.entity.position.y)
log("Resetting chunk timer."..event.entity.position.x.." "..event.entity.position.y)
OarcRegrowthForceRefreshChunk(event.entity.position, 0)
end
end
@ -249,7 +249,7 @@ function OarcRegrowthCheckArray()
-- Increment Y
if (global.chunk_regrow.y_index > global.chunk_regrow.max_y) then
global.chunk_regrow.y_index = global.chunk_regrow.min_y
DebugPrint("Finished checking regrowth array."..global.chunk_regrow.min_x.." "..global.chunk_regrow.max_x.." "..global.chunk_regrow.min_y.." "..global.chunk_regrow.max_y)
log("Finished checking regrowth array."..global.chunk_regrow.min_x.." "..global.chunk_regrow.max_x.." "..global.chunk_regrow.min_y.." "..global.chunk_regrow.max_y)
else
global.chunk_regrow.y_index = global.chunk_regrow.y_index + 1
end
@ -296,7 +296,7 @@ function OarcRegrowthRemoveAllChunks()
end
else
-- DebugPrint("Chunk no longer expired?")
-- log("Chunk no longer expired?")
end
end
end

View File

@ -68,7 +68,7 @@ function FindUnusedSpawns(event)
end
table.remove(global.delayedSpawns, i)
DebugPrint("Removing player from delayed spawn queue: " .. player.name)
log("Removing player from delayed spawn queue: " .. player.name)
end
end
@ -94,7 +94,7 @@ function FindUnusedSpawns(event)
nearOtherSpawn = false
for spawnPlayerName,otherSpawnPos in pairs(global.uniqueSpawns) do
if ((spawnPlayerName ~= player.name) and (getDistance(spawnPos, otherSpawnPos.pos) < (ENFORCE_LAND_AREA_TILE_DIST*3))) then
DebugPrint("Won't remove base as it's close to another spawn: " .. spawnPlayerName)
log("Won't remove base as it's close to another spawn: " .. spawnPlayerName)
nearOtherSpawn = true
end
end
@ -211,7 +211,7 @@ end
function ModifyEnemySpawnsNearPlayerStartingAreas(event)
if (not event.entity or not (event.entity.force.name == "enemy") or not event.entity.position) then
DebugPrint("ModifyBiterSpawns - Unexpected use.")
log("ModifyBiterSpawns - Unexpected use.")
return
end
@ -224,21 +224,21 @@ function ModifyEnemySpawnsNearPlayerStartingAreas(event)
if ((enemy_name == "big-biter") or (enemy_name == "behemoth-biter")) then
event.entity.destroy()
surface.create_entity{name = "medium-biter", position = enemy_pos, force = game.forces.enemy}
DebugPrint("Downgraded biter close to spawn.")
log("Downgraded biter close to spawn.")
elseif ((enemy_name == "big-spitter") or (enemy_name == "behemoth-spitter")) then
event.entity.destroy()
surface.create_entity{name = "medium-spitter", position = enemy_pos, force = game.forces.enemy}
DebugPrint("Downgraded spitter close to spawn.")
log("Downgraded spitter close to spawn.")
end
elseif (getDistance(enemy_pos, spawn.pos) < REDUCED_DANGER_AREA_REDUCTION_RATIO) then
if (enemy_name == "behemoth-biter") then
event.entity.destroy()
surface.create_entity{name = "medium-biter", position = enemy_pos, force = game.forces.enemy}
DebugPrint("Downgraded biter further from spawn.")
log("Downgraded biter further from spawn.")
elseif (enemy_name == "behemoth-spitter") then
event.entity.destroy()
surface.create_entity{name = "medium-spitter", position = enemy_pos, force = game.forces.enemy}
DebugPrint("Downgraded spitter further from spawn.")
log("Downgraded spitter further from spawn.")
end
end
end
@ -481,7 +481,7 @@ function QueuePlayerForDelayedSpawn(playerName, spawn, moatEnabled, vanillaSpawn
DisplayPleaseWaitForSpawnDialog(game.players[playerName], delay_spawn_seconds)
else
DebugPrint("THIS SHOULD NOT EVER HAPPEN! Spawn failed!")
log("THIS SHOULD NOT EVER HAPPEN! Spawn failed!")
SendBroadcastMsg("ERROR!! Failed to create spawn point for: " .. playerName)
end
end
@ -572,7 +572,7 @@ function CreatePlayerCustomForce(player)
-- Check if force already exists
if (game.forces[player.name] ~= nil) then
DebugPrint("Force already exists!")
log("Force already exists!")
player.force = game.forces[player.name]
return game.forces[player.name]
@ -622,7 +622,7 @@ function CreateVanillaSpawns(count, spacing)
log("sqrt_half " .. sqrt_half)
if (sqrt_count < 1) then
DebugPrint("CreateVanillaSpawns less than 1!!")
log("CreateVanillaSpawns less than 1!!")
return
end
@ -695,7 +695,7 @@ function FindUnusedVanillaSpawn(surface, target_distance)
spawn_pos.y = global.vanillaSpawns[best_key].y
table.remove(global.vanillaSpawns, best_key)
end
DebugPrint("Found unused vanilla spawn: x=" .. spawn_pos.x .. ",y=" .. spawn_pos.y)
log("Found unused vanilla spawn: x=" .. spawn_pos.x .. ",y=" .. spawn_pos.y)
return spawn_pos
end

View File

@ -27,7 +27,7 @@ local SPAWN_GUI_MAX_HEIGHT = 1000
-- Meant to be display the first time a player joins.
function DisplayWelcomeTextGui(player)
if (TableLength(player.gui.center.children) > 0) then
DebugPrint("DisplayWelcomeTextGui called while some other dialog is already displayed!")
log("DisplayWelcomeTextGui called while some other dialog is already displayed!")
return
end
player.gui.center.add{name = "welcome_msg",
@ -68,7 +68,7 @@ function WelcomeTextGuiClick(event)
local buttonClicked = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -84,12 +84,12 @@ end
-- Display the spawn options and explanation
function DisplaySpawnOptions(player)
if (player == nil) then
DebugPrint("DisplaySpawnOptions with no valid player...")
log("DisplaySpawnOptions with no valid player...")
return
end
if (player.gui.center.spawn_opts ~= nil) then
DebugPrint("Tried to display spawn options when it was already displayed!")
log("Tried to display spawn options when it was already displayed!")
return
end
player.gui.center.add{name = "spawn_opts",
@ -268,7 +268,7 @@ function SpawnOptsGuiClick(event)
local elemName = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -353,7 +353,7 @@ function SpawnOptsGuiClick(event)
-- If that fails, find a random map edge in a rand direction.
if ((newSpawn.x == 0) and (newSpawn.y == 0)) then
newSpawn = FindMapEdge(GetRandomVector(), player.surface)
DebugPrint("Resorting to find map edge! x=" .. newSpawn.x .. ",y=" .. newSpawn.y)
log("Resorting to find map edge! x=" .. newSpawn.x .. ",y=" .. newSpawn.y)
end
-- Create that player's spawn in the global vars
@ -439,7 +439,7 @@ function SharedSpwnOptsGuiClick(event)
local buttonClicked = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -512,7 +512,7 @@ function SharedSpawnJoinWaitMenuClick(event)
local elemName = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -538,7 +538,7 @@ function SharedSpawnJoinWaitMenuClick(event)
end
end
DebugPrint("ERROR! Failed to remove player from joinQueue!")
log("ERROR! Failed to remove player from joinQueue!")
end
end
@ -647,7 +647,7 @@ function SpawnCtrlGuiOptionsSelect(event)
local name = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -679,7 +679,7 @@ function SpawnCtrlGuiClick(event)
local elemName = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -876,7 +876,7 @@ function BuddySpawnOptsGuiClick(event)
local elemName = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -1013,7 +1013,7 @@ function BuddySpawnWaitMenuClick(event)
local elemName = event.element.name
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -1043,7 +1043,7 @@ end
function DisplayBuddySpawnRequestMenu(player, requestingBuddyName)
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -1103,7 +1103,7 @@ function BuddySpawnRequestMenuClick(event)
local requesterOptions = {}
if not player then
DebugPrint("Another gui click happened with no valid player...")
log("Another gui click happened with no valid player...")
return
end
@ -1124,7 +1124,7 @@ function BuddySpawnRequestMenuClick(event)
if (requesterName == nil) then
player.print("Error! Invalid buddy info...")
DebugPrint("Error! Invalid buddy info...")
log("Error! Invalid buddy info...")
player.gui.center.buddy_request_menu.destroy()
DisplaySpawnOptions(player)
@ -1167,7 +1167,7 @@ function BuddySpawnRequestMenuClick(event)
-- If that fails, find a random map edge in a rand direction.
if ((newSpawn.x == 0) and (newSpawn.x == 0)) then
newSpawn = FindMapEdge(GetRandomVector(), player.surface)
DebugPrint("Resorting to find map edge! x=" .. newSpawn.x .. ",y=" .. newSpawn.y)
log("Resorting to find map edge! x=" .. newSpawn.x .. ",y=" .. newSpawn.y)
end
-- Create that spawn in the global vars