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