News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[125.0.1 or 125.0.2] Cannot read savedata, at message_t::get_coord_from_text()

Started by poppo, Yesterday at 04:26:27 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

poppo

when we open a savedata, loading does not end and crash.

gdb backtrace:
#0  0x0000555555a6370a in message_t::get_coord_from_text(char const*) ()
#1  0x0000555555a6339a in message_t::add_message(char const*, koord3d, unsigned short, unsigned int, unsigned int) ()
#2  0x0000555555b04d89 in karte_t::recalc_average_speed() ()
#3  0x0000555555b0ad77 in karte_t::rdwr_gamestate(loadsave_t*, loadingscreen_t*) ()
#4  0x0000555555b091db in karte_t::load(loadsave_t*) ()

I add debug message to writing str in message_t::get_coord_from_text(), I found why it happened:
koord3d message_t::get_coord_from_text(const char* text)
{
koord3d pos(koord3d::invalid);
const char *str = text;
// scan until either @ or ( are found
while( *(str += strcspn(str, "@(")) ) {
str += 1;
int x=-1, y=-1, z=0;
dbg->message("message_t::get_coord_from_text()","read %s", str);// I add it for debug
int read_coords = sscanf(str, "%d,%d,%d", &x, &y, &z);
debug messages:

Message: message_t::get_coord_from_text():      read 1004,1007,1009)

Message: message_t::get_coord_from_text():      read 1005,1008) <- just before crash
We found that, text can be koord, not only koord3d. then it can be crash.

P.S.
I found that real crash point is
pos = welt->lookup_kartenboden(x,y)->get_pos();
in message_t::get_coord_from_text()


poppo

I found the detail:

when loading messages, some addons have name with (XX,YY,ZZ) to show the number of the vehicle, and its name is written in new or retire messages.
then, this message_t::add_message() trying to read this name as koord3d.

So, we need to add check koord3d needed or not in message_t::add_message().

prissi

Easy to fix in r12368. The first at-mark or opening bracket will parse a string as coordinates. The idea was than this way, one could add coordinates in chat messages.

Generally, any non number or letter for addons are not recommended, because some files systems may not like certain characters.

Andarix

QuoteD:\a\simutrans\simutrans\src\simutrans\descriptor\writer\image_writer.cc(94,49): error C2059: syntax error: ';'

QuoteD:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(1870,5): error C3861: 'rezoom_img': identifier not found [D:\a\simutrans\simutrans\Simutrans-GDI.vcxproj]
  D:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(2537,5): error C3861: 'rezoom_img': identifier not found [D:\a\simutrans\simutrans\Simutrans-GDI.vcxproj]
  D:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(2859,4): error C3861: 'rezoom_img': identifier not found [D:\a\simutrans\simutrans\Simutrans-GDI.vcxproj]
  D:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(3281,4): error C3861: 'rezoom_img': identifier not found [D:\a\simutrans\simutrans\Simutrans-GDI.vcxproj]
  D:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(3353,4): error C3861: 'rezoom_img': identifier not found [D:\a\simutrans\simutrans\Simutrans-GDI.vcxproj]
  D:\a\simutrans\simutrans\src\simutrans\display\simgraph16.cc(3360,4): error C3861: 'rezoom_img': identifier not found