Skip to content

Commit 0c3497f

Browse files
committed
Make powernet sensors not a subtype of /obj/machinery/power
1 parent b6f9cd8 commit 0c3497f

File tree

9 files changed

+50
-52
lines changed

9 files changed

+50
-52
lines changed

code/game/machinery/pipe/construction.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ Buildable meters
168168
icon = 'icons/obj/objects.dmi'
169169
icon_state = "floor_beacon" // If anyone wants to make better sprite, feel free to do so without asking me.
170170
w_class = ITEM_SIZE_NORMAL
171-
build_type = /obj/machinery/power/sensor
171+
build_type = /obj/machinery/power_sensor

code/modules/modular_computers/file_system/programs/engineering/power_monitor.dm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848

4949
// Checks whether there is an active alarm, if yes, returns 1, otherwise returns 0.
5050
/datum/nano_module/program/power_monitor/proc/has_alarm()
51-
for(var/obj/machinery/power/sensor/S in grid_sensors)
52-
if(S.check_grid_warning())
53-
return 1
54-
return 0
51+
for(var/obj/machinery/power_sensor/S in grid_sensors)
52+
if(S.has_grid_warning())
53+
return TRUE
54+
return FALSE
5555

5656
// If PC is not null header template is loaded. Use PC.get_header_data() to get relevant nanoui data from it. All data entries begin with "PC_...."
5757
// In future it may be expanded to other modular computer devices.
@@ -60,13 +60,13 @@
6060

6161
var/list/sensors = list()
6262
// Focus: If it remains null if no sensor is selected and UI will display sensor list, otherwise it will display sensor reading.
63-
var/obj/machinery/power/sensor/focus = null
63+
var/obj/machinery/power_sensor/focus = null
6464

6565
// Build list of data from sensor readings.
66-
for(var/obj/machinery/power/sensor/S in grid_sensors)
66+
for(var/obj/machinery/power_sensor/S in grid_sensors)
6767
sensors.Add(list(list(
6868
"name" = html_encode(S.id_tag),
69-
"alarm" = S.check_grid_warning()
69+
"alarm" = S.has_grid_warning()
7070
)))
7171
if(S.id_tag == active_sensor)
7272
focus = S
@@ -88,7 +88,7 @@
8888
/datum/nano_module/program/power_monitor/proc/refresh_sensors()
8989
grid_sensors = list()
9090
var/connected_z_levels = SSmapping.get_connected_levels(get_host_z())
91-
for(var/obj/machinery/power/sensor/S in SSmachines.machinery)
91+
for(var/obj/machinery/power_sensor/S in SSmachines.machinery)
9292
if(get_z(S) in connected_z_levels) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
9393
grid_sensors += S
9494
events_repository.register(/decl/observ/destroyed, S, src, TYPE_PROC_REF(/datum/nano_module/program/power_monitor, remove_sensor))

code/modules/power/powernet_sensor.dm

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// may be used in PDAs or similar applications. Second proc, return_reading_data will return list containing needed data.
88
// This is used in NanoUI, for example.
99

10-
/obj/machinery/power/sensor
10+
/obj/machinery/power_sensor
1111
name = "powernet sensor"
1212
desc = "A sensor that records and transmits data about its connected power network."
1313
anchored = TRUE
@@ -24,14 +24,14 @@
2424
// Proc: New()
2525
// Parameters: None
2626
// Description: Automatically assigns name according to ID tag.
27-
/obj/machinery/power/sensor/Initialize()
27+
/obj/machinery/power_sensor/Initialize()
2828
. = ..()
2929
auto_set_name()
3030

3131
// Proc: auto_set_name()
3232
// Parameters: None
3333
// Description: Sets name of this sensor according to the ID tag.
34-
/obj/machinery/power/sensor/proc/auto_set_name()
34+
/obj/machinery/power_sensor/proc/auto_set_name()
3535
if(!id_tag)
3636
var/area/A = get_area(src)
3737
if(!A)
@@ -42,20 +42,17 @@
4242
id_tag = "[A.proper_name][suffix ? " #[suffix]" : null]"
4343
name = "[id_tag] - powernet sensor"
4444

45-
// Proc: check_grid_warning()
45+
// Proc: has_grid_warning()
4646
// Parameters: None
47-
// Description: Checks connected powernet for warnings. If warning is found returns 1
48-
/obj/machinery/power/sensor/proc/check_grid_warning()
49-
connect_to_network()
50-
if(powernet)
51-
if(powernet.problem)
52-
return 1
53-
return 0
47+
// Description: Checks connected powernet for warnings. If warning is found returns TRUE
48+
/obj/machinery/power_sensor/proc/has_grid_warning()
49+
var/datum/powernet/net_to_check = get_powernet()
50+
return net_to_check?.problem ? TRUE : FALSE
5451

