Commit Graph

5489 Commits

Author SHA1 Message Date
Tamás Bálint Misius
b20d38d3b0
Silence unused variable warnings for fromNewerVersion 2022-12-08 07:48:00 +01:00
Tamás Bálint Misius
9a9c686d91
Expose BZ2 to Lua 2022-12-08 07:47:59 +01:00
Jakav-N
0e361c170c
Add inverted element filtering to CONV with tmp2 set to 1 (#871) 2022-12-07 12:43:21 +01:00
Mark Theng
34fa5d0cce
Make file browser respond to search query changes while loading files (#866) 2022-12-07 12:17:30 +01:00
catsoften
510424363b
Replace max/min pressure with constants (#870) 2022-12-07 12:07:46 +01:00
Tamás Bálint Misius
b393050e55
Fix PHOT reflecting off thin walls of particles incorrectly
When PHOT fails to move (do_move or eval_move return "no move"), it looks for
a surface (a contour of boundaries, as reported by is_boundary) along its path
and reflects off (or refracts into, see below) it, using get_normal_interp to
find the point of incidence and get_normal to deduce the surface normal.
get_normal is given the point and angle of incidence, and attempts to traverse
the surface the point belongs to by running two "surface scout" processes.

These processes remember their own position and "heading", a subset of the
eight cardinal directions on the grid. They are initialized with the point of
incidence and a heading that includes all directions whose dot product with
the angle of incidence is non-negative (see direction_to_map). They then
perform a few iterations (SURF_RANGE).

In each iteration, the processes check all eight neighbours of the cell they
are on and select the first neighbouring cell they find that is both a
boundary (as reported by is_boundary) and that is within their heading. They
then move to this neighbouring cell and update their heading by discarding
directions that are not similar enough to (differ by more than 45 degrees
from) the one that took them where they are now (see find_next_boundary). If
they find no such neighbour, they stop.

Continuing the militaristic line of thinking introduced by the term "surface
scout", you can imagine the two processes as two paratroopers who arrive from
above, land on a horizontal surface, and one starts going left, while the
other starts going right. They initially expect the surface they land on to be
close to horizontal, but are also prepared for not too erratic changes in its
angle as they go. Changes too erratic (imagine a precipice) scare them and
force them to stop.

Once the processes finish, an imaginary line segment is drawn between the
cells they ended up on. If the line segment is long enough (estimated by j,
and compared against NORMAL_MIN_EST), get_normal returns a normal that is
perpendicular to it. If it is too short, get_normal gives up and returns
nothing (which results in the PHOT being killed).

This amounts to our paratroopers attempting to get the "lay of the land" by
walking away from where they landed and comparing where they end up. They also
know that if they are still relatively close to each other at the end of their
walk, their measurement is probably wrong and their mission should be aborted.

The bug this commit fixes is that get_normal returns bogus surface normals
when it encounters thin walls of particles, defined as walls exactly two
layers of particles thick. One-layer walls are not really walls, as movement
code allows particles to penetrate these, and three-layer and thicker walls
are too thick for the bug to manifest.

The bug manifests for two-layer walls because the "left" scout process is
drawn to the side of the wall opposite to the one with the point of incidence.
This is because scout processes check neighbours in a clockwise order, and
always select the first suitable neighbour they find. As particles on the
other side of the wall are both boundaries and are within the heading of the
processes, they also qualify as suitable neighbours, so whether a scout
process selects the correct side of the wall depends on the order in which
neighbours are checked.

Essentially, the paratroopers look at their immediate surroundings in a
clockwise order. The right paratrooper always finds the ground and knows where
to step. The left paratrooper finds the Upside Down from Stranger Things and
teleports there.

This bug also affects refraction into and out of thin walls, but since these
walls are thin, the path the PHOT takes inside them is rather short and the
incorrect angle of travel is difficult to see. Furthermore, upon exit, the
same normal deduction bug causes the PHOT to take a path whose angle is almost
identical to that of the path that took it to the wall, so much so that it is
also difficult to see over shorter distances.

The solution is to have the left scout process check neighbours in reverse
order, so that it prefers the right side of the wall over the wrong one. This
does not affect its behaviour when facing thicker walls, but fixes its
behaviour when facing two-layer walls.

The changes in this commit also make find_next_boundary interact with
is_blocking directly to detect a change between the blocking trait of
immediate neighbours. This makes more sense than relying on is_boundary
because find_next_boundary is meant to find a transition from non-blocking to
blocking neighbours within the current heading, rather than to find any
boundary particle. The difference is subtle but important.
2022-11-12 11:10:43 +01:00
Tamás Bálint Misius
ab600780d0
Clean up GameSave somewhat
Namely:

 - get rid of unsafe memory management;
   - use vectors / Planes everywhere;
   - return a vector from serialization functions;
   - have read functions take a vector;
 - improve constness;
 - hide a few implementation details from GameSave.h;
 - get rid of GameSave copy constructor;
 - better member initialization;
 - use the slightly more C++-looking BZ2 wrappers.

The BSON library still takes ownership of the data it parses, and GameSave
ownership is still a joke. Those will need to be fixed later.
2022-11-10 15:15:10 +01:00
Tamás Bálint Misius
f70cc705cb
Remove GameSave::Collapse and GameSave::originalData
... and everything built around them.

A GameSave would hold at least one but sometimes two representations of a save:
one serialized, and one "friendly", accessible for modification. Thus, a
GameSave would have three states:

 - "Collapsed": only the serialized representation was present; this was the
   initial state of GameSaves loaded from files;
 - "Expanded With Data": both the serialized and the friendly representations
   were present; this was the state of GameSaves loaded from files after a call
   to Expand;
 - "Expanded Without Data": only the friendly representation was present; this
   was the initial state of GameSaves being prepared for being saved to files.

A GameSave would be able to go from Collapsed to Expanded With Data with a call
to Expand, and back with a call to Collapse. Of course, this latter transition
would discard any changes made to the friendly representation, for example with
Translate. A GameSave would however be unable to go from Expanded Without Data
to any other state; a call to Collapse in this state would have been a no-op.

There were two instances of Collapse being called, one in the GameSave
constructor taking the serialized representation, immediately after a call to
Expand, and another in SaveRenderer, which would Collapse a save "back down" if
it had originally been Collapsed. Now, consider that there reasons for
constructing a GameSave from the serialized representation are as follows:

 - loading an online save at startup from the command line;
 - loading a local save at startup from the command line;
 - loading a local save when it is dropped into the window;
 - loading a local save for placement of the most recently used stamp;
 - loading a local save for stamp placement via Lua;
 - loading an online save for preview generation while browsing;
 - loading a local save in the stamp browser for thumbnail generation;
 - loading a local save in the local save browser for thumbnail generation.

In some cases, the friendly representation is needed for thumbnail generation
by ThumbnailRendererTask. ThumbnailRendererTask operates on its own copy of the
GameSave, because it runs SaveRenderer on a thread different from the main one
and cannot be sure of the lifetime of the original GameSave. It destroys this
copy when it is done rendering, so the call SaveRenderer makes to Collapse is
pointless.

In all other cases, the friendly representation is needed immediately. In some
of these, SaveRenderer is used from the main thread, but since the friendly
representation of the GameSave will be needed for pasting anyway, the call
SaveRenderer makes to Collapse is pointless again.

So, Collapse goes away. This also means that it is pointless for GameSaves to
hold on to the serialized representation, since in all cases in which they have
access to it, the friendly representation is needed immediately, and with
Collapse gone, they will never need it again.
2022-11-10 12:03:48 +01:00
Tamás Bálint Misius
630db0ef6b
Update tpt-libs
Comes with a new SDL2 version that fixes some obscure bug on Linux with nvidia drivers installed which makes TPT unable to start.
2022-11-08 21:16:13 +01:00
Tamás Bálint Misius
d120529492
Update tpt-libs
Hopefully fixes 601 errors on win11.
2022-11-06 17:18:08 +01:00
Tamás Bálint Misius
9b76c0dfe2
Fix snapshots being configured with ignore_updates=true
By moving appimages to their own build jobs. This required restructuring prepare.py again: release and debug jobs are not configured in pairs anymore.
2022-11-03 08:06:26 +01:00
Tamás Bálint Misius
b568b11927
Explicitly specify appimage destination
Because appimagetool is too smart for its own good.
2022-11-02 06:45:19 +01:00
Tamás Bálint Misius
059b3a8e38
Add verb parameter to http.get/post
Also make ENFORCE_HTTPS optional, but default to enabled, so unencrypted HTTP is disabled by default, and require it to be enabled for release binaries.
2022-11-01 19:25:17 +01:00
jacob1
3011e45475
Fix text in some buttons being cut off prematurely 2022-10-31 16:22:34 -04:00
Tamás Bálint Misius
cf89fb7dfb
Fix starcatcher uploads for real
See previous commit. If this doesn't fix it, I don't know what will. Let's see how long this chain of "Fix starcatcher uploads" commits goes on.
2022-10-30 09:35:46 +01:00
Tamás Bálint Misius
b36a708623
Fix starcatcher uploads
Apparently download-artifact now works the way it should have always been?
2022-10-29 09:39:51 +02:00
Tamás Bálint Misius
a57bb09d02
Target v141 toolset with msvc, update tpt-libs
Also reduce per-host connection count to 1, now that we support HTTP/2.
2022-10-29 08:42:39 +02:00
jacob1
8fd6db56d1
Fix string handling in text drawing / width functions
Allows passing in null bytes, which allows 0s to be used with \x0F color codes
Also unrelated, fix two warnings in OptionsView.cpp
2022-10-25 22:35:49 -04:00
Tamás Bálint Misius
a3a874f4d6
Get png avatars from the static server
Also restore concurrent connection / stream counts, and fix a bug that would cause AvatarButtons to try to fetch avatars before they knew what name they belonged to. I apparently broke this in the first PNG commit.
2022-10-24 22:12:10 +02:00
Tamás Bálint Misius
1f7b01bd9e
Disable update checks for AppImages 2022-10-24 07:01:21 +02:00
Tamás Bálint Misius
59354731df
Remove all PTI code, use libpng to load avatars and thumbnails
Also write PNGs with libpng, and BMPs with SDL, and have the renderer only generate a large PNG thumbnail, and disable HTTP/2 multiplexing for now so we don't get banned when loading avatars.

simon pls reply to the stupid emails already.
2022-10-23 20:21:05 +02:00
Tamás Bálint Misius
3cda085bac
Build x86_64 AppImage 2022-10-22 22:01:04 +02:00
Tamás Bálint Misius
8161c1d71c
Fix font not being given the json dependency
Also make it and render get built as dynamic executables on ghactions, and disable dynamic+LTO, as it seems to be buggy in certain cases and isn't an important case.
2022-10-21 14:52:02 +02:00
Tamás Bálint Misius
ebb87a17c6
Unbundle bzip2 and jsoncpp, update tpt-libs
Also Disallow linking against non-C++ system Lua, unless configuring with -Dworkaround_noncpp_lua=true, add -Dworkaround_elusive_bzip2 and friends, and get rid of the -image_base hack for macos.
2022-10-20 23:15:49 +02:00
Tamás Bálint Misius
6944d95d5a
Use GITHUB_OUTPUT env var for setting job output
Also update some actions, and use my forks for the release ones.
2022-10-20 23:15:44 +02:00
jacob1
6338da7cb7
Fix empty string being discarded at beginning of lua log/return lists 2022-10-19 17:28:13 -04:00
Tamás Bálint Misius
b306c2c33c
Fix ghactions mingw-on-linux builds
mingw-on-windows builds still work fine, but the linux ones were actually using plain gcc targeting the host.
2022-10-19 14:32:54 +02:00
Tamás Bálint Misius
715333295b
Add clip rect feature to Graphics and gfx.setClipRect
Also retire the separate VideoBuffer in Panel and hiding ToolButtons in the GameView ToolButton panel in favour of clip rects.
2022-10-11 20:47:39 +02:00
Tamás Bálint Misius
f18bd6553f
Remove long defunct OpenGL code paths 2022-10-11 20:11:14 +02:00
Tamás Bálint Misius
f378b3ac1d
Fix BSON.h rolling its own 64-bit integer types
This is problematic as per a comment on #860, and everything we target has <cstdint> now.
2022-10-10 10:20:55 +02:00
Tamás Bálint Misius
04e8538a48
Fix uninitialized stickmen
Funny commit message aside, they were throwing warnings in valgrind.
2022-10-06 19:42:13 +02:00
Tamás Bálint Misius
d75e4ccb2e
Fix OOB read when parsing empty string as float
I really don't like how the only way to return with an error from ParseFloatProperty is via an exception >_>

Also do a range check on airTemp only if isValid is true, otherwise it's uninitialized.
2022-10-06 19:25:41 +02:00
Tamás Bálint Misius
a8d2b269b1
Move tricky compiler options over to build.sh
All of these are options that are specific to our ghactions builds and not something we want downstream and package maintainers to be locked into using.
2022-10-06 11:50:46 +02:00
Tamás Bálint Misius
304cc3a47b
Move Read/WriteFile from Client to Platform 2022-10-05 19:55:04 +02:00
Tamás Bálint Misius
084f196248
Add http.getAuthToken
This website API was created to enable TPTMP to prove the identity of connecting users, and while TPTMP works fine without explicit support for this from the game, it has to resort to parsing powder.pref. This is not only ugly but also likely to be disallowed by the next version of the script manager. This new script manager will probably come after 97.0, so it's okay for it to rely on a game feature that won't be available until 97.0.
2022-10-05 19:55:02 +02:00
Tamás Bálint Misius
e54df0e6ad
More Lua API 8-bit-cleanliness changes
Round 2 of what I started in 36d034dc2e, mostly fixing c_str usage where it's not sensible.
2022-10-05 11:38:35 +02:00
Tamás Bálint Misius
b4462273b0
Fix a very elusive PHOT reflection crash
get_normal_interp is given a PHOT and scans a line section starting from the PHOT, extended in the direction of its velocity, to determine the surface normal of the surface that is reflecting the PHOT. It uses is_boundary to detect "boundaries" on this line section, defined as one "blocking" cell with at least one "non-blocking" non-diagonal neighbour. It never actually makes sure the position it passes to is_boundary is within the simulation area, so I assume is_boundary is expected to handle this correctly.

Plot twist: it does not. It delegates checking whether a cell is "blocking" (defined as something PHOT would normally fail to move into as per eval_move, but GLAS and BLGA are handled specially) to is_blocking. is_blocking returns true for cells beyond the simulation area (as eval_move returns "no move" for such cells). Once is_boundary sees that the cell it's been given is blocking, it then proceeds to check whether any of its non-diagonal neighbours might be non-blocking. In most cases, non-diagonal neighbours of an out-of-bounds cell are also out of bounds and are thus blocking, but if the cell is_boundary is given is in the innermost layer of out-of-bounds cells, just beyond the simulation area, then it has a neighbour that is in bounds, and that one may not block PHOT. The takeaway is that out of bounds cells can indeed be boundaries, as far as is_boundary is concerned.

This is a problem because get_normal_interp's line section can easily reach beyond the simulation area if the PHOT's velocity is high enough, and if it finds a boundary along this line section, it immediately stops looking and passes its position to photoelectric_effect, which then uses this potentially out-of-bounds position to index pmap. A position with y = -1 causes photoelectric_effect to read from the last few slots of parts data that it then interprets as pmap entries, which then may direct it to particles to spark that are beyond parts. This eventually crashes.

This commit doesn't fix is_boundary's definition of boundaries, but it stops get_normal_interp looking at cells beyond the simulation area.

The crash is difficult to reproduce because there have to be many particles in the simulation for the very last slots of parts to be in use, and for them to point to memory that isn't accessible. PHOT also has to survive a try_move beyond the simulation area first (otherwise the reflection code isn't even run), which requires it to start from EHOLE. I have no idea why this is so. Reproduce the out of bounds read in photoelectric_effect with

	break Simulation.cpp:2934 if nx < 0

in gdb and executing the following Lua code:

	sim.clearSim()
	tpt.set_wallmap(55, 44, 12)
	local i = sim.partCreate(-1, 223, 178, 31)
	sim.partProperty(i, "vx", -300)
	sim.partProperty(i, "vy", 0)
	sim.framerender(1)
2022-10-02 22:57:36 +02:00
catsoften
5d66533f23
Make stickman movement strength independent of gravity (#857) 2022-09-25 14:49:43 +02:00
Tamás Bálint Misius
0f9b1a58b1
Add notification for missing or bad SSL certificates
Also add mbedtls to and document new certificate config options in README.md.
2022-09-25 07:22:23 +02:00
Tamás Bálint Misius
09c2704928
Add CAFile and CAPath config options, use mbedtls in static builds
This is how we'll handle systems where the cert bundle and cert directory is stored where mbedtls doesn't expect it.

Also update tpt-libs to get new curl and mbedtls.
2022-09-25 06:13:35 +02:00
Tamás Bálint Misius
b4213a20f7
Fix workflow sometimes releasing debug builds
Both the debug and release jobs would upload artifacts, with the same name, which ghactions of course accepted without question. Snapshot 240 happens to have been released correctly (so all binaries are release builds), but that's just luck. I'd thought I'd fixed this problem with another commit, but turns out I hadn't.

Also factor out a bunch of variables so I won't mess up in the future.
2022-09-15 12:11:52 +02:00
Tamás Bálint Misius
25d6ca9dec
Fix crash when trying to load a stamp that doesn't exist 2022-09-11 16:56:40 +02:00
Tamás Bálint Misius
fefafa3b3d
Display link command line when building for windows
Command line is limited in length on windows so meson/ninja puts it in a response file and passes that to the linker instead. Only problem is, ninja -v displays only the part of the command line where it tells link.exe where the response file is, not what's in the response file. So I just had the script print it. Care must also be taken for the script to properly fail if ninja fails, but not before the command line is printed.

Also add /GL and /LCTG to msvc command lines because they can't hurt. Right?
2022-09-11 14:15:34 +02:00
Tamás Bálint Misius
f42c8372d2
Fix release assets failing to upload 2022-09-11 07:15:36 +02:00
Tamás Bálint Misius
bc208a700f
Fix new workflow not creating releases in some cases 2022-09-11 06:49:07 +02:00
Tamás Bálint Misius
1f1f450177
Fix starcatcher uploads 2022-09-11 01:03:53 +02:00
Tamás Bálint Misius
a674498a96
Clean up Client::DoInstallation
Also Factor out app constants that mods might change into Meson options and clean up format::URLEncode in the process, convert app and document icon data in arrays to actual images, actualize AppStream data for possible future packaging, add alternative command line format for opening filesystem saves and ptsave URLs, fix a memory leak in Platform::GetCwd, and add format::URLDecode.
2022-09-08 06:54:35 +02:00
Tamás Bálint Misius
04e899e824
Use std::vector<char> consistently for file operations
This made it possible to get rid of two GameSave constructors.

Also clean up Client::LoadSaveFile, Client::ReadFile, and Client::WriteFile in the process, and remove unused SaveRenderer::Render
2022-09-08 06:45:25 +02:00
Tamás Bálint Misius
69faea971f
Enable By date button when viewing Favorites 2022-09-07 13:01:52 +02:00
Tamás Bálint Misius
513d2cae3e
Update tpt-libs
Also restructure meson.build and the ghactions workflow a bit, and enable -ffunction-sections and -fdata-sections.

Note that starcatcher uploads have not been tested and most likely don't work.
2022-09-03 07:01:21 +02:00