Ok I'm not sure how viable this is, but how it currently works is that if a reference in a list goes missing, null is left at that index in the list and the length of the list stays the same.
How I thought it worked for a long time (til I found out otherwise recently), and how I would like for it to work, is that if a reference in the list goes missing, it is removed from any lists that contain it, and the list would be shortened by 1 upon its removal.
In the case of my game, the list is filled with mobs. It is the global Player_List. The game loops thru it constantly and frequently for different reasons. I recently found out that every time a player logs out a null reference is left behind in the list and the length stays the same. So I would for example have 30 players online, and 1000 nulls in the list, making the length of the list 1030.
So I was looping thru 1030 entries instead of just 30 entries, causing a lot of lag. I had to make my own function called Remove_nulls(list/L) which just returns a new list without the nulls and assigns it to the old one. This is really inconvenient to have to do in so many places.
Am I just doing something wrong? Or could you guys make it so when a mob deletes all lists that reference it are shrunk by 1? (No null references would be left in the list)
Jan 11 2014, 12:24 pm