static bool GenerateZoqFotPik_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { if (ActivateStarShip (ZOQFOTPIK_SHIP, SPHERE_TRACKING)) { PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); if (GET_GAME_STATE (ZOQFOT_DISTRESS)) { CloneShipFragment (BLACK_URQUAN_SHIP, &GLOBAL (npc_built_ship_q), 0); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (BLACKURQ_CONVERSATION); if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) return true; if (GetHeadLink (&GLOBAL (npc_built_ship_q))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); return true; } } CloneShipFragment (ZOQFOTPIK_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (ZOQFOTPIK_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); } GenerateDefault_generateOrbital (solarSys, world); return true; }
CSiemensSR::CSiemensSR() { m_SendBuf [0] = 'Q'; // Para el primer envío m_DataLen = 1; m_fConnected = false; m_fConnecting = false; m_fReceivePend = false; InitCommunication (); }
//-------------------------------------------------------------------------- /// Initialize the DX12Server plugin. /// \returns True if initialization was successful, false if it failed. //-------------------------------------------------------------------------- bool InitPlugin() { LogHeader(); if (InitCommunication(GetShortDescription(), ProcessRequest) == false) { DeinitCommunication(); return false; } Log(logTRACE, "DX12Server2's InitPlugin success.\n"); return true; }
/** * @fn void MCUInit() * * @brief Sets the microcontroller to a predetermined state. Handles initialization * for all categories of peripherals: Analog, Architecture, Communication, * Data Converters, GPIO, LCD, Special Modules, Timers. * */ void MCUInit() { #if defined(__MCU_MSP430_SERIES) InitAnalog(); // Initialize the Analog modules InitArchitecture(); // Initialize the Architecture modules InitCommunication(); // Initialize the Communication modules InitDataConverters(); // Initialize the Data Converter modules InitGPIO(); // Initialize the GPIO modules InitLCD(); // Initialize the LCD modules InitSpecialModules(); // Initialize the Special modules InitTimers(); // Initialize the Timers modules #endif }
/* * Early initialization of a backend (either standalone or under postmaster). * This happens even before InitPostgres. * * This is separate from InitPostgres because it is also called by auxiliary * processes, such as the background writer process, which may not call * InitPostgres at all. */ void BaseInit(void) { /* * Attach to shared memory and semaphores, and initialize our * input/output/debugging file descriptors. */ InitCommunication(); DebugFileOpen(); /* Do local initialization of file, storage and buffer managers */ InitFileAccess(); smgrinit(); InitBufferPoolAccess(); }
static bool GenerateIlwrath_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { if (ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING)) { NotifyOthers (ILWRATH_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (ILWRATH_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (ILWRATH_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); } } GenerateDefault_generateOrbital (solarSys, world); if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { solarSys->SysInfo.PlanetInfo.Weather = 2; solarSys->SysInfo.PlanetInfo.Tectonics = 3; } return true; }
static bool GeneratePkunk_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { // JMS: No ships orbit Pkunk homeworld anymore. //if (ActivateStarShip (PKUNK_SHIP, SPHERE_TRACKING)) if (0) { NotifyOthers (PKUNK_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (PKUNK_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (PKUNK_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (PKUNK_RUINS_STRTAB)); // JMS: No more clear spindles! //if (GET_GAME_STATE (CLEAR_SPINDLE)) solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); } } GenerateDefault_generateOrbital (solarSys, world); return true; }
static bool GenerateSupox_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { if (StartSphereTracking (SUPOX_SHIP)) { NotifyOthers (SUPOX_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (SUPOX_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (SUPOX_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (SUPOX_RUINS_STRTAB)); if (GET_GAME_STATE (ULTRON_CONDITION)) { // Already picked up the Ultron, skip the report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); } } } GenerateDefault_generateOrbital (solarSys, world); return true; }
/*窗口初始化*/ LONG DoOperatorInit(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) { SetWindowPos(hDlg,NULL,0,0,800,480,SWP_SHOWWINDOW); //打印机串口通信初始化 TCHAR STRCOM[20]; _stprintf_s(STRCOM,10,_T("COM1:")); //hPrinterComPort = InitCommunication(STRCOM,hPrinterComPort,NOPARITY); //plc控制器串口通信初始化 _stprintf_s(STRCOM,10,_T("COM4:")); hServoComPort = InitCommunication(STRCOM,hServoComPort,NOPARITY); hPrinterComPort = hServoComPort; //下拉菜单初始化 OnInit( hDlg, message, wParam, lParam); //开启速度曲线刷新线程 MapFlag = TRUE; if (!GetExitCodeThread (hMapThread, &dwMapThreadID) ||(dwMapThreadID != STILL_ACTIVE)) { hMapThread = CreateThread(NULL,0,MapThread,(LPVOID)hDlg,0,&dwMapThreadID); } //开启伺服控制主线程 MainFlag = TRUE; if (!GetExitCodeThread (hmainThread, &dwMainThreadID) ||(dwMainThreadID != STILL_ACTIVE)) { hmainThread = CreateThread(NULL,0,MainThread,(LPVOID)hDlg,0,&dwMainThreadID); } //线程同步:伺服控制主线程和绘图线程 m_Event = CreateEvent(NULL,FALSE,TRUE,NULL); Button_Enable(GetDlgItem(hDlg,IDC_BtnNext),FALSE); return TRUE; }
void GenerateSlylandro (BYTE control) { switch (control) { case GENERATE_PLANETS: GenerateRandomIP (GENERATE_PLANETS); pSolarSysState->PlanetDesc[3].data_index = RED_GAS_GIANT; pSolarSysState->PlanetDesc[3].NumPlanets = 1; break; case GENERATE_ORBITAL: if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[3]) { pSolarSysState->MenuState.Initialized += 2; InitCommunication (SLYLANDRO_HOME_CONVERSATION); pSolarSysState->MenuState.Initialized -= 2; break; } default: GenerateRandomIP (control); break; } }
static bool GenerateUtwig_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if ((CurStarDescPtr->Index == UTWIG_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) || (CurStarDescPtr->Index == BOMB_DEFINED && matchWorld (solarSys, world, 5, 1) && !GET_GAME_STATE (UTWIG_BOMB))) { if ((CurStarDescPtr->Index == UTWIG_DEFINED || !GET_GAME_STATE (UTWIG_HAVE_ULTRON)) && ActivateStarShip (UTWIG_SHIP, SPHERE_TRACKING)) { NotifyOthers (UTWIG_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (UTWIG_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; if (CurStarDescPtr->Index == UTWIG_DEFINED) { SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); } else { SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); } InitCommunication (UTWIG_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } if (CurStarDescPtr->Index == BOMB_DEFINED && !GET_GAME_STATE (BOMB_UNPROTECTED) && ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING)) { COUNT i; PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); for (i = 0; i < 5; ++i) { CloneShipFragment (DRUUGE_SHIP, &GLOBAL (npc_built_ship_q), 0); } GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); InitCommunication (DRUUGE_CONVERSATION); if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) return true; { BOOLEAN DruugeSurvivors; DruugeSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q)) != 0; GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); if (DruugeSurvivors) return true; LockMutex (GraphicsLock); RepairSISBorder (); UnlockMutex (GraphicsLock); SET_GAME_STATE (BOMB_UNPROTECTED, 1); } } if (CurStarDescPtr->Index == BOMB_DEFINED) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (BOMB_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (BOMB_STRTAB)); } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); } } GenerateDefault_generateOrbital (solarSys, world); if (CurStarDescPtr->Index == UTWIG_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { solarSys->SysInfo.PlanetInfo.Weather = 1; solarSys->SysInfo.PlanetInfo.Tectonics = 1; } return true; }
void InitPostgres(char *name) /* database name */ { bool bootstrap; /* true if BootstrapProcessing */ /* ---------------- * see if we're running in BootstrapProcessing mode * ---------------- */ bootstrap = IsBootstrapProcessingMode(); /* ---------------- * turn on the exception handler. Note: we cannot use elog, Assert, * AssertState, etc. until after exception handling is on. * ---------------- */ EnableExceptionHandling(true); /* ---------------- * A stupid check to make sure we don't call this more than once. * But things like ReinitPostgres() get around this by just diddling * the PostgresIsInitialized flag. * ---------------- */ AssertState(!PostgresIsInitialized); /* ---------------- * Memory system initialization. * (we may call palloc after EnableMemoryContext()) * * Note EnableMemoryContext() must happen before EnablePortalManager(). * ---------------- */ EnableMemoryContext(true); /* initializes the "top context" */ EnablePortalManager(true); /* memory for portal/transaction stuff */ /* ---------------- * initialize the backend local portal stack used by * internal PQ function calls. see src/lib/libpq/be-dumpdata.c * This is different from the "portal manager" so this goes here. * -cim 2/12/91 * ---------------- */ be_portalinit(); /* ---------------- * attach to shared memory and semaphores, and initialize our * input/output/debugging file descriptors. * ---------------- */ InitCommunication(); InitStdio(); /* * initialize the local buffer manager */ InitLocalBuffer(); if (!TransactionFlushEnabled()) on_exitpg(FlushBufferPool, (caddr_t) NULL); /* ---------------- * check for valid "meta gunk" (??? -cim 10/5/90) and change to * database directory. * * Note: DatabaseName, MyDatabaseName, and DatabasePath are all * initialized with DatabaseMetaGunkIsConsistent(), strncpy() and * DoChdirAndInitDatabase() below! XXX clean this crap up! * -cim 10/5/90 * ---------------- */ { char myPath[MAXPGPATH] = "."; /* DatabasePath points here! */ /* ---------------- * DatabaseMetaGunkIsConsistent fills in myPath, but what about * when bootstrap or Noversion is true?? -cim 10/5/90 * ---------------- */ if (! bootstrap && ! DatabaseMetaGunkIsConsistent(name, myPath) && ! Noversion) { elog(NOTICE, "InitPostgres: could not locate valid PG_VERSION\n"); elog(NOTICE, "files for %s and %s.", DataDir, name); elog(FATAL, "Have you run initdb/createdb and set PGDATA properly?"); } /* ---------------- * ok, we've figured out myName and myPath, now save these * and chdir to myPath. * ---------------- */ DoChdirAndInitDatabaseNameAndPath(name, myPath); } /* ******************************** * code after this point assumes we are in the proper directory! * ******************************** */ /* ---------------- * initialize the database id used for system caches and lock tables * ---------------- */ InitMyDatabaseId(); smgrinit(); /* ---------------- * initialize the transaction system and the relation descriptor * cache. Note we have to make certain the lock manager is off while * we do this. * ---------------- */ AmiTransactionOverride(IsBootstrapProcessingMode()); LockDisable(true); /* * Part of the initialization processing done here sets a read * lock on pg_log. Since locking is disabled the set doesn't have * intended effect of locking out writers, but this is ok, since * we only lock it to examine AMI transaction status, and this is * never written after initdb is done. -mer 15 June 1992 */ RelationInitialize(); /* pre-allocated reldescs created here */ InitializeTransactionSystem(); /* pg_log,etc init/crash recovery here */ LockDisable(false); /* ---------------- * anyone knows what this does? something having to do with * system catalog cache invalidation in the case of multiple * backends, I think -cim 10/3/90 * Sets up MyBackendId a unique backend identifier. * ---------------- */ InitSharedInvalidationState(); /* ---------------- * Set up a per backend process in shared memory. Must be done after * InitSharedInvalidationState() as it relies on MyBackendId being * initialized already. XXX -mer 11 Aug 1991 * ---------------- */ InitProcess(PostgresIpcKey); if (MyBackendId > MaxBackendId || MyBackendId <= 0) { elog(FATAL, "cinit2: bad backend id %d (%d)", MyBackendTag, MyBackendId); } /* ---------------- * initialize the access methods. * ---------------- */ initam(); /* ---------------- * initialize all the system catalog caches. * ---------------- */ zerocaches(); InitCatalogCache(); /* ---------------- * set ourselves to the proper user id and figure out our postgres * user id. If we ever add security so that we check for valid * postgres users, we might do it here. * ---------------- */ InitUserid(); /* ---------------- * ok, all done, now let's make sure we don't do it again. * ---------------- */ PostgresIsInitialized = true; /* on_exitpg(DestroyLocalRelList, (caddr_t) NULL); */ /* ---------------- * Done with "InitPostgres", now change to NormalProcessing unless * we're in BootstrapProcessing mode. * ---------------- */ if (!bootstrap) SetProcessingMode(NormalProcessing); /* if (testFlag || lockingOff) */ if (lockingOff) LockDisable(true); }
static bool GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if (matchWorld (solarSys, world, 1, MATCH_PLANET)) { if (GET_GAME_STATE (CHMMR_UNLEASHED)) { SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); InitCommunication (CHMMR_CONVERSATION); if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) { GLOBAL (CurrentActivity) |= END_INTERPLANETARY; } return true; } else if (GET_GAME_STATE (SUN_DEVICE_ON_SHIP) && !GET_GAME_STATE (ILWRATH_DECEIVED) && ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING)) { PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (ILWRATH_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; InitCommunication (ILWRATH_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } } else if (matchWorld (solarSys, world, 1, 0)) { /* Starbase */ LockMutex (GraphicsLock); LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (CHMMR_BASE_STRTAB)); DoDiscoveryReport (MenuSounds); DestroyStringTable (ReleaseStringTable ( solarSys->SysInfo.PlanetInfo.DiscoveryString)); solarSys->SysInfo.PlanetInfo.DiscoveryString = 0; FreeLanderFont (&solarSys->SysInfo.PlanetInfo); UnlockMutex (GraphicsLock); return true; } GenerateDefault_generateOrbital (solarSys, world); return true; }
int Starcon2Main (void *threadArg) { #if CREATE_JOURNAL { int ac = argc; char **av = argv; while (--ac > 0) { ++av; if ((*av)[0] == '-') { switch ((*av)[1]) { #if CREATE_JOURNAL case 'j': ++create_journal; break; #endif //CREATE_JOURNAL } } } } #endif // CREATE_JOURNAL { /* TODO: Put initAudio back in main where it belongs once threading * is gone. */ extern sint32 initAudio (sint32 driver, sint32 flags); initAudio (snddriver, soundflags); } if (!LoadKernel (0,0)) { log_add (log_Fatal, "\n *** FATAL ERROR: Could not load basic content ***\n\nUQM requires at least the base content pack to run properly."); log_add (log_Fatal, "This file is typically called uqm-%d.%d.0.uqm. UQM was expecting it", P6014_MAJOR_VERSION, P6014_MINOR_VERSION); log_add (log_Fatal, "in the %s/packages directory.", baseContentPath); log_add (log_Fatal, "Either your installation did not install the content pack at all, or it\ninstalled it in a different directory.\n\nFix your installation and rerun UQM.\n\n *******************\n"); exit (EXIT_FAILURE); } log_add (log_Info, "We've loaded the Kernel"); Logo (); GLOBAL (CurrentActivity) = 0; // show splash and init the kernel in the meantime SplashScreen (BackgroundInitKernel); // OpenJournal (); while (StartGame ()) { // Initialise a new game if (!SetPlayerInputAll ()) { log_add (log_Fatal, "Could not set player input."); explode (); // Does not return; } InitGameStructures (); InitGameClock (); AddInitialGameEvents(); do { #ifdef DEBUG if (debugHook != NULL) { void (*saveDebugHook) (void); saveDebugHook = debugHook; debugHook = NULL; // No further debugHook calls unless the called // function resets debugHook. (*saveDebugHook) (); continue; } #endif SetStatusMessageMode (SMM_DEFAULT); if (!((GLOBAL (CurrentActivity) | NextActivity) & CHECK_LOAD)) ZeroVelocityComponents (&GLOBAL (velocity)); // not going into talking pet conversation else if (GLOBAL (CurrentActivity) & CHECK_LOAD) GLOBAL (CurrentActivity) = NextActivity; if ((GLOBAL (CurrentActivity) & START_ENCOUNTER) || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) { if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2 && !GET_GAME_STATE (STARBASE_AVAILABLE)) { /* BGD mode */ InstallBombAtEarth (); } else if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0 || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) { GLOBAL (CurrentActivity) |= START_ENCOUNTER; VisitStarBase (); } else { GLOBAL (CurrentActivity) |= START_ENCOUNTER; RaceCommunication (); } if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_ENCOUNTER; if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY) GLOBAL (CurrentActivity) |= START_INTERPLANETARY; } } else if (GLOBAL (CurrentActivity) & START_INTERPLANETARY) { GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0); DrawAutoPilotMessage (TRUE); SetGameClockRate (INTERPLANETARY_CLOCK_RATE); ExploreSolarSys (); } else { // Entering HyperSpace or QuasiSpace. GLOBAL (CurrentActivity) = MAKE_WORD (IN_HYPERSPACE, 0); DrawAutoPilotMessage (TRUE); SetGameClockRate (HYPERSPACE_CLOCK_RATE); Battle (&on_battle_frame); } LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); LastActivity = GLOBAL (CurrentActivity); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) && (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE || LOBYTE (GLOBAL (CurrentActivity)) == BLACK_ORB_CUTSCENE // JMS: End demo at cutscene upon finding black orb. || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)) // if died for some reason { if (GET_GAME_STATE (KOHR_AH_KILLED_ALL)) InitCommunication (BLACKURQ_CONVERSATION); // surrendered to Ur-Quan else if (GLOBAL (CurrentActivity) & CHECK_RESTART) GLOBAL (CurrentActivity) &= ~CHECK_RESTART; break; } } while (!(GLOBAL (CurrentActivity) & CHECK_ABORT)); StopSound (); UninitGameClock (); UninitGameStructures (); ClearPlayerInputAll (); } // CloseJournal (); UninitGameKernel (); FreeMasterShipList (); FreeKernel (); MainExited = TRUE; (void) threadArg; /* Satisfying compiler (unused parameter) */ return 0; }
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 GenerateVux_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if ((matchWorld (solarSys, world, 0, MATCH_PLANET) && (CurStarDescPtr->Index == VUX_DEFINED || (CurStarDescPtr->Index == MAIDENS_DEFINED && !GET_GAME_STATE (ZEX_IS_DEAD)))) && ActivateStarShip (VUX_SHIP, SPHERE_TRACKING)) { NotifyOthers (VUX_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (VUX_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); if (CurStarDescPtr->Index == VUX_DEFINED) { SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); } else { SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); } GLOBAL (CurrentActivity) |= START_INTERPLANETARY; InitCommunication (VUX_CONVERSATION); if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) return true; { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); if (CurStarDescPtr->Index == VUX_DEFINED || !GET_GAME_STATE (ZEX_IS_DEAD)) return true; LockMutex (GraphicsLock); RepairSISBorder (); UnlockMutex (GraphicsLock); } } if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { if (CurStarDescPtr->Index == MAIDENS_DEFINED) { if (!GET_GAME_STATE (SHOFIXTI_MAIDENS)) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (MAIDENS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (MAIDENS_STRTAB)); } } else if (CurStarDescPtr->Index == VUX_BEAST_DEFINED) { if (!GET_GAME_STATE (VUX_BEAST)) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = 0; solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (BEAST_STRTAB)); } } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); } } GenerateDefault_generateOrbital (solarSys, world); if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { solarSys->SysInfo.PlanetInfo.Weather = 2; solarSys->SysInfo.PlanetInfo.Tectonics = 0; } return true; }
static bool GenerateSaMatra_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { /* Samatra */ if (matchWorld (solarSys, world, 4, 0)) { PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); if (!GET_GAME_STATE (URQUAN_MESSED_UP)) { CloneShipFragment (!GET_GAME_STATE (KOHR_AH_FRENZY) ? URQUAN_SHIP : BLACK_URQUAN_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); } else { #define URQUAN_REMNANTS 3 BYTE i; for (i = 0; i < URQUAN_REMNANTS; ++i) { CloneShipFragment (URQUAN_SHIP, &GLOBAL (npc_built_ship_q), 0); CloneShipFragment (BLACK_URQUAN_SHIP, &GLOBAL (npc_built_ship_q), 0); } } GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 1); InitCommunication (URQUAN_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { BOOLEAN UrquanSurvivors; UrquanSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q)) != 0; GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); if (UrquanSurvivors) { SET_GAME_STATE (URQUAN_PROTECTING_SAMATRA, 0); } else { EncounterGroup = 0; EncounterRace = -1; GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER; if (GET_GAME_STATE (YEHAT_CIVIL_WAR) && ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING) && ActivateStarShip (YEHAT_REBEL_SHIP, FEASIBILITY_STUDY)) InitCommunication (YEHAT_REBEL_CONVERSATION); } } return true; } GenerateDefault_generateOrbital (solarSys, world); return true; }
static bool GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { DWORD rand_val; if (matchWorld (solarSys, world, 0, 0)) { /* Spathiwa's moon */ if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES) && StartSphereTracking (SPATHI_SHIP)) { NotifyOthers (SPATHI_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (SPATHI_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); GLOBAL (CurrentActivity) |= START_INTERPLANETARY; InitCommunication (SPATHI_CONVERSATION); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); } return true; } DoPlanetaryAnalysis (&solarSys->SysInfo, world); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; solarSys->SysInfo.PlanetInfo.Weather = 0; solarSys->SysInfo.PlanetInfo.Tectonics = 0; solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28; if (!GET_GAME_STATE (UMGAH_BROADCASTERS)) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (UMGAH_BCS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (UMGAH_BCS_STRTAB)); if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES)) { // The first report talks extensively about Spathi // slave-shielding selves. If they never did so, the report // makes no sense, so use an alternate. solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); } } LoadPlanet (NULL); return true; } else if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { /* visiting Spathiwa */ DoPlanetaryAnalysis (&solarSys->SysInfo, world); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; solarSys->SysInfo.PlanetInfo.PlanetRadius = 120; solarSys->SysInfo.PlanetInfo.SurfaceGravity = CalcGravity (&solarSys->SysInfo.PlanetInfo); solarSys->SysInfo.PlanetInfo.Weather = 0; solarSys->SysInfo.PlanetInfo.Tectonics = 0; solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31; LoadPlanet (NULL); return true; } GenerateDefault_generateOrbital (solarSys, world); return true; }
static bool GenerateOrz_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { if ((CurStarDescPtr->Index == ORZ_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) || (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED && matchWorld (solarSys, world, 1, 2) && !GET_GAME_STATE (TAALO_PROTECTOR))) { COUNT i; if ((CurStarDescPtr->Index == ORZ_DEFINED || !GET_GAME_STATE (TAALO_UNPROTECTED)) && ActivateStarShip (ORZ_SHIP, SPHERE_TRACKING)) { NotifyOthers (ORZ_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); if (CurStarDescPtr->Index == ORZ_DEFINED) { CloneShipFragment (ORZ_SHIP, &GLOBAL (npc_built_ship_q), INFINITE_FLEET); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); } else { for (i = 0; i < 14; ++i) { CloneShipFragment (ORZ_SHIP, &GLOBAL (npc_built_ship_q), 0); } SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); } GLOBAL (CurrentActivity) |= START_INTERPLANETARY; InitCommunication (ORZ_CONVERSATION); if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) return true; { BOOLEAN OrzSurvivors; OrzSurvivors = GetHeadLink (&GLOBAL (npc_built_ship_q)) && (CurStarDescPtr->Index == ORZ_DEFINED || !GET_GAME_STATE (TAALO_UNPROTECTED)); GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); if (OrzSurvivors) return true; LockMutex (GraphicsLock); RepairSISBorder (); UnlockMutex (GraphicsLock); } } SET_GAME_STATE (TAALO_UNPROTECTED, 1); if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable ( LoadGraphic (TAALO_DEVICE_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (TAALO_DEVICE_STRTAB)); } else { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); } } GenerateDefault_generateOrbital (solarSys, world); return true; }