src/newgrf.cpp
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
--- a/src/newgrf.cpp	Sun Apr 15 17:04:44 2007 +0000
+++ b/src/newgrf.cpp	Sat Apr 21 08:23:57 2007 +0000
@@ -136,7 +136,7 @@
  * loading/parsing grf files, not for runtime debug messages as there
  * is no file information available during that time.
  * @param severity debugging severity level, see debug.h
- * @param debugging message in printf() format */
+ * @param str message in printf() format */
 void CDECL grfmsg(int severity, const char *str, ...)
 {
 	char buf[1024];
@@ -234,6 +234,7 @@
 
 /** Used when setting an object's property to map to the GRF's strings
  * while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one
+ * @param grfid Id of the grf file
  * @param str StringID that we want to have the equivalent in OoenTTD
  * @return the properly adjusted StringID
  */
@@ -1371,7 +1372,7 @@
 		case 0x17: // Four random colours to use
 			FOR_EACH_OBJECT {
 				uint j;
-				for (j = 0; j < 4; j++)	housespec[i]->random_colour[j] = grf_load_byte(&buf);
+				for (j = 0; j < 4; j++) housespec[i]->random_colour[j] = grf_load_byte(&buf);
 			}
 			break;
 
@@ -1522,7 +1523,7 @@
 				uint32 tempfix = grf_load_dword(&buf);
 
 				if (curidx < NUM_CURRENCY) {
-					memcpy(&_currency_specs[curidx].suffix,&tempfix,4);
+					memcpy(&_currency_specs[curidx].suffix, &tempfix, 4);
 					_currency_specs[curidx].suffix[4] = 0;
 				} else {
 					grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx);
@@ -1971,7 +1972,7 @@
 		uint8 prop = grf_load_byte(&buf);
 
 		if (CargoChangeInfo(index, numinfo, prop, &buf, bufend - buf)) {
-			grfmsg(2, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented)", prop);
+			grfmsg(2, "ReserveChangeInfo: Ignoring property 0x%02X (not implemented)", prop);
 		}
 	}
 }
@@ -2004,8 +2005,8 @@
 
 /**
  * Creates a spritegroup representing a sprite number result.
- * @param value The sprite number.
- * @param sprites The number of sprites per set.
+ * @param sprite The sprite number.
+ * @param num_sprites The number of sprites per set.
  * @return A spritegroup representing the sprite number result.
  */
 static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites)
@@ -2060,7 +2061,7 @@
 	if (HASBIT(groupid, 15)) return NewCallBackResultSpriteGroup(groupid);
 
 	if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-		grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid);
+		grfmsg(1, "GetGroupFromGroupID(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid);
 		return NULL;
 	}
 
@@ -2073,7 +2074,7 @@
 	if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid);
 
 	if (spriteid >= _cur_grffile->spriteset_numsets) {
-		grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets);
+		grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets);
 		return NULL;
 	}
 
@@ -2081,7 +2082,7 @@
 	 * is skipped, as TTDPatch mandates that Action 0x02s must be processed.
 	 * We don't have that rule, but must live by the Patch... */
 	if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) {
-		grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty",
+		grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty",
 				setid, type,
 				_cur_grffile->spriteset_start + spriteid * num_sprites,
 				_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1);
@@ -2089,7 +2090,7 @@
 	}
 
 	if (feature != _cur_grffile->spriteset_feature) {
-		grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping",
+		grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping",
 				_cur_grffile->spriteset_feature, feature);
 		return NULL;
 	}
@@ -2385,7 +2386,7 @@
 	if (_cur_grffile->cargo_max == 0) {
 		/* No cargo table, so use bitnum values */
 		if (ctype >= 32) {
-			grfmsg(1, "FeatureMapSpriteGroup: Cargo bitnum %d out of range (max 31), skipping.", ctype);
+			grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
 			return CT_INVALID;
 		}
 
@@ -2394,35 +2395,35 @@
 			if (!cs->IsValid()) continue;
 
 			if (cs->bitnum == ctype) {
-				grfmsg(6, "FeatureMapSpriteGroup: Cargo bitnum %d mapped to cargo type %d.", ctype, c);
+				grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c);
 				return c;
 			}
 		}
 
