(svn r11163) -Codechange: Verify that the IndustryTileOverrideManager skip the magic value of 0xFF when assigning a new tileID. This is really important, since the value is reserved for water checking.
authorbelugas
Wed, 26 Sep 2007 02:15:00 +0000
changeset 8128 9fe288a99e99
parent 8127 0cbf1d4a5f6d
child 8129 7d673f9710c2
(svn r11163) -Codechange: Verify that the IndustryTileOverrideManager skip the magic value of 0xFF when assigning a new tileID. This is really important, since the value is reserved for water checking.
src/newgrf_commons.cpp
src/newgrf_commons.h
--- a/src/newgrf_commons.cpp	Wed Sep 26 02:11:30 2007 +0000
+++ b/src/newgrf_commons.cpp	Wed Sep 26 02:15:00 2007 +0000
@@ -105,7 +105,7 @@
 	for (id = max_offset; id < max_new_entities; id++) {
 		map = &mapping_ID[id];
 
-		if (map->entity_id == 0 && map->grfid == 0) {
+		if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) {
 			map->entity_id     = grf_local_id;
 			map->grfid         = grfid;
 			map->substitute_id = substitute_id;
--- a/src/newgrf_commons.h	Wed Sep 26 02:11:30 2007 +0000
+++ b/src/newgrf_commons.h	Wed Sep 26 02:15:00 2007 +0000
@@ -33,6 +33,7 @@
 	uint16 max_new_entities; ///< what is the amount of entities, old and new summed
 
 	uint16 invalid_ID;       ///< ID used to dected invalid entities;
+	virtual bool CheckValidNewID(uint16 testid) { return true; }
 
 public:
 	EntityIDMapping *mapping_ID; ///< mapping of ids from grf files.  Public out of convenience
@@ -76,6 +77,8 @@
 
 struct IndustryTileSpec;
 class IndustryTileOverrideManager : public OverrideManagerBase {
+protected:
+	virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; }
 public:
 	IndustryTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
 			OverrideManagerBase(offset, maximum, invalid) {}