Skip to content

Commit

Permalink
PRINCE: code indentation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Zbróg committed Nov 10, 2013
1 parent 416110d commit bd59732
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 33 deletions.
42 changes: 21 additions & 21 deletions engines/prince/archive.cpp
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions engines/prince/decompress.cpp
Expand Up @@ -20,6 +20,8 @@
*
*/

// John_Doe's implementation

#include "prince/decompress.h"

namespace Prince {
Expand Down
2 changes: 2 additions & 0 deletions engines/prince/decompress.h
Expand Up @@ -20,6 +20,8 @@
*
*/

// John_Doe's implementation

#ifndef PRINCE_DECOMPRESS_H
#define PRINCE_DECOMPRESS_H

Expand Down
2 changes: 1 addition & 1 deletion engines/prince/object.h
Expand Up @@ -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);
Expand Down
17 changes: 14 additions & 3 deletions engines/prince/prince.cpp
Expand Up @@ -143,8 +143,8 @@ bool loadResource(Common::Array<T> &array, const char *resourceName, bool requir
if (!stream) {
if (required) {
error("Can't load %s", resourceName);
return false;
}
return false;
}

typename Common::Array<T>::value_type t;
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
);
Expand Down
9 changes: 1 addition & 8 deletions engines/prince/prince.h
Expand Up @@ -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;
Expand Down

0 comments on commit bd59732

Please sign in to comment.