Skip to content

Commit

Permalink
Fix duplicate outpost IDs. (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
grilledham authored Nov 26, 2023
1 parent 112739c commit c9b64af
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions map_gen/maps/crash_site/presets/UK.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ bounds = b.translate(bounds, x_offset * scale, y_offset * scale)
local config = {
scenario_name = 'crashsite-UK',
map_gen_settings = {MGSP.starting_area_very_low, MGSP.ore_oil_none, MGSP.enemy_none, MGSP.cliff_none},
grid_number_of_blocks = 15,
mini_grid_number_of_blocks = 29,
grid_number_of_blocks = 17,
mini_grid_number_of_blocks = 33,
bounds_shape = bounds
}

Expand Down
13 changes: 6 additions & 7 deletions map_gen/maps/crash_site/presets/manhattan.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
local b = require 'map_gen.shared.builders'
local ScenarioInfo = require 'features.gui.info'
local MGSP = require 'resources.map_gen_settings'
local degrees = require'utils.math'.degrees

local type = type
local water_tiles = b.water_tiles
local path_tiles = b.path_tiles

local pic = require 'map_gen.data.presets.manhattan'
local world_map = b.picture(pic)
local degrees = require "utils.math".degrees
world_map = b.choose(b.rectangle(pic.width, pic.height - 4), world_map, b.empty_shape)

local x_offset, y_offset = 200, 1337
world_map = b.translate(world_map, x_offset, y_offset)
world_map = b.rotate(world_map, degrees(-270))

local scale = 2
local height = 8000 * scale
local width = 8000 * scale

world_map = b.scale(world_map, scale)

local bounds = b.rectangle(width, height)
bounds = b.translate(bounds, x_offset * scale, y_offset * scale)
local bounds = b.rectangle(pic.height * scale, pic.width * scale)
bounds = b.translate(bounds, y_offset * scale, -x_offset * scale)

local config = {
scenario_name = 'crashsite-manhattan',
Expand All @@ -31,8 +30,8 @@ local config = {
MGSP.enemy_none,
MGSP.cliff_none
},
grid_number_of_blocks = 15,
mini_grid_number_of_blocks = 29,
grid_number_of_blocks = 65,
mini_grid_number_of_blocks = 123,
bounds_shape = bounds
}

Expand Down
2 changes: 1 addition & 1 deletion map_gen/maps/crash_site/scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ local function init(config)
end

local outposts =
b.grid_pattern(pattern, grid_number_of_blocks, grid_number_of_blocks, grid_block_size, grid_block_size)
b.grid_pattern_no_repeat(pattern, --[[grid_number_of_blocks, grid_number_of_blocks,]] grid_block_size, grid_block_size)
local mini_outposts =
b.grid_pattern(
mini_pattern,
Expand Down
19 changes: 19 additions & 0 deletions map_gen/shared/builders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,25 @@ function Builders.grid_pattern(pattern, columns, rows, width, height)
end
end

function Builders.grid_pattern_no_repeat(pattern, width, height)
local half_width = width / 2
local half_height = height / 2

return function(x, y, world)
local y2 = ((y + half_height) % height) - half_height
local row_pos = floor(y / height + 0.5)
local row_i = row_pos + 1
local row = pattern[row_i] or {}

local x2 = ((x + half_width) % width) - half_width
local col_pos = floor(x / width + 0.5)
local col_i = col_pos + 1

local shape = row[col_i] or Builders.empty_shape
return shape(x2, y2, world)
end
end

function Builders.grid_pattern_no_offset(pattern, columns, rows, width, height)
return function(x, y, world)
local row_pos = floor(y / height + 0.5)
Expand Down

0 comments on commit c9b64af

Please sign in to comment.