View Issue Details

IDProjectCategoryView StatusLast Update
0004106The Dark ModCodingpublic26.02.2015 08:34
Reportergnartsch Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product VersionTDM 2.03 
Summary0004106: empty mission entries in missions.tdminfo
DescriptionWhenever TDM is started and stopped WITHOUT any FM installed, TDM will create an empty mission definition in the fms\mission.tdminfo file at the beginning of that file.
On consecutive runs one will even see another crumbled one at the end of the file one pop up at the end.

So, you see something like this:

tdm_missioninfo
{
}

tdm_missioninfo poets
{
    "downloaded_version" "1"
}

tdm_missioninfo {
{
}


The reason is found in the fact that during initialization of TDM, the following code is executed:

Game_local.cpp, lines 4522 ff:


    else if (cmd == "mainmenu_init")
    {
...
        idStr modName = m_MissionManager->GetCurrentModName();
        CModInfoPtr info = m_MissionManager->GetModInfo(modName);

        // grayman 0003733 - provide campaign and mission titles to the main menu
        if (info->_missionTitles.Num() > 1)
        {
            idStr campaignTitle = info->_missionTitles[0];
            campaignTitle += ":";
            idStr campaignMissionTitle = info->_missionTitles[m_MissionManager->GetCurrentMissionIndex() + 1];
            gui->SetStateString("CampaignTitleText", common->Translate(campaignTitle.c_str())); // grayman 0003733
            gui->SetStateString("CampaignMissionTitleText", common->Translate(campaignMissionTitle.c_str())); // grayman 0003733
        }
        else if (info->_missionTitles.Num() == 1)
        {
            idStr missionTitle = info->_missionTitles[0];
            gui->SetStateString("MissionTitleText", common->Translate(missionTitle.c_str())); // grayman 0003733



The problem here is that

m_MissionManager->GetModInfo(modName)

does not only try to retrieve info about the current mod (which is "" in case no mission is installed),
but it also adds that empty modname to it's internal modlist.


Thus, those weird entries are persisted into the file when closing TDM.


Proposed solution:

There is no need to retrieve any mod info, in case no mod is installed.
So, add a check for modname != "".
Works for me. And I did not notice any bad side-effects.



==> if (modName != "")
==> {
            CModInfoPtr info = m_MissionManager->GetModInfo(modName);

            // grayman 0003733 - provide campaign and mission titles to the main menu
            if (info->_missionTitles.Num() > 1)
            {
                idStr campaignTitle = info->_missionTitles[0];
                campaignTitle += ":";
                idStr campaignMissionTitle = info->_missionTitles[m_MissionManager->GetCurrentMissionIndex() + 1];
                gui->SetStateString("CampaignTitleText", common->Translate(campaignTitle.c_str())); // grayman 0003733
                gui->SetStateString("CampaignMissionTitleText", common->Translate(campaignMissionTitle.c_str())); // grayman 0003733
            }
            else if (info->_missionTitles.Num() == 1)
            {
                idStr missionTitle = info->_missionTitles[0];
                gui->SetStateString("MissionTitleText", common->Translate(missionTitle.c_str())); // grayman 0003733
            }
==> }
Steps To ReproduceStart with a clean missions.tdminfo without any junk and make sure to have no current_mission installed (== ready to play).
Start and stop TDM.
And you see junk showing up.

TagsNo tags attached.

Activities

gnartsch

gnartsch

25.02.2015 23:29

reporter   ~0007444

Oh, and persisting the mission list to disk should be fixed as well,
in case GetModInfo() would ever be called from other places as well.

Probably somthing like this:


MissionDB.cpp, lines 124 ff


    // Save changed declarations
    for (MissionInfoMap::iterator i = _missionInfo.begin(); i != _missionInfo.end(); ++i)
    {
==> if (i->first != "") {
            i->second->SaveToFile(outFile);
==> }
    }
gnartsch

gnartsch

26.02.2015 08:34

reporter   ~0007445

In order to get the trailing crumbled mission entry removed as well

tdm_missioninfo {
{
}


the following check could be modified, which makes perfect sense.

MissionDB.cpp line 69


old ==> if (!src.ReadToken(&token))
fixed ==> if (!src.ReadToken(&token) || idStr::Cmp(token.c_str(), "{") == 0)
            {
                src.Warning("Missing name on info declaration in %s line %d", src.GetFileName(), src.GetLineNum());
                break;
            }

Issue History

Date Modified Username Field Change
25.02.2015 22:53 gnartsch New Issue
25.02.2015 23:29 gnartsch Note Added: 0007444
26.02.2015 08:34 gnartsch Note Added: 0007445