From a4b3066433f2128e27d85d8df54f28a727287c21 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 20 Apr 2007 21:19:28 +0000 Subject: (svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables --- src/newgrf.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/newgrf.cpp') diff --git a/src/newgrf.cpp b/src/newgrf.cpp index e1ff6c3a1..4920ca3d6 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3434,6 +3434,28 @@ static void SafeParamSet(byte *buf, int len) _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 @@ static void ParamSet(byte *buf, int len) 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) { -- cgit v1.2.3-54-g00ecf