5552
// Proc: reading_to_text()
5653
// Parameters: 1 (amount - Power in Watts to be converted to W, kW or MW)
5754
// Description: Helper proc that converts reading in Watts to kW or MW (returns string version of amount parameter)
58-
/obj/machinery/power/sensor/proc/reading_to_text(var/amount = 0)
55+
/obj/machinery/power_sensor/proc/reading_to_text(var/amount = 0)
5956
var/units = ""
6057
// 10kW and less - Watts
6158
if(amount < 10000)
@@ -76,12 +73,13 @@
7673
// Proc: find_apcs()
7774
// Parameters: None
7875
// Description: Searches powernet for APCs and returns them in a list.
79-
/obj/machinery/power/sensor/proc/find_apcs()
80-
if(!powernet)
76+
/obj/machinery/power_sensor/proc/find_apcs()
77+
var/datum/powernet/net_to_check = get_powernet()
78+
if(!net_to_check)
8179
return
8280

8381
var/list/L = list()
84-
for(var/obj/machinery/power/terminal/term in powernet.nodes)
82+
for(var/obj/machinery/power/terminal/term in net_to_check.nodes)
8583
var/obj/machinery/apc/A = term.master_machine()
8684
if(istype(A))
8785
L += A
@@ -91,13 +89,11 @@
9189
// Proc: return_reading_data()
9290
// Parameters: None
9391
// Description: Generates list containing all powernet data. Optimised for usage with NanoUI
94-
/obj/machinery/power/sensor/proc/return_reading_data()
95-
// No powernet. Try to connect to one first.
96-
if(!powernet)
97-
connect_to_network()
92+
/obj/machinery/power_sensor/proc/return_reading_data()
93+
var/datum/powernet/net_to_check = get_powernet()
9894
var/list/data = list()
9995
data["name"] = id_tag
100-
if(!powernet)
96+
if(!net_to_check)
10197
data["error"] = "# SYSTEM ERROR - NO POWERNET #"
10298
data["alarm"] = 0 // Runtime Prevention
10399
return data
@@ -137,16 +133,16 @@
137133
// Add load of this APC to total APC load calculation
138134
total_apc_load += A.lastused_total
139135
data["apc_data"] = APC_data
140-
data["total_avail"] = reading_to_text(max(powernet.avail, 0))
136+
data["total_avail"] = reading_to_text(max(net_to_check.avail, 0))
141137
data["total_used_apc"] = reading_to_text(max(total_apc_load, 0))
142-
data["total_used_other"] = reading_to_text(max(powernet.viewload - total_apc_load, 0))
143-
data["total_used_all"] = reading_to_text(max(powernet.viewload, 0))
138+
data["total_used_other"] = reading_to_text(max(net_to_check.viewload - total_apc_load, 0))
139+
data["total_used_all"] = reading_to_text(max(net_to_check.viewload, 0))
144140
// Prevents runtimes when avail is 0 (division by zero)
145-
if(powernet.avail)
146-
data["load_percentage"] = round((powernet.viewload / powernet.avail) * 100)
141+
if(net_to_check.avail)
142+
data["load_percentage"] = round((net_to_check.viewload / net_to_check.avail) * 100)
147143
else
148144
data["load_percentage"] = 100
149-
data["alarm"] = powernet.problem ? 1 : 0
145+
data["alarm"] = net_to_check.problem ? 1 : 0
150146
return data
151147

152148

