mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22627) -Codechange: Rename PrepareTextRefStackUsage() to StartTextRefStackUsage() to make it more obvious that you must call StopTextRefStackUsage() at some point. Also extent the documentation.
This commit is contained in:
parent
d29def43b0
commit
f93c8ce5aa
|
@ -740,7 +740,7 @@ static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
|
|||
|
||||
/* STR_BLACK_STRING is used to start the string with {BLACK} */
|
||||
SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback));
|
||||
PrepareTextRefStackUsage(0);
|
||||
StartTextRefStackUsage(0);
|
||||
uint result = DrawStringMultiLine(left, right, y, INT32_MAX, STR_BLACK_STRING);
|
||||
StopTextRefStackUsage();
|
||||
return result;
|
||||
|
|
|
@ -74,7 +74,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
|
|||
if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) {
|
||||
uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->location.tile : INVALID_TILE);
|
||||
if (GB(callback, 0, 8) != 0xFF) {
|
||||
PrepareTextRefStackUsage(6);
|
||||
StartTextRefStackUsage(6);
|
||||
GetString(suffix, GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback), suffix_last);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ public:
|
|||
if (callback_res != CALLBACK_FAILED) { // Did it fail?
|
||||
str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string
|
||||
if (str != STR_UNDEFINED) {
|
||||
PrepareTextRefStackUsage(6);
|
||||
StartTextRefStackUsage(6);
|
||||
DrawStringMultiLine(left, right, y, bottom, str);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ public:
|
|||
if (message != STR_NULL && message != STR_UNDEFINED) {
|
||||
y += WD_PAR_VSEP_WIDE;
|
||||
|
||||
PrepareTextRefStackUsage(6);
|
||||
StartTextRefStackUsage(6);
|
||||
/* Use all the available space left from where we stand up to the
|
||||
* end of the window. We ALSO enlarge the window if needed, so we
|
||||
* can 'go' wild with the bottom of the window. */
|
||||
|
|
|
@ -551,7 +551,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
|
|||
|
||||
/* Copy some parameters from the registers to the error message text ref. stack */
|
||||
SwitchToErrorRefStack();
|
||||
PrepareTextRefStackUsage(4);
|
||||
StartTextRefStackUsage(4);
|
||||
SwitchToNormalRefStack();
|
||||
|
||||
switch (result) {
|
||||
|
|
|
@ -310,7 +310,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
|
|||
|
||||
/* Copy some parameters from the registers to the error message text ref. stack */
|
||||
SwitchToErrorRefStack();
|
||||
PrepareTextRefStackUsage(4);
|
||||
StartTextRefStackUsage(4);
|
||||
SwitchToNormalRefStack();
|
||||
|
||||
switch (callback_res) {
|
||||
|
|
|
@ -955,10 +955,22 @@ void RestoreTextRefStackBackup(struct TextRefStack *backup)
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepare the TTDP compatible string code parsing
|
||||
* Start using the TTDP compatible string code parsing.
|
||||
*
|
||||
* On start a number of values is copied on the #TextRefStack.
|
||||
* You can then use #GetString() and the normal string drawing functions,
|
||||
* and they will use the #TextRefStack for NewGRF string codes.
|
||||
*
|
||||
* However, when you want to draw a string multiple times using the same stack,
|
||||
* you have to call #RewindTextRefStack() between draws.
|
||||
*
|
||||
* After you are done with drawing, you must disable usage of the #TextRefStack
|
||||
* by calling #StopTextRefStackUsage(), so NewGRF string codes operate on the
|
||||
* normal string parameters again.
|
||||
*
|
||||
* @param numEntries number of entries to copy from the registers
|
||||
*/
|
||||
void PrepareTextRefStackUsage(byte numEntries)
|
||||
void StartTextRefStackUsage(byte numEntries)
|
||||
{
|
||||
extern TemporaryStorageArray<int32, 0x110> _temp_store;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void CleanUpGRFText(struct GRFText *grftext);
|
|||
|
||||
bool CheckGrfLangID(byte lang_id, byte grf_version);
|
||||
|
||||
void PrepareTextRefStackUsage(byte numEntries);
|
||||
void StartTextRefStackUsage(byte numEntries);
|
||||
void StopTextRefStackUsage();
|
||||
void SwitchToNormalRefStack();
|
||||
void SwitchToErrorRefStack();
|
||||
|
|
|
@ -236,7 +236,7 @@ public:
|
|||
if (callback_res != CALLBACK_FAILED) {
|
||||
StringID message = GetGRFStringID(spec->grf_prop.grffile->grfid, 0xD000 + callback_res);
|
||||
if (message != STR_NULL && message != STR_UNDEFINED) {
|
||||
PrepareTextRefStackUsage(6);
|
||||
StartTextRefStackUsage(6);
|
||||
/* Use all the available space left from where we stand up to the
|
||||
* end of the window. We ALSO enlarge the window if needed, so we
|
||||
* can 'go' wild with the bottom of the window. */
|
||||
|
|
Loading…
Reference in New Issue