Commit Graph

1160 Commits (master)

Author SHA1 Message Date
elsid 78b3f7288a
Support UTF-8 by StringRefId::toDebugString 2 years ago
Evil Eye 7b0680de5f Resolve attribute GMST members 2 years ago
Petr Mikheev 1b669db017 Load ESM4::Tree and ESM4::Furniture 2 years ago
florent.teppe ad8cfde4e0 ESM::LandData no longer a virtual interface
instead it is constructed from ESM::Land or ESM4::Land
2 years ago
fteppe 22dc383f63 fixes errors and warnings
Applies review comments

getWorldspaceTerrain => returns a reference because never null
crashfix in navigator
updateLandPositions fixes naming of it
const ESM4::Land* MWWorld::Store<ESM4::Land>::search(ESM::ExteriorCellLocation cellLocation) const removes useless else
ExteriorCellLocation uses default initializers
get terrain height returns -MAX_FLOAT when there is no esm4 terrain.

applied review comments

use default initlializer when possible
factorise code
uses pattern matching in for loop.
2 years ago
florent.teppe d0211acf9e Fixes bug in terrain loading + collision heightmap works
although terrain rendering is 100% broken right now
2 years ago
florent.teppe fffcf52316 land manager cache's key is an ExteriorCellLocation
ESM4::Land is now a ESM::LandData
2 years ago
florent.teppe e0fa15b727 Abstracted Land data that can be used by esm3 and esm4. 2 years ago
Evil Eye 90a3a7b62f Add mWerewolfGMST 2 years ago
Evil Eye a5e1c87fb8 Remove sGmstAttributeIds, sGmstAttributeDescIds, sAttributeIcons 2 years ago
unknown 14600de185 Remove sAttributeIds and sSkillIds 2 years ago
elsid 235eb65c97
Rename positionToCellIndex to match return type 2 years ago
Evil Eye 877f6747be Deduplicate specialization code 2 years ago
Pierre Mossler e6838cddc7 missing include in attr.cpp 2 years ago
Mads Buvik Sandvei b791ce9132 Remove redundant qualifiers 2 years ago
Mads Buvik Sandvei 7ba43c9426 actor.ActiveEffects and actor.ActiveSpells 2 years ago
florent.teppe a3bd6e7e47 ESM::ExteriorCellIndex => ESM::ExteriorCellLocation 2 years ago
florent.teppe 393357abc0 ESM::Cell::positionToCellIndex returns a ESM::ExteriorCellIndex
and takes a worldspace id as input
ESM::getCellSize takes a wordspace as input.
removed useless static in static inline funcs
2 years ago
florent.teppe 559830f59a applies review comments
Removes ToLowercase after .serializeText
removed unused variable
!ptr => ptr == nullptr
better indentation + error message on throw
friend struct std::hash<...> useless on struct with all public fields.
2 years ago
florent.teppe 3d06cabf6a indexToPosition moved from world -> esm/util.hpp 2 years ago
florent.teppe 1cf0cd5628 moved mwworld/cellutils.hpp -> esm/util.hpp 2 years ago
florent.teppe 75561abfca Factorises code and fixes preload bug. 2 years ago
florent.teppe 141878f30d int x, int y , ESM::RefId worldspace => ESM::ExteriorCellIndex
also removed the changeToExteriorCell that only took a position as input, didn't work with esm4.
2 years ago
florent.teppe 1d03b54694 maps with tuple key instead of map of map
instead of using a map with key as exterior and map of <int ,int >, Cell as value we use a single map with a tuple x,y,exterior as key
2 years ago
elsid 0601d7213e
Remove ESM::RefId::sEmpty
This variable is only required to return empty RefId as const reference. There
is no point in doing so for a type cheap to copy.
2 years ago
florent.teppe 3bbf60373a Keep things coherent between references and and cell table 2 years ago
psi29a 70ddca78bf Merge branch 'ref_id_print_tests' into 'master'
Add more tests for printing RefId and clarify some constants

