/** * @brief Base attack mission is over and is a failure (from an alien point of view): change interest values. */ void CP_BaseAttackMissionIsFailure (mission_t *mission) { base_t *base = mission->data.base; if (base) base->baseStatus = BASE_WORKING; ccs.mapAction = MA_NONE; /* we really don't want to use the fake aircraft anywhere */ if (base) base->aircraftCurrent = AIR_GetFirstFromBase(base); MAP_SetMissionAircraft(NULL); CL_ChangeIndividualInterest(0.05f, INTERESTCATEGORY_BUILDING); CL_ChangeIndividualInterest(0.1f, INTERESTCATEGORY_BASE_ATTACK); /* reset current selected mission */ MAP_NotifyMissionRemoved(mission); CP_MissionRemove(mission); }
/** * @brief Base attack mission is over and is a failure (from an alien point of view): change interest values. */ void CP_BaseAttackMissionIsFailure (mission_t* mission) { base_t* base = mission->data.base; if (base) { base->baseStatus = BASE_WORKING; /* clean up the fakeAircraft */ cgi->LIST_Delete(&baseAttackFakeAircraft.acTeam); base->aircraftCurrent = AIR_GetFirstFromBase(base); baseAttackFakeAircraft.mission = nullptr; } GEO_SetMissionAircraft(nullptr); INT_ChangeIndividualInterest(0.05f, INTERESTCATEGORY_BUILDING); INT_ChangeIndividualInterest(0.1f, INTERESTCATEGORY_BASE_ATTACK); /* reset current selected mission */ GEO_NotifyMissionRemoved(mission); CP_MissionRemove(mission); }
TEST_F(CampaignTest, testAircraftHandling) { const vec2_t destination = { 10, 10 }; base_t* base; aircraft_t* aircraft; aircraft_t* newAircraft; aircraft_t* aircraftTemplate; int firstIdx; int initialCount; int count; int newFound; base = CreateBase("unittestaircraft", destination); ASSERT_TRUE(nullptr != base); /** @todo we should not assume that initial base has aircraft. It's a campaign parameter */ aircraft = AIR_GetFirstFromBase(base); ASSERT_TRUE(nullptr != aircraft); /* aircraft should have a template */ aircraftTemplate = aircraft->tpl; ASSERT_TRUE(nullptr != aircraftTemplate); firstIdx = aircraft->idx; initialCount = AIR_BaseCountAircraft(base); /* test deletion (part 1) */ AIR_DeleteAircraft(aircraft); count = AIR_BaseCountAircraft(base); ASSERT_EQ(count, initialCount - 1); /* test addition (part 1) */ newAircraft = AIR_NewAircraft(base, aircraftTemplate); ASSERT_TRUE(nullptr != newAircraft); count = AIR_BaseCountAircraft(base); ASSERT_EQ(count, initialCount); /* new aircraft assigned to the right base */ ASSERT_EQ(newAircraft->homebase, base); newFound = 0; AIR_Foreach(a) { /* test deletion (part 2) */ ASSERT_NE(firstIdx, a->idx); /* for test addition (part 2) */ if (a->idx == newAircraft->idx) newFound++; } /* test addition (part 2) */ ASSERT_EQ(newFound, 1); /* check if AIR_Foreach iterates through all aircraft */ AIR_Foreach(a) { AIR_DeleteAircraft(a); } aircraft = AIR_GetFirstFromBase(base); ASSERT_TRUE(nullptr == aircraft); count = AIR_BaseCountAircraft(base); ASSERT_EQ(count, 0); /* cleanup for the following tests */ E_DeleteAllEmployees(nullptr); base->founded = false; }
static void testAircraftHandling (void) { const vec2_t destination = { 10, 10 }; campaign_t *campaign; base_t *base; aircraft_t *aircraft; aircraft_t *newAircraft; aircraft_t *aircraftTemplate; int firstIdx; int initialCount; int count; int newFound; ResetCampaignData(); campaign = GetCampaign(); base = CreateBase("unittestaircraft", destination); CU_ASSERT_PTR_NOT_NULL_FATAL(base); /** @todo we should not assume that initial base has aircraft. It's a campaign parameter */ aircraft = AIR_GetFirstFromBase(base); CU_ASSERT_PTR_NOT_NULL_FATAL(aircraft); /* aircraft should have a template */ aircraftTemplate = aircraft->tpl; CU_ASSERT_PTR_NOT_NULL_FATAL(aircraftTemplate); firstIdx = aircraft->idx; initialCount = AIR_BaseCountAircraft(base); /* test deletion (part 1) */ AIR_DeleteAircraft(aircraft); count = AIR_BaseCountAircraft(base); CU_ASSERT_EQUAL(count, initialCount - 1); /* test addition (part 1) */ newAircraft = AIR_NewAircraft(base, aircraftTemplate); CU_ASSERT_PTR_NOT_NULL_FATAL(newAircraft); count = AIR_BaseCountAircraft(base); CU_ASSERT_EQUAL(count, initialCount); /* new aircraft assigned to the right base */ CU_ASSERT_EQUAL(newAircraft->homebase, base); newFound = 0; AIR_Foreach(aircraft) { /* test deletion (part 2) */ CU_ASSERT_NOT_EQUAL(firstIdx, aircraft->idx); /* for test addition (part 2) */ if (aircraft->idx == newAircraft->idx) newFound++; } /* test addition (part 2) */ CU_ASSERT_EQUAL(newFound, 1); /* check if AIR_Foreach iterates through all aircraft */ AIR_Foreach(aircraft) { AIR_DeleteAircraft(aircraft); } aircraft = AIR_GetFirstFromBase(base); CU_ASSERT_PTR_NULL_FATAL(aircraft); count = AIR_BaseCountAircraft(base); CU_ASSERT_EQUAL(count, 0); /* cleanup for the following tests */ E_DeleteAllEmployees(NULL); base->founded = qfalse; }