Commit Graph

5650 Commits

Author SHA1 Message Date
catsoften
a715f5d71a Use RGB for constants and gradients, other misc changes 2023-04-16 22:13:39 +02:00
catsoften
bc085705a8 Remove deprecated PIXPACK/RGB/R/G/B functions 2023-04-16 22:13:39 +02:00
Tamás Bálint Misius
5fc8770ee2
Fix pmap usage in Simulation::flood_water
flood_water would occasionally corrupt pmap by moving the pmap entry at i's location even if the entry itself didn't refer to i. pmap updates are tricky, they are best handled by Simulation::move.
2023-04-16 11:05:42 +02:00
Tamás Bálint Misius
54d08f3496
Protect new math.random against division by 0 2023-04-15 23:22:20 +02:00
Tamás Bálint Misius
34e4d90dac
Properly seed rng at load time for saves that don't carry rng state
Also save rngState as a user object rather than two separate i64s.
2023-04-15 23:04:58 +02:00
Tamás Bálint Misius
a8604ef579
Add ensureDeterminism to saves 2023-04-15 22:19:54 +02:00
Tamás Bálint Misius
9c3b966c18
Expose new features to Lua
math.random now uses our rngs. In most cases, this means the interface rng, but it means the sim rng during simulation events.
2023-04-15 22:19:54 +02:00
Tamás Bálint Misius
0b82796ba4
Add Simulation::frameCount, save blockair/blockairh and rng state
Saving blockair/blockairh is nice because RecalculateBlockAirMaps uses the sim rng, which means the sim rng would get advanced in Simulation::Load. Also rename RecalculateBlockAirMaps to ApproximateBlockAirMaps because that's what it is, an approximation, and it's needed only if there are no block air maps in the save.

Simulation::frameCount keeps track of frames elapsed since the beginning of the simulation, zeroed at clear_sim. It overflows when it reaches the 64-bit limit, which means anything that depends on it should either handle this, or not fail catastrophically. sandcolour (the only thing that depends on it as of now) is a good example of the latter: sandcolour has a periodicity of 360 frames, which means that there is one sandcolour period that is cut short by the overflow. This is not "handled" (the period is cut short, which is detectable by users) but is not catastrophic either (it's not a big deal, and it won't ever happen unless someone hacks the save).

Also restrict saves with determinism data to 98.0.
2023-04-15 22:19:50 +02:00
Tamás Bálint Misius
eee42b2ea3
Fix RNG usage
Mostly boils down to having graphics functions use Renderer's RNG, update and similar functions Simulation's.
2023-04-15 18:22:03 +02:00
mniip
c23eba1921 Remove unused Component::Component overloads 2023-04-13 18:48:19 +02:00
mniip
8c387a5a00 convert ThumbnailRequest to Vec2 2023-04-12 19:28:55 +02:00
mniip
aa2fa9ed8c Remove Graphics::SetClipRect 2023-04-12 19:24:54 +02:00
mniip
9b9b0b794a Remove Graphics::vid, Graphics::textwidthx, Graphics::textsize 2023-04-12 19:21:37 +02:00
mniip
e1d230f814 New text width ops 2023-04-10 23:54:46 +02:00
mniip
7a459e8021 Fix CI 2023-04-10 23:31:30 +02:00
mniip
f443eeff2f Refactor Engine, Window, and Panel drawing 2023-04-10 23:05:44 +02:00
mniip
4b70eeab55 Refactor PNG and working with alpha 2023-04-05 21:30:24 +02:00
mniip
b26a1b4a88 VideoBuffer pointer correctness 2023-04-05 14:52:20 +02:00
mniip
50bfa7cd5e Remove unused VideoBuffer code 2023-04-05 14:16:25 +02:00
mniip
132e3508cf Refactor tools 2023-04-05 14:11:37 +02:00
mniip
7f84887f6d Refactor things referencing VideoBuffer internals 2023-04-05 02:30:05 +02:00
mniip
b56d3cf611 Fix return values in VideoBuffer::*Character 2023-04-05 02:30:05 +02:00
mniip
e5af4dab68 Refactor resize-related code 2023-04-05 02:30:05 +02:00
mniip
caab738184 Refactor raster draw methods 2023-04-05 02:29:35 +02:00
mniip
e93db9c06a RasterDrawMethods CRTP, PlaneAdapters in VideoBuffer, Graphics, and Renderer 2023-04-05 02:29:35 +02:00
mniip
a0a9ad0abd Add new Vec2, Mat2, RGB, RGBA classes and deprecate some old functions 2023-04-05 02:29:35 +02:00
Tamás Bálint Misius
a2c7242c7c
Fix uninitialized read of Engine::dt early after startup 2023-03-02 20:55:48 +01:00
Tamás Bálint Misius
369dadf81e
Fix crash from new brush code when TPTMP is enabled
Okay yeah this is actually a well-camouflaged refactor.
2023-02-28 14:57:30 +01:00
Tamás Bálint Misius
114017d550
Fix msvc error due to narrowing conversion 2023-02-28 14:57:29 +01:00
Tamás Bálint Misius
a13c29875f
Don't mangle custom element types in life, ctype, tmp{,2,3,4}
Achieved by adding a new element property called CarriesTypeIn, whose bits signal to save loading code which properties of particles of the element class in question carry element IDs. The bits in this property are numbered the same way as sim.FIELD_* constants for consistency. One would signal from Lua that a custom element carries element IDs in its tmp like this:

	elem.property(id, "CarriesTypeIn", 2 ^ sim.FIELD_TMP)

