mirror of
https://github.com/veden/Rampant.git
synced 2025-01-03 22:52:20 +02:00
missed some surface index checks
This commit is contained in:
parent
453525d987
commit
8d5a89e245
34
Upgrade.lua
34
Upgrade.lua
@ -56,7 +56,7 @@ function upgrade.attempt(natives)
|
||||
--remove version 14 retreat limit, it has been made redundant
|
||||
natives.retreats = nil
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.14.13")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.14.13")
|
||||
global.version = constants.VERSION_16
|
||||
end
|
||||
if (global.version < constants.VERSION_18) then
|
||||
@ -64,7 +64,7 @@ function upgrade.attempt(natives)
|
||||
natives.safeEntities = {}
|
||||
natives.safeEntityName = {}
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.5")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.5")
|
||||
global.version = constants.VERSION_18
|
||||
end
|
||||
if (global.version < constants.VERSION_20) then
|
||||
@ -72,7 +72,7 @@ function upgrade.attempt(natives)
|
||||
natives.aiPointsScaler = settings.global["rampant-aiPointsScaler"].value
|
||||
natives.aiNocturnalMode = settings.global["rampant-permanentNocturnal"].value
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.8")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.8")
|
||||
global.version = constants.VERSION_20
|
||||
end
|
||||
if (global.version < constants.VERSION_22) then
|
||||
@ -97,7 +97,7 @@ function upgrade.attempt(natives)
|
||||
game.map_settings.unit_group.max_member_slowdown_when_ahead = constants.UNIT_GROUP_MAX_SLOWDOWN
|
||||
game.map_settings.unit_group.max_group_slowdown_factor = constants.UNIT_GROUP_SLOWDOWN_FACTOR
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.10")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.10")
|
||||
global.version = constants.VERSION_22
|
||||
end
|
||||
if (global.version < constants.VERSION_23) then
|
||||
@ -121,33 +121,33 @@ function upgrade.attempt(natives)
|
||||
|
||||
natives.randomGenerator = game.create_random_generator()
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.11")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.11")
|
||||
global.version = constants.VERSION_23
|
||||
end
|
||||
if (global.version < constants.VERSION_25) then
|
||||
|
||||
game.map_settings.path_finder.min_steps_to_check_path_find_termination = constants.PATH_FINDER_MIN_STEPS_TO_CHECK_PATH
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.15")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.15")
|
||||
global.version = constants.VERSION_25
|
||||
end
|
||||
if (global.version < constants.VERSION_26) then
|
||||
|
||||
game.map_settings.max_failed_behavior_count = constants.MAX_FAILED_BEHAVIORS
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.16")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.16")
|
||||
global.version = constants.VERSION_26
|
||||
end
|
||||
if (global.version < constants.VERSION_27) then
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.17")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.17")
|
||||
global.version = constants.VERSION_27
|
||||
end
|
||||
if (global.version < constants.VERSION_33) then
|
||||
|
||||
global.world = nil
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.15.23")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.15.23")
|
||||
global.version = constants.VERSION_33
|
||||
end
|
||||
if (global.version < constants.VERSION_38) then
|
||||
@ -158,7 +158,7 @@ function upgrade.attempt(natives)
|
||||
|
||||
global.regionMap = nil
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.3")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.3")
|
||||
global.version = constants.VERSION_38
|
||||
end
|
||||
if (global.version < constants.VERSION_41) then
|
||||
@ -170,14 +170,14 @@ function upgrade.attempt(natives)
|
||||
natives.baseIndex = 1
|
||||
natives.baseIncrement = 0
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.6")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.6")
|
||||
global.version = constants.VERSION_41
|
||||
end
|
||||
if (global.version < constants.VERSION_44) then
|
||||
|
||||
natives.kamikazeThreshold = 0
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.9")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.9")
|
||||
global.version = constants.VERSION_44
|
||||
end
|
||||
if (global.version < constants.VERSION_51) then
|
||||
@ -186,7 +186,7 @@ function upgrade.attempt(natives)
|
||||
natives.tunnels = nil
|
||||
natives.baseLookup = nil
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.16")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.16")
|
||||
global.version = constants.VERSION_51
|
||||
end
|
||||
if (global.version < constants.VERSION_57) then
|
||||
@ -214,14 +214,12 @@ function upgrade.attempt(natives)
|
||||
natives.settlerWaveDeviation = 0
|
||||
natives.settlerWaveSize = 0
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.22")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.22")
|
||||
global.version = constants.VERSION_57
|
||||
end
|
||||
if (global.version < constants.VERSION_62) then
|
||||
|
||||
natives.activeSurface = 1
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.27")
|
||||
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.27")
|
||||
global.version = constants.VERSION_62
|
||||
end
|
||||
|
||||
|
32
control.lua
32
control.lua
@ -119,7 +119,7 @@ local function onIonCannonFired(event)
|
||||
event.force, event.surface, event.player_index, event.position, event.radius
|
||||
--]]
|
||||
local surface = event.surface
|
||||
if (surface.index == 1) then
|
||||
if (surface.index == natives.activeSurface) then
|
||||
natives.points = natives.points + 3000
|
||||
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
||||
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||
@ -157,7 +157,7 @@ end
|
||||
local function onChunkGenerated(event)
|
||||
-- queue generated chunk for delayed processing, queuing is required because some mods (RSO) mess with chunk as they
|
||||
-- are generated, which messes up the scoring.
|
||||
if (event.surface.index == 1) then
|
||||
if (event.surface.index == natives.activeSurface) then
|
||||
pendingChunks[#pendingChunks+1] = event
|
||||
end
|
||||
end
|
||||
@ -303,15 +303,17 @@ end
|
||||
|
||||
local function onConfigChanged()
|
||||
local upgraded
|
||||
upgraded, natives = upgrade.attempt(natives)
|
||||
onModSettingsChange(nil)
|
||||
if (game.surfaces["battle_surface_2"]) then
|
||||
|
||||
if (game.surfaces["battle_surface_2"] ~= nil) then
|
||||
natives.activeSurface = game.surfaces["battle_surface_2"].index
|
||||
elseif (game.surfaces["battle_surface_1"]) then
|
||||
elseif (game.surfaces["battle_surface_1"] ~= nil) then
|
||||
natives.activeSurface = game.surfaces["battle_surface_1"].index
|
||||
elseif (game.surfaces["battle_surface_1"]) then
|
||||
else
|
||||
natives.activeSurface = game.surfaces["nauvis"].index
|
||||
end
|
||||
|
||||
upgraded, natives = upgrade.attempt(natives)
|
||||
onModSettingsChange(nil)
|
||||
if upgraded then
|
||||
rebuildMap()
|
||||
|
||||
@ -395,7 +397,7 @@ end)
|
||||
|
||||
local function onBuild(event)
|
||||
local entity = event.created_entity
|
||||
if (entity.surface.index == 1) then
|
||||
if (entity.surface.index == natives.activeSurface) then
|
||||
addRemovePlayerEntity(map, entity, natives, true, false)
|
||||
if natives.safeBuildings then
|
||||
if natives.safeEntities[entity.type] or natives.safeEntityName[entity.name] then
|
||||
@ -408,7 +410,7 @@ end
|
||||
local function onMine(event)
|
||||
local entity = event.entity
|
||||
local surface = entity.surface
|
||||
if (surface.index == 1) then
|
||||
if (surface.index == natives.activeSurface) then
|
||||
addRemovePlayerEntity(map, entity, natives, false, false)
|
||||
end
|
||||
end
|
||||
@ -416,7 +418,7 @@ end
|
||||
local function onDeath(event)
|
||||
local entity = event.entity
|
||||
local surface = entity.surface
|
||||
if (surface.index == 1) then
|
||||
if (surface.index == natives.activeSurface) then
|
||||
local entityPosition = entity.position
|
||||
local chunk = getChunkByPosition(map, entityPosition)
|
||||
local cause = event.cause
|
||||
@ -488,7 +490,7 @@ local function onEnemyBaseBuild(event)
|
||||
local entity = event.entity
|
||||
local surface = entity.surface
|
||||
|
||||
if entity.valid and (surface.index == 1) then
|
||||
if entity.valid and (surface.index == natives.activeSurface) then
|
||||
local chunk = getChunkByPosition(map, entity.position)
|
||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||
local evolutionFactor = entity.force.evolution_factor
|
||||
@ -542,14 +544,14 @@ end
|
||||
|
||||
local function onResourceDepleted(event)
|
||||
local entity = event.entity
|
||||
if (entity.surface.index == 1) then
|
||||
if (entity.surface.index == natives.activeSurface) then
|
||||
chunkUtils.unregisterResource(entity, map)
|
||||
end
|
||||
end
|
||||
|
||||
local function onTriggerEntityCreated(event)
|
||||
local entity = event.entity
|
||||
if entity and entity.valid and (entity.surface.index == 1) then
|
||||
if entity and entity.valid and (entity.surface.index == natives.activeSurface) then
|
||||
local name = event.entity.name
|
||||
if isSpawner(name) then
|
||||
local tick = event.tick
|
||||
@ -568,7 +570,7 @@ end
|
||||
|
||||
local function onUsedCapsule(event)
|
||||
local surface = game.players[event.player_index].surface
|
||||
if (event.item.name == "cliff-explosives") and (surface.index == 1) then
|
||||
if (event.item.name == "cliff-explosives") and (surface.index == natives.activeSurface) then
|
||||
local cliffs = surface.find_entities_filtered({area={{event.position.x-0.75,event.position.y-0.75},
|
||||
{event.position.x+0.75,event.position.y+0.75}},
|
||||
type="cliff"})
|
||||
@ -580,7 +582,7 @@ end
|
||||
|
||||
local function onRocketLaunch(event)
|
||||
local entity = event.rocket_silo or event.rocket
|
||||
if entity and (entity.surface.index == 1) then
|
||||
if entity and (entity.surface.index == natives.activeSurface) then
|
||||
natives.points = natives.points + 2000
|
||||
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
||||
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||
|
28
tests.lua
28
tests.lua
@ -30,7 +30,7 @@ function tests.pheromoneLevels(size)
|
||||
for i=1,#chunk do
|
||||
str = str .. " " .. tostring(i) .. "/" .. tostring(chunk[i])
|
||||
end
|
||||
str = str .. " " .. "p/" .. game.surfaces[natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
|
||||
str = str .. " " .. "p/" .. game.surfaces[global.natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
|
||||
if (chunk.x == playerChunkX) and (chunk.y == playerChunkY) then
|
||||
print("=============")
|
||||
print(chunk.x, chunk.y, str)
|
||||
@ -99,7 +99,7 @@ function tests.entitiesOnPlayerChunk()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local entities = game.surfaces[natives.activeSurface].find_entities_filtered({area={{chunkX, chunkY},
|
||||
local entities = game.surfaces[global.natives.activeSurface].find_entities_filtered({area={{chunkX, chunkY},
|
||||
{chunkX + constants.CHUNK_SIZE, chunkY + constants.CHUNK_SIZE}},
|
||||
force="player"})
|
||||
for i=1, #entities do
|
||||
@ -112,7 +112,7 @@ function tests.findNearestPlayerEnemy()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local entity = game.surfaces[natives.activeSurface].find_nearest_enemy({position={chunkX, chunkY},
|
||||
local entity = game.surfaces[global.natives.activeSurface].find_nearest_enemy({position={chunkX, chunkY},
|
||||
max_distance=constants.CHUNK_SIZE,
|
||||
force = "enemy"})
|
||||
if (entity ~= nil) then
|
||||
@ -141,7 +141,7 @@ function tests.fillableDirtTest()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
game.surfaces[natives.activeSurface].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
||||
game.surfaces[global.natives.activeSurface].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
||||
{name="fillableDirt", position={chunkX, chunkY-1}},
|
||||
{name="fillableDirt", position={chunkX-1, chunkY}},
|
||||
{name="fillableDirt", position={chunkX, chunkY}}},
|
||||
@ -152,7 +152,7 @@ function tests.tunnelTest()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
game.surfaces[natives.activeSurface].create_entity({name="tunnel-entrance-rampant", position={chunkX, chunkY}})
|
||||
game.surfaces[global.natives.activeSurface].create_entity({name="tunnel-entrance-rampant", position={chunkX, chunkY}})
|
||||
end
|
||||
|
||||
function tests.createEnemy(x,d)
|
||||
@ -163,7 +163,7 @@ function tests.createEnemy(x,d)
|
||||
if d then
|
||||
a['direction'] = d
|
||||
end
|
||||
return game.surfaces[natives.activeSurface].create_entity(a)
|
||||
return game.surfaces[global.natives.activeSurface].create_entity(a)
|
||||
end
|
||||
|
||||
function tests.registeredNest(x)
|
||||
@ -174,7 +174,7 @@ function tests.registeredNest(x)
|
||||
end
|
||||
|
||||
function tests.attackOrigin()
|
||||
local enemy = game.surfaces[natives.activeSurface].find_nearest_enemy({position={0,0},
|
||||
local enemy = game.surfaces[global.natives.activeSurface].find_nearest_enemy({position={0,0},
|
||||
max_distance = 1000})
|
||||
if (enemy ~= nil) and enemy.valid then
|
||||
print(enemy, enemy.unit_number)
|
||||
@ -241,7 +241,7 @@ end
|
||||
|
||||
function tests.clearBases()
|
||||
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
local surface = game.surfaces[global.natives.activeSurface]
|
||||
for x=#global.natives.bases,1,-1 do
|
||||
local base = global.natives.bases[x]
|
||||
for c=1,#base.chunks do
|
||||
@ -302,7 +302,7 @@ function tests.showBaseGrid()
|
||||
elseif (pick == 3) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -318,7 +318,7 @@ function tests.showMovementGrid()
|
||||
elseif (chunk[constants.PASSABLE] == constants.CHUNK_EAST_WEST) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -334,7 +334,7 @@ function tests.colorResourcePoints()
|
||||
elseif (chunk[constants.NEST_COUNT] ~= 0) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -342,7 +342,7 @@ function tests.entityStats(name, d)
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local a = game.surfaces[natives.activeSurface].create_entity({name=name, position={chunkX, chunkY}})
|
||||
local a = game.surfaces[global.natives.activeSurface].create_entity({name=name, position={chunkX, chunkY}})
|
||||
if d then
|
||||
a['direction'] = d
|
||||
end
|
||||
@ -393,7 +393,7 @@ function tests.exportAiState()
|
||||
end
|
||||
|
||||
function tests.unitGroupBuild()
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
local surface = game.surfaces[global.natives.activeSurface]
|
||||
local group = surface.create_unit_group({position={-32, -32}})
|
||||
|
||||
for i=1,10 do
|
||||
@ -414,7 +414,7 @@ end
|
||||
|
||||
function tests.stepAdvanceTendrils()
|
||||
-- for _, base in pairs(global.natives.bases) do
|
||||
-- tendrilUtils.advanceTendrils(global.map, base, game.surfaces[natives.activeSurface], {nil,nil,nil,nil,nil,nil,nil,nil})
|
||||
-- tendrilUtils.advanceTendrils(global.map, base, game.surfaces[global.natives.activeSurface], {nil,nil,nil,nil,nil,nil,nil,nil})
|
||||
-- end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user