Changeset - r16961:63f09ebd622a
[Not reviewed]
master
0 3 0
rubidium - 13 years ago 2011-01-03 20:54:20
rubidium@openttd.org
(svn r21707) -Fix [FS#4371]: bit too strict assertion on validness of console colours
3 files changed with 23 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/console_func.h
Show inline comments
 
@@ -32,4 +32,6 @@ void IConsoleError(const char *string);
 
/* Parser */
 
void IConsoleCmdExec(const char *cmdstr);
 

	
 
bool IsValidConsoleColour(TextColour c);
 

	
 
#endif /* CONSOLE_FUNC_H */
src/console_gui.cpp
Show inline comments
 
@@ -494,3 +494,24 @@ void IConsoleGUIPrint(TextColour colour_
 
	new IConsoleLine(str, colour_code);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}
 

	
 

	
 
/**
 
 * Check whether the given TextColour is valid for console usage.
 
 * @param c The text colour to compare to.
 
 * @return true iff the TextColour is valid for console usage.
 
 */
 
bool IsValidConsoleColour(TextColour c)
 
{
 
	/* A normal text colour is used. */
 
	if (!(c & TC_IS_PALETTE_COLOUR)) return TC_BEGIN <= c && c < TC_END;
 

	
 
	/* A text colour from the palette is used; must be the company
 
	 * colour gradient, so it must be one of those. */
 
	c &= ~TC_IS_PALETTE_COLOUR;
 
	for (uint i = TC_BEGIN; i < TC_END; i++) {
 
		if (_colour_gradient[i][4] == c) return true;
 
	}
 

	
 
	return false;
 
}
src/console_type.h
Show inline comments
 
@@ -30,10 +30,4 @@ static const TextColour CC_DEBUG   = TC_
 
static const TextColour CC_COMMAND = TC_GOLD;        ///< Colour for the console's commands.
 
static const TextColour CC_WHITE   = TC_WHITE;       ///< White console lines for various things such as the welcome.
 

	
 
static inline bool IsValidConsoleColour(uint c)
 
{
 
	return c == CC_DEFAULT || c == CC_ERROR || c == CC_WARNING || c == CC_INFO ||
 
			c == CC_DEBUG || c == CC_COMMAND || c == CC_WHITE;
 
}
 

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