fix bad ship names in save file.

This commit is contained in:
Enno Rehling 2016-11-11 21:46:56 +01:00
parent 599c422852
commit 110e87916d
2 changed files with 9 additions and 3 deletions

View File

@ -750,7 +750,7 @@ unit *read_unit(struct gamedata *data)
READ_STR(data->store, obuf, sizeof(obuf)); READ_STR(data->store, obuf, sizeof(obuf));
if (unicode_utf8_trim(obuf)!=0) { if (unicode_utf8_trim(obuf)!=0) {
log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf);
}; }
u->_name = obuf[0] ? _strdup(obuf) : 0; u->_name = obuf[0] ? _strdup(obuf) : 0;
if (lomem) { if (lomem) {
READ_STR(data->store, NULL, 0); READ_STR(data->store, NULL, 0);
@ -759,7 +759,7 @@ unit *read_unit(struct gamedata *data)
READ_STR(data->store, obuf, sizeof(obuf)); READ_STR(data->store, obuf, sizeof(obuf));
if (unicode_utf8_trim(obuf)!=0) { if (unicode_utf8_trim(obuf)!=0) {
log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf);
}; }
u->display = obuf[0] ? _strdup(obuf) : 0; u->display = obuf[0] ? _strdup(obuf) : 0;
} }
READ_INT(data->store, &number); READ_INT(data->store, &number);
@ -1646,12 +1646,18 @@ struct building *read_building(gamedata *data) {
READ_INT(store, &b->no); READ_INT(store, &b->no);
bhash(b); bhash(b);
READ_STR(store, name, sizeof(name)); READ_STR(store, name, sizeof(name));
if (unicode_utf8_trim(name)!=0) {
log_warning("trim building %s name to '%s'", itoa36(b->no), name);
}
b->name = _strdup(name); b->name = _strdup(name);
if (lomem) { if (lomem) {
READ_STR(store, NULL, 0); READ_STR(store, NULL, 0);
} }
else { else {
READ_STR(store, name, sizeof(name)); READ_STR(store, name, sizeof(name));
if (unicode_utf8_trim(name)!=0) {
log_warning("trim building %s info to '%s'", itoa36(b->no), name);
}
b->display = _strdup(name); b->display = _strdup(name);
} }
READ_INT(store, &b->size); READ_INT(store, &b->size);

View File

@ -92,7 +92,7 @@ static void test_readwrite_building(CuTest * tc)
r = test_create_region(0, 0, 0); r = test_create_region(0, 0, 0);
b = test_create_building(r, 0); b = test_create_building(r, 0);
free(b->name); free(b->name);
b->name = strdup(" Hodor "); b->name = _strdup(" Hodor ");
CuAssertStrEquals(tc, " Hodor ", b->name); CuAssertStrEquals(tc, " Hodor ", b->name);
mstream_init(&data.strm); mstream_init(&data.strm);
gamedata_init(&data, &store, RELEASE_VERSION); gamedata_init(&data, &store, RELEASE_VERSION);