From b0cabba481a8a289e499d178576fb0ae08a38a7b Mon Sep 17 00:00:00 2001 From: cib Date: Tue, 25 Jun 2013 15:00:58 +0200 Subject: [PATCH] Fixed a severe bug with robot components. There were several desyncs between robot.cell and robot.components["power cell"].installed, leading to very annoying bugs. --- code/game/objects/items/robot/robot_parts.dm | 6 ++++++ code/modules/mob/living/silicon/robot/life.dm | 2 +- code/modules/mob/living/silicon/robot/robot.dm | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm index aa938a13e55..3d3b88f4d06 100644 --- a/code/game/objects/items/robot/robot_parts.dm +++ b/code/game/objects/items/robot/robot_parts.dm @@ -215,6 +215,12 @@ O.cell.loc = O W.loc = O//Should fix cybros run time erroring when blown up. It got deleted before, along with the frame. + // Since we "magically" installed a cell, we also have to update the correct component. + if(O.cell) + var/datum/robot_component/cell_component = O.components["power cell"] + cell_component.wrapped = O.cell + cell_component.installed = 1 + feedback_inc("cyborg_birth",1) O.Namepick() diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index 11d6bea91b4..748c9bdcdca 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -37,7 +37,7 @@ /mob/living/silicon/robot/proc/use_power() - if (is_component_functioning("power cell")) + if (is_component_functioning("power cell") && cell) if(src.cell.charge <= 0) uneq_all() src.stat = 1 diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 6ff3c4a1efa..ace234eb7c2 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -116,13 +116,13 @@ cell.maxcharge = 7500 cell.charge = 7500 + ..() + if(cell) var/datum/robot_component/cell_component = components["power cell"] cell_component.wrapped = cell cell_component.installed = 1 - ..() - playsound(loc, 'sound/voice/liveagain.ogg', 75, 1) // setup the PDA and its name @@ -725,7 +725,7 @@ var/datum/robot_component/C = components["power cell"] if(wiresexposed) user << "Close the panel first." - else if(cell || C.installed) + else if(cell) user << "There is a power cell already installed." else user.drop_item() @@ -1015,6 +1015,8 @@ user.put_in_active_hand(cell) user << "You remove \the [cell]." cell = null + cell_component.wrapped = null + cell_component.installed = 0 updateicon() else if(cell_component.installed == -1) cell_component.installed = 0