Okay, this is what i worked out:
Template.cpp
int pos[4];
void GetStartingLocations(int numPlayers)
{
int i=TethysGame::GetRand(4); // get a random position for player 1
if (numPlayers==2)
{
pos[0]=i;
pos[1]=3-i; // place player 2 opposite of player 1
}
else // randomize ALL players
{
for (int x=0; x<numPlayers; ++x)
pos[x]=(i+x)%4;
}
}
int InitProc()
{
int i;
GetStartingLocations(4);
// Place all bases on the map
for (i = 0; i < TethysGame::NoPlayers(); i++)
{
InitPlayerResources(i);
StartLocation &sLoc = startLocation[pos[i]];
CreateBase(i, sLoc.x, sLoc.y, pos[i]);
Player[i].CenterViewOn(sLoc.x, sLoc.y);
}
...
}
BaseData.h
Change the struct StartLocation startLocation difinition to this:
LOCATION startLocation[] = {
{ 49, 14},
{142, 14},
{ 49, 112},
{142, 112}
};
It should reflect the 3 correct starting locations!
I'll leave it to you to test if it works correctly. Be advised this ONLY works for 4 players max, so you should put in a test if (numPlayers>4) give error warning
Replace your code like this:
Unit factory;
// int i contains the playernumber
if (PlayerBuildingEnum(i,mapStructureFactory).GetNext(factory))
{
factory.SetFactoryCargo(0, mapTokamak,mapNone);
factory.SetFactoryCargo(1, mapNursery,mapNone);
factory.SetFactoryCargo(2, mapUniversity,mapNone);
factory.SetFactoryCargo(3, mapVehicleFactory,mapNone);
factory.SetFactoryCargo(4, mapRobotCommand,mapNone);
factory.SetFactoryCargo(5, mapResidence,mapNone);
}
The enum will find ALL SF's of that player. Since the player has only 1 SF - if won't go wrong.
int InitProc()
{
int i;
GetStartingLocations(TethysGame::NoPlayers());
// Place all bases on the map
for (i = 0; i < TethysGame::NoPlayers(); i++)
{
InitPlayerResources(i);
LOCATION sLoc = startLocation[pos[i]];
CreateBase(i, sLoc.x, sLoc.y, base[pos[i]]);
Player[i].CenterViewOn(sLoc.x, sLoc.y);
Player[i].MarkResearchComplete(3401); // Cybernetic Teleoperation
Player[i].MarkResearchComplete(3305); // Research Training Programs
Player[i].MarkResearchComplete(3304); // Offspring Enhancement
Player[i].MarkResearchComplete(3303); // Health Maintenance
Unit factory;
// int i contains the playernumber
if (PlayerBuildingEnum(i,mapStructureFactory).GetNext(factory))
{
factory.SetFactoryCargo(0, mapTokamak,mapNone);
factory.SetFactoryCargo(1, mapNursery,mapNone);
factory.SetFactoryCargo(2, mapUniversity,mapNone);
factory.SetFactoryCargo(3, mapVehicleFactory,mapNone);
factory.SetFactoryCargo(4, mapRobotCommand,mapNone);
factory.SetFactoryCargo(5, mapResidence,mapNone);
}
}
// Misc initialization
TethysGame::ForceMoraleGood(-1);
if (TethysGame::UsesMorale())
TethysGame::FreeMoraleLevel(-1);
TethysGame::SetDaylightEverywhere(TethysGame::UsesDayNight() == 0);
TethysGame::SetDaylightMoves(0);
GameMap::SetInitialLightLevel(-32);
//CreateLastOneStandingVictoryCondition();
return 1; // return 1 if OK; 0 on failure
//TethysGame::AddMessage(int -1, int -1, char *Good Luck, Have Fun., int -1, int 93);
}
}