Commit Graph

481 Commits (master)

Author SHA1 Message Date
orwell96 4f7c1b1b5d Rewrite movement logic again 2021-02-10 16:39:46 +01:00
orwell96 8f4c90c5a5 Add debug prints, modify LZB to fix problems with look_ahead 2021-02-10 16:39:46 +01:00
orwell96 080b8fb273 Add IGNORE_WORLD mode to test using only the advtrains save data 2021-02-10 16:39:45 +01:00
orwell96 838cf61eac Make cab signalling work with renamed lzb fields 2021-02-10 16:37:21 +01:00
orwell96 114b915518 Fix new green signals bug caused by old trav_lzbdata, and callback loop in signalling formspec 2021-02-10 16:36:24 +01:00
orwell96 61329c11a2 Start using path_invalidate_ahead() 2021-02-10 16:36:24 +01:00
orwell96 d3b2f614be Hm, forget about it for now. Might be perfectly valid when train goes farther than train length in step 2021-02-10 16:36:24 +01:00
orwell96 b5f8737095 More debug info to hopefully gain more info on the bug 2021-02-10 16:36:24 +01:00
orwell96 a3247dea28 Fix HUD position and Remote Routesetting button 2021-02-10 16:36:24 +01:00
orwell96 227a4aaeac Try to track down why ATC is broken 2021-02-10 16:36:24 +01:00
orwell96 aee7f0d419 Fix things, rework signal aspect select dialog, transform old aspects on-the-fly 2021-02-10 16:36:24 +01:00
orwell96 119a09b784 Simplify Signal Aspect Table (H#132) [breaks compatibility with signal API] 2021-02-10 16:36:24 +01:00
orwell96 573d6b06b2 Always do zero-barrier check and prevent LZB 0 overruns in movement logic 2021-02-10 16:36:24 +01:00
orwell96 8660794ef8 Fix lots of things around new LZB 2021-02-10 16:36:24 +01:00
orwell96 5c2534cc35 Remove pcall wrappers completely, add command to disable advtrains mainloop 2021-02-10 16:36:24 +01:00
orwell96 b59b0d587d Implement a LZB speed lookup table for the path and rewrite velocity controls 2021-02-10 16:35:45 +01:00
orwell96 a78ff65b31 Fix inconsistency between node enter callback and lzb approach callbacks
(this caused the lzb approach to be called on nodes that have just received an enter event, which is not intended)
2021-02-10 16:35:45 +01:00
orwell96 816245588d Disable ARS train flag and surrounding uses 2021-02-10 16:35:45 +01:00
orwell96 e935136d58 Make is_node_loaded() checks also for mesecon interactions and digiline_send(), move on_updated_from_nodedb to advtrains table 2021-02-04 12:35:24 +01:00
orwell96 8ae405f00f Discard get_node_or_nil() for area-loaded check and use either a distance-based approach or minetest.is_block_active() if available
See also https://github.com/minetest/minetest/pull/10897
2021-02-03 09:30:44 +01:00
ywang ef21e70479 Use graphical indication for more elements; improve 7-segment display 2021-01-20 17:12:25 +01:00
ywang 371b5ac503 Use absolute positioning from the bottom of the screen 2021-01-19 16:38:20 +01:00
orwell96 0ba5874b4f Some more serializer fixes (backported from new_lzb):
- Move DUMP_DEBUG_SAVE block before the actual saving so it can be used to trace serializer errors
- Don't crash on functions in data, ignore them silently
- Increase the save interval
2021-01-12 13:31:03 +01:00
orwell96 ce4631dbee Backport ndb format from cellworld to also store the cids in the ndb file; integrate ndb in serialize_lib atomic system 2021-01-12 13:27:00 +01:00
orwell96 e42fbf9dcc Make advtrains use serialize_lib (save version 4)
Old save format will be gracefully migrated
2021-01-12 13:27:00 +01:00
orwell96 bdc49b919d DUMP_DEBUG_SAVE also dumps interlocking data 2021-01-12 13:27:00 +01:00
Gabriel Pérez-Cerezo 0df208af53 fix mis-patched 90+60r crossing conns
Thanks, Maverick2797
2021-01-10 15:42:47 +01:00
Gabriel Pérez-Cerezo e9c76100a1 Add ATC "K" command
This command kicks out all passengers when the train is stopped and
its doors are open. In addtion, a wagon:is_driver_stand(seat) function
was added to allow finding out easily if a seat is the driver stand of
the wagon.
2021-01-07 23:58:05 +01:00
ywang 8655eebc5f Change color of max speed indication 2021-01-07 21:05:05 +01:00
ywang 6575b3dac7 Remove advtrains_hud_blank.png 2021-01-05 15:10:58 +01:00
ywang 741ed7b4a7 Revert to black background; use "blocks" for the (physical) maximum speed 2021-01-05 00:03:16 +01:00
ywang 501911f94c HUD improvements 2021-01-04 23:48:12 +01:00
ywang f4d193c6d1 Minor optimizations 2020-12-30 02:13:57 +01:00
ywang 846e688200 Add demo 2020-12-27 15:24:52 +01:00
ywang b74fc92f81 Minor improvements for speed indicator 2020-12-23 21:20:31 +01:00
ywang 5a0a6fa96d Minor improvements 2020-12-23 11:29:07 +01:00
ywang f4e2277f32 Improve speed indication 2020-12-23 11:14:18 +01:00
ywang 749edd62d1 Improved HUD textures 2020-12-23 10:35:16 +01:00
ywang 0395e81b79 HUD improvements 2020-12-22 23:15:04 +01:00
ywang 4405bbc57a Improved background for speed indicator 2020-12-19 20:38:01 +01:00
ywang 5659134c8c Improved speed indication
The speed indicator is now shown on 4 lines:
Line 1: ATC target speed (blue arrow pointing down)
Line 2: Train velocity (black line)
Line 3: Speed limit (if any) (red line)
Line 4: Next speed limit (red arrow pointing up)
2020-12-19 19:40:13 +01:00
ywang d6acadf018 Use PNG textures for the indication of reverser, lever, control mode, shunt mode, and doors 2020-12-19 18:15:02 +01:00
ywang a88e5aad64 Redesign train HUD
Some train HUD elements _might_ be replaced in the future.
2020-12-19 13:32:38 +01:00
Blockhead 48787fc1b2 Fix 60/90 degree crossing connection 2020-12-03 08:34:42 +01:00
orwell96 0d530ca49f Fix mesecon switch override group
Fixes issues with using mesecon switches as route locks
2020-11-23 23:02:55 +01:00
Blockhead 8d58bd51cd Workaround to destroy looping sounds
Needed for linetrack boat sound bug
2020-11-02 12:12:41 +01:00
Blockhead b616ae4425 Add missing recipe: 45_low platforms 2020-10-19 16:13:02 +02:00
Gabriel Pérez-Cerezo 964b0a7ab6 Remove couple entities when out of range from players
Work around the entity flood bug caused by improper engine handling of
static_save=false
2020-10-12 15:41:27 +02:00
Gabriel Pérez-Cerezo dcf5b8670e Remove last files with CR-LF line endings. 2020-10-11 12:36:06 +02:00
Blockhead 2ecd474ed7 Fix 3-way conns table so traverser doesn't complain
The remaining patch to make advtrains master stable: we can't have any conns
entries without a 'c' member, so make all ["3"] entries into just ["c"] entries.
2020-10-11 12:28:41 +02:00
orwell96 3256c2778d Forbid track modification when train, IP or TCB is on it, better handle removing of TCBs (H#149) 2020-10-07 17:20:47 +02:00
orwell96 a73236d7eb Don't allow wagons with non-empty inventories to be destroyed (H#164) 2020-10-07 15:19:55 +02:00
orwell96 b892d793ac Add windows compatibility in nodedb saving (H#153)
Note: it does not simply add os.delete()  but reverts to the "old" behavior of directly overwriting the file, because this did work before.
2020-10-07 14:41:57 +02:00
Gabriel Pérez-Cerezo 1a743c2dd6 Fix manual switching on regular track switches. 2020-09-14 16:51:43 +02:00
Blockhead 61009bf00d Fix issues introduced by changes to switching
The code I wrote worked only for my y-turnout and 3-way variants because
it assumed the variant name == the switching state, which is obviously
wrong for the default sw(l|r)(st|cr) variants. I have added a
'switchprefix' property to address this.
2020-09-14 19:59:15 +10:00
Blockhead 487ca4e38c Enable three-way turnouts with proper conns support on all sides
I chose to make three-way turnouts have 5 conns (last one is not used) so
that they can be distinguished from crossings easily without refactoring the
code. Three-ways should have their last entry with {["3"]=0} instead as a sort
of internal mark.
2020-09-11 17:19:23 +10:00
Blockhead 1d224d6b4c Add 3-way turnouts and y-turnouts (both diverging) 2020-09-11 04:25:38 +10:00
Gabriel Pérez-Cerezo 606fc83465 localize split function to prevent conflicts with the builtin one 2020-09-04 20:25:12 +02:00
orwell96 0aa83e4932 Escape fields in wagon properties (H#158) 2020-09-04 16:15:27 +02:00
Relatio e4ccf8ffce Fix seating_from_key_helper: use pname instead of player:get_player_name() 2020-08-27 19:18:52 +02:00
Blockhead 595f26b450 Deprecate old 4590 crossings
This is done with a task that runs once when the nodedb is loaded. A new
field of advtrains_ndb will keep a version integer to indicate migration
versions. This introduces verson 1, no version being equivalent to 0.
An LBM is also registered to replace the tracks in the world.
2020-08-21 16:02:02 +02:00
Blockhead b707f20ba2 Add two new sets of diamond crossing types
Add two new sets of diamond crossings in addition to the current set
of perpendicular crossings. Also cleans up the inside edges on the
perpendicular set models. All of these varieties have their mirror
images, which was previously a problem with the 45/90 crossing.

The naming convention for all of these rail types is this: when facing
east and param2=0, the angle and direction of the two crossing rails is
indicated. So 30l45r means 30 degrees left and 45 degrees right. The
mirror image of that would be 30r45l.

There is a recipe for each set of crossing types and the trackworker can
change geometry within types with left cick, and rotate between two 90
degree rotations with right-click. When left-clicking, the angles move
in an intuitive fashion like rotating rails.

* The perpendicular set (already existing) has rails that cross at 90
degrees.
* The 90+x set has 90 degree (straight, node aligned) rails plus a rail
intersecting that at 30, 45 or 60 degrees.
* The diagonal set has both rails not axis-aligned, for example 30r-45l,
60l60r. The latter is quite useful for scissors crossovers.
2020-08-21 16:02:02 +02:00
Gabriel Pérez-Cerezo b23d346ace add maximum length parameter to split_at_fc and split_off_locomotive 2020-08-21 15:58:12 +02:00
Gabriel Pérez-Cerezo 36d8c8b716 Add command to split off locomotive 2020-07-28 20:39:35 +02:00
Gabriel Pérez-Cerezo 45413ee5c0 Add function to step through freight codes 2020-07-26 23:30:07 +02:00
Gabriel Pérez-Cerezo c54e0b341a add split_train_at_fc luaatc command
This command splits the train at the second non-empty FC it
encounters, taking with it the first few freight cars that all go to
the same destination.
2020-07-26 23:30:07 +02:00
Gabriel Pérez-Cerezo de8add139c add Freightcodes to wagon properties formspec 2020-07-26 23:30:07 +02:00
orwell96 00031064a5 Do not unload wagons when a player that is logged in sits in it 2020-07-26 18:53:16 +02:00
Blockhead d65ba80df7 Add low 45 degree platforms
I would like to take this opportunity to credit Och_Noe as the original
author for the plans to the 45 degree platform model. I failed to credit
him properly when the first lot of 45 degree platforms were added.
2020-07-25 19:14:57 +02:00
Gabriel Pérez-Cerezo 9d52770f21 Add client side translations by ywang 2020-07-19 23:04:13 +02:00
Gabriel Pérez-Cerezo 8c66f1caf4 Fix error in workaround causing train entities to despawn. 2020-07-19 23:00:07 +02:00
Gabriel Pérez-Cerezo 7de2a9142f Merge branch 'master' of bananach.space:advtrains 2020-07-19 22:57:29 +02:00
ywang cc78b63e34 [BREAKING] Use client-side translations instead of intllib; add zh_CN translations
* Client-side translations is used instead of intllib. [Breaks MT4 compat]
* Existing locale files have been moved to advtrains/locale and named with the format advtrains.[lang].tr
* Add zh_CN locale. (requires a font that supports CJK text)
2020-07-19 16:21:08 +02:00
orwell96 19509acf56 Add workaround to unload wagons that are too far away from players 2020-07-12 20:37:51 +02:00
Blockhead 3040c53413 Move recipes to train_track and add crossing recipes 2020-07-10 22:14:39 +02:00
techniX 74bf177cc8 optimize path_get_index_by_offset
Instead of calling path_get_adjacent twice (which calls path_get
twice, i.e. 4 times overall), we call path_get directly only 2 times
with min and max indices to generate all the path we need for
calculations.
2020-07-10 12:02:23 +02:00
orwell96 f33bb563e7 Add "Fallback state" for freed routes, move p_mesecon_iface.lua to core 2020-07-07 14:25:47 +02:00
Blockhead 96236c04dc Add perpendicular and 45/90 degree crossing rails
Add a set of new models for crossings to make some new track
arrangements possible. This commit adds perpendicular crossigns that can
be rotated at any angle: 30/45/60/90 and 45/90 degree crossings in two
rotations. In future, further crossing types can be added to the blender
file.

Add the blender file in rail_crossings.blend that is the source of these
files and which refers to the texture inside advtrains_train_track.

Add a set of prototypes for rail crossings to advtrains/tracks.lua and
register the new crossings in advtrains_train_track.
2020-07-06 17:32:22 +02:00
Blockhead eb2e5f4cdf Fix access control to wagon properties
Previously, players were able to open the wagon properties of any wagon at all
through the wagon properties button on the inventory formspec and through the
wagon buttons on the onboard computer. Add a check for ownership before
allowing players to open wagon properties.
2020-06-29 01:37:35 +02:00
Gabriel Pérez-Cerezo 0b14d8ddb1 Add autocouple mode
The shunting mode no longer makes trains couple, since it was meant
for other purposes. For autocoupling, the new autocoupling mode is
used. If trains are in autocouple mode, they couple when they collide
with another train.
2020-06-29 01:30:27 +02:00
Gabriel Pérez-Cerezo f458f39fde comment out annoying debug info 2020-06-14 12:24:30 +02:00
Gabriel Pérez-Cerezo 51c0920bc0 Merge branch 'master' of bananach.space:advtrains 2020-06-14 12:04:13 +02:00
Gabriel Pérez-Cerezo ae79af604c display oncoming lzb speed restrictions in HUD 2020-06-14 12:02:48 +02:00
orwell96 b13c725976 Workaround to handle split points (dt. aufgefahrene Weichen), fixing H#77 2020-06-10 20:56:35 +02:00
Gabriel Pérez-Cerezo d61c2145a0 Merge branch 'wagon_prop_formspec' of https://github.com/Montandalar/advtrains 2020-06-08 13:50:08 +02:00
Gabriel Pérez-Cerezo 943e5208a9 Fix trains flipping when autocoupling 2020-06-08 00:25:29 +02:00
Blockhead e57c1eaa7f Remove debugging print statement 2020-04-12 18:44:57 +10:00
Blockhead f43254c282 Add road numbers to wagon properties, bordcom
A road number is used to allow users to set their own wagon numbers
other than the internal IDs assigned by advtrains. A railway company
would typically keep a roster of what rollingstock it has in road
numbers.

The road number can be set on the wagon properties formspec. It is
displayed above the wagon's inventory icon in the onboard computer as a
button, which will then open the wagon properties on that wagon.

Road numbers might be displayable as additional text entities on the
wagon like signs.

Currently opening the wagon properties (and sometimes onboard computer)
formspecs can be quite unreliable (at least on windows), so I hope that
closing the wagon 'main menu' before opening other formspecs helps that
reliability. It seems to be an upstream bug.
2020-04-07 14:16:47 +10:00
Blockhead d0629469aa Show the wagon properties button only to the owner 2020-03-18 01:13:06 +11:00
Blockhead 2da11c5a49 Use a standard wagon inventory formspec
This new formspec also allows access to the wagon properties. Once
whitelisted in the wagon properties, other players can access its
inventory.

Note on 'useless use' of OO: I tried passing just the wagon ID and
avoiding using the `self` object in order to bypass the need to look up
the lua entitie out of the list, but it ended up retrieving nil data.
The best way to solve this overhead might be to wait for some kind of
better way upstream in minetest's lua API to get entities, or to keep a
central record of entities. Either way, the solution is outside the
scope of this commit.
2020-03-18 00:35:30 +11:00
Gabriel Pérez-Cerezo fb837a449a Merge branch 'diagonal_platforms' of https://github.com/Montandalar/advtrains 2020-03-15 12:04:10 +01:00
Blockhead 301dcf953e Reduce the profile of the platforms by 0.1
Currently some trains clip the platform (especially E231
modpack), but they won't after the platform edge is moved
back slightly.
2020-03-15 21:56:42 +11:00
Blockhead 09fda4ffaa Add 45 degree diagonal platforms with a mesh 2020-03-15 21:51:38 +11:00
Blockhead 3b87ac5372 Delete train if it ends up off track, show a warning 2020-03-03 23:00:20 +11:00
Blockhead 0689c70aac Save clipboard on item metadata
Also a minor user feedback text cleanup
2020-03-03 23:00:20 +11:00
Blockhead 8a08d77166 Remove debugging print statements 2020-03-03 23:00:20 +11:00
Blockhead 378d862572 Draft copy tool
The copy tool copies a train to a global clipboard.  It copies
the Line number, Routing code, inside text and outside text.
It copies the kinds of wagons in the train and whether they
are flipped around.

Pasting with the copy tool will conditionally flip the train
such that 'your front' of the train, rather than the absolute
front of the train, is what is output. The new train is
oriented to travel forward with the placing player's view.

Conditons are:
- Multi-unit/push-pull train (= has locomotives on both ends):
  Never flipped
- Locomotive-hauled train (= has one end with a locomotive):
  Flipped so that the locomotive is always at the front. If the
  locomotive points long hood forward, it will still point long
  hood forward.
- Rake of wagons (= has no locomotives on ends):
  Flipped according to which end of the train the player copies
  from. If the player is towards the back (wagon out of train
  divded by total wagons > 0.5), then the back becomes the new
  front. If the player is towards the front, no change.
2020-03-03 23:00:20 +11:00
orwell96 9d7b21c451 Relicense under AGPLv3 and update information in readme.txt 2020-02-15 22:19:22 +01:00
orwell96 1bb1d825f4 Use minetest.safe_file_write() to atomically save state [Breaks MT4 compat] 2020-01-10 14:08:56 +01:00
Blockhead c0c6fcf00b Apply minetest.formspec_escape() to prevent formspec injection (H#143) 2020-01-04 18:33:57 +01:00