tgstation / tgstation

The /tg/station branch of SS13.
https://www.tgstation13.org/
GNU Affero General Public License v3.0
1.72k stars 4.74k forks source link

Placing an item on a disconnected human doesn't show in their UI #3643

Closed Rolan7 closed 10 years ago

Rolan7 commented 10 years ago

To reproduce: Create a human with spawn, or by joining then disconnecting Put a backpack on their back (or put anything in their hands, pockets, backpack, ID slot, or belt. Any slot that isn't hidden by the inventory toggle.) Take control of the mob by ckey or by reconnecting. The item's icon is not present. The victim can't put things into the slot because it's occupied. If it's a hand slot, they can drop the item or put it into another slot (which makes the icon appear correctly in the new slot).

The bug doesn't occur with monkeys. Tested both by possessing a monkey via ckey, and also by putting an item in the hands of a disconnected player-monkey: In both cases the icon appeared in the correct place.

The bug doesn't occur for the slots that can toggled hidden. Those slots are always hidden when a player reconnects, which made me think the toggle was fixing the icons, but if you comment out the I.screen_loc = null in /mob/living/carbon/human/equip_to_slot, the icon always appears but in the mob's right hand. This doesn't occur if you place something in one of the hideable inventory slots.

The comment for "I.screen_loc = null" says "will get moved if inventory is visible". Apparently it is this movement which doesn't take place if the human is disconnected.

Menshin commented 10 years ago

You're absolutely right, the procs in update_icons (tha handles updating the hud) uses checks like that :

if(wear_id)
    if(client && hud_used && hud_used.hud_shown)
        wear_id.screen_loc = ui_id  //place the item in its hud slot
        client.screen += wear_id         //add it to the hud "drawing list"

Disconnected or created mobs are clientless (not to mention hudless, etc), so the item on screen location is never updated (it stays null) and the item is not drawn when returning/possessing.

I don't see why assigning an item its slot should be done if there's a client (or a hud) only. That way of doing (edit : and that's the way of doing for monkeys, hence the bug avoidance)

if(wear_id)
    wear_id.screen_loc = ui_id  //place the item in its hud slot
    if(client && hud_used && hud_used.hud_shown)
        client.screen += wear_id         //add it to the hud "drawing list"

would solve (at least) this problem.

Aranclanos commented 10 years ago

that was my mistake