Fix crash on loading some saves with extra data
This commit is contained in:
@@ -107,8 +107,7 @@ static void CM_DecodeTownsExtraInfo(BitIStream &bs)
|
||||
uint n_affected_towns = bs.ReadBytes(2);
|
||||
for (uint i = 0; i < n_affected_towns; i++) {
|
||||
uint town_id = bs.ReadBytes(2);
|
||||
t = Town::Get(town_id);
|
||||
// TODO is it even supposed to return null? or just invalid pointer
|
||||
t = Town::GetIfValid(town_id);
|
||||
if (!t) {
|
||||
DEBUG(sl, 0, "Invalid TownID in CM extra towns info (%u)", town_id);
|
||||
continue;
|
||||
@@ -135,7 +134,7 @@ static void CM_DecodeTownsLayoutErrors(BitIStream &bs)
|
||||
uint n_affected_towns = bs.ReadBytes(2);
|
||||
for (uint i = 0; i < n_affected_towns; i++) {
|
||||
uint town_id = bs.ReadBytes(2);
|
||||
t = Town::Get(town_id);
|
||||
t = Town::GetIfValid(town_id);
|
||||
if (!t) {
|
||||
DEBUG(sl, 0, "Invalid TownID in CB towns layout errors (%u)", town_id);
|
||||
continue;
|
||||
@@ -177,7 +176,7 @@ static void CM_DecodeTownsCargo(BitIStream &bs)
|
||||
uint n_affected_towns = bs.ReadBytes(2);
|
||||
for (uint i = 0; i < n_affected_towns; i++) {
|
||||
uint town_id = bs.ReadBytes(2);
|
||||
t = Town::Get(town_id);
|
||||
t = Town::GetIfValid(town_id);
|
||||
if (!t) {
|
||||
DEBUG(sl, 0, "Invalid TownID in CB towns cargo data (%u)", town_id);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user