Changeset - r21158:ca0e73acc573
[Not reviewed]
master
0 2 0
frosch - 10 years ago 2014-01-12 18:01:33
frosch@openttd.org
(svn r26244) -Feature: [NewGRF] Add StringCodes 9A 1B, 9A 1C and 9A 1D to display amounts of cargo.
2 files changed with 35 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -22,6 +22,7 @@
 
#include "strings_func.h"
 
#include "newgrf_storage.h"
 
#include "newgrf_text.h"
 
#include "newgrf_cargo.h"
 
#include "string_func.h"
 
#include "date_type.h"
 
#include "debug.h"
 
@@ -520,7 +521,12 @@ char *TranslateTTDPatchCodes(uint32 grfi
 
					case 0x17:
 
					case 0x18:
 
					case 0x19:
 
					case 0x1A: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16); break;
 
					case 0x1A:
 
					case 0x1B:
 
					case 0x1C:
 
					case 0x1D:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16);
 
						break;
 

	
 
					default:
 
						grfmsg(1, "missing handler for extended format code");
 
@@ -993,6 +999,15 @@ uint RemapNewGRFStringControlCode(uint s
 
				return 0;
 
			}
 
			break;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_LONG:
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
 
			if (argv_size < 2) {
 
				DEBUG(misc, 0, "Too many NewGRF string parameters.");
 
				return 0;
 
			}
 
			break;
 
	}
 

	
 
	if (_newgrf_textrefstack.used && modify_argv) {
 
@@ -1032,6 +1047,13 @@ uint RemapNewGRFStringControlCode(uint s
 
			case SCC_NEWGRF_PUSH_WORD:              _newgrf_textrefstack.PushWord(Utf8Consume(str)); break;
 
			case SCC_NEWGRF_UNPRINT:                *buff = max(*buff - Utf8Consume(str), buf_start); break;
 

	
 
			case SCC_NEWGRF_PRINT_WORD_CARGO_LONG:
 
			case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
 
			case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
 
				argv[0] = GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile);
 
				argv[1] = _newgrf_textrefstack.PopUnsignedWord();
 
				break;
 

	
 
			case SCC_NEWGRF_PRINT_WORD_STRING_ID:
 
				*argv = MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord());
 
				break;
 
@@ -1085,6 +1107,15 @@ uint RemapNewGRFStringControlCode(uint s
 
		case SCC_NEWGRF_PRINT_WORD_POWER:
 
			return SCC_POWER;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_LONG:
 
			return SCC_CARGO_LONG;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
 
			return SCC_CARGO_SHORT;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
 
			return SCC_CARGO_TINY;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
 
			return SCC_STATION_NAME;
 

	
src/table/control_codes.h
Show inline comments
 
@@ -140,6 +140,9 @@ enum StringControlCode {
 
	SCC_NEWGRF_PRINT_WORD_POWER,                      ///< Read 2 bytes from the stack as unsigned power
 
	SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT,               ///< Read 2 bytes from the stack as short signed volume
 
	SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT,               ///< Read 2 bytes from the stack as short unsigned weight
 
	SCC_NEWGRF_PRINT_WORD_CARGO_LONG,                 ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PRINT_WORD_CARGO_SHORT,                ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PRINT_WORD_CARGO_TINY,                 ///< Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PUSH_WORD,                             ///< Pushes 2 bytes onto the stack
 
	SCC_NEWGRF_UNPRINT,                               ///< "Unprints" the given number of bytes from the string
 
	SCC_NEWGRF_DISCARD_WORD,                          ///< Discard the next two bytes
0 comments (0 inline, 0 general)