"Carrying an element ID in a property" is to be interpreted as follows: the property is treated as a combination of a PMAPBITS-bit (so, currently 9-bit) unsigned integer lower part holding an element ID and a 32-PMAPBITS-bit (so, currently 23-bit) signed integer upper part holding whatever makes sense for the element. CONV, for example, uses this signed integer in its ctype as the extra "v" parameter for particle creation.
2023-02-28 12:43:45 +01:00
Tamás Bálint Misius
2e2c3181b5
Fix custom elements disappearing on load (fixes #908)
Some checks on particles, most importantly whether their element IDs refers to an enabled element, were done _before_ in-save element IDs are mapped to in-simulation element IDs. This resulted in some particles being removed if their IDs were unlucky enough.
2023-02-28 12:29:26 +01:00
mniip
ed8ec51f95 Copy brushes instead of making temporary changes to them 2023-02-22 09:58:03 +01:00
mniip
515df765e4 Clean up brush code 2023-02-22 09:58:03 +01:00
jacob1
18a4407166
Use ubuntu 20.04 for github runners instead of 18.04
18.04's runner only has around a month left to live and the blackout periods are getting longer
2023-02-21 22:46:46 -05:00
jacob1
6d4f6218a4
Create wrapper around lua_pcall that properly tracks Lua execution time
A bug existed before where certain events would not update Engine's lastTick. If the sim was lagging hard, then this could cause "script is not responding" errors to appear in unintentional situations.

The starting execution time is tracked in LuaScriptInterface instead now, and set in tpt_lua_pcall
2023-02-17 21:58:57 -05:00
Tamás Bálint Misius
e5fec98d28
Fix stamps being impossible to delete
Broken by 416f84a1c4, oops.
2023-02-05 23:09:53 +01:00
Tamás Bálint Misius
1c92280097
Clean up Misc.cpp somewhat
Also make a feeble attempt at rooting out standard C I/O library function usage. Lua still uses it though >_>
2023-02-05 15:59:31 +01:00
Tamás Bálint Misius
6756c27274
Have ghactions check if dynamic windows builds have all their dependencies
Also update tpt-libs to properly fix the bug I fixed very temporarily earlier.
2023-02-05 15:59:31 +01:00
Tamás Bálint Misius
ef8764e6ab
Temporarily fix mingw builds on windows missing bz2.dll
This will need to be addressed in tpt-libs at some point.
2023-02-05 08:34:08 +01:00
Tamás Bálint Misius
0fe8d79e60
Make replace parameter of RenameFile explicit
Also replace a few rename calls with RenameFile calls. Old code doesn't expect rename to overwrite existing files without question, when it in fact can.
2023-02-01 21:48:18 +01:00
Tamás Bálint Misius
aa78a1ee6b
Clean up FFT gravity 2023-02-01 19:56:55 +01:00
Tamás Bálint Misius
85d492bad6
Make request progress variables atomic
These are the only bit of shared state between the Request user thread and RequestManager that aren't covered by RequestHandle::stateMx. The problem was that they were not covered by anything, which meant that they were not guaranteed to be coherent between threads.
2023-02-01 19:26:59 +01:00
Tamás Bálint Misius
b7a6663e08
Fix updating not deleting the old exe on windows
Also fix WriteFile being unable to overwrite existing files. The rename would fail because the file was still open, and the sanity remove in response to that would also fail for the same reason.
2023-01-29 18:54:02 +01:00
Tamás Bálint Misius
bd667dddad
Group request manager files into their own directory 2023-01-27 23:04:30 +01:00
Tamás Bálint Misius
b9c8817386
Group gravity files into their own directory
Also replace non-FFT gravity with "no gravity"; fine for render.
2023-01-27 23:04:27 +01:00
Tamás Bálint Misius
159d0eb4b7
Group platform files into their own directory 2023-01-27 17:31:40 +01:00
Tamás Bálint Misius
694bc8eb0f
Fix exit behaviour
We can't rely on atexit, handlers registered with it are in a hard to establish ordering relationship with destructors of static and thread-local objects.
2023-01-27 14:55:58 +01:00
Tamás Bálint Misius
11945ba620
Factor out game stuff from PowderToySDL.cpp 2023-01-27 09:29:19 +01:00
Tamás Bálint Misius
2566506e4b
Provide three levels of install support
Namely: no, yes, and yes and ask at startup.

The install_check option is thus replaced by the can_install option. -Dinstall_check=true maps to -Dcan_install=yes_check, while -Dinstall_check=false maps to -Dcan_install=yes. -Dcan_install=no is new and is recommended for downstream packaging, where -Dinstall_check=false was historically used.

Also improve error messages about bad configuration here and there and scatter configuration code in subdirectories, where they can be closer to their areas of effect.
2023-01-27 09:27:33 +01:00
Tamás Bálint Misius
416f84a1c4
Read stamps from stamps.json
... while retaining all the functionality of stamps.def.

Also fix stamp names encoding only 32 bits of the timestamp, migrate from stamps.def to stamps.json if the latter doesn't exist, delete both on migration to the shared data directory, rescan stamps at startup, and make rescanning a painless process in general by removing invalid entries and adding missing entires at the beginning of the list.
2023-01-27 09:27:33 +01:00