Skip to content

Commit

Permalink
Merge pull request #32 from Xynth - FreeAllegiance/rescueAchievements
Browse files Browse the repository at this point in the history
Rescue and Garrison Spot achievements
  • Loading branch information
BackTrak committed Nov 11, 2017
2 parents 69aae62 + bd94b24 commit 7434ef5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/FedSrv/CSteamAchievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ void CSteamAchievements::AwardIGCAchievements(AchievementMask am)
SetAchievement(EAchievements::NANITE_REPAIR_1_11);
m_nanAchievementEarned = true; //I was concerned about potentially calling set achievement too much
}
if ((am & c_achmGarrSpot) > 0)
SetAchievement(EAchievements::SPOT_GARRISON_1_14);

}

Expand All @@ -306,6 +308,16 @@ void CSteamAchievements::AwardRecoverTechAchievement()
SetAchievement(EAchievements::RECOVER_TECH_1_8);
}

void CSteamAchievements::AwardPodPickup()
{
SetAchievement(EAchievements::PICKUP_POD_1_13);
}

void CSteamAchievements::AwardGetRescued()
{
SetAchievement(EAchievements::GET_RESCUED_1_12);
}


void CSteamAchievements::AddUserStats(PlayerScoreObject* ppso, IshipIGC * pIship)
{
Expand Down
15 changes: 12 additions & 3 deletions src/FedSrv/CSteamAchievements.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ enum EAchievements
RECOVER_TECH_1_8 = 8,
FIRST_PROBE_KILL_1_9 = 9,
PROBE_SPOT_1_10 = 10,
NANITE_REPAIR_1_11 = 11
NANITE_REPAIR_1_11 = 11,
GET_RESCUED_1_12 = 12,
PICKUP_POD_1_13 = 13,
SPOT_GARRISON_1_14 = 14


// Don't forget to update g_nMaximumSteamAchievementCount and m_Achievements!
};
Expand All @@ -36,7 +40,7 @@ enum EStats

// Don't forget to update g_nMaximumSteamStatCount and m_Stats!
};
const int g_nMaximumSteamAchievementCount = 12; // Always keep this in sync with the number of achievments in EAchievements!
const int g_nMaximumSteamAchievementCount = 15; // Always keep this in sync with the number of achievments in EAchievements!
const int g_nMaximumSteamStatCount = 10; // Always keep this in sync with the number of stats in EStats!

// BT - STEAM
Expand Down Expand Up @@ -74,7 +78,10 @@ class CSteamAchievements
"RECOVER_TECH_1_8",
"FIRST_PROBE_KILL_1_9",
"PROBE_SPOT_1_10",
"NANITE_REPAIR_1_11"
"NANITE_REPAIR_1_11",
"GET_RESCUED_1_12",
"PICKUP_POD_1_13",
"SPOT_GARRISON_1_14"
};

// Keep in sync with EStats!
Expand Down Expand Up @@ -119,6 +126,8 @@ class CSteamAchievements
void AwardBaseKillOrCapture(bool kill);
void AwardIGCAchievements(AchievementMask am);
void AwardRecoverTechAchievement();
void AwardPodPickup();
void AwardGetRescued();

void AddUserStats(PlayerScoreObject* ppso, IshipIGC* pIship);
void UpdateLeaderboard(PlayerScoreObject* ppso);
Expand Down
31 changes: 30 additions & 1 deletion src/FedSrv/FedSrv.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -10885,10 +10885,27 @@ class ThingSiteImpl : public ThingSite
pfmObjectSpotted->oidObject = pmodel->GetObjectID();
pfmObjectSpotted->otSpotter = otSpotter;
pfmObjectSpotted->oidSpotter = s->GetObjectID();

g.fm.SendMessages(CFSSide::FromIGC(pside)->GetGroup(), FM_GUARANTEED, FM_FLUSH);

CFSMission* pfsMission = (CFSMission *)(pside->GetMission()->GetPrivateData());

if (otModel == OT_station)
{
IstationIGC* pstation = ((IstationIGC*)pmodel);
if ((pstation->GetStationType()->GetClassID() == c_scGarrison) ||
(pstation->GetStationType()->GetClassID() == c_scStarbase))
{
if (s->GetObjectType() == OT_ship)
{
ObjectID spotterID = s->GetObjectID();
ImodelIGC* pShipModel = s->GetMission()->GetModel(OT_ship, spotterID);
IshipIGC* pShip = (IshipIGC*)pShipModel;
pShip->SetAchievementMask(c_achmGarrSpot);
}
}
}


if ((otModel == OT_warp) || (otModel == OT_asteroid))
{
Expand Down Expand Up @@ -12805,6 +12822,18 @@ bool FedSrvSiteBase::RescueShipEvent(IshipIGC* pshipRescued, IshipIGC* pshipResc
{
CFSShip* pfsShip = (CFSShip*)(pshipRescuer->GetPrivateData());
pfsShip->GetPlayerScoreObject()->AddRescue();
if (pfsShip->IsPlayer())
{
CSteamAchievements *pSteamAchievements = pfsShip->GetPlayer()->GetSteamAchievements();
pSteamAchievements->AwardPodPickup();
}

CFSShip* rescuedShip = (CFSShip*)(pshipRescued->GetPrivateData());
if (rescuedShip->IsPlayer())
{
CSteamAchievements *pSteamAchievements = pfsShip->GetPlayer()->GetSteamAchievements();
pSteamAchievements->AwardGetRescued();
}
BEGIN_PFM_CREATE(g.fm, pfmPlayerRescued, S, PLAYER_RESCUED)
END_PFM_CREATE
pfmPlayerRescued->shipIDRescuer = pshipRescuer->GetObjectID();
Expand Down
1 change: 1 addition & 0 deletions src/Igc/igc.h
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ typedef short AchievementMask;
const AchievementMask c_achmProbeKill = 0x01;
const AchievementMask c_achmProbeSpot = 0x02;
const AchievementMask c_achmNewRepair = 0x04;
const AchievementMask c_achmGarrSpot = 0x08;

enum ShipControlStateIGC
{
Expand Down

0 comments on commit 7434ef5

Please sign in to comment.