Skip to content

Commit

Permalink
Fixes empty cell icons being improperly displayed.
Browse files Browse the repository at this point in the history
  • Loading branch information
afterthought2 committed Oct 20, 2018
1 parent e6f768c commit 5c92384
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 38 deletions.
21 changes: 8 additions & 13 deletions code/modules/power/batteryrack.dm
Expand Up @@ -217,18 +217,17 @@
data["cells_max"] = max_cells
data["cells_cur"] = internal_cells.len
var/list/cells = list()
var/cell_index = 0
var/cell_index = 1
for(var/obj/item/weapon/cell/C in internal_cells)
var/list/cell[0]
cell["slot"] = cell_index + 1
cell["slot"] = cell_index
cell["used"] = 1
cell["percentage"] = round(C.percent(), 0.01)
cell["id"] = C.c_uid
cell_index++
cells += list(cell)
while(cell_index < PSU_MAXCELLS)
while(cell_index <= PSU_MAXCELLS)
var/list/cell[0]
cell["slot"] = cell_index + 1
cell["slot"] = cell_index
cell["used"] = 0
cell_index++
cells += list(cell)
Expand Down Expand Up @@ -291,16 +290,12 @@
equalise = 0
return 1
else if( href_list["ejectcell"] )
var/obj/item/weapon/cell/C
for(var/obj/item/weapon/cell/CL in internal_cells)
if(CL.c_uid == text2num(href_list["ejectcell"]))
C = CL
break

if(!istype(C))
var/slot_number = text2num(href_list["ejectcell"])
if(slot_number != Clamp(round(slot_number), 1, length(internal_cells)))
return 1
var/obj/item/weapon/cell/C = internal_cells[slot_number]

C.forceMove(get_turf(src))
C.dropInto(loc)
internal_cells -= C
update_icon()
RefreshParts()
Expand Down
31 changes: 7 additions & 24 deletions code/modules/power/cell.dm
Expand Up @@ -11,21 +11,15 @@
throw_speed = 3
throw_range = 5
w_class = ITEM_SIZE_NORMAL
var/c_uid
var/charge // Current charge
var/maxcharge = 1000 // Capacity in Wh
var/overlay_state
matter = list(MATERIAL_STEEL = 700, MATERIAL_GLASS = 50)


/obj/item/weapon/cell/New()
if(isnull(charge))
charge = maxcharge
c_uid = sequential_id(/obj/item/weapon/cell)
..()

/obj/item/weapon/cell/Initialize()
. = ..()
if(isnull(charge))
charge = maxcharge
update_icon()

/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
Expand Down Expand Up @@ -135,9 +129,9 @@
maxcharge = 100
matter = list(MATERIAL_STEEL = 70, MATERIAL_GLASS = 5)

/obj/item/weapon/cell/device/variable/New(newloc, charge_amount)
/obj/item/weapon/cell/device/variable/Initialize(mapload, charge_amount)
maxcharge = charge_amount
..(newloc)
return ..(mapload)

/obj/item/weapon/cell/device/standard
name = "standard device power cell"
Expand Down Expand Up @@ -167,11 +161,6 @@
maxcharge = 250
matter = list(MATERIAL_STEEL = 700, MATERIAL_GLASS = 40)

/obj/item/weapon/cell/crap/empty/New()
..()
charge = 0


/obj/item/weapon/cell/apc
name = "APC power cell"
desc = "A special power cell designed for heavy-duty use in area power controllers."
Expand All @@ -188,11 +177,9 @@
maxcharge = 1000
matter = list(MATERIAL_STEEL = 700, MATERIAL_GLASS = 60)

/obj/item/weapon/cell/high/empty/New()
..()
/obj/item/weapon/cell/high/empty
charge = 0


/obj/item/weapon/cell/mecha
name = "exosuit power cell"
desc = "A special power cell designed for heavy-duty use in industrial exosuits."
Expand All @@ -210,11 +197,9 @@
maxcharge = 2000
matter = list(MATERIAL_STEEL = 700, MATERIAL_GLASS = 70)

/obj/item/weapon/cell/super/empty/New()
..()
/obj/item/weapon/cell/super/empty
charge = 0


/obj/item/weapon/cell/hyper
name = "superior power cell"
desc = "Pinnacle of power storage technology, this very expensive power cell provides the best energy density reachable with conventional electrochemical cells."
Expand All @@ -223,11 +208,9 @@
maxcharge = 3000
matter = list(MATERIAL_STEEL = 700, MATERIAL_GLASS = 80)

/obj/item/weapon/cell/hyper/empty/New()
..()
/obj/item/weapon/cell/hyper/empty
charge = 0


/obj/item/weapon/cell/infinite
name = "experimental power cell"
desc = "This special experimental power cell has both very large capacity, and ability to recharge itself by draining power from contained bluespace pocket."
Expand Down
2 changes: 1 addition & 1 deletion nano/templates/psu.tmpl
Expand Up @@ -48,7 +48,7 @@
{{if value.used}}
<td>{{:helper.displayBar(value.percentage, 0, 100, 'good')}}
<td>{{:value.percentage}} %
<td>{{:helper.link('E', null, { "ejectcell" : value.id })}}
<td>{{:helper.link('E', null, { "ejectcell" : value.slot })}}
{{else}}
<td>{{:helper.displayBar(100, 0, 100, 'bad')}}
<td>N/C
Expand Down

0 comments on commit 5c92384

Please sign in to comment.