See merge request OpenMW/openmw!2945
2 years ago
elsid 7db14b3392
Add more tests for printing RefId and clarify some constants 2 years ago
elsid c97df7d770
Check FormIdRefId value in constructor 2 years ago
Petr Mikheev 00beb06391 Initial Lua bindings for ESM4 types; bindings for ESM4Door. 2 years ago
Evil Eye 97fb06d8c9 Add RefId::is 2 years ago
elsid 20129568e6
Replace VisitorCellIdIsESM3Ext with RefId::getIf function 2 years ago
Petr Mikheev ff774d6406 Load more ESM4 records 2 years ago
Petr Mikheev f09a689a4f Merge ESM::RefNum and ESM4::FormId 2 years ago
elsid bd10becb65
Use lexicographical comparison in ESM3ExteriorCellRefId::operator< 2 years ago
elsid 794050df63
Fix and add tests for ESM3ExteriorCellRefId serialization and text representation 2 years ago
florent.teppe 0d17e20490 Implements serialize/deserialize
fixes test compilation.
2 years ago
florent.teppe 21bd28542a Applies review advice
2d coord hash moved to hash.hpp file
format version adds suffix to be more coherent
don't use ESM::RefId::sEmpty
RefId equality with string_view, conversion to refId unecessary
action teleport remove test that mCellId is empty
removes some const references, when copy is enough
invalid refid => empty refid
removes useless change
2 years ago
florent.teppe d782d37ee2 Make sure Vec2iRefId is trivially copyable on GCC 11.3
std::pair<int, int> isn't trivially copyable on some compilers
so a specific struct is defined, it's an int pair, but it should be recognised by GCC 11.3 as trivially copyable

Vec2iRefId => ESM3ExteriorCellRefId

more explcit name and use mX,mY instead of pair
renamed files and enum
2 years ago
florent.teppe 4c15064a83 Create new Vec2i RefId for ESM3 exterior cells.
Applies the necessary changes to use !2708 for the new Id type
2 years ago
florent.teppe c39dd576f8 Gets rid of most ESM::CellId 2 years ago
psi29a 0a791528bc Merge branch 'fix_index_ref_id_hash' into 'master'
Shift record type value for IndexRefId hash

See merge request OpenMW/openmw!2885
2 years ago
elsid 171a25645a
Make sure there are tests for all RefId types 2 years ago
elsid 258aec223a
Shift record type value for IndexRefId hash 2 years ago
elsid 90ed24f4c9
Split type traits for ESM4, ESM3 and unite common 2 years ago
psi29a 8f80895b59 Merge branch 'build_fix' into 'master'
Add missing include

See merge request OpenMW/openmw!2860
2 years ago
Andrei Kortunov e1bee039ac Add missing include 2 years ago
elsid b7fdca0fe6
Use serialized ESM::RefId for Lua records 2 years ago
elsid cd4027ffd6
Do not use ESM::RefId::getRefIdString for spell id 2 years ago
elsid 04d7781424
Support not only StringRefId for checking first person body part 2 years ago
elsid e6cf516e12
Support index RefId as pair of record type and std::uint32_t 2 years ago
elsid 86293af084
Support generated RefId as std::uint64_t 2 years ago
elsid 0992624c8b
Support reading and writing typed ESM::RefId to ESM 2 years ago
elsid 069d4255b9
Make ESM::RefId to be fixed size cheap to copy
Use std::variant. Store refId strings in unordered_set and use pointer to an
item there. Inserts to unordered_set do not invalidate pointers to values so the
pointer is always valid. Elements are not removed. Assume there is finite number
of string refIds.
2 years ago
elsid 83d212fe0f
Use SFINAE to avoid conflicts between visit functions 2 years ago
elsid cd6a5b5a0e
Support asymmetric comparison between ESM::RefId and std::string_view 2 years ago
elsid dfcea389be
Add helper functions for string comparison to RefId 2 years ago
elsid 6518688120
Reorder RefId members 2 years ago
elsid 2fcb94064d
Support RefId comparison with std::string_view 2 years ago
elsid 996153f78d
Convert RefId to class 2 years ago
elsid 6d261d38dd
Add functions to read and write ESM::RefId and use them
To be later changed with another implementation.
2 years ago
elsid 80e6d6cbe3
Support variable size strings in ESM3 2 years ago
elsid 2e64155c0f
Use signed type for left record and files size in ESM3 reader context
Otherwise reading some of the records like ESM::CellRef without a subrecord
after could lead to underflow of ESM_Context::leftRec which makes
ESM::ESMReader::hasMoreSubs to return true and load hangs for a while trying to
read the same subrecord many times.

