Changeset - r25480:81569e84403d
[Not reviewed]
master
0 1 0
Rubidium - 3 years ago 2021-05-10 21:02:44
rubidium@openttd.org
Codechange: comparison result is always the same due to earlier check

Practically the length of the handlers not being equal to the number of
features is the problem as it means something was forgotten when adding
a new feature, so static assert to that and let the existing check on
the feature number take care of invalid data from the NewGRFs.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -4746,6 +4746,7 @@ static void FeatureChangeInfo(ByteReader
 
		/* GSF_ROADTYPES */     RoadTypeChangeInfo,
 
		/* GSF_TRAMTYPES */     TramTypeChangeInfo,
 
	};
 
	static_assert(GSF_END == lengthof(handler));
 

	
 
	uint8 feature  = buf->ReadByte();
 
	uint8 numprops = buf->ReadByte();
 
@@ -4760,7 +4761,7 @@ static void FeatureChangeInfo(ByteReader
 
	grfmsg(6, "FeatureChangeInfo: Feature 0x%02X, %d properties, to apply to %d+%d",
 
	               feature, numprops, engine, numinfo);
 

	
 
	if (feature >= lengthof(handler) || handler[feature] == nullptr) {
 
	if (handler[feature] == nullptr) {
 
		if (feature != GSF_CARGOES) grfmsg(1, "FeatureChangeInfo: Unsupported feature 0x%02X, skipping", feature);
 
		return;
 
	}
0 comments (0 inline, 0 general)