From 5b731a1f44b44563937e2afc5604b4e98e37860d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Mar 2018 07:54:28 -0500 Subject: XEEN: Fix use of globally constructed object --- engines/xeen/font.cpp | 7 ++++--- engines/xeen/font.h | 4 +++- engines/xeen/window.cpp | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/xeen/font.cpp b/engines/xeen/font.cpp index 3a70c4c8be..ccdcbf4627 100644 --- a/engines/xeen/font.cpp +++ b/engines/xeen/font.cpp @@ -27,18 +27,19 @@ namespace Xeen { const byte *FontData::_fontData; -Common::Point FontData::_writePos; +Common::Point *FontData::_fontWritePos; byte FontData::_textColors[4]; byte FontData::_bgColor; bool FontData::_fontReduced; Justify FontData::_fontJustify; -FontSurface::FontSurface() : XSurface(), _msgWraps(false), _displayString(nullptr) { +FontSurface::FontSurface() : XSurface(), _msgWraps(false), _displayString(nullptr), + _writePos(*FontData::_fontWritePos) { setTextColor(0); } FontSurface::FontSurface(int wv, int hv) : XSurface(wv, hv), - _msgWraps(false), _displayString(nullptr) { + _msgWraps(false), _displayString(nullptr), _writePos(*FontData::_fontWritePos) { create(w, h); setTextColor(0); } diff --git a/engines/xeen/font.h b/engines/xeen/font.h index ca2cf87ad4..90bd24b67e 100644 --- a/engines/xeen/font.h +++ b/engines/xeen/font.h @@ -35,7 +35,7 @@ enum Justify { JUSTIFY_NONE = 0, JUSTIFY_CENTER = 1, JUSTIFY_RIGHT = 2 }; struct FontData { static const byte *_fontData; - static Common::Point _writePos; + static Common::Point *_fontWritePos; static byte _textColors[4]; static byte _bgColor; static bool _fontReduced; @@ -76,6 +76,8 @@ private: * Wrie a character to the surface */ void writeChar(char c, const Common::Rect &clipRect); +public: + Common::Point &_writePos; public: FontSurface(); FontSurface(int wv, int hv); diff --git a/engines/xeen/window.cpp b/engines/xeen/window.cpp index 99ceb9a0be..47732dc841 100644 --- a/engines/xeen/window.cpp +++ b/engines/xeen/window.cpp @@ -31,6 +31,7 @@ Windows::Windows() { byte *data = new byte[f.size()]; f.read(data, f.size()); _fontData = data; + _fontWritePos = new Common::Point(); Common::fill(&_textColors[0], &_textColors[4], 0); _bgColor = DEFAULT_BG_COLOR; @@ -87,6 +88,7 @@ Windows::Windows() { Windows::~Windows() { delete[] _fontData; + delete _fontWritePos; } void Windows::closeAll() { -- cgit v1.2.3