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)
The CharacterObject should remove the CharacterController upon
destruction.
Should fix this memory leak:
==31441== 480 (360 direct, 120 indirect) bytes in 5 blocks are definitely lost in loss record 2,038 of 2,723
==31441== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==31441== by 0x7E2370: GameWorld::createPedestrian(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&, unsigned int) (GameWorld.cpp:334)
==31441== by 0x8E2F01: TrafficDirector::populateNearby(ViewCamera const&, float, int) (TrafficDirector.cpp:164)
==31441== by 0x7E1170: GameWorld::createTraffic(ViewCamera const&) (GameWorld.cpp:176)
==31441== by 0x75C616: RWGame::tick(float) (RWGame.cpp:531)
==31441== by 0x75BF18: RWGame::run() (RWGame.cpp:420)
==31441== by 0x749184: main (main.cpp:15)
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)
How?
Calling stepsimulation each frame,
bullet interpolate vehicles and characters for us.
Removed unneeded code:
"float alpha = fmod(dt, GAME_TIMESTEP) / GAME_TIMESTEP;"
It looks like alpha shift is
I also removed unneeded variable clock
and refactored names to match bullet's example.
We should alse think about problem of
crossing the range of float.
This fixes #324 on macOS.
The only difference between memcpy and mempcpy is that mempcpy returns
a pointer one after the last written byte - the return value is unused.
openrw/rwengine/src/engine/GameData.cpp:358:26: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
textureslots[slot] = std::move(loadTextureArchive(name));
^
openrw/rwengine/src/engine/GameData.cpp:358:26: note: remove std::move call here
textureslots[slot] = std::move(loadTextureArchive(name));
^~~~~~~~~~ ~
openrw/rwengine/src/objects/CharacterObject.cpp:16:18: warning: unused variable 'enter_offset' [-Wunused-variable]
static glm::vec3 enter_offset(0.81756252f, 0.34800607f, -0.486281008f);
^
In file included from openrw/rwgame/RWGame.cpp:5:
openrw/rwgame/states/BenchmarkState.hpp:33:23: warning: 'BenchmarkState::getCamera' hides overloaded virtual function
[-Woverloaded-virtual]
const ViewCamera& getCamera();
^
openrw/rwgame/State.hpp:51:31: note: hidden overloaded virtual function 'State::getCamera' declared here: different number of
parameters (1 vs 0)
virtual const ViewCamera& getCamera(float alpha);
^
In file included from openrw/rwgame/RWGame.cpp:6:
openrw/rwgame/states/IngameState.hpp:53:18: warning: 'draw' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
virtual void draw(GameRenderer* r);
^
openrw/rwgame/State.hpp:28:18: note: overridden virtual function is here
virtual void draw(GameRenderer* r) {
^
In file included from openrw/rwgame/RWGame.cpp:6:
openrw/rwgame/states/IngameState.hpp:60:23: warning: 'getCamera' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
const ViewCamera& getCamera(float alpha);
^
openrw/rwgame/State.hpp:51:31: note: overridden virtual function is here
virtual const ViewCamera& getCamera(float alpha);
^
openrw/rwgame/RWGame.cpp:242:22: warning: unused variable 'vehicleModel' [-Wunused-variable]
uint16_t vehicleModel = 110; // @todo Which cars are spawned?!
^
In file included from openrw/rwengine/src/script/modules/GTA3Module.cpp:1:
In file included from openrw/rwengine/src/engine/GameState.hpp:7:
openrw/rwengine/src/engine/ScreenText.hpp:140:63: warning: suggest braces around initialization of subobject [-Wmissing-braces]
const std::array<GameString, sizeof...(args)> vals = {args...};
^~~~
{ }
openrw/rwengine/src/script/modules/GTA3ModuleImpl.inl:5669:16: note: in instantiation of function template specialization
'ScreenText::format<std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> > >'
requested here
ScreenText::format(
^
In file included from openrw/rwengine/src/script/modules/GTA3Module.cpp:1:
In file included from openrw/rwengine/src/engine/GameState.hpp:7:
openrw/rwengine/src/engine/ScreenText.hpp:140:63: warning: suggest braces around initialization of subobject [-Wmissing-braces]
const std::array<GameString, sizeof...(args)> vals = {args...};
^~~~
{ }
openrw/rwengine/src/script/modules/GTA3ModuleImpl.inl:10214:18: note: in instantiation of function template specialization
'ScreenText::format<std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> >,
std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> > >' requested here
ScreenText::format(script::gxt(args, gxtEntry),
^
openrw/rwgame/State.cpp:40:42: warning: unused parameter 'alpha' [-Wunused-parameter]
const ViewCamera& State::getCamera(float alpha) {
^
openrw/rwengine/src/render/ObjectRenderer.cpp:20:17: warning: unused variable 'kWorldDrawDistanceFactor'
[-Wunused-const-variable]
constexpr float kWorldDrawDistanceFactor = kDrawDistanceFactor;
^
After some researches I found that,
script with opcode 03d5 removes only short
connected with sound, not cutscene's text.
Example:
aa12022061/19_8ball.sc (L164)
But in case of cutscenes, script doesn't do anything,
so logically suspecting, all opcodes connected with key word NOW,
are flushing currently used text.
aa12022061/19_8ball.sc (L862)
Default initialization has a problem,
it doesn't initialize POD class,
so it's safer to use value initialization,
especially for "outside" class (like bullet).
* Replace "new" operator with std::make_unique for BS in BinaryStream.cpp
* Replace "new" operator with std::make_unique for textureArchive in TextureArchive.cpp
* Replace "new" operator with std::make_unique for variables in LoaderIDE.cpp
* Addition constructor for InstanceData
* Replace "new" operator with std::make_shared for instance in LoaderIPL.cpp