- make FileIndex const correct (std::map::operator[] modifies the std::map)
- use a single map
- keys are paths relative in the game data directory + filenames
(so paths like "data/main.scm" can be found twice in the map)
- normalization of the file paths is done inside FileIndex,
so there shouldn't be any ::tolower's anymore.
- added a normalizer helper function "normalizeFilePath"
- added Documentation
This is caused by different handling of formatted input in the C++
standard library on macOS than on a linux box.
On linux, characters after a number are ignored (such as 'f' in this
case), on macOS this leads to an error on the stream.
Fixed: mission timer
Timer was going crazy due to missing 02d9 opcode, update timer 25 times per second
Fixed: mission timer
Don't beep on every timer update
Fixes #519
==13884==ERROR: AddressSanitizer: heap-use-after-free on address 0x607000b3d954 at pc 0x0000008ba469 bp 0x7ffd7c8f9ab0 sp 0x7ffd7c8f9aa0
READ of size 4 at 0x607000b3d954 thread T0
#0 0x8ba468 in PlayerController::isTalkingOnPayphone() const /home/maarten/programming/openrw/rwengine/src/ai/PlayerController.cpp:315
#1 0xa148eb in CharacterObject::updateMovementAnimation(float) /home/maarten/programming/openrw/rwengine/src/objects/CharacterObject.cpp:128
#2 0xa185d9 in CharacterObject::updateCharacter(float) /home/maarten/programming/openrw/rwengine/src/objects/CharacterObject.cpp:356
#3 0xa17735 in CharacterObject::tick(float) /home/maarten/programming/openrw/rwengine/src/objects/CharacterObject.cpp:297
#4 0x7c7731 in RWGame::tick(float) /home/maarten/programming/openrw/rwgame/RWGame.cpp:541
#5 0x7c6abb in RWGame::run() /home/maarten/programming/openrw/rwgame/RWGame.cpp:447
#6 0x793b45 in main /home/maarten/programming/openrw/rwgame/main.cpp:17
#7 0x7f154c17e18a in __libc_start_main (/lib64/libc.so.6+0x2318a)
#8 0x793839 in _start (/home/maarten/programming/openrw/build/build/rwgame/rwgame+0x793839)
Fixes this warning:
/home/maarten/programming/openrw/rwengine/src/objects/CharacterObject.cpp:202:54: runtime error: downcast of address 0x00000ae11d00 which does not point to an object of type 'PlayerController'
0x00000ae11d00: note: object is of type 'DefaultAIController'
00 00 00 00 58 91 ca 00 00 00 00 00 e0 2e 90 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'DefaultAIController'
/home/maarten/programming/openrw/rwengine/src/objects/CharacterObject.cpp:202:75: runtime error: member call on address 0x00000ae11d00 which does not point to an object of type 'PlayerController'
0x00000ae11d00: note: object is of type 'DefaultAIController'
00 00 00 00 58 91 ca 00 00 00 00 00 e0 2e 90 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'DefaultAIController'
/home/maarten/programming/openrw/rwengine/src/ai/PlayerController.hpp:66:16: runtime error: member access within address 0x00000ae11d00 which does not point to an object of type 'PlayerController'
0x00000ae11d00: note: object is of type 'DefaultAIController'
00 00 00 00 58 91 ca 00 00 00 00 00 e0 2e 90 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'DefaultAIController'
Logic error: Called C++ object pointer is null
1: Assuming 'enable' is not equal to 0 in /home/filip/Projekty/qt/
small/rwengine/src/objects/VehicleObject.cpp:708
2: Assuming pointer value is null in /home/filip/Projekty/qt/small/
rwengine/src/objects/VehicleObject.cpp:709
3: Called C++ object pointer is null in /home/filip/Projekty/qt/small/
rwengine/src/objects/VehicleObject.cpp:716
* Make player gain money from getting into a taxi
* Remove redundant condition in VehicleObject
* Add documenting comment on SpecialModel
* Limit collecting money from each taxi to only once
Until now buoys would just fall down, we need to apply the force with an impulse to make it work. To update the object in debug mode, a tickPhysics function had to be created, like the vehicles already use.
There's a lot of unneeded operation,
I mean coping strings and searching in loops.
We can get rid of it with extra method (passing
by sound by ref) or coping code.
PS cutscene's sound loses sync, because cutscene
doesn't stop.
X86 is able to deal with
misaligned memory, but it can hurt perf.
Other arch like for example mips
is not able to digest it.
So in order of portability we should get
rid of this UB.
* move delete to earlier stage
* lines for better readability
* Added detach shader
* Addition forgotten glDeleteProgram
https://github.com/rwengine/openrw/search?utf8=%E2%9C%93&q=glDeleteProgram&type=
In project there's no necessary clearing call of glDeleteProgram.
* Removing/Closing shader programs
Each shader program should be taken care by glDeleteProgram.
To make it works/usefull, each shader's raw ptr will convertet to unique_ptr
in next commit.
* Converting ShaderProgram's ptr to unique
Actually deleting isn't handled,
so this commit removes memory leak.
Should fix this memory leak:
==16721== 8 bytes in 1 blocks are definitely lost in loss record 7 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x7E7B5D: GameWorld::GameWorld(Logger*, GameData*) (GameWorld.cpp:100)
==16721== by 0x76EC0B: std::_MakeUniq<GameWorld>::__single_object std::make_unique<GameWorld, Logger*,
GameData*>(Logger*&&, GameData*&&) (unique_ptr.h:825)
==16721== by 0x760F50: RWGame::newGame() (RWGame.cpp:107)
==16721== by 0x78E713: LoadingState::enter() (LoadingState.cpp:9)
==16721== by 0x76602B: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, ch
ar**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:4
0)
==16721== by 0x760842: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==16721== by 0x750385: main (main.cpp:13)
Should fix this memory leak:
==16721== 103 bytes in 1 blocks are definitely lost in loss record 181 of 264
==16721== at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==16721== by 0x58F1AF3: ??? (in /usr/lib64/libLinearMath.so.2.83)
==16721== by 0x83E3C9: btBoxShape::operator new(unsigned long) (btBoxShape.h:34)
==16721== by 0x83CD75: VehicleObject::createObjectHinge(VehicleObject::Part*) (VehicleObject.cpp:722)
==16721== by 0x83C251: VehicleObject::setPartLocked(VehicleObject::Part*, bool) (VehicleObject.cpp:610)
==16721== by 0x83C2D0: VehicleObject::setPartTarget(VehicleObject::Part*, bool, float) (VehicleObject.cpp:623)
==16721== by 0x7B10CD: Activities::EnterVehicle::update(CharacterObject*, CharacterController*) (CharacterController.cpp:226)
==16721== by 0x7B062D: CharacterController::updateActivity() (CharacterController.cpp:26)
==16721== by 0x7B09FE: CharacterController::update(float) (CharacterController.cpp:98)
==16721== by 0x8EBBFA: DefaultAIController::update(float) (DefaultAIController.cpp:87)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721==
==16721== 120 bytes in 5 blocks are definitely lost in loss record 187 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x8EBA26: DefaultAIController::update(float) (DefaultAIController.cpp:63)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721== by 0x763128: RWGame::run() (RWGame.cpp:420)
==16721== by 0x750394: main (main.cpp:15)
Should fix this memory leak:
==16721== 120 bytes in 5 blocks are definitely lost in loss record 187 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x8EBA26: DefaultAIController::update(float) (DefaultAIController.cpp:63)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721== by 0x763128: RWGame::run() (RWGame.cpp:420)
==16721== by 0x750394: main (main.cpp:15)
Should fix this memory leak:
==16721== 912 (600 direct, 312 indirect) bytes in 1 blocks are definitely lost in loss record 225 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x84A697: GameRenderer::GameRenderer(Logger*, GameData*) (GameRenderer.cpp:71)
==16721== by 0x75FC7D: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:35)
==16721== by 0x750385: 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== 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 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
On Visual Studio 2017
std::istringstream ss("0.4f,0.8f,");
float f1, f2;
ss >> f1; /* Will leave the f suffix available on the stream. */
ss.ignore(2, ','); /* Ignore until the comma. */
ss >> f2;
...