News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Reverting the reserving through feature (and consequential changes to Github)

Started by jamespetts, September 01, 2016, 11:33:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

Unfortunately, I have had to revert the new feature whereby trains would reserve through station stops and not reset to drive by sight at each station: I have not been able to make this work within a reasonable time-frame, and have not been able to identify any reliable way of determining how to resolve the remaining issues or even how to identify the nature of the remaining issues.

In retrospect, the design of the signalling code has not proved to be very readable or maintainable: I tried to change it incrementally from the Standard code, but this has resulted in it being insufficiently modular, as the Standard code was much simpler, which has made it hard to modify substantially. Any more experienced programmer than I who would like a go at making this work again (including if necessary rewriting the signalling code to make it more modular) is more than welcome to have a go - this would be a very worthwhile feature if it could be made to work, as it would allow for unsignalled halts.

To accomplish this reversion, I have put all of the code for the reserving through feature that I had so far completed onto a new reserving-through branch of Github. This should enable work to continue on this branch one day if anyone is up to the challenge of making this feature work.

I can no longer use devel-new as a consequence of having to reset my local working copy to an earlier version, so I have created a new branch, devel-new-2, which will be the main development branch henceforth.

Further, I have incorporated into that branch all of the fixes and changes not directly relating to the reserving through feature that I have made since that feature was introduced (including the monthly way wear feature), and made one further fix to the signalling relating to directional reservations.

I should be very grateful if people could test this reverted and modified version to make sure that it is working properly; my brief tests indicate that it appears to work as expected, but I have not had the time for extensive testing.

Thank you to everyone for your patience whilst I tried to fix these difficulties, and my apologies that i have not been able to make this feature work as requested: I know that it was a popular request amongst some of the most dedicated users.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

You seem to have made some HUGE amount of commits to this branch (devel-new-2) while the server was down, looks like you have incorporated alot of things from standard?

However, I get these errors while trying to compile:

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'SDL.h': No such file or directory Simutrans-Experimental C:\Users\Victor\Documents\GitHub\simutrans-experimental\simsys_s.cc 7
Error C1083 Cannot open include file: 'allegro.h': No such file or directory Simutrans-Experimental C:\Users\Victor\Documents\GitHub\simutrans-experimental\simsys_d.cc 17
Error C1083 Cannot open include file: 'SDL.h': No such file or directory Simutrans-Experimental C:\Users\Victor\Documents\GitHub\simutrans-experimental\simsys_opengl.cc 15
Error C1083 Cannot open include file: 'SDL2/SDL.h': No such file or directory Simutrans-Experimental C:\Users\Victor\Documents\GitHub\simutrans-experimental\simsys_s2.cc 7
Error (active) placement 'new' expression refers to non-placement function "operator delete(void *, unsigned int)" (declared implicitly) Simutrans-Experimental c:\Users\Victor\Documents\GitHub\simutrans-experimental\besch\bild_besch.cc 411
Error (active) placement 'new' expression refers to non-placement function "operator delete(void *, unsigned int)" (declared implicitly) Simutrans-Experimental c:\Users\Victor\Documents\GitHub\simutrans-experimental\besch\bild_besch.cc 383
Error (active) placement 'new' expression refers to non-placement function "operator delete(void *, unsigned int)" (declared implicitly) Simutrans-Experimental c:\Users\Victor\Documents\GitHub\simutrans-experimental\besch\bild_besch.cc 334
Error (active) placement 'new' expression refers to non-placement function "operator delete(void *, unsigned int)" (declared implicitly) Simutrans-Experimental c:\Users\Victor\Documents\GitHub\simutrans-experimental\besch\bild_besch.cc 308

jamespetts

Indeed - I have incorporated the changes from Standard in 2016. Can you give me more information on the system on which you are trying to compile this?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Junna

Windows, presumably. I get the same things missing. Missing SDL.h, SDL2.h, and allegro (though I am sure I had allegro as it was required before...)

Ves

I'm running windows 10 and vs2015.
I think I remember having the issues with the "new" problem before, and the fix for those is including or defining something. Don't remember what and where though.

Does this mean that the new features regarding transparency and dat file shortening as well as the image implementation in text, is now workable in experimental?

Junna

I run win7 and vs2012, and I have the same problem. I guess that SDL or allegro stuff was updated in some way...

jamespetts

If you are in Windows, you need to exclude the simsys_x files from the build (right click on the files in MSVS for the relevant menu) where x represents anything other than "w", which should give you a GDI build. I thought that this would have been done automatically unless you are using a different vxproj file?

The reason for this change is that I am using the in-built system in MSVS for excluding files from the build, rather than preprocessor directives as before, making it more compatible with other platforms.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

I am using the file called "Simutrans-Experimental.vcxproj". I tested to delete every simsys_*.cc file except "simsys_w.cc", but it gave me a bunch of other errors instead.

Starting over with a fresh one....

edit:

Starting over again and deleting files creating errors one file at a time, I end up with "simsys.cc", "simsys_w.cc" and "simsys_w32_png.cc" getting this bunch of errors:

