read tunnel length from different config and fix tests
This commit is contained in:
@@ -18,7 +18,6 @@ cost = 5
|
|||||||
player_placeable = true
|
player_placeable = true
|
||||||
construction_time_seconds = 3
|
construction_time_seconds = 3
|
||||||
surface_mask = ["A>"]
|
surface_mask = ["A>"]
|
||||||
tunnel_max_distance = 10
|
|
||||||
|
|
||||||
[[building]]
|
[[building]]
|
||||||
id = "tunnel_exit"
|
id = "tunnel_exit"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ refund_percentage = 75
|
|||||||
starting_building_blocks = 100
|
starting_building_blocks = 100
|
||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
belt_speed_tiles_per_second = 2
|
||||||
|
tunnel_max_distance = 10
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width = 40
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -19,7 +18,6 @@ struct BuildingDef
|
|||||||
// Stored as raw strings here; parsing into per-cell tiles + output ports
|
// Stored as raw strings here; parsing into per-cell tiles + output ports
|
||||||
// happens when buildings are placed, not at load time.
|
// happens when buildings are placed, not at load time.
|
||||||
std::vector<std::string> surfaceMask;
|
std::vector<std::string> surfaceMask;
|
||||||
std::optional<int> tunnelMaxDistance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuildingsConfig
|
struct BuildingsConfig
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ WorldConfig ConfigLoader::loadWorld(const std::string& path)
|
|||||||
cfg.startingBuildingBlocks = static_cast<int>(requireInt(tbl["world"]["starting_building_blocks"], file, "world.starting_building_blocks"));
|
cfg.startingBuildingBlocks = static_cast<int>(requireInt(tbl["world"]["starting_building_blocks"], file, "world.starting_building_blocks"));
|
||||||
cfg.scrapDespawnSeconds = requireDouble(tbl["world"]["scrap_despawn_seconds"], file, "world.scrap_despawn_seconds");
|
cfg.scrapDespawnSeconds = requireDouble(tbl["world"]["scrap_despawn_seconds"], file, "world.scrap_despawn_seconds");
|
||||||
cfg.beltSpeedTilesPerSecond = requireDouble(tbl["world"]["belt_speed_tiles_per_second"], file, "world.belt_speed_tiles_per_second");
|
cfg.beltSpeedTilesPerSecond = requireDouble(tbl["world"]["belt_speed_tiles_per_second"], file, "world.belt_speed_tiles_per_second");
|
||||||
|
cfg.tunnelMaxDistance = static_cast<int>(requireInt(tbl["world"]["tunnel_max_distance"], file, "world.tunnel_max_distance"));
|
||||||
|
|
||||||
cfg.regions.asteroidWidth = static_cast<int>(requireInt(tbl["regions"]["asteroid_width"], file, "regions.asteroid_width"));
|
cfg.regions.asteroidWidth = static_cast<int>(requireInt(tbl["regions"]["asteroid_width"], file, "regions.asteroid_width"));
|
||||||
cfg.regions.playerBufferWidth = static_cast<int>(requireInt(tbl["regions"]["player_buffer_width"], file, "regions.player_buffer_width"));
|
cfg.regions.playerBufferWidth = static_cast<int>(requireInt(tbl["regions"]["player_buffer_width"], file, "regions.player_buffer_width"));
|
||||||
@@ -275,11 +276,6 @@ BuildingsConfig ConfigLoader::loadBuildings(const std::string& path)
|
|||||||
def.constructionTimeSeconds = requireDouble(mt["construction_time_seconds"], file, elemPath + ".construction_time_seconds");
|
def.constructionTimeSeconds = requireDouble(mt["construction_time_seconds"], file, elemPath + ".construction_time_seconds");
|
||||||
def.surfaceMask = requireStringArray(mt["surface_mask"], file, elemPath + ".surface_mask");
|
def.surfaceMask = requireStringArray(mt["surface_mask"], file, elemPath + ".surface_mask");
|
||||||
|
|
||||||
if (const std::optional<int64_t> tmd = mt["tunnel_max_distance"].value<int64_t>())
|
|
||||||
{
|
|
||||||
def.tunnelMaxDistance = static_cast<int>(*tmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::optional<BuildingType> parsedType = parseBuildingType(def.id);
|
const std::optional<BuildingType> parsedType = parseBuildingType(def.id);
|
||||||
if (!parsedType)
|
if (!parsedType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ struct WorldConfig
|
|||||||
int startingBuildingBlocks; // REQ-HQ-STARTING-BLOCKS
|
int startingBuildingBlocks; // REQ-HQ-STARTING-BLOCKS
|
||||||
double scrapDespawnSeconds; // REQ-RES-SCRAP-DROP
|
double scrapDespawnSeconds; // REQ-RES-SCRAP-DROP
|
||||||
double beltSpeedTilesPerSecond; // REQ-GW-BELT-SPEED
|
double beltSpeedTilesPerSecond; // REQ-GW-BELT-SPEED
|
||||||
|
int tunnelMaxDistance; // REQ-BLD-TUNNEL-PAIR
|
||||||
|
|
||||||
WorldRegions regions;
|
WorldRegions regions;
|
||||||
WorldExpansion expansion;
|
WorldExpansion expansion;
|
||||||
|
|||||||
@@ -427,9 +427,7 @@ void BuildingSystem::tickConstruction(Tick currentTick)
|
|||||||
}
|
}
|
||||||
else if (front.type == BuildingType::TunnelEntry)
|
else if (front.type == BuildingType::TunnelEntry)
|
||||||
{
|
{
|
||||||
const BuildingDef* bdef = findBuildingDef(front.type);
|
m_belts.placeTunnelEntry(front.anchor, front.rotation, m_config.world.tunnelMaxDistance);
|
||||||
const int maxDist = (bdef && bdef->tunnelMaxDistance) ? *bdef->tunnelMaxDistance : 0;
|
|
||||||
m_belts.placeTunnelEntry(front.anchor, front.rotation, maxDist);
|
|
||||||
}
|
}
|
||||||
else if (front.type == BuildingType::TunnelExit)
|
else if (front.type == BuildingType::TunnelExit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ refund_percentage = 75
|
|||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
belt_speed_tiles_per_second = 2
|
||||||
starting_building_blocks = 100
|
starting_building_blocks = 100
|
||||||
|
tunnel_max_distance = 10
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width = 40
|
||||||
@@ -209,6 +210,7 @@ refund_percentage = 75
|
|||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
belt_speed_tiles_per_second = 2
|
||||||
starting_building_blocks = 100
|
starting_building_blocks = 100
|
||||||
|
tunnel_max_distance = 10
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width = 40
|
||||||
@@ -322,3 +324,4 @@ duration_seconds = 1.0
|
|||||||
ConfigLoader::loadRecipes((dir.path() / "recipes.toml").string()),
|
ConfigLoader::loadRecipes((dir.path() / "recipes.toml").string()),
|
||||||
std::runtime_error);
|
std::runtime_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,20 @@ player_placeable = true
|
|||||||
construction_time_seconds = 1
|
construction_time_seconds = 1
|
||||||
surface_mask = ["<A>"]
|
surface_mask = ["<A>"]
|
||||||
|
|
||||||
|
[[building]]
|
||||||
|
id = "tunnel_entry"
|
||||||
|
cost = 5
|
||||||
|
player_placeable = true
|
||||||
|
construction_time_seconds = 3
|
||||||
|
surface_mask = ["A>"]
|
||||||
|
|
||||||
|
[[building]]
|
||||||
|
id = "tunnel_exit"
|
||||||
|
cost = 5
|
||||||
|
player_placeable = true
|
||||||
|
construction_time_seconds = 3
|
||||||
|
surface_mask = ["A>"]
|
||||||
|
|
||||||
[[building]]
|
[[building]]
|
||||||
id = "miner"
|
id = "miner"
|
||||||
cost = 15
|
cost = 15
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ refund_percentage = 75
|
|||||||
starting_building_blocks = 100
|
starting_building_blocks = 100
|
||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
belt_speed_tiles_per_second = 2
|
||||||
|
tunnel_max_distance = 10
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width = 40
|
||||||
|
|||||||
Reference in New Issue
Block a user