-		grfmsg(5, "FeatureMapSpriteGroup: Cargo bitnum %d not available in this climate, skipping.", ctype);
+		grfmsg(5, "TranslateCargo: Cargo bitnum %d not available in this climate, skipping.", ctype);
 		return CT_INVALID;
 	}
 
 	/* Check if the cargo type is out of bounds of the cargo translation table */
 	if (ctype >= _cur_grffile->cargo_max) {
-		grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1);
+		grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1);
 		return CT_INVALID;
 	}
 
 	/* Look up the cargo label from the translation table */
 	CargoLabel cl = _cur_grffile->cargo_list[ctype];
 	if (cl == 0) {
-		grfmsg(5, "FeatureMapSpriteGroup: Cargo type %d not available in this climate, skipping.", ctype);
+		grfmsg(5, "TranslateCargo: Cargo type %d not available in this climate, skipping.", ctype);
 		return CT_INVALID;
 	}
 
 	ctype = GetCargoIDByLabel(cl);
 	if (ctype == CT_INVALID) {
-		grfmsg(5, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8));
+		grfmsg(5, "TranslateCargo: Cargo '%c%c%c%c' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8));
 		return CT_INVALID;
 	}
 
-	grfmsg(6, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype);
+	grfmsg(6, "TranslateCargo: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype);
 	return ctype;
 }
 
@@ -2439,11 +2440,11 @@
 		}
 	} else {
 		if (last_engines_count == 0) {
-			grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with");
+			grfmsg(0, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with");
 			return;
 		}
 
-		grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons",
+		grfmsg(6, "VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons",
 				last_engines_count, idcount);
 	}
 
@@ -2457,16 +2458,16 @@
 			return;
 		}
 
-		grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine);
+		grfmsg(7, "VehicleMapSpriteGroup: [%d] Engine %d...", i, engine);
 
 		for (uint c = 0; c < cidcount; c++) {
 			uint8 ctype = grf_load_byte(&bp);
 			uint16 groupid = grf_load_word(&bp);
 
-			grfmsg(8, "FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid);
+			grfmsg(8, "VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid);
 
 			if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-				grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count);
+				grfmsg(1, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count);
 				continue;
 			}
 
@@ -2529,7 +2530,7 @@
 			uint16 groupid = grf_load_word(&bp);
 
 			if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-				grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping",
+				grfmsg(1, "StationMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping",
 				       groupid, _cur_grffile->spritegroups_count);
 				continue;
 			}
@@ -2546,7 +2547,7 @@
 		uint16 groupid = grf_load_word(&bp);
 
 		if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-			grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping",
+			grfmsg(1, "StationMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping",
 			       groupid, _cur_grffile->spritegroups_count);
 			return;
 		}
@@ -2570,7 +2571,7 @@
 	uint16 groupid = grf_load_word(&bp);
 
 	if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-		grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.",
+		grfmsg(1, "TownHouseMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.",
 		       groupid, _cur_grffile->spritegroups_count);
 		return;
 	}
@@ -2580,7 +2581,7 @@
 		HouseSpec *hs = _cur_grffile->housespec[hid];
 
 		if (hs == NULL) {
-			grfmsg(1, "FeatureMapSpriteGroup: Too many houses defined, skipping");
+			grfmsg(1, "TownHouseMapSpriteGroup: Too many houses defined, skipping");
 			return;
 		}
 
@@ -2595,7 +2596,7 @@
 	uint16 groupid = grf_load_word(&bp);
 
 	if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) {
-		grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.",
+		grfmsg(1, "CargoMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.",
 		       groupid, _cur_grffile->spritegroups_count);
 		return;
 	}
@@ -2604,7 +2605,7 @@
 		CargoID cid = buf[3 + i];
 
 		if (cid >= NUM_CARGO) {
-			grfmsg(1, "FeatureMapSpriteGroup: Cargo ID %d out of range, skipping");
+			grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping");
 			continue;
 		}
 
