Changeset - r7755:f4e3b487aca8
[Not reviewed]
master
0 3 0
glx - 17 years ago 2007-10-18 20:35:59
glx@openttd.org
(svn r11293) -Fix: newgrf defined industry news messages use TTD format for args, which is not the same as our. So we must detect those strings and pass them the right params
3 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1618,13 +1618,18 @@ CommandCost CmdBuildIndustry(TileIndex t
 
			if (Random() <= indspec->prospecting_chance) {
 
				for (int i = 0; i < 5000; i++) {
 
					uint tilespec_index = RandomRange(indspec->num_table);
 
					const Industry *ind = CreateNewIndustryHelper(RandomTile(), p1, flags, indspec, tilespec_index);
 
					if (ind != NULL) {
 
						SetDParam(0, indspec->name);
 
						if (indspec->new_industry_text > STR_LAST_STRINGID) {
 
							SetDParam(1, STR_TOWN);
 
							SetDParam(2, ind->town->index);
 
						} else {
 
						SetDParam(1, ind->town->index);
 
						}
 
						AddNewsItem(indspec->new_industry_text,
 
								NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
 
						break;
 
					}
 
				}
 
			}
 
@@ -1826,13 +1831,18 @@ static void MaybeNewIndustry(void)
 
		ind = CreateNewIndustry(RandomTile(), cumulative_probs[j].ind);
 
		if (ind != NULL) break;
 
		if (--num == 0) return;
 
	}
 

	
 
	SetDParam(0, ind_spc->name);
 
	if (ind_spc->new_industry_text > STR_LAST_STRINGID) {
 
		SetDParam(1, STR_TOWN);
 
		SetDParam(2, ind->town->index);
 
	} else {
 
	SetDParam(1, ind->town->index);
 
	}
 
	AddNewsItem(ind_spc->new_industry_text,
 
		NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
 
}
 

	
 
/**
 
 * Protects an industry from closure if the appropriate flags and conditions are met
 
@@ -1981,13 +1991,19 @@ static void ChangeIndustryProduction(Ind
 
	if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
 
		i->prod_level = 0;
 
		str = indspec->closure_text;
 
	}
 

	
 
	if (!suppress_message && str != STR_NULL) {
 
		if (str > STR_LAST_STRINGID) {
 
			SetDParam(0, STR_TOWN);
 
			SetDParam(1, i->town->index);
 
			SetDParam(2, indspec->name);
 
		} else {
 
		SetDParam(0, i->index);
 
		}
 
		AddNewsItem(str,
 
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, closeit ? NT_OPENCLOSE : NT_ECONOMY, 0),
 
			i->xy + TileDiffXY(1, 1), 0);
 
	}
 
}
 

	
src/newgrf_text.cpp
Show inline comments
 
@@ -633,13 +633,13 @@ uint RemapNewGRFStringControlCode(uint s
 

	
 
		case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
 
		case SCC_NEWGRF_PRINT_QWORD_CURRENCY:
 
			return SCC_CURRENCY;
 

	
 
		case SCC_NEWGRF_PRINT_STRING_ID:
 
			return SCC_STRING;
 
			return SCC_STRING1;
 

	
 
		case SCC_NEWGRF_PRINT_DATE:
 
			return SCC_DATE_LONG;
 

	
 
		case SCC_NEWGRF_PRINT_MONTH_YEAR:
 
			return SCC_DATE_TINY;
src/strgen/strgen.cpp
Show inline comments
 
@@ -1011,31 +1011,30 @@ bool CompareFiles(const char *n1, const 
 

	
 
static void WriteStringsH(const char *filename)
 
{
 
	FILE *out;
 
	int i;
 
	int next = -1;
 
	int lastgrp;
 

	
 
	out = fopen("tmp.xxx", "w");
 
	if (out == NULL) fatal("can't open tmp.xxx");
 

	
 
	fprintf(out, "/* This file is automatically generated. Do not modify */\n\n");
 
	fprintf(out, "#ifndef TABLE_STRINGS_H\n");
 
	fprintf(out, "#define TABLE_STRINGS_H\n");
 

	
 
	lastgrp = 0;
 

	
 
	for (i = 0; i != lengthof(_strings); i++) {
 
		if (_strings[i] != NULL) {
 
			if (next != i) fprintf(out, "\n");
 
			fprintf(out, "static const StringID %s = 0x%X;\n", _strings[i]->name, i);
 
			next = i + 1;
 
		}
 
	}
 

	
 
	fprintf(out, "\nstatic const StringID STR_LAST_STRINGID = 0x%X;\n", next - 1);
 

	
 
	fprintf(out,
 
		"\nenum {\n"
 
		"\tLANGUAGE_PACK_IDENT = 0x474E414C, // Big Endian value for 'LANG' (LE is 0x 4C 41 4E 47)\n"
 
		"\tLANGUAGE_PACK_VERSION = 0x%X,\n"
 
		"};\n", (uint)_hash
 
	);
0 comments (0 inline, 0 general)