src/industry_cmd.cpp
changeset 7786 7a03d776107a
parent 7784 efb98124ce51
child 7787 6e0b6ea38850
equal deleted inserted replaced
7785:9e85a222f8fb 7786:7a03d776107a
  2053 		SlSetArrayIndex(ind->index);
  2053 		SlSetArrayIndex(ind->index);
  2054 		SlObject(ind, _industry_desc);
  2054 		SlObject(ind, _industry_desc);
  2055 	}
  2055 	}
  2056 }
  2056 }
  2057 
  2057 
       
  2058 /* Save and load the mapping between the industry/tile id on the map, and the grf file
       
  2059  * it came from. */
       
  2060 static const SaveLoad _industries_id_mapping_desc[] = {
       
  2061 	SLE_VAR(EntityIDMapping, grfid,         SLE_UINT32),
       
  2062 	SLE_VAR(EntityIDMapping, entity_id,     SLE_UINT8),
       
  2063 	SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8),
       
  2064 	SLE_END()
       
  2065 };
       
  2066 
       
  2067 static void Save_IIDS()
       
  2068 {
       
  2069 	uint i;
       
  2070 	uint j = _industry_mngr.GetMaxMapping();
       
  2071 
       
  2072 	for (i = 0; i < j; i++) {
       
  2073 		SlSetArrayIndex(i);
       
  2074 		SlObject(&_industry_mngr.mapping_ID[i], _industries_id_mapping_desc);
       
  2075 	}
       
  2076 }
       
  2077 
       
  2078 static void Save_TIDS()
       
  2079 {
       
  2080 	uint i;
       
  2081 	uint j = _industile_mngr.GetMaxMapping();
       
  2082 
       
  2083 	for (i = 0; i < j; i++) {
       
  2084 		SlSetArrayIndex(i);
       
  2085 		SlObject(&_industile_mngr.mapping_ID[i], _industries_id_mapping_desc);
       
  2086 	}
       
  2087 }
       
  2088 
  2058 static void Load_INDY()
  2089 static void Load_INDY()
  2059 {
  2090 {
  2060 	int index;
  2091 	int index;
  2061 
  2092 
  2062 	ResetIndustryCounts();
  2093 	ResetIndustryCounts();
  2071 		SlObject(i, _industry_desc);
  2102 		SlObject(i, _industry_desc);
  2072 		IncIndustryTypeCount(i->type);
  2103 		IncIndustryTypeCount(i->type);
  2073 	}
  2104 	}
  2074 }
  2105 }
  2075 
  2106 
       
  2107 static void Load_IIDS()
       
  2108 {
       
  2109 	int index;
       
  2110 	uint max_id;
       
  2111 
       
  2112 	/* clear the current mapping stored.
       
  2113 	 * This will create the manager if ever it is not yet done */
       
  2114 	_industry_mngr.ResetMapping();
       
  2115 
       
  2116 	/* get boundary for the temporary map loader NUM_INDUSTRYTYPES? */
       
  2117 	max_id = _industry_mngr.GetMaxMapping();
       
  2118 
       
  2119 	while ((index = SlIterateArray()) != -1) {
       
  2120 		if ((uint)index >= max_id) break;
       
  2121 		SlObject(&_industry_mngr.mapping_ID[index], _industries_id_mapping_desc);
       
  2122 	}
       
  2123 }
       
  2124 
       
  2125 static void Load_TIDS()
       
  2126 {
       
  2127 	int index;
       
  2128 	uint max_id;
       
  2129 
       
  2130 	/* clear the current mapping stored.
       
  2131 	 * This will create the manager if ever it is not yet done */
       
  2132 	_industile_mngr.ResetMapping();
       
  2133 
       
  2134 	/* get boundary for the temporary map loader NUM_INDUSTILES? */
       
  2135 	max_id = _industile_mngr.>GetMaxMapping();
       
  2136 
       
  2137 	while ((index = SlIterateArray()) != -1) {
       
  2138 		if ((uint)index >= max_id) break;
       
  2139 		SlObject(&_industile_mngr.mapping_ID[index], _industries_id_mapping_desc);
       
  2140 	}
       
  2141 }
       
  2142 
  2076 extern const ChunkHandler _industry_chunk_handlers[] = {
  2143 extern const ChunkHandler _industry_chunk_handlers[] = {
  2077 	{ 'INDY', Save_INDY, Load_INDY, CH_ARRAY | CH_LAST},
  2144 	{ 'INDY', Save_INDY, Load_INDY, CH_ARRAY},
       
  2145 	{ 'IIDS', Save_IIDS, Load_IIDS, CH_ARRAY},
       
  2146 	{ 'TIDS', Save_TIDS, Load_TIDS, CH_ARRAY | CH_LAST},
  2078 };
  2147 };