Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Adds logging to SSore_generation on subsystem initialize #2916

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#define LOG_CATEGORY_TOOL "tool"
#define LOG_CATEGORY_TRANSPORT "transport"
#define LOG_CATEGORY_VIRUS "virus"
#define LOG_CATEGORY_CAVE_GENERATION "cave-generation"

// Admin categories
#define LOG_CATEGORY_ADMIN "admin"
Expand Down
11 changes: 11 additions & 0 deletions code/__DEFINES/mining.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
/// The chance of ore spawning in a wall that is VENT_PROX_FAR tiles to a vent.
#define VENT_CHANCE_FAR 1

/// The amount of ore that is mined from a wall that is VENT_PROX_VERY_HIGH tiles to a vent.
#define ORE_WALL_VERY_HIGH 5
/// The amount of ore that is mined from a wall that is VENT_PROX_HIGH tiles to a vent.
#define ORE_WALL_HIGH 4
/// The amount of ore that is mined from a wall that is VENT_PROX_MEDIUM tiles to a vent.
#define ORE_WALL_MEDIUM 3
/// The amount of ore that is mined from a wall that is VENT_PROX_LOW tiles to a vent.
#define ORE_WALL_LOW 2
/// The amount of ore that is mined from a wall that is VENT_PROX_FAR tiles to a vent.
#define ORE_WALL_FAR 1

/// The number of points a miner gets for discovering a vent, multiplied by BOULDER_SIZE when completing a wave defense minus the discovery bonus.
#define MINER_POINT_MULTIPLIER 100
/// The multiplier that gets applied for automatically generated mining points.
Expand Down
23 changes: 23 additions & 0 deletions code/_globalvars/lists/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,26 @@ GLOBAL_LIST_INIT(megafauna_spawn_list, list(
/mob/living/simple_animal/hostile/megafauna/colossus = 2,
/mob/living/simple_animal/hostile/megafauna/dragon = 4,
))

/// List of how many minerals spawned based on proximity to an ore vent.
GLOBAL_LIST_INIT(post_ore_random, list(
"[ORE_WALL_FAR]" = 0,
"[ORE_WALL_LOW]" = 0,
"[ORE_WALL_MEDIUM]" = 0,
"[ORE_WALL_HIGH]" = 0,
"[ORE_WALL_VERY_HIGH]" = 0,
))
/// List of how many minerals spawned randomly off of mining Z-levels, and at what quantity.
GLOBAL_LIST_INIT(post_ore_manual, list(
"[ORE_WALL_FAR]" = 0,
"[ORE_WALL_LOW]" = 0,
"[ORE_WALL_MEDIUM]" = 0,
"[ORE_WALL_HIGH]" = 0,
"[ORE_WALL_VERY_HIGH]" = 0,
))
/// List of how many ore vents spawned, and of what size.
GLOBAL_LIST_INIT(ore_vent_sizes, list(
LARGE_VENT_TYPE = 0,
MEDIUM_VENT_TYPE = 0,
SMALL_VENT_TYPE = 0,
))
58 changes: 36 additions & 22 deletions code/controllers/subsystem/ore_generation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@ SUBSYSTEM_DEF(ore_generation)
*/
var/list/ore_vent_minerals = list()
/// A tracker of how many of each ore vent size we have in the game. Useful for tracking purposes.
var/list/ore_vent_sizes = list(
LARGE_VENT_TYPE = 0,
MEDIUM_VENT_TYPE = 0,
SMALL_VENT_TYPE = 0,
)
/// Ores spawned by proximity to an ore vent. Useful for logging purposes.
var/list/post_ore_random = list(
"1" = 0,
"2" = 0,
"3" = 0,
"4" = 0,
"5" = 0,
)
/// Ores spawned randomly on the map without proximity to an ore vent. Useful for logging purposes.
var/list/post_ore_manual = list(
"1" = 0,
"2" = 0,
"3" = 0,
"4" = 0,
"5" = 0,
)

/datum/controller/subsystem/ore_generation/Initialize()
//Basically, we're going to round robin through the list of ore vents and assign a mineral to them until complete.
Expand All @@ -55,8 +34,43 @@ SUBSYSTEM_DEF(ore_generation)
else
stallbreaker++
if(stallbreaker >= length(possible_vents))
return SS_INIT_SUCCESS //We've done all we can here.
break //We've done all we can here. break inner loop
continue
if(stallbreaker >= length(possible_vents))
break //We've done all we can here. break outer loop