Fix ESM::Variant tests since it's now required to have a record for any ESM
data. Add 16 (size of record header) to all expected data sizes.
2 years ago
florent.teppe 084207af64 Avoids a lot a special cases for ESM3 vs ESM4 cells. 2 years ago
florent.teppe 1caed2de2a Applies some review comments.
Proper visit for ESM::CellVariant

Fixed MWWorldCell constructor
2 years ago
florent.teppe ebfee18e35 implements std::visit for CellVariant, fixes struct vs class forward decl 2 years ago
florent.teppe aa29f86efe fixed struct vs class. 2 years ago
florent.teppe 216ca71149 Applied review comments
getEditorName => getNameId
restored cosntructor in CoordinateConverter
2 years ago
florent.teppe e6e27413d9 gives MWWorld::CellRef the MWWorld::Cell treatment
MWWorld::CellRef now has a variant, and datas that are part of the intersection of both ESM4::Reference and ESM::CellRef are part of MWWorld::CellRef

For ESM4 most data isn't filled in, so it returns default values.
2 years ago
florent.teppe 23614ae2ae Renamed esm3esm4bridge => esmbridge 2 years ago
florent.teppe 5037dcf9bc Fixes a crash on launch and some compile issue
also uses std::visit in cellstore comparison to avoid missing combinasion

split loadrefs in loadref of ESM4 and ESM3.
2 years ago
florent.teppe cb8cdd8831 ESM::CellVariant aans MWWorld:Cell now take reference in constructor: signals that nullptr isn't accepted.
also applied other review comments.
2 years ago
florent.teppe 531e55e04c Better handling of the esm3 vs esm4 cell problem
Common attribute are in one structure that has two constructors, one for ESM3 vs ESM4 Cell
Mood part of MWWorld::Cell
2 years ago
florent.teppe 3515c8e61a Static references are created as refcells, nothing displayed yet. 2 years ago
florent.teppe c896a2ca48 Crashfix on launch 2 years ago
florent.teppe 0018bcf7de Should make cellvariant safer to use.
Hopefully clang tidy agrees.
2 years ago
florent.teppe 562e129bd0 encapsulations of esm3 cell and esm4 cells. 2 years ago
florent.teppe 08b68fcd48 Cannot load a cell yet, but getting more necessary parts in 2 years ago
psi29a 83718878b2 Merge branch 'Load_ESM4' into 'master'
Loading ESM4 data and storing them in the ESMStore

See merge request OpenMW/openmw!2557
2 years ago
elsid 2bbed8cc06
Fix gcc warning: array subscript 5 is outside array bounds of ‘const char [5]’
In function ‘bool ESM::operator==(const FixedString<capacity>&, const T* const&) [with long unsigned int capacity = 5; T = char; <template-parameter-1-3> = void]’,
    inlined from ‘testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = ESM::FixedString<5>; T2 = const char*]’ at /home/elsid/dev/googletest/build/gcc/release/install/include/gtest/gtest.h:1358:11,
    inlined from ‘static testing::AssertionResult testing::internal::EqHelper::Compare(const char*, const char*, const T1&, const T2&) [with T1 = ESM::FixedString<5>; T2 = const char*; typename std::enable_if<((! std::is_integral<_Tp>::value) || (! std::is_pointer<_Dp>::value))>::type* <anonymous> = 0]’ at /home/elsid/dev/googletest/build/gcc/release/install/include/gtest/gtest.h:1377:64,
    inlined from ‘virtual void {anonymous}::EsmFixedString_equality_operator_for_not_convertible_to_uint32_with_const_char_pointer_Test::TestBody()’ at apps/openmw_test_suite/esm/test_fixed_string.cpp:165:9:
