1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-08-13 23:14:06 +00:00
Commit graph

86 commits

Author SHA1 Message Date
elsid
d121b606b6
Fix and enforce local variable naming 2025-08-05 21:27:48 +02:00
Petr Mikheev
0b5c8271e0 ESM4 landscape textures 2025-08-01 18:45:24 +02:00
elsid
ec0c76d2f3
Ignore false positive warning
cellSize > 1 so the result of the division cannot be undefined.

/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:18:35: error: The result of the '/' expression is undefined [clang-analyzer-core.UndefinedBinaryOperatorResult,-warnings-as-errors]
   18 |         std::size_t cell = global / (cellSize - 1);
      |                                   ^
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:13: note: Assuming 'lodLevel' is >= 0
  244 |         if (lodLevel < 0 || 63 < lodLevel)
      |             ^~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:13: note: Left side of '||' is false
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:29: note: Assuming 'lodLevel' is <= 63
  244 |         if (lodLevel < 0 || 63 < lodLevel)
      |                             ^~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:9: note: Taking false branch
  244 |         if (lodLevel < 0 || 63 < lodLevel)
      |         ^
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:247:13: note: Assuming 'size' is > 0
  247 |         if (size <= 0)
      |             ^~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:247:9: note: Taking false branch
  247 |         if (size <= 0)
      |         ^
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:272:13: note: Assuming the condition is false
  272 |         if (land != nullptr)
      |             ^~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:272:9: note: Taking false branch
  272 |         if (land != nullptr)
      |         ^
/home/elsid/dev/openmw/components/esmterrain/storage.cpp:363:9: note: Calling 'sampleCellGrid<const (lambda at /home/elsid/dev/openmw/components/esmterrain/storage.cpp:280:35) &>'
  363 |         sampleCellGrid(cellSize, sampleSize, beginX, beginY, distance, handleSample);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:13: note: Assuming 'cellSize' is >= 2
   72 |         if (cellSize < 2 || !Misc::isPowerOfTwo(cellSize - 1))
      |             ^~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:13: note: Left side of '||' is false
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:9: note: Taking false branch
   72 |         if (cellSize < 2 || !Misc::isPowerOfTwo(cellSize - 1))
      |         ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:13: note: Assuming 'sampleSize' is not equal to 0
   75 |         if (sampleSize == 0 || !Misc::isPowerOfTwo(sampleSize))
      |             ^~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:13: note: Left side of '||' is false
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:9: note: Taking false branch
   75 |         if (sampleSize == 0 || !Misc::isPowerOfTwo(sampleSize))
      |         ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:13: note: Assuming 'distance' is >= 2
   78 |         if (distance < 2 || !Misc::isPowerOfTwo(distance - 1))
      |             ^~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:13: note: Left side of '||' is false
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:9: note: Taking false branch
   78 |         if (distance < 2 || !Misc::isPowerOfTwo(distance - 1))
      |         ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:13: note: Assuming 'distance' is >= 'cellSize'
   84 |         if (distance < cellSize || sampleSize > cellSize - 1)
      |             ^~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:13: note: Left side of '||' is false
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:36: note: Assuming the condition is true
   84 |         if (distance < cellSize || sampleSize > cellSize - 1)
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:9: note: Taking true branch
   84 |         if (distance < cellSize || sampleSize > cellSize - 1)
      |         ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:85:20: note: Calling 'sampleCellGridSimple<const (lambda at /home/elsid/dev/openmw/components/esmterrain/storage.cpp:280:35) &>'
   85 |             return sampleCellGridSimple(cellSize, sampleSize, beginX, beginY, endX, endY, f);
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:56:16: note: 'cellSize' is > 1
   56 |         assert(cellSize > 1);
      |                ^
/usr/include/assert.h💯27: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |                           ^~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:56:9: note: '?' condition is true
   56 |         assert(cellSize > 1);
      |         ^
/usr/include/assert.h💯7: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |       ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:57:9: note: '?' condition is true
   57 |         assert(Misc::isPowerOfTwo(cellSize - 1));
      |         ^
/usr/include/assert.h💯7: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |       ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:58:16: note: 'sampleSize' is not equal to 0
   58 |         assert(sampleSize != 0);
      |                ^
