News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

[patch] Fix ships restarting at 0 speed upon loading game

Started by TurfIt, September 17, 2010, 03:00:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TurfIt

Upon loading a game, any ships that are moving on the open sea start over at 0 speed. Actually, they 'jump' as though you had opened/closed the schedule for each ship. Ships in canals behave.


vehicle/simvehikel.cc:944
vehikel_t::hop_check()
if((dir&new_dir)==0) {
// new one way sign here?
cnv->suche_neue_route();
return false;
}

is triggering a new route search because

vehicle/simvehikel.cc:612
vehikel_t::set_convoi(
grund_t const* const gr = welt->lookup(pos_next);
if (!gr || !gr->get_weg(get_waytype())) {
pos_next = r.position_bei(route_index + 1U);
}

is corrupting pos_next. After this call, pos_next is set equal to the current position which confuses the first code block, causing the unnecessary route search. This would be fine if the convoi was saved with broken coordinates as set_convoi expects at this point. However, it still triggers with valid coordinates.

The problem is open sea tiles don't require a weg for ships to transverse them. Patch to fix attached.