fixes #6023 and cleans up mechbay.dm

- adds tile update on attackby() to fix #6023 using a so far dormant icon state ( line 49 )
- adds missing console initalization on attack_hand() ( line 189 )
- comments unreachable ( via normal means ) mech_bay_power_console/Topic ( line 225 )
- gets rid of relative paths, leaving procs unchanged
note : recharge-floors currently don't care about what direction the console is, unlike the charger-port which always has to be west of the floor.
this should be probably changed to console having to be east of the floor, as most mappers do that anyway and to reduce the chance of future bugs. awaiting feedback on that one.
 like the charger and floor.
This commit is contained in:
Walter0o
2014-08-18 15:49:38 +02:00
parent 14b1eabf85
commit 2bb22e5ddb

View File

@@ -6,7 +6,7 @@
var/obj/machinery/computer/mech_bay_power_console/recharge_console var/obj/machinery/computer/mech_bay_power_console/recharge_console
var/obj/mecha/recharging_mecha = null var/obj/mecha/recharging_mecha = null
Entered(var/obj/mecha/mecha) /turf/simulated/floor/mech_bay_recharge_floor/Entered(var/obj/mecha/mecha)
. = ..() . = ..()
if(istype(mecha)) if(istype(mecha))
mecha.occupant_message("<b>Initializing power control devices.</b>") mecha.occupant_message("<b>Initializing power control devices.</b>")
@@ -21,7 +21,7 @@
mecha.occupant_message("<font color='red'>Power port not found. Terminating.</font>") mecha.occupant_message("<font color='red'>Power port not found. Terminating.</font>")
return return
Exited(atom) /turf/simulated/floor/mech_bay_recharge_floor/Exited(atom)
. = ..() . = ..()
if(atom == recharging_mecha) if(atom == recharging_mecha)
recharging_mecha = null recharging_mecha = null
@@ -29,9 +29,12 @@
recharge_console.mecha_out() recharge_console.mecha_out()
return return
proc/init_devices() /turf/simulated/floor/mech_bay_recharge_floor/proc/init_devices()
if(!recharge_console)
recharge_console = locate() in range(1,src) recharge_console = locate() in range(1,src)
recharge_port = locate(/obj/machinery/mech_bay_recharge_port, get_step(src, WEST)) if(!recharge_port)
recharge_port = locate() in get_step(src, WEST)
if(recharge_console) if(recharge_console)
recharge_console.recharge_floor = src recharge_console.recharge_floor = src
if(recharge_port) if(recharge_port)
@@ -42,7 +45,13 @@
recharge_port.recharge_console = recharge_console recharge_port.recharge_console = recharge_console
return return
// temporary fix for broken icon until somebody gets around to make these player-buildable
/turf/simulated/floor/mech_bay_recharge_floor/attackby(obj/item/C as obj, mob/user as mob)
..()
if(floor_tile)
icon_state = "recharge_floor"
else
icon_state = "support_lattice"
/obj/machinery/mech_bay_recharge_port /obj/machinery/mech_bay_recharge_port
@@ -55,12 +64,12 @@
var/obj/machinery/computer/mech_bay_power_console/recharge_console var/obj/machinery/computer/mech_bay_power_console/recharge_console
var/datum/global_iterator/mech_bay_recharger/pr_recharger var/datum/global_iterator/mech_bay_recharger/pr_recharger
New() /obj/machinery/mech_bay_recharge_port/New()
..() ..()
pr_recharger = new /datum/global_iterator/mech_bay_recharger(null,0) pr_recharger = new /datum/global_iterator/mech_bay_recharger(null,0)
return return
proc/start_charge(var/obj/mecha/recharging_mecha) /obj/machinery/mech_bay_recharge_port/proc/start_charge(var/obj/mecha/recharging_mecha)
if(stat&(NOPOWER|BROKEN)) if(stat&(NOPOWER|BROKEN))
recharging_mecha.occupant_message("<font color='red'>Power port not responding. Terminating.</font>") recharging_mecha.occupant_message("<font color='red'>Power port not responding. Terminating.</font>")
return 0 return 0
@@ -72,19 +81,19 @@
else else
return 0 return 0
proc/stop_charge() /obj/machinery/mech_bay_recharge_port/proc/stop_charge()
if(recharge_console && !recharge_console.stat) if(recharge_console && !recharge_console.stat)
recharge_console.icon_state = initial(recharge_console.icon_state) recharge_console.icon_state = initial(recharge_console.icon_state)
pr_recharger.stop() pr_recharger.stop()
return return
proc/active() /obj/machinery/mech_bay_recharge_port/proc/active()
if(pr_recharger.active()) if(pr_recharger.active())
return 1 return 1
else else
return 0 return 0
power_change() /obj/machinery/mech_bay_recharge_port/power_change()
if(powered()) if(powered())
stat &= ~NOPOWER stat &= ~NOPOWER
else else
@@ -93,7 +102,7 @@
pr_recharger.stop() pr_recharger.stop()
return return
proc/set_voltage(new_voltage) /obj/machinery/mech_bay_recharge_port/proc/set_voltage(new_voltage)
if(new_voltage && isnum(new_voltage)) if(new_voltage && isnum(new_voltage))
pr_recharger.max_charge = new_voltage pr_recharger.max_charge = new_voltage
return 1 return 1
@@ -106,11 +115,12 @@
var/max_charge = 45 var/max_charge = 45
check_for_null = 0 //since port.stop_charge() must be called. The checks are made in process() check_for_null = 0 //since port.stop_charge() must be called. The checks are made in process()
process(var/obj/machinery/mech_bay_recharge_port/port, var/obj/mecha/mecha) /datum/global_iterator/mech_bay_recharger/process(var/obj/machinery/mech_bay_recharge_port/port, var/obj/mecha/mecha)
if(!port) if(!port)
return 0 return 0
if(mecha && mecha in port.recharge_floor) if(mecha && mecha in port.recharge_floor)
if(!mecha.cell) return if(!mecha.cell)
return
var/delta = min(max_charge, mecha.cell.maxcharge - mecha.cell.charge) var/delta = min(max_charge, mecha.cell.maxcharge - mecha.cell.charge)
if(delta>0) if(delta>0)
mecha.give_power(delta) mecha.give_power(delta)
@@ -123,8 +133,6 @@
return return
/obj/machinery/computer/mech_bay_power_console /obj/machinery/computer/mech_bay_power_console
name = "Mech Bay Power Control Console" name = "Mech Bay Power Control Console"
density = 1 density = 1
@@ -137,7 +145,7 @@
var/turf/simulated/floor/mech_bay_recharge_floor/recharge_floor var/turf/simulated/floor/mech_bay_recharge_floor/recharge_floor
var/obj/machinery/mech_bay_recharge_port/recharge_port var/obj/machinery/mech_bay_recharge_port/recharge_port
proc/mecha_in(var/obj/mecha/mecha) /obj/machinery/computer/mech_bay_power_console/proc/mecha_in(var/obj/mecha/mecha)
if(stat&(NOPOWER|BROKEN)) if(stat&(NOPOWER|BROKEN))
mecha.occupant_message("<font color='red'>Control console not responding. Terminating...</font>") mecha.occupant_message("<font color='red'>Control console not responding. Terminating...</font>")
return return
@@ -148,13 +156,13 @@
src.icon_state = initial(src.icon_state)+"_on" src.icon_state = initial(src.icon_state)+"_on"
return return
proc/mecha_out() /obj/machinery/computer/mech_bay_power_console/proc/mecha_out()
if(recharge_port) if(recharge_port)
recharge_port.stop_charge() recharge_port.stop_charge()
return return
power_change() /obj/machinery/computer/mech_bay_power_console/power_change()
if(stat & BROKEN) if(stat & BROKEN)
icon_state = initial(icon_state)+"_broken" icon_state = initial(icon_state)+"_broken"
if(recharge_port) if(recharge_port)
@@ -169,14 +177,20 @@
if(recharge_port) if(recharge_port)
recharge_port.stop_charge() recharge_port.stop_charge()
set_broken() /obj/machinery/computer/mech_bay_power_console/set_broken()
icon_state = initial(icon_state)+"_broken" icon_state = initial(icon_state)+"_broken"
stat |= BROKEN stat |= BROKEN
if(recharge_port) if(recharge_port)
recharge_port.stop_charge() recharge_port.stop_charge()
attack_hand(mob/user as mob) /obj/machinery/computer/mech_bay_power_console/attack_hand(mob/user as mob)
if(..()) return if(..())
return
if(!recharge_floor || !recharge_port)
var/turf/simulated/floor/mech_bay_recharge_floor/F = locate() in range(1,src)
if(F)
F.init_devices()
var/output = "<html><head><title>[src.name]</title></head><body>" var/output = "<html><head><title>[src.name]</title></head><body>"
if(!recharge_floor) if(!recharge_floor)
output += "<font color='red'>Mech Bay Recharge Station not initialized.</font><br>" output += "<font color='red'>Mech Bay Recharge Station not initialized.</font><br>"
@@ -206,8 +220,9 @@
onclose(user, "mech_bay_console") onclose(user, "mech_bay_console")
return return
// unused at the moment, also lacks any kind of exploit prevention
Topic(href, href_list) /*
/obj/machinery/computer/mech_bay_power_console/Topic(href, href_list)
if(href_list["autostart"]) if(href_list["autostart"])
autostart = !autostart autostart = !autostart
if(href_list["voltage"]) if(href_list["voltage"])
@@ -216,3 +231,4 @@
recharge_port.set_voltage(voltage) recharge_port.set_voltage(voltage)
updateUsrDialog() updateUsrDialog()
return return
*/