1>------ Build started: Project: Simutrans-Experimental, Configuration: Release Win32 ------
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_get_IHDR
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_read_image
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_write_info
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_invert_alpha
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_destroy_write_struct
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_get_rowbytes
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_expand
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_read_info
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_strip_alpha
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_strip_16
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_packing
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_create_read_struct
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_write_end
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_create_info_struct
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_read_update_info
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_read_end
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_write_row
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_create_write_struct
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_filler
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_init_io
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_IHDR
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_swap_alpha
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_set_compression_level
1>dr_rdpng.obj : error LNK2001: unresolved external symbol _png_destroy_read_struct
1>.\simutrans\Simutrans-Experimental.exe : fatal error LNK1120: 24 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Junna

I use the .sln file available. It never shewed this particular error in the past.

There are a number of files, like simsys.cc, should that be excluded? Simsys_d?
simsys_posix, simsys_s, simsys_s2, I assume those are SDL...

Either way, removing them, including and excluding w32_png just gives:

Error   2   error LNK2001: unresolved external symbol _png_get_IHDR   C:\simusrc 2\dr_rdpng.obj   Simutrans-Experimental

Including w32 just makes it give another error.

jamespetts

Ahh - no, you need simsys.cc as that is the base file. You also need simsys_w32_png.cc, as that is important for graphics. You need to exclude dr_rdpng.cc, simsys_d.cc, simsys_opengl.cc, simsys_posix.cc, simsys_s.cc and simsys_s2.cc. These should already be excluded in the debug build, but I may not have propagated this to the release build, so if you are compiling a release build, this might explain the errors.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.


Junna

Ah, okay, d_rdpng excluded as well, now it works. Indeed it was a release build (I only run debug builds if it's an easily reproducible crash, as it lags too much to run the game at anything but snail's pace).

jamespetts

 I have modified the various build definitions so that the following builds should now work:
* Debug
* Release
* Debug (command line server)
* Release (command line server)

I hope that this helps.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves


Vladki

Server recompiled and restarted with devel-new-2

I'd like to refresh my rusty coding skills, and I was wondering if I could try a really new approach to signaling. Though I'd need some introduction on how it works now. I mean also with connection to pathfinding and such. Could you give me some introduction?

jamespetts

The signalling code is quite hard to read, so it will not be a gentle introduction.

In essence, however, the most important functions are both in the vehicle class, being vehikel_t::can_enter_tile() and vehikel_t::block_reserver(). The important ancillary functions are all called from there. Only the front vehicle in a train calls these methods.

Vehicle movement is generally calculated stop to stop. When a train is preparing to leave a stop, it advances its schedule to the next item, calculates the route to the next stop, and then checks that it can enter the first tile of that route using can_enter_tile(). It also always starts in the drive by sight method (with some specific exceptions, such as the token block working method).

The can_enter_tile() method in turn calls the block_reserver() method in some instances (and every tile for the drive by sight working method), which then checks a number of tiles ahead (how many will depend on the working method and other various parameters). Much more detailed logic is invoked when a signal is reached.

The block_reserver() code iterates over the tiles on the train's current route (i.e., from one stop to the next). It tries to reserve each tile one by one until a certain point is reached, either the end of the route, enough signals ahead that, depending on the working method, it need reserve no further, or a failure to reserve.

Then, depending on where it has ended, a certain part of the route may need to be un-reserved again (usually back to the previous signal, for example), and there is a routine for that.

Next, all of the signals on the route, which had been put into a vector, need to be cleared and given the right aspects, and there is a long routine for that.

There are also specific routines for splicing routes for choose signals (which calls block_reserver() recursively from a separate function, activate_choose_signal(), with special flags when called recursively to prevent infinite loops) and for token block working.

As trains leave tiles, the leave_tile() method unreserves the route behind them, and also changes the states of automatic signals (i.e. signals in the track circuit block working method that do not protect junctions). This unreserving is disabled in the token block and one train staff working methods.

The block_reserver() method is passed a pointer to a variable "next_signal", which is then used to set the "next_stop" variable in the convoy object attached to that vehicle. This is very important, as it tells the train where it needs to brake to try to stop next. What is supposed to happen is that, if a signal should be at danger, calling can_enter_tile() from the tile on which that signal is situated will return false, and the train will be held. If the signal should be at a less restrictive aspect, a reservation should be calculated from beyond that point to the next signal (or other place) and the next_stop variable increased accordingly. If, for some reason, can_enter_tile() returns true but next_stop is not updated, the train will be stuck at 1km/h and unable to reserve a route onwards, but will also not be held. In this situation, there is an emergency escape route in which the train will at the next tile revert to drive by sight, but it ought not to get here in the first place. This was the (immediate) cause of many of the bugs reported during the development of the new signalling system.

As it continues along its route, the train will check for signals ahead within its sighting distance, and call block_reserver() if it finds one. This will then update the next_stop variable (as well as the reservations and displayed signal aspects).

This is a very brief overview indeed, and the system is much more complex than this, but this gives at least a brief introduction that should help to get you started. Do let me know if you have any more specific questions.

Edit: Incidentally, as to waypoints, when the schedule is advanced, the route is calculated. Before any attempt at reserving or moving, if the next stop is a non-reversing waypoint, the schedule is moved on again and a further route calculated, and this route is spliced to the old route. This continues until a stop that is not a non-reversing waypoint is found or the total number of iterations equals the total number of stops in the schedule. Only after this process completes is the can_enter_tile() function called.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.