oldloader.c
changeset 2951 2de6d3a59743
parent 2916 b687477adcba
child 3009 c75f1a8d5ff9
equal deleted inserted replaced
2950:30eee9c93028 2951:2de6d3a59743
   176 						ReadByte(ls);
   176 						ReadByte(ls);
   177 						break;
   177 						break;
   178 
   178 
   179 					case OC_CHUNK:
   179 					case OC_CHUNK:
   180 						/* Call function, with 'i' as parameter to tell which item we
   180 						/* Call function, with 'i' as parameter to tell which item we
   181 						are going to read */
   181 						 * are going to read */
   182 						if (!chunk->proc(ls, i))
   182 						if (!chunk->proc(ls, i)) return false;
   183 							return false;
       
   184 						break;
   183 						break;
   185 
   184 
   186 					case OC_ASSERT:
   185 					case OC_ASSERT:
   187 						DEBUG(oldloader, 4)("[OldLoader] Assert point: %x / %x", ls->total_read, chunk->offset + _bump_assert_value);
   186 						DEBUG(oldloader, 4)("[OldLoader] Assert point: %x / %x", ls->total_read, chunk->offset + _bump_assert_value);
   188 						if (ls->total_read != chunk->offset + _bump_assert_value)
   187 						if (ls->total_read != chunk->offset + _bump_assert_value) {
   189 							ls->failed = true;
   188 							ls->failed = true;
   190 
   189 						}
   191 						break;
   190 						break;
   192 
   191 
   193 				}
   192 				}
   194 			} else {
   193 			} else {
   195 				uint32 res = 0;
   194 				uint32 res = 0;
   343 {
   342 {
   344 	Town *town;
   343 	Town *town;
   345 
   344 
   346 	/* Convert town-names if needed */
   345 	/* Convert town-names if needed */
   347 	FOR_ALL_TOWNS(town) {
   346 	FOR_ALL_TOWNS(town) {
   348 		if (town->xy == 0)
   347 		if (town->xy == 0) continue;
   349 			continue;
       
   350 
   348 
   351 		if (IS_INT_INSIDE(town->townnametype, 0x20C1, 0x20C3)) {
   349 		if (IS_INT_INSIDE(town->townnametype, 0x20C1, 0x20C3)) {
   352 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
   350 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
   353 			town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
   351 			town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
   354 		}
   352 		}
   391 }
   389 }
   392 
   390 
   393 static void FixOldVehicles(void)
   391 static void FixOldVehicles(void)
   394 {
   392 {
   395 	/* Check for shared orders, and link them correctly */
   393 	/* Check for shared orders, and link them correctly */
   396 	{
   394 	Vehicle* v;
   397 		Vehicle *v;
   395 
   398 
   396 	FOR_ALL_VEHICLES(v) {
   399 		FOR_ALL_VEHICLES(v) {
   397 		Vehicle* u;
   400 			Vehicle *u;
   398 
   401 
   399 		if (v->type == 0) continue;
   402 			if (v->type == 0)
   400 
   403 				continue;
   401 		FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
   404 
   402 			if (u->type == 0) continue;
   405 			FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
   403 
   406 				if (u->type == 0)
   404 			/* If a vehicle has the same orders, add the link to eachother
   407 					continue;
   405 			 * in both vehicles */
   408 
   406 			if (v->orders == u->orders) {
   409 					/* If a vehicle has the same orders, add the link to eachother
   407 				v->next_shared = u;
   410 				in both vehicles */
   408 				u->prev_shared = v;
   411 				if (v->orders == u->orders) {
   409 				break;
   412 					v->next_shared = u;
       
   413 					u->prev_shared = v;
       
   414 					break;
       
   415 				}
       
   416 			}
   410 			}
   417 		}
   411 		}
   418 	}
   412 	}
   419 }
   413 }
   420 
   414 
   459 
   453 
   460 static void ReadTTDPatchFlags(void)
   454 static void ReadTTDPatchFlags(void)
   461 {
   455 {
   462 	int i;
   456 	int i;
   463 
   457 
   464 	if (_read_ttdpatch_flags)
   458 	if (_read_ttdpatch_flags) return;
   465 		return;
       
   466 
   459 
   467 	_read_ttdpatch_flags = true;
   460 	_read_ttdpatch_flags = true;
   468 
   461 
   469 	/* TTDPatch misuses _old_map3 for flags.. read them! */
   462 	/* TTDPatch misuses _old_map3 for flags.. read them! */
   470 	_old_vehicle_multipler = _old_map3[0];
   463 	_old_vehicle_multipler = _old_map3[0];
   471 	/* Somehow.... there was an error in some savegames, so 0 becomes 1
   464 	/* Somehow.... there was an error in some savegames, so 0 becomes 1
   472 	and 1 becomes 2. The rest of the values are okay */
   465 	and 1 becomes 2. The rest of the values are okay */
   473 	if (_old_vehicle_multipler < 2)
   466 	if (_old_vehicle_multipler < 2) _old_vehicle_multipler++;
   474 		_old_vehicle_multipler++;
       
   475 
   467 
   476 	/* TTDPatch incraeses the Vehicle-part in the middle of the game,
   468 	/* TTDPatch incraeses the Vehicle-part in the middle of the game,
   477 	so if the multipler is anything else but 1, the assert fails..
   469 	so if the multipler is anything else but 1, the assert fails..
   478 	bump the assert value so it doesn't!
   470 	bump the assert value so it doesn't!
   479 	(1 multipler == 850 vehicles
   471 	(1 multipler == 850 vehicles
  1023 
  1015 
  1024 	OCL_NULL( 8 ), // junk at end of chunk
  1016 	OCL_NULL( 8 ), // junk at end of chunk
  1025 
  1017 
  1026 	OCL_END()
  1018 	OCL_END()
  1027 };
  1019 };
       
  1020 
  1028 static bool LoadOldPlayer(LoadgameState *ls, int num)
  1021 static bool LoadOldPlayer(LoadgameState *ls, int num)
  1029 {
  1022 {
  1030 	Player *p = GetPlayer(num);
  1023 	Player *p = GetPlayer(num);
  1031 
  1024 
  1032 	_current_player_id = num;
  1025 	_current_player_id = num;
  1338 
  1331 
  1339 	OCL_END()
  1332 	OCL_END()
  1340 };
  1333 };
  1341 static bool LoadOldEngine(LoadgameState *ls, int num)
  1334 static bool LoadOldEngine(LoadgameState *ls, int num)
  1342 {
  1335 {
  1343 	if (!LoadChunk(ls, GetEngine(num), engine_chunk))
  1336 	if (!LoadChunk(ls, GetEngine(num), engine_chunk)) return false;
  1344 		return false;
       
  1345 
  1337 
  1346 	/* Make sure wagons are marked as do-not-age */
  1338 	/* Make sure wagons are marked as do-not-age */
  1347 	if ((num >= 27 && num < 54) || (num >= 57 && num < 84) || (num >= 89 && num < 116))
  1339 	if ((num >= 27 && num < 54) || (num >= 57 && num < 84) || (num >= 89 && num < 116))
  1348 		GetEngine(num)->age = 0xFFFF;
  1340 		GetEngine(num)->age = 0xFFFF;
  1349 
  1341