Should fix this memory leak:
==31441== 576 bytes in 4 blocks are possibly lost in loss record 2,109 of 2,723
==31441== at 0x4C30A1E: calloc (vg_replace_malloc.c:711)
==31441== by 0x14F98CEF: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14FD8303: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14FD8B6F: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14BF0C40: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14BF0E27: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x910D28: LoaderDFF::readGeometry(RWBStream const&) (LoaderDFF.cpp:253)
==31441== by 0x9104E2: LoaderDFF::readGeometryList(RWBStream const&) (LoaderDFF.cpp:129)
==31441== by 0x911CED: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:474)
==31441== by 0x7BE007: GameData::loadModel(unsigned short) (GameData.cpp:474)
==31441== by 0x7E0DD2: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==31441== by 0x86E0BE: opcode_029b(ScriptArguments const&, int, glm::tvec3<float, (glm::precision)0>, ScriptObjectType<InstanceObject>&) (GTA3ModuleImpl.inl:7234)
==31441==
==31441== 696 bytes in 3 blocks are possibly lost in loss record 2,197 of 2,723
==31441== at 0x4C30A1E: calloc (vg_replace_malloc.c:711)
==31441== by 0x14FD8298: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14BEEF21: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x14BEF057: ??? (in /usr/lib64/dri/i965_dri.so)
==31441== by 0x910CA6: LoaderDFF::readGeometry(RWBStream const&) (LoaderDFF.cpp:248)
==31441== by 0x9104E2: LoaderDFF::readGeometryList(RWBStream const&) (LoaderDFF.cpp:129)
==31441== by 0x911CED: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:474)
==31441== by 0x7BD346: GameData::loadClump(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameData.cpp:394)
==31441== by 0x75914F: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:54)
==31441== by 0x749175: main (main.cpp:13)
Should fix these memory leaks:
==22737== 513,622,016 bytes in 6,650 blocks are definitely lost in loss record 3,126 of 3,126
==22737== at 0x14F996E4: ??? (in /usr/lib64/dri/i965_dri.so)
==22737== by 0x14FE717A: ??? (in /usr/lib64/dri/i965_dri.so)
==22737== by 0x14FE622E: ??? (in /usr/lib64/dri/i965_dri.so)
==22737== by 0x14CDED2A: ??? (in /usr/lib64/dri/i965_dri.so)
==22737== by 0x14CDF85F: ??? (in /usr/lib64/dri/i965_dri.so)
==22737== by 0x91602C: createTexture(RW::BSTextureNative&, RW::BinaryStreamSection&) (LoaderTXD.cpp:79)
==22737== by 0x91649E: TextureLoader::loadFromMemory(std::shared_ptr<FileContentsInfo>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::shared_ptr<TextureData>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<TextureData> > > >&) (LoaderTXD.cpp:183)
==22737== by 0x7BBCE0: GameData::loadTextureArchive(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameData.cpp:372)
==22737== by 0x7BBABA: GameData::loadTXD(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameData.cpp:358)
==22737== by 0x7BCA80: GameData::loadModel(unsigned short) (GameData.cpp:466)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
This introduces indexGameDirectory and findFilePath.
indexGameDirectory indexes the files in the game directory.
findFilePath returns the on-disk location of a case-insensitive
game data path.
Previously the worker thread was constructed before the queue was, leading to
unfortunate race conditions. This fixes that, along with unrelated minor cleanup.
This involves a few changes. The first changes involve
allocating GameWindow and WorkContext on the heap, so that
RWGame still owns them but chooses when they're freed.
The work queue is given a method to stop the worker thread
without destroying the work context, so that subsystems
relying on the work context may still function to shut down.
Then RWGame is rearranged to cleanup separate subsystems
in an order that does not conflict (i.e., stop the work queue,
shut down other subsystems, then the renderer, *then* the window.)
The window needs to be cleaned up *after* the renderer because it
owns the OpenGL context.