void PlaySpace::checkSectorGeneration(Vec2F position) { Vec2I sectCoordinates = position / SectorSize; auto& sector = Sectors[sectCoordinates]; if(sector.Generated == false) { sector.Generated = true; NumberGeneratedSectors++; Vec2F sectStart = sectCoordinates * SectorSize; Vec2F sectEnd = sectCoordinates * SectorSize + SectorSize; int primaryFaction = WorldRNG.getNumber(0, 2); int secondaryFaction = WorldRNG.getNumber(0, 2); while(primaryFaction == secondaryFaction) secondaryFaction = WorldRNG.getNumber(0, 2); int type = WorldRNG.getNumber(0, 2); // First sector is always a sector that is at war. if(NumberGeneratedSectors == 1) type = 1; if(type == 0) { generateSystem(WorldRNG.getVec2(sectStart, sectEnd), primaryFaction); } else if(type == 1) { generateSystem(WorldRNG.getVec2(sectStart, sectEnd), primaryFaction); generateSystem(WorldRNG.getVec2(sectStart, sectEnd), secondaryFaction); } else if(type == 2) { generateSystem(WorldRNG.getVec2(sectStart, sectEnd), primaryFaction); generateSystem(WorldRNG.getVec2(sectStart, sectEnd), primaryFaction); generateSystem(WorldRNG.getVec2(sectStart, sectEnd), secondaryFaction); } } }
int main() { struct solarSystem system; unsigned int ID = 0,//Starting ID and current ID maxID = 0,//Maximum ID to generate choice = 0;//Output selection printf("Written by Craig Comberbach.\nCreated in 2011\nVersion %0.1f\n\n", REVISION); //Start ID Sentry while(ID < 1)//0 is an illegal ID { //Gather the starting ID from the user printf("Generate from ID: "); scanf("%d", &ID); } //Max ID Sentry while(maxID < ID)//The value has to be at least equal to the minimum ID, but also, not below it! { //Gather the maximum starting ID from the user printf("Generate to ID: "); scanf("%d", &maxID); } //Choice Sentry while((choice < 1) || (choice > 3))//It has to be either a 1, 2 or a 3 { //Gather the user O/P choice printf("\n1: Database capable output (*.csv)"); printf("\n2: Single spreadsheet output (*.csv)"); printf("\n3: Onscreen display\n"); printf("\nChoose output format: "); scanf("%d", &choice); }//*/ //Formating printf("\n\n\n\n"); //Open the files for edditing Open_Files(choice); for(; ID <= maxID; ++ID) { //Create the system from scratch system = initializeStars(system);//Remove any previous data system = generateSystem(system, ID);//Create new data //How to display the newly created system switch(choice) { case 1: print_DB_file(system); break; case 2: print_CSV_file(system); break; case 3: displaySystem(system); getch();//Pause for the user to preview the output break; default: printf("Whoops, I need to fix that!\n"); } //Display the currently finished ID of the printf("ID = %d\r",ID); } //Close all open files Close_Files(); //Sign off for now printf("\n\n\n\nThanks for using the GURPS Solar System Builder\n\n\n"); //Bye for now return 0; }