@@ -2795,7 +2796,7 @@
 				case GSF_CANAL :
 				case GSF_BRIDGE :
 					AddGRFString(_cur_spriteid, id, lang, name);
-					switch (GB(id, 8,8)) {
+					switch (GB(id, 8, 8)) {
 						case 0xC9: // House name
 						default:
 							grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id);
@@ -2835,7 +2836,7 @@
 	switch (type) {
 		case 0x04: // Signal graphics
 			if (num != 112 && num != 240) {
-				grfmsg(1, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping");
+				grfmsg(1, "GraphicsNew: Signal graphics sprite count must be 112 or 240, skipping");
 				return;
 			}
 			_signal_base = _cur_spriteid;
@@ -2843,7 +2844,7 @@
 
 		case 0x05: // Catenary graphics
 			if (num != 48) {
-				grfmsg(1, "GraphicsNews: Catenary graphics sprite count must be 48, skipping");
+				grfmsg(1, "GraphicsNew: Catenary graphics sprite count must be 48, skipping");
 				return;
 			}
 			replace = SPR_ELRAIL_BASE + 3;
@@ -2851,7 +2852,7 @@
 
 		case 0x06: // Foundations
 			if (num != 74) {
-				grfmsg(1, "GraphicsNews: Foundation graphics sprite count must be 74, skipping");
+				grfmsg(1, "GraphicsNew: Foundation graphics sprite count must be 74, skipping");
 				return;
 			}
 			replace = SPR_SLOPES_BASE;
@@ -2859,20 +2860,44 @@
 
 		case 0x08: // Canal graphics
 			if (num != 65) {
-				grfmsg(1, "GraphicsNews: Canal graphics sprite count must be 65, skipping");
+				grfmsg(1, "GraphicsNew: Canal graphics sprite count must be 65, skipping");
 				return;
 			}
 			replace = SPR_CANALS_BASE + 5;
 			break;
 
+		case 0x0A: // 2CC colour maps
+			if (num != 256) {
+				grfmsg(1, "GraphicsNew: 2CC colour maps sprite count must be 256, skipping");
+				return;
+			}
+			replace = SPR_2CCMAP_BASE;
+			break;
+
 		case 0x0D: // Coast graphics
 			if (num != 16) {
-				grfmsg(1, "GraphicsNews: Coast graphics sprite count must be 16, skipping");
+				grfmsg(1, "GraphicsNew: Coast graphics sprite count must be 16, skipping");
 				return;
 			}
 			_coast_base = _cur_spriteid;
 			break;
 
+		case 0x10: // New airport sprites
+			if (num != 15) {
+				grfmsg(1, "GraphicsNew: Airport graphics sprite count must be 15, skipping");
+				return;
+			}
+			replace = SPR_AIRPORTX_BASE;
+			break;
+
+		case 0x11: // Road stop sprites
+			if (num != 8) {
+				grfmsg(1, "GraphicsNew: Road stop graphics sprite count must be 8, skipping");
+				return;
+			}
+			replace = SPR_ROADSTOP_BASE;
+			break;
+
 		default:
 			grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)",
 					type, num);
@@ -3070,13 +3095,13 @@
 	}
 
 	if (param < 0x80 && _cur_grffile->param_end <= param) {
-		grfmsg(7, "Param %d undefined, skipping test", param);
+		grfmsg(7, "SkipIf: Param %d undefined, skipping test", param);
 		return;
 	}
 
 	uint32 param_val = GetParamVal(param, &cond_val);
 
-	grfmsg(7, "Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val);
+	grfmsg(7, "SkipIf: Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val);
 
 	if (param == 0x88) {
 		/* GRF ID checks */
@@ -3084,7 +3109,7 @@
 		const GRFConfig *c = GetGRFConfig(cond_val);
 
 		if (condtype != 10 && c == NULL) {
-			grfmsg(7, "GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val));
+			grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val));
 			return;
 		}
 
@@ -3111,7 +3136,7 @@
 				result = c == NULL || c->flags == GCS_DISABLED || c->status == GCS_NOT_FOUND;
 				break;
 
-			default: grfmsg(1, "Unsupported GRF test %d. Ignoring", condtype); return;
+			default: grfmsg(1, "SkipIf: Unsupported GRF test %d. Ignoring", condtype); return;
 		}
 	} else {
 		/* Parameter or variable tests */
@@ -3129,12 +3154,12 @@
 			case 5: result = (param_val & mask) > cond_val;
 				break;
 
-			default: grfmsg(1, "Unsupported test %d. Ignoring", condtype); return;
+			default: grfmsg(1, "SkipIf: Unsupported test %d. Ignoring", condtype); return;
 		}
 	}
 
 	if (!result) {
-		grfmsg(2, "Not skipping sprites, test was false");
+		grfmsg(2, "SkipIf: Not skipping sprites, test was false");
 		return;
 	}
 
