void CampaignAndMissionSetup( int buildTables, CampaignOptions *campaign, struct MissionOptions *mo) { CampaignSeedRandom(campaign); SetupMission( buildTables, CampaignGetCurrentMission(campaign), mo, campaign->MissionIndex); }
void MapClassicLoad(Map *map, const Mission *m, const CampaignOptions* co) { // The classic random map generator randomly attempts to place // a configured number of features on the map, in order: // 1. "Squares", almost-square areas of empty floor // 2. Rooms, rectangles of "room" squares surrounded by walls, // some of which have doors // 3. "Pillars", or rectangles of solid wall // 4. Walls, single-thickness walls that sometimes bend and // split // All features are placed by randomly picking a position in // the map and checking to see if it's possible to place the // feature at that point, and repeating this process until // either all features are placed or too many attempts have // been done. // Sometimes it's impossible to place features, either because // they overlap with other incompatible features, or it may // create inaccessible areas on the map. // Re-seed RNG so results are consistent CampaignSeedRandom(co); MapSetupPerimeter(map); // place squares int pad = MAX(m->u.Classic.CorridorWidth, 1); int count = 0; int i = 0; while (i < 1000 && count < m->u.Classic.Squares) { if (MapTryBuildSquare(map)) { count++; } i++; } // place rooms count = 0; i = 0; while (i < 1000 && count < m->u.Classic.Rooms.Count) { int doorMin = CLAMP(m->u.Classic.Doors.Min, 1, 6); int doorMax = CLAMP(m->u.Classic.Doors.Max, doorMin, 6); if (MapTryBuildRoom( map, m, pad, doorMin, doorMax, AreKeysAllowed(gCampaign.Entry.Mode))) { count++; } i++; } // place pillars count = 0; i = 0; while (i < 1000 && count < m->u.Classic.Pillars.Count) { if (MapTryBuildPillar(map, m, pad)) { count++; } i++; } // place walls count = 0; i = 0; while (i < 1000 && count < m->u.Classic.Walls) { if (MapTryBuildWall( map, MAP_FLOOR, pad, m->u.Classic.WallLength)) { count++; } i++; } }