The incrementation is more simple than you shows.
PHP код:
new gangid = 8;
gangid++; // Gangid's value is 9
// You can also use the incrementation before the var name
++gangid; // Without using the incrementation before, gangid's value is also 9. Else, it will be 10.
The difference between the "++" pos (before or after) is explained through a condition :
PHP код:
new stuff = 15;
new myAge = 16;
if(myAge == ++stuff) // Will be true
if(myAge == stuf++) // Will be false
In the first condition, stuff is incremented before the condition is checked.
In the second one, stuff is incremented after the condition is checked.
But on both, stuff will be 16 after checking.
EDIT :
The second part is very simple.
It's used to get the lowest gang id from 0, which will be useful to order the gangs using their IDs.
The loop checks each value of the array (MAX_GANGS is not defined of course, define it as the value as you want.
G is initialized, then g is compared to MAX_GANGS, and if g is smaller than MAX_GANGS, g will be incremented.
After doing everything which is between the brackets of the for loop, the program will come back to the comparison, etc, etc.
My loop checks (inside) if gangID's value is 0. If it is, the loops stop and I use g out of the loop (I don't like working in the loops, it's a personnal habits, if you prefer to work in, do as you want), which value is the value of the array which not contains a gang created (a bit hard to understand, anyway), and it's used as an external ID to complete and assign values to the enumerator.