/usr/include/assert.h💯27: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |                           ^~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:58:9: note: '?' condition is true
   58 |         assert(sampleSize != 0);
      |         ^
/usr/include/assert.h💯7: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |       ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:60:9: note: Calling 'sampleGrid<(lambda at /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:61:13)>'
   60 |         sampleGrid(sampleSize, beginX, beginY, endX, endY,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |             [&](std::size_t globalX, std::size_t globalY, std::size_t vertX, std::size_t vertY) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 |                 const auto [cellX, x] = toCellAndLocal(beginX, globalX, cellSize);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   63 |                 const auto [cellY, y] = toCellAndLocal(beginY, globalY, cellSize);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 |                 f(cellX, cellY, x, y, vertX, vertY);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 |             });
      |             ~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:33:38: note: Assuming 'y' is < 'endY'
   33 |         for (std::size_t y = beginY; y < endY; y += sampleSize)
      |                                      ^~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:33:9: note: Loop condition is true.  Entering loop body
   33 |         for (std::size_t y = beginY; y < endY; y += sampleSize)
      |         ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:42: note: Assuming 'x' is < 'endX'
   36 |             for (std::size_t x = beginX; x < endX; x += sampleSize)
      |                                          ^~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:13: note: Loop condition is true.  Entering loop body
   36 |             for (std::size_t x = beginX; x < endX; x += sampleSize)
      |             ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:42: note: Assuming 'x' is < 'endX'
   36 |             for (std::size_t x = beginX; x < endX; x += sampleSize)
      |                                          ^~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:13: note: Loop condition is true.  Entering loop body
   36 |             for (std::size_t x = beginX; x < endX; x += sampleSize)
      |             ^
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:37:17: note: Calling 'operator()'
   37 |                 f(x, y, vertX++, vertY);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:62:41: note: Calling 'toCellAndLocal'
   62 |                 const auto [cellX, x] = toCellAndLocal(beginX, globalX, cellSize);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:18:35: note: The result of the '/' expression is undefined
   18 |         std::size_t cell = global / (cellSize - 1);
      |                            ~~~~~~~^~~~~~~~~~~~~~~~
2025-07-27 12:11:24 +02:00
Evil Eye
ca6baed366 Fix LTEX overriding and allow deletion 2024-06-03 16:42:27 +02:00
Evil Eye
6a10311ae5 Use more appropriate types in terrain storage 2024-05-23 18:48:54 +02:00
elsid
01166b1f26
Split ESM headers 2024-05-03 01:55:20 +02:00
Andrei Kortunov
87c9f395f1 Move local variables in components 2024-01-19 16:01:48 +04:00
elsid
eba553821b
Use std::vector for LandCache implementation 2023-08-27 01:32:36 +02:00
elsid
bda29819cf
Reduce include dependency for land records 2023-08-19 01:30:17 +02:00
elsid
a027cd898b
Use only cell position to detect cell change 2023-08-19 01:30:17 +02:00
elsid
28614730da
Pass land reference to LandObject constructor 2023-08-19 01:30:17 +02:00
elsid
e6f35373b5
Remove ESM::LandObject dependency on ESM::Land 2023-08-19 01:30:16 +02:00
elsid
8a88a2d61f
Make ESM::LandData::mLoadFlags private 2023-08-19 01:30:16 +02:00
elsid
07c1177b0d
Optimize land lookup on blendmaps sampling
Minimize number of getLand calls by grouping samples per cell.
2023-08-12 02:57:16 +02:00
elsid
ce6ffba986
Move blendmap sampling logic into separate function 2023-08-12 02:45:09 +02:00
elsid
8e7fe44514
Support terrain sample size greater than cell size 2023-08-06 23:47:35 +02:00
elsid
2a49919b53
Move esm3terrain to esmterrain 2023-08-06 19:17:44 +02:00
Bret Curtis
cdbab2325f rename esmterrain to esm3terrain 2022-01-23 17:19:30 +01:00
Bret Curtis
d1fb854521 move most of the files from esm to esm3, keep common code in esm; this is make space for a future with esm4
esm typo

