Changeset - r18122:623505749ded
[Not reviewed]
master
0 3 0
rubidium - 13 years ago 2011-09-23 19:27:15
rubidium@openttd.org
(svn r22957) -Codechange: SPECSTR_PLAYERNAME is actually the company name, which is derived from the town name + ' Transport'. So make sure the last constant is in sync with the town name table
3 files changed with 7 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -328,49 +328,49 @@ CommandCost CheckTileOwnership(TileIndex
 

	
 
	/* no need to get the name of the owner unless we're the local company (saves some time) */
 
	if (IsLocalCompany()) GetNameOfOwner(owner, tile);
 
	return_cmd_error(STR_ERROR_OWNED_BY);
 
}
 

	
 
/**
 
 * Generate the name of a company from the last build coordinate.
 
 * @param c Company to give a name.
 
 */
 
static void GenerateCompanyName(Company *c)
 
{
 
	/* Reserve space for extra unicode character. We need to do this to be able
 
	 * to detect too long company name. */
 
	char buffer[(MAX_LENGTH_COMPANY_NAME_CHARS + 1) * MAX_CHAR_LENGTH];
 

	
 
	if (c->name_1 != STR_SV_UNNAMED) return;
 
	if (c->last_build_coordinate == 0) return;
 

	
 
	Town *t = ClosestTownFromTile(c->last_build_coordinate, UINT_MAX);
 

	
 
	StringID str;
 
	uint32 strp;
 
	if (t->name == NULL && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
 
		str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_PLAYERNAME_START;
 
		str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
 
		strp = t->townnameparts;
 

	
 
verify_name:;
 
		/* No companies must have this name already */
 
		Company *cc;
 
		FOR_ALL_COMPANIES(cc) {
 
			if (cc->name_1 == str && cc->name_2 == strp) goto bad_town_name;
 
		}
 

	
 
		GetString(buffer, str, lastof(buffer));
 
		if (Utf8StringLength(buffer) >= MAX_LENGTH_COMPANY_NAME_CHARS) goto bad_town_name;
 

	
 
set_name:;
 
		c->name_1 = str;
 
		c->name_2 = strp;
 

	
 
		MarkWholeScreenDirty();
 

	
 
		if (c->is_ai) {
 
			CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
 
			cni->FillData(c);
 
			SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
 
			SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
 
			SetDParamStr(2, cni->company_name);
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -8,50 +8,50 @@
 
 */
 

	
 
/** @file strings_sl.cpp Code handling saving and loading of strings */
 

	
 
#include "../stdafx.h"
 
#include "../string_func.h"
 
#include "saveload_internal.h"
 

	
 
#include "table/strings.h"
 

	
 
static const int NUM_OLD_STRINGS     = 512; ///< The number of custom strings stored in old savegames.
 
static const int LEN_OLD_STRINGS     =  32; ///< The number of characters per string.
 
static const int LEN_OLD_STRINGS_TTO =  24; ///< The number of characters per string in TTO savegames.
 

	
 
/**
 
 * Remap a string ID from the old format to the new format
 
 * @param s StringID that requires remapping
 
 * @return translated ID
 
 */
 
StringID RemapOldStringID(StringID s)
 
{
 
	switch (s) {
 
		case 0x0006: return STR_SV_EMPTY;
 
		case 0x7000: return STR_SV_UNNAMED;
 
		case 0x70E4: return SPECSTR_PLAYERNAME_ENGLISH;
 
		case 0x70E9: return SPECSTR_PLAYERNAME_ENGLISH;
 
		case 0x70E4: return SPECSTR_COMPANY_NAME_START;
 
		case 0x70E9: return SPECSTR_COMPANY_NAME_START;
 
		case 0x8864: return STR_SV_TRAIN_NAME;
 
		case 0x902B: return STR_SV_ROAD_VEHICLE_NAME;
 
		case 0x9830: return STR_SV_SHIP_NAME;
 
		case 0xA02F: return STR_SV_AIRCRAFT_NAME;
 

	
 
		default:
 
			if (IsInsideMM(s, 0x300F, 0x3030)) {
 
				return s - 0x300F + STR_SV_STNAME;
 
			} else {
 
				return s;
 
			}
 
	}
 
}
 

	
 
/** Location to load the old names to. */
 
char *_old_name_array = NULL;
 

	
 
/**
 
 * Copy and convert old custom names to UTF-8.
 
 * They were all stored in a 512 by 32 (200 by 24 for TTO) long string array
 
 * and are now stored with stations, waypoints and other places with names.
 
 * @param id the StringID of the custom name to clone.
 
 * @return the clones custom name.
 
 */
src/strings_type.h
Show inline comments
 
@@ -33,51 +33,46 @@ enum SpecialStrings {
 
	SPECSTR_TOWNNAME_START     = 0x20C0,
 
	SPECSTR_TOWNNAME_ENGLISH   = SPECSTR_TOWNNAME_START,
 
	SPECSTR_TOWNNAME_FRENCH,
 
	SPECSTR_TOWNNAME_GERMAN,
 
	SPECSTR_TOWNNAME_AMERICAN,
 
	SPECSTR_TOWNNAME_LATIN,
 
	SPECSTR_TOWNNAME_SILLY,
 
	SPECSTR_TOWNNAME_SWEDISH,
 
	SPECSTR_TOWNNAME_DUTCH,
 
	SPECSTR_TOWNNAME_FINNISH,
 
	SPECSTR_TOWNNAME_POLISH,
 
	SPECSTR_TOWNNAME_SLOVAK,
 
	SPECSTR_TOWNNAME_NORWEGIAN,
 
	SPECSTR_TOWNNAME_HUNGARIAN,
 
	SPECSTR_TOWNNAME_AUSTRIAN,
 
	SPECSTR_TOWNNAME_ROMANIAN,
 
	SPECSTR_TOWNNAME_CZECH,
 
	SPECSTR_TOWNNAME_SWISS,
 
	SPECSTR_TOWNNAME_DANISH,
 
	SPECSTR_TOWNNAME_TURKISH,
 
	SPECSTR_TOWNNAME_ITALIAN,
 
	SPECSTR_TOWNNAME_CATALAN,
 
	SPECSTR_TOWNNAME_LAST      = SPECSTR_TOWNNAME_CATALAN,
 

	
 
	/* special strings for player names on the form "TownName transport". */
 
	SPECSTR_PLAYERNAME_START   = 0x70EA,
 
	SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START,
 
	SPECSTR_PLAYERNAME_FRENCH,
 
	SPECSTR_PLAYERNAME_GERMAN,
 
	SPECSTR_PLAYERNAME_AMERICAN,
 
	SPECSTR_PLAYERNAME_LATIN,
 
	SPECSTR_PLAYERNAME_SILLY,
 
	SPECSTR_PLAYERNAME_LAST    = SPECSTR_PLAYERNAME_SILLY,
 
	/* special strings for company names on the form "TownName transport". */
 
	SPECSTR_COMPANY_NAME_START = 0x70EA,
 
	SPECSTR_COMPANY_NAME_LAST  = SPECSTR_COMPANY_NAME_START + SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START,
 

	
 
	SPECSTR_SILLY_NAME         = 0x70E5,
 
	SPECSTR_ANDCO_NAME         = 0x70E6,
 
	SPECSTR_PRESIDENT_NAME     = 0x70E7,
 

	
 
	/* reserve MAX_LANG strings for the *.lng files */
 
	SPECSTR_LANGUAGE_START     = 0x7100,
 
	SPECSTR_LANGUAGE_END       = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
 

	
 
	/* reserve 32 strings for various screen resolutions */
 
	SPECSTR_RESOLUTION_START   = SPECSTR_LANGUAGE_END + 1,
 
	SPECSTR_RESOLUTION_END     = SPECSTR_RESOLUTION_START + 0x1F,
 

	
 
	/* reserve 32 strings for screenshot formats */
 
	SPECSTR_SCREENSHOT_START   = SPECSTR_RESOLUTION_END + 1,
 
	SPECSTR_SCREENSHOT_END     = SPECSTR_SCREENSHOT_START + 0x1F,
 
};
 

	
 
#endif /* STRINGS_TYPE_H */
0 comments (0 inline, 0 general)