changeset 6515:a2425eabe13e draft

(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
author peter1138 <peter1138@openttd.org>
date Fri, 20 Apr 2007 21:19:28 +0000
parents f2786f7b2c3b
children f8eb4662e1e5
files src/newgrf.cpp
diffstat 1 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -3434,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)
 {
@@ -3488,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) {