Ticket #2807: replayWarnOnModMismatch_v2.diff

File replayWarnOnModMismatch_v2.diff, 2.6 KB (added by Arno Hemelhof, 8 years ago)
  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    2424            {"nick": "Alan", "name": "Alan Kemp"},
    2525            {"nick": "aBothe", "name": "Alexander Bothe"},
    2626            {"nick": "alpha123", "name": "Peter P. Cannici"},
     27            {"nick": "ArnH", "name": "Arno Hemelhof"},
    2728            {"nick": "Aurium", "name": "Aurélio Heckert"},
    2829            {"nick": "badmadblacksad", "name": "Martin F"},
    2930            {"name": "Mikołaj \"Bajter\" Korcz"},
  • source/main.cpp

     
    453453    // run non-visual simulation replay if requested
    454454    if (isReplay)
    455455    {
     456        if (!args.Has("mod"))
     457        {
     458            LOGERROR("At least one mod should be specified! Did you mean to add the argument '-mod=public'?");
     459            CXeromyces::Terminate();
     460            return;
     461        }
    456462        Paths paths(args);
    457463        g_VFS = CreateVfs(20 * MiB);
    458464        g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE);
  • source/ps/Replay.cpp

     
    2525#include "lib/res/h_mgr.h"
    2626#include "lib/tex/tex.h"
    2727#include "ps/Game.h"
     28#include "ps/CLogger.h"
    2829#include "ps/Loader.h"
    2930#include "ps/Mod.h"
    3031#include "ps/Profile.h"
     
    168169            JS::RootedValue attribs(cx);
    169170            ENSURE(g_Game->GetSimulation2()->GetScriptInterface().ParseJSON(line, &attribs));
    170171
     172            std::vector<CStr> replayModList;
     173            g_Game->GetSimulation2()->GetScriptInterface().GetProperty(attribs, "mods", replayModList);
     174           
     175            // Check for necessary mods which aren't loaded
     176            for (const CStr& mod : replayModList)
     177                if (mod != "user" && std::find(g_modsLoaded.begin(), g_modsLoaded.end(), mod) == g_modsLoaded.end())
     178                    LOGWARNING("The mod '%s' is required by the replay file, but wasn't passed as an argument!", mod);
     179           
     180            // Check for mods which are loaded, but weren't used when the replay was made
     181            for (const CStr& mod : g_modsLoaded)
     182                if (mod != "user" && std::find(replayModList.begin(), replayModList.end(), mod) == replayModList.end())
     183                    LOGWARNING("The mod '%s' wasn't used when creating this replay file, but was passed as an argument!", mod);
     184
    171185            g_Game->StartGame(&attribs, "");
    172186
    173187            // TODO: Non progressive load can fail - need a decent way to handle this