1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00
Commit Graph

105 Commits

Author SHA1 Message Date
Anonymous Maarten
2ad9667b50 rwengine: add per-font mapping + unicode support + tests 2018-08-04 01:11:47 +02:00
Filip Gawin
d95d05e291 Remove old style cast 2018-07-29 22:21:01 +02:00
Filip Gawin
b2c2075be7 cast_to_float 2018-07-26 00:10:17 +02:00
Filip Gawin
da7e54b64a Rename bit_cast.hpp to casts.hpp and add cast_to_int 2018-07-26 00:09:58 +02:00
Filip Gawin
247a4c034d Use LoaderSDT to feed ffmpeg using sfx sounds
Function loadSound returns
AVFormatContext with custom AVIOContext.
2018-07-11 21:43:38 +02:00
Daniel Evans
83ee9ef568
Merge pull request #526 from madebr/rwlib_changes
Rwlib changes
2018-07-05 22:05:56 +01:00
Anonymous Maarten
8aee672466 rwlib: refactor FileIndex
- 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
2018-06-30 04:03:20 +02:00
Anonymous Maarten
4f60dfad43 rwlib: bit_case is a header, not a source file 2018-06-30 04:03:20 +02:00
Anonymous Maarten
36149cf38e rwlib: rw/defines.hpp -> rw/debug.hpp 2018-06-30 04:03:20 +02:00
Anonymous Maarten
b6a2b2181d cmake: do not override find modules but wrap them separately 2018-06-14 02:10:54 +02:00
Anonymous Maarten
8f70b36d6f cmake: include all dependencies at top of main CMakeLists.txt 2018-06-14 02:10:54 +02:00
Anonymous Maarten
52a9cc42f5 rwlib: create librw library instead of librwlib library 2018-06-08 18:30:25 +02:00
Anonymous Maarten
7d18898e2c cmake: only install shared libraries 2018-06-08 18:30:25 +02:00
Anonymous Maarten
e3c0b00453 cmake: use GNUInstallDirs for install paths + install everything (optionally) 2018-06-08 18:30:25 +02:00
Filip Gawin
09c5d36398 Set ptr to const if possible
Also:
- make args name matching in header
and source file,
- make more ptrs to const ref,
2018-05-16 19:17:13 +02:00
Filip Gawin
4e1948c23c Rearrange passing args to functions/ctors
Kill extra shared_ptr by passing them using const reference.
Use perfect forwarding for strings.
Remove redundant std::move.
2018-05-16 19:17:13 +02:00
Filip Gawin
2aa6d3b3b3 More nullptr 2018-04-17 16:15:17 +02:00
Filip Gawin
cf5efb9560 Use "= default" for trivial ctor/dtor 2018-04-17 16:15:17 +02:00
Anonymous Maarten
aa71fd4a6a rwlib: boost 1.58.0 needs to inclue boost/version.hpp for BOOST_VERSION 2018-02-15 21:10:11 +00:00
Filip Gawin
96ed30bc02 Three emplace_backs more 2018-02-14 22:32:08 +00:00
Filip Gawin
1ae0768725 Move temp data(instead of copying) 2018-02-14 22:32:08 +00:00
Anonymous Maarten
91fc924a45 rwlib: do not include <Windows.h> in defines.hpp 2018-02-13 22:15:26 +00:00
Christoph Heiss
bbf0752a3d Fix unit test 'LoaderDFF/test_clump_clone'.
This test crashed apparently only on macOS, although it should have not
worked on Linux as well as it exhibits undefined behavior

Anyway, the cause was passing a uninitialized variable into OpenGL as a
buffer id. Just initialize it with 0 (reserved 'no object' id) and check
before using it.
2018-02-10 16:58:59 +00:00
Lucas Eriksson
3e96ad9c92 Stop using default initialization onglm datatypes.
It results in undefined behaviour with glm 0.9.9
2018-02-09 22:33:10 +00:00
Filip Gawin
73a5daab82 Use range loop 2018-02-06 19:19:09 +00:00
Daniel Evans
23fc9bbbe8 Remove RWTypes RGB and RGBA as they are unused 2018-01-30 01:48:33 +00:00
Daniel Evans
6780be6fff Update hierarchy transforms for new frame children 2018-01-27 21:36:22 +00:00
Filip Gawin
a60bc20585 Fix misaligned memory(UB)
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.
2018-01-13 00:49:17 +00:00
Filip Gawin
70d72fed38 Change type of _currChunkSz 2018-01-08 23:00:30 +00:00
Filip Gawin
3db102a13e braced initializer 2018-01-08 23:00:30 +00:00
Anonymous Maarten
90acef28f7 rwlib: iwyu: reduce warnings
- use mapping file
- forward define FileContentsInfo, CutsceneTracks, GameTexts
- no more "#pragma once"
- add mapping file
2018-01-08 22:52:48 +00:00
Filip Gawin
8cc8be5603 Small change, new -> make_shared. 2018-01-05 06:51:58 +00:00
Anonymous Maarten
f14bf308cf rwlib: rwlib has a dependency on glm 2018-01-05 06:21:34 +00:00
Anonymous Maarten
9231ecbcb0 cmake: use OpenGL::GL instead of OpenGL::OpenGL
- OpenGL::GL -> defined to the platform-specific OpenGL libraries
- OpenGL::OpenGL -> defined to libOpenGL if the system is GLVND
2017-12-17 01:36:08 +00:00
Anonymous Maarten
32fb5eb409 rwlib: LoaderIMG accepts rwfs::path 2017-11-17 00:50:50 +00:00
Anonymous Maarten
820c4bd25c rwengine: GameData accepts rwfs::path as path of game data 2017-11-17 00:50:50 +00:00
Anonymous Maarten
6dffed543a rwlib: add error_code to rwfs namespace
Some rwfs functions need an error_code argument.
2017-11-17 00:50:50 +00:00
Daniel Evans
9c48b4424a Add build time option for CXX17 or boost filesystem 2017-10-31 00:55:19 +00:00
Anonymous Maarten
a40a2706a9 cmake: add support for include-what-you-use to check #include's
The output is currently very verbose and includes many false positives.
Adding a mapping file should solve this.

