From 6b07218eb24e91865eee277758112e5bb4fecd97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 18:22:10 +0200 Subject: WINTERMUTE: Remove statics and silence spam in debug console. --- engines/wintermute/base/base_parser.cpp | 21 +++++++++++---------- engines/wintermute/base/base_parser.h | 8 ++++---- engines/wintermute/base/font/base_font_truetype.cpp | 7 +------ .../base/gfx/osystem/base_render_osystem.cpp | 21 ++++++++------------- .../base/gfx/osystem/base_render_osystem.h | 2 +- 5 files changed, 25 insertions(+), 34 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 5d5a2d534d..1b39b55768 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -64,7 +64,7 @@ char *BaseParser::getLastOffender() { ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -119,7 +119,7 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } @@ -205,12 +205,10 @@ char *BaseParser::getAssignmentText(char **buf) { return result; } - -////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *BaseParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; +Common::String BaseParser::getToken(char **buf) { + char token[100]; // TODO: Remove static + char *b = *buf, *t = token; while (true) { while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { b++; @@ -265,7 +263,8 @@ char *BaseParser::getToken(char **buf) { ////////////////////////////////////////////////////////////////////// float BaseParser::getTokenFloat(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. return 0.; @@ -277,7 +276,8 @@ float BaseParser::getTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// int BaseParser::getTokenInt(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. return 0; @@ -289,7 +289,8 @@ int BaseParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (strcmp(t, tok)) { return; // Error } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 3b1979efa1..34266bd5bd 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -40,7 +40,7 @@ TOKEN_TOTAL_COUNT \ }; #define TOKEN_TABLE_START(name) \ - static BaseParser::TokenDesc name [] = \ + static const BaseParser::TokenDesc name [] = \ { #define TOKEN_TABLE(name) \ { TOKEN_ ## name, #name }, @@ -65,7 +65,7 @@ public: public: int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); + int32 getCommand(char **buf, const TokenDesc *tokens, char **params); BaseParser(); virtual ~BaseParser(); private: @@ -73,11 +73,11 @@ private: void skipToken(char **buf, char *tok, char *msg = NULL); int getTokenInt(char **buf); float getTokenFloat(char **buf); - char *getToken(char **buf); + Common::String getToken(char **buf); char *getAssignmentText(char **buf); char *getSubText(char **buf, char open, char close); void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data); int _parserLine; char _lastOffender[255]; char *_whiteSpace; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index a141c68db7..b80bbdc41d 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -568,12 +568,7 @@ bool BaseFontTT::initFont() { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } + if (maxWidth >= 0) { Common::Array lines; _font->wordWrapText(text, maxWidth, lines); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index f407a871b0..fa0663dc65 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -105,7 +105,6 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { setAlphaMod(255); setColorMod(255, 255, 255); _dirtyRect = NULL; - _disableDirtyRects = true; } ////////////////////////////////////////////////////////////////////////// @@ -232,12 +231,10 @@ void BaseRenderOSystem::fade(uint16 alpha) { void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - } - hasWarned = true; + + // TODO: Add fading with dirty rects. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); } Common::Rect fillRect; @@ -461,13 +458,11 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); - } - hasWarned = true; + + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); } + byte r = RGBCOLGetR(color); byte g = RGBCOLGetG(color); byte b = RGBCOLGetB(color); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index dfffc68c17..2b6b5943c2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -115,7 +115,7 @@ private: int _borderRight; int _borderBottom; - bool _disableDirtyRects; + static const bool _disableDirtyRects = true; float _ratioX; float _ratioY; uint32 _colorMod; -- cgit v1.2.3