void SetupMission( int buildTables, Mission *m, struct MissionOptions *mo, int missionIndex) { int i; MissionOptionsInit(mo); mo->index = missionIndex; mo->missionData = m; mo->doorPics = doorStyles[abs(m->DoorStyle) % DOORSTYLE_COUNT]; mo->keyPics = keyStyles[abs(m->KeyStyle) % KEYSTYLE_COUNT]; for (i = 0; i < (int)m->Items.size; i++) { CArrayPushBack( &mo->MapObjects, MapObjectGet(*(int32_t *)CArrayGet(&m->Items, i))); } mo->exitPic = exitPics[2 * (abs(m->ExitStyle) % EXIT_COUNT)]; mo->exitShadow = exitPics[2 * (abs(m->ExitStyle) % EXIT_COUNT) + 1]; ActorsInit(); ObjsInit(); MobObjsInit(); SetupObjectives(mo, m); SetupBadguysForMission(m); SetupWeapons(gPlayerDatas, &m->Weapons); SetPaletteRanges(m->WallColor, m->FloorColor, m->RoomColor, m->AltColor); if (buildTables) { BuildTranslationTables(gPicManager.palette); } }
void SetupMission(int index, int buildTables, CampaignOptions *campaign) { int i; int x, y; struct Mission *m; memset(&gMission, 0, sizeof(gMission)); gMission.index = index; m = &campaign->Setting.missions[abs(index) % campaign->Setting.missionCount]; gMission.missionData = m; gMission.doorPics = doorStyles[abs(m->doorStyle) % DOORSTYLE_COUNT]; gMission.keyPics = keyStyles[abs(m->keyStyle) % KEYSTYLE_COUNT]; gMission.objectCount = m->itemCount; for (i = 0; i < m->itemCount; i++) gMission.mapObjects[i] = &mapItems[abs(m->items[i]) % ITEMS_COUNT]; srand(10 * index + campaign->seed); gMission.exitPic = exitPics[2 * (abs(m->exitStyle) % EXIT_COUNT)]; gMission.exitShadow = exitPics[2 * (abs(m->exitStyle) % EXIT_COUNT) + 1]; if (m->exitLeft > 0) { gMission.exitLeft = m->exitLeft * TILE_WIDTH; gMission.exitRight = m->exitRight * TILE_WIDTH; gMission.exitTop = m->exitTop * TILE_HEIGHT; gMission.exitBottom = m->exitBottom * TILE_HEIGHT; } else { if (m->mapWidth) x = (rand() % (abs(m->mapWidth) - EXIT_WIDTH)) + (XMAX - abs(m->mapWidth)) / 2; else x = rand() % (XMAX - EXIT_WIDTH); if (m->mapHeight) y = (rand() % (abs(m->mapHeight) - EXIT_HEIGHT)) + (YMAX - abs(m->mapHeight)) / 2; else y = rand() % (YMAX - EXIT_HEIGHT); gMission.exitLeft = x * TILE_WIDTH; gMission.exitRight = (x + EXIT_WIDTH + 1) * TILE_WIDTH; gMission.exitTop = y * TILE_HEIGHT; gMission.exitBottom = (y + EXIT_HEIGHT + 1) * TILE_HEIGHT; } SetupObjectives(m); SetupBadguysForMission(m); SetupWeapons(m->weaponSelection); SetPaletteRanges(m->wallRange, m->floorRange, m->roomRange, m->altRange); if (buildTables) BuildTranslationTables(); }