File diff r11916:e3a8d08bf479 → r11917:612c11f7ab47
src/strings.cpp
Show inline comments
 
@@ -656,25 +656,25 @@ static char *FormatString(char *buff, co
 
				uint str = modifier + GetInt32(&argv);
 
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 5), last);
 
				modifier = 0;
 
				break;
 
			}
 

	
 
			case SCC_STATION_FEATURES: { // {STATIONFEATURES}
 
				buff = StationGetSpecialString(buff, GetInt32(&argv), last);
 
				break;
 
			}
 

	
 
			case SCC_INDUSTRY_NAME: { // {INDUSTRY}
 
				const Industry *i = GetIndustry(GetInt32(&argv));
 
				const Industry *i = Industry::Get(GetInt32(&argv));
 
				int64 args[2];
 

	
 
				/* industry not valid anymore? */
 
				if (!i->IsValid()) break;
 

	
 
				/* First print the town name and the industry type name. */
 
				args[0] = i->town->index;
 
				args[1] = GetIndustrySpec(i->type)->name;
 
				buff = FormatString(buff, GetStringPtr(STR_INDUSTRY_FORMAT), args, modifier >> 24, last);
 
				modifier = 0;
 
				break;
 
			}
 
@@ -818,25 +818,25 @@ static char *FormatString(char *buff, co
 
				buff = FormatHexNumber(buff, GetInt64(&argv), last);
 
				break;
 

	
 
			case SCC_BYTES: // {BYTES}
 
				buff = FormatBytes(buff, GetInt64(&argv), last);
 
				break;
 

	
 
			case SCC_CURRENCY: // {CURRENCY}
 
				buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), false, last);
 
				break;
 

	
 
			case SCC_WAYPOINT_NAME: { // {WAYPOINT}
 
				Waypoint *wp = GetWaypoint(GetInt32(&argv));
 
				Waypoint *wp = Waypoint::Get(GetInt32(&argv));
 

	
 
				assert(wp->IsValid());
 

	
 
				if (wp->name != NULL) {
 
					buff = strecpy(buff, wp->name, last);
 
				} else {
 
					int64 temp[2];
 
					temp[0] = wp->town_index;
 
					temp[1] = wp->town_cn + 1;
 
					StringID str = wp->town_cn == 0 ? STR_WAYPOINTNAME_CITY : STR_WAYPOINTNAME_CITY_SERIAL;
 

	
 
					buff = GetStringWithArgs(buff, str, temp, last);
 
@@ -846,25 +846,25 @@ static char *FormatString(char *buff, co
 

	
 
			case SCC_STATION_NAME: { // {STATION}
 
				StationID sid = GetInt32(&argv);
 

	
 
				if (!IsValidStationID(sid)) {
 
					/* The station doesn't exist anymore. The only place where we might
 
					 * be "drawing" an invalid station is in the case of cargo that is
 
					 * in transit. */
 
					buff = GetStringWithArgs(buff, STR_UNKNOWN_STATION, NULL, last);
 
					break;
 
				}
 

	
 
				const Station *st = GetStation(sid);
 
				const Station *st = Station::Get(sid);
 
				if (st->name != NULL) {
 
					buff = strecpy(buff, st->name, last);
 
				} else {
 
					StringID str = st->string_id;
 
					if (st->indtype != IT_INVALID) {
 
						/* Special case where the industry provides the name for the station */
 
						const IndustrySpec *indsp = GetIndustrySpec(st->indtype);
 

	
 
						/* Industry GRFs can change which might remove the station name and
 
						 * thus cause very strange things. Here we check for that before we
 
						 * actually set the station name. */
 
						if (indsp->station_name != STR_NULL && indsp->station_name != STR_UNDEFINED) {
 
@@ -873,25 +873,25 @@ static char *FormatString(char *buff, co
 
					}
 

	
 
					int64 temp[3];
 
					temp[0] = STR_TOWN;
 
					temp[1] = st->town->index;
 
					temp[2] = st->index;
 
					buff = GetStringWithArgs(buff, str, temp, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_TOWN_NAME: { // {TOWN}
 
				const Town *t = GetTown(GetInt32(&argv));
 
				const Town *t = Town::Get(GetInt32(&argv));
 
				int64 temp[1];
 

	
 
				assert(t->IsValid());
 

	
 
				temp[0] = t->townnameparts;
 
				uint32 grfid = t->townnamegrfid;
 

	
 
				if (t->name != NULL) {
 
					buff = strecpy(buff, t->name, last);
 
				} else if (grfid == 0) {
 
					/* Original town name */
 
					buff = GetStringWithArgs(buff, t->townnametype, temp, last);
 
@@ -900,111 +900,111 @@ static char *FormatString(char *buff, co
 
					if (GetGRFTownName(grfid) != NULL) {
 
						/* The grf is loaded */
 
						buff = GRFTownNameGenerate(buff, t->townnamegrfid, t->townnametype, t->townnameparts, last);
 
					} else {
 
						/* Fallback to english original */
 
						buff = GetStringWithArgs(buff, SPECSTR_TOWNNAME_ENGLISH, temp, last);
 
					}
 
				}
 
				break;
 
			}
 

	
 
			case SCC_GROUP_NAME: { // {GROUP}
 
				const Group *g = GetGroup(GetInt32(&argv));
 
				const Group *g = Group::Get(GetInt32(&argv));
 

	
 
				assert(g->IsValid());
 

	
 
				if (g->name != NULL) {
 
					buff = strecpy(buff, g->name, last);
 
				} else {
 
					int64 args[1];
 

	
 
					args[0] = g->index;
 
					buff = GetStringWithArgs(buff, STR_GROUP_NAME_FORMAT, args, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_ENGINE_NAME: { // {ENGINE}
 
				EngineID engine = (EngineID)GetInt32(&argv);
 
				const Engine *e = GetEngine(engine);
 
				const Engine *e = Engine::Get(engine);
 

	
 
				if (e->name != NULL) {
 
					buff = strecpy(buff, e->name, last);
 
				} else {
 
					buff = GetStringWithArgs(buff, e->info.string_id, NULL, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_VEHICLE_NAME: { // {VEHICLE}
 
				const Vehicle *v = GetVehicle(GetInt32(&argv));
 
				const Vehicle *v = Vehicle::Get(GetInt32(&argv));
 

	
 
				if (v->name != NULL) {
 
					buff = strecpy(buff, v->name, last);
 
				} else {
 
					int64 args[1];
 
					args[0] = v->unitnumber;
 

	
 
					StringID str;
 
					switch (v->type) {
 
						default: NOT_REACHED();
 
						case VEH_TRAIN:    str = STR_SV_TRAIN_NAME; break;
 
						case VEH_ROAD:     str = STR_SV_ROADVEH_NAME; break;
 
						case VEH_SHIP:     str = STR_SV_SHIP_NAME; break;
 
						case VEH_AIRCRAFT: str = STR_SV_AIRCRAFT_NAME; break;
 
					}
 

	
 
					buff = GetStringWithArgs(buff, str, args, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_SIGN_NAME: { // {SIGN}
 
				const Sign *si = GetSign(GetInt32(&argv));
 
				const Sign *si = Sign::Get(GetInt32(&argv));
 
				if (si->name != NULL) {
 
					buff = strecpy(buff, si->name, last);
 
				} else {
 
					buff = GetStringWithArgs(buff, STR_SIGN_DEFAULT, NULL, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_COMPANY_NAME: { // {COMPANY}
 
				const Company *c = GetCompany((CompanyID)GetInt32(&argv));
 
				const Company *c = Company::Get((CompanyID)GetInt32(&argv));
 

	
 
				if (c->name != NULL) {
 
					buff = strecpy(buff, c->name, last);
 
				} else {
 
					int64 args[1];
 
					args[0] = c->name_2;
 
					buff = GetStringWithArgs(buff, c->name_1, args, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_COMPANY_NUM: { // {COMPANYNUM}
 
				CompanyID company = (CompanyID)GetInt32(&argv);
 

	
 
				/* Nothing is added for AI or inactive companies */
 
				if (IsValidCompanyID(company) && IsHumanCompany(company)) {
 
					int64 args[1];
 
					args[0] = company + 1;
 
					buff = GetStringWithArgs(buff, STR_COMPANY_NUM, args, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_PRESIDENT_NAME: { // {PRESIDENTNAME}
 
				const Company *c = GetCompany((CompanyID)GetInt32(&argv));
 
				const Company *c = Company::Get((CompanyID)GetInt32(&argv));
 

	
 
				if (c->president_name != NULL) {
 
					buff = strecpy(buff, c->president_name, last);
 
				} else {
 
					int64 args[1];
 
					args[0] = c->president_name_2;
 
					buff = GetStringWithArgs(buff, c->president_name_1, args, last);
 
				}
 
				break;
 
			}
 

	
 
			case SCC_SETCASE: { // {SETCASE}