String class usage cleanup

svn-id: r23582
This commit is contained in:
Max Horn 2006-07-23 15:08:48 +00:00
parent 602548cea3
commit 4fcdbb9349
6 changed files with 9 additions and 12 deletions

View file

@ -57,21 +57,16 @@ namespace Common {
uint hashit(const char *p) { uint hashit(const char *p) {
uint hash = 0; uint hash = 0;
byte c; byte c;
hash = 0;
while ((c = *p++)) while ((c = *p++))
hash = (hash * 31 + c); hash = (hash * 31 + c);
return hash; return hash;
} }
uint hashit_lower(const char *p) { uint hashit_lower(const char *p) {
uint hash = 0; uint hash = 0;
byte c; byte c;
while ((c = *p++)) while ((c = *p++))
hash = (hash * 31 + tolower(c)); hash = (hash * 31 + tolower(c));
return hash; return hash;
} }

View file

@ -47,6 +47,8 @@
#include "gob/util.h" #include "gob/util.h"
#include "gob/music.h" #include "gob/music.h"
#include "sound/mididrv.h"
namespace Gob { namespace Gob {
enum { enum {
@ -228,7 +230,7 @@ int GobEngine::init() {
else else
error("GobEngine::init(): Unknown version of game engine"); error("GobEngine::init(): Unknown version of game engine");
if ((_features & Gob::GF_MAC) || (_features & Gob::GF_GOB1) || (_features & Gob::GF_GOB2)) { if ((_features & Gob::GF_MAC) || (_features & Gob::GF_GOB1) || (_features & Gob::GF_GOB2)) {
if (ConfMan.get("music_driver") == "null") if (MidiDriver::parseMusicDriver(ConfMan.get("music_driver")) == MD_NULL)
_music = new Music_Dummy(this); _music = new Music_Dummy(this);
else else
_music = new Music(this); _music = new Music(this);

View file

@ -373,12 +373,12 @@ uint32 PAKFile::getFileSize(const char* file) {
bool PAKFile::openFile(Common::File &filehandle) { bool PAKFile::openFile(Common::File &filehandle) {
filehandle.close(); filehandle.close();
if (!filehandle.open(_physfile == "" ? _filename : _physfile)) { if (!filehandle.open(_physfile.empty() ? _filename : _physfile)) {
debug(3, "couldn't open pakfile '%s'\n", _filename.c_str()); debug(3, "couldn't open pakfile '%s'\n", _filename.c_str());
return false; return false;
} }
if (_physfile != "") { if (!_physfile.empty()) {
filehandle.seek(_physOffset, SEEK_CUR); filehandle.seek(_physOffset, SEEK_CUR);
} }

View file

@ -296,7 +296,7 @@ void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &
_screen.drawLine(p0.x, p1.y, p1.x, p1.y, color); _screen.drawLine(p0.x, p1.y, p1.x, p1.y, color);
} }
if (sel != "") { if (!sel.empty()) {
Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + _font->getFontHeight()); Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + _font->getFontHeight());
_font->drawString(&_screen, sel, text.left, text.top, text.width(), color, convertAligment(align), deltax, false); _font->drawString(&_screen, sel, text.left, text.top, text.width(), color, convertAligment(align), deltax, false);
} }

View file

@ -1309,7 +1309,7 @@ const Graphics::Font *ThemeNew::loadFont(const char *filename) {
Common::String cacheFilename = genCacheFilename(filename); Common::String cacheFilename = genCacheFilename(filename);
Common::File fontFile; Common::File fontFile;
if (cacheFilename != "") { if (!cacheFilename.empty()) {
if (fontFile.open(cacheFilename)) if (fontFile.open(cacheFilename))
font = Graphics::NewFont::loadFromCache(fontFile); font = Graphics::NewFont::loadFromCache(fontFile);
if (font) if (font)
@ -1368,7 +1368,7 @@ const Graphics::Font *ThemeNew::loadFont(const char *filename) {
#endif #endif
if (font) { if (font) {
if (cacheFilename != "") { if (!cacheFilename.empty()) {
if (!Graphics::NewFont::cacheFontData(*font, cacheFilename)) { if (!Graphics::NewFont::cacheFontData(*font, cacheFilename)) {
warning("Couldn't create cache file for font '%s'", filename); warning("Couldn't create cache file for font '%s'", filename);
} }

View file

@ -60,7 +60,7 @@ GuiObject::GuiObject(const Common::String &name) : _firstWidget(0) {
} }
void GuiObject::handleScreenChanged() { void GuiObject::handleScreenChanged() {
if (_name != "") { if (!_name.empty()) {
if ((_x = g_gui.evaluator()->getVar(_name + ".x")) == EVAL_UNDEF_VAR) if ((_x = g_gui.evaluator()->getVar(_name + ".x")) == EVAL_UNDEF_VAR)
error("Undefined variable %s.x", _name.c_str()); error("Undefined variable %s.x", _name.c_str());
if ((_y = g_gui.evaluator()->getVar(_name + ".y")) == EVAL_UNDEF_VAR) if ((_y = g_gui.evaluator()->getVar(_name + ".y")) == EVAL_UNDEF_VAR)