esm typo
2022-01-23 17:04:48 +01:00
Bo Svensson
6cf74f7041
refactors ESM::Land (#3213)
With this PR we reduce coupling, simplify code, encapsulate a variable and separate actual `ESM` data from its context.
2021-11-04 16:55:32 +01:00
Andrei Kortunov
8084a336b5 Replace zeroes and nulls by nullptrs 2020-11-29 11:14:07 +04:00
Andrei Kortunov
8ca3c3b123 Mark overrided methods by override keyword 2020-10-16 22:18:54 +04:00
elsid
40ad87bc4d
Replace OpenThreads by std types 2020-06-25 22:16:09 +02:00
Andrei Kortunov
1cdd33b434 Implement additional stringops to avoid Boost functions 2020-01-09 19:40:22 +04:00
bzzt
f09125fc93 perf regression fix 2019-11-20 13:37:00 +00:00
Nelsson Huotari
0ce971c1bb Revert back to less aggressive component-level changes. 2019-10-22 21:26:55 +03:00
Nelsson Huotari
c2428bc5fa Remove unneeded forward declaration 2019-10-22 21:25:10 +03:00
Nelsson Huotari
16138fc896 Transient land shape editing 2019-10-22 21:25:10 +03:00
bzzt
528cda8032 Prevent layers duplication when a terrain chunk crosses plugin borders 2019-06-01 14:52:42 +04:00
Andrei Kortunov
1da012f6ee Optimize blendmap generation 2019-06-01 14:37:29 +04:00
Andrei Kortunov
7c53b99d31 Avoid possible data race during access to the static local variable 2019-05-24 08:03:45 +04:00
Capostrophic
786f3e5fc3 Remove unused and unfinished blendmap packing feature 2019-03-22 22:15:28 +03:00
bzzt
b42ad0f610 Inline certain terrain storage functions 2019-03-17 07:27:27 +03:00
bzzt
e131e6699c Match vertex colors data type to source 2019-03-17 07:24:22 +03:00
Andrei Kortunov
3032b177a1 Remove redundant includes 2019-02-23 08:02:12 +04:00
Andrei Kortunov
e06f0b797a Replace all NULLs to nullptr 2018-10-09 10:21:12 +04:00
Andrei Kortunov
70ed8fd1a9 Use constants instead of widely used magic numbers (task #4645) 2018-09-17 19:22:50 +04:00
Andrei Kortunov
1452684d9e Use new logging system for components 2018-08-14 19:42:41 +04:00
Andrei Kortunov
12144de8ed Initialize missing variables 2018-08-01 20:18:37 +04:00
Andrei Kortunov
359e748c28 Initialize some missing fields in constructors 2018-06-25 09:35:42 +04:00
wareya
94f695cffc Fix #4452 and remove dead code 2018-06-12 21:04:27 -04:00
wareya
7344323b9e remove indentation from blank lines 2018-06-09 10:31:51 -04:00
wareya
8f45b0d53a remove unnecessary conditions 2018-06-09 10:11:43 -04:00
wareya
6277f5511c fix #3876 and #3993 2018-06-08 17:52:46 -04:00
tri4ng1e
d4d1703bcf
Some PVS-Studio and cppcheck fixes
cppcheck:
[apps/esmtool/record.cpp:697]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1126]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1138]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/niftest/niftest.cpp:36]: (performance) Function parameter 'filename' should be passed by reference.
[apps/niftest/niftest.cpp:41]: (performance) Function parameter 'filename' should be passed by reference.
[apps/opencs/model/prefs/boolsetting.cpp:25]: (warning) Possible leak in public function. The pointer 'mWidget' is not deallocated before it is allocated.
[apps/opencs/model/prefs/shortcuteventhandler.cpp:52]: (warning) Return value of std::remove() ignored. Elements remain in container.
[apps/openmw/mwstate/quicksavemanager.cpp:5]: (performance) Variable 'mSaveName' is assigned in constructor body. Consider performing initialization in initialization list.

