src/newgrf_text.cpp
branchNewGRF_ports
changeset 6877 889301acc299
parent 6872 1c4a4a609f85
child 6878 7d1ff2f621c7
equal deleted inserted replaced
6876:2c40faeef7a5 6877:889301acc299
   291 			case 0xB4: d += Utf8Encode(d, SCC_TRAIN); break;
   291 			case 0xB4: d += Utf8Encode(d, SCC_TRAIN); break;
   292 			case 0xB5: d += Utf8Encode(d, SCC_LORRY); break;
   292 			case 0xB5: d += Utf8Encode(d, SCC_LORRY); break;
   293 			case 0xB6: d += Utf8Encode(d, SCC_BUS); break;
   293 			case 0xB6: d += Utf8Encode(d, SCC_BUS); break;
   294 			case 0xB7: d += Utf8Encode(d, SCC_PLANE); break;
   294 			case 0xB7: d += Utf8Encode(d, SCC_PLANE); break;
   295 			case 0xB8: d += Utf8Encode(d, SCC_SHIP); break;
   295 			case 0xB8: d += Utf8Encode(d, SCC_SHIP); break;
       
   296 			case 0xB9: d += Utf8Encode(d, SCC_SUPERSCRIPT_M1); break;
       
   297 			case 0xBC: d += Utf8Encode(d, SCC_SMALLUPARROW); break;
       
   298 			case 0xBD: d += Utf8Encode(d, SCC_SMALLDOWNARROW); break;
   296 			default:
   299 			default:
   297 				/* Validate any unhandled character */
   300 				/* Validate any unhandled character */
   298 				if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?';
   301 				if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?';
   299 				d += Utf8Encode(d, c);
   302 				d += Utf8Encode(d, c);
   300 				break;
   303 				break;
   400 
   403 
   401 	return STR_UNDEFINED;
   404 	return STR_UNDEFINED;
   402 }
   405 }
   403 
   406 
   404 
   407 
   405 char *GetGRFString(char *buff, uint16 stringid, const char* last)
   408 const char *GetGRFStringPtr(uint16 stringid)
   406 {
   409 {
   407 	const GRFText *default_text = NULL;
   410 	const GRFText *default_text = NULL;
   408 	const GRFText *search_text;
   411 	const GRFText *search_text;
   409 
   412 
   410 	assert(_grf_text[stringid].grfid != 0);
   413 	assert(_grf_text[stringid].grfid != 0);
   413 	_last_grfid = _grf_text[stringid].grfid;
   416 	_last_grfid = _grf_text[stringid].grfid;
   414 
   417 
   415 	/*Search the list of lang-strings of this stringid for current lang */
   418 	/*Search the list of lang-strings of this stringid for current lang */
   416 	for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) {
   419 	for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) {
   417 		if (search_text->langid == _currentLangID) {
   420 		if (search_text->langid == _currentLangID) {
   418 			return strecpy(buff, search_text->text, last);
   421 			return search_text->text;
   419 		}
   422 		}
   420 
   423 
   421 		/* If the current string is English or American, set it as the
   424 		/* If the current string is English or American, set it as the
   422 		 * fallback language if the specific language isn't available. */
   425 		 * fallback language if the specific language isn't available. */
   423 		if (search_text->langid == GRFLX_UNSPECIFIED || (default_text == NULL && (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN))) {
   426 		if (search_text->langid == GRFLX_UNSPECIFIED || (default_text == NULL && (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN))) {
   424 			default_text = search_text;
   427 			default_text = search_text;
   425 		}
   428 		}
   426 	}
   429 	}
   427 
   430 
   428 	/* If there is a fallback string, return that */
   431 	/* If there is a fallback string, return that */
   429 	if (default_text != NULL) return strecpy(buff, default_text->text, last);
   432 	if (default_text != NULL) return default_text->text;
   430 
   433 
   431 	/* Use the default string ID if the fallback string isn't available */
   434 	/* Use the default string ID if the fallback string isn't available */
   432 	return GetString(buff, _grf_text[stringid].def_string, last);
   435 	return GetStringPtr(_grf_text[stringid].def_string);
   433 }
   436 }
   434 
   437 
   435 /**
   438 /**
   436  * Equivalence Setter function between game and newgrf langID.
   439  * Equivalence Setter function between game and newgrf langID.
   437  * This function will adjust _currentLangID as to what is the LangID
   440  * This function will adjust _currentLangID as to what is the LangID