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

Fixing bad local var used in shared vision, cleaned up share vision function. Changed to global to avoid desyncs.

This commit is contained in:
Oarcinae 2017-05-21 15:33:52 -04:00
parent 6c994929d9
commit aa4286d9e4
3 changed files with 24 additions and 21 deletions

View File

@ -253,17 +253,10 @@ script.on_event(defines.events.on_built_entity, function(event)
end)
local tick_counter = 0
script.on_event(defines.events.on_tick, function(event)
-- Every few seconds, chart all players to "share vision"
if ENABLE_SHARED_TEAM_VISION then
if (tick_counter >= (TICKS_PER_SECOND*5)) then
ShareVisionBetweenPlayers()
tick_counter = 0
else
tick_counter = tick_counter + 1
end
ShareVisionBetweenPlayers()
end
end)

2
locale

@ -1 +1 @@
Subproject commit bf570538e654615ac588613f28849686f806cf50
Subproject commit a0943ad0f1b78c9d67868a3ea20038443e547a77

View File

@ -188,6 +188,9 @@ function InitSpawnGlobalsAndForces()
if (global.playerCooldowns == nil) then
global.playerCooldowns = {}
end
if (global.tick_counter == nil) then
global.tick_counter = 0
end
game.create_force(MAIN_FORCE)
game.forces[MAIN_FORCE].set_spawn_position(game.forces["player"].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME)
@ -283,21 +286,28 @@ end
-- I have no idea how compute intensive this function is. If it starts to lag the game
-- we'll have to figure out how to change it.
function ShareVisionBetweenPlayers()
for _,force in pairs(game.forces) do
if (force~=nil) then
if ((force.name~=enemy) and
(force.name ~=neutral) and
(force.name ~=player)) then
for _,player in pairs(game.connected_players) do
force.chart(GAME_SURFACE_NAME,
{{player.position.x-CHUNK_SIZE,
player.position.y-CHUNK_SIZE},
{player.position.x+CHUNK_SIZE,
player.position.y+CHUNK_SIZE}})
if (global.tick_counter >= (TICKS_PER_SECOND*5)) then
for _,force in pairs(game.forces) do
if (force ~= nil) then
if ((force.name ~= enemy) and
(force.name ~= neutral) and
(force.name ~= player)) then
for _,player in pairs(game.connected_players) do
force.chart(GAME_SURFACE_NAME,
{{player.position.x-CHUNK_SIZE,
player.position.y-CHUNK_SIZE},
{player.position.x+CHUNK_SIZE,
player.position.y+CHUNK_SIZE}})
end
end
end
end
global.tick_counter = 0
else
global.tick_counter = global.tick_counter + 1
end
end