@@ -3158,13 +3183,13 @@
 	}
 
 	if (choice != NULL) {
-		grfmsg(2, "Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line);
+		grfmsg(2, "SkipIf: Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line);
 		FioSeekTo(choice->pos, SEEK_SET);
 		_nfo_line = choice->nfo_line;
 		return;
 	}
 
-	grfmsg(2, "Skipping %d sprites, test was true", numsprites);
+	grfmsg(2, "SkipIf: Skipping %d sprites, test was true", numsprites);
 	_skip_sprites = numsprites;
 	if (_skip_sprites == 0) {
 		/* Zero means there are no sprites to skip, so
@@ -3226,7 +3251,7 @@
 	_cur_grfconfig->status = _cur_stage < GLS_ACTIVATION ? GCS_INITIALISED : GCS_ACTIVATED;
 
 	/* Do swap the GRFID for displaying purposes since people expect that */
-	DEBUG(grf, 1, "Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name);
+	DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name);
 }
 
 /* Action 0x0A */
@@ -3315,7 +3340,7 @@
 	/* Skip the error until the activation stage unless bit 7 of the severity
 	 * is set. */
 	if (!HASBIT(severity, 7) && _cur_stage < GLS_ACTIVATION) {
-		grfmsg(7, "Skipping non-fatal GRFLoadError in stage 1");
+		grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage 1");
 		return;
 	}
 	CLRBIT(severity, 7);
@@ -3409,6 +3434,28 @@
 	_skip_sprites = -1;
 }
 
+
+static uint32 GetPatchVariable(uint8 param)
+{
+	switch (param) {
+		/* start year - 1920 */
+		case 0x0B: return _cur_year - ORIGINAL_BASE_YEAR;
+		/* freight trains weight factor */
+		case 0x0E: return _patches.freight_trains;
+		/* empty wagon speed increase */
+		case 0x0F: return 0;
+		/* plane speed factor */
+		case 0x10: return 4;
+		/* 2CC colormap base sprite */
+		case 0x11: return SPR_2CCMAP_BASE;
+
+		default:
+			grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param);
+			return 0;
+	}
+}
+
+
 /* Action 0x0D */
 static void ParamSet(byte *buf, int len)
 {
@@ -3452,7 +3499,7 @@
 	 *   an earlier action D */
 	if (HASBIT(oper, 7)) {
 		if (target < 0x80 && target < _cur_grffile->param_end) {
-			grfmsg(7, "Param %u already defined, skipping", target);
+			grfmsg(7, "ParamSet: Param %u already defined, skipping", target);
 			return;
 		}
 
@@ -3463,8 +3510,7 @@
 		if (GB(data, 0, 8) == 0xFF) {
 			if (data == 0x0000FFFF) {
 				/* Patch variables */
-				grfmsg(2, "ParamSet: Reading Patch variables unsupported");
-				return;
+				src1 = GetPatchVariable(src1);
 			} else {
 				/* GRF Resource Management */
 				if (_cur_stage != GLS_ACTIVATION) {
@@ -3509,7 +3555,7 @@
 							if (size == count) {
 								/* Got the slot... */
 								if (op == 0 || op == 3) {
-									grfmsg(2, "GRM: Reserving %d vehicles at %d", count, start);
+									grfmsg(2, "ParamSet: GRM: Reserving %d vehicles at %d", count, start);
 									for (uint i = 0; i < count; i++) _grm_engines[shift + start + i] = _cur_grffile->grfid;
 								}
 								src1 = start;
@@ -3517,14 +3563,14 @@
 								/* Unable to allocate */
 								if (op != 4 && op != 5) {
 									/* Deactivate GRF */
-									grfmsg(0, "GRM: Unable to allocate %d vehicles, deactivating", count);
+									grfmsg(0, "ParamSet: GRM: Unable to allocate %d vehicles, deactivating", count);
 									_cur_grfconfig->status = GCS_DISABLED;
 
 									_skip_sprites = -1;
 									return;
 								}
 
-								grfmsg(1, "GRM: Unable to allocate %d vehicles", count);
+								grfmsg(1, "ParamSet: GRM: Unable to allocate %d vehicles", count);
 								src1 = UINT_MAX;
 							}
 							break;
@@ -3535,7 +3581,7 @@
 								case 0:
 									/* Check if the allocated sprites will fit below the original sprite limit */
 									if (_cur_spriteid + count >= 16384) {
-										grfmsg(0, "GRM: Unable to allocate %d sprites; try changing NewGRF order", count);
+										grfmsg(0, "ParamSet: GRM: Unable to allocate %d sprites; try changing NewGRF order", count);
 										_cur_grfconfig->status = GCS_DISABLED;
 
 										_skip_sprites = -1;
@@ -3552,12 +3598,12 @@
 									break;
 
 								default:
-									grfmsg(1, "GRM: Unsupported operation %d for general sprites", op);
+									grfmsg(1, "ParamSet: GRM: Unsupported operation %d for general sprites", op);
 									return;
 							}
 							break;
 
-						default: grfmsg(1, "GRM: Unsupported feature 0x%X", feature); return;
+						default: grfmsg(1, "ParamSet: GRM: Unsupported feature 0x%X", feature); return;
 					}
 				}
 			}
@@ -3960,7 +4006,7 @@
 	uint32 grfid = grf_load_dword(&buf);
 	const GRFConfig *c = GetGRFConfig(grfid);
 	if (c == NULL || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) {
-		grfmsg(7, "GRFID 0x%08x unknown, skipping action 13", BSWAP32(grfid));
+		grfmsg(7, "TranslateGRFStrings: GRFID 0x%08x unknown, skipping action 13", BSWAP32(grfid));
 		return;
 	}
 
@@ -3984,7 +4030,7 @@
 	uint16 first_id  = grf_load_word(&buf);
 
 	if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD3FF) || (first_id >= 0xDC00 && first_id + num_strings <= 0xDCFF))) {
-		grfmsg(7, "Attempting to set out-of-range string IDs in action 13 (first: 0x%4X, number: 0x%2X)", first_id, num_strings);
+		grfmsg(7, "TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x%4X, number: 0x%2X)", first_id, num_strings);
 		return;
 	}
 
