aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sludge/CommonCode/functionlist.h20
-rw-r--r--engines/sludge/backdrop.cpp43
-rw-r--r--engines/sludge/backdrop.h3
-rw-r--r--engines/sludge/builtin.cpp2
-rw-r--r--engines/sludge/builtin.h9
-rw-r--r--engines/sludge/colours.h3
-rw-r--r--engines/sludge/console.cpp3
-rw-r--r--engines/sludge/console.h4
-rw-r--r--engines/sludge/csludge.h61
-rw-r--r--engines/sludge/cursors.cpp11
-rw-r--r--engines/sludge/fileset.cpp33
-rw-r--r--engines/sludge/floor.cpp195
-rw-r--r--engines/sludge/floor.h3
-rw-r--r--engines/sludge/fonttext.cpp64
-rw-r--r--engines/sludge/freeze.cpp101
-rw-r--r--engines/sludge/freeze.h1
-rw-r--r--engines/sludge/graphics.cpp72
-rw-r--r--engines/sludge/graphics.h20
-rw-r--r--engines/sludge/language.cpp33
-rw-r--r--engines/sludge/line.cpp12
-rw-r--r--engines/sludge/loadsave.cpp53
-rw-r--r--engines/sludge/main_loop.cpp99
-rw-r--r--engines/sludge/memwatch.cpp6
-rw-r--r--engines/sludge/moreio.cpp61
-rw-r--r--engines/sludge/movie.cpp152
-rw-r--r--engines/sludge/movie.h4
-rw-r--r--engines/sludge/newfatal.cpp43
-rw-r--r--engines/sludge/objtypes.cpp68
-rw-r--r--engines/sludge/people.cpp441
-rw-r--r--engines/sludge/people.h11
-rw-r--r--engines/sludge/region.cpp41
-rw-r--r--engines/sludge/savedata.cpp96
-rw-r--r--engines/sludge/sludge.h14
-rw-r--r--engines/sludge/sludger.cpp549
-rw-r--r--engines/sludge/sludger.h29
-rw-r--r--engines/sludge/sound_bass.cpp145
-rw-r--r--engines/sludge/sound_openal.cpp134
-rw-r--r--engines/sludge/sprbanks.cpp25
-rw-r--r--engines/sludge/sprites.cpp220
-rw-r--r--engines/sludge/sprites.h37
-rw-r--r--engines/sludge/stringy.cpp10
-rw-r--r--engines/sludge/talk.cpp39
-rw-r--r--engines/sludge/talk.h1
-rw-r--r--engines/sludge/thumbnail.cpp4
-rw-r--r--engines/sludge/timing.cpp3
-rw-r--r--engines/sludge/transition.cpp7
-rw-r--r--engines/sludge/variable.cpp345
-rw-r--r--engines/sludge/variable.h55
-rw-r--r--engines/sludge/vid.cpp237
-rw-r--r--engines/sludge/winstuff.cpp283
-rw-r--r--engines/sludge/zbuffer.cpp13
-rw-r--r--engines/sludge/zbuffer.h1
52 files changed, 2179 insertions, 1740 deletions
diff --git a/engines/sludge/CommonCode/functionlist.h b/engines/sludge/CommonCode/functionlist.h
index 3d98553129..637ed5c026 100644
--- a/engines/sludge/CommonCode/functionlist.h
+++ b/engines/sludge/CommonCode/functionlist.h
@@ -1,10 +1,10 @@
/*
-This is the list of the built in functions
+ This is the list of the built in functions
-true or false states if it's a used function
-in the current version of the engine,
-but that value currently isn't used anywhere
-*/
+ true or false states if it's a used function
+ in the current version of the engine,
+ but that value currently isn't used anywhere
+ */
FUNC(true, say)
FUNC(true, skipSpeech)
@@ -135,10 +135,10 @@ FUNC(true, captureAllKeys)
FUNC(true, cacheSound)
FUNC(true, setCharacterSpinSpeed)
FUNC(true, transitionMode)
-FUNC(false, _rem_movieStart)
-FUNC(false, _rem_movieAbort)
-FUNC(false, _rem_moviePlaying)
-FUNC(false, _rem_updateDisplay)
+FUNC(false, _rem_movieStart)
+FUNC(false, _rem_movieAbort)
+FUNC(false, _rem_moviePlaying)
+FUNC(false, _rem_updateDisplay)
FUNC(true, getSoundCache)
FUNC(true, saveCustomData)
FUNC(true, loadCustomData)
@@ -160,7 +160,7 @@ FUNC(true, hasFlag)
FUNC(true, snapshotGrab)
FUNC(true, snapshotClear)
FUNC(true, bodgeFilenames)
-FUNC(false, _rem_registryGetString)
+FUNC(false, _rem_registryGetString)
FUNC(true, quitWithFatalError)
FUNC(true, _rem_setCharacterAA)
FUNC(true, _rem_setMaximumAA)
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index c28a7d05fb..7fecf573d6 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -155,7 +155,7 @@ bool snapshot() {
viewSpeech();// ...and anything being said
drawStatusBar();
- // Copy Our ViewPort To The Texture
+ // Copy Our ViewPort To The Texture
copyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewportOffsetX, viewportOffsetY, winWidth, winHeight, snapshotTextureName);
setPixelCoords(false);
@@ -320,7 +320,9 @@ void loadBackDrop(int fileNum, int x, int y) {
if (!loadHSI(bigDataFile, x, y, false)) {
char mess[200];
- sprintf(mess, "Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i", x, y, sceneWidth, sceneHeight);
+ sprintf(mess,
+ "Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i",
+ x, y, sceneWidth, sceneHeight);
fatal(mess);
}
@@ -1006,11 +1008,14 @@ bool loadParallax(unsigned short v, unsigned short fracX,
extern int viewportOffsetX, viewportOffsetY;
-bool loadPng(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
- debug("Loading back drop png.");
+bool loadPng(int &picWidth, int &picHeight, int &realPicWidth,
+ int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
+ debug(kSludgeDebugGraphics, "Loading back drop png.");
::Image::PNGDecoder png;
- if (!png.loadStream(*stream))
+ if (!png.loadStream(*stream)) {
+ debug(kSludgeDebugGraphics, "Back drop is not a png");
return false;
+ }
backdropSurface.copyFrom(*(png.getSurface()));
picWidth = realPicWidth = backdropSurface.w;
picHeight = realPicHeight = backdropSurface.h;
@@ -1049,7 +1054,7 @@ bool loadPng(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeigh
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return false;
}
- png_init_io(png_ptr, stream); // Tell libpng which file to read
+ png_init_io(png_ptr, stream); // Tell libpng which file to read
png_set_sig_bytes(png_ptr, 8);// 8 bytes already read
png_read_info(png_ptr, info_ptr);
@@ -1086,7 +1091,8 @@ bool loadPng(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeigh
#endif
}
-bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
+bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth,
+ int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
#if 0
int32_t transCol = reserve ? -1 : 63519;
int t1, t2, n;
@@ -1128,17 +1134,25 @@ bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPi
#endif
}
-bool loadImage(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, int x, int y, bool reserve) {
+bool loadImage(int &picWidth, int &picHeight, int &realPicWidth,
+ int &realPicHeight, Common::SeekableReadStream *stream, int x, int y,
+ bool reserve) {
debug(kSludgeDebugGraphics, "Loading back drop image.");
- if (!loadPng(picWidth, picHeight, realPicWidth, realPicHeight, stream, reserve)) {
- if (!loadByteArray(picWidth, picHeight, realPicWidth, realPicHeight, stream, reserve)) {
+ if (!loadPng(picWidth, picHeight, realPicWidth, realPicHeight, stream,
+ reserve)) {
+ if (!loadByteArray(picWidth, picHeight, realPicWidth, realPicHeight,
+ stream, reserve)) {
return false;
}
}
- if (x == IN_THE_CENTRE) x = (sceneWidth - realPicWidth) >> 1;
- if (y == IN_THE_CENTRE) y = (sceneHeight - realPicHeight) >> 1;
- if (x < 0 || x + realPicWidth > sceneWidth || y < 0 || y + realPicHeight > sceneHeight) return false;
+ if (x == IN_THE_CENTRE)
+ x = (sceneWidth - realPicWidth) >> 1;
+ if (y == IN_THE_CENTRE)
+ y = (sceneHeight - realPicHeight) >> 1;
+ if (x < 0 || x + realPicWidth > sceneWidth || y < 0
+ || y + realPicHeight > sceneHeight)
+ return false;
return true;
}
@@ -1269,7 +1283,8 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
int picWidth, picHeight;
int realPicWidth, realPicHeight;
- if (!loadImage(picWidth, picHeight, realPicWidth, realPicHeight, stream, x, y, reserve))
+ if (!loadImage(picWidth, picHeight, realPicWidth, realPicHeight, stream, x,
+ y, reserve))
return false;
#if 0
GLuint tmpTex;
diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h
index 8974f92deb..8346a4650d 100644
--- a/engines/sludge/backdrop.h
+++ b/engines/sludge/backdrop.h
@@ -37,7 +37,7 @@
namespace Sludge {
enum {
- LIGHTMAPMODE_NONE = -1,
+ LIGHTMAPMODE_NONE = -1,
LIGHTMAPMODE_HOTSPOT,
LIGHTMAPMODE_PIXEL,
LIGHTMAPMODE_NUM
@@ -46,7 +46,6 @@ enum {
extern unsigned int winWidth, winHeight, sceneWidth, sceneHeight;
extern int lightMapMode;
-
struct parallaxLayer {
#if 0
GLubyte *texture;
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 5d5c0fa3cf..f35a2bd2e8 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -2529,7 +2529,7 @@ builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun) {
char buff[100];
sprintf(buff, "Built in function must have %i parameter%s",
paramNum[whichFunc],
- (paramNum[whichFunc] == 1) ? "" : "s");
+ (paramNum[whichFunc] == 1) ? "" : "s");
fatal(copyString(buff));
return BR_ERROR;
diff --git a/engines/sludge/builtin.h b/engines/sludge/builtin.h
index 00d780e18b..0fb15d1be5 100644
--- a/engines/sludge/builtin.h
+++ b/engines/sludge/builtin.h
@@ -25,7 +25,14 @@
namespace Sludge {
-enum builtReturn {BR_KEEP_AND_PAUSE, BR_ERROR, BR_CONTINUE, BR_PAUSE, BR_CALLAFUNC, BR_ALREADY_GONE};
+enum builtReturn {
+ BR_KEEP_AND_PAUSE,
+ BR_ERROR,
+ BR_CONTINUE,
+ BR_PAUSE,
+ BR_CALLAFUNC,
+ BR_ALREADY_GONE
+};
bool failSecurityCheck(char *fn);
builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun);
diff --git a/engines/sludge/colours.h b/engines/sludge/colours.h
index 2caf963590..a613f6772c 100644
--- a/engines/sludge/colours.h
+++ b/engines/sludge/colours.h
@@ -42,7 +42,8 @@ inline unsigned short makeGrey(unsigned short int r) {
return ((r >> 3) << 11) | ((r >> 2) << 5) | (r >> 3);
}
-inline unsigned short makeColour(unsigned short int r, unsigned short int g, unsigned short int b) {
+inline unsigned short makeColour(unsigned short int r, unsigned short int g,
+ unsigned short int b) {
return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
}
diff --git a/engines/sludge/console.cpp b/engines/sludge/console.cpp
index 95d70b9c6d..d47f04c15a 100644
--- a/engines/sludge/console.cpp
+++ b/engines/sludge/console.cpp
@@ -24,7 +24,8 @@
namespace Sludge {
-SludgeConsole::SludgeConsole(SludgeEngine *vm) : GUI::Debugger() {
+SludgeConsole::SludgeConsole(SludgeEngine *vm) :
+ GUI::Debugger() {
_vm = vm;
}
diff --git a/engines/sludge/console.h b/engines/sludge/console.h
index 5f9640972a..a72007309e 100644
--- a/engines/sludge/console.h
+++ b/engines/sludge/console.h
@@ -30,11 +30,11 @@ namespace Sludge {
class SludgeEngine;
// Example console class
-class SludgeConsole : public GUI::Debugger {
+class SludgeConsole: public GUI::Debugger {
public:
SludgeConsole(SludgeEngine *vm);
virtual ~SludgeConsole(void);
-
+
private:
SludgeEngine *_vm;
};
diff --git a/engines/sludge/csludge.h b/engines/sludge/csludge.h
index 22b6125ff0..0564853c59 100644
--- a/engines/sludge/csludge.h
+++ b/engines/sludge/csludge.h
@@ -25,22 +25,51 @@
namespace Sludge {
-enum sludgeCommand {SLU_UNKNOWN,
- SLU_RETURN, SLU_BRANCH, SLU_BR_ZERO, SLU_SET_GLOBAL,
- SLU_SET_LOCAL, SLU_LOAD_GLOBAL, SLU_LOAD_LOCAL,
- SLU_PLUS, SLU_MINUS, SLU_MULT, SLU_DIVIDE,
- SLU_AND, SLU_OR, SLU_EQUALS, SLU_NOT_EQ, SLU_MODULUS,
- SLU_LOAD_VALUE, SLU_LOAD_BUILT, SLU_LOAD_FUNC, SLU_CALLIT,
- SLU_LOAD_STRING, SLU_LOAD_FILE, /*SLU_LOAD_SCENE,*/ SLU_LOAD_OBJTYPE,
- SLU_NOT, SLU_LOAD_NULL, SLU_STACK_PUSH, SLU_LESSTHAN, SLU_MORETHAN, SLU_NEGATIVE,
- SLU_UNREG, SLU_LESS_EQUAL, SLU_MORE_EQUAL,
- SLU_INCREMENT_LOCAL,
- SLU_DECREMENT_LOCAL,
- SLU_INCREMENT_GLOBAL,
- SLU_DECREMENT_GLOBAL, SLU_INDEXSET, SLU_INDEXGET,
- SLU_INCREMENT_INDEX, SLU_DECREMENT_INDEX, SLU_QUICK_PUSH,
- numSludgeCommands
- };
+enum sludgeCommand {
+ SLU_UNKNOWN,
+ SLU_RETURN,
+ SLU_BRANCH,
+ SLU_BR_ZERO,
+ SLU_SET_GLOBAL,
+ SLU_SET_LOCAL,
+ SLU_LOAD_GLOBAL,
+ SLU_LOAD_LOCAL,
+ SLU_PLUS,
+ SLU_MINUS,
+ SLU_MULT,
+ SLU_DIVIDE,
+ SLU_AND,
+ SLU_OR,
+ SLU_EQUALS,
+ SLU_NOT_EQ,
+ SLU_MODULUS,
+ SLU_LOAD_VALUE,
+ SLU_LOAD_BUILT,
+ SLU_LOAD_FUNC,
+ SLU_CALLIT,
+ SLU_LOAD_STRING,
+ SLU_LOAD_FILE, /*SLU_LOAD_SCENE,*/
+ SLU_LOAD_OBJTYPE,
+ SLU_NOT,
+ SLU_LOAD_NULL,
+ SLU_STACK_PUSH,
+ SLU_LESSTHAN,
+ SLU_MORETHAN,
+ SLU_NEGATIVE,
+ SLU_UNREG,
+ SLU_LESS_EQUAL,
+ SLU_MORE_EQUAL,
+ SLU_INCREMENT_LOCAL,
+ SLU_DECREMENT_LOCAL,
+ SLU_INCREMENT_GLOBAL,
+ SLU_DECREMENT_GLOBAL,
+ SLU_INDEXSET,
+ SLU_INDEXGET,
+ SLU_INCREMENT_INDEX,
+ SLU_DECREMENT_INDEX,
+ SLU_QUICK_PUSH,
+ numSludgeCommands
+};
} // End of namespace Sludge
diff --git a/engines/sludge/cursors.cpp b/engines/sludge/cursors.cpp
index 91d0112ab5..562f3869c2 100644
--- a/engines/sludge/cursors.cpp
+++ b/engines/sludge/cursors.cpp
@@ -68,8 +68,8 @@ void displayCursor() {
if (flipMe != 2) {
(flipMe ? flipFontSprite : fontSprite)(input.mouseX, input.mouseY,
- mouseCursorAnim -> theSprites -> bank.sprites[spriteNum],
- mouseCursorAnim -> theSprites -> bank.myPalette /* ( spritePalette&) NULL*/);
+ mouseCursorAnim -> theSprites -> bank.sprites[spriteNum],
+ mouseCursorAnim -> theSprites -> bank.myPalette /* ( spritePalette&) NULL*/);
}
if (++ mouseCursorCountUp >= mouseCursorAnim -> frames[mouseCursorFrameNum].howMany) {
@@ -82,9 +82,10 @@ void displayCursor() {
}
void pasteCursor(int x, int y, personaAnimation *c) {
- if (c -> numFrames) pasteSpriteToBackDrop(x, y,
- c -> theSprites -> bank.sprites[c -> frames[0].frameNum],
- c -> theSprites -> bank.myPalette);
+ if (c->numFrames)
+ pasteSpriteToBackDrop(x, y,
+ c->theSprites->bank.sprites[c->frames[0].frameNum],
+ c->theSprites->bank.myPalette);
}
} // End of namespace Sludge
diff --git a/engines/sludge/fileset.cpp b/engines/sludge/fileset.cpp
index 3c653f4bed..eb39166019 100644
--- a/engines/sludge/fileset.cpp
+++ b/engines/sludge/fileset.cpp
@@ -42,8 +42,8 @@ bool sliceBusy = true;
Common::File *bigDataFile = NULL;
-uint32_t startOfDataIndex, startOfTextIndex,
- startOfSubIndex, startOfObjectIndex;
+uint32_t startOfDataIndex, startOfTextIndex, startOfSubIndex,
+ startOfObjectIndex;
bool openSubSlice(int num) {
// FILE * dbug = fopen ("debuggy.txt", "at");
@@ -100,7 +100,6 @@ unsigned int openFileFromNum(int num) {
return get4bytes(bigDataFile);
}
-
// Converts a string from Windows CP-1252 to UTF-8.
// This is needed for old games.
char *convertString(char *s) {
@@ -124,10 +123,10 @@ char *convertString(char *s) {
if (convert == (iconv_t) - 1) {
switch (errno) {
- case EINVAL:
+ case EINVAL:
fprintf(stderr, "Error: Encoding not supported by iconv.\n");
break;
- default:
+ default:
fprintf(stderr, "Error: Could not open iconv conversion descriptor.\n");
}
}
@@ -136,35 +135,34 @@ char *convertString(char *s) {
size_t len2 = 65535;
size_t iconv_value =
#ifdef _WIN32
- iconv(convert, (const char **) tmp1, &len1, tmp2, &len2);
+ iconv(convert, (const char **) tmp1, &len1, tmp2, &len2);
#else
- iconv(convert, (char **) tmp1, &len1, tmp2, &len2);
+ iconv(convert, (char **) tmp1, &len1, tmp2, &len2);
#endif
if (iconv_value == (size_t) - 1) {
switch (errno) {
- /* See "man 3 iconv" for an explanation. */
- case EILSEQ:
+ /* See "man 3 iconv" for an explanation. */
+ case EILSEQ:
fprintf(stderr, "Invalid multibyte sequence.\n");
break;
- case EINVAL:
+ case EINVAL:
fprintf(stderr, "Incomplete multibyte sequence.\n");
break;
- case E2BIG:
+ case E2BIG:
fprintf(stderr, "No more room.\n");
break;
- default:
+ default:
fprintf(stderr, "Error: %s.\n", strerror(errno));
}
fatal("Conversion to Unicode failed. This can be fixed by recompiling the game in a current version of the SLUDGE Development Kit, but this error should never happen. Congratulations, you've found a bug in the SLUDGE engine! Please let us know about it.");
}
iconv_close(convert);
-
delete [] sOrig;
return copyString(buf = bufOrig);
#endif
- return s;//TODO: false value
+ return s; //TODO: false value
}
char *getNumberedString(int value) {
@@ -199,7 +197,8 @@ void finishAccess() {
int32_t startIndex;
-void setFileIndices(Common::File *fp, int numLanguages, unsigned int skipBefore) {
+void setFileIndices(Common::File *fp, int numLanguages,
+ unsigned int skipBefore) {
if (fp) {
// Keep hold of the file handle, and let things get at it
bigDataFile = fp;
@@ -220,7 +219,7 @@ void setFileIndices(Common::File *fp, int numLanguages, unsigned int skipBefore)
int skipAfter = numLanguages - skipBefore;
while (skipBefore) {
fp->seek(get4bytes(fp), SEEK_SET);
- skipBefore --;
+ skipBefore--;
}
startOfTextIndex = fp->pos() + 4;
@@ -228,7 +227,7 @@ void setFileIndices(Common::File *fp, int numLanguages, unsigned int skipBefore)
while (skipAfter) {
fp->seek(get4bytes(fp), SEEK_SET);
- skipAfter --;
+ skipAfter--;
}
startOfSubIndex = fp->pos() + 4;
diff --git a/engines/sludge/floor.cpp b/engines/sludge/floor.cpp
index 7ca30b6c3d..ec5738728f 100644
--- a/engines/sludge/floor.cpp
+++ b/engines/sludge/floor.cpp
@@ -35,17 +35,15 @@ bool pointInFloorPolygon(floorPolygon &floorPoly, int x, int y) {
float xp_i, yp_i;
float xp_j, yp_j;
- for (j = floorPoly.numVertices - 1; i < floorPoly.numVertices;
- j = i ++) {
+ for (j = floorPoly.numVertices - 1; i < floorPoly.numVertices; j = i++) {
- xp_i = currentFloor -> vertex[floorPoly.vertexID[i]].x;
- yp_i = currentFloor -> vertex[floorPoly.vertexID[i]].y;
- xp_j = currentFloor -> vertex[floorPoly.vertexID[j]].x;
- yp_j = currentFloor -> vertex[floorPoly.vertexID[j]].y;
+ xp_i = currentFloor->vertex[floorPoly.vertexID[i]].x;
+ yp_i = currentFloor->vertex[floorPoly.vertexID[i]].y;
+ xp_j = currentFloor->vertex[floorPoly.vertexID[j]].x;
+ yp_j = currentFloor->vertex[floorPoly.vertexID[j]].y;
- if ((((yp_i <= y) && (y < yp_j)) ||
- ((yp_j <= y) && (y < yp_i))) &&
- (x < (xp_j - xp_i) * (y - yp_i) / (yp_j - yp_i) + xp_i)) {
+ if ((((yp_i <= y) && (y < yp_j)) || ((yp_j <= y) && (y < yp_i)))
+ && (x < (xp_j - xp_i) * (y - yp_i) / (yp_j - yp_i) + xp_i)) {
c = !c;
}
@@ -53,14 +51,15 @@ bool pointInFloorPolygon(floorPolygon &floorPoly, int x, int y) {
return c;
}
-bool getMatchingCorners(floorPolygon &a, floorPolygon &b, int &cornerA, int &cornerB) {
+bool getMatchingCorners(floorPolygon &a, floorPolygon &b, int &cornerA,
+ int &cornerB) {
int sharedVertices = 0;
int i, j;
- for (i = 0; i < a.numVertices; i ++) {
- for (j = 0; j < b.numVertices; j ++) {
+ for (i = 0; i < a.numVertices; i++) {
+ for (j = 0; j < b.numVertices; j++) {
if (a.vertexID[i] == b.vertexID[j]) {
- if (sharedVertices ++) {
+ if (sharedVertices++) {
cornerB = a.vertexID[i];
return true;
} else {
@@ -77,10 +76,11 @@ bool polysShareSide(floorPolygon &a, floorPolygon &b) {
int sharedVertices = 0;
int i, j;
- for (i = 0; i < a.numVertices; i ++) {
- for (j = 0; j < b.numVertices; j ++) {
+ for (i = 0; i < a.numVertices; i++) {
+ for (j = 0; j < b.numVertices; j++) {
if (a.vertexID[i] == b.vertexID[j]) {
- if (sharedVertices ++) return true;
+ if (sharedVertices++)
+ return true;
}
}
}
@@ -89,30 +89,31 @@ bool polysShareSide(floorPolygon &a, floorPolygon &b) {
}
void noFloor() {
- currentFloor -> numPolygons = 0;
- currentFloor -> polygon = NULL;
- currentFloor -> vertex = NULL;
- currentFloor -> matrix = NULL;
+ currentFloor->numPolygons = 0;
+ currentFloor->polygon = NULL;
+ currentFloor->vertex = NULL;
+ currentFloor->matrix = NULL;
}
bool initFloor() {
currentFloor = new flor;
- if (! checkNew(currentFloor)) return false;
+ if (!checkNew(currentFloor))
+ return false;
noFloor();
return true;
}
void killFloor() {
- for (int i = 0; i < currentFloor -> numPolygons; i ++) {
- delete currentFloor -> polygon[i].vertexID;
- delete currentFloor -> matrix[i];
+ for (int i = 0; i < currentFloor->numPolygons; i++) {
+ delete currentFloor->polygon[i].vertexID;
+ delete currentFloor->matrix[i];
}
- delete currentFloor -> polygon;
- currentFloor -> polygon = NULL;
- delete currentFloor -> vertex;
- currentFloor -> vertex = NULL;
- delete currentFloor -> matrix;
- currentFloor -> matrix = NULL;
+ delete currentFloor->polygon;
+ currentFloor->polygon = NULL;
+ delete currentFloor->vertex;
+ currentFloor->vertex = NULL;
+ delete currentFloor->matrix;
+ currentFloor->matrix = NULL;
}
void setFloorNull() {
@@ -128,73 +129,81 @@ bool setFloor(int fileNum) {
setResourceForFatal(fileNum);
- if (! openFileFromNum(fileNum)) return false;
+ if (!openFileFromNum(fileNum))
+ return false;
// Find out how many polygons there are and reserve memory
- currentFloor -> originalNum = fileNum;
- currentFloor -> numPolygons = getch(bigDataFile);
- currentFloor -> polygon = new floorPolygon[currentFloor -> numPolygons];
- if (! checkNew(currentFloor -> polygon)) return false;
+ currentFloor->originalNum = fileNum;
+ currentFloor->numPolygons = getch(bigDataFile);
+ currentFloor->polygon = new floorPolygon[currentFloor->numPolygons];
+ if (!checkNew(currentFloor->polygon))
+ return false;
// Read in each polygon
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
+ for (i = 0; i < currentFloor->numPolygons; i++) {
// Find out how many vertex IDs there are and reserve memory
- currentFloor -> polygon[i].numVertices = getch(bigDataFile);
- currentFloor -> polygon[i].vertexID = new int[currentFloor -> polygon[i].numVertices];
- if (! checkNew(currentFloor -> polygon[i].vertexID)) return false;
+ currentFloor->polygon[i].numVertices = getch(bigDataFile);
+ currentFloor->polygon[i].vertexID =
+ new int[currentFloor->polygon[i].numVertices];
+ if (!checkNew(currentFloor->polygon[i].vertexID))
+ return false;
// Read in each vertex ID
- for (j = 0; j < currentFloor -> polygon[i].numVertices; j ++) {
- currentFloor -> polygon[i].vertexID[j] = get2bytes(bigDataFile);
+ for (j = 0; j < currentFloor->polygon[i].numVertices; j++) {
+ currentFloor->polygon[i].vertexID[j] = get2bytes(bigDataFile);
}
}
// Find out how many vertices there are and reserve memory
i = get2bytes(bigDataFile);
- currentFloor -> vertex = new POINT[i];
- if (! checkNew(currentFloor -> vertex)) return false;
+ currentFloor->vertex = new POINT[i];
+ if (!checkNew(currentFloor->vertex))
+ return false;
- for (j = 0; j < i; j ++) {
+ for (j = 0; j < i; j++) {
- currentFloor -> vertex[j].x = get2bytes(bigDataFile);
- currentFloor -> vertex[j].y = get2bytes(bigDataFile);
+ currentFloor->vertex[j].x = get2bytes(bigDataFile);
+ currentFloor->vertex[j].y = get2bytes(bigDataFile);
}
finishAccess();
// Now build the movement martix
- currentFloor -> matrix = new int *[currentFloor -> numPolygons];
- int * * distanceMatrix = new int *[currentFloor -> numPolygons];
+ currentFloor->matrix = new int *[currentFloor->numPolygons];
+ int * * distanceMatrix = new int *[currentFloor->numPolygons];
- if (! checkNew(currentFloor -> matrix)) return false;
+ if (!checkNew(currentFloor->matrix))
+ return false;
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
- currentFloor -> matrix[i] = new int [currentFloor -> numPolygons];
- distanceMatrix [i] = new int [currentFloor -> numPolygons];
- if (! checkNew(currentFloor -> matrix[i])) return false;
- for (j = 0; j < currentFloor -> numPolygons; j ++) {
- currentFloor -> matrix[i][j] = -1;
- distanceMatrix [i][j] = 10000;
+ for (i = 0; i < currentFloor->numPolygons; i++) {
+ currentFloor->matrix[i] = new int[currentFloor->numPolygons];
+ distanceMatrix[i] = new int[currentFloor->numPolygons];
+ if (!checkNew(currentFloor->matrix[i]))
+ return false;
+ for (j = 0; j < currentFloor->numPolygons; j++) {
+ currentFloor->matrix[i][j] = -1;
+ distanceMatrix[i][j] = 10000;
}
}
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
- for (j = 0; j < currentFloor -> numPolygons; j ++) {
+ for (i = 0; i < currentFloor->numPolygons; i++) {
+ for (j = 0; j < currentFloor->numPolygons; j++) {
if (i != j) {
- if (polysShareSide(currentFloor -> polygon[i], currentFloor -> polygon[j])) {
- currentFloor -> matrix[i][j] = j;
- distanceMatrix [i][j] = 1;
+ if (polysShareSide(currentFloor->polygon[i],
+ currentFloor->polygon[j])) {
+ currentFloor->matrix[i][j] = j;
+ distanceMatrix[i][j] = 1;
}
} else {
- currentFloor -> matrix[i][j] = -2;
- distanceMatrix [i][j] = 0;
+ currentFloor->matrix[i][j] = -2;
+ distanceMatrix[i][j] = 0;
}
}
}
@@ -203,22 +212,23 @@ bool setFloor(int fileNum) {
int lookForDistance = 0;
do {
- lookForDistance ++;
+ lookForDistance++;
// debugMatrix ();
madeChange = false;
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
- for (j = 0; j < currentFloor -> numPolygons; j ++) {
- if (currentFloor -> matrix[i][j] == -1) {
+ for (i = 0; i < currentFloor->numPolygons; i++) {
+ for (j = 0; j < currentFloor->numPolygons; j++) {
+ if (currentFloor->matrix[i][j] == -1) {
// OK, so we don't know how to get from i to j...
- for (int d = 0; d < currentFloor -> numPolygons; d ++) {
+ for (int d = 0; d < currentFloor->numPolygons; d++) {
if (d != i && d != j) {
- if (currentFloor -> matrix[i][d] == d &&
- currentFloor -> matrix[d][j] >= 0 &&
- distanceMatrix [d][j] <= lookForDistance) {
+ if (currentFloor->matrix[i][d] == d
+ && currentFloor->matrix[d][j] >= 0
+ && distanceMatrix[d][j]
+ <= lookForDistance) {
- currentFloor -> matrix[i][j] = d;
- distanceMatrix [i][j] = lookForDistance + 1;
+ currentFloor->matrix[i][j] = d;
+ distanceMatrix[i][j] = lookForDistance + 1;
madeChange = true;
}
}
@@ -228,8 +238,8 @@ bool setFloor(int fileNum) {
}
} while (madeChange);
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
- delete distanceMatrix [i];
+ for (i = 0; i < currentFloor->numPolygons; i++) {
+ delete distanceMatrix[i];
}
delete distanceMatrix;
@@ -242,20 +252,26 @@ bool setFloor(int fileNum) {
void drawFloor() {
int i, j, nV;
- for (i = 0; i < currentFloor -> numPolygons; i ++) {
+ for (i = 0; i < currentFloor->numPolygons; i++) {
// drawLine (i, 0, i + 5, 100);
- nV = currentFloor -> polygon[i].numVertices;
+ nV = currentFloor->polygon[i].numVertices;
if (nV > 1) {
- for (j = 1; j < nV; j ++) {
- drawLine(currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j - 1]].x,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j - 1]].y,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j]].x,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j]].y);
+ for (j = 1; j < nV; j++) {
+ drawLine(
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j
+ - 1]].x,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j
+ - 1]].y,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y);
}
- drawLine(currentFloor -> vertex[currentFloor -> polygon[i].vertexID[0]].x,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[0]].y,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[nV - 1]].x,
- currentFloor -> vertex[currentFloor -> polygon[i].vertexID[nV - 1]].y);
+ drawLine(
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[0]].x,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[0]].y,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[nV
+ - 1]].x,
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[nV
+ - 1]].y);
}
}
}
@@ -263,14 +279,15 @@ void drawFloor() {
int inFloor(int x, int y) {
int i, r = -1;
- for (i = 0; i < currentFloor -> numPolygons; i ++)
- if (pointInFloorPolygon(currentFloor -> polygon[i], x, y))
+ for (i = 0; i < currentFloor->numPolygons; i++)
+ if (pointInFloorPolygon(currentFloor->polygon[i], x, y))
r = i;
return r;
}
-bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2, int y2, int xP, int yP) {
+bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2,
+ int y2, int xP, int yP) {
int xDiff = x2 - x1;
int yDiff = y2 - y1;
diff --git a/engines/sludge/floor.h b/engines/sludge/floor.h
index 193b6d19bf..50fe56e87c 100644
--- a/engines/sludge/floor.h
+++ b/engines/sludge/floor.h
@@ -54,7 +54,8 @@ bool setFloor(int fileNum);
void drawFloor();
int inFloor(int x, int y);
bool getMatchingCorners(floorPolygon &, floorPolygon &, int &, int &);
-bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2, int y2, int xP, int yP);
+bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2,
+ int y2, int xP, int yP);
} // End of namespace Sludge
diff --git a/engines/sludge/fonttext.cpp b/engines/sludge/fonttext.cpp
index 6ac9209e8d..7339d8fcae 100644
--- a/engines/sludge/fonttext.cpp
+++ b/engines/sludge/fonttext.cpp
@@ -51,11 +51,14 @@ unsigned int fontTableSize = 0;
extern float cameraZoom;
bool isInFont(char *theText) {
- if (! fontTableSize) return 0;
- if (! theText[0]) return 0;
+ if (!fontTableSize)
+ return 0;
+ if (!theText[0])
+ return 0;
// We don't want to compare strings. Only single characters allowed!
- if (u8_strlen(theText) > 1) return false;
+ if (u8_strlen(theText) > 1)
+ return false;
int i = 0;
uint32_t c = u8_nextchar(theText, &i);
@@ -72,7 +75,8 @@ int stringWidth(char *theText) {
uint32_t c;
int xOff = 0;
- if (! fontTableSize) return 0;
+ if (!fontTableSize)
+ return 0;
while (theText[a]) {
c = u8_nextchar(theText, &a);
@@ -87,46 +91,51 @@ void pasteString(char *theText, int xOff, int y, spritePalette &thePal) {
int a = 0;
uint32_t c;
- if (! fontTableSize) return;
+ if (!fontTableSize)
+ return;
- xOff += (int)((float)(fontSpace >> 1) / cameraZoom);
+ xOff += (int) ((float) (fontSpace >> 1) / cameraZoom);
while (theText[a]) {
c = u8_nextchar(theText, &a);
- mySprite = & theFont.sprites[fontInTable(c)];
- fontSprite(xOff, y, * mySprite, thePal);
- xOff += (int)((double)(mySprite -> width + fontSpace) / cameraZoom);
+ mySprite = &theFont.sprites[fontInTable(c)];
+ fontSprite(xOff, y, *mySprite, thePal);
+ xOff += (int) ((double) (mySprite->width + fontSpace) / cameraZoom);
}
}
-void pasteStringToBackdrop(char *theText, int xOff, int y, spritePalette &thePal) {
+void pasteStringToBackdrop(char *theText, int xOff, int y,
+ spritePalette &thePal) {
sprite *mySprite;
int a = 0;
uint32_t c;
- if (! fontTableSize) return;
+ if (!fontTableSize)
+ return;
xOff += fontSpace >> 1;
while (theText[a]) {
c = u8_nextchar(theText, &a);
- mySprite = & theFont.sprites[fontInTable(c)];
- pasteSpriteToBackDrop(xOff, y, * mySprite, thePal);
- xOff += mySprite -> width + fontSpace;
+ mySprite = &theFont.sprites[fontInTable(c)];
+ pasteSpriteToBackDrop(xOff, y, *mySprite, thePal);
+ xOff += mySprite->width + fontSpace;
}
}
-void burnStringToBackdrop(char *theText, int xOff, int y, spritePalette &thePal) {
+void burnStringToBackdrop(char *theText, int xOff, int y,
+ spritePalette &thePal) {
sprite *mySprite;
int a = 0;
uint32_t c;
- if (! fontTableSize) return;
+ if (!fontTableSize)
+ return;
xOff += fontSpace >> 1;
while (theText[a]) {
c = u8_nextchar(theText, &a);
- mySprite = & theFont.sprites[fontInTable(c)];
- burnSpriteToBackDrop(xOff, y, * mySprite, thePal);
- xOff += mySprite -> width + fontSpace;
+ mySprite = &theFont.sprites[fontInTable(c)];
+ burnSpriteToBackDrop(xOff, y, *mySprite, thePal);
+ xOff += mySprite->width + fontSpace;
}
}
@@ -167,26 +176,27 @@ bool loadFont(int filenum, const char *charOrder, int h) {
int a = 0;
uint32_t c;
- delete [] fontOrderString;
+ delete[] fontOrderString;
fontOrderString = copyString(charOrder);
forgetSpriteBank(theFont);
loadedFontNum = filenum;
-
fontTableSize = 0;
while (charOrder[a]) {
c = u8_nextchar(charOrder, &a);
- if (c > fontTableSize) fontTableSize = c;
+ if (c > fontTableSize)
+ fontTableSize = c;
}
fontTableSize++;
- delete [] fontTable;
- fontTable = new uint32_t [fontTableSize];
- if (! checkNew(fontTable)) return false;
+ delete[] fontTable;
+ fontTable = new uint32_t[fontTableSize];
+ if (!checkNew(fontTable))
+ return false;
- for (a = 0; a < fontTableSize; a ++) {
+ for (a = 0; a < fontTableSize; a++) {
fontTable[a] = 0;
}
a = 0;
@@ -197,7 +207,7 @@ bool loadFont(int filenum, const char *charOrder, int h) {
i++;
}
- if (! loadSpriteBank(filenum, theFont, true)) {
+ if (!loadSpriteBank(filenum, theFont, true)) {
fatal("Can't load font");
return false;
}
diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp
index 8435a9cd1d..7057f6e925 100644
--- a/engines/sludge/freeze.cpp
+++ b/engines/sludge/freeze.cpp
@@ -72,7 +72,7 @@ void freezeGraphics() {
#endif
int w = winWidth;
int h = winHeight;
- if (! NPOT_textures) {
+ if (!NPOT_textures) {
w = getNextPOT(winWidth);
h = getNextPOT(winHeight);
}
@@ -89,7 +89,6 @@ void freezeGraphics() {
int antiAlias = gameSettings.antiAlias;
gameSettings.antiAlias = 0;
-
int x = 0;
while (x < winWidth) {
int y = 0;
@@ -109,10 +108,10 @@ void freezeGraphics() {
}
#if 0
const GLfloat bPMVMatrix[] = {
- 2.0f / realWinWidth * cameraZoom, .0, .0, .0,
- .0, 2.0f / realWinHeight * cameraZoom, .0, .0,
- .0, .0, 1.0f, .0,
- -2.0f * (x / realWinWidth) - 1.0f, -2.0f * (y / realWinHeight) - 1.0f, .0, 1.0f
+ 2.0f / realWinWidth * cameraZoom, .0, .0, .0,
+ .0, 2.0f / realWinHeight * cameraZoom, .0, .0,
+ .0, .0, 1.0f, .0,
+ -2.0f * (x / realWinWidth) - 1.0f, -2.0f * (y / realWinHeight) - 1.0f, .0, 1.0f
};
for (int i = 0; i < 16; i++) {
@@ -120,19 +119,18 @@ void freezeGraphics() {
}
// Render scene
glDepthMask(GL_TRUE);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen
glDepthMask(GL_FALSE);
- drawBackDrop(); // Draw the room
+ drawBackDrop();// Draw the room
drawZBuffer(cameraX, cameraY, false);
glEnable(GL_DEPTH_TEST);
- drawPeople(); // Then add any moving characters...
+ drawPeople();// Then add any moving characters...
glDisable(GL_DEPTH_TEST);
-
// Copy Our ViewPort To The Texture
copyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, w, h, freezeTextureName);
#endif
@@ -152,7 +150,8 @@ void freezeGraphics() {
bool freeze() {
debugOut("calling freeze()\n");
frozenStuffStruct *newFreezer = new frozenStuffStruct;
- if (! checkNew(newFreezer)) return false;
+ if (!checkNew(newFreezer))
+ return false;
// Grab a copy of the current scene
freezeGraphics();
@@ -161,7 +160,7 @@ bool freeze() {
#endif
int picWidth = sceneWidth;
int picHeight = sceneHeight;
- if (! NPOT_textures) {
+ if (!NPOT_textures) {
picWidth = getNextPOT(picWidth);
picHeight = getNextPOT(picHeight);
}
@@ -173,11 +172,11 @@ bool freeze() {
backdropTextureName = 0;
#endif
- newFreezer -> sceneWidth = sceneWidth;
- newFreezer -> sceneHeight = sceneHeight;
- newFreezer -> cameraX = cameraX;
- newFreezer -> cameraY = cameraY;
- newFreezer -> cameraZoom = cameraZoom;
+ newFreezer->sceneWidth = sceneWidth;
+ newFreezer->sceneHeight = sceneHeight;
+ newFreezer->cameraX = cameraX;
+ newFreezer->cameraY = cameraY;
+ newFreezer->cameraZoom = cameraZoom;
#if 0
newFreezer -> lightMapTexture = lightMap.data;
newFreezer -> lightMapTextureName = lightMap.name;
@@ -192,9 +191,10 @@ bool freeze() {
zBuffer.tex = NULL;
#endif
// resizeBackdrop kills parallax stuff, light map, z-buffer...
- if (! resizeBackdrop(winWidth, winHeight)) return fatal("Can't create new temporary backdrop buffer");
+ if (!resizeBackdrop(winWidth, winHeight))
+ return fatal("Can't create new temporary backdrop buffer");
- if (! NPOT_textures) {
+ if (!NPOT_textures) {
picWidth = getNextPOT(sceneWidth);
picHeight = getNextPOT(sceneHeight);
#if 0
@@ -225,31 +225,33 @@ bool freeze() {
deleteTextures(1, &newFreezer -> backdropTextureName);
}
#endif
- newFreezer -> allPeople = allPeople;
+ newFreezer->allPeople = allPeople;
allPeople = NULL;
statusStuff *newStatusStuff = new statusStuff;
- if (! checkNew(newStatusStuff)) return false;
- newFreezer -> frozenStatus = copyStatusBarStuff(newStatusStuff);
+ if (!checkNew(newStatusStuff))
+ return false;
+ newFreezer->frozenStatus = copyStatusBarStuff(newStatusStuff);
- newFreezer -> allScreenRegions = allScreenRegions;
+ newFreezer->allScreenRegions = allScreenRegions;
allScreenRegions = NULL;
overRegion = NULL;
- newFreezer -> mouseCursorAnim = mouseCursorAnim;
- newFreezer -> mouseCursorFrameNum = mouseCursorFrameNum;
+ newFreezer->mouseCursorAnim = mouseCursorAnim;
+ newFreezer->mouseCursorFrameNum = mouseCursorFrameNum;
mouseCursorAnim = makeNullAnim();
mouseCursorFrameNum = 0;
- newFreezer -> speech = speech;
+ newFreezer->speech = speech;
initSpeech();
- newFreezer -> currentEvents = currentEvents;
+ newFreezer->currentEvents = currentEvents;
currentEvents = new eventHandlers;
- if (! checkNew(currentEvents)) return false;
+ if (!checkNew(currentEvents))
+ return false;
memset(currentEvents, 0, sizeof(eventHandlers));
- newFreezer -> next = frozenStuff;
+ newFreezer->next = frozenStuff;
frozenStuff = newFreezer;
return true;
@@ -259,8 +261,8 @@ int howFrozen() {
int a = 0;
frozenStuffStruct *f = frozenStuff;
while (f) {
- a ++;
- f = f -> next;
+ a++;
+ f = f->next;
}
return a;
}
@@ -272,25 +274,26 @@ extern GLubyte *backdropTexture;
void unfreeze(bool killImage) {
frozenStuffStruct *killMe = frozenStuff;
- if (! frozenStuff) return;
+ if (!frozenStuff)
+ return;
- sceneWidth = frozenStuff -> sceneWidth;
- sceneHeight = frozenStuff -> sceneHeight;
+ sceneWidth = frozenStuff->sceneWidth;
+ sceneHeight = frozenStuff->sceneHeight;
- cameraX = frozenStuff -> cameraX;
- cameraY = frozenStuff -> cameraY;
- input.mouseX = (int)(input.mouseX * cameraZoom);
- input.mouseY = (int)(input.mouseY * cameraZoom);
- cameraZoom = frozenStuff -> cameraZoom;
- input.mouseX = (int)(input.mouseX / cameraZoom);
- input.mouseY = (int)(input.mouseY / cameraZoom);
+ cameraX = frozenStuff->cameraX;
+ cameraY = frozenStuff->cameraY;
+ input.mouseX = (int) (input.mouseX * cameraZoom);
+ input.mouseY = (int) (input.mouseY * cameraZoom);
+ cameraZoom = frozenStuff->cameraZoom;
+ input.mouseX = (int) (input.mouseX / cameraZoom);
+ input.mouseY = (int) (input.mouseY / cameraZoom);
setPixelCoords(false);
killAllPeople();
- allPeople = frozenStuff -> allPeople;
+ allPeople = frozenStuff->allPeople;
killAllRegions();
- allScreenRegions = frozenStuff -> allScreenRegions;
+ allScreenRegions = frozenStuff->allScreenRegions;
killLightMap();
#if 0
@@ -346,18 +349,18 @@ void unfreeze(bool killImage) {
}
#endif
deleteAnim(mouseCursorAnim);
- mouseCursorAnim = frozenStuff -> mouseCursorAnim;
- mouseCursorFrameNum = frozenStuff -> mouseCursorFrameNum;
+ mouseCursorAnim = frozenStuff->mouseCursorAnim;
+ mouseCursorFrameNum = frozenStuff->mouseCursorFrameNum;
- restoreBarStuff(frozenStuff -> frozenStatus);
+ restoreBarStuff(frozenStuff->frozenStatus);
delete currentEvents;
- currentEvents = frozenStuff -> currentEvents;
+ currentEvents = frozenStuff->currentEvents;
killAllSpeech();
delete speech;
- speech = frozenStuff -> speech;
- frozenStuff = frozenStuff -> next;
+ speech = frozenStuff->speech;
+ frozenStuff = frozenStuff->next;
overRegion = NULL;
delete killMe;
diff --git a/engines/sludge/freeze.h b/engines/sludge/freeze.h
index a9f5129ba2..4472852217 100644
--- a/engines/sludge/freeze.h
+++ b/engines/sludge/freeze.h
@@ -48,7 +48,6 @@ struct frozenStuffStruct {
frozenStuffStruct *next;
};
-
bool freeze();
void unfreeze(bool killImage = true);
int howFrozen();
diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp
index 702865e9d4..7c7c7bec61 100644
--- a/engines/sludge/graphics.cpp
+++ b/engines/sludge/graphics.cpp
@@ -94,13 +94,13 @@ struct textureList *firstTexture = NULL;
textureList *addTexture() {
textureList *newTexture = new textureList;
- newTexture -> next = firstTexture;
+ newTexture->next = firstTexture;
firstTexture = newTexture;
return newTexture;
}
#if 0
-void deleteTextures(GLsizei n, const GLuint *textures) {
+void deleteTextures(GLsizei n, const GLuint *textures) {
if (firstTexture == NULL) {
//debugOut("Deleting texture while list is already empty.\n");
} else {
@@ -133,10 +133,10 @@ void deleteTextures(GLsizei n, const GLuint *textures) {
}
-void getTextureDimensions(GLuint name, GLint *width, GLint *height) {
+void getTextureDimensions(GLuint name, GLint *width, GLint *height) {
textureList *list = firstTexture;
while (list) {
- if (list->name == name) {
+ if (list->name == name) {
*width = list->width;
*height = list->height;
#if !defined(HAVE_GLES2)
@@ -156,7 +156,7 @@ void getTextureDimensions(GLuint name, GLint *width, GLint *height) {
fatal("Texture not found in list.\n");
}
-void storeTextureDimensions(GLuint name, GLsizei width, GLsizei height, const char *file, int line) {
+void storeTextureDimensions(GLuint name, GLsizei width, GLsizei height, const char *file, int line) {
if (! NPOT_textures && !(((height & (height - 1)) == 0) || ((width & (width - 1)) == 0))) {
debugOut("I was told to create a texture with dimensions %ix%i in %s @ line %d although NPOT textures are disabled.\n", width, height, file, line);
//height = getNextPOT(height);
@@ -165,7 +165,7 @@ void storeTextureDimensions(GLuint name, GLsizei width, GLsizei height, const c
textureList *list = firstTexture;
while (list) {
- if (list->name == name) {
+ if (list->name == name) {
//debugOut("Texture dimensions are overwritten.\n");
break;
}
@@ -182,14 +182,14 @@ void storeTextureDimensions(GLuint name, GLsizei width, GLsizei height, const c
#endif
#ifdef HAVE_GLES2
-void glesCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
+void glesCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
// Work around for broken glCopy(Sub)TexImage2D...
void *tmp = malloc(width * height * 4);
glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
glTexSubImage2D(target, level, xoffset, yoffset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
free(tmp);
}
-void glesCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
+void glesCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
// Work around for broken glCopy(Sub)TexImage2D...
void *tmp = malloc(width * height * 4);
glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
@@ -199,7 +199,7 @@ void glesCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GL
#endif
#if 0
-void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line) {
+void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line) {
glBindTexture(GL_TEXTURE_2D, name);
#ifdef HAVE_GLES2_
@@ -209,7 +209,7 @@ void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint
#endif
}
-void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line) {
+void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line) {
glBindTexture(GL_TEXTURE_2D, name);
#ifdef HAVE_GLES2_
glesCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
@@ -218,16 +218,16 @@ void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
#endif
}
-void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
- storeTextureDimensions(name, width, height, file, line);
+void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
+ storeTextureDimensions(name, width, height, file, line);
glBindTexture(GL_TEXTURE_2D, name);
- glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
+ glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
}
-void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
- storeTextureDimensions(name, width, height, file, line);
+void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
+ storeTextureDimensions(name, width, height, file, line);
glBindTexture(GL_TEXTURE_2D, name);
glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
}
@@ -289,7 +289,6 @@ void drawQuad(GLint program, const GLfloat *vertices, int numTexCoords, ...) {
}
-
void setPMVMatrix(GLint program) {
glUniformMatrix4fv(glGetUniformLocation(program, "myPMVMatrix"), 1, GL_FALSE, aPMVMatrix);
}
@@ -310,10 +309,10 @@ void setPixelCoords(bool pixels) {
glClear(GL_COLOR_BUFFER_BIT);
const GLfloat bPMVMatrix[] = {
- 2.0f / viewportWidth, .0, .0, .0,
- .0, 2.0f / viewportHeight, .0, .0,
- .0, .0, 1.0f, .0,
- -1.0, -1.0f, .0, 1.0f
+ 2.0f / viewportWidth, .0, .0, .0,
+ .0, 2.0f / viewportHeight, .0, .0,
+ .0, .0, 1.0f, .0,
+ -1.0, -1.0f, .0, 1.0f
};
for (int i = 0; i < 16; i++) {
@@ -332,10 +331,10 @@ void setPixelCoords(bool pixels) {
GLfloat h = (GLfloat) winHeight / cameraZoom;
const GLfloat bPMVMatrix[] = {
- 2.0f / w, .0, .0, .0,
- .0, -2.0f / h, .0, .0,
- .0, .0, 1.0f, .0,
- -1.0, 1.0f, .0, 1.0f
+ 2.0f / w, .0, .0, .0,
+ .0, -2.0f / h, .0, .0,
+ .0, .0, 1.0f, .0,
+ -1.0, 1.0f, .0, 1.0f
};
for (int i = 0; i < 16; i++) {
@@ -348,7 +347,6 @@ void setPixelCoords(bool pixels) {
int desktopW = 0, desktopH = 0;
bool runningFullscreen = false;
-
#if defined(HAVE_GLES2)
void saveTexture(GLuint tex, GLubyte *data) {
// use an FBO to easily grab the texture...
@@ -412,7 +410,7 @@ void saveTexture(GLuint tex, GLubyte *data) {
drawQuad(shader.texture, vertices, 1, texCoords);
glUseProgram(0);
- for (int i = 0; i < h; i++) {
+ for (int i = 0; i < h; i++) {
glReadPixels(viewportOffsetX, viewportOffsetY + i, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, data + xoffset * 4 + (yoffset + i) * 4 * tw);
}
@@ -607,13 +605,13 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Fragment = shaderFileRead("scale.frag");
#else
/* const GLubyte *str;
- int glDerivativesAvailable;
- str = glGetString (GL_EXTENSIONS);
- glDerivativesAvailable = (strstr((const char *)str, "GL_OES_standard_derivatives") != NULL);
- if (!glDerivativesAvailable) {
- debugOut("Extension \"GL_OES_standard_derivatives\" not available. Advanced anti-aliasing is not possible. Using linear anti-aliasing instead.");
- gameSettings.antiAlias = -1;
- */
+ int glDerivativesAvailable;
+ str = glGetString (GL_EXTENSIONS);
+ glDerivativesAvailable = (strstr((const char *)str, "GL_OES_standard_derivatives") != NULL);
+ if (!glDerivativesAvailable) {
+ debugOut("Extension \"GL_OES_standard_derivatives\" not available. Advanced anti-aliasing is not possible. Using linear anti-aliasing instead.");
+ gameSettings.antiAlias = -1;
+ */
Fragment = shaderFileRead("scale_noaa.frag");
// }
@@ -823,7 +821,6 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
}
}
-
reloadSpriteTextures();
reloadParallaxTextures();
zBuffer.texName = 0;
@@ -839,7 +836,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
}
if (movieIsPlaying)
- setMovieViewport();
+ setMovieViewport();
#endif
}
@@ -923,7 +920,6 @@ void setupOpenGLStuff() {
}
-
// I found this function on a coding forum on the 'net.
// Looks a bit weird, but it should work.
int getNextPOT(int n) {
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 24b7671464..493e6f1454 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -87,7 +87,8 @@ void setPMVMatrix(GLint program);
#endif
void setPixelCoords(bool pixels);
-void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true, bool resize = false);
+void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true,
+ bool resize = false);
void setupOpenGLStuff();
@@ -96,10 +97,10 @@ int getNextPOT(int n);
#if 0
void saveTexture(GLuint tex, GLubyte *data);
-void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line);
-void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line);
-void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
-void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
+void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line);
+void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line);
+void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
+void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
#define copyTexImage2D(target, level, internalformat, x, y, width, height, border, name) dcopyTexImage2D(target, level, internalformat, x, y, width,height, border, name, __FILE__, __LINE__)
@@ -109,14 +110,15 @@ void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
#define texSubImage2D( target, level, xoffset, yoffset, width, height, format, type, data,name) dtexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, data, name, __FILE__, __LINE__)
-void deleteTextures(GLsizei n, const GLuint *textures);
+void deleteTextures(GLsizei n, const GLuint *textures);
-void getTextureDimensions(GLuint name, GLint *width, GLint *height);
+void getTextureDimensions(GLuint name, GLint *width, GLint *height);
-int printOglError(const char *file, int line);
+int printOglError(const char *file, int line);
#define printOpenGLError() printOglError(__FILE__, __LINE__)
#endif
-} // End of namespace Sludge
+}
+ // End of namespace Sludge
#endif
diff --git a/engines/sludge/language.cpp b/engines/sludge/language.cpp
index 4fe27805b6..6bbb6d3882 100644
--- a/engines/sludge/language.cpp
+++ b/engines/sludge/language.cpp
@@ -44,9 +44,9 @@ unsigned int stringToInt(char *s) {
if (*s >= '0' && *s <= '9') {
i *= 10;
i += *s - '0';
- s ++;
+ s++;
} else if (*s == '-') {
- negative = ! negative;
+ negative = !negative;
s++;
} else {
if (negative)
@@ -56,7 +56,6 @@ unsigned int stringToInt(char *s) {
}
}
-
char *getPrefsFilename(char *filename) {
// Yes, this trashes the original string, but
// we also free it at the end (warning!)...
@@ -92,7 +91,8 @@ void readIniFile(char *filename) {
Common::File fd;
if (!fd.open(langName)) {
- debug(kSludgeDebugDataLoad, "Fail to open language file : %s", langName);
+ debug(kSludgeDebugDataLoad, "Fail to open language file : %s",
+ langName);
return;
}
@@ -127,7 +127,7 @@ void readIniFile(char *filename) {
if (strcmp(lineSoFar, "LANGUAGE") == 0) {
gameSettings.languageID = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "WINDOW") == 0) {
- gameSettings.userFullScreen = ! stringToInt(secondSoFar);
+ gameSettings.userFullScreen = !stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "REFRESH") == 0) {
gameSettings.refreshRate = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "ANTIALIAS") == 0) {
@@ -153,10 +153,10 @@ void readIniFile(char *filename) {
default:
if (doingSecond) {
- secondSoFar[here ++] = readChar;
+ secondSoFar[here++] = readChar;
secondSoFar[here] = 0;
} else {
- lineSoFar[here ++] = readChar;
+ lineSoFar[here++] = readChar;
lineSoFar[here] = 0;
}
break;
@@ -185,19 +185,23 @@ void saveIniFile(char *filename) {
void makeLanguageTable(Common::File *table) {
languageTable = new int[gameSettings.numLanguages + 1];
- if (! checkNew(languageTable)) return;
+ if (!checkNew(languageTable))
+ return;
languageName = new char *[gameSettings.numLanguages + 1];
- if (! checkNew(languageName)) return;
+ if (!checkNew(languageName))
+ return;
- for (unsigned int i = 0; i <= gameSettings.numLanguages; i ++) {
+ for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
languageTable[i] = i ? get2bytes(table) : 0;
- debug(kSludgeDebugDataLoad, "languageTable %i: %i", i, languageTable[i]);
+ debug(kSludgeDebugDataLoad, "languageTable %i: %i", i,
+ languageTable[i]);
languageName[i] = 0;
if (gameVersion >= VERSION(2, 0)) {
if (gameSettings.numLanguages) {
languageName[i] = readString(table);
- debug(kSludgeDebugDataLoad, "languageName %i: %s\n", i, languageName[i]);
+ debug(kSludgeDebugDataLoad, "languageName %i: %s\n", i,
+ languageName[i]);
}
}
}
@@ -206,8 +210,9 @@ void makeLanguageTable(Common::File *table) {
int getLanguageForFileB() {
int indexNum = -1;
- for (unsigned int i = 0; i <= gameSettings.numLanguages; i ++) {
- if (languageTable[i] == gameSettings.languageID) indexNum = i;
+ for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
+ if (languageTable[i] == gameSettings.languageID)
+ indexNum = i;
}
return indexNum;
diff --git a/engines/sludge/line.cpp b/engines/sludge/line.cpp
index bcb13437e3..1feba03756 100644
--- a/engines/sludge/line.cpp
+++ b/engines/sludge/line.cpp
@@ -37,10 +37,10 @@ void drawLine(int x1, int y1, int x2, int y2) {
int x, y;
bool backwards = false;
#if 0
- if (x1 < 0) x1 = 0;
- if (y1 < 0) y1 = 0;
- if (x2 < 0) x2 = 0;
- if (y2 < 0) y2 = 0;
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
if (x1 > sceneWidth) x1 = sceneWidth - 1;
if (x2 > sceneWidth) x2 = sceneWidth - 1;
if (y1 > sceneHeight) y1 = sceneHeight - 1;
@@ -69,10 +69,8 @@ void drawLine(int x1, int y1, int x2, int y2) {
}
setPixelCoords(true);
-
glLineWidth(2.0);
-
int xoffset = 0;
while (xoffset < diffX) {
int w = (diffX - xoffset < viewportWidth) ? diffX - xoffset : viewportWidth;
@@ -98,7 +96,6 @@ void drawLine(int x1, int y1, int x2, int y2) {
backdropTexW, backdropTexH
};
-
glUseProgram(shader.texture);
setPMVMatrix(shader.texture);
@@ -118,7 +115,6 @@ void drawLine(int x1, int y1, int x2, int y2) {
xo2, -yoffset + diffY, 0,
};
-
glUseProgram(shader.color);
setPMVMatrix(shader.color);
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index 959885f166..125e3183b6 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -78,7 +78,6 @@ extern parallaxLayer *parallaxStuff; // "
extern int lightMapMode; // "
extern int languageNum;
-
//----------------------------------------------------------------------
// Globals (so we know what's saved already and what's a reference
//----------------------------------------------------------------------
@@ -100,7 +99,7 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
variableStack *search = vs;
while (search) {
- elements ++;
+ elements++;
search = search->next;
}
@@ -114,7 +113,8 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
}
}
-variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **last) {
+variableStack *loadStack(Common::SeekableReadStream *stream,
+ variableStack **last) {
int elements = get2bytes(stream);
int a;
variableStack *first = NULL;
@@ -122,14 +122,15 @@ variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **las
for (a = 0; a < elements; ++a) {
variableStack *nS = new variableStack;
- if (!checkNew(nS)) return NULL;
+ if (!checkNew(nS))
+ return NULL;
loadVariable(&(nS->thisVar), stream);
if (last && a == elements - 1) {
stackDebug((stackfp, "Setting last to %p\n", nS));
*last = nS;
}
nS->next = NULL;
- (* changeMe) = nS;
+ (*changeMe) = nS;
changeMe = &(nS->next);
}
@@ -151,8 +152,9 @@ bool saveStackRef(stackHandler *vs, Common::WriteStream *stream) {
putch(0, stream);
saveStack(vs->first, stream);
s = new stackLibrary;
- stackLibTotal ++;
- if (! checkNew(s)) return false;
+ stackLibTotal++;
+ if (!checkNew(s))
+ return false;
s->next = stackLib;
s->stack = vs;
stackLib = s;
@@ -173,7 +175,7 @@ stackHandler *getStackFromLibrary(int n) {
n = stackLibTotal - n;
while (n) {
stackLib = stackLib->next;
- n --;
+ n--;
}
return stackLib->stack;
}
@@ -185,14 +187,15 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
stackDebug((stackfp, "loadStackRef (duplicate, get from library)\n"));
nsh = getStackFromLibrary(get2bytes(stream));
- nsh->timesUsed ++;
+ nsh->timesUsed++;
} else {
stackDebug((stackfp, "loadStackRef (new one)\n"));
// Load the new stack
nsh = new stackHandler;
- if (! checkNew(nsh)) return NULL;
+ if (!checkNew(nsh))
+ return NULL;
nsh->last = NULL;
nsh->first = loadStack(stream, &nsh->last);
nsh->timesUsed = 1;
@@ -206,11 +209,12 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
// Add it to the library of loaded stacks
stackLibrary *s = new stackLibrary;
- if (! checkNew(s)) return NULL;
+ if (!checkNew(s))
+ return NULL;
s->stack = nsh;
s->next = stackLib;
stackLib = s;
- stackLibTotal ++;
+ stackLibTotal++;
}
return nsh;
}
@@ -257,15 +261,14 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
default:
fatal("Can't save variables of this type:",
- (from->varType < SVT_NUM_TYPES) ?
- typeName[from->varType] :
- "bad ID");
+ (from->varType < SVT_NUM_TYPES) ?
+ typeName[from->varType] : "bad ID");
}
return true;
}
bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
- to->varType = (variableType)getch(stream);
+ to->varType = (variableType) getch(stream);
switch (to->varType) {
case SVT_INT:
case SVT_FUNC:
@@ -292,13 +295,15 @@ bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
case SVT_COSTUME:
to->varData.costumeHandler = new persona;
- if (! checkNew(to->varData.costumeHandler)) return false;
+ if (!checkNew(to->varData.costumeHandler))
+ return false;
loadCostume(to->varData.costumeHandler, stream);
return true;
case SVT_ANIM:
to->varData.animHandler = new personaAnimation;
- if (! checkNew(to->varData.animHandler)) return false;
+ if (!checkNew(to->varData.animHandler))
+ return false;
loadAnim(to->varData.animHandler, stream);
return true;
@@ -342,7 +347,8 @@ loadedFunction *loadFunction(Common::SeekableReadStream *stream) {
// Reserve memory...
loadedFunction *buildFunc = new loadedFunction;
- if (! checkNew(buildFunc)) return NULL;
+ if (!checkNew(buildFunc))
+ return NULL;
// See what it was called by and load if we need to...
@@ -350,7 +356,8 @@ loadedFunction *loadFunction(Common::SeekableReadStream *stream) {
buildFunc->calledBy = NULL;
if (getch(stream)) {
buildFunc->calledBy = loadFunction(stream);
- if (! buildFunc->calledBy) return NULL;
+ if (!buildFunc->calledBy)
+ return NULL;
}
buildFunc->timeLeft = get4bytes(stream);
@@ -396,7 +403,7 @@ bool saveGame(char *fname) {
fputc(allowAnyFilename, fp);
fputc(captureAllKeys, fp);
- fputc(true, fp); // updateDisplay
+ fputc(true, fp);// updateDisplay
fputc(fontTableSize > 0, fp);
if (fontTableSize > 0) {
@@ -515,7 +522,7 @@ bool loadGame(char *fname) {
}
if (savedGameTime.dwLowDateTime != fileTime.dwLowDateTime ||
- savedGameTime.dwHighDateTime != fileTime.dwHighDateTime) {
+ savedGameTime.dwHighDateTime != fileTime.dwHighDateTime) {
return fatal(ERROR_GAME_LOAD_WRONG, fname);
}
@@ -579,7 +586,6 @@ bool loadGame(char *fname) {
loadedFunction *rFunc;
loadedFunction * * buildList = &allRunningFunctions;
-
int countFunctions = get2bytes(fp);
while (countFunctions --) {
rFunc = loadFunction(fp);
@@ -595,7 +601,6 @@ bool loadGame(char *fname) {
loadPeople(fp);
-
if (fgetc(fp)) {
if (! setFloor(get2bytes(fp))) return false;
} else setFloorNull();
diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp
index 283a2282c1..8496a9b041 100644
--- a/engines/sludge/main_loop.cpp
+++ b/engines/sludge/main_loop.cpp
@@ -36,7 +36,6 @@
#include <iostream>
-
#include <stdexcept>
#include <time.h>
@@ -159,19 +158,19 @@ void checkInput() {
while (SDL_PollEvent(&event)) {
switch (event.type) {
- case SDL_VIDEORESIZE:
+ case SDL_VIDEORESIZE:
realWinWidth = event.resize.w;
realWinHeight = event.resize.h;
setGraphicsWindow(false, true, true);
break;
- case SDL_MOUSEMOTION:
+ case SDL_MOUSEMOTION:
input.justMoved = true;
input.mouseX = event.motion.x * ((float)winWidth / cameraZoom) / realWinWidth;
input.mouseY = event.motion.y * ((float)winHeight / cameraZoom) / realWinHeight;
break;
- case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT) {
if (SDL_GetModState() & KMOD_CTRL) {
input.rightClick = true;
@@ -186,7 +185,7 @@ void checkInput() {
input.mouseY = event.motion.y * ((float)winHeight / cameraZoom) / realWinHeight;
break;
- case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONUP:
if (event.button.button == SDL_BUTTON_LEFT) {
if (fakeRightclick) {
fakeRightclick = false;
@@ -200,7 +199,7 @@ void checkInput() {
input.mouseY = event.motion.y * ((float)winHeight / cameraZoom) / realWinHeight;
break;
- case SDL_KEYDOWN:
+ case SDL_KEYDOWN:
// A Windows key is pressed - let's leave fullscreen.
if (runningFullscreen) {
if (event.key.keysym.sym == SDLK_LSUPER || event.key.keysym.sym == SDLK_LSUPER) {
@@ -224,7 +223,7 @@ void checkInput() {
break;
}
// Allow Alt+F4 to quit
- if (SDLK_F4 == event.key.keysym.sym) {
+ if (SDLK_F4 == event.key.keysym.sym) {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
@@ -233,86 +232,86 @@ void checkInput() {
break;
}
switch (event.key.keysym.sym) {
- case SDLK_BACKSPACE:
- case SDLK_DELETE: // Ok, mapping these to the same key is weird, I admit. But good?
+ case SDLK_BACKSPACE:
+ case SDLK_DELETE: // Ok, mapping these to the same key is weird, I admit. But good?
input.keyPressed = 127;
break;
- case SDLK_TAB:
+ case SDLK_TAB:
input.keyPressed = 9;
break;
- case SDLK_RETURN:
+ case SDLK_RETURN:
input.keyPressed = 13;
break;
- case SDLK_ESCAPE:
+ case SDLK_ESCAPE:
input.keyPressed = 27;
break;
- case SDLK_PAGEUP:
+ case SDLK_PAGEUP:
input.keyPressed = 63276;
break;
- case SDLK_PAGEDOWN:
+ case SDLK_PAGEDOWN:
input.keyPressed = 63277;
break;
- case SDLK_END:
+ case SDLK_END:
input.keyPressed = 63275;
break;
- case SDLK_HOME:
+ case SDLK_HOME:
input.keyPressed = 63273;
break;
- case SDLK_LEFT:
+ case SDLK_LEFT:
input.keyPressed = 63234;
break;
- case SDLK_UP:
+ case SDLK_UP:
input.keyPressed = 63232;
break;
- case SDLK_RIGHT:
+ case SDLK_RIGHT:
input.keyPressed = 63235;
break;
- case SDLK_DOWN:
+ case SDLK_DOWN:
input.keyPressed = 63233;
break;
- case SDLK_F1:
+ case SDLK_F1:
input.keyPressed = 63236;
break;
- case SDLK_F2:
+ case SDLK_F2:
input.keyPressed = 63237;
break;
- case SDLK_F3:
+ case SDLK_F3:
input.keyPressed = 63238;
break;
- case SDLK_F4:
+ case SDLK_F4:
input.keyPressed = 63239;
break;
- case SDLK_F5:
+ case SDLK_F5:
input.keyPressed = 63240;
break;
- case SDLK_F6:
+ case SDLK_F6:
input.keyPressed = 63241;
break;
- case SDLK_F7:
+ case SDLK_F7:
input.keyPressed = 63242;
break;
- case SDLK_F8:
+ case SDLK_F8:
input.keyPressed = 63243;
break;
- case SDLK_F9:
+ case SDLK_F9:
input.keyPressed = 63244;
break;
- case SDLK_F10:
+ case SDLK_F10:
input.keyPressed = 63245;
break;
- case SDLK_F11:
+ case SDLK_F11:
input.keyPressed = 63246;
break;
- case SDLK_F12:
+ case SDLK_F12:
input.keyPressed = 63247;
break;
- default:
+ default:
input.keyPressed = event.key.keysym.unicode;
break;
}
break;
- case SDL_QUIT:
+ case SDL_QUIT:
if (reallyWantToQuit) {
// The game file has requested that we quit
weAreDoneSoQuit = 1;
@@ -326,7 +325,7 @@ void checkInput() {
}
break;
- default:
+ default:
break;
}
}
@@ -335,9 +334,9 @@ void checkInput() {
int main_loop(char *filename)
#if 0
-try
+ try
#endif
-{
+ {
/* Dimensions of our window. */
winWidth = 640;
winHeight = 480;
@@ -348,7 +347,6 @@ try
time_t t;
srand((unsigned) time(&t));
-
// bundleFolder is used to look for the game file
// and later to find the shader programs
#ifdef __APPLE__
@@ -392,11 +390,13 @@ try
// The player pressed cancel in the file selection dialogue,
// so we should quit now.
- if (!sludgeFile) return 0;
+ if (!sludgeFile)
+ return 0;
// OK, so we DO want to start up, then...
setGameFilePath(sludgeFile);
- if (!initSludge(sludgeFile)) return 0;
+ if (!initSludge(sludgeFile))
+ return 0;
#if 0
/* Initialize the SDL library */
@@ -430,12 +430,16 @@ try
registerWindowForFatal();
- if (!resizeBackdrop(winWidth, winHeight)) return fatal("Couldn't allocate memory for backdrop");
+ if (!resizeBackdrop(winWidth, winHeight))
+ return fatal("Couldn't allocate memory for backdrop");
blankScreen(0, 0, winWidth, winHeight);
- if (!initPeople()) return fatal("Couldn't initialise people stuff");
- if (!initFloor()) return fatal("Couldn't initialise floor stuff");
- if (!initObjectTypes()) return fatal("Couldn't initialise object type stuff");
+ if (!initPeople())
+ return fatal("Couldn't initialise people stuff");
+ if (!initFloor())
+ return fatal("Couldn't initialise floor stuff");
+ if (!initObjectTypes())
+ return fatal("Couldn't initialise object type stuff");
initSpeech();
initStatusBar();
resetRandW();
@@ -473,7 +477,9 @@ try
walkAllPeople();
handleInput();
sludgeDisplay();
- g_system->copyRectToScreen(backdropSurface.getPixels(), backdropSurface.pitch, 0, 0, backdropSurface.w, backdropSurface.h);
+ g_system->copyRectToScreen(backdropSurface.getPixels(),
+ backdropSurface.pitch, 0, 0, backdropSurface.w,
+ backdropSurface.h);
g_system->updateScreen();
#if 0
Wait_Frame();
@@ -509,4 +515,5 @@ catch (std::exception &ex) { //NOTE by reference, not value
}
#endif
-} // End of namespace Sludge
+}
+ // End of namespace Sludge
diff --git a/engines/sludge/memwatch.cpp b/engines/sludge/memwatch.cpp
index 34e860574d..f9148c5408 100644
--- a/engines/sludge/memwatch.cpp
+++ b/engines/sludge/memwatch.cpp
@@ -43,7 +43,7 @@ void outputKnownMem() {
void adding(void *mem) {
allKnownMem[allKnownNum] = mem;
- allKnownNum ++;
+ allKnownNum++;
outputKnownMem();
if (allKnownNum == 3000) {
@@ -55,8 +55,8 @@ void adding(void *mem) {
}
void deleting(void *mem) {
- allKnownNum --;
- for (int i = 0; i <= allKnownNum; i ++) {
+ allKnownNum--;
+ for (int i = 0; i <= allKnownNum; i++) {
if (allKnownMem[i] == mem) {
allKnownMem[i] = allKnownMem[allKnownNum];
outputKnownMem();
diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp
index 8bb0d77a67..754f22c46a 100644
--- a/engines/sludge/moreio.cpp
+++ b/engines/sludge/moreio.cpp
@@ -58,8 +58,8 @@ int get2bytes(Common::SeekableReadStream *stream) {
}
void put2bytes(int numtoput, Common::WriteStream *stream) {
- putch((char)(numtoput / 256), stream);
- putch((char)(numtoput % 256), stream);
+ putch((char) (numtoput / 256), stream);
+ putch((char) (numtoput % 256), stream);
}
void writeString(char *s, Common::WriteStream *stream) {
@@ -70,7 +70,6 @@ void writeString(char *s, Common::WriteStream *stream) {
}
}
-
char *readString(Common::SeekableReadStream *stream) {
int a, len = get2bytes(stream);
char *s = new char[len + 1];
@@ -78,7 +77,7 @@ char *readString(Common::SeekableReadStream *stream) {
return NULL;
}
for (a = 0; a < len; ++a) {
- s[a] = (char)(getch(stream) - 1);
+ s[a] = (char) (getch(stream) - 1);
}
s[len] = 0;
debug(kSludgeDebugDataLoad, "Read string of length %i: %s", len, s);
@@ -99,11 +98,10 @@ float floatSwap(float f) {
return dat2.f;
}
-
float getFloat(Common::SeekableReadStream *stream) {
float f;
size_t bytes_read = stream->read(&f, sizeof(float));
- //fread(& f, sizeof(float), 1, fp);
+ //fread(& f, sizeof(float), 1, fp);
if (bytes_read != sizeof(float) && stream->err()) {
debug("Reading error in getFloat.\n");
}
@@ -119,7 +117,7 @@ void putFloat(float f, Common::WriteStream *stream) {
#ifdef __BIG_ENDIAN__
f = floatSwap(f);
#endif
- stream->write(&f,sizeof(float));
+ stream->write(&f, sizeof(float));
//fwrite(& f, sizeof(float), 1, fp);
}
@@ -132,7 +130,6 @@ short shortSwap(short s) {
return (b1 << 8) + b2;
}
-
short getSigned(Common::SeekableReadStream *stream) {
short f;
size_t bytes_read = stream->read(&f, sizeof(short));
@@ -152,7 +149,6 @@ void putSigned(short f, Common::WriteStream *stream) {
stream->write(&f, sizeof(short));
}
-
// The following two functions treat signed integers as unsigned.
// That's done on purpose.
@@ -169,7 +165,6 @@ int32_t get4bytes(Common::SeekableReadStream *stream) {
return x;
}
-
void put4bytes(unsigned int i, Common::WriteStream *stream) {
unsigned char f1, f2, f3, f4;
@@ -187,10 +182,12 @@ void put4bytes(unsigned int i, Common::WriteStream *stream) {
}
char *encodeFilename(char *nameIn) {
- if (!nameIn) return NULL;
+ if (!nameIn)
+ return NULL;
if (allowAnyFilename) {
char *newName = new char[strlen(nameIn) * 2 + 1];
- if (!checkNew(newName)) return NULL;
+ if (!checkNew(newName))
+ return NULL;
int i = 0;
while (*nameIn) {
@@ -241,7 +238,7 @@ char *encodeFilename(char *nameIn) {
break;
}
newName[i] = 0;
- nameIn ++;
+ nameIn++;
}
return newName;
} else {
@@ -250,7 +247,8 @@ char *encodeFilename(char *nameIn) {
#ifdef _WIN32
if (nameIn[a] == '/') nameIn[a] = '\\';
#else
- if (nameIn[a] == '\\') nameIn[a] = '/';
+ if (nameIn[a] == '\\')
+ nameIn[a] = '/';
#endif
}
@@ -261,61 +259,62 @@ char *encodeFilename(char *nameIn) {
char *decodeFilename(char *nameIn) {
if (allowAnyFilename) {
char *newName = new char[strlen(nameIn) + 1];
- if (!checkNew(newName)) return NULL;
+ if (!checkNew(newName))
+ return NULL;
int i = 0;
- while (* nameIn) {
- if (* nameIn == '_') {
- nameIn ++;
- switch (* nameIn) {
+ while (*nameIn) {
+ if (*nameIn == '_') {
+ nameIn++;
+ switch (*nameIn) {
case 'L':
newName[i] = '<';
- nameIn ++;
+ nameIn++;
break;
case 'G':
newName[i] = '>';
- nameIn ++;
+ nameIn++;
break;
case 'P':
newName[i] = '|';
- nameIn ++;
+ nameIn++;
break;
case 'U':
newName[i] = '_';
- nameIn ++;
+ nameIn++;
break;
case 'S':
newName[i] = '\"';
- nameIn ++;
+ nameIn++;
break;
case 'B':
newName[i] = '\\';
- nameIn ++;
+ nameIn++;
break;
case 'F':
newName[i] = '/';
- nameIn ++;
+ nameIn++;
break;
case 'C':
newName[i] = ':';
- nameIn ++;
+ nameIn++;
break;
case 'A':
newName[i] = '*';
- nameIn ++;
+ nameIn++;
break;
case 'Q':
newName[i] = '?';
- nameIn ++;
+ nameIn++;
break;
default:
newName[i] = '_';
}
} else {
newName[i] = *nameIn;
- nameIn ++;
+ nameIn++;
}
- i ++;
+ i++;
}
newName[i] = 0;
diff --git a/engines/sludge/movie.cpp b/engines/sludge/movie.cpp
index 3f02f736d7..cd4ef1bcf8 100644
--- a/engines/sludge/movie.cpp
+++ b/engines/sludge/movie.cpp
@@ -71,7 +71,7 @@ bool handleInput();
void playMovieStream(int a);
#if 0
int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate,
- ALuint(*callback)(void *userdata, ALubyte *data, ALuint bytes));
+ ALuint(*callback)(void *userdata, ALubyte *data, ALuint bytes));
#endif
movieStates movieIsPlaying = nothing;
@@ -85,14 +85,14 @@ typedef struct audioBuffers {
unsigned int size;
audioBuffers *next;
Uint32 time_ms;
-} audioBuffers;
+}audioBuffers;
typedef struct audioQueue {
audioBuffers *first, *last;
int size;
SDL_mutex *mutex;
SDL_cond *cond;
-} audioQueue;
+}audioQueue;
audioQueue audioQ;
@@ -115,18 +115,17 @@ typedef struct videoBuffers {
videoBuffers *next;
GLsizei w, h;
Uint32 time_ms;
-} videoBuffers;
+}videoBuffers;
typedef struct videoQueue {
videoBuffers *first, *last;
int size;
SDL_mutex *mutex;
SDL_cond *cond;
-} videoQueue;
+}videoQueue;
videoQueue videoQ;
-
void audio_queue_init(audioQueue *q) {
memset(q, 0, sizeof(audioQueue));
@@ -138,7 +137,7 @@ int audio_queue_put(audioQueue *q, char *buffer, unsigned int size, long long ti
audioBuffers *audioBuf = new audioBuffers;
if (!audioBuf)
- return -1;
+ return -1;
audioBuf->buffer = buffer;
audioBuf->next = NULL;
audioBuf->size = size;
@@ -147,9 +146,9 @@ int audio_queue_put(audioQueue *q, char *buffer, unsigned int size, long long ti
SDL_LockMutex(q->mutex);
if (!q->last)
- q->first = audioBuf;
+ q->first = audioBuf;
else
- q->last->next = audioBuf;
+ q->last->next = audioBuf;
q->last = audioBuf;
q->size ++;
SDL_CondSignal(q->cond);
@@ -161,7 +160,6 @@ int audio_queue_put(audioQueue *q, char *buffer, unsigned int size, long long ti
inline static int audio_queue_get(audioQueue *q, char **buffer) {
int ret = 0;
-
audioBuffers *audioBuf;
SDL_LockMutex(q->mutex);
@@ -176,7 +174,7 @@ inline static int audio_queue_get(audioQueue *q, char **buffer) {
q->first = audioBuf->next;
if (!q->first)
- q->last = NULL;
+ q->last = NULL;
q->size--;
*buffer = audioBuf->buffer;
ret = audioBuf->size;
@@ -194,14 +192,14 @@ void video_queue_init(videoQueue *q) {
q->cond = SDL_CreateCond();
}
int video_queue_put(videoQueue *q, GLubyte *ytex,
- GLubyte *utex,
- GLubyte *vtex,
- GLsizei w, GLsizei h,
- long long time_ms) {
+ GLubyte *utex,
+ GLubyte *vtex,
+ GLsizei w, GLsizei h,
+ long long time_ms) {
videoBuffers *videoBuf = new videoBuffers;
if (!videoBuf)
- return -1;
+ return -1;
videoBuf->ytex = ytex;
videoBuf->utex = utex;
videoBuf->vtex = vtex;
@@ -213,9 +211,9 @@ int video_queue_put(videoQueue *q, GLubyte *ytex,
SDL_LockMutex(q->mutex);
if (!q->last)
- q->first = videoBuf;
+ q->first = videoBuf;
else
- q->last->next = videoBuf;
+ q->last->next = videoBuf;
q->last = videoBuf;
q->size ++;
SDL_CondSignal(q->cond);
@@ -224,10 +222,10 @@ int video_queue_put(videoQueue *q, GLubyte *ytex,
return 0;
}
inline static int video_queue_get(videoQueue *q,
- GLubyte **ytex,
- GLubyte **utex,
- GLubyte **vtex,
- GLsizei *w, GLsizei *h) {
+ GLubyte **ytex,
+ GLubyte **utex,
+ GLubyte **vtex,
+ GLsizei *w, GLsizei *h) {
videoBuffers *videoBuf;
int ret = 0;
@@ -237,7 +235,7 @@ inline static int video_queue_get(videoQueue *q,
if (videoBuf) {
q->first = videoBuf->next;
if (!q->first)
- q->last = NULL;
+ q->last = NULL;
q->size--;
*ytex = videoBuf->ytex;
*utex = videoBuf->utex;
@@ -279,10 +277,10 @@ void setMovieViewport() {
glViewport(vpOffsetX, vpOffsetY, vpWidth, vpHeight);
#endif
const GLfloat bPMVMatrix[] = {
- 2.0f / 640.f, .0, .0, .0,
- .0, -2.0f / 400.f, .0, .0,
- .0, .0, 1.0f, .0,
- -1.0, 1.0f, .0, 1.0f
+ 2.0f / 640.f, .0, .0, .0,
+ .0, -2.0f / 400.f, .0, .0,
+ .0, .0, 1.0f, .0,
+ -1.0, 1.0f, .0, 1.0f
};
for (int i = 0; i < 16; i++) {
@@ -341,9 +339,9 @@ ALuint feedAudio(void *userdata, ALubyte *data, ALuint length) {
fakeAudio = false;
if (length > bufSize - bufOffset)
- bufLen = bufSize - bufOffset;
+ bufLen = bufSize - bufOffset;
else
- bufLen = length;
+ bufLen = length;
memcpy(data, buffer + bufOffset, bufLen);
@@ -364,13 +362,13 @@ ALuint feedAudio(void *userdata, ALubyte *data, ALuint length) {
int playMovie(int fileNumber) {
#if 0
if (specialSettings & SPECIAL_SILENT)
- return 0;
+ return 0;
if (movieIsPlaying) return 0;
movieSoundPlaying = false;
- vpx_codec_ctx_t codec;
+ vpx_codec_ctx_t codec;
float pausefade = 1.0;
@@ -396,7 +394,7 @@ int playMovie(int fileNumber) {
fatal("Movie error: Segment::CreateInstance() failed.\n");
}
- ret = pSegment->Load();
+ ret = pSegment->Load();
if (ret < 0) {
fatal("Movie error: Segment::Load() failed.\n");
}
@@ -413,7 +411,7 @@ int playMovie(int fileNumber) {
unsigned long i = 0;
const unsigned long j = pTracks->GetTracksCount();
- enum { VIDEO_TRACK = 1, AUDIO_TRACK = 2 };
+ enum {VIDEO_TRACK = 1, AUDIO_TRACK = 2};
int videoTrack = -1;
int audioTrack = -1;
long long audioBitDepth;
@@ -427,7 +425,7 @@ int playMovie(int fileNumber) {
const Track *const pTrack = pTracks->GetTrackByIndex(i++);
if (pTrack == NULL)
- continue;
+ continue;
const long long trackType = pTrack->GetType();
//const unsigned long long trackUid = pTrack->GetUid();
@@ -436,15 +434,15 @@ int playMovie(int fileNumber) {
if (trackType == VIDEO_TRACK && videoTrack < 0) {
videoTrack = pTrack->GetNumber();
const VideoTrack *const pVideoTrack =
- static_cast<const VideoTrack *>(pTrack);
+ static_cast<const VideoTrack *>(pTrack);
- const long long width = pVideoTrack->GetWidth();
+ const long long width = pVideoTrack->GetWidth();
const long long height = pVideoTrack->GetHeight();
const double rate = pVideoTrack->GetFrameRate();
if (rate > 0)
- Init_Special_Timer(rate);
+ Init_Special_Timer(rate);
movieAspect = (float)width / height;
}
@@ -452,9 +450,9 @@ int playMovie(int fileNumber) {
if (trackType == AUDIO_TRACK && audioTrack < 0) {
audioTrack = pTrack->GetNumber();
const AudioTrack *const pAudioTrack =
- static_cast<const AudioTrack *>(pTrack);
+ static_cast<const AudioTrack *>(pTrack);
- audioChannels = pAudioTrack->GetChannels();
+ audioChannels = pAudioTrack->GetChannels();
audioBitDepth = pAudioTrack->GetBitDepth();
audioSampleRate = pAudioTrack->GetSamplingRate();
@@ -503,17 +501,17 @@ int playMovie(int fileNumber) {
oggPacket.b_o_s = oggPacket.packetno == 0;
r = vorbis_synthesis_headerin(&vorbisInfo, &vorbisComment, &oggPacket);
if (r)
- fprintf(stderr, "vorbis_synthesis_headerin failed, error: %d", r);
+ fprintf(stderr, "vorbis_synthesis_headerin failed, error: %d", r);
oggPacket.packetno++;
p += sizes[i];
}
r = vorbis_synthesis_init(&vorbisDspState, &vorbisInfo);
if (r)
- fprintf(stderr, "vorbis_synthesis_init failed, error: %d", r);
+ fprintf(stderr, "vorbis_synthesis_init failed, error: %d", r);
r = vorbis_block_init(&vorbisDspState, &vorbisBlock);
if (r)
- fprintf(stderr, "vorbis_block_init failed, error: %d", r);
+ fprintf(stderr, "vorbis_block_init failed, error: %d", r);
ALenum audioFormat = alureGetSampleFormat(audioChannels, 16, 0);
movieAudioIndex = initMovieSound(fileNumber, audioFormat, audioChannels, (ALuint) audioSampleRate, feedAudio);
@@ -527,10 +525,10 @@ int playMovie(int fileNumber) {
}
if (videoTrack < 0)
- fatal("Movie error: No video in movie file.");
+ fatal("Movie error: No video in movie file.");
if (audioTrack < 0)
- fatal("Movie error: No sound found.");
+ fatal("Movie error: No sound found.");
video_queue_init(&videoQ);
@@ -540,11 +538,9 @@ int playMovie(int fileNumber) {
fatal("Movie error: Segment has no clusters.\n");
}
-
/* Initialize video codec */
if (vpx_codec_dec_init(&codec, interface, NULL, 0))
- die_codec(&codec, "Failed to initialize decoder for movie.");
-
+ die_codec(&codec, "Failed to initialize decoder for movie.");
unsigned char *frame = new unsigned char[256 * 1024];
if (! checkNew(frame)) return false;
@@ -571,7 +567,7 @@ int playMovie(int fileNumber) {
}
pBlockEntry = pCluster->GetFirst();
}
- const Block *pBlock = pBlockEntry->GetBlock();
+ const Block *pBlock = pBlockEntry->GetBlock();
long long trackNum = pBlock->GetTrackNumber();
unsigned long tn = static_cast<unsigned long>(trackNum);
const Track *pTrack = pTracks->GetTrackByNumber(tn);
@@ -634,7 +630,7 @@ int playMovie(int fileNumber) {
checkInput();
if (weAreDoneSoQuit)
- break;
+ break;
handleInput();
if (movieIsPlaying && (! movieIsEnding) && (videoQ.size < 100 || audioQ.size < 100)) {
@@ -652,7 +648,7 @@ int playMovie(int fileNumber) {
}
pBlockEntry = pCluster->GetFirst();
}
- pBlock = pBlockEntry->GetBlock();
+ pBlock = pBlockEntry->GetBlock();
trackNum = pBlock->GetTrackNumber();
tn = static_cast<unsigned long>(trackNum);
pTrack = pTracks->GetTrackByNumber(tn);
@@ -673,28 +669,27 @@ int playMovie(int fileNumber) {
if (! checkNew(frame)) return 0;
}
/*
- fprintf (stderr, "Block :%s,%s,%15lld\n",
- (trackType == VIDEO_TRACK) ? "V" : "A",
- pBlock->IsKey() ? "I" : "P",
- time_ns);
+ fprintf (stderr, "Block :%s,%s,%15lld\n",
+ (trackType == VIDEO_TRACK) ? "V" : "A",
+ pBlock->IsKey() ? "I" : "P",
+ time_ns);
*/
if (trackNum == videoTrack) {
theFrame.Read(&reader, frame);
-
/* Decode the frame */
if (vpx_codec_decode(&codec, frame, size, NULL, 0))
- die_codec(&codec, "Failed to decode frame");
+ die_codec(&codec, "Failed to decode frame");
// Let's decode an image frame!
- vpx_codec_iter_t iter = NULL;
- vpx_image_t *img;
+ vpx_codec_iter_t iter = NULL;
+ vpx_image_t *img;
/* Get frame data */
while ((img = vpx_codec_get_frame(&codec, &iter))) {
if (img->fmt != VPX_IMG_FMT_I420)
- fatal("Movie error. The movie is not in I420 colour format, which is the only one I can hanlde at the moment.");
+ fatal("Movie error. The movie is not in I420 colour format, which is the only one I can hanlde at the moment.");
unsigned int y;
@@ -707,7 +702,7 @@ int playMovie(int fileNumber) {
utex = new GLubyte [(img->d_w >> 1) * (img->d_h >> 1)];
vtex = new GLubyte [(img->d_w >> 1) * (img->d_h >> 1)];
if (!ytex || !utex || !vtex)
- fatal(ERROR_OUT_OF_MEMORY);
+ fatal(ERROR_OUT_OF_MEMORY);
}
@@ -728,8 +723,7 @@ int playMovie(int fileNumber) {
}
video_queue_put(&videoQ, ytex, utex, vtex,
- img->d_w, img->d_h, time_ns / 1000000);
-
+ img->d_w, img->d_h, time_ns / 1000000);
}
@@ -744,7 +738,7 @@ int playMovie(int fileNumber) {
oggPacket.granulepos = -1;
if (! vorbis_synthesis(&vorbisBlock, &oggPacket)) {
if (vorbis_synthesis_blockin(&vorbisDspState, &vorbisBlock))
- fprintf(stderr, "Vorbis Synthesis block in error.\n");
+ fprintf(stderr, "Vorbis Synthesis block in error.\n");
} else {
fprintf(stderr, "Vorbis Synthesis error.\n");
@@ -771,12 +765,12 @@ int playMovie(int fileNumber) {
int off = (sgned ? 0 : 128);
vorbis_fpu_setround(&fpu);
for (j = 0; j < numSamples; j++)
- for (i = 0; i < audioChannels; i++) {
- val = vorbis_ftoi(pcm[i][j] * 128.f);
- if (val > 127)val = 127;
- else if (val < -128)val = -128;
- *buffer++ = val + off;
- }
+ for (i = 0; i < audioChannels; i++) {
+ val = vorbis_ftoi(pcm[i][j] * 128.f);
+ if (val > 127)val = 127;
+ else if (val < -128)val = -128;
+ *buffer++ = val + off;
+ }
vorbis_fpu_restore(fpu);
} else {
int off = (sgned ? 0 : 32768);
@@ -835,7 +829,7 @@ int playMovie(int fileNumber) {
++frameCounter;
} else {
-movieHasEnded:
+ movieHasEnded:
movieIsEnding = 1;
}
}
@@ -865,30 +859,29 @@ movieHasEnded:
if (! vTextureName) glGenTextures(1, &vTextureName);
glBindTexture(GL_TEXTURE_2D, yTextureName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, ytex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, ytex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, uTextureName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w >> 1, h >> 1, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, utex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, utex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, vTextureName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w >> 1, h >> 1, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, vtex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, vtex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-
glBindTexture(GL_TEXTURE_2D, yTextureName);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
- GL_ALPHA, GL_UNSIGNED_BYTE, ytex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, ytex);
glBindTexture(GL_TEXTURE_2D, uTextureName);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w >> 1, h >> 1,
- GL_ALPHA, GL_UNSIGNED_BYTE, utex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, utex);
glBindTexture(GL_TEXTURE_2D, vTextureName);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w >> 1, h >> 1,
- GL_ALPHA, GL_UNSIGNED_BYTE, vtex);
+ GL_ALPHA, GL_UNSIGNED_BYTE, vtex);
delete [] ytex;
delete [] utex;
@@ -946,7 +939,6 @@ movieHasEnded:
glUseProgram(0);
-
glDisable(GL_BLEND);
Wait_Frame();
@@ -971,10 +963,8 @@ movieHasEnded:
for (int i = 0; i < 10; i++) Wait_Frame();
huntKillFreeSound(fileNumber);
-
if (vpx_codec_destroy(&codec))
- die_codec(&codec, "Failed to destroy codec");
-
+ die_codec(&codec, "Failed to destroy codec");
vorbis_dsp_clear(&vorbisDspState);
vorbis_block_clear(&vorbisBlock);
diff --git a/engines/sludge/movie.h b/engines/sludge/movie.h
index 100439a95d..c34322f9bc 100644
--- a/engines/sludge/movie.h
+++ b/engines/sludge/movie.h
@@ -28,9 +28,7 @@ namespace Sludge {
movieIsPlaying tracks the state of movie playing
*/
enum movieStates {
- nothing = 0,
- playing,
- paused
+ nothing = 0, playing, paused
};
extern movieStates movieIsPlaying;
diff --git a/engines/sludge/newfatal.cpp b/engines/sludge/newfatal.cpp
index 5c8a36db36..477a7f9673 100644
--- a/engines/sludge/newfatal.cpp
+++ b/engines/sludge/newfatal.cpp
@@ -41,7 +41,9 @@ namespace Sludge {
const char emergencyMemoryMessage[] = "Out of memory displaying error message!";
static char *fatalMessage = NULL;
-static char *fatalInfo = joinStrings("Initialisation error! Something went wrong before we even got started!", "");
+static char *fatalInfo =
+ joinStrings("Initialisation error! Something went wrong before we even got started!",
+ "");
extern int numResourceNames /* = 0*/;
extern char * *allResourceNames /*= NULL*/;
@@ -49,14 +51,18 @@ extern char * *allResourceNames /*= NULL*/;
int resourceForFatal = -1;
const char *resourceNameFromNum(int i) {
- if (i == -1) return NULL;
- if (numResourceNames == 0) return "RESOURCE";
- if (i < numResourceNames) return allResourceNames[i];
+ if (i == -1)
+ return NULL;
+ if (numResourceNames == 0)
+ return "RESOURCE";
+ if (i < numResourceNames)
+ return allResourceNames[i];
return "Unknown resource";
}
bool hasFatal() {
- if (fatalMessage) return true;
+ if (fatalMessage)
+ return true;
return false;
}
@@ -77,7 +83,10 @@ void warning(const char *l) {
void registerWindowForFatal() {
delete fatalInfo;
- fatalInfo = joinStrings("There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.", "");
+ fatalInfo =
+ joinStrings(
+ "There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.",
+ "");
}
#if 0
@@ -93,8 +102,8 @@ int inFatal(const char *str) {
}
#endif
fatalMessage = copyString(str);
- if (fatalMessage == NULL) fatalMessage = copyString("Out of memory");
-
+ if (fatalMessage == NULL)
+ fatalMessage = copyString("Out of memory");
killSoundStuff();
@@ -120,8 +129,10 @@ int checkNew(const void *mem) {
void setFatalInfo(const char *userFunc, const char *BIF) {
delete fatalInfo;
- fatalInfo = new char [strlen(userFunc) + strlen(BIF) + 38];
- if (fatalInfo) sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc, BIF);
+ fatalInfo = new char[strlen(userFunc) + strlen(BIF) + 38];
+ if (fatalInfo)
+ sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc,
+ BIF);
debug("%s", fatalInfo);
}
@@ -132,17 +143,20 @@ void setResourceForFatal(int n) {
int fatal(const char *str1) {
if (numResourceNames && resourceForFatal != -1) {
const char *r = resourceNameFromNum(resourceForFatal);
- char *newStr = new char[strlen(str1) + strlen(r) + strlen(fatalInfo) + 14];
+ char *newStr = new char[strlen(str1) + strlen(r) + strlen(fatalInfo)
+ + 14];
if (checkNew(newStr)) {
sprintf(newStr, "%s\nResource: %s\n\n%s", fatalInfo, r, str1);
inFatal(newStr);
- } else fatal(emergencyMemoryMessage);
+ } else
+ fatal(emergencyMemoryMessage);
} else {
char *newStr = new char[strlen(str1) + strlen(fatalInfo) + 3];
if (checkNew(newStr)) {
sprintf(newStr, "%s\n\n%s", fatalInfo, str1);
inFatal(newStr);
- } else fatal(emergencyMemoryMessage);
+ } else
+ fatal(emergencyMemoryMessage);
}
return 0;
}
@@ -152,7 +166,8 @@ int fatal(const char *str1, const char *str2) {
if (checkNew(newStr)) {
sprintf(newStr, "%s %s", str1, str2);
fatal(newStr);
- } else fatal(emergencyMemoryMessage);
+ } else
+ fatal(emergencyMemoryMessage);
return 0;
}
diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp
index ba709777b4..5f82fb0281 100644
--- a/engines/sludge/objtypes.cpp
+++ b/engines/sludge/objtypes.cpp
@@ -42,8 +42,9 @@ objectType *findObjectType(int i) {
objectType *huntType = allObjectTypes;
while (huntType) {
- if (huntType -> objectNum == i) return huntType;
- huntType = huntType -> next;
+ if (huntType->objectNum == i)
+ return huntType;
+ huntType = huntType->next;
}
return loadObjectType(i);
@@ -56,13 +57,13 @@ objectType *loadObjectType(int i) {
if (checkNew(newType)) {
if (openObjectSlice(i)) {
nameNum = get2bytes(bigDataFile);
- newType -> r = (byte) getch(bigDataFile);
- newType -> g = (byte) getch(bigDataFile);
- newType -> b = (byte) getch(bigDataFile);
- newType -> speechGap = getch(bigDataFile);
- newType -> walkSpeed = getch(bigDataFile);
- newType -> wrapSpeech = get4bytes(bigDataFile);
- newType -> spinSpeed = get2bytes(bigDataFile);
+ newType->r = (byte) getch(bigDataFile);
+ newType->g = (byte) getch(bigDataFile);
+ newType->b = (byte) getch(bigDataFile);
+ newType->speechGap = getch(bigDataFile);
+ newType->walkSpeed = getch(bigDataFile);
+ newType->wrapSpeech = get4bytes(bigDataFile);
+ newType->spinSpeed = get2bytes(bigDataFile);
if (gameVersion >= VERSION(1, 6)) {
// aaLoad
@@ -72,13 +73,14 @@ objectType *loadObjectType(int i) {
}
if (gameVersion >= VERSION(1, 4)) {
- newType -> flags = get2bytes(bigDataFile);
+ newType->flags = get2bytes(bigDataFile);
} else {
- newType -> flags = 0;
+ newType->flags = 0;
}
- newType -> numCom = get2bytes(bigDataFile);
- newType -> allCombis = (newType -> numCom) ? new combination[newType -> numCom] : NULL;
+ newType->numCom = get2bytes(bigDataFile);
+ newType->allCombis =
+ (newType->numCom) ? new combination[newType->numCom] : NULL;
#if DEBUG_COMBINATIONS
FILE *callEventLog = fopen("callEventLog.txt", "at");
@@ -87,9 +89,9 @@ objectType *loadObjectType(int i) {
}
#endif
- for (a = 0; a < newType -> numCom; a ++) {
- newType -> allCombis[a].withObj = get2bytes(bigDataFile);
- newType -> allCombis[a].funcNum = get2bytes(bigDataFile);
+ for (a = 0; a < newType->numCom; a++) {
+ newType->allCombis[a].withObj = get2bytes(bigDataFile);
+ newType->allCombis[a].funcNum = get2bytes(bigDataFile);
#if DEBUG_COMBINATIONS
if (callEventLog) {
fprintf(callEventLog, "%d(%d) ", newType -> allCombis[a].withObj, newType -> allCombis[a].funcNum);
@@ -103,9 +105,9 @@ objectType *loadObjectType(int i) {
}
#endif
finishAccess();
- newType -> screenName = getNumberedString(nameNum);
- newType -> objectNum = i;
- newType -> next = allObjectTypes;
+ newType->screenName = getNumberedString(nameNum);
+ newType->objectNum = i;
+ newType->next = allObjectTypes;
allObjectTypes = newType;
return newType;
}
@@ -116,14 +118,14 @@ objectType *loadObjectType(int i) {
objectType *loadObjectRef(Common::SeekableReadStream *stream) {
objectType *r = loadObjectType(get2bytes(stream));
- delete r -> screenName;
- r -> screenName = readString(stream);
+ delete r->screenName;
+ r->screenName = readString(stream);
return r;
}
void saveObjectRef(objectType *r, Common::WriteStream *stream) {
- put2bytes(r -> objectNum, stream);
- writeString(r -> screenName, stream);
+ put2bytes(r->objectNum, stream);
+ writeString(r->screenName, stream);
}
int getCombinationFunction(int withThis, int thisObject) {
@@ -137,9 +139,9 @@ int getCombinationFunction(int withThis, int thisObject) {
}
#endif
- for (i = 0; i < obj -> numCom; i ++) {
- if (obj -> allCombis[i].withObj == withThis) {
- num = obj -> allCombis[i].funcNum;
+ for (i = 0; i < obj->numCom; i++) {
+ if (obj->allCombis[i].withObj == withThis) {
+ num = obj->allCombis[i].funcNum;
break;
}
}
@@ -155,21 +157,21 @@ int getCombinationFunction(int withThis, int thisObject) {
}
void removeObjectType(objectType *oT) {
- objectType * * huntRegion = & allObjectTypes;
+ objectType * * huntRegion = &allObjectTypes;
- while (* huntRegion) {
- if ((* huntRegion) == oT) {
+ while (*huntRegion) {
+ if ((*huntRegion) == oT) {
// FILE * debuggy2 = fopen ("debug.txt", "at");
// fprintf (debuggy2, "DELETING OBJECT TYPE: %p %s\n", oT, oT -> screenName);
// fclose (debuggy2);
- * huntRegion = oT -> next;
- delete oT -> allCombis;
- delete oT -> screenName;
+ *huntRegion = oT->next;
+ delete oT->allCombis;
+ delete oT->screenName;
delete oT;
return;
} else {
- huntRegion = & ((* huntRegion) -> next);
+ huntRegion = &((*huntRegion)->next);
}
}
fatal("Can't delete object type: bad pointer");
diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp
index 6430d354f8..93f1d6c16a 100644
--- a/engines/sludge/people.cpp
+++ b/engines/sludge/people.cpp
@@ -71,7 +71,8 @@ inline int TF_abs(int a) {
}
void setFrames(onScreenPerson &m, int a) {
- m.myAnim = m.myPersona->animation[(a * m.myPersona->numDirections) + m.direction];
+ m.myAnim = m.myPersona->animation[(a * m.myPersona->numDirections)
+ + m.direction];
}
personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
@@ -85,15 +86,17 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
int a = num, frameNum, howMany;
while (a) {
- a --;
+ a--;
newP->frames[a].noise = 0;
if (stacky->thisVar.varType == SVT_FILE) {
newP->frames[a].noise = stacky->thisVar.varData.intValue;
} else if (stacky->thisVar.varType == SVT_FUNC) {
- newP->frames[a].noise = - stacky->thisVar.varData.intValue;
+ newP->frames[a].noise = -stacky->thisVar.varData.intValue;
} else if (stacky->thisVar.varType == SVT_STACK) {
- getValueType(frameNum, SVT_INT, stacky->thisVar.varData.theStack->first->thisVar);
- getValueType(howMany, SVT_INT, stacky->thisVar.varData.theStack->first->next->thisVar);
+ getValueType(frameNum, SVT_INT,
+ stacky->thisVar.varData.theStack->first->thisVar);
+ getValueType(howMany, SVT_INT,
+ stacky->thisVar.varData.theStack->first->next->thisVar);
} else {
getValueType(frameNum, SVT_INT, stacky->thisVar);
howMany = 1;
@@ -107,32 +110,34 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
}
personaAnimation *makeNullAnim() {
- personaAnimation *newAnim = new personaAnimation;
- if (!checkNew(newAnim)) return NULL;
+ personaAnimation *newAnim = new personaAnimation;
+ if (!checkNew(newAnim))
+ return NULL;
-
- newAnim->theSprites = NULL;
- newAnim->numFrames = 0;
- newAnim->frames = NULL;
+ newAnim->theSprites = NULL;
+ newAnim->numFrames = 0;
+ newAnim->frames = NULL;
return newAnim;
}
personaAnimation *copyAnim(personaAnimation *orig) {
int num = orig->numFrames;
- personaAnimation *newAnim = new personaAnimation;
- if (!checkNew(newAnim)) return NULL;
+ personaAnimation *newAnim = new personaAnimation;
+ if (!checkNew(newAnim))
+ return NULL;
// Copy the easy bits...
- newAnim->theSprites = orig->theSprites;
- newAnim->numFrames = num;
+ newAnim->theSprites = orig->theSprites;
+ newAnim->numFrames = num;
if (num) {
// Argh!Frames!We need a whole NEW array of animFrame structures...
newAnim->frames = new animFrame[num];
- if (!checkNew(newAnim->frames)) return NULL;
+ if (!checkNew(newAnim->frames))
+ return NULL;
for (int a = 0; a < num; ++a) {
newAnim->frames[a].frameNum = orig->frames[a].frameNum;
@@ -161,7 +166,8 @@ void turnMeAngle(onScreenPerson *thisPerson, int direc) {
int d = thisPerson->myPersona->numDirections;
thisPerson->angle = direc;
direc += (180 / d) + 180 + thisPerson->angleOffset;
- while (direc >= 360) direc -= 360;
+ while (direc >= 360)
+ direc -= 360;
thisPerson->direction = (direc * d) / 360;
}
@@ -176,14 +182,17 @@ bool initPeople() {
void spinStep(onScreenPerson *thisPerson) {
int diff = (thisPerson->angle + 360) - thisPerson->wantAngle;
- int eachSlice = thisPerson->spinSpeed ? thisPerson->spinSpeed : (360 / thisPerson->myPersona->numDirections);
+ int eachSlice =
+ thisPerson->spinSpeed ?
+ thisPerson->spinSpeed :
+ (360 / thisPerson->myPersona->numDirections);
while (diff > 180) {
diff -= 360;
}
if (diff >= eachSlice) {
turnMeAngle(thisPerson, thisPerson->angle - eachSlice);
- } else if (diff <= - eachSlice) {
+ } else if (diff <= -eachSlice) {
turnMeAngle(thisPerson, thisPerson->angle + eachSlice);
} else {
turnMeAngle(thisPerson, thisPerson->wantAngle);
@@ -194,19 +203,22 @@ void spinStep(onScreenPerson *thisPerson) {
void rethinkAngle(onScreenPerson *thisPerson) {
int d = thisPerson->myPersona->numDirections;
int direc = thisPerson->angle + (180 / d) + 180 + thisPerson->angleOffset;
- while (direc >= 360) direc -= 360;
+ while (direc >= 360)
+ direc -= 360;
thisPerson->direction = (direc * d) / 360;
}
bool turnPersonToFace(int thisNum, int direc) {
onScreenPerson *thisPerson = findPerson(thisNum);
if (thisPerson) {
- if (thisPerson->continueAfterWalking) abortFunction(thisPerson->continueAfterWalking);
+ if (thisPerson->continueAfterWalking)
+ abortFunction(thisPerson->continueAfterWalking);
thisPerson->continueAfterWalking = NULL;
thisPerson->walking = false;
thisPerson->spinning = false;
turnMeAngle(thisPerson, direc);
- setFrames(* thisPerson, (thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND);
+ setFrames(*thisPerson,
+ (thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND);
return true;
}
return false;
@@ -216,7 +228,8 @@ bool setPersonExtra(int thisNum, int extra) {
onScreenPerson *thisPerson = findPerson(thisNum);
if (thisPerson) {
thisPerson->extra = extra;
- if (extra & EXTRA_NOSCALE) thisPerson->scale = 1;
+ if (extra & EXTRA_NOSCALE)
+ thisPerson->scale = 1;
return true;
}
return false;
@@ -230,13 +243,15 @@ void setScale(short int h, short int d) {
void moveAndScale(onScreenPerson &me, float x, float y) {
me.x = x;
me.y = y;
- if (!(me.extra & EXTRA_NOSCALE) && scaleDivide) me.scale = (me.y - scaleHorizon) / scaleDivide;
+ if (!(me.extra & EXTRA_NOSCALE) && scaleDivide)
+ me.scale = (me.y - scaleHorizon) / scaleDivide;
}
onScreenPerson *findPerson(int v) {
onScreenPerson *thisPerson = allPeople;
while (thisPerson) {
- if (v == thisPerson->thisType->objectNum) break;
+ if (v == thisPerson->thisType->objectNum)
+ break;
thisPerson = thisPerson->next;
}
return thisPerson;
@@ -244,12 +259,14 @@ onScreenPerson *findPerson(int v) {
void movePerson(int x, int y, int objNum) {
onScreenPerson *moveMe = findPerson(objNum);
- if (moveMe) moveAndScale(* moveMe, x, y);
+ if (moveMe)
+ moveAndScale(*moveMe, x, y);
}
void setShown(bool h, int ob) {
onScreenPerson *moveMe = findPerson(ob);
- if (moveMe) moveMe->show = h;
+ if (moveMe)
+ moveMe->show = h;
}
enum drawModes {
@@ -318,57 +335,57 @@ void setMyDrawMode(onScreenPerson *moveMe, int h) {
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
- case drawModeShadow1:
+ case drawModeShadow1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 64;
break;
- case drawModeShadow2:
+ case drawModeShadow2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 128;
break;
- case drawModeShadow3:
+ case drawModeShadow3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 192;
break;
- case drawModeFoggy3:
+ case drawModeFoggy3:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
- case drawModeFoggy2:
+ case drawModeFoggy2:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
- case drawModeFoggy1:
+ case drawModeFoggy1:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
- case drawModeFoggy4:
+ case drawModeFoggy4:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
- case drawModeGlow3:
+ case drawModeGlow3:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
- case drawModeGlow2:
+ case drawModeGlow2:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
- case drawModeGlow1:
+ case drawModeGlow1:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
- case drawModeGlow4:
+ case drawModeGlow4:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 255;
moveMe->transparency = 0;
@@ -384,22 +401,27 @@ void setMyDrawMode(onScreenPerson *moveMe, int h) {
void setDrawMode(int h, int ob) {
onScreenPerson *moveMe = findPerson(ob);
- if (!moveMe) return;
+ if (!moveMe)
+ return;
setMyDrawMode(moveMe, h);
}
void setPersonTransparency(int ob, unsigned char x) {
onScreenPerson *moveMe = findPerson(ob);
- if (!moveMe) return;
+ if (!moveMe)
+ return;
- if (x > 254) x = 254;
+ if (x > 254)
+ x = 254;
moveMe->transparency = x;
}
-void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char b, unsigned char colourmix) {
+void setPersonColourise(int ob, unsigned char r, unsigned char g,
+ unsigned char b, unsigned char colourmix) {
onScreenPerson *moveMe = findPerson(ob);
- if (!moveMe) return;
+ if (!moveMe)
+ return;
moveMe->r = r;
moveMe->g = g;
@@ -407,37 +429,36 @@ void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char
moveMe->colourmix = colourmix;
}
-
-
extern screenRegion *overRegion;
void shufflePeople() {
- onScreenPerson * * thisReference = & allPeople;
- onScreenPerson *A, * B;
+ onScreenPerson * * thisReference = &allPeople;
+ onScreenPerson *A, *B;
- if (!allPeople) return;
+ if (!allPeople)
+ return;
- while ((* thisReference)->next) {
- float y1 = (* thisReference)->y;
- if ((* thisReference)->extra & EXTRA_FRONT) y1 += 1000;
+ while ((*thisReference)->next) {
+ float y1 = (*thisReference)->y;
+ if ((*thisReference)->extra & EXTRA_FRONT)
+ y1 += 1000;
- float y2 = (* thisReference)->next->y;
- if ((* thisReference)->next->extra & EXTRA_FRONT) y2 += 1000;
+ float y2 = (*thisReference)->next->y;
+ if ((*thisReference)->next->extra & EXTRA_FRONT)
+ y2 += 1000;
if (y1 > y2) {
- A = (* thisReference);
- B = (* thisReference)->next;
+ A = (*thisReference);
+ B = (*thisReference)->next;
A->next = B->next;
B->next = A;
- (* thisReference) = B;
+ (*thisReference) = B;
} else {
- thisReference = & ((* thisReference)->next);
+ thisReference = &((*thisReference)->next);
}
}
}
-
-
void drawPeople() {
shufflePeople();
@@ -453,15 +474,20 @@ void drawPeople() {
thisPerson->frameNum = 0;
thisPerson->frameTick = myAnim->frames[0].howMany;
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
- startSound(myAnim->frames[thisPerson->frameNum].noise, false);
- thisPerson->frameNum ++;
+ startSound(myAnim->frames[thisPerson->frameNum].noise,
+ false);
+ thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
- thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
+ thisPerson->frameTick =
+ thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
} else if (myAnim->frames[thisPerson->frameNum].noise) {
- startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack);
- thisPerson->frameNum ++;
+ startNewFunctionNum(
+ -myAnim->frames[thisPerson->frameNum].noise, 0,
+ NULL, noStack);
+ thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
- thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
+ thisPerson->frameTick =
+ thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
}
}
int fNumSign = myAnim->frames[thisPerson->frameNum].frameNum;
@@ -473,31 +499,39 @@ void drawPeople() {
}
if (m != 2) {
bool r = false;
- r = scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim->theSprites->bank.myPalette, thisPerson, m);
+ r = scaleSprite(myAnim->theSprites->bank.sprites[fNum],
+ myAnim->theSprites->bank.myPalette, thisPerson, m);
if (r) {
if (thisPerson->thisType->screenName[0]) {
- if (personRegion.thisType != thisPerson->thisType) lastRegion = NULL;
+ if (personRegion.thisType != thisPerson->thisType)
+ lastRegion = NULL;
personRegion.thisType = thisPerson->thisType;
- overRegion = & personRegion;
+ overRegion = &personRegion;
}
}
}
}
- if (!-- thisPerson->frameTick) {
- thisPerson->frameNum ++;
+ if (!--thisPerson->frameTick) {
+ thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
- thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
+ thisPerson->frameTick =
+ thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
if (thisPerson->show && myAnim && myAnim->frames) {
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
- startSound(myAnim->frames[thisPerson->frameNum].noise, false);
- thisPerson->frameNum ++;
+ startSound(myAnim->frames[thisPerson->frameNum].noise,
+ false);
+ thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
- thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
+ thisPerson->frameTick =
+ thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
} else if (myAnim->frames[thisPerson->frameNum].noise) {
- startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack);
- thisPerson->frameNum ++;
+ startNewFunctionNum(
+ -myAnim->frames[thisPerson->frameNum].noise, 0,
+ NULL, noStack);
+ thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
- thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
+ thisPerson->frameTick =
+ thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
}
}
}
@@ -514,22 +548,27 @@ void makeSilent(onScreenPerson &me) {
}
bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
- int gotX = 320, gotY = 200, gotPoly = -1, i, j, xTest1, yTest1,
- xTest2, yTest2, closestX, closestY, oldJ, currentDistance = 0xFFFFF,
- thisDistance;
+ int gotX = 320, gotY = 200, gotPoly = -1, i, j, xTest1, yTest1, xTest2,
+ yTest2, closestX, closestY, oldJ, currentDistance = 0xFFFFF,
+ thisDistance;
// FILE * dbug = fopen ("debug_closest.txt", "at");
// fprintf (dbug, "\nGetting closest point to %i, %i\n", setX, setY);
- for (i = 0; i < currentFloor->numPolygons; i ++) {
+ for (i = 0; i < currentFloor->numPolygons; i++) {
oldJ = currentFloor->polygon[i].numVertices - 1;
- for (j = 0; j < currentFloor->polygon[i].numVertices; j ++) {
+ for (j = 0; j < currentFloor->polygon[i].numVertices; j++) {
// fprintf (dbug, "Polygon %i, line %i... ", i, j);
- xTest1 = currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x;
- yTest1 = currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y;
- xTest2 = currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].x;
- yTest2 = currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].y;
- closestPointOnLine(closestX, closestY, xTest1, yTest1, xTest2, yTest2, setX, setY);
+ xTest1 =
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x;
+ yTest1 =
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y;
+ xTest2 =
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].x;
+ yTest2 =
+ currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].y;
+ closestPointOnLine(closestX, closestY, xTest1, yTest1, xTest2,
+ yTest2, setX, setY);
// fprintf (dbug, "closest point is %i, %i... ", closestX, closestY);
xTest1 = setX - closestX;
yTest1 = setY - closestY;
@@ -549,7 +588,8 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
}
// fclose (dbug);
- if (gotPoly == -1) return false;
+ if (gotPoly == -1)
+ return false;
setX = gotX;
setY = gotY;
setPoly = gotPoly;
@@ -565,11 +605,13 @@ bool doBorderStuff(onScreenPerson *moveMe) {
} else {
// The section in which we need to be next...
int newPoly = currentFloor->matrix[moveMe->inPoly][moveMe->walkToPoly];
- if (newPoly == -1) return false;
+ if (newPoly == -1)
+ return false;
// Grab the index of the second matching corner...
int ID, ID2;
- if (!getMatchingCorners(currentFloor->polygon[moveMe->inPoly], currentFloor->polygon[newPoly], ID, ID2))
+ if (!getMatchingCorners(currentFloor->polygon[moveMe->inPoly],
+ currentFloor->polygon[newPoly], ID, ID2))
return fatal("Not a valid floor plan!");
// Remember that we're walking to the new polygon...
@@ -605,8 +647,8 @@ bool doBorderStuff(onScreenPerson *moveMe) {
dy23 *= dy23;
dy24 *= dy24;
- if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23) <
- sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) {
+ if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23)
+ < sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) {
moveMe->thisStepX = x3;
moveMe->thisStepY = y3;
} else {
@@ -623,7 +665,7 @@ bool doBorderStuff(onScreenPerson *moveMe) {
moveMe->spinning = true;
}
- setFrames(* moveMe, ANI_WALK);
+ setFrames(*moveMe, ANI_WALK);
return true;
}
@@ -634,20 +676,22 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
xDiff = thisPerson->thisStepX - thisPerson->x;
yDiff = (thisPerson->thisStepY - thisPerson->y) * 2;
s = thisPerson->scale * thisPerson->walkSpeed;
- if (s < 0.2) s = 0.2;
+ if (s < 0.2)
+ s = 0.2;
- maxDiff = (TF_abs(xDiff) >= TF_abs(yDiff)) ? TF_abs(xDiff) : TF_abs(yDiff);
+ maxDiff =
+ (TF_abs(xDiff) >= TF_abs(yDiff)) ?
+ TF_abs(xDiff) : TF_abs(yDiff);
if (TF_abs(maxDiff) > s) {
if (thisPerson->spinning) {
spinStep(thisPerson);
- setFrames(* thisPerson, ANI_WALK);
+ setFrames(*thisPerson, ANI_WALK);
}
s = maxDiff / s;
if (move)
- moveAndScale(* thisPerson,
- thisPerson->x + xDiff / s,
- thisPerson->y + yDiff / (s * 2));
+ moveAndScale(*thisPerson, thisPerson->x + xDiff / s,
+ thisPerson->y + yDiff / (s * 2));
return true;
}
@@ -659,24 +703,27 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
}
break;
}
- if (!doBorderStuff(thisPerson)) break;
+ if (!doBorderStuff(thisPerson))
+ break;
}
thisPerson->walking = false;
- setFrames(* thisPerson, ANI_STAND);
- moveAndScale(* thisPerson,
- thisPerson->walkToX,
- thisPerson->walkToY);
+ setFrames(*thisPerson, ANI_STAND);
+ moveAndScale(*thisPerson, thisPerson->walkToX, thisPerson->walkToY);
return false;
}
bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
- if (x == 0 && y == 0) return false;
- if (currentFloor->numPolygons == 0) return false;
+ if (x == 0 && y == 0)
+ return false;
+ if (currentFloor->numPolygons == 0)
+ return false;
onScreenPerson *moveMe = findPerson(objNum);
- if (!moveMe) return false;
+ if (!moveMe)
+ return false;
- if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
+ if (moveMe->continueAfterWalking)
+ abortFunction(moveMe->continueAfterWalking);
moveMe->continueAfterWalking = NULL;
moveMe->walking = true;
moveMe->directionWhenDoneWalking = di;
@@ -685,13 +732,16 @@ bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
moveMe->walkToY = y;
moveMe->walkToPoly = inFloor(x, y);
if (moveMe->walkToPoly == -1) {
- if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY, moveMe->walkToPoly)) return false;
+ if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY,
+ moveMe->walkToPoly))
+ return false;
}
moveMe->inPoly = inFloor(moveMe->x, moveMe->y);
if (moveMe->inPoly == -1) {
int xxx = moveMe->x, yyy = moveMe->y;
- if (!handleClosestPoint(xxx, yyy, moveMe->inPoly)) return false;
+ if (!handleClosestPoint(xxx, yyy, moveMe->inPoly))
+ return false;
}
doBorderStuff(moveMe);
@@ -711,18 +761,22 @@ bool stopPerson(int o) {
moveMe->continueAfterWalking = NULL;
moveMe->walking = false;
moveMe->spinning = false;
- setFrames(* moveMe, ANI_STAND);
+ setFrames(*moveMe, ANI_STAND);
return true;
}
return false;
}
-bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
- if (x == 0 && y == 0) return false;
+bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func,
+ int di) {
+ if (x == 0 && y == 0)
+ return false;
onScreenPerson *moveMe = findPerson(objNum);
- if (!moveMe) return false;
+ if (!moveMe)
+ return false;
- if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
+ if (moveMe->continueAfterWalking)
+ abortFunction(moveMe->continueAfterWalking);
moveMe->walking = true;
moveMe->continueAfterWalking = NULL;
moveMe->directionWhenDoneWalking = di;
@@ -745,27 +799,33 @@ bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di)
}
void jumpPerson(int x, int y, int objNum) {
- if (x == 0 && y == 0) return;
+ if (x == 0 && y == 0)
+ return;
onScreenPerson *moveMe = findPerson(objNum);
- if (!moveMe) return;
- if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
+ if (!moveMe)
+ return;
+ if (moveMe->continueAfterWalking)
+ abortFunction(moveMe->continueAfterWalking);
moveMe->continueAfterWalking = NULL;
moveMe->walking = false;
moveMe->spinning = false;
- moveAndScale(* moveMe, x, y);
+ moveAndScale(*moveMe, x, y);
}
bool floatCharacter(int f, int objNum) {
onScreenPerson *moveMe = findPerson(objNum);
- if (!moveMe) return false;
+ if (!moveMe)
+ return false;
moveMe->floaty = f;
return true;
}
bool setCharacterWalkSpeed(int f, int objNum) {
- if (f <= 0) return false;
+ if (f <= 0)
+ return false;
onScreenPerson *moveMe = findPerson(objNum);
- if (!moveMe) return false;
+ if (!moveMe)
+ return false;
moveMe->walkSpeed = f;
return true;
}
@@ -778,9 +838,10 @@ void walkAllPeople() {
walkMe(thisPerson);
} else if (thisPerson->spinning) {
spinStep(thisPerson);
- setFrames(* thisPerson, ANI_STAND);
+ setFrames(*thisPerson, ANI_STAND);
}
- if ((!thisPerson->walking) && (!thisPerson->spinning) && thisPerson->continueAfterWalking) {
+ if ((!thisPerson->walking) && (!thisPerson->spinning)
+ && thisPerson->continueAfterWalking) {
restartFunction(thisPerson->continueAfterWalking);
thisPerson->continueAfterWalking = NULL;
}
@@ -790,14 +851,15 @@ void walkAllPeople() {
bool addPerson(int x, int y, int objNum, persona *p) {
onScreenPerson *newPerson = new onScreenPerson;
- if (!checkNew(newPerson)) return false;
+ if (!checkNew(newPerson))
+ return false;
// EASY STUFF
newPerson->thisType = loadObjectType(objNum);
newPerson->scale = 1;
newPerson->extra = 0;
newPerson->continueAfterWalking = NULL;
- moveAndScale(* newPerson, x, y);
+ moveAndScale(*newPerson, x, y);
newPerson->frameNum = 0;
newPerson->walkToX = x;
newPerson->walkToY = y;
@@ -819,7 +881,7 @@ bool addPerson(int x, int y, int objNum, persona *p) {
newPerson->transparency = 0;
newPerson->myPersona = p;
- setFrames(* newPerson, ANI_STAND);
+ setFrames(*newPerson, ANI_STAND);
// HEIGHT (BASED ON 1st FRAME OF 1st ANIMATION... INC. SPECIAL CASES)
int fNumSigned = p->animation[0]->frames[0].frameNum;
@@ -828,22 +890,24 @@ bool addPerson(int x, int y, int objNum, persona *p) {
if (fNumSigned < 0) {
newPerson->height = 5;
} else {
- newPerson->height = p->animation[0]->theSprites->bank.sprites[0].yhot + 5;
+ newPerson->height =
+ p->animation[0]->theSprites->bank.sprites[0].yhot + 5;
}
} else {
- newPerson->height = p->animation[0]->theSprites->bank.sprites[fNum].yhot + 5;
+ newPerson->height = p->animation[0]->theSprites->bank.sprites[fNum].yhot
+ + 5;
}
// NOW ADD IT IN THE RIGHT PLACE
- onScreenPerson * * changethat = & allPeople;
+ onScreenPerson * * changethat = &allPeople;
- while (((* changethat) != NULL) && ((* changethat)->y < y))
- changethat = & ((* changethat)->next);
+ while (((*changethat) != NULL) && ((*changethat)->y < y))
+ changethat = &((*changethat)->next);
- newPerson->next = (* changethat);
- (* changethat) = newPerson;
+ newPerson->next = (*changethat);
+ (*changethat) = newPerson;
- return (bool)(newPerson->thisType != NULL);
+ return (bool) (newPerson->thisType != NULL);
}
int timeForAnim(personaAnimation *fram) {
@@ -854,10 +918,11 @@ int timeForAnim(personaAnimation *fram) {
return total;
}
-void animatePerson(int obj, personaAnimation *fram) { // Set a new SINGLE animation
+void animatePerson(int obj, personaAnimation *fram) { // Set a new SINGLE animation
onScreenPerson *moveMe = findPerson(obj);
if (moveMe) {
- if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
+ if (moveMe->continueAfterWalking)
+ abortFunction(moveMe->continueAfterWalking);
moveMe->continueAfterWalking = NULL;
moveMe->walking = false;
moveMe->spinning = false;
@@ -874,10 +939,10 @@ void animatePerson(int obj, persona *per) { // Set a new costume
moveMe->spinning = false;
moveMe->myPersona = per;
rethinkAngle(moveMe);
- if (moveMe-> walking) {
- setFrames(* moveMe, ANI_WALK);
+ if (moveMe->walking) {
+ setFrames(*moveMe, ANI_WALK);
} else {
- setFrames(* moveMe, ANI_STAND);
+ setFrames(*moveMe, ANI_STAND);
}
}
}
@@ -885,7 +950,8 @@ void animatePerson(int obj, persona *per) { // Set a new costume
void killAllPeople() {
onScreenPerson *killPeople;
while (allPeople) {
- if (allPeople->continueAfterWalking) abortFunction(allPeople->continueAfterWalking);
+ if (allPeople->continueAfterWalking)
+ abortFunction(allPeople->continueAfterWalking);
allPeople->continueAfterWalking = NULL;
killPeople = allPeople;
allPeople = allPeople->next;
@@ -896,19 +962,20 @@ void killAllPeople() {
void killMostPeople() {
onScreenPerson *killPeople;
- onScreenPerson * * lookyHere = & allPeople;
+ onScreenPerson * * lookyHere = &allPeople;
- while (* lookyHere) {
- if ((* lookyHere)->extra & EXTRA_NOREMOVE) {
- lookyHere = & (* lookyHere)->next;
+ while (*lookyHere) {
+ if ((*lookyHere)->extra & EXTRA_NOREMOVE) {
+ lookyHere = &(*lookyHere)->next;
} else {
- killPeople = (* lookyHere);
+ killPeople = (*lookyHere);
// Change last pointer to NEXT in the list instead
- (* lookyHere) = killPeople->next;
+ (*lookyHere) = killPeople->next;
// Gone from the list... now free some memory
- if (killPeople->continueAfterWalking) abortFunction(killPeople->continueAfterWalking);
+ if (killPeople->continueAfterWalking)
+ abortFunction(killPeople->continueAfterWalking);
killPeople->continueAfterWalking = NULL;
removeObjectType(killPeople->thisType);
delete killPeople;
@@ -920,21 +987,22 @@ void removeOneCharacter(int i) {
onScreenPerson *p = findPerson(i);
if (p) {
- if (overRegion == &personRegion && overRegion->thisType == p->thisType) {
+ if (overRegion == &personRegion
+ && overRegion->thisType == p->thisType) {
overRegion = NULL;
}
- if (p->continueAfterWalking) abortFunction(p->continueAfterWalking);
+ if (p->continueAfterWalking)
+ abortFunction(p->continueAfterWalking);
p->continueAfterWalking = NULL;
onScreenPerson * * killPeople;
- for (killPeople = & allPeople;
- * killPeople != p;
- killPeople = & ((* killPeople)->next)) {
+ for (killPeople = &allPeople; *killPeople != p; killPeople =
+ &((*killPeople)->next)) {
;
}
- * killPeople = p->next;
+ *killPeople = p->next;
removeObjectType(p->thisType);
delete p;
}
@@ -960,7 +1028,8 @@ bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) {
if (p->numFrames) {
int a = get4bytes(stream);
p->frames = new animFrame[p->numFrames];
- if (!checkNew(p->frames)) return false;
+ if (!checkNew(p->frames))
+ return false;
p->theSprites = loadBankForAnim(a);
for (a = 0; a < p->numFrames; ++a) {
@@ -979,25 +1048,26 @@ bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) {
return true;
}
/*
-void debugCostume (char * message, persona * cossy) {
- FILE * db = fopen ("debuTURN.txt", "at");
- fprintf (db, " %s costume with %i directions...\n", message, cossy->numDirections);
- for (int a = 0; a < cossy->numDirections * 3; ++a) {
- fprintf (db, " %i frames:", cossy->animation[a]->numFrames);
- for (int b = 0; b < cossy->animation[a]->numFrames; b ++) {
- fprintf (db, " %i", cossy->animation[a]->frames[b]);
- }
- fprintf (db, "\n");
-
- }
- fclose (db);
-}
-*/
+ void debugCostume (char * message, persona * cossy) {
+ FILE * db = fopen ("debuTURN.txt", "at");
+ fprintf (db, " %s costume with %i directions...\n", message, cossy->numDirections);
+ for (int a = 0; a < cossy->numDirections * 3; ++a) {
+ fprintf (db, " %i frames:", cossy->animation[a]->numFrames);
+ for (int b = 0; b < cossy->animation[a]->numFrames; b ++) {
+ fprintf (db, " %i", cossy->animation[a]->frames[b]);
+ }
+ fprintf (db, "\n");
+
+ }
+ fclose (db);
+ }
+ */
bool saveCostume(persona *cossy, Common::WriteStream *stream) {
int a;
put2bytes(cossy->numDirections, stream);
for (a = 0; a < cossy->numDirections * 3; ++a) {
- if (!saveAnim(cossy->animation[a], stream)) return false;
+ if (!saveAnim(cossy->animation[a], stream))
+ return false;
}
// debugCostume ("Saved", cossy);
return true;
@@ -1006,13 +1076,16 @@ bool saveCostume(persona *cossy, Common::WriteStream *stream) {
bool loadCostume(persona *cossy, Common::SeekableReadStream *stream) {
int a;
cossy->numDirections = get2bytes(stream);
- cossy->animation = new personaAnimation * [cossy->numDirections * 3];
- if (!checkNew(cossy->animation)) return false;
+ cossy->animation = new personaAnimation *[cossy->numDirections * 3];
+ if (!checkNew(cossy->animation))
+ return false;
for (a = 0; a < cossy->numDirections * 3; ++a) {
cossy->animation[a] = new personaAnimation;
- if (!checkNew(cossy->animation[a])) return false;
+ if (!checkNew(cossy->animation[a]))
+ return false;
- if (!loadAnim(cossy->animation[a], stream)) return false;
+ if (!loadAnim(cossy->animation[a], stream))
+ return false;
}
// debugCostume ("Loaded", cossy);
return true;
@@ -1026,7 +1099,7 @@ bool savePeople(Common::WriteStream *stream) {
putSigned(scaleDivide, stream);
while (me) {
- countPeople ++;
+ countPeople++;
me = me->next;
}
@@ -1086,7 +1159,7 @@ bool savePeople(Common::WriteStream *stream) {
}
bool loadPeople(Common::SeekableReadStream *stream) {
- onScreenPerson * * pointy = & allPeople;
+ onScreenPerson * * pointy = &allPeople;
onScreenPerson *me;
scaleHorizon = getSigned(stream);
@@ -1098,13 +1171,16 @@ bool loadPeople(Common::SeekableReadStream *stream) {
allPeople = NULL;
for (a = 0; a < countPeople; ++a) {
me = new onScreenPerson;
- if (!checkNew(me)) return false;
+ if (!checkNew(me))
+ return false;
me->myPersona = new persona;
- if (!checkNew(me->myPersona)) return false;
+ if (!checkNew(me->myPersona))
+ return false;
me->myAnim = new personaAnimation;
- if (!checkNew(me->myAnim)) return false;
+ if (!checkNew(me->myAnim))
+ return false;
me->x = getFloat(stream);
me->y = getFloat(stream);
@@ -1132,7 +1208,8 @@ bool loadPeople(Common::SeekableReadStream *stream) {
me->spinning = getch(stream);
if (getch(stream)) {
me->continueAfterWalking = loadFunction(stream);
- if (!me->continueAfterWalking) return false;
+ if (!me->continueAfterWalking)
+ return false;
} else {
me->continueAfterWalking = NULL;
}
@@ -1169,8 +1246,8 @@ bool loadPeople(Common::SeekableReadStream *stream) {
}
me->next = NULL;
- * pointy = me;
- pointy = & (me->next);
+ *pointy = me;
+ pointy = &(me->next);
}
// db ("End of loadPeople");
return true;
diff --git a/engines/sludge/people.h b/engines/sludge/people.h
index ba726b01be..f6d87847e3 100644
--- a/engines/sludge/people.h
+++ b/engines/sludge/people.h
@@ -96,13 +96,16 @@ void makeSilent(onScreenPerson &me);
void setShown(bool h, int ob);
void setDrawMode(int h, int ob);
void setPersonTransparency(int ob, unsigned char x);
-void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char b, unsigned char colourmix);
+void setPersonColourise(int ob, unsigned char r, unsigned char g,
+ unsigned char b, unsigned char colourmix);
// Moving 'em
void movePerson(int x, int y, int objNum);
-bool makeWalkingPerson(int x, int y, int objNum, struct loadedFunction *func, int di);
-bool forceWalkingPerson(int x, int y, int objNum, struct loadedFunction *func, int di);
+bool makeWalkingPerson(int x, int y, int objNum, struct loadedFunction *func,
+ int di);
+bool forceWalkingPerson(int x, int y, int objNum, struct loadedFunction *func,
+ int di);
void jumpPerson(int x, int y, int objNum);
void walkAllPeople();
bool turnPersonToFace(int thisNum, int direc);
@@ -116,7 +119,7 @@ void animatePerson(int obj, personaAnimation *);
void animatePerson(int obj, persona *per);
personaAnimation *createPersonaAnim(int num, struct variableStack *&stacky);
inline void setBankFile(personaAnimation *newP, loadedSpriteBank *sB) {
- newP -> theSprites = sB;
+ newP->theSprites = sB;
}
bool setPersonExtra(int f, int newSetting);
int timeForAnim(personaAnimation *fram);
diff --git a/engines/sludge/region.cpp b/engines/sludge/region.cpp
index eebcb577dd..f837d32a17 100644
--- a/engines/sludge/region.cpp
+++ b/engines/sludge/region.cpp
@@ -47,19 +47,20 @@ void showBoxes() {
}
void removeScreenRegion(int objectNum) {
- screenRegion * * huntRegion = & allScreenRegions;
+ screenRegion * * huntRegion = &allScreenRegions;
screenRegion *killMe;
- while (* huntRegion) {
- if ((* huntRegion)->thisType->objectNum == objectNum) {
- killMe = * huntRegion;
- * huntRegion = killMe->next;
+ while (*huntRegion) {
+ if ((*huntRegion)->thisType->objectNum == objectNum) {
+ killMe = *huntRegion;
+ *huntRegion = killMe->next;
removeObjectType(killMe->thisType);
- if (killMe == overRegion) overRegion = NULL;
+ if (killMe == overRegion)
+ overRegion = NULL;
delete killMe;
killMe = NULL;
} else {
- huntRegion = & ((* huntRegion)->next);
+ huntRegion = &((*huntRegion)->next);
}
}
}
@@ -69,7 +70,7 @@ void saveRegions(Common::WriteStream *stream) {
screenRegion *thisRegion = allScreenRegions;
while (thisRegion) {
thisRegion = thisRegion->next;
- numRegions ++;
+ numRegions++;
}
put2bytes(numRegions, stream);
thisRegion = allScreenRegions;
@@ -91,12 +92,12 @@ void loadRegions(Common::SeekableReadStream *stream) {
int numRegions = get2bytes(stream);
screenRegion *newRegion;
- screenRegion * * pointy = & allScreenRegions;
+ screenRegion * * pointy = &allScreenRegions;
- while (numRegions --) {
+ while (numRegions--) {
newRegion = new screenRegion;
- * pointy = newRegion;
- pointy = & (newRegion->next);
+ *pointy = newRegion;
+ pointy = &(newRegion->next);
newRegion->x1 = get2bytes(stream);
newRegion->y1 = get2bytes(stream);
@@ -107,7 +108,7 @@ void loadRegions(Common::SeekableReadStream *stream) {
newRegion->di = get2bytes(stream);
newRegion->thisType = loadObjectRef(stream);
}
- * pointy = NULL;
+ *pointy = NULL;
}
void killAllRegions() {
@@ -121,9 +122,11 @@ void killAllRegions() {
overRegion = NULL;
}
-bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, int objectNum) {
+bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di,
+ int objectNum) {
screenRegion *newRegion = new screenRegion;
- if (!checkNew(newRegion)) return false;
+ if (!checkNew(newRegion))
+ return false;
newRegion->di = di;
newRegion->x1 = x1;
newRegion->y1 = y1;
@@ -134,14 +137,16 @@ bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, int
newRegion->thisType = loadObjectType(objectNum);
newRegion->next = allScreenRegions;
allScreenRegions = newRegion;
- return (bool)(newRegion->thisType != NULL);
+ return (bool) (newRegion->thisType != NULL);
}
void getOverRegion() {
screenRegion *thisRegion = allScreenRegions;
while (thisRegion) {
- if ((input.mouseX >= thisRegion->x1 - cameraX) && (input.mouseY >= thisRegion->y1 - cameraY) &&
- (input.mouseX <= thisRegion->x2 - cameraX) && (input.mouseY <= thisRegion->y2 - cameraY)) {
+ if ((input.mouseX >= thisRegion->x1 - cameraX)
+ && (input.mouseY >= thisRegion->y1 - cameraY)
+ && (input.mouseX <= thisRegion->x2 - cameraX)
+ && (input.mouseY <= thisRegion->y2 - cameraY)) {
overRegion = thisRegion;
return;
}
diff --git a/engines/sludge/savedata.cpp b/engines/sludge/savedata.cpp
index dc061c6465..805f006f7b 100644
--- a/engines/sludge/savedata.cpp
+++ b/engines/sludge/savedata.cpp
@@ -42,30 +42,30 @@ char encode2 = 0;
extern char *gamePath;
/*
-void loadSaveDebug (char * com) {
- FILE * ffpp = fopen ("debuggy.txt", "at");
- fprintf (ffpp, "%s\n", com);
- fclose (ffpp);
-}
-
-void loadSaveDebug (char com) {
- FILE * ffpp = fopen ("debuggy.txt", "at");
- fprintf (ffpp, "%c\n", com);
- fclose (ffpp);
-}
-
-void loadSaveDebug (int com) {
- FILE * ffpp = fopen ("debuggy.txt", "at");
- fprintf (ffpp, "%d\n", com);
- fclose (ffpp);
-}
-*/
+ void loadSaveDebug (char * com) {
+ FILE * ffpp = fopen ("debuggy.txt", "at");
+ fprintf (ffpp, "%s\n", com);
+ fclose (ffpp);
+ }
+
+ void loadSaveDebug (char com) {
+ FILE * ffpp = fopen ("debuggy.txt", "at");
+ fprintf (ffpp, "%c\n", com);
+ fclose (ffpp);
+ }
+
+ void loadSaveDebug (int com) {
+ FILE * ffpp = fopen ("debuggy.txt", "at");
+ fprintf (ffpp, "%d\n", com);
+ fclose (ffpp);
+ }
+ */
void writeStringEncoded(const char *s, Common::WriteStream *stream) {
int a, len = strlen(s);
put2bytes(len, stream);
- for (a = 0; a < len; a ++) {
+ for (a = 0; a < len; a++) {
putch(s[a] ^ encode1, stream);
encode1 += encode2;
}
@@ -74,9 +74,10 @@ void writeStringEncoded(const char *s, Common::WriteStream *stream) {
char *readStringEncoded(Common::File *fp) {
int a, len = get2bytes(fp);
char *s = new char[len + 1];
- if (!checkNew(s)) return NULL;
- for (a = 0; a < len; a ++) {
- s[a] = (char)(getch(fp) ^ encode1);
+ if (!checkNew(s))
+ return NULL;
+ for (a = 0; a < len; a++) {
+ s[a] = (char) (getch(fp) ^ encode1);
encode1 += encode2;
}
s[len] = 0;
@@ -98,7 +99,7 @@ char *readTextPlain(Common::File *fp) {
if ((gotChar == '\n') || (fp->eos())) {
keepGoing = false;
} else {
- stringSize ++;
+ stringSize++;
}
}
@@ -107,7 +108,8 @@ char *readTextPlain(Common::File *fp) {
} else {
fp->seek(startPos, SEEK_SET);
reply = new char[stringSize + 1];
- if (reply == NULL) return NULL;
+ if (reply == NULL)
+ return NULL;
size_t bytes_read = fp->read(reply, stringSize);
if (bytes_read != stringSize && fp->err()) {
debugOut("Reading error in readTextPlain.\n");
@@ -123,7 +125,9 @@ bool fileToStack(char *filename, stackHandler *sH) {
variable stringVar;
stringVar.varType = SVT_NULL;
- const char *checker = saveEncoding ? "[Custom data (encoded)]\r\n" : "[Custom data (ASCII)]\n";
+ const char *checker =
+ saveEncoding ?
+ "[Custom data (encoded)]\r\n" : "[Custom data (ASCII)]\n";
Common::File fd;
@@ -150,39 +154,42 @@ bool fileToStack(char *filename, stackHandler *sH) {
}
encode1 = (unsigned char) saveEncoding & 255;
- encode2 = (unsigned char)(saveEncoding >> 8);
+ encode2 = (unsigned char) (saveEncoding >> 8);
- while (* checker) {
- if (getch(&fd) != * checker) {
+ while (*checker) {
+ if (getch(&fd) != *checker) {
fd.close();
- return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:", filename);
+ return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:",
+ filename);
}
- checker ++;
+ checker++;
}
if (saveEncoding) {
char *checker = readStringEncoded(&fd);
if (strcmp(checker, "UN�LO�CKED")) {
fd.close();
- return fatal(LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:", filename);
+ return fatal(
+ LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:",
+ filename);
}
delete checker;
checker = NULL;
}
-
for (;;) {
if (saveEncoding) {
char i = getch(&fd) ^ encode1;
- if (fd.eos()) break;
+ if (fd.eos())
+ break;
switch (i) {
case 0: {
char *g = readStringEncoded(&fd);
makeTextVar(stringVar, g);
delete g;
}
- break;
+ break;
case 1:
setVariable(stringVar, SVT_INT, get4bytes(&fd));
@@ -199,18 +206,21 @@ bool fileToStack(char *filename, stackHandler *sH) {
}
} else {
char *line = readTextPlain(&fd);
- if (!line) break;
+ if (!line)
+ break;
makeTextVar(stringVar, line);
}
- if (sH -> first == NULL) {
+ if (sH->first == NULL) {
// Adds to the TOP of the array... oops!
- if (!addVarToStackQuick(stringVar, sH -> first)) return false;
- sH -> last = sH -> first;
+ if (!addVarToStackQuick(stringVar, sH->first))
+ return false;
+ sH->last = sH->first;
} else {
// Adds to the END of the array... much better
- if (!addVarToStackQuick(stringVar, sH -> last -> next)) return false;
- sH -> last = sH -> last -> next;
+ if (!addVarToStackQuick(stringVar, sH->last->next))
+ return false;
+ sH->last = sH->last->next;
}
}
fd.close();
@@ -238,12 +248,12 @@ bool stackToFile(char *filename, const variable &from) {
while (hereWeAre) {
if (saveEncoding) {
switch (hereWeAre -> thisVar.varType) {
- case SVT_STRING:
+ case SVT_STRING:
fputc(encode1, fp);
writeStringEncoded(hereWeAre -> thisVar.varData.theString, fp);
break;
- case SVT_INT:
+ case SVT_INT:
// Small enough to be stored as a char
if (hereWeAre -> thisVar.varData.intValue >= 0 && hereWeAre -> thisVar.varData.intValue < 256) {
fputc(2 ^ encode1, fp);
@@ -254,7 +264,7 @@ bool stackToFile(char *filename, const variable &from) {
}
break;
- default:
+ default:
fatal("Can't create an encoded custom data file containing anything other than numbers and strings", filename);
fclose(fp);
return false;
diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h
index 734a85685b..73105c4160 100644
--- a/engines/sludge/sludge.h
+++ b/engines/sludge/sludge.h
@@ -30,7 +30,7 @@
#include "sludge/console.h"
namespace Sludge {
-
+
class SludgeConsole;
struct SludgeGameDescription;
@@ -43,8 +43,8 @@ enum {
kSludgeDebugBuiltin = 1 << 3,
kSludgeDebugGraphics = 1 << 4
};
-
-class SludgeEngine : public Engine {
+
+class SludgeEngine: public Engine {
protected:
// Engine APIs
virtual Common::Error run();
@@ -52,19 +52,19 @@ protected:
public:
SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc);
virtual ~SludgeEngine();
-
+
int getGameType() const;
const char *getGameId() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
const SludgeGameDescription *_gameDescription;
-
+
private:
SludgeConsole *_console;
- Common::RandomSource *_rnd;
+ Common::RandomSource *_rnd;
};
} // End of namespace Sludge
-
+
#endif
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 5202168f25..c7ffd9d309 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -101,7 +101,7 @@ bool captureAllKeys = false;
unsigned char brightnessLevel = 255;
eventHandlers mainHandlers;
-eventHandlers *currentEvents = & mainHandlers;
+eventHandlers *currentEvents = &mainHandlers;
extern HWND hMainWindow;
extern screenRegion *overRegion;
@@ -117,50 +117,55 @@ inputType input;
variable *globalVars;
int numGlobals;
-const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", "SET_GLOBAL",
- "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL",
- "PLUS", "MINUS", "MULT", "DIVIDE",
- "AND", "OR", "EQUALS", "NOT_EQ", "MODULUS", "LOAD_VALUE",
- "LOAD_BUILT", "LOAD_FUNC", "CALLIT", "LOAD_STRING", "LOAD_FILE",
- "LOAD_OBJTYPE", "NOT", "LOAD_NULL", "STACK_PUSH",
- "LESSTHAN", "MORETHAN", "NEGATIVE", "U", "LESS_EQUAL", "MORE_EQUAL",
- "INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET", "INDEXGET",
- "INC_INDEX", "DEC_INDEX", "QUICK_PUSH"
- };
+const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO",
+ "SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS",
+ "MULT", "DIVIDE", "AND", "OR", "EQUALS", "NOT_EQ", "MODULUS",
+ "LOAD_VALUE", "LOAD_BUILT", "LOAD_FUNC", "CALLIT", "LOAD_STRING",
+ "LOAD_FILE", "LOAD_OBJTYPE", "NOT", "LOAD_NULL", "STACK_PUSH",
+ "LESSTHAN", "MORETHAN", "NEGATIVE", "U", "LESS_EQUAL", "MORE_EQUAL",
+ "INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET",
+ "INDEXGET", "INC_INDEX", "DEC_INDEX", "QUICK_PUSH" };
void loadHandlers(Common::SeekableReadStream *stream) {
- currentEvents->leftMouseFunction = get2bytes(stream);
- currentEvents->leftMouseUpFunction = get2bytes(stream);
- currentEvents->rightMouseFunction = get2bytes(stream);
- currentEvents->rightMouseUpFunction = get2bytes(stream);
- currentEvents->moveMouseFunction = get2bytes(stream);
- currentEvents->focusFunction = get2bytes(stream);
- currentEvents->spaceFunction = get2bytes(stream);
+ currentEvents->leftMouseFunction = get2bytes(stream);
+ currentEvents->leftMouseUpFunction = get2bytes(stream);
+ currentEvents->rightMouseFunction = get2bytes(stream);
+ currentEvents->rightMouseUpFunction = get2bytes(stream);
+ currentEvents->moveMouseFunction = get2bytes(stream);
+ currentEvents->focusFunction = get2bytes(stream);
+ currentEvents->spaceFunction = get2bytes(stream);
}
void saveHandlers(Common::WriteStream *stream) {
- put2bytes(currentEvents->leftMouseFunction, stream);
- put2bytes(currentEvents->leftMouseUpFunction, stream);
- put2bytes(currentEvents->rightMouseFunction, stream);
- put2bytes(currentEvents->rightMouseUpFunction, stream);
- put2bytes(currentEvents->moveMouseFunction, stream);
- put2bytes(currentEvents->focusFunction, stream);
- put2bytes(currentEvents->spaceFunction, stream);
+ put2bytes(currentEvents->leftMouseFunction, stream);
+ put2bytes(currentEvents->leftMouseUpFunction, stream);
+ put2bytes(currentEvents->rightMouseFunction, stream);
+ put2bytes(currentEvents->rightMouseUpFunction, stream);
+ put2bytes(currentEvents->moveMouseFunction, stream);
+ put2bytes(currentEvents->focusFunction, stream);
+ put2bytes(currentEvents->spaceFunction, stream);
}
-Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion) {
+Common::File *openAndVerify(char *filename, char extra1, char extra2,
+ const char *er, int &fileVersion) {
Common::File *fp = new Common::File();
if (!fp->open(filename)) {
fatal("Can't open file", filename);
return NULL;
}
bool headerBad = false;
- if (getch(fp) != 'S') headerBad = true;
- if (getch(fp) != 'L') headerBad = true;
- if (getch(fp) != 'U') headerBad = true;
- if (getch(fp) != 'D') headerBad = true;
- if (getch(fp) != extra1) headerBad = true;
- if (getch(fp) != extra2) headerBad = true;
+ if (getch(fp) != 'S')
+ headerBad = true;
+ if (getch(fp) != 'L')
+ headerBad = true;
+ if (getch(fp) != 'U')
+ headerBad = true;
+ if (getch(fp) != 'D')
+ headerBad = true;
+ if (getch(fp) != extra1)
+ headerBad = true;
+ if (getch(fp) != extra2)
+ headerBad = true;
if (headerBad) {
fatal(er, filename);
return NULL;
@@ -196,34 +201,40 @@ bool initSludge(char *filename) {
int a = 0;
mouseCursorAnim = makeNullAnim();
- Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion);
- if (!fp) return false;
+ Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER,
+ gameVersion);
+ if (!fp)
+ return false;
char c = getch(fp);
if (c) {
numBIFNames = get2bytes(fp);
debug(kSludgeDebugDataLoad, "numBIFNames %i", numBIFNames);
allBIFNames = new char *[numBIFNames];
- if (!checkNew(allBIFNames)) return false;
+ if (!checkNew(allBIFNames))
+ return false;
- for (int fn = 0; fn < numBIFNames; fn ++) {
+ for (int fn = 0; fn < numBIFNames; fn++) {
allBIFNames[fn] = readString(fp);
}
numUserFunc = get2bytes(fp);
debug(kSludgeDebugDataLoad, "numUserFunc %i", numUserFunc);
allUserFunc = new char *[numUserFunc];
- if (!checkNew(allUserFunc)) return false;
+ if (!checkNew(allUserFunc))
+ return false;
- for (int fn = 0; fn < numUserFunc; fn ++) {
+ for (int fn = 0; fn < numUserFunc; fn++) {
allUserFunc[fn] = readString(fp);
}
if (gameVersion >= VERSION(1, 3)) {
numResourceNames = get2bytes(fp);
- debug(kSludgeDebugDataLoad, "numResourceNames %i", numResourceNames);
+ debug(kSludgeDebugDataLoad, "numResourceNames %i",
+ numResourceNames);
allResourceNames = new char *[numResourceNames];
- if (!checkNew(allResourceNames)) return false;
+ if (!checkNew(allResourceNames))
+ return false;
- for (int fn = 0; fn < numResourceNames; fn ++) {
+ for (int fn = 0; fn < numResourceNames; fn++) {
allResourceNames[fn] = readString(fp);
}
}
@@ -244,10 +255,13 @@ bool initSludge(char *filename) {
debug("Reading error in initSludge.");
}
- char *dataFol = (gameVersion >= VERSION(1, 3)) ? readString(fp) : joinStrings("", "");
+ char *dataFol =
+ (gameVersion >= VERSION(1, 3)) ?
+ readString(fp) : joinStrings("", "");
debug(kSludgeDebugDataLoad, "dataFol : %s", dataFol);
- gameSettings.numLanguages = (gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0;
+ gameSettings.numLanguages =
+ (gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0;
debug(kSludgeDebugDataLoad, "numLanguages : %c", gameSettings.numLanguages);
makeLanguageTable(fp);
@@ -262,7 +276,8 @@ bool initSludge(char *filename) {
char *checker = readString(fp);
debug(kSludgeDebugDataLoad, "checker : %s", checker);
- if (strcmp(checker, "okSoFar")) return fatal(ERROR_BAD_HEADER, filename);
+ if (strcmp(checker, "okSoFar"))
+ return fatal(ERROR_BAD_HEADER, filename);
delete checker;
checker = NULL;
@@ -316,7 +331,7 @@ bool initSludge(char *filename) {
return false;
}
png_init_io(png_ptr, fp); // Tell libpng which file to read
- png_set_sig_bytes(png_ptr, 8); // 8 bytes already read
+ png_set_sig_bytes(png_ptr, 8);// 8 bytes already read
png_read_info(png_ptr, info_ptr);
@@ -348,7 +363,7 @@ bool initSludge(char *filename) {
if (fileIsPNG) {
unsigned char *row_pointers[iconH];
for (int i = 0; i < iconH; i++)
- row_pointers[i] = p + 4 * i * iconW;
+ row_pointers[i] = p + 4 * i * iconW;
png_read_image(png_ptr, (png_byte **) row_pointers);
png_read_end(png_ptr, NULL);
@@ -425,7 +440,7 @@ bool initSludge(char *filename) {
return false;
}
png_init_io(png_ptr, fp); // Tell libpng which file to read
- png_set_sig_bytes(png_ptr, 8); // 8 bytes already read
+ png_set_sig_bytes(png_ptr, 8);// 8 bytes already read
png_read_info(png_ptr, info_ptr);
@@ -443,8 +458,8 @@ bool initSludge(char *filename) {
#ifdef WIN32
// Windows wants a BGR bitmap
if (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- png_set_bgr(png_ptr);
+ color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ png_set_bgr(png_ptr);
#endif
png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
@@ -465,7 +480,7 @@ bool initSludge(char *filename) {
if (fileIsPNG) {
unsigned char *row_pointers[logoH];
for (int i = 0; i < logoH; i++)
- row_pointers[i] = p + 4 * i * logoW;
+ row_pointers[i] = p + 4 * i * logoW;
png_read_image(png_ptr, (png_byte **) row_pointers);
png_read_end(png_ptr, NULL);
@@ -493,7 +508,7 @@ bool initSludge(char *filename) {
*p++ = (Uint8) greenValue(c);
*p++ = (Uint8) blueValue(c);
#endif
- *p++ = (Uint8) /*(c == transCol) ? 0 :*/ 255;
+ *p++ = (Uint8) /*(c == transCol) ? 0 :*/255;
t1++;
}
@@ -507,8 +522,10 @@ bool initSludge(char *filename) {
debug("numGlobals : %i", numGlobals);
globalVars = new variable[numGlobals];
- if (!checkNew(globalVars)) return false;
- for (a = 0; a < numGlobals; a ++) initVarNew(globalVars[a]);
+ if (!checkNew(globalVars))
+ return false;
+ for (a = 0; a < numGlobals; a++)
+ initVarNew(globalVars[a]);
// Get the original (untranslated) name of the game and convert it to Unicode.
// We use this to find saved preferences and saved games.
@@ -530,7 +547,7 @@ bool initSludge(char *filename) {
if (chdir(gameName)) return fatal("This game's preference folder is inaccessible!\nI can't access the following directory (maybe there's a file with the same name, or maybe it's read-protected):", gameName);
#endif
- delete [] gameName;
+ delete[] gameName;
// Get user settings
readIniFile(filename);
@@ -551,7 +568,8 @@ bool initSludge(char *filename) {
// Now set file indices properly to the chosen language.
languageNum = getLanguageForFileB();
- if (languageNum < 0) return fatal("Can't find the translation data specified!");
+ if (languageNum < 0)
+ return fatal("Can't find the translation data specified!");
setFileIndices(NULL, gameSettings.numLanguages, languageNum);
if (dataFol[0]) {
@@ -581,8 +599,8 @@ bool checkColourChange(bool reset) {
static GLuint oldPixel;
static GLuint pixel;
glReadPixels((GLint)(viewportOffsetX + input.mouseX * viewportWidth / ((float)winWidth / cameraZoom)),
- (GLint)(viewportOffsetY + (((float)winHeight / cameraZoom) - input.mouseY)*viewportHeight / ((float)winHeight / cameraZoom)),
- 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
+ (GLint)(viewportOffsetY + (((float)winHeight / cameraZoom) - input.mouseY)*viewportHeight / ((float)winHeight / cameraZoom)),
+ 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
if (reset || oldPixel != pixel) {
oldPixel = pixel;
@@ -631,21 +649,21 @@ void sludgeDisplay() {
fbo_tex_w = (float)realWinWidth / width;
fbo_tex_h = (float)realWinHeight / height;
// create shader for blitting the fbo...
- const char _blit_vsh[] = " \n\t" \
- "attribute highp vec2 aPosition; \n\t" \
- "attribute highp vec2 aTexCoord; \n\t" \
- "varying mediump vec2 vTexCoord; \n\t" \
- "void main(){ \n\t" \
- "gl_Position = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n\t" \
- "vTexCoord = aTexCoord; \n\t" \
- "} \n\t";
-
- const char _blit_fsh[] = " \n\t" \
- "uniform sampler2D uTex; \n\t" \
- "varying mediump vec2 vTexCoord; \n\t" \
- "void main(){ \n\t" \
- "gl_FragColor = texture2D(uTex, vTexCoord); \n\t" \
- "} \n\t";
+ const char _blit_vsh[] = " \n\t"
+ "attribute highp vec2 aPosition; \n\t"
+ "attribute highp vec2 aTexCoord; \n\t"
+ "varying mediump vec2 vTexCoord; \n\t"
+ "void main(){ \n\t"
+ "gl_Position = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n\t"
+ "vTexCoord = aTexCoord; \n\t"
+ "} \n\t";
+
+ const char _blit_fsh[] = " \n\t"
+ "uniform sampler2D uTex; \n\t"
+ "varying mediump vec2 vTexCoord; \n\t"
+ "void main(){ \n\t"
+ "gl_FragColor = texture2D(uTex, vTexCoord); \n\t"
+ "} \n\t";
GLint success;
fbo_frag = glCreateShader(GL_FRAGMENT_SHADER);
@@ -682,20 +700,20 @@ void sludgeDisplay() {
glDepthMask(GL_TRUE);
// glClearColor(0.5, 0.5, 1.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen
glDepthMask(GL_FALSE);
- drawBackDrop(); // Draw the room
+ drawBackDrop();// Draw the room
drawZBuffer(cameraX, cameraY, false);
glEnable(GL_DEPTH_TEST);
- drawPeople(); // Then add any moving characters...
+ drawPeople();// Then add any moving characters...
glDisable(GL_DEPTH_TEST);
- viewSpeech(); // ...and anything being said
+ viewSpeech();// ...and anything being said
drawStatusBar();
displayCursor();
- if (brightnessLevel < 255) fixBrightness(); // This is for transitionLevel special effects
+ if (brightnessLevel < 255) fixBrightness();// This is for transitionLevel special effects
glFlush();
#if !defined(HAVE_GLES2)
@@ -735,13 +753,13 @@ void sludgeDisplay() {
}
void pauseFunction(loadedFunction *fun) {
- loadedFunction * * huntAndDestroy = & allRunningFunctions;
- while (* huntAndDestroy) {
- if (fun == * huntAndDestroy) {
- (* huntAndDestroy) = (* huntAndDestroy)->next;
+ loadedFunction * * huntAndDestroy = &allRunningFunctions;
+ while (*huntAndDestroy) {
+ if (fun == *huntAndDestroy) {
+ (*huntAndDestroy) = (*huntAndDestroy)->next;
fun->next = NULL;
} else {
- huntAndDestroy = & (* huntAndDestroy)->next;
+ huntAndDestroy = &(*huntAndDestroy)->next;
}
}
}
@@ -755,7 +773,8 @@ void killSpeechTimers() {
loadedFunction *thisFunction = allRunningFunctions;
while (thisFunction) {
- if (thisFunction->freezerLevel == 0 && thisFunction->isSpeech && thisFunction->timeLeft) {
+ if (thisFunction->freezerLevel == 0 && thisFunction->isSpeech
+ && thisFunction->timeLeft) {
thisFunction->timeLeft = 0;
thisFunction->isSpeech = false;
}
@@ -769,7 +788,8 @@ void completeTimers() {
loadedFunction *thisFunction = allRunningFunctions;
while (thisFunction) {
- if (thisFunction->freezerLevel == 0) thisFunction->timeLeft = 0;
+ if (thisFunction->freezerLevel == 0)
+ thisFunction->timeLeft = 0;
thisFunction = thisFunction->next;
}
}
@@ -778,9 +798,11 @@ void finishFunction(loadedFunction *fun) {
int a;
pauseFunction(fun);
- if (fun->stack) fatal(ERROR_NON_EMPTY_STACK);
+ if (fun->stack)
+ fatal(ERROR_NON_EMPTY_STACK);
delete fun->compiledLines;
- for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]);
+ for (a = 0; a < fun->numLocals; a++)
+ unlinkVar(fun->localVars[a]);
delete fun->localVars;
unlinkVar(fun->reg);
delete fun;
@@ -791,12 +813,15 @@ void abortFunction(loadedFunction *fun) {
int a;
pauseFunction(fun);
- while (fun->stack) trimStack(fun->stack);
+ while (fun->stack)
+ trimStack(fun->stack);
delete fun->compiledLines;
- for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]);
+ for (a = 0; a < fun->numLocals; a++)
+ unlinkVar(fun->localVars[a]);
delete fun->localVars;
unlinkVar(fun->reg);
- if (fun->calledBy) abortFunction(fun->calledBy);
+ if (fun->calledBy)
+ abortFunction(fun->calledBy);
delete fun;
fun = NULL;
}
@@ -809,8 +834,9 @@ int cancelAFunction(int funcNum, loadedFunction *myself, bool &killedMyself) {
while (fun) {
if (fun->originalNumber == funcNum) {
fun->cancelMe = true;
- n ++;
- if (fun == myself) killedMyself = true;
+ n++;
+ if (fun == myself)
+ killedMyself = true;
}
fun = fun->next;
}
@@ -824,7 +850,7 @@ void freezeSubs() {
if (thisFunction->unfreezable) {
//msgBox ("SLUDGE debugging bollocks!", "Trying to freeze an unfreezable function!");
} else {
- thisFunction->freezerLevel ++;
+ thisFunction->freezerLevel++;
}
thisFunction = thisFunction->next;
}
@@ -834,12 +860,12 @@ void unfreezeSubs() {
loadedFunction *thisFunction = allRunningFunctions;
while (thisFunction) {
- if (thisFunction->freezerLevel) thisFunction->freezerLevel --;
+ if (thisFunction->freezerLevel)
+ thisFunction->freezerLevel--;
thisFunction = thisFunction->next;
}
}
-
bool continueFunction(loadedFunction *fun) {
bool keepLooping = true;
bool advanceNow;
@@ -864,8 +890,11 @@ bool continueFunction(loadedFunction *fun) {
if (numBIFNames) {
setFatalInfo(
- (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
- (com < numSludgeCommands) ? sludgeText[com] : ERROR_UNKNOWN_MCODE);
+ (fun->originalNumber < numUserFunc) ?
+ allUserFunc[fun->originalNumber] :
+ "Unknown user function",
+ (com < numSludgeCommands) ?
+ sludgeText[com] : ERROR_UNKNOWN_MCODE);
// newDebug (
// (com < numSludgeCommands) ? sludgeText[com] : "Unknown SLUDGE machine code",
// param);
@@ -877,13 +906,14 @@ bool continueFunction(loadedFunction *fun) {
case SLU_RETURN:
if (fun->calledBy) {
loadedFunction *returnTo = fun->calledBy;
- if (fun->returnSomething) copyVariable(fun->reg, returnTo->reg);
+ if (fun->returnSomething)
+ copyVariable(fun->reg, returnTo->reg);
finishFunction(fun);
fun = returnTo;
restartFunction(fun);
} else {
finishFunction(fun);
- advanceNow = false; // So we don't do anything else with "fun"
+ advanceNow = false; // So we don't do anything else with "fun"
keepLooping = false; // So we drop out of the loop
}
break;
@@ -892,26 +922,36 @@ bool continueFunction(loadedFunction *fun) {
switch (fun->reg.varType) {
case SVT_FUNC:
pauseFunction(fun);
- if (numBIFNames) setFatalInfo(
- (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
- (fun->reg.varData.intValue < numUserFunc) ? allUserFunc[fun->reg.varData.intValue] : "Unknown user function");
-
- if (!startNewFunctionNum(fun->reg.varData.intValue, param, fun, fun->stack)) return false;
+ if (numBIFNames)
+ setFatalInfo(
+ (fun->originalNumber < numUserFunc) ?
+ allUserFunc[fun->originalNumber] :
+ "Unknown user function",
+ (fun->reg.varData.intValue < numUserFunc) ?
+ allUserFunc[fun->reg.varData.intValue] :
+ "Unknown user function");
+
+ if (!startNewFunctionNum(fun->reg.varData.intValue, param, fun,
+ fun->stack))
+ return false;
fun = allRunningFunctions;
- advanceNow = false; // So we don't do anything else with "fun"
+ advanceNow = false; // So we don't do anything else with "fun"
break;
case SVT_BUILT: {
- debug(kSludgeDebugStackMachine, "Built-in init value: %i", fun->reg.varData.intValue);
- builtReturn br = callBuiltIn(fun->reg.varData.intValue, param, fun);
+ debug(kSludgeDebugStackMachine, "Built-in init value: %i",
+ fun->reg.varData.intValue);
+ builtReturn br = callBuiltIn(fun->reg.varData.intValue, param,
+ fun);
switch (br) {
case BR_ERROR:
- return fatal("Unknown error. This shouldn't happen. Please notify the SLUDGE developers.");
+ return fatal(
+ "Unknown error. This shouldn't happen. Please notify the SLUDGE developers.");
case BR_PAUSE:
pauseFunction(fun);
- // No break!
+ // No break!
case BR_KEEP_AND_PAUSE:
keepLooping = false;
@@ -926,27 +966,33 @@ bool continueFunction(loadedFunction *fun) {
int i = fun->reg.varData.intValue;
setVariable(fun->reg, SVT_INT, 1);
pauseFunction(fun);
- if (numBIFNames) setFatalInfo(
- (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
- (i < numUserFunc) ? allUserFunc[i] : "Unknown user function");
- if (!startNewFunctionNum(i, 0, fun, noStack, false)) return false;
+ if (numBIFNames)
+ setFatalInfo(
+ (fun->originalNumber < numUserFunc) ?
+ allUserFunc[fun->originalNumber] :
+ "Unknown user function",
+ (i < numUserFunc) ?
+ allUserFunc[i] :
+ "Unknown user function");
+ if (!startNewFunctionNum(i, 0, fun, noStack, false))
+ return false;
fun = allRunningFunctions;
- advanceNow = false; // So we don't do anything else with "fun"
+ advanceNow = false; // So we don't do anything else with "fun"
}
- break;
+ break;
default:
break;
}
}
- break;
+ break;
default:
return fatal(ERROR_CALL_NONFUNCTION);
}
break;
- // These all grab things and shove 'em into the register
+ // These all grab things and shove 'em into the register
case SLU_LOAD_NULL:
setVariable(fun->reg, SVT_NULL, 0);
@@ -961,16 +1007,19 @@ bool continueFunction(loadedFunction *fun) {
break;
case SLU_LOAD_LOCAL:
- if (!copyVariable(fun->localVars[param], fun->reg)) return false;
+ if (!copyVariable(fun->localVars[param], fun->reg))
+ return false;
break;
case SLU_AND:
- setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) && getBoolean(fun->stack->thisVar));
+ setVariable(fun->reg, SVT_INT,
+ getBoolean(fun->reg) && getBoolean(fun->stack->thisVar));
trimStack(fun->stack);
break;
case SLU_OR:
- setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) || getBoolean(fun->stack->thisVar));
+ setVariable(fun->reg, SVT_INT,
+ getBoolean(fun->reg) || getBoolean(fun->stack->thisVar));
trimStack(fun->stack);
break;
@@ -987,7 +1036,8 @@ bool continueFunction(loadedFunction *fun) {
break;
case SLU_UNREG:
- if (dialogValue != 1) fatal(ERROR_HACKER);
+ if (dialogValue != 1)
+ fatal(ERROR_HACKER);
break;
case SLU_LOAD_STRING:
@@ -1015,11 +1065,16 @@ bool continueFunction(loadedFunction *fun) {
return fatal(ERROR_INDEX_EMPTY);
} else {
int ii;
- if (!getValueType(ii, SVT_INT, fun->reg)) return false;
- variable *grab = (fun->stack->thisVar.varType == SVT_FASTARRAY) ?
- fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii)
- :
- stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii);
+ if (!getValueType(ii, SVT_INT, fun->reg))
+ return false;
+ variable *grab =
+ (fun->stack->thisVar.varType == SVT_FASTARRAY) ?
+ fastArrayGetByIndex(
+ fun->stack->thisVar.varData.fastArray,
+ ii) :
+ stackGetByIndex(
+ fun->stack->thisVar.varData.theStack->first,
+ ii);
trimStack(fun->stack);
@@ -1029,19 +1084,22 @@ bool continueFunction(loadedFunction *fun) {
int ii;
switch (com) {
case SLU_INCREMENT_INDEX:
- if (!getValueType(ii, SVT_INT, * grab)) return false;
+ if (!getValueType(ii, SVT_INT, *grab))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
grab->varData.intValue = ii + 1;
break;
case SLU_DECREMENT_INDEX:
- if (!getValueType(ii, SVT_INT, * grab)) return false;
+ if (!getValueType(ii, SVT_INT, *grab))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
grab->varData.intValue = ii - 1;
break;
default:
- if (!copyVariable(* grab, fun->reg)) return false;
+ if (!copyVariable(*grab, fun->reg))
+ return false;
}
}
}
@@ -1059,8 +1117,11 @@ bool continueFunction(loadedFunction *fun) {
return fatal(ERROR_INDEX_EMPTY);
} else {
int ii;
- if (!getValueType(ii, SVT_INT, fun->reg)) return false;
- if (!stackSetByIndex(fun->stack->thisVar.varData.theStack->first, ii, fun->stack->next->thisVar)) {
+ if (!getValueType(ii, SVT_INT, fun->reg))
+ return false;
+ if (!stackSetByIndex(
+ fun->stack->thisVar.varData.theStack->first, ii,
+ fun->stack->next->thisVar)) {
return false;
}
trimStack(fun->stack);
@@ -1070,78 +1131,91 @@ bool continueFunction(loadedFunction *fun) {
case SVT_FASTARRAY: {
int ii;
- if (!getValueType(ii, SVT_INT, fun->reg)) return false;
- variable *v = fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii);
- if (v == NULL) return fatal("Not within bounds of fast array.");
- if (!copyVariable(fun->stack->next->thisVar, * v)) return false;
+ if (!getValueType(ii, SVT_INT, fun->reg))
+ return false;
+ variable *v = fastArrayGetByIndex(
+ fun->stack->thisVar.varData.fastArray, ii);
+ if (v == NULL)
+ return fatal("Not within bounds of fast array.");
+ if (!copyVariable(fun->stack->next->thisVar, *v))
+ return false;
trimStack(fun->stack);
trimStack(fun->stack);
}
- break;
+ break;
default:
return fatal(ERROR_INDEX_NONSTACK);
}
break;
- // What can we do with the register? Well, we can copy it into a local
- // variable, a global or onto the stack...
+ // What can we do with the register? Well, we can copy it into a local
+ // variable, a global or onto the stack...
case SLU_INCREMENT_LOCAL: {
int ii;
- if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false;
+ if (!getValueType(ii, SVT_INT, fun->localVars[param]))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
setVariable(fun->localVars[param], SVT_INT, ii + 1);
}
- break;
+ break;
case SLU_INCREMENT_GLOBAL: {
int ii;
- if (!getValueType(ii, SVT_INT, globalVars[param])) return false;
+ if (!getValueType(ii, SVT_INT, globalVars[param]))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
setVariable(globalVars[param], SVT_INT, ii + 1);
}
- break;
+ break;
case SLU_DECREMENT_LOCAL: {
int ii;
- if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false;
+ if (!getValueType(ii, SVT_INT, fun->localVars[param]))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
setVariable(fun->localVars[param], SVT_INT, ii - 1);
}
- break;
+ break;
case SLU_DECREMENT_GLOBAL: {
int ii;
- if (!getValueType(ii, SVT_INT, globalVars[param])) return false;
+ if (!getValueType(ii, SVT_INT, globalVars[param]))
+ return false;
setVariable(fun->reg, SVT_INT, ii);
setVariable(globalVars[param], SVT_INT, ii - 1);
}
- break;
+ break;
case SLU_SET_LOCAL:
- if (!copyVariable(fun->reg, fun->localVars[param])) return false;
+ if (!copyVariable(fun->reg, fun->localVars[param]))
+ return false;
break;
case SLU_SET_GLOBAL:
// newDebug (" Copying TO global variable", param);
// newDebug (" Global type at the moment", globalVars[param].varType);
- if (!copyVariable(fun->reg, globalVars[param])) return false;
+ if (!copyVariable(fun->reg, globalVars[param]))
+ return false;
// newDebug (" New type", globalVars[param].varType);
break;
case SLU_LOAD_GLOBAL:
// newDebug (" Copying FROM global variable", param);
// newDebug (" Global type at the moment", globalVars[param].varType);
- if (!copyVariable(globalVars[param], fun->reg)) return false;
+ if (!copyVariable(globalVars[param], fun->reg))
+ return false;
break;
case SLU_STACK_PUSH:
- if (!addVarToStack(fun->reg, fun->stack)) return false;
+ if (!addVarToStack(fun->reg, fun->stack))
+ return false;
break;
case SLU_QUICK_PUSH:
- if (!addVarToStackQuick(fun->reg, fun->stack)) return false;
+ if (!addVarToStackQuick(fun->reg, fun->stack))
+ return false;
break;
case SLU_NOT:
@@ -1162,12 +1236,13 @@ bool continueFunction(loadedFunction *fun) {
case SLU_NEGATIVE: {
int i;
- if (!getValueType(i, SVT_INT, fun->reg)) return false;
+ if (!getValueType(i, SVT_INT, fun->reg))
+ return false;
setVariable(fun->reg, SVT_INT, -i);
}
- break;
+ break;
- // All these things rely on there being somet' on the stack
+ // All these things rely on there being somet' on the stack
case SLU_MULT:
case SLU_PLUS:
@@ -1201,41 +1276,51 @@ bool continueFunction(loadedFunction *fun) {
break;
default:
- if (!getValueType(firstValue, SVT_INT, fun->stack->thisVar)) return false;
- if (!getValueType(secondValue, SVT_INT, fun->reg)) return false;
+ if (!getValueType(firstValue, SVT_INT, fun->stack->thisVar))
+ return false;
+ if (!getValueType(secondValue, SVT_INT, fun->reg))
+ return false;
trimStack(fun->stack);
switch (com) {
case SLU_MULT:
- setVariable(fun->reg, SVT_INT, firstValue * secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue * secondValue);
break;
case SLU_MINUS:
- setVariable(fun->reg, SVT_INT, firstValue - secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue - secondValue);
break;
case SLU_MODULUS:
- setVariable(fun->reg, SVT_INT, firstValue % secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue % secondValue);
break;
case SLU_DIVIDE:
- setVariable(fun->reg, SVT_INT, firstValue / secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue / secondValue);
break;
case SLU_LESSTHAN:
- setVariable(fun->reg, SVT_INT, firstValue < secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue < secondValue);
break;
case SLU_MORETHAN:
- setVariable(fun->reg, SVT_INT, firstValue > secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue > secondValue);
break;
case SLU_LESS_EQUAL:
- setVariable(fun->reg, SVT_INT, firstValue <= secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue <= secondValue);
break;
case SLU_MORE_EQUAL:
- setVariable(fun->reg, SVT_INT, firstValue >= secondValue);
+ setVariable(fun->reg, SVT_INT,
+ firstValue >= secondValue);
break;
default:
@@ -1251,13 +1336,13 @@ bool continueFunction(loadedFunction *fun) {
return fatal(ERROR_UNKNOWN_CODE);
}
- if (advanceNow) fun->runThisLine ++;
+ if (advanceNow)
+ fun->runThisLine++;
}
return true;
}
-
bool runSludge() {
loadedFunction *thisFunction = allRunningFunctions;
@@ -1269,10 +1354,11 @@ bool runSludge() {
if (!thisFunction->freezerLevel) {
if (thisFunction->timeLeft) {
if (thisFunction->timeLeft < 0) {
- if (!stillPlayingSound(findInSoundCache(speech->lastFile))) {
+ if (!stillPlayingSound(
+ findInSoundCache(speech->lastFile))) {
thisFunction->timeLeft = 0;
}
- } else if (!-- (thisFunction->timeLeft)) {
+ } else if (!--(thisFunction->timeLeft)) {
}
} else {
if (thisFunction->isSpeech) {
@@ -1292,7 +1378,8 @@ bool runSludge() {
saveGame(loadNow + 1);
setVariable(saverFunc->reg, SVT_INT, 1);
} else {
- if (!loadGame(loadNow)) return false;
+ if (!loadGame(loadNow))
+ return false;
}
delete loadNow;
loadNow = NULL;
@@ -1306,52 +1393,62 @@ bool loadFunctionCode(loadedFunction *newFunc) {
debug(kSludgeDebugDataLoad, "Current address: %i", bigDataFile->pos());
unsigned int numLines, numLinesRead;
- if (!openSubSlice(newFunc->originalNumber)) return false;
+ if (!openSubSlice(newFunc->originalNumber))
+ return false;
debug(kSludgeDebugDataLoad, "Load function code");
- newFunc->unfreezable = getch(bigDataFile);
- numLines = get2bytes(bigDataFile);
+ newFunc->unfreezable = getch(bigDataFile);
+ numLines = get2bytes(bigDataFile);
debug(kSludgeDebugDataLoad, "numLines: %i", numLines);
- newFunc->numArgs = get2bytes(bigDataFile);
+ newFunc->numArgs = get2bytes(bigDataFile);
debug(kSludgeDebugDataLoad, "numArgs: %i", newFunc->numArgs);
- newFunc->numLocals = get2bytes(bigDataFile);
+ newFunc->numLocals = get2bytes(bigDataFile);
debug(kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals);
newFunc->compiledLines = new lineOfCode[numLines];
- if (!checkNew(newFunc->compiledLines)) return false;
+ if (!checkNew(newFunc->compiledLines))
+ return false;
- for (numLinesRead = 0; numLinesRead < numLines; numLinesRead ++) {
- newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(bigDataFile);
+ for (numLinesRead = 0; numLinesRead < numLines; numLinesRead++) {
+ newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(
+ bigDataFile);
newFunc->compiledLines[numLinesRead].param = get2bytes(bigDataFile);
- debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead, newFunc->compiledLines[numLinesRead].theCommand);
+ debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead,
+ newFunc->compiledLines[numLinesRead].theCommand);
}
finishAccess();
// Now we need to reserve memory for the local variables
newFunc->localVars = new variable[newFunc->numLocals];
- if (!checkNew(newFunc->localVars)) return false;
- for (int a = 0; a < newFunc->numLocals; a ++) {
+ if (!checkNew(newFunc->localVars))
+ return false;
+ for (int a = 0; a < newFunc->numLocals; a++) {
initVarNew(newFunc->localVars[a]);
}
return true;
}
-int startNewFunctionNum(unsigned int funcNum, unsigned int numParamsExpected, loadedFunction *calledBy, variableStack *&vStack, bool returnSommet) {
+int startNewFunctionNum(unsigned int funcNum, unsigned int numParamsExpected,
+ loadedFunction *calledBy, variableStack *&vStack, bool returnSommet) {
loadedFunction *newFunc = new loadedFunction;
checkNew(newFunc);
newFunc->originalNumber = funcNum;
loadFunctionCode(newFunc);
- if (newFunc->numArgs != (int)numParamsExpected) return fatal("Wrong number of parameters!");
- if (newFunc->numArgs > newFunc->numLocals) return fatal("More arguments than local variable space!");
+ if (newFunc->numArgs != (int) numParamsExpected)
+ return fatal("Wrong number of parameters!");
+ if (newFunc->numArgs > newFunc->numLocals)
+ return fatal("More arguments than local variable space!");
// Now, lets copy the parameters from the calling function's stack...
while (numParamsExpected) {
- numParamsExpected --;
- if (vStack == NULL) return fatal("Corrupted file!The stack's empty and there were still parameters expected");
+ numParamsExpected--;
+ if (vStack == NULL)
+ return fatal(
+ "Corrupted file!The stack's empty and there were still parameters expected");
copyVariable(vStack->thisVar, newFunc->localVars[numParamsExpected]);
trimStack(vStack);
}
@@ -1397,7 +1494,7 @@ bool handleInput() {
} else {
l = 1;
- setVariable(* launchResult, SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value
+ setVariable(*launchResult, SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value
launchMe = NULL;
launchResult = NULL;
}
@@ -1406,38 +1503,53 @@ bool handleInput() {
l = 0;
}
- if (!overRegion) getOverRegion();
+ if (!overRegion)
+ getOverRegion();
if (input.justMoved) {
if (currentEvents->moveMouseFunction) {
- if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL, noStack)) return false;
+ if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL,
+ noStack))
+ return false;
}
}
input.justMoved = false;
if (lastRegion != overRegion && currentEvents->focusFunction) {
variableStack *tempStack = new variableStack;
- if (!checkNew(tempStack)) return false;
+ if (!checkNew(tempStack))
+ return false;
initVarNew(tempStack->thisVar);
if (overRegion) {
- setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum);
+ setVariable(tempStack->thisVar, SVT_OBJTYPE,
+ overRegion->thisType->objectNum);
} else {
setVariable(tempStack->thisVar, SVT_INT, 0);
}
tempStack->next = NULL;
- if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL, tempStack)) return false;
+ if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL,
+ tempStack))
+ return false;
}
- if (input.leftRelease && currentEvents->leftMouseUpFunction) {
- if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL, noStack)) return false;
+ if (input.leftRelease && currentEvents->leftMouseUpFunction) {
+ if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL,
+ noStack))
+ return false;
}
if (input.rightRelease && currentEvents->rightMouseUpFunction) {
- if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL, noStack)) return false;
+ if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL,
+ noStack))
+ return false;
}
if (input.leftClick && currentEvents->leftMouseFunction)
- if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL, noStack)) return false;
+ if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL,
+ noStack))
+ return false;
if (input.rightClick && currentEvents->rightMouseFunction) {
- if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL, noStack)) return false;
+ if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL,
+ noStack))
+ return false;
}
if (input.keyPressed && currentEvents->spaceFunction) {
char *tempString = NULL;
@@ -1454,22 +1566,22 @@ bool handleInput() {
case 27:
tempString = copyString("ESCAPE");
break;
- /*
- case 1112: tempString = copyString ("ALT+F1"); break;
- case 1113: tempString = copyString ("ALT+F2"); break;
- case 1114: tempString = copyString ("ALT+F3"); break;
- case 1115: tempString = copyString ("ALT+F4"); break;
- case 1116: tempString = copyString ("ALT+F5"); break;
- case 1117: tempString = copyString ("ALT+F6"); break;
- case 1118: tempString = copyString ("ALT+F7"); break;
- case 1119: tempString = copyString ("ALT+F8"); break;
- case 1120: tempString = copyString ("ALT+F9"); break;
- case 1121: tempString = copyString ("ALT+F10"); break;
- case 1122: tempString = copyString ("ALT+F11"); break;
- case 1123: tempString = copyString ("ALT+F12"); break;
-
- case 2019: tempString = copyString ("PAUSE"); break;
- */
+ /*
+ case 1112: tempString = copyString ("ALT+F1"); break;
+ case 1113: tempString = copyString ("ALT+F2"); break;
+ case 1114: tempString = copyString ("ALT+F3"); break;
+ case 1115: tempString = copyString ("ALT+F4"); break;
+ case 1116: tempString = copyString ("ALT+F5"); break;
+ case 1117: tempString = copyString ("ALT+F6"); break;
+ case 1118: tempString = copyString ("ALT+F7"); break;
+ case 1119: tempString = copyString ("ALT+F8"); break;
+ case 1120: tempString = copyString ("ALT+F9"); break;
+ case 1121: tempString = copyString ("ALT+F10"); break;
+ case 1122: tempString = copyString ("ALT+F11"); break;
+ case 1123: tempString = copyString ("ALT+F12"); break;
+
+ case 2019: tempString = copyString ("PAUSE"); break;
+ */
case 63276:
tempString = copyString("PAGE UP");
break;
@@ -1494,10 +1606,10 @@ bool handleInput() {
case 63233:
tempString = copyString("DOWN");
break;
- /*
- case 2045: tempString = copyString ("INSERT"); break;
- case 2046: tempString = copyString ("DELETE"); break;
- */
+ /*
+ case 2045: tempString = copyString ("INSERT"); break;
+ case 2046: tempString = copyString ("DELETE"); break;
+ */
case 63236:
tempString = copyString("F1");
break;
@@ -1549,13 +1661,16 @@ bool handleInput() {
if (tempString) {
variableStack *tempStack = new variableStack;
- if (!checkNew(tempStack)) return false;
+ if (!checkNew(tempStack))
+ return false;
initVarNew(tempStack->thisVar);
makeTextVar(tempStack->thisVar, tempString);
delete tempString;
tempString = NULL;
tempStack->next = NULL;
- if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL, tempStack)) return false;
+ if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL,
+ tempStack))
+ return false;
}
}
input.rightClick = false;
diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h
index d67192d511..ef319dbda1 100644
--- a/engines/sludge/sludger.h
+++ b/engines/sludge/sludger.h
@@ -59,17 +59,17 @@ struct lineOfCode {
};
struct loadedFunction {
- int originalNumber;
- lineOfCode *compiledLines;
- int numLocals, timeLeft, numArgs;
- variable *localVars;
- variableStack *stack;
- variable reg;
- unsigned int runThisLine;
- loadedFunction *calledBy;
- loadedFunction *next;
- bool returnSomething, isSpeech, unfreezable, cancelMe;
- unsigned char freezerLevel;
+ int originalNumber;
+ lineOfCode *compiledLines;
+ int numLocals, timeLeft, numArgs;
+ variable *localVars;
+ variableStack *stack;
+ variable reg;
+ unsigned int runThisLine;
+ loadedFunction *calledBy;
+ loadedFunction *next;
+ bool returnSomething, isSpeech, unfreezable, cancelMe;
+ unsigned char freezerLevel;
};
struct inputType {
@@ -80,10 +80,10 @@ struct inputType {
extern unsigned char *gameIcon;
extern int iconW, iconH;
-
bool initSludge(char *);
void sludgeDisplay();
-int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *, variableStack*&, bool = true);
+int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *,
+ variableStack*&, bool = true);
bool handleInput();
void restartFunction(loadedFunction *fun);
bool loadFunctionCode(loadedFunction *newFunc);
@@ -92,7 +92,8 @@ void saveHandlers(Common::WriteStream *stream);
void finishFunction(loadedFunction *fun);
void abortFunction(loadedFunction *fun);
-Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion);
+Common::File *openAndVerify(char *filename, char extra1, char extra2,
+ const char *er, int &fileVersion);
void freezeSubs();
void unfreezeSubs();
diff --git a/engines/sludge/sound_bass.cpp b/engines/sludge/sound_bass.cpp
index 6f16d66bb3..5bb4e79e51 100644
--- a/engines/sludge/sound_bass.cpp
+++ b/engines/sludge/sound_bass.cpp
@@ -49,9 +49,11 @@ soundThing soundCache[MAX_SAMPLES];
int defVol = 128;
int defSoundVol = 255;
-char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {
+char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile,
+ uint32_t size) {
char *allData = new char[size];
- if (!allData) return NULL;
+ if (!allData)
+ return NULL;
inputFile->read(allData, size);
finishAccess();
@@ -68,15 +70,17 @@ void stopMOD(int i) {
int findInSoundCache(int a) {
int i;
- for (i = 0; i < MAX_SAMPLES; i ++) {
- if (soundCache[i].fileLoaded == a) return i;
+ for (i = 0; i < MAX_SAMPLES; i++) {
+ if (soundCache[i].fileLoaded == a)
+ return i;
}
return -1;
}
void huntKillSound(int filenum) {
int gotSlot = findInSoundCache(filenum);
- if (gotSlot == -1) return;
+ if (gotSlot == -1)
+ return;
soundCache[gotSlot].looping = false;
BASS_SampleStop(soundCache[gotSlot].sample);
}
@@ -90,7 +94,8 @@ void freeSound(int a) {
void huntKillFreeSound(int filenum) {
int gotSlot = findInSoundCache(filenum);
- if (gotSlot != -1) freeSound(gotSlot);
+ if (gotSlot != -1)
+ freeSound(gotSlot);
}
bool initSoundStuff(HWND hwnd) {
@@ -119,8 +124,10 @@ bool initSoundStuff(HWND hwnd) {
void killSoundStuff() {
if (soundOK) {
int a;
- for (a = 0; a < MAX_MODS; a ++) stopMOD(a);
- for (a = 0; a < MAX_SAMPLES; a ++) freeSound(a);
+ for (a = 0; a < MAX_MODS; a++)
+ stopMOD(a);
+ for (a = 0; a < MAX_SAMPLES; a++)
+ freeSound(a);
BASS_Free();
}
}
@@ -132,13 +139,19 @@ bool playMOD(int f, int a, int fromTrack) {
setResourceForFatal(f);
uint32_t length = openFileFromNum(f);
- if (length == 0) return NULL;
+ if (length == 0)
+ return NULL;
char *memImage;
memImage = loadEntireFileToMemory(bigDataFile, length);
- if (!memImage) return fatal(ERROR_MUSIC_MEMORY_LOW);
-
- mod[a] = BASS_MusicLoad(true, memImage, 0, length, BASS_MUSIC_LOOP | BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);
+ if (!memImage)
+ return fatal(ERROR_MUSIC_MEMORY_LOW);
+
+ mod[a] =
+ BASS_MusicLoad(true, memImage, 0, length,
+ BASS_MUSIC_LOOP
+ | BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/,
+ 0);
delete memImage;
if (!mod[a]) {
@@ -149,8 +162,10 @@ bool playMOD(int f, int a, int fromTrack) {
if (!BASS_ChannelPlay(mod[a], true))
debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());
- BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER);
- BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP, BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP);
+ BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0),
+ BASS_POS_MUSIC_ORDER);
+ BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP,
+ BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP);
}
setResourceForFatal(-1);
}
@@ -160,7 +175,8 @@ bool playMOD(int f, int a, int fromTrack) {
void setMusicVolume(int a, int v) {
int ret;
if (soundOK && mod[a]) {
- ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL, (float) v / 256);
+ ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL,
+ (float) v / 256);
if (!ret) {
debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode());
}
@@ -176,7 +192,8 @@ void setSoundVolume(int a, int v) {
int ch = findInSoundCache(a);
if (ch != -1) {
if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel)) {
- BASS_ChannelSetAttribute(soundCache[ch].mostRecentChannel, BASS_ATTRIB_VOL, (float) v / 256);
+ BASS_ChannelSetAttribute(soundCache[ch].mostRecentChannel,
+ BASS_ATTRIB_VOL, (float) v / 256);
}
}
}
@@ -186,7 +203,8 @@ bool stillPlayingSound(int ch) {
if (soundOK)
if (ch != -1)
if (soundCache[ch].fileLoaded != -1)
- if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel) != BASS_ACTIVE_STOPPED)
+ if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel)
+ != BASS_ACTIVE_STOPPED)
return true;
return false;
}
@@ -212,8 +230,8 @@ int emptySoundSlot = 0;
int findEmptySoundSlot() {
int t;
- for (t = 0; t < MAX_SAMPLES; t ++) {
- emptySoundSlot ++;
+ for (t = 0; t < MAX_SAMPLES; t++) {
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
if (!soundCache[emptySoundSlot].sample)
return emptySoundSlot;
@@ -221,15 +239,16 @@ int findEmptySoundSlot() {
// Argh!They're all playing!Let's trash the oldest that's not looping...
- for (t = 0; t < MAX_SAMPLES; t ++) {
- emptySoundSlot ++;
+ for (t = 0; t < MAX_SAMPLES; t++) {
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
- if (!soundCache[emptySoundSlot].looping) return emptySoundSlot;
+ if (!soundCache[emptySoundSlot].looping)
+ return emptySoundSlot;
}
// Holy crap, they're all looping!What's this twat playing at?
- emptySoundSlot ++;
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
return emptySoundSlot;
}
@@ -237,15 +256,15 @@ int findEmptySoundSlot() {
int guessSoundFree = 0;
/*
-void soundWarning (char * t, int i) {
- FILE * u = fopen ("soundlog.txt", "at");
- fprintf (u, "%s: %i\n", t, i);
- fclose (u);
-}
-*/
+ void soundWarning (char * t, int i) {
+ FILE * u = fopen ("soundlog.txt", "at");
+ fprintf (u, "%s: %i\n", t, i);
+ fclose (u);
+ }
+ */
bool forceRemoveSound() {
- for (int a = 0; a < 8; a ++) {
+ for (int a = 0; a < 8; a++) {
if (soundCache[a].fileLoaded != -1 && !stillPlayingSound(a)) {
// soundWarning ("Deleting silent sound", a);
freeSound(a);
@@ -253,7 +272,7 @@ bool forceRemoveSound() {
}
}
- for (int a = 0; a < 8; a ++) {
+ for (int a = 0; a < 8; a++) {
if (soundCache[a].fileLoaded != -1) {
// soundWarning ("Deleting playing sound", a);
freeSound(a);
@@ -267,16 +286,20 @@ bool forceRemoveSound() {
int cacheSound(int f) {
setResourceForFatal(f);
- if (!soundOK) return 0;
+ if (!soundOK)
+ return 0;
int a = findInSoundCache(f);
- if (a != -1) return a;
- if (f == -2) return -1;
+ if (a != -1)
+ return a;
+ if (f == -2)
+ return -1;
a = findEmptySoundSlot();
freeSound(a);
uint32_t length = openFileFromNum(f);
- if (!length) return -1;
+ if (!length)
+ return -1;
char *memImage;
@@ -295,7 +318,8 @@ int cacheSound(int f) {
for (;;) {
// soundWarning (" Trying to load sound into slot", a);
- soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535, 0);
+ soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535,
+ 0);
if (soundCache[a].sample) {
soundCache[a].fileLoaded = f;
@@ -315,17 +339,21 @@ int cacheSound(int f) {
bool startSound(int f, bool loopy) {
if (soundOK) {
int a = cacheSound(f);
- if (a == -1) return false;
+ if (a == -1)
+ return false;
soundCache[a].looping = loopy;
soundCache[a].vol = defSoundVol;
- soundCache[a].mostRecentChannel = BASS_SampleGetChannel(soundCache[a].sample, false);
+ soundCache[a].mostRecentChannel = BASS_SampleGetChannel(
+ soundCache[a].sample, false);
if (soundCache[a].mostRecentChannel) {
BASS_ChannelPlay(soundCache[a].mostRecentChannel, true);
- BASS_ChannelSetAttribute(soundCache[a].mostRecentChannel, BASS_ATTRIB_VOL, defSoundVol);
+ BASS_ChannelSetAttribute(soundCache[a].mostRecentChannel,
+ BASS_ATTRIB_VOL, defSoundVol);
if (loopy) {
- BASS_ChannelFlags(soundCache[a].mostRecentChannel, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag
+ BASS_ChannelFlags(soundCache[a].mostRecentChannel,
+ BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag
}
}
@@ -334,22 +362,22 @@ bool startSound(int f, bool loopy) {
}
/*
-void debugSounds () {
- FILE * fp = fopen ("newdebug.txt", "at");
- if (fp) {
- for (int aa = 0; aa < 32; aa ++) {
- if (aa == EFFECT_CHANNELS) fprintf (fp, "|");
- fprintf (fp, FSOUND_IsPlaying (aa) ? "#" : ".");
- }
- fprintf (fp, "\n");
- fclose (fp);
- }
-}
-// */
+ void debugSounds () {
+ FILE * fp = fopen ("newdebug.txt", "at");
+ if (fp) {
+ for (int aa = 0; aa < 32; aa ++) {
+ if (aa == EFFECT_CHANNELS) fprintf (fp, "|");
+ fprintf (fp, FSOUND_IsPlaying (aa) ? "#" : ".");
+ }
+ fprintf (fp, "\n");
+ fclose (fp);
+ }
+ }
+ // */
void saveSounds(Common::WriteStream *stream) {
if (soundOK) {
- for (int i = 0; i < MAX_SAMPLES; i ++) {
+ for (int i = 0; i < MAX_SAMPLES; i++) {
if (soundCache[i].looping) {
putch(1, stream);
put2bytes(soundCache[i].fileLoaded, stream);
@@ -363,7 +391,8 @@ void saveSounds(Common::WriteStream *stream) {
}
void loadSounds(Common::SeekableReadStream *stream) {
- for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i);
+ for (int i = 0; i < MAX_SAMPLES; i++)
+ freeSound(i);
while (getch(stream)) {
int fileLoaded = get2bytes(stream);
@@ -379,11 +408,13 @@ bool getSoundCacheStack(stackHandler *sH) {
variable newFileHandle;
newFileHandle.varType = SVT_NULL;
- for (int a = 0; a < MAX_SAMPLES; a ++) {
+ for (int a = 0; a < MAX_SAMPLES; a++) {
if (soundCache[a].fileLoaded != -1) {
setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded);
- if (!addVarToStackQuick(newFileHandle, sH -> first)) return false;
- if (sH -> last == NULL) sH -> last = sH -> first;
+ if (!addVarToStackQuick(newFileHandle, sH->first))
+ return false;
+ if (sH->last == NULL)
+ sH->last = sH->first;
}
}
return true;
diff --git a/engines/sludge/sound_openal.cpp b/engines/sludge/sound_openal.cpp
index 5faefdb9cc..72824d37ca 100644
--- a/engines/sludge/sound_openal.cpp
+++ b/engines/sludge/sound_openal.cpp
@@ -97,7 +97,8 @@ bool initSoundStuff(HWND hwnd) {
}
void killSoundStuff() {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
#if 0
SilenceIKillYou = true;
for (int i = 0; i < MAX_SAMPLES; i ++) {
@@ -105,7 +106,7 @@ void killSoundStuff() {
if (! alureStopSource(soundCache[i].playingOnSource, AL_TRUE)) {
debugOut("Failed to stop source: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
@@ -114,7 +115,7 @@ void killSoundStuff() {
if (! alureDestroyStream(soundCache[i].stream, 0, NULL)) {
debugOut("Failed to destroy stream: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
@@ -125,7 +126,7 @@ void killSoundStuff() {
if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) {
debugOut("Failed to stop source: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
@@ -134,7 +135,7 @@ void killSoundStuff() {
if (! alureDestroyStream(modCache[i].stream, 0, NULL)) {
debugOut("Failed to destroy stream: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
@@ -151,7 +152,8 @@ void killSoundStuff() {
*/
void setMusicVolume(int a, int v) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
if (modCache[a].playing) {
#if 0
@@ -165,7 +167,8 @@ void setDefaultMusicVolume(int v) {
}
void setSoundVolume(int a, int v) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
int ch = findInSoundCache(a);
if (ch != -1) {
if (soundCache[ch].playing) {
@@ -218,7 +221,7 @@ static void mod_eos_callback(void *cacheIndex, ALuint source) {
if (! alureDestroyStream(modCache[*a].stream, 0, NULL)) {
debugOut("Failed to destroy stream: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
modCache[*a].stream = NULL;
@@ -232,7 +235,7 @@ static void mod_eos_callback(void *cacheIndex, ALuint source) {
int findInSoundCache(int a) {
int i;
- for (i = 0; i < MAX_SAMPLES; i ++) {
+ for (i = 0; i < MAX_SAMPLES; i++) {
if (soundCache[i].fileLoaded == a) {
return i;
}
@@ -241,7 +244,8 @@ int findInSoundCache(int a) {
}
void stopMOD(int i) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
#if 0
alGetError();
if (modCache[i].playing) {
@@ -253,7 +257,8 @@ void stopMOD(int i) {
}
void huntKillSound(int filenum) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
#if 0
// Clear OpenAL errors to make sure they don't block anything:
alGetError();
@@ -273,7 +278,8 @@ void huntKillSound(int filenum) {
}
void freeSound(int a) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
#if 0
// Clear OpenAL errors to make sure they don't block anything:
alGetError();
@@ -283,12 +289,12 @@ void freeSound(int a) {
if (soundCache[a].playing) {
if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) {
debugOut("Failed to stop source: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
if (! alureDestroyStream(soundCache[a].stream, 0, NULL)) {
debugOut("Failed to destroy stream: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
soundCache[a].stream = NULL;
@@ -297,11 +303,12 @@ void freeSound(int a) {
SilenceIKillYou = false;
}
-
void huntKillFreeSound(int filenum) {
- if (! soundOK) return;
+ if (!soundOK)
+ return;
int gotSlot = findInSoundCache(filenum);
- if (gotSlot == -1) return;
+ if (gotSlot == -1)
+ return;
freeSound(gotSlot);
}
@@ -339,10 +346,10 @@ void playStream(int a, bool isMOD, bool loopy) {
if (loopy) {
ok = alurePlaySourceStream(src, (*st).stream,
- NUM_BUFS, -1, eos_callback, &intpointers[a]);
+ NUM_BUFS, -1, eos_callback, &intpointers[a]);
} else {
ok = alurePlaySourceStream(src, (*st).stream,
- NUM_BUFS, 0, eos_callback, &intpointers[a]);
+ NUM_BUFS, 0, eos_callback, &intpointers[a]);
}
if (!ok) {
@@ -361,9 +368,11 @@ void playStream(int a, bool isMOD, bool loopy) {
#endif
}
-char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {
+char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile,
+ uint32_t size) {
char *allData = new char[size];
- if (! allData) return NULL;
+ if (!allData)
+ return NULL;
size_t bytes_read = inputFile->read(allData, size);
if (bytes_read != size && inputFile->err()) {
@@ -376,7 +385,8 @@ char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t siz
}
bool playMOD(int f, int a, int fromTrack) {
- if (! soundOK) return true;
+ if (!soundOK)
+ return true;
stopMOD(a);
setResourceForFatal(f);
@@ -400,7 +410,7 @@ bool playMOD(int f, int a, int fromTrack) {
if (! alureSetStreamOrder(modCache[a].stream, fromTrack)) {
debugOut("Failed to set stream order: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
playStream(a, true, true);
@@ -408,7 +418,7 @@ bool playMOD(int f, int a, int fromTrack) {
} else {
debugOut("Failed to create stream from MOD: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
warning(ERROR_MUSIC_ODDNESS);
soundCache[a].stream = NULL;
@@ -431,15 +441,15 @@ bool stillPlayingSound(int ch) {
}
bool forceRemoveSound() {
- for (int a = 0; a < MAX_SAMPLES; a ++) {
- if (soundCache[a].fileLoaded != -1 && ! stillPlayingSound(a)) {
+ for (int a = 0; a < MAX_SAMPLES; a++) {
+ if (soundCache[a].fileLoaded != -1 && !stillPlayingSound(a)) {
// soundWarning ("Deleting silent sound", a);
freeSound(a);
return 1;
}
}
- for (int a = 0; a < MAX_SAMPLES; a ++) {
+ for (int a = 0; a < MAX_SAMPLES; a++) {
if (soundCache[a].fileLoaded != -1) {
// soundWarning ("Deleting playing sound", a);
freeSound(a);
@@ -454,17 +464,17 @@ int emptySoundSlot = 0;
int findEmptySoundSlot() {
int t;
- for (t = 0; t < MAX_SAMPLES; t ++) {
- emptySoundSlot ++;
+ for (t = 0; t < MAX_SAMPLES; t++) {
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
#if 0
if (soundCache[emptySoundSlot].stream == NULL)
- return emptySoundSlot;
+ return emptySoundSlot;
#endif
}
- for (t = 0; t < MAX_SAMPLES; t ++) {
- emptySoundSlot ++;
+ for (t = 0; t < MAX_SAMPLES; t++) {
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
if (!soundCache[emptySoundSlot].playing)
return emptySoundSlot;
@@ -472,22 +482,24 @@ int findEmptySoundSlot() {
// Argh! They're all playing! Let's trash the oldest that's not looping...
- for (t = 0; t < MAX_SAMPLES; t ++) {
- emptySoundSlot ++;
+ for (t = 0; t < MAX_SAMPLES; t++) {
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
- if (! soundCache[emptySoundSlot].looping) return emptySoundSlot;
+ if (!soundCache[emptySoundSlot].looping)
+ return emptySoundSlot;
}
// Holy crap, they're all looping! What's this twat playing at?
- emptySoundSlot ++;
+ emptySoundSlot++;
emptySoundSlot %= MAX_SAMPLES;
return emptySoundSlot;
}
int cacheSound(int f) {
- if (! soundOK) return -1;
+ if (!soundOK)
+ return -1;
unsigned int chunkLength;
int retval;
@@ -506,12 +518,12 @@ int cacheSound(int f) {
if (soundCache[a].playing) {
if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) {
debugOut("Failed to stop source: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
}
if (! alureRewindStream(soundCache[a].stream)) {
debugOut("Failed to rewind stream: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
}
return a;
@@ -560,7 +572,7 @@ int cacheSound(int f) {
} else {
debugOut("Failed to create stream from sound: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
warning(ERROR_SOUND_ODDNESS);
soundCache[a].stream = NULL;
@@ -592,7 +604,7 @@ bool startSound(int f, bool loopy) {
void saveSounds(Common::WriteStream *stream) {
if (soundOK) {
- for (int i = 0; i < MAX_SAMPLES; i ++) {
+ for (int i = 0; i < MAX_SAMPLES; i++) {
if (soundCache[i].looping) {
putch(1, stream);
put2bytes(soundCache[i].fileLoaded, stream);
@@ -606,7 +618,8 @@ void saveSounds(Common::WriteStream *stream) {
}
void loadSounds(Common::SeekableReadStream *stream) {
- for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i);
+ for (int i = 0; i < MAX_SAMPLES; i++)
+ freeSound(i);
while (getch(stream)) {
int fileLoaded = get2bytes(stream);
@@ -622,11 +635,13 @@ bool getSoundCacheStack(stackHandler *sH) {
variable newFileHandle;
newFileHandle.varType = SVT_NULL;
- for (int a = 0; a < MAX_SAMPLES; a ++) {
+ for (int a = 0; a < MAX_SAMPLES; a++) {
if (soundCache[a].fileLoaded != -1) {
setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded);
- if (! addVarToStackQuick(newFileHandle, sH -> first)) return false;
- if (sH -> last == NULL) sH -> last = sH -> first;
+ if (!addVarToStackQuick(newFileHandle, sH->first))
+ return false;
+ if (sH->last == NULL)
+ sH->last = sH->first;
}
}
return true;
@@ -634,19 +649,22 @@ bool getSoundCacheStack(stackHandler *sH) {
soundList *deleteSoundFromList(soundList *s) {
// Don't delete a playing sound.
- if (s->cacheIndex) return NULL;
+ if (s->cacheIndex)
+ return NULL;
soundList *o = NULL;
- if (! s->next) {
+ if (!s->next) {
o = s->prev;
- if (o) o-> next = NULL;
+ if (o)
+ o->next = NULL;
delete s;
return o;
}
if (s != s->next) {
o = s->next;
o->prev = s->prev;
- if (o->prev) o->prev->next = o;
+ if (o->prev)
+ o->prev->next = o;
}
delete s;
return o;
@@ -699,9 +717,9 @@ void playSoundList(soundList *s) {
}
soundCache[a].looping = false;
if (s->vol < 0)
- soundCache[a].vol = defSoundVol;
+ soundCache[a].vol = defSoundVol;
else
- soundCache[a].vol = s->vol;
+ soundCache[a].vol = s->vol;
s-> cacheIndex = a;
ALboolean ok;
@@ -719,7 +737,7 @@ void playSoundList(soundList *s) {
alSourcef(src, AL_GAIN, (float) soundCache[a].vol / 256);
ok = alurePlaySourceStream(src, (*st).stream,
- NUM_BUFS, 0, list_eos_callback, s);
+ NUM_BUFS, 0, list_eos_callback, s);
if (!ok) {
@@ -753,7 +771,7 @@ void playMovieStream(int a) {
alSourcef(src, AL_GAIN, (float) soundCache[a].vol / 256);
ok = alurePlaySourceStream(src, soundCache[a].stream,
- 10, 0, sound_eos_callback, &intpointers[a]);
+ 10, 0, sound_eos_callback, &intpointers[a]);
if (!ok) {
debugOut("Failed to play stream: %s\n", alureGetErrorString());
alDeleteSources(1, &src);
@@ -771,7 +789,7 @@ void playMovieStream(int a) {
#if 0
int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate,
- ALuint(*callback)(void *userdata, ALubyte *data, ALuint bytes)) {
+ ALuint(*callback)(void *userdata, ALubyte *data, ALuint bytes)) {
if (! soundOK) return 0;
int retval;
@@ -782,9 +800,9 @@ int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate,
#if 0
// audioChannel * sampleRate gives us a buffer of half a second. Not much, but it should be enough.
soundCache[a].stream = alureCreateStreamFromCallback(
- callback,
- &intpointers[a], format, samplerate,
- audioChannels * samplerate, 0, NULL);
+ callback,
+ &intpointers[a], format, samplerate,
+ audioChannels * samplerate, 0, NULL);
#endif
if (soundCache[a].stream != NULL) {
soundCache[a].fileLoaded = f;
@@ -793,7 +811,7 @@ int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate,
} else {
#if 0
debugOut("Failed to create stream from sound: %s\n",
- alureGetErrorString());
+ alureGetErrorString());
#endif
warning(ERROR_SOUND_ODDNESS);
soundCache[a].stream = NULL;
diff --git a/engines/sludge/sprbanks.cpp b/engines/sludge/sprbanks.cpp
index c95e405cb4..8598cb51ac 100644
--- a/engines/sludge/sprbanks.cpp
+++ b/engines/sludge/sprbanks.cpp
@@ -31,42 +31,43 @@ loadedSpriteBank *allLoadedBanks = NULL;
extern spriteBank theFont;
extern int loadedFontNum, fontTableSize;
-
loadedSpriteBank *loadBankForAnim(int ID) {
//debugOut ("loadBankForAnim: Looking for sprite bank with ID %d\n", ID);
loadedSpriteBank *returnMe = allLoadedBanks;
while (returnMe) {
- if (returnMe -> ID == ID) {
+ if (returnMe->ID == ID) {
//debugOut ("loadBankForAnim: Found existing sprite bank with ID %d\n", returnMe -> ID);
return returnMe;
}
- returnMe = returnMe -> next;
+ returnMe = returnMe->next;
}
returnMe = new loadedSpriteBank;
//debugOut ("loadBankForAnim: No existing sprite bank with ID %d\n", ID);
if (checkNew(returnMe)) {
- returnMe -> ID = ID;
- if (loadSpriteBank(ID, returnMe -> bank, false)) {
- returnMe -> timesUsed = 0;
- returnMe -> next = allLoadedBanks;
+ returnMe->ID = ID;
+ if (loadSpriteBank(ID, returnMe->bank, false)) {
+ returnMe->timesUsed = 0;
+ returnMe->next = allLoadedBanks;
allLoadedBanks = returnMe;
debugOut("loadBankForAnim: New sprite bank created OK\n");
return returnMe;
} else {
- debugOut("loadBankForAnim: I guess I couldn't load the sprites...\n");
+ debugOut(
+ "loadBankForAnim: I guess I couldn't load the sprites...\n");
return NULL;
}
- } else return NULL;
+ } else
+ return NULL;
}
void reloadSpriteTextures() {
loadedSpriteBank *spriteBank = allLoadedBanks;
while (spriteBank) {
//fprintf (stderr, "Reloading bank %d: %s.\n", spriteBank->ID, resourceNameFromNum (spriteBank->ID));
- delete spriteBank-> bank.sprites;
- spriteBank-> bank.sprites = NULL;
+ delete spriteBank->bank.sprites;
+ spriteBank->bank.sprites = NULL;
loadSpriteBank(spriteBank->ID, spriteBank->bank, false);
- spriteBank = spriteBank -> next;
+ spriteBank = spriteBank->next;
}
if (fontTableSize) {
delete theFont.sprites;
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index ec4144f7bf..5b372e6ece 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -57,7 +57,6 @@ extern float cameraZoom;
unsigned char currentBurnR = 0, currentBurnG = 0, currentBurnB = 0;
-
void forgetSpriteBank(spriteBank &forgetme) {
#if 0
deleteTextures(forgetme.myPalette.numTextures, forgetme.myPalette.tex_names);
@@ -70,49 +69,53 @@ void forgetSpriteBank(spriteBank &forgetme) {
delete [] forgetme.myPalette.tex_names;
forgetme.myPalette.tex_names = NULL;
#endif
- delete [] forgetme.myPalette.tex_w;
+ delete[] forgetme.myPalette.tex_w;
forgetme.myPalette.tex_w = NULL;
- delete [] forgetme.myPalette.tex_h;
+ delete[] forgetme.myPalette.tex_h;
forgetme.myPalette.tex_h = NULL;
if (forgetme.myPalette.pal) {
- delete [] forgetme.myPalette.pal;
+ delete[] forgetme.myPalette.pal;
forgetme.myPalette.pal = NULL;
- delete [] forgetme.myPalette.r;
+ delete[] forgetme.myPalette.r;
forgetme.myPalette.r = NULL;
- delete [] forgetme.myPalette.g;
+ delete[] forgetme.myPalette.g;
forgetme.myPalette.g = NULL;
- delete [] forgetme.myPalette.b;
+ delete[] forgetme.myPalette.b;
forgetme.myPalette.b = NULL;
}
delete forgetme.sprites;
forgetme.sprites = NULL;
-
// TODO: also remove sprite bank from allLoadedBanks
// And add a function call for this function to the scripting language
}
bool reserveSpritePal(spritePalette &sP, int n) {
if (sP.pal) {
- delete [] sP.pal;
- delete [] sP.r;
- delete [] sP.g;
- delete [] sP.b;
+ delete[] sP.pal;
+ delete[] sP.r;
+ delete[] sP.g;
+ delete[] sP.b;
}
- sP.pal = new unsigned short int [n];
- if (! checkNew(sP.pal)) return false;
-
- sP.r = new unsigned char [n];
- if (! checkNew(sP.r)) return false;
- sP.g = new unsigned char [n];
- if (! checkNew(sP.g)) return false;
- sP.b = new unsigned char [n];
- if (! checkNew(sP.b)) return false;
+ sP.pal = new unsigned short int[n];
+ if (!checkNew(sP.pal))
+ return false;
+
+ sP.r = new unsigned char[n];
+ if (!checkNew(sP.r))
+ return false;
+ sP.g = new unsigned char[n];
+ if (!checkNew(sP.g))
+ return false;
+ sP.b = new unsigned char[n];
+ if (!checkNew(sP.b))
+ return false;
sP.total = n;
- return (bool)(sP.pal != NULL) && (sP.r != NULL) && (sP.g != NULL) && (sP.b != NULL);
+ return (bool) (sP.pal != NULL) && (sP.r != NULL) && (sP.g != NULL)
+ && (sP.b != NULL);
}
bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
@@ -173,60 +176,60 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
for (i = 0; i < total; i ++) {
switch (spriteBankVersion) {
- case 3: {
- loadhere.sprites[i].xhot = getSigned(bigDataFile);
- loadhere.sprites[i].yhot = getSigned(bigDataFile);
+ case 3: {
+ loadhere.sprites[i].xhot = getSigned(bigDataFile);
+ loadhere.sprites[i].yhot = getSigned(bigDataFile);
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) {
- return fatal("Can't open sprite bank / font.");
- }
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) {
+ return fatal("Can't open sprite bank / font.");
+ }
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
- return fatal("Can't open sprite bank / font.");
- }
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
+ return fatal("Can't open sprite bank / font.");
+ }
- png_infop end_info = png_create_info_struct(png_ptr);
- if (!end_info) {
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- return fatal("Can't open sprite bank / font.");
- }
- png_init_io(png_ptr, bigDataFile); // Tell libpng which file to read
- png_set_sig_bytes(png_ptr, 8); // No sig
+ png_infop end_info = png_create_info_struct(png_ptr);
+ if (!end_info) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ return fatal("Can't open sprite bank / font.");
+ }
+ png_init_io(png_ptr, bigDataFile); // Tell libpng which file to read
+ png_set_sig_bytes(png_ptr, 8);// No sig
- png_read_info(png_ptr, info_ptr);
+ png_read_info(png_ptr, info_ptr);
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type, compression_type, filter_method;
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
+ png_uint_32 width, height;
+ int bit_depth, color_type, interlace_type, compression_type, filter_method;
+ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
- int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+ int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
- unsigned char *row_pointers[height];
- spriteData[i] = new unsigned char [rowbytes * height];
- if (! checkNew(spriteData[i])) return false;
+ unsigned char *row_pointers[height];
+ spriteData[i] = new unsigned char [rowbytes * height];
+ if (! checkNew(spriteData[i])) return false;
- for (unsigned int row = 0; row < height; row++)
+ for (unsigned int row = 0; row < height; row++)
row_pointers[row] = spriteData[i] + row * rowbytes;
- png_read_image(png_ptr, (png_byte **) row_pointers);
- png_read_end(png_ptr, NULL);
- png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ png_read_image(png_ptr, (png_byte **) row_pointers);
+ png_read_end(png_ptr, NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- picwidth = loadhere.sprites[i].width = width;
- picheight = loadhere.sprites[i].height = height;
- break;
- }
- case 2:
+ picwidth = loadhere.sprites[i].width = width;
+ picheight = loadhere.sprites[i].height = height;
+ break;
+ }
+ case 2:
picwidth = get2bytes(bigDataFile);
picheight = get2bytes(bigDataFile);
loadhere.sprites[i].xhot = getSigned(bigDataFile);
loadhere.sprites[i].yhot = getSigned(bigDataFile);
break;
- default:
+ default:
picwidth = (byte) fgetc(bigDataFile);
picheight = (byte) fgetc(bigDataFile);
loadhere.sprites[i].xhot = fgetc(bigDataFile);
@@ -256,27 +259,27 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
}
spriteData[i] = data;
switch (spriteBankVersion) {
- case 2: { // RUN LENGTH COMPRESSED DATA
- unsigned size = picwidth * picheight;
- unsigned pip = 0;
-
- while (pip < size) {
- byte col = fgetc(bigDataFile);
- int looper;
-
- if (col > howmany) {
- col -= howmany + 1;
- looper = fgetc(bigDataFile) + 1;
- } else looper = 1;
-
- while (looper --) {
- data[pip ++] = col;
+ case 2: { // RUN LENGTH COMPRESSED DATA
+ unsigned size = picwidth * picheight;
+ unsigned pip = 0;
+
+ while (pip < size) {
+ byte col = fgetc(bigDataFile);
+ int looper;
+
+ if (col > howmany) {
+ col -= howmany + 1;
+ looper = fgetc(bigDataFile) + 1;
+ } else looper = 1;
+
+ while (looper --) {
+ data[pip ++] = col;
+ }
}
}
- }
- break;
+ break;
- default: // RAW DATA
+ default: // RAW DATA
size_t bytes_read = fread(data, picwidth, picheight, bigDataFile);
if (bytes_read != picwidth * picheight && ferror(bigDataFile)) {
debugOut("Reading error in loadSpriteBank.\n");
@@ -287,7 +290,6 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
}
numTextures++;
-
if (! spriteBankVersion) {
howmany = fgetc(bigDataFile);
startIndex = fgetc(bigDataFile);
@@ -368,9 +370,9 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
target[1] = (GLubyte) 255;
target[2] = (GLubyte) 255;
if (s)
- target[3] = (GLubyte) loadhere.myPalette.r[s];
+ target[3] = (GLubyte) loadhere.myPalette.r[s];
/*else
- target[3] = (GLubyte) 0;*/
+ target[3] = (GLubyte) 0;*/
}
} else {
target[0] = (GLubyte) spriteData[i][fromhere++];
@@ -390,7 +392,7 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
glGenTextures(numTextures, loadhere.myPalette.tex_names);
if (isFont)
- glGenTextures(numTextures, loadhere.myPalette.burnTex_names);
+ glGenTextures(numTextures, loadhere.myPalette.burnTex_names);
#endif
@@ -436,7 +438,8 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
return true;
}
-void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
+void pasteSpriteToBackDrop(int x1, int y1, sprite &single,
+ const spritePalette &fontPal) {
#if 0
float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
float ty1 = 0.0;
@@ -490,7 +493,6 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
while (yoffset < diffY) {
int h = (diffY - yoffset < viewportHeight) ? diffY - yoffset : viewportHeight;
-
// Render the sprite to the backdrop
// (using mulitexturing, so the backdrop is seen where alpha < 1.0)
glActiveTexture(GL_TEXTURE2);
@@ -499,7 +501,7 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
glUseProgram(shader.paste);
GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
- if (uniform >= 0) glUniform1i(uniform, 0); // No lighting
+ if (uniform >= 0) glUniform1i(uniform, 0);// No lighting
setPMVMatrix(shader.paste);
@@ -536,7 +538,8 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
setPixelCoords(false);
}
-void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
+void burnSpriteToBackDrop(int x1, int y1, sprite &single,
+ const spritePalette &fontPal) {
#if 0
float tx1 = (float)(single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
float ty1 = 0.0;
@@ -626,7 +629,7 @@ void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &f
glBindTexture(GL_TEXTURE_2D, fontPal.burnTex_names[single.texNum]);
//FIXME: Test this some more. Also pasting the backdrop again is not strictly necessary but allows using the paste shader.
- drawQuad(shader.paste, spriteVertices, 3, spriteTexCoords, NULL, backdropTexCoords);
+ drawQuad(shader.paste, spriteVertices, 3, spriteTexCoords, NULL, backdropTexCoords);
glUseProgram(0);
// Copy Our ViewPort To The Texture
@@ -644,17 +647,19 @@ void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &f
extern GLuint backdropTextureName;
#endif
-void fontSprite(bool flip, int x, int y, sprite &single, const spritePalette &fontPal) {
+void fontSprite(bool flip, int x, int y, sprite &single,
+ const spritePalette &fontPal) {
- float tx1 = (float)(single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
+ float tx1 = (float) (single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
float ty1 = 0.0;
- float tx2 = (float)(single.tex_x + single.width + (flip ? 1.0 : 0.5)) / fontPal.tex_w[single.texNum];
- float ty2 = (float)(single.height + 2) / fontPal.tex_h[single.texNum];
+ float tx2 = (float) (single.tex_x + single.width + (flip ? 1.0 : 0.5))
+ / fontPal.tex_w[single.texNum];
+ float ty2 = (float) (single.height + 2) / fontPal.tex_h[single.texNum];
- float x1 = (float)x - (float)single.xhot / cameraZoom;
- float y1 = (float)y - (float)single.yhot / cameraZoom;
- float x2 = x1 + (float)single.width / cameraZoom;
- float y2 = y1 + (float)single.height / cameraZoom;
+ float x1 = (float) x - (float) single.xhot / cameraZoom;
+ float y1 = (float) y - (float) single.yhot / cameraZoom;
+ float x2 = x1 + (float) single.width / cameraZoom;
+ float y2 = y1 + (float) single.height / cameraZoom;
#if 0
GLfloat vertices[] = {
@@ -707,13 +712,11 @@ void fontSprite(int x, int y, sprite &single, const spritePalette &fontPal) {
fontSprite(false, x, y, single, fontPal);
}
-void flipFontSprite(int x, int y, sprite &single, const spritePalette &fontPal) {
+void flipFontSprite(int x, int y, sprite &single,
+ const spritePalette &fontPal) {
fontSprite(true, x, y, single, fontPal);
}
-
-
-
unsigned char curLight[3];
void setDrawMode(onScreenPerson *thisPerson) {
@@ -734,7 +737,8 @@ extern GLuint backdropTextureName;
bool checkColourChange(bool reset);
-bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror) {
+bool scaleSprite(sprite &single, const spritePalette &fontPal,
+ onScreenPerson *thisPerson, bool mirror) {
#if 0
float x = thisPerson->x;
float y = thisPerson->y;
@@ -758,9 +762,9 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
x = x / cameraZoom;
y = y / cameraZoom;
if (single.xhot < 0)
- x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale / cameraZoom);
+ x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale / cameraZoom);
else
- x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale / cameraZoom);
+ x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale / cameraZoom);
y1 = y - (int)((single.yhot - thisPerson->floaty) * scale / cameraZoom);
x2 = x1 + (int)(diffX / cameraZoom);
y2 = y1 + (int)(diffY / cameraZoom);
@@ -768,9 +772,9 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
x -= cameraX;
y -= cameraY;
if (single.xhot < 0)
- x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale);
+ x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale);
else
- x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale);
+ x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale);
y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
x2 = x1 + diffX;
y2 = y1 + diffY;
@@ -843,7 +847,7 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
}
#ifndef HAVE_GLES2
if (!(thisPerson->extra & EXTRA_RECTANGULAR))
- checkColourChange(true);
+ checkColourChange(true);
#endif
setDrawMode(thisPerson);
@@ -909,7 +913,8 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
}
// Paste a scaled sprite onto the backdrop
-void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, int camX, int camY, bool mirror) {
+void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
+ onScreenPerson *thisPerson, int camX, int camY, bool mirror) {
#if 0
float scale = thisPerson-> scale;
bool useZB = !(thisPerson->extra & EXTRA_NOZB);
@@ -926,9 +931,9 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
int diffY = (int)(((float)single.height) * scale);
int x1;
if (single.xhot < 0)
- x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale);
+ x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale);
else
- x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale);
+ x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale);
int y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
float spriteWidth = diffX;
@@ -942,7 +947,6 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
GLfloat z;
-
if (useZB && zBuffer.numPanels) {
int i;
for (i = 1; i < zBuffer.numPanels; i++) {
diff --git a/engines/sludge/sprites.h b/engines/sludge/sprites.h
index 2a617bb5ee..067c84a2de 100644
--- a/engines/sludge/sprites.h
+++ b/engines/sludge/sprites.h
@@ -51,23 +51,24 @@ public:
GLuint *tex_names;
GLuint *burnTex_names;
#endif
- int *tex_w, * tex_h;
+ int *tex_w, *tex_h;
int numTextures;
unsigned char originalRed, originalGreen, originalBlue, total;
- spritePalette(): pal(0), r(0), g(0), b(0)/*, tex_names(0), burnTex_names(0)*/
- , tex_w(0), tex_h(0), numTextures(0)
- , total(0) {}
+ spritePalette() :
+ pal(0), r(0), g(0), b(0)/*, tex_names(0), burnTex_names(0)*/
+ , tex_w(0), tex_h(0), numTextures(0), total(0) {
+ }
~spritePalette() {
- delete [] pal;
- delete [] r;
- delete [] g;
- delete [] b;
+ delete[] pal;
+ delete[] r;
+ delete[] g;
+ delete[] b;
// delete [] tex_names;
// delete [] burnTex_names;
- delete [] tex_w;
- delete [] tex_h;
+ delete[] tex_w;
+ delete[] tex_h;
}
};
@@ -84,13 +85,19 @@ bool loadSpriteBank(char *filename, spriteBank &loadhere);
bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont);
void fontSprite(int x1, int y1, sprite &single, const spritePalette &fontPal);
-void flipFontSprite(int x1, int y1, sprite &single, const spritePalette &fontPal);
+void flipFontSprite(int x1, int y1, sprite &single,
+ const spritePalette &fontPal);
-bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror);
-void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal);
+bool scaleSprite(sprite &single, const spritePalette &fontPal,
+ onScreenPerson *thisPerson, bool mirror);
+void pasteSpriteToBackDrop(int x1, int y1, sprite &single,
+ const spritePalette &fontPal);
bool reserveSpritePal(spritePalette &sP, int n);
-void fixScaleSprite(int x1, int y1, sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, const int camX, const int camY, bool);
-void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal);
+void fixScaleSprite(int x1, int y1, sprite &single,
+ const spritePalette &fontPal, onScreenPerson *thisPerson,
+ const int camX, const int camY, bool);
+void burnSpriteToBackDrop(int x1, int y1, sprite &single,
+ const spritePalette &fontPal);
} // End of namespace Sludge
diff --git a/engines/sludge/stringy.cpp b/engines/sludge/stringy.cpp
index a5440b6c96..5446f571da 100644
--- a/engines/sludge/stringy.cpp
+++ b/engines/sludge/stringy.cpp
@@ -28,15 +28,17 @@
namespace Sludge {
char *copyString(const char *copyMe) {
- char *newString = new char [strlen(copyMe) + 1];
- if (! checkNew(newString)) return NULL;
+ char *newString = new char[strlen(copyMe) + 1];
+ if (!checkNew(newString))
+ return NULL;
strcpy(newString, copyMe);
return newString;
}
char *joinStrings(const char *s1, const char *s2) {
- char *newString = new char [strlen(s1) + strlen(s2) + 1];
- if (! checkNew(newString)) return NULL;
+ char *newString = new char[strlen(s1) + strlen(s2) + 1];
+ if (!checkNew(newString))
+ return NULL;
sprintf(newString, "%s%s", s1, s2);
return newString;
}
diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp
index abee33c88a..5e6c10dd25 100644
--- a/engines/sludge/talk.cpp
+++ b/engines/sludge/talk.cpp
@@ -60,7 +60,7 @@ void killAllSpeech() {
}
if (speech->currentTalker) {
- makeSilent(* (speech->currentTalker));
+ makeSilent(*(speech->currentTalker));
speech->currentTalker = NULL;
}
@@ -96,8 +96,9 @@ void addSpeechLine(char *theLine, int x, int &offset) {
speech->allSpeech = newLine;
if ((xx1 < 5) && (offset < (5 - xx1))) {
offset = 5 - xx1;
- } else if ((xx2 >= ((float)winWidth / cameraZoom) - 5) && (offset > (((float)winWidth / cameraZoom) - 5 - xx2))) {
- offset = ((float)winWidth / cameraZoom) - 5 - xx2;
+ } else if ((xx2 >= ((float) winWidth / cameraZoom) - 5)
+ && (offset > (((float) winWidth / cameraZoom) - 5 - xx2))) {
+ offset = ((float) winWidth / cameraZoom) - 5 - xx2;
}
}
@@ -111,7 +112,8 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
killAllSpeech();
int speechTime = (strlen(theText) + 20) * speechSpeed;
- if (speechTime < 1) speechTime = 1;
+ if (speechTime < 1)
+ speechTime = 1;
if (sampleFile != -1) {
if (speechMode >= 1) {
#if 0
@@ -128,7 +130,7 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
while (strlen(theText) > wrap) {
a = wrap;
while (theText[a] != ' ') {
- a --;
+ a--;
if (a == 0) {
a = wrap;
break;
@@ -143,8 +145,12 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
addSpeechLine(theText, x, offset);
y -= fontHeight / cameraZoom;
- if (y < 0) speech->speechY -= y;
- else if (speech->speechY > cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom) speech->speechY = cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom;
+ if (y < 0)
+ speech->speechY -= y;
+ else if (speech->speechY
+ > cameraY + (float) (winHeight - fontHeight / 3) / cameraZoom)
+ speech->speechY = cameraY
+ + (float) (winHeight - fontHeight / 3) / cameraZoom;
if (offset) {
speechLine *viewLine = speech->allSpeech;
@@ -156,8 +162,13 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
return speechTime;
}
-int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile, bool animPerson) {
- int i = wrapSpeechXY(theText, thePerson.x - cameraX, thePerson.y - cameraY - (thePerson.scale * (thePerson.height - thePerson.floaty)) - thePerson.thisType->speechGap, thePerson.thisType->wrapSpeech, sampleFile);
+int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile,
+ bool animPerson) {
+ int i = wrapSpeechXY(theText, thePerson.x - cameraX,
+ thePerson.y - cameraY
+ - (thePerson.scale * (thePerson.height - thePerson.floaty))
+ - thePerson.thisType->speechGap,
+ thePerson.thisType->wrapSpeech, sampleFile);
if (animPerson) {
makeTalker(thePerson);
speech->currentTalker = &thePerson;
@@ -172,16 +183,20 @@ int wrapSpeech(char *theText, int objT, int sampleFile, bool animPerson) {
onScreenPerson *thisPerson = findPerson(objT);
if (thisPerson) {
setObjFontColour(thisPerson->thisType);
- i = wrapSpeechPerson(theText, * thisPerson, sampleFile, animPerson);
+ i = wrapSpeechPerson(theText, *thisPerson, sampleFile, animPerson);
} else {
screenRegion *thisRegion = getRegionForObject(objT);
if (thisRegion) {
setObjFontColour(thisRegion->thisType);
- i = wrapSpeechXY(theText, ((thisRegion->x1 + thisRegion->x2) >> 1) - cameraX, thisRegion->y1 - thisRegion->thisType->speechGap - cameraY, thisRegion->thisType->wrapSpeech, sampleFile);
+ i = wrapSpeechXY(theText,
+ ((thisRegion->x1 + thisRegion->x2) >> 1) - cameraX,
+ thisRegion->y1 - thisRegion->thisType->speechGap - cameraY,
+ thisRegion->thisType->wrapSpeech, sampleFile);
} else {
objectType *temp = findObjectType(objT);
setObjFontColour(temp);
- i = wrapSpeechXY(theText, winWidth >> 1, 10, temp->wrapSpeech, sampleFile);
+ i = wrapSpeechXY(theText, winWidth >> 1, 10, temp->wrapSpeech,
+ sampleFile);
}
}
return i;
diff --git a/engines/sludge/talk.h b/engines/sludge/talk.h
index 2ce4c4a72e..5e32def11e 100644
--- a/engines/sludge/talk.h
+++ b/engines/sludge/talk.h
@@ -32,7 +32,6 @@ struct speechLine {
int x;
};
-
struct speechStruct {
onScreenPerson *currentTalker;
speechLine *allSpeech;
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index c24946a5b1..7c588a283a 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -40,7 +40,6 @@ int thumbWidth = 0, thumbHeight = 0;
extern GLuint backdropTextureName;
#endif
-
bool saveThumbnail(Common::WriteStream *stream) {
#if 0
GLuint thumbnailTextureName = 0;
@@ -72,7 +71,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-
const GLfloat vertices[] = {
0., 0., 0.,
thumbWidth - 1.f, 0., 0.,
@@ -120,8 +118,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
glReadPixels(viewportOffsetX, viewportOffsetY, thumbWidth, thumbHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image);
#endif
-
-
glUseProgram(0);
#endif
setPixelCoords(false);
diff --git a/engines/sludge/timing.cpp b/engines/sludge/timing.cpp
index 887c4ed614..6bf68632d0 100644
--- a/engines/sludge/timing.cpp
+++ b/engines/sludge/timing.cpp
@@ -59,4 +59,5 @@ void Wait_Frame(void) {
}
#endif
-} // End of namespace Sludge
+}
+ // End of namespace Sludge
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 0fcd4fe7a4..73ac73736b 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -113,7 +113,7 @@ void transitionSnapshotBox() {
//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
- float xScale = (float) brightnessLevel * winWidth / 510.f; // 510 = 255*2
+ float xScale = (float) brightnessLevel * winWidth / 510.f;// 510 = 255*2
float yScale = (float) brightnessLevel * winHeight / 510.f;
const GLfloat vertices[] = {
@@ -187,7 +187,6 @@ bool reserveTransitionTexture() {
return true;
}
-
void transitionDisolve() {
#if 0
@@ -224,7 +223,7 @@ void transitionDisolve() {
toScreen[0] = toScreen[1] = toScreen[2] = toScreen[3] = 0;
}
toScreen += 4;
- } while (toScreen < end);
+ }while (toScreen < end);
texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
@@ -292,7 +291,7 @@ void transitionTV() {
toScreen[0] = toScreen[1] = toScreen[2] = toScreen[3] = 0;
}
toScreen += 4;
- } while (toScreen < end);
+ }while (toScreen < end);
texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index 928b65bb1a..8d6beb2536 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -41,10 +41,9 @@
namespace Sludge {
-const char *typeName[] = {"undefined", "number", "user function", "string",
- "built-in function", "file", "stack",
- "object type", "animation", "costume"
- };
+const char *typeName[] = { "undefined", "number", "user function", "string",
+ "built-in function", "file", "stack", "object type", "animation",
+ "costume" };
extern char *outputDir;
@@ -56,18 +55,19 @@ void unlinkVar(variable &thisVar) {
break;
case SVT_STACK:
- thisVar.varData.theStack -> timesUsed --;
- if (thisVar.varData.theStack -> timesUsed <= 0) {
- while (thisVar.varData.theStack -> first) trimStack(thisVar.varData.theStack -> first);
+ thisVar.varData.theStack->timesUsed--;
+ if (thisVar.varData.theStack->timesUsed <= 0) {
+ while (thisVar.varData.theStack->first)
+ trimStack(thisVar.varData.theStack->first);
delete thisVar.varData.theStack;
thisVar.varData.theStack = NULL;
}
break;
case SVT_FASTARRAY:
- thisVar.varData.fastArray -> timesUsed --;
- if (thisVar.varData.theStack -> timesUsed <= 0) {
- delete thisVar.varData.fastArray -> fastVariables;
+ thisVar.varData.fastArray->timesUsed--;
+ if (thisVar.varData.theStack->timesUsed <= 0) {
+ delete thisVar.varData.fastArray->fastVariables;
delete[] thisVar.varData.fastArray;
thisVar.varData.fastArray = NULL;
}
@@ -101,7 +101,8 @@ personaAnimation *getAnimationFromVar(variable &thisVar) {
if (thisVar.varType == SVT_INT && thisVar.varData.intValue == 0)
return makeNullAnim();
- fatal("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
+ fatal("Expecting an animation variable; found variable of type",
+ typeName[thisVar.varType]);
return NULL;
}
@@ -117,13 +118,15 @@ persona *getCostumeFromVar(variable &thisVar) {
switch (thisVar.varType) {
case SVT_ANIM:
p = new persona;
- if (! checkNew(p)) return NULL;
- p -> numDirections = 1;
- p -> animation = new personaAnimation * [3];
- if (! checkNew(p -> animation)) return NULL;
+ if (!checkNew(p))
+ return NULL;
+ p->numDirections = 1;
+ p->animation = new personaAnimation *[3];
+ if (!checkNew(p->animation))
+ return NULL;
- for (int iii = 0; iii < 3; iii ++)
- p -> animation[iii] = copyAnim(thisVar.varData.animHandler);
+ for (int iii = 0; iii < 3; iii++)
+ p->animation[iii] = copyAnim(thisVar.varData.animHandler);
break;
@@ -132,7 +135,8 @@ persona *getCostumeFromVar(variable &thisVar) {
break;
default:
- fatal("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
+ fatal("Expecting an animation variable; found variable of type",
+ typeName[thisVar.varType]);
}
return p;
@@ -140,10 +144,10 @@ persona *getCostumeFromVar(variable &thisVar) {
int stackSize(const stackHandler *me) {
int r = 0;
- variableStack *a = me -> first;
+ variableStack *a = me->first;
while (a) {
- r ++;
- a = a -> next;
+ r++;
+ a = a->next;
}
return r;
}
@@ -156,7 +160,8 @@ char *ConvertFromUTF16(const WCHAR *input);
bool getSavedGamesStack(stackHandler *sH, char *ext) {
char *pattern = joinStrings("*", ext);
- if (! pattern) return false;
+ if (!pattern)
+ return false;
variable newName;
newName.varType = SVT_NULL;
@@ -182,30 +187,32 @@ bool getSavedGamesStack(stackHandler *sH, char *ext) {
if (! addVarToStack(newName, sH -> first)) return false;
if (sH -> last == NULL) sH -> last = sH -> first;
keepGoing = FindNextFile(handle, & theData);
- } while (keepGoing);
+ }while (keepGoing);
FindClose(handle);
}
#else
DIR *dir = opendir(".");
- if (! dir) return false;
+ if (!dir)
+ return false;
struct dirent *d = readdir(dir);
while (d != NULL) {
- if (! strcmp(d->d_name + strlen(d->d_name) - strlen(ext), ext)) {
+ if (!strcmp(d->d_name + strlen(d->d_name) - strlen(ext), ext)) {
d->d_name[strlen(d->d_name) - strlen(ext)] = 0;
char *decoded = decodeFilename(d->d_name);
makeTextVar(newName, decoded);
delete[] decoded;
- if (! addVarToStack(newName, sH -> first)) return false;
- if (sH -> last == NULL) sH -> last = sH -> first;
+ if (!addVarToStack(newName, sH->first))
+ return false;
+ if (sH->last == NULL)
+ sH->last = sH->first;
}
d = readdir(dir);
}
-
closedir(dir);
#endif
@@ -218,11 +225,12 @@ bool getSavedGamesStack(stackHandler *sH, char *ext) {
bool copyStack(const variable &from, variable &to) {
to.varType = SVT_STACK;
to.varData.theStack = new stackHandler;
- if (! checkNew(to.varData.theStack)) return false;
- to.varData.theStack -> first = NULL;
- to.varData.theStack -> last = NULL;
- to.varData.theStack -> timesUsed = 1;
- variableStack *a = from.varData.theStack -> first;
+ if (!checkNew(to.varData.theStack))
+ return false;
+ to.varData.theStack->first = NULL;
+ to.varData.theStack->last = NULL;
+ to.varData.theStack->timesUsed = 1;
+ variableStack *a = from.varData.theStack->first;
#if DEBUG_STACKINESS
{
@@ -233,12 +241,12 @@ bool copyStack(const variable &from, variable &to) {
#endif
while (a) {
- addVarToStack(a -> thisVar, to.varData.theStack -> first);
- if (to.varData.theStack -> last == NULL) {
+ addVarToStack(a->thisVar, to.varData.theStack->first);
+ if (to.varData.theStack->last == NULL) {
#if DEBUG_STACKINESS
stackDebug((stackfp, "LAST"));
#endif
- to.varData.theStack -> last = to.varData.theStack -> first;
+ to.varData.theStack->last = to.varData.theStack->first;
}
#if DEBUG_STACKINESS
@@ -249,7 +257,7 @@ bool copyStack(const variable &from, variable &to) {
}
#endif
- a = a -> next;
+ a = a->next;
}
#if DEBUG_STACKINESS
@@ -265,10 +273,10 @@ bool copyStack(const variable &from, variable &to) {
}
/*void newStackVar (variable & thisVar) {
- unlinkVar (thisVar);
- thisVar.varType = VT_STACK;
- thisVar.varData.theStack = NULL;
-} */
+ unlinkVar (thisVar);
+ thisVar.varType = VT_STACK;
+ thisVar.varData.theStack = NULL;
+ } */
void addVariablesInSecond(variable &var1, variable &var2) {
if (var1.varType == SVT_INT && var2.varType == SVT_INT) {
@@ -330,7 +338,7 @@ void makeTextVar(variable &thisVar, const char *txt) {
bool loadStringToVar(variable &thisVar, int value) {
makeTextVar(thisVar, getNumberedString(value));
- return (bool)(thisVar.varData.theString != NULL);
+ return (bool) (thisVar.varData.theString != NULL);
}
char *getTextFromAnyVar(const variable &from) {
@@ -343,13 +351,16 @@ char *getTextFromAnyVar(const variable &from) {
char *builder2;
char *grabText;
- for (int i = 0; i < from.varData.fastArray -> size; i ++) {
+ for (int i = 0; i < from.varData.fastArray->size; i++) {
builder2 = joinStrings(builder, " ");
- if (! builder2) return NULL;
+ if (!builder2)
+ return NULL;
delete builder;
- grabText = getTextFromAnyVar(from.varData.fastArray -> fastVariables[i]);
+ grabText = getTextFromAnyVar(
+ from.varData.fastArray->fastVariables[i]);
builder = joinStrings(builder2, grabText);
- if (! builder) return NULL;
+ if (!builder)
+ return NULL;
delete grabText;
grabText = NULL;
delete builder2;
@@ -363,27 +374,30 @@ char *getTextFromAnyVar(const variable &from) {
char *builder2;
char *grabText;
- variableStack *stacky = from.varData.theStack -> first;
+ variableStack *stacky = from.varData.theStack->first;
while (stacky) {
builder2 = joinStrings(builder, " ");
- if (! builder2) return NULL;
+ if (!builder2)
+ return NULL;
delete builder;
- grabText = getTextFromAnyVar(stacky -> thisVar);
+ grabText = getTextFromAnyVar(stacky->thisVar);
builder = joinStrings(builder2, grabText);
- if (! builder) return NULL;
+ if (!builder)
+ return NULL;
delete grabText;
grabText = NULL;
delete builder2;
builder2 = NULL;
- stacky = stacky -> next;
+ stacky = stacky->next;
}
return builder;
}
case SVT_INT: {
char *buff = new char[10];
- if (! checkNew(buff)) return NULL;
+ if (!checkNew(buff))
+ return NULL;
sprintf(buff, "%i", from.varData.intValue);
return buff;
}
@@ -395,17 +409,18 @@ char *getTextFromAnyVar(const variable &from) {
return joinStrings("", resourceNameFromNum(from.varData.intValue));
}
- /* case SVT_ANIM:
- {
- char * buff = new char[20];
- if (! checkNew (buff)) return NULL;
- sprintf (buff, "%p", from.varData.animHandler);
- return buff;
- }*/
+ /* case SVT_ANIM:
+ {
+ char * buff = new char[20];
+ if (! checkNew (buff)) return NULL;
+ sprintf (buff, "%p", from.varData.animHandler);
+ return buff;
+ }*/
case SVT_OBJTYPE: {
objectType *thisType = findObjectType(from.varData.intValue);
- if (thisType) return copyString(thisType -> screenName);
+ if (thisType)
+ return copyString(thisType->screenName);
}
default:
@@ -421,16 +436,16 @@ bool getBoolean(const variable &from) {
return false;
case SVT_INT:
- return (bool)(from.varData.intValue != 0);
+ return (bool) (from.varData.intValue != 0);
case SVT_STACK:
- return (bool)(from.varData.theStack -> first != NULL);
+ return (bool) (from.varData.theStack->first != NULL);
case SVT_STRING:
- return (bool)(from.varData.theString[0] != 0);
+ return (bool) (from.varData.theString[0] != 0);
case SVT_FASTARRAY:
- return (bool)(from.varData.fastArray -> size != 0);
+ return (bool) (from.varData.fastArray->size != 0);
default:
break;
@@ -451,7 +466,7 @@ bool copyMain(const variable &from, variable &to) {
case SVT_FASTARRAY:
to.varData.fastArray = from.varData.fastArray;
- to.varData.fastArray -> timesUsed ++;
+ to.varData.fastArray->timesUsed++;
return true;
case SVT_STRING:
@@ -460,7 +475,7 @@ bool copyMain(const variable &from, variable &to) {
case SVT_STACK:
to.varData.theStack = from.varData.theStack;
- to.varData.theStack -> timesUsed ++;
+ to.varData.theStack->timesUsed++;
return true;
case SVT_COSTUME:
@@ -487,109 +502,124 @@ bool copyVariable(const variable &from, variable &to) {
}
variable *fastArrayGetByIndex(fastArrayHandler *vS, unsigned int theIndex) {
- if (theIndex < 0 || theIndex >= vS -> size) return NULL;
- return & vS -> fastVariables[theIndex];
+ if (theIndex < 0 || theIndex >= vS->size)
+ return NULL;
+ return &vS->fastVariables[theIndex];
}
bool makeFastArraySize(variable &to, int size) {
- if (size < 0) return fatal("Can't create a fast array with a negative number of elements!");
+ if (size < 0)
+ return fatal(
+ "Can't create a fast array with a negative number of elements!");
unlinkVar(to);
to.varType = SVT_FASTARRAY;
to.varData.fastArray = new fastArrayHandler;
- if (! checkNew(to.varData.fastArray)) return false;
- to.varData.fastArray -> fastVariables = new variable[size];
- if (! checkNew(to.varData.fastArray -> fastVariables)) return false;
- for (int i = 0; i < size; i ++) {
- initVarNew(to.varData.fastArray -> fastVariables[i]);
+ if (!checkNew(to.varData.fastArray))
+ return false;
+ to.varData.fastArray->fastVariables = new variable[size];
+ if (!checkNew(to.varData.fastArray->fastVariables))
+ return false;
+ for (int i = 0; i < size; i++) {
+ initVarNew(to.varData.fastArray->fastVariables[i]);
}
- to.varData.fastArray -> size = size;
- to.varData.fastArray -> timesUsed = 1;
+ to.varData.fastArray->size = size;
+ to.varData.fastArray->timesUsed = 1;
return true;
}
bool makeFastArrayFromStack(variable &to, const stackHandler *stacky) {
int size = stackSize(stacky);
- if (! makeFastArraySize(to, size)) return false;
+ if (!makeFastArraySize(to, size))
+ return false;
// Now let's fill up the new array
- variableStack *allV = stacky -> first;
+ variableStack *allV = stacky->first;
size = 0;
while (allV) {
- copyMain(allV -> thisVar, to.varData.fastArray -> fastVariables[size]);
- size ++;
- allV = allV -> next;
+ copyMain(allV->thisVar, to.varData.fastArray->fastVariables[size]);
+ size++;
+ allV = allV->next;
}
return true;
}
/*
-bool moveVariable (variable & from, variable & to) {
- unlinkVar (to);
- memcpy (& to, & from, sizeof (variable));
- from.varType = SVT_NULL;
-}
-*/
+ bool moveVariable (variable & from, variable & to) {
+ unlinkVar (to);
+ memcpy (& to, & from, sizeof (variable));
+ from.varType = SVT_NULL;
+ }
+ */
bool addVarToStack(const variable &va, variableStack *&thisStack) {
variableStack *newStack = new variableStack;
- if (! checkNew(newStack)) return false;
+ if (!checkNew(newStack))
+ return false;
- if (! copyMain(va, newStack -> thisVar)) return false;
- newStack -> next = thisStack;
+ if (!copyMain(va, newStack->thisVar))
+ return false;
+ newStack->next = thisStack;
thisStack = newStack;
- debug(kSludgeDebugStackMachine, "Variable %s was added to stack", getTextFromAnyVar(va));
+ debug(kSludgeDebugStackMachine, "Variable %s was added to stack",
+ getTextFromAnyVar(va));
return true;
}
bool addVarToStackQuick(variable &va, variableStack *&thisStack) {
variableStack *newStack = new variableStack;
- if (! checkNew(newStack)) return false;
+ if (!checkNew(newStack))
+ return false;
// if (! copyMain (va, newStack -> thisVar)) return false;
- memcpy(& (newStack -> thisVar), & va, sizeof(variable));
+ memcpy(&(newStack->thisVar), &va, sizeof(variable));
va.varType = SVT_NULL;
- newStack -> next = thisStack;
+ newStack->next = thisStack;
thisStack = newStack;
- debug(kSludgeDebugStackMachine, "Variable %s was added to stack quick", getTextFromAnyVar(va));
+ debug(kSludgeDebugStackMachine, "Variable %s was added to stack quick",
+ getTextFromAnyVar(va));
return true;
}
-bool stackSetByIndex(variableStack *vS, unsigned int theIndex, const variable &va) {
- while (theIndex --) {
- vS = vS -> next;
- if (! vS) return fatal("Index past end of stack.");
+bool stackSetByIndex(variableStack *vS, unsigned int theIndex,
+ const variable &va) {
+ while (theIndex--) {
+ vS = vS->next;
+ if (!vS)
+ return fatal("Index past end of stack.");
}
- return copyVariable(va, vS -> thisVar);
+ return copyVariable(va, vS->thisVar);
}
variable *stackGetByIndex(variableStack *vS, unsigned int theIndex) {
- while (theIndex --) {
- vS = vS -> next;
- if (! vS) {
+ while (theIndex--) {
+ vS = vS->next;
+ if (!vS) {
return NULL;
}
}
- return & (vS -> thisVar);
+ return &(vS->thisVar);
}
-int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOfEm) {
- variableStack * * huntVar = & thisStack;
+int deleteVarFromStack(const variable &va, variableStack *&thisStack,
+ bool allOfEm) {
+ variableStack * * huntVar = &thisStack;
variableStack *killMe;
int reply = 0;
- while (* huntVar) {
- if (compareVars((* huntVar) -> thisVar, va)) {
- killMe = * huntVar;
- * huntVar = killMe -> next;
- unlinkVar(killMe -> thisVar);
+ while (*huntVar) {
+ if (compareVars((*huntVar)->thisVar, va)) {
+ killMe = *huntVar;
+ *huntVar = killMe->next;
+ unlinkVar(killMe->thisVar);
delete killMe;
- if (! allOfEm) return 1;
- reply ++;
+ if (!allOfEm)
+ return 1;
+ reply++;
} else {
- huntVar = & ((* huntVar) -> next);
+ huntVar = &((*huntVar)->next);
}
}
@@ -610,8 +640,12 @@ variableStack *stackFindLast(variableStack *hunt) {
bool getValueType(int &toHere, variableType vT, const variable &v) {
//if (! v) return false;
if (v.varType != vT) {
- char *e1 = joinStrings("Can only perform specified operation on a value which is of type ", typeName[vT]);
- char *e2 = joinStrings("... value supplied was of type ", typeName[v.varType]);
+ char *e1 =
+ joinStrings(
+ "Can only perform specified operation on a value which is of type ",
+ typeName[vT]);
+ char *e2 = joinStrings("... value supplied was of type ",
+ typeName[v.varType]);
fatal(e1, e2);
return false;
@@ -622,50 +656,51 @@ bool getValueType(int &toHere, variableType vT, const variable &v) {
void trimStack(variableStack *&stack) {
variableStack *killMe = stack;
- stack = stack -> next;
+ stack = stack->next;
- debug(kSludgeDebugStackMachine, "Variable %s was removed from stack", getTextFromAnyVar(killMe -> thisVar));
+ debug(kSludgeDebugStackMachine, "Variable %s was removed from stack",
+ getTextFromAnyVar(killMe->thisVar));
// When calling this, we've ALWAYS checked that stack != NULL
- unlinkVar(killMe -> thisVar);
+ unlinkVar(killMe->thisVar);
delete killMe;
}
/*
-void debugVar (FILE * fp, const variable & thisVar) {
- switch (thisVar.varType) {
- case SVT_INT:
- fprintf (fp, "integer value %i", thisVar.varData.intValue);
- break;
-
- case SVT_FUNC:
- fprintf (fp, "pointer to function %i", thisVar.varData.intValue);
- break;
-
- case SVT_BUILT:
- fprintf (fp, "pointer to bif %i", thisVar.varData.intValue);
- break;
-
- case SVT_OBJTYPE:
- fprintf (fp, "object type %i", thisVar.varData.intValue);
- break;
-
- case SVT_STRING:
- fprintf (fp, "\"%s\"", thisVar.varData.theString);
- break;
-
- case SVT_FILE:
- fprintf (fp, "file handle %i", thisVar.varData.intValue);
- break;
-
- case SVT_NULL:
- fprintf (fp, "null");
- break;
-
- default:
- fprintf (fp, "unknown variable type");
- break;
- }
-}
-*/
+ void debugVar (FILE * fp, const variable & thisVar) {
+ switch (thisVar.varType) {
+ case SVT_INT:
+ fprintf (fp, "integer value %i", thisVar.varData.intValue);
+ break;
+
+ case SVT_FUNC:
+ fprintf (fp, "pointer to function %i", thisVar.varData.intValue);
+ break;
+
+ case SVT_BUILT:
+ fprintf (fp, "pointer to bif %i", thisVar.varData.intValue);
+ break;
+
+ case SVT_OBJTYPE:
+ fprintf (fp, "object type %i", thisVar.varData.intValue);
+ break;
+
+ case SVT_STRING:
+ fprintf (fp, "\"%s\"", thisVar.varData.theString);
+ break;
+
+ case SVT_FILE:
+ fprintf (fp, "file handle %i", thisVar.varData.intValue);
+ break;
+
+ case SVT_NULL:
+ fprintf (fp, "null");
+ break;
+
+ default:
+ fprintf (fp, "unknown variable type");
+ break;
+ }
+ }
+ */
} // End of namespace Sludge
diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h
index 8f9f743fb8..295473e55c 100644
--- a/engines/sludge/variable.h
+++ b/engines/sludge/variable.h
@@ -27,41 +27,50 @@ namespace Sludge {
struct variable;
struct variableStack;
-enum variableType {SVT_NULL, SVT_INT, SVT_FUNC, SVT_STRING,
- SVT_BUILT, SVT_FILE, SVT_STACK,
- SVT_OBJTYPE, SVT_ANIM, SVT_COSTUME,
- SVT_FASTARRAY, SVT_NUM_TYPES
- };
+enum variableType {
+ SVT_NULL,
+ SVT_INT,
+ SVT_FUNC,
+ SVT_STRING,
+ SVT_BUILT,
+ SVT_FILE,
+ SVT_STACK,
+ SVT_OBJTYPE,
+ SVT_ANIM,
+ SVT_COSTUME,
+ SVT_FASTARRAY,
+ SVT_NUM_TYPES
+};
struct fastArrayHandler {
- struct variable *fastVariables;
- int size;
- int timesUsed;
+ struct variable *fastVariables;
+ int size;
+ int timesUsed;
};
struct stackHandler {
- struct variableStack *first;
- struct variableStack *last;
- int timesUsed;
+ struct variableStack *first;
+ struct variableStack *last;
+ int timesUsed;
};
union variableData {
- signed int intValue;
- char *theString;
- stackHandler *theStack;
- struct personaAnimation *animHandler;
- struct persona *costumeHandler;
- fastArrayHandler *fastArray;
+ signed int intValue;
+ char *theString;
+ stackHandler *theStack;
+ struct personaAnimation *animHandler;
+ struct persona *costumeHandler;
+ fastArrayHandler *fastArray;
};
struct variable {
- variableType varType;
- variableData varData;
+ variableType varType;
+ variableData varData;
};
struct variableStack {
- variable thisVar;
- variableStack *next;
+ variable thisVar;
+ variableStack *next;
};
// Initialisation
@@ -94,7 +103,8 @@ bool getValueType(int &toHere, variableType vT, const variable &v);
bool addVarToStack(const variable &va, variableStack *&thisStack);
bool addVarToStackQuick(variable &va, variableStack *&thisStack);
void trimStack(variableStack *&stack);
-int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOfEm = false);
+int deleteVarFromStack(const variable &va, variableStack *&thisStack,
+ bool allOfEm = false);
variableStack *stackFindLast(variableStack *hunt);
bool copyStack(const variable &from, variable &to);
int stackSize(const stackHandler *me);
@@ -106,7 +116,6 @@ bool makeFastArrayFromStack(variable &to, const stackHandler *stacky);
bool makeFastArraySize(variable &to, int size);
variable *fastArrayGetByIndex(fastArrayHandler *vS, unsigned int theIndex);
-
#define DEBUG_STACKINESS 0
#if DEBUG_STACKINESS
diff --git a/engines/sludge/vid.cpp b/engines/sludge/vid.cpp
index 13eea5263c..00e2063938 100644
--- a/engines/sludge/vid.cpp
+++ b/engines/sludge/vid.cpp
@@ -40,10 +40,10 @@
namespace Sludge {
struct timStream {
- PAVISTREAM got;
- AVISTREAMINFO info;
- LONG chunkSize;
- LPBYTE chunk;
+ PAVISTREAM got;
+ AVISTREAMINFO info;
+ LONG chunkSize;
+ LPBYTE chunk;
};
static PAVIFILE pAviFile = NULL;
@@ -64,27 +64,32 @@ extern HWND hMainWindow;
void initialiseMovieStuff() {
char buffer[500];
- if (ExpandEnvironmentStrings("%temp%", buffer, 499) == 0) buffer[0] = NULL;
+ if (ExpandEnvironmentStrings("%temp%", buffer, 499) == 0)
+ buffer[0] = NULL;
videoFile = joinStrings(buffer, "\\test.avi");
// warning (videoFile);
}
bool getStream(DWORD type, timStream &intoHere) {
- if (AVIFileGetStream(pAviFile, & intoHere.got, type, 0)) {
+ if (AVIFileGetStream(pAviFile, &intoHere.got, type, 0)) {
intoHere.got = NULL;
return true;
- } else if (AVIStreamInfo(intoHere.got, & intoHere.info, sizeof(AVISTREAMINFO))) {
+ } else if (AVIStreamInfo(intoHere.got, &intoHere.info,
+ sizeof(AVISTREAMINFO))) {
return fatal("Can't get stream info");
- } else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got), NULL, & intoHere.chunkSize)) {
+ } else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got),
+ NULL, &intoHere.chunkSize)) {
return fatal("Can't get stream chunk size");
} else {
// So far so good! Let's read a chunk of data (huh?)
intoHere.chunk = new BYTE[intoHere.chunkSize];
- if (! intoHere.chunk) {
+ if (!intoHere.chunk) {
return fatal("Out of memory");
- } else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got), intoHere.chunk, & intoHere.chunkSize)) {
+ } else if (AVIStreamReadFormat(intoHere.got,
+ AVIStreamStart(intoHere.got), intoHere.chunk,
+ &intoHere.chunkSize)) {
return fatal("Couldn't read stream format");
}
}
@@ -97,46 +102,48 @@ void killStream(timStream &intoHere) {
}
/*
-#define WAVHEADERSIZE 20
-char wavHeader[WAVHEADERSIZE] = {'R', 'I', 'F', 'F', 0, 0, 0, 0,
- 'W', 'A', 'V', 'E', 'f', 'm', 't',
- 0x20, 0x10, 0, 0, 0};
-
-void handleAudio () {
- LONG aSize;
-
- if(AVIStreamRead(audio.got, 0, AVISTREAMREAD_CONVENIENT, NULL, 0, & aSize, NULL)) return;
-
- int totalSize = aSize + audio.chunkSize + WAVHEADERSIZE + 4;
-
- LPBYTE pBuffer = new BYTE[totalSize];
- if (!pBuffer) return;
-
- memcpy (pBuffer, wavHeader, WAVHEADERSIZE);
- pBuffer[4] = (char) (aSize);
- pBuffer[5] = (char) (aSize >> 8);
- memcpy (pBuffer + WAVHEADERSIZE, audio.chunk, audio.chunkSize);
- memcpy (pBuffer + WAVHEADERSIZE + audio.chunkSize, "data", 4);
-
- if(! AVIStreamRead (audio.got, 0, AVISTREAMREAD_CONVENIENT, pBuffer + audio.chunkSize + WAVHEADERSIZE + 4, aSize, NULL, NULL)) {
- FILE * fp = fopen ("test.wav", "wb");
- if (fp) {
- fwrite (pBuffer, 1, totalSize, fp);
- fclose (fp);
- }
- int i = fakeCacheSoundForVideo ((char *) pBuffer, totalSize);
- if (i != -1) startSound (i, false);
- }
-
- delete pBuffer;
-}
-*/
+ #define WAVHEADERSIZE 20
+ char wavHeader[WAVHEADERSIZE] = {'R', 'I', 'F', 'F', 0, 0, 0, 0,
+ 'W', 'A', 'V', 'E', 'f', 'm', 't',
+ 0x20, 0x10, 0, 0, 0};
+
+ void handleAudio () {
+ LONG aSize;
+
+ if(AVIStreamRead(audio.got, 0, AVISTREAMREAD_CONVENIENT, NULL, 0, & aSize, NULL)) return;
+
+ int totalSize = aSize + audio.chunkSize + WAVHEADERSIZE + 4;
+
+ LPBYTE pBuffer = new BYTE[totalSize];
+ if (!pBuffer) return;
+
+ memcpy (pBuffer, wavHeader, WAVHEADERSIZE);
+ pBuffer[4] = (char) (aSize);
+ pBuffer[5] = (char) (aSize >> 8);
+ memcpy (pBuffer + WAVHEADERSIZE, audio.chunk, audio.chunkSize);
+ memcpy (pBuffer + WAVHEADERSIZE + audio.chunkSize, "data", 4);
+
+ if(! AVIStreamRead (audio.got, 0, AVISTREAMREAD_CONVENIENT, pBuffer + audio.chunkSize + WAVHEADERSIZE + 4, aSize, NULL, NULL)) {
+ FILE * fp = fopen ("test.wav", "wb");
+ if (fp) {
+ fwrite (pBuffer, 1, totalSize, fp);
+ fclose (fp);
+ }
+ int i = fakeCacheSoundForVideo ((char *) pBuffer, totalSize);
+ if (i != -1) startSound (i, false);
+ }
+
+ delete pBuffer;
+ }
+ */
void finishVideo() {
videoPlaying = false;
AVIStreamGetFrameClose(pgf);
- if (audio.got) AVIStreamRelease(audio.got);
- if (video.got) AVIStreamRelease(video.got);
+ if (audio.got)
+ AVIStreamRelease(audio.got);
+ if (video.got)
+ AVIStreamRelease(video.got);
killStream(audio);
killStream(video);
AVIFileRelease(pAviFile);
@@ -144,17 +151,19 @@ void finishVideo() {
#ifdef _MSC_VER
_unlink(videoFile);
#else
- unlink(videoFile);
+ unlink(videoFile)
+;
#endif
}
#define COPYSIZE 256
bool extractSlice(int fileNum, char *toName) {
- unsigned char buff[COPYSIZE];
+unsigned char buff[COPYSIZE];
- unsigned long fileLength = openFileFromNum(fileNum);
- if (! fileLength) return false; // Error already displayed
+unsigned long fileLength = openFileFromNum(fileNum);
+if (!fileLength)
+ return false; // Error already displayed
#if 0
FILE *copyVid = fopen(toName, "wb");
if (! copyVid) return fatal("Can't extract resource");
@@ -171,94 +180,100 @@ bool extractSlice(int fileNum, char *toName) {
fclose(copyVid);
#endif
- finishAccess();
+finishAccess();
- return true;
+return true;
}
bool startVideo(int fileNum) {
- setResourceForFatal(fileNum);
+setResourceForFatal(fileNum);
- AVIFILEINFO info;
+AVIFILEINFO info;
- if (videoPlaying) finishVideo();
- AVIFileInit();
+if (videoPlaying)
+ finishVideo();
+AVIFileInit();
- if (! extractSlice(fileNum, videoFile)) return false;
- if (AVIFileOpen(& pAviFile, videoFile, OF_READ, NULL))
- return fatal(ERROR_AVI_FILE_ERROR);
+if (!extractSlice(fileNum, videoFile))
+ return false;
+if (AVIFileOpen(&pAviFile, videoFile, OF_READ, NULL))
+ return fatal(ERROR_AVI_FILE_ERROR);
- AVIFileInfo(pAviFile, &info, sizeof(info));
+AVIFileInfo(pAviFile, &info, sizeof(info));
- if (! getStream(streamtypeAUDIO, audio)) return false;
- if (! getStream(streamtypeVIDEO, video)) return false;
+if (!getStream(streamtypeAUDIO, audio))
+ return false;
+if (!getStream(streamtypeVIDEO, video))
+ return false;
- if (! video.got) return fatal(ERROR_AVI_NO_STREAM);
+if (!video.got)
+ return fatal(ERROR_AVI_NO_STREAM);
// if (audio.got) handleAudio ();
- pgf = AVIStreamGetFrameOpen(video.got, NULL);
- if (!pgf) return fatal(ERROR_AVI_ARGH);
+pgf = AVIStreamGetFrameOpen(video.got, NULL);
+if (!pgf)
+ return fatal(ERROR_AVI_ARGH);
- LPBITMAPINFO pInfo = (LPBITMAPINFO)(video.chunk);
- vidBytesPerPixel = pInfo -> bmiHeader.biBitCount / 8;
- biSize = pInfo -> bmiHeader.biSize;
- vidWidth = pInfo -> bmiHeader.biWidth;
- vidHeight = pInfo -> bmiHeader.biHeight;
+LPBITMAPINFO pInfo = (LPBITMAPINFO)(video.chunk);
+vidBytesPerPixel = pInfo->bmiHeader.biBitCount / 8;
+biSize = pInfo->bmiHeader.biSize;
+vidWidth = pInfo->bmiHeader.biWidth;
+vidHeight = pInfo->bmiHeader.biHeight;
- videoFrameNum = 0;
- videoPlaying = true;
+videoFrameNum = 0;
+videoPlaying = true;
- setResourceForFatal(-1);
+setResourceForFatal(-1);
- return true;
+return true;
}
bool nextVideoFrame() {
- LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER) AVIStreamGetFrame(pgf, videoFrameNum);
- if (! lpbi) {
- finishVideo();
- return false;
- }
+LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER) AVIStreamGetFrame(pgf,
+ videoFrameNum);
+if (!lpbi) {
+ finishVideo();
+ return false;
+}
+
+BYTE *pData = (((BYTE *) lpbi) + lpbi->biSize);
+
+int xOff = (winWidth - vidWidth) >> 1;
+int yOff = (winHeight + vidHeight) >> 1;
+unsigned short int *startingPoint = screen + xOff + (yOff * winWidth);
- BYTE *pData = (((BYTE *) lpbi) + lpbi->biSize);
-
- int xOff = (winWidth - vidWidth) >> 1;
- int yOff = (winHeight + vidHeight) >> 1;
- unsigned short int *startingPoint = screen + xOff + (yOff * winWidth);
-
- for (int y = 0; y < vidHeight; y ++) {
- startingPoint -= winWidth;
- unsigned short int *toHere = startingPoint;
- for (int x = 0; x < vidWidth; x ++) {
- switch (vidBytesPerPixel) {
- case 1:
- (* toHere) = makeGrey(*pData);
- break;
-
- case 3:
- case 4:
- (* toHere) = makeColour(*(pData + 2), *(pData + 1), *pData);
- break;
-
- default: {
- WORD Pixel16 = * ((WORD *) pData);
- (* toHere) = makeColour(
- (((UINT)(Pixel16) >> 10) & 0x1F) << 3,
- (((UINT)(Pixel16) >> 5) & 0x1F) << 3,
- (((UINT)(Pixel16) >> 0) & 0x1F) << 3);
- }
+for (int y = 0; y < vidHeight; y++) {
+ startingPoint -= winWidth;
+ unsigned short int *toHere = startingPoint;
+ for (int x = 0; x < vidWidth; x++) {
+ switch (vidBytesPerPixel) {
+ case 1:
+ (*toHere) = makeGrey(*pData);
break;
- }
- pData += vidBytesPerPixel;
- toHere ++;
+
+ case 3:
+ case 4:
+ (*toHere) = makeColour(*(pData + 2), *(pData + 1), *pData);
+ break;
+
+ default: {
+ WORD Pixel16 = *((WORD *) pData);
+ (*toHere) = makeColour((((UINT)(Pixel16) >> 10) & 0x1F) << 3,
+ (((UINT)(Pixel16) >> 5) & 0x1F) << 3,
+ (((UINT)(Pixel16) >> 0) & 0x1F) << 3);
}
+ break;
+ }
+ pData += vidBytesPerPixel;
+ toHere++;
}
+}
- videoFrameNum ++;
+videoFrameNum++;
- return true;
+return true;
}
} // End of namespace Sludge
diff --git a/engines/sludge/winstuff.cpp b/engines/sludge/winstuff.cpp
index 266df699d9..a229225422 100644
--- a/engines/sludge/winstuff.cpp
+++ b/engines/sludge/winstuff.cpp
@@ -53,179 +53,178 @@
namespace Sludge {
-HINSTANCE hInst; // Handle of the main instance
-extern HWND hMainWindow;
+ HINSTANCE hInst; // Handle of the main instance
+ extern HWND hMainWindow;
-extern variableStack *noStack;
+ extern variableStack *noStack;
// The platform-specific functions - Windows edition.
-WCHAR *ConvertToUTF16(const char *input) {
- int s = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, input, -1, NULL, 0);
- WCHAR *ret = new WCHAR [s];
- checkNew(ret);
- /*int a = */MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, input, -1, ret, s);
- return ret;
-}
-
-char *ConvertFromUTF16(const WCHAR *input) {
- int s = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
- char *ret = new char [s];
- checkNew(ret);
- /*int a = */WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, s, NULL, NULL);
- return ret;
-}
-
-
-char *grabFileName() {
- OPENFILENAME ofn;
- WCHAR path[MAX_PATH];
- WCHAR file[MAX_PATH] = TEXT("");
-
- hInst = GetModuleHandle(NULL);
-
- memset(& ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = NULL;
- ofn.hInstance = hInst;
- ofn.nMaxFile = MAX_PATH;
- ofn.lpstrInitialDir = path;
- ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER;
- ofn.lpstrFilter = TEXT("SLUDGE games (*.SLG)\0*.slg\0\0");
- ofn.lpstrFile = file;
-
- if (GetOpenFileName(& ofn)) {
- return ConvertFromUTF16(file);
- } else {
- return NULL;
+ WCHAR *ConvertToUTF16(const char *input) {
+ int s = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, input, -1, NULL, 0);
+ WCHAR *ret = new WCHAR [s];
+ checkNew(ret);
+ /*int a = */MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, input, -1, ret, s);
+ return ret;
}
-}
-extern char **languageName;
-extern int *languageTable;
-
-HBITMAP hLogo = NULL;
-extern unsigned char *gameLogo;
+ char *ConvertFromUTF16(const WCHAR *input) {
+ int s = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
+ char *ret = new char [s];
+ checkNew(ret);
+ /*int a = */WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, s, NULL, NULL);
+ return ret;
+ }
-BOOL CALLBACK setupDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
- switch (message) {
- case WM_INITDIALOG:
- if (gameLogo) {
- hLogo = CreateBitmap(310, 88, 1, 32, gameLogo);
- SendDlgItemMessage(hDlg, 1003, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hLogo);
+ char *grabFileName() {
+ OPENFILENAME ofn;
+ WCHAR path[MAX_PATH];
+ WCHAR file[MAX_PATH] = TEXT("");
+
+ hInst = GetModuleHandle(NULL);
+
+ memset(& ofn, 0, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = NULL;
+ ofn.hInstance = hInst;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrInitialDir = path;
+ ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER;
+ ofn.lpstrFilter = TEXT("SLUDGE games (*.SLG)\0*.slg\0\0");
+ ofn.lpstrFile = file;
+
+ if (GetOpenFileName(& ofn)) {
+ return ConvertFromUTF16(file);
+ } else {
+ return NULL;
}
+ }
+
+ extern char **languageName;
+ extern int *languageTable;
+
+ HBITMAP hLogo = NULL;
+ extern unsigned char *gameLogo;
+
+ BOOL CALLBACK setupDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
+ switch (message) {
+ case WM_INITDIALOG:
+ if (gameLogo) {
+ hLogo = CreateBitmap(310, 88, 1, 32, gameLogo);
+ SendDlgItemMessage(hDlg, 1003, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hLogo);
+ }
- if (gameSettings.userFullScreen)
+ if (gameSettings.userFullScreen)
CheckDlgButton(hDlg, 1000, BST_CHECKED);
- else
+ else
CheckDlgButton(hDlg, 1000, BST_UNCHECKED);
- SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Default (best looking)")));
- SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Linear (faster but blurry)")));
- SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Off (blocky graphics)")));
+ SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Default (best looking)")));
+ SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Linear (faster but blurry)")));
+ SendDlgItemMessage(hDlg, 1002, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)TEXT("Off (blocky graphics)")));
- if (gameSettings.antiAlias < 0)
+ if (gameSettings.antiAlias < 0)
SendDlgItemMessage(hDlg, 1002, CB_SETCURSEL, 1, 0);
- else if (gameSettings.antiAlias)
+ else if (gameSettings.antiAlias)
SendDlgItemMessage(hDlg, 1002, CB_SETCURSEL, 0, 0);
- else
+ else
SendDlgItemMessage(hDlg, 1002, CB_SETCURSEL, 2, 0);
- if (gameSettings.numLanguages) {
- WCHAR text[20];
- for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
- if (languageName[i]) {
- WCHAR *w_lang = ConvertToUTF16(languageName[i]);
- SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)w_lang));
- delete w_lang;
- } else {
- swprintf(text, TEXT("Language %d"), i);
- SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)text));
+ if (gameSettings.numLanguages) {
+ WCHAR text[20];
+ for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
+ if (languageName[i]) {
+ WCHAR *w_lang = ConvertToUTF16(languageName[i]);
+ SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)w_lang));
+ delete w_lang;
+ } else {
+ swprintf(text, TEXT("Language %d"), i);
+ SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)text));
+ }
}
+ SendDlgItemMessage(hDlg, 1001, CB_SETCURSEL, getLanguageForFileB(), 0);
+ } else {
+ const WCHAR *text = TEXT("No translations available");
+ SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)text));
+ SendDlgItemMessage(hDlg, 1001, CB_SETCURSEL, 0, 0);
+ EnableWindow(GetDlgItem(hDlg, 1001), false);
}
- SendDlgItemMessage(hDlg, 1001, CB_SETCURSEL, getLanguageForFileB(), 0);
- } else {
- const WCHAR *text = TEXT("No translations available");
- SendDlgItemMessage(hDlg, 1001, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)text));
- SendDlgItemMessage(hDlg, 1001, CB_SETCURSEL, 0, 0);
- EnableWindow(GetDlgItem(hDlg, 1001), false);
- }
- return true;
-
- case WM_COMMAND:
- if (hLogo) DeleteObject(hLogo);
- switch (LOWORD(wParam)) {
- case IDOK:
-
- gameSettings.userFullScreen = (IsDlgButtonChecked(hDlg, 1000) == BST_CHECKED);
- gameSettings.antiAlias = SendDlgItemMessage(hDlg, 1002, CB_GETCURSEL, 0, 0);
- if (gameSettings.antiAlias == 0) gameSettings.antiAlias = 1;
- else if (gameSettings.antiAlias == 1) gameSettings.antiAlias = -1;
- else if (gameSettings.antiAlias == 2) gameSettings.antiAlias = 0;
+ return true;
+
+ case WM_COMMAND:
+ if (hLogo) DeleteObject(hLogo);
+ switch (LOWORD(wParam)) {
+ case IDOK:
+
+ gameSettings.userFullScreen = (IsDlgButtonChecked(hDlg, 1000) == BST_CHECKED);
+ gameSettings.antiAlias = SendDlgItemMessage(hDlg, 1002, CB_GETCURSEL, 0, 0);
+ if (gameSettings.antiAlias == 0) gameSettings.antiAlias = 1;
+ else if (gameSettings.antiAlias == 1) gameSettings.antiAlias = -1;
+ else if (gameSettings.antiAlias == 2) gameSettings.antiAlias = 0;
+
+ if (gameSettings.numLanguages) {
+ gameSettings.languageID = SendDlgItemMessage(hDlg, 1001, CB_GETCURSEL, 0, 0);
+ if (gameSettings.languageID < 0) gameSettings.languageID = 0;
+ gameSettings.languageID = languageTable[gameSettings.languageID];
+ }
+ EndDialog(hDlg, true);
+ return TRUE;
- if (gameSettings.numLanguages) {
- gameSettings.languageID = SendDlgItemMessage(hDlg, 1001, CB_GETCURSEL, 0, 0);
- if (gameSettings.languageID < 0) gameSettings.languageID = 0;
- gameSettings.languageID = languageTable[gameSettings.languageID];
+ case IDCANCEL:
+ EndDialog(hDlg, false);
+ return TRUE;
}
- EndDialog(hDlg, true);
- return TRUE;
-
- case IDCANCEL:
- EndDialog(hDlg, false);
- return TRUE;
+ break;
}
- break;
+ return false;
}
- return false;
-}
-int showSetupWindow() {
+ int showSetupWindow() {
- hInst = GetModuleHandle(NULL);
+ hInst = GetModuleHandle(NULL);
- if (! hInst) debugOut("ERROR: No hInst!\n");
+ if (! hInst) debugOut("ERROR: No hInst!\n");
- if (DialogBox(hInst, TEXT("SETUPWINDOW"), NULL, setupDlgProc)) return true;
- return false;
+ if (DialogBox(hInst, TEXT("SETUPWINDOW"), NULL, setupDlgProc)) return true;
+ return false;
-}
+ }
-void msgBox(const char *head, const char *msg) {
- WCHAR *w_head = ConvertToUTF16(head);
- WCHAR *w_msg = ConvertToUTF16(msg);
- MessageBox(NULL, w_msg, w_head, MB_OK | MB_ICONSTOP | MB_SYSTEMMODAL | MB_SETFOREGROUND);
- delete w_head;
- delete w_msg;
-}
+ void msgBox(const char *head, const char *msg) {
+ WCHAR *w_head = ConvertToUTF16(head);
+ WCHAR *w_msg = ConvertToUTF16(msg);
+ MessageBox(NULL, w_msg, w_head, MB_OK | MB_ICONSTOP | MB_SYSTEMMODAL | MB_SETFOREGROUND);
+ delete w_head;
+ delete w_msg;
+ }
-int msgBoxQuestion(const char *head, const char *msg) {
- WCHAR *w_head = ConvertToUTF16(head);
- WCHAR *w_msg = ConvertToUTF16(msg);
- int val = MessageBox(NULL, w_msg, w_head, MB_YESNO | MB_SETFOREGROUND | MB_APPLMODAL | MB_ICONQUESTION) == IDNO;
- delete w_head;
- delete w_msg;
- if (val)
+ int msgBoxQuestion(const char *head, const char *msg) {
+ WCHAR *w_head = ConvertToUTF16(head);
+ WCHAR *w_msg = ConvertToUTF16(msg);
+ int val = MessageBox(NULL, w_msg, w_head, MB_YESNO | MB_SETFOREGROUND | MB_APPLMODAL | MB_ICONQUESTION) == IDNO;
+ delete w_head;
+ delete w_msg;
+ if (val)
return false;
- return true;
-}
-
-void changeToUserDir() {
- TCHAR szAppData[MAX_PATH];
- /*hr = */SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);
- _wchdir(szAppData);
-}
-
-uint32_t launch(char *f) {
- WCHAR *w_f = ConvertToUTF16(f);
- uint32_t r = (uint32_t) ShellExecute(hMainWindow, TEXT("open"), w_f, NULL, TEXT("C:\\"), SW_SHOWNORMAL);
- delete w_f;
- return r;
-}
-
-bool defaultUserFullScreen() {
- return true;
-}
+ return true;
+ }
+
+ void changeToUserDir() {
+ TCHAR szAppData[MAX_PATH];
+ /*hr = */SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);
+ _wchdir(szAppData);
+ }
+
+ uint32_t launch(char *f) {
+ WCHAR *w_f = ConvertToUTF16(f);
+ uint32_t r = (uint32_t) ShellExecute(hMainWindow, TEXT("open"), w_f, NULL, TEXT("C:\\"), SW_SHOWNORMAL);
+ delete w_f;
+ return r;
+ }
+
+ bool defaultUserFullScreen() {
+ return true;
+ }
} // End of namespace Sludge
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index f73f4f6e7e..fe13a98116 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -47,13 +47,14 @@ void killZBuffer() {
void sortZPal(int *oldpal, int *newpal, int size) {
int i, tmp;
- for (i = 0; i < size; i ++) {
+ for (i = 0; i < size; i++) {
newpal[i] = i;
}
- if (size < 2) return;
+ if (size < 2)
+ return;
- for (i = 1; i < size; i ++) {
+ for (i = 1; i < size; i++) {
if (oldpal[newpal[i]] < oldpal[newpal[i - 1]]) {
tmp = newpal[i];
newpal[i] = newpal[i - 1];
@@ -80,17 +81,17 @@ bool setZBuffer(int y) {
if (fgetc(bigDataFile) != 'b') return fatal("Not a Z-buffer file");
switch (fgetc(bigDataFile)) {
- case 0:
+ case 0:
zBuffer.width = 640;
zBuffer.height = 480;
break;
- case 1:
+ case 1:
zBuffer.width = get2bytes(bigDataFile);
zBuffer.height = get2bytes(bigDataFile);
break;
- default:
+ default:
return fatal("Extended Z-buffer format not supported in this version of the SLUDGE engine");
}
if (zBuffer.width != sceneWidth || zBuffer.height != sceneHeight) {
diff --git a/engines/sludge/zbuffer.h b/engines/sludge/zbuffer.h
index 6fdbd0284e..46510ece71 100644
--- a/engines/sludge/zbuffer.h
+++ b/engines/sludge/zbuffer.h
@@ -44,7 +44,6 @@ struct zBufferData {
#endif
};
-
bool setZBuffer(int y);
void killZBuffer();
void drawZBuffer(int x, int y, bool upsidedown);