See
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md
2017-10-29 20:40:57 +00:00
Anonymous Maarten
06c4bf09f7 cmake: make OpenGL an imported target 2017-10-29 20:40:57 +00:00
Anonymous Maarten
e555331748 cmake: be more specific about Boost library to link with
CMake 3.2's FindBoost.cmake does not support boost:: namespaces
2017-10-29 20:40:57 +00:00
Anonymous Maarten
99951b9e05 cmake: reformat rwlib/CMakeLists.txt 2017-10-29 20:40:57 +00:00
Anonymous Maarten
1926795d63 cmake: use rwengine::interface + no more add_definitions & include_directories 2017-10-29 20:40:57 +00:00
Filip
c54cfa0ae8 Avoid making unnecessary copies (#337)
* frames.emplace_back

* vehicleColours.emplace_back

* colours.emplace_back

* waterBlocks.emplace_back

* state.garages.emplace_back

* bonedata->frames.emplace_back

* lines.emplace_back

* circleVerts.emplace_back

* geo.emplace_back

* Water renderer

* perf_colours.emplace_back
2017-10-29 17:14:07 +00:00
Anonymous Maarten
2282734425 rwlib: free Geometry OpenGL buffers
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)
2017-10-18 21:52:29 +01:00
Anonymous Maarten
c2da40d0a0 rwlib/rwengine: Use AnimationPtr instead of Animation*
Should fix these memory leaks:
==31441== 3,694,699 (17,248 direct, 3,677,451 indirect) bytes in 196 blocks are definitely lost in loss record 2,720 of 2,723
==31441==    at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==31441==    by 0x81D98E: LoaderIFP::loadFromMemory(char*) (LoaderIFP.cpp:69)
==31441==    by 0x7BE5D2: GameData::loadIFP(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameData.cpp:506)
==31441==    by 0x7B9B4A: GameData::load() (GameData.cpp:59)
==31441==    by 0x7590C5: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:51)
==31441==    by 0x749175: main (main.cpp:13)
==31441==
==31441== 5,298,984 (1,080 direct, 5,297,904 indirect) bytes in 15 blocks are definitely lost in loss record 2,722 of 2,723
==31441==    at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==31441==    by 0x820253: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> > >::allocate(unsigned long, void const*) (new_allocator.h:111)
==31441==    by 0x820175: std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> > > >::allocate(std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> > >&, unsigned long) (alloc_traits.h:436)
==31441==    by 0x81FFB4: std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_M_get_node() (stl_tree.h:588)
==31441==    by 0x81FE03: std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >* std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_M_create_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&>(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&) (stl_tree.h:642)
==31441==    by 0x81FC26: std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >* std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_Alloc_node::operator()<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&>(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&) const (stl_tree.h:556)
==31441==    by 0x81F620: std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> > std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_M_insert_<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&, std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_Alloc_node>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&, std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_Alloc_node&) (stl_tree.h:1753)
==31441==    by 0x81EDFD: std::pair<std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, bool> std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> >, 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, AnimationBone*> > >::_M_insert_unique<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&>(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&) (stl_tree.h:2096)
==31441==    by 0x81E9F0: std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, AnimationBone*, 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, AnimationBone*> > >::insert(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AnimationBone*> const&) (stl_map.h:796)
==31441==    by 0x81E0BB: LoaderIFP::loadFromMemory(char*) (LoaderIFP.cpp:132)
==31441==    by 0x7BE5D2: GameData::loadIFP(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameData.cpp:506)
==31441==    by 0x7E4060: GameWorld::loadCutscene(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:692)
2017-10-18 21:52:29 +01:00
Anonymous Maarten
5ff31db04f rwlib: Delete textures on close
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)
2017-10-18 21:52:29 +01:00
Anonymous Maarten
7e4e1db85d rwlib: Use ClumpPtr instead of Clump*
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)
2017-10-18 21:52:29 +01:00
Christoph Heiss
fab9047ef9 Update OpenGL loader files.
Generated using:
lua LoadGen.lua -style=noload_c -spec=gl -version=3.3 -profile=core core_3_3 -stdext=gl_ubiquitous.txt -stdext=gl_core_post_3_3.txt
2017-10-13 19:54:10 +01:00
Anonymous Maarten
02c60311ee rwlib/rwengine: make use of RW_ASSERT instead of assert 2017-09-16 22:19:39 +01:00