static bool GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; COUNT nodeI; DWORD rand_val; DWORD old_rand; old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); nodeI = 0; i = 0; do { rand_val = TFB_Random (); solarSys->SysInfo.PlanetInfo.CurPt.x = ((LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurPt.y = ((LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; // JMS: No more clear spindles! /*if (!GET_GAME_STATE (CLEAR_SPINDLE)) solarSys->SysInfo.PlanetInfo.CurType = 0; else*/ solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i)) { solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] &= ~(1L << i); // JMS: No more clear spindles! /*if (!GET_GAME_STATE (CLEAR_SPINDLE)) { SetLanderTakeoff (); SET_GAME_STATE (CLEAR_SPINDLE, 1); SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1); }*/ } if (nodeI >= *whichNode && !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i))) break; ++nodeI; } while (++i < 16); *whichNode = nodeI; TFB_SeedRandom (old_rand); return true; } *whichNode = 0; return true; }
static COUNT GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode) { if (CurStarDescPtr->Index == MAIDENS_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; DWORD old_rand; old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); for (i = 0; i <= whichNode && i < 12; ++i) { GenerateRandomLocation (&solarSys->SysInfo); if (i < 4) solarSys->SysInfo.PlanetInfo.CurType = 9; else if (i < 8) solarSys->SysInfo.PlanetInfo.CurType = 14; else /* if (i < 12) */ solarSys->SysInfo.PlanetInfo.CurType = 18; } TFB_SeedRandom (old_rand); return 12; // only matters when count is requested } if (CurStarDescPtr->Index == VUX_BEAST_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; DWORD old_rand; old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); for (i = 0; i <= whichNode && i < 11; ++i) { GenerateRandomLocation (&solarSys->SysInfo); if (i == 0) /* VUX Beast */ solarSys->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 2; else if (i <= 5) /* {SPEED_MOTIONLESS | DANGER_NORMAL, MAKE_BYTE (5, 3)}, */ solarSys->SysInfo.PlanetInfo.CurType = 3; else /* if (i <= 10) */ /* {BEHAVIOR_UNPREDICTABLE | SPEED_SLOW | DANGER_NORMAL, MAKE_BYTE (3, 8)}, */ solarSys->SysInfo.PlanetInfo.CurType = 8; } TFB_SeedRandom (old_rand); return 11; // only matters when count is requested } return GenerateDefault_generateLife (solarSys, world, whichNode); }
DWORD GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_life) { DWORD old_rand; old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); *pwhich_life = CalcLifeForms (SysInfoPtr, *pwhich_life); return (TFB_SeedRandom (old_rand)); }
DWORD GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_deposit) { DWORD old_rand; old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]); *pwhich_deposit = CalcMineralDeposits (SysInfoPtr, *pwhich_deposit); return (TFB_SeedRandom (old_rand)); }
static bool GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; COUNT nodeI; DWORD rand_val; DWORD old_rand; old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); nodeI = 0; i = 0; do { rand_val = TFB_Random (); solarSys->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; if (!GET_GAME_STATE (ULTRON_CONDITION)) solarSys->SysInfo.PlanetInfo.CurType = 0; else solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i)) { solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] &= ~(1L << i); if (!GET_GAME_STATE (ULTRON_CONDITION)) { SetLanderTakeoff (); SET_GAME_STATE (ULTRON_CONDITION, 1); } } if (nodeI >= *whichNode && !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i))) break; ++nodeI; } while (++i < 16); *whichNode = nodeI; TFB_SeedRandom (old_rand); return true; } *whichNode = 0; return true; }
void crc_processRNG(crc_State *state) { DWORD seed; #ifdef DUMP_CRC_OPS log_add(log_Debug, "START crc_processRNG()."); #endif seed = TFB_SeedRandom(0); // This modifies the seed too. crc_processDWORD(state, seed); TFB_SeedRandom(seed); // Restore the old seed. #ifdef DUMP_CRC_OPS log_add(log_Debug, "END crc_processRNG()."); #endif }
void OpenJournal (void) { DWORD start_seed; #if CREATE_JOURNAL if (create_journal) { if (journal_fh = copen (journal_buf, MEMORY_STREAM, STREAM_WRITE)) { start_seed = SeedRandomNumbers (); cwrite ((PBYTE)&start_seed, sizeof (start_seed), 1, journal_fh); } } else #endif /* CREATE_JOURNAL */ { uio_Stream *fp; if (fp = res_OpenResFile ("starcon.jnl", "rb")) { ReadResFile (journal_buf, 1, sizeof (journal_buf), fp); res_CloseResFile (fp); if (journal_fh = copen (journal_buf, MEMORY_STREAM, STREAM_READ)) { OldArrowInput = ArrowInput; ArrowInput = DemoInput; PlayerInput[0] = PlayerInput[1] = DemoInput; FlushInput (); cread ((PBYTE)&start_seed, sizeof (start_seed), 1, journal_fh); TFB_SeedRandom (start_seed); } } } }
void GenerateBurvixes (BYTE control) { COUNT i; DWORD rand_val; switch (control) { case GENERATE_ENERGY: { DWORD rand_val, old_rand; if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) { COUNT which_node; old_rand = TFB_SeedRandom ( pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); which_node = i = 0; do { rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurType = 1; pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; if (which_node >= pSolarSysState->CurNode && !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i))) break; ++which_node; } while (++i < 16); pSolarSysState->CurNode = which_node; TFB_SeedRandom (old_rand); break; } else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0] && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) { old_rand = TFB_SeedRandom ( pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; pSolarSysState->SysInfo.PlanetInfo.CurType = 0; if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << 0)) && pSolarSysState->CurNode == (COUNT)~0) pSolarSysState->CurNode = 1; else { pSolarSysState->CurNode = 0; if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << 0)) { SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); } } TFB_SeedRandom (old_rand); break; } pSolarSysState->CurNode = 0; break; } case GENERATE_MOONS: GenerateRandomIP (GENERATE_MOONS); if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0]) { COUNT angle; pSolarSysState->MoonDesc[0].data_index = SELENIC_WORLD; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + (MAX_MOONS - 1) * MOON_DELTA; rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pSolarSysState->MoonDesc[0].location.x = COSINE (angle, pSolarSysState->MoonDesc[0].radius); pSolarSysState->MoonDesc[0].location.y = SINE (angle, pSolarSysState->MoonDesc[0].radius); } break; case GENERATE_PLANETS: { COUNT angle; GenerateRandomIP (GENERATE_PLANETS); pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD; pSolarSysState->PlanetDesc[0].NumPlanets = 1; pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 39L / 100; angle = ARCTAN ( pSolarSysState->PlanetDesc[0].location.x, pSolarSysState->PlanetDesc[0].location.y ); pSolarSysState->PlanetDesc[0].location.x = COSINE (angle, pSolarSysState->PlanetDesc[0].radius); pSolarSysState->PlanetDesc[0].location.y = SINE (angle, pSolarSysState->PlanetDesc[0].radius); break; } case GENERATE_ORBITAL: { rand_val = DoPlanetaryAnalysis ( &pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc ); pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; i = (COUNT)~0; rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i); pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; i = (COUNT)~0; GenerateMineralDeposits (&pSolarSysState->SysInfo, &i); pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) { LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (RUINS_MASK_PMAP_ANIM)); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (BURV_RUINS_STRTAB)); pSolarSysState->SysInfo.PlanetInfo.Weather = 0; pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0; } else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0] && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) { LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (BURV_BCS_MASK_PMAP_ANIM)); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (BURV_BCS_STRTAB)); } LoadPlanet (NULL); break; } default: GenerateRandomIP (control); break; } }
void GeneratePkunk (BYTE control) { switch (control) { case GENERATE_ENERGY: if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) { COUNT i, which_node; DWORD rand_val, old_rand; old_rand = TFB_SeedRandom ( pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); which_node = i = 0; do { rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; if (!GET_GAME_STATE (CLEAR_SPINDLE)) pSolarSysState->SysInfo.PlanetInfo.CurType = 0; else pSolarSysState->SysInfo.PlanetInfo.CurType = 1; pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i)) { pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] &= ~(1L << i); if (!GET_GAME_STATE (CLEAR_SPINDLE)) { ((PPLANETSIDE_DESC)pMenuState->ModuleFrame)->InTransit = TRUE; SET_GAME_STATE (CLEAR_SPINDLE, 1); SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1); } } if (which_node >= pSolarSysState->CurNode && !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i))) break; ++which_node; } while (++i < 16); pSolarSysState->CurNode = which_node; TFB_SeedRandom (old_rand); break; } pSolarSysState->CurNode = 0; break; case GENERATE_PLANETS: { COUNT angle; GenerateRandomIP (GENERATE_PLANETS); pSolarSysState->PlanetDesc[0].data_index = WATER_WORLD; pSolarSysState->PlanetDesc[0].NumPlanets = 1; pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 104L / 100; angle = ARCTAN ( pSolarSysState->PlanetDesc[0].location.x, pSolarSysState->PlanetDesc[0].location.y ); pSolarSysState->PlanetDesc[0].location.x = COSINE (angle, pSolarSysState->PlanetDesc[0].radius); pSolarSysState->PlanetDesc[0].location.y = SINE (angle, pSolarSysState->PlanetDesc[0].radius); break; } case GENERATE_ORBITAL: if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) { if (ActivateStarShip (PKUNK_SHIP, SPHERE_TRACKING)) { NotifyOthers (PKUNK_SHIP, (BYTE)~0); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (npc_built_ship_q)); CloneShipFragment (PKUNK_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); pSolarSysState->MenuState.Initialized += 2; GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (PKUNK_CONVERSATION); pSolarSysState->MenuState.Initialized -= 2; if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } break; } else { LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (RUINS_MASK_PMAP_ANIM) ); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (PKUNK_RUINS_STRTAB) ); if (GET_GAME_STATE (CLEAR_SPINDLE)) pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( pSolarSysState->SysInfo.PlanetInfo.DiscoveryString, 1 ); } } default: GenerateRandomIP (control); break; } }
static bool GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { DWORD rand_val; DWORD old_rand; if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT nodeI; COUNT i; old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); nodeI = 0; i = 0; do { rand_val = TFB_Random (); solarSys->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; if (nodeI >= *whichNode && !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << i))) break; ++nodeI; } while (++i < 16); *whichNode = nodeI; TFB_SeedRandom (old_rand); return true; } if (matchWorld (solarSys, world, 0, 0) && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) { old_rand = TFB_SeedRandom ( solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); rand_val = TFB_Random (); solarSys->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << 0)) && *whichNode == (COUNT)~0) *whichNode = 1; else { *whichNode = 0; if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << 0)) { SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); } } TFB_SeedRandom (old_rand); return true; } *whichNode = 0; return true; }
BOOLEAN Battle (BattleFrameCallback *callback) { SIZE num_ships; LockMutex (GraphicsLock); #if !(DEMO_MODE || CREATE_JOURNAL) if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) { // In Supermelee, the RNG is already initialised. TFB_SeedRandom (GetTimeCounter ()); } #else /* DEMO_MODE */ if (BattleSeed == 0) BattleSeed = TFB_Random (); TFB_SeedRandom (BattleSeed); BattleSeed = TFB_Random (); /* get next battle seed */ #endif /* DEMO_MODE */ BattleSong (FALSE); num_ships = InitShips (); if (instantVictory) { num_ships = 0; battle_counter[0] = 1; battle_counter[1] = 0; instantVictory = FALSE; } if (num_ships) { BATTLE_STATE bs; GLOBAL (CurrentActivity) |= IN_BATTLE; battle_counter[0] = CountLinks (&race_q[0]); battle_counter[1] = CountLinks (&race_q[1]); if (optMeleeScale != TFB_SCALE_STEP) SetGraphicScaleMode (optMeleeScale); setupBattleInputOrder (); #ifdef NETPLAY initBattleInputBuffers (); #ifdef NETPLAY_CHECKSUM initChecksumBuffers (); #endif /* NETPLAY_CHECKSUM */ battleFrameCount = 0; ResetWinnerStarShip (); setBattleStateConnections (&bs); #endif /* NETPLAY */ if (!selectAllShips (num_ships)) { GLOBAL (CurrentActivity) |= CHECK_ABORT; goto AbortBattle; } BattleSong (TRUE); bs.NextTime = 0; #ifdef NETPLAY initBattleStateDataConnections (); { bool allOk = negotiateReadyConnections (true, NetState_inBattle); if (!allOk) { GLOBAL (CurrentActivity) |= CHECK_ABORT; goto AbortBattle; } } #endif /* NETPLAY */ bs.InputFunc = DoBattle; bs.frame_cb = callback; bs.first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE); UnlockMutex (GraphicsLock); DoInput (&bs, FALSE); LockMutex (GraphicsLock); AbortBattle: if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) { if (GLOBAL (CurrentActivity) & CHECK_ABORT) { // Do not return to the main menu when a game is aborted, // (just to the supermelee menu). #ifdef NETPLAY UnlockMutex (GraphicsLock); waitResetConnections(NetState_inSetup); // A connection may already be in inSetup (set from // GetMeleeStarship). This is not a problem, although // it will generate a warning in debug mode. LockMutex (GraphicsLock); #endif GLOBAL (CurrentActivity) &= ~CHECK_ABORT; } else { // Show the result of the battle. MeleeGameOver (); } } #ifdef NETPLAY uninitBattleInputBuffers(); #ifdef NETPLAY_CHECKSUM uninitChecksumBuffers (); #endif /* NETPLAY_CHECKSUM */ setBattleStateConnections (NULL); #endif /* NETPLAY */ StopDitty (); StopMusic (); StopSound (); } UninitShips (); FreeBattleSong (); UnlockMutex (GraphicsLock); return (BOOLEAN) (num_ships < 0); }
void GenerateShipVault (BYTE control) { switch (control) { case GENERATE_ENERGY: if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]) { DWORD rand_val, old_rand; old_rand = TFB_SeedRandom ( pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] ); rand_val = TFB_Random (); pSolarSysState->SysInfo.PlanetInfo.CurPt.x = (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurPt.y = (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; if (!GET_GAME_STATE (SHIP_VAULT_UNLOCKED)) pSolarSysState->SysInfo.PlanetInfo.CurType = 0; else pSolarSysState->SysInfo.PlanetInfo.CurType = 1; pSolarSysState->CurNode = 1; if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] & (1L << 0)) { pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] &= ~(1L << 0); if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP)) { ((PLANETSIDE_DESC*)pMenuState->ModuleFrame)->InTransit = TRUE; SET_GAME_STATE (SHIP_VAULT_UNLOCKED, 1); SET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP, 0); SET_GAME_STATE (SYREEN_HOME_VISITS, 0); } else if (!GET_GAME_STATE (KNOW_SYREEN_VAULT)) { SET_GAME_STATE (KNOW_SYREEN_VAULT, 1); SET_GAME_STATE (SYREEN_HOME_VISITS, 0); } } TFB_SeedRandom (old_rand); break; } pSolarSysState->CurNode = 0; break; case GENERATE_ORBITAL: if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]) { LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (VAULT_MASK_PMAP_ANIM) ); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (VAULT_STRTAB) ); if (GET_GAME_STATE (SHIP_VAULT_UNLOCKED)) pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( pSolarSysState->SysInfo.PlanetInfo.DiscoveryString, 2 ); else if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP)) pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( pSolarSysState->SysInfo.PlanetInfo.DiscoveryString, 1 ); } default: GenerateRandomIP (control); break; } }