maps/away/bearcat/bearcat-2.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3993,7 +3993,7 @@
39933993
/turf/floor/tiled/usedup,
39943994
/area/ship/scrap/maintenance/power)
39953995
"hK" = (
3996-
/obj/machinery/power/sensor{
3996+
/obj/machinery/power_sensor{
39973997
id_tag = "Main Grid"
39983998
},
39993999
/obj/structure/cable{

maps/exodus/exodus-1.dmm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@
15701570
name = "north bump";
15711571
pixel_y = 24
15721572
},
1573-
/obj/machinery/power/sensor{
1573+
/obj/machinery/power_sensor{
15741574
id_tag = "Command Sublevel Subgrid";
15751575
name = "Powernet Sensor - Command Sublevel Subgrid"
15761576
},
@@ -3588,7 +3588,7 @@
35883588
/turf/floor/tiled/steel_grid,
35893589
/area/exodus/engineering/atmos)
35903590
"jx" = (
3591-
/obj/machinery/power/sensor{
3591+
/obj/machinery/power_sensor{
35923592
id_tag = "Atmospherics Subgrid";
35933593
name = "Powernet Sensor - Atmospherics Subgrid"
35943594
},

maps/exodus/exodus-2.dmm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5981,7 +5981,7 @@
59815981
dir = 4;
59825982
pixel_x = -22
59835983
},
5984-
/obj/machinery/power/sensor{
5984+
/obj/machinery/power_sensor{
59855985
id_tag = "Security Subgrid";
59865986
name = "Powernet Sensor - Security Subgrid"
59875987
},
@@ -14969,7 +14969,7 @@
1496914969
/obj/structure/cable/green{
1497014970
icon_state = "0-8"
1497114971
},
14972-
/obj/machinery/power/sensor{
14972+
/obj/machinery/power_sensor{
1497314973
id_tag = "Civilian East Subgrid";
1497414974
name = "Powernet Sensor - Civilian East Subgrid"
1497514975
},
@@ -16978,7 +16978,7 @@
1697816978
/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers{
1697916979
dir = 4
1698016980
},
16981-
/obj/machinery/power/sensor{
16981+
/obj/machinery/power_sensor{
1698216982
id_tag = "Civilian West Subgrid";
1698316983
name = "Powernet Sensor - Civilian West"
1698416984
},
@@ -27810,7 +27810,7 @@
2781027810
/turf/floor/plating,
2781127811
/area/exodus/engineering/engine_room)
2781227812
"bhS" = (
27813-
/obj/machinery/power/sensor{
27813+
/obj/machinery/power_sensor{
2781427814
id_tag = "AI Subgrid";
2781527815
name = "Powernet Sensor - AI Subgrid"
2781627816
},
@@ -31646,7 +31646,7 @@
3164631646
icon_state = "0-4"
3164731647
},
3164831648
/obj/structure/cable/green,
31649-
/obj/machinery/power/sensor{
31649+
/obj/machinery/power_sensor{
3165031650
id_tag = "Command Subgrid";
3165131651
name = "Powernet Sensor - Command Subgrid"
3165231652
},
@@ -37164,7 +37164,7 @@
3716437164
icon_state = "0-4"
3716537165
},
3716637166
/obj/structure/cable/green,
37167-
/obj/machinery/power/sensor{
37167+
/obj/machinery/power_sensor{
3716837168
id_tag = "Medbay Subgrid";
3716937169
name = "Powernet Sensor - Medbay Subgrid"
3717037170
},
@@ -50870,7 +50870,7 @@
5087050870
icon_state = "0-2"
5087150871
},
5087250872
/obj/structure/cable/green,
50873-
/obj/machinery/power/sensor{
50873+
/obj/machinery/power_sensor{
5087450874
id_tag = "Research Subgrid";
5087550875
name = "Powernet Sensor - Research Subgrid"
5087650876
},
@@ -54796,7 +54796,7 @@
5479654796
/obj/structure/cable/green{
5479754797
icon_state = "0-8"
5479854798
},
54799-
/obj/machinery/power/sensor{
54799+
/obj/machinery/power_sensor{
5480054800
id_tag = "Engineering Subgrid";
5480154801
name = "Powernet Sensor - Engineering Subgrid"
5480254802
},
@@ -61661,7 +61661,7 @@
6166161661
/obj/structure/cable{
6166261662
icon_state = "0-4"
6166361663
},
61664-
/obj/machinery/power/sensor{
61664+
/obj/machinery/power_sensor{
6166561665
id_tag = "Master";
6166661666
name = "Powernet Sensor - Master Grid"
6166761667
},
@@ -61872,7 +61872,7 @@
6187261872
dir = 4
6187361873
},
6187461874
/obj/structure/cable/yellow,
61875-
/obj/machinery/power/sensor{
61875+
/obj/machinery/power_sensor{
6187661876
id_tag = "Engine Output";
6187761877
name = "Powernet Sensor - Engine Output"
6187861878
},
@@ -62721,7 +62721,7 @@
6272162721
/obj/structure/cable/cyan{
6272262722
icon_state = "0-8"
6272362723
},
62724-
/obj/machinery/power/sensor{
62724+
/obj/machinery/power_sensor{
6272562725
id_tag = "Engine Power";
6272662726
name = "Powernet Sensor - Engine Power"
6272762727
},

maps/ministation/ministation-0.dmm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6993,7 +6993,7 @@
69936993
/obj/structure/cable{
69946994
icon_state = "0-8"
69956995
},
6996-
/obj/machinery/power/sensor{
6996+
/obj/machinery/power_sensor{
69976997
id_tag = "Station Power";
69986998
name = "Powernet Sensor - Station Power"
69996999
},
@@ -7583,7 +7583,7 @@
75837583
/obj/structure/cable/yellow{
75847584
icon_state = "4-8"
75857585
},
7586-
/obj/machinery/power/sensor{
7586+
/obj/machinery/power_sensor{
75877587
id_tag = "Engine Power";
75887588
name = "Powernet Sensor - Engine Power"
75897589
},

maps/tradeship/tradeship-2.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3434,7 +3434,7 @@
34343434
/turf/floor/tiled/techfloor/grid,
34353435
/area/ship/trade/maintenance/power)
34363436
"ip" = (
3437-
/obj/machinery/power/sensor{
3437+
/obj/machinery/power_sensor{
34383438
id_tag = "Main Grid"
34393439
},
34403440
/obj/structure/cable{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Powernet sensors are no longer a subtype of /obj/machinery/power
2+
/obj/machinery/power/sensor/@SUBTYPES : /obj/machinery/power_sensor/@SUBTYPES{@OLD}

0 commit comments

Comments
 (0)