Permalink
Browse files

STARTREK: Reformat with artistic style

  • Loading branch information...
Drenn1 authored and sev- committed Jul 24, 2018
1 parent aa68655 commit fe98dbb69d1f8222eeb391111f59670658b0daad
Showing with 446 additions and 546 deletions.
  1. +6 −2 engines/startrek/action.h
  2. +3 −3 engines/startrek/awaymission.cpp
  3. +1 −1 engines/startrek/bitmap.cpp
  4. +1 −1 engines/startrek/common.cpp
  5. +6 −2 engines/startrek/common.h
  6. +17 −15 engines/startrek/detection.cpp
  7. +1 −1 engines/startrek/events.cpp
  8. +1 −1 engines/startrek/filestream.cpp
  9. +4 −4 engines/startrek/font.h
  10. +18 −23 engines/startrek/graphics.cpp
  11. +9 −7 engines/startrek/graphics.h
  12. +3 −1 engines/startrek/iwfile.h
  13. +1 −1 engines/startrek/lzss.cpp
  14. +15 −15 engines/startrek/lzss.h
  15. +27 −28 engines/startrek/menu.cpp
  16. +6 −7 engines/startrek/object.h
  17. +11 −12 engines/startrek/room.cpp
  18. +30 −10 engines/startrek/room.h
  19. +1 −2 engines/startrek/rooms/demon0.cpp
  20. +11 −22 engines/startrek/rooms/demon1.cpp
  21. +14 −28 engines/startrek/rooms/demon3.cpp
  22. +4 −8 engines/startrek/rooms/demon4.cpp
  23. +10 −20 engines/startrek/rooms/demon5.cpp
  24. +6 −12 engines/startrek/rooms/demon6.cpp
  25. +2 −2 engines/startrek/rooms/feather1.cpp
  26. +2 −2 engines/startrek/rooms/feather3.cpp
  27. +2 −2 engines/startrek/rooms/feather4.cpp
  28. +1 −1 engines/startrek/rooms/feather5.cpp
  29. +5 −5 engines/startrek/rooms/feather6.cpp
  30. +3 −3 engines/startrek/rooms/love1.cpp
  31. +5 −10 engines/startrek/rooms/love3.cpp
  32. +1 −2 engines/startrek/rooms/love4.cpp
  33. +5 −9 engines/startrek/rooms/love5.cpp
  34. +6 −12 engines/startrek/rooms/lovea.cpp
  35. +5 −6 engines/startrek/rooms/mudd0.cpp
  36. +1 −1 engines/startrek/rooms/mudd1.cpp
  37. +1 −2 engines/startrek/rooms/mudd2.cpp
  38. +7 −11 engines/startrek/rooms/mudd4.cpp
  39. +6 −6 engines/startrek/rooms/mudda.cpp
  40. +1 −1 engines/startrek/rooms/trial5.cpp
  41. +8 −13 engines/startrek/rooms/tug2.cpp
  42. +16 −26 engines/startrek/rooms/tug3.cpp
  43. +4 −8 engines/startrek/saveload.cpp
  44. +27 −28 engines/startrek/sound.cpp
  45. +7 −7 engines/startrek/sound.h
  46. +1 −1 engines/startrek/space.cpp
  47. +1 −1 engines/startrek/sprite.cpp
  48. +1 −1 engines/startrek/sprite.h
  49. +55 −89 engines/startrek/startrek.cpp
  50. +30 −16 engines/startrek/startrek.h
  51. +36 −54 engines/startrek/text.cpp
  52. +1 −1 engines/startrek/text.h
