Skip to content

Commit

Permalink
Fixes stacks/sheets building turfs not calling ChangeTurf (#4661)
Browse files Browse the repository at this point in the history
# About the pull request

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

This is not only generally bad, it also breaks lighting and area gizmos.

Fixes #4417

# Explain why it's good for the game
Consistency, Integrity, etc

# Testing Photographs and Procedure
Testing protocol: building "temple floor" from runed sandstone sheets
near a wall light on the almayer. Without the patch the turf goes full
black.


# Changelog
:cl:
fix: Fixed issues with turfs, notably lighting, arising when building it
from a sheets stack.
/:cl:
  • Loading branch information
fira committed Oct 15, 2023
1 parent 92ac9a6 commit d5608cf
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions code/game/objects/items/stacks/stack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,21 @@ Also change the icon to reflect the amount of sheets, if possible.*/
if(check_one_per_turf(R,usr))
return

var/atom/O = new R.result_type(usr.loc, usr)
usr.visible_message(SPAN_NOTICE("[usr] assembles \a [O]."),
SPAN_NOTICE("You assemble \a [O]."))
O.setDir(usr.dir)
var/atom/new_item
if(ispath(R.result_type, /turf))
var/turf/current_turf = get_turf(usr)
if(!current_turf)
return
new_item = current_turf.ChangeTurf(R.result_type)
else
new_item = new R.result_type(usr.loc, usr)

usr.visible_message(SPAN_NOTICE("[usr] assembles \a [new_item]."),
SPAN_NOTICE("You assemble \a [new_item]."))
new_item.setDir(usr.dir)
if(R.max_res_amount > 1)
var/obj/item/stack/new_item = O
new_item.amount = R.res_amount * multiplier
var/obj/item/stack/new_stack = new_item
new_stack.amount = R.res_amount * multiplier
amount -= R.req_amount * multiplier
update_icon()

Expand All @@ -218,25 +226,25 @@ Also change the icon to reflect the amount of sheets, if possible.*/
usr.drop_inv_item_on_ground(oldsrc)
qdel(oldsrc)

if(istype(O,/obj/item/stack)) //floor stacking convenience
var/obj/item/stack/S = O
for(var/obj/item/stack/F in usr.loc)
if(S.stack_id == F.stack_id && S != F)
var/diff = F.max_amount - F.amount
if (S.amount < diff)
F.amount += S.amount
qdel(S)
if(istype(new_item,/obj/item/stack)) //floor stacking convenience
var/obj/item/stack/stack_item = new_item
for(var/obj/item/stack/found_item in usr.loc)
if(stack_item.stack_id == found_item.stack_id && stack_item != found_item)
var/diff = found_item.max_amount - found_item.amount
if (stack_item.amount < diff)
found_item.amount += stack_item.amount
qdel(stack_item)
else
S.amount -= diff
F.amount += diff
stack_item.amount -= diff
found_item.amount += diff
break

O?.add_fingerprint(usr)
new_item?.add_fingerprint(usr)

//BubbleWrap - so newly formed boxes are empty
if(isstorage(O))
for (var/obj/item/I in O)
qdel(I)
if(isstorage(new_item))
for (var/obj/item/found_item in new_item)
qdel(found_item)
//BubbleWrap END
if(src && usr.interactee == src) //do not reopen closed window
INVOKE_ASYNC(src, PROC_REF(interact), usr)
Expand Down

0 comments on commit d5608cf

Please sign in to comment.