components/esm/esmcommon.hpp:134:19: warning: array subscript 5 is outside array bounds of ‘const char [5]’ [-Warray-bounds]
  134 |         return rhs[capacity] == '\0';
      |                ~~~^
apps/openmw_test_suite/esm/test_fixed_string.cpp: In member function ‘virtual void {anonymous}::EsmFixedString_equality_operator_for_not_convertible_to_uint32_with_const_char_pointer_Test::TestBody()’:
apps/openmw_test_suite/esm/test_fixed_string.cpp:164:20: note: at offset 5 into object ‘other’ of size 5
  164 |         const char other[5] = { 'a', 'b', 'c', 'd', '\0' };
      |                    ^~~~~
2 years ago
florent.teppe 077cf97bc4 The esm4 reader logic is mutualised
to avoid copy pasting code, readerutils gives functions that take visitors as params to decide how a record must be handled

Check encoder exists, and get value of stateless encoder.

fixes code formatting conventions

Fixed output of record with RefId

also fixed readTypedRecord and readRecord to have the proper return types

Check if the type has a sRecordId
2 years ago
florent.teppe c721a6cafa Initial commit to load ESM4
Some data is actually loaded and store in ESM Store
Any new ESM4 will go through the same code path and be automatically sent to the right store
2 years ago
elsid 755067f0f3
Remove redundant ESM::RefId member functions 2 years ago
elsid fe57aec2a4
Move ESM::RefId comment to make sure IDEs recognize it and show in tooltips 2 years ago
florent.teppe dc21df97c8 Fixed issue with getSummonedCreature( that returned a reference to a non const static value
Fix compile, and apply review comment

Fixed greater vs more typo.

getCellname is back to a string view.

Because in most cases was used as a strong not a refId.
and there was a fundamental issue with region names used as a cellname
2 years ago
florent.teppe e7deffb376 Adds comment that explains what RefIds are 2 years ago
florent.teppe d49f60d2d6 To change fewer things with the master implementation, the Id isn't changed to lower case on creation
lower case utility functions used in comparison functions
2 years ago
florent.teppe 65cdd489fb create a specific esm reader function for RefID to avoid allocation for string and then again for RefId
Fixed some types

removed useless header

applied clang format

fixed compile tests

fixed clang tidy, and closer to logic before this MR

Removed hardcoded refids

unless there is a returned value we don't use static RefIds
can use == between RefId and hardcoded string

Fix clang format

Fixed a few instances where std::string was used, when only const std::string& was needed

removed unused variable
2 years ago
fteppe c283ea0ae8 string_view& => string_view
fixed ref to temp variable
2 years ago
fteppe 7da38113be Changed more hardcoded RefId to be static to avoid multiple runtime creations
adresses multiple review comments
2 years ago
fteppe 62d8fe3fc2 changed a few hardcoded refIds used in mutliple places to be defined only once in a variable 2 years ago
fteppe 0d68735e23 moved all code in CPP in ESM namespace since it was already necessary for << operator
in the equality operator, no longer need ciequal since the id is already always lowercase
2 years ago
fteppe c8bb733360 removed clear() function, the only way to change the Id from the outside is from the assignment operator
replaced ciEqual with == operator
2 years ago
fteppe ee941f9b09 RefId's mId can't be get as mutable from the outside
also removed useless operator= defintion
2 years ago
fteppe d6d2a37d03 some clean and better comments 2 years ago
fteppe 125b21de20 Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
2 years ago
elsid baa39c06bb
Move fourCC to a separate file 2 years ago
elsid 843753da14
Remove unused includes 2 years ago
jvoisin 3cbf1dc042 First pass with include-what-you-use 2 years ago
clang-format-bot ddb0522bbf
Apply clang-format to code base 2 years ago