TLeonardUK / ZombieGrinder

Zombie Grinder
6 stars 6 forks source link

Parsing Resources #2

Closed AntonioCS closed 2 years ago

AntonioCS commented 2 years ago

Hey,

So I'm back at trying to get this to compile. I'm at the ResourceFactory::Parse_Resources which is here: https://github.com/AntonioCS/ZombieGrinder/blob/master/Source/Engine/Resources/ResourceFactory.cpp#L227

The code is trying to find <resource_dir_name> + .dat. I've added a DBG_LOG and got this:

[00:00:00:703, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Base/Base.dat
[00:00:00:703, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Examples/Examples.dat
[00:00:00:703, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Web/Web.dat
[00:00:00:703, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Base/Base.dat
[00:00:00:703, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Examples/Examples.dat
[00:00:00:719, 0, 0.0mb] Data file not found: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Web/Web.dat

The only files I find in those directories are xml not dat files.

I have tried changing the .dat to .xml which of course results in the code continuing. The issue with the code after this is that I get this exception:

Found resource package: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Base/Base.xml
Successfully opened stream to: D:/Projects/Personal/cpp/Games/ZombieGrinder/Data/Base/Base.xml
~~~~~~~~~~~~ UNHANDLED EXCEPTION OCCURRED ~~~~~~~~~~~
Attempt to create dump file ...
Path: D:\Projects\Personal\cpp\Games\ZombieGrinder\cmake-build-debug-visual-studio\Source\Game\Debug\.crashes\24.dmp
Success!

Call Stack:
[0] <unknown> (0): RaiseException
[1] <unknown> (0): CxxThrowException
[2] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\heap\throw_bad_alloc.cpp (41): __scrt_throw_std_bad_array_new_length
[3] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\heap\new_scalar.cpp (45): operator new
[4] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\heap\new_array.cpp (28): operator new[]
[5] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Engine\Resources\PackageFile.cpp (129): PackageFile::Open
[6] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Engine\Resources\ResourceFactory.cpp (262): ResourceFactory::Parse_Resources
[7] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Engine\Engine\GameEngine.cpp (345): GameEngine::GameEngine
[8] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Game\Runner\Game.cpp (189): Game_Entry_Point
[9] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Engine\Platform\Win32\Win32_EntryPoint.cpp (350): RealMain
[10] D:\Projects\Personal\cpp\Games\ZombieGrinder\Source\Engine\Platform\Win32\Win32_EntryPoint.cpp (244): main
[11] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (78): invoke_main
[12] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (288): __scrt_common_main_seh
[13] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (331): __scrt_common_main
[14] D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): mainCRTStartup
[15] <unknown> (0): BaseThreadInitThunk
[16] <unknown> (0): RtlGetAppContainerNamedObjectPath
[17] <unknown> (0): RtlGetAppContainerNamedObjectPath

Attempting recovery through longjmp ...
Recovered from unhandled exception. Beginning cleanup.

So I guess this wasn't suppose to be xml? I really need to figure out how to parse the resource files properly because if nothing gets loaded the whole projects halts at:

    DBG_LOG("Selecting default language: %s", (*EngineOptions::language_default).c_str());
    {
        bool result = m_locale->Change_Language((*EngineOptions::language_default).c_str());
        DBG_ASSERT_STR(result, "Failed to set default language to: %s", (*EngineOptions::language_default).c_str());
    }

Because then this whole things fails:

bool Locale::Change_Language(const char* name)
{ 
    LanguageHandle* lang = ResourceFactory::Get()->Get_Language(name); // <-- this is empty
    return Change_Language(lang);
}

bool Locale::Change_Language(LanguageHandle* language)
{
    if (language == NULL)
    {
        DBG_LOG("Language passed is null");
        return false; // <-- triggers this
    }

    DBG_LOG("Changed to langauge: %s (%s)", language->Get()->Long_Name, language->Get()->Short_Name);

    m_current_language = language;
    return true;
}

Apologies if this is something super obvious... My c++ is limited, any tips will be helpful. Thanks!

TLeonardUK commented 2 years ago

The .dat files are archive files, the xml files describe what goes into them and how they are built. To build the archive files there are some bat files in the Tools folder.

AntonioCS commented 2 years ago

Right, I can see a build_data.bat which calls Builder.exe. The code for Builderis included in the project. I'll try and see if I can make something run this automatically.

Thank you so much for the super quick response.