/// Handles roundstart logging
logger.Log(
LOG_CATEGORY_CAVE_GENERATION,
"Ore Generation spawned the following ores based on vent proximity",
list(
"[ORE_WALL_FAR]" = GLOB.post_ore_random["[ORE_WALL_FAR]"],
"[ORE_WALL_LOW]" = GLOB.post_ore_random["[ORE_WALL_LOW]"],
"[ORE_WALL_MEDIUM]" = GLOB.post_ore_random["[ORE_WALL_MEDIUM]"],
"[ORE_WALL_HIGH]" = GLOB.post_ore_random["[ORE_WALL_HIGH]"],
"[ORE_WALL_VERY_HIGH]" = GLOB.post_ore_random["[ORE_WALL_VERY_HIGH]"],
),
)
logger.Log(
LOG_CATEGORY_CAVE_GENERATION,
"Ore Generation spawned the following ores randomly",
list(
"[ORE_WALL_FAR]" = GLOB.post_ore_manual["[ORE_WALL_FAR]"],
"[ORE_WALL_LOW]" = GLOB.post_ore_manual["[ORE_WALL_LOW]"],
"[ORE_WALL_MEDIUM]" = GLOB.post_ore_manual["[ORE_WALL_MEDIUM]"],
"[ORE_WALL_HIGH]" = GLOB.post_ore_manual["[ORE_WALL_HIGH]"],
"[ORE_WALL_VERY_HIGH]" = GLOB.post_ore_manual["[ORE_WALL_VERY_HIGH]"],
),
)
logger.Log(
LOG_CATEGORY_CAVE_GENERATION,
"Ore Generation spawned the following vent sizes",
list(
"large" = LAZYACCESS(GLOB.ore_vent_sizes, LARGE_VENT_TYPE),
"medium" = LAZYACCESS(GLOB.ore_vent_sizes, MEDIUM_VENT_TYPE),
"small" = LAZYACCESS(GLOB.ore_vent_sizes, SMALL_VENT_TYPE),
),
)
return SS_INIT_SUCCESS

/datum/controller/subsystem/ore_generation/fire(resumed)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/structures/lavaland/ore_vent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,15 @@
if(LARGE_VENT_TYPE)
boulder_size = BOULDER_SIZE_LARGE
if(mapload)
SSore_generation.ore_vent_sizes["large"] += 1
GLOB.ore_vent_sizes["large"] += 1
if(MEDIUM_VENT_TYPE)
boulder_size = BOULDER_SIZE_MEDIUM
if(mapload)
SSore_generation.ore_vent_sizes["medium"] += 1
GLOB.ore_vent_sizes["medium"] += 1
if(SMALL_VENT_TYPE)
boulder_size = BOULDER_SIZE_SMALL
if(mapload)
SSore_generation.ore_vent_sizes["small"] += 1
GLOB.ore_vent_sizes["small"] += 1
else
boulder_size = BOULDER_SIZE_SMALL //Might as well set a default value
name = initial(name)
Expand Down
14 changes: 7 additions & 7 deletions code/game/turfs/closed/minerals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@
return rand(1,5)

if(distance < VENT_PROX_VERY_HIGH)
return 5
return ORE_WALL_VERY_HIGH
if(distance < VENT_PROX_HIGH)
return 4
return ORE_WALL_HIGH
if(distance < VENT_PROX_MEDIUM)
return 3
return ORE_WALL_MEDIUM
if(distance < VENT_PROX_LOW)
return 2
return ORE_WALL_LOW
if(distance < VENT_PROX_FAR)
return 1
return ORE_WALL_FAR
return 0

/turf/closed/mineral/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
Expand Down Expand Up @@ -319,7 +319,7 @@
var/turf/closed/mineral/M = T
M.turf_type = src.turf_type
M.mineralAmt = scale_ore_to_vent()
SSore_generation.post_ore_random["[M.mineralAmt]"] += 1
GLOB.post_ore_random["[M.mineralAmt]"] += 1
src = M
M.levelupdate()
else
Expand All @@ -330,7 +330,7 @@
Change_Ore(path, FALSE)
Spread_Vein(path)
mineralAmt = scale_ore_to_vent()
SSore_generation.post_ore_manual["[mineralAmt]"] += 1
GLOB.post_ore_manual["[mineralAmt]"] += 1

/turf/closed/mineral/random/high_chance
icon_state = "rock_highchance"
Expand Down
3 changes: 3 additions & 0 deletions code/modules/logging/categories/log_category_misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@
category = LOG_CATEGORY_QDEL
// We want this human readable so it's easy to see at a glance
entry_flags = ENTRY_USE_DATA_W_READABLE

/datum/log_category/cave_generation
category = LOG_CATEGORY_CAVE_GENERATION
Loading