@@ -4079,16 +4125,17 @@
 	                   |                                        (0 << 0x0B)  // enhancedgui
 	                   |                                        (0 << 0x0C)  // newagerating
 	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x0D)  // buildonslopes
+	                   |         ((_patches.full_load_any ? 1 : 0) << 0x0E)  // fullloadany
 	                   |                                        (0 << 0x0F)  // planespeed
 	                   |                                        (0 << 0x10)  // moreindustriesperclimate - obsolete
 	                   |                                        (0 << 0x11)  // moretoylandfeatures
 	                   |                                        (1 << 0x12)  // newstations
 	                   |                                        (0 << 0x13)  // tracktypecostdiff
-	                   |                                        (0 << 0x14)  // manualconvert
+	                   |                                        (1 << 0x14)  // manualconvert
 	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x15)  // buildoncoasts
 	                   |                                        (1 << 0x16)  // canals
 	                   |                                        (1 << 0x17)  // newstartyear
-	                   |                                        (0 << 0x18)  // freighttrains
+	                   |    ((_patches.freight_trains > 1 ? 1 : 0) << 0x18)  // freighttrains
 	                   |                                        (1 << 0x19)  // newhouses
 	                   |                                        (1 << 0x1A)  // newbridges
 	                   |                                        (0 << 0x1B)  // newtownnames
