src/game/Tactical/Soldier_Init_List.cc
FOR_EACH_SOLDIERINITNODE(curr)
	{
		if (ubFreeSlots == 0 || ubMaxNum == 0) break;
		if(!curr->pSoldier &&
			(curr->pBasicPlacement->bTeam == ENEMY_TEAM ||
			curr->pBasicPlacement->bTeam == MILITIA_TEAM))
		{
			//Randomly determine if we will use this slot; the more available slots in proportion to
			//the number of enemies, the lower the chance of accepting the slot.
			if( ubFreeSlots <= ubMaxNum || Random( ubFreeSlots ) < ubMaxNum )
			{
				//Choose which team to use.
				iRandom = Random( ubMaxNum );
				if( iRandom < ubNumElites )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ELITE_MILITIA;
					ubNumElites--;
				}
				else if( iRandom < ubNumElites + ubNumRegs )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_REG_MILITIA;
					ubNumRegs--;
				}
				else if( iRandom < ubNumElites + ubNumRegs + ubNumGreen )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_GREEN_MILITIA;
					ubNumGreen--;
				}
				else
					SLOGE(
						"AddSoldierInitListMilitia: something wrong with random");
				curr->pBasicPlacement->bTeam = MILITIA_TEAM;
				curr->pBasicPlacement->bOrders = STATIONARY;
				curr->pBasicPlacement->bAttitude = (INT8) Random( MAXATTITUDES );
				if( curr->pDetailedPlacement )
				{
					//delete the detailed placement information.
					delete curr->pDetailedPlacement;
					curr->pDetailedPlacement = NULL;
					curr->pBasicPlacement->fDetailedPlacement = FALSE;
					RandomizeRelativeLevel( &( curr->pBasicPlacement->bRelativeAttributeLevel), curr->pBasicPlacement->ubSoldierClass );
					RandomizeRelativeLevel( &( curr->pBasicPlacement->bRelativeEquipmentLevel), curr->pBasicPlacement->ubSoldierClass );
				}
				if( AddPlacementToWorld( curr ) )
				{
					ubMaxNum--;
				}
				else
					return;
			}
			ubFreeSlots--;
			//With the decrementing of the slot vars in this manner, the chances increase so that all slots
			//will be full by the time the end of the list comes up.
		}
	}
//Now, loop through the entire list again, but for the last time.  All enemies will be inserted now ignoring
//detailed placements and classes.
Now, loop through the entire list again, but for the last time.  All enemies will be inserted now ignoring
detailed placements and classes.
Now loop through the entire list again but for the last time . All enemies will be inserted now ignoring detailed placements and classes .
FOR_EACH_SOLDIERINITNODE(curr)
	{
		if (ubFreeSlots == 0 || ubMaxNum == 0) break;
		if(!curr->pSoldier &&
			(curr->pBasicPlacement->bTeam == ENEMY_TEAM ||
			curr->pBasicPlacement->bTeam == MILITIA_TEAM))
		{
			if( ubFreeSlots <= ubMaxNum || Random( ubFreeSlots ) < ubMaxNum )
			{
				iRandom = Random( ubMaxNum );
				if( iRandom < ubNumElites )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ELITE_MILITIA;
					ubNumElites--;
				}
				else if( iRandom < ubNumElites + ubNumRegs )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_REG_MILITIA;
					ubNumRegs--;
				}
				else if( iRandom < ubNumElites + ubNumRegs + ubNumGreen )
				{
					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_GREEN_MILITIA;
					ubNumGreen--;
				}
				else
					SLOGE(
						"AddSoldierInitListMilitia: something wrong with random");
				curr->pBasicPlacement->bTeam = MILITIA_TEAM;
				curr->pBasicPlacement->bOrders = STATIONARY;
				curr->pBasicPlacement->bAttitude = (INT8) Random( MAXATTITUDES );
				if( curr->pDetailedPlacement )
				{
					delete curr->pDetailedPlacement;
					curr->pDetailedPlacement = NULL;
					curr->pBasicPlacement->fDetailedPlacement = FALSE;
					RandomizeRelativeLevel( &( curr->pBasicPlacement->bRelativeAttributeLevel), curr->pBasicPlacement->ubSoldierClass );
					RandomizeRelativeLevel( &( curr->pBasicPlacement->bRelativeEquipmentLevel), curr->pBasicPlacement->ubSoldierClass );
				}
				if( AddPlacementToWorld( curr ) )
				{
					ubMaxNum--;
				}
				else
					return;
			}
			ubFreeSlots--;
		}
	}
FOR_EACH_SOLDIERINITNODE ( curr ) { if ( ubFreeSlots == 0 || ubMaxNum == 0 ) break ; if ( ! curr -> pSoldier && ( curr -> pBasicPlacement -> bTeam == ENEMY_TEAM || curr -> pBasicPlacement -> bTeam == MILITIA_TEAM ) ) { if ( ubFreeSlots <= ubMaxNum || Random ( ubFreeSlots ) < ubMaxNum ) { iRandom = Random ( ubMaxNum ) ; if ( iRandom < ubNumElites ) { curr -> pBasicPlacement -> ubSoldierClass = SOLDIER_CLASS_ELITE_MILITIA ; ubNumElites -- ; } else if ( iRandom < ubNumElites + ubNumRegs ) { curr -> pBasicPlacement -> ubSoldierClass = SOLDIER_CLASS_REG_MILITIA ; ubNumRegs -- ; } else if ( iRandom < ubNumElites + ubNumRegs + ubNumGreen ) { curr -> pBasicPlacement -> ubSoldierClass = SOLDIER_CLASS_GREEN_MILITIA ; ubNumGreen -- ; } else SLOGE ( " " ) ; curr -> pBasicPlacement -> bTeam = MILITIA_TEAM ; curr -> pBasicPlacement -> bOrders = STATIONARY ; curr -> pBasicPlacement -> bAttitude = ( INT8 ) Random ( MAXATTITUDES ) ; if ( curr -> pDetailedPlacement ) { delete curr -> pDetailedPlacement ; curr -> pDetailedPlacement = NULL ; curr -> pBasicPlacement -> fDetailedPlacement = FALSE ; RandomizeRelativeLevel ( & ( curr -> pBasicPlacement -> bRelativeAttributeLevel ) , curr -> pBasicPlacement -> ubSoldierClass ) ; RandomizeRelativeLevel ( & ( curr -> pBasicPlacement -> bRelativeEquipmentLevel ) , curr -> pBasicPlacement -> ubSoldierClass ) ; } if ( AddPlacementToWorld ( curr ) ) { ubMaxNum -- ; } else return ; } ubFreeSlots -- ; } }
Now, loop through the entire list again, but for the last time.
Now loop through the entire list again but for the last time .
//Randomly determine if we will use this slot; the more available slots in proportion to //the number of enemies, the lower the chance of accepting the slot. //Choose which team to use. //delete the detailed placement information. //With the decrementing of the slot vars in this manner, the chances increase so that all slots //will be full by the time the end of the list comes up.