PVS-Studio:
apps/opencs/model/filter/parser.cpp  582  warn  V560 A part of conditional expression is always true: allowPredefined.
apps/opencs/view/world/referencecreator.cpp  67  warn  V547 Expression '!errors.empty()' is always false.
apps/opencs/view/world/referencecreator.cpp  74  warn  V547 Expression '!errors.empty()' is always false.
apps/opencs/view/doc/loader.cpp  170  warn  V560 A part of conditional expression is always true: !completed.
apps/opencs/view/doc/loader.cpp  170  warn  V560 A part of conditional expression is always true: !error.empty().
apps/opencs/model/tools/pathgridcheck.cpp  32  err  V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 32, 34.
apps/opencs/model/world/refidadapterimp.cpp  1376  err  V547 Expression 'subColIndex < 3' is always true.

apps/openmw/mwgui/widgets.hpp  318  warn  V703 It is odd that the 'mEnableRepeat' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:318, MyGUI_ScrollBar.h:179.
apps/openmw/mwgui/widgets.hpp  319  warn  V703 It is odd that the 'mRepeatTriggerTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:319, MyGUI_ScrollBar.h:180.
apps/openmw/mwgui/widgets.hpp  320  warn  V703 It is odd that the 'mRepeatStepTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:320, MyGUI_ScrollBar.h:181
apps/openmw/mwmechanics/actors.cpp  1425  warn  V547 Expression '!detected' is always true.
apps/openmw/mwmechanics/character.cpp  2155  err  V547 Expression 'mode == 0' is always true.
apps/openmw/mwmechanics/character.cpp  1192  warn  V592 The expression was enclosed by parentheses twice: ((expression)). One pair of parentheses is unnecessary or misprint is present.
apps/openmw/mwmechanics/character.cpp  521  warn  V560 A part of conditional expression is always true: (idle == mIdleState).
apps/openmw/mwmechanics/pathfinding.cpp  317  err  V547 Expression 'mPath.size() >= 2' is always true.
apps/openmw/mwscript/interpretercontext.cpp  409  warn  V560 A part of conditional expression is always false: rank > 9.
apps/openmw/mwgui/windowbase.cpp  28  warn  V560 A part of conditional expression is always true: !visible.
apps/openmw/mwgui/journalwindow.cpp  561  warn  V547 Expression '!mAllQuests' is always false.
apps/openmw/mwgui/referenceinterface.cpp  18  warn  V571 Recurring check. The '!mPtr.isEmpty()' condition was already verified in line 16.
apps/openmw/mwworld/scene.cpp  463  warn  V547 Expression 'adjustPlayerPos' is always true.
apps/openmw/mwworld/worldimp.cpp  409  err  V766 An item with the same key '"sCompanionShare"' has already been added.
apps/openmw/mwworld/cellstore.cpp  691  warn  V519 The 'state.mWaterLevel' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 689, 691.
apps/openmw/mwworld/weather.cpp  1125  warn  V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1123, 1125.
apps/openmw/mwworld/weather.cpp  1137  warn  V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1135, 1137.

apps/wizard/unshield/unshieldworker.cpp  475  warn  V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression.
apps/wizard/installationpage.cpp  163  warn  V735 Possibly an incorrect HTML. The "</p" closing tag was encountered, while the "</span" tag was expected.

components/fontloader/fontloader.cpp  427  err  V547 Expression 'i == 1' is always true.
components/nifosg/nifloader.cpp  282  warn  V519 The 'created' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 278, 282.
components/esm/loadregn.cpp  119  err  V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 112, 119.
components/esm/cellref.cpp  178  warn  V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 175, 178.
components/esmterrain/storage.cpp  235  warn  V560 A part of conditional expression is always true: colStart == 0.
components/esmterrain/storage.cpp  237  warn  V560 A part of conditional expression is always true: rowStart == 0.
2018-04-18 12:36:10 +00:00
Allofich
3780d94214 Cast LAND_SIZE to integer to avoid linking error 2017-03-28 01:57:31 +09:00
scrawl
fd215caa02 Add local LandCache to cut down on store searches 2017-03-14 19:27:57 +01:00
scrawl
0756fc4ae6 Optimize getBlendmaps for the general case that most points are within the given cell 2017-03-14 19:27:55 +01:00
scrawl
81c9853fe9 Fix handling in getBlendmaps when the chunk is >1 ESM::Cell 2017-03-14 19:27:55 +01:00
scrawl
b384087e28 Fix handling in fillVertexBuffers when the chunk is >1 ESM::Cell 2017-03-14 19:27:55 +01:00