Changeset - r17826:e881883992f4
[Not reviewed]
master
0 7 0
frosch - 13 years ago 2011-07-03 13:49:29
frosch@openttd.org
(svn r22627) -Codechange: Rename PrepareTextRefStackUsage() to StartTextRefStackUsage() to make it more obvious that you must call StopTextRefStackUsage() at some point. Also extent the documentation.
7 files changed with 22 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -740,7 +740,7 @@ static uint ShowAdditionalText(int left,
 

	
 
	/* 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;
src/industry_gui.cpp
Show inline comments
 
@@ -74,7 +74,7 @@ static void GetCargoSuffix(uint cargo, C
 
	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. */
src/newgrf_industries.cpp
Show inline comments
 
@@ -551,7 +551,7 @@ CommandCost CheckIfCallBackAllowsCreatio
 

	
 
	/* Copy some parameters from the registers to the error message text ref. stack */
 
	SwitchToErrorRefStack();
 
	PrepareTextRefStackUsage(4);
 
	StartTextRefStackUsage(4);
 
	SwitchToNormalRefStack();
 

	
 
	switch (result) {
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -310,7 +310,7 @@ CommandCost PerformIndustryTileSlopeChec
 

	
 
	/* Copy some parameters from the registers to the error message text ref. stack */
 
	SwitchToErrorRefStack();
 
	PrepareTextRefStackUsage(4);
 
	StartTextRefStackUsage(4);
 
	SwitchToNormalRefStack();
 

	
 
	switch (callback_res) {
src/newgrf_text.cpp
Show inline comments
 
@@ -955,10 +955,22 @@ void RestoreTextRefStackBackup(struct Te
 
}
 

	
 
/**
 
 * 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;
 

	
src/newgrf_text.h
Show inline comments
 
@@ -34,7 +34,7 @@ void CleanUpGRFText(struct GRFText *grft
 

	
 
bool CheckGrfLangID(byte lang_id, byte grf_version);
 

	
 
void PrepareTextRefStackUsage(byte numEntries);
 
void StartTextRefStackUsage(byte numEntries);
 
void StopTextRefStackUsage();
 
void SwitchToNormalRefStack();
 
void SwitchToErrorRefStack();
src/object_gui.cpp
Show inline comments
 
@@ -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. */
0 comments (0 inline, 0 general)