Changeset - r28470:1ebe16c3eb3f
[Not reviewed]
master
0 1 0
Rubidium - 11 months ago 2024-01-15 17:39:31
rubidium@openttd.org
Codechange: use range based for loop, instead of tile numbers
1 file changed with 16 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -49,14 +49,13 @@ void FixOldMapArray()
 
	 * (without assigned station struct) */
 
	MakeSea(0);
 
}
 

	
 
static void FixTTDMapArray()
 
{
 
	for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
 
		Tile tile(t);
 
	for (auto tile : Map::Iterate()) {
 
		switch (GetTileType(tile)) {
 
			case MP_STATION:
 
				tile.m4() = 0; // We do not understand this TTDP station mapping (yet)
 
				switch (tile.m5()) {
 
					/* We have drive through stops at a totally different place */
 
					case 0x53: case 0x54: tile.m5() += 170 - 0x53; break; // Bus drive through
 
@@ -210,14 +209,13 @@ void FixOldVehicles()
 
		/* Shared orders are fixed in AfterLoadVehicles now */
 
	}
 
}
 

	
 
static bool FixTTOMapArray()
 
{
 
	for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
 
		Tile tile(t);
 
	for (auto tile : Map::Iterate()) {
 
		TileType tt = GetTileType(tile);
 
		if (tt == 11) {
 
			/* TTO has a different way of storing monorail.
 
			 * Instead of using bits in m3 it uses a different tile type. */
 
			tile.m3() = 1; // rail type = monorail (in TTD)
 
			SetTileType(tile, MP_RAILWAY);
 
@@ -1481,46 +1479,42 @@ static bool LoadOldGameDifficulty(Loadga
 
static bool LoadOldMapPart1(LoadgameState *ls, int)
 
{
 
	if (_savegame_type == SGT_TTO) {
 
		Map::Allocate(OLD_MAP_SIZE, OLD_MAP_SIZE);
 
	}
 

	
 
	for (uint i = 0; i < OLD_MAP_SIZE; i++) {
 
		Tile(i).m1() = ReadByte(ls);
 
	for (auto t : Map::Iterate()) {
 
		t.m1() = ReadByte(ls);
 
	}
 
	for (uint i = 0; i < OLD_MAP_SIZE; i++) {
 
		Tile(i).m2() = ReadByte(ls);
 
	for (auto t : Map::Iterate()) {
 
		t.m2() = ReadByte(ls);
 
	}
 

	
 
	if (_savegame_type != SGT_TTO) {
 
		/* old map3 is split into to m3 and m4 */
 
		for (uint i = 0; i < OLD_MAP_SIZE; i++) {
 
			Tile(i).m3() = ReadByte(ls);
 
			Tile(i).m4() = ReadByte(ls);
 
		for (auto t : Map::Iterate()) {
 
			t.m3() = ReadByte(ls);
 
			t.m4() = ReadByte(ls);
 
		}
 
		for (uint i = 0; i < OLD_MAP_SIZE / 4; i++) {
 
		auto range = Map::Iterate();
 
		for (auto it = range.begin(); it != range.end(); /* nothing. */) {
 
			byte b = ReadByte(ls);
 
			Tile(i * 4 + 0).m6() = GB(b, 0, 2);
 
			Tile(i * 4 + 1).m6() = GB(b, 2, 2);
 
			Tile(i * 4 + 2).m6() = GB(b, 4, 2);
 
			Tile(i * 4 + 3).m6() = GB(b, 6, 2);
 
			for (int i = 0; i < 8; i += 2, ++it) (*it).m6() = GB(b, i, 2);
 
		}
 
	}
 

	
 
	return true;
 
}
 

	
 
static bool LoadOldMapPart2(LoadgameState *ls, int)
 
{
 
	uint i;
 

	
 
	for (i = 0; i < OLD_MAP_SIZE; i++) {
 
		Tile(i).type() = ReadByte(ls);
 
	for (auto t : Map::Iterate()) {
 
		t.type() = ReadByte(ls);
 
	}
 
	for (i = 0; i < OLD_MAP_SIZE; i++) {
 
		Tile(i).m5() = ReadByte(ls);
 
	for (auto t : Map::Iterate()) {
 
		t.m5() = ReadByte(ls);
 
	}
 

	
 
	return true;
 
}
 

	
 
static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
0 comments (0 inline, 0 general)