From bd59732ce20df7d62b74b9a88bf510e4e2305c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Zbr=C3=B3g?= Date: Sun, 10 Nov 2013 22:49:34 +0000 Subject: [PATCH] PRINCE: code indentation cleanup --- engines/prince/archive.cpp | 42 +++++++++++++++++------------------ engines/prince/decompress.cpp | 2 ++ engines/prince/decompress.h | 2 ++ engines/prince/object.h | 2 +- engines/prince/prince.cpp | 17 +++++++++++--- engines/prince/prince.h | 9 +------- 6 files changed, 41 insertions(+), 33 deletions(-) diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp index 2cf3126f0ce9..a6927baf0c15 100644 --- a/engines/prince/archive.cpp +++ b/engines/prince/archive.cpp @@ -37,13 +37,13 @@ PtcArchive::~PtcArchive() { } static void decrypt(byte *buffer, uint32 size) { - uint32 key = 0xDEADF00D; - while (size--) { - *buffer++ += key & 0xFF; - key ^= 0x2E84299A; - key += 0x424C4148; - key = ((key & 1) << 31) | (key >> 1); - } + uint32 key = 0xDEADF00D; + while (size--) { + *buffer++ += key & 0xFF; + key ^= 0x2E84299A; + key += 0x424C4148; + key = ((key & 1) << 31) | (key >> 1); + } } bool PtcArchive::open(const Common::String &filename) { @@ -55,26 +55,26 @@ bool PtcArchive::open(const Common::String &filename) { uint32 fileTableOffset = _stream->readUint32LE() ^ 0x4D4F4B2D; // MOK- uint32 fileTableSize = _stream->readUint32LE() ^ 0x534F4654; // SOFT - debug("fileTableOffset : %08X", fileTableOffset); - debug("fileTableSize: %08X", fileTableSize); + debug("fileTableOffset : %08X", fileTableOffset); + debug("fileTableSize: %08X", fileTableSize); _stream->seek(fileTableOffset); - byte *fileTable = new byte[fileTableSize]; - byte *fileTableEnd = fileTable + fileTableSize; - _stream->read(fileTable, fileTableSize); - decrypt(fileTable, fileTableSize); - - for (byte *fileItem = fileTable; fileItem < fileTableEnd; fileItem += 32) { - FileEntry item; + byte *fileTable = new byte[fileTableSize]; + byte *fileTableEnd = fileTable + fileTableSize; + _stream->read(fileTable, fileTableSize); + decrypt(fileTable, fileTableSize); + + for (byte *fileItem = fileTable; fileItem < fileTableEnd; fileItem += 32) { + FileEntry item; Common::String name = (const char*)fileItem; - item._offset = READ_LE_UINT32(fileItem + 24); - item._size = READ_LE_UINT32(fileItem + 28); - debug("%12s %8X %d", name.c_str(), item._offset, item._size); + item._offset = READ_LE_UINT32(fileItem + 24); + item._size = READ_LE_UINT32(fileItem + 28); + debug("%12s %8X %d", name.c_str(), item._offset, item._size); _items[name] = item; } - - delete[] fileTable; + + delete[] fileTable; return true; } diff --git a/engines/prince/decompress.cpp b/engines/prince/decompress.cpp index 8eca653e0a97..ed52aaf6f7de 100644 --- a/engines/prince/decompress.cpp +++ b/engines/prince/decompress.cpp @@ -20,6 +20,8 @@ * */ +// John_Doe's implementation + #include "prince/decompress.h" namespace Prince { diff --git a/engines/prince/decompress.h b/engines/prince/decompress.h index 19c7906eda4d..88b19c6ae325 100644 --- a/engines/prince/decompress.h +++ b/engines/prince/decompress.h @@ -20,6 +20,8 @@ * */ +// John_Doe's implementation + #ifndef PRINCE_DECOMPRESS_H #define PRINCE_DECOMPRESS_H diff --git a/engines/prince/object.h b/engines/prince/object.h index 052b88dad6be..aa55bf06a604 100644 --- a/engines/prince/object.h +++ b/engines/prince/object.h @@ -34,7 +34,7 @@ class Object { ~Object(); bool loadFromStream(Common::SeekableReadStream &stream); - Graphics::Surface *getSurface() const { return _surface; } + const Graphics::Surface *getSurface() const { return _surface; } private: void loadSurface(Common::SeekableReadStream &stream); diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 005a829444f6..53c8684a6d89 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -143,8 +143,8 @@ bool loadResource(Common::Array &array, const char *resourceName, bool requir if (!stream) { if (required) { error("Can't load %s", resourceName); - return false; } + return false; } typename Common::Array::value_type t; @@ -235,6 +235,8 @@ Common::Error PrinceEngine::run() { } bool PrinceEngine::loadLocation(uint16 locationNr) { + _cameraX = 0; + _newCameraX = 0; _debugger->_locationNr = locationNr; debugEngine("PrinceEngine::loadLocation %d", locationNr); const Common::FSNode gameDataDir(ConfMan.get("path")); @@ -259,7 +261,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { } _mobList.clear(); - loadResource(_mobList, "mob.lst"); + loadResource(_mobList, "mob.lst", false); const char *musName = MusicPlayer::_musTable[MusicPlayer::_musRoomTable[locationNr]]; _midiPlayer->loadMidi(musName); @@ -331,6 +333,11 @@ void PrinceEngine::stopSample(uint16 sampleId) { bool PrinceEngine::loadVoice(uint32 slot, const Common::String &streamName) { debugEngine("Loading wav %s slot %d", streamName.c_str(), slot); + if (slot > MAXTEXTS) { + error("Text slot bigger than MAXTEXTS %d", MAXTEXTS); + return false; + } + _voiceStream = SearchMan.createReadStreamForMember(streamName); if (!_voiceStream) { error("Can't open %s", streamName.c_str()); @@ -443,11 +450,15 @@ void PrinceEngine::hotspot() { if (x + textW > _graph->_frontScreen->w) x = _graph->_frontScreen->w - textW; + uint16 y = mousepos.y - _font->getFontHeight(); + if (y > _graph->_frontScreen->h) + y = _font->getFontHeight() - 2; + _font->drawString( _graph->_frontScreen, mob._name, x, - mousepos.y - _font->getFontHeight(), + y, _graph->_frontScreen->w, 216 ); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 2df8e6682537..0da0bcfe719e 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -47,14 +47,7 @@ namespace Prince { -#if 0 - bool loadFromStream(Common::SeekableReadStream &stream) { - ResourceType *resource = new ResourceType(); - while (resource->loadFromStream(stream)) - _list.push_back(resource); - return true; - } -#endif + struct PrinceGameDescription; class PrinceEngine;