SLUDGE: format code and remove oneliners

This commit is contained in:
yinsimei 2017-06-05 11:49:19 +02:00 committed by Eugene Sandulenko
parent 414b3c4714
commit 10ff6994ae
31 changed files with 1448 additions and 1396 deletions

View File

@ -251,11 +251,11 @@ void killParallax() {
bool reserveBackdrop() {
cameraX = 0;
cameraY = 0;
input.mouseX = (int) ((float) input.mouseX * cameraZoom);
input.mouseY = (int) ((float) input.mouseY * cameraZoom);
input.mouseX = (int)((float)input.mouseX * cameraZoom);
input.mouseY = (int)((float)input.mouseY * cameraZoom);
cameraZoom = 1.0;
input.mouseX = (int) ((float) input.mouseX / cameraZoom);
input.mouseY = (int) ((float) input.mouseY / cameraZoom);
input.mouseX = (int)((float)input.mouseX / cameraZoom);
input.mouseY = (int)((float)input.mouseY / cameraZoom);
setPixelCoords(false);
int picWidth = sceneWidth;
int picHeight = sceneHeight;
@ -317,9 +317,7 @@ 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);
}
@ -348,10 +346,10 @@ void blankScreen(int x1, int y1, int x2, int y2) {
y1 = 0;
if (x1 < 0)
x1 = 0;
if (x2 > (int) sceneWidth)
x2 = (int) sceneWidth;
if (y2 > (int) sceneHeight)
y2 = (int) sceneHeight;
if (x2 > (int)sceneWidth)
x2 = (int)sceneWidth;
if (y2 > (int)sceneHeight)
y2 = (int)sceneHeight;
int picWidth = x2 - x1;
int picHeight = y2 - y1;
@ -467,13 +465,11 @@ void darkScreen() {
int xoffset = 0;
while (xoffset < sceneWidth) {
int w = (sceneWidth - xoffset < viewportWidth) ?
sceneWidth - xoffset : viewportWidth;
int w = (sceneWidth - xoffset < viewportWidth) ? sceneWidth - xoffset : viewportWidth;
int yoffset = 0;
while (yoffset < sceneHeight) {
int h = (sceneHeight - yoffset < viewportHeight) ?
sceneHeight - yoffset : viewportHeight;
int h = (sceneHeight - yoffset < viewportHeight) ? sceneHeight - yoffset : viewportHeight;
// Render the scene - first the old backdrop
#if 0
@ -533,8 +529,7 @@ void darkScreen() {
}
inline int sortOutPCamera(int cX, int fX, int sceneMax, int boxMax) {
return (fX == 65535) ?
(sceneMax ? ((cX * boxMax) / sceneMax) : 0) : ((cX * fX) / 100);
return (fX == 65535) ? (sceneMax ? ((cX * boxMax) / sceneMax) : 0) : ((cX * fX) / 100);
}
void drawBackDrop() {
@ -624,7 +619,8 @@ void drawBackDrop() {
bool loadLightMap(int v) {
setResourceForFatal(v);
if (!openFileFromNum(v)) return fatal("Can't open light map.");
if (!openFileFromNum(v))
return fatal("Can't open light map.");
killLightMap();
lightMapNumber = v;
@ -714,10 +710,12 @@ void reloadParallaxTextures() {
bool loadParallax(unsigned short v, unsigned short fracX, unsigned short fracY) {
setResourceForFatal(v);
if (!openFileFromNum(v)) return fatal("Can't open parallax image");
if (!openFileFromNum(v))
return fatal("Can't open parallax image");
parallaxLayer *nP = new parallaxLayer;
if (!checkNew(nP)) return false;
if (!checkNew(nP))
return false;
nP->next = parallaxStuff;
parallaxStuff = nP;
@ -924,15 +922,15 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
int realPicHeight = backdropSurface.h;
if (reserve) { // resize backdrop
if (!resizeBackdrop(realPicWidth, realPicHeight)) return false;
if (!resizeBackdrop(realPicWidth, realPicHeight))
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) {
if (x < 0 || x + realPicWidth > sceneWidth || y < 0 || y + realPicHeight > sceneHeight) {
debug(kSludgeDebugGraphics, "Illegal back drop size");
return false;
}
@ -957,9 +955,12 @@ bool mixHSI(Common::SeekableReadStream *stream, int x, int y) {
int realPicWidth = backdropSurface.w;
int realPicHeight = backdropSurface.h;
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;
#if 0
float btx1, tx1;
float btx2, tx2;
@ -1160,27 +1161,22 @@ void saveCorePNG(Common::WriteStream *stream, GLuint texture, int w, int h) {
#endif
}
#endif
#if 0
void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
GLint tw, th;
glBindTexture(GL_TEXTURE_2D, texture);
getTextureDimensions(texture, &tw, &th);
GLushort *image = new GLushort [tw * th];
if (!checkNew(image)) return;
GLushort *image = new GLushort[tw * th];
if (!checkNew(image))
return;
glPixelStorei(GL_PACK_ALIGNMENT, 1);
// glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image);
setPixelCoords(true);
//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
const GLfloat texCoords[] = {
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f
};
const GLfloat texCoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f };
int xoffset = 0;
while (xoffset < tw) {
@ -1189,13 +1185,9 @@ void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
int yoffset = 0;
while (yoffset < th) {
int h = (th - yoffset < viewportHeight) ? th - yoffset : viewportHeight;
glClear(GL_COLOR_BUFFER_BIT); // Clear The Screen
const GLfloat vertices[] = {
(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,
(GLfloat)w - xoffset, (GLfloat) - yoffset, 0.,
(GLfloat) - xoffset, (GLfloat) - yoffset + h, 0.,
(GLfloat)w - xoffset, (GLfloat) - yoffset + h, 0.
};
glClear (GL_COLOR_BUFFER_BIT); // Clear The Screen
const GLfloat vertices[] = { (GLfloat)-xoffset, (GLfloat)-yoffset, 0., (GLfloat)w - xoffset, (GLfloat)-yoffset, 0., (GLfloat)-xoffset, (GLfloat)-yoffset + h, 0., (GLfloat)w - xoffset,
(GLfloat)-yoffset + h, 0. };
glUseProgram(shader.texture);
setPMVMatrix(shader.texture);
@ -1203,7 +1195,7 @@ void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
glUseProgram(0);
for (int i = 0; i < h; i++) {
glReadPixels(viewportOffsetX, viewportOffsetY + i, w, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image + xoffset + (yoffset + i)*tw);
glReadPixels(viewportOffsetX, viewportOffsetY + i, w, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image + xoffset + (yoffset + i) * tw);
}
yoffset += viewportHeight;
}
@ -1214,32 +1206,34 @@ void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
setPixelCoords(false);
int x, y, lookAhead;
unsigned short int *fromHere, * lookPointer;
unsigned short int *fromHere, *lookPointer;
stream->writeUint16BE(w);
stream->writeUint16BE(h);
for (y = 0; y < h; y ++) {
for (y = 0; y < h; y++) {
fromHere = image + (y * tw);
x = 0;
while (x < w) {
lookPointer = fromHere + 1;
for (lookAhead = x + 1; lookAhead < w; lookAhead ++) {
if (lookAhead - x == 256) break;
if (* fromHere != * lookPointer) break;
lookPointer ++;
for (lookAhead = x + 1; lookAhead < w; lookAhead++) {
if (lookAhead - x == 256)
break;
if (*fromHere != *lookPointer)
break;
lookPointer++;
}
if (lookAhead == x + 1) {
put2bytes((* fromHere) & 65503, stream);
put2bytes((*fromHere) & 65503, stream);
} else {
stream->writeUint16BE(* fromHere | 32);
stream->writeUint16BE(*fromHere | 32);
stream->writeByte(lookAhead - x - 1);
}
fromHere = lookPointer;
x = lookAhead;
}
}
delete [] image;
delete[] image;
image = NULL;
}
#endif

View File

@ -64,14 +64,14 @@ static int s_matrixEffectBase = 15;
static int s_matrixEffectDivide = 4;
static int s_matrixEffectWidth = 3;
static int s_matrixEffectHeight = 3;
static int s_matrixEffectData[9] = { -2, -1, 0, -1, 1, 1, 0, 1, 2};
static int s_matrixEffectData[9] = {-2, -1, 0, -1, 1, 1, 0, 1, 2};
static int s_matrixEffectBase = 16;
#elif 0
// Standard emboss
static int s_matrixEffectDivide = 2;
static int s_matrixEffectWidth = 3;
static int s_matrixEffectHeight = 3;
static int s_matrixEffectData[9] = { -1, 0, 0, 0, 0, 0, 0, 0, 1};
static int s_matrixEffectData[9] = {-1, 0, 0, 0, 0, 0, 0, 0, 1};
static int s_matrixEffectBase = 128;
#elif 0
// Horizontal blur
@ -92,7 +92,7 @@ static int s_matrixEffectBase = 0;
static int s_matrixEffectDivide = 1;
static int s_matrixEffectWidth = 1;
static int s_matrixEffectHeight = 1;
static int s_matrixEffectData[9] = { -1};
static int s_matrixEffectData[9] = {-1};
static int s_matrixEffectBase = 255;
#elif 0
// Fog
@ -136,7 +136,7 @@ static int *blur_allocateMemoryForEffect() {
s_matrixEffectData = NULL;
if (s_matrixEffectWidth && s_matrixEffectHeight) {
s_matrixEffectData = (int *) malloc(sizeof(int) * s_matrixEffectHeight * s_matrixEffectWidth);
s_matrixEffectData = (int *)malloc(sizeof(int) * s_matrixEffectHeight * s_matrixEffectWidth);
checkNew(s_matrixEffectData);
}
return s_matrixEffectData;
@ -169,7 +169,7 @@ bool blur_createSettings(int numParams, variableStack *&stack) {
int width = 0;
variableStack *justToCheckSizes = stack;
for (int a = 0; a < height; a ++) {
for (int a = 0; a < height; a++) {
if (justToCheckSizes->thisVar.varType != SVT_STACK) {
error = "Third and subsequent parameters in setBackgroundEffect should be arrays";
break;
@ -189,19 +189,19 @@ bool blur_createSettings(int numParams, variableStack *&stack) {
}
}
if (width == 0 && ! error) {
if (width == 0 && !error) {
error = "Empty arrays found in setBackgroundEffect parameters";
}
if (! error) {
if (!error) {
s_matrixEffectWidth = width;
s_matrixEffectHeight = height;
if (blur_allocateMemoryForEffect()) {
for (int y = height - 1; y >= 0; y --) {
for (int y = height - 1; y >= 0; y--) {
variableStack *eachNumber = stack->thisVar.varData.theStack->first;
if (! error) {
for (int x = 0; x < width; x ++) {
if (!error) {
for (int x = 0; x < width; x++) {
int arraySlot = x + (y * width);
// s_matrixEffectData[arraySlot] = (rand() % 4);
if (!getValueType(s_matrixEffectData[arraySlot], SVT_INT, eachNumber->thisVar)) {
@ -213,13 +213,13 @@ bool blur_createSettings(int numParams, variableStack *&stack) {
trimStack(stack);
}
}
if (! error && !getValueType(s_matrixEffectDivide, SVT_INT, stack -> thisVar))
if (!error && !getValueType(s_matrixEffectDivide, SVT_INT, stack->thisVar))
error = "";
trimStack(stack);
if (! error && !getValueType(s_matrixEffectBase, SVT_INT, stack -> thisVar))
if (!error && !getValueType(s_matrixEffectBase, SVT_INT, stack->thisVar))
error = "";
trimStack(stack);
if (! error) {
if (!error) {
if (s_matrixEffectDivide) {
createNullThing = false;
} else {
@ -249,7 +249,7 @@ bool blur_createSettings(int numParams, variableStack *&stack) {
fatal(error);
}
return ! createNullThing;
return !createNullThing;
}
static inline int clampi(int i, int min, int max) {
@ -260,13 +260,13 @@ static inline void blur_createSourceLine(unsigned char *createLine, unsigned cha
int miniX;
memcpy(createLine + overlapOnLeft * 4, fromLine, width * 4);
for (miniX = 0; miniX < overlapOnLeft; miniX ++) {
for (miniX = 0; miniX < overlapOnLeft; miniX++) {
createLine[miniX * 4] = fromLine[0];
createLine[miniX * 4 + 1] = fromLine[1];
createLine[miniX * 4 + 2] = fromLine[2];
}
for (miniX = width + overlapOnLeft; miniX < width + s_matrixEffectWidth - 1; miniX ++) {
for (miniX = width + overlapOnLeft; miniX < width + s_matrixEffectWidth - 1; miniX++) {
createLine[miniX * 4] = fromLine[width * 4 - 4];
createLine[miniX * 4 + 1] = fromLine[width * 4 - 3];
createLine[miniX * 4 + 2] = fromLine[width * 4 - 2];
@ -280,15 +280,16 @@ bool blurScreen() {
int y, x;
bool ok = true;
int overlapOnLeft = s_matrixEffectWidth / 2;
int overlapAbove = s_matrixEffectHeight / 2;
int overlapAbove = s_matrixEffectHeight / 2;
unsigned char **sourceLine = new unsigned char *[s_matrixEffectHeight];
if (! checkNew(sourceLine)) return false;
if (!checkNew(sourceLine))
return false;
int picWidth = sceneWidth;
int picHeight = sceneHeight;
if (! NPOT_textures) {
if (!NPOT_textures) {
picWidth = getNextPOT(sceneWidth);
picHeight = getNextPOT(sceneHeight);
}
@ -296,26 +297,26 @@ bool blurScreen() {
// Retrieve the texture
saveTexture(backdropTextureName, backdropTexture);
for (y = 0; y < s_matrixEffectHeight; y ++) {
for (y = 0; y < s_matrixEffectHeight; y++) {
sourceLine[y] = new unsigned char[(s_matrixEffectWidth - 1 + picWidth) * 4];
ok &= (sourceLine[y] != NULL);
}
if (ok) {
for (y = 0; y < s_matrixEffectHeight; y ++) {
for (y = 0; y < s_matrixEffectHeight; y++) {
int miniY = clampi(y - overlapAbove - 1, 0, sceneHeight - 1);
blur_createSourceLine(sourceLine[y], backdropTexture + miniY * picWidth * 4, overlapOnLeft, picWidth);
}
for (y = 0; y < sceneHeight; y ++) {
for (y = 0; y < sceneHeight; y++) {
thisLine = backdropTexture + y * picWidth * 4;
//-------------------------
// Scroll source lines
//-------------------------
unsigned char *tempLine = sourceLine[0];
for (int miniY = 0; miniY < s_matrixEffectHeight - 1; miniY ++) {
for (int miniY = 0; miniY < s_matrixEffectHeight - 1; miniY++) {
sourceLine[miniY] = sourceLine[miniY + 1];
}
sourceLine[s_matrixEffectHeight - 1] = tempLine;
@ -325,19 +326,19 @@ bool blurScreen() {
blur_createSourceLine(sourceLine[h], backdropTexture + miniY * picWidth * 4, overlapOnLeft, picWidth);
}
for (x = 0; x < sceneWidth; x ++) {
for (x = 0; x < sceneWidth; x++) {
int totalRed = 0;
int totalGreen = 0;
int totalBlue = 0;
int *matrixElement = s_matrixEffectData;
for (int miniY = 0; miniY < s_matrixEffectHeight; ++ miniY) {
unsigned char *pixel = & sourceLine[miniY][x * 4];
for (int miniX = 0; miniX < s_matrixEffectWidth; ++ miniX) {
for (int miniY = 0; miniY < s_matrixEffectHeight; ++miniY) {
unsigned char *pixel = &sourceLine[miniY][x * 4];
for (int miniX = 0; miniX < s_matrixEffectWidth; ++miniX) {
totalRed += pixel[0] * * matrixElement;
totalGreen += pixel[1] * * matrixElement;
totalBlue += pixel[2] * * matrixElement;
++ matrixElement;
totalRed += pixel[0] * *matrixElement;
totalGreen += pixel[1] * *matrixElement;
totalBlue += pixel[2] * *matrixElement;
++matrixElement;
pixel += 4;
}
}
@ -350,19 +351,19 @@ bool blurScreen() {
totalBlue = (totalBlue + s_matrixEffectDivide / 2) / s_matrixEffectDivide + s_matrixEffectBase;
totalBlue = (totalBlue < 0) ? 0 : ((totalBlue > 255) ? 255 : totalBlue);
* thisLine = totalRed;
++ thisLine;
* thisLine = totalGreen;
++ thisLine;
* thisLine = totalBlue;
++ thisLine;
// * thisLine = totalAlpha;
++ thisLine;
*thisLine = totalRed;
++thisLine;
*thisLine = totalGreen;
++thisLine;
*thisLine = totalBlue;
++thisLine;
// *thisLine = totalAlpha;
++thisLine;
}
}
}
for (y = 0; y < s_matrixEffectHeight; y ++) {
for (y = 0; y < s_matrixEffectHeight; y++) {
delete sourceLine[y];
}
delete sourceLine;

File diff suppressed because it is too large Load Diff

View File

@ -56,9 +56,9 @@ namespace Sludge {
#define ERROR_MUSIC_MEMORY_LOW "Your computer doesn't have enough memory available to load a music resource that needs playing." _NO_MEMORY_GENERAL_
#define ERROR_SOUND_MEMORY_LOW "Your computer doesn't have enough memory available to load a sound resource that needs playing." _NO_MEMORY_GENERAL_
#define ERROR_MUSIC_UNKNOWN "I can't understand a piece of music which I've been told to play!\n\n" \
"Maybe it's stored in a format that SLUDGE doesn't know about... " \
"make sure you've got a recent version of the SLUDGE engine from http://opensludge.github.io/. " \
"Failing that, maybe the resource in question isn't a valid music format at all... in which case, contact the game's author and tell them what's happened."
"Maybe it's stored in a format that SLUDGE doesn't know about... " \
"make sure you've got a recent version of the SLUDGE engine from http://opensludge.github.io/. " \
"Failing that, maybe the resource in question isn't a valid music format at all... in which case, contact the game's author and tell them what's happened."
#define ERROR_SOUND_UNKNOWN "I can't understand a sample which I've been told to play!\nMake sure you've got the latest SLUDGE engine from http://opensludge.github.io/. Failing that, maybe the resource in question isn't a valid sound at all... in which case, contact the game's author and tell them what's happened."
#define ERROR_MUSIC_ODDNESS "I can't load a music resource I've been told to play. Sorry."
#define ERROR_SOUND_ODDNESS "I can't load a sound resource I've been told to play. Sorry."

View File

@ -44,8 +44,7 @@ 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");
@ -199,8 +198,7 @@ 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;

View File

@ -42,17 +42,14 @@ bool pointInFloorPolygon(floorPolygon &floorPoly, int x, int 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;
}
}
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;
@ -147,8 +144,7 @@ bool setFloor(int fileNum) {
// Find out how many vertex IDs there are and reserve memory
currentFloor->polygon[i].numVertices = bigDataFile->readByte();
currentFloor->polygon[i].vertexID =
new int[currentFloor->polygon[i].numVertices];
currentFloor->polygon[i].vertexID = new int[currentFloor->polygon[i].numVertices];
if (!checkNew(currentFloor->polygon[i].vertexID))
return false;
@ -196,8 +192,7 @@ bool setFloor(int fileNum) {
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])) {
if (polysShareSide(currentFloor->polygon[i], currentFloor->polygon[j])) {
currentFloor->matrix[i][j] = j;
distanceMatrix[i][j] = 1;
}
@ -222,11 +217,7 @@ bool setFloor(int fileNum) {
// OK, so we don't know how to get from i to j...
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;
madeChange = true;
@ -257,21 +248,11 @@ void drawFloor() {
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);
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);
}
}
}
@ -286,8 +267,7 @@ int inFloor(int x, int y) {
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;

View File

@ -54,8 +54,7 @@ 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

View File

@ -94,17 +94,16 @@ void pasteString(char *theText, int xOff, int y, spritePalette &thePal) {
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->surface.w + fontSpace) / cameraZoom);
xOff += (int)((double)(mySprite->surface.w + 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;
@ -121,8 +120,7 @@ void pasteStringToBackdrop(char *theText, int xOff, int y,
}
}
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;

View File

@ -156,7 +156,7 @@ bool freeze() {
// Grab a copy of the current scene
freezeGraphics();
#if 0
newFreezer -> backdropTextureName = backdropTextureName;
newFreezer->backdropTextureName = backdropTextureName;
#endif
int picWidth = sceneWidth;
int picHeight = sceneHeight;
@ -165,8 +165,9 @@ bool freeze() {
picHeight = getNextPOT(picHeight);
}
#if 0
newFreezer -> backdropTexture = new GLubyte [picHeight * picWidth * 4];
if (! checkNew(newFreezer -> backdropTexture)) return false;
newFreezer->backdropTexture = new GLubyte[picHeight * picWidth * 4];
if (!checkNew(newFreezer->backdropTexture))
return false;
saveTexture(backdropTextureName, newFreezer->backdropTexture);
@ -178,16 +179,16 @@ bool freeze() {
newFreezer->cameraY = cameraY;
newFreezer->cameraZoom = cameraZoom;
#if 0
newFreezer -> lightMapTexture = lightMap.data;
newFreezer -> lightMapTextureName = lightMap.name;
newFreezer -> lightMapNumber = lightMapNumber;
newFreezer->lightMapTexture = lightMap.data;
newFreezer->lightMapTextureName = lightMap.name;
newFreezer->lightMapNumber = lightMapNumber;
lightMap.data = NULL;
lightMap.name = 0;
newFreezer -> parallaxStuff = parallaxStuff;
newFreezer->parallaxStuff = parallaxStuff;
parallaxStuff = NULL;
newFreezer -> zBufferImage = zBuffer.tex;
newFreezer -> zBufferNumber = zBuffer.originalNum;
newFreezer -> zPanels = zBuffer.numPanels;
newFreezer->zBufferImage = zBuffer.tex;
newFreezer->zBufferNumber = zBuffer.originalNum;
newFreezer->zPanels = zBuffer.numPanels;
zBuffer.tex = NULL;
#endif
// resizeBackdrop kills parallax stuff, light map, z-buffer...
@ -198,8 +199,8 @@ bool freeze() {
picWidth = getNextPOT(sceneWidth);
picHeight = getNextPOT(sceneHeight);
#if 0
backdropTexW = (double) sceneWidth / picWidth;
backdropTexH = (double) sceneHeight / picHeight;
backdropTexW = (double)sceneWidth / picWidth;
backdropTexH = (double)sceneHeight / picHeight;
#endif
}
@ -210,19 +211,19 @@ bool freeze() {
backdropExists = true;
// Free texture memory used by old stuff
parallaxStuff = newFreezer -> parallaxStuff;
parallaxStuff = newFreezer->parallaxStuff;
while (parallaxStuff) {
deleteTextures(1, &parallaxStuff -> textureName);
parallaxStuff = parallaxStuff -> next;
deleteTextures(1, &parallaxStuff->textureName);
parallaxStuff = parallaxStuff->next;
}
if (newFreezer -> zBufferImage) {
if (newFreezer->zBufferImage) {
deleteTextures(1, &zBuffer.texName);
}
if (newFreezer -> lightMapTextureName) {
deleteTextures(1, &newFreezer -> lightMapTextureName);
if (newFreezer->lightMapTextureName) {
deleteTextures(1, &newFreezer->lightMapTextureName);
}
if (newFreezer -> backdropTextureName) {
deleteTextures(1, &newFreezer -> backdropTextureName);
if (newFreezer->backdropTextureName) {
deleteTextures(1, &newFreezer->backdropTextureName);
}
#endif
newFreezer->allPeople = allPeople;
@ -282,11 +283,11 @@ void unfreeze(bool killImage) {
cameraX = frozenStuff->cameraX;
cameraY = frozenStuff->cameraY;
input.mouseX = (int) (input.mouseX * cameraZoom);
input.mouseY = (int) (input.mouseY * cameraZoom);
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);
input.mouseX = (int)(input.mouseX / cameraZoom);
input.mouseY = (int)(input.mouseY / cameraZoom);
setPixelCoords(false);
killAllPeople();
@ -297,31 +298,33 @@ void unfreeze(bool killImage) {
killLightMap();
#if 0
lightMap.data = frozenStuff -> lightMapTexture;
lightMap.name = frozenStuff -> lightMapTextureName;
lightMapNumber = frozenStuff -> lightMapNumber;
lightMap.data = frozenStuff->lightMapTexture;
lightMap.name = frozenStuff->lightMapTextureName;
lightMapNumber = frozenStuff->lightMapNumber;
if (lightMapNumber) {
lightMap.name = 0;
loadLightMap(lightMapNumber);
}
killZBuffer();
zBuffer.tex = frozenStuff -> zBufferImage;
zBuffer.originalNum = frozenStuff -> zBufferNumber;
zBuffer.numPanels = frozenStuff -> zPanels;
zBuffer.tex = frozenStuff->zBufferImage;
zBuffer.originalNum = frozenStuff->zBufferNumber;
zBuffer.numPanels = frozenStuff->zPanels;
if (zBuffer.numPanels) {
zBuffer.texName = 0;
setZBuffer(zBuffer.originalNum);
}
killParallax();
parallaxStuff = frozenStuff -> parallaxStuff;
parallaxStuff = frozenStuff->parallaxStuff;
reloadParallaxTextures();
if (killImage) killBackDrop();
backdropTextureName = frozenStuff -> backdropTextureName;
if (backdropTexture) delete[] backdropTexture;
backdropTexture = frozenStuff -> backdropTexture;
if (killImage)
killBackDrop();
backdropTextureName = frozenStuff->backdropTextureName;
if (backdropTexture)
delete[] backdropTexture;
backdropTexture = frozenStuff->backdropTexture;
backdropExists = true;
if (backdropTextureName) {
backdropTextureName = 0;
@ -340,12 +343,12 @@ void unfreeze(bool killImage) {
int picWidth = sceneWidth;
int picHeight = sceneHeight;
if (! NPOT_textures) {
if (!NPOT_textures) {
picWidth = getNextPOT(picWidth);
picHeight = getNextPOT(picHeight);
}
// Restore the backdrop
texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, frozenStuff -> backdropTexture, backdropTextureName);
texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, frozenStuff->backdropTexture, backdropTextureName);
}
#endif
deleteAnim(mouseCursorAnim);

View File

@ -91,8 +91,7 @@ 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;
}
@ -121,45 +120,45 @@ void readIniFile(char *filename) {
keepGoing = false;
}
switch (readChar) {
case '\n':
case '\r':
if (doingSecond) {
if (strcmp(lineSoFar, "LANGUAGE") == 0) {
gameSettings.languageID = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "WINDOW") == 0) {
gameSettings.userFullScreen = !stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "REFRESH") == 0) {
gameSettings.refreshRate = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "ANTIALIAS") == 0) {
gameSettings.antiAlias = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "FIXEDPIXELS") == 0) {
gameSettings.fixedPixels = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "NOSTARTWINDOW") == 0) {
gameSettings.noStartWindow = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "DEBUGMODE") == 0) {
gameSettings.debugMode = stringToInt(secondSoFar);
case '\n':
case '\r':
if (doingSecond) {
if (strcmp(lineSoFar, "LANGUAGE") == 0) {
gameSettings.languageID = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "WINDOW") == 0) {
gameSettings.userFullScreen = !stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "REFRESH") == 0) {
gameSettings.refreshRate = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "ANTIALIAS") == 0) {
gameSettings.antiAlias = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "FIXEDPIXELS") == 0) {
gameSettings.fixedPixels = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "NOSTARTWINDOW") == 0) {
gameSettings.noStartWindow = stringToInt(secondSoFar);
} else if (strcmp(lineSoFar, "DEBUGMODE") == 0) {
gameSettings.debugMode = stringToInt(secondSoFar);
}
}
}
here = 0;
doingSecond = false;
lineSoFar[0] = 0;
secondSoFar[0] = 0;
break;
here = 0;
doingSecond = false;
lineSoFar[0] = 0;
secondSoFar[0] = 0;
break;
case '=':
doingSecond = true;
here = 0;
break;
case '=':
doingSecond = true;
here = 0;
break;
default:
if (doingSecond) {
secondSoFar[here++] = readChar;
secondSoFar[here] = 0;
} else {
lineSoFar[here++] = readChar;
lineSoFar[here] = 0;
}
break;
default:
if (doingSecond) {
secondSoFar[here++] = readChar;
secondSoFar[here] = 0;
} else {
lineSoFar[here++] = readChar;
lineSoFar[here] = 0;
}
break;
}
} while (keepGoing);
@ -194,14 +193,12 @@ void makeLanguageTable(Common::File *table) {
for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
languageTable[i] = i ? table->readUint16BE() : 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]);
}
}
}

View File

@ -37,35 +37,47 @@ 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 > sceneWidth) x1 = sceneWidth - 1;
if (x2 > sceneWidth) x2 = sceneWidth - 1;
if (y1 > sceneHeight) y1 = sceneHeight - 1;
if (y2 > sceneHeight) y2 = sceneHeight - 1;
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;
if (y2 > sceneHeight)
y2 = sceneHeight - 1;
if (x1 > x2) {
x = x2;
backwards = !backwards;
} else x = x1;
} else
x = x1;
if (y1 > y2) {
y = y2;
backwards = !backwards;
} else y = y1;
} else
y = y1;
int diffX = abs(x2 - x1);
int diffY = abs(y2 - y1);
if (! diffX) {
if (!diffX) {
diffX = 1;
if (x == sceneWidth - 1) x = sceneWidth - 2;
if (x == sceneWidth - 1)
x = sceneWidth - 2;
}
if (! diffY) {
if (!diffY) {
diffY = 1;
if (y == sceneHeight - 1) y = sceneHeight - 2;
if (y == sceneHeight - 1)
y = sceneHeight - 2;
}
setPixelCoords(true);
@ -82,19 +94,10 @@ void drawLine(int x1, int y1, int x2, int y2) {
// Render the scene - first the old backdrop
glBindTexture(GL_TEXTURE_2D, backdropTextureName);
//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
const GLfloat vertices[] = {
(GLfloat) - x - xoffset, (GLfloat)1 - y - yoffset, 0.,
(GLfloat)sceneWidth - x - xoffset, (GLfloat)1 - y - yoffset, 0.,
(GLfloat) - x - xoffset, (GLfloat)sceneHeight - y - yoffset, 0.,
(GLfloat)sceneWidth - x - xoffset, (GLfloat)sceneHeight - y - yoffset, 0.
};
const GLfloat vertices[] = { (GLfloat)-x - xoffset, (GLfloat)1 - y - yoffset, 0., (GLfloat)sceneWidth - x - xoffset, (GLfloat)1 - y - yoffset, 0., (GLfloat)-x - xoffset,
(GLfloat)sceneHeight - y - yoffset, 0., (GLfloat)sceneWidth - x - xoffset, (GLfloat)sceneHeight - y - yoffset, 0. };
const GLfloat texCoords[] = {
0.0f, 0.0f,
backdropTexW, 0.0f,
0.0f, backdropTexH,
backdropTexW, backdropTexH
};
const GLfloat texCoords[] = { 0.0f, 0.0f, backdropTexW, 0.0f, 0.0f, backdropTexH, backdropTexW, backdropTexH };
glUseProgram(shader.texture);
@ -105,15 +108,12 @@ void drawLine(int x1, int y1, int x2, int y2) {
//FIXME:Removing the lines doesn't work, but also didn't work properly before.
GLint xo1 = -xoffset, xo2 = -xoffset;
if (! backwards) {
if (!backwards) {
xo2 += diffX;
} else {
xo1 += diffX;
}
const GLint lineVertices[] = {
xo1, -yoffset, 0,
xo2, -yoffset + diffY, 0,
};
const GLint lineVertices[] = { xo1, -yoffset, 0, xo2, -yoffset + diffY, 0, };
glUseProgram(shader.color);

View File

@ -113,14 +113,13 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
}
}
variableStack *loadStack(Common::SeekableReadStream *stream,
variableStack **last) {
variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **last) {
int elements = stream->readUint16BE();
int a;
variableStack *first = NULL;
variableStack * * changeMe = &first;
for (a = 0; a < elements; ++a) {
for (a = 0; a < elements; a++) {
variableStack *nS = new variableStack;
if (!checkNew(nS))
return NULL;
@ -147,7 +146,7 @@ bool saveStackRef(stackHandler *vs, Common::WriteStream *stream) {
return true;
}
s = s->next;
++a;
a++;
}
stream->writeByte(0);
saveStack(vs->first, stream);
@ -233,36 +232,34 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
stream->writeByte(from->varType);
switch (from->varType) {
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
stream->writeUint32LE(from->varData.intValue);
return true;
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
stream->writeUint32LE(from->varData.intValue);
return true;
case SVT_STRING:
writeString(from->varData.theString, stream);
return true;
case SVT_STRING:
writeString(from->varData.theString, stream);
return true;
case SVT_STACK:
return saveStackRef(from->varData.theStack, stream);
case SVT_STACK:
return saveStackRef(from->varData.theStack, stream);
case SVT_COSTUME:
saveCostume(from->varData.costumeHandler, stream);
return false;
case SVT_COSTUME:
saveCostume(from->varData.costumeHandler, stream);
return false;
case SVT_ANIM:
saveAnim(from->varData.animHandler, stream);
return false;
case SVT_ANIM:
saveAnim(from->varData.animHandler, stream);
return false;
case SVT_NULL:
return false;
case SVT_NULL:
return false;
default:
fatal("Can't save variables of this type:",
(from->varType < SVT_NUM_TYPES) ?
typeName[from->varType] : "bad ID");
default:
fatal("Can't save variables of this type:", (from->varType < SVT_NUM_TYPES) ? typeName[from->varType] : "bad ID");
}
return true;
}
@ -270,45 +267,45 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
to->varType = (variableType)stream->readByte();
switch (to->varType) {
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
to->varData.intValue = stream->readUint32LE();
return true;
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
to->varData.intValue = stream->readUint32LE();
return true;
case SVT_STRING:
to->varData.theString = readString(stream);
return true;
case SVT_STRING:
to->varData.theString = readString(stream);
return true;
case SVT_STACK:
to->varData.theStack = loadStackRef(stream);
case SVT_STACK:
to->varData.theStack = loadStackRef(stream);
#if DEBUG_STACKINESS
{
char *str = getTextFromAnyVar(*to);
stackDebug((stackfp, "just loaded %s\n", str));
delete str;
}
{
char *str = getTextFromAnyVar(*to);
stackDebug((stackfp, "just loaded %s\n", str));
delete str;
}
#endif
return true;
return true;
case SVT_COSTUME:
to->varData.costumeHandler = new persona;
if (!checkNew(to->varData.costumeHandler))
return false;
loadCostume(to->varData.costumeHandler, stream);
return true;
case SVT_COSTUME:
to->varData.costumeHandler = new persona;
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;
loadAnim(to->varData.animHandler, stream);
return true;
case SVT_ANIM:
to->varData.animHandler = new personaAnimation;
if (!checkNew(to->varData.animHandler))
return false;
loadAnim(to->varData.animHandler, stream);
return true;
default:
break;
default:
break;
}
return true;
}

View File

@ -136,50 +136,50 @@ char *encodeFilename(char *nameIn) {
int i = 0;
while (*nameIn) {
switch (*nameIn) {
case '<':
newName[i++] = '_';
newName[i++] = 'L';
break;
case '>':
newName[i++] = '_';
newName[i++] = 'G';
break;
case '|':
newName[i++] = '_';
newName[i++] = 'P';
break;
case '_':
newName[i++] = '_';
newName[i++] = 'U';
break;
case '\"':
newName[i++] = '_';
newName[i++] = 'S';
break;
case '\\':
newName[i++] = '_';
newName[i++] = 'B';
break;
case '/':
newName[i++] = '_';
newName[i++] = 'F';
break;
case ':':
newName[i++] = '_';
newName[i++] = 'C';
break;
case '*':
newName[i++] = '_';
newName[i++] = 'A';
break;
case '?':
newName[i++] = '_';
newName[i++] = 'Q';
break;
case '<':
newName[i++] = '_';
newName[i++] = 'L';
break;
case '>':
newName[i++] = '_';
newName[i++] = 'G';
break;
case '|':
newName[i++] = '_';
newName[i++] = 'P';
break;
case '_':
newName[i++] = '_';
newName[i++] = 'U';
break;
case '\"':
newName[i++] = '_';
newName[i++] = 'S';
break;
case '\\':
newName[i++] = '_';
newName[i++] = 'B';
break;
case '/':
newName[i++] = '_';
newName[i++] = 'F';
break;
case ':':
newName[i++] = '_';
newName[i++] = 'C';
break;
case '*':
newName[i++] = '_';
newName[i++] = 'A';
break;
case '?':
newName[i++] = '_';
newName[i++] = 'Q';
break;
default:
newName[i++] = *nameIn;
break;
default:
newName[i++] = *nameIn;
break;
}
newName[i] = 0;
nameIn++;
@ -211,48 +211,48 @@ char *decodeFilename(char *nameIn) {
if (*nameIn == '_') {
nameIn++;
switch (*nameIn) {
case 'L':
newName[i] = '<';
nameIn++;
break;
case 'G':
newName[i] = '>';
nameIn++;
break;
case 'P':
newName[i] = '|';
nameIn++;
break;
case 'U':
newName[i] = '_';
nameIn++;
break;
case 'S':
newName[i] = '\"';
nameIn++;
break;
case 'B':
newName[i] = '\\';
nameIn++;
break;
case 'F':
newName[i] = '/';
nameIn++;
break;
case 'C':
newName[i] = ':';
nameIn++;
break;
case 'A':
newName[i] = '*';
nameIn++;
break;
case 'Q':
newName[i] = '?';
nameIn++;
break;
default:
newName[i] = '_';
case 'L':
newName[i] = '<';
nameIn++;
break;
case 'G':
newName[i] = '>';
nameIn++;
break;
case 'P':
newName[i] = '|';
nameIn++;
break;
case 'U':
newName[i] = '_';
nameIn++;
break;
case 'S':
newName[i] = '\"';
nameIn++;
break;
case 'B':
newName[i] = '\\';
nameIn++;
break;
case 'F':
newName[i] = '/';
nameIn++;
break;
case 'C':
newName[i] = ':';
nameIn++;
break;
case 'A':
newName[i] = '*';
nameIn++;
break;
case 'Q':
newName[i] = '?';
nameIn++;
break;
default:
newName[i] = '_';
}
} else {
newName[i] = *nameIn;

View File

@ -42,9 +42,7 @@ 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*/;
@ -85,9 +83,7 @@ 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.",
"");
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
@ -132,8 +128,7 @@ 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);
sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc, BIF);
debug(kSludgeDebugFatal, "%s", fatalInfo);
}
@ -144,8 +139,7 @@ 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);

View File

@ -79,8 +79,7 @@ objectType *loadObjectType(int i) {
}
newType->numCom = bigDataFile->readUint16BE();
newType->allCombis =
(newType->numCom) ? new combination[newType->numCom] : NULL;
newType->allCombis = (newType->numCom) ? new combination[newType->numCom] : NULL;
#if DEBUG_COMBINATIONS
FILE *callEventLog = fopen("callEventLog.txt", "at");

View File

@ -71,8 +71,7 @@ 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) {
@ -93,10 +92,8 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
} else if (stacky->thisVar.varType == SVT_FUNC) {
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;
@ -182,10 +179,7 @@ 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;
}
@ -217,8 +211,7 @@ bool turnPersonToFace(int thisNum, int direc) {
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;
@ -295,106 +288,106 @@ enum drawModes {
void setMyDrawMode(onScreenPerson *moveMe, int h) {
switch (h) {
case drawModeTransparent3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 64;
break;
case drawModeTransparent2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 128;
break;
case drawModeTransparent1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 192;
break;
case drawModeInvisible:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 254;
break;
case drawModeDark1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeDark2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeDark3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeBlack:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
case drawModeShadow1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 64;
break;
case drawModeShadow2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 128;
break;
case drawModeShadow3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 192;
break;
case drawModeFoggy3:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeFoggy2:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeFoggy1:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeFoggy4:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
case drawModeGlow3:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeGlow2:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeGlow1:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeGlow4:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
default:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 0;
break;
case drawModeTransparent3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 64;
break;
case drawModeTransparent2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 128;
break;
case drawModeTransparent1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 192;
break;
case drawModeInvisible:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 254;
break;
case drawModeDark1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeDark2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeDark3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeBlack:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
case drawModeShadow1:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 64;
break;
case drawModeShadow2:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 128;
break;
case drawModeShadow3:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 255;
moveMe->transparency = 192;
break;
case drawModeFoggy3:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeFoggy2:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeFoggy1:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeFoggy4:
moveMe->r = moveMe->g = moveMe->b = 128;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
case drawModeGlow3:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 192;
moveMe->transparency = 0;
break;
case drawModeGlow2:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 128;
moveMe->transparency = 0;
break;
case drawModeGlow1:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 64;
moveMe->transparency = 0;
break;
case drawModeGlow4:
moveMe->r = moveMe->g = moveMe->b = 255;
moveMe->colourmix = 255;
moveMe->transparency = 0;
break;
default:
moveMe->r = moveMe->g = moveMe->b = 0;
moveMe->colourmix = 0;
moveMe->transparency = 0;
break;
}
}
@ -417,8 +410,7 @@ void setPersonTransparency(int ob, unsigned char x) {
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;
@ -474,20 +466,16 @@ 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);
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);
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;
@ -499,8 +487,7 @@ 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)
@ -514,24 +501,19 @@ void drawPeople() {
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);
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);
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;
}
}
}
@ -548,9 +530,7 @@ 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);
@ -559,16 +539,11 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
oldJ = currentFloor->polygon[i].numVertices - 1;
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;
@ -610,8 +585,7 @@ bool doBorderStuff(onScreenPerson *moveMe) {
// 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...
@ -647,8 +621,7 @@ 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 {
@ -679,9 +652,7 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
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) {
@ -690,8 +661,7 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
}
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;
}
@ -732,8 +702,7 @@ 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))
if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY, moveMe->walkToPoly))
return false;
}
@ -767,8 +736,7 @@ bool stopPerson(int o) {
return false;
}
bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func,
int di) {
bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
if (x == 0 && y == 0)
return false;
onScreenPerson *moveMe = findPerson(objNum);
@ -840,8 +808,7 @@ void walkAllPeople() {
spinStep(thisPerson);
setFrames(*thisPerson, ANI_STAND);
}
if ((!thisPerson->walking) && (!thisPerson->spinning)
&& thisPerson->continueAfterWalking) {
if ((!thisPerson->walking) && (!thisPerson->spinning) && thisPerson->continueAfterWalking) {
restartFunction(thisPerson->continueAfterWalking);
thisPerson->continueAfterWalking = NULL;
}
@ -890,12 +857,10 @@ 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
@ -907,7 +872,7 @@ bool addPerson(int x, int y, int objNum, persona *p) {
newPerson->next = (*changethat);
(*changethat) = newPerson;
return (bool) (newPerson->thisType != NULL);
return (bool)(newPerson->thisType != NULL);
}
int timeForAnim(personaAnimation *fram) {
@ -987,8 +952,7 @@ 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;
}
@ -997,8 +961,7 @@ void removeOneCharacter(int i) {
p->continueAfterWalking = NULL;
onScreenPerson * * killPeople;
for (killPeople = &allPeople; *killPeople != p; killPeople =
&((*killPeople)->next)) {
for (killPeople = &allPeople; *killPeople != p; killPeople = &((*killPeople)->next)) {
;
}

View File

@ -69,43 +69,34 @@ struct onScreenPerson {
};
// Initialisation and creation
bool initPeople();
bool addPerson(int x, int y, int objNum, persona *p);
// Draw to screen and to backdrop
void drawPeople();
void freezePeople(int, int);
// Removalisationisms
void killAllPeople();
void killMostPeople();
void removeOneCharacter(int i);
// Things which affect or use all characters
onScreenPerson *findPerson(int v);
void setScale(short int h, short int d);
// Things which affect one character
void makeTalker(onScreenPerson &me);
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);
@ -114,7 +105,6 @@ bool floatCharacter(int f, int objNum);
bool setCharacterWalkSpeed(int f, int objNum);
// Animating 'em
void animatePerson(int obj, personaAnimation *);
void animatePerson(int obj, persona *per);
personaAnimation *createPersonaAnim(int num, struct variableStack *&stacky);

View File

@ -47,7 +47,7 @@ void showBoxes() {
}
void removeScreenRegion(int objectNum) {
screenRegion * * huntRegion = &allScreenRegions;
screenRegion ** huntRegion = &allScreenRegions;
screenRegion *killMe;
while (*huntRegion) {

View File

@ -77,7 +77,7 @@ char *readStringEncoded(Common::File *fp) {
if (!checkNew(s))
return NULL;
for (a = 0; a < len; a++) {
s[a] = (char) (fp->readByte() ^ encode1);
s[a] = (char)(fp->readByte() ^ encode1);
encode1 += encode2;
}
s[len] = 0;
@ -95,7 +95,7 @@ char *readTextPlain(Common::File *fp) {
startPos = fp->pos();
while (keepGoing) {
gotChar = (char) fp->readByte();
gotChar = (char)fp->readByte();
if ((gotChar == '\n') || (fp->eos())) {
keepGoing = false;
} else {
@ -125,9 +125,7 @@ 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;
@ -153,14 +151,13 @@ bool fileToStack(char *filename, stackHandler *sH) {
return fatal("No such file", filename); //TODO: false value
}
encode1 = (unsigned char) saveEncoding & 255;
encode2 = (unsigned char) (saveEncoding >> 8);
encode1 = (unsigned char)saveEncoding & 255;
encode2 = (unsigned char)(saveEncoding >> 8);
while (*checker) {
if (fd.readByte() != *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++;
}
@ -170,8 +167,7 @@ bool fileToStack(char *filename, stackHandler *sH) {
if (strcmp(checker, "UN<EFBFBD>LO<EFBFBD>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);
LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:", filename);
}
delete checker;
checker = NULL;
@ -184,25 +180,25 @@ bool fileToStack(char *filename, stackHandler *sH) {
if (fd.eos())
break;
switch (i) {
case 0: {
char *g = readStringEncoded(&fd);
makeTextVar(stringVar, g);
delete g;
}
break;
case 0: {
char *g = readStringEncoded(&fd);
makeTextVar(stringVar, g);
delete g;
}
break;
case 1:
setVariable(stringVar, SVT_INT, fd.readUint32LE());
break;
case 1:
setVariable(stringVar, SVT_INT, fd.readUint32LE());
break;
case 2:
setVariable(stringVar, SVT_INT, fd.readByte());
break;
case 2:
setVariable(stringVar, SVT_INT, fd.readByte());
break;
default:
fatal(LOAD_ERROR "Corrupt custom data file:", filename);
fd.close();
return false;
default:
fatal(LOAD_ERROR "Corrupt custom data file:", filename);
fd.close();
return false;
}
} else {
char *line = readTextPlain(&fd);

View File

@ -20,7 +20,7 @@
*
*/
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
@ -32,10 +32,10 @@
#include "main_loop.h"
namespace Sludge {
SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
: Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
// register your random source
_rnd = new Common::RandomSource("sludge");
@ -49,19 +49,19 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
// check init
debug("SludgeEngine::SludgeEngine");
}
SludgeEngine::~SludgeEngine() {
// Dispose resources
delete _rnd;
// Remove debug levels
DebugMan.clearAllDebugChannels();
// Dispose console
delete _console;
}
Common::Error SludgeEngine::run() {
// init graphics
Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
@ -69,12 +69,12 @@ Common::Error SludgeEngine::run() {
// create console
_console = new SludgeConsole(this);
// debug log
main_loop("Welcome.slg");
return Common::kNoError;
}
} // End of namespace Sludge

View File

@ -1672,8 +1672,7 @@ bool handleInput() {
delete tempString;
tempString = NULL;
tempStack->next = NULL;
if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL,
tempStack))
if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL, tempStack))
return false;
}
}

View File

@ -82,8 +82,7 @@ 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,8 +91,7 @@ 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();

View File

@ -49,8 +49,7 @@ 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;
@ -147,11 +146,7 @@ bool playMOD(int f, int a, int fromTrack) {
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);
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]) {
@ -162,10 +157,8 @@ 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);
}
@ -175,8 +168,7 @@ 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());
}
@ -192,8 +184,7 @@ 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);
}
}
}
@ -203,8 +194,7 @@ 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;
}
@ -318,8 +308,7 @@ 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;
@ -345,15 +334,12 @@ bool startSound(int f, bool loopy) {
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
}
}

View File

@ -52,8 +52,7 @@ loadedSpriteBank *loadBankForAnim(int ID) {
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

View File

@ -67,19 +67,13 @@ 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

View File

@ -223,8 +223,8 @@ bool loadStatusBars(Common::SeekableReadStream *stream) {
if (! checkNew(newOne)) return false;
newOne->text = readString(stream);
newOne->next = NULL;
(* viewLine) = newOne;
viewLine = & (newOne->next);
(*viewLine) = newOne;
viewLine = &(newOne->next);
}
return true;
}

View File

@ -104,8 +104,8 @@ bool saveThumbnail(Common::WriteStream *stream) {
GLuint *tmp = new GLuint [thumbWidth * thumbHeight];
if (! checkNew(image)) return false;
glReadPixels(viewportOffsetX, viewportOffsetY, thumbWidth, thumbHeight, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
for (int y = 0; y < thumbHeight; y ++) {
for (int x = 0; x < thumbWidth; x ++) {
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
const GLuint a = tmp[y * thumbWidth + x];
image[y * thumbWidth + x] = ((a & 0x00f80000) >> (16 + 3)) | ((a & 0x0000fc00) >> (8 + 2 - 5)) | ((a & 0x000000f8) << (11 - 3));
}
@ -122,8 +122,8 @@ bool saveThumbnail(Common::WriteStream *stream) {
#endif
setPixelCoords(false);
for (int y = 0; y < thumbHeight; y ++) {
for (int x = 0; x < thumbWidth; x ++) {
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
put2bytes((*(image + y * thumbWidth + x)), fp);
}
}
@ -167,7 +167,7 @@ void showThumbnail(char *filename, int atX, int atY) {
int t1, t2;
unsigned short c;
GLubyte *target;
for (t2 = 0; t2 < fileHeight; t2 ++) {
for (t2 = 0; t2 < fileHeight; t2++) {
t1 = 0;
while (t1 < fileWidth) {
c = (unsigned short) fp->readUint16BE();

View File

@ -380,27 +380,27 @@ void transitionBlinds() {
void fixBrightness() {
switch (fadeMode) {
case 0:
transitionFader();
break;
case 1:
resetRandW();
// Fall through!
case 2:
transitionDisolve();
break;
case 3:
transitionTV();
break;
case 4:
transitionBlinds();
break;
case 5:
transitionCrossFader();
break;
case 6:
transitionSnapshotBox();
break;
case 0:
transitionFader();
break;
case 1:
resetRandW();
// Fall through!
case 2:
transitionDisolve();
break;
case 3:
transitionTV();
break;
case 4:
transitionBlinds();
break;
case 5:
transitionCrossFader();
break;
case 6:
transitionSnapshotBox();
break;
}
}

View File

@ -49,36 +49,36 @@ extern char *outputDir;
void unlinkVar(variable &thisVar) {
switch (thisVar.varType) {
case SVT_STRING:
delete[] thisVar.varData.theString;
thisVar.varData.theString = NULL;
break;
case SVT_STRING:
delete[] thisVar.varData.theString;
thisVar.varData.theString = NULL;
break;
case SVT_STACK:
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_STACK:
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;
delete[] thisVar.varData.fastArray;
thisVar.varData.fastArray = NULL;
}
break;
case SVT_FASTARRAY:
thisVar.varData.fastArray->timesUsed--;
if (thisVar.varData.theStack->timesUsed <= 0) {
delete thisVar.varData.fastArray->fastVariables;
delete[] thisVar.varData.fastArray;
thisVar.varData.fastArray = NULL;
}
break;
case SVT_ANIM:
deleteAnim(thisVar.varData.animHandler);
break;
case SVT_ANIM:
deleteAnim(thisVar.varData.animHandler);
break;
default:
break;
default:
break;
}
}
@ -101,8 +101,7 @@ 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;
}
@ -116,27 +115,26 @@ persona *getCostumeFromVar(variable &thisVar) {
persona *p = NULL;
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;
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;
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;
break;
case SVT_COSTUME:
return thisVar.varData.costumeHandler;
break;
case SVT_COSTUME:
return thisVar.varData.costumeHandler;
break;
default:
fatal("Expecting an animation variable; found variable of type",
typeName[thisVar.varType]);
default:
fatal("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
}
return p;
@ -297,29 +295,29 @@ int compareVars(const variable &var1, const variable &var2) {
int re = 0;
if (var1.varType == var2.varType) {
switch (var1.varType) {
case SVT_NULL:
re = 1;
break;
case SVT_NULL:
re = 1;
break;
case SVT_COSTUME:
re = (var1.varData.costumeHandler == var2.varData.costumeHandler);
break;
case SVT_COSTUME:
re = (var1.varData.costumeHandler == var2.varData.costumeHandler);
break;
case SVT_ANIM:
re = (var1.varData.animHandler == var2.varData.animHandler);
break;
case SVT_ANIM:
re = (var1.varData.animHandler == var2.varData.animHandler);
break;
case SVT_STRING:
case SVT_STRING:
re = (strcmp(var1.varData.theString, var2.varData.theString) == 0);
break;
re = (strcmp(var1.varData.theString, var2.varData.theString) == 0);
break;
case SVT_STACK:
re = (var1.varData.theStack == var2.varData.theStack);
break;
case SVT_STACK:
re = (var1.varData.theStack == var2.varData.theStack);
break;
default:
re = (var1.varData.intValue == var2.varData.intValue);
default:
re = (var1.varData.intValue == var2.varData.intValue);
}
}
return re;
@ -338,93 +336,92 @@ 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) {
switch (from.varType) {
case SVT_STRING:
return copyString(from.varData.theString);
case SVT_STRING:
return copyString(from.varData.theString);
case SVT_FASTARRAY: {
char *builder = copyString("FAST:");
char *builder2;
char *grabText;
case SVT_FASTARRAY: {
char *builder = copyString("FAST:");
char *builder2;
char *grabText;
for (int i = 0; i < from.varData.fastArray->size; i++) {
builder2 = joinStrings(builder, " ");
if (!builder2)
return NULL;
delete builder;
grabText = getTextFromAnyVar(
from.varData.fastArray->fastVariables[i]);
builder = joinStrings(builder2, grabText);
if (!builder)
return NULL;
delete grabText;
grabText = NULL;
delete builder2;
builder2 = NULL;
for (int i = 0; i < from.varData.fastArray->size; i++) {
builder2 = joinStrings(builder, " ");
if (!builder2)
return NULL;
delete builder;
grabText = getTextFromAnyVar(from.varData.fastArray->fastVariables[i]);
builder = joinStrings(builder2, grabText);
if (!builder)
return NULL;
delete grabText;
grabText = NULL;
delete builder2;
builder2 = NULL;
}
return builder;
}
return builder;
}
case SVT_STACK: {
char *builder = copyString("ARRAY:");
char *builder2;
char *grabText;
case SVT_STACK: {
char *builder = copyString("ARRAY:");
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;
delete builder;
grabText = getTextFromAnyVar(stacky->thisVar);
builder = joinStrings(builder2, grabText);
if (!builder)
return NULL;
delete grabText;
grabText = NULL;
delete builder2;
builder2 = NULL;
stacky = stacky->next;
while (stacky) {
builder2 = joinStrings(builder, " ");
if (!builder2)
return NULL;
delete builder;
grabText = getTextFromAnyVar(stacky->thisVar);
builder = joinStrings(builder2, grabText);
if (!builder)
return NULL;
delete grabText;
grabText = NULL;
delete builder2;
builder2 = NULL;
stacky = stacky->next;
}
return builder;
}
return builder;
}
case SVT_INT: {
char *buff = new char[10];
if (!checkNew(buff))
return NULL;
sprintf(buff, "%i", from.varData.intValue);
return buff;
}
case SVT_INT: {
char *buff = new char[10];
if (!checkNew(buff))
return NULL;
sprintf(buff, "%i", from.varData.intValue);
return buff;
}
case SVT_FILE: {
case SVT_FILE: {
// char * buff = new char[15];
// if (! checkNew (buff)) return NULL;
// sprintf (buff, "FILE %i", from.varData.intValue);
return joinStrings("", resourceNameFromNum(from.varData.intValue));
}
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);
}
case SVT_OBJTYPE: {
objectType *thisType = findObjectType(from.varData.intValue);
if (thisType)
return copyString(thisType->screenName);
}
default:
break;
default:
break;
}
return copyString(typeName[from.varType]);
@ -432,23 +429,23 @@ char *getTextFromAnyVar(const variable &from) {
bool getBoolean(const variable &from) {
switch (from.varType) {
case SVT_NULL:
return false;
case SVT_NULL:
return false;
case SVT_INT:
return (bool) (from.varData.intValue != 0);
case SVT_INT:
return (bool)(from.varData.intValue != 0);
case SVT_STACK:
return (bool) (from.varData.theStack->first != NULL);
case SVT_STACK:
return (bool)(from.varData.theStack->first != NULL);
case SVT_STRING:
return (bool) (from.varData.theString[0] != 0);
case SVT_STRING:
return (bool)(from.varData.theString[0] != 0);
case SVT_FASTARRAY:
return (bool) (from.varData.fastArray->size != 0);
case SVT_FASTARRAY:
return (bool)(from.varData.fastArray->size != 0);
default:
break;
default:
break;
}
return true;
}
@ -456,41 +453,41 @@ bool getBoolean(const variable &from) {
bool copyMain(const variable &from, variable &to) {
to.varType = from.varType;
switch (to.varType) {
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
to.varData.intValue = from.varData.intValue;
return true;
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
to.varData.intValue = from.varData.intValue;
return true;
case SVT_FASTARRAY:
to.varData.fastArray = from.varData.fastArray;
to.varData.fastArray->timesUsed++;
return true;
case SVT_FASTARRAY:
to.varData.fastArray = from.varData.fastArray;
to.varData.fastArray->timesUsed++;
return true;
case SVT_STRING:
to.varData.theString = copyString(from.varData.theString);
return to.varData.theString ? true : false;
case SVT_STRING:
to.varData.theString = copyString(from.varData.theString);
return to.varData.theString ? true : false;
case SVT_STACK:
to.varData.theStack = from.varData.theStack;
to.varData.theStack->timesUsed++;
return true;
case SVT_STACK:
to.varData.theStack = from.varData.theStack;
to.varData.theStack->timesUsed++;
return true;
case SVT_COSTUME:
to.varData.costumeHandler = from.varData.costumeHandler;
return true;
case SVT_COSTUME:
to.varData.costumeHandler = from.varData.costumeHandler;
return true;
case SVT_ANIM:
to.varData.animHandler = copyAnim(from.varData.animHandler);
return true;
case SVT_ANIM:
to.varData.animHandler = copyAnim(from.varData.animHandler);
return true;
case SVT_NULL:
return true;
case SVT_NULL:
return true;
default:
break;
default:
break;
}
fatal("Unknown value type");
return false;
@ -509,8 +506,7 @@ variable *fastArrayGetByIndex(fastArrayHandler *vS, unsigned int theIndex) {
bool makeFastArraySize(variable &to, int size) {
if (size < 0)
return fatal(
"Can't create a fast array with a negative number of elements!");
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;
@ -561,8 +557,7 @@ bool addVarToStack(const variable &va, variableStack *&thisStack) {
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;
}
@ -578,13 +573,11 @@ bool addVarToStackQuick(variable &va, variableStack *&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) {
bool stackSetByIndex(variableStack *vS, unsigned int theIndex, const variable &va) {
while (theIndex--) {
vS = vS->next;
if (!vS)
@ -603,8 +596,7 @@ variable *stackGetByIndex(variableStack *vS, unsigned int theIndex) {
return &(vS->thisVar);
}
int deleteVarFromStack(const variable &va, variableStack *&thisStack,
bool allOfEm) {
int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOfEm) {
variableStack * * huntVar = &thisStack;
variableStack *killMe;
int reply = 0;
@ -640,12 +632,8 @@ 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;
@ -658,8 +646,7 @@ void trimStack(variableStack *&stack) {
variableStack *killMe = stack;
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);

View File

@ -74,8 +74,7 @@ bool getStream(DWORD type, timStream &intoHere) {
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)) {
@ -87,9 +86,7 @@ bool getStream(DWORD type, timStream &intoHere) {
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");
}
}
@ -231,14 +228,13 @@ return true;
}
bool nextVideoFrame() {
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER) AVIStreamGetFrame(pgf,
videoFrameNum);
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, videoFrameNum);
if (!lpbi) {
finishVideo();
return false;
}
BYTE *pData = (((BYTE *) lpbi) + lpbi->biSize);
BYTE *pData = (((BYTE *)lpbi) + lpbi->biSize);
int xOff = (winWidth - vidWidth) >> 1;
int yOff = (winHeight + vidHeight) >> 1;
@ -249,22 +245,20 @@ for (int y = 0; y < vidHeight; y++) {
unsigned short int *toHere = startingPoint;
for (int x = 0; x < vidWidth; x++) {
switch (vidBytesPerPixel) {
case 1:
(*toHere) = makeGrey(*pData);
break;
case 1:
(*toHere) = makeGrey(*pData);
break;
case 3:
case 4:
(*toHere) = makeColour(*(pData + 2), *(pData + 1), *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);
}
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++;

View File

@ -75,133 +75,140 @@ bool setZBuffer(int y) {
setResourceForFatal(y);
zBuffer.originalNum = y;
if (! openFileFromNum(y)) return false;
if (fgetc(bigDataFile) != 'S') return fatal("Not a Z-buffer file");
if (fgetc(bigDataFile) != 'z') return fatal("Not a Z-buffer file");
if (fgetc(bigDataFile) != 'b') return fatal("Not a Z-buffer file");
if (!openFileFromNum(y))
return false;
if (bigDataFile->readByte() != 'S')
return fatal("Not a Z-buffer file");
if (bigDataFile->readByte() != 'z')
return fatal("Not a Z-buffer file");
if (bigDataFile->readByte() != 'b')
return fatal("Not a Z-buffer file");
switch (fgetc(bigDataFile)) {
case 0:
zBuffer.width = 640;
zBuffer.height = 480;
break;
switch (bigDataFile->readByte()) {
case 0:
zBuffer.width = 640;
zBuffer.height = 480;
break;
case 1:
zBuffer.width = bigDataFile->readUint16BE();
zBuffer.height = bigDataFile->readUint16BE();
break;
case 1:
zBuffer.width = bigDataFile->readUint16BE();
zBuffer.height = bigDataFile->readUint16BE();
break;
default:
return fatal("Extended Z-buffer format not supported in this version of the SLUDGE engine");
}
if (zBuffer.width != sceneWidth || zBuffer.height != sceneHeight) {
char tmp[256];
sprintf(tmp, "Z-w: %d Z-h:%d w: %d, h:%d", zBuffer.width, zBuffer.height, sceneWidth, sceneHeight);
return fatal("Z-buffer width and height don't match scene width and height", tmp);
}
default:
return fatal("Extended Z-buffer format not supported in this version of the SLUDGE engine");
}
if (zBuffer.width != sceneWidth || zBuffer.height != sceneHeight) {
char tmp[256];
sprintf(tmp, "Z-w: %d Z-h:%d w: %d, h:%d", zBuffer.width, zBuffer.height, sceneWidth, sceneHeight);
return fatal("Z-buffer width and height don't match scene width and height", tmp);
}
zBuffer.numPanels = fgetc(bigDataFile);
for (y = 0; y < zBuffer.numPanels; y ++) {
yPalette[y] = bigDataFile->readUint16BE();
}
sortZPal(yPalette, sorted, zBuffer.numPanels);
for (y = 0; y < zBuffer.numPanels; y ++) {
zBuffer.panel[y] = yPalette[sorted[y]];
sortback[sorted[y]] = y;
}
zBuffer.numPanels = bigDataFile->readByte();
for (y = 0; y < zBuffer.numPanels; y++) {
yPalette[y] = bigDataFile->readUint16BE();
}
sortZPal(yPalette, sorted, zBuffer.numPanels);
for (y = 0; y < zBuffer.numPanels; y++) {
zBuffer.panel[y] = yPalette[sorted[y]];
sortback[sorted[y]] = y;
}
int picWidth = sceneWidth;
int picHeight = sceneHeight;
if (! NPOT_textures) {
picWidth = getNextPOT(picWidth);
picHeight = getNextPOT(picHeight);
}
zBuffer.tex = new GLubyte [picHeight * picWidth];
if (! checkNew(zBuffer.tex)) return false;
int picWidth = sceneWidth;
int picHeight = sceneHeight;
if (!NPOT_textures) {
picWidth = getNextPOT(picWidth);
picHeight = getNextPOT(picHeight);
}
zBuffer.tex = new GLubyte[picHeight * picWidth];
if (!checkNew(zBuffer.tex))
return false;
for (y = 0; y < sceneHeight; y ++) {
for (x = 0; x < sceneWidth; x ++) {
if (stillToGo == 0) {
n = fgetc(bigDataFile);
stillToGo = n >> 4;
if (stillToGo == 15) stillToGo = bigDataFile->readUint16BE() + 16l;
else stillToGo ++;
n &= 15;
for (y = 0; y < sceneHeight; y++) {
for (x = 0; x < sceneWidth; x++) {
if (stillToGo == 0) {
n = bigDataFile->readByte();
stillToGo = n >> 4;
if (stillToGo == 15)
stillToGo = bigDataFile->readUint16BE() + 16l;
else
stillToGo++;
n &= 15;
}
zBuffer.tex[y * picWidth + x] = sortback[n] * 16;
stillToGo--;
}
zBuffer.tex[y * picWidth + x] = sortback[n] * 16;
stillToGo --;
}
}
finishAccess();
finishAccess();
#endif
setResourceForFatal(-1);
setResourceForFatal(-1);
#if 0
if (! zBuffer.texName) glGenTextures(1, &zBuffer.texName);
glBindTexture(GL_TEXTURE_2D, zBuffer.texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (! zBuffer.texName) glGenTextures(1, &zBuffer.texName);
glBindTexture(GL_TEXTURE_2D, zBuffer.texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
texImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, picWidth, picHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, zBuffer.tex, zBuffer.texName);
texImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, picWidth, picHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, zBuffer.tex, zBuffer.texName);
#endif
return true;
}
void drawZBuffer(int x, int y, bool upsidedown) {
int i;
#if 0
if (! zBuffer.tex) return;
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_TRUE);
glUseProgram(shader.texture);
setPMVMatrix(shader.texture);
//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, zBuffer.texName);
setPrimaryColor(1.0, 1.0, 1.0, 1.0);
for (i = 1; i < zBuffer.numPanels; i++) {
GLfloat z = 1.0 - (double) i * (1.0 / 128.0);
GLfloat vy1 = -y, vy2 = zBuffer.height - y;
if (upsidedown) {
vy1 += zBuffer.height;
vy2 -= zBuffer.height;
}
const GLfloat vertices[] = {
(GLfloat) - x, vy1, z,
(GLfloat)zBuffer.width - x, vy1, z,
(GLfloat) - x, vy2, z,
(GLfloat)zBuffer.width - x, vy2, z
};
const GLfloat texCoords[] = {
0.0f, 0.0f,
backdropTexW, 0.0f,
0.0f, backdropTexH,
backdropTexW, backdropTexH
};
glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 1);
glUniform1f(glGetUniformLocation(shader.texture, "zBufferLayer"), i);
drawQuad(shader.texture, vertices, 1, texCoords);
glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 0);
return true;
}
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
glUseProgram(0);
#endif
}
void drawZBuffer(int x, int y, bool upsidedown) {
int i;
#if 0
if (! zBuffer.tex) return;
} // End of namespace Sludge
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_TRUE);
glUseProgram(shader.texture);
setPMVMatrix(shader.texture);
//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, zBuffer.texName);
setPrimaryColor(1.0, 1.0, 1.0, 1.0);
for (i = 1; i < zBuffer.numPanels; i++) {
GLfloat z = 1.0 - (double) i * (1.0 / 128.0);
GLfloat vy1 = -y, vy2 = zBuffer.height - y;
if (upsidedown) {
vy1 += zBuffer.height;
vy2 -= zBuffer.height;
}
const GLfloat vertices[] = {
(GLfloat) - x, vy1, z,
(GLfloat)zBuffer.width - x, vy1, z,
(GLfloat) - x, vy2, z,
(GLfloat)zBuffer.width - x, vy2, z
};
const GLfloat texCoords[] = {
0.0f, 0.0f,
backdropTexW, 0.0f,
0.0f, backdropTexH,
backdropTexW, backdropTexH
};
glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 1);
glUniform1f(glGetUniformLocation(shader.texture, "zBufferLayer"), i);
drawQuad(shader.texture, vertices, 1, texCoords);
glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 0);
}
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
glUseProgram(0);
#endif
}
} // End of namespace Sludge