Data Management for Management Game

Blitz3D Forums/Blitz3D Beginners Area/Data Management for Management Game

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

I was thinking about it, and now think that representing unused array elements would be simpler using "blank" objects rather than NULLs.

To move a player from one team to another:

delete p\league[1]\team[12]\player[18]
p\league[1]\team[12]\player[18] = p\league[0]\team[0]\player[0]
p\league[0]\team[0]\player[0] = new player
; update parent pointers
p\league[0]\team[0]\player[0]\team = p\league[0]\team[0]
p\league[1]\team[12]\player[18]\team = p\league[1]\team[12]


or, alternately you could simply swap the pointers if you know there's already a blank object at the destination:

temp.player = p\league[1]\team[12]\player[18]
p\league[1]\team[12]\player[18] = p\league[0]\team[0]\player[0]
p\league[0]\team[0]\player[0] = temp
; update parent pointers
p\league[0]\team[0]\player[0]\team = p\league[0]\team[0]
p\league[1]\team[12]\player[18]\team = p\league[1]\team[12]


This last snippet will also trade two players between two teams.