From e4a37322a6678aa3874d96ce131bebbccbdd7a44 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 20 Aug 2011 00:23:45 +0200 Subject: CGE: More misc cleanup. --- engines/cge/text.cpp | 78 +++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'engines/cge/text.cpp') diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 7e58762afa..0e6fc40920 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -79,44 +79,44 @@ int Text::find(int ref) { void Text::preload(int from, int upto) { INI_FILE tf = _fileName; - if (!tf._error) { - Han *CacheLim = _cache + _size; - char line[kLineMax + 1]; - int n; - - while ((n = tf.read((uint8 *)line)) != 0) { - char *s; - - if (line[n - 1] == '\n') - line[--n] = '\0'; - - if ((s = strtok(line, " =,;/\t\n")) == NULL) - continue; - if (!IsDigit(*s)) - continue; - - int ref = atoi(s); - if (ref && ref >= from && ref < upto) { - Han *p = &_cache[find(ref)]; - - if (p < CacheLim) { - delete[] p->_text; - p->_text = NULL; - } else - p = &_cache[find(0)]; - - if (p >= CacheLim) - break; - - s += strlen(s); - if (s < line + n) - ++s; - if ((p->_text = new char[strlen(s) + 1]) == NULL) - break; - - p->_ref = ref; - strcpy(p->_text, s); - } + if (tf._error) + return; + + Han *CacheLim = _cache + _size; + char line[kLineMax + 1]; + int n; + + while ((n = tf.read((uint8 *)line)) != 0) { + if (line[n - 1] == '\n') + line[--n] = '\0'; + + char *s; + if ((s = strtok(line, " =,;/\t\n")) == NULL) + continue; + if (!IsDigit(*s)) + continue; + + int ref = atoi(s); + if (ref && ref >= from && ref < upto) { + Han *p = &_cache[find(ref)]; + + if (p < CacheLim) { + delete[] p->_text; + p->_text = NULL; + } else + p = &_cache[find(0)]; + + if (p >= CacheLim) + break; + + s += strlen(s); + if (s < line + n) + ++s; + if ((p->_text = new char[strlen(s) + 1]) == NULL) + break; + + p->_ref = ref; + strcpy(p->_text, s); } } } @@ -161,7 +161,6 @@ char *Text::load(int idx, int ref) { return NULL; } - char *Text::getText(int ref) { int i; if ((i = find(ref)) < _size) @@ -177,7 +176,6 @@ char *Text::getText(int ref) { return load(i, ref); } - void Text::say(const char *text, Sprite *spr) { killText(); _talk = new Talk(_vm, text, kTBRound); -- cgit v1.2.3