Skip to content
Permalink
Browse files

Fix ORIGINAL8 medal always being awarded

  • Loading branch information
SupSuper committed Jan 5, 2018
1 parent c7204b1 commit c3280c589261798c5c5996be606d90e64af906eb
Showing with 22 additions and 12 deletions.
  1. +14 −8 src/Engine/CrossPlatform.cpp
  2. +7 −4 src/Mod/Mod.cpp
  3. +1 −0 src/Savegame/SoldierDiary.cpp
@@ -752,15 +752,21 @@ std::pair<std::wstring, std::wstring> timeToString(time_t time)
*/
bool naturalCompare(const std::wstring &a, const std::wstring &b)
{
//#if defined(_WIN32) && (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR))
#ifdef _MSC_VER
return (StrCmpLogicalW(a.c_str(), b.c_str()) < 0);
#else
// sorry unix users you get ASCII sort
std::wstring::const_iterator i, j;
for (i = a.begin(), j = b.begin(); i != a.end() && j != b.end() && tolower(*i) == tolower(*j); i++, j++);
return (i != a.end() && j != b.end() && tolower(*i) < tolower(*j));
#if defined(_WIN32) && (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR))
typedef int (WINAPI *WinStrCmp)(PCWSTR, PCWSTR);
WinStrCmp pWinStrCmp = (WinStrCmp)GetProcAddress(GetModuleHandleA("shlwapi.dll"), "StrCmpLogicalW");
if (pWinStrCmp)
{
return (pWinStrCmp(a.c_str(), b.c_str()) < 0);
}
else
#endif
{
// sorry unix users you get ASCII sort
std::wstring::const_iterator i, j;
for (i = a.begin(), j = b.begin(); i != a.end() && j != b.end() && tolower(*i) == tolower(*j); i++, j++);
return (i != a.end() && j != b.end() && tolower(*i) < tolower(*j));
}
}

/**
@@ -1432,11 +1432,14 @@ SavedGame *Mod::newSave() const
}
base->getSoldiers()->push_back(soldier);
// Award soldier a special 'original eigth' commendation
SoldierDiary *diary = soldier->getDiary();
diary->awardOriginalEightCommendation();
for (std::vector<SoldierCommendations*>::iterator comm = diary->getSoldierCommendations()->begin(); comm != diary->getSoldierCommendations()->end(); ++comm)
if (_commendations.find("STR_MEDAL_ORIGINAL8_NAME") != _commendations.end())
{
(*comm)->makeOld();
SoldierDiary *diary = soldier->getDiary();
diary->awardOriginalEightCommendation();
for (std::vector<SoldierCommendations*>::iterator comm = diary->getSoldierCommendations()->begin(); comm != diary->getSoldierCommendations()->end(); ++comm)
{
(*comm)->makeOld();
}
}
}
}
@@ -875,6 +875,7 @@ int SoldierDiary::getMonthsService() const
*/
void SoldierDiary::awardOriginalEightCommendation()
{
// TODO: Unhardcode this
_commendations.push_back(new SoldierCommendations("STR_MEDAL_ORIGINAL8_NAME", "NoNoun"));

This comment has been minimized.

Copy link
@Shoes01

Shoes01 Jan 7, 2018

Contributor

In order to unhardcode this, a new bool could be added to Soldier Diary and the awardOriginalEightCommendation() function could set it to true. That way, instead of looking for a specific commendation, a specific flag is looked for and the commendation is given like any normal one. I would do this myself, but I don't have my dev environment set up...

}

0 comments on commit c3280c5

Please sign in to comment.
You can’t perform that action at this time.