What to use? Enum or Array?
#3

You are using arrays in all the cases you have listed, however PlayerData is a two-dimensional array, MAX_PLAYERS * pInfo (where pInfo is really the total size of the 'pInfo' enumerator (which in your case is 8 + MAX_PLAYER_NAME + 16 (ip).
Then you just refer to the cell in the array basing on the enumerator.
So PlayerData[0][pDeaths] is really PlayerData[0][2] (pAdmin = 0, pKills = 1, pDeaths = 2)
Enumerator is not a data storage type, I think that the name 'enumerator' is clear enough.
You could have tried assigning 'default' values in the enum and thought it will set the data value by default to this one, like this:
Код:
enum test
{
    thingA,
    thingB = 13,
    thingC
};
Then you would notice that doing something like PlayerData[id][thingB] would return 0 instead of 13, thats because assigning 13 to thingB in the enumerator didn't really set the data to 13 but set the 'position' of thingB to 13, thus the array created basing on this enumerator now has 15 cells instead of 3 (which is just wasting the memory, because you won't access the rest of it)
Reply


Messages In This Thread
What to use? Enum or Array? - by Yera96 - 14.10.2014, 14:48
Re: What to use? Enum or Array? - by Yera96 - 14.10.2014, 14:57
Re: What to use? Enum or Array? - by silentus - 14.10.2014, 15:11
Re: What to use? Enum or Array? - by Pottus - 14.10.2014, 15:15
Re: What to use? Enum or Array? - by Yera96 - 15.10.2014, 12:51

Forum Jump:


Users browsing this thread: 1 Guest(s)