From 634b4afea7f95ec2f338783f2641a88201e536e1 Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Fri, 4 Feb 2011 19:25:44 +0100 Subject: [PATCH] * allocate ccs_t via Mem_PoolAlloc * some places are #if 0'ed because they are using data from the scripts before that data is parsed. These (2) locations must be fixed. --- src/client/campaign/cp_aircraft.c | 56 ++-- src/client/campaign/cp_aircraft.h | 4 +- src/client/campaign/cp_airfight.c | 60 ++-- src/client/campaign/cp_airfight.h | 2 +- src/client/campaign/cp_alien_interest.c | 50 ++-- src/client/campaign/cp_alienbase.c | 16 +- src/client/campaign/cp_alienbase.h | 4 +- src/client/campaign/cp_aliencont.c | 42 ++-- src/client/campaign/cp_aliencont_callbacks.c | 12 +- src/client/campaign/cp_base.c | 130 ++++---- src/client/campaign/cp_base.h | 2 +- src/client/campaign/cp_base_callbacks.c | 42 ++-- src/client/campaign/cp_basedefence_callbacks.c | 2 +- src/client/campaign/cp_building.c | 18 +- src/client/campaign/cp_campaign.c | 155 +++++----- src/client/campaign/cp_campaign.h | 10 +- src/client/campaign/cp_employee.c | 22 +- src/client/campaign/cp_employee.h | 2 +- src/client/campaign/cp_event.c | 32 +- src/client/campaign/cp_event.h | 2 +- src/client/campaign/cp_installation.c | 67 ++-- src/client/campaign/cp_installation.h | 4 +- src/client/campaign/cp_installation_callbacks.c | 30 +- src/client/campaign/cp_map.c | 322 ++++++++++---------- src/client/campaign/cp_map.h | 32 +- src/client/campaign/cp_mapfightequip.c | 2 +- src/client/campaign/cp_market.c | 14 +- src/client/campaign/cp_market_callbacks.c | 48 ++-- src/client/campaign/cp_messageoptions.c | 40 ++-- src/client/campaign/cp_messageoptions_callbacks.c | 8 +- src/client/campaign/cp_messages.c | 4 +- src/client/campaign/cp_mission_triggers.c | 2 +- src/client/campaign/cp_missions.c | 94 +++--- src/client/campaign/cp_nation.c | 62 ++-- src/client/campaign/cp_parse.c | 66 ++-- src/client/campaign/cp_popup.c | 2 +- src/client/campaign/cp_produce.c | 4 +- src/client/campaign/cp_produce.h | 2 +- src/client/campaign/cp_produce_callbacks.c | 4 +- src/client/campaign/cp_rank.c | 22 +- src/client/campaign/cp_research.c | 100 +++--- src/client/campaign/cp_research_callbacks.c | 6 +- src/client/campaign/cp_save.c | 4 +- src/client/campaign/cp_statistics.c | 106 ++++---- src/client/campaign/cp_team_callbacks.c | 4 +- src/client/campaign/cp_time.c | 34 +- src/client/campaign/cp_transfer.c | 40 ++-- src/client/campaign/cp_transfer.h | 4 +- src/client/campaign/cp_transfer_callbacks.c | 16 +- src/client/campaign/cp_ufo.c | 64 ++-- src/client/campaign/cp_ufo.h | 2 +- src/client/campaign/cp_ufopedia.c | 58 ++-- src/client/campaign/cp_uforecovery.c | 24 +- src/client/campaign/cp_uforecovery.h | 2 +- src/client/campaign/cp_uforecovery_callbacks.c | 32 +- src/client/campaign/cp_xvi.c | 24 +- .../campaign/missions/cp_mission_baseattack.c | 10 +- .../campaign/missions/cp_mission_buildbase.c | 4 +- src/client/campaign/missions/cp_mission_harvest.c | 10 +- .../campaign/missions/cp_mission_intercept.c | 12 +- src/client/campaign/missions/cp_mission_recon.c | 8 +- src/client/campaign/missions/cp_mission_rescue.c | 6 +- src/client/campaign/missions/cp_mission_supply.c | 2 +- src/client/campaign/missions/cp_mission_terror.c | 14 +- src/client/campaign/missions/cp_mission_xvi.c | 4 +- src/client/cl_game_campaign.c | 40 ++-- src/client/ui/node/ui_node_base.c | 8 +- src/client/ui/node/ui_node_map.c | 86 +++--- src/tests/test_campaign.c | 72 +++--- 69 files changed, 1146 insertions(+), 1142 deletions(-) diff --git a/src/client/campaign/cp_aircraft.c b/src/client/campaign/cp_aircraft.c index 2b321b2..d208ead 100644 --- a/src/client/campaign/cp_aircraft.c +++ b/src/client/campaign/cp_aircraft.c @@ -331,15 +331,15 @@ static void AII_CarriedItems (const le_t *soldier) for (invList = CONTAINER(soldier, container); invList; invList = invList->next) { const objDef_t *item = invList->item.t; technology_t *tech = RS_GetTechForItem(item); - ccs.eMission.numItems[item->idx]++; + ccs->eMission.numItems[item->idx]++; RS_MarkCollected(tech); if (!item->reload || invList->item.a == 0) continue; - ccs.eMission.numItemsLoose[invList->item.m->idx] += invList->item.a; - if (ccs.eMission.numItemsLoose[invList->item.m->idx] >= item->ammo) { - ccs.eMission.numItemsLoose[invList->item.m->idx] -= item->ammo; - ccs.eMission.numItems[invList->item.m->idx]++; + ccs->eMission.numItemsLoose[invList->item.m->idx] += invList->item.a; + if (ccs->eMission.numItemsLoose[invList->item.m->idx] >= item->ammo) { + ccs->eMission.numItemsLoose[invList->item.m->idx] -= item->ammo; + ccs->eMission.numItems[invList->item.m->idx]++; } /* The guys keep their weapons (half-)loaded. Auto-reload * will happen at equip screen or at the start of next mission, @@ -407,9 +407,9 @@ void AII_CollectingItems (aircraft_t *aircraft, int won) } } /* Fill the missionResults array. */ - ccs.missionResults.itemTypes = aircraft->itemTypes; + ccs->missionResults.itemTypes = aircraft->itemTypes; for (i = 0; i < aircraft->itemTypes; i++) - ccs.missionResults.itemAmount += cargo[i].amount; + ccs->missionResults.itemAmount += cargo[i].amount; #ifdef DEBUG /* Print all of collected items. */ @@ -736,8 +736,8 @@ const aircraft_t *AIR_GetAircraftSilent (const char *name) if (!name) return NULL; - for (i = 0; i < ccs.numAircraftTemplates; i++) { - const aircraft_t *aircraftTemplate = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + const aircraft_t *aircraftTemplate = &ccs->aircraftTemplates[i]; if (Q_streq(aircraftTemplate->id, name)) return aircraftTemplate; } @@ -786,7 +786,7 @@ static void AII_SetAircraftInSlots (aircraft_t *aircraft) */ aircraft_t *AIR_Add (base_t *base, const aircraft_t *aircraftTemplate) { - aircraft_t *aircraft = (aircraft_t *)LIST_Add(&ccs.aircraft, (const byte *)aircraftTemplate, sizeof(*aircraftTemplate))->data; + aircraft_t *aircraft = (aircraft_t *)LIST_Add(&ccs->aircraft, (const byte *)aircraftTemplate, sizeof(*aircraftTemplate))->data; aircraft->homebase = base; return aircraft; } @@ -800,7 +800,7 @@ aircraft_t *AIR_Add (base_t *base, const aircraft_t *aircraftTemplate) */ qboolean AIR_Delete (base_t *base, const aircraft_t *aircraft) { - return LIST_Remove(&ccs.aircraft, (const void *)aircraft); + return LIST_Remove(&ccs->aircraft, (const void *)aircraft); } /** @@ -815,7 +815,7 @@ aircraft_t* AIR_NewAircraft (base_t *base, const aircraft_t *aircraftTemplate) * we do this because every aircraft can have its own parameters * now lets use the aircraft array for the base to set some parameters */ aircraft_t *aircraft = AIR_Add(base, aircraftTemplate); - aircraft->idx = ccs.campaignStats.aircraftHad++; /**< set a unique index to this aircraft. */ + aircraft->idx = ccs->campaignStats.aircraftHad++; /**< set a unique index to this aircraft. */ aircraft->homebase = base; /* Update the values of its stats */ AII_UpdateAircraftStats(aircraft); @@ -1458,15 +1458,15 @@ void AIR_ParseAircraft (const char *name, const char **text, qboolean assignAirc technology_t *tech; aircraftItemType_t itemType = MAX_ACITEMS; - if (ccs.numAircraftTemplates >= MAX_AIRCRAFT) { + if (ccs->numAircraftTemplates >= MAX_AIRCRAFT) { Com_Printf("AIR_ParseAircraft: too many aircraft definitions; def \"%s\" ignored\n", name); return; } if (!assignAircraftItems) { aircraftTemplate = NULL; - for (i = 0; i < ccs.numAircraftTemplates; i++) { - aircraft_t *aircraft = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + aircraft_t *aircraft = &ccs->aircraftTemplates[i]; if (Q_streq(aircraft->id, name)) { aircraftTemplate = aircraft; break; @@ -1479,7 +1479,7 @@ void AIR_ParseAircraft (const char *name, const char **text, qboolean assignAirc } /* initialize the menu */ - aircraftTemplate = &ccs.aircraftTemplates[ccs.numAircraftTemplates]; + aircraftTemplate = &ccs->aircraftTemplates[ccs->numAircraftTemplates]; OBJZERO(*aircraftTemplate); Com_DPrintf(DEBUG_CLIENT, "...found aircraft %s\n", name); @@ -1494,11 +1494,11 @@ void AIR_ParseAircraft (const char *name, const char **text, qboolean assignAirc /* Initialise UFO sensored */ RADAR_InitialiseUFOs(&aircraftTemplate->radar); - ccs.numAircraftTemplates++; + ccs->numAircraftTemplates++; } else { aircraftTemplate = NULL; - for (i = 0; i < ccs.numAircraftTemplates; i++) { - aircraft_t *aircraft = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + aircraft_t *aircraft = &ccs->aircraftTemplates[i]; if (Q_streq(aircraft->id, name)) { aircraftTemplate = aircraft; break; @@ -1767,18 +1767,18 @@ void AIR_ListCraftIndexes_f (void) */ void AIR_ListAircraftSamples_f (void) { - int i = 0, max = ccs.numAircraftTemplates; + int i = 0, max = ccs->numAircraftTemplates; const value_t *vp; Com_Printf("%i aircraft\n", max); if (Cmd_Argc() == 2) { max = atoi(Cmd_Argv(1)); - if (max >= ccs.numAircraftTemplates || max < 0) + if (max >= ccs->numAircraftTemplates || max < 0) return; i = max - 1; } for (; i < max; i++) { - aircraft_t *aircraftTemplate = &ccs.aircraftTemplates[i]; + aircraft_t *aircraftTemplate = &ccs->aircraftTemplates[i]; Com_Printf("aircraft: '%s'\n", aircraftTemplate->id); for (vp = aircraft_vals; vp->string; vp++) { Com_Printf("..%s: %s\n", vp->string, Com_ValueToStr(aircraftTemplate, vp->type, vp->ofs)); @@ -2616,7 +2616,7 @@ static qboolean AIR_LoadAircraftXML (mxml_node_t *p, aircraft_t *craft) craft->missionID = Mem_PoolStrDup(s, cp_campaignPool, 0); if (!craft->homebase) { - craft->idx = ccs.numUFOs; + craft->idx = ccs->numUFOs; /* detection id and time */ craft->detectionIdx = mxml_GetInt(p, SAVE_AIRCRAFT_DETECTIONIDX, 0); mxml_GetDate(p, SAVE_AIRCRAFT_LASTSPOTTED_DATE, &craft->lastSpotted.day, &craft->lastSpotted.sec); @@ -2649,7 +2649,7 @@ static qboolean AIR_LoadAircraftXML (mxml_node_t *p, aircraft_t *craft) else if (!craft->homebase) craft->aircraftTarget = AIR_AircraftGetFromIDX(tmpInt); else - craft->aircraftTarget = ccs.ufos + tmpInt; + craft->aircraftTarget = ccs->ufos + tmpInt; /* read equipment slots */ snode = mxml_GetNode(p, SAVE_AIRCRAFT_WEAPONS); @@ -2780,7 +2780,7 @@ qboolean AIR_LoadXML (mxml_node_t *parent) ssnode = mxml_GetNextNode(ssnode, snode, SAVE_AIRCRAFT_AIRCRAFT), i++) { if (!AIR_LoadAircraftXML(ssnode, UFO_GetByIDX(i))) return qfalse; - ccs.numUFOs++; + ccs->numUFOs++; } /* Load projectiles. */ @@ -2789,7 +2789,7 @@ qboolean AIR_LoadXML (mxml_node_t *parent) return qfalse; /* check UFOs - backwards */ - for (i = ccs.numUFOs - 1; i >= 0; i--) { + for (i = ccs->numUFOs - 1; i >= 0; i--) { aircraft_t *ufo = UFO_GetByIDX(i); if (ufo->time < 0 || ufo->stats[AIR_STATS_SPEED] <= 0) { Com_Printf("AIR_Load: Found invalid ufo entry - remove it - time: %i - speed: %i\n", @@ -2888,7 +2888,7 @@ qboolean AIR_ScriptSanityCheck (void) int i, j, k, error = 0; aircraft_t* a; - for (i = 0, a = ccs.aircraftTemplates; i < ccs.numAircraftTemplates; i++, a++) { + for (i = 0, a = ccs->aircraftTemplates; i < ccs->numAircraftTemplates; i++, a++) { if (a->name[0] == '\0') { error++; Com_Printf("...... aircraft '%s' has no name\n", a->id); @@ -3203,7 +3203,7 @@ void AIR_Shutdown (void) AIR_Foreach(craft) { AIR_ResetAircraftTeam(craft); } - LIST_Delete(&ccs.aircraft); + LIST_Delete(&ccs->aircraft); AIR_ShutdownCallbacks(); #ifdef DEBUG diff --git a/src/client/campaign/cp_aircraft.h b/src/client/campaign/cp_aircraft.h index 9bfe01b..109c1b5 100644 --- a/src/client/campaign/cp_aircraft.h +++ b/src/client/campaign/cp_aircraft.h @@ -159,7 +159,7 @@ typedef enum aircraftStatus_s { /** @brief An aircraft with all it's data */ typedef struct aircraft_s { - int idx; /**< Global index of this aircraft. See also ccs.numAircraft and AIRCRAFT_INVALID + int idx; /**< Global index of this aircraft. See also ccs->numAircraft and AIRCRAFT_INVALID * this index is also updated when AIR_DeleteAircraft was called * for all the other aircraft. * For aircraftTemplates[] aircraft this is the index in that array. @@ -239,7 +239,7 @@ void AIR_ListCraftIndexes_f(void); #endif #define AIR_IsAircraftOfBase(aircraft, base) ((aircraft)->homebase == (base) && (aircraft)->status != AIR_CRASHED) -#define AIR_Foreach(var) LIST_Foreach(ccs.aircraft, aircraft_t, var) +#define AIR_Foreach(var) LIST_Foreach(ccs->aircraft, aircraft_t, var) aircraft_t *AIR_Add(struct base_s *base, const aircraft_t *aircraftTemplate); qboolean AIR_Delete(struct base_s *base, const aircraft_t *aircraft); diff --git a/src/client/campaign/cp_airfight.c b/src/client/campaign/cp_airfight.c index 4d6e9a8..50b990c 100644 --- a/src/client/campaign/cp_airfight.c +++ b/src/client/campaign/cp_airfight.c @@ -33,21 +33,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "save/save_airfight.h" /** - * @brief Remove a projectile from ccs.projectiles + * @brief Remove a projectile from ccs->projectiles * @param[in] projectile The projectile to remove * @sa AIRFIGHT_AddProjectile */ static qboolean AIRFIGHT_RemoveProjectile (aircraftProjectile_t *projectile) { - const ptrdiff_t num = (ptrdiff_t)(projectile - ccs.projectiles); - REMOVE_ELEM_ADJUST_IDX(ccs.projectiles, num, ccs.numProjectiles); + const ptrdiff_t num = (ptrdiff_t)(projectile - ccs->projectiles); + REMOVE_ELEM_ADJUST_IDX(ccs->projectiles, num, ccs->numProjectiles); return qtrue; } /** - * @brief Add a projectile in ccs.projectiles - * @param[in] attackingBase the attacking base in ccs.bases[]. NULL is the attacker is an aircraft or a samsite. - * @param[in] attackingInstallation the attacking samsite in ccs.installations[]. NULL is the attacker is an aircraft or a base. + * @brief Add a projectile in ccs->projectiles + * @param[in] attackingBase the attacking base in ccs->bases[]. NULL is the attacker is an aircraft or a samsite. + * @param[in] attackingInstallation the attacking samsite in ccs->installations[]. NULL is the attacker is an aircraft or a base. * @param[in] attacker Pointer to the attacking aircraft * @param[in] target Pointer to the target aircraft * @param[in] weaponSlot Pointer to the weapon slot that fires the projectile. @@ -59,12 +59,12 @@ static qboolean AIRFIGHT_AddProjectile (const base_t* attackingBase, const insta { aircraftProjectile_t *projectile; - if (ccs.numProjectiles >= MAX_PROJECTILESONGEOSCAPE) { + if (ccs->numProjectiles >= MAX_PROJECTILESONGEOSCAPE) { Com_DPrintf(DEBUG_CLIENT, "Too many projectiles on map\n"); return qfalse; } - projectile = &ccs.projectiles[ccs.numProjectiles]; + projectile = &ccs->projectiles[ccs->numProjectiles]; if (!weaponSlot->ammo) { Com_Printf("AIRFIGHT_AddProjectile: Error - no ammo assigned\n"); @@ -106,7 +106,7 @@ static qboolean AIRFIGHT_AddProjectile (const base_t* attackingBase, const insta if (weaponSlot->ammoLeft <= 0) AII_ReloadWeapon(weaponSlot); - ccs.numProjectiles++; + ccs->numProjectiles++; return qtrue; } @@ -120,18 +120,18 @@ static void AIRFIGHT_ProjectileList_f (void) { int i; - for (i = 0; i < ccs.numProjectiles; i++) { - Com_Printf("%i. (idx: %i)\n", i, ccs.projectiles[i].idx); - Com_Printf("... type '%s'\n", ccs.projectiles[i].aircraftItem->id); - if (ccs.projectiles[i].attackingAircraft) - Com_Printf("... shooting aircraft '%s'\n", ccs.projectiles[i].attackingAircraft->id); + for (i = 0; i < ccs->numProjectiles; i++) { + Com_Printf("%i. (idx: %i)\n", i, ccs->projectiles[i].idx); + Com_Printf("... type '%s'\n", ccs->projectiles[i].aircraftItem->id); + if (ccs->projectiles[i].attackingAircraft) + Com_Printf("... shooting aircraft '%s'\n", ccs->projectiles[i].attackingAircraft->id); else Com_Printf("... base is shooting, or shooting aircraft is destroyed\n"); - if (ccs.projectiles[i].aimedAircraft) - Com_Printf("... aiming aircraft '%s'\n", ccs.projectiles[i].aimedAircraft->id); + if (ccs->projectiles[i].aimedAircraft) + Com_Printf("... aiming aircraft '%s'\n", ccs->projectiles[i].aimedAircraft->id); else Com_Printf("... aiming iddle target at (%.02f, %.02f)\n", - ccs.projectiles[i].idleTarget[0], ccs.projectiles[i].idleTarget[1]); + ccs->projectiles[i].idleTarget[0], ccs->projectiles[i].idleTarget[1]); } } #endif @@ -320,7 +320,7 @@ void AIRFIGHT_ExecuteActions (const campaign_t* campaign, aircraft_t* shooter, a const float probability = frand(); shooter->weapons[slotIdx].delayNextShot = ammo->craftitem.weaponDelay; if (probability > AIRFIGHT_ProbabilityToHit(shooter, target, shooter->weapons + slotIdx)) - AIRFIGHT_MissTarget(&ccs.projectiles[ccs.numProjectiles - 1], qfalse); + AIRFIGHT_MissTarget(&ccs->projectiles[ccs->numProjectiles - 1], qfalse); if (shooter->type != AIRCRAFT_UFO) { /* Maybe UFO is going to shoot back ? */ @@ -369,7 +369,7 @@ static void AIRFIGHT_RemoveProjectileAimingAircraft (const aircraft_t * aircraft if (!aircraft) return; - for (projectile = ccs.projectiles; idx < ccs.numProjectiles; projectile++, idx++) { + for (projectile = ccs->projectiles; idx < ccs->numProjectiles; projectile++, idx++) { if (projectile->aimedAircraft == aircraft) AIRFIGHT_MissTarget(projectile, qtrue); } @@ -385,7 +385,7 @@ static void AIRFIGHT_UpdateProjectileForDestroyedAircraft (const aircraft_t * ai aircraftProjectile_t *projectile; int idx; - for (idx = 0, projectile = ccs.projectiles; idx < ccs.numProjectiles; projectile++, idx++) { + for (idx = 0, projectile = ccs->projectiles; idx < ccs->numProjectiles; projectile++, idx++) { const aircraft_t *attacker = projectile->attackingAircraft; if (attacker == aircraft) @@ -594,9 +594,9 @@ void AIRFIGHT_CampaignRunProjectiles (const campaign_t* campaign, int dt) { int idx; - /* ccs.numProjectiles is changed in AIRFIGHT_RemoveProjectile */ - for (idx = ccs.numProjectiles - 1; idx >= 0; idx--) { - aircraftProjectile_t *projectile = &ccs.projectiles[idx]; + /* ccs->numProjectiles is changed in AIRFIGHT_RemoveProjectile */ + for (idx = ccs->numProjectiles - 1; idx >= 0; idx--) { + aircraftProjectile_t *projectile = &ccs->projectiles[idx]; const float movement = (float) dt * projectile->aircraftItem->craftitem.weaponSpeed / (float)SECONDS_PER_HOUR; projectile->time += dt; projectile->hasMoved = qtrue; @@ -608,7 +608,7 @@ void AIRFIGHT_CampaignRunProjectiles (const campaign_t* campaign, int dt) if (projectile->aimedAircraft) AIRFIGHT_ProjectileHits(campaign, projectile); - /* remove the missile from ccs.projectiles[] */ + /* remove the missile from ccs->projectiles[] */ AIRFIGHT_RemoveProjectile(projectile); } else { float angle; @@ -682,7 +682,7 @@ static void AIRFIGHT_BaseShoot (const base_t *base, baseWeapon_t *weapons, int m slot->delayNextShot = slot->ammo->craftitem.weaponDelay; /* will we miss the target ? */ if (frand() > AIRFIGHT_ProbabilityToHit(NULL, target, slot)) - AIRFIGHT_MissTarget(&ccs.projectiles[ccs.numProjectiles - 1], qfalse); + AIRFIGHT_MissTarget(&ccs->projectiles[ccs->numProjectiles - 1], qfalse); } } } @@ -738,7 +738,7 @@ static void AIRFIGHT_InstallationShoot (const installation_t *installation, base slot->delayNextShot = slot->ammo->craftitem.weaponDelay; /* will we miss the target ? */ if (frand() > AIRFIGHT_ProbabilityToHit(NULL, target, slot)) - AIRFIGHT_MissTarget(&ccs.projectiles[ccs.numProjectiles - 1], qfalse); + AIRFIGHT_MissTarget(&ccs->projectiles[ccs->numProjectiles - 1], qfalse); } } } @@ -817,9 +817,9 @@ qboolean AIRFIGHT_SaveXML (mxml_node_t *parent) { int i; - for (i = 0; i < ccs.numProjectiles; i++) { + for (i = 0; i < ccs->numProjectiles; i++) { int j; - aircraftProjectile_t *projectile = &ccs.projectiles[i]; + aircraftProjectile_t *projectile = &ccs->projectiles[i]; mxml_node_t *node = mxml_AddNode(parent, SAVE_AIRFIGHT_PROJECTILE); mxml_AddString(node, SAVE_AIRFIGHT_ITEMID, projectile->aircraftItem->id); @@ -872,7 +872,7 @@ qboolean AIRFIGHT_LoadXML (mxml_node_t *parent) mxml_node_t *positions; mxml_node_t *attackingAircraft; mxml_node_t *aimedAircraft; - aircraftProjectile_t *projectile = &ccs.projectiles[i]; + aircraftProjectile_t *projectile = &ccs->projectiles[i]; if (!tech) { Com_Printf("AIR_Load: Could not get technology of projectile %i\n", i); @@ -911,7 +911,7 @@ qboolean AIRFIGHT_LoadXML (mxml_node_t *parent) projectile->aimedAircraft = NULL; } } - ccs.numProjectiles = i; + ccs->numProjectiles = i; return qtrue; } diff --git a/src/client/campaign/cp_airfight.h b/src/client/campaign/cp_airfight.h index 51e5ddd..83ab7b5 100644 --- a/src/client/campaign/cp_airfight.h +++ b/src/client/campaign/cp_airfight.h @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** @brief projectile used during fight between two or more aircraft */ typedef struct aircraftProjectile_s { const objDef_t *aircraftItem; /**< Corresponding ammo */ - int idx; /**< self link of the idx in ccs.projectiles[] @todo: is this really needed? */ + int idx; /**< self link of the idx in ccs->projectiles[] @todo: is this really needed? */ vec3_t pos[MAX_MULTIPLE_PROJECTILES]; /**< array of positions of the projectile (latitude and longitude) - @todo why vec3_t this is long/lat */ vec3_t projectedPos[MAX_MULTIPLE_PROJECTILES]; /**< Array if projected positions of the projectile (latitude and longitude). */ vec3_t oldDrawPos[MAX_MULTIPLE_PROJECTILES]; /**< Array if old draw positions of the projectile (latitude and longitude). */ diff --git a/src/client/campaign/cp_alien_interest.c b/src/client/campaign/cp_alien_interest.c index 5d6417c..3e60df9 100644 --- a/src/client/campaign/cp_alien_interest.c +++ b/src/client/campaign/cp_alien_interest.c @@ -37,13 +37,13 @@ void CL_ResetAlienInterest (void) { int i; - ccs.lastInterestIncreaseDelay = 0; - ccs.lastMissionSpawnedDelay = 0; - ccs.overallInterest = INITIAL_OVERALL_INTEREST; + ccs->lastInterestIncreaseDelay = 0; + ccs->lastMissionSpawnedDelay = 0; + ccs->overallInterest = INITIAL_OVERALL_INTEREST; for (i = 0; i < INTERESTCATEGORY_MAX; i++) - ccs.interest[i] = 0; - ccs.interest[INTERESTCATEGORY_RECON] = INITIAL_OVERALL_INTEREST; + ccs->interest[i] = 0; + ccs->interest[INTERESTCATEGORY_RECON] = INITIAL_OVERALL_INTEREST; } /** @@ -60,8 +60,8 @@ void CL_ChangeIndividualInterest (float interestFactor, interestCategory_t categ } if (interestFactor > 0.0f) { - const int gain = (int) (interestFactor * ccs.overallInterest); - const int diff = ccs.overallInterest - ccs.interest[category]; + const int gain = (int) (interestFactor * ccs->overallInterest); + const int diff = ccs->overallInterest - ccs->interest[category]; /* Fraction of individual interest that will be won if * individal interest becomes higher than overall interest. 0 means no increase */ const float slowerIncreaseFraction = 0.5f; @@ -69,19 +69,19 @@ void CL_ChangeIndividualInterest (float interestFactor, interestCategory_t categ * But it increase slower if the individual interest becomes higher than the overall interest value */ if (diff > gain) /* Final value of individual interest is below overall interest */ - ccs.interest[category] += gain; + ccs->interest[category] += gain; else if (diff > 0) /* Initial value of individual interest is below overall interest */ - ccs.interest[category] = ccs.overallInterest + (int) (slowerIncreaseFraction * (gain - diff)); + ccs->interest[category] = ccs->overallInterest + (int) (slowerIncreaseFraction * (gain - diff)); else /* Final value of individual interest is above overall interest */ - ccs.interest[category] += (int) (slowerIncreaseFraction * gain); + ccs->interest[category] += (int) (slowerIncreaseFraction * gain); } else { /* Value decreases: interestFactor is taken from the individual interest value */ - ccs.interest[category] += (int) (interestFactor * ccs.interest[category]); - if (ccs.interest[category] < 0) { + ccs->interest[category] += (int) (interestFactor * ccs->interest[category]); + if (ccs->interest[category] < 0) { /* this may be reached if interestFactor is below -1 */ - ccs.interest[category] = 0; + ccs->interest[category] = 0; } } } @@ -96,11 +96,11 @@ void CP_IncreaseAlienInterest (const campaign_t *campaign) /* Adjust interest increase rate by difficulty. */ const int delayBetweenIncrease = HOURS_PER_ONE_INTEREST - campaign->difficulty; - ccs.lastInterestIncreaseDelay++; + ccs->lastInterestIncreaseDelay++; - if (ccs.lastInterestIncreaseDelay > delayBetweenIncrease) { - ccs.overallInterest++; - ccs.lastInterestIncreaseDelay %= delayBetweenIncrease; + if (ccs->lastInterestIncreaseDelay > delayBetweenIncrease) { + ccs->overallInterest++; + ccs->lastInterestIncreaseDelay %= delayBetweenIncrease; } } @@ -113,14 +113,14 @@ qboolean CP_SaveInterestsXML (mxml_node_t *parent) mxml_node_t *interestsNode = mxml_AddNode(parent, SAVE_INTERESTS); int i; - mxml_AddShortValue(interestsNode, SAVE_INTERESTS_LASTINCREASEDELAY, ccs.lastInterestIncreaseDelay); - mxml_AddShortValue(interestsNode, SAVE_INTERESTS_LASTMISSIONSPAWNEDDELAY, ccs.lastMissionSpawnedDelay); - mxml_AddShortValue(interestsNode, SAVE_INTERESTS_OVERALL, ccs.overallInterest); + mxml_AddShortValue(interestsNode, SAVE_INTERESTS_LASTINCREASEDELAY, ccs->lastInterestIncreaseDelay); + mxml_AddShortValue(interestsNode, SAVE_INTERESTS_LASTMISSIONSPAWNEDDELAY, ccs->lastMissionSpawnedDelay); + mxml_AddShortValue(interestsNode, SAVE_INTERESTS_OVERALL, ccs->overallInterest); Com_RegisterConstList(saveInterestConstants); for (i = 0; i < INTERESTCATEGORY_MAX; i++) { mxml_node_t * interestNode = mxml_AddNode(interestsNode, SAVE_INTERESTS_INTEREST); mxml_AddString(interestNode, SAVE_INTERESTS_ID, Com_GetConstVariable(SAVE_INTERESTCAT_NAMESPACE, i)); - mxml_AddShort(interestNode, SAVE_INTERESTS_VAL, ccs.interest[i]); + mxml_AddShort(interestNode, SAVE_INTERESTS_VAL, ccs->interest[i]); } Com_UnregisterConstList(saveInterestConstants); return qtrue; @@ -136,9 +136,9 @@ qboolean CP_LoadInterestsXML (mxml_node_t *parent) mxml_node_t *interestsNode = mxml_GetNode(parent, SAVE_INTERESTS); qboolean success = qtrue; - ccs.lastInterestIncreaseDelay = mxml_GetInt(interestsNode, SAVE_INTERESTS_LASTINCREASEDELAY, 0); - ccs.lastMissionSpawnedDelay = mxml_GetInt(interestsNode, SAVE_INTERESTS_LASTMISSIONSPAWNEDDELAY, 0); - ccs.overallInterest = mxml_GetInt(interestsNode, SAVE_INTERESTS_OVERALL, 0); + ccs->lastInterestIncreaseDelay = mxml_GetInt(interestsNode, SAVE_INTERESTS_LASTINCREASEDELAY, 0); + ccs->lastMissionSpawnedDelay = mxml_GetInt(interestsNode, SAVE_INTERESTS_LASTMISSIONSPAWNEDDELAY, 0); + ccs->overallInterest = mxml_GetInt(interestsNode, SAVE_INTERESTS_OVERALL, 0); Com_RegisterConstList(saveInterestConstants); for (node = mxml_GetNode(interestsNode, SAVE_INTERESTS_INTEREST); node; node = mxml_GetNextNode(node, interestsNode, SAVE_INTERESTS_INTEREST)) { @@ -150,7 +150,7 @@ qboolean CP_LoadInterestsXML (mxml_node_t *parent) success = qfalse; break; } - ccs.interest[cat]= mxml_GetInt(node, SAVE_INTERESTS_VAL, 0); + ccs->interest[cat]= mxml_GetInt(node, SAVE_INTERESTS_VAL, 0); } Com_UnregisterConstList(saveInterestConstants); return success; diff --git a/src/client/campaign/cp_alienbase.c b/src/client/campaign/cp_alienbase.c index e635636..f1b285a 100644 --- a/src/client/campaign/cp_alienbase.c +++ b/src/client/campaign/cp_alienbase.c @@ -97,9 +97,9 @@ alienBase_t* AB_BuildBase (const vec2_t pos) OBJZERO(base); Vector2Copy(pos, base.pos); base.stealth = initialStealthValue; - base.idx = ccs.campaignStats.alienBasesBuilt++; + base.idx = ccs->campaignStats.alienBasesBuilt++; - return (alienBase_t*)(LIST_Add(&ccs.alienBases, (const byte *)&base, sizeof(base)))->data; + return (alienBase_t*)(LIST_Add(&ccs->alienBases, (const byte *)&base, sizeof(base)))->data; } /** @@ -110,11 +110,11 @@ void AB_DestroyBase (alienBase_t *base) { assert(base); - LIST_Remove(&ccs.alienBases, (void*)base); + LIST_Remove(&ccs->alienBases, (void*)base); /* Alien loose all their interest in supply if there's no base to send the supply */ if (!AB_Exists()) - ccs.interest[INTERESTCATEGORY_SUPPLY] = 0; + ccs->interest[INTERESTCATEGORY_SUPPLY] = 0; } /** @@ -250,7 +250,7 @@ void AB_BaseSearchedByNations (void) alienBase_t* base; /* Stealth is updated only once a week */ - if (ccs.date.day % daysPerWeek) + if (ccs->date.day % daysPerWeek) return; AB_Foreach(base) { @@ -311,7 +311,7 @@ void AB_SupplyBase (alienBase_t *base, qboolean decreaseStealth) */ int AB_GetAlienBaseNumber (void) { - return LIST_Count(ccs.alienBases); + return LIST_Count(ccs->alienBases); } #ifdef DEBUG @@ -377,7 +377,7 @@ qboolean AB_LoadXML (mxml_node_t *p) } base.supply = mxml_GetInt(s, SAVE_ALIENBASE_SUPPLY, 0); base.stealth = mxml_GetFloat(s, SAVE_ALIENBASE_STEALTH, 0.0); - LIST_Add(&ccs.alienBases, (const byte *)&base, sizeof(base)); + LIST_Add(&ccs->alienBases, (const byte *)&base, sizeof(base)); } return qtrue; @@ -421,7 +421,7 @@ void AB_InitStartup (void) */ void AB_Shutdown (void) { - LIST_Delete(&ccs.alienBases); + LIST_Delete(&ccs->alienBases); #ifdef DEBUG Cmd_RemoveCommand("debug_listalienbase"); diff --git a/src/client/campaign/cp_alienbase.h b/src/client/campaign/cp_alienbase.h index 492d1a3..45627bd 100644 --- a/src/client/campaign/cp_alienbase.h +++ b/src/client/campaign/cp_alienbase.h @@ -34,10 +34,10 @@ typedef struct alienBase_s { * and base is known if stealth < 0 */ } alienBase_t; -#define AB_Foreach(var) LIST_Foreach(ccs.alienBases, alienBase_t, var) +#define AB_Foreach(var) LIST_Foreach(ccs->alienBases, alienBase_t, var) alienBase_t* AB_GetByIDX(int baseIDX); -#define AB_Exists() (!LIST_IsEmpty(ccs.alienBases)) +#define AB_Exists() (!LIST_IsEmpty(ccs->alienBases)) void AB_SetAlienBasePosition(vec2_t pos); alienBase_t* AB_BuildBase(const vec2_t pos); diff --git a/src/client/campaign/cp_aliencont.c b/src/client/campaign/cp_aliencont.c index f25a540..80f12d7 100644 --- a/src/client/campaign/cp_aliencont.c +++ b/src/client/campaign/cp_aliencont.c @@ -116,7 +116,7 @@ void AL_FillInContainment (base_t *base) containment->amountAlive = 0; containment->amountDead = 0; /* for sanity checking */ - containment->tech = ccs.teamDefTechs[td->idx]; + containment->tech = ccs->teamDefTechs[td->idx]; if (!containment->tech) Com_Error(ERR_DROP, "Could not find a valid tech for '%s'\n", td->name); Com_DPrintf(DEBUG_CLIENT, "AL_FillInContainment: type: %s tech-index: %i\n", td->name, containment->tech->idx); @@ -192,7 +192,7 @@ void AL_AddAliens (aircraft_t *aircraft) Com_Error(ERR_DROP, "AL_AddAliens: Could not get breathing apparatus item definition"); for (i = 0; i < alienCargoTypes; i++) { - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { assert(toBase->alienscont[j].teamDef); assert(cargo[i].teamDef); @@ -212,9 +212,9 @@ void AL_AddAliens (aircraft_t *aircraft) MS_AddNewMessage(_("Notice"), _("You can't hold live aliens yet. Aliens died."), qfalse, MSG_DEATH, NULL); messageAlreadySet = qtrue; } - if (!ccs.breathingMailSent) { + if (!ccs->breathingMailSent) { Cmd_ExecuteString("addeventmail alienbreathing"); - ccs.breathingMailSent = qtrue; + ccs->breathingMailSent = qtrue; } } else { int k; @@ -247,7 +247,7 @@ void AL_AddAliens (aircraft_t *aircraft) } } - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { aliensCont_t *ac = &toBase->alienscont[i]; technology_t *tech = ac->tech; #ifdef DEBUG @@ -298,7 +298,7 @@ void AL_RemoveAliens (base_t *base, const teamDef_t *alienType, int amount, cons * in Alien Containment, then remove (amount). */ while (amount > 0) { /* Find the type with maxamount. */ - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { const aliensCont_t *ac = &containment[j]; if (maxamount < ac->amountAlive) { maxamount = ac->amountAlive; @@ -329,7 +329,7 @@ void AL_RemoveAliens (base_t *base, const teamDef_t *alienType, int amount, cons break; case AL_KILL: /* We ignore 2nd and 3rd parameter of AL_RemoveAliens() here. */ - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { aliensCont_t *ac = &containment[j]; if (ac->amountAlive > 0) { ac->amountDead += ac->amountAlive; @@ -339,7 +339,7 @@ void AL_RemoveAliens (base_t *base, const teamDef_t *alienType, int amount, cons break; case AL_KILLONE: /* We ignore 3rd parameter of AL_RemoveAliens() here. */ - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { aliensCont_t *ac = &containment[j]; assert(ac->teamDef); if (ac->teamDef == alienType) { @@ -373,7 +373,7 @@ static void AL_AddAliens2 (base_t *base, const teamDef_t *alienType, const qbool containment = base->alienscont; if (dead) { - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { aliensCont_t *ac = &containment[j]; assert(ac->teamDef); if (ac->teamDef == alienType) { @@ -386,7 +386,7 @@ static void AL_AddAliens2 (base_t *base, const teamDef_t *alienType, const qbool if (!AL_CheckAliveFreeSpace(base, NULL, 1)) { return; /* stop because we will else exceed the max of aliens */ } - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { aliensCont_t *ac = &containment[j]; assert(ac->teamDef); if (ac->teamDef == alienType) { @@ -401,7 +401,7 @@ static void AL_AddAliens2 (base_t *base, const teamDef_t *alienType, const qbool /** * @brief Get index of alien. * @param[in] alienType Pointer to alien type. - * @return Index of alien in alien containment (so less than @c ccs.numAliensTD) + * @return Index of alien in alien containment (so less than @c ccs->numAliensTD) * @note It does NOT return the global team index from @c csi.teamDef array. * That would be @c alienType->idx * @sa RS_AssignTechLinks @@ -490,7 +490,7 @@ int AL_CountInBase (const base_t *base) assert(base); - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { if (base->alienscont[j].teamDef) amount += base->alienscont[j].amountAlive; } @@ -541,7 +541,7 @@ void AL_RemoveAliensExceedingCapacity (base_t *base) assert(base); assert(max >= 0); - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { const int remove = min(base->alienscont[i].amountAlive, current - max); if (!base->alienscont[i].teamDef) @@ -611,7 +611,7 @@ int AL_CountAll (void) int j; if (!B_GetBuildingStatus(base, B_ALIEN_CONTAINMENT)) continue; - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { const aliensCont_t *ac = &base->alienscont[j]; if (ac->teamDef) amount += ac->amountAlive; @@ -633,7 +633,7 @@ void AC_KillAll (base_t *base) assert(base); /* Are there aliens here at all? */ - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (base->alienscont[i].amountAlive > 0) { aliens = qtrue; break; @@ -680,15 +680,15 @@ static void AC_AddOne_f (void) /* Check that alientType exists */ containment = base->alienscont; - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { aliensCont_t *ac = &containment[j]; assert(ac->teamDef); if (ac->teamDef == alienType) break; } - if (j == ccs.numAliensTD) { + if (j == ccs->numAliensTD) { Com_Printf("AC_AddOne_f: Alien Type '%s' does not exist. Available choices are:\n", alienName); - for (j = 0; j < ccs.numAliensTD; j++) + for (j = 0; j < ccs->numAliensTD; j++) Com_Printf("\t* %s\n", containment[j].teamDef->name); return; } @@ -733,7 +733,7 @@ qboolean AC_SaveXML (mxml_node_t * parent) base_t *base; aliencont = mxml_AddNode(parent, SAVE_ALIENCONT_ALIENCONT); - mxml_AddBoolValue(aliencont, SAVE_ALIENCONT_BREATHINGMAILSENT, ccs.breathingMailSent); + mxml_AddBoolValue(aliencont, SAVE_ALIENCONT_BREATHINGMAILSENT, ccs->breathingMailSent); base = NULL; while ((base = B_GetNext(base)) != NULL) { @@ -745,7 +745,7 @@ qboolean AC_SaveXML (mxml_node_t * parent) node = mxml_AddNode(aliencont, SAVE_ALIENCONT_CONT); mxml_AddInt(node, SAVE_ALIENCONT_BASEIDX, base->idx); - for (k = 0; k < MAX_ALIENCONT_CAP && k < ccs.numAliensTD; k++) { + for (k = 0; k < MAX_ALIENCONT_CAP && k < ccs->numAliensTD; k++) { mxml_node_t * snode = mxml_AddNode(node, SAVE_ALIENCONT_ALIEN); assert(base->alienscont); @@ -774,7 +774,7 @@ qboolean AC_LoadXML (mxml_node_t * parent) int i; aliencont = mxml_GetNode(parent, SAVE_ALIENCONT_ALIENCONT); - ccs.breathingMailSent = mxml_GetBool(aliencont, SAVE_ALIENCONT_BREATHINGMAILSENT, qfalse); + ccs->breathingMailSent = mxml_GetBool(aliencont, SAVE_ALIENCONT_BREATHINGMAILSENT, qfalse); /* Init alienContainers */ for (i = 0; i < MAX_BASES; i++) { diff --git a/src/client/campaign/cp_aliencont_callbacks.c b/src/client/campaign/cp_aliencont_callbacks.c index 0b80009..f64ff00 100644 --- a/src/client/campaign/cp_aliencont_callbacks.c +++ b/src/client/campaign/cp_aliencont_callbacks.c @@ -126,7 +126,7 @@ static void AC_AlienClick (const base_t *base, int num) const aliensCont_t *containment = base->alienscont; int i, step; - for (i = 0, step = 0; i < ccs.numAliensTD; i++) { + for (i = 0, step = 0; i < ccs->numAliensTD; i++) { if (!containment[i].amountAlive && !containment[i].amountDead) continue; if (step == num) { @@ -185,7 +185,7 @@ static void AC_UpdateMenu (const base_t *base) if (B_GetBuildingStatus(base, B_ALIEN_CONTAINMENT)) { const aliensCont_t *containment = base->alienscont; int i, j; - for (i = 0, j = 0; i < ccs.numAliensTD; i++) { + for (i = 0, j = 0; i < ccs->numAliensTD; i++) { if (j < MAX_AC_MENU_ENTRIES) { if (containment[i].teamDef) { const technology_t *tech = containment[i].tech; @@ -301,7 +301,7 @@ static void AC_KillOne_f (void) if (B_GetBuildingStatus(base, B_ALIEN_CONTAINMENT)) { aliensCont_t *containment = base->alienscont; int i, step; - for (i = 0, step = 0; i < ccs.numAliensTD; i++) { + for (i = 0, step = 0; i < ccs->numAliensTD; i++) { if (!containment[i].amountAlive && !containment[i].amountDead) continue; if (step == num) { @@ -326,10 +326,12 @@ void AC_InitCallbacks (void) Cmd_AddCommand("aliencont_click", AC_AlienClick_f, "Click function for aliencont list"); aliencontCurrent = NULL; - if (ccs.numAliensTD > MAX_AC_MENU_ENTRIES) { +#if 0 + if (ccs->numAliensTD > MAX_AC_MENU_ENTRIES) { Com_Printf("Warning: More alien team definitions than we are able to display in the menus\n"); - ccs.numAliensTD = MAX_AC_MENU_ENTRIES; + ccs->numAliensTD = MAX_AC_MENU_ENTRIES; } +#endif } void AC_ShutdownCallbacks (void) diff --git a/src/client/campaign/cp_base.c b/src/client/campaign/cp_base.c index ac649c4..ab5e9cd 100644 --- a/src/client/campaign/cp_base.c +++ b/src/client/campaign/cp_base.c @@ -42,9 +42,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cp_ufo.h" #include "save/save_base.h" -#define B_GetBuildingByIDX(baseIdx, buildingIdx) (&ccs.buildings[(baseIdx)][(buildingIdx)]) -#define B_GetBuildingIDX(base, building) ((ptrdiff_t)((building) - ccs.buildings[base->idx])) -#define B_GetBaseIDX(base) ((ptrdiff_t)((base) - ccs.bases)) +#define B_GetBuildingByIDX(baseIdx, buildingIdx) (&ccs->buildings[(baseIdx)][(buildingIdx)]) +#define B_GetBuildingIDX(base, building) ((ptrdiff_t)((building) - ccs->buildings[base->idx])) +#define B_GetBaseIDX(base) ((ptrdiff_t)((base) - ccs->bases)) static void B_PackInitialEquipment(aircraft_t *aircraft, const equipDef_t *ed); @@ -291,7 +291,7 @@ qboolean B_IsBuildingDestroyable (building_t *building) */ int B_GetCount (void) { - return ccs.numBases; + return ccs->numBases; } /** @@ -300,15 +300,15 @@ int B_GetCount (void) */ base_t *B_GetNext (base_t *lastBase) { - base_t* endOfBases = &ccs.bases[B_GetCount()]; + base_t* endOfBases = &ccs->bases[B_GetCount()]; base_t* base; if (!B_GetCount()) return NULL; if (!lastBase) - return ccs.bases; - assert(lastBase >= ccs.bases); + return ccs->bases; + assert(lastBase >= ccs->bases); assert(lastBase < endOfBases); base = lastBase; @@ -331,7 +331,7 @@ base_t* B_GetBaseByIDX (int baseIdx) if (baseIdx >= MAX_BASES || baseIdx < 0) return NULL; - return &ccs.bases[baseIdx]; + return &ccs->bases[baseIdx]; } /** @@ -354,15 +354,15 @@ base_t* B_GetFoundedBaseByIDX (int baseIdx) */ building_t* B_GetNextBuilding (const base_t *base, building_t *lastBuilding) { - building_t *endOfBuildings = B_GetBuildingByIDX(base->idx, ccs.numBuildings[base->idx]); + building_t *endOfBuildings = B_GetBuildingByIDX(base->idx, ccs->numBuildings[base->idx]); building_t *building; - if (!ccs.numBuildings[base->idx]) + if (!ccs->numBuildings[base->idx]) return NULL; if (!lastBuilding) - return ccs.buildings[base->idx]; - assert(lastBuilding >= ccs.buildings[base->idx]); + return ccs->buildings[base->idx]; + assert(lastBuilding >= ccs->buildings[base->idx]); assert(lastBuilding < endOfBuildings); building = lastBuilding; @@ -537,7 +537,7 @@ void B_ResetBuildingCurrent (base_t* base) { if (base) base->buildingCurrent = NULL; - ccs.baseAction = BA_NONE; + ccs->baseAction = BA_NONE; } /** @@ -603,7 +603,7 @@ qboolean B_AssembleMap (const base_t *base) Com_Error(ERR_DROP, "MapPart for building '%s' is missing'", entry->id); Q_strcat(maps, va("b/%s ", entry->mapPart), sizeof(maps)); - } else if (entry && ccs.date.day > entry->timeStart) { + } else if (entry && ccs->date.day > entry->timeStart) { Q_strcat(maps, "b/construction ", sizeof(maps)); } else { Q_strcat(maps, "b/empty ", sizeof(maps)); @@ -725,7 +725,7 @@ static qboolean B_UpdateStatusBuilding (base_t* base, buildingType_t buildingTyp while ((building = B_GetNextBuilding(base, building))) { const building_t *dependsBuilding = building->dependsBuilding; if (dependsBuilding && buildingType == dependsBuilding->buildingType) { - /* ccs.buildings[base->idx][i] needs built/removed building */ + /* ccs->buildings[base->idx][i] needs built/removed building */ if (onBuilt && !B_GetBuildingStatus(base, building->buildingType)) { /* we can only activate a non operationnal building */ if (B_CheckUpdateBuilding(building)) { @@ -891,15 +891,15 @@ qboolean B_BuildingDestroy (building_t* building) { int const baseIDX = base->idx; - building_t* const buildings = ccs.buildings[baseIDX]; + building_t* const buildings = ccs->buildings[baseIDX]; int const idx = building->idx; int cntBldgs; int i; - REMOVE_ELEM(buildings, idx, ccs.numBuildings[baseIDX]); + REMOVE_ELEM(buildings, idx, ccs->numBuildings[baseIDX]); /* Update the link of other buildings */ - cntBldgs = ccs.numBuildings[baseIDX]; + cntBldgs = ccs->numBuildings[baseIDX]; for (i = 0; i < cntBldgs; i++) if (buildings[i].idx >= idx) { buildings[i].idx--; @@ -997,7 +997,7 @@ void B_Destroy (base_t *base) B_MoveAircraftOnGeoscapeToOtherBases(base); /* do a reverse loop as buildings are going to be destroyed */ - for (buildingIdx = ccs.numBuildings[base->idx] - 1; buildingIdx >= 0; buildingIdx--) { + for (buildingIdx = ccs->numBuildings[base->idx] - 1; buildingIdx >= 0; buildingIdx--) { building_t *building = B_GetBuildingByIDX(base->idx, buildingIdx); B_BuildingDestroy(building); } @@ -1193,7 +1193,7 @@ static void B_InitialEquipment (base_t *base, aircraft_t *assignInitialAircraft, } /* Finally update credits. */ - CL_UpdateCredits(ccs.credits - price); + CL_UpdateCredits(ccs->credits - price); } /** @@ -1230,8 +1230,8 @@ static void B_BuildFromTemplate (base_t *base, const char *templateName, qboolea } /* we need to set up the mandatory buildings */ - for (i = 0; i < ccs.numBuildingTemplates; i++) { - building_t* building = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) { + building_t* building = &ccs->buildingTemplates[i]; vec2_t pos; if (!building->mandatory || B_GetBuildingStatus(base, building->buildingType)) @@ -1263,7 +1263,7 @@ static void B_BuildFromTemplate (base_t *base, const char *templateName, qboolea /* Create random blocked fields in the base. * The first base never has blocked fields so we skip it. */ - if (ccs.campaignStats.basesBuilt >= 1) { + if (ccs->campaignStats.basesBuilt >= 1) { linkedList_t *tileGraph[BASE_SIZE * BASE_SIZE]; const int j = round((frand() * (MAX_BLOCKEDFIELDS - MIN_BLOCKEDFIELDS)) + MIN_BLOCKEDFIELDS); @@ -1322,7 +1322,7 @@ static void B_SetUpFirstBase (const campaign_t *campaign, base_t* base) const char *firebird = Com_DropShipTypeToShortName(DROPSHIP_FIREBIRD); const aircraft_t *firebirdAircraft = AIR_GetAircraft(firebird); aircraft_t *aircraft = AIR_NewAircraft(base, firebirdAircraft); - CL_UpdateCredits(ccs.credits - firebirdAircraft->price); + CL_UpdateCredits(ccs->credits - firebirdAircraft->price); if (!E_HireEmployeeByType(base, EMPL_PILOT)) Com_Error(ERR_DROP, "B_SetUpFirstBase: Hiring pilot failed."); /* Assign and equip soldiers on Dropships */ @@ -1333,7 +1333,7 @@ static void B_SetUpFirstBase (const campaign_t *campaign, base_t* base) const char *stiletto = Com_DropShipTypeToShortName(INTERCEPTOR_STILETTO); const aircraft_t *stilettoAircraft = AIR_GetAircraft(stiletto); aircraft_t *aircraft = AIR_NewAircraft(base, stilettoAircraft); - CL_UpdateCredits(ccs.credits - stilettoAircraft->price); + CL_UpdateCredits(ccs->credits - stilettoAircraft->price); if (!E_HireEmployeeByType(base, EMPL_PILOT)) Com_Error(ERR_DROP, "B_SetUpFirstBase: Hiring pilot failed."); AIM_AutoEquipAircraft(aircraft); @@ -1392,10 +1392,10 @@ void B_SetUpBase (const campaign_t *campaign, base_t* base, const vec2_t pos, co /* increase this early because a lot of functions rely on this * value to get the base we are setting up here */ - ccs.numBases++; + ccs->numBases++; /* setup for first base */ - if (ccs.campaignStats.basesBuilt == 0) + if (ccs->campaignStats.basesBuilt == 0) B_SetUpFirstBase(campaign, base); else B_BuildFromTemplate(base, NULL, qtrue); @@ -1414,8 +1414,8 @@ void B_SetUpBase (const campaign_t *campaign, base_t* base, const vec2_t pos, co AL_FillInContainment(base); PR_UpdateProductionCap(base); - ccs.campaignStats.basesBuilt++; - ccs.mapAction = MA_NONE; + ccs->campaignStats.basesBuilt++; + ccs->mapAction = MA_NONE; } /** @@ -1430,9 +1430,9 @@ const baseTemplate_t *B_GetBaseTemplate (const char *baseTemplateID) if (!baseTemplateID) return NULL; - for (i = 0; i < ccs.numBaseTemplates; i++) - if (Q_streq(ccs.baseTemplates[i].id, baseTemplateID)) - return &ccs.baseTemplates[i]; + for (i = 0; i < ccs->numBaseTemplates; i++) + if (Q_streq(ccs->baseTemplates[i].id, baseTemplateID)) + return &ccs->baseTemplates[i]; Com_Printf("Base Template %s not found\n", baseTemplateID); return NULL; @@ -1464,7 +1464,7 @@ building_t* B_SetBuildingByClick (base_t *base, const building_t const *building if (0 <= row && row < BASE_SIZE && 0 <= col && col < BASE_SIZE) { /* new building in base (not a template) */ - building_t *buildingNew = B_GetBuildingByIDX(base->idx, ccs.numBuildings[base->idx]); + building_t *buildingNew = B_GetBuildingByIDX(base->idx, ccs->numBuildings[base->idx]); /* copy building from template list to base-buildings-list */ *buildingNew = *buildingTemplate; @@ -1474,7 +1474,7 @@ building_t* B_SetBuildingByClick (base_t *base, const building_t const *building buildingNew->base = base; /* status and build (start) time */ buildingNew->buildingStatus = B_STATUS_UNDER_CONSTRUCTION; - buildingNew->timeStart = ccs.date.day; + buildingNew->timeStart = ccs->date.day; if (!base->map[row][col].blocked && !base->map[row][col].building) { baseBuildingTile_t tile; @@ -1534,9 +1534,9 @@ building_t* B_SetBuildingByClick (base_t *base, const building_t const *building buildingNew->pos[1] = row; /* pay */ - CL_UpdateCredits(ccs.credits - buildingNew->fixCosts); + CL_UpdateCredits(ccs->credits - buildingNew->fixCosts); /* Update number of buildings on the base. */ - ccs.numBuildings[base->idx]++; + ccs->numBuildings[base->idx]++; B_BuildingStatus(buildingNew); B_ResetBuildingCurrent(base); @@ -1596,7 +1596,7 @@ void B_DrawBuilding (const building_t* building) /** * @brief Counts the number of buildings of a particular type in a base. * @param[in] base Which base to count in. - * @param[in] tpl The template type in the ccs.buildingTemplates list. + * @param[in] tpl The template type in the ccs->buildingTemplates list. * @return The number of buildings or -1 on error (e.g. base index out of range) */ int B_GetNumberOfBuildingsInBaseByTemplate (const base_t *base, const building_t *tpl) @@ -1703,18 +1703,18 @@ void B_ParseBaseTemplate (const char *name, const char **text) return; } - if (ccs.numBaseTemplates >= MAX_BASETEMPLATES) + if (ccs->numBaseTemplates >= MAX_BASETEMPLATES) Com_Error(ERR_DROP, "B_ParseBaseTemplate: too many base templates"); /* create new Template */ - baseTemplate = &ccs.baseTemplates[ccs.numBaseTemplates]; + baseTemplate = &ccs->baseTemplates[ccs->numBaseTemplates]; baseTemplate->id = Mem_PoolStrDup(name, cp_campaignPool, 0); /* clear map for checking duplicate positions and buildingNums for checking moreThanOne constraint */ OBJZERO(map); OBJZERO(buildingNums); - ccs.numBaseTemplates++; + ccs->numBaseTemplates++; do { /* get the building */ @@ -1731,9 +1731,9 @@ void B_ParseBaseTemplate (const char *name, const char **text) tile = &baseTemplate->buildings[baseTemplate->numBuildings]; baseTemplate->numBuildings++; - for (i = 0; i < ccs.numBuildingTemplates; i++) - if (Q_streq(ccs.buildingTemplates[i].id, token)) { - tile->building = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) + if (Q_streq(ccs->buildingTemplates[i].id, token)) { + tile->building = &ccs->buildingTemplates[i]; if (tile->building->maxCount >= 0 && tile->building->maxCount <= buildingNums[i]) Com_Error(ERR_DROP, "B_ParseBaseTemplate: Found more %s than allowed in template %s (%d))", token, baseTemplate->id, tile->building->maxCount); buildingNums[i]++; @@ -1764,8 +1764,8 @@ void B_ParseBaseTemplate (const char *name, const char **text) } while (*text); /* templates without the must-have buildings can't be used */ - for (i = 0; i < ccs.numBuildingTemplates; i++) { - const building_t *building = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) { + const building_t *building = &ccs->buildingTemplates[i]; if (building && building->mandatory && !buildingNums[i]) { Com_Error(ERR_DROP, "Every base template needs one '%s'! '%s' has none.", building->id, baseTemplate->id); } @@ -1839,7 +1839,7 @@ void B_SelectBase (const base_t *base) if (!base) { /* if player hit the "create base" button while creating base mode is enabled * that means that player wants to quit this mode */ - if (ccs.mapAction == MA_NEWBASE) { + if (ccs->mapAction == MA_NEWBASE) { MAP_ResetAction(); return; } @@ -1848,13 +1848,13 @@ void B_SelectBase (const base_t *base) /* show radar overlay (if not already displayed) */ if (!MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); - ccs.mapAction = MA_NEWBASE; + ccs->mapAction = MA_NEWBASE; } else { - ccs.mapAction = MA_NONE; + ccs->mapAction = MA_NONE; } } else { Com_DPrintf(DEBUG_CLIENT, "B_SelectBase_f: select base with id %i\n", base->idx); - ccs.mapAction = MA_NONE; + ccs->mapAction = MA_NONE; UI_PushWindow("bases", NULL, NULL); B_SetCurrentSelectedBase(base); } @@ -2020,8 +2020,8 @@ void B_BaseResetStatus (base_t* const base) { assert(base); base->baseStatus = BASE_NOT_USED; - if (ccs.mapAction == MA_BASEATTACK) - ccs.mapAction = MA_NONE; + if (ccs->mapAction == MA_BASEATTACK) + ccs->mapAction = MA_NONE; } #ifdef DEBUG @@ -2040,7 +2040,7 @@ static void B_BuildingList_f (void) Com_Printf("\nBase id %i: %s\n", base->idx, base->name); /** @todo building count should not depend on base->idx. base->idx will not be an array index! */ - for (j = 0; j < ccs.numBuildings[base->idx]; j++) { + for (j = 0; j < ccs->numBuildings[base->idx]; j++) { const building_t *building = B_GetBuildingByIDX(base->idx, j); int k; @@ -2209,12 +2209,12 @@ static void B_PrintCapacities_f (void) if (buildingType >= MAX_BUILDING_TYPE) Com_Printf("B_PrintCapacities_f: Could not find building associated with capacity %i\n", i); else { - for (j = 0; j < ccs.numBuildingTemplates; j++) { - if (ccs.buildingTemplates[j].buildingType == buildingType) + for (j = 0; j < ccs->numBuildingTemplates; j++) { + if (ccs->buildingTemplates[j].buildingType == buildingType) break; } Com_Printf("Building: %s, capacity max: %i, capacity cur: %i\n", - ccs.buildingTemplates[j].id, base->capacities[i].max, base->capacities[i].cur); + ccs->buildingTemplates[j].id, base->capacities[i].max, base->capacities[i].cur); } } } @@ -2230,7 +2230,7 @@ static void B_BuildingConstructionFinished_f (void) if (!base) return; - for (i = 0; i < ccs.numBuildings[base->idx]; i++) { + for (i = 0; i < ccs->numBuildings[base->idx]; i++) { building_t *building = B_GetBuildingByIDX(base->idx, i); if (building->buildingStatus == B_STATUS_UNDER_CONSTRUCTION) { @@ -2393,7 +2393,7 @@ static void B_SellOrAddItems (aircraft_t *aircraft) continue; } else { /* If the related technology is researched, check the autosell option. */ - if (ccs.eMarket.autosell[item->idx]) { /* Sell items if autosell is enabled. */ + if (ccs->eMarket.autosell[item->idx]) { /* Sell items if autosell is enabled. */ BS_AddItemToMarket(item, amount); gained += (item->price * amount); numitems += amount; @@ -2424,7 +2424,7 @@ static void B_SellOrAddItems (aircraft_t *aircraft) base->name, va(ngettext("%i item was sold for %i credits.", "%i items were sold for %i credits.", forcedsold), forcedsold, forcedgained)); MS_AddNewMessage(_("Notice"), cp_messageBuffer, qfalse, MSG_STANDARD, NULL); } - CL_UpdateCredits(ccs.credits + gained + forcedgained); + CL_UpdateCredits(ccs->credits + gained + forcedgained); /* ship no longer has cargo aboard */ aircraft->itemTypes = 0; @@ -2542,8 +2542,8 @@ void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base) /* Reset given capacity in current base. */ base->capacities[cap].max = 0; /* Get building capacity. */ - for (i = 0; i < ccs.numBuildingTemplates; i++) { - const building_t *b = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) { + const building_t *b = &ccs->buildingTemplates[i]; if (b->buildingType == buildingType) { capacity = b->capacity; Com_DPrintf(DEBUG_CLIENT, "Building: %s capacity: %i\n", b->id, capacity); @@ -2559,7 +2559,7 @@ void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base) if (buildingTemplateIDX != -1) Com_DPrintf(DEBUG_CLIENT, "B_UpdateBaseCapacities: updated capacity of %s: %i\n", - ccs.buildingTemplates[buildingTemplateIDX].id, base->capacities[cap].max); + ccs->buildingTemplates[buildingTemplateIDX].id, base->capacities[cap].max); break; case MAX_CAP: /**< Update all capacities in base. */ Com_DPrintf(DEBUG_CLIENT, "B_UpdateBaseCapacities: going to update ALL capacities.\n"); @@ -2773,7 +2773,7 @@ qboolean B_LoadXML (mxml_node_t *parent) return qfalse; } - ccs.numBases = 0; + ccs->numBases = 0; Com_RegisterConstList(saveBaseConstants); for (base = mxml_GetNode(bases, SAVE_BASES_BASE), i = 0; i < MAX_BASES && base; i++, base = mxml_GetNextNode(base, bases, SAVE_BASES_BASE)) { @@ -2783,7 +2783,7 @@ qboolean B_LoadXML (mxml_node_t *parent) const char *str = mxml_GetString(base, SAVE_BASES_BASESTATUS); int j; - ccs.numBases++; + ccs->numBases++; b->idx = B_GetBaseIDX(b); b->founded = qtrue; @@ -2849,7 +2849,7 @@ qboolean B_LoadXML (mxml_node_t *parent) if (!building) continue; - ccs.buildings[i][buildId] = *building; + ccs->buildings[i][buildId] = *building; building = B_GetBuildingByIDX(i, buildId); building->idx = B_GetBuildingIDX(b, building); if (building->idx != buildId) { @@ -2871,7 +2871,7 @@ qboolean B_LoadXML (mxml_node_t *parent) building->level = mxml_GetFloat(snode, SAVE_BASES_BUILDINGLEVEL, 0); mxml_GetPos2(snode, SAVE_BASES_POS, building->pos); } - ccs.numBuildings[i] = j; + ccs->numBuildings[i] = j; BDEF_InitialiseBaseSlots(b); /* read missile battery slots */ diff --git a/src/client/campaign/cp_base.h b/src/client/campaign/cp_base.h index 99e2c4e..977c9b1 100644 --- a/src/client/campaign/cp_base.h +++ b/src/client/campaign/cp_base.h @@ -212,7 +212,7 @@ void B_SetCurrentSelectedBase(const base_t *base); qboolean B_AssembleMap(const base_t *base); /* building functions */ -#define B_IsBuildingBuiltUp(building) (!(building)->timeStart || (building)->timeStart + (building)->buildTime <= ccs.date.day) +#define B_IsBuildingBuiltUp(building) (!(building)->timeStart || (building)->timeStart + (building)->buildTime <= ccs->date.day) buildingType_t B_GetBuildingTypeByCapacity(baseCapacities_t cap); diff --git a/src/client/campaign/cp_base_callbacks.c b/src/client/campaign/cp_base_callbacks.c index 87dfd5b..56bf3d9 100644 --- a/src/client/campaign/cp_base_callbacks.c +++ b/src/client/campaign/cp_base_callbacks.c @@ -105,7 +105,7 @@ static void B_SelectBase_f (void) } baseID = atoi(Cmd_Argv(1)); /* check against MAX_BASES here! - only -1 will create a new base - * if we would check against ccs.numBases here, a click on the base summary + * if we would check against ccs->numBases here, a click on the base summary * base nodes would try to select unfounded bases */ if (baseID >= 0 && baseID < MAX_BASES) { const base_t *base = B_GetFoundedBaseByIDX(baseID); @@ -187,7 +187,7 @@ static void B_SetBaseTitle_f (void) do { j = 0; Com_sprintf(baseName, lengthof(baseName), _("Base #%i"), i); - while (j <= baseCount && !Q_streq(baseName, ccs.bases[j++].name)); + while (j <= baseCount && !Q_streq(baseName, ccs->bases[j++].name)); } while (i++ <= baseCount && j <= baseCount); } else { Q_strncpyz(baseName, _("Home"), lengthof(baseName)); @@ -208,20 +208,20 @@ static void B_BuildBase_f (void) { const nation_t *nation; base_t *base = B_GetFirstUnfoundedBase(); - const campaign_t *campaign = ccs.curCampaign; + const campaign_t *campaign = ccs->curCampaign; if (!base) return; - if (ccs.credits - campaign->basecost > 0) { + if (ccs->credits - campaign->basecost > 0) { const char *baseName = mn_base_title->string; if (baseName[0] == '\0') baseName = "Base"; /* set up the base with buildings from template */ - B_SetUpBase(campaign, base, ccs.newBasePos, baseName); + B_SetUpBase(campaign, base, ccs->newBasePos, baseName); - CL_UpdateCredits(ccs.credits - campaign->basecost); + CL_UpdateCredits(ccs->credits - campaign->basecost); nation = MAP_GetNation(base->pos); if (nation) Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("A new base has been built: %s (nation: %s)"), mn_base_title->string, _(nation->name)); @@ -234,8 +234,8 @@ static void B_BuildBase_f (void) } else { if (MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); - if (ccs.mapAction == MA_NEWBASE) - ccs.mapAction = MA_NONE; + if (ccs->mapAction == MA_NEWBASE) + ccs->mapAction = MA_NONE; CP_PopupList(_("Notice"), _("Not enough credits to set up a new base.")); } @@ -283,7 +283,7 @@ static void B_BaseInit_f (void) return; /* make sure the credits cvar is up-to-date */ - CL_UpdateCredits(ccs.credits); + CL_UpdateCredits(ccs->credits); Cvar_SetValue("mn_base_num_aircraft", AIR_BaseCountAircraft(base)); @@ -407,8 +407,8 @@ static void B_BuildingInit (base_t* base) if (!base) return; - for (i = 0; i < ccs.numBuildingTemplates; i++) { - building_t *tpl = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) { + building_t *tpl = &ccs->buildingTemplates[i]; /* make an entry in list for this building */ if (tpl->mapPart) { @@ -491,7 +491,7 @@ static void B_BuildingClick_f (void) base->buildingCurrent = building; B_DrawBuilding(building); - ccs.baseAction = BA_NEWBUILDING; + ccs->baseAction = BA_NEWBUILDING; } /** @@ -587,7 +587,7 @@ static void B_BuildingDestroy_f (void) const int buildingID = atoi(Cmd_Argv(2)); base = B_GetBaseByIDX(baseID); assert(base); - building = &ccs.buildings[baseID][buildingID]; + building = &ccs->buildings[baseID][buildingID]; } if (!base || !building) @@ -682,7 +682,7 @@ static void B_CheckBuildingStatusForMenu_f (void) while ((b = B_GetNextBuildingByType(base, b, building->buildingType))) { if (b->buildingStatus == B_STATUS_UNDER_CONSTRUCTION) { - const int delta = b->buildTime - (ccs.date.day - b->timeStart); + const int delta = b->buildTime - (ccs->date.day - b->timeStart); minDay = min(minDay, delta); } } @@ -708,7 +708,7 @@ static void B_CheckBuildingStatusForMenu_f (void) building_t *b = NULL; while ((b = B_GetNextBuildingByType(base, b, dependenceBuilding->buildingType))) { - if (b->buildTime > (ccs.date.day - b->timeStart)) { + if (b->buildTime > (ccs->date.day - b->timeStart)) { Com_sprintf(popupText, sizeof(popupText), _("Building %s is not finished yet, and is needed to use building %s."), _(dependenceBuilding->name), _(building->name)); UI_Popup(_("Notice"), popupText); @@ -780,7 +780,7 @@ static void BaseSummary_Init (const base_t *base) Q_strcat(textInfoBuffer, "\n", sizeof(textInfoBuffer)); Q_strcat(textInfoBuffer, _("^BAliens\n"), sizeof(textInfoBuffer)); - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (!containment[i].amountAlive && !containment[i].amountDead) continue; Q_strcat(textInfoBuffer, va("\t%s:\t\t\t\t%i/%i\n", @@ -792,8 +792,8 @@ static void BaseSummary_Init (const base_t *base) UI_RegisterText(TEXT_STANDARD, textInfoBuffer); Q_strcat(textStatsBuffer, _("^BBuildings\t\t\t\t\t\tCapacity\t\t\t\tAmount\n"), sizeof(textStatsBuffer)); - for (i = 0; i < ccs.numBuildingTemplates; i++) { - const building_t* b = &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) { + const building_t* b = &ccs->buildingTemplates[i]; /* only show already researched buildings */ if (!RS_IsResearched_ptr(b->tech)) @@ -812,7 +812,7 @@ static void BaseSummary_Init (const base_t *base) base->capacities[cap].cur, base->capacities[cap].max), sizeof(textStatsBuffer)); } else { if (b->buildingStatus == B_STATUS_UNDER_CONSTRUCTION) { - const int daysLeft = b->timeStart + b->buildTime - ccs.date.day; + const int daysLeft = b->timeStart + b->buildTime - ccs->date.day; /* if there is no day left the status should not be B_STATUS_UNDER_CONSTRUCTION */ assert(daysLeft); Q_strcat(textStatsBuffer, va("%s:\t\t\t\t\t\t%i %s", _(b->name), daysLeft, ngettext("day", "days", daysLeft)), sizeof(textStatsBuffer)); @@ -843,7 +843,7 @@ static void BaseSummary_Init (const base_t *base) Q_strcat(textStatsBuffer, _("^BResearch\t\t\t\t\t\tScientists\t\t\t\tPercent\n"), sizeof(textStatsBuffer)); tmp = 0; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { tech = RS_GetTechByIDX(i); if (tech->base == base && (tech->statusResearch == RS_RUNNING || tech->statusResearch == RS_PAUSED)) { Q_strcat(textStatsBuffer, va(_("%s\t\t\t\t\t\t%d\t\t\t\t%1.2f%%\n"), _(tech->name), @@ -910,7 +910,7 @@ void B_InitCallbacks (void) { mn_base_title = Cvar_Get("mn_base_title", "", 0, NULL); cl_start_buildings = Cvar_Get("cl_start_buildings", "1", CVAR_ARCHIVE, "Start with initial buildings in your first base"); - Cvar_Set("mn_base_cost", va(_("%i c"), ccs.curCampaign->basecost)); + Cvar_Set("mn_base_cost", va(_("%i c"), ccs->curCampaign->basecost)); Cvar_SetValue("mn_base_count", B_GetCount()); Cvar_SetValue("mn_base_max", MAX_BASES); diff --git a/src/client/campaign/cp_basedefence_callbacks.c b/src/client/campaign/cp_basedefence_callbacks.c index fd62434..3ca3cda 100644 --- a/src/client/campaign/cp_basedefence_callbacks.c +++ b/src/client/campaign/cp_basedefence_callbacks.c @@ -450,7 +450,7 @@ static void BDEF_RemoveItem_f (void) * @note 1st argument is the basedefence system type to destroy (sa basedefenceType_t). * @note 2nd argument is the idx of the base in which you want the battery to be destroyed. * @note if the first argument is BASEDEF_RANDOM, the type of the battery to destroy is randomly selected - * @note the building must already be removed from ccs.buildings[baseIdx][] + * @note the building must already be removed from ccs->buildings[baseIdx][] */ static void BDEF_RemoveBattery_f (void) { diff --git a/src/client/campaign/cp_building.c b/src/client/campaign/cp_building.c index 4912732..d804fcb 100644 --- a/src/client/campaign/cp_building.c +++ b/src/client/campaign/cp_building.c @@ -129,20 +129,20 @@ void B_ParseBuildings (const char *name, const char **text, qboolean link) return; } - if (ccs.numBuildingTemplates >= MAX_BUILDINGS) + if (ccs->numBuildingTemplates >= MAX_BUILDINGS) Com_Error(ERR_DROP, "B_ParseBuildings: too many buildings"); if (!link) { int i; - for (i = 0; i < ccs.numBuildingTemplates; i++) { - if (Q_streq(ccs.buildingTemplates[i].id, name)) { + for (i = 0; i < ccs->numBuildingTemplates; i++) { + if (Q_streq(ccs->buildingTemplates[i].id, name)) { Com_Printf("B_ParseBuildings: Second building with same name found (%s) - second ignored\n", name); return; } } /* new entry */ - building = &ccs.buildingTemplates[ccs.numBuildingTemplates]; + building = &ccs->buildingTemplates[ccs->numBuildingTemplates]; OBJZERO(*building); building->id = Mem_PoolStrDup(name, cp_campaignPool, 0); @@ -156,7 +156,7 @@ void B_ParseBuildings (const char *name, const char **text, qboolean link) building->dependsBuilding = NULL; building->maxCount = -1; /* Default: no limit */ - ccs.numBuildingTemplates++; + ccs->numBuildingTemplates++; do { /* get the name type */ token = Com_EParse(text, errhead, name); @@ -245,7 +245,7 @@ qboolean B_BuildingScriptSanityCheck (void) int i, error = 0; building_t* b; - for (i = 0, b = ccs.buildingTemplates; i < ccs.numBuildingTemplates; i++, b++) { + for (i = 0, b = ccs->buildingTemplates; i < ccs->numBuildingTemplates; i++, b++) { if (!b->name) { error++; Com_Printf("...... no name for building '%s' given\n", b->id); @@ -278,9 +278,9 @@ building_t *B_GetBuildingTemplate (const char *buildingName) int i = 0; assert(buildingName); - for (i = 0; i < ccs.numBuildingTemplates; i++) - if (Q_streq(ccs.buildingTemplates[i].id, buildingName)) - return &ccs.buildingTemplates[i]; + for (i = 0; i < ccs->numBuildingTemplates; i++) + if (Q_streq(ccs->buildingTemplates[i].id, buildingName)) + return &ccs->buildingTemplates[i]; Com_Printf("Building %s not found\n", buildingName); return NULL; diff --git a/src/client/campaign/cp_campaign.c b/src/client/campaign/cp_campaign.c index 2de7561..d31541a 100644 --- a/src/client/campaign/cp_campaign.c +++ b/src/client/campaign/cp_campaign.c @@ -54,7 +54,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "save/save_campaign.h" struct memPool_s *cp_campaignPool; /**< reset on every game restart */ -ccs_t ccs; +ccs_t *ccs; cvar_t *cp_campaign; cvar_t *cp_start_employees; cvar_t *cp_missiontest; @@ -140,7 +140,7 @@ void CP_ParseCharacterData (struct dbuffer *msg) */ qboolean CP_IsRunning (void) { - return ccs.curCampaign != NULL; + return ccs->curCampaign != NULL; } /** @@ -323,7 +323,7 @@ void CP_CheckLostCondition (const campaign_t *campaign) if (cp_missiontest->integer) return; - if (!endCampaign && ccs.credits < -campaign->negativeCreditsUntilLost) { + if (!endCampaign && ccs->credits < -campaign->negativeCreditsUntilLost) { UI_RegisterText(TEXT_STANDARD, _("You've gone too far into debt.")); endCampaign = qtrue; } @@ -331,7 +331,7 @@ void CP_CheckLostCondition (const campaign_t *campaign) /** @todo Should we make the campaign lost when a player loses all his bases? * until he has set up a base again, the aliens might have invaded the whole * world ;) - i mean, removing the credits check here. */ - if (ccs.credits < campaign->basecost - campaign->negativeCreditsUntilLost && !B_AtLeastOneExists()) { + if (ccs->credits < campaign->basecost - campaign->negativeCreditsUntilLost && !B_AtLeastOneExists()) { UI_RegisterText(TEXT_STANDARD, _("You've lost your bases and don't have enough money to build new ones.")); endCampaign = qtrue; } @@ -348,14 +348,14 @@ void CP_CheckLostCondition (const campaign_t *campaign) } else { /* check for nation happiness */ int j, nationBelowLimit = 0; - for (j = 0; j < ccs.numNations; j++) { + for (j = 0; j < ccs->numNations; j++) { const nation_t *nation = NAT_GetNationByIDX(j); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); if (stats->happiness < campaign->minhappiness) { nationBelowLimit++; } } - if (nationBelowLimit >= nationBelowLimitPercentage * ccs.numNations) { + if (nationBelowLimit >= nationBelowLimitPercentage * ccs->numNations) { /* lost the game */ UI_RegisterText(TEXT_STANDARD, _("Under your command, PHALANX operations have" " consistently failed to protect nations." @@ -414,7 +414,7 @@ void CL_HandleNationData (float minHappiness, qboolean won, mission_t * mis, con } /* Book-keeping. */ - won ? ccs.campaignStats.missionsWon++ : ccs.campaignStats.missionsLost++; + won ? ccs->campaignStats.missionsWon++ : ccs->campaignStats.missionsLost++; /* Calculate the actual happiness delta. The bigger the mission, the more potential influence. */ deltaHappiness = 0.004 * civilianSum + 0.004 * alienSum; @@ -423,7 +423,7 @@ void CL_HandleNationData (float minHappiness, qboolean won, mission_t * mis, con if (deltaHappiness > HAPPINESS_MAX_MISSION_IMPACT) deltaHappiness = HAPPINESS_MAX_MISSION_IMPACT; - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); float happinessFactor; @@ -445,7 +445,7 @@ static void CP_CheckMissionEnd (const campaign_t* campaign) { mission_t *mission; MIS_Foreach(mission) { - if (CP_CheckMissionLimitedInTime(mission) && Date_LaterThan(&ccs.date, &mission->finalDate)) + if (CP_CheckMissionLimitedInTime(mission) && Date_LaterThan(&ccs->date, &mission->finalDate)) CP_MissionStageEnd(campaign, mission); } } @@ -553,10 +553,10 @@ const int DETECTION_INTERVAL = (SECONDS_PER_HOUR / 2); */ static inline void CP_AdvanceTimeBySeconds (int seconds) { - ccs.date.sec += seconds; - while (ccs.date.sec >= SECONDS_PER_DAY) { - ccs.date.sec -= SECONDS_PER_DAY; - ccs.date.day++; + ccs->date.sec += seconds; + while (ccs->date.sec >= SECONDS_PER_DAY) { + ccs->date.sec -= SECONDS_PER_DAY; + ccs->date.day++; } } @@ -570,21 +570,21 @@ static inline void CP_AdvanceTimeBySeconds (int seconds) void CL_CampaignRun (campaign_t *campaign) { /* advance time */ - ccs.timer += cls.frametime * ccs.gameTimeScale; + ccs->timer += cls.frametime * ccs->gameTimeScale; - if (ccs.timer >= 1.0) { + if (ccs->timer >= 1.0) { /* calculate new date */ int currenthour; int currentmin; - int currentsecond = ccs.date.sec; - int currentday = ccs.date.day; + int currentsecond = ccs->date.sec; + int currentday = ccs->date.day; int i; const int currentinterval = (int)floor(currentsecond) % DETECTION_INTERVAL; int dt = DETECTION_INTERVAL - currentinterval; dateLong_t date, oldDate; - const int checks = (currentinterval + (int)floor(ccs.timer)) / DETECTION_INTERVAL; + const int checks = (currentinterval + (int)floor(ccs->timer)) / DETECTION_INTERVAL; - CL_DateConvertLong(&ccs.date, &oldDate); + CL_DateConvertLong(&ccs->date, &oldDate); currenthour = (int)floor(currentsecond / SECONDS_PER_HOUR); currentmin = (int)floor(currentsecond / SECONDS_PER_MINUTE); @@ -594,24 +594,24 @@ void CL_CampaignRun (campaign_t *campaign) * - Check if any new mission is detected * - Update stealth value of phalanx bases and installations ; alien bases */ for (i = 0; i < checks; i++) { - ccs.timer -= dt; + ccs->timer -= dt; currentsecond += dt; CP_AdvanceTimeBySeconds(dt); CL_CampaignFunctionPeriodicCall(campaign, dt, qfalse); /* if something stopped time, we must stop here the loop */ if (CL_IsTimeStopped()) { - ccs.timer = 0.0f; + ccs->timer = 0.0f; break; } dt = DETECTION_INTERVAL; } - dt = (int)floor(ccs.timer); + dt = (int)floor(ccs->timer); CP_AdvanceTimeBySeconds(dt); currentsecond += dt; - ccs.timer -= dt; + ccs->timer -= dt; /* compute minutely events */ /* (this may run multiple times if the time stepping is > 1 minute at a time) */ @@ -633,7 +633,7 @@ void CL_CampaignRun (campaign_t *campaign) } /* daily events */ - for (i = currentday; i < ccs.date.day; i++) { + for (i = currentday; i < ccs->date.day; i++) { /* every day */ B_UpdateBaseData(); INS_UpdateInstallationData(); @@ -664,14 +664,14 @@ void CL_CampaignRun (campaign_t *campaign) CP_CheckBaseAttacks(); BDEF_AutoSelectTarget(); - CL_DateConvertLong(&ccs.date, &date); + CL_DateConvertLong(&ccs->date, &date); /* every new month we have to handle the budget */ - if (oldDate.month < date.month && ccs.paid && B_AtLeastOneExists()) { + if (oldDate.month < date.month && ccs->paid && B_AtLeastOneExists()) { NAT_BackupMonthlyData(); NAT_HandleBudget(campaign); - ccs.paid = qfalse; + ccs->paid = qfalse; } else if (date.day > 1) - ccs.paid = qtrue; + ccs->paid = qtrue; CP_UpdateXVIMapButton(); /* set time cvars */ @@ -687,7 +687,7 @@ void CL_CampaignRun (campaign_t *campaign) */ inline qboolean CP_CheckCredits (int costs) { - if (costs >= ccs.credits) + if (costs >= ccs->credits) return qfalse; return qtrue; } @@ -702,8 +702,8 @@ void CL_UpdateCredits (int credits) /* credits */ if (credits > MAX_CREDITS) credits = MAX_CREDITS; - ccs.credits = credits; - Cvar_Set("mn_credits", va(_("%i c"), ccs.credits)); + ccs->credits = credits; + Cvar_Set("mn_credits", va(_("%i c"), ccs->credits)); } /** @@ -767,32 +767,32 @@ qboolean CP_LoadXML (mxml_node_t *parent) /* read credits */ CL_UpdateCredits(mxml_GetLong(campaignNode, SAVE_CAMPAIGN_CREDITS, 0)); - ccs.paid = mxml_GetBool(campaignNode, SAVE_CAMPAIGN_PAID, qfalse); + ccs->paid = mxml_GetBool(campaignNode, SAVE_CAMPAIGN_PAID, qfalse); cls.nextUniqueCharacterNumber = mxml_GetInt(campaignNode, SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER, 0); - mxml_GetDate(campaignNode, SAVE_CAMPAIGN_DATE, &ccs.date.day, &ccs.date.sec); + mxml_GetDate(campaignNode, SAVE_CAMPAIGN_DATE, &ccs->date.day, &ccs->date.sec); /* read other campaign data */ - ccs.civiliansKilled = mxml_GetInt(campaignNode, SAVE_CAMPAIGN_CIVILIANSKILLED, 0); - ccs.aliensKilled = mxml_GetInt(campaignNode, SAVE_CAMPAIGN_ALIENSKILLED, 0); + ccs->civiliansKilled = mxml_GetInt(campaignNode, SAVE_CAMPAIGN_CIVILIANSKILLED, 0); + ccs->aliensKilled = mxml_GetInt(campaignNode, SAVE_CAMPAIGN_ALIENSKILLED, 0); Com_DPrintf(DEBUG_CLIENT, "CP_LoadXML: Getting position\n"); /* read map view */ mapNode = mxml_GetNode(campaignNode, SAVE_CAMPAIGN_MAP); - ccs.center[0] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_CENTER0, 0.0); - ccs.center[1] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_CENTER1, 0.0); - ccs.angles[0] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ANGLES0, 0.0); - ccs.angles[1] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ANGLES1, 0.0); - ccs.zoom = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ZOOM, 0.0); + ccs->center[0] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_CENTER0, 0.0); + ccs->center[1] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_CENTER1, 0.0); + ccs->angles[0] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ANGLES0, 0.0); + ccs->angles[1] = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ANGLES1, 0.0); + ccs->zoom = mxml_GetFloat(mapNode, SAVE_CAMPAIGN_ZOOM, 0.0); /* restore the overlay. * do not use Cvar_SetValue, because this function check if value->string are equal to skip calculation * and we never set r_geoscape_overlay->string in game: cl_geoscape_overlay won't be updated if the loaded * value is 0 (and that's a problem if you're loading a game when cl_geoscape_overlay is set to another value */ cl_geoscape_overlay->integer = mxml_GetInt(mapNode, SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY, 0); radarOverlayWasSet = mxml_GetBool(mapNode, SAVE_CAMPAIGN_RADAROVERLAYWASSET, qfalse); - ccs.XVIShowMap = mxml_GetBool(mapNode, SAVE_CAMPAIGN_XVISHOWMAP, qfalse); + ccs->XVIShowMap = mxml_GetBool(mapNode, SAVE_CAMPAIGN_XVISHOWMAP, qfalse); CP_UpdateXVIMapButton(); mapDefStat = mxml_GetNode(campaignNode, SAVE_CAMPAIGN_MAPDEFSTAT); @@ -835,25 +835,25 @@ qboolean CP_SaveXML (mxml_node_t *parent) campaign = mxml_AddNode(parent, SAVE_CAMPAIGN_CAMPAIGN); - mxml_AddString(campaign, SAVE_CAMPAIGN_ID, ccs.curCampaign->id); - mxml_AddDate(campaign, SAVE_CAMPAIGN_DATE, ccs.date.day, ccs.date.sec); - mxml_AddLong(campaign, SAVE_CAMPAIGN_CREDITS, ccs.credits); - mxml_AddShort(campaign, SAVE_CAMPAIGN_PAID, ccs.paid); + mxml_AddString(campaign, SAVE_CAMPAIGN_ID, ccs->curCampaign->id); + mxml_AddDate(campaign, SAVE_CAMPAIGN_DATE, ccs->date.day, ccs->date.sec); + mxml_AddLong(campaign, SAVE_CAMPAIGN_CREDITS, ccs->credits); + mxml_AddShort(campaign, SAVE_CAMPAIGN_PAID, ccs->paid); mxml_AddShortValue(campaign, SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER, cls.nextUniqueCharacterNumber); - mxml_AddIntValue(campaign, SAVE_CAMPAIGN_CIVILIANSKILLED, ccs.civiliansKilled); - mxml_AddIntValue(campaign, SAVE_CAMPAIGN_ALIENSKILLED, ccs.aliensKilled); + mxml_AddIntValue(campaign, SAVE_CAMPAIGN_CIVILIANSKILLED, ccs->civiliansKilled); + mxml_AddIntValue(campaign, SAVE_CAMPAIGN_ALIENSKILLED, ccs->aliensKilled); /* Map and user interface */ map = mxml_AddNode(campaign, SAVE_CAMPAIGN_MAP); - mxml_AddFloat(map, SAVE_CAMPAIGN_CENTER0, ccs.center[0]); - mxml_AddFloat(map, SAVE_CAMPAIGN_CENTER1, ccs.center[1]); - mxml_AddFloat(map, SAVE_CAMPAIGN_ANGLES0, ccs.angles[0]); - mxml_AddFloat(map, SAVE_CAMPAIGN_ANGLES1, ccs.angles[1]); - mxml_AddFloat(map, SAVE_CAMPAIGN_ZOOM, ccs.zoom); + mxml_AddFloat(map, SAVE_CAMPAIGN_CENTER0, ccs->center[0]); + mxml_AddFloat(map, SAVE_CAMPAIGN_CENTER1, ccs->center[1]); + mxml_AddFloat(map, SAVE_CAMPAIGN_ANGLES0, ccs->angles[0]); + mxml_AddFloat(map, SAVE_CAMPAIGN_ANGLES1, ccs->angles[1]); + mxml_AddFloat(map, SAVE_CAMPAIGN_ZOOM, ccs->zoom); mxml_AddShort(map, SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY, cl_geoscape_overlay->integer); mxml_AddBool(map, SAVE_CAMPAIGN_RADAROVERLAYWASSET, radarOverlayWasSet); - mxml_AddBool(map, SAVE_CAMPAIGN_XVISHOWMAP, ccs.XVIShowMap); + mxml_AddBool(map, SAVE_CAMPAIGN_XVISHOWMAP, ccs->XVIShowMap); mapDefStat = mxml_AddNode(campaign, SAVE_CAMPAIGN_MAPDEFSTAT); if (!CP_SaveMapDefStatXML(mapDefStat)) @@ -873,7 +873,7 @@ void CP_StartSelectedMission (void) mission_t *mis; aircraft_t *aircraft = MAP_GetMissionAircraft(); base_t *base; - battleParam_t *battleParam = &ccs.battleParameters; + battleParam_t *battleParam = &ccs->battleParameters; if (!aircraft) { Com_Printf("CP_StartSelectedMission: No mission aircraft\n"); @@ -892,7 +892,7 @@ void CP_StartSelectedMission (void) } /* Before we start, we should clear the missionResults array. */ - OBJZERO(ccs.missionResults); + OBJZERO(ccs->missionResults); /* Various sanity checks. */ if (!mis->active) { @@ -915,9 +915,9 @@ void CP_StartSelectedMission (void) Cvar_SetValue("mn_autogo", 0); /* manage inventory */ - ccs.eMission = base->storage; /* copied, including arrays inside! */ + ccs->eMission = base->storage; /* copied, including arrays inside! */ CL_CleanTempInventory(base); - CL_CleanupAircraftCrew(aircraft, &ccs.eMission); + CL_CleanupAircraftCrew(aircraft, &ccs->eMission); CP_StartMissionMap(mis, battleParam); } @@ -1176,9 +1176,9 @@ void CL_UpdateCharacterStats (const base_t *base, const aircraft_t *aircraft) /* Check if the soldier meets the requirements for a higher rank * and do a promotion. */ - if (ccs.numRanks >= 2) { + if (ccs->numRanks >= 2) { int j; - for (j = ccs.numRanks - 1; j > chr->score.rank; j--) { + for (j = ccs->numRanks - 1; j > chr->score.rank; j--) { const rank_t *rank = CL_GetRankByIdx(j); if (CL_ShouldUpdateSoldierRank(rank, chr)) { chr->score.rank = j; @@ -1355,11 +1355,11 @@ static void CP_RemoveCampaignCommands (void) /** * @brief Called at new game and load game * @param[in] load @c true if we are loading game, @c false otherwise - * @param[in] campaign Pointer to campaign - it will be set to @c ccs.curCampaign here. + * @param[in] campaign Pointer to campaign - it will be set to @c ccs->curCampaign here. */ void CP_CampaignInit (campaign_t *campaign, qboolean load) { - ccs.curCampaign = campaign; + ccs->curCampaign = campaign; CL_ReadCampaignData(campaign); @@ -1386,25 +1386,25 @@ void CP_CampaignInit (campaign_t *campaign, qboolean load) } /* initialise view angle for 3D geoscape so that europe is seen */ - ccs.angles[YAW] = GLOBE_ROTATE; + ccs->angles[YAW] = GLOBE_ROTATE; /* initialise date */ - ccs.date = campaign->date; + ccs->date = campaign->date; MAP_Reset(campaign->map); PR_ProductionInit(); /* get day */ - while (ccs.date.sec > SECONDS_PER_DAY) { - ccs.date.sec -= SECONDS_PER_DAY; - ccs.date.day++; + while (ccs->date.sec > SECONDS_PER_DAY) { + ccs->date.sec -= SECONDS_PER_DAY; + ccs->date.day++; } CL_UpdateTime(); /* set map view */ - ccs.center[0] = ccs.center[1] = 0.5; - ccs.zoom = 1.0; - Vector2Set(ccs.smoothFinal2DGeoscapeCenter, 0.5, 0.5); - VectorSet(ccs.smoothFinalGlobeAngle, 0, GLOBE_ROTATE, 0); + ccs->center[0] = ccs->center[1] = 0.5; + ccs->zoom = 1.0; + Vector2Set(ccs->smoothFinal2DGeoscapeCenter, 0.5, 0.5); + VectorSet(ccs->smoothFinalGlobeAngle, 0, GLOBE_ROTATE, 0); CL_UpdateCredits(campaign->credits); @@ -1412,7 +1412,7 @@ void CP_CampaignInit (campaign_t *campaign, qboolean load) CL_ResetAlienInterest(); /* Initialize XVI overlay */ - Cvar_SetValue("mn_xvimap", ccs.XVIShowMap); + Cvar_SetValue("mn_xvimap", ccs->XVIShowMap); CP_InitializeXVIOverlay(NULL); /* create a base as first step */ @@ -1444,8 +1444,8 @@ void CP_Shutdown (void) UR_Shutdown(); /** @todo Where does this belong? */ - for (i = 0; i < ccs.numAlienCategories; i++) { - alienTeamCategory_t *alienCat = &ccs.alienCategories[i]; + for (i = 0; i < ccs->numAlienCategories; i++) { + alienTeamCategory_t *alienCat = &ccs->alienCategories[i]; LIST_Delete(&alienCat->equipment); } @@ -1469,11 +1469,11 @@ campaign_t* CL_GetCampaign (const char* name) campaign_t* campaign; int i; - for (i = 0, campaign = ccs.campaigns; i < ccs.numCampaigns; i++, campaign++) + for (i = 0, campaign = ccs->campaigns; i < ccs->numCampaigns; i++, campaign++) if (Q_streq(name, campaign->id)) break; - if (i == ccs.numCampaigns) { + if (i == ccs->numCampaigns) { Com_Printf("CL_GetCampaign: Campaign \"%s\" doesn't exist.\n", name); return NULL; } @@ -1495,19 +1495,18 @@ void CL_ResetSinglePlayerData (void) CL_FreeDynamicEventMail(); Mem_FreePool(cp_campaignPool); + ccs = Mem_PoolAlloc(sizeof(*ccs), cp_campaignPool, 0); /* called to flood the hash list - because the parse tech function * was maybe already called */ RS_ResetTechs(); E_ResetEmployees(); - OBJZERO(ccs); - /* Collect and count Alien team definitions. */ for (i = 0; i < csi.numTeamDefs; i++) { teamDef_t *td = &csi.teamDef[i]; if (CHRSH_IsTeamDefAlien(td)) - ccs.alienTeams[ccs.numAliensTD++] = td; + ccs->alienTeams[ccs->numAliensTD++] = td; } /* Clear mapDef usage staistics */ for (i = 0; i < cls.numMDs; i++) { diff --git a/src/client/campaign/cp_campaign.h b/src/client/campaign/cp_campaign.h index 15de1b5..4bee7ed 100644 --- a/src/client/campaign/cp_campaign.h +++ b/src/client/campaign/cp_campaign.h @@ -264,7 +264,7 @@ typedef struct mission_s { /** * @brief iterates through missions */ -#define MIS_Foreach(var) LIST_Foreach(ccs.missions, mission_t, var) +#define MIS_Foreach(var) LIST_Foreach(ccs->missions, mission_t, var) /** battlescape parameters that were used */ typedef struct battleParam_s { @@ -399,10 +399,10 @@ typedef struct ccs_s { /* Smoothing variables */ qboolean smoothRotation; /**< @c true if the rotation of 3D geoscape must me smooth */ - vec3_t smoothFinalGlobeAngle; /**< value of final ccs.angles for a smooth change of angle (see MAP_CenterOnPoint)*/ - vec2_t smoothFinal2DGeoscapeCenter; /**< value of ccs.center for a smooth change of position (see MAP_CenterOnPoint) */ + vec3_t smoothFinalGlobeAngle; /**< value of final ccs->angles for a smooth change of angle (see MAP_CenterOnPoint)*/ + vec2_t smoothFinal2DGeoscapeCenter; /**< value of ccs->center for a smooth change of position (see MAP_CenterOnPoint) */ float smoothDeltaLength; /**< angle/position difference that we need to change when smoothing */ - float smoothFinalZoom; /**< value of final ccs.zoom for a smooth change of angle (see MAP_CenterOnPoint)*/ + float smoothFinalZoom; /**< value of final ccs->zoom for a smooth change of angle (see MAP_CenterOnPoint)*/ float smoothDeltaZoom; /**< zoom difference that we need to change when smoothing */ float curZoomSpeed; /**< The current zooming speed. Used for smooth zooming. */ float curRotationSpeed; /**< The current rotation speed. Used for smooth rotating.*/ @@ -576,7 +576,7 @@ typedef struct { int x, y; } screenPoint_t; -extern ccs_t ccs; +extern ccs_t *ccs; extern const int DETECTION_INTERVAL; extern cvar_t *cp_campaign; extern cvar_t *cp_missiontest; diff --git a/src/client/campaign/cp_employee.c b/src/client/campaign/cp_employee.c index e8373d8..6ef12ee 100644 --- a/src/client/campaign/cp_employee.c +++ b/src/client/campaign/cp_employee.c @@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ int E_CountByType (employeeType_t type) { - return LIST_Count(ccs.employees[type]); + return LIST_Count(ccs->employees[type]); } /** @@ -250,7 +250,7 @@ void E_ResetEmployees (void) Com_DPrintf(DEBUG_CLIENT, "E_ResetEmployees: Delete all employees\n"); for (i = EMPL_SOLDIER; i < MAX_EMPL; i++) - LIST_Delete(&ccs.employees[i]); + LIST_Delete(&ccs->employees[i]); } /** @@ -603,7 +603,7 @@ employee_t* E_CreateEmployee (employeeType_t type, const nation_t *nation, const Com_DPrintf(DEBUG_CLIENT, "Generate character for type: %i\n", type); - return (employee_t*) LIST_Add(&ccs.employees[type], (void*) &employee, sizeof(employee))->data; + return (employee_t*) LIST_Add(&ccs->employees[type], (void*) &employee, sizeof(employee))->data; } /** @@ -614,7 +614,7 @@ employee_t* E_CreateEmployee (employeeType_t type, const nation_t *nation, const * @sa E_ResetEmployees * @sa E_UnhireEmployee * @note This function has the side effect, that the global employee number for - * the given employee type is reduced by one, also the ccs.employees pointers are + * the given employee type is reduced by one, also the ccs->employees pointers are * moved to fill the gap of the removed employee. Thus pointers like acTeam in * the aircraft can point to wrong employees now. This has to be taken into * account @@ -639,7 +639,7 @@ qboolean E_DeleteEmployee (employee_t *employee) } /* Remove the employee from the global list. */ - return LIST_Remove(&ccs.employees[type], (void*) employee); + return LIST_Remove(&ccs->employees[type], (void*) employee); } /** @@ -719,7 +719,7 @@ int E_RefreshUnhiredEmployeeGlobalList (const employeeType_t type, const qboolea happyNations[0] = NULL; /* get a list of nations, if excludeHappyNations is qtrue then also exclude * unhappy nations (unhappy nation: happiness <= 0) from the list */ - for (idx = 0; idx < ccs.numNations; idx++) { + for (idx = 0; idx < ccs->numNations; idx++) { const nation_t *nation = NAT_GetNationByIDX(idx); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); if (stats->happiness > 0 || !excludeUnhappyNations) { @@ -935,7 +935,7 @@ int E_CountUnassigned (const base_t* const base, employeeType_t type) */ static inline const nation_t *E_RandomNation (void) { - const int nationIndex = rand() % ccs.numNations; + const int nationIndex = rand() % ccs->numNations; return NAT_GetNationByIDX(nationIndex); } @@ -960,7 +960,7 @@ void E_InitialEmployees (const campaign_t *campaign) /* Fill the global data employee list with pilots, evenly distributed between nations */ for (i = 0; i < MAX_EMPLOYEES; i++) { - const int index = ++j % ccs.numNations; + const int index = ++j % ccs->numNations; const nation_t *nation = NAT_GetNationByIDX(index); if (!E_CreateEmployee(EMPL_PILOT, nation, NULL)) break; @@ -993,7 +993,7 @@ static void E_ListHired_f (void) static void CL_DebugNewEmployees_f (void) { int j; - nation_t *nation = &ccs.nations[0]; /**< This is just a debugging function, nation does not matter */ + nation_t *nation = &ccs->nations[0]; /**< This is just a debugging function, nation does not matter */ for (j = 0; j < 5; j++) /* Create a scientist */ @@ -1153,7 +1153,7 @@ qboolean E_LoadXML (mxml_node_t *p) success = qfalse; break; } - LIST_Add(&ccs.employees[emplType], (void*) &e, sizeof(e)); + LIST_Add(&ccs->employees[emplType], (void*) &e, sizeof(e)); } if (!success) break; @@ -1226,7 +1226,7 @@ void E_Shutdown (void) employeeType_t employeeType; for (employeeType = EMPL_SOLDIER; employeeType < MAX_EMPL; employeeType++) - LIST_Delete(&ccs.employees[employeeType]); + LIST_Delete(&ccs->employees[employeeType]); E_ShutdownCallbacks(); #ifdef DEBUG diff --git a/src/client/campaign/cp_employee.h b/src/client/campaign/cp_employee.h index 9f62433..eff5b1f 100644 --- a/src/client/campaign/cp_employee.h +++ b/src/client/campaign/cp_employee.h @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * @endcode */ -#define E_Foreach(employeeType, var) LIST_Foreach(ccs.employees[employeeType], employee_t, var) +#define E_Foreach(employeeType, var) LIST_Foreach(ccs->employees[employeeType], employee_t, var) /** * @brief The types of employees. diff --git a/src/client/campaign/cp_event.c b/src/client/campaign/cp_event.c index ef39bba..e51b8b2 100644 --- a/src/client/campaign/cp_event.c +++ b/src/client/campaign/cp_event.c @@ -36,7 +36,7 @@ static linkedList_t *eventMails = NULL; * @note If you want to create mails that base on a script defintion but have differnet * body messages, set createCopy to true * @param[in] id The id from the script files - * @param[in] createCopy Don't return the link to ccs.eventMails but allocate memory + * @param[in] createCopy Don't return the link to ccs->eventMails but allocate memory * and copy the gd.eventMail memory over to the newly allocated. Don't use createCopy on * dynamic mails * @sa UP_SetMailHeader @@ -49,9 +49,9 @@ eventMail_t* CL_GetEventMail (const char *id, qboolean createCopy) if (!createCopy) { eventMail_t* listMail; - for (i = 0; i < ccs.numEventMails; i++) - if (Q_streq(ccs.eventMails[i].id, id)) - return &ccs.eventMails[i]; + for (i = 0; i < ccs->numEventMails; i++) + if (Q_streq(ccs->eventMails[i].id, id)) + return &ccs->eventMails[i]; LIST_Foreach(eventMails, eventMail_t, listMail) { if (Q_streq(listMail->id, id)) @@ -64,8 +64,8 @@ eventMail_t* CL_GetEventMail (const char *id, qboolean createCopy) eventMail_t *eventMail = NULL, *newEventMail; /* search the static mails - and only the static ones! */ - for (i = 0; i < ccs.numEventMails; i++) { - eventMail_t* mail = &ccs.eventMails[i]; + for (i = 0; i < ccs->numEventMails; i++) { + eventMail_t* mail = &ccs->eventMails[i]; if (Q_streq(mail->id, id)) { eventMail = mail; break; @@ -156,13 +156,13 @@ void CL_ParseEventMails (const char *name, const char **text) const value_t *vp; const char *token; - if (ccs.numEventMails >= MAX_EVENTMAILS) { + if (ccs->numEventMails >= MAX_EVENTMAILS) { Com_Printf("CL_ParseEventMails: mail def \"%s\" with same name found, second ignored\n", name); return; } /* initialize the eventMail */ - eventMail = &ccs.eventMails[ccs.numEventMails++]; + eventMail = &ccs->eventMails[ccs->numEventMails++]; OBJZERO(*eventMail); Com_DPrintf(DEBUG_CLIENT, "...found eventMail %s\n", name); @@ -173,7 +173,7 @@ void CL_ParseEventMails (const char *name, const char **text) if (!*text || *token != '{') { Com_Printf("CL_ParseEventMails: eventMail def \"%s\" without body ignored\n", name); - ccs.numEventMails--; + ccs->numEventMails--; return; } @@ -227,7 +227,7 @@ void CP_CheckCampaignEvents (campaign_t *campaign) for (i = 0; i < events->numCampaignEvents; i++) { const campaignEvent_t *event = &events->campaignEvents[i]; - if (event->interest <= ccs.overallInterest) { + if (event->interest <= ccs->overallInterest) { RS_MarkStoryLineEventResearched(event->tech); } } @@ -242,8 +242,8 @@ const campaignEvents_t *CP_GetEventsByID (const char *name) { int i; - for (i = 0; i < ccs.numCampaignEventDefinitions; i++) { - const campaignEvents_t *events = &ccs.campaignEvents[i]; + for (i = 0; i < ccs->numCampaignEventDefinitions; i++) { + const campaignEvents_t *events = &ccs->campaignEvents[i]; if (Q_streq(events->id, name)) { int j; for (j = 0; j < events->numCampaignEvents; j++) { @@ -268,7 +268,7 @@ void CL_ParseCampaignEvents (const char *name, const char **text) const char *token; campaignEvents_t* events; - if (ccs.numCampaignEventDefinitions >= MAX_CAMPAIGNS) { + if (ccs->numCampaignEventDefinitions >= MAX_CAMPAIGNS) { Com_Printf("CL_ParseCampaignEvents: max event def limit hit\n"); return; } @@ -282,11 +282,11 @@ void CL_ParseCampaignEvents (const char *name, const char **text) return; } - events = &ccs.campaignEvents[ccs.numCampaignEventDefinitions]; + events = &ccs->campaignEvents[ccs->numCampaignEventDefinitions]; OBJZERO(*events); Com_DPrintf(DEBUG_CLIENT, "...found events %s\n", name); events->id = Mem_PoolStrDup(name, cp_campaignPool, 0); - ccs.numCampaignEventDefinitions++; + ccs->numCampaignEventDefinitions++; do { campaignEvent_t *event; @@ -351,7 +351,7 @@ void CL_EventAddMail_f (void) if (!eventMail->date) { dateLong_t date; - CL_DateConvertLong(&ccs.date, &date); + CL_DateConvertLong(&ccs->date, &date); Com_sprintf(dateBuf, sizeof(dateBuf), _("%i %s %02i"), date.year, Date_GetMonthName(date.month - 1), date.day); eventMail->date = Mem_PoolStrDup(dateBuf, cp_campaignPool, 0); diff --git a/src/client/campaign/cp_event.h b/src/client/campaign/cp_event.h index bbfa35b..7e45e3f 100644 --- a/src/client/campaign/cp_event.h +++ b/src/client/campaign/cp_event.h @@ -62,7 +62,7 @@ void CL_FreeDynamicEventMail(void); */ typedef struct campaignEvent_s { char *tech; /**< technology id that should be researched if the overall interest is reached */ - int interest; /**< the interest value (see @c ccs.oberallInterest) */ + int interest; /**< the interest value (see @c ccs->oberallInterest) */ } campaignEvent_t; typedef struct campaignEvents_s { diff --git a/src/client/campaign/cp_installation.c b/src/client/campaign/cp_installation.c index fcbae3c..e7e7517 100644 --- a/src/client/campaign/cp_installation.c +++ b/src/client/campaign/cp_installation.c @@ -60,7 +60,7 @@ installation_t* INS_GetInstallationByIDX (int instIdx) if (instIdx < 0 || instIdx >= MAX_INSTALLATIONS) return NULL; - return &ccs.installations[instIdx]; + return &ccs->installations[instIdx]; } /** @@ -87,8 +87,8 @@ const installationTemplate_t* INS_GetInstallationTemplateFromInstallationID (con { int idx; - for (idx = 0; idx < ccs.numInstallationTemplates; idx++) { - const installationTemplate_t *t = &ccs.installationTemplates[idx]; + for (idx = 0; idx < ccs->numInstallationTemplates; idx++) { + const installationTemplate_t *t = &ccs->installationTemplates[idx]; if (Q_streq(t->id, id)) return t; } @@ -114,7 +114,7 @@ void INS_SetUpInstallation (installation_t* installation, const installationTemp installation->founded = qtrue; installation->installationStatus = INSTALLATION_UNDER_CONSTRUCTION; installation->installationTemplate = installationTemplate; - installation->buildStart = ccs.date.day; + installation->buildStart = ccs->date.day; Q_strncpyz(installation->name, name, sizeof(installation->name)); /* a new installation is not discovered (yet) */ @@ -131,9 +131,9 @@ void INS_SetUpInstallation (installation_t* installation, const installationTemp /* Reset Radar */ RADAR_Initialise(&(installation->radar), 0.0f, 0.0f, 0.0f, qfalse); - ccs.numInstallations++; - ccs.campaignStats.installationsBuild++; - ccs.mapAction = MA_NONE; + ccs->numInstallations++; + ccs->campaignStats.installationsBuild++; + ccs->mapAction = MA_NONE; } /** @@ -145,10 +145,10 @@ installation_t *INS_GetFirstUnfoundedInstallation (void) { const int maxInstallations = B_GetInstallationLimit(); - if (ccs.numInstallations >= maxInstallations) + if (ccs->numInstallations >= maxInstallations) return NULL; - return INS_GetInstallationByIDX(ccs.numInstallations); + return INS_GetInstallationByIDX(ccs->numInstallations); } /** @@ -177,13 +177,13 @@ void INS_DestroyInstallation (installation_t *installation) Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("Installation %s was destroyed."), installation->name); MSO_CheckAddNewMessage(NT_INSTALLATION_DESTROY, _("Installation destroyed"), cp_messageBuffer, qfalse, MSG_CONSTRUCTION, NULL); - REMOVE_ELEM_ADJUST_IDX(ccs.installations, installation->idx, ccs.numInstallations); + REMOVE_ELEM_ADJUST_IDX(ccs->installations, installation->idx, ccs->numInstallations); /* Correct UFO store positions */ US_Foreach(ufo) { if (ufo->installation >= installation) ufo->installation--; } - Cvar_Set("mn_installation_count", va("%i", ccs.numInstallations)); + Cvar_Set("mn_installation_count", va("%i", ccs->numInstallations)); } /** @@ -272,7 +272,7 @@ static void INS_InstallationList_f (void) { int i; - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { const installation_t *installation = INS_GetInstallationByIDX(i); if (!installation->founded) { @@ -316,7 +316,7 @@ static void INS_ConstructionFinished_f (void) } } - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { installation_t *ins; if (idx >= 0 && i != idx) @@ -339,7 +339,7 @@ installation_t *INS_GetFirstUFOYard (qboolean free) { int i; - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { installation_t *installation = INS_GetFoundedInstallationByIDX(i); if (!installation) @@ -366,16 +366,17 @@ void INS_InitStartup (void) int idx; Com_DPrintf(DEBUG_CLIENT, "Reset installation\n"); - - for (idx = 0; idx < ccs.numInstallationTemplates; idx++) { - ccs.installationTemplates[idx].id = NULL; - ccs.installationTemplates[idx].name = NULL; - ccs.installationTemplates[idx].cost = 0; - ccs.installationTemplates[idx].radarRange = 0.0f; - ccs.installationTemplates[idx].trackingRange = 0.0f; - ccs.installationTemplates[idx].maxUFOsStored = 0; - ccs.installationTemplates[idx].maxBatteries = 0; +#if 0 + for (idx = 0; idx < ccs->numInstallationTemplates; idx++) { + ccs->installationTemplates[idx].id = NULL; + ccs->installationTemplates[idx].name = NULL; + ccs->installationTemplates[idx].cost = 0; + ccs->installationTemplates[idx].radarRange = 0.0f; + ccs->installationTemplates[idx].trackingRange = 0.0f; + ccs->installationTemplates[idx].maxUFOsStored = 0; + ccs->installationTemplates[idx].maxBatteries = 0; } +#endif /* add commands and cvars */ #ifdef DEBUG @@ -399,7 +400,7 @@ void INS_UpdateInstallationData (void) if (installation->installationStatus == INSTALLATION_UNDER_CONSTRUCTION && installation->buildStart - && installation->buildStart + installation->installationTemplate->buildTime <= ccs.date.day) { + && installation->buildStart + installation->installationTemplate->buildTime <= ccs->date.day) { INS_FinishInstallation(installation); @@ -450,27 +451,27 @@ void INS_ParseInstallations (const char *name, const char **text) return; } - if (ccs.numInstallationTemplates >= MAX_INSTALLATION_TEMPLATES) { + if (ccs->numInstallationTemplates >= MAX_INSTALLATION_TEMPLATES) { Com_Printf("INS_ParseInstallations: too many installation templates\n"); - ccs.numInstallationTemplates = MAX_INSTALLATION_TEMPLATES; /* just in case it's bigger. */ + ccs->numInstallationTemplates = MAX_INSTALLATION_TEMPLATES; /* just in case it's bigger. */ return; } - for (i = 0; i < ccs.numInstallationTemplates; i++) { - if (Q_streq(ccs.installationTemplates[i].name, name)) { + for (i = 0; i < ccs->numInstallationTemplates; i++) { + if (Q_streq(ccs->installationTemplates[i].name, name)) { Com_Printf("INS_ParseInstallations: Second installation with same name found (%s) - second ignored\n", name); return; } } /* new entry */ - installation = &ccs.installationTemplates[ccs.numInstallationTemplates]; + installation = &ccs->installationTemplates[ccs->numInstallationTemplates]; OBJZERO(*installation); installation->id = Mem_PoolStrDup(name, cp_campaignPool, 0); Com_DPrintf(DEBUG_CLIENT, "...found installation %s\n", installation->id); - ccs.numInstallationTemplates++; + ccs->numInstallationTemplates++; do { /* get the name type */ token = Com_EParse(text, errhead, name); @@ -544,7 +545,7 @@ qboolean INS_SaveXML (mxml_node_t *p) n = mxml_AddNode(p, SAVE_INSTALLATION_INSTALLATIONS); Com_RegisterConstList(saveInstallationConstants); - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { const installation_t *inst = INS_GetInstallationByIDX(i); mxml_node_t *s, *ss; @@ -642,10 +643,10 @@ qboolean INS_LoadXML (mxml_node_t *p) } B_LoadBaseSlotsXML(inst->batteries, inst->numBatteries, ss); - ccs.numInstallations++; + ccs->numInstallations++; } Com_UnregisterConstList(saveInstallationConstants); - Cvar_Set("mn_installation_count", va("%i", ccs.numInstallations)); + Cvar_Set("mn_installation_count", va("%i", ccs->numInstallations)); return success; } diff --git a/src/client/campaign/cp_installation.h b/src/client/campaign/cp_installation.h index b5e8b73..b3c0f9a 100644 --- a/src/client/campaign/cp_installation.h +++ b/src/client/campaign/cp_installation.h @@ -33,8 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAX_INSTALLATION_DAMAGE 100 #define MAX_INSTALLATION_BATTERIES 5 -#define INS_GetInstallationIDX(installation) ((ptrdiff_t)((installation) - ccs.installations)) -#define INS_GetFoundedInstallationCount() (ccs.numInstallations) +#define INS_GetInstallationIDX(installation) ((ptrdiff_t)((installation) - ccs->installations)) +#define INS_GetFoundedInstallationCount() (ccs->numInstallations) /** * @brief Possible installation states diff --git a/src/client/campaign/cp_installation_callbacks.c b/src/client/campaign/cp_installation_callbacks.c index 2c9bacb..baaa3e8 100644 --- a/src/client/campaign/cp_installation_callbacks.c +++ b/src/client/campaign/cp_installation_callbacks.c @@ -45,8 +45,8 @@ static void INS_SetInstallationTitle (void) do { j = 0; Com_sprintf(insName, lengthof(insName), "%s #%i", (insTemp) ? _(insTemp->name) : _("Installation"), i); - while (j <= ccs.numInstallations && !Q_streq(insName, ccs.installations[j++].name)); - } while (i++ <= ccs.numInstallations && j <= ccs.numInstallations); + while (j <= ccs->numInstallations && !Q_streq(insName, ccs->installations[j++].name)); + } while (i++ <= ccs->numInstallations && j <= ccs->numInstallations); Cvar_Set("mn_installation_title", insName); if (!insTemp || !insTemp->description || !strlen(insTemp->description)) @@ -67,11 +67,11 @@ void INS_SelectInstallation (installation_t *installation) if (!installation) { /* if player hit the "create base" button while creating base mode is enabled * that means that player wants to quit this mode */ - if (ccs.mapAction == MA_NEWINSTALLATION || ccs.numInstallations >= B_GetInstallationLimit()) { + if (ccs->mapAction == MA_NEWINSTALLATION || ccs->numInstallations >= B_GetInstallationLimit()) { MAP_ResetAction(); return; } else { - ccs.mapAction = MA_NEWINSTALLATION; + ccs->mapAction = MA_NEWINSTALLATION; /* show radar overlay (if not already displayed) */ if (!MAP_IsRadarOverlayActivated()) @@ -80,10 +80,10 @@ void INS_SelectInstallation (installation_t *installation) INS_SetInstallationTitle(); } } else { - const int timetobuild = max(0, installation->installationTemplate->buildTime - (ccs.date.day - installation->buildStart)); + const int timetobuild = max(0, installation->installationTemplate->buildTime - (ccs->date.day - installation->buildStart)); Com_DPrintf(DEBUG_CLIENT, "INS_SelectInstallation: select installation with id %i\n", installation->idx); - ccs.mapAction = MA_NONE; + ccs->mapAction = MA_NONE; if (installation->installationStatus == INSTALLATION_WORKING) { Cvar_Set("mn_installation_timetobuild", "-"); } else { @@ -110,7 +110,7 @@ static void INS_BuildInstallation_f (void) } /* We shouldn't build more installations than the actual limit */ - if (B_GetInstallationLimit() <= ccs.numInstallations) + if (B_GetInstallationLimit() <= ccs->numInstallations) return; installationTemplate = INS_GetInstallationTemplateFromInstallationID(Cmd_Argv(1)); @@ -126,13 +126,13 @@ static void INS_BuildInstallation_f (void) assert(!installation->founded); assert(installationTemplate->cost >= 0); - if (ccs.credits - installationTemplate->cost > 0) { + if (ccs->credits - installationTemplate->cost > 0) { /* set up the installation */ - INS_SetUpInstallation(installation, installationTemplate, ccs.newBasePos, Cvar_GetString("mn_installation_title")); + INS_SetUpInstallation(installation, installationTemplate, ccs->newBasePos, Cvar_GetString("mn_installation_title")); - CL_UpdateCredits(ccs.credits - installationTemplate->cost); + CL_UpdateCredits(ccs->credits - installationTemplate->cost); /* this cvar is used for disabling the installation build button on geoscape if MAX_INSTALLATIONS was reached */ - Cvar_SetValue("mn_installation_count", ccs.numInstallations); + Cvar_SetValue("mn_installation_count", ccs->numInstallations); nation = MAP_GetNation(installation->pos); if (nation) @@ -143,8 +143,8 @@ static void INS_BuildInstallation_f (void) } else { if (MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); - if (ccs.mapAction == MA_NEWINSTALLATION) - ccs.mapAction = MA_NONE; + if (ccs->mapAction == MA_NEWINSTALLATION) + ccs->mapAction = MA_NONE; UI_Popup(_("Notice"), _("Not enough credits to set up a new installation.")); } @@ -165,7 +165,7 @@ static void INS_SelectInstallation_f (void) } installationID = atoi(Cmd_Argv(1)); - if (installationID >= 0 && installationID < ccs.numInstallations) + if (installationID >= 0 && installationID < ccs->numInstallations) installation = INS_GetFoundedInstallationByIDX(installationID); else /* create a new installation */ @@ -237,7 +237,7 @@ void INS_InitCallbacks (void) Cmd_AddCommand("mn_installation_destroy", INS_DestroyInstallation_f, "Destroys an installation"); Cmd_AddCommand("mn_installation_update_max_count", INS_UpdateInstallationLimit_f, "Updates the installation count limit"); - Cvar_SetValue("mn_installation_count", ccs.numInstallations); + Cvar_SetValue("mn_installation_count", ccs->numInstallations); Cvar_Set("mn_installation_title", ""); Cvar_Set("mn_installation_type", ""); Cvar_Set("mn_installation_max", ""); diff --git a/src/client/campaign/cp_map.c b/src/client/campaign/cp_map.c index 4eb505e..3f3f613 100644 --- a/src/client/campaign/cp_map.c +++ b/src/client/campaign/cp_map.c @@ -204,7 +204,7 @@ static void MAP_MultiSelectExecuteAction_f (void) B_SelectBase(B_GetFoundedBaseByIDX(id)); break; case MULTISELECT_TYPE_INSTALLATION: /* Select a installation */ - if (id >= ccs.numInstallations) + if (id >= ccs->numInstallations) break; MAP_ResetAction(); INS_SelectInstallation(INS_GetFoundedInstallationByIDX(id)); @@ -212,7 +212,7 @@ static void MAP_MultiSelectExecuteAction_f (void) case MULTISELECT_TYPE_MISSION: { mission_t *mission = MAP_GetSelectedMission(); /* Select a mission */ - if (ccs.mapAction == MA_INTERCEPT && mission && mission == MAP_GetMissionByIDX(id)) { + if (ccs->mapAction == MA_INTERCEPT && mission && mission == MAP_GetMissionByIDX(id)) { CL_DisplayPopupInterceptMission(mission); return; } @@ -244,7 +244,7 @@ static void MAP_MultiSelectExecuteAction_f (void) break; case MULTISELECT_TYPE_UFO : /* Selection of a UFO */ /* Get the ufo selected */ - if (id < 0 || id >= ccs.numUFOs) + if (id < 0 || id >= ccs->numUFOs) return; aircraft = UFO_GetByIDX(id); @@ -288,13 +288,13 @@ void MAP_MapClick (uiNode_t* node, int x, int y) else MAP_ScreenToMap(node, x, y, pos); - switch (ccs.mapAction) { + switch (ccs->mapAction) { case MA_NEWBASE: /* new base construction */ /** @todo make this a function in cp_base.c - B_BuildBaseAtPos */ if (!MapIsWater(MAP_GetColor(pos, MAPTYPE_TERRAIN))) { if (B_GetCount() < MAX_BASES) { - Vector2Copy(pos, ccs.newBasePos); + Vector2Copy(pos, ccs->newBasePos); CL_GameTimeStop(); Cmd_ExecuteString("mn_set_base_title"); UI_PushWindow("popup_newbase", NULL, NULL); @@ -304,8 +304,8 @@ void MAP_MapClick (uiNode_t* node, int x, int y) break; case MA_NEWINSTALLATION: if (!MapIsWater(MAP_GetColor(pos, MAPTYPE_TERRAIN))) { - if (ccs.numInstallations < MAX_INSTALLATIONS) { - Vector2Copy(pos, ccs.newBasePos); + if (ccs->numInstallations < MAX_INSTALLATIONS) { + Vector2Copy(pos, ccs->newBasePos); CL_GameTimeStop(); UI_PushWindow("popup_newinstallation", NULL, NULL); } @@ -417,7 +417,7 @@ static qboolean MAP_IsMapPositionSelected (const uiNode_t* node, const vec2_t po const float STANDARD_3D_ZOOM = 40.0f; /** @brief radius of the globe in screen coordinates */ -#define GLOBE_RADIUS EARTH_RADIUS * (ccs.zoom / STANDARD_3D_ZOOM) +#define GLOBE_RADIUS EARTH_RADIUS * (ccs->zoom / STANDARD_3D_ZOOM) /** * @brief Transform a 2D position on the map to screen coordinates. @@ -442,13 +442,13 @@ static qboolean MAP_3DMapToScreen (const uiNode_t* node, const vec2_t pos, int * /* rotate the vector to switch of reference frame. * We switch from the static frame of earth to the local frame of the player (opposite rotation of MAP3D_ScreenToMap) */ VectorSet(rotationAxis, 0, 0, 1); - RotatePointAroundVector(v1, rotationAxis, v, - ccs.angles[PITCH]); + RotatePointAroundVector(v1, rotationAxis, v, - ccs->angles[PITCH]); VectorSet(rotationAxis, 0, 1, 0); - RotatePointAroundVector(v, rotationAxis, v1, - ccs.angles[YAW]); + RotatePointAroundVector(v, rotationAxis, v1, - ccs->angles[YAW]); /* set mid to the coordinates of the center of the globe */ - Vector2Set(mid, ccs.mapPos[0] + ccs.mapSize[0] / 2.0f, ccs.mapPos[1] + ccs.mapSize[1] / 2.0f); + Vector2Set(mid, ccs->mapPos[0] + ccs->mapSize[0] / 2.0f, ccs->mapPos[1] + ccs->mapSize[1] / 2.0f); /* We now convert those coordinates relative to the center of the globe to coordinates of the screen * (which are relative to the upper left side of the screen) */ @@ -463,7 +463,7 @@ static qboolean MAP_3DMapToScreen (const uiNode_t* node, const vec2_t pos, int * return qfalse; /* if the point is outside the screen, the player cannot see it */ - if (*x < ccs.mapPos[0] && *y < ccs.mapPos[1] && *x > ccs.mapPos[0] + ccs.mapSize[0] && *y > ccs.mapPos[1] + ccs.mapSize[1]) + if (*x < ccs->mapPos[0] && *y < ccs->mapPos[1] && *x > ccs->mapPos[0] + ccs->mapSize[0] && *y > ccs->mapPos[1] + ccs->mapSize[1]) return qfalse; return qtrue; @@ -484,7 +484,7 @@ qboolean MAP_MapToScreen (const uiNode_t* node, const vec2_t pos, int *x, int *y float sx; /* get "raw" position */ - sx = pos[0] / 360 + ccs.center[0] - 0.5; + sx = pos[0] / 360 + ccs->center[0] - 0.5; /* shift it on screen */ if (sx < -0.5) @@ -492,12 +492,12 @@ qboolean MAP_MapToScreen (const uiNode_t* node, const vec2_t pos, int *x, int *y else if (sx > +0.5) sx -= 1.0; - *x = ccs.mapPos[0] + 0.5 * ccs.mapSize[0] - sx * ccs.mapSize[0] * ccs.zoom; - *y = ccs.mapPos[1] + 0.5 * ccs.mapSize[1] - - (pos[1] / 180 + ccs.center[1] - 0.5) * ccs.mapSize[1] * ccs.zoom; + *x = ccs->mapPos[0] + 0.5 * ccs->mapSize[0] - sx * ccs->mapSize[0] * ccs->zoom; + *y = ccs->mapPos[1] + 0.5 * ccs->mapSize[1] - + (pos[1] / 180 + ccs->center[1] - 0.5) * ccs->mapSize[1] * ccs->zoom; - if (*x < ccs.mapPos[0] && *y < ccs.mapPos[1] && - *x > ccs.mapPos[0] + ccs.mapSize[0] && *y > ccs.mapPos[1] + ccs.mapSize[1]) + if (*x < ccs->mapPos[0] && *y < ccs->mapPos[1] && + *x > ccs->mapPos[0] + ccs->mapSize[0] && *y > ccs->mapPos[1] + ccs->mapSize[1]) return qfalse; return qtrue; } @@ -535,7 +535,7 @@ qboolean MAP_AllMapToScreen (const uiNode_t* node, const vec2_t pos, int *x, int void MAP_Draw3DMarkerIfVisible (const uiNode_t* node, const vec2_t pos, float theta, const char *model, int skin) { if (cl_3dmap->integer) { - R_Draw3DMapMarkers(ccs.mapPos[0], ccs.mapPos[1], ccs.mapSize[0], ccs.mapSize[1], ccs.angles, pos, theta, GLOBE_RADIUS, model, skin); + R_Draw3DMapMarkers(ccs->mapPos[0], ccs->mapPos[1], ccs->mapSize[0], ccs->mapSize[1], ccs->angles, pos, theta, GLOBE_RADIUS, model, skin); } else { int x, y; vec3_t screenPos; @@ -557,8 +557,8 @@ void MAP_Draw3DMarkerIfVisible (const uiNode_t* node, const vec2_t pos, float th */ static void MAP_ScreenToMap (const uiNode_t* node, int x, int y, vec2_t pos) { - pos[0] = (((ccs.mapPos[0] - x) / ccs.mapSize[0] + 0.5) / ccs.zoom - (ccs.center[0] - 0.5)) * 360.0; - pos[1] = (((ccs.mapPos[1] - y) / ccs.mapSize[1] + 0.5) / ccs.zoom - (ccs.center[1] - 0.5)) * 180.0; + pos[0] = (((ccs->mapPos[0] - x) / ccs->mapSize[0] + 0.5) / ccs->zoom - (ccs->center[0] - 0.5)) * 360.0; + pos[1] = (((ccs->mapPos[1] - y) / ccs->mapSize[1] + 0.5) / ccs->zoom - (ccs->center[1] - 0.5)) * 180.0; while (pos[0] > 180.0) pos[0] -= 360.0; @@ -582,7 +582,7 @@ static void MAP3D_ScreenToMap (const uiNode_t* node, int x, int y, vec2_t pos) const float radius = GLOBE_RADIUS; /* set mid to the coordinates of the center of the globe */ - Vector2Set(mid, ccs.mapPos[0] + ccs.mapSize[0] / 2.0f, ccs.mapPos[1] + ccs.mapSize[1] / 2.0f); + Vector2Set(mid, ccs->mapPos[0] + ccs->mapSize[0] / 2.0f, ccs->mapPos[1] + ccs->mapSize[1] / 2.0f); /* stop if we click outside the globe (distance is the distance of the point to the center of the globe) */ dist = sqrt((x - mid[0]) * (x - mid[0]) + (y - mid[1]) * (y - mid[1])); @@ -603,17 +603,17 @@ static void MAP3D_ScreenToMap (const uiNode_t* node, int x, int y, vec2_t pos) VectorNormalize(v); /* rotate the vector to switch of reference frame - * note the ccs.angles[ROLL] is always 0, so there is only 2 rotations and not 3 - * and that GLOBE_ROTATE is already included in ccs.angles[YAW] + * note the ccs->angles[ROLL] is always 0, so there is only 2 rotations and not 3 + * and that GLOBE_ROTATE is already included in ccs->angles[YAW] * first rotation is along the horizontal axis of the screen, to put north-south axis of the earth * perpendicular to the screen */ VectorSet(rotationAxis, 0, 1, 0); - RotatePointAroundVector(v1, rotationAxis, v, ccs.angles[YAW]); + RotatePointAroundVector(v1, rotationAxis, v, ccs->angles[YAW]); /* second rotation is to rotate the earth around its north-south axis * so that Greenwich meridian is along the vertical axis of the screen */ VectorSet(rotationAxis, 0, 0, 1); - RotatePointAroundVector(v, rotationAxis, v1, ccs.angles[PITCH]); + RotatePointAroundVector(v, rotationAxis, v1, ccs->angles[PITCH]); /* we therefore got in v the coordinates of the point in the static frame of the earth * that we can convert in polar coordinates to get its latitude and longitude */ @@ -723,19 +723,19 @@ static void MAP_MapDrawLine (const uiNode_t* node, const mapline_t* line) /* draw */ R_Color(color); start = 0; - old = ccs.mapSize[0] / 2; + old = ccs->mapSize[0] / 2; for (i = 0, p = pts; i < line->numPoints; i++, p++) { MAP_MapToScreen(node, line->point[i], &p->x, &p->y); /* If we cross longitude 180 degree (right/left edge of the screen), draw the first part of the path */ - if (i > start && abs(p->x - old) > ccs.mapSize[0] / 2) { + if (i > start && abs(p->x - old) > ccs->mapSize[0] / 2) { /* shift last point */ int diff; - if (p->x - old > ccs.mapSize[0] / 2) - diff = -ccs.mapSize[0] * ccs.zoom; + if (p->x - old > ccs->mapSize[0] / 2) + diff = -ccs->mapSize[0] * ccs->zoom; else - diff = ccs.mapSize[0] * ccs.zoom; + diff = ccs->mapSize[0] * ccs->zoom; p->x += diff; /* wrap around screen border */ @@ -1042,26 +1042,26 @@ static void MAP_StartCenter (void) /* case 3D geoscape */ vec3_t diff; - ccs.smoothFinalGlobeAngle[1] += GLOBE_ROTATE; - VectorSubtract(ccs.smoothFinalGlobeAngle, ccs.angles, diff); - ccs.smoothDeltaLength = VectorLength(diff); + ccs->smoothFinalGlobeAngle[1] += GLOBE_ROTATE; + VectorSubtract(ccs->smoothFinalGlobeAngle, ccs->angles, diff); + ccs->smoothDeltaLength = VectorLength(diff); } else { /* case 2D geoscape */ vec2_t diff; - Vector2Set(ccs.smoothFinal2DGeoscapeCenter, 0.5f - ccs.smoothFinal2DGeoscapeCenter[0] / 360.0f, 0.5f - ccs.smoothFinal2DGeoscapeCenter[1] / 180.0f); - if (ccs.smoothFinal2DGeoscapeCenter[1] < 0.5 / ZOOM_LIMIT) - ccs.smoothFinal2DGeoscapeCenter[1] = 0.5 / ZOOM_LIMIT; - if (ccs.smoothFinal2DGeoscapeCenter[1] > 1.0 - 0.5 / ZOOM_LIMIT) - ccs.smoothFinal2DGeoscapeCenter[1] = 1.0 - 0.5 / ZOOM_LIMIT; - diff[0] = ccs.smoothFinal2DGeoscapeCenter[0] - ccs.center[0]; - diff[1] = ccs.smoothFinal2DGeoscapeCenter[1] - ccs.center[1]; - ccs.smoothDeltaLength = sqrt(diff[0] * diff[0] + diff[1] * diff[1]); + Vector2Set(ccs->smoothFinal2DGeoscapeCenter, 0.5f - ccs->smoothFinal2DGeoscapeCenter[0] / 360.0f, 0.5f - ccs->smoothFinal2DGeoscapeCenter[1] / 180.0f); + if (ccs->smoothFinal2DGeoscapeCenter[1] < 0.5 / ZOOM_LIMIT) + ccs->smoothFinal2DGeoscapeCenter[1] = 0.5 / ZOOM_LIMIT; + if (ccs->smoothFinal2DGeoscapeCenter[1] > 1.0 - 0.5 / ZOOM_LIMIT) + ccs->smoothFinal2DGeoscapeCenter[1] = 1.0 - 0.5 / ZOOM_LIMIT; + diff[0] = ccs->smoothFinal2DGeoscapeCenter[0] - ccs->center[0]; + diff[1] = ccs->smoothFinal2DGeoscapeCenter[1] - ccs->center[1]; + ccs->smoothDeltaLength = sqrt(diff[0] * diff[0] + diff[1] * diff[1]); } - ccs.smoothFinalZoom = ZOOM_LIMIT; - ccs.smoothDeltaZoom = fabs(ccs.smoothFinalZoom - ccs.zoom); - ccs.smoothRotation = qtrue; + ccs->smoothFinalZoom = ZOOM_LIMIT; + ccs->smoothDeltaZoom = fabs(ccs->smoothFinalZoom - ccs->zoom); + ccs->smoothRotation = qtrue; } /** @@ -1082,18 +1082,18 @@ static void MAP_SelectObject_f (void) if (cl_3dmap->integer) { if (Q_streq(type, "mission")) - MAP_GetMissionAngle(ccs.smoothFinalGlobeAngle, idx); + MAP_GetMissionAngle(ccs->smoothFinalGlobeAngle, idx); else if (Q_streq(type, "ufo")) - MAP_GetUFOAngle(ccs.smoothFinalGlobeAngle, idx); + MAP_GetUFOAngle(ccs->smoothFinalGlobeAngle, idx); else { Com_Printf("MAP_SelectObject_f: type %s unsupported.", type); return; } } else { if (Q_streq(type, "mission")) - MAP_GetMissionAngle(ccs.smoothFinal2DGeoscapeCenter, idx); + MAP_GetMissionAngle(ccs->smoothFinal2DGeoscapeCenter, idx); else if (Q_streq(type, "ufo")) - MAP_GetUFOAngle(ccs.smoothFinal2DGeoscapeCenter, idx); + MAP_GetUFOAngle(ccs->smoothFinal2DGeoscapeCenter, idx); else { Com_Printf("MAP_SelectObject_f: type %s unsupported.", type); return; @@ -1119,7 +1119,7 @@ static void MAP_GetGeoscapeAngle (float *vector) int numBases = B_GetCount(); /* If the value of maxEventIdx is too big or to low, restart from begining */ - maxEventIdx = numMissions + numBases + ccs.numInstallations - 1; + maxEventIdx = numMissions + numBases + ccs->numInstallations - 1; base = NULL; while ((base = B_GetNext(base)) != NULL) { aircraft_t *aircraft; @@ -1175,7 +1175,7 @@ static void MAP_GetGeoscapeAngle (float *vector) counter += numBases; /* Cycle through installations */ - if (centerOnEventIdx < ccs.numInstallations + counter) { + if (centerOnEventIdx < ccs->numInstallations + counter) { int instIdx; for (instIdx = 0; instIdx < MAX_INSTALLATIONS; instIdx++) { const installation_t *inst = INS_GetFoundedInstallationByIDX(instIdx); @@ -1189,7 +1189,7 @@ static void MAP_GetGeoscapeAngle (float *vector) counter++; } } - counter += ccs.numInstallations; + counter += ccs->numInstallations; /* Cycle through aircraft (only those present on geoscape) */ AIR_Foreach(aircraft) { @@ -1219,7 +1219,7 @@ static void MAP_GetGeoscapeAngle (float *vector) * @brief Switch to next model on 2D and 3D geoscape. * @note Set @c smoothRotation to @c qtrue to allow a smooth rotation in MAP_DrawMap. * @note This function sets the value of smoothFinalGlobeAngle (for 3D) or smoothFinal2DGeoscapeCenter (for 2D), - * which contains the final value that ccs.angles or ccs.centre must respectively take. + * which contains the final value that ccs->angles or ccs->centre must respectively take. * @sa MAP_GetGeoscapeAngle * @sa MAP_DrawMap * @sa MAP3D_SmoothRotate @@ -1233,26 +1233,26 @@ void MAP_CenterOnPoint_f (void) centerOnEventIdx++; if (cl_3dmap->integer) - MAP_GetGeoscapeAngle(ccs.smoothFinalGlobeAngle); + MAP_GetGeoscapeAngle(ccs->smoothFinalGlobeAngle); else - MAP_GetGeoscapeAngle(ccs.smoothFinal2DGeoscapeCenter); + MAP_GetGeoscapeAngle(ccs->smoothFinal2DGeoscapeCenter); MAP_StartCenter(); } /** * @brief smooth rotation of the 3D geoscape - * @note updates slowly values of ccs.angles and ccs.zoom so that its value goes to smoothFinalGlobeAngle + * @note updates slowly values of ccs->angles and ccs->zoom so that its value goes to smoothFinalGlobeAngle * @sa MAP_DrawMap * @sa MAP_CenterOnPoint */ static void MAP3D_SmoothRotate (void) { vec3_t diff; - const float diffZoom = ccs.smoothFinalZoom - ccs.zoom; + const float diffZoom = ccs->smoothFinalZoom - ccs->zoom; - VectorSubtract(ccs.smoothFinalGlobeAngle, ccs.angles, diff); + VectorSubtract(ccs->smoothFinalGlobeAngle, ccs->angles, diff); - if (ccs.smoothDeltaLength > ccs.smoothDeltaZoom) { + if (ccs->smoothDeltaLength > ccs->smoothDeltaZoom) { /* when we rotate (and zoom) */ const float diffAngle = VectorLength(diff); const float epsilon = 0.1f; @@ -1260,14 +1260,14 @@ static void MAP3D_SmoothRotate (void) float rotationSpeed; /* Append the old speed to the new speed if this is the first half of a new rotation, but never exceed the max speed. * This allows the globe to rotate at maximum speed when the button is held down. */ - if (diffAngle / ccs.smoothDeltaLength > 0.5) - rotationSpeed = min(diffAngle, ccs.curRotationSpeed + sin(3.05f * diffAngle / ccs.smoothDeltaLength) * diffAngle * 0.5); + if (diffAngle / ccs->smoothDeltaLength > 0.5) + rotationSpeed = min(diffAngle, ccs->curRotationSpeed + sin(3.05f * diffAngle / ccs->smoothDeltaLength) * diffAngle * 0.5); else - rotationSpeed = sin(3.05f * diffAngle / ccs.smoothDeltaLength) * diffAngle; - ccs.curRotationSpeed = rotationSpeed; + rotationSpeed = sin(3.05f * diffAngle / ccs->smoothDeltaLength) * diffAngle; + ccs->curRotationSpeed = rotationSpeed; VectorScale(diff, smoothAcceleration / diffAngle * rotationSpeed, diff); - VectorAdd(ccs.angles, diff, ccs.angles); - ccs.zoom = ccs.zoom + smoothAcceleration * diffZoom / diffAngle * rotationSpeed; + VectorAdd(ccs->angles, diff, ccs->angles); + ccs->zoom = ccs->zoom + smoothAcceleration * diffZoom / diffAngle * rotationSpeed; return; } } else { @@ -1277,21 +1277,21 @@ static void MAP3D_SmoothRotate (void) float speed; /* Append the old speed to the new speed if this is the first half of a new zoom operation, but never exceed the max speed. * This allows the globe to zoom at maximum speed when the button is held down. */ - if (fabs(diffZoom) / ccs.smoothDeltaZoom > 0.5) - speed = min(smoothAcceleration * 2.0, ccs.curZoomSpeed + sin(3.05f * (fabs(diffZoom) / ccs.smoothDeltaZoom)) * smoothAcceleration); + if (fabs(diffZoom) / ccs->smoothDeltaZoom > 0.5) + speed = min(smoothAcceleration * 2.0, ccs->curZoomSpeed + sin(3.05f * (fabs(diffZoom) / ccs->smoothDeltaZoom)) * smoothAcceleration); else { - speed = sin(3.05f * (fabs(diffZoom) / ccs.smoothDeltaZoom)) * smoothAcceleration * 2.0; + speed = sin(3.05f * (fabs(diffZoom) / ccs->smoothDeltaZoom)) * smoothAcceleration * 2.0; } - ccs.curZoomSpeed = speed; - ccs.zoom = ccs.zoom + diffZoom * speed; + ccs->curZoomSpeed = speed; + ccs->zoom = ccs->zoom + diffZoom * speed; return; } } /* if we reach this point, that means that movement is over */ - VectorCopy(ccs.smoothFinalGlobeAngle, ccs.angles); - ccs.smoothRotation = qfalse; - ccs.zoom = ccs.smoothFinalZoom; + VectorCopy(ccs->smoothFinalGlobeAngle, ccs->angles); + ccs->smoothRotation = qfalse; + ccs->zoom = ccs->smoothFinalZoom; } /** @@ -1301,33 +1301,33 @@ static void MAP3D_SmoothRotate (void) */ void MAP_StopSmoothMovement (void) { - ccs.smoothRotation = qfalse; + ccs->smoothRotation = qfalse; } #define SMOOTHING_STEP_2D 0.02f /** * @brief smooth translation of the 2D geoscape - * @note updates slowly values of ccs.center so that its value goes to smoothFinal2DGeoscapeCenter - * @note updates slowly values of ccs.zoom so that its value goes to ZOOM_LIMIT + * @note updates slowly values of ccs->center so that its value goes to smoothFinal2DGeoscapeCenter + * @note updates slowly values of ccs->zoom so that its value goes to ZOOM_LIMIT * @sa MAP_DrawMap * @sa MAP_CenterOnPoint */ static void MAP_SmoothTranslate (void) { - const float dist1 = ccs.smoothFinal2DGeoscapeCenter[0] - ccs.center[0]; - const float dist2 = ccs.smoothFinal2DGeoscapeCenter[1] - ccs.center[1]; + const float dist1 = ccs->smoothFinal2DGeoscapeCenter[0] - ccs->center[0]; + const float dist2 = ccs->smoothFinal2DGeoscapeCenter[1] - ccs->center[1]; const float length = sqrt(dist1 * dist1 + dist2 * dist2); if (length < SMOOTHING_STEP_2D) { - ccs.center[0] = ccs.smoothFinal2DGeoscapeCenter[0]; - ccs.center[1] = ccs.smoothFinal2DGeoscapeCenter[1]; - ccs.zoom = ccs.smoothFinalZoom; - ccs.smoothRotation = qfalse; + ccs->center[0] = ccs->smoothFinal2DGeoscapeCenter[0]; + ccs->center[1] = ccs->smoothFinal2DGeoscapeCenter[1]; + ccs->zoom = ccs->smoothFinalZoom; + ccs->smoothRotation = qfalse; } else { - const float diffZoom = ccs.smoothFinalZoom - ccs.zoom; - ccs.center[0] = ccs.center[0] + SMOOTHING_STEP_2D * dist1 / length; - ccs.center[1] = ccs.center[1] + SMOOTHING_STEP_2D * dist2 / length; - ccs.zoom = ccs.zoom + SMOOTHING_STEP_2D * diffZoom; + const float diffZoom = ccs->smoothFinalZoom - ccs->zoom; + ccs->center[0] = ccs->center[0] + SMOOTHING_STEP_2D * dist1 / length; + ccs->center[1] = ccs->center[1] + SMOOTHING_STEP_2D * dist2 / length; + ccs->zoom = ccs->zoom + SMOOTHING_STEP_2D * diffZoom; } } @@ -1368,7 +1368,7 @@ static void MAP_DrawBeam (const uiNode_t* node, const vec3_t start, const vec3_t R_Color(NULL); } -#define SELECT_CIRCLE_RADIUS 1.5f + 3.0f / ccs.zoom +#define SELECT_CIRCLE_RADIUS 1.5f + 3.0f / ccs->zoom /** * @brief Draws one mission on the geoscape map (2D and 3D) @@ -1522,8 +1522,8 @@ static void MAP_DrawMapOneBase (const uiNode_t* node, const base_t *base, */ static void MAP_DrawAircraftHealthBar (const uiNode_t* node, const aircraft_t *aircraft) { const vec4_t bordercolor = {1, 1, 1, 1}; - const int width = 8 * ccs.zoom; - const int height = 1 * ccs.zoom * 0.9; + const int width = 8 * ccs->zoom; + const int height = 1 * ccs->zoom * 0.9; vec4_t color; int centerX; int centerY; @@ -1548,8 +1548,8 @@ static void MAP_DrawAircraftHealthBar (const uiNode_t* node, const aircraft_t *a visible = MAP_AllMapToScreen(node, aircraft->pos, ¢erX, ¢erY, NULL); if (visible) { - R_DrawFill(centerX - width / 2 , centerY - 5 * ccs.zoom, round(width * ((float)aircraft->damage / aircraft->stats[AIR_STATS_DAMAGE])), height, color); - R_DrawRect(centerX - width / 2, centerY - 5 * ccs.zoom, width, height, bordercolor, 1.0, 1); + R_DrawFill(centerX - width / 2 , centerY - 5 * ccs->zoom, round(width * ((float)aircraft->damage / aircraft->stats[AIR_STATS_DAMAGE])), height, color); + R_DrawRect(centerX - width / 2, centerY - 5 * ccs->zoom, width, height, bordercolor, 1.0, 1); } } @@ -1834,14 +1834,14 @@ static void MAP_DrawMapMarkers (const uiNode_t* node) } } - if (ccs.gameTimeScale > 0) - maxInterpolationPoints = floor(1.0f / (cls.frametime * (float)ccs.gameTimeScale)); + if (ccs->gameTimeScale > 0) + maxInterpolationPoints = floor(1.0f / (cls.frametime * (float)ccs->gameTimeScale)); else maxInterpolationPoints = 0; /* draws projectiles */ - for (idx = 0; idx < ccs.numProjectiles; idx++) { - aircraftProjectile_t *projectile = &ccs.projectiles[idx]; + for (idx = 0; idx < ccs->numProjectiles; idx++) { + aircraftProjectile_t *projectile = &ccs->projectiles[idx]; vec3_t drawPos = {0, 0, 0}; if (projectile->hasMoved) { @@ -1887,7 +1887,7 @@ static void MAP_DrawMapMarkers (const uiNode_t* node) showXVI = CP_IsXVIResearched(); /* Draw nation names */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); if (MAP_AllMapToScreen(node, nation->pos, &x, &y, NULL)) UI_DrawString("f_verysmall", ALIGN_UC, x , y, 0, 0, 0, _(nation->name), 0, 0, NULL, qfalse, 0); @@ -1917,11 +1917,11 @@ void MAP_DrawMap (const uiNode_t* node, campaign_t *campaign) /* store these values in ccs struct to be able to handle this even in the input code */ UI_GetNodeAbsPos(node, pos); - Vector2Copy(pos, ccs.mapPos); - Vector2Copy(node->size, ccs.mapSize); + Vector2Copy(pos, ccs->mapPos); + Vector2Copy(node->size, ccs->mapSize); if (cl_3dmap->integer) { /* remove the left padding */ - ccs.mapSize[0] -= UI_MAPEXTRADATACONST(node).paddingRight; + ccs->mapSize[0] -= UI_MAPEXTRADATACONST(node).paddingRight; } /* Draw the map and markers */ @@ -1930,18 +1930,18 @@ void MAP_DrawMap (const uiNode_t* node, campaign_t *campaign) /** @todo I think this check is wrong; isn't zoom clamped to this value already? * A value of 3.3 seems about right for me, but this should probably be fixed...*/ #if 0 - if (ccs.zoom > cl_mapzoommax->value) + if (ccs->zoom > cl_mapzoommax->value) #else - if (ccs.zoom > 3.3) + if (ccs->zoom > 3.3) #endif disableSolarRender = qtrue; R_EnableRenderbuffer(qtrue); - if (ccs.smoothRotation) + if (ccs->smoothRotation) MAP3D_SmoothRotate(); - R_Draw3DGlobe(ccs.mapPos[0], ccs.mapPos[1], ccs.mapSize[0], ccs.mapSize[1], - ccs.date.day, ccs.date.sec, ccs.angles, ccs.zoom, campaign->map, disableSolarRender, + R_Draw3DGlobe(ccs->mapPos[0], ccs->mapPos[1], ccs->mapSize[0], ccs->mapSize[1], + ccs->date.day, ccs->date.sec, ccs->angles, ccs->zoom, campaign->map, disableSolarRender, cl_3dmapAmbient->value, MAP_IsNationOverlayActivated(), MAP_IsXVIOverlayActivated(), MAP_IsRadarOverlayActivated(), r_xviTexture, r_radarTexture); @@ -1954,15 +1954,15 @@ void MAP_DrawMap (const uiNode_t* node, campaign_t *campaign) static float lastQ = 0.0f; /* the sun is not always in the plane of the equator on earth - calculate the angle the sun is at */ - const float q = (ccs.date.day % DAYS_PER_YEAR + (float)(ccs.date.sec / (SECONDS_PER_HOUR * 6)) / 4) * 2 * M_PI / DAYS_PER_YEAR - M_PI; - if (ccs.smoothRotation) + const float q = (ccs->date.day % DAYS_PER_YEAR + (float)(ccs->date.sec / (SECONDS_PER_HOUR * 6)) / 4) * 2 * M_PI / DAYS_PER_YEAR - M_PI; + if (ccs->smoothRotation) MAP_SmoothTranslate(); if (lastQ != q) { CP_CalcAndUploadDayAndNightTexture(q); lastQ = q; } - R_DrawFlatGeoscape(ccs.mapPos[0], ccs.mapPos[1], ccs.mapSize[0], ccs.mapSize[1], (float) ccs.date.sec / SECONDS_PER_DAY, - ccs.center[0], ccs.center[1], 0.5 / ccs.zoom, campaign->map, MAP_IsNationOverlayActivated(), + R_DrawFlatGeoscape(ccs->mapPos[0], ccs->mapPos[1], ccs->mapSize[0], ccs->mapSize[1], (float) ccs->date.sec / SECONDS_PER_DAY, + ccs->center[0], ccs->center[1], 0.5 / ccs->zoom, campaign->map, MAP_IsNationOverlayActivated(), MAP_IsXVIOverlayActivated(), MAP_IsRadarOverlayActivated(), r_dayandnightTexture, r_xviTexture, r_radarTexture); MAP_DrawMapMarkers(node); } @@ -1970,7 +1970,7 @@ void MAP_DrawMap (const uiNode_t* node, campaign_t *campaign) mission = MAP_GetSelectedMission(); /* display text */ UI_ResetData(TEXT_STANDARD); - switch (ccs.mapAction) { + switch (ccs->mapAction) { case MA_NEWBASE: UI_RegisterText(TEXT_STANDARD, _("Select the desired location of the new base on the map.\n")); return; @@ -2013,7 +2013,7 @@ void MAP_DrawMap (const uiNode_t* node, campaign_t *campaign) #ifdef DEBUG if (debug_showInterest->integer) { static char t[64]; - Com_sprintf(t, lengthof(t), "Interest level: %i\n", ccs.overallInterest); + Com_sprintf(t, lengthof(t), "Interest level: %i\n", ccs->overallInterest); UI_RegisterText(TEXT_STANDARD, t); } else #endif @@ -2028,7 +2028,7 @@ void MAP_ResetAction (void) { /* don't allow a reset when no base is set up */ if (B_AtLeastOneExists()) - ccs.mapAction = MA_NONE; + ccs->mapAction = MA_NONE; MAP_SetInterceptorAircraft(NULL); MAP_SetSelectedMission(NULL); @@ -2065,7 +2065,7 @@ void MAP_SelectMission (mission_t* mission) if (!mission || MAP_IsMissionSelected(mission)) return; MAP_ResetAction(); - ccs.mapAction = MA_INTERCEPT; + ccs->mapAction = MA_INTERCEPT; MAP_SetSelectedMission(mission); } @@ -2096,9 +2096,9 @@ void MAP_NotifyUFORemoved (const aircraft_t* ufo, qboolean destroyed) /* Unselect the current selected ufo if its the same */ if (MAP_IsUFOSelected(ufo)) MAP_ResetAction(); - else if (destroyed && ccs.geoscape.selectedUFO > ufo) + else if (destroyed && ccs->geoscape.selectedUFO > ufo) /** @todo convert to linked list */ - ccs.geoscape.selectedUFO--; + ccs->geoscape.selectedUFO--; } /** @@ -2127,7 +2127,7 @@ nation_t* MAP_GetNation (const vec2_t pos) #ifdef PARANOID Com_DPrintf(DEBUG_CLIENT, "MAP_GetNation: color value for %.0f:%.0f is r:%i, g:%i, b: %i\n", pos[0], pos[1], color[0], color[1], color[2]); #endif - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { nation_t *nation = NAT_GetNationByIDX(i); /* compare the first three color values with color value at pos */ if (VectorCompare(nation->color, color)) @@ -2316,10 +2316,10 @@ qboolean MAP_IsNight (const vec2_t pos) { float p, q, a, root, x; - /* set p to hours (we don't use ccs.day here because we need a float value) */ - p = (float) ccs.date.sec / SECONDS_PER_DAY; + /* set p to hours (we don't use ccs->day here because we need a float value) */ + p = (float) ccs->date.sec / SECONDS_PER_DAY; /* convert current day to angle (-pi on 1st january, pi on 31 december) */ - q = (ccs.date.day + p) * (2 * M_PI / DAYS_PER_YEAR_AVG) - M_PI; + q = (ccs->date.day + p) * (2 * M_PI / DAYS_PER_YEAR_AVG) - M_PI; p = (0.5 + pos[0] / 360 - p) * (2 * M_PI) - q; a = -sin(pos[1] * torad); root = sqrt(1.0 - a * a); @@ -2532,32 +2532,32 @@ void MAP_Zoom_f (void) cmd = Cmd_Argv(1); switch (cmd[0]) { case 'i': - ccs.smoothFinalZoom = ccs.zoom * pow(0.995, -zoomAmount); + ccs->smoothFinalZoom = ccs->zoom * pow(0.995, -zoomAmount); break; case 'o': - ccs.smoothFinalZoom = ccs.zoom * pow(0.995, zoomAmount); + ccs->smoothFinalZoom = ccs->zoom * pow(0.995, zoomAmount); break; default: Com_Printf("MAP_Zoom_f: Invalid parameter: %s\n", cmd); return; } - if (ccs.smoothFinalZoom < cl_mapzoommin->value) - ccs.smoothFinalZoom = cl_mapzoommin->value; - else if (ccs.smoothFinalZoom > cl_mapzoommax->value) - ccs.smoothFinalZoom = cl_mapzoommax->value; + if (ccs->smoothFinalZoom < cl_mapzoommin->value) + ccs->smoothFinalZoom = cl_mapzoommin->value; + else if (ccs->smoothFinalZoom > cl_mapzoommax->value) + ccs->smoothFinalZoom = cl_mapzoommax->value; if (!cl_3dmap->integer) { - ccs.zoom = ccs.smoothFinalZoom; - if (ccs.center[1] < 0.5 / ccs.zoom) - ccs.center[1] = 0.5 / ccs.zoom; - if (ccs.center[1] > 1.0 - 0.5 / ccs.zoom) - ccs.center[1] = 1.0 - 0.5 / ccs.zoom; + ccs->zoom = ccs->smoothFinalZoom; + if (ccs->center[1] < 0.5 / ccs->zoom) + ccs->center[1] = 0.5 / ccs->zoom; + if (ccs->center[1] > 1.0 - 0.5 / ccs->zoom) + ccs->center[1] = 1.0 - 0.5 / ccs->zoom; } else { - VectorCopy(ccs.angles, ccs.smoothFinalGlobeAngle); - ccs.smoothDeltaLength = 0; - ccs.smoothRotation = qtrue; - ccs.smoothDeltaZoom = fabs(ccs.smoothFinalZoom - ccs.zoom); + VectorCopy(ccs->angles, ccs->smoothFinalGlobeAngle); + ccs->smoothDeltaLength = 0; + ccs->smoothRotation = qtrue; + ccs->smoothDeltaZoom = fabs(ccs->smoothFinalZoom - ccs->zoom); } } @@ -2597,48 +2597,48 @@ void MAP_Scroll_f (void) /* case 3D geoscape */ vec3_t diff; - VectorCopy(ccs.angles, ccs.smoothFinalGlobeAngle); + VectorCopy(ccs->angles, ccs->smoothFinalGlobeAngle); /* rotate a model */ - ccs.smoothFinalGlobeAngle[PITCH] += ROTATE_SPEED * (scrollX) / ccs.zoom; - ccs.smoothFinalGlobeAngle[YAW] -= ROTATE_SPEED * (scrollY) / ccs.zoom; + ccs->smoothFinalGlobeAngle[PITCH] += ROTATE_SPEED * (scrollX) / ccs->zoom; + ccs->smoothFinalGlobeAngle[YAW] -= ROTATE_SPEED * (scrollY) / ccs->zoom; - while (ccs.smoothFinalGlobeAngle[YAW] < -180.0) { - ccs.smoothFinalGlobeAngle[YAW] = -180.0; + while (ccs->smoothFinalGlobeAngle[YAW] < -180.0) { + ccs->smoothFinalGlobeAngle[YAW] = -180.0; } - while (ccs.smoothFinalGlobeAngle[YAW] > 0.0) { - ccs.smoothFinalGlobeAngle[YAW] = 0.0; + while (ccs->smoothFinalGlobeAngle[YAW] > 0.0) { + ccs->smoothFinalGlobeAngle[YAW] = 0.0; } - while (ccs.smoothFinalGlobeAngle[PITCH] > 180.0) { - ccs.smoothFinalGlobeAngle[PITCH] -= 360.0; - ccs.angles[PITCH] -= 360.0; + while (ccs->smoothFinalGlobeAngle[PITCH] > 180.0) { + ccs->smoothFinalGlobeAngle[PITCH] -= 360.0; + ccs->angles[PITCH] -= 360.0; } - while (ccs.smoothFinalGlobeAngle[PITCH] < -180.0) { - ccs.smoothFinalGlobeAngle[PITCH] += 360.0; - ccs.angles[PITCH] += 360.0; + while (ccs->smoothFinalGlobeAngle[PITCH] < -180.0) { + ccs->smoothFinalGlobeAngle[PITCH] += 360.0; + ccs->angles[PITCH] += 360.0; } - VectorSubtract(ccs.smoothFinalGlobeAngle, ccs.angles, diff); - ccs.smoothDeltaLength = VectorLength(diff); + VectorSubtract(ccs->smoothFinalGlobeAngle, ccs->angles, diff); + ccs->smoothDeltaLength = VectorLength(diff); - ccs.smoothFinalZoom = ccs.zoom; - ccs.smoothDeltaZoom = 0.0f; - ccs.smoothRotation = qtrue; + ccs->smoothFinalZoom = ccs->zoom; + ccs->smoothDeltaZoom = 0.0f; + ccs->smoothRotation = qtrue; } else { int i; /* shift the map */ - ccs.center[0] -= (float) (scrollX) / (ccs.mapSize[0] * ccs.zoom); - ccs.center[1] -= (float) (scrollY) / (ccs.mapSize[1] * ccs.zoom); + ccs->center[0] -= (float) (scrollX) / (ccs->mapSize[0] * ccs->zoom); + ccs->center[1] -= (float) (scrollY) / (ccs->mapSize[1] * ccs->zoom); for (i = 0; i < 2; i++) { - while (ccs.center[i] < 0.0) - ccs.center[i] += 1.0; - while (ccs.center[i] > 1.0) - ccs.center[i] -= 1.0; + while (ccs->center[i] < 0.0) + ccs->center[i] += 1.0; + while (ccs->center[i] > 1.0) + ccs->center[i] -= 1.0; } - if (ccs.center[1] < 0.5 / ccs.zoom) - ccs.center[1] = 0.5 / ccs.zoom; - if (ccs.center[1] > 1.0 - 0.5 / ccs.zoom) - ccs.center[1] = 1.0 - 0.5 / ccs.zoom; + if (ccs->center[1] < 0.5 / ccs->zoom) + ccs->center[1] = 0.5 / ccs->zoom; + if (ccs->center[1] > 1.0 - 0.5 / ccs->zoom) + ccs->center[1] = 1.0 - 0.5 / ccs->zoom; } } diff --git a/src/client/campaign/cp_map.h b/src/client/campaign/cp_map.h index 3ea05d0..373e614 100644 --- a/src/client/campaign/cp_map.h +++ b/src/client/campaign/cp_map.h @@ -38,22 +38,22 @@ extern cvar_t *cl_3dmap; /* prototype */ struct uiNode_s; -#define MAP_IsAircraftSelected(aircraft) ((aircraft) == ccs.geoscape.selectedAircraft) -#define MAP_IsInterceptorSelected(aircraft) ((aircraft) == ccs.geoscape.interceptAircraft) -#define MAP_IsUFOSelected(ufo) ((ufo) == ccs.geoscape.selectedUFO) -#define MAP_IsMissionSelected(mission) ((mission) == ccs.geoscape.selectedMission) - -#define MAP_GetSelectedAircraft() (ccs.geoscape.selectedAircraft) -#define MAP_GetInterceptorAircraft() (ccs.geoscape.interceptAircraft) -#define MAP_GetSelectedUFO() (ccs.geoscape.selectedUFO) -#define MAP_GetSelectedMission() (ccs.geoscape.selectedMission) -#define MAP_GetMissionAircraft() (ccs.geoscape.missionAircraft) - -#define MAP_SetSelectedAircraft(aircraft) (ccs.geoscape.selectedAircraft = (aircraft)) -#define MAP_SetInterceptorAircraft(interceptor) (ccs.geoscape.interceptAircraft = (interceptor)) -#define MAP_SetSelectedUFO(ufo) (ccs.geoscape.selectedUFO = (ufo)) -#define MAP_SetSelectedMission(mission) (ccs.geoscape.selectedMission = (mission)) -#define MAP_SetMissionAircraft(aircraft) (ccs.geoscape.missionAircraft = (aircraft)) +#define MAP_IsAircraftSelected(aircraft) ((aircraft) == ccs->geoscape.selectedAircraft) +#define MAP_IsInterceptorSelected(aircraft) ((aircraft) == ccs->geoscape.interceptAircraft) +#define MAP_IsUFOSelected(ufo) ((ufo) == ccs->geoscape.selectedUFO) +#define MAP_IsMissionSelected(mission) ((mission) == ccs->geoscape.selectedMission) + +#define MAP_GetSelectedAircraft() (ccs->geoscape.selectedAircraft) +#define MAP_GetInterceptorAircraft() (ccs->geoscape.interceptAircraft) +#define MAP_GetSelectedUFO() (ccs->geoscape.selectedUFO) +#define MAP_GetSelectedMission() (ccs->geoscape.selectedMission) +#define MAP_GetMissionAircraft() (ccs->geoscape.missionAircraft) + +#define MAP_SetSelectedAircraft(aircraft) (ccs->geoscape.selectedAircraft = (aircraft)) +#define MAP_SetInterceptorAircraft(interceptor) (ccs->geoscape.interceptAircraft = (interceptor)) +#define MAP_SetSelectedUFO(ufo) (ccs->geoscape.selectedUFO = (ufo)) +#define MAP_SetSelectedMission(mission) (ccs->geoscape.selectedMission = (mission)) +#define MAP_SetMissionAircraft(aircraft) (ccs->geoscape.missionAircraft = (aircraft)) nation_t* MAP_GetNation(const vec2_t pos); qboolean MAP_AllMapToScreen(const struct uiNode_s* node, const vec2_t pos, int *x, int *y, int *z); diff --git a/src/client/campaign/cp_mapfightequip.c b/src/client/campaign/cp_mapfightequip.c index 6000c94..1f1538e 100644 --- a/src/client/campaign/cp_mapfightequip.c +++ b/src/client/campaign/cp_mapfightequip.c @@ -1318,7 +1318,7 @@ void BDEF_AutoSelectTarget (void) BDEF_AutoTarget(base->lasers, base->numLasers); } - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { installation_t *inst = INS_GetFoundedInstallationByIDX(i); if (!inst) continue; diff --git a/src/client/campaign/cp_market.c b/src/client/campaign/cp_market.c index 1fe6e15..a4c0cb9 100644 --- a/src/client/campaign/cp_market.c +++ b/src/client/campaign/cp_market.c @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cp_market.h" #include "save/save_market.h" -#define BS_GetMarket() (&ccs.eMarket) +#define BS_GetMarket() (&ccs->eMarket) void BS_AddItemToMarket (const objDef_t *od, int amount) { @@ -149,7 +149,7 @@ qboolean BS_CheckAndDoBuyItem (base_t* base, const objDef_t *item, int number) /* you can't buy more items than you have credits for */ /** @todo Handle items with price 0 better */ if (price) - numItems = min(numItems, ccs.credits / price); + numItems = min(numItems, ccs->credits / price); if (numItems <= 0) return qfalse; @@ -166,7 +166,7 @@ qboolean BS_CheckAndDoBuyItem (base_t* base, const objDef_t *item, int number) B_UpdateStorageAndCapacity(base, item, numItems, qfalse, qfalse); BS_RemoveItemFromMarket(item, numItems); - CL_UpdateCredits(ccs.credits - price * numItems); + CL_UpdateCredits(ccs->credits - price * numItems); return qtrue; } @@ -179,7 +179,7 @@ static void BS_ProcessCraftItemSale (const objDef_t *craftitem, const int numIte { if (craftitem) { BS_AddItemToMarket(craftitem, numItems); - CL_UpdateCredits(ccs.credits + BS_GetItemSellingPrice(craftitem) * numItems); + CL_UpdateCredits(ccs->credits + BS_GetItemSellingPrice(craftitem) * numItems); } } @@ -218,7 +218,7 @@ qboolean BS_SellAircraft (aircraft_t *aircraft) /* the capacities are also updated here */ BS_AddAircraftToMarket(aircraft, 1); - CL_UpdateCredits(ccs.credits + BS_GetAircraftSellingPrice(aircraft)); + CL_UpdateCredits(ccs->credits + BS_GetAircraftSellingPrice(aircraft)); AIR_DeleteAircraft(aircraft); @@ -381,7 +381,7 @@ void CL_CampaignRunMarket (campaign_t *campaign) const technology_t *tech = RS_GetTechForItem(od); int asymptoticNumber; - if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numItems[i] != 0 || ccs.date.day > tech->researchedDate.day + RESEARCH_LIMIT_DELAY)) { + if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numItems[i] != 0 || ccs->date.day > tech->researchedDate.day + RESEARCH_LIMIT_DELAY)) { /* if items are researched for more than RESEARCH_LIMIT_DELAY or was on the initial market, * there number tend to the value defined in equipment.ufo. * This value is the asymptotic value if it is not 0, or initial value else */ @@ -412,7 +412,7 @@ void CL_CampaignRunMarket (campaign_t *campaign) const technology_t *tech = aircraft->tech; int asymptoticNumber; - if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numAircraft[i] != 0 || ccs.date.day > tech->researchedDate.day + RESEARCH_LIMIT_DELAY)) { + if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numAircraft[i] != 0 || ccs->date.day > tech->researchedDate.day + RESEARCH_LIMIT_DELAY)) { /* if aircraft is researched for more than RESEARCH_LIMIT_DELAY or was on the initial market, * there number tend to the value defined in equipment.ufo. * This value is the asymptotic value if it is not 0, or initial value else */ diff --git a/src/client/campaign/cp_market_callbacks.c b/src/client/campaign/cp_market_callbacks.c index 506190f..c657783 100644 --- a/src/client/campaign/cp_market_callbacks.c +++ b/src/client/campaign/cp_market_callbacks.c @@ -158,7 +158,7 @@ static inline qboolean BS_GetMinMaxValueByItemID (const base_t *base, int itemNu if (!item) return qfalse; *value = B_ItemInBase(item, base); - *max = B_ItemInBase(item, base) + ccs.eMarket.numItems[item->idx]; + *max = B_ItemInBase(item, base) + ccs->eMarket.numItems[item->idx]; *min = 0; } @@ -212,7 +212,7 @@ static void BS_MarketScroll_f (void) break; /* Check whether the item matches the proper filter, storage in current base and market. */ - if (od && (B_ItemInBase(od, base) > 0 || ccs.eMarket.numItems[od->idx]) && INV_ItemMatchesFilter(od, buyCat)) { + if (od && (B_ItemInBase(od, base) > 0 || ccs->eMarket.numItems[od->idx]) && INV_ItemMatchesFilter(od, buyCat)) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", i - buyList.scroll); @@ -221,7 +221,7 @@ static void BS_MarketScroll_f (void) /* autosell setting */ if (!RS_IsResearched_ptr(tech)) continue; - if (ccs.eMarket.autosell[od->idx]) + if (ccs->eMarket.autosell[od->idx]) UI_ExecuteConfunc("buy_autoselle %i", i - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", i - buyList.scroll); @@ -324,7 +324,7 @@ static void BS_BuyType (const base_t *base) if (!base || buyCat >= MAX_FILTERTYPES || buyCat < 0) return; - CL_UpdateCredits(ccs.credits); + CL_UpdateCredits(ccs->credits); bsMarketNames = NULL; bsMarketStorage = NULL; @@ -342,7 +342,7 @@ static void BS_BuyType (const base_t *base) { const technology_t* tech; const aircraft_t *aircraftTemplate; - for (i = 0, j = 0, aircraftTemplate = ccs.aircraftTemplates; i < ccs.numAircraftTemplates; i++, aircraftTemplate++) { + for (i = 0, j = 0, aircraftTemplate = ccs->aircraftTemplates; i < ccs->numAircraftTemplates; i++, aircraftTemplate++) { if (!BS_AircraftIsOnMarket(aircraftTemplate)) continue; tech = aircraftTemplate->tech; @@ -371,20 +371,20 @@ static void BS_BuyType (const base_t *base) if (!BS_IsOnMarket(od)) continue; /* Check whether the item matches the proper filter, storage in current base and market. */ - if ((B_ItemInBase(od, base) || ccs.eMarket.numItems[i]) + if ((B_ItemInBase(od, base) || ccs->eMarket.numItems[i]) && INV_ItemMatchesFilter(od, FILTER_CRAFTITEM)) { if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); if (RS_IsResearched_ptr(tech)) { - if (ccs.eMarket.autosell[i]) + if (ccs->eMarket.autosell[i]) UI_ExecuteConfunc("buy_autoselle %i", j - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", j - buyList.scroll); } } - BS_AddToList(od->name, B_ItemInBase(od, base), ccs.eMarket.numItems[i], BS_GetItemBuyingPrice(od)); + BS_AddToList(od->name, B_ItemInBase(od, base), ccs->eMarket.numItems[i], BS_GetItemBuyingPrice(od)); if (j >= MAX_BUYLIST) Com_Error(ERR_DROP, "Increase the MAX_FILTERLIST value to handle that much items\n"); buyList.l[j].item = od; @@ -438,15 +438,15 @@ static void BS_BuyType (const base_t *base) continue; /* Check whether the item matches the proper filter, storage in current base and market. */ - if (INV_ItemMatchesFilter(od, FILTER_UGVITEM) && (B_ItemInBase(od, base) || ccs.eMarket.numItems[i])) { - BS_AddToList(od->name, B_ItemInBase(od, base), ccs.eMarket.numItems[i], BS_GetItemBuyingPrice(od)); + if (INV_ItemMatchesFilter(od, FILTER_UGVITEM) && (B_ItemInBase(od, base) || ccs->eMarket.numItems[i])) { + BS_AddToList(od->name, B_ItemInBase(od, base), ccs->eMarket.numItems[i], BS_GetItemBuyingPrice(od)); /* Set state of Autosell button. */ if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); if (RS_IsResearched_ptr(tech)) { - if (ccs.eMarket.autosell[i]) + if (ccs->eMarket.autosell[i]) UI_ExecuteConfunc("buy_autoselle %i", j - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", j - buyList.scroll); @@ -472,15 +472,15 @@ static void BS_BuyType (const base_t *base) if (!BS_IsOnMarket(od)) continue; /* Check whether the item matches the proper filter, storage in current base and market. */ - if ((B_ItemInBase(od, base) || ccs.eMarket.numItems[i]) && INV_ItemMatchesFilter(od, buyCat)) { - BS_AddToList(od->name, B_ItemInBase(od, base), ccs.eMarket.numItems[i], BS_GetItemBuyingPrice(od)); + if ((B_ItemInBase(od, base) || ccs->eMarket.numItems[i]) && INV_ItemMatchesFilter(od, buyCat)) { + BS_AddToList(od->name, B_ItemInBase(od, base), ccs->eMarket.numItems[i], BS_GetItemBuyingPrice(od)); /* Set state of Autosell button. */ if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); if (RS_IsResearched_ptr(tech)) { - if (ccs.eMarket.autosell[i]) + if (ccs->eMarket.autosell[i]) UI_ExecuteConfunc("buy_autoselle %i", j - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", j - buyList.scroll); @@ -634,13 +634,13 @@ static void BS_BuyAircraft_f (void) return; } else { const int price = BS_GetAircraftBuyingPrice(aircraftTemplate); - if (ccs.credits < price) { + if (ccs->credits < price) { UI_Popup(_("Notice"), _("You cannot buy this aircraft.\nNot enough credits.\n")); return; } else { /* Hangar capacities are being updated in AIR_NewAircraft().*/ BS_RemoveAircraftFromMarket(aircraftTemplate, 1); - CL_UpdateCredits(ccs.credits - price); + CL_UpdateCredits(ccs->credits - price); AIR_NewAircraft(base, aircraftTemplate); Cmd_ExecuteString(va("buy_type %s", INV_GetFilterType(FILTER_AIRCRAFT))); } @@ -748,7 +748,7 @@ static void BS_BuyItem_f (void) UP_UGVDescription(ugv); - if (ccs.credits >= ugv->price && E_CountUnhiredRobotsByType(ugv) > 0) { + if (ccs->credits >= ugv->price && E_CountUnhiredRobotsByType(ugv) > 0) { qboolean ugvWeaponBuyable; /* Check if we have a weapon for this ugv in the market and there is enough storage-room for it. */ const objDef_t *ugvWeapon = INVSH_GetItemByID(ugv->weapon); @@ -756,7 +756,7 @@ static void BS_BuyItem_f (void) Com_Error(ERR_DROP, "BS_BuyItem_f: Could not get weapon '%s' for ugv/tank '%s'.", ugv->weapon, ugv->id); ugvWeaponBuyable = qtrue; - if (!ccs.eMarket.numItems[ugvWeapon->idx]) + if (!ccs->eMarket.numItems[ugvWeapon->idx]) ugvWeaponBuyable = qfalse; if (base->capacities[CAP_ITEMS].max - base->capacities[CAP_ITEMS].cur < @@ -772,7 +772,7 @@ static void BS_BuyItem_f (void) /* Update Display/List and credits. */ BS_BuyType(base); - CL_UpdateCredits(ccs.credits - ugv->price); /** @todo make this depend on market as well? */ + CL_UpdateCredits(ccs->credits - ugv->price); /** @todo make this depend on market as well? */ } else { Com_Printf("Could not buy this item.\n"); } @@ -845,7 +845,7 @@ static void BS_SellItem_f (void) BS_AddItemToMarket(ugvWeapon, 1); } BS_BuyType(base); - CL_UpdateCredits(ccs.credits + ugv->price); /** @todo make this depend on market as well? */ + CL_UpdateCredits(ccs->credits + ugv->price); /** @todo make this depend on market as well? */ } } else { const objDef_t *item = BS_GetObjectDefition(&buyList.l[num + buyList.scroll]); @@ -862,7 +862,7 @@ static void BS_SellItem_f (void) B_UpdateStorageAndCapacity(base, item, -numItems, qfalse, qfalse); BS_AddItemToMarket(item, numItems); BS_BuyType(base); - CL_UpdateCredits(ccs.credits + BS_GetItemSellingPrice(item) * numItems); + CL_UpdateCredits(ccs->credits + BS_GetItemSellingPrice(item) * numItems); BS_UpdateItem(base, num); } } @@ -915,15 +915,15 @@ static void BS_Autosell_f (void) item = BS_GetObjectDefition(&buyList.l[num + buyList.scroll]); assert(item); - if (ccs.eMarket.autosell[item->idx]) { - ccs.eMarket.autosell[item->idx] = qfalse; + if (ccs->eMarket.autosell[item->idx]) { + ccs->eMarket.autosell[item->idx] = qfalse; Com_DPrintf(DEBUG_CLIENT, "item name: %s, autosell false\n", item->name); } else { const technology_t *tech = RS_GetTechForItem(item); /* Don't allow to enable autosell for items not researched. */ if (!RS_IsResearched_ptr(tech)) return; - ccs.eMarket.autosell[item->idx] = qtrue; + ccs->eMarket.autosell[item->idx] = qtrue; Com_DPrintf(DEBUG_CLIENT, "item name: %s, autosell true\n", item->name); } diff --git a/src/client/campaign/cp_messageoptions.c b/src/client/campaign/cp_messageoptions.c index 26dc9a6..61c079e 100644 --- a/src/client/campaign/cp_messageoptions.c +++ b/src/client/campaign/cp_messageoptions.c @@ -319,29 +319,29 @@ void MSO_ParseCategories (const char *name, const char **text) } /* add category */ - if (ccs.numMsgCategories >= MAX_MESSAGECATEGORIES) { + if (ccs->numMsgCategories >= MAX_MESSAGECATEGORIES) { Com_Printf("MSO_ParseCategories: too many messagecategory defs\n"); return; } - category = &ccs.messageCategories[ccs.numMsgCategories]; + category = &ccs->messageCategories[ccs->numMsgCategories]; OBJZERO(*category); category->id = Mem_PoolStrDup(name, cp_campaignPool, 0); - category->idx = ccs.numMsgCategories; /* set self-link */ + category->idx = ccs->numMsgCategories; /* set self-link */ - entry = &ccs.msgCategoryEntries[ccs.numMsgCategoryEntries]; + entry = &ccs->msgCategoryEntries[ccs->numMsgCategoryEntries]; /* first entry is category */ OBJZERO(*entry); - entry->category = &ccs.messageCategories[ccs.numMsgCategories]; - category->last = category->first = &ccs.msgCategoryEntries[ccs.numMsgCategoryEntries]; + entry->category = &ccs->messageCategories[ccs->numMsgCategories]; + category->last = category->first = &ccs->msgCategoryEntries[ccs->numMsgCategoryEntries]; entry->previous = NULL; entry->next = NULL; entry->isCategory = qtrue; entry->notifyType = category->id; - ccs.numMsgCategoryEntries++; + ccs->numMsgCategoryEntries++; do { /* get entries and add them to category */ @@ -355,25 +355,25 @@ void MSO_ParseCategories (const char *name, const char **text) for (idx = 0; idx < NT_NUM_NOTIFYTYPE; idx ++) { if (Q_streq(token, nt_strings[idx])) { /* prepare a new msgcategory entry */ - msgCategoryEntry_t *old = ccs.messageCategories[ccs.numMsgCategories].last; - - OBJZERO(ccs.msgCategoryEntries[ccs.numMsgCategoryEntries]); - ccs.msgCategoryEntries[ccs.numMsgCategoryEntries].category = &ccs.messageCategories[ccs.numMsgCategories]; - - ccs.messageCategories[ccs.numMsgCategories].last = &ccs.msgCategoryEntries[ccs.numMsgCategoryEntries]; - old->next = &ccs.msgCategoryEntries[ccs.numMsgCategoryEntries]; - ccs.msgCategoryEntries[ccs.numMsgCategoryEntries].previous = old; - ccs.msgCategoryEntries[ccs.numMsgCategoryEntries].next = NULL; - ccs.msgCategoryEntries[ccs.numMsgCategoryEntries].notifyType = nt_strings[idx]; - ccs.msgCategoryEntries[ccs.numMsgCategoryEntries].settings = &messageSettings[idx]; - ccs.numMsgCategoryEntries++; + msgCategoryEntry_t *old = ccs->messageCategories[ccs->numMsgCategories].last; + + OBJZERO(ccs->msgCategoryEntries[ccs->numMsgCategoryEntries]); + ccs->msgCategoryEntries[ccs->numMsgCategoryEntries].category = &ccs->messageCategories[ccs->numMsgCategories]; + + ccs->messageCategories[ccs->numMsgCategories].last = &ccs->msgCategoryEntries[ccs->numMsgCategoryEntries]; + old->next = &ccs->msgCategoryEntries[ccs->numMsgCategoryEntries]; + ccs->msgCategoryEntries[ccs->numMsgCategoryEntries].previous = old; + ccs->msgCategoryEntries[ccs->numMsgCategoryEntries].next = NULL; + ccs->msgCategoryEntries[ccs->numMsgCategoryEntries].notifyType = nt_strings[idx]; + ccs->msgCategoryEntries[ccs->numMsgCategoryEntries].settings = &messageSettings[idx]; + ccs->numMsgCategoryEntries++; break; } } } } while (*text); - ccs.numMsgCategories++; + ccs->numMsgCategories++; MSO_SetMenuState(MSO_MSTATE_REINIT,qfalse,qfalse); } diff --git a/src/client/campaign/cp_messageoptions_callbacks.c b/src/client/campaign/cp_messageoptions_callbacks.c index e5cbd11..04025c2 100644 --- a/src/client/campaign/cp_messageoptions_callbacks.c +++ b/src/client/campaign/cp_messageoptions_callbacks.c @@ -51,8 +51,8 @@ static void MSO_InitList (void) return; UI_ResetData(TEXT_MESSAGEOPTIONS); - for (idx = 0; idx < ccs.numMsgCategoryEntries; idx++) { - const msgCategoryEntry_t *entry = &ccs.msgCategoryEntries[idx]; + for (idx = 0; idx < ccs->numMsgCategoryEntries; idx++) { + const msgCategoryEntry_t *entry = &ccs->msgCategoryEntries[idx]; const char *id = va("%d", idx); if (entry->isCategory) { @@ -89,7 +89,7 @@ static void MSO_UpdateVisibleButtons (void) break; idx = atoi(OPTIONEXTRADATACONST(option).value); - entry = &ccs.msgCategoryEntries[idx]; + entry = &ccs->msgCategoryEntries[idx]; if (!entry) break; if (entry->isCategory) { @@ -166,7 +166,7 @@ static void MSO_Toggle_f (void) return; idx = atoi(OPTIONEXTRADATA(iterator.option).value); - selectedEntry = &ccs.msgCategoryEntries[idx]; + selectedEntry = &ccs->msgCategoryEntries[idx]; if (!selectedEntry) return; if (selectedEntry->isCategory) { diff --git a/src/client/campaign/cp_messages.c b/src/client/campaign/cp_messages.c index e7110b4..e7c6422 100644 --- a/src/client/campaign/cp_messages.c +++ b/src/client/campaign/cp_messages.c @@ -96,7 +96,7 @@ message_t *MS_AddNewMessageSound (const char *title, const char *text, qboolean mess->type = type; mess->pedia = pedia; /* pointer to UFOpaedia entry */ - mess->date = ccs.date; + mess->date = ccs->date; Q_strncpyz(mess->title, title, sizeof(mess->title)); mess->text = Mem_PoolStrDup(text, cp_campaignPool, 0); @@ -128,7 +128,7 @@ message_t *MS_AddNewMessageSound (const char *title, const char *text, qboolean case MSG_EVENT: case MSG_NEWS: /* reread the new mails in UP_GetUnreadMails */ - ccs.numUnreadMails = -1; + ccs->numUnreadMails = -1; sound = "geoscape/mail"; break; case MSG_UFOSPOTTED: diff --git a/src/client/campaign/cp_mission_triggers.c b/src/client/campaign/cp_mission_triggers.c index cc37725..f0191aa 100644 --- a/src/client/campaign/cp_mission_triggers.c +++ b/src/client/campaign/cp_mission_triggers.c @@ -111,7 +111,7 @@ static void CP_ChangeNationHappiness_f (void) assert(nation); stats = NAT_GetCurrentMonthInfo(nation); - NAT_SetHappiness(ccs.curCampaign->minhappiness, nation, stats->happiness + change); + NAT_SetHappiness(ccs->curCampaign->minhappiness, nation, stats->happiness + change); } /** diff --git a/src/client/campaign/cp_missions.c b/src/client/campaign/cp_missions.c index aeee6df..0a2d84b 100644 --- a/src/client/campaign/cp_missions.c +++ b/src/client/campaign/cp_missions.c @@ -166,15 +166,15 @@ static void CP_SetAlienTeamByInterest (const mission_t *mission, battleParam_t * int numAvailableGroup = 0; /* Find all available alien team groups */ - for (i = 0; i < ccs.numAlienCategories; i++) { - alienTeamCategory_t *cat = &ccs.alienCategories[i]; + for (i = 0; i < ccs->numAlienCategories; i++) { + alienTeamCategory_t *cat = &ccs->alienCategories[i]; /* Check if this alien team category may be used */ if (!CP_IsAlienTeamForCategory(cat, mission->category)) continue; /* Find all available team groups for current alien interest - * use mission->initialOverallInterest and not ccs.overallInterest: + * use mission->initialOverallInterest and not ccs->overallInterest: * the alien team should not change depending on when you encounter it */ for (j = 0; j < cat->numAlienTeamGroups; j++) { if (cat->alienTeamGroups[j].minInterest <= mission->initialOverallInterest @@ -228,7 +228,7 @@ static void CP_SetAlienEquipmentByInterest (const mission_t *mission, linkedList int i, randomNum, availableEquipDef = 0; /* look for all available fitting alien equipment definitions - * use mission->initialOverallInterest and not ccs.overallInterest: the alien equipment should not change depending on + * use mission->initialOverallInterest and not ccs->overallInterest: the alien equipment should not change depending on * when you encounter it */ for (i = 0; i < csi.numEDs; i++) { const equipDef_t *ed = &csi.eds[i]; @@ -269,7 +269,7 @@ static void MIS_CreateAlienTeam (mission_t *mission, battleParam_t *battleParam) assert(mission->posAssigned); - numAliens = max(4, 4 + (int) ccs.overallInterest / 50 + (rand() % 3) - 1); + numAliens = max(4, 4 + (int) ccs->overallInterest / 50 + (rand() % 3) - 1); if (mission->ufo && mission->ufo->maxTeamSize && numAliens > mission->ufo->maxTeamSize) numAliens = mission->ufo->maxTeamSize; if (numAliens > mission->mapDef->maxAliens) @@ -278,7 +278,7 @@ static void MIS_CreateAlienTeam (mission_t *mission, battleParam_t *battleParam) CP_SetAlienTeamByInterest(mission, battleParam); - CP_SetAlienEquipmentByInterest(mission, ccs.alienCategories[battleParam->alienTeamGroup->categoryIdx].equipment, battleParam); + CP_SetAlienEquipmentByInterest(mission, ccs->alienCategories[battleParam->alienTeamGroup->categoryIdx].equipment, battleParam); } /** @@ -380,7 +380,7 @@ void CP_CreateBattleParameters (mission_t *mission, battleParam_t *param, const ====================================*/ /** - * @brief Get a mission in ccs.missions by Id without error messages. + * @brief Get a mission in ccs->missions by Id without error messages. * @param[in] missionId Unique string id for the mission * @return pointer to the mission or NULL if Id was NULL or mission not found */ @@ -400,7 +400,7 @@ mission_t* CP_GetMissionByIDSilent (const char *missionId) } /** - * @brief Get a mission in ccs.missions by Id. + * @brief Get a mission in ccs->missions by Id. * @param[in] missionId Unique string id for the mission * @return pointer to the mission or NULL if Id was NULL or mission not found */ @@ -860,13 +860,13 @@ void CP_MissionRemove (mission_t *mission) CP_UFORemoveFromGeoscape(mission, qtrue); /* for the notifications */ /* Remove from battle parameters */ - if (mission == ccs.battleParameters.mission) - ccs.battleParameters.mission = NULL; + if (mission == ccs->battleParameters.mission) + ccs->battleParameters.mission = NULL; /* Notifications */ CP_MissionRemoveFromGeoscape(mission); - if (!LIST_Remove(&ccs.missions, mission)) + if (!LIST_Remove(&ccs->missions, mission)) Com_Error(ERR_DROP, "CP_MissionRemove: Could not find mission '%s' to remove.\n", mission->id); } @@ -944,7 +944,7 @@ void CP_MissionNotifyInstallationDestroyed (const installation_t const *installa void CP_MissionStageEnd (const campaign_t* campaign, mission_t *mission) { Com_DPrintf(DEBUG_CLIENT, "Ending mission category %i, stage %i (time: %i day, %i sec)\n", - mission->category, mission->stage, ccs.date.day, ccs.date.sec); + mission->category, mission->stage, ccs->date.day, ccs->date.sec); /* Crash mission is on the map for too long: aliens die or go away. End mission */ if (mission->crashed) { @@ -1125,9 +1125,9 @@ void CP_MissionEnd (const campaign_t *campaign, mission_t* mission, const battle } /* add the looted goods to base storage and market */ - base->storage = ccs.eMission; + base->storage = ccs->eMission; - CL_HandleNationData(campaign->minhappiness, won, mission, battleParameters->nation, &ccs.missionResults); + CL_HandleNationData(campaign->minhappiness, won, mission, battleParameters->nation, &ccs->missionResults); CP_CheckLostCondition(campaign); /* update the character stats */ @@ -1149,7 +1149,7 @@ void CP_MissionEnd (const campaign_t *campaign, mission_t* mission, const battle /* Check for alien containment in aircraft homebase. */ /** @todo this shouldn't be here. Ideally we should check for alien/store space when aircraft arrived * home and start a player controlled transfer */ - if (CP_TransferOfAliensToOtherBaseNeeded(base, &ccs.missionResults)) { + if (CP_TransferOfAliensToOtherBaseNeeded(base, &ccs->missionResults)) { /* We have captured/killed aliens, but the homebase of this aircraft does not have free alien containment space. * Popup aircraft transfer dialog to choose a better base. */ Cmd_ExecuteString(va("trans_aliens %i", aircraft->idx)); @@ -1251,7 +1251,7 @@ void CP_SpawnCrashSiteMission (aircraft_t *ufo) Com_sprintf(mission->location, sizeof(mission->location), "%s", _("No nation")); } - mission->finalDate = Date_Add(ccs.date, Date_Random(minCrashDelay, crashDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minCrashDelay, crashDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array * (may be used to know what items are collected from battlefield)*/ CP_UFORemoveFromGeoscape(mission, qfalse); @@ -1370,7 +1370,7 @@ qboolean CP_MissionBegin (mission_t *mission) if (ufoType == UFO_MAX) { mission->ufo = NULL; /* Mission starts from ground: no UFO. Go to next stage on next frame (skip UFO arrives on earth) */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } else { mission->ufo = UFO_AddToGeoscape(ufoType, NULL, mission); if (!mission->ufo) { @@ -1383,7 +1383,7 @@ qboolean CP_MissionBegin (mission_t *mission) CP_MissionDisableTimeLimit(mission); } - mission->idx = ++ccs.campaignStats.missions; + mission->idx = ++ccs->campaignStats.missions; return qtrue; } @@ -1482,7 +1482,7 @@ static inline void CP_SetMissionName (mission_t *mission) mission->category, mission->initialOverallInterest, num); /* if mission list is empty, the id is unique for sure */ - if (LIST_IsEmpty(ccs.missions)) + if (LIST_IsEmpty(ccs->missions)) return; /* check whether a mission with the same id already exists in the list @@ -1517,17 +1517,17 @@ mission_t *CP_CreateNewMission (interestCategory_t category, qboolean beginNow) /* First fill common datas between all type of missions */ mission.category = category; - mission.initialOverallInterest = ccs.overallInterest; - mission.initialIndividualInterest = ccs.interest[category]; + mission.initialOverallInterest = ccs->overallInterest; + mission.initialIndividualInterest = ccs->interest[category]; mission.stage = STAGE_NOT_ACTIVE; mission.ufo = NULL; if (beginNow) { - mission.startDate.day = ccs.date.day; - mission.startDate.sec = ccs.date.sec; + mission.startDate.day = ccs->date.day; + mission.startDate.sec = ccs->date.sec; } else - mission.startDate = Date_Add(ccs.date, Date_Random(minNextSpawningDate, nextSpawningDate)); + mission.startDate = Date_Add(ccs->date, Date_Random(minNextSpawningDate, nextSpawningDate)); mission.finalDate = mission.startDate; - mission.idx = ++ccs.campaignStats.missions; + mission.idx = ++ccs->campaignStats.missions; CP_SetMissionName(&mission); @@ -1540,7 +1540,7 @@ mission_t *CP_CreateNewMission (interestCategory_t category, qboolean beginNow) CP_TerrorMissionOnSpawn(); /* Add mission to global array */ - list = LIST_Add(&ccs.missions, (byte*) &mission, sizeof(mission)); + list = LIST_Add(&ccs->missions, (byte*) &mission, sizeof(mission)); return (mission_t *)list->data; } @@ -1554,12 +1554,12 @@ static int CP_SelectNewMissionType (void) int i, randomNumber; for (i = 0; i < INTERESTCATEGORY_MAX; i++) - sum += ccs.interest[i]; + sum += ccs->interest[i]; randomNumber = (int) (frand() * (float) sum); for (i = 0; randomNumber >= 0; i++) - randomNumber -= ccs.interest[i]; + randomNumber -= ccs->interest[i]; return i - 1; } @@ -1571,9 +1571,9 @@ static int CP_SelectNewMissionType (void) */ void CP_SpawnNewMissions (void) { - ccs.lastMissionSpawnedDelay++; + ccs->lastMissionSpawnedDelay++; - if (ccs.lastMissionSpawnedDelay > DELAY_BETWEEN_MISSION_SPAWNING) { + if (ccs->lastMissionSpawnedDelay > DELAY_BETWEEN_MISSION_SPAWNING) { float nonOccurrence; int newMissionNum, i; /* Select the amount of missions that will be spawned in the next cycle. */ @@ -1581,8 +1581,8 @@ void CP_SpawnNewMissions (void) /* Each mission has a certain probability to not occur. This provides some randomness to the mission density. * However, once the campaign passes a certain point, this effect rapidly diminishes. This means that by the * end of the game, ALL missions will spawn, quickly overrunning the player. */ - if (ccs.overallInterest > FINAL_OVERALL_INTEREST) - nonOccurrence = NON_OCCURRENCE_PROBABILITY / pow(((ccs.overallInterest - FINAL_OVERALL_INTEREST / 30) + 1), 2); + if (ccs->overallInterest > FINAL_OVERALL_INTEREST) + nonOccurrence = NON_OCCURRENCE_PROBABILITY / pow(((ccs->overallInterest - FINAL_OVERALL_INTEREST / 30) + 1), 2); else nonOccurrence = NON_OCCURRENCE_PROBABILITY; @@ -1594,8 +1594,8 @@ void CP_SpawnNewMissions (void) * Note: This is a function over css.overallInterest. It looks like this: * http://www.wolframalpha.com/input/?i=Plot%5B40%2B%285-40%29%2A%28%28x-1000%29%2F%2820-1000%29%29%5E2%2C+%7Bx%2C+0%2C+1100%7D%5D */ - newMissionNum = (int) (MAXIMUM_MISSIONS_PER_CYCLE + (MINIMUM_MISSIONS_PER_CYCLE - MAXIMUM_MISSIONS_PER_CYCLE) * pow(((ccs.overallInterest - FINAL_OVERALL_INTEREST) / (INITIAL_OVERALL_INTEREST - FINAL_OVERALL_INTEREST)), 2)); - Com_DPrintf(DEBUG_CLIENT, "interest = %d, new missions = %d\n", ccs.overallInterest, newMissionNum); + newMissionNum = (int) (MAXIMUM_MISSIONS_PER_CYCLE + (MINIMUM_MISSIONS_PER_CYCLE - MAXIMUM_MISSIONS_PER_CYCLE) * pow(((ccs->overallInterest - FINAL_OVERALL_INTEREST) / (INITIAL_OVERALL_INTEREST - FINAL_OVERALL_INTEREST)), 2)); + Com_DPrintf(DEBUG_CLIENT, "interest = %d, new missions = %d\n", ccs->overallInterest, newMissionNum); for (i = 0; i < newMissionNum; i++) { if (frand() > nonOccurrence) { const int type = CP_SelectNewMissionType(); @@ -1603,7 +1603,7 @@ void CP_SpawnNewMissions (void) } } - ccs.lastMissionSpawnedDelay -= DELAY_BETWEEN_MISSION_SPAWNING; + ccs->lastMissionSpawnedDelay -= DELAY_BETWEEN_MISSION_SPAWNING; } } @@ -1614,7 +1614,7 @@ void CP_SpawnNewMissions (void) */ void CP_InitializeSpawningDelay (void) { - ccs.lastMissionSpawnedDelay = DELAY_BETWEEN_MISSION_SPAWNING; + ccs->lastMissionSpawnedDelay = DELAY_BETWEEN_MISSION_SPAWNING; CP_SpawnNewMissions(); } @@ -1768,7 +1768,7 @@ static void CP_MissionList_f (void) mission->startDate.day, mission->startDate.sec, mission->finalDate.day, mission->finalDate.sec); Com_Printf("...pos (%.02f, %.02f)%s -- mission %son Geoscape\n", mission->pos[0], mission->pos[1], mission->posAssigned ? "(assigned Pos)" : "", mission->onGeoscape ? "" : "not "); if (mission->ufo) - Com_Printf("...UFO: %s (%i/%i)\n", mission->ufo->id, (int) (mission->ufo - ccs.ufos), ccs.numUFOs - 1); + Com_Printf("...UFO: %s (%i/%i)\n", mission->ufo->id, (int) (mission->ufo - ccs->ufos), ccs->numUFOs - 1); else Com_Printf("...UFO: no UFO\n"); noMission = qfalse; @@ -1789,10 +1789,10 @@ static void CP_DeleteMissions_f (void) CP_MissionRemove(mission); } - if (ccs.numUFOs != 0) { - Com_Printf("CP_DeleteMissions_f: Error, there are still %i UFO in game afer removing all missions. Force removal.\n", ccs.numUFOs); - while (ccs.numUFOs) - UFO_RemoveFromGeoscape(ccs.ufos); + if (ccs->numUFOs != 0) { + Com_Printf("CP_DeleteMissions_f: Error, there are still %i UFO in game afer removing all missions. Force removal.\n", ccs->numUFOs); + while (ccs->numUFOs) + UFO_RemoveFromGeoscape(ccs->ufos); } } @@ -1804,11 +1804,11 @@ static void CP_AlienInterestList_f (void) { int i; - Com_Printf("Overall interest: %i\n", ccs.overallInterest); + Com_Printf("Overall interest: %i\n", ccs->overallInterest); Com_Printf("Individual interest:\n"); for (i = 0; i < INTERESTCATEGORY_MAX; i++) - Com_Printf("...%i. %s -- %i\n", i, CP_MissionCategoryToName(i), ccs.interest[i]); + Com_Printf("...%i. %s -- %i\n", i, CP_MissionCategoryToName(i), ccs->interest[i]); } /** @@ -1822,7 +1822,7 @@ static void CP_SetAlienInterest_f (void) return; } - ccs.overallInterest = max(0, atoi(Cmd_Argv(1))); + ccs->overallInterest = max(0, atoi(Cmd_Argv(1))); } #endif @@ -2032,7 +2032,7 @@ qboolean CP_LoadMissionsXML (mxml_node_t *parent) mxml_GetPos2(node, SAVE_MISSIONS_POS, mission.pos); ufoIdx = mxml_GetInt(node, SAVE_MISSIONS_UFO, -1); - if (ufoIdx <= -1 || ufoIdx >= lengthof(ccs.ufos)) + if (ufoIdx <= -1 || ufoIdx >= lengthof(ccs->ufos)) mission.ufo = NULL; else mission.ufo = UFO_GetByIDX(ufoIdx); @@ -2044,7 +2044,7 @@ qboolean CP_LoadMissionsXML (mxml_node_t *parent) defaultAssigned = qtrue; mission.posAssigned = mxml_GetBool(node, SAVE_MISSIONS_POSASSIGNED, defaultAssigned); /* Add mission to global array */ - LIST_Add(&ccs.missions, (byte*) &mission, sizeof(mission)); + LIST_Add(&ccs->missions, (byte*) &mission, sizeof(mission)); } Com_UnregisterConstList(saveInterestConstants); Com_UnregisterConstList(saveMissionConstants); @@ -2073,7 +2073,7 @@ void MIS_InitStartup (void) */ void MIS_Shutdown (void) { - LIST_Delete(&ccs.missions); + LIST_Delete(&ccs->missions); #ifdef DEBUG Cmd_RemoveCommand("debug_missionsetmap"); diff --git a/src/client/campaign/cp_nation.c b/src/client/campaign/cp_nation.c index a8fae18..0988fa4 100644 --- a/src/client/campaign/cp_nation.c +++ b/src/client/campaign/cp_nation.c @@ -37,9 +37,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. nation_t *NAT_GetNationByIDX (const int index) { assert(index >= 0); - assert(index < ccs.numNations); + assert(index < ccs->numNations); - return &ccs.nations[index]; + return &ccs->nations[index]; } /** @@ -55,7 +55,7 @@ nation_t *NAT_GetNationByID (const char *nationID) Com_Printf("NAT_GetNationByID: NULL nationID\n"); return NULL; } - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { nation_t *nation = NAT_GetNationByIDX(i); if (Q_streq(nation->id, nationID)) return nation; @@ -211,7 +211,7 @@ qboolean NAT_SaveXML (mxml_node_t *p) int i; mxml_node_t *n = mxml_AddNode(p, SAVE_NATION_NATIONS); - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { nation_t *nation = NAT_GetNationByIDX(i); mxml_node_t *s; int j; @@ -306,27 +306,27 @@ void CL_ParseNations (const char *name, const char **text) const char *token; int i; - if (ccs.numNations >= MAX_NATIONS) { + if (ccs->numNations >= MAX_NATIONS) { Com_Printf("CL_ParseNations: nation number exceeding maximum number of nations: %i\n", MAX_NATIONS); return; } /* search for nations with same name */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *n = NAT_GetNationByIDX(i); if (Q_streq(name, n->id)) break; } - if (i < ccs.numNations) { + if (i < ccs->numNations) { Com_Printf("CL_ParseNations: nation def \"%s\" with same name found, second ignored\n", name); return; } /* initialize the nation */ - nation = &ccs.nations[ccs.numNations]; + nation = &ccs->nations[ccs->numNations]; OBJZERO(*nation); - nation->idx = ccs.numNations; - ccs.numNations++; + nation->idx = ccs->numNations; + ccs->numNations++; Com_DPrintf(DEBUG_CLIENT, "...found nation %s\n", name); nation->id = Mem_PoolStrDup(name, cp_campaignPool, 0); @@ -338,7 +338,7 @@ void CL_ParseNations (const char *name, const char **text) if (!*text || *token != '{') { Com_Printf("CL_ParseNations: nation def \"%s\" without body ignored\n", name); - ccs.numNations--; + ccs->numNations--; return; } @@ -402,7 +402,7 @@ void CL_ParseCities (const char *name, const char **text) const char *token; /* search for cities with same name */ - LIST_Foreach(ccs.cities, city_t, city) { + LIST_Foreach(ccs->cities, city_t, city) { if (Q_streq(name, city->id)) { Com_Printf("CL_ParseCities: city def \"%s\" with same name found, second ignored\n", name); return; @@ -411,8 +411,8 @@ void CL_ParseCities (const char *name, const char **text) /* initialize the nation */ OBJZERO(newCity); - newCity.idx = ccs.numCities; - ccs.numCities++; + newCity.idx = ccs->numCities; + ccs->numCities++; Com_DPrintf(DEBUG_CLIENT, "...found city %s\n", name); newCity.id = Mem_PoolStrDup(name, cp_campaignPool, 0); @@ -422,7 +422,7 @@ void CL_ParseCities (const char *name, const char **text) if (!*text || *token != '{') { Com_Printf("CL_ParseCities: city def \"%s\" without body ignored\n", name); - ccs.numCities--; + ccs->numCities--; return; } @@ -462,7 +462,7 @@ void CL_ParseCities (const char *name, const char **text) } while (*text); /* Add city to the list */ - LIST_Add(&ccs.cities, (byte*) &newCity, sizeof(newCity)); + LIST_Add(&ccs->cities, (byte*) &newCity, sizeof(newCity)); } /** @@ -476,7 +476,7 @@ qboolean NAT_ScriptSanityCheck (void) city_t *city; /* Check if there is at least one map fitting city parameter for terror mission */ - LIST_Foreach(ccs.cities, city_t, city) { + LIST_Foreach(ccs->cities, city_t, city) { int mapIdx; qboolean cityCanBeUsed = qfalse; qboolean parametersFit = qfalse; @@ -551,7 +551,7 @@ static void CP_NationStatsClick_f (void) /* Which entry in the list? */ num = atoi(Cmd_Argv(1)); - if (num < 0 || num >= ccs.numNations) + if (num < 0 || num >= ccs->numNations) return; UI_PushWindow("nations", NULL, NULL); @@ -589,7 +589,7 @@ static int CL_NationsMaxFunding (void) int m, n; int max = 0; - for (n = 0; n < ccs.numNations; n++) { + for (n = 0; n < ccs->numNations; n++) { const nation_t *nation = NAT_GetNationByIDX(n); for (m = 0; m < MONTHS_PER_YEAR; m++) { if (nation->stats[m].inuse) { @@ -694,7 +694,7 @@ static void CL_NationStatsUpdate_f (void) dy = (int)(colorNode->size[1] / MAX_NATIONS); } - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); lineStrip_t *color = &colorLineStrip[i]; const int funding = NAT_GetFunding(nation, 0); @@ -734,7 +734,7 @@ static void CL_NationStatsUpdate_f (void) UI_RegisterLineStrip(LINESTRIP_COLOR, &colorLineStrip[0]); /* Hide unused nation-entries. */ - for (i = ccs.numNations; i < MAX_NATIONS; i++) { + for (i = ccs->numNations; i < MAX_NATIONS; i++) { UI_ExecuteConfunc("nation_hide %i", i); } @@ -745,7 +745,7 @@ static void CL_NationStatsUpdate_f (void) if (graphNode) { const int maxFunding = CL_NationsMaxFunding(); usedFundPtslist = 0; - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); lineStrip_t *funding = &fundingLineStrip[i]; @@ -779,7 +779,7 @@ static void CL_NationSelect_f (void) } nat = atoi(Cmd_Argv(1)); - if (nat < 0 || nat >= ccs.numNations) { + if (nat < 0 || nat >= ccs->numNations) { Com_Printf("Invalid nation index: %is\n",nat); return; } @@ -797,7 +797,7 @@ static void NAT_ListCities_f (void) { city_t *city; - LIST_Foreach(ccs.cities, city_t, city) { + LIST_Foreach(ccs->cities, city_t, city) { Com_Printf("City '%s' -- position (%0.1f, %0.1f)\n", city->id, city->pos[0], city->pos[1]); MAP_PrintParameterStringByPos(city->pos); } @@ -810,8 +810,8 @@ static void NAT_ListCities_f (void) static void NAT_NationList_f (void) { int i; - for (i = 0; i < ccs.numNations; i++) { - const nation_t *nation = &ccs.nations[i]; + for (i = 0; i < ccs->numNations; i++) { + const nation_t *nation = &ccs->nations[i]; Com_Printf("Nation ID: %s\n", nation->id); Com_Printf("...max-funding %i c\n", nation->maxFunding); Com_Printf("...happiness %0.2f\n", nation->stats[0].happiness); @@ -842,7 +842,7 @@ void NAT_HandleBudget (const campaign_t *campaign) int cost; int totalIncome = 0; int totalExpenditure = 0; - int initialCredits = ccs.credits; + int initialCredits = ccs->credits; base_t *base; const salary_t *salary = &campaign->salaries; aircraft_t *aircraft; @@ -851,7 +851,7 @@ void NAT_HandleBudget (const campaign_t *campaign) * pilots are replaced. The new pilots is evenly distributed between the nations that are happy (happiness > 0). */ E_RefreshUnhiredEmployeeGlobalList(EMPL_PILOT, qtrue); - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); const int funding = NAT_GetFunding(nation, 0); @@ -937,7 +937,7 @@ void NAT_HandleBudget (const campaign_t *campaign) totalExpenditure += cost; MS_AddNewMessageSound(_("Notice"), message, qfalse, MSG_STANDARD, NULL, qfalse); } - CL_UpdateCredits(ccs.credits - totalExpenditure + totalIncome); + CL_UpdateCredits(ccs->credits - totalExpenditure + totalIncome); CL_GameTimeStop(); } @@ -955,7 +955,7 @@ void NAT_BackupMonthlyData (void) * Back up nation relationship . * "inuse" is copied as well so we do not need to set it anywhere. */ - for (nat = 0; nat < ccs.numNations; nat++) { + for (nat = 0; nat < ccs->numNations; nat++) { nation_t *nation = NAT_GetNationByIDX(nat); for (i = MONTHS_PER_YEAR - 1; i > 0; i--) { /* Reverse copy to not overwrite with wrong data */ @@ -984,7 +984,7 @@ void NAT_InitStartup (void) */ void NAT_Shutdown (void) { - LIST_Delete(&ccs.cities); + LIST_Delete(&ccs->cities); Cmd_RemoveCommand("nation_stats_click"); Cmd_RemoveCommand("nation_update"); diff --git a/src/client/campaign/cp_parse.c b/src/client/campaign/cp_parse.c index 8f8757c..7788c36 100644 --- a/src/client/campaign/cp_parse.c +++ b/src/client/campaign/cp_parse.c @@ -87,21 +87,21 @@ static void CL_ParseAlienTeam (const char *name, const char **text) return; } - if (ccs.numAlienCategories >= ALIENCATEGORY_MAX) { + if (ccs->numAlienCategories >= ALIENCATEGORY_MAX) { Com_Printf("CL_ParseAlienTeam: maximum number of alien team category reached (%i)\n", ALIENCATEGORY_MAX); return; } /* search for category with same name */ - for (i = 0; i < ccs.numAlienCategories; i++) - if (Q_streq(name, ccs.alienCategories[i].id)) + for (i = 0; i < ccs->numAlienCategories; i++) + if (Q_streq(name, ccs->alienCategories[i].id)) break; - if (i < ccs.numAlienCategories) { + if (i < ccs->numAlienCategories) { Com_Printf("CL_ParseAlienTeam: alien category def \"%s\" with same name found, second ignored\n", name); return; } - alienCategory = &ccs.alienCategories[ccs.numAlienCategories++]; + alienCategory = &ccs->alienCategories[ccs->numAlienCategories++]; Q_strncpyz(alienCategory->id, name, sizeof(alienCategory->id)); do { @@ -155,7 +155,7 @@ static void CL_ParseAlienTeam (const char *name, const char **text) group = &alienCategory->alienTeamGroups[alienCategory->numAlienTeamGroups]; group->idx = alienCategory->numAlienTeamGroups; - group->categoryIdx = alienCategory - ccs.alienCategories; + group->categoryIdx = alienCategory - ccs->alienCategories; alienCategory->numAlienTeamGroups++; do { @@ -224,7 +224,7 @@ static void CL_ParseResearchedCampaignItems (const campaign_t *campaign, const c if (!*text || *token == '}') return; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); assert(tech); if (Q_streq(token, tech->id)) { @@ -237,7 +237,7 @@ static void CL_ParseResearchedCampaignItems (const campaign_t *campaign, const c } } - if (i == ccs.numTechnologies) + if (i == ccs->numTechnologies) Com_Printf("CL_ParseResearchedCampaignItems: unknown token \"%s\" ignored (tech %s)\n", token, name); } while (*text); @@ -276,7 +276,7 @@ static void CL_ParseResearchableCampaignStates (const campaign_t *campaign, cons if (!*text || *token == '}') return; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); if (Q_streq(token, tech->id)) { if (researchable) { @@ -290,7 +290,7 @@ static void CL_ParseResearchableCampaignStates (const campaign_t *campaign, cons } } - if (i == ccs.numTechnologies) + if (i == ccs->numTechnologies) Com_Printf("CL_ParseResearchableCampaignStates: unknown token \"%s\" ignored (tech %s)\n", token, name); } while (*text); @@ -413,25 +413,25 @@ void CL_ParseCampaign (const char *name, const char **text) salary_t *s; /* search for campaigns with same name */ - for (i = 0; i < ccs.numCampaigns; i++) - if (Q_streq(name, ccs.campaigns[i].id)) + for (i = 0; i < ccs->numCampaigns; i++) + if (Q_streq(name, ccs->campaigns[i].id)) break; - if (i < ccs.numCampaigns) { + if (i < ccs->numCampaigns) { Com_Printf("CL_ParseCampaign: campaign def \"%s\" with same name found, second ignored\n", name); return; } - if (ccs.numCampaigns >= MAX_CAMPAIGNS) { + if (ccs->numCampaigns >= MAX_CAMPAIGNS) { Com_Printf("CL_ParseCampaign: Max campaigns reached (%i)\n", MAX_CAMPAIGNS); return; } /* initialize the campaign */ - cp = &ccs.campaigns[ccs.numCampaigns++]; + cp = &ccs->campaigns[ccs->numCampaigns++]; OBJZERO(*cp); - cp->idx = ccs.numCampaigns - 1; + cp->idx = ccs->numCampaigns - 1; Q_strncpyz(cp->id, name, sizeof(cp->id)); /* some default values */ @@ -443,7 +443,7 @@ void CL_ParseCampaign (const char *name, const char **text) if (!*text || *token != '{') { Com_Printf("CL_ParseCampaign: campaign def \"%s\" without body ignored\n", name); - ccs.numCampaigns--; + ccs->numCampaigns--; return; } @@ -525,14 +525,14 @@ static void CL_ParseComponents (const char *name, const char **text) Com_Printf("CL_ParseComponents: \"%s\" components def without body ignored.\n", name); return; } - if (ccs.numComponents >= MAX_ASSEMBLIES) { + if (ccs->numComponents >= MAX_ASSEMBLIES) { Com_Printf("CL_ParseComponents: too many technology entries. limit is %i.\n", MAX_ASSEMBLIES); return; } /* New components-entry (next free entry in global comp-list) */ - comp = &ccs.components[ccs.numComponents]; - ccs.numComponents++; + comp = &ccs->components[ccs->numComponents]; + ccs->numComponents++; OBJZERO(*comp); @@ -595,8 +595,8 @@ components_t *CL_GetComponentsByItem (const objDef_t *item) { int i; - for (i = 0; i < ccs.numComponents; i++) { - components_t *comp = &ccs.components[i]; + for (i = 0; i < ccs->numComponents; i++) { + components_t *comp = &ccs->components[i]; if (comp->assemblyItem == item) { Com_DPrintf(DEBUG_CLIENT, "CL_GetComponentsByItem: found components id: %s\n", comp->assemblyId); return comp; @@ -614,8 +614,8 @@ components_t *CL_GetComponentsByID (const char *id) { int i; - for (i = 0; i < ccs.numComponents; i++) { - components_t *comp = &ccs.components[i]; + for (i = 0; i < ccs->numComponents; i++) { + components_t *comp = &ccs->components[i]; if (Q_streq(comp->assemblyId, id)) { return comp; } @@ -812,23 +812,23 @@ void CL_ReadSinglePlayerData (void) if (!CHRSH_IsTeamDefAlien(teamDef)) continue; - ccs.teamDefTechs[teamDef->idx] = RS_GetTechByID(teamDef->tech); - if (ccs.teamDefTechs[teamDef->idx] == NULL) + ccs->teamDefTechs[teamDef->idx] = RS_GetTechByID(teamDef->tech); + if (ccs->teamDefTechs[teamDef->idx] == NULL) Com_Error(ERR_DROP, "Could not find a tech for teamdef %s", teamDef->id); } - for (i = 0, campaign = ccs.campaigns; i < ccs.numCampaigns; i++, campaign++) { + for (i = 0, campaign = ccs->campaigns; i < ccs->numCampaigns; i++, campaign++) { /* find the relevant markets */ campaign->marketDef = INV_GetEquipmentDefinitionByID(campaign->market); campaign->asymptoticMarketDef = INV_GetEquipmentDefinitionByID(campaign->asymptoticMarket); } - Com_Printf("Campaign data loaded - size "UFO_SIZE_T" bytes\n", sizeof(ccs)); - Com_Printf("...techs: %i\n", ccs.numTechnologies); - Com_Printf("...buildings: %i\n", ccs.numBuildingTemplates); - Com_Printf("...ranks: %i\n", ccs.numRanks); - Com_Printf("...nations: %i\n", ccs.numNations); - Com_Printf("...cities: %i\n", ccs.numCities); + Com_Printf("Campaign data loaded\n"); + Com_Printf("...techs: %i\n", ccs->numTechnologies); + Com_Printf("...buildings: %i\n", ccs->numBuildingTemplates); + Com_Printf("...ranks: %i\n", ccs->numRanks); + Com_Printf("...nations: %i\n", ccs->numNations); + Com_Printf("...cities: %i\n", ccs->numCities); Com_Printf("\n"); } diff --git a/src/client/campaign/cp_popup.c b/src/client/campaign/cp_popup.c index 7d4f34a..51ec733 100644 --- a/src/client/campaign/cp_popup.c +++ b/src/client/campaign/cp_popup.c @@ -416,7 +416,7 @@ void CL_DisplayPopupInterceptUFO (aircraft_t* ufo) else UI_RegisterText(TEXT_AIRCRAFT_LIST, _("No craft available, no pilot assigned, or no weapon or ammo equipped.")); - for (installationIdx = 0; installationIdx < ccs.numInstallations; installationIdx++) { + for (installationIdx = 0; installationIdx < ccs->numInstallations; installationIdx++) { const installation_t const *installation = INS_GetFoundedInstallationByIDX(installationIdx); if (!installation) continue; diff --git a/src/client/campaign/cp_produce.c b/src/client/campaign/cp_produce.c index 6bc22bf..4a4ddaa 100644 --- a/src/client/campaign/cp_produce.c +++ b/src/client/campaign/cp_produce.c @@ -561,11 +561,11 @@ static void PR_ProductionFrame (base_t* base, production_t *prod) prod->amount--; if (PR_IsItem(prod)) { - CL_UpdateCredits(ccs.credits - PR_GetPrice(prod->data.data.item)); + CL_UpdateCredits(ccs->credits - PR_GetPrice(prod->data.data.item)); /* Now add it to equipment and update capacity. */ B_UpdateStorageAndCapacity(base, prod->data.data.item, 1, qfalse, qfalse); } else if (PR_IsAircraft(prod)) { - CL_UpdateCredits(ccs.credits - PR_GetPrice(prod->data.data.aircraft)); + CL_UpdateCredits(ccs->credits - PR_GetPrice(prod->data.data.aircraft)); /* Now add new aircraft. */ AIR_NewAircraft(base, prod->data.data.aircraft); } diff --git a/src/client/campaign/cp_produce.h b/src/client/campaign/cp_produce.h index e3d426c..e1d5eb9 100644 --- a/src/client/campaign/cp_produce.h +++ b/src/client/campaign/cp_produce.h @@ -89,7 +89,7 @@ typedef struct production_s #define PRODUCE_DIVISOR 1 #define PR_GetPrice(item) ((item)->price * PRODUCE_FACTOR / PRODUCE_DIVISOR) -#define PR_HasInsufficientCredits(item) (PR_GetPrice(item) > ccs.credits) +#define PR_HasInsufficientCredits(item) (PR_GetPrice(item) > ccs->credits) /** * @brief A production queue. Lists all items to be produced. diff --git a/src/client/campaign/cp_produce_callbacks.c b/src/client/campaign/cp_produce_callbacks.c index 3832663..0a22c49 100644 --- a/src/client/campaign/cp_produce_callbacks.c +++ b/src/client/campaign/cp_produce_callbacks.c @@ -140,8 +140,8 @@ static void PR_UpdateProductionList (const base_t* base) LIST_AddString(&productionQueued, ""); } } else if (produceCategory == FILTER_AIRCRAFT) { - for (i = 0; i < ccs.numAircraftTemplates; i++) { - aircraft_t *aircraftTemplate = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + aircraft_t *aircraftTemplate = &ccs->aircraftTemplates[i]; /* don't allow producing ufos */ if (AIR_IsUFO(aircraftTemplate)) continue; diff --git a/src/client/campaign/cp_rank.c b/src/client/campaign/cp_rank.c index f00ce6b..b53213e 100644 --- a/src/client/campaign/cp_rank.c +++ b/src/client/campaign/cp_rank.c @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cp_campaign.h" /** - * @brief Get the index of the given rankID in ccs.ranks array + * @brief Get the index of the given rankID in ccs->ranks array * @param[in] rankID Script id of the rank * @return -1 if no rank with rankID found */ @@ -36,8 +36,8 @@ int CL_GetRankIdx (const char* rankID) { int i; - for (i = 0; i < ccs.numRanks; i++) { - if (Q_streq(ccs.ranks[i].id, rankID)) + for (i = 0; i < ccs->numRanks; i++) { + if (Q_streq(ccs->ranks[i].id, rankID)) return i; } @@ -46,16 +46,16 @@ int CL_GetRankIdx (const char* rankID) /** * @brief Returns a rank at an index - * @param[in] index Index of rank in ccs.ranks + * @param[in] index Index of rank in ccs->ranks * @return NULL on invalid index * @return pointer to the rank definition otherwise */ rank_t *CL_GetRankByIdx (const int index) { - if (index < 0 || index >= ccs.numRanks) + if (index < 0 || index >= ccs->numRanks) return NULL; - return &ccs.ranks[index]; + return &ccs->ranks[index]; } static const value_t rankValues[] = { @@ -89,20 +89,20 @@ void CL_ParseRanks (const char *name, const char **text) return; } - for (i = 0; i < ccs.numRanks; i++) { - if (Q_streq(name, ccs.ranks[i].name)) { + for (i = 0; i < ccs->numRanks; i++) { + if (Q_streq(name, ccs->ranks[i].name)) { Com_Printf("CL_ParseRanks: Rank with same name '%s' already loaded.\n", name); return; } } /* parse ranks */ - if (ccs.numRanks >= MAX_RANKS) { + if (ccs->numRanks >= MAX_RANKS) { Com_Printf("CL_ParseRanks: Too many rank descriptions, '%s' ignored.\n", name); - ccs.numRanks = MAX_RANKS; + ccs->numRanks = MAX_RANKS; return; } - rank = &ccs.ranks[ccs.numRanks++]; + rank = &ccs->ranks[ccs->numRanks++]; OBJZERO(*rank); rank->id = Mem_PoolStrDup(name, cp_campaignPool, 0); diff --git a/src/client/campaign/cp_research.c b/src/client/campaign/cp_research.c index 592a167..5f6a20a 100644 --- a/src/client/campaign/cp_research.c +++ b/src/client/campaign/cp_research.c @@ -76,10 +76,10 @@ void RS_ResearchFinish (technology_t* tech) Cmd_ExecuteString(tech->finishedResearchEvent); tech->statusResearch = RS_FINISH; - tech->researchedDate = ccs.date; + tech->researchedDate = ccs->date; if (!tech->statusResearchable) { tech->statusResearchable = qtrue; - tech->preResearchedDate = ccs.date; + tech->preResearchedDate = ccs->date; } RS_PushNewsWhenResearchedFinished(tech); @@ -141,7 +141,7 @@ void RS_MarkOneResearchable (technology_t* tech) /* only change the date if it wasn't set before */ if (tech->preResearchedDate.day == 0) { - tech->preResearchedDate = ccs.date; + tech->preResearchedDate = ccs->date; } } @@ -317,7 +317,7 @@ void RS_MarkCollected (technology_t* tech) /* only change the date if it wasn't set before */ if (tech->preResearchedDate.day == 0) { - tech->preResearchedDate = ccs.date; + tech->preResearchedDate = ccs->date; } tech->statusCollected = qtrue; @@ -336,12 +336,12 @@ void RS_MarkResearchable (qboolean init, const base_t* base) const base_t *thisBase = base; /* Set all entries to initial value. */ - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); tech->statusResearchable = qfalse; } - for (i = 0; i < ccs.numTechnologies; i++) { /* i = tech-index */ + for (i = 0; i < ccs->numTechnologies; i++) { /* i = tech-index */ technology_t *tech = RS_GetTechByIDX(i); if (!tech->statusResearchable) { /* In case we loopback we need to check for already marked techs. */ /* Check for collected items/aliens/etc... */ @@ -433,7 +433,7 @@ void RS_RequiredLinksAssign (void) technology_t *redirectedTech; int i; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); if (tech->requireAND.numLinks) RS_AssignTechLinks(&tech->requireAND); @@ -465,11 +465,11 @@ technology_t* RS_GetTechForItem (const objDef_t *item) { if (item == NULL) Com_Error(ERR_DROP, "RS_GetTechForItem: No item given"); - if (item->idx < 0 || item->idx > lengthof(ccs.objDefTechs)) + if (item->idx < 0 || item->idx > lengthof(ccs->objDefTechs)) Com_Error(ERR_DROP, "RS_GetTechForItem: Buffer overflow"); - if (ccs.objDefTechs[item->idx] == NULL) + if (ccs->objDefTechs[item->idx] == NULL) Com_Error(ERR_DROP, "RS_GetTechForItem: No technology for item %s", item->id); - return ccs.objDefTechs[item->idx]; + return ccs->objDefTechs[item->idx]; } /** @@ -491,12 +491,12 @@ void RS_InitTree (const campaign_t *campaign, qboolean load) /* Add links to technologies. */ for (i = 0, od = csi.ods; i < csi.numODs; i++, od++) { - ccs.objDefTechs[od->idx] = RS_GetTechByProvided(od->id); - if (!ccs.objDefTechs[od->idx]) + ccs->objDefTechs[od->idx] = RS_GetTechByProvided(od->id); + if (!ccs->objDefTechs[od->idx]) Com_Error(ERR_DROP, "RS_InitTree: Could not find a valid tech for item %s", od->id); } - for (i = 0, tech = ccs.technologies; i < ccs.numTechnologies; i++, tech++) { + for (i = 0, tech = ccs->technologies; i < ccs->numTechnologies; i++, tech++) { for (j = 0; j < tech->markResearched.numDefinitions; j++) { if (tech->markResearched.markOnly[j] && Q_streq(tech->markResearched.campaign[j], campaign->researched)) { Com_DPrintf(DEBUG_CLIENT, "...mark %s as researched\n", tech->id); @@ -551,8 +551,8 @@ void RS_InitTree (const campaign_t *campaign, qboolean load) break; case RS_BUILDING: found = qfalse; - for (j = 0; j < ccs.numBuildingTemplates; j++) { - building_t *building = &ccs.buildingTemplates[j]; + for (j = 0; j < ccs->numBuildingTemplates; j++) { + building_t *building = &ccs->buildingTemplates[j]; /* This building has been 'provided' -> get the correct data. */ if (Q_streq(tech->provides, building->id)) { found = qtrue; @@ -571,8 +571,8 @@ void RS_InitTree (const campaign_t *campaign, qboolean load) break; case RS_CRAFT: found = qfalse; - for (j = 0; j < ccs.numAircraftTemplates; j++) { - aircraft_t *aircraftTemplate = &ccs.aircraftTemplates[j]; + for (j = 0; j < ccs->numAircraftTemplates; j++) { + aircraft_t *aircraftTemplate = &ccs->aircraftTemplates[j]; /* This aircraft has been 'provided' -> get the correct data. */ if (!tech->provides) Com_Error(ERR_FATAL, "RS_InitTree: \"%s\" - No linked aircraft or craft-upgrade.\n", tech->id); @@ -798,7 +798,7 @@ int RS_ResearchRun (void) { int i, newResearch = 0; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); if (tech->statusResearch != RS_RUNNING) @@ -926,8 +926,8 @@ static void RS_TechnologyList_f (void) requirements_t *reqs; dateLong_t date; - Com_Printf("#techs: %i\n", ccs.numTechnologies); - for (i = 0; i < ccs.numTechnologies; i++) { + Com_Printf("#techs: %i\n", ccs->numTechnologies); + for (i = 0; i < ccs->numTechnologies; i++) { tech = RS_GetTechByIDX(i); Com_Printf("Tech: %s\n", tech->id); Com_Printf("... time -> %.2f\n", tech->time); @@ -986,7 +986,7 @@ static void RS_DebugMarkResearchedAll (void) { int i; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); Com_DPrintf(DEBUG_CLIENT, "...mark %s as researched\n", tech->id); RS_MarkOneResearchable(tech); @@ -1022,7 +1022,7 @@ static void RS_DebugResearchableAll_f (void) int i; if (Cmd_Argc() != 2) { - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); Com_Printf("...mark %s as researchable\n", tech->id); RS_MarkOneResearchable(tech); @@ -1042,7 +1042,7 @@ static void RS_DebugFinishResearches_f (void) { int i; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); if (tech->statusResearch == RS_RUNNING) { assert(tech->base); @@ -1134,14 +1134,14 @@ void RS_ParseTechnologies (const char *name, const char **text) descriptions_t *descTemp; int i; - for (i = 0; i < ccs.numTechnologies; i++) { - if (Q_streq(ccs.technologies[i].id, name)) { + for (i = 0; i < ccs->numTechnologies; i++) { + if (Q_streq(ccs->technologies[i].id, name)) { Com_Printf("RS_ParseTechnologies: Second tech with same name found (%s) - second ignored\n", name); return; } } - if (ccs.numTechnologies >= MAX_TECHNOLOGIES) { + if (ccs->numTechnologies >= MAX_TECHNOLOGIES) { Com_Printf("RS_ParseTechnologies: too many technology entries. limit is %i.\n", MAX_TECHNOLOGIES); return; } @@ -1154,15 +1154,15 @@ void RS_ParseTechnologies (const char *name, const char **text) } /* New technology (next free entry in global tech-list) */ - tech = &ccs.technologies[ccs.numTechnologies]; - ccs.numTechnologies++; + tech = &ccs->technologies[ccs->numTechnologies]; + ccs->numTechnologies++; OBJZERO(*tech); /* * Set standard values */ - tech->idx = ccs.numTechnologies - 1; + tech->idx = ccs->numTechnologies - 1; tech->id = Mem_PoolStrDup(name, cp_campaignPool, 0); hash = Com_HashKey(tech->id, TECH_HASH_SIZE); @@ -1402,26 +1402,26 @@ void RS_ParseTechnologies (const char *name, const char **text) if (*token) { /* find chapter */ - for (i = 0; i < ccs.numChapters; i++) { - if (Q_streq(token, ccs.upChapters[i].id)) { + for (i = 0; i < ccs->numChapters; i++) { + if (Q_streq(token, ccs->upChapters[i].id)) { /* add entry to chapter */ - tech->upChapter = &ccs.upChapters[i]; - if (!ccs.upChapters[i].first) { - ccs.upChapters[i].first = tech; - ccs.upChapters[i].last = tech; + tech->upChapter = &ccs->upChapters[i]; + if (!ccs->upChapters[i].first) { + ccs->upChapters[i].first = tech; + ccs->upChapters[i].last = tech; tech->upPrev = NULL; tech->upNext = NULL; } else { /* get "last entry" in chapter */ - technology_t *techOld = ccs.upChapters[i].last; - ccs.upChapters[i].last = tech; + technology_t *techOld = ccs->upChapters[i].last; + ccs->upChapters[i].last = tech; techOld->upNext = tech; - ccs.upChapters[i].last->upPrev = techOld; - ccs.upChapters[i].last->upNext = NULL; + ccs->upChapters[i].last->upPrev = techOld; + ccs->upChapters[i].last->upNext = NULL; } break; } - if (i == ccs.numChapters) + if (i == ccs->numChapters) Com_Printf("RS_ParseTechnologies: \"%s\" - chapter \"%s\" not found.\n", name, token); } } @@ -1533,7 +1533,7 @@ static inline qboolean RS_IsValidTechIndex (int techIdx) { if (techIdx == TECH_INVALID) return qfalse; - if (techIdx < 0 || techIdx >= ccs.numTechnologies) + if (techIdx < 0 || techIdx >= ccs->numTechnologies) return qfalse; if (techIdx >= MAX_TECHNOLOGIES) return qfalse; @@ -1552,7 +1552,7 @@ qboolean RS_IsResearched_idx (int techIdx) if (!RS_IsValidTechIndex(techIdx)) return qfalse; - if (ccs.technologies[techIdx].statusResearch == RS_FINISH) + if (ccs->technologies[techIdx].statusResearch == RS_FINISH) return qtrue; return qfalse; @@ -1572,8 +1572,8 @@ qboolean RS_IsResearched_ptr (const technology_t * tech) /** * @brief Returns the technology pointer for a tech index. - * You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices. - * @param[in] techIdx Index in the global ccs.technologies[] array. + * You can use this instead of "&ccs->technologies[techIdx]" to avoid having to check valid indices. + * @param[in] techIdx Index in the global ccs->technologies[] array. * @return technology_t pointer or NULL if an error occurred. */ technology_t* RS_GetTechByIDX (int techIdx) @@ -1581,7 +1581,7 @@ technology_t* RS_GetTechByIDX (int techIdx) if (!RS_IsValidTechIndex(techIdx)) return NULL; else - return &ccs.technologies[techIdx]; + return &ccs->technologies[techIdx]; } @@ -1649,7 +1649,7 @@ technology_t *RS_GetTechWithMostScientists (const struct base_s *base) tech = NULL; max = 0; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech_temp = RS_GetTechByIDX(i); if (tech_temp->statusResearch == RS_RUNNING && tech_temp->base == base) { if (tech_temp->scientists > max) { @@ -1690,8 +1690,8 @@ int RS_CountScientistsInBase (const base_t *base) { int i, counter = 0; - for (i = 0; i < ccs.numTechnologies; i++) { - const technology_t *tech = &ccs.technologies[i]; + for (i = 0; i < ccs->numTechnologies; i++) { + const technology_t *tech = &ccs->technologies[i]; if (tech->base == base) { /* Get a free lab from the base. */ counter += tech->scientists; @@ -1730,7 +1730,7 @@ qboolean RS_SaveXML (mxml_node_t *parent) Com_RegisterConstList(saveResearchConstants); node = mxml_AddNode(parent, SAVE_RESEARCH_RESEARCH); - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { int j; const technology_t *t = RS_GetTechByIDX(i); @@ -1854,7 +1854,7 @@ qboolean RS_ScriptSanityCheck (void) int i, error = 0; technology_t *t; - for (i = 0, t = ccs.technologies; i < ccs.numTechnologies; i++, t++) { + for (i = 0, t = ccs->technologies; i < ccs->numTechnologies; i++, t++) { if (!t->name) { error++; Com_Printf("...... technology '%s' has no name\n", t->id); diff --git a/src/client/campaign/cp_research_callbacks.c b/src/client/campaign/cp_research_callbacks.c index 0b4e02c..afd51ae 100644 --- a/src/client/campaign/cp_research_callbacks.c +++ b/src/client/campaign/cp_research_callbacks.c @@ -674,7 +674,7 @@ static void RS_InitGUIData (base_t* base) /* update tech of the base */ row = 0; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); /* Don't show technologies with time == 0 - those are NOT separate research topics. */ @@ -705,7 +705,7 @@ static void RS_InitGUIData (base_t* base) /* Items collected but not yet researchable. */ first = qtrue; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); /* Don't show technologies with time == 0 - those are NOT separate research topics. */ @@ -754,7 +754,7 @@ static void RS_InitGUIData (base_t* base) researchList2[row].base = b; row++; - for (i = 0; i < ccs.numTechnologies; i++) { + for (i = 0; i < ccs->numTechnologies; i++) { technology_t *tech = RS_GetTechByIDX(i); /* Don't show technologies with time == 0 - those are NOT separate research topics. */ diff --git a/src/client/campaign/cp_save.c b/src/client/campaign/cp_save.c index c4b0039..6db34f5 100644 --- a/src/client/campaign/cp_save.c +++ b/src/client/campaign/cp_save.c @@ -287,7 +287,7 @@ static qboolean SAV_GameSave (const char *filename, const char *comment, char ** mxml_AddString(node, SAVE_COMMENT, comment); mxml_AddString(node, SAVE_UFOVERSION, UFO_VERSION); mxml_AddString(node, SAVE_REALDATE, timeStampBuffer); - CL_DateConvertLong(&ccs.date, &date); + CL_DateConvertLong(&ccs->date, &date); Com_sprintf(message, sizeof(message), _("%i %s %02i"), date.year, Date_GetMonthName(date.month - 1), date.day); mxml_AddString(node, SAVE_GAMEDATE, message); @@ -306,7 +306,7 @@ static qboolean SAV_GameSave (const char *filename, const char *comment, char ** header.version = LittleLong(SAVE_FILE_VERSION); Q_strncpyz(header.name, comment, sizeof(header.name)); Q_strncpyz(header.gameVersion, UFO_VERSION, sizeof(header.gameVersion)); - CL_DateConvertLong(&ccs.date, &date); + CL_DateConvertLong(&ccs->date, &date); Com_sprintf(header.gameDate, sizeof(header.gameDate), _("%i %s %02i"), date.year, Date_GetMonthName(date.month - 1), date.day); Q_strncpyz(header.realDate, timeStampBuffer, sizeof(header.realDate)); diff --git a/src/client/campaign/cp_statistics.c b/src/client/campaign/cp_statistics.c index b164fa3..f2ce500 100644 --- a/src/client/campaign/cp_statistics.c +++ b/src/client/campaign/cp_statistics.c @@ -40,7 +40,7 @@ void CL_StatsUpdate_f (void) int hired[MAX_EMPL]; int i, costs = 0, sum = 0, totalfunds = 0; base_t *base; - const campaign_t *campaign = ccs.curCampaign; + const campaign_t *campaign = ccs->curCampaign; const salary_t *salary = &campaign->salaries; aircraft_t *aircraft; @@ -52,26 +52,26 @@ void CL_StatsUpdate_f (void) /* missions */ UI_RegisterText(TEXT_STATS_MISSION, pos); - Com_sprintf(pos, MAX_STATS_BUFFER, _("Won:\t%i\nLost:\t%i\n\n"), ccs.campaignStats.missionsWon, ccs.campaignStats.missionsLost); + Com_sprintf(pos, MAX_STATS_BUFFER, _("Won:\t%i\nLost:\t%i\n\n"), ccs->campaignStats.missionsWon, ccs->campaignStats.missionsLost); /* bases */ pos += (strlen(pos) + 1); UI_RegisterText(TEXT_STATS_BASES, pos); Com_sprintf(pos, (ptrdiff_t)(&statsBuffer[MAX_STATS_BUFFER] - pos), _("Built:\t%i\nActive:\t%i\nAttacked:\t%i\n"), - ccs.campaignStats.basesBuilt, B_GetCount(), ccs.campaignStats.basesAttacked), + ccs->campaignStats.basesBuilt, B_GetCount(), ccs->campaignStats.basesAttacked), /* installations */ pos += (strlen(pos) + 1); UI_RegisterText(TEXT_STATS_INSTALLATIONS, pos); - for (i = 0; i < ccs.numInstallations; i++) { - const installation_t *inst = &ccs.installations[i]; + for (i = 0; i < ccs->numInstallations; i++) { + const installation_t *inst = &ccs->installations[i]; Q_strcat(pos, va("%s\n", inst->name), (ptrdiff_t)(&statsBuffer[MAX_STATS_BUFFER] - pos)); } /* nations */ pos += (strlen(pos) + 1); UI_RegisterText(TEXT_STATS_NATIONS, pos); - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); Q_strcat(pos, va(_("%s\t%s\n"), _(nation->name), NAT_GetHappinessString(nation)), (ptrdiff_t)(&statsBuffer[MAX_STATS_BUFFER] - pos)); totalfunds += NAT_GetFunding(nation, 0); @@ -122,8 +122,8 @@ void CL_StatsUpdate_f (void) Q_strcat(pos, va(_("Administrative costs:\t%i c\n"), costs), (ptrdiff_t)(&statsBuffer[MAX_STATS_BUFFER] - pos)); sum += costs; - if (ccs.credits < 0) { - const float interest = ccs.credits * campaign->salaries.debtInterest; + if (ccs->credits < 0) { + const float interest = ccs->credits * campaign->salaries.debtInterest; costs = (int)ceil(interest); Q_strcat(pos, va(_("Debt:\t%i c\n"), costs), (ptrdiff_t)(&statsBuffer[MAX_STATS_BUFFER] - pos)); @@ -157,25 +157,25 @@ qboolean STATS_SaveXML (mxml_node_t *parent) stats = mxml_AddNode(parent, SAVE_STATS_STATS); - mxml_AddIntValue(stats, SAVE_STATS_MISSIONS, ccs.campaignStats.missions); - mxml_AddIntValue(stats, SAVE_STATS_MISSIONSWON, ccs.campaignStats.missionsWon); - mxml_AddIntValue(stats, SAVE_STATS_MISSIONSLOST, ccs.campaignStats.missionsLost); - mxml_AddIntValue(stats, SAVE_STATS_BASESBUILT, ccs.campaignStats.basesBuilt); - mxml_AddIntValue(stats, SAVE_STATS_BASESATTACKED, ccs.campaignStats.basesAttacked); - mxml_AddIntValue(stats, SAVE_STATS_INTERCEPTIONS, ccs.campaignStats.interceptions); - mxml_AddIntValue(stats, SAVE_STATS_SOLDIERSLOST, ccs.campaignStats.soldiersLost); - mxml_AddIntValue(stats, SAVE_STATS_SOLDIERSNEW, ccs.campaignStats.soldiersNew); - mxml_AddIntValue(stats, SAVE_STATS_KILLEDALIENS, ccs.campaignStats.killedAliens); - mxml_AddIntValue(stats, SAVE_STATS_RESCUEDCIVILIANS, ccs.campaignStats.rescuedCivilians); - mxml_AddIntValue(stats, SAVE_STATS_RESEARCHEDTECHNOLOGIES, ccs.campaignStats.researchedTechnologies); - mxml_AddIntValue(stats, SAVE_STATS_MONEYINTERCEPTIONS, ccs.campaignStats.moneyInterceptions); - mxml_AddIntValue(stats, SAVE_STATS_MONEYBASES, ccs.campaignStats.moneyBases); - mxml_AddIntValue(stats, SAVE_STATS_MONEYRESEARCH, ccs.campaignStats.moneyResearch); - mxml_AddIntValue(stats, SAVE_STATS_MONEYWEAPONS, ccs.campaignStats.moneyWeapons); - mxml_AddIntValue(stats, SAVE_STATS_UFOSDETECTED, ccs.campaignStats.ufosDetected); - mxml_AddIntValue(stats, SAVE_STATS_ALIENBASESBUILT, ccs.campaignStats.alienBasesBuilt); - mxml_AddIntValue(stats, SAVE_STATS_UFOSSTORED, ccs.campaignStats.ufosStored); - mxml_AddIntValue(stats, SAVE_STATS_AIRCRAFTHAD, ccs.campaignStats.aircraftHad); + mxml_AddIntValue(stats, SAVE_STATS_MISSIONS, ccs->campaignStats.missions); + mxml_AddIntValue(stats, SAVE_STATS_MISSIONSWON, ccs->campaignStats.missionsWon); + mxml_AddIntValue(stats, SAVE_STATS_MISSIONSLOST, ccs->campaignStats.missionsLost); + mxml_AddIntValue(stats, SAVE_STATS_BASESBUILT, ccs->campaignStats.basesBuilt); + mxml_AddIntValue(stats, SAVE_STATS_BASESATTACKED, ccs->campaignStats.basesAttacked); + mxml_AddIntValue(stats, SAVE_STATS_INTERCEPTIONS, ccs->campaignStats.interceptions); + mxml_AddIntValue(stats, SAVE_STATS_SOLDIERSLOST, ccs->campaignStats.soldiersLost); + mxml_AddIntValue(stats, SAVE_STATS_SOLDIERSNEW, ccs->campaignStats.soldiersNew); + mxml_AddIntValue(stats, SAVE_STATS_KILLEDALIENS, ccs->campaignStats.killedAliens); + mxml_AddIntValue(stats, SAVE_STATS_RESCUEDCIVILIANS, ccs->campaignStats.rescuedCivilians); + mxml_AddIntValue(stats, SAVE_STATS_RESEARCHEDTECHNOLOGIES, ccs->campaignStats.researchedTechnologies); + mxml_AddIntValue(stats, SAVE_STATS_MONEYINTERCEPTIONS, ccs->campaignStats.moneyInterceptions); + mxml_AddIntValue(stats, SAVE_STATS_MONEYBASES, ccs->campaignStats.moneyBases); + mxml_AddIntValue(stats, SAVE_STATS_MONEYRESEARCH, ccs->campaignStats.moneyResearch); + mxml_AddIntValue(stats, SAVE_STATS_MONEYWEAPONS, ccs->campaignStats.moneyWeapons); + mxml_AddIntValue(stats, SAVE_STATS_UFOSDETECTED, ccs->campaignStats.ufosDetected); + mxml_AddIntValue(stats, SAVE_STATS_ALIENBASESBUILT, ccs->campaignStats.alienBasesBuilt); + mxml_AddIntValue(stats, SAVE_STATS_UFOSSTORED, ccs->campaignStats.ufosStored); + mxml_AddIntValue(stats, SAVE_STATS_AIRCRAFTHAD, ccs->campaignStats.aircraftHad); return qtrue; } @@ -194,34 +194,34 @@ qboolean STATS_LoadXML (mxml_node_t *parent) Com_Printf("Did not find stats entry in xml!\n"); return qfalse; } - ccs.campaignStats.missions = mxml_GetInt(stats, SAVE_STATS_MISSIONS, 0); - ccs.campaignStats.missionsWon = mxml_GetInt(stats, SAVE_STATS_MISSIONSWON, 0); - ccs.campaignStats.missionsLost = mxml_GetInt(stats, SAVE_STATS_MISSIONSLOST, 0); - ccs.campaignStats.basesBuilt = mxml_GetInt(stats, SAVE_STATS_BASESBUILT, 0); - ccs.campaignStats.basesAttacked = mxml_GetInt(stats, SAVE_STATS_BASESATTACKED, 0); - ccs.campaignStats.interceptions = mxml_GetInt(stats, SAVE_STATS_INTERCEPTIONS, 0); - ccs.campaignStats.soldiersLost = mxml_GetInt(stats, SAVE_STATS_SOLDIERSLOST, 0); - ccs.campaignStats.soldiersNew = mxml_GetInt(stats, SAVE_STATS_SOLDIERSNEW, 0); - ccs.campaignStats.killedAliens = mxml_GetInt(stats, SAVE_STATS_KILLEDALIENS, 0); - ccs.campaignStats.rescuedCivilians = mxml_GetInt(stats, SAVE_STATS_RESCUEDCIVILIANS, 0); - ccs.campaignStats.researchedTechnologies = mxml_GetInt(stats, SAVE_STATS_RESEARCHEDTECHNOLOGIES, 0); - ccs.campaignStats.moneyInterceptions = mxml_GetInt(stats, SAVE_STATS_MONEYINTERCEPTIONS, 0); - ccs.campaignStats.moneyBases = mxml_GetInt(stats, SAVE_STATS_MONEYBASES, 0); - ccs.campaignStats.moneyResearch = mxml_GetInt(stats, SAVE_STATS_MONEYRESEARCH, 0); - ccs.campaignStats.moneyWeapons = mxml_GetInt(stats, SAVE_STATS_MONEYWEAPONS, 0); - ccs.campaignStats.ufosDetected = mxml_GetInt(stats, SAVE_STATS_UFOSDETECTED, 0); - ccs.campaignStats.alienBasesBuilt = mxml_GetInt(stats, SAVE_STATS_ALIENBASESBUILT, 0); + ccs->campaignStats.missions = mxml_GetInt(stats, SAVE_STATS_MISSIONS, 0); + ccs->campaignStats.missionsWon = mxml_GetInt(stats, SAVE_STATS_MISSIONSWON, 0); + ccs->campaignStats.missionsLost = mxml_GetInt(stats, SAVE_STATS_MISSIONSLOST, 0); + ccs->campaignStats.basesBuilt = mxml_GetInt(stats, SAVE_STATS_BASESBUILT, 0); + ccs->campaignStats.basesAttacked = mxml_GetInt(stats, SAVE_STATS_BASESATTACKED, 0); + ccs->campaignStats.interceptions = mxml_GetInt(stats, SAVE_STATS_INTERCEPTIONS, 0); + ccs->campaignStats.soldiersLost = mxml_GetInt(stats, SAVE_STATS_SOLDIERSLOST, 0); + ccs->campaignStats.soldiersNew = mxml_GetInt(stats, SAVE_STATS_SOLDIERSNEW, 0); + ccs->campaignStats.killedAliens = mxml_GetInt(stats, SAVE_STATS_KILLEDALIENS, 0); + ccs->campaignStats.rescuedCivilians = mxml_GetInt(stats, SAVE_STATS_RESCUEDCIVILIANS, 0); + ccs->campaignStats.researchedTechnologies = mxml_GetInt(stats, SAVE_STATS_RESEARCHEDTECHNOLOGIES, 0); + ccs->campaignStats.moneyInterceptions = mxml_GetInt(stats, SAVE_STATS_MONEYINTERCEPTIONS, 0); + ccs->campaignStats.moneyBases = mxml_GetInt(stats, SAVE_STATS_MONEYBASES, 0); + ccs->campaignStats.moneyResearch = mxml_GetInt(stats, SAVE_STATS_MONEYRESEARCH, 0); + ccs->campaignStats.moneyWeapons = mxml_GetInt(stats, SAVE_STATS_MONEYWEAPONS, 0); + ccs->campaignStats.ufosDetected = mxml_GetInt(stats, SAVE_STATS_UFOSDETECTED, 0); + ccs->campaignStats.alienBasesBuilt = mxml_GetInt(stats, SAVE_STATS_ALIENBASESBUILT, 0); /* fallback for savegame compatibility */ - if (ccs.campaignStats.alienBasesBuilt == 0) - ccs.campaignStats.alienBasesBuilt = AB_GetAlienBaseNumber(); - ccs.campaignStats.ufosStored = mxml_GetInt(stats, SAVE_STATS_UFOSSTORED, 0); + if (ccs->campaignStats.alienBasesBuilt == 0) + ccs->campaignStats.alienBasesBuilt = AB_GetAlienBaseNumber(); + ccs->campaignStats.ufosStored = mxml_GetInt(stats, SAVE_STATS_UFOSSTORED, 0); /* fallback for savegame compatibility */ - if (ccs.campaignStats.ufosStored == 0) - ccs.campaignStats.ufosStored = US_StoredUFOCount(); - ccs.campaignStats.aircraftHad = mxml_GetInt(stats, SAVE_STATS_AIRCRAFTHAD, 0); + if (ccs->campaignStats.ufosStored == 0) + ccs->campaignStats.ufosStored = US_StoredUFOCount(); + ccs->campaignStats.aircraftHad = mxml_GetInt(stats, SAVE_STATS_AIRCRAFTHAD, 0); /* fallback for savegame compatibility */ - if (ccs.campaignStats.aircraftHad == 0) - ccs.campaignStats.aircraftHad = LIST_Count(ccs.aircraft); + if (ccs->campaignStats.aircraftHad == 0) + ccs->campaignStats.aircraftHad = LIST_Count(ccs->aircraft); /* freeing the memory below this node */ mxmlDelete(stats); @@ -235,7 +235,7 @@ qboolean STATS_LoadXML (mxml_node_t *parent) */ static void CP_CampaignStats_f (void) { - campaign_t *campaign = ccs.curCampaign; + campaign_t *campaign = ccs->curCampaign; const salary_t *salary; if (!CP_IsRunning()) { diff --git a/src/client/campaign/cp_team_callbacks.c b/src/client/campaign/cp_team_callbacks.c index 6d82835..7072856 100644 --- a/src/client/campaign/cp_team_callbacks.c +++ b/src/client/campaign/cp_team_callbacks.c @@ -143,7 +143,7 @@ static qboolean CL_UpdateEmployeeList (employeeType_t employeeType, const char * * @brief Init the teamlist checkboxes * @sa CL_UpdateActorAircraftVar * @todo Make this function use a temporary list with all list-able employees - * instead of using ccs.employees[][] directly. See also CL_Select_f->SELECT_MODE_TEAM + * instead of using ccs->employees[][] directly. See also CL_Select_f->SELECT_MODE_TEAM */ static void CL_UpdateSoldierList_f (void) { @@ -167,7 +167,7 @@ static void CL_UpdateSoldierList_f (void) * @brief Init the teamlist checkboxes * @sa CL_UpdateActorAircraftVar * @todo Make this function use a temporary list with all list-able employees - * instead of using ccs.employees[][] directly. See also CL_Select_f->SELECT_MODE_TEAM + * instead of using ccs->employees[][] directly. See also CL_Select_f->SELECT_MODE_TEAM */ static void CL_UpdatePilotList_f (void) { diff --git a/src/client/campaign/cp_time.c b/src/client/campaign/cp_time.c index ac053de..dd47884 100644 --- a/src/client/campaign/cp_time.c +++ b/src/client/campaign/cp_time.c @@ -56,13 +56,13 @@ CASSERT(lengthof(lapse) == NUM_TIMELAPSE); void CL_UpdateTime (void) { dateLong_t date; - CL_DateConvertLong(&ccs.date, &date); + CL_DateConvertLong(&ccs->date, &date); /* Update the timelapse text */ - if (ccs.gameLapse >= 0 && ccs.gameLapse < NUM_TIMELAPSE) { - Cvar_Set("mn_timelapse", _(lapse[ccs.gameLapse].name)); - ccs.gameTimeScale = lapse[ccs.gameLapse].scale; - Cvar_SetValue("mn_timelapse_id", ccs.gameLapse); + if (ccs->gameLapse >= 0 && ccs->gameLapse < NUM_TIMELAPSE) { + Cvar_Set("mn_timelapse", _(lapse[ccs->gameLapse].name)); + ccs->gameTimeScale = lapse[ccs->gameLapse].scale; + Cvar_SetValue("mn_timelapse_id", ccs->gameLapse); } /* Update the date */ @@ -81,7 +81,7 @@ void CL_GameTimeStop (void) { /* don't allow time scale in tactical mode - only on the geoscape */ if (!cp_missiontest->integer && CP_OnGeoscape()) - ccs.gameLapse = 0; + ccs->gameLapse = 0; /* Make sure the new lapse state is updated and it (and the time) is show in the menu. */ CL_UpdateTime(); @@ -92,7 +92,7 @@ void CL_GameTimeStop (void) */ qboolean CL_IsTimeStopped (void) { - return !ccs.gameLapse; + return !ccs->gameLapse; } /** @@ -102,7 +102,7 @@ static qboolean CL_AllowTimeScale (void) { /* check the stats value - already build bases might have been destroyed * so the B_GetCount() values is pointless here */ - if (!ccs.campaignStats.basesBuilt) + if (!ccs->campaignStats.basesBuilt) return qfalse; return CP_OnGeoscape(); @@ -115,8 +115,8 @@ void CL_GameTimeSlow (void) { /* don't allow time scale in tactical mode - only on the geoscape */ if (CL_AllowTimeScale()) { - if (ccs.gameLapse > 0) - ccs.gameLapse--; + if (ccs->gameLapse > 0) + ccs->gameLapse--; /* Make sure the new lapse state is updated and it (and the time) is show in the menu. */ CL_UpdateTime(); } @@ -129,8 +129,8 @@ void CL_GameTimeFast (void) { /* don't allow time scale in tactical mode - only on the geoscape */ if (CL_AllowTimeScale()) { - if (ccs.gameLapse < NUM_TIMELAPSE) - ccs.gameLapse++; + if (ccs->gameLapse < NUM_TIMELAPSE) + ccs->gameLapse++; /* Make sure the new lapse state is updated and it (and the time) is show in the menu. */ CL_UpdateTime(); } @@ -142,18 +142,18 @@ void CL_GameTimeFast (void) */ static void CL_SetGameTime (int gameLapseValue) { - if (gameLapseValue == ccs.gameLapse) + if (gameLapseValue == ccs->gameLapse) return; /* check the stats value - already build bases might have been destroyed * so the B_GetCount() values is pointless here */ - if (!ccs.campaignStats.basesBuilt) + if (!ccs->campaignStats.basesBuilt) return; if (gameLapseValue < 0 || gameLapseValue >= NUM_TIMELAPSE) return; - ccs.gameLapse = gameLapseValue; + ccs->gameLapse = gameLapseValue; /* Make sure the new lapse state is updated and it (and the time) is show in the menu. */ CL_UpdateTime(); @@ -198,10 +198,10 @@ qboolean Date_LaterThan (const date_t *now, const date_t *compare) */ qboolean Date_IsDue (const date_t *date) { - if (date->day > ccs.date.day) + if (date->day > ccs->date.day) return qtrue; - else if (ccs.date.day == date->day && ccs.date.sec <= date->sec) + else if (ccs->date.day == date->day && ccs->date.sec <= date->sec) return qtrue; return qfalse; diff --git a/src/client/campaign/cp_transfer.c b/src/client/campaign/cp_transfer.c index a23ca82..cae4ceb 100644 --- a/src/client/campaign/cp_transfer.c +++ b/src/client/campaign/cp_transfer.c @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * @brief Unloads transfer cargo when finishing the transfer or destroys it when no buildings/base. * @param[in,out] destination The destination base - might be NULL in case the base * is already destroyed - * @param[in] transfer Pointer to transfer in ccs.transfers. + * @param[in] transfer Pointer to transfer in ccs->transfers. * @param[in] success True if the transfer reaches dest base, false if the base got destroyed. * @sa TR_TransferEnd */ @@ -113,7 +113,7 @@ static void TR_EmptyTransferCargo (base_t *destination, transfer_t *transfer, qb int i; qboolean capacityWarning = qfalse; - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { /* dead aliens */ if (transfer->alienAmount[i][TRANS_ALIEN_DEAD] > 0) { destination->alienscont[i].amountDead += transfer->alienAmount[i][TRANS_ALIEN_DEAD]; @@ -192,9 +192,9 @@ void TR_TransferAlienAfterMissionStart (const base_t *base, aircraft_t *transfer /* Initialize transfer. * calculate time to go from 1 base to another : 1 day for one quarter of the globe*/ time = GetDistanceOnGlobe(base->pos, transferAircraft->pos) / 90.0f; - transfer.event.day = ccs.date.day + floor(time); /* add day */ + transfer.event.day = ccs->date.day + floor(time); /* add day */ time = (time - floor(time)) * SECONDS_PER_DAY; /* convert remaining time in second */ - transfer.event.sec = ccs.date.sec + round(time); + transfer.event.sec = ccs->date.sec + round(time); /* check if event is not the following day */ if (transfer.event.sec > SECONDS_PER_DAY) { transfer.event.sec -= SECONDS_PER_DAY; @@ -211,7 +211,7 @@ void TR_TransferAlienAfterMissionStart (const base_t *base, aircraft_t *transfer cargo->amountAlive = 0; } if (cargo->amountAlive > 0) { - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { if (!CHRSH_IsTeamDefAlien(&csi.teamDef[j])) continue; if (base->alienscont[j].teamDef == cargo->teamDef) { @@ -223,7 +223,7 @@ void TR_TransferAlienAfterMissionStart (const base_t *base, aircraft_t *transfer } } if (cargo->amountDead > 0) { - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { if (!CHRSH_IsTeamDefAlien(&csi.teamDef[j])) continue; if (base->alienscont[j].teamDef == cargo->teamDef) { @@ -245,12 +245,12 @@ void TR_TransferAlienAfterMissionStart (const base_t *base, aircraft_t *transfer MSO_CheckAddNewMessage(NT_TRANSFER_ALIENBODIES_DEFERED, _("Transport mission"), message, qfalse, MSG_TRANSFERFINISHED, NULL); UI_PopWindow(qfalse); - LIST_Add(&ccs.transfers, (const byte*) &transfer, sizeof(transfer)); + LIST_Add(&ccs->transfers, (const byte*) &transfer, sizeof(transfer)); } /** * @brief Ends the transfer. - * @param[in] transfer Pointer to transfer in ccs.transfers + * @param[in] transfer Pointer to transfer in ccs->transfers */ static void TR_TransferEnd (transfer_t *transfer) { @@ -267,7 +267,7 @@ static void TR_TransferEnd (transfer_t *transfer) Com_sprintf(message, sizeof(message), _("Transport mission ended, unloading cargo in %s"), destination->name); MSO_CheckAddNewMessage(NT_TRANSFER_COMPLETED_SUCCESS, _("Transport mission"), message, qfalse, MSG_TRANSFERFINISHED, NULL); } - LIST_Remove(&ccs.transfers, transfer); + LIST_Remove(&ccs->transfers, transfer); } qboolean TR_AddData (transferData_t *transferData, transferCargoType_t type, const void* data) @@ -307,9 +307,9 @@ transfer_t* TR_TransferStart (base_t *srcBase, transferData_t *transData) /* Initialize transfer. */ /* calculate time to go from 1 base to another : 1 day for one quarter of the globe*/ time = GetDistanceOnGlobe(transData->transferBase->pos, srcBase->pos) / 90.0f; - transfer.event.day = ccs.date.day + floor(time); /* add day */ + transfer.event.day = ccs->date.day + floor(time); /* add day */ time = (time - floor(time)) * SECONDS_PER_DAY; /* convert remaining time in second */ - transfer.event.sec = ccs.date.sec + round(time); + transfer.event.sec = ccs->date.sec + round(time); /* check if event is not the following day */ if (transfer.event.sec > SECONDS_PER_DAY) { transfer.event.sec -= SECONDS_PER_DAY; @@ -340,7 +340,7 @@ transfer_t* TR_TransferStart (base_t *srcBase, transferData_t *transData) employee->transfer = qtrue; } } - for (i = 0; i < ccs.numAliensTD; i++) { /* Aliens. */ + for (i = 0; i < ccs->numAliensTD; i++) { /* Aliens. */ if (transData->trAliensTmp[i][TRANS_ALIEN_ALIVE] > 0) { transfer.hasAliens = qtrue; transfer.alienAmount[i][TRANS_ALIEN_ALIVE] = transData->trAliensTmp[i][TRANS_ALIEN_ALIVE]; @@ -362,7 +362,7 @@ transfer_t* TR_TransferStart (base_t *srcBase, transferData_t *transData) PR_ProductionAllowed(srcBase); RS_ResearchAllowed(srcBase); - return (transfer_t*) LIST_Add(&ccs.transfers, (const byte*) &transfer, sizeof(transfer))->data; + return (transfer_t*) LIST_Add(&ccs->transfers, (const byte*) &transfer, sizeof(transfer))->data; } /** @@ -414,7 +414,7 @@ static void TR_ListTransfers_f (void) if (Cmd_Argc() == 2) { transIdx = atoi(Cmd_Argv(1)); - if (transIdx < 0 || transIdx > LIST_Count(ccs.transfers)) { + if (transIdx < 0 || transIdx > LIST_Count(ccs->transfers)) { Com_Printf("Usage: %s [transferIDX]\nWithout parameter it lists all.\n", Cmd_Argv(0)); return; } @@ -537,11 +537,11 @@ qboolean TR_SaveXML (mxml_node_t *p) } /* save aliens */ if (transfer->hasAliens) { - for (j = 0; j < ccs.numAliensTD; j++) { + for (j = 0; j < ccs->numAliensTD; j++) { if (transfer->alienAmount[j][TRANS_ALIEN_ALIVE] > 0 || transfer->alienAmount[j][TRANS_ALIEN_DEAD] > 0) { - teamDef_t *team = ccs.alienTeams[j]; + teamDef_t *team = ccs->alienTeams[j]; mxml_node_t *ss = mxml_AddNode(s, SAVE_TRANSFER_ALIEN); assert(team); @@ -637,12 +637,12 @@ qboolean TR_LoadXML (mxml_node_t *p) int j; /* look for alien teamDef */ - for (j = 0; j < ccs.numAliensTD; j++) { - if (ccs.alienTeams[j] && Q_streq(id, ccs.alienTeams[j]->id)) + for (j = 0; j < ccs->numAliensTD; j++) { + if (ccs->alienTeams[j] && Q_streq(id, ccs->alienTeams[j]->id)) break; } - if (j < ccs.numAliensTD) { + if (j < ccs->numAliensTD) { transfer.alienAmount[j][TRANS_ALIEN_ALIVE] = alive; transfer.alienAmount[j][TRANS_ALIEN_DEAD] = dead; } else { @@ -679,7 +679,7 @@ qboolean TR_LoadXML (mxml_node_t *p) LIST_AddPointer(&transfer.aircraft, (void*)aircraft); } } - LIST_Add(&ccs.transfers, (const byte*) &transfer, sizeof(transfer)); + LIST_Add(&ccs->transfers, (const byte*) &transfer, sizeof(transfer)); } return qtrue; diff --git a/src/client/campaign/cp_transfer.h b/src/client/campaign/cp_transfer.h index fcd73aa..46f478b 100644 --- a/src/client/campaign/cp_transfer.h +++ b/src/client/campaign/cp_transfer.h @@ -44,7 +44,7 @@ enum { TRANS_ALIEN_MAX }; -/** @brief Transfer informations (they are being stored in ccs.transfers). */ +/** @brief Transfer informations (they are being stored in ccs->transfers). */ typedef struct transfer_s { base_t *destBase; /**< Pointer to destination base. May not be NULL if active is true. */ base_t *srcBase; /**< Pointer to source base. May be NULL if transfer comes from a mission (alien body recovery). */ @@ -116,7 +116,7 @@ typedef struct transferData_s { } transferData_t; #define TR_SetData(dataPtr, typeVal, ptr) do { (dataPtr)->data.pointer = (ptr); (dataPtr)->type = (typeVal); } while (0); -#define TR_Foreach(var) LIST_Foreach(ccs.transfers, transfer_t, var) +#define TR_Foreach(var) LIST_Foreach(ccs->transfers, transfer_t, var) #define TR_ForeachEmployee(var, transfer, employeeType) LIST_Foreach(transfer->employees[employeeType], employee_t, var) #define TR_ForeachAircraft(var, transfer) LIST_Foreach(transfer->aircraft, aircraft_t, var) diff --git a/src/client/campaign/cp_transfer_callbacks.c b/src/client/campaign/cp_transfer_callbacks.c index 514ea21..9e35def 100644 --- a/src/client/campaign/cp_transfer_callbacks.c +++ b/src/client/campaign/cp_transfer_callbacks.c @@ -329,7 +329,7 @@ static qboolean TR_CheckAlien (const base_t *destbase) assert(destbase); /* Count amount of live aliens already on the transfer list. */ - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (td.trAliensTmp[i][TRANS_ALIEN_ALIVE] > 0) intransfer += td.trAliensTmp[i][TRANS_ALIEN_ALIVE]; } @@ -471,7 +471,7 @@ static void TR_CargoList (void) } /* Show aliens. */ - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (td.trAliensTmp[i][TRANS_ALIEN_DEAD] > 0) { const teamDef_t* teamDef = AL_GetAlienTeamDef(i); Com_sprintf(str, sizeof(str), _("Corpse of %s"), _(teamDef->name)); @@ -480,7 +480,7 @@ static void TR_CargoList (void) TR_AddData(&td, CARGO_TYPE_ALIEN_DEAD, teamDef); } } - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (td.trAliensTmp[i][TRANS_ALIEN_ALIVE] > 0) { const teamDef_t* teamDef = AL_GetAlienTeamDef(i); LIST_AddString(&cargoList, _(teamDef->name)); @@ -642,7 +642,7 @@ static int TR_FillAliens (const base_t *srcbase, const base_t *destbase, linkedL if (B_GetBuildingStatus(destbase, B_ALIEN_CONTAINMENT)) { int i; - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { const aliensCont_t *alienCont = &srcbase->alienscont[i]; const teamDef_t *teamDef = alienCont->teamDef; if (teamDef == NULL) @@ -799,7 +799,7 @@ static void TR_TransferListClear_f (void) B_UpdateStorageAndCapacity(base, od, itemCargoAmount, qfalse, qfalse); } } - for (i = 0; i < ccs.numAliensTD; i++) { /* Return aliens. */ + for (i = 0; i < ccs->numAliensTD; i++) { /* Return aliens. */ const int alienCargoAmountAlive = td.trAliensTmp[i][TRANS_ALIEN_ALIVE]; const int alienCargoAmountDead = td.trAliensTmp[i][TRANS_ALIEN_DEAD]; if (alienCargoAmountAlive > 0) @@ -972,7 +972,7 @@ static void TR_AddAlienToTransferList (base_t *base, transferData_t *transferDat if (!B_GetBuildingStatus(transferBase, B_ALIEN_CONTAINMENT)) return; - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { aliensCont_t *aliensCont = &base->alienscont[i]; if (!aliensCont->teamDef) continue; @@ -1278,7 +1278,7 @@ static void TR_RemoveDeadAliensFromCargoList (base_t *base, transferData_t *tran } /* Start increasing cnt from the amount of previous entries. */ cnt = entries; - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (transferData->trAliensTmp[i][TRANS_ALIEN_DEAD] > 0) { if (cnt == num) { transferData->trAliensTmp[i][TRANS_ALIEN_DEAD]--; @@ -1308,7 +1308,7 @@ static void TR_RemoveAliveAliensFromCargoList (base_t *base, transferData_t *tra } /* Start increasing cnt from the amount of previous entries. */ cnt = entries; - for (i = 0; i < ccs.numAliensTD; i++) { + for (i = 0; i < ccs->numAliensTD; i++) { if (transferData->trAliensTmp[i][TRANS_ALIEN_ALIVE] > 0) { if (cnt == num) { transferData->trAliensTmp[i][TRANS_ALIEN_ALIVE]--; diff --git a/src/client/campaign/cp_ufo.c b/src/client/campaign/cp_ufo.c index af24c4b..a41a853 100644 --- a/src/client/campaign/cp_ufo.c +++ b/src/client/campaign/cp_ufo.c @@ -38,15 +38,15 @@ static const float MAX_DETECTING_RANGE = 25.0f; /**< range to detect and fire at */ aircraft_t* UFO_GetNext (aircraft_t *lastUFO) { - aircraft_t* endOfUFOs = &ccs.ufos[ccs.numUFOs]; + aircraft_t* endOfUFOs = &ccs->ufos[ccs->numUFOs]; aircraft_t* ufo; - if (!ccs.numUFOs) + if (!ccs->numUFOs) return NULL; if (!lastUFO) - return ccs.ufos; - assert(lastUFO >= ccs.ufos); + return ccs->ufos; + assert(lastUFO >= ccs->ufos); assert(lastUFO < endOfUFOs); ufo = lastUFO; @@ -83,7 +83,7 @@ aircraft_t *UFO_GetNextOnGeoscape (aircraft_t *lastUFO) aircraft_t* UFO_GetByIDX (const int idx) { assert(idx >= 0 && idx < MAX_UFOONGEOSCAPE); - return &ccs.ufos[idx]; + return &ccs->ufos[idx]; } /** @@ -108,8 +108,8 @@ const aircraft_t* UFO_GetByType (const ufoType_t type) { int i; - for (i = 0; i < ccs.numAircraftTemplates; i++) { - aircraft_t *ufo = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + aircraft_t *ufo = &ccs->aircraftTemplates[i]; if (ufo->ufotype == type) return ufo; } @@ -126,7 +126,7 @@ qboolean UFO_ShouldAppearOnGeoscape (const ufoType_t type) { const aircraft_t *ufo = UFO_GetByType(type); - return ufo->ufoInterestOnGeoscape <= ccs.overallInterest; + return ufo->ufoInterestOnGeoscape <= ccs->overallInterest; } /** @@ -164,11 +164,11 @@ const char* UFO_AircraftToIDOnGeoscape (const aircraft_t *ufocraft) */ const char* UFO_MissionResultToString (void) { - const char *ufoName = Com_UFOTypeToShortName(ccs.missionResults.ufotype); + const char *ufoName = Com_UFOTypeToShortName(ccs->missionResults.ufotype); const aircraft_t *aircraft = AIR_GetAircraft(ufoName); const char *geoscapeName = UFO_AircraftToIDOnGeoscape(aircraft); - if (ccs.missionResults.crashsite) - return va(_("\nSecured crashed %s (%.0f%%)\n"), geoscapeName, ccs.missionResults.ufoCondition * 100); + if (ccs->missionResults.crashsite) + return va(_("\nSecured crashed %s (%.0f%%)\n"), geoscapeName, ccs->missionResults.ufoCondition * 100); else return va(_("\nSecured landed %s\n"), geoscapeName); } @@ -515,7 +515,7 @@ void UFO_CampaignRunUFOs (const campaign_t* campaign, int deltaTime) int ufoIdx, k; /* now the ufos are flying around, too - cycle backward - ufo might be destroyed */ - for (ufoIdx = ccs.numUFOs - 1; ufoIdx >= 0; ufoIdx--) { + for (ufoIdx = ccs->numUFOs - 1; ufoIdx >= 0; ufoIdx--) { aircraft_t *ufo = UFO_GetByIDX(ufoIdx); /* don't run a landed ufo */ if (ufo->landed) @@ -539,7 +539,7 @@ void UFO_CampaignRunUFOs (const campaign_t* campaign, int deltaTime) /* UFO has been removed from game */ continue; /* UFO was destroyed (maybe because the mission was removed) */ - if (ufoIdx == ccs.numUFOs) + if (ufoIdx == ccs->numUFOs) continue; } @@ -566,9 +566,9 @@ void UFO_CampaignRunUFOs (const campaign_t* campaign, int deltaTime) static void UFO_DestroyUFOs_f (void) { aircraft_t* ufo; - campaign_t* campaign = ccs.curCampaign; + campaign_t* campaign = ccs->curCampaign; - for (ufo = ccs.ufos; ufo < ccs.ufos + ccs.numUFOs; ufo++) { + for (ufo = ccs->ufos; ufo < ccs->ufos + ccs->numUFOs; ufo++) { AIRFIGHT_ActionsAfterAirfight(campaign, NULL, ufo, qtrue); } } @@ -582,8 +582,8 @@ static void UFO_ListOnGeoscape_f (void) aircraft_t* ufo; int k; - Com_Printf("There are %i UFOs in game\n", ccs.numUFOs); - for (ufo = ccs.ufos; ufo < ccs.ufos + ccs.numUFOs; ufo++) { + Com_Printf("There are %i UFOs in game\n", ccs->numUFOs); + for (ufo = ccs->ufos; ufo < ccs->ufos + ccs->numUFOs; ufo++) { Com_Printf("..%s (%s) - status: %i - pos: %.0f:%0.f\n", ufo->name, ufo->id, ufo->status, ufo->pos[0], ufo->pos[1]); Com_Printf("...route length: %i (current: %i), time: %i, distance: %.2f, speed: %i\n", ufo->route.numPoints, ufo->point, ufo->time, ufo->route.distance, ufo->stats[AIR_STATS_SPEED]); @@ -615,17 +615,17 @@ static const aircraft_t* UFO_GetTemplateForGeoscape (ufoType_t ufoType) { int newUFONum; - for (newUFONum = 0; newUFONum < ccs.numAircraftTemplates; newUFONum++) { - const aircraft_t *tpl = &ccs.aircraftTemplates[newUFONum]; + for (newUFONum = 0; newUFONum < ccs->numAircraftTemplates; newUFONum++) { + const aircraft_t *tpl = &ccs->aircraftTemplates[newUFONum]; if (tpl->type == AIRCRAFT_UFO && ufoType == tpl->ufotype && !tpl->notOnGeoscape) break; } /* not found */ - if (newUFONum == ccs.numAircraftTemplates) + if (newUFONum == ccs->numAircraftTemplates) return NULL; - return &ccs.aircraftTemplates[newUFONum]; + return &ccs->aircraftTemplates[newUFONum]; } /** @@ -639,7 +639,7 @@ static aircraft_t* UFO_CreateFromTemplate (const aircraft_t *ufoTemplate) aircraft_t *ufo; /* check max amount */ - if (ccs.numUFOs >= MAX_UFOONGEOSCAPE) + if (ccs->numUFOs >= MAX_UFOONGEOSCAPE) return NULL; /* must be an ufo */ @@ -648,11 +648,11 @@ static aircraft_t* UFO_CreateFromTemplate (const aircraft_t *ufoTemplate) assert(!ufoTemplate->notOnGeoscape); /* get a new free slot */ - ufo = UFO_GetByIDX(ccs.numUFOs); + ufo = UFO_GetByIDX(ccs->numUFOs); /* copy the data */ *ufo = *ufoTemplate; /* assign an unique index */ - ufo->idx = ccs.numUFOs++; + ufo->idx = ccs->numUFOs++; return ufo; } @@ -712,11 +712,11 @@ aircraft_t *UFO_AddToGeoscape (ufoType_t ufoType, const vec2_t destination, miss void UFO_RemoveFromGeoscape (aircraft_t* ufo) { /* Remove ufo from ufos list */ - const ptrdiff_t num = (ptrdiff_t) (ufo - ccs.ufos); + const ptrdiff_t num = (ptrdiff_t) (ufo - ccs->ufos); Com_DPrintf(DEBUG_CLIENT, "Remove ufo from geoscape: '%s'\n", ufo->id); - REMOVE_ELEM_ADJUST_IDX(ccs.ufos, num, ccs.numUFOs); + REMOVE_ELEM_ADJUST_IDX(ccs->ufos, num, ccs->numUFOs); } #ifdef DEBUG @@ -725,8 +725,8 @@ void UFO_RemoveFromGeoscape (aircraft_t* ufo) */ static void UFO_RemoveFromGeoscape_f (void) { - if (ccs.numUFOs > 0) - UFO_RemoveFromGeoscape(ccs.ufos); + if (ccs->numUFOs > 0) + UFO_RemoveFromGeoscape(ccs->ufos); } #endif @@ -742,9 +742,9 @@ void UFO_DetectNewUFO (aircraft_t *ufocraft) /* Make this UFO detected */ ufocraft->detected = qtrue; if (!ufocraft->detectionIdx) { - ufocraft->detectionIdx = ++ccs.campaignStats.ufosDetected; + ufocraft->detectionIdx = ++ccs->campaignStats.ufosDetected; } - ufocraft->lastSpotted = ccs.date; + ufocraft->lastSpotted = ccs->date; /* If this is the first UFO on geoscape, activate radar */ if (!MAP_IsRadarOverlayActivated()) @@ -818,7 +818,7 @@ qboolean UFO_CampaignCheckEvents (void) } /* Check if UFO is detected by a radartower */ - for (installationIdx = 0; installationIdx < ccs.numInstallations; installationIdx++) { + for (installationIdx = 0; installationIdx < ccs->numInstallations; installationIdx++) { installation_t *installation = INS_GetFoundedInstallationByIDX(installationIdx); if (!installation) continue; @@ -876,7 +876,7 @@ void UFO_NotifyPhalanxAircraftRemoved (const aircraft_t * const aircraft) assert(aircraft); - for (ufoIdx = 0; ufoIdx < ccs.numUFOs; ufoIdx++) { + for (ufoIdx = 0; ufoIdx < ccs->numUFOs; ufoIdx++) { aircraft_t *ufo = UFO_GetByIDX(ufoIdx); if (ufo->aircraftTarget == aircraft) diff --git a/src/client/campaign/cp_ufo.h b/src/client/campaign/cp_ufo.h index 8538ef7..b1021ee 100644 --- a/src/client/campaign/cp_ufo.h +++ b/src/client/campaign/cp_ufo.h @@ -31,7 +31,7 @@ enum { UFO_IS_TARGET_OF_LASER }; -#define UFO_GetGeoscapeIDX(ufo) ((ufo) - ccs.ufos) +#define UFO_GetGeoscapeIDX(ufo) ((ufo) - ccs->ufos) const char* UFO_TypeToName(ufoType_t type); const technology_t* UFO_GetTechnologyFromType(const ufoType_t type); diff --git a/src/client/campaign/cp_ufopedia.c b/src/client/campaign/cp_ufopedia.c index d5a5c5f..8214324 100644 --- a/src/client/campaign/cp_ufopedia.c +++ b/src/client/campaign/cp_ufopedia.c @@ -406,7 +406,7 @@ void UP_UGVDescription (const ugv_t *ugvType) /** * @brief Sets the amount of unread/new mails - * @note This is called every campaign frame - to update ccs.numUnreadMails + * @note This is called every campaign frame - to update ccs->numUnreadMails * just set it to -1 before calling this function * @sa CL_CampaignRun */ @@ -414,34 +414,34 @@ int UP_GetUnreadMails (void) { const message_t *m = cp_messageStack; - if (ccs.numUnreadMails != -1) - return ccs.numUnreadMails; + if (ccs->numUnreadMails != -1) + return ccs->numUnreadMails; - ccs.numUnreadMails = 0; + ccs->numUnreadMails = 0; while (m) { switch (m->type) { case MSG_RESEARCH_PROPOSAL: assert(m->pedia); if (m->pedia->mail[TECHMAIL_PRE].from && !m->pedia->mail[TECHMAIL_PRE].read) - ccs.numUnreadMails++; + ccs->numUnreadMails++; break; case MSG_RESEARCH_FINISHED: assert(m->pedia); if (m->pedia->mail[TECHMAIL_RESEARCHED].from && RS_IsResearched_ptr(m->pedia) && !m->pedia->mail[TECHMAIL_RESEARCHED].read) - ccs.numUnreadMails++; + ccs->numUnreadMails++; break; case MSG_NEWS: assert(m->pedia); if (m->pedia->mail[TECHMAIL_PRE].from && !m->pedia->mail[TECHMAIL_PRE].read) - ccs.numUnreadMails++; + ccs->numUnreadMails++; if (m->pedia->mail[TECHMAIL_RESEARCHED].from && !m->pedia->mail[TECHMAIL_RESEARCHED].read) - ccs.numUnreadMails++; + ccs->numUnreadMails++; break; case MSG_EVENT: assert(m->eventMail); if (!m->eventMail->read) - ccs.numUnreadMails++; + ccs->numUnreadMails++; break; default: break; @@ -450,8 +450,8 @@ int UP_GetUnreadMails (void) } /* use strings here */ - Cvar_Set("mn_upunreadmail", va("%i", ccs.numUnreadMails)); - return ccs.numUnreadMails; + Cvar_Set("mn_upunreadmail", va("%i", ccs->numUnreadMails)); + return ccs->numUnreadMails; } /** @@ -480,7 +480,7 @@ static void UP_SetMailHeader (technology_t* tech, techMailType_t type, eventMail Q_strncpyz(dateBuf, _(mail->date), sizeof(dateBuf)); mail->read = qtrue; /* reread the unread mails in UP_GetUnreadMails */ - ccs.numUnreadMails = -1; + ccs->numUnreadMails = -1; } else { assert(tech); assert(type < TECHMAIL_MAX); @@ -512,7 +512,7 @@ static void UP_SetMailHeader (technology_t* tech, techMailType_t type, eventMail if (!tech->mail[type].read) { tech->mail[type].read = qtrue; /* reread the unread mails in UP_GetUnreadMails */ - ccs.numUnreadMails = -1; + ccs->numUnreadMails = -1; } /* only if mail and mail_pre are available */ if (tech->numTechMails == TECHMAIL_MAX) { @@ -799,11 +799,11 @@ static void UP_GenerateSummary (void) numChaptersDisplayList = 0; - for (i = 0; i < ccs.numChapters; i++) { + for (i = 0; i < ccs->numChapters; i++) { /* Check if there are any researched or collected items in this chapter ... */ uiNode_t *chapter; qboolean researchedEntries = qfalse; - upCurrentTech = ccs.upChapters[i].first; + upCurrentTech = ccs->upChapters[i].first; do { if (UP_TechGetsDisplayed(upCurrentTech)) { researchedEntries = qtrue; @@ -816,12 +816,12 @@ static void UP_GenerateSummary (void) if (researchedEntries) { if (numChaptersDisplayList >= MAX_PEDIACHAPTERS) Com_Error(ERR_DROP, "MAX_PEDIACHAPTERS hit"); - upChaptersDisplayList[numChaptersDisplayList++] = &ccs.upChapters[i]; + upChaptersDisplayList[numChaptersDisplayList++] = &ccs->upChapters[i]; /* chapter section*/ - chapter = UI_AddOption(&chapters, ccs.upChapters[i].id, va("_%s", ccs.upChapters[i].name), va("%i", num)); - OPTIONEXTRADATA(chapter).icon = UI_GetSpriteByName(va("icons/ufopedia_%s", ccs.upChapters[i].id)); - chapter->firstChild = UP_GenerateArticlesSummary(&ccs.upChapters[i]); + chapter = UI_AddOption(&chapters, ccs->upChapters[i].id, va("_%s", ccs->upChapters[i].name), va("%i", num)); + OPTIONEXTRADATA(chapter).icon = UI_GetSpriteByName(va("icons/ufopedia_%s", ccs->upChapters[i].id)); + chapter->firstChild = UP_GenerateArticlesSummary(&ccs->upChapters[i]); num++; } @@ -855,8 +855,8 @@ static void UP_Click_f (void) const int techId = atoi(Cmd_Argv(1) + 1); technology_t* tech; assert(techId >= 0); - assert(techId < ccs.numTechnologies); - tech = &ccs.technologies[techId]; + assert(techId < ccs->numTechnologies); + tech = &ccs->technologies[techId]; if (tech) UP_Article(tech, NULL); return; @@ -1208,8 +1208,8 @@ static void UP_SetAllMailsRead_f (void) m = m->next; } - ccs.numUnreadMails = 0; - Cvar_Set("mn_upunreadmail", va("%i", ccs.numUnreadMails)); + ccs->numUnreadMails = 0; + Cvar_Set("mn_upunreadmail", va("%i", ccs->numUnreadMails)); UP_OpenMail_f(); } @@ -1287,13 +1287,13 @@ void UP_ParseChapters (const char *name, const char **text) break; /* add chapter */ - if (ccs.numChapters >= MAX_PEDIACHAPTERS) { + if (ccs->numChapters >= MAX_PEDIACHAPTERS) { Com_Printf("UP_ParseChapters: too many chapter defs\n"); return; } - OBJZERO(ccs.upChapters[ccs.numChapters]); - ccs.upChapters[ccs.numChapters].id = Mem_PoolStrDup(token, cp_campaignPool, 0); - ccs.upChapters[ccs.numChapters].idx = ccs.numChapters; /* set self-link */ + OBJZERO(ccs->upChapters[ccs->numChapters]); + ccs->upChapters[ccs->numChapters].id = Mem_PoolStrDup(token, cp_campaignPool, 0); + ccs->upChapters[ccs->numChapters].idx = ccs->numChapters; /* set self-link */ /* get the name */ token = Com_EParse(text, errhead, name); @@ -1305,8 +1305,8 @@ void UP_ParseChapters (const char *name, const char **text) token++; if (!*token) continue; - ccs.upChapters[ccs.numChapters].name = Mem_PoolStrDup(token, cp_campaignPool, 0); + ccs->upChapters[ccs->numChapters].name = Mem_PoolStrDup(token, cp_campaignPool, 0); - ccs.numChapters++; + ccs->numChapters++; } while (*text); } diff --git a/src/client/campaign/cp_uforecovery.c b/src/client/campaign/cp_uforecovery.c index 0d8b72d..68d66d4 100644 --- a/src/client/campaign/cp_uforecovery.c +++ b/src/client/campaign/cp_uforecovery.c @@ -53,7 +53,7 @@ void UR_ProcessActive (void) if (ufo->status == SUFO_STORED) continue; - if (Date_LaterThan(&ufo->arrive, &ccs.date)) + if (Date_LaterThan(&ufo->arrive, &ccs->date)) continue; ufo->status = SUFO_STORED; @@ -112,7 +112,7 @@ storedUFO_t *US_StoreUFO (const aircraft_t *ufoTemplate, installation_t *install } /* we can store it there */ - ufo.idx = ccs.campaignStats.ufosStored++; + ufo.idx = ccs->campaignStats.ufosStored++; Q_strncpyz(ufo.id, ufoTemplate->id, sizeof(ufo.id)); ufo.comp = CL_GetComponentsByID(ufo.id); assert(ufo.comp); @@ -126,7 +126,7 @@ storedUFO_t *US_StoreUFO (const aircraft_t *ufoTemplate, installation_t *install ufo.disassembly = NULL; ufo.arrive = date; - if (Date_LaterThan(&ccs.date, &ufo.arrive)) { + if (Date_LaterThan(&ccs->date, &ufo.arrive)) { ufo.status = SUFO_STORED; RS_MarkCollected(ufo.ufoTemplate->tech); } else { @@ -134,7 +134,7 @@ storedUFO_t *US_StoreUFO (const aircraft_t *ufoTemplate, installation_t *install } ufo.condition = min(max(0, condition), 1); - return (storedUFO_t *)(LIST_Add(&ccs.storedUFOs, (const byte *)&ufo, sizeof(ufo)))->data; + return (storedUFO_t *)(LIST_Add(&ccs->storedUFOs, (const byte *)&ufo, sizeof(ufo)))->data; } /** @@ -168,7 +168,7 @@ void US_RemoveStoredUFO (storedUFO_t *ufo) /* remove ufo */ ufo->installation->ufoCapacity.cur--; - LIST_Remove(&ccs.storedUFOs, (void*)ufo); + LIST_Remove(&ccs->storedUFOs, (void*)ufo); } @@ -262,7 +262,7 @@ storedUFO_t *US_GetClosestStoredUFO (const aircraft_t *ufoTemplate, const base_t */ int US_StoredUFOCount (void) { - return LIST_Count(ccs.storedUFOs); + return LIST_Count(ccs->storedUFOs); } /** @@ -354,7 +354,7 @@ qboolean US_LoadXML (mxml_node_t *p) ufo.condition = mxml_GetFloat(snode, SAVE_UFORECOVERY_CONDITION, 1.0f); /* disassembly is set by production savesystem later but only for UFOs that are being disassembled */ ufo.disassembly = NULL; - LIST_Add(&ccs.storedUFOs, (const byte *)&ufo, sizeof(ufo)); + LIST_Add(&ccs->storedUFOs, (const byte *)&ufo, sizeof(ufo)); } Com_UnregisterConstList(saveStoredUFOConstants); return qtrue; @@ -418,9 +418,9 @@ static void US_StoreUFO_f (void) } /* Get UFO Type */ - for (i = 0; i < ccs.numAircraftTemplates; i++) { - if (strstr(ccs.aircraftTemplates[i].id, ufoId)) { - ufoType = &ccs.aircraftTemplates[i]; + for (i = 0; i < ccs->numAircraftTemplates; i++) { + if (strstr(ccs->aircraftTemplates[i].id, ufoId)) { + ufoType = &ccs->aircraftTemplates[i]; break; } } @@ -429,7 +429,7 @@ static void US_StoreUFO_f (void) return; } - US_StoreUFO(ufoType, installation, ccs.date, 1.0f); + US_StoreUFO(ufoType, installation, ccs->date, 1.0f); } /** @@ -471,7 +471,7 @@ void UR_InitStartup (void) */ void UR_Shutdown (void) { - LIST_Delete(&ccs.storedUFOs); + LIST_Delete(&ccs->storedUFOs); UR_ShutdownCallbacks(); #ifdef DEBUG diff --git a/src/client/campaign/cp_uforecovery.h b/src/client/campaign/cp_uforecovery.h index c34619d..d70aa33 100644 --- a/src/client/campaign/cp_uforecovery.h +++ b/src/client/campaign/cp_uforecovery.h @@ -63,7 +63,7 @@ typedef struct storedUFO_s { void UR_ProcessActive(void); -#define US_Foreach(var) LIST_Foreach(ccs.storedUFOs, storedUFO_t, var) +#define US_Foreach(var) LIST_Foreach(ccs->storedUFOs, storedUFO_t, var) storedUFO_t *US_StoreUFO(const aircraft_t *ufoTemplate, installation_t *installation, date_t date, float condition); storedUFO_t *US_GetStoredUFOByIDX(const int idx); diff --git a/src/client/campaign/cp_uforecovery_callbacks.c b/src/client/campaign/cp_uforecovery_callbacks.c index af53a8a..65b13b2 100644 --- a/src/client/campaign/cp_uforecovery_callbacks.c +++ b/src/client/campaign/cp_uforecovery_callbacks.c @@ -108,10 +108,10 @@ static void UR_DialogInit_f (void) ufoCraft = AIR_GetAircraft(ufoID); /* Put relevant info into missionResults array. */ - ccs.missionResults.recovery = qtrue; - ccs.missionResults.ufoCondition = cond; - ccs.missionResults.crashsite = (cond < 1); - ccs.missionResults.ufotype = ufoCraft->ufotype; + ccs->missionResults.recovery = qtrue; + ccs->missionResults.ufoCondition = cond; + ccs->missionResults.crashsite = (cond < 1); + ccs->missionResults.ufotype = ufoCraft->ufotype; /* Prepare related cvars. */ Cvar_SetValue("mission_uforecovered", 1); /* This is used in menus to enable UFO Recovery nodes. */ /* Fill ufoRecovery structure */ @@ -141,7 +141,7 @@ static void UR_DialogInitStore_f (void) return; /* Check how many bases can store this UFO. */ - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { const installation_t *installation = INS_GetFoundedInstallationByIDX(i); const capacities_t *capacity; @@ -190,7 +190,7 @@ static void UR_DialogStartStore_f (void) idx = atoi(Cmd_Argv(1)); - for (i = 0; i < ccs.numInstallations; i++) { + for (i = 0; i < ccs->numInstallations; i++) { installation_t *installation = INS_GetFoundedInstallationByIDX(i); if (!installation) @@ -213,7 +213,7 @@ static void UR_DialogStartStore_f (void) Com_sprintf(cp_messageBuffer, lengthof(cp_messageBuffer), _("Recovered %s from the battlefield. UFO is being transported to %s."), UFO_TypeToName(ufoRecovery.ufoTemplate->ufotype), UFOYard->name); MS_AddNewMessage(_("UFO Recovery"), cp_messageBuffer, qfalse, MSG_STANDARD, NULL); - date = ccs.date; + date = ccs->date; date.day += (int) RECOVERY_DELAY; US_StoreUFO(ufoRecovery.ufoTemplate, UFOYard, date, ufoRecovery.condition); @@ -228,7 +228,7 @@ static void UR_DialogFillNations (void) int i; linkedList_t *nationList = NULL; - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = ufoRecovery.UFONations[i].nation; if (nation) { char row[512]; @@ -304,11 +304,11 @@ static void UR_SortNations (COMP_FUNCTION comp, qboolean order) { int i; - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { qboolean swapped = qfalse; int j; - for (j = 0; j < ccs.numNations - 1; j++) { + for (j = 0; j < ccs->numNations - 1; j++) { int value = (*comp)(&ufoRecovery.UFONations[j], &ufoRecovery.UFONations[j + 1]); ufoRecoveryNation_t tmp; @@ -361,7 +361,7 @@ static void UR_DialogInitSell_f (void) if (!ufoRecovery.ufoTemplate) return; - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); int price; @@ -385,7 +385,7 @@ static int UR_DialogGetCurrentNationIndex (void) { int i; - for (i = 0; i < ccs.numNations; i++) + for (i = 0; i < ccs->numNations; i++) if (ufoRecovery.UFONations[i].nation == ufoRecovery.nation) return i; return -1; @@ -462,7 +462,7 @@ static void UR_DialogSelectSellNation_f (void) num = atoi(Cmd_Argv(1)); /* don't do anything if index is higher than visible nations */ - if (0 > num || num >= ccs.numNations) + if (0 > num || num >= ccs->numNations) return; nation = ufoRecovery.UFONations[num].nation; @@ -504,10 +504,10 @@ static void UR_DialogStartSell_f (void) ufoRecovery.ufoTemplate->ufotype), _(nation->name), price); } MS_AddNewMessage(_("UFO Recovery"), cp_messageBuffer, qfalse, MSG_STANDARD, NULL); - CL_UpdateCredits(ccs.credits + price); + CL_UpdateCredits(ccs->credits + price); /* update nation happiness */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { nation_t *nat = NAT_GetNationByIDX(i); float ufoHappiness; @@ -519,7 +519,7 @@ static void UR_DialogStartSell_f (void) /* nation is unhappy because it wanted the UFO */ ufoHappiness = HAPPINESS_UFO_SALE_LOSS; - NAT_SetHappiness(ccs.curCampaign->minhappiness, nat, nat->stats[0].happiness + ufoHappiness); + NAT_SetHappiness(ccs->curCampaign->minhappiness, nat, nat->stats[0].happiness + ufoHappiness); } /* UFO recovery process is done, disable buttons. */ diff --git a/src/client/campaign/cp_xvi.c b/src/client/campaign/cp_xvi.c index 89921b2..593c5b3 100644 --- a/src/client/campaign/cp_xvi.c +++ b/src/client/campaign/cp_xvi.c @@ -72,7 +72,7 @@ void CP_ReduceXVIEverywhere (void) return; /* Only decrease XVI if given days has passed */ - if (ccs.date.day % XVI_DECREASE_DAYS) + if (ccs->date.day % XVI_DECREASE_DAYS) return; CP_DecreaseXVILevelEverywhere(); @@ -111,7 +111,7 @@ void CP_UpdateNationXVIInfection (void) return; /* Initialize array */ - for (nationIdx = 0; nationIdx < ccs.numNations; nationIdx++) + for (nationIdx = 0; nationIdx < ccs->numNations; nationIdx++) xviInfection[nationIdx] = 0; CP_GetXVIMapDimensions(&width, &height); @@ -147,12 +147,12 @@ void CP_UpdateNationXVIInfection (void) } /* divide the total XVI infection by the area of a pixel * because pixel are smaller as you go closer from the pole */ - for (nationIdx = 0; nationIdx < ccs.numNations; nationIdx++) + for (nationIdx = 0; nationIdx < ccs->numNations; nationIdx++) xviInfection[nationIdx] += ((float) sum[nationIdx]) / (cos(torad * currentPos[1]) * normalizingArea); } /* copy the new values of XVI infection level into nation array */ - for (nationIdx = 0; nationIdx < ccs.numNations; nationIdx++) { + for (nationIdx = 0; nationIdx < ccs->numNations; nationIdx++) { nation_t* nation = NAT_GetNationByIDX(nationIdx); nation->stats[0].xviInfection = ceil(xviInfection[nation->idx]); } @@ -169,15 +169,15 @@ int CP_GetAverageXVIRate (void) int XVIRate = 0; int i; - assert(ccs.numNations); + assert(ccs->numNations); /* check for XVI infection rate */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); XVIRate += stats->xviInfection; } - XVIRate /= ccs.numNations; + XVIRate /= ccs->numNations; return XVIRate; } @@ -292,13 +292,13 @@ qboolean XVI_LoadXML (mxml_node_t *p) void CP_StartXVISpreading_f (void) { int i, numAlienBases; - const campaign_t *campaign = ccs.curCampaign; + const campaign_t *campaign = ccs->curCampaign; - /** @todo ccs.XVIShowMap should not be enabled at the same time than - * CP_IsXVIResearched(): ccs.XVIShowMap means that PHALANX has a map of + /** @todo ccs->XVIShowMap should not be enabled at the same time than + * CP_IsXVIResearched(): ccs->XVIShowMap means that PHALANX has a map of * XVI, whereas CP_IsXVIResearched() means that aliens started * spreading XVI */ - ccs.XVIShowMap = qtrue; + ccs->XVIShowMap = qtrue; /* Spawn a few alien bases depending on difficulty level */ if (campaign->difficulty > 0) @@ -317,5 +317,5 @@ void CP_StartXVISpreading_f (void) */ void CP_UpdateXVIMapButton (void) { - Cvar_SetValue("mn_xvimap", ccs.XVIShowMap); + Cvar_SetValue("mn_xvimap", ccs->XVIShowMap); } diff --git a/src/client/campaign/missions/cp_mission_baseattack.c b/src/client/campaign/missions/cp_mission_baseattack.c index 10990f4..2d8307b 100644 --- a/src/client/campaign/missions/cp_mission_baseattack.c +++ b/src/client/campaign/missions/cp_mission_baseattack.c @@ -64,7 +64,7 @@ void CP_BaseAttackMissionIsFailure (mission_t *mission) if (base) base->baseStatus = BASE_WORKING; - ccs.mapAction = MA_NONE; + ccs->mapAction = MA_NONE; /* we really don't want to use the fake aircraft anywhere */ if (base) @@ -104,7 +104,7 @@ void CP_BaseAttackMissionLeave (mission_t *mission) mission->ufo->landed = qfalse; } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } @@ -166,7 +166,7 @@ void CP_BaseAttackStartMission (mission_t *mission) } base->baseStatus = BASE_UNDER_ATTACK; - ccs.campaignStats.basesAttacked++; + ccs->campaignStats.basesAttacked++; #if 0 /** @todo implement onattack: add it to basemanagement.ufo and implement functions */ @@ -177,7 +177,7 @@ void CP_BaseAttackStartMission (mission_t *mission) MAP_SelectMission(mission); mission->active = qtrue; - ccs.mapAction = MA_BASEATTACK; + ccs->mapAction = MA_BASEATTACK; Com_DPrintf(DEBUG_CLIENT, "Base attack: %s at %.0f:%.0f\n", mission->id, mission->pos[0], mission->pos[1]); /** @todo EMPL_ROBOT */ @@ -316,7 +316,7 @@ static void CP_BaseAttackGoToBase (mission_t *mission) UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } diff --git a/src/client/campaign/missions/cp_mission_buildbase.c b/src/client/campaign/missions/cp_mission_buildbase.c index 256b399..d9d5734 100644 --- a/src/client/campaign/missions/cp_mission_buildbase.c +++ b/src/client/campaign/missions/cp_mission_buildbase.c @@ -141,7 +141,7 @@ static void CP_BuildBaseSetUpBase (mission_t *mission) mission->stage = STAGE_BUILD_BASE; - mission->finalDate = Date_Add(ccs.date, Date_Random(minBuildingTime, buildingTime)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minBuildingTime, buildingTime)); base = AB_BuildBase(mission->pos); if (!base) { @@ -215,7 +215,7 @@ static void CP_BuildBaseSubvertGovernment (mission_t *mission) /* mission appear on geoscape, player can go there */ CP_MissionAddToGeoscape(mission, qfalse); - mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minMissionDelay, missionDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/ CP_UFORemoveFromGeoscape(mission, qfalse); } diff --git a/src/client/campaign/missions/cp_mission_harvest.c b/src/client/campaign/missions/cp_mission_harvest.c index 0695f5f..455cd31 100644 --- a/src/client/campaign/missions/cp_mission_harvest.c +++ b/src/client/campaign/missions/cp_mission_harvest.c @@ -75,12 +75,12 @@ static void CP_HarvestMissionStart (mission_t *mission) CP_MissionAddToGeoscape(mission, qfalse); if (mission->ufo) { - mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minMissionDelay, missionDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/ CP_UFORemoveFromGeoscape(mission, qfalse); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } @@ -103,7 +103,7 @@ static qboolean CP_ChooseNation (const mission_t *mission, linkedList_t **nation return qfalse; /* favour mission with higher XVI level */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); max += OFFSET + stats->xviInfection; @@ -112,7 +112,7 @@ static qboolean CP_ChooseNation (const mission_t *mission, linkedList_t **nation randomNumber = (int) (frand() * (float) max); /* Select the corresponding nation */ - for (i = 0; i < ccs.numNations; i++) { + for (i = 0; i < ccs->numNations; i++) { const nation_t *nation = NAT_GetNationByIDX(i); const nationInfo_t *stats = NAT_GetCurrentMonthInfo(nation); randomNumber -= OFFSET + stats->xviInfection; @@ -175,7 +175,7 @@ void CP_HarvestMissionGo (mission_t *mission) UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } diff --git a/src/client/campaign/missions/cp_mission_intercept.c b/src/client/campaign/missions/cp_mission_intercept.c index 029ea67..3e6121a 100644 --- a/src/client/campaign/missions/cp_mission_intercept.c +++ b/src/client/campaign/missions/cp_mission_intercept.c @@ -110,7 +110,7 @@ static void CP_InterceptAttackInstallation (mission_t *mission) /* Check that installation is not already destroyed */ installation = mission->data.installation; if (!installation->founded) { - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; return; } @@ -118,13 +118,13 @@ static void CP_InterceptAttackInstallation (mission_t *mission) installation = mission->data.installation; Vector2Copy(mission->pos, missionPos); if (!VectorCompareEps(missionPos, installation->pos, UFO_EPSILON)) { - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; return; } /* Make round around the position of the mission */ UFO_SetRandomDestAround(mission->ufo, mission->pos); - mission->finalDate = Date_Add(ccs.date, Date_Random(minAttackDelay, attackDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minAttackDelay, attackDelay)); } /** @@ -137,7 +137,7 @@ void CP_InterceptAircraftMissionSet (mission_t *mission) const date_t reconDelay = {6, 0}; /* How long the UFO should stay on earth */ mission->stage = STAGE_INTERCEPT; - mission->finalDate = Date_Add(ccs.date, Date_Random(minReconDelay, reconDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minReconDelay, reconDelay)); } /** @@ -213,7 +213,7 @@ static void CP_InterceptMissionSet (mission_t *mission) assert(mission->ufo); /* Only harvesters can attack installations -- if there are installations to attack */ - if (mission->ufo->ufotype == UFO_HARVESTER && ccs.numInstallations) { + if (mission->ufo->ufotype == UFO_HARVESTER && ccs->numInstallations) { CP_InterceptGoToInstallation(mission); } @@ -269,7 +269,7 @@ void CP_InterceptNextStage (mission_t *mission) AIRFIGHT_WEAPON_CAN_NEVER_SHOOT && mission->ufo->status == AIR_UFO && !mission->data.installation) { /* UFO is fighting and has still ammo, wait a little bit before leaving (UFO is not attacking an installation) */ const date_t AdditionalDelay = {0, 3600}; /* check every hour if there is still ammos */ - mission->finalDate = Date_Add(ccs.date, AdditionalDelay); + mission->finalDate = Date_Add(ccs->date, AdditionalDelay); } else CP_InterceptMissionLeave(mission, qtrue); break; diff --git a/src/client/campaign/missions/cp_mission_recon.c b/src/client/campaign/missions/cp_mission_recon.c index e94350b..1401c43 100644 --- a/src/client/campaign/missions/cp_mission_recon.c +++ b/src/client/campaign/missions/cp_mission_recon.c @@ -77,7 +77,7 @@ void CP_ReconMissionLeave (mission_t *mission) mission->ufo->landed = qfalse; } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } CP_MissionRemoveFromGeoscape(mission); } @@ -111,7 +111,7 @@ void CP_ReconMissionAerial (mission_t *mission) mission->stage = STAGE_RECON_AIR; - mission->finalDate = Date_Add(ccs.date, Date_Random(minReconDelay, reconDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minReconDelay, reconDelay)); } /** @@ -166,7 +166,7 @@ void CP_ReconMissionGroundGo (mission_t *mission) UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } @@ -182,7 +182,7 @@ static void CP_ReconMissionGround (mission_t *mission) mission->stage = STAGE_RECON_GROUND; mission->posAssigned = qtrue; - mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minMissionDelay, missionDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/ if (mission->ufo) CP_UFORemoveFromGeoscape(mission, qfalse); diff --git a/src/client/campaign/missions/cp_mission_rescue.c b/src/client/campaign/missions/cp_mission_rescue.c index 0c512a4..96c4b58 100644 --- a/src/client/campaign/missions/cp_mission_rescue.c +++ b/src/client/campaign/missions/cp_mission_rescue.c @@ -43,7 +43,7 @@ static void CP_BeginRescueMission (mission_t *mission) mission->ufo->landed = qtrue; mission->stage = STAGE_RECON_GROUND; - mission->finalDate = Date_Add(ccs.date, Date_Random(minCrashDelay, crashDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minCrashDelay, crashDelay)); /* mission appear on geoscape, player can go there */ CP_MissionAddToGeoscape(mission, qfalse); } @@ -77,7 +77,7 @@ void CP_EndRescueMission (mission_t *mission, aircraft_t *aircraft, qboolean won B_DumpAircraftToHomeBase(crashedAircraft); } - if (won || (CP_CheckMissionLimitedInTime(mission) && Date_LaterThan(&ccs.date, &mission->finalDate))) + if (won || (CP_CheckMissionLimitedInTime(mission) && Date_LaterThan(&ccs->date, &mission->finalDate))) AIR_DestroyAircraft(crashedAircraft); } @@ -97,7 +97,7 @@ static void CP_LeaveRescueMission (mission_t *mission) mission->ufo->landed = qfalse; } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } CP_MissionRemoveFromGeoscape(mission); } diff --git a/src/client/campaign/missions/cp_mission_supply.c b/src/client/campaign/missions/cp_mission_supply.c index 3a76e5a..2a5af9a 100644 --- a/src/client/campaign/missions/cp_mission_supply.c +++ b/src/client/campaign/missions/cp_mission_supply.c @@ -103,7 +103,7 @@ static void CP_SupplySetStayAtBase (mission_t *mission) return; } - mission->finalDate = Date_Add(ccs.date, Date_Random(minSupplyTime, supplyTime)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minSupplyTime, supplyTime)); AB_SupplyBase(mission->data.alienBase, mission->ufo->detected); diff --git a/src/client/campaign/missions/cp_mission_terror.c b/src/client/campaign/missions/cp_mission_terror.c index cb2f508..7eedec6 100644 --- a/src/client/campaign/missions/cp_mission_terror.c +++ b/src/client/campaign/missions/cp_mission_terror.c @@ -79,7 +79,7 @@ void CP_TerrorMissionStart (mission_t *mission) mission->stage = STAGE_TERROR_MISSION; - mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minMissionDelay, missionDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/ if (mission->ufo) CP_UFORemoveFromGeoscape(mission, qfalse); @@ -90,14 +90,14 @@ void CP_TerrorMissionStart (mission_t *mission) /** * @brief Choose a city for terror mission. - * @return chosen city in ccs.cities + * @return chosen city in ccs->cities */ static const city_t* CP_ChooseCity (void) { - if (ccs.numCities > 0) { - const int randnumber = rand() % ccs.numCities; + if (ccs->numCities > 0) { + const int randnumber = rand() % ccs->numCities; - return (city_t*) LIST_GetByIdx(ccs.cities, randnumber); + return (city_t*) LIST_GetByIdx(ccs->cities, randnumber); } else { return NULL; } @@ -122,7 +122,7 @@ static const mission_t* CP_TerrorInCity (const city_t *city) /** * @brief Set Terror attack mission, and go to Terror attack mission pos. * @note Terror attack mission -- Stage 1 - * @note Terror missions can only take place in city: pick one in ccs.cities. + * @note Terror missions can only take place in city: pick one in ccs->cities. */ static void CP_TerrorMissionGo (mission_t *mission) { @@ -162,7 +162,7 @@ static void CP_TerrorMissionGo (mission_t *mission) UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } diff --git a/src/client/campaign/missions/cp_mission_xvi.c b/src/client/campaign/missions/cp_mission_xvi.c index 9441db9..453af05 100644 --- a/src/client/campaign/missions/cp_mission_xvi.c +++ b/src/client/campaign/missions/cp_mission_xvi.c @@ -71,12 +71,12 @@ static void CP_XVIMissionStart (mission_t *mission) CP_MissionAddToGeoscape(mission, qfalse); if (mission->ufo) { - mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay)); + mission->finalDate = Date_Add(ccs->date, Date_Random(minMissionDelay, missionDelay)); /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/ CP_UFORemoveFromGeoscape(mission, qfalse); } else { /* Go to next stage on next frame */ - mission->finalDate = ccs.date; + mission->finalDate = ccs->date; } } diff --git a/src/client/cl_game_campaign.c b/src/client/cl_game_campaign.c index 27d78d8..51047d9 100644 --- a/src/client/cl_game_campaign.c +++ b/src/client/cl_game_campaign.c @@ -44,8 +44,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void GAME_CP_MissionAutoGo_f (void) { mission_t *mission = MAP_GetSelectedMission(); - missionResults_t *results = &ccs.missionResults; - battleParam_t *battleParam = &ccs.battleParameters; + missionResults_t *results = &ccs->missionResults; + battleParam_t *battleParam = &ccs->battleParameters; if (!mission) { Com_DPrintf(DEBUG_CLIENT, "GAME_CP_MissionAutoGo_f: No update after automission\n"); @@ -80,7 +80,7 @@ static void GAME_CP_MissionAutoGo_f (void) CP_CreateBattleParameters(mission, battleParam, MAP_GetMissionAircraft()); results->won = qfalse; - CL_GameAutoGo(mission, MAP_GetInterceptorAircraft(), ccs.curCampaign, battleParam, results); + CL_GameAutoGo(mission, MAP_GetInterceptorAircraft(), ccs->curCampaign, battleParam, results); if (results->won) { Cvar_SetValue("mn_autogo", 1); @@ -143,7 +143,7 @@ static void GAME_CP_Results_f (void) return; } - CP_MissionEnd(ccs.curCampaign, mission, &ccs.battleParameters, Com_ParseBoolean(Cmd_Argv(1))); + CP_MissionEnd(ccs->curCampaign, mission, &ccs->battleParameters, Com_ParseBoolean(Cmd_Argv(1))); } /** @@ -186,8 +186,8 @@ static void GAME_CP_GetCampaigns_f (void) *campaignDesc = '\0'; - for (i = 0; i < ccs.numCampaigns; i++) { - const campaign_t *c = &ccs.campaigns[i]; + for (i = 0; i < ccs->numCampaigns; i++) { + const campaign_t *c = &ccs->campaigns[i]; if (c->visible) LIST_AddString(&campaignList, va("%s", _(c->name))); } @@ -196,8 +196,8 @@ static void GAME_CP_GetCampaigns_f (void) UI_RegisterLinkedListText(TEXT_CAMPAIGN_LIST, campaignList); /* select main as default */ - for (i = 0; i < ccs.numCampaigns; i++) { - const campaign_t *c = &ccs.campaigns[i]; + for (i = 0; i < ccs->numCampaigns; i++) { + const campaign_t *c = &ccs->campaigns[i]; if (Q_streq(c->id, "main")) { Cmd_ExecuteString(va("campaignlist_click %i", i)); return; @@ -223,19 +223,19 @@ static void GAME_CP_CampaignListClick_f (void) /* Which campaign in the list? */ num = atoi(Cmd_Argv(1)); - if (num < 0 || num >= ccs.numCampaigns) + if (num < 0 || num >= ccs->numCampaigns) return; /* jump over all invisible campaigns */ - while (!ccs.campaigns[num].visible) { + while (!ccs->campaigns[num].visible) { num++; - if (num >= ccs.numCampaigns) + if (num >= ccs->numCampaigns) return; } - campaign = &ccs.campaigns[num]; + campaign = &ccs->campaigns[num]; Cvar_Set("cp_campaign", campaign->id); - if (ccs.campaigns[num].team == TEAM_PHALANX) + if (ccs->campaigns[num].team == TEAM_PHALANX) racetype = _("Human"); else racetype = _("Aliens"); @@ -343,9 +343,9 @@ void GAME_CP_Results (struct dbuffer *msg, int winner, int *numSpawned, int *num /* Collect aliens from the battlefield. */ AL_CollectingAliens(aircraft); - ccs.aliensKilled += aliensKilled; + ccs->aliensKilled += aliensKilled; - results = &ccs.missionResults; + results = &ccs->missionResults; results->won = won; results->aliensKilled = aliensKilled; results->aliensStunned = aliensStunned; @@ -422,10 +422,10 @@ qboolean GAME_CP_TeamIsKnown (const teamDef_t *teamDef) if (!CHRSH_IsTeamDefAlien(teamDef)) return qtrue; - if (!ccs.teamDefTechs[teamDef->idx]) + if (!ccs->teamDefTechs[teamDef->idx]) Com_Error(ERR_DROP, "Could not find tech for teamdef '%s'", teamDef->id); - return RS_IsResearched_ptr(ccs.teamDefTechs[teamDef->idx]); + return RS_IsResearched_ptr(ccs->teamDefTechs[teamDef->idx]); } void GAME_CP_Drop (void) @@ -450,12 +450,12 @@ void GAME_CP_Frame (void) return; /* advance time */ - CL_CampaignRun(ccs.curCampaign); + CL_CampaignRun(ccs->curCampaign); } const char* GAME_CP_GetTeamDef (void) { - const int team = ccs.curCampaign->team; + const int team = ccs->curCampaign->team; return Com_ValueToStr(&team, V_TEAM, 0); } @@ -482,7 +482,7 @@ void GAME_CP_InitializeBattlescape (const chrList_t *team) equipDef_t *GAME_CP_GetEquipmentDefinition (void) { - return &ccs.eMission; + return &ccs->eMission; } void GAME_CP_CharacterCvars (const character_t *chr) diff --git a/src/client/ui/node/ui_node_base.c b/src/client/ui/node/ui_node_base.c index 37d5e23..e6b7b49 100644 --- a/src/client/ui/node/ui_node_base.c +++ b/src/client/ui/node/ui_node_base.c @@ -194,7 +194,7 @@ static void UI_BaseMapNodeDraw (uiNode_t * node) break; case B_STATUS_UNDER_CONSTRUCTION: { - const int time = building->buildTime - (ccs.date.day - building->timeStart); + const int time = building->buildTime - (ccs->date.day - building->timeStart); UI_DrawString("f_small", ALIGN_UL, pos[0] + 10, pos[1] + 10, pos[0] + 10, node->size[0], 0, va(ngettext("%i day left", "%i days left", time), time), 0, 0, NULL, qfalse, 0); break; } @@ -213,7 +213,7 @@ static void UI_BaseMapNodeDraw (uiNode_t * node) return; /* if we are building */ - if (ccs.baseAction == BA_NEWBUILDING) { + if (ccs->baseAction == BA_NEWBUILDING) { qboolean isLarge; assert(base->buildingCurrent); /** @todo we should not compute here if we can (or not build something) the map model know it better */ @@ -292,7 +292,7 @@ static void UI_BaseMapNodeClick (uiNode_t *node, int x, int y) if (col == -1) return; - if (ccs.baseAction == BA_NEWBUILDING) { + if (ccs->baseAction == BA_NEWBUILDING) { assert(base->buildingCurrent); if (!base->map[row][col].building && !base->map[row][col].blocked) { if (!base->buildingCurrent->needs @@ -310,7 +310,7 @@ static void UI_BaseMapNodeClick (uiNode_t *node, int x, int y) assert(!base->map[row][col].blocked); B_BuildingOpenAfterClick(entry); - ccs.baseAction = BA_NONE; + ccs->baseAction = BA_NONE; return; } } diff --git a/src/client/ui/node/ui_node_map.c b/src/client/ui/node/ui_node_map.c index ebab5a1..e9d9084 100644 --- a/src/client/ui/node/ui_node_map.c +++ b/src/client/ui/node/ui_node_map.c @@ -48,7 +48,7 @@ static void UI_MapNodeDraw (uiNode_t *node) /* Draw geoscape */ R_PushClipRect(pos[0], pos[1], node->size[0], node->size[1]); - MAP_DrawMap(node, ccs.curCampaign); + MAP_DrawMap(node, ccs->curCampaign); R_PopClipRect(); } } @@ -70,54 +70,54 @@ static void UI_MapNodeCapturedMouseMove (uiNode_t *node, int x, int y) case MODE_SHIFT2DMAP: { int i; - const float zoom = 0.5 / ccs.zoom; + const float zoom = 0.5 / ccs->zoom; /* shift the map */ - ccs.center[0] -= (float) (mousePosX - oldMousePosX) / (ccs.mapSize[0] * ccs.zoom); - ccs.center[1] -= (float) (mousePosY - oldMousePosY) / (ccs.mapSize[1] * ccs.zoom); + ccs->center[0] -= (float) (mousePosX - oldMousePosX) / (ccs->mapSize[0] * ccs->zoom); + ccs->center[1] -= (float) (mousePosY - oldMousePosY) / (ccs->mapSize[1] * ccs->zoom); for (i = 0; i < 2; i++) { /* clamp to min/max values */ - while (ccs.center[i] < 0.0) - ccs.center[i] += 1.0; - while (ccs.center[i] > 1.0) - ccs.center[i] -= 1.0; + while (ccs->center[i] < 0.0) + ccs->center[i] += 1.0; + while (ccs->center[i] > 1.0) + ccs->center[i] -= 1.0; } - if (ccs.center[1] < zoom) - ccs.center[1] = zoom; - if (ccs.center[1] > 1.0 - zoom) - ccs.center[1] = 1.0 - zoom; + if (ccs->center[1] < zoom) + ccs->center[1] = zoom; + if (ccs->center[1] > 1.0 - zoom) + ccs->center[1] = 1.0 - zoom; break; } case MODE_SHIFT3DMAP: /* rotate a model */ - ccs.angles[PITCH] += ROTATE_SPEED * (mousePosX - oldMousePosX) / ccs.zoom; - ccs.angles[YAW] -= ROTATE_SPEED * (mousePosY - oldMousePosY) / ccs.zoom; + ccs->angles[PITCH] += ROTATE_SPEED * (mousePosX - oldMousePosX) / ccs->zoom; + ccs->angles[YAW] -= ROTATE_SPEED * (mousePosY - oldMousePosY) / ccs->zoom; /* clamp the angles */ - while (ccs.angles[YAW] > 0.0) - ccs.angles[YAW] = 0.0; - while (ccs.angles[YAW] < -180.0) - ccs.angles[YAW] = -180.0; - - while (ccs.angles[PITCH] > 180.0) - ccs.angles[PITCH] -= 360.0; - while (ccs.angles[PITCH] < -180.0) - ccs.angles[PITCH] += 360.0; + while (ccs->angles[YAW] > 0.0) + ccs->angles[YAW] = 0.0; + while (ccs->angles[YAW] < -180.0) + ccs->angles[YAW] = -180.0; + + while (ccs->angles[PITCH] > 180.0) + ccs->angles[PITCH] -= 360.0; + while (ccs->angles[PITCH] < -180.0) + ccs->angles[PITCH] += 360.0; break; case MODE_ZOOMMAP: { - const float zoom = 0.5 / ccs.zoom; + const float zoom = 0.5 / ccs->zoom; /* zoom the map */ - ccs.zoom *= pow(0.995, mousePosY - oldMousePosY); - if (ccs.zoom < cl_mapzoommin->value) - ccs.zoom = cl_mapzoommin->value; - else if (ccs.zoom > cl_mapzoommax->value) - ccs.zoom = cl_mapzoommax->value; - - if (ccs.center[1] < zoom) - ccs.center[1] = zoom; - if (ccs.center[1] > 1.0 - zoom) - ccs.center[1] = 1.0 - zoom; + ccs->zoom *= pow(0.995, mousePosY - oldMousePosY); + if (ccs->zoom < cl_mapzoommin->value) + ccs->zoom = cl_mapzoommin->value; + else if (ccs->zoom > cl_mapzoommax->value) + ccs->zoom = cl_mapzoommax->value; + + if (ccs->center[1] < zoom) + ccs->center[1] = zoom; + if (ccs->center[1] > 1.0 - zoom) + ccs->center[1] = 1.0 - zoom; break; } default: @@ -183,17 +183,17 @@ static void UI_MapNodeCapturedMouseLost (uiNode_t *node) static void UI_MapNodeZoom (uiNode_t *node, qboolean out) { - ccs.zoom *= pow(0.995, (out ? 10: -10)); - if (ccs.zoom < cl_mapzoommin->value) - ccs.zoom = cl_mapzoommin->value; - else if (ccs.zoom > cl_mapzoommax->value) - ccs.zoom = cl_mapzoommax->value; + ccs->zoom *= pow(0.995, (out ? 10: -10)); + if (ccs->zoom < cl_mapzoommin->value) + ccs->zoom = cl_mapzoommin->value; + else if (ccs->zoom > cl_mapzoommax->value) + ccs->zoom = cl_mapzoommax->value; if (!cl_3dmap->integer) { - if (ccs.center[1] < 0.5 / ccs.zoom) - ccs.center[1] = 0.5 / ccs.zoom; - if (ccs.center[1] > 1.0 - 0.5 / ccs.zoom) - ccs.center[1] = 1.0 - 0.5 / ccs.zoom; + if (ccs->center[1] < 0.5 / ccs->zoom) + ccs->center[1] = 0.5 / ccs->zoom; + if (ccs->center[1] > 1.0 - 0.5 / ccs->zoom) + ccs->center[1] = 1.0 - 0.5 / ccs->zoom; } MAP_StopSmoothMovement(); } diff --git a/src/tests/test_campaign.c b/src/tests/test_campaign.c index f0bc990..f17dbbd 100644 --- a/src/tests/test_campaign.c +++ b/src/tests/test_campaign.c @@ -142,7 +142,7 @@ static installation_t* CreateInstallation (const char *name, const vec2_t pos) CU_ASSERT_EQUAL(installation->installationStatus, INSTALLATION_UNDER_CONSTRUCTION); /* fake the build time */ - installation->buildStart = ccs.date.day - installation->installationTemplate->buildTime; + installation->buildStart = ccs->date.day - installation->installationTemplate->buildTime; INS_UpdateInstallationData(); CU_ASSERT_EQUAL(installation->installationStatus, INSTALLATION_WORKING); @@ -328,7 +328,7 @@ static void testBaseBuilding (void) campaign = GetCampaign(); - ccs.credits = 10000000; + ccs->credits = 10000000; base = CreateBase("unittestcreatebase", pos); @@ -349,13 +349,15 @@ static void testAutoMissions (void) { missionResults_t result; battleParam_t battleParameters; - aircraft_t* aircraft = ccs.aircraftTemplates; + aircraft_t* aircraft; mission_t *mission; campaign_t *campaign; employee_t *pilot, *e1, *e2; ResetCampaignData(); + aircraft = ccs->aircraftTemplates; + OBJZERO(result); OBJZERO(battleParameters); @@ -415,7 +417,7 @@ static void testTransferItem (void) CU_ASSERT_PTR_NOT_NULL_FATAL(base); /* make sure that we get all buildings in our second base, too. * This is needed for starting a transfer */ - ccs.campaignStats.basesBuilt = 0; + ccs->campaignStats.basesBuilt = 0; targetBase = CreateBase("unittesttransferitemtargetbase", posTarget); CU_ASSERT_PTR_NOT_NULL_FATAL(targetBase); @@ -430,13 +432,13 @@ static void testTransferItem (void) transfer = TR_TransferStart(base, &td); CU_ASSERT_PTR_NOT_NULL_FATAL(transfer); - CU_ASSERT_EQUAL(LIST_Count(ccs.transfers), 1); + CU_ASSERT_EQUAL(LIST_Count(ccs->transfers), 1); /* to ensure that the transfer is finished with the first think call */ - transfer->event = ccs.date; + transfer->event = ccs->date; TR_TransferRun(); - CU_ASSERT_TRUE(LIST_IsEmpty(ccs.transfers)); + CU_ASSERT_TRUE(LIST_IsEmpty(ccs->transfers)); /* cleanup for the following tests */ E_DeleteAllEmployees(NULL); @@ -463,7 +465,7 @@ static void testUFORecovery (void) const aircraft_t *ufo; storedUFO_t *storedUFO; installation_t *installation; - date_t date = ccs.date; + date_t date = ccs->date; ResetCampaignData(); @@ -483,7 +485,7 @@ static void testUFORecovery (void) CU_ASSERT_EQUAL(storedUFO->status, SUFO_RECOVERED); - ccs.date.day++; + ccs->date.day++; UR_ProcessActive(); @@ -683,7 +685,7 @@ static void testDisassembly (void) installation = CreateInstallation("unittestproduction", pos); - storedUFO = US_StoreUFO(ufo, installation, ccs.date, 1.0); + storedUFO = US_StoreUFO(ufo, installation, ccs->date, 1.0); CU_ASSERT_PTR_NOT_NULL_FATAL(storedUFO); CU_ASSERT_EQUAL(storedUFO->status, SUFO_RECOVERED); PR_SetData(&data, PRODUCTION_TYPE_DISASSEMBLY, storedUFO); @@ -789,7 +791,7 @@ static void testAirFight (void) UFO_CheckShootBack(campaign, ufo, ufo->aircraftTarget); /* one projectile should be spawned */ - CU_ASSERT_EQUAL(ccs.numProjectiles, 1); + CU_ASSERT_EQUAL(ccs->numProjectiles, 1); AIRFIGHT_CampaignRunProjectiles(campaign, deltaTime); /* don't use mission pointer from here it might been removed */ @@ -887,7 +889,7 @@ static void testSaveLoad (void) SAV_Init(); - ccs.curCampaign = campaign; + ccs->curCampaign = campaign; Cvar_Set("save_compressed", "0"); @@ -948,12 +950,12 @@ static void testCampaignRun (void) cls.frametime = 1; - startDay = ccs.date.day; + startDay = ccs->date.day; for (i = 0; i < seconds; i++) { - ccs.gameTimeScale = 1; + ccs->gameTimeScale = 1; CL_CampaignRun(campaign); } - CU_ASSERT_EQUAL(ccs.date.day - startDay, days); + CU_ASSERT_EQUAL(ccs->date.day - startDay, days); /* cleanup for the following tests */ E_DeleteAllEmployees(NULL); @@ -971,9 +973,9 @@ static void testLoad (void) CP_InitOverlay(); - ccs.curCampaign = NULL; + ccs->curCampaign = NULL; CU_ASSERT_TRUE(SAV_GameLoad("unittest1", &error)); - CU_ASSERT_PTR_NOT_NULL(ccs.curCampaign); + CU_ASSERT_PTR_NOT_NULL(ccs->curCampaign); i = 0; ufo = NULL; @@ -990,34 +992,34 @@ static void testDateHandling (void) date.day = 300; date.sec = 300; - ccs.date = date; + ccs->date = date; CU_ASSERT_TRUE(Date_IsDue(&date)); - CU_ASSERT_FALSE(Date_LaterThan(&ccs.date, &date)); + CU_ASSERT_FALSE(Date_LaterThan(&ccs->date, &date)); date.day = 299; date.sec = 310; CU_ASSERT_FALSE(Date_IsDue(&date)); - CU_ASSERT_TRUE(Date_LaterThan(&ccs.date, &date)); + CU_ASSERT_TRUE(Date_LaterThan(&ccs->date, &date)); date.day = 301; date.sec = 0; CU_ASSERT_TRUE(Date_IsDue(&date)); - CU_ASSERT_FALSE(Date_LaterThan(&ccs.date, &date)); + CU_ASSERT_FALSE(Date_LaterThan(&ccs->date, &date)); date.day = 300; date.sec = 299; CU_ASSERT_FALSE(Date_IsDue(&date)); - CU_ASSERT_TRUE(Date_LaterThan(&ccs.date, &date)); + CU_ASSERT_TRUE(Date_LaterThan(&ccs->date, &date)); date.day = 300; date.sec = 301; CU_ASSERT_TRUE(Date_IsDue(&date)); - CU_ASSERT_FALSE(Date_LaterThan(&ccs.date, &date)); + CU_ASSERT_FALSE(Date_LaterThan(&ccs->date, &date)); } /** @@ -1042,14 +1044,14 @@ static void testCampaignDateHandling (void) cls.frametime = 1; /* one hour till month change */ - ccs.date.day = 30; - ccs.date.sec = 23 * 60 * 60; + ccs->date.day = 30; + ccs->date.sec = 23 * 60 * 60; /** @todo fix magic number */ - ccs.gameLapse = 7; - ccs.paid = qtrue; + ccs->gameLapse = 7; + ccs->paid = qtrue; CL_UpdateTime(); CL_CampaignRun(campaign); - CU_ASSERT_FALSE(ccs.paid); + CU_ASSERT_FALSE(ccs->paid); CU_ASSERT_TRUE(CL_IsTimeStopped()); /* cleanup for the following tests */ @@ -1112,15 +1114,15 @@ static void testBuildingConstruction (void) /* day 0 has special meaning! */ /* if building->startTime is 0 no buildTime checks done! */ - ccs.date.day++; - ccs.campaignStats.basesBuilt = 1; + ccs->date.day++; + ccs->campaignStats.basesBuilt = 1; base = CreateBase("unittestbuildingconstruction", pos); CU_ASSERT_PTR_NOT_NULL_FATAL(base); /* base should have exactly one building: entrance */ - CU_ASSERT_EQUAL(ccs.numBuildings[base->idx], 1); - entrance = &ccs.buildings[base->idx][0]; + CU_ASSERT_EQUAL(ccs->numBuildings[base->idx], 1); + entrance = &ccs->buildings[base->idx][0]; /* try to build powerplant that is not connected */ buildingTemplate = B_GetBuildingTemplate("building_powerplant"); @@ -1154,12 +1156,12 @@ static void testBuildingConstruction (void) building2 = B_SetBuildingByClick(base, buildingTemplate, y, x); CU_ASSERT_PTR_NULL_FATAL(building2); /* roll time one day before building finishes */ - ccs.date.day += building1->buildTime - 1; + ccs->date.day += building1->buildTime - 1; B_UpdateBaseData(); /* building should be under construction */ CU_ASSERT_EQUAL(building1->buildingStatus, B_STATUS_UNDER_CONSTRUCTION); /* step a day */ - ccs.date.day++; + ccs->date.day++; B_UpdateBaseData(); /* building should be ready */ CU_ASSERT_EQUAL(building1->buildingStatus, B_STATUS_WORKING); @@ -1177,7 +1179,7 @@ static void testBuildingConstruction (void) /* try to destroy the first (should fail) */ CU_ASSERT_FALSE(B_BuildingDestroy(building1)); /* build up the second */ - ccs.date.day += building2->buildTime; + ccs->date.day += building2->buildTime; B_UpdateBaseData(); /* try to destroy the first (should fail) */ CU_ASSERT_FALSE(B_BuildingDestroy(building1)); -- 1.7.1