Changeset - r22499:52b2a22ff6c1
[Not reviewed]
master
0 2 0
frosch - 8 years ago 2016-12-23 13:38:50
frosch@openttd.org
(svn r27706) -Feature: [NewGRF] String command 9A 1E to print the name of a cargo type.
2 files changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -524,12 +524,13 @@ char *TranslateTTDPatchCodes(uint32 grfi
 
					case 0x18:
 
					case 0x19:
 
					case 0x1A:
 
					case 0x1B:
 
					case 0x1C:
 
					case 0x1D:
 
					case 0x1E:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16);
 
						break;
 

	
 
					default:
 
						grfmsg(1, "missing handler for extended format code");
 
						break;
 
@@ -993,12 +994,13 @@ uint RemapNewGRFStringControlCode(uint s
 
		case SCC_NEWGRF_PRINT_WORD_VOLUME_LONG:
 
		case SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT:
 
		case SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG:
 
		case SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT:
 
		case SCC_NEWGRF_PRINT_WORD_POWER:
 
		case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
 
		case SCC_NEWGRF_PRINT_WORD_CARGO_NAME:
 
			if (argv_size < 1) {
 
				DEBUG(misc, 0, "Too many NewGRF string parameters.");
 
				return 0;
 
			}
 
			break;
 

	
 
@@ -1056,12 +1058,16 @@ uint RemapNewGRFStringControlCode(uint s
 
				argv[1] = _newgrf_textrefstack.PopUnsignedWord();
 
				break;
 

	
 
			case SCC_NEWGRF_PRINT_WORD_STRING_ID:
 
				*argv = MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord());
 
				break;
 

	
 
			case SCC_NEWGRF_PRINT_WORD_CARGO_NAME:
 
				*argv = 1 << GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile);
 
				break;
 
		}
 
	} else {
 
		/* Consume additional parameter characters */
 
		switch (scc) {
 
			default: break;
 

	
 
@@ -1125,12 +1131,15 @@ uint RemapNewGRFStringControlCode(uint s
 
		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_CARGO_NAME:
 
			return SCC_CARGO_LIST;
 

	
 
		case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
 
			return SCC_STATION_NAME;
 

	
 
		case SCC_NEWGRF_DISCARD_WORD:
 
		case SCC_NEWGRF_ROTATE_TOP_4_WORDS:
 
		case SCC_NEWGRF_PUSH_WORD:
src/table/control_codes.h
Show inline comments
 
@@ -140,12 +140,13 @@ enum StringControlCode {
 
	SCC_NEWGRF_PRINT_WORD_POWER,                      ///< 9A 18: Read 2 bytes from the stack as unsigned power
 
	SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT,               ///< 9A 19: Read 2 bytes from the stack as short signed volume
 
	SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT,               ///< 9A 1A: Read 2 bytes from the stack as short unsigned weight
 
	SCC_NEWGRF_PRINT_WORD_CARGO_LONG,                 ///< 9A 1B: Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PRINT_WORD_CARGO_SHORT,                ///< 9A 1C: Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PRINT_WORD_CARGO_TINY,                 ///< 9A 1D: Read 2 + 2 bytes from the stack as cargo type (translated) and unsigned cargo amount
 
	SCC_NEWGRF_PRINT_WORD_CARGO_NAME,                 ///< 9A 1E: Read 2 bytes from the stack as cargo name
 
	SCC_NEWGRF_PUSH_WORD,                             ///< 9A 03: Pushes 2 bytes onto the stack
 
	SCC_NEWGRF_UNPRINT,                               ///< 9A 04: "Unprints" the given number of bytes from the string
 
	SCC_NEWGRF_DISCARD_WORD,                          ///< 85: Discard the next two bytes
 
	SCC_NEWGRF_ROTATE_TOP_4_WORDS,                    ///< 86: Rotate the top 4 words of the stack (W4 W1 W2 W3)
 
	SCC_NEWGRF_LAST = SCC_NEWGRF_ROTATE_TOP_4_WORDS,
 

	
0 comments (0 inline, 0 general)