54 Commits
Author SHA1 Message Date
nox7 768773a31a Don't run simulation or game timers when the game is paused 2026-10-13 20:24:09 -05:00
nox7 9e932a79f9 Consolidate "get real time" into helper function and use steady_clock instead of high-res clock (for time consistency guarantees)
Format
2026-09-18 13:54:43 -05:00
nox7 880372971a CLANG format 2026-09-18 13:54:43 -05:00
nox7 4e88ec9049 Remove useless method and just group the timers into the original two 2026-09-18 13:54:43 -05:00
nox7 4bdc4396e8 Save/Load real timers as a delta time and restart the timer from that remaining delta on load 2026-09-18 13:54:43 -05:00
nox7 c992c8cb0c Implement new real time timers. Works when the game is paused 2026-09-18 13:54:43 -05:00
S3kshun8 Games 04b1ee951b Merge branch 'lua-perf' into 'master'
Cut Lua frame time on heavy script loads

See merge request OpenMW/openmw!5506
2026-09-16 06:31:36 +00:00
Thomas 512f20501b Keep Lua timers alive during callbacks 2026-09-10 23:50:37 +02:00
Thomas decf020ecd Add test coverage to avoid silent breakage 2026-09-08 13:01:49 +02:00
Thomas Portal ebbadc87fa Decay Lua script instruction averages lazily
statsNextFrame walked every script in a container every frame purely to
multiply each running average by a decay constant, whether or not the script
had run. With 701 active containers that walk is pure overhead for scripts
that were idle.

The averaging is a geometric decay, so the frames a script sat out fold into
a single power. Record the frame each average was last written and apply the
missing decay when it is next written or read; the per-frame call then only
bumps a counter, and a frame costs the same whether a container holds one
script or a thousand.

Reading the stats deliberately does not write them back, so collectStats
stays const and the decay is applied for real by whoever writes next.
2026-09-08 13:01:49 +02:00
Evil Eye 233fb4e7bd Address feedback 2026-03-09 21:25:59 +01:00
Evil Eye 814e51785f Avoid tracking dangling LocalScripts 2026-03-09 21:15:42 +01:00
Evil Eye ee1cee1181 Reassign script id and test script order changes 2026-02-04 16:36:53 +01:00
Evil Eye fdc2e63152 Save Lua script ids instead of paths 2026-02-04 16:36:51 +01:00
AnyOldName3 ef8e7d97cb Resolve merge conflicts from !4971 2025-11-10 16:01:47 +00:00
Evil Eye 4f8b418c23 Ensure LuaUtil::call is invoked from a safe context 2025-10-30 22:24:53 +01:00
AnyOldName3 06cb00bb0b Resolve merge conflicts from !4924 and !4928
luamanagerimp still needs float frameDuration, and reordering a bunch of fields in the scene manager conflicted with changing the type of maxanisotropy.
2025-10-04 23:08:20 +01:00
Evil EyeandPetr Mikheev ff79c2d826 Turn menu.saveGame into a delayed action 2025-09-20 10:39:43 +00:00
Evil Eye f7292680d6 Fix most conversion warnings in components 2025-09-18 22:00:55 +02:00
elsid 3067294f0d Add and fix -Wshadow 2025-08-18 21:09:06 +02:00
Evil Eye bc05628fa8 Resolve unused code warnings when compiling in Debug mode using MSVC 2025-07-30 20:44:59 +02:00
Evil Eye b0e9df0139 Ensure class members are tied to the main Lua state 2025-03-03 19:37:07 +01:00
Evil Eye f92b5040c6 Don't add auto started local Lua scripts twice 2025-01-01 13:21:28 +01:00
Evil Eye 6572122acc Use the right deserializer for unloaded scripts 2024-11-09 13:05:39 +01:00
Evil EyeandPetr Mikheev 68ebefc2dd Fix Lua memory usage 2024-10-15 21:18:13 +00:00
elsid b4f77e8bd7 Store Lua script path as VFS normalized 2024-09-15 13:53:20 +02:00
elsid 32ec92e71c Use normalized path in LuaState 2024-09-08 11:53:57 +02:00
Evil Eye 032d506aa7 Fix components_tests 2024-08-24 09:10:23 +02:00
Evil Eye c9783344a0 Wrap all memory allocating Lua functions in protected calls 2024-08-22 22:22:28 +02:00
AnyOldName3 28131fd62b Fixes for a whole bunch of warnings
These warnings were always enabled, but we didn't see them due to https://gitlab.com/OpenMW/openmw/-/issues/7882.
I do not fully understand the cause of 7822 as I can't repro it in a minimal CMake project.

Some of these fixes are thought through.
Some are sensible best guesses.
Some are kind of a stab in the dark as I don't know whether there was a
possible bug the warning was telling me about that I've done nothing to
help by introducing a static_cast.

Nearly all of these warnings were about some kind of narrowing
conversion, so I'm not sure why they weren't firing with GCC and Clang,
which have -Wall -Wextra -pedantic set, which should imply -Wnarrowing,
and they can't have been affected by 7882.

There were also some warnings being triggered from Boost code.
The vast majority of library headers that do questionable things weren't
firing warnings off, but for some reason, /external:I wasn't putting
these Boost headers into external mode.

We need these warnings dealt with one way or another so we can switch
the default Windows CI from MSBuild (which doesn't do ccache) to Ninja
(which does).
I have the necessary magic for that on a branch, but the branch won't
build because of these warnings.
2024-03-14 23:39:33 +00:00
Andrei Kortunov 225e834b88 Fix some Coverity Scan complaints 2024-02-02 09:28:19 +04:00
Petr Mikheev 87eacf774a Control GUI modes from Lua 2023-08-20 17:49:56 +02:00
Andrei Kortunov f5b18d2d5d Do not copy objects twice where possible 2023-08-02 20:03:48 +04:00
psi29a cdc753df70 Merge branch 'lua_refactoring' into 'master'
MWLua refactoring

See merge request OpenMW/openmw!2956
2023-05-02 19:48:21 +00:00
Petr Mikheev 4562b8c06b Add headers for all .cpp files in mwlua; move packages initilaization from LuaManager to luabindings.cpp 2023-04-25 23:24:51 +02:00
Petr Mikheev c362b2efa6 Use LuaUtil::cast for casting sol::object to prevent crashing on type mismatch in Lua scripts. 2023-04-25 22:11:04 +02:00
Petr Mikheev d9e9db0983 Additional information in Lua profiler 2023-01-13 21:14:23 +01:00
Petr Mikheev b248c3e173 Allow passing initData to the :addSript call (#7091) 2022-12-31 22:08:17 +01:00
Petr Mikheev 55db95d4cf Update Lua profiler; add ability to run OpenMW with old LuaJit that doesn't allow custom allocator (Lua profiler will be disabled in this case) 2022-12-03 16:58:03 +01:00
Petr Mikheev 6fa65e4729 Track memory and CPU usage per script in LuaUtil::LuaState 2022-11-30 00:06:14 +01:00
uramer a2fa1fe0a5 Execute async callbacks on the main Lua stack 2022-10-18 22:12:11 +02:00
clang-format-botandζeh Matt ddb0522bbf Apply clang-format to code base 2022-09-22 21:35:26 +03:00
Petr Mikheev a70d5831c5 Lua scripts configuration in omwaddon 2022-06-05 01:36:39 +02:00
Petr MikheevandEvil Eye a294adcdaf Proper support of pairs and ipairs in Lua; fix bug in makeReadOnly. 2022-02-06 22:10:20 +00:00
Petr Mikheev 2d1b100239 Change terminology of gameSecond/gameHour to simulationTime/gameTime 2022-01-10 21:03:35 +01:00
Petr Mikheev f9136d4392 Support multiple arguments in Lua callbacks. 2021-11-21 13:12:35 +01:00
Petr Mikheev e7ec89573e Refactoring. Lua Callback is moved from apps/openmw/mwlua to components/lua. 2021-10-31 17:47:46 +01:00
Petr Mikheev 4ec7f0625e Store Lua timers in std::map rather than in sol::table. 2021-10-26 21:32:48 +02:00
Petr Mikheev 9adc190209 Redesign LuaUtil::ScriptsContainer to work with ScriptsConfiguration 2021-10-26 21:32:48 +02:00
Petr Mikheev 24ecdc37a7 Fix crash in LuaUtil::ScriptsContainer::~ScriptsContainer() 2021-09-30 03:01:38 +02:00