mob
proc
Update_Hand()
if(!client)
return
for(var/obj/card/c in client.screen)
c.layer = OBJ_LAYER
client.screen -= c //remove all cards from screen.
var/hand_length = 1
while(hand_length <= hand.len)
var/obj/card/c = hand[hand_length]
c.layer = MOB_LAYER+1
var/obj/hand/screen_spot
for(var/obj/hand/h in client.screen)
if(istype(h, text2path("/obj/hand/h[hand_length]")))
screen_spot = h
c.icon = c.hand_icon
screen_spot.card = c
c.screen_loc = screen_spot.screen_loc
client.screen += c
hand_length ++
Problem description:
Pretty much what I am using seems fine, but I have narrowed it down to what seems to be this block of code. I can't be 100% certain though, as whatever it is is crashing the game so much I can't even read the error messages.
Anyways, the point of this block of code is to add cards to a screen based on the cards in the player's list; "hand". Does anyone see any reason why this code could potentially cause an infinite loop?
P.S.
Also it might be worth mentioning that I call this procedure everytime I add a new card to the hand, so this means if I were to draw 5 cards at the beginning of a game, it would call this block 5 times (including sleep(10) between each draw card to add to the effect).
EDIT: Also this Update_Hand() procedure actually does work entirely, but when I end a game and start a new one, the issue seems to stem from here. I am not sure why though.
I don't see any obvious problems with that code. The only errors I could see appearing are if the hand list is null or contains null entries, or there are more cards in the hand than screen_spot types to hold them (all of which would give you "cannot read null.[var]" errors). I don't see any infinite loops.
Can you show us how you're clearing the hand card list?