@@ -60,8 +60,12 @@ struct Action {
byte b3;

// ACTION_USE, ACTION_GET, ACTION_LOOK, ACTION_TALK
byte activeObject() const { return b1; }
byte passiveObject() const { return b2; }
byte activeObject() const {
return b1;
}
byte passiveObject() const {
return b2;
}

bool operator==(const Action &a) const {
return type == a.type && b1 == a.b1 && b2 == a.b2 && b3 == a.b3;
@@ -404,7 +404,7 @@ void StarTrekEngine::awayMissionUseObject(int16 clickedObject) {
tryWalkToHotspot = true;
else if (_awayMission.activeObject == OBJECT_MCCOY && _room->actionHasCode(ACTION_USE, OBJECT_IMEDKIT, _awayMission.passiveObject, 0))
tryWalkToHotspot = true;
else if (_awayMission.activeObject == OBJECT_SPOCK &&_room->actionHasCode(ACTION_USE, OBJECT_ISTRICOR, _awayMission.passiveObject, 0))
else if (_awayMission.activeObject == OBJECT_SPOCK && _room->actionHasCode(ACTION_USE, OBJECT_ISTRICOR, _awayMission.passiveObject, 0))
tryWalkToHotspot = true;

if (!tryWalkToHotspot) {
@@ -694,7 +694,7 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) {
int16 offset = _room->getFirstDoorPolygonOffset();

while (offset != _room->getDoorPolygonEndOffset()) {
if (isPointInPolygon((int16*)(_room->_rdfData + offset), x, y)) {
if (isPointInPolygon((int16 *)(_room->_rdfData + offset), x, y)) {
uint16 var = _room->readRdfWord(offset);
if (_activeDoorWarpHotspot != var) {
_activeDoorWarpHotspot = var;
@@ -712,7 +712,7 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) {
offset = _room->getFirstWarpPolygonOffset();

while (offset != _room->getWarpPolygonEndOffset()) {
if (isPointInPolygon((int16*)(_room->_rdfData + offset), x, y)) {
if (isPointInPolygon((int16 *)(_room->_rdfData + offset), x, y)) {
uint16 var = _room->readRdfWord(offset);
if (_activeWarpHotspot != var) {
_activeWarpHotspot = var;
@@ -46,7 +46,7 @@ Bitmap::Bitmap(const Bitmap &bitmap) {
}

Bitmap::Bitmap(int w, int h) : width(w), height(h), xoffset(0), yoffset(0) {
pixels = new byte[width*height];
pixels = new byte[width * height];
}

Bitmap::~Bitmap() {
@@ -32,7 +32,7 @@ Common::Rect getRectEncompassing(Common::Rect r1, Common::Rect r2) {
uint16 r = max(r1.right, r2.right);
uint16 b = max(r1.bottom, r2.bottom);

return Common::Rect(l,t,r,b);
return Common::Rect(l, t, r, b);
}

void serializeRect(Common::Rect rect, Common::Serializer &ser) {
@@ -33,10 +33,14 @@ class Serializer;
namespace StarTrek {

template<class T>
T min(T a, T b) { return a < b ? a : b; }
T min(T a, T b) {
return a < b ? a : b;
}

template<class T>
T max(T a, T b) { return a > b ? a : b; }
T max(T a, T b) {
return a > b ? a : b;
}

Common::Rect getRectEncompassing(Common::Rect r1, Common::Rect r2);
void serializeRect(Common::Rect rect, Common::Serializer &ser);
@@ -92,7 +92,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -107,7 +107,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -122,7 +122,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -137,7 +137,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -152,7 +152,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -167,7 +167,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
0,
0,
},

{
{
"st25",
@@ -197,7 +197,7 @@ static const StarTrekGameDescription gameDescriptions[] = {
GF_DEMO,
0,
},

{
{
"stjr",
@@ -211,8 +211,8 @@ static const StarTrekGameDescription gameDescriptions[] = {
GType_STJR,
0,
0,
},
},

{ AD_TABLE_END_MARKER, 0, 0, 0 }
};

@@ -250,14 +250,14 @@ bool StarTrekMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
(f == kSavesSupportPlayTime) ||
(f == kSimpleSavesNames);
(f == kSimpleSavesNames);
}

bool StarTrekMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const StarTrek::StarTrekGameDescription *gd = (const StarTrek::StarTrekGameDescription *)desc;

*engine = new StarTrek::StarTrekEngine(syst, gd);

return (gd != 0);
}

@@ -304,7 +304,9 @@ SaveStateList StarTrekMetaEngine::listSaves(const char *target) const {
}


int StarTrekMetaEngine::getMaximumSaveSlot() const { return 999; }
int StarTrekMetaEngine::getMaximumSaveSlot() const {
return 999;
}

void StarTrekMetaEngine::removeSaveState(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s.%03d", target, slot);
@@ -372,8 +374,8 @@ SaveStateDescriptor StarTrekMetaEngine::querySaveMetaInfos(const char *target, i


#if PLUGIN_ENABLED_DYNAMIC(STARTREK)
REGISTER_PLUGIN_DYNAMIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine);
REGISTER_PLUGIN_DYNAMIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine);
#else
REGISTER_PLUGIN_STATIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine);
REGISTER_PLUGIN_STATIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine);
#endif

@@ -161,7 +161,7 @@ bool StarTrekEngine::popNextEvent(TrekEvent *e, bool poll) {
void StarTrekEngine::addEventToQueue(const TrekEvent &e) {
if (e.type == TREKEVENT_MOUSEMOVE && _mouseMoveEventInQueue) {
// Only allow one mouse move event at once
for (Common::List<TrekEvent>::iterator i = _eventQueue.begin(); i!=_eventQueue.end(); i++) {
for (Common::List<TrekEvent>::iterator i = _eventQueue.begin(); i != _eventQueue.end(); i++) {
if (i->type == TREKEVENT_MOUSEMOVE) {
*i = e;
return;
@@ -18,7 +18,7 @@ FileStream::~FileStream() {

// ReadStream functions

uint32 FileStream::read(void* dataPtr, uint32 dataSize) {
uint32 FileStream::read(void *dataPtr, uint32 dataSize) {
if (_pos + dataSize > (uint32)size())
dataSize = size() - _pos;
memcpy(dataPtr, _data + _pos, dataSize);
@@ -25,9 +25,9 @@

#ifndef STARTREK_FONT_H
#define STARTREK_FONT_H

#include "startrek/startrek.h"

namespace StarTrek {

class StarTrekEngine;
@@ -38,7 +38,7 @@ class Font {
~Font();

byte *getCharData(int i);

private:
StarTrekEngine *_vm;

@@ -48,6 +48,6 @@ class Font {
};


}
}

#endif
@@ -79,7 +79,7 @@ void Graphics::setBackgroundImage(SharedPtr<Bitmap> bitmap) {
void Graphics::drawBitmapToBackground(const Common::Rect &origRect, const Common::Rect &drawRect, SharedPtr<Bitmap> bitmap) {
byte *dest = _backgroundImage->pixels + drawRect.top * SCREEN_WIDTH + drawRect.left;
byte *src = bitmap->pixels + (drawRect.left - origRect.left)
+ (drawRect.top - origRect.top) * bitmap->width;
+ (drawRect.top - origRect.top) * bitmap->width;

for (int y = drawRect.top; y < drawRect.bottom; y++) {
for (int x = drawRect.left; x < drawRect.right; x++) {
@@ -298,19 +298,19 @@ void Graphics::drawSprite(const Sprite &sprite, ::Graphics::Surface *surface) {
// sprite's actual, full rectangle.
void Graphics::drawSprite(const Sprite &sprite, ::Graphics::Surface *surface, const Common::Rect &rect) {
Common::Rect spriteRect = Common::Rect(sprite.drawX, sprite.drawY,
sprite.drawX + sprite.bitmap->width, sprite.drawY + sprite.bitmap->height);
sprite.drawX + sprite.bitmap->width, sprite.drawY + sprite.bitmap->height);

assert(_screenRect.contains(rect));
assert(spriteRect.contains(rect));

byte *dest = (byte*)surface->getPixels() + rect.top*SCREEN_WIDTH + rect.left;
byte *dest = (byte *)surface->getPixels() + rect.top * SCREEN_WIDTH + rect.left;

switch(sprite.drawMode) {
switch (sprite.drawMode) {
case 0: { // Normal sprite
byte *src = sprite.bitmap->pixels + (rect.left - sprite.drawX)
+ (rect.top - sprite.drawY) * sprite.bitmap->width;
+ (rect.top - sprite.drawY) * sprite.bitmap->width;

int priOffset = rect.top*SCREEN_WIDTH + rect.left;
int priOffset = rect.top * SCREEN_WIDTH + rect.left;

for (int y = rect.top; y < rect.bottom; y++) {
for (int x = rect.left; x < rect.right; x++) {
@@ -342,7 +342,7 @@ void Graphics::drawSprite(const Sprite &sprite, ::Graphics::Surface *surface, co

case 2: { // Normal sprite with darkened background for "transparent" pixels (and no priority)
byte *src = sprite.bitmap->pixels + (rect.left - sprite.drawX)
+ (rect.top - sprite.drawY) * sprite.bitmap->width;
+ (rect.top - sprite.drawY) * sprite.bitmap->width;

for (int y = rect.top; y < rect.bottom; y++) {
for (int x = rect.left; x < rect.right; x++) {
@@ -380,13 +380,13 @@ void Graphics::drawSprite(const Sprite &sprite, ::Graphics::Surface *surface, co
int drawWidth = rectangle1.width();
int drawHeight = rectangle1.height();

dest = (byte*)surface->getPixels() + sprite.drawY*SCREEN_WIDTH + sprite.drawX
+ rectangle1.top*8*SCREEN_WIDTH + rectangle1.left*8;
dest = (byte *)surface->getPixels() + sprite.drawY * SCREEN_WIDTH + sprite.drawX
+ rectangle1.top * 8 * SCREEN_WIDTH + rectangle1.left * 8;

byte *src = sprite.bitmap->pixels + rectangle1.top * sprite.bitmap->width / 8 + rectangle1.left;

for (int y=0; y < drawHeight; y++) {
for (int x=0; x < drawWidth; x++) {
for (int y = 0; y < drawHeight; y++) {
for (int x = 0; x < drawWidth; x++) {
byte c = *src;

int textColor;
@@ -456,7 +456,7 @@ void Graphics::drawAllSprites(bool updateScreen) {
Common::sort(_sprites, _sprites + _numSprites, &compareSpritesByLayer);

// Update sprite rectangles
for (int i=0; i<_numSprites; i++) {
for (int i = 0; i < _numSprites; i++) {
Sprite *spr = _sprites[i];
Common::Rect rect;

@@ -483,15 +483,13 @@ void Graphics::drawAllSprites(bool updateScreen) {
spr->rectangle2 = getRectEncompassing(spr->drawRect, spr->lastDrawRect);
spr->rect2Valid = 1;
}
}
else {
} else {
spr->rectangle2 = spr->drawRect;
spr->rect2Valid = 1;
}

spr->isOnScreen = 1;
}
else { // Off-screen
} else { // Off-screen
spr->rect2Valid = 0;
spr->isOnScreen = 0;
}
@@ -508,13 +506,11 @@ void Graphics::drawAllSprites(bool updateScreen) {
if (spr->isOnScreen) {
if (spr->rect2Valid) {
dirtyRects[numDirtyRects++] = spr->rectangle2;
}
else {
} else {
dirtyRects[numDirtyRects++] = spr->drawRect;
dirtyRects[numDirtyRects++] = spr->lastDrawRect;
}
}
else {
} else {
dirtyRects[numDirtyRects++] = spr->lastDrawRect;
}
}
@@ -584,8 +580,7 @@ void Graphics::drawAllSprites(bool updateScreen) {
if (_mouseToBeShown) {
CursorMan.showMouse(true);
_mouseToBeShown = false;
}
else if (_mouseToBeHidden) {
} else if (_mouseToBeHidden) {
CursorMan.showMouse(false);
_mouseToBeHidden = false;
}
@@ -650,7 +645,7 @@ void Graphics::addSprite(Sprite *sprite) {
}

void Graphics::delSprite(Sprite *sprite) {
for (int i=0; i<_numSprites; i++) {
for (int i = 0; i < _numSprites; i++) {
if (sprite != _sprites[i])
continue;

Oops, something went wrong.

0 comments on commit fe98dbb

Please sign in to comment.