@@ -4108,7 +4155,7 @@
 	                   |                                        (0 << 0x08)  // fifoloading
 	                   |                                        (0 << 0x09)  // townroadbranchprob
 	                   |                                        (0 << 0x0A)  // tempsnowline
-	                   |                                        (0 << 0x0B)  // newcargo
+	                   |                                        (1 << 0x0B)  // newcargo
 	                   |                                        (1 << 0x0C)  // enhancemultiplayer
 	                   |                                        (1 << 0x0D)  // onewayroads
 	                   |   ((_patches.nonuniform_stations ? 1 : 0) << 0x0E)  // irregularstations
@@ -4120,7 +4167,8 @@
 	                   |                                        (0 << 0x14)  // trams
 	                   |                                        (0 << 0x15)  // enhancetunnels
 	                   |                                        (0 << 0x16)  // shortrvs
-	                   |                                        (0 << 0x17); // articulatedrvs
+	                   |                                        (0 << 0x17)  // articulatedrvs
+	                   |                                        (1 << 0x1E); // variablerunningcosts
 }
 
 static void ResetCustomStations()
@@ -4378,9 +4426,6 @@
 static void CalculateRefitMasks()
 {
 	for (EngineID engine = 0; engine < TOTAL_NUM_ENGINES; engine++) {
-		/* Skip engine if not available in this climate */
-		if (!HASBIT(_engine_info[engine].climates, _opt.landscape)) continue;
-
 		uint32 mask = 0;
 		uint32 not_mask = 0;
 		uint32 xor_mask = 0;
@@ -4581,17 +4626,17 @@
 	byte action = buf[0];
 
 	if (action == 0xFF) {
-		grfmsg(7, "Handling data block in stage %d", stage);
+		grfmsg(7, "DecodeSpecialSprite: Handling data block in stage %d", stage);
 		GRFDataBlock(buf, num);
 	} else if (action == 0xFE) {
-		grfmsg(7, "Handling import block in stage %d", stage);
+		grfmsg(7, "DecodeSpecialSprite: andling import block in stage %d", stage);
 		GRFImportBlock(buf, num);
 	} else if (action >= lengthof(handlers)) {
-		grfmsg(7, "Skipping unknown action 0x%02X", action);
+		grfmsg(7, "DecodeSpecialSprite: Skipping unknown action 0x%02X", action);
 	} else if (handlers[action][stage] == NULL) {
-		grfmsg(7, "Skipping action 0x%02X in stage %d", action, stage);
+		grfmsg(7, "DecodeSpecialSprite: Skipping action 0x%02X in stage %d", action, stage);
 	} else {
-		grfmsg(7, "Handling action 0x%02X in stage %d", action, stage);
+		grfmsg(7, "DecodeSpecialSprite: Handling action 0x%02X in stage %d", action, stage);
 		handlers[action][stage](buf, num);
 	}
 	free(buf);
@@ -4623,7 +4668,7 @@
 
 	_cur_grfconfig = config;
 
-	DEBUG(grf, 2, "Reading NewGRF-file '%s'", filename);
+	DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename);
 
 	/* Skip the first sprite; we don't care about how many sprites this
 	 * does contain; newest TTDPatches and George's longvehicles don't
@@ -4631,7 +4676,7 @@
 	if (FioReadWord() == 4 && FioReadByte() == 0xFF) {
 		FioReadDword();
 	} else {
-		DEBUG(grf, 7, "Custom .grf has invalid format");
+		DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format");
 		return;
 	}
 
@@ -4654,7 +4699,7 @@
 				FioSkipBytes(num);
 			}
 		} else {
-			if (_skip_sprites == 0) grfmsg(7, "Skipping unexpected sprite");
+			if (_skip_sprites == 0) grfmsg(7, "LoadNewGRFFile: Skipping unexpected sprite");
 
 			FioSkipBytes(7);
 			num -= 8;
@@ -4723,7 +4768,7 @@
 			if (stage == GLS_ACTIVATION) {
 				ClearTemporaryNewGRFData();
 				BuildCargoTranslationMap();
-				DEBUG(sprite, 2, "Currently %i sprites are loaded", _cur_spriteid);
+				DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid);
 			}
 		}
 	}