Skip to content

Commit

Permalink
[MIRROR] Adds logging to SSore_generation on subsystem initialize (#1448
Browse files Browse the repository at this point in the history
)

* Adds logging to SSore_generation on subsystem initialize (#81488)

This PR adds a new logging category and a logging message specific to
SSore_generation's initialize, logging the number of vents of each size,
as well as the number of random and proximity based ore spawns due to
cave generation and map generation.

Currently drafted as I could use some feedback as to why I'm not seeing
the logger.log() messages not appearing on any of the current in-game
log files 👍

Useful for data logging to determine how many of each type of ore is
spawned on the map, for the purposes of determining how much ore is
being spawned manually over the automatic amounts based on the vents,
with the quantity of ores spawning being a product of the ore vent sizes
being logged as well.

* Adds logging to SSore_generation on subsystem initialize

---------

Co-authored-by: ArcaneMusic <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Mar 15, 2024
1 parent 3bb12e3 commit 58ddcbe
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 32 deletions.
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 @@ -20,27 +20,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 @@ -56,8 +35,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 @@ -425,15 +425,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 @@ -143,15 +143,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 @@ -323,7 +323,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 @@ -334,7 +334,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

0 comments on commit 58ddcbe

Please sign in to comment.