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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 >_>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.