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; }
/* * Test if the SIS can have an escort of the specified race. * Returns 0 if 'race' is not available. * Otherwise, returns the number of ships that can be added. */ COUNT EscortFeasibilityStudy (COUNT race) { HFLEETINFO hFleet; hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); if (!hFleet) return 0; return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q))); }
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 GenerateUtwig_initNpcs (SOLARSYS_STATE *solarSys) { if (CurStarDescPtr->Index == BOMB_DEFINED && !GET_GAME_STATE (UTWIG_BOMB)) { ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); } else { GenerateDefault_initNpcs (solarSys); } 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; }
int main(int argc, char **argv) { char *netF; FILE *infile=NULL; struct node_gra *net=NULL; struct node_gra *p=NULL; /* --------------------------------------------------------------------------- Command line parameters --------------------------------------------------------------------------- */ if (argc < 2) { printf("\nUse: betweenness.out net_file\n\n"); return; } netF = argv[1]; /* --------------------------------------------------------------------------- Build the network --------------------------------------------------------------------------- */ infile = fopen(netF, "r"); net = FBuildNetwork(infile, 0, 0, 0, 1); fclose(infile); /* --------------------------------------------------------------------------- Calculate betweenness --------------------------------------------------------------------------- */ CalculateNodeBetweenness(net); /* --------------------------------------------------------------------------- Output results and finish --------------------------------------------------------------------------- */ p = net; while ((p = p->next) != NULL) printf("%s %d %g\n", p->label, CountLinks(p), p->dvar1); RemoveGraph(net); return 0; }
BOOLEAN RosterMenu (void) { MENU_STATE MenuState; ROSTER_STATE RosterState; memset (&MenuState, 0, sizeof MenuState); MenuState.privData = &RosterState; memset (&RosterState, 0, sizeof RosterState); RosterState.count = CountLinks (&GLOBAL (built_ship_q)); if (!RosterState.count) return FALSE; // Get the escort positions we will use and sort on X then Y assert (sizeof (RosterState.shipPos) == sizeof (ship_pos)); memcpy (RosterState.shipPos, ship_pos, sizeof (ship_pos)); qsort (RosterState.shipPos, RosterState.count, sizeof (RosterState.shipPos[0]), compShipPos); LockMutex (GraphicsLock); SetContext (StatusContext); selectSupportShip (&RosterState, MenuState.CurState); UnlockMutex (GraphicsLock); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); MenuState.InputFunc = DoModifyRoster; DoInput (&MenuState, TRUE); LockMutex (GraphicsLock); SetContext (StatusContext); // unselect the last ship drawSupportShip (&RosterState, FALSE); DrawStatusMessage (NULL); UnlockMutex (GraphicsLock); return TRUE; }
/* LinkElements verbindet die zuvor berechneten Daten eines Nahrungsnetzes in einen Vektor, damit die Populationsdynamik damit berechnet werden kann. Die Größe des Vektors beträgt ((Rnum+S)²+ 1 + Y² + 1 + (Rnum+S) + S ). Beachte dabei, dass der Index von 0 bis (Rnum+S)²+...+ S - 1 läuft! Der Rückgabewert enthält: (Rnum*S)²: Zeilen von A aneinander gereiht + 1: Links in A Y² : Zeilen von D aneinander gereiht + 1: Links in D Rnum+S: Massen aller Spezies inkl. Ressourcen S: Trophische Level aller Spezies */ gsl_vector* LinkElements(struct foodweb nicheweb, gsl_matrix* NV, gsl_matrix* A, gsl_matrix* mas, gsl_matrix* D, double Rsize, int len){ int S = nicheweb.S; int Y = nicheweb.Y; int Rnum = nicheweb.Rnum; int i, j = 0; int index = 0; // Läuft die Elemente von result ab gsl_vector* result = gsl_vector_calloc(len); //--Inhalt an die richtigen Stellen schreiben-------------------------------------------------------------------- //--A und Links in A--------------------------------------------------------------------------------------------- for(i=0; i< (S+Rnum); i++) { for(j=0; j< (S+Rnum); j++) { gsl_vector_set(result, i*(Rnum+S)+j, gsl_matrix_get(A, i, j)); // i*Res+S Zeilen = (Res+S)² Elemente aus A //printf("Index = %i, result %i gesetzt auf %f\n", index, i*(Rnum+S)+j, gsl_vector_get(result, i*(Rnum+S)+j)); index++; } //printf("\n"); } printf("Fressmatrix im Netzwerk\n"); gsl_vector_set(result, index, CountLinks(A, Rnum+S)); //printf("Index = %i, result %i gesetzt auf %f\n\n", index, index, gsl_vector_get(result, index+1)); index++; //--D und Links in D----------------------------------------------------------------------------------------------- for(i=0; i< Y; i++) { for(j=0; j< Y; j++) { gsl_vector_set(result, index, gsl_matrix_get(D, i, j)); // i*(Res+S) + Y Zeilen = Y² Elemente aus A //printf("Index = %i, result %i gesetzt auf %f\n", index, index, gsl_vector_get(result, index)); index++; } } printf("\nMigrationsmatrix im Netzwerk\n"); gsl_vector_set(result, index, CountLinks(D, Y)); //Nochmal checken ob decmigcount wirklich Links in D ist -> JA //printf("result %i gesetzt auf %f\n\n", index, gsl_vector_get(result, index)); index++; //--Massen auch von Ressource--------------------------------------------------------------------------------------- gsl_vector_set(result, index, Rsize); index++; for(i=1; i< Rnum+S; i++) { gsl_vector_set(result, index, gsl_matrix_get(mas, 0, i)); // i*(Res+S) + Y Zeilen = Y² Elemente aus A // printf("result %i gesetzt auf %f\n", index, gsl_vector_get(result, index)); index++; } printf("\nMassen im Netzwerk\n"); //--Trophische Level nur von S Spezies------------------------------------------------------------------------------- printf("Trophische Level:\n"); for(i=1; i<= S; i++) { gsl_vector_set(result, index, gsl_matrix_get(mas, 1, i)); printf("%3.1f\t", gsl_vector_get(result, index)); index++; } //-- Nischenwerte nur von S Spezies------------------------------------------------------------------------------- for(i=0; i< 3; i++) { for(j=0; j<S; j++) { gsl_vector_set(result, index, gsl_matrix_get(NV, i, j)); index++; } } printf("Nischenwerte im Netzwerk\n"); printf("\nNetzwerkkomponenten zusammengesetzt. Insgesamt %i Elemente\n\n", index); return result; }// end LinkElements
static void BuildUrquanGuard (SOLARSYS_STATE *solarSys) { BYTE ship1, ship2; BYTE b0, b1; POINT org; HIPGROUP hGroup, hNextGroup; GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (SAMATRA_GRPOFFS0); if (!GET_GAME_STATE (KOHR_AH_FRENZY)) { ship1 = URQUAN_SHIP; ship2 = BLACK_URQUAN_SHIP; } else { ship1 = BLACK_URQUAN_SHIP; ship2 = URQUAN_SHIP; } assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0) CloneShipFragment (ship1, &GLOBAL (npc_built_ship_q), 0); if (GLOBAL (BattleGroupRef) == 0) { GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1); SET_GAME_STATE_32 (SAMATRA_GRPOFFS0, GLOBAL (BattleGroupRef)); } #define NUM_URQUAN_GUARDS0 12 for (b0 = 1; b0 <= NUM_URQUAN_GUARDS0; ++b0) PutGroupInfo (GLOBAL (BattleGroupRef), b0); ReinitQueue (&GLOBAL (npc_built_ship_q)); for (b0 = 0; b0 < MAX_SHIPS_PER_SIDE; ++b0) CloneShipFragment (ship2, &GLOBAL (npc_built_ship_q), 0); #define NUM_URQUAN_GUARDS1 4 for (b0 = 1; b0 <= NUM_URQUAN_GUARDS1; ++b0) PutGroupInfo (GLOBAL (BattleGroupRef), (BYTE)(NUM_URQUAN_GUARDS0 + b0)); ReinitQueue (&GLOBAL (npc_built_ship_q)); GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP); org = planetOuterLocation (4); hGroup = GetHeadLink (&GLOBAL (ip_group_q)); for (b0 = 0, b1 = 0; b0 < NUM_URQUAN_GUARDS0; ++b0, b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1)) { IP_GROUP *GroupPtr; if (b1 % (FULL_CIRCLE / NUM_URQUAN_GUARDS1) == 0) b1 += FULL_CIRCLE / (NUM_URQUAN_GUARDS0 + NUM_URQUAN_GUARDS1); GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup); hNextGroup = _GetSuccLink (GroupPtr); GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP; GroupPtr->sys_loc = 0; GroupPtr->dest_loc = 4 + 1; GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1)); GroupPtr->group_counter = 0; GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS); GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS); UnlockIpGroup (&GLOBAL (ip_group_q), hGroup); hGroup = hNextGroup; } for (b0 = 0, b1 = 0; b0 < NUM_URQUAN_GUARDS1; ++b0, b1 += FULL_CIRCLE / NUM_URQUAN_GUARDS1) { IP_GROUP *GroupPtr; GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup); hNextGroup = _GetSuccLink (GroupPtr); GroupPtr->task = ON_STATION | IGNORE_FLAGSHIP; GroupPtr->sys_loc = 0; GroupPtr->dest_loc = 4 + 1; GroupPtr->orbit_pos = NORMALIZE_FACING (ANGLE_TO_FACING (b1)); GroupPtr->group_counter = 0; GroupPtr->loc.x = org.x + COSINE (b1, STATION_RADIUS); GroupPtr->loc.y = org.y + SINE (b1, STATION_RADIUS); UnlockIpGroup (&GLOBAL (ip_group_q), hGroup); hGroup = hNextGroup; } (void) solarSys; }
/* * What this function does depends on the value of the 'state' argument: * SPHERE_TRACKING: * The sphere of influence for the race for 'which_ship' will be shown * on the starmap in the future. * The value returned is 'which_ship', unless the type of ship is only * available in SuperMelee, in which case 0 is returned. * SPHERE_KNOWN: * The size of the fleet of the race of 'which_ship' when the starmap was * last checked is returned. * ESCORT_WORTH: * The total value of all the ships escorting the SIS is returned. * 'which_ship' is ignored. * ESCORTING_FLAGSHIP: * Test if a ship of type 'which_ship' is among the escorts of the SIS * 0 is returned if false, 1 if true. * FEASIBILITY_STUDY: * Test if the SIS can have an escort of type 'which_ship'. * 0 is returned if 'which_ship' is not available. * Otherwise, the number of ships that can be added is returned. * CHECK_ALLIANCE: * Test the alliance status of the race of 'which_ship'. * Either GOOD_GUY (allied) or BAD_GUY (not allied) is returned. * 0: * Ally with the race of 'which_ship'. This makes their ship available * for building in the shipyard. * -1: * End an alliance with the race of 'which_ship'. This ends the possibility * of building their ships in the shipyard. For the Orz also the ships the * player has with him will disappear. * any other positive number: * Give the player this much ships of type 'which_ship'. If it's */ COUNT ActivateStarShip (COUNT which_ship, SIZE state) { HSTARSHIP hStarShip, hNextShip; hStarShip = GetStarShipFromIndex ( &GLOBAL (avail_race_q), which_ship ); if (hStarShip) { switch (state) { case SPHERE_TRACKING: case SPHERE_KNOWN: { EXTENDED_SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hStarShip); if (state == SPHERE_KNOWN) which_ship = StarShipPtr->ShipInfo.known_strength; else if (StarShipPtr->ShipInfo.actual_strength == 0) { if (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY))) which_ship = 0; } else if (StarShipPtr->ShipInfo.known_strength == 0 && StarShipPtr->ShipInfo.actual_strength != (COUNT)~0) { StarShipPtr->ShipInfo.known_strength = 1; StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.loc; } UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); return (which_ship); } case ESCORT_WORTH: { COUNT ShipCost[] = { RACE_SHIP_COST }; COUNT total = 0; for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip; hStarShip = hNextShip) { SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR) LockStarShip ( &GLOBAL (built_ship_q), hStarShip); hNextShip = _GetSuccLink (StarShipPtr); total += ShipCost[GET_RACE_ID (StarShipPtr)]; UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); } return total; } case ESCORTING_FLAGSHIP: { for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip; hStarShip = hNextShip) { BYTE ship_type; SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR) LockStarShip ( &GLOBAL (built_ship_q), hStarShip); hNextShip = _GetSuccLink (StarShipPtr); ship_type = GET_RACE_ID (StarShipPtr); UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); if ((COUNT) ship_type == which_ship) return 1; } return 0; } case FEASIBILITY_STUDY: return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q))); default: { SHIP_FRAGMENTPTR StarShipPtr; if (state <= 0) { StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hStarShip ); if (state == CHECK_ALLIANCE) { state = StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY); UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); return ((COUNT)state); } else if (StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)) { StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); if (state == 0) StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY; else { StarShipPtr->ShipInfo.ship_flags |= BAD_GUY; if (which_ship == ORZ_SHIP) { BOOLEAN ShipRemoved; ShipRemoved = FALSE; for (hStarShip = GetHeadLink ( &GLOBAL (built_ship_q)); hStarShip; hStarShip = hNextShip) { BOOLEAN RemoveShip; SHIP_FRAGMENTPTR StarShipPtr2; StarShipPtr2 = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hStarShip); hNextShip = _GetSuccLink (StarShipPtr2); RemoveShip = (BOOLEAN) ( GET_RACE_ID (StarShipPtr2) == ORZ_SHIP); UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); if (RemoveShip) { ShipRemoved = TRUE; RemoveQueue (&GLOBAL (built_ship_q), hStarShip); FreeStarShip (&GLOBAL (built_ship_q), hStarShip); } } if (ShipRemoved) { LockMutex (GraphicsLock); DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); UnlockMutex (GraphicsLock); } } } } UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } else { /* 'state > 0', add ships to the escorts */ BYTE which_window; COUNT i; which_window = 0; for (i = 0; i < (COUNT)state; i++) { HSTARSHIP hOldShip; BYTE crewLevel; if (which_ship == SPATHI_SHIP && GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) crewLevel = 1; // Only Fwiffo is on board. else crewLevel = 0; // Crewed to the max hStarShip = CloneShipFragment((COUNT) which_ship, &GLOBAL (built_ship_q), crewLevel); if (!hStarShip) break; RemoveQueue (&GLOBAL (built_ship_q), hStarShip); while ((hOldShip = GetStarShipFromIndex ( &GLOBAL (built_ship_q), which_window++))) { BYTE win_loc; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hOldShip); win_loc = GET_GROUP_LOC (StarShipPtr); UnlockStarShip (&GLOBAL (built_ship_q), hOldShip); if (which_window <= win_loc) break; } StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hStarShip); SET_GROUP_LOC (StarShipPtr, which_window - 1); if (which_ship == SPATHI_SHIP && GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) { OwnStarShip (StarShipPtr, GOOD_GUY, NAME_OFFSET + NUM_CAPTAINS_NAMES); } UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip); } LockMutex (GraphicsLock); DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); UnlockMutex (GraphicsLock); return (i); } break; } } return 1; } return 0; }
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; }
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); }
int main() { long seed; FILE *inFile,*outFile; struct node_gra *net = NULL; struct node_gra *netran = NULL; struct node_gra *p = NULL; int S; struct group *part = NULL; struct group *roles = NULL; int i,t1; int rep; double realmod; double ranmodav, ranmodst; double *ranmodlis; double Tsched, Tf = 0.0; double iterfac; char netF[100]; gsl_rng *rand_gen; /* ------------------------------------------------------------ Prompt for user-defined parameters ------------------------------------------------------------ */ printf("\n# Enter random number seed (POSITIVE integer): "); scanf("%d", &seed); printf("\n# Enter the name of the network file: "); scanf("%s", &netF); printf("\n# Enter iteration factor (recommended 1.0): "); scanf("%lf", &iterfac); printf("\n# Enter the cooling factor (recommended 0.950-0.995): "); scanf("%lf", &Tsched); printf("\n# Enter the number of randomizations: "); scanf("%d", &rep); ranmodlis = allocate_d_vec(rep); /* ------------------------------------------------------------ Initialize the random number generator ------------------------------------------------------------ */ rand_gen = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(rand_gen, seed); /* ------------------------------------------------------------ Build the network ------------------------------------------------------------ */ fprintf(stderr, "\n# Creating the network\n"); inFile=fopen(netF,"r"); net = FBuildNetwork(inFile, 0, 0, 0, 1); fclose(inFile); S = CountNodes(net); fprintf(stderr, "\n# The network has %d nodes\n", S); /* ------------------------------------------------------------ Find and print the modules ------------------------------------------------------------ */ fprintf(stderr, "\n# Starting the simulated annealing\n"); fprintf(stderr, "\n# 1/T\tM\tT\n"); part = SACommunityIdent(net, 2.0 / (double)S, Tf, Tsched, iterfac, 0, 'o', 1, 's', rand_gen); outFile = fopen("modules.dat", "w"); FPrintPartition(outFile, part, 0); realmod = Modularity(part); fprintf(outFile, "# Modularity = %g\n", realmod); fclose(outFile); FPrintPajekFile("network.net", net, 0, 0, 1); FPrintPajekPartitionFile("modules.clu", net); /* ------------------------------------------------------------ Calculate and print node properties ------------------------------------------------------------ */ outFile=fopen("node_prop.dat","w"); p = net; while ((p = p->next) != NULL) { fprintf(outFile,"%s %d %lf %lf\n", p->label, CountLinks(p), ParticipationCoefficient(p), WithinModuleRelativeDegree(p, part)); } fclose(outFile); /* ------------------------------------------------------------ Find and print the roles ------------------------------------------------------------ */ fprintf(stderr, "\n# Finding node roles\n"); roles = CatalogRoleIdent(net, part); outFile = fopen("roles.dat","w"); FPrintPartition(outFile, roles, 0); fclose(outFile); MapPartToNet(roles, net); FPrintPajekPartitionFile("roles.clu", net); /* ------------------------------------------------------------ Calculate properties for the randomized graph ------------------------------------------------------------ */ ranmodav = 0.0; for (i=0; i<rep; i++) { fprintf(stderr, "\nRandomization %d\n", i+1); RemovePartition(part); if ( netran != NULL) RemoveGraph(netran); netran = RandomizeSymmetricNetwork(CopyNetwork(net), 100, rand_gen); part = SACommunityIdent(netran, 2.0 / (double)S, Tf, Tsched, iterfac, 0, 'o', 1, 'n', rand_gen); ranmodlis[i] = Modularity(part); ranmodav += ranmodlis[i]; } /* Average and standard deviation */ ranmodav /= (double)rep; ranmodst = 0.0; for (i=0; i<rep; i++) { ranmodst += (ranmodlis[i] - ranmodav) * (ranmodlis[i] - ranmodav); } ranmodst = sqrt(ranmodst / (double)rep); outFile = fopen("randomized_mod.dat", "w"); fprintf(outFile, "# M\tMrand\tsimga_Mrand\n"); fprintf(outFile, "%lf %lf %lf\n", realmod, ranmodav, ranmodst); fclose(outFile); /* ------------------------------------------------------------ Free memory ------------------------------------------------------------ */ gsl_rng_free(rand_gen); free_d_vec(ranmodlis); RemovePartition(part); RemovePartition(roles); RemoveGraph(net); if (netran != NULL) RemoveGraph(netran); return 0; }
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 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; }
/* Diese Funktion erstellt ein Nahrungsnetz nach dem Nischenmodell für S Spezies auf Y Lebensräumen, die über die Kopplungskonstante d verbunden sind. T gibt die Topologie an (siehe SetTopology). Rnum ist die Anzahl der Ressource(n) und Rsize die Startgröße der Ressource(n). C beschreibt die Konnektivität des Netzes, wobei CRange die erlaubte max. Abweichung von C angibt. */ gsl_vector *SetNicheNetwork(struct foodweb nicheweb, struct resource res, gsl_rng* rng1, const gsl_rng_type* rng1_T){ int len = ((nicheweb.Rnum+nicheweb.S)*(nicheweb.S+nicheweb.Rnum)+1+nicheweb.Y*nicheweb.Y+1+(nicheweb.Rnum+nicheweb.S)+nicheweb.S+3*(nicheweb.S)); // Länge des Rückabewerts double C = 0.15; // vorgegebenes C double CRange = 0.01; double Rsize = res.size; gsl_vector *result = gsl_vector_calloc(len); gsl_matrix *NV = gsl_matrix_calloc(3, nicheweb.S); gsl_matrix *A = gsl_matrix_calloc((nicheweb.Rnum+nicheweb.S),(nicheweb.S+nicheweb.Rnum)); gsl_matrix *mas = gsl_matrix_calloc(2, (nicheweb.Rnum+nicheweb.S)); printf("Erzeuge Nischennetz mit %i Spezies (davon gewünschte Anzahl basaler Spezies %i) auf %i Patches. Topologie-Marker %i.\n", nicheweb.S, nicheweb.B, nicheweb.Y, nicheweb.T); //--Zufallszahlengenerator initialisieren-------------------------------------------------------------------------------- // const gsl_rng_type *rng1_T; // **** // gsl_rng *rng1; // initialize random number generator // gsl_rng_env_setup(); // ermöglicht Konsolenparameter // rng1_T = gsl_rng_default; // default random number generator (so called mt19937) // gsl_rng_default_seed = 0; // default seed for rng // //gsl_rng_default_seed = ((unsigned)time(NULL)); // random starting seed for rng // //gsl_rng_default_seed = (rdtsc()); // rng1 = gsl_rng_alloc(rng1_T); //--Alle benötigten Daten ausrechnen-------------------------------------------------------------------------------------- int flag = 1; int i = 0; while(flag == 1) { flag = 0; NV = SetNicheValues(nicheweb, C, rng1, rng1_T); // Nischenwerte NOTIZ: In den gsl Objekten liegen floats! A = SetFeedingMatrix(nicheweb, NV, C, CRange); // interaction matrix int links = CountLinks(A, (nicheweb.Rnum+nicheweb.S)); //printf("Prüfe Linkanzahl\n"); double CON = (double)links/(((double)nicheweb.S)*((double)nicheweb.S)-1); if(CON < (C-CRange) || CON > (C+CRange)) { flag = 1; continue; } int bcount = 0; for(i = nicheweb.Rnum; i< (nicheweb.S + nicheweb.Rnum); i++) { if(gsl_matrix_get(A, i, 0)==1) bcount++; } if(bcount!=nicheweb.B) { flag = 1; continue; } mas = SetMasses(nicheweb, NV, A, Rsize); // Massen + TL int TL0 = 0; for(i = 0; i< nicheweb.S; i++){ if(gsl_matrix_get(mas, 1, i+nicheweb.Rnum) == 0) TL0++; } if(TL0!=0) { flag = 1; continue; } } for(i=0; i<nicheweb.S; i++) printf("Nischenwerte: %f\n", gsl_matrix_get(NV, 0, i)); gsl_matrix *D = SetTopology(nicheweb.Y, nicheweb.T); // migration matrix result = LinkElements(nicheweb, NV, A, mas, D, Rsize, len); printf("\nNetzwerk erfolgreich erzeugt!\n"); gsl_matrix_free(D); gsl_matrix_free(NV); gsl_matrix_free(A); gsl_matrix_free(mas); return result; }
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; }
// Returns TRUE if the broadcaster has been successfully activated, // and FALSE otherwise. static BOOLEAN UseCaster (void) { if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) { if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) { SET_GAME_STATE (USED_BROADCASTER, 1); return TRUE; } return FALSE; } if (LOBYTE (GLOBAL (CurrentActivity)) != IN_INTERPLANETARY || !playerInSolarSystem ()) return FALSE; if (playerInPlanetOrbit () && matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, 1, MATCH_PLANET) && CurStarDescPtr->Index == CHMMR_DEFINED && !GET_GAME_STATE (CHMMR_UNLEASHED)) { // In orbit around the Chenjesu/Mmrnmhrm home planet. NextActivity |= CHECK_LOAD; /* fake a load game */ GLOBAL (CurrentActivity) |= START_ENCOUNTER; EncounterGroup = 0; PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); SaveSolarSysLocation (); return TRUE; } { BOOLEAN FoundIlwrath; HIPGROUP hGroup; FoundIlwrath = (CurStarDescPtr->Index == ILWRATH_DEFINED) && ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING); // In the Ilwrath home system and they are alive? if (!FoundIlwrath && (hGroup = GetHeadLink (&GLOBAL (ip_group_q)))) { // Is an Ilwrath ship in the system? IP_GROUP *GroupPtr; GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup); FoundIlwrath = (GroupPtr->race_id == ILWRATH_SHIP); UnlockIpGroup (&GLOBAL (ip_group_q), hGroup); } if (FoundIlwrath) { NextActivity |= CHECK_LOAD; /* fake a load game */ GLOBAL (CurrentActivity) |= START_ENCOUNTER; EncounterGroup = 0; PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); if (CurStarDescPtr->Index == ILWRATH_DEFINED) { // Ilwrath home system. SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 4); } else { // Ilwrath ship. SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 5); } if (playerInPlanetOrbit ()) SaveSolarSysLocation (); return TRUE; } } return FALSE; }
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; }
// Put the ship icons in the PickMeleeFrame, and create a queue // for each player. // XXX TODO: split off creating the queue into a separate function. void FillPickMeleeFrame (MeleeSetup *setup) { COUNT i; CONTEXT OldContext; OldContext = SetContext (OffScreenContext); for (i = 0; i < NUM_SIDES; ++i) { COUNT side; COUNT sideI; RECT r; TEXT t; STAMP s; UNICODE buf[30]; FleetShipIndex index; sideI = GetPlayerOrder (i); side = !sideI; s.frame = SetAbsFrameIndex (PickMeleeFrame, side); SetContextFGFrame (s.frame); GetFrameRect (s.frame, &r); t.baseline.x = r.extent.width >> 1; t.baseline.y = r.extent.height - NAME_AREA_HEIGHT + RES_SCALE(4); r.corner.x += RES_SCALE(2); r.corner.y += RES_SCALE(2); r.extent.width -= RES_SCALE((2 * 2) + (RES_DESCALE(ICON_WIDTH) + 2) + 1); // JMS_GFX r.extent.height -= RES_SCALE(2 * 2) + NAME_AREA_HEIGHT; // JMS_GFX SetContextForeGroundColor (PICK_BG_COLOR); DrawFilledRectangle (&r); r.corner.x += RES_SCALE(2); // JMS_GFX r.extent.width += RES_SCALE((RES_DESCALE(ICON_WIDTH) + 2) - (2 * 2)); // JMS_GFX r.corner.y += r.extent.height; r.extent.height = NAME_AREA_HEIGHT; DrawFilledRectangle (&r); // Team name at the bottom of the frame: t.align = ALIGN_CENTER; t.pStr = MeleeSetup_getTeamName (setup, sideI); t.CharCount = (COUNT) ~0; SetContextFont (TinyFont); SetContextForeGroundColor (PICKSHIP_TEAM_NAME_TEXT_COLOR); font_DrawText (&t); // Total team value of the starting team: sprintf (buf, "%u", MeleeSetup_getFleetValue (setup, sideI)); t.baseline.x = RES_SCALE(4); t.baseline.y = RES_SCALE(7); t.align = ALIGN_LEFT; t.pStr = buf; t.CharCount = (COUNT)~0; SetContextForeGroundColor (PICKSHIP_TEAM_START_VALUE_COLOR); font_DrawText (&t); assert (CountLinks (&race_q[side]) == 0); for (index = 0; index < MELEE_FLEET_SIZE; index++) { MeleeShip StarShip; StarShip = MeleeSetup_getShip (setup, sideI, index); if (StarShip == MELEE_NONE) continue; { BYTE row, col; BYTE ship_cost; HMASTERSHIP hMasterShip; HSTARSHIP hBuiltShip; MASTER_SHIP_INFO *MasterPtr; STARSHIP *BuiltShipPtr; BYTE captains_name_index; hMasterShip = GetStarShipFromIndex (&master_q, StarShip); MasterPtr = LockMasterShip (&master_q, hMasterShip); captains_name_index = NameCaptain (&race_q[side], MasterPtr->SpeciesID); hBuiltShip = Build (&race_q[side], MasterPtr->SpeciesID); // Draw the icon. row = PickMelee_GetShipRow (index); col = PickMelee_GetShipColumn (index); s.origin.x = RES_SCALE(4) + ((ICON_WIDTH + RES_SCALE(2)) * col); // JMS_GFX s.origin.y = RES_SCALE(10) + ((ICON_HEIGHT + RES_SCALE(2)) * row); s.frame = MasterPtr->ShipInfo.icons; DrawStamp (&s); ship_cost = MasterPtr->ShipInfo.ship_cost; UnlockMasterShip (&master_q, hMasterShip); BuiltShipPtr = LockStarShip (&race_q[side], hBuiltShip); BuiltShipPtr->index = index; BuiltShipPtr->ship_cost = ship_cost; BuiltShipPtr->playerNr = side; BuiltShipPtr->captains_name_index = captains_name_index; // The next ones are not used in Melee BuiltShipPtr->crew_level = 0; BuiltShipPtr->max_crew = 0; BuiltShipPtr->race_strings = 0; BuiltShipPtr->icons = 0; BuiltShipPtr->RaceDescPtr = 0; UnlockStarShip (&race_q[side], hBuiltShip); } } } SetContext (OldContext); }
static DeviceStatus InvokeDevice (BYTE which_device) { BYTE val; switch (which_device) { case ROSY_SPHERE_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case ARTIFACT_2_DEVICE: break; case ARTIFACT_3_DEVICE: break; case SUN_EFFICIENCY_DEVICE: if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY && playerInPlanetOrbit ()) { PlayMenuSound (MENU_SOUND_INVOKED); SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND * 1) + (ONE_SECOND * 2)); if (CurStarDescPtr->Index != CHMMR_DEFINED || !matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, 1, MATCH_PLANET)) { FadeScreen (FadeAllToColor, ONE_SECOND * 2); } else { SET_GAME_STATE (CHMMR_EMERGING, 1); EncounterGroup = 0; GLOBAL (CurrentActivity) |= START_ENCOUNTER; PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (CHMMR_SHIP, &GLOBAL (npc_built_ship_q), 0); } return DEVICE_SUCCESS_NO_SOUND; } break; case UTWIG_BOMB_DEVICE: SET_GAME_STATE (UTWIG_BOMB, 0); GLOBAL (CurrentActivity) &= ~IN_BATTLE; GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; return DEVICE_SUCCESS; case ULTRON_0_DEVICE: break; case ULTRON_1_DEVICE: break; case ULTRON_2_DEVICE: break; case ULTRON_3_DEVICE: break; case MAIDENS_DEVICE: break; case TALKING_PET_DEVICE: NextActivity |= CHECK_LOAD; /* fake a load game */ GLOBAL (CurrentActivity) |= START_ENCOUNTER; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 0); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) { if (GetHeadEncounter ()) { SET_GAME_STATE (SHIP_TO_COMPEL, 1); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; SaveSisHyperState (); } else { EncounterGroup = 0; if (GetHeadLink (&GLOBAL (ip_group_q))) { SET_GAME_STATE (SHIP_TO_COMPEL, 1); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); } if (CurStarDescPtr->Index == SAMATRA_DEFINED) { SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1); } if (playerInPlanetOrbit ()) SaveSolarSysLocation (); } return DEVICE_SUCCESS; case AQUA_HELIX_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (AQUA_HELIX_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case CLEAR_SPINDLE_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case UMGAH_HYPERWAVE_DEVICE: case BURVIX_HYPERWAVE_DEVICE: if (UseCaster ()) return DEVICE_SUCCESS; break; case TAALO_PROTECTOR_DEVICE: break; case EGG_CASING0_DEVICE: case EGG_CASING1_DEVICE: case EGG_CASING2_DEVICE: break; case SYREEN_SHUTTLE_DEVICE: break; case VUX_BEAST_DEVICE: break; case DESTRUCT_CODE_DEVICE: break; case PORTAL_SPAWNER_DEVICE: #define PORTAL_FUEL_COST (10 * FUEL_TANK_SCALE) if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1 && GLOBAL_SIS (FuelOnBoard) >= PORTAL_FUEL_COST) { /* No DeltaSISGauges because the flagship picture * is currently obscured. */ GLOBAL_SIS (FuelOnBoard) -= PORTAL_FUEL_COST; SET_GAME_STATE (PORTAL_COUNTER, 1); return DEVICE_SUCCESS; } break; case URQUAN_WARP_DEVICE: break; case LUNAR_BASE_DEVICE: break; } return DEVICE_FAILURE; }
COUNT ActivateStarShip (COUNT which_ship, SIZE state) { HSTARSHIP hStarShip, hNextShip; hStarShip = GetStarShipFromIndex ( &GLOBAL (avail_race_q), which_ship ); if (hStarShip) { switch (state) { case SPHERE_TRACKING: case SPHERE_KNOWN: { EXTENDED_SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hStarShip ); if (state == SPHERE_KNOWN) which_ship = StarShipPtr->ShipInfo.known_strength; else if (StarShipPtr->ShipInfo.actual_strength == 0) { if (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY))) which_ship = 0; } else if (StarShipPtr->ShipInfo.known_strength == 0 && StarShipPtr->ShipInfo.actual_strength != (COUNT)~0) { StarShipPtr->ShipInfo.known_strength = 1; StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.loc; } UnlockStarShip ( &GLOBAL (avail_race_q), hStarShip ); return (which_ship); } case ESCORT_WORTH: which_ship = 0; case ESCORTING_FLAGSHIP: { COUNT ShipCost[] = { RACE_SHIP_COST }; for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip; hStarShip = hNextShip) { BYTE ship_type; SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hStarShip ); hNextShip = _GetSuccLink (StarShipPtr); if (state == ESCORT_WORTH) which_ship += ShipCost[GET_RACE_ID (StarShipPtr)]; else ship_type = GET_RACE_ID (StarShipPtr); UnlockStarShip ( &GLOBAL (built_ship_q), hStarShip ); if (state != ESCORT_WORTH && (COUNT)ship_type == which_ship) return (1); } return (state == ESCORTING_FLAGSHIP ? 0 : which_ship); } case FEASIBILITY_STUDY: return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q))); default: { SHIP_FRAGMENTPTR StarShipPtr; if (state <= 0) { StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hStarShip ); if (state == CHECK_ALLIANCE) { state = StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY); UnlockStarShip ( &GLOBAL (avail_race_q), hStarShip ); return ((COUNT)state); } else if (StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)) { StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); if (state == 0) StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY; else { StarShipPtr->ShipInfo.ship_flags |= BAD_GUY; if (which_ship == ORZ_SHIP) { BOOLEAN ShipRemoved; ShipRemoved = FALSE; for (hStarShip = GetHeadLink ( &GLOBAL (built_ship_q )); hStarShip; hStarShip = hNextShip) { BOOLEAN RemoveShip; SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hStarShip ); hNextShip = _GetSuccLink (StarShipPtr); RemoveShip = (BOOLEAN)( GET_RACE_ID (StarShipPtr) == ORZ_SHIP ); UnlockStarShip ( &GLOBAL (built_ship_q), hStarShip ); if (RemoveShip) { ShipRemoved = TRUE; RemoveQueue ( &GLOBAL (built_ship_q), hStarShip ); FreeStarShip ( &GLOBAL (built_ship_q), hStarShip ); } } if (ShipRemoved) { SetSemaphore (GraphicsSem); DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); ClearSemaphore (GraphicsSem); } } } } UnlockStarShip ( &GLOBAL (avail_race_q), hStarShip ); } else { BYTE which_window; COUNT i; which_window = 0; for ( i = 0; i < (COUNT)state && ( hStarShip = CloneShipFragment ( (COUNT)which_ship, (PQUEUE)(&GLOBAL (built_ship_q)), (BYTE) ( ( which_ship == SPATHI_SHIP && GET_GAME_STATE (FOUND_PLUTO_SPATHI) ) == 1 ? 1 : 0 ) ) ); i++ ) { HSTARSHIP hOldShip; RemoveQueue ( &GLOBAL (built_ship_q), hStarShip ); while ((hOldShip = GetStarShipFromIndex ( &GLOBAL (built_ship_q), which_window++ ))) { BYTE win_loc; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hOldShip ); win_loc = GET_GROUP_LOC (StarShipPtr); UnlockStarShip ( &GLOBAL (built_ship_q), hOldShip ); if (which_window <= win_loc) break; } StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (built_ship_q), hStarShip ); SET_GROUP_LOC (StarShipPtr, which_window - 1); if (which_ship == SPATHI_SHIP && GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) { OwnStarShip (StarShipPtr, GOOD_GUY, NAME_OFFSET + NUM_CAPTAINS_NAMES); } UnlockStarShip ( &GLOBAL (built_ship_q), hStarShip ); InsertQueue ( &GLOBAL (built_ship_q), hStarShip, hOldShip ); } SetSemaphore (GraphicsSem); DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); ClearSemaphore (GraphicsSem); return (i); } break; } } return (1); } return (0); }
BOOLEAN Roster (void) { COUNT num_support_ships; num_support_ships = CountLinks (&GLOBAL (built_ship_q)); if (num_support_ships) { SIZE i, j, k, l; POINT modified_ship_pos[MAX_COMBAT_SHIPS]; POINT ship_pos[MAX_COMBAT_SHIPS] = { SUPPORT_SHIP_PTS }; MENU_STATE MenuState; MENU_STATE *pOldMenuState; pOldMenuState = pMenuState; pMenuState = &MenuState; j = 0; k = (num_support_ships + 1) >> 1; for (i = 0; (int)i < (int)num_support_ships; i += 2) { modified_ship_pos[j++] = ship_pos[i]; modified_ship_pos[k++] = ship_pos[i + 1]; } k = (num_support_ships + 1) >> 1; for (i = 0; i < k; ++i) { for (j = k - 1; j > i; --j) { if (modified_ship_pos[i].y > modified_ship_pos[j].y) { POINT temp; temp = modified_ship_pos[i]; modified_ship_pos[i] = modified_ship_pos[j]; modified_ship_pos[j] = temp; } } } l = k; k = num_support_ships >> 1; for (i = 0; i < k; ++i) { for (j = k - 1; j > i; --j) { if (modified_ship_pos[i + l].y > modified_ship_pos[j + l].y) { POINT temp; temp = modified_ship_pos[i + l]; modified_ship_pos[i + l] = modified_ship_pos[j + l]; modified_ship_pos[j + l] = temp; } } } MenuState.InputFunc = DoModifyRoster; MenuState.Initialized = FALSE; MenuState.CurState = 0; MenuState.flash_task = 0; MenuState.delta_item = (SIZE)num_support_ships; MenuState.flash_frame0 = (FRAME)ship_pos; MenuState.flash_frame1 = (FRAME)modified_ship_pos; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); DoInput (&MenuState, TRUE); pMenuState = pOldMenuState; return TRUE; } return FALSE; }
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; }