MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CheckAward

Function CheckAward

engine/Poseidon/UI/OptionsUI.cpp:1646–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1644 GWorld->UI()->ShowMessage(UIMsgVehicle, bShowHUD);
1645 GWorld->UI()->ShowMessage(UIMsgHelp, bShowHUD);
1646 }
1647 */
1648
1649 RString epizode = missionCls >> "template";
1650 disp->CreateChild(new DisplayIntro(disp, epizode));
1651 }
1652}
1653
1654void __cdecl PlayAward(Display* disp, RString name, const ParamEntry& cls);
1655
1656void __cdecl PlayAward(Display* disp, RString name, const ParamEntry& cls)
1657{
1658 RString dir = GetTmpSaveDirectory();
1659 char buffer[256];
1660 snprintf(buffer, sizeof(buffer), "%s%s.sqc", (const char*)dir, (const char*)CurrentCampaign);
1661 GetGCampaignHistory().campaignName = CurrentCampaign;
1662 SaveMission(buffer);
1663 // play it
1664 RString cutscene = cls >> Glob.header.worldname;
1665 disp->CreateChild(new DisplayAward(disp, cutscene));
1666}
1667
1668bool CheckAward(Display* disp)
1669{
1670 // check if awards disabled
1671 const ParamEntry& campaignCls = ExtParsCampaign >> "Campaign";
1672 const ParamEntry& battleCls = campaignCls >> CurrentBattle;
1673 const ParamEntry& missionCls = battleCls >> CurrentMission;
1674 if (missionCls.FindEntry("noAward") && (bool)(missionCls >> "noAward"))
1675 {
1676 return false;
1677 }
1678
1679 float oldScore = GStats._campaign._lastScore;
1680 float newScore = GStats._campaign._score;
1681 if (newScore < oldScore)
1682 {
1683 // penalties
1684 const ParamEntry* penalties = ExtParsCampaign.FindEntry("Penalties");
1685 if (penalties)
1686 {
1687 // fix - play cutscene with minimal score, mark all
1688 int best = INT_MAX;
1689 int bestIndex = -1;
1690
1691 for (int i = 0; i < penalties->GetEntryCount(); i++)
1692 {
1693 const ParamEntry& cls = penalties->GetEntry(i);
1694 float limit = cls >> "limit";
1695 if (newScore <= limit)
1696 {
1697 RString name = cls.GetName();
1698 // check if cutscene was played before
1699 bool found = false;
1700 for (int j = 0; j < GStats._campaign._penalties.Size(); j++)
1701 {
1702 if (GStats._campaign._penalties[j] == name)
1703 {

Callers 1

OnChildDestroyedMethod · 0.85

Calls 6

PlayAwardFunction · 0.85
FindEntryMethod · 0.45
GetEntryCountMethod · 0.45
GetNameMethod · 0.45
SizeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected