6163 Commits

Author SHA1 Message Date
Tamás Bálint Misius
3e2fc0b31f
Snapshot 374 snapshot-374 2024-12-12 17:30:03 +01:00
Tamás Bálint Misius
0ee442e0b8
Fix crash when navigating away from a save while voting on it
By tying the lifetimes of the vote request and the queued vote to the online save info. Broken since c73fa1bcdde3, where the vote request was made non-blocking. TODO: Let the user know that their vote may not have gone through if the vote request gets destroyed abnormally.
2024-12-12 15:37:38 +01:00
Tamás Bálint Misius
76dca483e9
Fix unnatural stacking near powers of 2 positions
Displacing the swapped-out particle by the difference between the integer positions (derived from the float position via rounding) of the particles would sometimes cause the floats in Particle to switch to a lower precision range, and this would overflow them such that the integer position would change by an amount different from what was intended (exactly the difference between the integer positions of the particles). Such switches between precision ranges can only happen when a sufficiently big positive number is added to a positive float near the positive end of its current precision range. Swapping displacements are usually small, so this problem mostly manifested near the positive end of precision ranges, that is, near powers of 2.

Informally, for illustrative purposes, consider the float position (either x or y, doesn't matter) 511.49995, fairly close to the positive end of the precision range [256, 512), and the swap displacement +1: these yield the position 512.49995. Assume that this is not be representable, and that the two nearest representable values are 512.4998 and 512.5. 512.49995 is closer to 512.5, so that's what it gets rounded to. But oops, 511 = round(511.49995) + 1 != round(512.5) = 513, so we're now overwriting the wrong pmap entry.

Reproduce with

	sim.paused(true)
	sim.clearSim()
	local brmt = sim.partCreate(-1, 128, 100, elem.DEFAULT_PT_BRMT)
	local dust = sim.partCreate(-1, 127, 101, elem.DEFAULT_PT_DUST)
	sim.createBox(125, 98, 130, 103, elem.DEFAULT_PT_DMND)
	sim.partProperty(dust, "x", 127.49999)
	sim.frameRender(2)

The BRMT and the DUST should swap places; instead, without the fix, the DUST gets stacked under a DMND.

This commit fixes this problem by moving the swapped-out particle exactly where the moving particle is.
2024-12-12 13:10:00 +01:00
Tamás Bálint Misius
5540517368
Make properties and callbacks of non-custom tools read-only
Non-custom here means any built-in tool but also the ElementTool associated with elements, including custom ones. So, describing the tools this commit affects as "built-in tools" wouldn't quite be correct. It was even possible to cause crashes by freeing such tools.

Also fix crashes when attempting to access non-custom tools as if they were custom tools. The incorrect assumption was that GameModel::GetToolIndex succeeding means that LuaScriptInterface::customTools has an entry for the tool, but this is only guaranteed for custom tools.
2024-12-09 21:46:05 +01:00
Tamás Bálint Misius
860ba13899
Fix crash on windows when using invalid particle/element property values
See the comment in meson.build. Reproduce with

	elem.property(elem.DEFAULT_PT_DMND, "Enabled", false)
2024-12-09 20:43:50 +01:00
Tamás Bálint Misius
9233b0036f
Only use custom LTO flags when we actually want LTO
This considerably speeds up linking of release binaries with msvc when testing locally, when LTO is of no concern.

Also properly override b_lto and b_vscrt in all cases for all targets, never leaving them to take default values.
2024-12-09 17:55:11 +01:00
Tamás Bálint Misius
a85bee5578
Fix gravity staying broken when pasted over by unrelated data
Gravity has been possible to save since 7e9d9686dda4, but the gravity process's definition of when there is work to be done wasn't adjusted accordingly. Thus, when the user manually changed the gravity force (the output of the gravity process) by e.g. pasting over it, it would stay, not quite broken, but very much out of place.
2024-12-09 16:47:36 +01:00
Tamás Bálint Misius
fb7ae9fc63
Only dispatch the gravity thread if there is work to be done
The definition of when there is work to be done is more or less "when the input to the gravity process has changed"; this is about to be extended to cover some other situations by the next commit.
2024-12-09 16:47:25 +01:00
Tamás Bálint Misius
6b5bbb177d
Stop copying the gravity process's input every frame
In the vast majority of cases (i.e. when Gravity::Exchange is indirectly called from BeforeSim), the input is cleared to zeros anyway, so it's less work in Exchange to actually just exchange the old input with the new one than to copy the new one into the old one.

Also make gravity functions private in Simulation.
2024-12-09 16:35:01 +01:00
Tamás Bálint Misius
a65338beea
Fix occasional hang on exit when SRT is enabled
Aka episode 29743 of game mvc being a joke: Happens since 74386631e0b6, where GameModel started being destroyed after GameView. The problem is that GameModel assumes that GameView is still alive and tells it to stop rendering the simulation on another thread, and expects it to acknowledge this request.
2024-12-07 14:27:34 +01:00
Tamás Bálint Misius
5454ef892d
Fix crashes when giving !set invalid property values
This fixes two kinds of crashes: the one where the value passed is not possible to convert at all to the type of value expected (e.g. expect unsigned integer, get point), and also when it is possible, because the difference is only in signedness (e.g. expect unsigned integer, get signed integer). Both cases crash since 8552aafbceb7, where the handling of the former case got removed and accidentally never got added back, and the handling of the latter changed from converting everything to strings and working from there to converting directly between floats and numbers, disregarding signedness.
2024-12-07 00:10:33 +01:00
Tamás Bálint Misius
639504ab23
Make global quit shortcut optional
Some people prefer to use the window manager to close windows.
2024-12-04 23:27:26 +01:00
Tamás Bálint Misius
5e20edeb9e
Don't complain about missing elements that aren't actually used
We would complain about them indiscriminately, see 36800a76cd97.
2024-12-02 18:38:26 +01:00
jacob1
75d33adbde
CRMC low pressure - preserve .temp when breaking 2024-11-23 11:23:36 -05:00
jacob1
32033af67c
Fix EMP radius when damaging things around SPRK 2024-11-20 21:25:45 -05:00
Tamás Bálint Misius
74386631e0
Fix crash on exit while there are Lua windows visible
Broken since 02b679aec37f, where GameView started popping everything above itself before popping itself. The problem was that LSI would get destroyed before GameView did this, but popping Lua windows needed LSI to be alive still.
2024-11-20 21:33:54 +01:00
Tamás Bálint Misius
b448622921
Fix crash when a Lua tool Perform callback throws an error
Broken since 00ec4e0754d1, when the Perform callback was added. It's a bad idea to pop return values that never got pushed because the function that was supposed to push them threw an error.
2024-11-20 21:33:54 +01:00
Tamás Bálint Misius
0c74c8080d
Make LuaSmartRef properly non-copyable
Broken since 06e28367266e, which added LuaSmartRef. That it had absolutely not followed the rule of five at all didn't use to be a problem because it had only ever been in vectors that got resized only once throughout the lifetime of the program >_>
2024-11-20 21:33:14 +01:00
Tamás Bálint Misius
afb9fa7df2
Add Select callback to Lua tools
This is intended to support selection-time configuration the way PROP and the custom life tools do it. Indeed, they now use the infrastructure this commit adds to implement their own configuration actions.
2024-11-20 19:02:35 +01:00
Tamás Bálint Misius
eaef47074b
Handle steam builds in build.sh
Also report the package mode/type in tpt.version and the user agent, and make shared data folder support optional.
2024-11-17 18:50:22 +01:00
Tamás Bálint Misius
8b6b12cff3
Snapshot 373 snapshot-373 2024-11-08 16:57:55 +01:00
Tamás Bálint Misius
ce250e31f2
Bound-check SOAP links (fixes #973) 2024-11-08 16:37:56 +01:00
Tamás Bálint Misius
809ae3ae93
Automatically set b_vscrt on Windows 2024-11-07 18:42:19 +01:00
Tamás Bálint Misius
b46f35c1e5
Upgrade to C++20 2024-11-07 18:42:19 +01:00
Tamás Bálint Misius
119591d14d
Add support for aarch64 on windows, update tpt-libs 2024-11-07 18:42:19 +01:00
Tamás Bálint Misius
c3b30ec120
Bump some ghactions jobs to ubuntu-22.04 2024-11-07 11:22:56 +01:00
Tamás Bálint Misius
87ab4c285a
Bump some ghactions jobs to macos-13 2024-11-04 18:40:47 +01:00
Tamás Bálint Misius
8620ea13a4
Fix nullptr deref when flooding deco
Broken in ff4500620e56, where the code that constructs DecorationTools got moved from GameModel::BuildMenus to GameModel::InitTools. BuildMenus used to run fairly late, while InitTools is run fairly early, before GameModel's view member is initialized. This wasn't a problem before f52e04703731, since which DecorationTools access Renderer through GameView, rather than directly.
2024-11-04 18:14:33 +01:00
jacob1
875f92b2a6
Fix chance of NEUT spawning PHOT in GLAS and of PHOT multiplying in GLOW. Originally broken in cda029ff4246 2024-11-02 00:02:34 -04:00
Tamás Bálint Misius
02b679aec3
Fix views leaking when closing themselves
Views would invoke c->Exit() upon closing themselves, which would close them but not delete them. The controller would then be destroyed, fail to close the view because it wouldn't be the window on top, and skip destroying it in fear of something worse. This behaviour was introduced by c2f8a7df25f3, fixing something indeed worse: views would be destroyed while they were still in use by ui::Engine, sitting somewhere on the window stack but not at the top. In other words, the problem was (and is) that the terms of ownership of views between controllers and ui::Engine are unclear.

This commit effectively undoes that earlier commit and tries a different approach: when something is closed, close everything above it. This seems a correct thing to do and also allows controllers to unconditionally take care of their views. Prepare your popcorn though.

This fixes a bug where the stamp browser would stop rendering stamps if it was previously closed "too quickly", which turned out to mean that it was closed before all stamps had finished rendering, and thus ThumbnailRendererTasks belonging to LocalBrowserViews indirectly through SaveButtons would get stuck in a queued state, preventing other SaveButtons from starting their own ThumbnailRendererTasks.
2024-10-25 22:08:38 +02:00
Tamás Bálint Misius
d4cbdc84ca
Migrate starcatcher-publish step to sftp 2024-10-24 16:28:59 +02:00
Tamás Bálint Misius
ca930c2494
Allow only a single instance of the exit prompt
This is required because there is a very low-level shortcut that can create one even if one is already being shown.
2024-10-18 08:55:36 +02:00
jacob1
03e1b12173
Snapshot 372 snapshot-372 2024-10-17 23:26:54 -04:00
Tamás Bálint Misius
8cab4ab738
Fix saves sometimes being one cell larger than intended
Namely, when any dimension of the underlying particle area is divisible by CELL. Importantly, this includes "normal" saves (as opposed to stamps), which take the entire simulation area, making them impossible to load.

Broken by c2bb77721208, where RectBetween(topLeft / CELL, bottomRight / CELL) was rewritten to RectSized(pos / CELL, size / CELL), which is not equivalent. This commit also neglected to add TopLeft() and BottomRight() to Rect. Incorrectly fixed by 6a903ed132b3, where RectSized(pos / CELL, size / CELL) was rewritten to RectBetween(pos / CELL, (pos + size) / CELL), which is also not equivalent.
2024-10-16 08:08:24 +02:00
jacob1
7353894618
Ctrl+q - don't trigger quit dialog if alt is also held
Should fix dialog coming up when typing / on some Brazilian keyboards, which use Alt Gr + q to type a /. Apparently this also acts as if Ctrl were held.
2024-10-16 00:04:48 -04:00
jacob1
6a903ed132
Fix possible crash when creating stamps
The save's blockSize was set one cell too short, so extend it by one (by using RectBetween). This fixes a crash when serializing save data that had particles outside its range.
2024-10-15 23:12:35 -04:00
Tamás Bálint Misius
948f6bf27f
Snapshot 371 snapshot-371 2024-10-15 19:37:06 +02:00
Tamás Bálint Misius
43a4311762
Add !get console command
Uses the same selector syntax as !set, and if there is exactly one resulting particle, reads from it the requested property.
2024-10-14 10:23:53 +02:00
Tamás Bálint Misius
7a2d8f6aaf
Deduplicate console command function list 2024-10-14 10:23:49 +02:00
Tamás Bálint Misius
01a6bf15be
Fix the position-based selector of !set
Broken since the addition of !set in 7ae5eaab79a4.
2024-10-14 10:18:00 +02:00
Tamás Bálint Misius
8552aafbce
Unify particle property parsing code
This means that the !set console command now accepts the same language as the prop tool's property value field.
2024-10-14 10:05:40 +02:00
Tamás Bálint Misius
a03db32dd5
Add sim.listDefaultGol 2024-10-14 07:41:17 +02:00
Tamás Bálint Misius
c96128f241
Show placeholder text in text fields even when focused
This is fine, there's no particular benefit to hiding it when they are focused. I did find it annoying that the cursor got a bit tangled up with the placeholder text though, so I moved the text a bit to the right.
2024-10-14 00:15:13 +02:00
Tamás Bálint Misius
f9ccc24177
Remove the single C TU from the codebase
This leaves one non-C++ TU in the entire codebase: Cocoa.mm is Objective C++ and is only compiled on MacOS, where it's used for clipboard integration. This too will go away when we move to SDL3, which has a proper clipboard API.
2024-10-14 00:14:29 +02:00
Tamás Bálint Misius
c2bb777212
Migrate Rects to (pos, size) representation 2024-10-10 19:51:59 +02:00
Tamás Bálint Misius
2cc5d9bbbb
Fix tools drawing rectangles with tools not doing anything in some cases
Namely, when those rectangles are not drawn in a top left to bottom right corner order. Broken by a26544ba955f, which neglected to port the rectangle normalization logic from Simulation::ToolBox.
2024-10-08 22:07:50 +02:00
Tamás Bálint Misius
0c048a9d6e
Show address of Main in stack traces
This beats main because that expands to SDL_main and leaves everyone confused.
2024-10-05 22:14:13 +02:00
Tamás Bálint Misius
07fa908102
Fix EndsWidth crash when the suffix is longer than *this 2024-10-05 21:14:05 +02:00
Tamás Bálint Misius
5928125594
Make more Lua tool properties trigger a menu rebuild
Turns out GameView needs to be told about every single thing, oops.
2024-10-05 09:21:03 +02:00
Tamás Bálint Misius
9c3cd69cef
Add MenuSection and MenuVisible properties to Tool
This makes the task of deciding which tool goes in which menu easier (GameModel::BuildMenus). Due to changes in the order tools are added to menus, the sign/sample/prop tool triplet now comes before custom tools, and the custom life creation tool comes before custom life element tools, which I think is fine.
2024-10-04 12:32:32 +02:00