diff options
| author | yinsimei | 2017-05-27 20:16:54 +0200 | 
|---|---|---|
| committer | Eugene Sandulenko | 2017-07-13 18:27:45 +0200 | 
| commit | 45dcfdfc0bad326800618d4d3edfd772d53c9fc6 (patch) | |
| tree | 28ac6da0023fa94cb1c756ea77e50c1b2cbf9d6e | |
| parent | f5b4cf680371b5b2098c766361b5efc6e0a68e91 (diff) | |
| download | scummvm-rg350-45dcfdfc0bad326800618d4d3edfd772d53c9fc6.tar.gz scummvm-rg350-45dcfdfc0bad326800618d4d3edfd772d53c9fc6.tar.bz2 scummvm-rg350-45dcfdfc0bad326800618d4d3edfd772d53c9fc6.zip | |
SLUDGE: Replace standard file reading functions by Common functions
45 files changed, 2127 insertions, 2104 deletions
| diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index bb840b3497..929e67dea6 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -96,16 +96,16 @@ void nosnapshot() {  #endif  } +void saveSnapshot(Common::WriteStream *stream) {  #if 0 -void saveSnapshot(FILE *fp) {  	if (snapshotTextureName) { -		fputc(1, fp);               // 1 for snapshot follows -		saveCoreHSI(fp, snapshotTextureName, winWidth, winHeight); +		putch(1, stream);               // 1 for snapshot follows +		saveCoreHSI(stream, snapshotTextureName, winWidth, winHeight);  	} else { -		fputc(0, fp); +		putch(0, stream);  	} -}  #endif +}  bool snapshot() { @@ -157,17 +157,16 @@ bool snapshot() {  	return true;  } -#if 0 -bool restoreSnapshot(FILE *fp) { -	unsigned int picWidth = get2bytes(fp); -	unsigned int picHeight = get2bytes(fp); +bool restoreSnapshot(Common::SeekableReadStream *stream) { +	unsigned int picWidth = get2bytes(stream); +	unsigned int picHeight = get2bytes(stream);  	if ((picWidth != winWidth) || (picHeight != winHeight))  		return false;  	unsigned int t1, t2, n;  	unsigned short c; - +#if 0  	GLubyte *target;  	if (! NPOT_textures) {  		picWidth = getNextPOT(picWidth); @@ -177,17 +176,19 @@ bool restoreSnapshot(FILE *fp) {  	}  	GLubyte *snapshotTexture = new GLubyte [picHeight * picWidth * 4];  	if (! snapshotTexture) return fatal("Out of memory while restoring snapshot."); +#endif  	for (t2 = 0; t2 < winHeight; t2 ++) {  		t1 = 0;  		while (t1 < winWidth) { -			c = (unsigned short) get2bytes(fp); +			c = (unsigned short) get2bytes(stream);  			if (c & 32) { -				n = fgetc(fp) + 1; +				n = getch(stream) + 1;  				c -= 32;  			} else {  				n = 1;  			} +#if 0  			while (n --) {  				target = snapshotTexture + 4 * picWidth * t2 + t1 * 4;  				target[0] = (GLubyte) redValue(c); @@ -196,9 +197,10 @@ bool restoreSnapshot(FILE *fp) {  				target[3] = (GLubyte) 255;  				t1++;  			} +#endif  		}  	} - +#if 0  	if (! snapshotTextureName) glGenTextures(1, &snapshotTextureName);  	glBindTexture(GL_TEXTURE_2D, snapshotTextureName);  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -210,10 +212,9 @@ bool restoreSnapshot(FILE *fp) {  	delete snapshotTexture;  	snapshotTexture = NULL; - +#endif  	return true;  } -#endif  void killBackDrop() {  #if 0 @@ -1005,7 +1006,7 @@ bool loadParallax(unsigned short v, unsigned short fracX, unsigned short fracY)  extern int viewportOffsetX, viewportOffsetY;  #if 0 -bool loadHSI(FILE *fp, int x, int y, bool reserve) { +bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {  	int t1, t2, n;  	unsigned short c; @@ -1014,7 +1015,7 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  	int picWidth;  	int picHeight;  	int realPicWidth, realPicHeight; -	long file_pointer = ftell(fp); +	long file_pointer = stream->pos();  	png_structp png_ptr;  	png_infop info_ptr, end_info; @@ -1025,20 +1026,20 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  	// Is this a PNG file?  	char tmp[10]; -	size_t bytes_read = fread(tmp, 1, 8, fp); -	if (bytes_read != 8 && ferror(fp)) { +	size_t bytes_read = stream->read(tmp, 8); +	if (bytes_read != 8 && stream->err()) {  		debugOut("Reading error in loadHSI.\n");  	}  	if (png_sig_cmp((png_byte *) tmp, 0, 8)) {  		// No, it's old-school HSI  		fileIsPNG = false; -		fseek(fp, file_pointer, SEEK_SET); +		stream->seek(file_pointer, SEEK_SET); -		picWidth = realPicWidth = get2bytes(fp); -		picHeight = realPicHeight = get2bytes(fp); +		picWidth = realPicWidth = get2bytes(stream); +		picHeight = realPicHeight = get2bytes(stream);  	} else {  		// Read the PNG header - +#if 0  		png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);  		if (!png_ptr) {  			return false; @@ -1078,10 +1079,10 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  		png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);  		//int rowbytes = png_get_rowbytes(png_ptr, info_ptr); - +#endif  	} - +#if 0  	GLfloat texCoordW = 1.0;  	GLfloat texCoordH = 1.0;  	if (! NPOT_textures) { @@ -1138,7 +1139,7 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  	}  	GLuint tmpTex; -#if 0 +  	glGenTextures(1, &tmpTex);  	glBindTexture(GL_TEXTURE_2D, tmpTex);  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -1150,7 +1151,7 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);  	} -#endif +  	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, tmpTex); @@ -1189,9 +1190,9 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  		int yoffset = 0;  		while (yoffset < realPicHeight) {  			int h = (realPicHeight - yoffset < viewportHeight) ? realPicHeight - yoffset : viewportHeight; -#if 0 +  			glClear(GL_COLOR_BUFFER_BIT);   // Clear The Screen -#endif +  			const GLfloat vertices[] = {  				(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,  				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset, 0., @@ -1207,7 +1208,7 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  			};  			if (backdropExists) { -#if 0 +  				// Render the sprite to the backdrop  				// (using mulitexturing, so the old backdrop is seen where alpha < 1.0)  				glActiveTexture(GL_TEXTURE2); @@ -1217,35 +1218,34 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  				glUseProgram(shader.paste);  				GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");  				if (uniform >= 0) glUniform1i(uniform, 0); // No lighting -#endif  				setPMVMatrix(shader.paste);  				setPrimaryColor(1.0, 1.0, 1.0, 1.0); -#if 0 +  				glBindTexture(GL_TEXTURE_2D, tmpTex);  				//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -#endif +  				drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords); -#if 0 +  				glUseProgram(0); -#endif +  			} else {  				// It's all new - nothing special to be done. -#if 0 +  				glUseProgram(shader.texture); -#endif +  				setPMVMatrix(shader.texture); -#if 0 +  				glBindTexture(GL_TEXTURE_2D, tmpTex); -#endif +  				setPrimaryColor(1.0, 0.0, 0.0, 0.0);  				drawQuad(shader.texture, vertices, 1, texCoords); -#if 0 +  				glUseProgram(0); -#endif +  			}  			// Copy Our ViewPort To The Texture @@ -1259,17 +1259,17 @@ bool loadHSI(FILE *fp, int x, int y, bool reserve) {  	deleteTextures(1, &tmpTex);  	setPixelCoords(false); - +#endif  	backdropExists = true;  	return true;  } -bool mixHSI(FILE *fp, int x, int y) { +bool mixHSI(Common::SeekableReadStream *stream, int x, int y) {  	int realPicWidth, realPicHeight;  	int picWidth;  	int picHeight; -	long file_pointer = ftell(fp); +	long file_pointer = stream->pos();  	png_structp png_ptr;  	png_infop info_ptr, end_info; @@ -1279,17 +1279,18 @@ bool mixHSI(FILE *fp, int x, int y) {  	// Is this a PNG file?  	char tmp[10]; -	size_t bytes_read = fread(tmp, 1, 8, fp); -	if (bytes_read != 8 && ferror(fp)) { +	size_t bytes_read = stream->read(tmp, 8); +	if (bytes_read != 8 && stream->err()) {  		debugOut("Reading error in mixHSI.\n");  	} +#if 0  	if (png_sig_cmp((png_byte *) tmp, 0, 8)) {  		// No, it's old-school HSI  		fileIsPNG = false; -		fseek(fp, file_pointer, SEEK_SET); +		stream->seek(file_pointer, SEEK_SET); -		picWidth = realPicWidth = get2bytes(fp); -		picHeight = realPicHeight = get2bytes(fp); +		picWidth = realPicWidth = get2bytes(stream); +		picHeight = realPicHeight = get2bytes(stream);  	} else {  		// Read the PNG header @@ -1309,7 +1310,7 @@ bool mixHSI(FILE *fp, int x, int y) {  			png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);  			return false;  		} -		png_init_io(png_ptr, fp);       // Tell libpng which file to read +		png_init_io(png_ptr, stream);       // Tell libpng which file to read  		png_set_sig_bytes(png_ptr, 8);  // 8 bytes already read  		png_read_info(png_ptr, info_ptr); @@ -1398,9 +1399,9 @@ bool mixHSI(FILE *fp, int x, int y) {  		for (t2 = 0; t2 < realPicHeight; t2 ++) {  			t1 = 0;  			while (t1 < realPicWidth) { -				c = (unsigned short) get2bytes(fp); +				c = (unsigned short) get2bytes(stream);  				if (c & 32) { -					n = fgetc(fp) + 1; +					n = getch(stream) + 1;  					c -= 32;  				} else {  					n = 1; @@ -1425,7 +1426,7 @@ bool mixHSI(FILE *fp, int x, int y) {  	}  	GLuint tmpTex; -#if 0 +  	glGenTextures(1, &tmpTex);  	glBindTexture(GL_TEXTURE_2D, tmpTex);  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -1437,7 +1438,7 @@ bool mixHSI(FILE *fp, int x, int y) {  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);  	} -#endif +  	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, tmpTex); @@ -1453,7 +1454,7 @@ bool mixHSI(FILE *fp, int x, int y) {  		int yoffset = 0;  		while (yoffset < realPicHeight) {  			int h = (realPicHeight - yoffset < viewportHeight) ? realPicHeight - yoffset : viewportHeight; -#if 0 +  			glClear(GL_COLOR_BUFFER_BIT);   // Clear The Screen  			// Render the sprite to the backdrop @@ -1465,14 +1466,14 @@ bool mixHSI(FILE *fp, int x, int y) {  			glUseProgram(shader.paste);  			GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");  			if (uniform >= 0) glUniform1i(uniform, 0); // No lighting -#endif +  			setPMVMatrix(shader.paste);  			setPrimaryColor(1.0, 1.0, 1.0, 0.5); -#if 0 +  			glBindTexture(GL_TEXTURE_2D, tmpTex);  			//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -#endif +  			const GLfloat vertices[] = {  				(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,  				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset, 0., @@ -1481,10 +1482,10 @@ bool mixHSI(FILE *fp, int x, int y) {  			};  			drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords); -#if 0 +  			// Copy Our ViewPort To The Texture  			glUseProgram(0); -#endif +  			copyTexSubImage2D(GL_TEXTURE_2D, 0, (int)((x < 0) ? xoffset : x + xoffset), (int)((y < 0) ? yoffset : y + yoffset), (int)((x < 0) ? viewportOffsetX - x : viewportOffsetX), (int)((y < 0) ? viewportOffsetY - y : viewportOffsetY), w, h, backdropTextureName);  			yoffset += viewportHeight; @@ -1494,19 +1495,21 @@ bool mixHSI(FILE *fp, int x, int y) {  	}  	deleteTextures(1, &tmpTex);  	setPixelCoords(false); +#endif  	return true;  } -void saveCorePNG(FILE *writer, GLuint texture, int w, int h) { -	GLint tw, th; +void saveCorePNG(Common::WriteStream *stream, GLuint texture, int w, int h) {  #if 0 +	GLint tw, th; +  	glBindTexture(GL_TEXTURE_2D, texture); -#endif +  	getTextureDimensions(texture, &tw, &th);  	GLubyte *image = new GLubyte [tw * th * 4];  	if (! checkNew(image)) return; -#if 0 +  	glPixelStorei(GL_PACK_ALIGNMENT, 1);  //	glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, image);  #endif @@ -1557,11 +1560,11 @@ void saveCorePNG(FILE *writer, GLuint texture, int w, int h) {  #if 0  			glUseProgram(shader.texture); -#endif +  			setPMVMatrix(shader.texture);  			drawQuad(shader.texture, vertices, 1, texCoords); -#if 0 +  			glUseProgram(0);  			for (int i = 0; i < h; i++)   { diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h index 5dd2014ddc..8974f92deb 100644 --- a/engines/sludge/backdrop.h +++ b/engines/sludge/backdrop.h @@ -67,12 +67,12 @@ void mixBackDrop(int fileNum, int x, int y);  void drawBackDrop();  void blankScreen(int x1, int y1, int x2, int y2);  void darkScreen(); +void saveHSI(Common::WriteStream *stream);  #if 0 -void saveHSI(FILE *writer); -void saveCoreHSI(FILE *writer, GLuint texture, int w, int h); -bool loadHSI(FILE *fp, int, int, bool); -bool mixHSI(FILE *fp, int x = 0, int y = 0); +void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h);  #endif +bool loadHSI(Common::SeekableReadStream *stream, int, int, bool); +bool mixHSI(Common::SeekableReadStream *stream, int x = 0, int y = 0);  void drawHorizontalLine(unsigned int, unsigned int, unsigned int);  void drawVerticalLine(unsigned int, unsigned int, unsigned int);  void hardScroll(int distance); @@ -91,17 +91,13 @@ extern texture lightMap;  void killParallax();  bool loadParallax(unsigned short v, unsigned short fracX, unsigned short fracY); -#if 0 -void saveParallaxRecursive(parallaxLayer *me, FILE *fp); -#endif +void saveParallaxRecursive(parallaxLayer *me, Common::WriteStream *fp);  void reloadParallaxTextures();  void nosnapshot();  bool snapshot(); -#if ALLOW_FILE -void saveSnapshot(FILE *fp); -bool restoreSnapshot(FILE *fp); -#endif +void saveSnapshot(Common::WriteStream *stream); +bool restoreSnapshot(Common::SeekableReadStream *stream);  #endif  } // End of namespace Sludge diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp index 0a8550e01f..8a615514fa 100644 --- a/engines/sludge/bg_effects.cpp +++ b/engines/sludge/bg_effects.cpp @@ -28,6 +28,9 @@  #include "newfatal.h"  #include "moreio.h" +#include "common/debug.h" +#include "common/file.h" +  namespace Sludge {  #if 0 @@ -113,22 +116,20 @@ static int *s_matrixEffectData = NULL;  static int s_matrixEffectBase = 0;  #endif -#if ALLOW_FILE -void blur_saveSettings(FILE *fp) { +void blur_saveSettings(Common::WriteStream *stream) {  	if (s_matrixEffectData) { -		put4bytes(s_matrixEffectDivide, fp); -		put4bytes(s_matrixEffectWidth, fp); -		put4bytes(s_matrixEffectHeight, fp); -		put4bytes(s_matrixEffectBase, fp); -		fwrite(s_matrixEffectData, sizeof(int), s_matrixEffectWidth * s_matrixEffectHeight, fp); +		put4bytes(s_matrixEffectDivide, stream); +		put4bytes(s_matrixEffectWidth, stream); +		put4bytes(s_matrixEffectHeight, stream); +		put4bytes(s_matrixEffectBase, stream); +		stream->write(s_matrixEffectData, sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight);  	} else { -		put4bytes(0, fp); -		put4bytes(0, fp); -		put4bytes(0, fp); -		put4bytes(0, fp); +		put4bytes(0, stream); +		put4bytes(0, stream); +		put4bytes(0, stream); +		put4bytes(0, stream);  	}  } -#endif  static int *blur_allocateMemoryForEffect() {  	free(s_matrixEffectData); @@ -141,23 +142,21 @@ static int *blur_allocateMemoryForEffect() {  	return s_matrixEffectData;  } -#if ALLOW_FILE -void blur_loadSettings(FILE *fp) { -	s_matrixEffectDivide = get4bytes(fp); -	s_matrixEffectWidth = get4bytes(fp); -	s_matrixEffectHeight = get4bytes(fp); -	s_matrixEffectBase = get4bytes(fp); +void blur_loadSettings(Common::SeekableReadStream *stream) { +	s_matrixEffectDivide = get4bytes(stream); +	s_matrixEffectWidth = get4bytes(stream); +	s_matrixEffectHeight = get4bytes(stream); +	s_matrixEffectBase = get4bytes(stream);  	if (blur_allocateMemoryForEffect()) { -		size_t bytes_read = fread(s_matrixEffectData, sizeof(int), s_matrixEffectWidth * s_matrixEffectHeight, fp); -		if (bytes_read != sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight && ferror(fp)) { -			debugOut("Reading error in blur_loadSettings.\n"); +		size_t bytes_read = stream->read(s_matrixEffectData, sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight); +		if (bytes_read != sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight && stream->err()) { +			debug("Reading error in blur_loadSettings.");  		}  	} else { -		fseek(fp, sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight, SEEK_CUR); +		stream->seek(sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight, SEEK_CUR);  	}  } -#endif  bool blur_createSettings(int numParams, variableStack *&stack) {  	bool createNullThing = true; diff --git a/engines/sludge/bg_effects.h b/engines/sludge/bg_effects.h index d18fae6b20..b726ec7d3b 100644 --- a/engines/sludge/bg_effects.h +++ b/engines/sludge/bg_effects.h @@ -23,13 +23,13 @@  #ifndef SLUDGE_BG_EFFECTS_H
  #define SLUDGE_BG_EFFECTS_H
 +#include "common/file.h"
 +
  namespace Sludge {
  bool blurScreen();
 -#if ALLOW_FILE
 -void blur_saveSettings(FILE *fp);
 -void blur_loadSettings(FILE *fp);
 -#endif
 +void blur_saveSettings(Common::WriteStream *stream);
 +void blur_loadSettings(Common::SeekableReadStream *stream);
  bool blur_createSettings(int numParams, variableStack *&stack);
  } // End of namespace Sludge
 diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index 6f2660db0d..5d5c0fa3cf 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -99,11 +99,11 @@ extern unsigned int currentBlankColour;  extern unsigned int languageID;  extern unsigned char currentBurnR, currentBurnG, currentBurnB; -int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1,    // SAY -> MOVEMOUSE -                   -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS -> REMOVEREGION -                   2, 2, 0, 0, 2,                              // ANIMATE -> SETSCALE +int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1,    // SAY->MOVEMOUSE +                   -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION +                   2, 2, 0, 0, 2,                              // ANIMATE->SETSCALE                     -1, 2, 1, 0, 0, 0, 1, 0, 3,                 // new/push/pop stack, status stuff -                   2, 0, 0, 3, 1, 0, 2,                        // delFromStack -> completeTimers +                   2, 0, 0, 3, 1, 0, 2,                        // delFromStack->completeTimers                     -1, -1, -1, 2, 2, 0, 3, 1,                  // anim, costume, pO, setC, wait, sS, substring, stringLength                     0, 1, 1, 0, 2,                              // dark, save, load, quit, rename                     1, 3, 3, 1, 2, 1, 1, 3, 1, 0, 0, 2, 1,      // stackSize, pasteString, startMusic, defvol, vol, stopmus, stopsound, setfont, alignStatus, show x 2, pos'Status, setFloor @@ -166,20 +166,20 @@ static builtReturn sayCore(int numParams, loadedFunction *fun, bool sayIt) {  	switch (numParams) {  	case 3: -		if (!getValueType(fileNum, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(fileNum, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  	// No break; here  	case 2: -		newText = getTextFromAnyVar(fun -> stack -> thisVar); +		newText = getTextFromAnyVar(fun->stack->thisVar);  		if (!newText) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(objT, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		trimStack(fun->stack); +		if (!getValueType(objT, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		p = wrapSpeech(newText, objT, fileNum, sayIt); -		fun -> timeLeft = p; +		fun->timeLeft = p;  		//debugOut ("BUILTIN: sayCore: %s (%i)\n", newText, p); -		fun -> isSpeech = true; +		fun->isSpeech = true;  		delete newText;  		newText = NULL;  		return BR_KEEP_AND_PAUSE; @@ -206,7 +206,7 @@ builtIn(freeze) {  	UNUSEDALL  	freeze();  	freezeSubs(); -	fun -> freezerLevel = 0; +	fun->freezerLevel = 0;  	return BR_CONTINUE;  } @@ -219,63 +219,63 @@ builtIn(unfreeze) {  builtIn(howFrozen) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, howFrozen()); +	setVariable(fun->reg, SVT_INT, howFrozen());  	return BR_CONTINUE;  }  builtIn(setCursor) {  	UNUSEDALL -	personaAnimation *aa = getAnimationFromVar(fun -> stack -> thisVar); +	personaAnimation *aa = getAnimationFromVar(fun->stack->thisVar);  	pickAnimCursor(aa); -	trimStack(fun -> stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(getMouseX) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, input.mouseX + cameraX); +	setVariable(fun->reg, SVT_INT, input.mouseX + cameraX);  	return BR_CONTINUE;  }  builtIn(getMouseY) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, input.mouseY + cameraY); +	setVariable(fun->reg, SVT_INT, input.mouseY + cameraY);  	return BR_CONTINUE;  }  builtIn(getMouseScreenX) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, input.mouseX * cameraZoom); +	setVariable(fun->reg, SVT_INT, input.mouseX * cameraZoom);  	return BR_CONTINUE;  }  builtIn(getMouseScreenY) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, input.mouseY * cameraZoom); +	setVariable(fun->reg, SVT_INT, input.mouseY * cameraZoom);  	return BR_CONTINUE;  }  builtIn(getStatusText) {  	UNUSEDALL -	makeTextVar(fun -> reg, statusBarText()); +	makeTextVar(fun->reg, statusBarText());  	return BR_CONTINUE;  }  builtIn(getMatchingFiles) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newText = getTextFromAnyVar(fun->stack->thisVar);  	if (!newText) return BR_ERROR; -	trimStack(fun -> stack); -	unlinkVar(fun -> reg); +	trimStack(fun->stack); +	unlinkVar(fun->reg);  	// Return value -	fun -> reg.varType = SVT_STACK; -	fun -> reg.varData.theStack = new stackHandler; -	if (!checkNew(fun -> reg.varData.theStack)) return BR_ERROR; -	fun -> reg.varData.theStack -> first = NULL; -	fun -> reg.varData.theStack -> last = NULL; -	fun -> reg.varData.theStack -> timesUsed = 1; -	if (!getSavedGamesStack(fun -> reg.varData.theStack, newText)) return BR_ERROR; +	fun->reg.varType = SVT_STACK; +	fun->reg.varData.theStack = new stackHandler; +	if (!checkNew(fun->reg.varData.theStack)) return BR_ERROR; +	fun->reg.varData.theStack->first = NULL; +	fun->reg.varData.theStack->last = NULL; +	fun->reg.varData.theStack->timesUsed = 1; +	if (!getSavedGamesStack(fun->reg.varData.theStack, newText)) return BR_ERROR;  	delete newText;  	newText = NULL;  	return BR_CONTINUE; @@ -288,8 +288,8 @@ builtIn(saveGame) {  		fatal("Can't save game state while the engine is frozen");  	} -	loadNow = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	loadNow = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	char *aaaaa = encodeFilename(loadNow);  	delete[] loadNow; @@ -298,15 +298,15 @@ builtIn(saveGame) {  	loadNow = joinStrings(":", aaaaa);  	delete[] aaaaa; -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	saverFunc = fun;  	return BR_KEEP_AND_PAUSE;  }  builtIn(fileExists) {  	UNUSEDALL -	loadNow = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	loadNow = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	char *aaaaa = encodeFilename(loadNow);  	delete loadNow;  	if (failSecurityCheck(aaaaa)) return BR_ERROR; @@ -328,7 +328,7 @@ builtIn(fileExists) {  	}  #endif  	// Return value -	setVariable(fun -> reg, SVT_INT, 0/*(fp != NULL)*/);//TODO:false value +	setVariable(fun->reg, SVT_INT, 0/*(fp != NULL)*/);//TODO:false value  #if 0  	if (fp) fclose(fp);  	delete[] aaaaa; @@ -339,24 +339,23 @@ builtIn(fileExists) {  builtIn(loadGame) {  	UNUSEDALL -	char *aaaaa = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	char *aaaaa = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	loadNow = encodeFilename(aaaaa);  	delete aaaaa;  	if (frozenStuff) {  		fatal("Can't load a saved game while the engine is frozen");  	} -#if ALLOW_FILE  	if (failSecurityCheck(loadNow)) return BR_ERROR; -	FILE *fp = fopen(loadNow, "rb"); -	if (fp) { -		fclose(fp); +	Common::File fd; +	if (fd.open(loadNow)) { +		fd.close();  		return BR_KEEP_AND_PAUSE;  	}  	delete loadNow;  	loadNow = NULL; -#endif +  	return BR_CONTINUE;  } @@ -373,14 +372,14 @@ builtIn(blankScreen) {  builtIn(blankArea) {  	UNUSEDALL  	int x1, y1, x2, y2; -	if (!getValueType(y2, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x2, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(y1, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x1, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y2, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x2, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(y1, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x1, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	blankScreen(x1, y1, x2, y2);  	return BR_CONTINUE;  } @@ -394,12 +393,12 @@ builtIn(darkBackground) {  builtIn(addOverlay) {  	UNUSEDALL  	int fileNumber, xPos, yPos; -	if (!getValueType(yPos, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(xPos, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(yPos, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(xPos, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	loadBackDrop(fileNumber, xPos, yPos);  	return BR_CONTINUE;  } @@ -407,12 +406,12 @@ builtIn(addOverlay) {  builtIn(mixOverlay) {  	UNUSEDALL  	int fileNumber, xPos, yPos; -	if (!getValueType(yPos, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(xPos, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(yPos, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(xPos, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	mixBackDrop(fileNumber, xPos, yPos);  	return BR_CONTINUE;  } @@ -420,12 +419,12 @@ builtIn(mixOverlay) {  builtIn(pasteImage) {  	UNUSEDALL  	int x, y; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	personaAnimation *pp = getAnimationFromVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	personaAnimation *pp = getAnimationFromVar(fun->stack->thisVar); +	trimStack(fun->stack);  	if (pp == NULL) return BR_CONTINUE;  	pasteCursor(x, y, pp); @@ -438,10 +437,10 @@ builtIn(pasteImage) {  builtIn(setSceneDimensions) {  	UNUSEDALL  	int x, y; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (resizeBackdrop(x, y)) {  		blankScreen(0, 0, x, y);  		return BR_CONTINUE; @@ -452,10 +451,10 @@ builtIn(setSceneDimensions) {  builtIn(aimCamera) {  	UNUSEDALL -	if (!getValueType(cameraY, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(cameraX, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(cameraY, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(cameraX, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	cameraX -= (float)(winWidth >> 1) / cameraZoom;  	cameraY -= (float)(winHeight >> 1) / cameraZoom; @@ -471,8 +470,8 @@ builtIn(aimCamera) {  builtIn(zoomCamera) {  	UNUSEDALL  	int z; -	if (!getValueType(z, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(z, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	input.mouseX = input.mouseX * cameraZoom;  	input.mouseY = input.mouseY * cameraZoom; @@ -507,8 +506,8 @@ builtIn(pickOne) {  	// Return value  	while (numParams --) { -		if (i == numParams) copyVariable(fun -> stack -> thisVar, fun -> reg); -		trimStack(fun -> stack); +		if (i == numParams) copyVariable(fun->stack->thisVar, fun->reg); +		trimStack(fun->stack);  	}  	return BR_CONTINUE;  } @@ -521,12 +520,12 @@ builtIn(substring) {  	//debugOut ("BUILTIN: substring\n"); -	if (!getValueType(length, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(start, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	wholeString = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	if (!getValueType(length, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(start, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	wholeString = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	if (u8_strlen(wholeString) < start + length) {  		length = u8_strlen(wholeString) - start; @@ -549,37 +548,37 @@ builtIn(substring) {  	memcpy(newString, wholeString + startoffset, endoffset - startoffset);  	newString[endoffset - startoffset] = 0; -	makeTextVar(fun -> reg, newString); +	makeTextVar(fun->reg, newString);  	delete newString;  	return BR_CONTINUE;  }  builtIn(stringLength) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, stringLength(newText)); +	char *newText = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, stringLength(newText));  	delete[] newText;  	return BR_CONTINUE;  }  builtIn(newStack) {  	UNUSEDALL -	unlinkVar(fun -> reg); +	unlinkVar(fun->reg);  	// Return value -	fun -> reg.varType = SVT_STACK; -	fun -> reg.varData.theStack = new stackHandler; -	if (!checkNew(fun -> reg.varData.theStack)) return BR_ERROR; -	fun -> reg.varData.theStack -> first = NULL; -	fun -> reg.varData.theStack -> last = NULL; -	fun -> reg.varData.theStack -> timesUsed = 1; +	fun->reg.varType = SVT_STACK; +	fun->reg.varData.theStack = new stackHandler; +	if (!checkNew(fun->reg.varData.theStack)) return BR_ERROR; +	fun->reg.varData.theStack->first = NULL; +	fun->reg.varData.theStack->last = NULL; +	fun->reg.varData.theStack->timesUsed = 1;  	while (numParams --) { -		if (!addVarToStack(fun -> stack -> thisVar, fun -> reg.varData.theStack -> first)) return BR_ERROR; -		if (fun -> reg.varData.theStack -> last == NULL) { -			fun -> reg.varData.theStack -> last = fun -> reg.varData.theStack -> first; +		if (!addVarToStack(fun->stack->thisVar, fun->reg.varData.theStack->first)) return BR_ERROR; +		if (fun->reg.varData.theStack->last == NULL) { +			fun->reg.varData.theStack->last = fun->reg.varData.theStack->first;  		} -		trimStack(fun -> stack); +		trimStack(fun->stack);  	}  	return BR_CONTINUE;  } @@ -589,17 +588,17 @@ builtIn(newStack) {  builtIn(stackSize) {  	UNUSEDALL -	switch (fun -> stack -> thisVar.varType) { +	switch (fun->stack->thisVar.varType) {  	case SVT_STACK:  		// Return value -		setVariable(fun -> reg, SVT_INT, stackSize(fun -> stack -> thisVar.varData.theStack)); -		trimStack(fun -> stack); +		setVariable(fun->reg, SVT_INT, stackSize(fun->stack->thisVar.varData.theStack)); +		trimStack(fun->stack);  		return BR_CONTINUE;  	case SVT_FASTARRAY:  		// Return value -		setVariable(fun -> reg, SVT_INT, fun -> stack -> thisVar.varData.fastArray -> size); -		trimStack(fun -> stack); +		setVariable(fun->reg, SVT_INT, fun->stack->thisVar.varData.fastArray->size); +		trimStack(fun->stack);  		return BR_CONTINUE;  	default: @@ -611,147 +610,147 @@ builtIn(stackSize) {  builtIn(copyStack) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType != SVT_STACK) { +	if (fun->stack->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	}  	// Return value -	if (!copyStack(fun -> stack -> thisVar, fun -> reg)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!copyStack(fun->stack->thisVar, fun->reg)) return BR_ERROR; +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(pushToStack) {  	UNUSEDALL -	if (fun -> stack -> next -> thisVar.varType != SVT_STACK) { +	if (fun->stack->next->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack");  		return BR_ERROR;  	} -	if (!addVarToStack(fun -> stack -> thisVar, fun -> stack -> next -> thisVar.varData.theStack -> first)) +	if (!addVarToStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first))  		return BR_ERROR; -	if (fun -> stack -> next -> thisVar.varData.theStack -> first -> next == NULL) -		fun -> stack -> next -> thisVar.varData.theStack -> last = fun -> stack -> next -> thisVar.varData.theStack -> first; +	if (fun->stack->next->thisVar.varData.theStack->first->next == NULL) +		fun->stack->next->thisVar.varData.theStack->last = fun->stack->next->thisVar.varData.theStack->first; -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(enqueue) {  	UNUSEDALL -	if (fun -> stack -> next -> thisVar.varType != SVT_STACK) { +	if (fun->stack->next->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack");  		return BR_ERROR;  	} -	if (fun -> stack -> next -> thisVar.varData.theStack -> first == NULL) { -		if (!addVarToStack(fun -> stack -> thisVar, fun -> stack -> next -> thisVar.varData.theStack -> first)) +	if (fun->stack->next->thisVar.varData.theStack->first == NULL) { +		if (!addVarToStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first))  			return BR_ERROR; -		fun -> stack -> next -> thisVar.varData.theStack -> last = fun -> stack -> next -> thisVar.varData.theStack -> first; +		fun->stack->next->thisVar.varData.theStack->last = fun->stack->next->thisVar.varData.theStack->first;  	} else { -		if (!addVarToStack(fun -> stack -> thisVar, -		                    fun -> stack -> next -> thisVar.varData.theStack -> last -> next)) +		if (!addVarToStack(fun->stack->thisVar, +		                    fun->stack->next->thisVar.varData.theStack->last->next))  			return BR_ERROR; -		fun -> stack -> next -> thisVar.varData.theStack -> last = fun -> stack -> next -> thisVar.varData.theStack -> last -> next; +		fun->stack->next->thisVar.varData.theStack->last = fun->stack->next->thisVar.varData.theStack->last->next;  	} -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(deleteFromStack) {  	UNUSEDALL -	if (fun -> stack -> next -> thisVar.varType != SVT_STACK) { +	if (fun->stack->next->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	}  	// Return value -	setVariable(fun -> reg, SVT_INT, -	            deleteVarFromStack(fun -> stack -> thisVar, -	                               fun -> stack -> next -> thisVar.varData.theStack -> first, false)); +	setVariable(fun->reg, SVT_INT, +	            deleteVarFromStack(fun->stack->thisVar, +	                               fun->stack->next->thisVar.varData.theStack->first, false));  	// Horrible hacking because 'last' value might now be wrong!  	fun->stack->next->thisVar.varData.theStack->last = stackFindLast(fun->stack->next->thisVar.varData.theStack->first); -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(deleteAllFromStack) {  	UNUSEDALL -	if (fun -> stack -> next -> thisVar.varType != SVT_STACK) { +	if (fun->stack->next->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	}  	// Return value -	setVariable(fun -> reg, SVT_INT, -	            deleteVarFromStack(fun -> stack -> thisVar, -	                               fun -> stack -> next -> thisVar.varData.theStack -> first, true)); +	setVariable(fun->reg, SVT_INT, +	            deleteVarFromStack(fun->stack->thisVar, +	                               fun->stack->next->thisVar.varData.theStack->first, true));  	// Horrible hacking because 'last' value might now be wrong!  	fun->stack->next->thisVar.varData.theStack->last = stackFindLast(fun->stack->next->thisVar.varData.theStack->first); -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(popFromStack) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType != SVT_STACK) { +	if (fun->stack->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	} -	if (fun -> stack -> thisVar.varData.theStack -> first == NULL) { +	if (fun->stack->thisVar.varData.theStack->first == NULL) {  		fatal("The stack's empty.");  		return BR_ERROR;  	}  	// Return value -	copyVariable(fun -> stack -> thisVar.varData.theStack -> first -> thisVar, fun -> reg); -	trimStack(fun -> stack -> thisVar.varData.theStack -> first); -	trimStack(fun -> stack); +	copyVariable(fun->stack->thisVar.varData.theStack->first->thisVar, fun->reg); +	trimStack(fun->stack->thisVar.varData.theStack->first); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(peekStart) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType != SVT_STACK) { +	if (fun->stack->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	} -	if (fun -> stack -> thisVar.varData.theStack -> first == NULL) { +	if (fun->stack->thisVar.varData.theStack->first == NULL) {  		fatal("The stack's empty.");  		return BR_ERROR;  	}  	// Return value -	copyVariable(fun -> stack -> thisVar.varData.theStack -> first -> thisVar, fun -> reg); -	trimStack(fun -> stack); +	copyVariable(fun->stack->thisVar.varData.theStack->first->thisVar, fun->reg); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(peekEnd) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType != SVT_STACK) { +	if (fun->stack->thisVar.varType != SVT_STACK) {  		fatal("Parameter isn't a stack.");  		return BR_ERROR;  	} -	if (fun -> stack -> thisVar.varData.theStack -> first == NULL) { +	if (fun->stack->thisVar.varData.theStack->first == NULL) {  		fatal("The stack's empty.");  		return BR_ERROR;  	}  	// Return value -	copyVariable(fun -> stack -> thisVar.varData.theStack -> last -> thisVar, fun -> reg); -	trimStack(fun -> stack); +	copyVariable(fun->stack->thisVar.varData.theStack->last->thisVar, fun->reg); +	trimStack(fun->stack);  	return BR_CONTINUE;  } @@ -759,22 +758,22 @@ builtIn(random) {  	UNUSEDALL  	int num; -	if (!getValueType(num, SVT_INT, fun -> stack -> thisVar)) +	if (!getValueType(num, SVT_INT, fun->stack->thisVar))  		return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack);  	if (num <= 0) num = 1; -	setVariable(fun -> reg, SVT_INT, 0 /*rand() % num*/); //TODO:false value +	setVariable(fun->reg, SVT_INT, 0 /*rand() % num*/); //TODO:false value  	return BR_CONTINUE;  }  static bool getRGBParams(int &red, int &green, int &blue, loadedFunction *fun) { -	if (!getValueType(blue, SVT_INT, fun -> stack -> thisVar)) return false; -	trimStack(fun -> stack); -	if (!getValueType(green, SVT_INT, fun -> stack -> thisVar)) return false; -	trimStack(fun -> stack); -	if (!getValueType(red, SVT_INT, fun -> stack -> thisVar)) return false; -	trimStack(fun -> stack); +	if (!getValueType(blue, SVT_INT, fun->stack->thisVar)) return false; +	trimStack(fun->stack); +	if (!getValueType(green, SVT_INT, fun->stack->thisVar)) return false; +	trimStack(fun->stack); +	if (!getValueType(red, SVT_INT, fun->stack->thisVar)) return false; +	trimStack(fun->stack);  	return true;  } @@ -819,7 +818,7 @@ builtIn(setBlankColour) {  		return BR_ERROR;  	currentBlankColour = makeColour(red & 255, green & 255, blue & 255); -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  } @@ -833,7 +832,7 @@ builtIn(setBurnColour) {  	currentBurnR = red;  	currentBurnG = green;  	currentBurnB = blue; -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  } @@ -841,16 +840,16 @@ builtIn(setBurnColour) {  builtIn(setFont) {  	UNUSEDALL  	int fileNumber, newHeight; -	if (!getValueType(newHeight, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; +	if (!getValueType(newHeight, SVT_INT, fun->stack->thisVar)) return BR_ERROR;  	//              newDebug ("  Height:", newHeight); -	trimStack(fun -> stack); -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); +	trimStack(fun->stack); +	char *newText = getTextFromAnyVar(fun->stack->thisVar);  	if (!newText) return BR_ERROR;  	//              newDebug ("  Character supported:", newText); -	trimStack(fun -> stack); -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR;  	//              newDebug ("  File:", fileNumber); -	trimStack(fun -> stack); +	trimStack(fun->stack);  	if (!loadFont(fileNumber, newText, newHeight)) return BR_ERROR;  	//              newDebug ("  Done!");  	delete newText; @@ -860,25 +859,25 @@ builtIn(setFont) {  builtIn(inFont) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newText = getTextFromAnyVar(fun->stack->thisVar);  	if (!newText) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack);  	// Return value -	setVariable(fun -> reg, SVT_INT, isInFont(newText)); +	setVariable(fun->reg, SVT_INT, isInFont(newText));  	return BR_CONTINUE;  }  builtIn(pasteString) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	char *newText = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	int y, x; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (x == IN_THE_CENTRE) x = (winWidth - stringWidth(newText)) >> 1;  	fixFont(pastePalette);  	pasteStringToBackdrop(newText, x, y, pastePalette); @@ -894,12 +893,12 @@ builtIn(anim) {  	}  	// First store the frame numbers and take 'em off the stack -	personaAnimation *ba = createPersonaAnim(numParams - 1, fun -> stack); +	personaAnimation *ba = createPersonaAnim(numParams - 1, fun->stack);  	// Only remaining paramter is the file number  	int fileNumber; -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	// Load the required sprite bank  	loadedSpriteBank *sprBanky = loadBankForAnim(fileNumber); @@ -907,7 +906,7 @@ builtIn(anim) {  	setBankFile(ba, sprBanky);  	// Return value -	newAnimationVariable(fun -> reg, ba); +	newAnimationVariable(fun->reg, ba);  	return BR_CONTINUE;  } @@ -916,32 +915,32 @@ builtIn(costume) {  	UNUSEDALL  	persona *newPersona = new persona;  	if (!checkNew(newPersona)) return BR_ERROR; -	newPersona -> numDirections = numParams / 3; -	if (numParams == 0 || newPersona -> numDirections * 3 != numParams) { +	newPersona->numDirections = numParams / 3; +	if (numParams == 0 || newPersona->numDirections * 3 != numParams) {  		fatal("Illegal number of parameters (should be greater than 0 and divisible by 3)");  		return BR_ERROR;  	}  	int iii; -	newPersona -> animation = new personaAnimation * [numParams]; -	if (!checkNew(newPersona -> animation)) return BR_ERROR; +	newPersona->animation = new personaAnimation * [numParams]; +	if (!checkNew(newPersona->animation)) return BR_ERROR;  	for (iii = numParams - 1; iii >= 0; iii --) { -		newPersona -> animation[iii] = getAnimationFromVar(fun -> stack -> thisVar); -		trimStack(fun -> stack); +		newPersona->animation[iii] = getAnimationFromVar(fun->stack->thisVar); +		trimStack(fun->stack);  	}  	// Return value -	newCostumeVariable(fun -> reg, newPersona); +	newCostumeVariable(fun->reg, newPersona);  	return BR_CONTINUE;  }  builtIn(launch) {  	UNUSEDALL -	char *newTextA = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newTextA = getTextFromAnyVar(fun->stack->thisVar);  	if (!newTextA) return BR_ERROR;  	char *newText = encodeFilename(newTextA); -	trimStack(fun -> stack); +	trimStack(fun->stack);  	if (newTextA[0] == 'h' &&  	        newTextA[1] == 't' &&  	        newTextA[2] == 't' && @@ -963,7 +962,7 @@ builtIn(launch) {  	}  	delete newTextA;  	setGraphicsWindow(false); -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	launchResult = &fun->reg;  	return BR_KEEP_AND_PAUSE; @@ -972,11 +971,11 @@ builtIn(launch) {  builtIn(pause) {  	UNUSEDALL  	int theTime; -	if (!getValueType(theTime, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(theTime, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (theTime > 0) { -		fun -> timeLeft = theTime - 1; -		fun -> isSpeech = false; +		fun->timeLeft = theTime - 1; +		fun->isSpeech = false;  		return BR_KEEP_AND_PAUSE;  	}  	return BR_CONTINUE; @@ -991,19 +990,19 @@ builtIn(completeTimers) {  builtIn(callEvent) {  	UNUSEDALL  	int obj1, obj2; -	if (!getValueType(obj2, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj1, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(obj2, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj1, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	int fNum = getCombinationFunction(obj1, obj2);  	// Return value  	if (fNum) { -		setVariable(fun -> reg, SVT_FUNC, fNum); +		setVariable(fun->reg, SVT_FUNC, fNum);  		return BR_CALLAFUNC;  	} -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  } @@ -1030,19 +1029,19 @@ builtIn(quitGame) {  // The old movie functions are deprecated and does nothing.  builtIn(_rem_movieStart) {  	UNUSEDALL -	trimStack(fun -> stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  }  builtIn(_rem_movieAbort) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  }  builtIn(_rem_moviePlaying) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  } @@ -1052,12 +1051,12 @@ builtIn(playMovie) {  	if (movieIsPlaying) return BR_PAUSE; -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	r = playMovie(fileNumber); -	setVariable(fun -> reg, SVT_INT, r); +	setVariable(fun->reg, SVT_INT, r);  	if (r && (!fun->next)) {  		restartFunction(fun); @@ -1072,7 +1071,7 @@ builtIn(stopMovie) {  	r = stopMovie(); -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  } @@ -1082,7 +1081,7 @@ builtIn(pauseMovie) {  	r = pauseMovie(); -	setVariable(fun -> reg, SVT_INT, 0); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  } @@ -1093,12 +1092,12 @@ builtIn(pauseMovie) {  builtIn(startMusic) {  	UNUSEDALL  	int fromTrack, musChan, fileNumber; -	if (!getValueType(fromTrack, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(musChan, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(fromTrack, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(musChan, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (!playMOD(fileNumber, musChan, fromTrack)) return BR_CONTINUE;  //BR_ERROR;  	return BR_CONTINUE;  } @@ -1106,8 +1105,8 @@ builtIn(startMusic) {  builtIn(stopMusic) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	stopMOD(v);  	return BR_CONTINUE;  } @@ -1115,10 +1114,10 @@ builtIn(stopMusic) {  builtIn(setMusicVolume) {  	UNUSEDALL  	int musChan, v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(musChan, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(musChan, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setMusicVolume(musChan, v);  	return BR_CONTINUE;  } @@ -1126,8 +1125,8 @@ builtIn(setMusicVolume) {  builtIn(setDefaultMusicVolume) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setDefaultMusicVolume(v);  	return BR_CONTINUE;  } @@ -1135,8 +1134,8 @@ builtIn(setDefaultMusicVolume) {  builtIn(playSound) {  	UNUSEDALL  	int fileNumber; -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (!startSound(fileNumber, false)) return BR_CONTINUE;    // Was BR_ERROR  	return BR_CONTINUE;  } @@ -1149,8 +1148,8 @@ builtIn(loopSound) {  		return BR_ERROR;  	} else if (numParams < 2) { -		if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		if (!startSound(fileNumber, true)) return BR_CONTINUE;     // Was BR_ERROR  		return BR_CONTINUE;  	} else { @@ -1162,12 +1161,12 @@ builtIn(loopSound) {  		// Should we loop?  		if (fun->stack->thisVar.varType != SVT_FILE) { -			getValueType(doLoop, SVT_INT, fun -> stack -> thisVar); -			trimStack(fun -> stack); +			getValueType(doLoop, SVT_INT, fun->stack->thisVar); +			trimStack(fun->stack);  			numParams--;  		}  		while (numParams) { -			if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) { +			if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) {  				fatal("Illegal parameter given built-in function loopSound().");  				return BR_ERROR;  			} @@ -1198,8 +1197,8 @@ builtIn(loopSound) {  builtIn(stopSound) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	huntKillSound(v);  	return BR_CONTINUE;  } @@ -1207,8 +1206,8 @@ builtIn(stopSound) {  builtIn(setDefaultSoundVolume) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setDefaultSoundVolume(v);  	return BR_CONTINUE;  } @@ -1216,10 +1215,10 @@ builtIn(setDefaultSoundVolume) {  builtIn(setSoundVolume) {  	UNUSEDALL  	int musChan, v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(musChan, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setSoundVolume(musChan, v);  	return BR_CONTINUE;  } @@ -1228,12 +1227,12 @@ builtIn(setSoundVolume) {  builtIn(setSoundLoopPoints) {  	UNUSEDALL  	int musChan, theEnd, theStart; -	if (!getValueType(theEnd, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(theStart, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(musChan, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(theEnd, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(theStart, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setSoundLoop(musChan, theStart, theEnd);  	return BR_CONTINUE;  } @@ -1243,13 +1242,13 @@ builtIn(setSoundLoopPoints) {  builtIn(setFloor) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType == SVT_FILE) { +	if (fun->stack->thisVar.varType == SVT_FILE) {  		int v; -		getValueType(v, SVT_FILE, fun -> stack -> thisVar); -		trimStack(fun -> stack); +		getValueType(v, SVT_FILE, fun->stack->thisVar); +		trimStack(fun->stack);  		if (!setFloor(v)) return BR_ERROR;  	} else { -		trimStack(fun -> stack); +		trimStack(fun->stack);  		setFloorNull();  	}  	return BR_CONTINUE; @@ -1263,13 +1262,13 @@ builtIn(showFloor) {  builtIn(setZBuffer) {  	UNUSEDALL -	if (fun -> stack -> thisVar.varType == SVT_FILE) { +	if (fun->stack->thisVar.varType == SVT_FILE) {  		int v; -		getValueType(v, SVT_FILE, fun -> stack -> thisVar); -		trimStack(fun -> stack); +		getValueType(v, SVT_FILE, fun->stack->thisVar); +		trimStack(fun->stack);  		if (!setZBuffer(v)) return BR_ERROR;  	} else { -		trimStack(fun -> stack); +		trimStack(fun->stack);  		killZBuffer();  	}  	return BR_CONTINUE; @@ -1279,22 +1278,22 @@ builtIn(setLightMap) {  	UNUSEDALL  	switch (numParams) {  	case 2: -		if (!getValueType(lightMapMode, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(lightMapMode, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		lightMapMode %= LIGHTMAPMODE_NUM;  	// No break;  	case 1: -		if (fun -> stack -> thisVar.varType == SVT_FILE) { +		if (fun->stack->thisVar.varType == SVT_FILE) {  			int v; -			getValueType(v, SVT_FILE, fun -> stack -> thisVar); -			trimStack(fun -> stack); +			getValueType(v, SVT_FILE, fun->stack->thisVar); +			trimStack(fun->stack);  			if (!loadLightMap(v)) return BR_ERROR; -			setVariable(fun -> reg, SVT_INT, 1); +			setVariable(fun->reg, SVT_INT, 1);  		} else { -			trimStack(fun -> stack); +			trimStack(fun->stack);  			killLightMap(); -			setVariable(fun -> reg, SVT_INT, 0); +			setVariable(fun->reg, SVT_INT, 0);  		}  		break; @@ -1311,8 +1310,8 @@ builtIn(setLightMap) {  builtIn(setSpeechMode) {  	UNUSEDALL -	if (!getValueType(speechMode, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(speechMode, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (speechMode < 0 || speechMode > 2) {  		fatal("Valid parameters are be SPEECHANDTEXT, SPEECHONLY or TEXTONLY");  		return BR_ERROR; @@ -1324,9 +1323,9 @@ builtIn(somethingSpeaking) {  	UNUSEDALL  	int i = isThereAnySpeechGoingOn();  	if (i == -1) { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	} else { -		setVariable(fun -> reg, SVT_OBJTYPE, i); +		setVariable(fun->reg, SVT_OBJTYPE, i);  	}  	return BR_CONTINUE;  } @@ -1341,42 +1340,42 @@ builtIn(getOverObject) {  	UNUSEDALL  	if (overRegion)  		// Return value -		setVariable(fun -> reg, SVT_OBJTYPE, overRegion -> thisType -> objectNum); +		setVariable(fun->reg, SVT_OBJTYPE, overRegion->thisType->objectNum);  	else  		// Return value -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  }  builtIn(rename) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newText = getTextFromAnyVar(fun->stack->thisVar);  	int objT;  	if (!newText) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(objT, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack); +	if (!getValueType(objT, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	objectType *o = findObjectType(objT); -	delete o -> screenName; -	o -> screenName = newText; +	delete o->screenName; +	o->screenName = newText;  	return BR_CONTINUE;  }  builtIn(getObjectX) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *pers = findPerson(objectNumber);  	if (pers) { -		setVariable(fun -> reg, SVT_INT, pers -> x); +		setVariable(fun->reg, SVT_INT, pers->x);  	} else {  		screenRegion *la = getRegionForObject(objectNumber);  		if (la) { -			setVariable(fun -> reg, SVT_INT, la -> sX); +			setVariable(fun->reg, SVT_INT, la->sX);  		} else { -			setVariable(fun -> reg, SVT_INT, 0); +			setVariable(fun->reg, SVT_INT, 0);  		}  	}  	return BR_CONTINUE; @@ -1385,18 +1384,18 @@ builtIn(getObjectX) {  builtIn(getObjectY) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *pers = findPerson(objectNumber);  	if (pers) { -		setVariable(fun -> reg, SVT_INT, pers -> y); +		setVariable(fun->reg, SVT_INT, pers->y);  	} else {  		screenRegion *la = getRegionForObject(objectNumber);  		if (la) { -			setVariable(fun -> reg, SVT_INT, la -> sY); +			setVariable(fun->reg, SVT_INT, la->sY);  		} else { -			setVariable(fun -> reg, SVT_INT, 0); +			setVariable(fun->reg, SVT_INT, 0);  		}  	}  	return BR_CONTINUE; @@ -1406,22 +1405,22 @@ builtIn(getObjectY) {  builtIn(addScreenRegion) {  	UNUSEDALL  	int sX, sY, x1, y1, x2, y2, di, objectNumber; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(sY, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(sX, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(y2, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x2, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(y1, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x1, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(sY, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(sX, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(y2, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x2, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(y1, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x1, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (addScreenRegion(x1, y1, x2, y2, sX, sY, di, objectNumber)) return BR_CONTINUE;  	return BR_ERROR; @@ -1430,8 +1429,8 @@ builtIn(addScreenRegion) {  builtIn(removeScreenRegion) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	removeScreenRegion(objectNumber);  	return BR_CONTINUE;  } @@ -1453,16 +1452,16 @@ builtIn(addCharacter) {  	persona *p;  	int x, y, objectNumber; -	p = getCostumeFromVar(fun -> stack -> thisVar); +	p = getCostumeFromVar(fun->stack->thisVar);  	if (p == NULL) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (addPerson(x, y, objectNumber, p)) return BR_CONTINUE;  	return BR_ERROR;  } @@ -1470,8 +1469,8 @@ builtIn(addCharacter) {  builtIn(hideCharacter) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setShown(false, objectNumber);  	return BR_CONTINUE;  } @@ -1479,8 +1478,8 @@ builtIn(hideCharacter) {  builtIn(showCharacter) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setShown(true, objectNumber);  	return BR_CONTINUE;  } @@ -1495,36 +1494,36 @@ builtIn(removeAllCharacters) {  builtIn(setCharacterDrawMode) {  	UNUSEDALL  	int obj, di; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setDrawMode(di, obj);  	return BR_CONTINUE;  }  builtIn(setCharacterTransparency) {  	UNUSEDALL  	int obj, x; -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setPersonTransparency(obj, x);  	return BR_CONTINUE;  }  builtIn(setCharacterColourise) {  	UNUSEDALL  	int obj, r, g, b, mix; -	if (!getValueType(mix, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(b, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(g, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(r, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(mix, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(b, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(g, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(r, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setPersonColourise(obj, r, g, b, mix);  	return BR_CONTINUE;  } @@ -1532,10 +1531,10 @@ builtIn(setCharacterColourise) {  builtIn(setScale) {  	UNUSEDALL  	int val1, val2; -	if (!getValueType(val2, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(val1, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(val2, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(val1, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setScale((short int) val1, (short int) val2);  	return BR_CONTINUE;  } @@ -1543,35 +1542,35 @@ builtIn(setScale) {  builtIn(stopCharacter) {  	UNUSEDALL  	int obj; -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	// Return value -	setVariable(fun -> reg, SVT_INT, stopPerson(obj)); +	setVariable(fun->reg, SVT_INT, stopPerson(obj));  	return BR_CONTINUE;  }  builtIn(pasteCharacter) {  	UNUSEDALL  	int obj; -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(obj);  	if (thisPerson) {  		personaAnimation *myAnim; -		myAnim = thisPerson -> myAnim; -		if (myAnim != thisPerson -> lastUsedAnim) { -			thisPerson -> lastUsedAnim = myAnim; -			thisPerson -> frameNum = 0; -			thisPerson -> frameTick = myAnim -> frames[0].howMany; +		myAnim = thisPerson->myAnim; +		if (myAnim != thisPerson->lastUsedAnim) { +			thisPerson->lastUsedAnim = myAnim; +			thisPerson->frameNum = 0; +			thisPerson->frameTick = myAnim->frames[0].howMany;  		} -		int fNum = myAnim -> frames[thisPerson -> frameNum].frameNum; -		fixScaleSprite(thisPerson -> x, thisPerson -> y, myAnim -> theSprites -> bank.sprites[abs(fNum)], myAnim -> theSprites -> bank.myPalette, thisPerson, 0, 0, fNum < 0); -		setVariable(fun -> reg, SVT_INT, 1); +		int fNum = myAnim->frames[thisPerson->frameNum].frameNum; +		fixScaleSprite(thisPerson->x, thisPerson->y, myAnim->theSprites->bank.sprites[abs(fNum)], myAnim->theSprites->bank.myPalette, thisPerson, 0, 0, fNum < 0); +		setVariable(fun->reg, SVT_INT, 1);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -1579,24 +1578,24 @@ builtIn(pasteCharacter) {  builtIn(animate) {  	UNUSEDALL  	int obj; -	personaAnimation *pp = getAnimationFromVar(fun -> stack -> thisVar); +	personaAnimation *pp = getAnimationFromVar(fun->stack->thisVar);  	if (pp == NULL) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	animatePerson(obj, pp); -	setVariable(fun -> reg, SVT_INT, timeForAnim(pp)); +	setVariable(fun->reg, SVT_INT, timeForAnim(pp));  	return BR_CONTINUE;  }  builtIn(setCostume) {  	UNUSEDALL  	int obj; -	persona *pp = getCostumeFromVar(fun -> stack -> thisVar); +	persona *pp = getCostumeFromVar(fun->stack->thisVar);  	if (pp == NULL) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	animatePerson(obj, pp);  	return BR_CONTINUE;  } @@ -1604,52 +1603,52 @@ builtIn(setCostume) {  builtIn(floatCharacter) {  	UNUSEDALL  	int obj, di; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, floatCharacter(di, obj)); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, floatCharacter(di, obj));  	return BR_CONTINUE;  }  builtIn(setCharacterWalkSpeed) {  	UNUSEDALL  	int obj, di; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, setCharacterWalkSpeed(di, obj)); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, setCharacterWalkSpeed(di, obj));  	return BR_CONTINUE;  }  builtIn(turnCharacter) {  	UNUSEDALL  	int obj, di; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, turnPersonToFace(obj, di)); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, turnPersonToFace(obj, di));  	return BR_CONTINUE;  }  builtIn(setCharacterExtra) {  	UNUSEDALL  	int obj, di; -	if (!getValueType(di, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, setPersonExtra(obj, di)); +	if (!getValueType(di, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, setPersonExtra(obj, di));  	return BR_CONTINUE;  }  builtIn(removeCharacter) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	removeOneCharacter(objectNumber);  	return BR_CONTINUE;  } @@ -1659,12 +1658,12 @@ static builtReturn moveChr(int numParams, loadedFunction *fun, bool force, bool  	case 3: {  		int x, y, objectNumber; -		if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack); +		if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack); +		if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		if (force) {  			if (forceWalkingPerson(x, y, objectNumber, fun, -1)) return BR_PAUSE; @@ -1680,19 +1679,19 @@ static builtReturn moveChr(int numParams, loadedFunction *fun, bool force, bool  		int toObj, objectNumber;  		screenRegion *reggie; -		if (!getValueType(toObj, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(toObj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack); +		if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		reggie = getRegionForObject(toObj);  		if (reggie == NULL) return BR_CONTINUE;  		if (force) { -			if (forceWalkingPerson(reggie -> sX, reggie -> sY, objectNumber, fun, reggie -> di)) return BR_PAUSE; +			if (forceWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di)) return BR_PAUSE;  		} else if (immediate) { -			jumpPerson(reggie -> sX, reggie -> sY, objectNumber); +			jumpPerson(reggie->sX, reggie->sY, objectNumber);  		} else { -			if (makeWalkingPerson(reggie -> sX, reggie -> sY, objectNumber, fun, reggie -> di)) return BR_PAUSE; +			if (makeWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di)) return BR_PAUSE;  		}  		return BR_CONTINUE;  	} @@ -1738,9 +1737,9 @@ builtIn(addStatus) {  builtIn(statusText) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newText = getTextFromAnyVar(fun->stack->thisVar);  	if (!newText) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack);  	setStatusBar(newText);  	delete newText;  	return BR_CONTINUE; @@ -1749,8 +1748,8 @@ builtIn(statusText) {  builtIn(lightStatus) {  	UNUSEDALL  	int val; -	if (!getValueType(val, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(val, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	setLitStatus(val);  	return BR_CONTINUE;  } @@ -1758,10 +1757,10 @@ builtIn(lightStatus) {  builtIn(positionStatus) {  	UNUSEDALL  	int x, y; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	positionStatus(x, y);  	return BR_CONTINUE;  } @@ -1769,9 +1768,9 @@ builtIn(positionStatus) {  builtIn(alignStatus) {  	UNUSEDALL  	int val; -	if (!getValueType(val, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	nowStatus -> alignStatus = (short) val; +	if (!getValueType(val, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	nowStatus->alignStatus = (short) val;  	return BR_CONTINUE;  } @@ -1782,8 +1781,8 @@ static bool getFuncNumForCallback(int numParams, loadedFunction *fun, int &funct  		break;  	case 1: -		if (!getValueType(functionNum, SVT_FUNC, fun -> stack -> thisVar)) return false; -		trimStack(fun -> stack); +		if (!getValueType(functionNum, SVT_FUNC, fun->stack->thisVar)) return false; +		trimStack(fun->stack);  		break;  	default: @@ -1797,7 +1796,7 @@ builtIn(onLeftMouse) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> leftMouseFunction = functionNum; +		currentEvents->leftMouseFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1807,7 +1806,7 @@ builtIn(onLeftMouseUp) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> leftMouseUpFunction = functionNum; +		currentEvents->leftMouseUpFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1817,7 +1816,7 @@ builtIn(onRightMouse) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> rightMouseFunction = functionNum; +		currentEvents->rightMouseFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1827,7 +1826,7 @@ builtIn(onRightMouseUp) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> rightMouseUpFunction = functionNum; +		currentEvents->rightMouseUpFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1837,7 +1836,7 @@ builtIn(onFocusChange) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> focusFunction = functionNum; +		currentEvents->focusFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1847,7 +1846,7 @@ builtIn(onMoveMouse) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> moveMouseFunction = functionNum; +		currentEvents->moveMouseFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1857,7 +1856,7 @@ builtIn(onKeyboard) {  	UNUSEDALL  	int functionNum;  	if (getFuncNumForCallback(numParams, fun, functionNum)) { -		currentEvents -> spaceFunction = functionNum; +		currentEvents->spaceFunction = functionNum;  		return BR_CONTINUE;  	}  	return BR_ERROR; @@ -1890,12 +1889,12 @@ builtIn(cancelSub) {  builtIn(stringWidth) {  	UNUSEDALL -	char *theText = getTextFromAnyVar(fun -> stack -> thisVar); +	char *theText = getTextFromAnyVar(fun->stack->thisVar);  	if (!theText) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack);  	// Return value -	setVariable(fun -> reg, SVT_INT, stringWidth(theText)); +	setVariable(fun->reg, SVT_INT, stringWidth(theText));  	delete theText;  	return BR_CONTINUE;  } @@ -1903,8 +1902,8 @@ builtIn(stringWidth) {  builtIn(hardScroll) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	hardScroll(v);  	return BR_CONTINUE;  } @@ -1913,37 +1912,37 @@ builtIn(hardScroll) {  builtIn(isScreenRegion) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, getRegionForObject(objectNumber) != NULL); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, getRegionForObject(objectNumber) != NULL);  	return BR_CONTINUE;  }  builtIn(setSpeechSpeed) {  	UNUSEDALL  	int number; -	if (!getValueType(number, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(number, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	speechSpeed = number * 0.01; -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  }  builtIn(setFontSpacing) {  	UNUSEDALL  	int fontSpaceI; -	if (!getValueType(fontSpaceI, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; +	if (!getValueType(fontSpaceI, SVT_INT, fun->stack->thisVar)) return BR_ERROR;  	fontSpace = fontSpaceI; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, 1); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  }  builtIn(transitionLevel) {  	UNUSEDALL  	int number; -	if (!getValueType(number, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(number, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (number < 0)  		brightnessLevel = 0; @@ -1952,15 +1951,15 @@ builtIn(transitionLevel) {  	else  		brightnessLevel = number; -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  }  builtIn(captureAllKeys) {  	UNUSEDALL -	captureAllKeys = getBoolean(fun -> stack -> thisVar); -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, captureAllKeys); +	captureAllKeys = getBoolean(fun->stack->thisVar); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, captureAllKeys);  	return BR_CONTINUE;  } @@ -1968,20 +1967,20 @@ builtIn(captureAllKeys) {  builtIn(spinCharacter) {  	UNUSEDALL  	int number, objectNumber; -	if (!getValueType(number, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(number, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(objectNumber);  	if (thisPerson) { -		thisPerson -> wantAngle = number; -		thisPerson -> spinning = true; -		thisPerson -> continueAfterWalking = fun; -		setVariable(fun -> reg, SVT_INT, 1); +		thisPerson->wantAngle = number; +		thisPerson->spinning = true; +		thisPerson->continueAfterWalking = fun; +		setVariable(fun->reg, SVT_INT, 1);  		return BR_PAUSE;  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  		return BR_CONTINUE;  	}  } @@ -1989,13 +1988,13 @@ builtIn(spinCharacter) {  builtIn(getCharacterDirection) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(objectNumber);  	if (thisPerson) { -		setVariable(fun -> reg, SVT_INT, thisPerson -> direction); +		setVariable(fun->reg, SVT_INT, thisPerson->direction);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2003,24 +2002,24 @@ builtIn(getCharacterDirection) {  builtIn(isCharacter) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(objectNumber); -	setVariable(fun -> reg, SVT_INT, thisPerson != NULL); +	setVariable(fun->reg, SVT_INT, thisPerson != NULL);  	return BR_CONTINUE;  }  builtIn(normalCharacter) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(objectNumber);  	if (thisPerson) { -		thisPerson -> myAnim = thisPerson -> myPersona -> animation[thisPerson -> direction]; -		setVariable(fun -> reg, SVT_INT, 1); +		thisPerson->myAnim = thisPerson->myPersona->animation[thisPerson->direction]; +		setVariable(fun->reg, SVT_INT, 1);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2028,13 +2027,13 @@ builtIn(normalCharacter) {  builtIn(isMoving) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(objectNumber);  	if (thisPerson) { -		setVariable(fun -> reg, SVT_INT, thisPerson -> walking); +		setVariable(fun->reg, SVT_INT, thisPerson->walking);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2042,18 +2041,18 @@ builtIn(isMoving) {  builtIn(fetchEvent) {  	UNUSEDALL  	int obj1, obj2; -	if (!getValueType(obj2, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(obj1, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(obj2, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(obj1, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	int fNum = getCombinationFunction(obj1, obj2);  	// Return value  	if (fNum) { -		setVariable(fun -> reg, SVT_FUNC, fNum); +		setVariable(fun->reg, SVT_FUNC, fNum);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2061,12 +2060,12 @@ builtIn(fetchEvent) {  builtIn(deleteFile) {  	UNUSEDALL -	char *namNormal = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	char *namNormal = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	char *nam = encodeFilename(namNormal);  	delete namNormal;  	if (failSecurityCheck(nam)) return BR_ERROR; -	setVariable(fun -> reg, SVT_INT, remove(nam)); +	setVariable(fun->reg, SVT_INT, remove(nam));  	delete nam;  	return BR_CONTINUE; @@ -2076,19 +2075,19 @@ builtIn(renameFile) {  	UNUSEDALL  	char *temp; -	temp = getTextFromAnyVar(fun -> stack -> thisVar); +	temp = getTextFromAnyVar(fun->stack->thisVar);  	char *newnam = encodeFilename(temp); -	trimStack(fun -> stack); +	trimStack(fun->stack);  	if (failSecurityCheck(newnam)) return BR_ERROR;  	delete temp; -	temp = getTextFromAnyVar(fun -> stack -> thisVar); +	temp = getTextFromAnyVar(fun->stack->thisVar);  	char *nam = encodeFilename(temp); -	trimStack(fun -> stack); +	trimStack(fun->stack);  	if (failSecurityCheck(nam)) return BR_ERROR;  	delete temp; -	setVariable(fun -> reg, SVT_INT, rename(nam, newnam)); +	setVariable(fun->reg, SVT_INT, rename(nam, newnam));  	delete nam;  	delete newnam; @@ -2099,21 +2098,21 @@ builtIn(renameFile) {  builtIn(cacheSound) {  	UNUSEDALL  	int fileNumber; -	if (!getValueType(fileNumber, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (cacheSound(fileNumber) == -1) return BR_ERROR;  	return BR_CONTINUE;  }  builtIn(burnString) {  	UNUSEDALL -	char *newText = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	char *newText = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	int y, x; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (x == IN_THE_CENTRE) x = (winWidth - stringWidth(newText)) >> 1;  	fixFont(pastePalette);  	burnStringToBackdrop(newText, x, y, pastePalette); @@ -2124,18 +2123,18 @@ builtIn(burnString) {  builtIn(setCharacterSpinSpeed) {  	UNUSEDALL  	int speed, who; -	if (!getValueType(speed, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(who, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(speed, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(who, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(who);  	if (thisPerson) { -		thisPerson -> spinSpeed = speed; -		setVariable(fun -> reg, SVT_INT, 1); +		thisPerson->spinSpeed = speed; +		setVariable(fun->reg, SVT_INT, 1);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2143,18 +2142,18 @@ builtIn(setCharacterSpinSpeed) {  builtIn(setCharacterAngleOffset) {  	UNUSEDALL  	int angle, who; -	if (!getValueType(angle, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(who, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(angle, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(who, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *thisPerson = findPerson(who);  	if (thisPerson) { -		thisPerson -> angleOffset = angle; -		setVariable(fun -> reg, SVT_INT, 1); +		thisPerson->angleOffset = angle; +		setVariable(fun->reg, SVT_INT, 1);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  } @@ -2163,10 +2162,10 @@ builtIn(setCharacterAngleOffset) {  builtIn(transitionMode) {  	UNUSEDALL  	int n; -	if (!getValueType(n, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; +	if (!getValueType(n, SVT_INT, fun->stack->thisVar)) return BR_ERROR;  	fadeMode = n; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, 1); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  } @@ -2174,41 +2173,41 @@ builtIn(transitionMode) {  // Removed function - does nothing  builtIn(_rem_updateDisplay) {  	UNUSEDALL -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, true); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, true);  	return BR_CONTINUE;  }  builtIn(getSoundCache) {  	UNUSEDALL -	fun -> reg.varType = SVT_STACK; -	fun -> reg.varData.theStack = new stackHandler; -	if (!checkNew(fun -> reg.varData.theStack)) return BR_ERROR; -	fun -> reg.varData.theStack -> first = NULL; -	fun -> reg.varData.theStack -> last = NULL; -	fun -> reg.varData.theStack -> timesUsed = 1; -	if (!getSoundCacheStack(fun -> reg.varData.theStack)) return BR_ERROR; +	fun->reg.varType = SVT_STACK; +	fun->reg.varData.theStack = new stackHandler; +	if (!checkNew(fun->reg.varData.theStack)) return BR_ERROR; +	fun->reg.varData.theStack->first = NULL; +	fun->reg.varData.theStack->last = NULL; +	fun->reg.varData.theStack->timesUsed = 1; +	if (!getSoundCacheStack(fun->reg.varData.theStack)) return BR_ERROR;  	return BR_CONTINUE;  }  builtIn(saveCustomData) {  	UNUSEDALL  	// saveCustomData (thisStack, fileName); -	char *fileNameB = getTextFromAnyVar(fun -> stack -> thisVar); +	char *fileNameB = getTextFromAnyVar(fun->stack->thisVar);  	if (!checkNew(fileNameB)) return BR_ERROR;  	char *fileName = encodeFilename(fileNameB);  	delete fileNameB;  	if (failSecurityCheck(fileName)) return BR_ERROR; -	trimStack(fun -> stack); +	trimStack(fun->stack); -	if (fun -> stack -> thisVar.varType != SVT_STACK) { +	if (fun->stack->thisVar.varType != SVT_STACK) {  		fatal("First parameter isn't a stack");  		return BR_ERROR;  	} -	if (!stackToFile(fileName, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!stackToFile(fileName, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	delete fileName;  	return BR_CONTINUE;  } @@ -2216,23 +2215,23 @@ builtIn(saveCustomData) {  builtIn(loadCustomData) {  	UNUSEDALL -	char *newTextA = getTextFromAnyVar(fun -> stack -> thisVar); +	char *newTextA = getTextFromAnyVar(fun->stack->thisVar);  	if (!checkNew(newTextA)) return BR_ERROR;  	char *newText = encodeFilename(newTextA);  	delete newTextA;  	if (failSecurityCheck(newText)) return BR_ERROR; -	trimStack(fun -> stack); - -	unlinkVar(fun -> reg); -	fun -> reg.varType = SVT_STACK; -	fun -> reg.varData.theStack = new stackHandler; -	if (!checkNew(fun -> reg.varData.theStack)) return BR_ERROR; -	fun -> reg.varData.theStack -> first = NULL; -	fun -> reg.varData.theStack -> last = NULL; -	fun -> reg.varData.theStack -> timesUsed = 1; -	if (!fileToStack(newText, fun -> reg.varData.theStack)) return BR_ERROR; +	trimStack(fun->stack); + +	unlinkVar(fun->reg); +	fun->reg.varType = SVT_STACK; +	fun->reg.varData.theStack = new stackHandler; +	if (!checkNew(fun->reg.varData.theStack)) return BR_ERROR; +	fun->reg.varData.theStack->first = NULL; +	fun->reg.varData.theStack->last = NULL; +	fun->reg.varData.theStack->timesUsed = 1; +	if (!fileToStack(newText, fun->reg.varData.theStack)) return BR_ERROR;  	delete newText;  	return BR_CONTINUE;  } @@ -2240,18 +2239,18 @@ builtIn(loadCustomData) {  builtIn(setCustomEncoding) {  	UNUSEDALL  	int n; -	if (!getValueType(n, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; +	if (!getValueType(n, SVT_INT, fun->stack->thisVar)) return BR_ERROR;  	saveEncoding = n; -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, 1); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  }  builtIn(freeSound) {  	UNUSEDALL  	int v; -	if (!getValueType(v, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(v, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	huntKillFreeSound(v);  	return BR_CONTINUE;  } @@ -2263,15 +2262,15 @@ builtIn(parallaxAdd) {  		return BR_ERROR;  	} else {  		int wrapX, wrapY, v; -		if (!getValueType(wrapY, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(wrapX, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); -		if (!getValueType(v, SVT_FILE, fun -> stack -> thisVar)) return BR_ERROR; -		trimStack(fun -> stack); +		if (!getValueType(wrapY, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack); +		if (!getValueType(wrapX, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack); +		if (!getValueType(v, SVT_FILE, fun->stack->thisVar)) return BR_ERROR; +		trimStack(fun->stack);  		if (!loadParallax(v, wrapX, wrapY)) return BR_ERROR; -		setVariable(fun -> reg, SVT_INT, 1); +		setVariable(fun->reg, SVT_INT, 1);  	}  	return BR_CONTINUE;  } @@ -2279,44 +2278,44 @@ builtIn(parallaxAdd) {  builtIn(parallaxClear) {  	UNUSEDALL  	killParallax(); -	setVariable(fun -> reg, SVT_INT, 1); +	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE;  }  builtIn(getPixelColour) {  	UNUSEDALL  	int x, y; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); -	unlinkVar(fun -> reg); -	fun -> reg.varType = SVT_STACK; -	fun -> reg.varData.theStack = new stackHandler; -	if (!checkNew(fun -> reg.varData.theStack)) return BR_ERROR; -	fun -> reg.varData.theStack -> first = NULL; -	fun -> reg.varData.theStack -> last = NULL; -	fun -> reg.varData.theStack -> timesUsed = 1; -	if (!getRGBIntoStack(x, y, fun -> reg.varData.theStack)) return BR_ERROR; +	unlinkVar(fun->reg); +	fun->reg.varType = SVT_STACK; +	fun->reg.varData.theStack = new stackHandler; +	if (!checkNew(fun->reg.varData.theStack)) return BR_ERROR; +	fun->reg.varData.theStack->first = NULL; +	fun->reg.varData.theStack->last = NULL; +	fun->reg.varData.theStack->timesUsed = 1; +	if (!getRGBIntoStack(x, y, fun->reg.varData.theStack)) return BR_ERROR;  	return BR_CONTINUE;  }  builtIn(makeFastArray) {  	UNUSEDALL -	switch (fun -> stack -> thisVar.varType) { +	switch (fun->stack->thisVar.varType) {  	case SVT_STACK: { -		bool success = makeFastArrayFromStack(fun -> reg, fun -> stack -> thisVar.varData.theStack); -		trimStack(fun -> stack); +		bool success = makeFastArrayFromStack(fun->reg, fun->stack->thisVar.varData.theStack); +		trimStack(fun->stack);  		return success ? BR_CONTINUE : BR_ERROR;  	}  	break;  	case SVT_INT: { -		int i = fun -> stack -> thisVar.varData.intValue; -		trimStack(fun -> stack); -		return makeFastArraySize(fun -> reg, i) ? BR_CONTINUE : BR_ERROR; +		int i = fun->stack->thisVar.varData.intValue; +		trimStack(fun->stack); +		return makeFastArraySize(fun->reg, i) ? BR_CONTINUE : BR_ERROR;  	}  	break; @@ -2330,21 +2329,21 @@ builtIn(makeFastArray) {  builtIn(getCharacterScale) {  	UNUSEDALL  	int objectNumber; -	if (!getValueType(objectNumber, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	onScreenPerson *pers = findPerson(objectNumber);  	if (pers) { -		setVariable(fun -> reg, SVT_INT, pers -> scale * 100); +		setVariable(fun->reg, SVT_INT, pers->scale * 100);  	} else { -		setVariable(fun -> reg, SVT_INT, 0); +		setVariable(fun->reg, SVT_INT, 0);  	}  	return BR_CONTINUE;  }  builtIn(getLanguageID) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, gameSettings.languageID); +	setVariable(fun->reg, SVT_INT, gameSettings.languageID);  	return BR_CONTINUE;  } @@ -2352,9 +2351,9 @@ builtIn(getLanguageID) {  builtIn(_rem_launchWith) {  	UNUSEDALL -	trimStack(fun -> stack); -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, false); +	trimStack(fun->stack); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, false);  	return BR_CONTINUE; @@ -2362,22 +2361,22 @@ builtIn(_rem_launchWith) {  builtIn(getFramesPerSecond) {  	UNUSEDALL -	setVariable(fun -> reg, SVT_INT, lastFramesPerSecond); +	setVariable(fun->reg, SVT_INT, lastFramesPerSecond);  	return BR_CONTINUE;  }  builtIn(showThumbnail) {  	UNUSEDALL  	int x, y; -	if (!getValueType(y, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(x, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(y, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(x, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	// Encode the name!Encode the name! -	char *aaaaa = getTextFromAnyVar(fun -> stack -> thisVar); +	char *aaaaa = getTextFromAnyVar(fun->stack->thisVar);  	//              deb ("Got name:", aaaaa;) -	trimStack(fun -> stack); +	trimStack(fun->stack);  	//              deb ("About to encode", aaaaa);  	char *file = encodeFilename(aaaaa);  	//              deb ("Made new name", file); @@ -2391,10 +2390,10 @@ builtIn(showThumbnail) {  builtIn(setThumbnailSize) {  	UNUSEDALL -	if (!getValueType(thumbHeight, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(thumbWidth, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(thumbHeight, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(thumbWidth, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	if (thumbWidth < 0 || thumbHeight < 0 || thumbWidth > winWidth || thumbHeight > winHeight) {  		char buff[50];  		sprintf(buff, "%d x %d", thumbWidth, thumbHeight); @@ -2407,13 +2406,13 @@ builtIn(setThumbnailSize) {  builtIn(hasFlag) {  	UNUSEDALL  	int objNum, flagIndex; -	if (!getValueType(flagIndex, SVT_INT, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); -	if (!getValueType(objNum, SVT_OBJTYPE, fun -> stack -> thisVar)) return BR_ERROR; -	trimStack(fun -> stack); +	if (!getValueType(flagIndex, SVT_INT, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack); +	if (!getValueType(objNum, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; +	trimStack(fun->stack);  	objectType *objT = findObjectType(objNum);  	if (!objT) return BR_ERROR; -	setVariable(fun -> reg, SVT_INT, objT->flags & (1 << flagIndex)); +	setVariable(fun->reg, SVT_INT, objT->flags & (1 << flagIndex));  	return BR_CONTINUE;  } @@ -2431,26 +2430,26 @@ builtIn(snapshotClear) {  builtIn(bodgeFilenames) {  	UNUSEDALL  	bool lastValue = allowAnyFilename; -	allowAnyFilename = getBoolean(fun -> stack -> thisVar); -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, lastValue); +	allowAnyFilename = getBoolean(fun->stack->thisVar); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, lastValue);  	return BR_CONTINUE;  }  // Deprecated - does nothing.  builtIn(_rem_registryGetString) {  	UNUSEDALL -	trimStack(fun -> stack); -	trimStack(fun -> stack); -	setVariable(fun -> reg, SVT_INT, 0); +	trimStack(fun->stack); +	trimStack(fun->stack); +	setVariable(fun->reg, SVT_INT, 0);  	return BR_CONTINUE;  }  builtIn(quitWithFatalError) {  	UNUSEDALL -	char *mess = getTextFromAnyVar(fun -> stack -> thisVar); -	trimStack(fun -> stack); +	char *mess = getTextFromAnyVar(fun->stack->thisVar); +	trimStack(fun->stack);  	fatal(mess);  	return BR_ERROR;  } @@ -2458,10 +2457,10 @@ builtIn(quitWithFatalError) {  builtIn(_rem_setCharacterAA) {  	UNUSEDALL -	trimStack(fun -> stack); -	trimStack(fun -> stack); -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE;  } @@ -2469,9 +2468,9 @@ builtIn(_rem_setCharacterAA) {  builtIn(_rem_setMaximumAA) {  	UNUSEDALL -	trimStack(fun -> stack); -	trimStack(fun -> stack); -	trimStack(fun -> stack); +	trimStack(fun->stack); +	trimStack(fun->stack); +	trimStack(fun->stack);  	return BR_CONTINUE; @@ -2480,14 +2479,14 @@ builtIn(_rem_setMaximumAA) {  builtIn(setBackgroundEffect) {  	UNUSEDALL  	bool done = blur_createSettings(numParams, fun->stack); -	setVariable(fun -> reg, SVT_INT, done ? 1 : 0); +	setVariable(fun->reg, SVT_INT, done ? 1 : 0);  	return BR_CONTINUE;  }  builtIn(doBackgroundEffect) {  	UNUSEDALL  	bool done = blurScreen(); -	setVariable(fun -> reg, SVT_INT, done ? 1 : 0); +	setVariable(fun->reg, SVT_INT, done ? 1 : 0);  	return BR_CONTINUE;  } @@ -2516,11 +2515,11 @@ builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun) {  	// fprintf (stderr, "Calling function %d: %s\n", whichFunc, builtInFunctionNames[whichFunc]);    fflush (stderr);  	if (numBIFNames) { -		//      deb ("IN:", (fun -> originalNumber < numUserFunc) ? allUserFunc[fun -> originalNumber] : "Unknown user function"); +		//      deb ("IN:", (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function");  		//      deb ("GO:", (whichFunc < numBIFNames) ? allBIFNames[whichFunc] : "Unknown built-in function");  		setFatalInfo( -		    (fun -> originalNumber < numUserFunc) ? allUserFunc[fun -> originalNumber] : "Unknown user function", +		    (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",  		    (whichFunc < numBIFNames) ? allBIFNames[whichFunc] : "Unknown built-in function");  	} diff --git a/engines/sludge/detection.cpp b/engines/sludge/detection.cpp index 8297165f73..7e5c124fa3 100644 --- a/engines/sludge/detection.cpp +++ b/engines/sludge/detection.cpp @@ -43,6 +43,8 @@ Common::Language SludgeEngine::getLanguage() const { return _gameDescription->de  static const PlainGameDescriptor sludgeGames[] = {  	{ "sludge", "Sludge Game" },  	{ "welcome", "Welcome Example" }, +	{ "welcome2", "Welcome Example 2" }, +	{ "verbcoin", "Verb Coin" },  	{ 0, 0 }  }; @@ -61,6 +63,32 @@ static const SludgeGameDescription gameDescriptions[] = {  		0  	}, +	{ +		{ +			"welcome2", +			"", +			AD_ENTRY1("Welcome.slg", "cb1f307c05b8ae4107bcc7f86a3d2f99"), +			Common::EN_ANY, +			Common::kPlatformUnknown, +			ADGF_NO_FLAGS, +			GUIO0() +		}, +		0 +	}, + +	{ +		{ +			"verbcoin", +			"", +			AD_ENTRY1("Welcome.slg", "e39ec315dcbf3a1137481f0a5fe1617d"), +			Common::EN_ANY, +			Common::kPlatformUnknown, +			ADGF_NO_FLAGS, +			GUIO0() +		}, +		0 +	}, +  	{ AD_TABLE_END_MARKER, 0 }  }; diff --git a/engines/sludge/fileset.cpp b/engines/sludge/fileset.cpp index 852fd70016..3c653f4bed 100644 --- a/engines/sludge/fileset.cpp +++ b/engines/sludge/fileset.cpp @@ -29,18 +29,19 @@  #include "debug.h"  #include "stringy.h" -  #include "allfiles.h"  #include "moreio.h"  #include "newfatal.h"  #include "CommonCode/version.h" +#include "common/file.h" +  namespace Sludge {  bool sliceBusy = true; -#if ALLOW_FILE -FILE *bigDataFile = NULL; -#endif + +Common::File *bigDataFile = NULL; +  uint32_t startOfDataIndex, startOfTextIndex,           startOfSubIndex, startOfObjectIndex; @@ -54,8 +55,8 @@ bool openSubSlice(int num) {  		return false;  	}  //	fprintf (dbug, "Going to position %li\n", startOfSubIndex + (num << 2)); -	fseek(bigDataFile, startOfSubIndex + (num << 2), 0); -	fseek(bigDataFile, get4bytes(bigDataFile), 0); +	bigDataFile->seek(startOfSubIndex + (num << 2), 0); +	bigDataFile->seek(get4bytes(bigDataFile), 0);  //	fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));  //	fclose (dbug); @@ -73,8 +74,8 @@ bool openObjectSlice(int num) {  	}  //	fprintf (dbug, "Going to position %li\n", startOfObjectIndex + (num << 2)); -	fseek(bigDataFile, startOfObjectIndex + (num << 2), 0); -	fseek(bigDataFile, get4bytes(bigDataFile), 0); +	bigDataFile->seek(startOfObjectIndex + (num << 2), 0); +	bigDataFile->seek(get4bytes(bigDataFile), 0);  //	fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));  //	fclose (dbug);  	return sliceBusy = true; @@ -90,8 +91,8 @@ unsigned int openFileFromNum(int num) {  //	fprintf (dbug, "\nTrying to open file %i\n", num);  //	fprintf (dbug, "Jumping to %li (for index) \n", startOfDataIndex + (num << 2)); -	fseek(bigDataFile, startOfDataIndex + (num << 2), 0); -	fseek(bigDataFile, get4bytes(bigDataFile), 1); +	bigDataFile->seek(startOfDataIndex + (num << 2), 0); +	bigDataFile->seek(get4bytes(bigDataFile), 1);  //	fprintf (dbug, "Jumping to %li (for data) \n", ftell (bigDataFile));  	sliceBusy = true;  //	fclose (dbug); @@ -103,6 +104,7 @@ unsigned int openFileFromNum(int num) {  // Converts a string from Windows CP-1252 to UTF-8.  // This is needed for old games.  char *convertString(char *s) { +#if 0  	static char *buf = NULL;  	if (! buf) { @@ -161,6 +163,8 @@ char *convertString(char *s) {  	delete [] sOrig;  	return copyString(buf = bufOrig); +#endif +	return s;//TODO: false value  }  char *getNumberedString(int value) { @@ -170,9 +174,9 @@ char *getNumberedString(int value) {  		return NULL;  	} -	fseek(bigDataFile, (value << 2) + startOfTextIndex, 0); +	bigDataFile->seek((value << 2) + startOfTextIndex, 0);  	value = get4bytes(bigDataFile); -	fseek(bigDataFile, value, 0); +	bigDataFile->seek(value, 0);  	char *s = readString(bigDataFile); @@ -195,15 +199,15 @@ void finishAccess() {  int32_t startIndex; -void setFileIndices(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; -		startIndex = ftell(fp); +		startIndex = fp->pos();  	} else {  		// No file pointer - this means that we reuse the bigDataFile  		fp = bigDataFile; -		fseek(fp, startIndex, 0); +		fp->seek(startIndex, SEEK_SET);  	}  	sliceBusy = false; @@ -215,26 +219,26 @@ void setFileIndices(FILE *fp, int numLanguages, unsigned int skipBefore) {  	// STRINGS  	int skipAfter = numLanguages - skipBefore;  	while (skipBefore) { -		fseek(fp, get4bytes(fp), 0); +		fp->seek(get4bytes(fp), SEEK_SET);  		skipBefore --;  	} -	startOfTextIndex = ftell(fp) + 4; +	startOfTextIndex = fp->pos() + 4; -	fseek(fp, get4bytes(fp), 0); +	fp->seek(get4bytes(fp), SEEK_SET);  	while (skipAfter) { -		fseek(fp, get4bytes(fp), 0); +		fp->seek(get4bytes(fp), SEEK_SET);  		skipAfter --;  	} -	startOfSubIndex = ftell(fp) + 4; -	fseek(fp, get4bytes(fp), 1); +	startOfSubIndex = fp->pos() + 4; +	fp->seek(get4bytes(fp), SEEK_CUR); -	startOfObjectIndex = ftell(fp) + 4; -	fseek(fp, get4bytes(fp), 1); +	startOfObjectIndex = fp->pos() + 4; +	fp->seek(get4bytes(fp), SEEK_CUR);  	// Remember that the data section starts here -	startOfDataIndex = ftell(fp); +	startOfDataIndex = fp->pos();  }  } // End of namespace Sludge diff --git a/engines/sludge/fileset.h b/engines/sludge/fileset.h index b83e47dcf5..2dec0d3d4c 100644 --- a/engines/sludge/fileset.h +++ b/engines/sludge/fileset.h @@ -22,13 +22,13 @@  #ifndef SLUDGE_FILESET_H
  #define SLUDGE_FILESET_H
 +#include "common/file.h"
 +
  namespace Sludge {
 -#if ALLOW_FILE
 -extern FILE *bigDataFile;
 +extern Common::File *bigDataFile;
 -void setFileIndices(FILE *fp, int, unsigned int);
 -#endif
 +void setFileIndices(Common::File *fp, int, unsigned int);
  unsigned int openFileFromNum(int num);
  bool openSubSlice(int num);
 diff --git a/engines/sludge/floor.cpp b/engines/sludge/floor.cpp index 291961dc68..7ca30b6c3d 100644 --- a/engines/sludge/floor.cpp +++ b/engines/sludge/floor.cpp @@ -127,13 +127,13 @@ bool setFloor(int fileNum) {  	killFloor();  	setResourceForFatal(fileNum); -#if ALLOW_FILE +  	if (! openFileFromNum(fileNum)) return false;  	// Find out how many polygons there are and reserve memory  	currentFloor -> originalNum = fileNum; -	currentFloor -> numPolygons = fgetc(bigDataFile); +	currentFloor -> numPolygons = getch(bigDataFile);  	currentFloor -> polygon = new floorPolygon[currentFloor -> numPolygons];  	if (! checkNew(currentFloor -> polygon)) return false; @@ -143,7 +143,7 @@ bool setFloor(int fileNum) {  		// Find out how many vertex IDs there are and reserve memory -		currentFloor -> polygon[i].numVertices = fgetc(bigDataFile); +		currentFloor -> polygon[i].numVertices = getch(bigDataFile);  		currentFloor -> polygon[i].vertexID = new int[currentFloor -> polygon[i].numVertices];  		if (! checkNew(currentFloor -> polygon[i].vertexID)) return false; @@ -167,7 +167,7 @@ bool setFloor(int fileNum) {  	}  	finishAccess(); -#endif +  	// Now build the movement martix  	currentFloor -> matrix = new int *[currentFloor -> numPolygons]; diff --git a/engines/sludge/helpers.cpp b/engines/sludge/helpers.cpp index 30d50943ac..60a29af4c6 100644 --- a/engines/sludge/helpers.cpp +++ b/engines/sludge/helpers.cpp @@ -22,18 +22,19 @@  #include "allfiles.h"  #include "helpers.h" +#include "common/file.h" +  namespace Sludge {  bool fileExists(const char *file) {  	bool retval = false; -#if ALLOW_FILE -	FILE *tester; -	tester = fopen(file, "rb"); -	if (tester) { + +	Common::File tester; +	if (tester.open(file)) {  		retval = true; -		fclose(tester); +		tester.close();  	} -#endif +  	return retval;  } diff --git a/engines/sludge/language.cpp b/engines/sludge/language.cpp index a55adae752..4fe27805b6 100644 --- a/engines/sludge/language.cpp +++ b/engines/sludge/language.cpp @@ -19,8 +19,7 @@   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.   *   */ -#include <stdio.h> -#include <string.h> +#include "allfiles.h"  #include "stringy.h"  #include "newfatal.h"  #include "moreio.h" @@ -28,6 +27,10 @@  #include "CommonCode/version.h"  #include "platform-dependent.h" +#include "sludge.h" + +#include "common/debug.h" +  namespace Sludge {  int *languageTable; @@ -84,13 +87,17 @@ char *getPrefsFilename(char *filename) {  }  void readIniFile(char *filename) { -#if ALLOW_FILE +  	char *langName = getPrefsFilename(copyString(filename)); -	FILE *fp = fopen(langName, "rb"); +	Common::File fd; +	if (!fd.open(langName)) { +		debug(kSludgeDebugDataLoad, "Fail to open language file : %s", langName); +		return; +	}  	gameSettings.languageID = 0; -	gameSettings.userFullScreen = defaultUserFullScreen(); +	gameSettings.userFullScreen = false; //defaultUserFullScreen(); TODO: false value  	gameSettings.refreshRate = 0;  	gameSettings.antiAlias = 1;  	gameSettings.fixedPixels = false; @@ -100,70 +107,67 @@ void readIniFile(char *filename) {  	delete langName;  	langName = NULL; -	if (fp) { -		char lineSoFar[257] = ""; -		char secondSoFar[257] = ""; -		unsigned char here = 0; -		char readChar = ' '; -		bool keepGoing = true; -		bool doingSecond = false; - -		do { -			readChar = fgetc(fp); -			if (feof(fp)) { -				readChar = '\n'; -				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); -					} -				} -				here = 0; -				doingSecond = false; -				lineSoFar[0] = 0; -				secondSoFar[0] = 0; -				break; - -			case '=': -				doingSecond = true; -				here = 0; -				break; - -			default: -				if (doingSecond) { -					secondSoFar[here ++] = readChar; -					secondSoFar[here] = 0; -				} else { -					lineSoFar[here ++] = readChar; -					lineSoFar[here] = 0; +	char lineSoFar[257] = ""; +	char secondSoFar[257] = ""; +	unsigned char here = 0; +	char readChar = ' '; +	bool keepGoing = true; +	bool doingSecond = false; + +	do { +		readChar = getch(&fd); +		if (fd.eos()) { +			readChar = '\n'; +			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);  				} -				break;  			} -		} while (keepGoing); +			here = 0; +			doingSecond = false; +			lineSoFar[0] = 0; +			secondSoFar[0] = 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; +		} +	} while (keepGoing); -		fclose(fp); -	} -#endif +	fd.close();  }  void saveIniFile(char *filename) { -#if ALLOW_FILE +#if 0  	char *langName = getPrefsFilename(copyString(filename));  	FILE *fp = fopen(langName, "wt");  	delete langName; @@ -179,8 +183,7 @@ void saveIniFile(char *filename) {  #endif  } -#if ALLOW_FILE -void makeLanguageTable(FILE *table) { +void makeLanguageTable(Common::File *table) {  	languageTable = new int[gameSettings.numLanguages + 1];  	if (! checkNew(languageTable)) return; @@ -189,17 +192,16 @@ void makeLanguageTable(FILE *table) {  	for (unsigned int i = 0; i <= gameSettings.numLanguages; i ++) {  		languageTable[i] = i ? get2bytes(table) : 0; -		printf("languageTable %i: %i\n", 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); -				printf("languageName %i: %s\n", i, languageName[i]); +				debug(kSludgeDebugDataLoad, "languageName %i: %s\n", i, languageName[i]);  			}  		}  	}  } -#endif  int getLanguageForFileB() {  	int indexNum = -1; diff --git a/engines/sludge/language.h b/engines/sludge/language.h index 27faffb4ac..93805c2428 100644 --- a/engines/sludge/language.h +++ b/engines/sludge/language.h @@ -22,6 +22,10 @@  #ifndef LANGUAGE_H  #define LANGUAGE_H +#include "allfiles.h" + +#include "common/file.h" +  namespace Sludge {  struct settingsStruct { @@ -41,9 +45,7 @@ void readIniFile(char *filename);  void saveIniFile(char *filename);  int getLanguageForFileB(); -#if ALLOW_FILE -void makeLanguageTable(FILE *table); -#endif +void makeLanguageTable(Common::File *table);  } // End of namespace Sludge diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index 20140959ab..959885f166 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -40,6 +40,7 @@  #include "sound.h"  #include "fileset.h"  #include "debug.h" +#include "loadsave.h"  namespace Sludge { @@ -93,81 +94,76 @@ stackLibrary *stackLib = NULL;  //----------------------------------------------------------------------  // For saving and loading stacks...  //---------------------------------------------------------------------- -#if 0 -bool saveVariable(variable *from, FILE *fp); -bool loadVariable(variable *to, FILE *fp); - -void saveStack(variableStack *vs, FILE *fp) { +void saveStack(variableStack *vs, Common::WriteStream *stream) {  	int elements = 0;  	int a;  	variableStack *search = vs;  	while (search) {  		elements ++; -		search = search -> next; +		search = search->next;  	}  	stackDebug((stackfp, "  stack contains %d elements\n", elements)); -	put2bytes(elements, fp); +	put2bytes(elements, stream);  	search = vs; -	for (a = 0; a < elements; a ++) { -		saveVariable(& search -> thisVar, fp); -		search = search -> next; +	for (a = 0; a < elements; ++a) { +		saveVariable(&search->thisVar, stream); +		search = search->next;  	}  } -variableStack *loadStack(FILE *fp, variableStack **last) { -	int elements = get2bytes(fp); +variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **last) { +	int elements = get2bytes(stream);  	int a;  	variableStack *first = NULL; -	variableStack * * changeMe = & first; +	variableStack * * changeMe = &first; -	for (a = 0; a < elements; a ++) { +	for (a = 0; a < elements; ++a) {  		variableStack *nS = new variableStack;  		if (!checkNew(nS)) return NULL; -		loadVariable(& (nS -> thisVar), fp); +		loadVariable(&(nS->thisVar), stream);  		if (last && a == elements - 1) {  			stackDebug((stackfp, "Setting last to %p\n", nS));  			*last = nS;  		} -		nS -> next = NULL; +		nS->next = NULL;  		(* changeMe) = nS; -		changeMe = & (nS -> next); +		changeMe = &(nS->next);  	}  	return first;  } -bool saveStackRef(stackHandler *vs, FILE *fp) { +bool saveStackRef(stackHandler *vs, Common::WriteStream *stream) {  	stackLibrary *s = stackLib;  	int a = 0;  	while (s) { -		if (s -> stack == vs) { -			fputc(1, fp); -			put2bytes(stackLibTotal - a, fp); +		if (s->stack == vs) { +			putch(1, stream); +			put2bytes(stackLibTotal - a, stream);  			return true;  		} -		s = s -> next; -		a ++; +		s = s->next; +		++a;  	} -	fputc(0, fp); -	saveStack(vs -> first, fp); +	putch(0, stream); +	saveStack(vs->first, stream);  	s = new stackLibrary;  	stackLibTotal ++;  	if (! checkNew(s)) return false; -	s -> next = stackLib; -	s -> stack = vs; +	s->next = stackLib; +	s->stack = vs;  	stackLib = s;  	return true;  } -#endif  void clearStackLib() {  	stackLibrary *k;  	while (stackLib) {  		k = stackLib; -		stackLib = stackLib -> next; +		stackLib = stackLib->next;  		delete k;  	}  	stackLibTotal = 0; @@ -176,20 +172,20 @@ void clearStackLib() {  stackHandler *getStackFromLibrary(int n) {  	n = stackLibTotal - n;  	while (n) { -		stackLib = stackLib -> next; +		stackLib = stackLib->next;  		n --;  	} -	return stackLib -> stack; +	return stackLib->stack;  } -#if 0 -stackHandler *loadStackRef(FILE *fp) { + +stackHandler *loadStackRef(Common::SeekableReadStream *stream) {  	stackHandler *nsh; -	if (fgetc(fp)) {    // It's one we've loaded already... +	if (getch(stream)) {    // It's one we've loaded already...  		stackDebug((stackfp, "loadStackRef (duplicate, get from library)\n")); -		nsh = getStackFromLibrary(get2bytes(fp)); -		nsh -> timesUsed ++; +		nsh = getStackFromLibrary(get2bytes(stream)); +		nsh->timesUsed ++;  	} else {  		stackDebug((stackfp, "loadStackRef (new one)\n")); @@ -197,9 +193,9 @@ stackHandler *loadStackRef(FILE *fp) {  		nsh = new stackHandler;  		if (! checkNew(nsh)) return NULL; -		nsh -> last = NULL; -		nsh -> first = loadStack(fp, & nsh->last); -		nsh -> timesUsed = 1; +		nsh->last = NULL; +		nsh->first = loadStack(stream, &nsh->last); +		nsh->timesUsed = 1;  		stackDebug((stackfp, "  first = %p\n", nsh->first));  		if (nsh->first)  			stackDebug((stackfp, "  first->next = %p\n", nsh->first->next)); @@ -211,8 +207,8 @@ stackHandler *loadStackRef(FILE *fp) {  		stackLibrary *s = new stackLibrary;  		if (! checkNew(s)) return NULL; -		s -> stack = nsh; -		s -> next = stackLib; +		s->stack = nsh; +		s->next = stackLib;  		stackLib = s;  		stackLibTotal ++;  	} @@ -222,8 +218,7 @@ stackHandler *loadStackRef(FILE *fp) {  //----------------------------------------------------------------------  // For saving and loading variables...  //---------------------------------------------------------------------- - -bool saveVariable(variable *from, FILE *fp) { +bool saveVariable(variable *from, Common::WriteStream *stream) {  #if DEBUG_STACKINESS  	{  		char *str = getTextFromAnyVar(*from); @@ -232,29 +227,29 @@ bool saveVariable(variable *from, FILE *fp) {  	}  #endif -	fputc(from -> varType, fp); -	switch (from -> varType) { +	putch(from->varType, stream); +	switch (from->varType) {  	case SVT_INT:  	case SVT_FUNC:  	case SVT_BUILT:  	case SVT_FILE:  	case SVT_OBJTYPE: -		put4bytes(from -> varData.intValue, fp); +		put4bytes(from->varData.intValue, stream);  		return true;  	case SVT_STRING: -		writeString(from -> varData.theString, fp); +		writeString(from->varData.theString, stream);  		return true;  	case SVT_STACK: -		return saveStackRef(from -> varData.theStack, fp); +		return saveStackRef(from->varData.theStack, stream);  	case SVT_COSTUME: -		saveCostume(from -> varData.costumeHandler, fp); +		saveCostume(from->varData.costumeHandler, stream);  		return false;  	case SVT_ANIM: -		saveAnim(from -> varData.animHandler, fp); +		saveAnim(from->varData.animHandler, stream);  		return false;  	case SVT_NULL: @@ -269,23 +264,23 @@ bool saveVariable(variable *from, FILE *fp) {  	return true;  } -bool loadVariable(variable *to, FILE *fp) { -	to -> varType = (variableType) fgetc(fp); -	switch (to -> varType) { +bool loadVariable(variable *to, Common::SeekableReadStream *stream) { +	to->varType = (variableType)getch(stream); +	switch (to->varType) {  	case SVT_INT:  	case SVT_FUNC:  	case SVT_BUILT:  	case SVT_FILE:  	case SVT_OBJTYPE: -		to -> varData.intValue = get4bytes(fp); +		to->varData.intValue = get4bytes(stream);  		return true;  	case SVT_STRING: -		to -> varData.theString = readString(fp); +		to->varData.theString = readString(stream);  		return true;  	case SVT_STACK: -		to -> varData.theStack = loadStackRef(fp); +		to->varData.theStack = loadStackRef(stream);  #if DEBUG_STACKINESS  		{  			char *str = getTextFromAnyVar(*to); @@ -296,15 +291,15 @@ bool loadVariable(variable *to, FILE *fp) {  		return true;  	case SVT_COSTUME: -		to -> varData.costumeHandler = new persona; -		if (! checkNew(to -> varData.costumeHandler)) return false; -		loadCostume(to -> varData.costumeHandler, fp); +		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, fp); +		to->varData.animHandler = new personaAnimation; +		if (! checkNew(to->varData.animHandler)) return false; +		loadAnim(to->varData.animHandler, stream);  		return true;  	default: @@ -316,34 +311,32 @@ bool loadVariable(variable *to, FILE *fp) {  //----------------------------------------------------------------------  // For saving and loading functions  //---------------------------------------------------------------------- - -void saveFunction(loadedFunction *fun, FILE *fp) { +void saveFunction(loadedFunction *fun, Common::WriteStream *stream) {  	int a; -	put2bytes(fun -> originalNumber, fp); -	if (fun -> calledBy) { -		fputc(1, fp); -		saveFunction(fun -> calledBy, fp); +	put2bytes(fun->originalNumber, stream); +	if (fun->calledBy) { +		putch(1, stream); +		saveFunction(fun->calledBy, stream);  	} else { -		fputc(0, fp); +		putch(0, stream);  	} -	put4bytes(fun -> timeLeft, fp); -	put2bytes(fun -> runThisLine, fp); -	fputc(fun -> cancelMe, fp); -	fputc(fun -> returnSomething, fp); -	fputc(fun -> isSpeech, fp); -	saveVariable(& (fun -> reg), fp); +	put4bytes(fun->timeLeft, stream); +	put2bytes(fun->runThisLine, stream); +	putch(fun->cancelMe, stream); +	putch(fun->returnSomething, stream); +	putch(fun->isSpeech, stream); +	saveVariable(&(fun->reg), stream); -	if (fun -> freezerLevel) { +	if (fun->freezerLevel) {  		fatal(ERROR_GAME_SAVE_FROZEN);  	} -	saveStack(fun -> stack, fp); -	for (a = 0; a < fun -> numLocals; a ++) { -		saveVariable(& (fun -> localVars[a]), fp); +	saveStack(fun->stack, stream); +	for (a = 0; a < fun->numLocals; ++a) { +		saveVariable(&(fun->localVars[a]), stream);  	}  } - -loadedFunction *loadFunction(FILE *fp) { +loadedFunction *loadFunction(Common::SeekableReadStream *stream) {  	int a;  	// Reserve memory... @@ -353,31 +346,31 @@ loadedFunction *loadFunction(FILE *fp) {  	// See what it was called by and load if we need to... -	buildFunc -> originalNumber = get2bytes(fp); -	buildFunc -> calledBy = NULL; -	if (fgetc(fp)) { -		buildFunc -> calledBy = loadFunction(fp); -		if (! buildFunc -> calledBy) return NULL; +	buildFunc->originalNumber = get2bytes(stream); +	buildFunc->calledBy = NULL; +	if (getch(stream)) { +		buildFunc->calledBy = loadFunction(stream); +		if (! buildFunc->calledBy) return NULL;  	} -	buildFunc -> timeLeft = get4bytes(fp); -	buildFunc -> runThisLine = get2bytes(fp); -	buildFunc -> freezerLevel = 0; -	buildFunc -> cancelMe = fgetc(fp); -	buildFunc -> returnSomething = fgetc(fp); -	buildFunc -> isSpeech = fgetc(fp); -	loadVariable(& (buildFunc -> reg), fp); +	buildFunc->timeLeft = get4bytes(stream); +	buildFunc->runThisLine = get2bytes(stream); +	buildFunc->freezerLevel = 0; +	buildFunc->cancelMe = getch(stream); +	buildFunc->returnSomething = getch(stream); +	buildFunc->isSpeech = getch(stream); +	loadVariable(&(buildFunc->reg), stream);  	loadFunctionCode(buildFunc); -	buildFunc -> stack = loadStack(fp, NULL); +	buildFunc->stack = loadStack(stream, NULL); -	for (a = 0; a < buildFunc -> numLocals; a ++) { -		loadVariable(& (buildFunc -> localVars[a]), fp); +	for (a = 0; a < buildFunc->numLocals; ++a) { +		loadVariable(&(buildFunc->localVars[a]), stream);  	}  	return buildFunc;  } -#endif +  //----------------------------------------------------------------------  // Save everything  //---------------------------------------------------------------------- @@ -397,7 +390,7 @@ bool saveGame(char *fname) {  	if (! saveThumbnail(fp)) return false; -	fwrite(& fileTime, sizeof(FILETIME), 1, fp); +	fwrite(&fileTime, sizeof(FILETIME), 1, fp);  	// DON'T ADD ANYTHING NEW BEFORE THIS POINT! @@ -435,25 +428,25 @@ bool saveGame(char *fname) {  	int countFunctions = 0;  	while (thisFunction) {  		countFunctions ++; -		thisFunction = thisFunction -> next; +		thisFunction = thisFunction->next;  	}  	put2bytes(countFunctions, fp);  	thisFunction = allRunningFunctions;  	while (thisFunction) {  		saveFunction(thisFunction, fp); -		thisFunction = thisFunction -> next; +		thisFunction = thisFunction->next;  	} -	for (a = 0; a < numGlobals; a ++) { -		saveVariable(& globalVars[a], fp); +	for (a = 0; a < numGlobals; ++a) { +		saveVariable(&globalVars[a], fp);  	}  	savePeople(fp); -	if (currentFloor -> numPolygons) { +	if (currentFloor->numPolygons) {  		fputc(1, fp); -		put2bytes(currentFloor -> originalNum, fp); +		put2bytes(currentFloor->originalNum, fp);  	} else fputc(0, fp);  	if (zBuffer.tex) { @@ -516,7 +509,7 @@ bool loadGame(char *fname) {  		if (! skipThumbnail(fp)) return fatal(ERROR_GAME_LOAD_CORRUPT, fname);  	} -	size_t bytes_read = fread(& savedGameTime, sizeof(FILETIME), 1, fp); +	size_t bytes_read = fread(&savedGameTime, sizeof(FILETIME), 1, fp);  	if (bytes_read != sizeof(FILETIME) && ferror(fp)) {  		debugOut("Reading error in loadGame.\n");  	} @@ -546,7 +539,7 @@ bool loadGame(char *fname) {  			charOrder = new char[257];  			if (! checkNew(charOrder)) return false; -			for (int a = 0; a < 256; a ++) { +			for (int a = 0; a < 256; ++a) {  				x = fgetc(fp);  				charOrder[x] = a;  			} @@ -584,20 +577,20 @@ bool loadGame(char *fname) {  	mouseCursorFrameNum = get2bytes(fp);  	loadedFunction *rFunc; -	loadedFunction * * buildList = & allRunningFunctions; +	loadedFunction * * buildList = &allRunningFunctions;  	int countFunctions = get2bytes(fp);  	while (countFunctions --) {  		rFunc = loadFunction(fp); -		rFunc -> next = NULL; +		rFunc->next = NULL;  		(* buildList) = rFunc; -		buildList = & (rFunc -> next); +		buildList = &(rFunc->next);  	} -	for (a = 0; a < numGlobals; a ++) { +	for (a = 0; a < numGlobals; ++a) {  		unlinkVar(globalVars[a]); -		loadVariable(& globalVars[a], fp); +		loadVariable(&globalVars[a], fp);  	}  	loadPeople(fp); diff --git a/engines/sludge/loadsave.h b/engines/sludge/loadsave.h index b91e8725e1..87024f246d 100644 --- a/engines/sludge/loadsave.h +++ b/engines/sludge/loadsave.h @@ -27,10 +27,15 @@ namespace Sludge {  bool saveGame(char *fname);
  bool loadGame(char *fname);
 -#if ALLOW_FILE
 -loadedFunction *loadFunction(FILE *fp);
 -void saveFunction(loadedFunction *fun, FILE *fp);
 -#endif
 +bool saveVariable(variable *from, Common::WriteStream *stream);
 +bool loadVariable(variable *to, Common::SeekableReadStream *stream);
 +
 +variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **last);
 +bool saveStackRef(stackHandler *vs, Common::WriteStream *stream);
 +stackHandler *loadStackRef(Common::SeekableReadStream *stream);
 +
 +loadedFunction *loadFunction(Common::SeekableReadStream *stream);
 +void saveFunction(loadedFunction *fun, Common::WriteStream *stream);
  } // End of namespace Sludge
 diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp index 47bfe67fe6..b278a35ec8 100644 --- a/engines/sludge/main_loop.cpp +++ b/engines/sludge/main_loop.cpp @@ -138,9 +138,7 @@ void setGameFilePath(char *f) {  #endif  } -#if ALLOW_FILE -void saveHSI(FILE *writer); -#endif +void saveHSI(Common::WriteStream *writer);  extern bool reallyWantToQuit; @@ -440,9 +438,8 @@ try  	initStatusBar();  	resetRandW(); -#if ALLOW_FILE  	gameName = getNumberedString(1); -#endif +  #if 0  	SDL_WM_SetCaption(gameName, gameName); diff --git a/engines/sludge/memwatch.cpp b/engines/sludge/memwatch.cpp index d3166877f7..34e860574d 100644 --- a/engines/sludge/memwatch.cpp +++ b/engines/sludge/memwatch.cpp @@ -21,12 +21,15 @@   */
  #include "allfiles.h"
 +#include "common/debug.h"
 +
  namespace Sludge {
  void *allKnownMem[3000];
  int allKnownNum = 0;
  void outputKnownMem() {
 +#if 0
  	FILE *debu = fopen("debuTURN.txt", "at");
  	fprintf(debu, "%i lumps:", allKnownNum);
 @@ -35,6 +38,7 @@ void outputKnownMem() {  	}
  	fprintf(debu, "\n");
  	fclose(debu);
 +#endif
  }
  void adding(void *mem) {
 @@ -43,8 +47,10 @@ void adding(void *mem) {  	outputKnownMem();
  	if (allKnownNum == 3000) {
 -		//db ("Error! Array too full!");
 +		debug("Error! Array too full!");
 +#if 0
  		exit(1);
 +#endif
  	}
  }
 @@ -57,8 +63,10 @@ void deleting(void *mem) {  			return;
  		}
  	}
 +#if 0
  	//db ("Error! Deleted a block which hasn't been allocated!");
  	exit(1);
 +#endif
  }
  } // End of namespace Sludge
 diff --git a/engines/sludge/module.mk b/engines/sludge/module.mk index 78f41dd631..bad7f3589c 100644 --- a/engines/sludge/module.mk +++ b/engines/sludge/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \  	cursors.o \  	debug.o \  	detection.o \ +	fileset.o \  	floor.o \  	freeze.o \  	fonttext.o \ @@ -17,6 +18,7 @@ MODULE_OBJS := \  	line.o \  	loadsave.o \  	main_loop.o \ +	memwatch.o \  	moreio.o \  	movie.o \  	newfatal.o \ @@ -33,15 +35,13 @@ MODULE_OBJS := \  	stringy.o \  	talk.o \  	thumbnail.o \ +	timing.o \  	transition.o \  	variable.o \  	zbuffer.o \  	CommonCode/utf8.o \ -#	fileset.o \ -	linuxstuff.o \ -	memwatch.o \ +#	linuxstuff.o \  	shaders.o \ -	timing.o \  	libwebm/mkvparser.o \  	libwebm/mkvreader.o \ diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp index b8dc3f9909..8bb0d77a67 100644 --- a/engines/sludge/moreio.cpp +++ b/engines/sludge/moreio.cpp @@ -24,7 +24,10 @@  #include "newfatal.h"  #include "stringy.h" -#include "debug.h" +#include "sludge.h" + +#include "common/debug.h" +#include "common/file.h"  #if defined __unix__ && !(defined __APPLE__)  #include <endian.h> @@ -37,43 +40,48 @@ namespace Sludge {  bool allowAnyFilename = true; -#if ALLOW_FILE -int get2bytes(FILE *fp) { +int getch(Common::SeekableReadStream *stream) { +	return stream->readByte(); +} + +void putch(int c, Common::WriteStream *stream) { +	stream->writeByte(c); +} + +int get2bytes(Common::SeekableReadStream *stream) {  	int f1, f2; -	f1 = fgetc(fp); -	f2 = fgetc(fp); +	f1 = getch(stream); +	f2 = getch(stream);  	return (f1 * 256 + f2);  } -void put2bytes(int numtoput, FILE *fp) { -	fputc((char)(numtoput / 256), fp); -	fputc((char)(numtoput % 256), fp); +void put2bytes(int numtoput, Common::WriteStream *stream) { +	putch((char)(numtoput / 256), stream); +	putch((char)(numtoput % 256), stream);  } -void writeString(char *s, FILE *fp) { +void writeString(char *s, Common::WriteStream *stream) {  	int a, len = strlen(s); -	put2bytes(len, fp); -	for (a = 0; a < len; a ++) { -		fputc(s[a] + 1, fp); +	put2bytes(len, stream); +	for (a = 0; a < len; ++a) { +		putch(s[a] + 1, stream);  	}  } -char *readString(FILE *fp) { - -	int a, len = get2bytes(fp); -	//debugOut ("MOREIO: readString - len %i\n", len); +char *readString(Common::SeekableReadStream *stream) { +	int a, len = get2bytes(stream);  	char *s = new char[len + 1]; -	if (! checkNew(s)) { +	if (!checkNew(s)) {  		return NULL;  	} -	for (a = 0; a < len; a ++) { -		s[a] = (char)(fgetc(fp) - 1); +	for (a = 0; a < len; ++a) { +		s[a] = (char)(getch(stream) - 1);  	}  	s[len] = 0; -	//debugOut ("MOREIO: readString: %s\n", s); +	debug(kSludgeDebugDataLoad, "Read string of length %i: %s", len, s);  	return s;  } @@ -92,11 +100,12 @@ float floatSwap(float f) {  } -float getFloat(FILE *fp) { +float getFloat(Common::SeekableReadStream *stream) {  	float f; -	size_t bytes_read = fread(& f, sizeof(float), 1, fp); -	if (bytes_read != sizeof(float) && ferror(fp)) { -		debugOut("Reading error in getFloat.\n"); +	size_t bytes_read = stream->read(&f, sizeof(float)); +			//fread(& f, sizeof(float), 1, fp); +	if (bytes_read != sizeof(float) && stream->err()) { +		debug("Reading error in getFloat.\n");  	}  #ifdef  __BIG_ENDIAN__ @@ -106,11 +115,12 @@ float getFloat(FILE *fp) {  #endif  } -void putFloat(float f, FILE *fp) { +void putFloat(float f, Common::WriteStream *stream) {  #ifdef  __BIG_ENDIAN__  	f = floatSwap(f);  #endif -	fwrite(& f, sizeof(float), 1, fp); +	stream->write(&f,sizeof(float)); +	//fwrite(& f, sizeof(float), 1, fp);  }  short shortSwap(short s) { @@ -123,11 +133,11 @@ short shortSwap(short s) {  } -short getSigned(FILE *fp) { +short getSigned(Common::SeekableReadStream *stream) {  	short f; -	size_t bytes_read = fread(& f, sizeof(short), 1, fp); -	if (bytes_read != sizeof(short) && ferror(fp)) { -		debugOut("Reading error in getSigned.\n"); +	size_t bytes_read = stream->read(&f, sizeof(short)); +	if (bytes_read != sizeof(short) && stream->err()) { +		debug("Reading error in getSigned.\n");  	}  #ifdef  __BIG_ENDIAN__  	f = shortSwap(f); @@ -135,39 +145,32 @@ short getSigned(FILE *fp) {  	return f;  } -void putSigned(short f, FILE *fp) { +void putSigned(short f, Common::WriteStream *stream) {  #ifdef  __BIG_ENDIAN__  	f = shortSwap(f);  #endif -	fwrite(& f, sizeof(short), 1, fp); +	stream->write(&f, sizeof(short));  }  // The following two functions treat signed integers as unsigned.  // That's done on purpose. -int32_t get4bytes(FILE *fp) { +int32_t get4bytes(Common::SeekableReadStream *stream) {  	int f1, f2, f3, f4; -	f1 = fgetc(fp); -	f2 = fgetc(fp); -	f3 = fgetc(fp); -	f4 = fgetc(fp); +	f1 = getch(stream); +	f2 = getch(stream); +	f3 = getch(stream); +	f4 = getch(stream);  	unsigned int x = f1 + f2 * 256 + f3 * 256 * 256 + f4 * 256 * 256 * 256;  	return x; - -	/* - -	    int32_t f; -	    fread (& f, sizeof (int32_t), 1, fp); -	    return f;*/  } -void put4bytes(unsigned int i, FILE *fp) { -	//  fwrite (&i, sizeof (long int), 1, fp); +void put4bytes(unsigned int i, Common::WriteStream *stream) {  	unsigned char f1, f2, f3, f4;  	f4 = i / (256 * 256 * 256); @@ -177,17 +180,17 @@ void put4bytes(unsigned int i, FILE *fp) {  	f2 = i / 256;  	f1 = i % 256; -	fputc(f1, fp); -	fputc(f2, fp); -	fputc(f3, fp); -	fputc(f4, fp); +	putch(f1, stream); +	putch(f2, stream); +	putch(f3, stream); +	putch(f4, stream);  } -#endif +  char *encodeFilename(char *nameIn) { -	if (! nameIn) return NULL; +	if (!nameIn) return NULL;  	if (allowAnyFilename) {  		char *newName = new char[strlen(nameIn) * 2 + 1]; -		if (! checkNew(newName)) return NULL; +		if (!checkNew(newName)) return NULL;  		int i = 0;  		while (*nameIn) { @@ -243,7 +246,7 @@ char *encodeFilename(char *nameIn) {  		return newName;  	} else {  		int a; -		for (a = 0; nameIn[a]; a ++) { +		for (a = 0; nameIn[a]; ++a) {  #ifdef _WIN32  			if (nameIn[a] == '/') nameIn[a] = '\\';  #else @@ -258,7 +261,7 @@ char *encodeFilename(char *nameIn) {  char *decodeFilename(char *nameIn) {  	if (allowAnyFilename) {  		char *newName = new char[strlen(nameIn) + 1]; -		if (! checkNew(newName)) return NULL; +		if (!checkNew(newName)) return NULL;  		int i = 0;  		while (* nameIn) { diff --git a/engines/sludge/moreio.h b/engines/sludge/moreio.h index 5d107a82e4..9c2287b274 100644 --- a/engines/sludge/moreio.h +++ b/engines/sludge/moreio.h @@ -26,18 +26,22 @@  namespace Sludge { -#if ALLOW_FILE -int get2bytes(FILE *fp); -void put2bytes(int numtoput, FILE *fp); -char *readString(FILE *fp); -void writeString(char *s, FILE *fp); -void putFloat(float f, FILE *fp); -float getFloat(FILE *fp); -void putSigned(short f, FILE *fp); -short getSigned(FILE *fp); -int32_t get4bytes(FILE *fp); -void put4bytes(uint32_t f, FILE *fp); -#endif +// Read +int getch(Common::SeekableReadStream *stream); +int get2bytes(Common::SeekableReadStream *stream); +char *readString(Common::SeekableReadStream *stream); +float getFloat(Common::SeekableReadStream *stream); +short getSigned(Common::SeekableReadStream *stream); +int32_t get4bytes(Common::SeekableReadStream *stream); + +// Write +void putch(int c, Common::WriteStream *stream); +void put2bytes(int numtoput, Common::WriteStream *stream); +void writeString(char *s, Common::WriteStream *stream); +void putFloat(float f, Common::WriteStream *stream); +void putSigned(short f, Common::WriteStream *stream); +void put4bytes(uint32_t f, Common::WriteStream *stream); +  char *encodeFilename(char *nameIn);  char *decodeFilename(char *nameIn); diff --git a/engines/sludge/newfatal.cpp b/engines/sludge/newfatal.cpp index f05de5c4c2..5c8a36db36 100644 --- a/engines/sludge/newfatal.cpp +++ b/engines/sludge/newfatal.cpp @@ -95,9 +95,8 @@ int inFatal(const char *str) {  	fatalMessage = copyString(str);  	if (fatalMessage == NULL) fatalMessage = copyString("Out of memory"); -#if 0 +  	killSoundStuff(); -#endif  #if defined(HAVE_GLES2)  	EGL_Close(); @@ -123,7 +122,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); -	debug("%s\n", fatalInfo); +	debug("%s", fatalInfo);  }  void setResourceForFatal(int n) { diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp index 58572b0f92..ba709777b4 100644 --- a/engines/sludge/objtypes.cpp +++ b/engines/sludge/objtypes.cpp @@ -50,24 +50,23 @@ objectType *findObjectType(int i) {  }  objectType *loadObjectType(int i) { -#if ALLOW_FILE  	int a, nameNum;  	objectType *newType = new objectType;  	if (checkNew(newType)) {  		if (openObjectSlice(i)) {  			nameNum = get2bytes(bigDataFile); -			newType -> r = (byte) fgetc(bigDataFile); -			newType -> g = (byte) fgetc(bigDataFile); -			newType -> b = (byte) fgetc(bigDataFile); -			newType -> speechGap = fgetc(bigDataFile); -			newType -> walkSpeed = fgetc(bigDataFile); +			newType -> r = (byte) getch(bigDataFile); +			newType -> g = (byte) getch(bigDataFile); +			newType -> b = (byte) getch(bigDataFile); +			newType -> speechGap = getch(bigDataFile); +			newType -> walkSpeed = getch(bigDataFile);  			newType -> wrapSpeech = get4bytes(bigDataFile);  			newType -> spinSpeed = get2bytes(bigDataFile);  			if (gameVersion >= VERSION(1, 6)) {  				// aaLoad -				fgetc(bigDataFile); +				getch(bigDataFile);  				getFloat(bigDataFile);  				getFloat(bigDataFile);  			} @@ -111,23 +110,21 @@ objectType *loadObjectType(int i) {  			return newType;  		}  	} -#endif +  	return NULL;  } -#if ALLOW_FILE -objectType *loadObjectRef(FILE *fp) { -	objectType *r = loadObjectType(get2bytes(fp)); +objectType *loadObjectRef(Common::SeekableReadStream *stream) { +	objectType *r = loadObjectType(get2bytes(stream));  	delete r -> screenName; -	r -> screenName = readString(fp); +	r -> screenName = readString(stream);  	return r;  } -void saveObjectRef(objectType *r, FILE *fp) { -	put2bytes(r -> objectNum, fp); -	writeString(r -> screenName, fp); +void saveObjectRef(objectType *r, Common::WriteStream *stream) { +	put2bytes(r -> objectNum, stream); +	writeString(r -> screenName, stream);  } -#endif  int getCombinationFunction(int withThis, int thisObject) {  	int i, num = 0; diff --git a/engines/sludge/objtypes.h b/engines/sludge/objtypes.h index f61c845074..0bd785a1e3 100644 --- a/engines/sludge/objtypes.h +++ b/engines/sludge/objtypes.h @@ -44,10 +44,8 @@ objectType *findObjectType(int i);  objectType *loadObjectType(int i);
  int getCombinationFunction(int a, int b);
  void removeObjectType(objectType *oT);
 -#if ALLOW_FILE
 -void saveObjectRef(objectType *r, FILE *fp);
 -objectType *loadObjectRef(FILE *fp);
 -#endif
 +void saveObjectRef(objectType *r, Common::WriteStream *stream);
 +objectType *loadObjectRef(Common::SeekableReadStream *stream);
  } // End of namespace Sludge
 diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp index f54b1ff0c5..6430d354f8 100644 --- a/engines/sludge/people.cpp +++ b/engines/sludge/people.cpp @@ -71,36 +71,36 @@ 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) {  	personaAnimation *newP = new personaAnimation;  	checkNew(newP); -	newP -> numFrames = num; -	newP -> frames = new animFrame[num]; -	checkNew(newP -> frames); +	newP->numFrames = num; +	newP->frames = new animFrame[num]; +	checkNew(newP->frames);  	int a = num, frameNum, howMany;  	while (a) {  		a --; -		newP -> frames[a].noise = 0; -		if (stacky -> thisVar.varType == SVT_FILE) { -			newP -> frames[a].noise = stacky -> thisVar.varData.intValue; -		} else if (stacky -> thisVar.varType == SVT_FUNC) { -			newP -> frames[a].noise = - stacky -> thisVar.varData.intValue; -		} 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); +		newP->frames[a].noise = 0; +		if (stacky->thisVar.varType == SVT_FILE) { +			newP->frames[a].noise = stacky->thisVar.varData.intValue; +		} else if (stacky->thisVar.varType == SVT_FUNC) { +			newP->frames[a].noise = - stacky->thisVar.varData.intValue; +		} 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);  		} else { -			getValueType(frameNum, SVT_INT, stacky -> thisVar); +			getValueType(frameNum, SVT_INT, stacky->thisVar);  			howMany = 1;  		}  		trimStack(stacky); -		newP -> frames[a].frameNum = frameNum; -		newP -> frames[a].howMany = howMany; +		newP->frames[a].frameNum = frameNum; +		newP->frames[a].howMany = howMany;  	}  	return newP; @@ -108,39 +108,39 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {  personaAnimation *makeNullAnim() {  	personaAnimation *newAnim  = new personaAnimation; -	if (! checkNew(newAnim)) return NULL; +	if (!checkNew(newAnim)) return NULL; -	newAnim -> theSprites       = NULL; -	newAnim -> numFrames        = 0; -	newAnim -> frames           = NULL; +	newAnim->theSprites       = NULL; +	newAnim->numFrames        = 0; +	newAnim->frames           = NULL;  	return newAnim;  }  personaAnimation *copyAnim(personaAnimation *orig) { -	int num = orig -> numFrames; +	int num = orig->numFrames;  	personaAnimation *newAnim  = new personaAnimation; -	if (! checkNew(newAnim)) return NULL; +	if (!checkNew(newAnim)) return NULL;  	// Copy the easy bits... -	newAnim -> theSprites       = orig -> theSprites; -	newAnim -> numFrames        = num; +	newAnim->theSprites       = orig->theSprites; +	newAnim->numFrames        = num;  	if (num) { -		// Argh! Frames! We need a whole NEW array of animFrame structures... +		// Argh!Frames!We need a whole NEW array of animFrame structures...  		newAnim->frames = new animFrame[num]; -		if (! checkNew(newAnim->frames)) return NULL; +		if (!checkNew(newAnim->frames)) return NULL; -		for (int a = 0; a < num; a ++) { -			newAnim -> frames[a].frameNum = orig -> frames[a].frameNum; -			newAnim -> frames[a].howMany = orig -> frames[a].howMany; -			newAnim -> frames[a].noise = orig -> frames[a].noise; +		for (int a = 0; a < num; ++a) { +			newAnim->frames[a].frameNum = orig->frames[a].frameNum; +			newAnim->frames[a].howMany = orig->frames[a].howMany; +			newAnim->frames[a].noise = orig->frames[a].noise;  		}  	} else { -		newAnim -> frames = NULL; +		newAnim->frames = NULL;  	}  	return newAnim; @@ -149,8 +149,8 @@ personaAnimation *copyAnim(personaAnimation *orig) {  void deleteAnim(personaAnimation *orig) {  	if (orig) { -		if (orig -> numFrames) { -			delete[] orig -> frames; +		if (orig->numFrames) { +			delete[] orig->frames;  		}  		delete orig;  		orig = NULL; @@ -158,11 +158,11 @@ void deleteAnim(personaAnimation *orig) {  }  void turnMeAngle(onScreenPerson *thisPerson, int direc) { -	int d = thisPerson -> myPersona -> numDirections; -	thisPerson -> angle = direc; -	direc += (180 / d) + 180 + thisPerson -> angleOffset; +	int d = thisPerson->myPersona->numDirections; +	thisPerson->angle = direc; +	direc += (180 / d) + 180 + thisPerson->angleOffset;  	while (direc >= 360) direc -= 360; -	thisPerson -> direction = (direc * d) / 360; +	thisPerson->direction = (direc * d) / 360;  }  bool initPeople() { @@ -175,36 +175,36 @@ bool initPeople() {  }  void spinStep(onScreenPerson *thisPerson) { -	int diff = (thisPerson -> angle + 360) - thisPerson -> wantAngle; -	int eachSlice = thisPerson -> spinSpeed ? thisPerson -> spinSpeed : (360 / thisPerson -> myPersona -> numDirections); +	int diff = (thisPerson->angle + 360) - thisPerson->wantAngle; +	int eachSlice = thisPerson->spinSpeed ? thisPerson->spinSpeed : (360 / thisPerson->myPersona->numDirections);  	while (diff > 180) {  		diff -= 360;  	}  	if (diff >= eachSlice) { -		turnMeAngle(thisPerson, thisPerson -> angle - eachSlice); +		turnMeAngle(thisPerson, thisPerson->angle - eachSlice);  	} else if (diff <= - eachSlice) { -		turnMeAngle(thisPerson, thisPerson -> angle + eachSlice); +		turnMeAngle(thisPerson, thisPerson->angle + eachSlice);  	} else { -		turnMeAngle(thisPerson, thisPerson -> wantAngle); -		thisPerson -> spinning = false; +		turnMeAngle(thisPerson, thisPerson->wantAngle); +		thisPerson->spinning = false;  	}  }  void rethinkAngle(onScreenPerson *thisPerson) { -	int d = thisPerson -> myPersona -> numDirections; -	int direc = thisPerson -> angle + (180 / d) + 180 + thisPerson -> angleOffset; +	int d = thisPerson->myPersona->numDirections; +	int direc = thisPerson->angle + (180 / d) + 180 + thisPerson->angleOffset;  	while (direc >= 360) direc -= 360; -	thisPerson -> direction = (direc * d) / 360; +	thisPerson->direction = (direc * d) / 360;  }  bool turnPersonToFace(int thisNum, int direc) {  	onScreenPerson *thisPerson = findPerson(thisNum);  	if (thisPerson) { -		if (thisPerson -> continueAfterWalking) abortFunction(thisPerson -> continueAfterWalking); -		thisPerson -> continueAfterWalking = NULL; -		thisPerson -> walking = false; -		thisPerson -> spinning = false; +		if (thisPerson->continueAfterWalking) abortFunction(thisPerson->continueAfterWalking); +		thisPerson->continueAfterWalking = NULL; +		thisPerson->walking = false; +		thisPerson->spinning = false;  		turnMeAngle(thisPerson, direc);  		setFrames(* thisPerson, (thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND);  		return true; @@ -215,8 +215,8 @@ bool turnPersonToFace(int thisNum, int direc) {  bool setPersonExtra(int thisNum, int extra) {  	onScreenPerson *thisPerson = findPerson(thisNum);  	if (thisPerson) { -		thisPerson -> extra = extra; -		if (extra & EXTRA_NOSCALE) thisPerson -> scale = 1; +		thisPerson->extra = extra; +		if (extra & EXTRA_NOSCALE) thisPerson->scale = 1;  		return true;  	}  	return false; @@ -236,8 +236,8 @@ void moveAndScale(onScreenPerson &me, float x, float y) {  onScreenPerson *findPerson(int v) {  	onScreenPerson *thisPerson = allPeople;  	while (thisPerson) { -		if (v == thisPerson -> thisType -> objectNum) break; -		thisPerson = thisPerson -> next; +		if (v == thisPerson->thisType->objectNum) break; +		thisPerson = thisPerson->next;  	}  	return thisPerson;  } @@ -249,7 +249,7 @@ void movePerson(int x, int y, int objNum) {  void setShown(bool h, int ob) {  	onScreenPerson *moveMe = findPerson(ob); -	if (moveMe) moveMe -> show = h; +	if (moveMe) moveMe->show = h;  }  enum drawModes { @@ -384,14 +384,14 @@ void setMyDrawMode(onScreenPerson *moveMe, int h) {  void setDrawMode(int h, int ob) {  	onScreenPerson *moveMe = findPerson(ob); -	if (! moveMe) return; +	if (!moveMe) return;  	setMyDrawMode(moveMe, h);  }  void setPersonTransparency(int ob, unsigned char x) {  	onScreenPerson *moveMe = findPerson(ob); -	if (! moveMe) return; +	if (!moveMe) return;  	if (x > 254) x = 254;  	moveMe->transparency = x; @@ -399,7 +399,7 @@ void setPersonTransparency(int ob, unsigned char x) {  void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char b, unsigned char colourmix) {  	onScreenPerson *moveMe = findPerson(ob); -	if (! moveMe) return; +	if (!moveMe) return;  	moveMe->r = r;  	moveMe->g = g; @@ -415,23 +415,23 @@ void shufflePeople() {  	onScreenPerson * * thisReference = & allPeople;  	onScreenPerson *A, * B; -	if (! allPeople) return; +	if (!allPeople) return; -	while ((* thisReference) -> next) { -		float y1 = (* thisReference) -> y; -		if ((* thisReference) -> extra & EXTRA_FRONT) y1 += 1000; +	while ((* thisReference)->next) { +		float y1 = (* thisReference)->y; +		if ((* thisReference)->extra & EXTRA_FRONT) y1 += 1000; -		float y2 = (* thisReference) -> next -> y; -		if ((* thisReference) -> next -> extra & EXTRA_FRONT) y2 += 1000; +		float y2 = (* thisReference)->next->y; +		if ((* thisReference)->next->extra & EXTRA_FRONT) y2 += 1000;  		if (y1 > y2) {  			A = (* thisReference); -			B = (* thisReference) -> next; -			A -> next = B -> next; -			B -> next = A; +			B = (* thisReference)->next; +			A->next = B->next; +			B->next = A;  			(* thisReference) = B;  		} else { -			thisReference = & ((* thisReference) -> next); +			thisReference = & ((* thisReference)->next);  		}  	}  } @@ -446,62 +446,62 @@ void drawPeople() {  	overRegion = NULL;  	while (thisPerson) { -		if (thisPerson -> show) { -			myAnim = thisPerson -> myAnim; -			if (myAnim != thisPerson -> lastUsedAnim) { -				thisPerson -> lastUsedAnim = myAnim; -				thisPerson -> frameNum = 0; -				thisPerson -> frameTick = myAnim -> frames[0].howMany; -				if (myAnim -> frames[thisPerson -> frameNum].noise > 0) { -					startSound(myAnim -> frames[thisPerson -> frameNum].noise, false); -					thisPerson -> frameNum ++; -					thisPerson -> frameNum %= thisPerson -> myAnim -> numFrames; -					thisPerson -> frameTick = thisPerson -> myAnim -> frames[thisPerson -> frameNum].howMany; -				} else if (myAnim -> frames[thisPerson -> frameNum].noise) { -					startNewFunctionNum(- myAnim -> frames[thisPerson -> frameNum].noise, 0, NULL, noStack); -					thisPerson -> frameNum ++; -					thisPerson -> frameNum %= thisPerson -> myAnim -> numFrames; -					thisPerson -> frameTick = thisPerson -> myAnim -> frames[thisPerson -> frameNum].howMany; +		if (thisPerson->show) { +			myAnim = thisPerson->myAnim; +			if (myAnim != thisPerson->lastUsedAnim) { +				thisPerson->lastUsedAnim = myAnim; +				thisPerson->frameNum = 0; +				thisPerson->frameTick = myAnim->frames[0].howMany; +				if (myAnim->frames[thisPerson->frameNum].noise > 0) { +					startSound(myAnim->frames[thisPerson->frameNum].noise, false); +					thisPerson->frameNum ++; +					thisPerson->frameNum %= thisPerson->myAnim->numFrames; +					thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany; +				} else if (myAnim->frames[thisPerson->frameNum].noise) { +					startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack); +					thisPerson->frameNum ++; +					thisPerson->frameNum %= thisPerson->myAnim->numFrames; +					thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;  				}  			} -			int fNumSign = myAnim -> frames[thisPerson -> frameNum].frameNum; +			int fNumSign = myAnim->frames[thisPerson->frameNum].frameNum;  			int m = fNumSign < 0;  			int fNum = abs(fNumSign); -			if (fNum >= myAnim -> theSprites -> bank.total) { +			if (fNum >= myAnim->theSprites->bank.total) {  				fNum = 0;  				m = 2 - m;  			}  			if (m != 2) {  				bool r = false; -				r = scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim -> theSprites -> bank.myPalette, thisPerson, m); +				r = scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim->theSprites->bank.myPalette, thisPerson, m);  				if (r) { -					if (thisPerson -> thisType -> screenName[0]) { -						if (personRegion.thisType != thisPerson -> thisType) lastRegion = NULL; -						personRegion.thisType = thisPerson -> thisType; +					if (thisPerson->thisType->screenName[0]) { +						if (personRegion.thisType != thisPerson->thisType) lastRegion = NULL; +						personRegion.thisType = thisPerson->thisType;  						overRegion = & personRegion;  					}  				}  			}  		} -		if (! -- thisPerson -> frameTick) { -			thisPerson -> frameNum ++; -			thisPerson -> frameNum %= thisPerson -> myAnim -> numFrames; -			thisPerson -> frameTick = thisPerson -> myAnim -> frames[thisPerson -> frameNum].howMany; -			if (thisPerson -> show && myAnim && myAnim -> frames) { -				if (myAnim -> frames[thisPerson -> frameNum].noise > 0) { -					startSound(myAnim -> frames[thisPerson -> frameNum].noise, false); -					thisPerson -> frameNum ++; -					thisPerson -> frameNum %= thisPerson -> myAnim -> numFrames; -					thisPerson -> frameTick = thisPerson -> myAnim -> frames[thisPerson -> frameNum].howMany; -				} else if (myAnim -> frames[thisPerson -> frameNum].noise) { -					startNewFunctionNum(- myAnim -> frames[thisPerson -> frameNum].noise, 0, NULL, noStack); -					thisPerson -> frameNum ++; -					thisPerson -> frameNum %= thisPerson -> myAnim -> numFrames; -					thisPerson -> frameTick = thisPerson -> myAnim -> frames[thisPerson -> frameNum].howMany; +		if (!-- thisPerson->frameTick) { +			thisPerson->frameNum ++; +			thisPerson->frameNum %= thisPerson->myAnim->numFrames; +			thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany; +			if (thisPerson->show && myAnim && myAnim->frames) { +				if (myAnim->frames[thisPerson->frameNum].noise > 0) { +					startSound(myAnim->frames[thisPerson->frameNum].noise, false); +					thisPerson->frameNum ++; +					thisPerson->frameNum %= thisPerson->myAnim->numFrames; +					thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany; +				} else if (myAnim->frames[thisPerson->frameNum].noise) { +					startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack); +					thisPerson->frameNum ++; +					thisPerson->frameNum %= thisPerson->myAnim->numFrames; +					thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;  				}  			}  		} -		thisPerson = thisPerson -> next; +		thisPerson = thisPerson->next;  	}  } @@ -521,14 +521,14 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {  //	FILE * dbug = fopen ("debug_closest.txt", "at");  //	fprintf (dbug, "\nGetting closest point to %i, %i\n", setX, setY); -	for (i = 0; i < currentFloor -> numPolygons; i ++) { -		oldJ = currentFloor -> polygon[i].numVertices - 1; -		for (j = 0; j < currentFloor -> polygon[i].numVertices; j ++) { +	for (i = 0; i < currentFloor->numPolygons; i ++) { +		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; +			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; @@ -537,7 +537,7 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {  //			fprintf (dbug, "Distance squared %i\n", thisDistance);  			if (thisDistance < currentDistance) { -//				fprintf (dbug, "** We have a new winner! **\n"); +//				fprintf (dbug, "** We have a new winner!**\n");  				currentDistance = thisDistance;  				gotX = closestX; @@ -558,28 +558,28 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {  }  bool doBorderStuff(onScreenPerson *moveMe) { -	if (moveMe -> inPoly == moveMe -> walkToPoly) { -		moveMe -> inPoly = -1; -		moveMe -> thisStepX = moveMe -> walkToX; -		moveMe -> thisStepY = moveMe -> walkToY; +	if (moveMe->inPoly == moveMe->walkToPoly) { +		moveMe->inPoly = -1; +		moveMe->thisStepX = moveMe->walkToX; +		moveMe->thisStepY = moveMe->walkToY;  	} else {  		// The section in which we need to be next... -		int newPoly = currentFloor -> matrix[moveMe -> inPoly][moveMe -> walkToPoly]; +		int newPoly = currentFloor->matrix[moveMe->inPoly][moveMe->walkToPoly];  		if (newPoly == -1) return false;  		// Grab the index of the second matching corner...  		int ID, ID2; -		if (! getMatchingCorners(currentFloor -> polygon[moveMe -> inPoly], currentFloor -> polygon[newPoly], ID, ID2)) +		if (!getMatchingCorners(currentFloor->polygon[moveMe->inPoly], currentFloor->polygon[newPoly], ID, ID2))  			return fatal("Not a valid floor plan!");  		// Remember that we're walking to the new polygon... -		moveMe -> inPoly = newPoly; +		moveMe->inPoly = newPoly;  		// Calculate the destination position on the coincidantal line... -		int x1 = moveMe -> x, y1 = moveMe -> y; -		int x2 = moveMe -> walkToX, y2 = moveMe -> walkToY; -		int x3 = currentFloor -> vertex[ID].x, y3 = currentFloor -> vertex[ID].y; -		int x4 = currentFloor -> vertex[ID2].x, y4 = currentFloor -> vertex[ID2].y; +		int x1 = moveMe->x, y1 = moveMe->y; +		int x2 = moveMe->walkToX, y2 = moveMe->walkToY; +		int x3 = currentFloor->vertex[ID].x, y3 = currentFloor->vertex[ID].y; +		int x4 = currentFloor->vertex[ID2].x, y4 = currentFloor->vertex[ID2].y;  		int xAB = x1 - x2;  		int yAB = y1 - y2; @@ -590,8 +590,8 @@ bool doBorderStuff(onScreenPerson *moveMe) {  		m /= ((xAB * yCD) - (yAB * xCD));  		if (m > 0 && m < 1) { -			moveMe -> thisStepX = x3 + m * xCD; -			moveMe -> thisStepY = y3 + m * yCD; +			moveMe->thisStepX = x3 + m * xCD; +			moveMe->thisStepY = y3 + m * yCD;  		} else {  			int dx13 = x1 - x3, dx14 = x1 - x4, dx23 = x2 - x3, dx24 = x2 - x4;  			int dy13 = y1 - y3, dy14 = y1 - y4, dy23 = y2 - y3, dy24 = y2 - y4; @@ -607,20 +607,20 @@ bool doBorderStuff(onScreenPerson *moveMe) {  			if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23) <  			        sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) { -				moveMe -> thisStepX = x3; -				moveMe -> thisStepY = y3; +				moveMe->thisStepX = x3; +				moveMe->thisStepY = y3;  			} else { -				moveMe -> thisStepX = x4; -				moveMe -> thisStepY = y4; +				moveMe->thisStepX = x4; +				moveMe->thisStepY = y4;  			}  		}  	} -	float yDiff = moveMe -> thisStepY - moveMe -> y; -	float xDiff = moveMe -> x - moveMe -> thisStepX; +	float yDiff = moveMe->thisStepY - moveMe->y; +	float xDiff = moveMe->x - moveMe->thisStepX;  	if (xDiff || yDiff) { -		moveMe -> wantAngle = 180 + ANGLEFIX * atan2(xDiff, yDiff * 2); -		moveMe -> spinning = true; +		moveMe->wantAngle = 180 + ANGLEFIX * atan2(xDiff, yDiff * 2); +		moveMe->spinning = true;  	}  	setFrames(* moveMe, ANI_WALK); @@ -631,72 +631,72 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {  	float xDiff, yDiff, maxDiff, s;  	for (;;) { -		xDiff = thisPerson -> thisStepX - thisPerson -> x; -		yDiff = (thisPerson -> thisStepY - thisPerson -> y) * 2; -		s = thisPerson -> scale * thisPerson -> walkSpeed; +		xDiff = thisPerson->thisStepX - thisPerson->x; +		yDiff = (thisPerson->thisStepY - thisPerson->y) * 2; +		s = thisPerson->scale * thisPerson->walkSpeed;  		if (s < 0.2) s = 0.2;  		maxDiff = (TF_abs(xDiff) >= TF_abs(yDiff)) ? TF_abs(xDiff) : TF_abs(yDiff);  		if (TF_abs(maxDiff) > s) { -			if (thisPerson -> spinning) { +			if (thisPerson->spinning) {  				spinStep(thisPerson);  				setFrames(* thisPerson, ANI_WALK);  			}  			s = maxDiff / s;  			if (move)  				moveAndScale(* thisPerson, -				             thisPerson -> x + xDiff / s, -				             thisPerson -> y + yDiff / (s * 2)); +				             thisPerson->x + xDiff / s, +				             thisPerson->y + yDiff / (s * 2));  			return true;  		} -		if (thisPerson -> inPoly == -1) { -			if (thisPerson -> directionWhenDoneWalking != -1) { -				thisPerson -> wantAngle = thisPerson -> directionWhenDoneWalking; -				thisPerson -> spinning = true; +		if (thisPerson->inPoly == -1) { +			if (thisPerson->directionWhenDoneWalking != -1) { +				thisPerson->wantAngle = thisPerson->directionWhenDoneWalking; +				thisPerson->spinning = true;  				spinStep(thisPerson);  			}  			break;  		} -		if (! doBorderStuff(thisPerson)) break; +		if (!doBorderStuff(thisPerson)) break;  	} -	thisPerson -> walking = false; +	thisPerson->walking = false;  	setFrames(* thisPerson, ANI_STAND);  	moveAndScale(* thisPerson, -	             thisPerson -> walkToX, -	             thisPerson -> walkToY); +	             thisPerson->walkToX, +	             thisPerson->walkToY);  	return false;  }  bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {  	if (x == 0 && y == 0) return false; -	if (currentFloor -> numPolygons == 0) return false; +	if (currentFloor->numPolygons == 0) return false;  	onScreenPerson *moveMe = findPerson(objNum); -	if (! moveMe) return false; - -	if (moveMe -> continueAfterWalking) abortFunction(moveMe -> continueAfterWalking); -	moveMe -> continueAfterWalking = NULL; -	moveMe -> walking = true; -	moveMe -> directionWhenDoneWalking = di; - -	moveMe -> walkToX = x; -	moveMe -> walkToY = y; -	moveMe -> walkToPoly = inFloor(x, y); -	if (moveMe -> walkToPoly == -1) { -		if (! handleClosestPoint(moveMe -> walkToX, moveMe -> walkToY, moveMe -> walkToPoly)) return false; +	if (!moveMe) return false; + +	if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking); +	moveMe->continueAfterWalking = NULL; +	moveMe->walking = true; +	moveMe->directionWhenDoneWalking = di; + +	moveMe->walkToX = x; +	moveMe->walkToY = y; +	moveMe->walkToPoly = inFloor(x, y); +	if (moveMe->walkToPoly == -1) { +		if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY, moveMe->walkToPoly)) return false;  	} -	moveMe -> inPoly = inFloor(moveMe -> x, moveMe -> y); -	if (moveMe -> inPoly == -1) { -		int xxx = moveMe -> x, yyy = moveMe -> y; -		if (! handleClosestPoint(xxx, yyy, moveMe -> inPoly)) return false; +	moveMe->inPoly = inFloor(moveMe->x, moveMe->y); +	if (moveMe->inPoly == -1) { +		int xxx = moveMe->x, yyy = moveMe->y; +		if (!handleClosestPoint(xxx, yyy, moveMe->inPoly)) return false;  	}  	doBorderStuff(moveMe); -	if (walkMe(moveMe, false) || moveMe -> spinning) { -		moveMe -> continueAfterWalking = func; +	if (walkMe(moveMe, false) || moveMe->spinning) { +		moveMe->continueAfterWalking = func;  		return true;  	} else {  		return false; @@ -706,11 +706,11 @@ bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {  bool stopPerson(int o) {  	onScreenPerson *moveMe = findPerson(o);  	if (moveMe) -		if (moveMe -> continueAfterWalking) { -			abortFunction(moveMe -> continueAfterWalking); -			moveMe -> continueAfterWalking = NULL; -			moveMe -> walking = false; -			moveMe -> spinning = false; +		if (moveMe->continueAfterWalking) { +			abortFunction(moveMe->continueAfterWalking); +			moveMe->continueAfterWalking = NULL; +			moveMe->walking = false; +			moveMe->spinning = false;  			setFrames(* moveMe, ANI_STAND);  			return true;  		} @@ -720,24 +720,24 @@ bool stopPerson(int o) {  bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {  	if (x == 0 && y == 0) return false;  	onScreenPerson *moveMe = findPerson(objNum); -	if (! moveMe) return false; +	if (!moveMe) return false; -	if (moveMe -> continueAfterWalking) abortFunction(moveMe -> continueAfterWalking); -	moveMe -> walking = true; -	moveMe -> continueAfterWalking = NULL; -	moveMe -> directionWhenDoneWalking = di; +	if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking); +	moveMe->walking = true; +	moveMe->continueAfterWalking = NULL; +	moveMe->directionWhenDoneWalking = di; -	moveMe -> walkToX = x; -	moveMe -> walkToY = y; +	moveMe->walkToX = x; +	moveMe->walkToY = y;  	// Let's pretend the start and end points are both in the same  	// polygon (which one isn't important) -	moveMe -> inPoly = 0; -	moveMe -> walkToPoly = 0; +	moveMe->inPoly = 0; +	moveMe->walkToPoly = 0;  	doBorderStuff(moveMe); -	if (walkMe(moveMe) || moveMe -> spinning) { -		moveMe -> continueAfterWalking = func; +	if (walkMe(moveMe) || moveMe->spinning) { +		moveMe->continueAfterWalking = func;  		return true;  	} else {  		return false; @@ -747,26 +747,26 @@ bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di)  void jumpPerson(int x, int y, int objNum) {  	if (x == 0 && y == 0) return;  	onScreenPerson *moveMe = findPerson(objNum); -	if (! moveMe) return; -	if (moveMe -> continueAfterWalking) abortFunction(moveMe -> continueAfterWalking); -	moveMe -> continueAfterWalking = NULL; -	moveMe -> walking = false; -	moveMe -> spinning = false; +	if (!moveMe) return; +	if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking); +	moveMe->continueAfterWalking = NULL; +	moveMe->walking = false; +	moveMe->spinning = false;  	moveAndScale(* moveMe, x, y);  }  bool floatCharacter(int f, int objNum) {  	onScreenPerson *moveMe = findPerson(objNum); -	if (! moveMe) return false; -	moveMe -> floaty = f; +	if (!moveMe) return false; +	moveMe->floaty = f;  	return true;  }  bool setCharacterWalkSpeed(int f, int objNum) {  	if (f <= 0) return false;  	onScreenPerson *moveMe = findPerson(objNum); -	if (! moveMe) return false; -	moveMe -> walkSpeed = f; +	if (!moveMe) return false; +	moveMe->walkSpeed = f;  	return true;  } @@ -774,82 +774,82 @@ void walkAllPeople() {  	onScreenPerson *thisPerson = allPeople;  	while (thisPerson) { -		if (thisPerson -> walking) { +		if (thisPerson->walking) {  			walkMe(thisPerson); -		} else if (thisPerson -> spinning) { +		} else if (thisPerson->spinning) {  			spinStep(thisPerson);  			setFrames(* thisPerson, ANI_STAND);  		} -		if ((! thisPerson -> walking) && (! thisPerson -> spinning) && thisPerson -> continueAfterWalking) { -			restartFunction(thisPerson -> continueAfterWalking); -			thisPerson -> continueAfterWalking = NULL; +		if ((!thisPerson->walking) && (!thisPerson->spinning) && thisPerson->continueAfterWalking) { +			restartFunction(thisPerson->continueAfterWalking); +			thisPerson->continueAfterWalking = NULL;  		} -		thisPerson = thisPerson -> next; +		thisPerson = thisPerson->next;  	}  }  bool addPerson(int x, int y, int objNum, persona *p) {  	onScreenPerson *newPerson = new onScreenPerson; -	if (! checkNew(newPerson)) return false; +	if (!checkNew(newPerson)) return false;  	// EASY STUFF -	newPerson -> thisType = loadObjectType(objNum); -	newPerson -> scale = 1; -	newPerson -> extra = 0; -	newPerson -> continueAfterWalking = NULL; +	newPerson->thisType = loadObjectType(objNum); +	newPerson->scale = 1; +	newPerson->extra = 0; +	newPerson->continueAfterWalking = NULL;  	moveAndScale(* newPerson, x, y); -	newPerson -> frameNum = 0; -	newPerson -> walkToX = x; -	newPerson -> walkToY = y; -	newPerson -> walking = false; -	newPerson -> spinning = false; -	newPerson -> show = true; -	newPerson -> direction = 0; -	newPerson -> angle = 180; -	newPerson -> wantAngle = 180; -	newPerson -> angleOffset = 0; -	newPerson -> floaty = 0; -	newPerson -> walkSpeed = newPerson -> thisType -> walkSpeed; -	newPerson -> myAnim = NULL; -	newPerson -> spinSpeed = newPerson -> thisType -> spinSpeed; -	newPerson -> r = 0; -	newPerson -> g = 0; -	newPerson -> b = 0; -	newPerson -> colourmix = 0; -	newPerson -> transparency = 0; -	newPerson -> myPersona = p; +	newPerson->frameNum = 0; +	newPerson->walkToX = x; +	newPerson->walkToY = y; +	newPerson->walking = false; +	newPerson->spinning = false; +	newPerson->show = true; +	newPerson->direction = 0; +	newPerson->angle = 180; +	newPerson->wantAngle = 180; +	newPerson->angleOffset = 0; +	newPerson->floaty = 0; +	newPerson->walkSpeed = newPerson->thisType->walkSpeed; +	newPerson->myAnim = NULL; +	newPerson->spinSpeed = newPerson->thisType->spinSpeed; +	newPerson->r = 0; +	newPerson->g = 0; +	newPerson->b = 0; +	newPerson->colourmix = 0; +	newPerson->transparency = 0; +	newPerson->myPersona = p;  	setFrames(* newPerson, ANI_STAND);  	// HEIGHT (BASED ON 1st FRAME OF 1st ANIMATION... INC. SPECIAL CASES) -	int fNumSigned = p -> animation[0] -> frames[0].frameNum; +	int fNumSigned = p->animation[0]->frames[0].frameNum;  	int fNum = abs(fNumSigned); -	if (fNum >= p -> animation[0] -> theSprites -> bank.total) { +	if (fNum >= p->animation[0]->theSprites->bank.total) {  		if (fNumSigned < 0) { -			newPerson -> height = 5; +			newPerson->height = 5;  		} else { -			newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[0].yhot + 5; +			newPerson->height = p->animation[0]->theSprites->bank.sprites[0].yhot + 5;  		}  	} else { -		newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[fNum].yhot + 5; +		newPerson->height = p->animation[0]->theSprites->bank.sprites[fNum].yhot + 5;  	}  	// NOW ADD IT IN THE RIGHT PLACE  	onScreenPerson * * changethat = & allPeople; -	while (((* changethat) != NULL) && ((* changethat) -> y < y)) -		changethat = & ((* changethat) -> next); +	while (((* changethat) != NULL) && ((* changethat)->y < y)) +		changethat = & ((* changethat)->next); -	newPerson -> next = (* changethat); +	newPerson->next = (* changethat);  	(* changethat) = newPerson; -	return (bool)(newPerson -> thisType != NULL); +	return (bool)(newPerson->thisType != NULL);  }  int timeForAnim(personaAnimation *fram) {  	int total = 0; -	for (int a = 0; a < fram -> numFrames; a ++) { -		total += fram -> frames[a].howMany; +	for (int a = 0; a < fram->numFrames; ++a) { +		total += fram->frames[a].howMany;  	}  	return total;  } @@ -857,22 +857,22 @@ int timeForAnim(personaAnimation *fram) {  void animatePerson(int obj, personaAnimation *fram) {   // Set a new SINGLE animation  	onScreenPerson *moveMe = findPerson(obj);  	if (moveMe) { -		if (moveMe -> continueAfterWalking) abortFunction(moveMe -> continueAfterWalking); -		moveMe -> continueAfterWalking = NULL; -		moveMe -> walking = false; -		moveMe -> spinning = false; -		moveMe -> myAnim = fram; +		if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking); +		moveMe->continueAfterWalking = NULL; +		moveMe->walking = false; +		moveMe->spinning = false; +		moveMe->myAnim = fram;  	}  }  void animatePerson(int obj, persona *per) {             // Set a new costume  	onScreenPerson *moveMe = findPerson(obj);  	if (moveMe) { -		//  if (moveMe -> continueAfterWalking) abortFunction (moveMe -> continueAfterWalking); -		//  moveMe -> continueAfterWalking = NULL; -		//  moveMe -> walking = false; -		moveMe -> spinning = false; -		moveMe -> myPersona = per; +		//  if (moveMe->continueAfterWalking) abortFunction (moveMe->continueAfterWalking); +		//  moveMe->continueAfterWalking = NULL; +		//  moveMe->walking = false; +		moveMe->spinning = false; +		moveMe->myPersona = per;  		rethinkAngle(moveMe);  		if (moveMe-> walking) {  			setFrames(* moveMe, ANI_WALK); @@ -885,11 +885,11 @@ void animatePerson(int obj, persona *per) {             // Set a new costume  void killAllPeople() {  	onScreenPerson *killPeople;  	while (allPeople) { -		if (allPeople -> continueAfterWalking) abortFunction(allPeople -> continueAfterWalking); -		allPeople -> continueAfterWalking = NULL; +		if (allPeople->continueAfterWalking) abortFunction(allPeople->continueAfterWalking); +		allPeople->continueAfterWalking = NULL;  		killPeople = allPeople; -		allPeople = allPeople -> next; -		removeObjectType(killPeople -> thisType); +		allPeople = allPeople->next; +		removeObjectType(killPeople->thisType);  		delete killPeople;  	}  } @@ -899,18 +899,18 @@ void killMostPeople() {  	onScreenPerson * * lookyHere = & allPeople;  	while (* lookyHere) { -		if ((* lookyHere) -> extra & EXTRA_NOREMOVE) { -			lookyHere = & (* lookyHere) -> next; +		if ((* lookyHere)->extra & EXTRA_NOREMOVE) { +			lookyHere = & (* lookyHere)->next;  		} else {  			killPeople = (* lookyHere);  			// Change last pointer to NEXT in the list instead -			(* lookyHere) = killPeople -> next; +			(* lookyHere) = killPeople->next;  			// Gone from the list... now free some memory -			if (killPeople -> continueAfterWalking) abortFunction(killPeople -> continueAfterWalking); -			killPeople -> continueAfterWalking = NULL; -			removeObjectType(killPeople -> thisType); +			if (killPeople->continueAfterWalking) abortFunction(killPeople->continueAfterWalking); +			killPeople->continueAfterWalking = NULL; +			removeObjectType(killPeople->thisType);  			delete killPeople;  		}  	} @@ -924,69 +924,68 @@ void removeOneCharacter(int i) {  			overRegion = NULL;  		} -		if (p -> continueAfterWalking) abortFunction(p -> continueAfterWalking); -		p -> continueAfterWalking = NULL; +		if (p->continueAfterWalking) abortFunction(p->continueAfterWalking); +		p->continueAfterWalking = NULL;  		onScreenPerson * * killPeople;  		for (killPeople = & allPeople;  		        * killPeople != p; -		        killPeople = & ((* killPeople) -> next)) { +		        killPeople = & ((* killPeople)->next)) {  			;  		} -		* killPeople = p -> next; -		removeObjectType(p -> thisType); +		* killPeople = p->next; +		removeObjectType(p->thisType);  		delete p;  	}  } -#if ALLOW_FILE -bool saveAnim(personaAnimation *p, FILE *fp) { -	put2bytes(p -> numFrames, fp); -	if (p -> numFrames) { -		put4bytes(p -> theSprites -> ID, fp); +bool saveAnim(personaAnimation *p, Common::WriteStream *stream) { +	put2bytes(p->numFrames, stream); +	if (p->numFrames) { +		put4bytes(p->theSprites->ID, stream); -		for (int a = 0; a < p -> numFrames; a ++) { -			put4bytes(p -> frames[a].frameNum, fp); -			put4bytes(p -> frames[a].howMany, fp); -			put4bytes(p -> frames[a].noise, fp); +		for (int a = 0; a < p->numFrames; ++a) { +			put4bytes(p->frames[a].frameNum, stream); +			put4bytes(p->frames[a].howMany, stream); +			put4bytes(p->frames[a].noise, stream);  		}  	}  	return true;  } -bool loadAnim(personaAnimation *p, FILE *fp) { -	p -> numFrames = get2bytes(fp); +bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) { +	p->numFrames = get2bytes(stream); -	if (p -> numFrames) { -		int a = get4bytes(fp); -		p -> frames = new animFrame[p -> numFrames]; -		if (! checkNew(p -> frames)) return false; -		p -> theSprites = loadBankForAnim(a); +	if (p->numFrames) { +		int a = get4bytes(stream); +		p->frames = new animFrame[p->numFrames]; +		if (!checkNew(p->frames)) return false; +		p->theSprites = loadBankForAnim(a); -		for (a = 0; a < p -> numFrames; a ++) { -			p -> frames[a].frameNum = get4bytes(fp); -			p -> frames[a].howMany = get4bytes(fp); +		for (a = 0; a < p->numFrames; ++a) { +			p->frames[a].frameNum = get4bytes(stream); +			p->frames[a].howMany = get4bytes(stream);  			if (ssgVersion >= VERSION(2, 0)) { -				p -> frames[a].noise = get4bytes(fp); +				p->frames[a].noise = get4bytes(stream);  			} else { -				p -> frames[a].noise = 0; +				p->frames[a].noise = 0;  			}  		}  	} else { -		p -> theSprites = NULL; -		p -> frames = NULL; +		p->theSprites = NULL; +		p->frames = NULL;  	}  	return true;  }  /*  void debugCostume (char * message, persona * cossy) {      FILE * db = fopen ("debuTURN.txt", "at"); -    fprintf (db, "  %s costume with %i directions...\n", message, cossy -> numDirections); -    for (int a = 0; a < cossy -> numDirections * 3; a ++) { -        fprintf (db, "      %i frames:", cossy -> animation[a] -> numFrames); -        for (int b = 0; b < cossy -> animation[a] -> numFrames; b ++) { -            fprintf (db, " %i", cossy -> animation[a] -> frames[b]); +    fprintf (db, "  %s costume with %i directions...\n", message, cossy->numDirections); +    for (int a = 0; a < cossy->numDirections * 3; ++a) { +        fprintf (db, "      %i frames:", cossy->animation[a]->numFrames); +        for (int b = 0; b < cossy->animation[a]->numFrames; b ++) { +            fprintf (db, " %i", cossy->animation[a]->frames[b]);          }          fprintf (db, "\n"); @@ -994,188 +993,187 @@ void debugCostume (char * message, persona * cossy) {      fclose (db);  }  */ -bool saveCostume(persona *cossy, FILE *fp) { +bool saveCostume(persona *cossy, Common::WriteStream *stream) {  	int a; -	put2bytes(cossy -> numDirections, fp); -	for (a = 0; a < cossy -> numDirections * 3; a ++) { -		if (! saveAnim(cossy -> animation[a], fp)) return false; +	put2bytes(cossy->numDirections, stream); +	for (a = 0; a < cossy->numDirections * 3; ++a) { +		if (!saveAnim(cossy->animation[a], stream)) return false;  	}  //	debugCostume ("Saved", cossy);  	return true;  } -bool loadCostume(persona *cossy, FILE *fp) { +bool loadCostume(persona *cossy, Common::SeekableReadStream *stream) {  	int a; -	cossy -> numDirections = get2bytes(fp); -	cossy -> animation = new personaAnimation * [cossy -> numDirections * 3]; -	if (! checkNew(cossy -> animation)) return false; -	for (a = 0; a < cossy -> numDirections * 3; a ++) { -		cossy -> animation[a] = new personaAnimation; -		if (! checkNew(cossy -> animation[a])) return false; - -		if (! loadAnim(cossy -> animation[a], fp)) return false; +	cossy->numDirections = get2bytes(stream); +	cossy->animation = new personaAnimation * [cossy->numDirections * 3]; +	if (!checkNew(cossy->animation)) return false; +	for (a = 0; a < cossy->numDirections * 3; ++a) { +		cossy->animation[a] = new personaAnimation; +		if (!checkNew(cossy->animation[a])) return false; + +		if (!loadAnim(cossy->animation[a], stream)) return false;  	}  //	debugCostume ("Loaded", cossy);  	return true;  } -bool savePeople(FILE *fp) { +bool savePeople(Common::WriteStream *stream) {  	onScreenPerson *me = allPeople;  	int countPeople = 0, a; -	putSigned(scaleHorizon, fp); -	putSigned(scaleDivide, fp); +	putSigned(scaleHorizon, stream); +	putSigned(scaleDivide, stream);  	while (me) {  		countPeople ++; -		me = me -> next; +		me = me->next;  	} -	put2bytes(countPeople, fp); +	put2bytes(countPeople, stream);  	me = allPeople; -	for (a = 0; a < countPeople; a ++) { - -		putFloat(me -> x, fp); -		putFloat(me -> y, fp); - -		saveCostume(me -> myPersona, fp); -		saveAnim(me -> myAnim, fp); -		fputc(me -> myAnim == me -> lastUsedAnim, fp); - -		putFloat(me -> scale, fp); - -		put2bytes(me -> extra, fp); -		put2bytes(me -> height, fp); -		put2bytes(me -> walkToX, fp); -		put2bytes(me -> walkToY, fp); -		put2bytes(me -> thisStepX, fp); -		put2bytes(me -> thisStepY, fp); -		put2bytes(me -> frameNum, fp); -		put2bytes(me -> frameTick, fp); -		put2bytes(me -> walkSpeed, fp); -		put2bytes(me -> spinSpeed, fp); -		putSigned(me -> floaty, fp); -		fputc(me -> show, fp); -		fputc(me -> walking, fp); -		fputc(me -> spinning, fp); -		if (me -> continueAfterWalking) { -			fputc(1, fp); -			saveFunction(me -> continueAfterWalking, fp); +	for (a = 0; a < countPeople; ++a) { + +		putFloat(me->x, stream); +		putFloat(me->y, stream); + +		saveCostume(me->myPersona, stream); +		saveAnim(me->myAnim, stream); +		putch(me->myAnim == me->lastUsedAnim, stream); + +		putFloat(me->scale, stream); + +		put2bytes(me->extra, stream); +		put2bytes(me->height, stream); +		put2bytes(me->walkToX, stream); +		put2bytes(me->walkToY, stream); +		put2bytes(me->thisStepX, stream); +		put2bytes(me->thisStepY, stream); +		put2bytes(me->frameNum, stream); +		put2bytes(me->frameTick, stream); +		put2bytes(me->walkSpeed, stream); +		put2bytes(me->spinSpeed, stream); +		putSigned(me->floaty, stream); +		putch(me->show, stream); +		putch(me->walking, stream); +		putch(me->spinning, stream); +		if (me->continueAfterWalking) { +			putch(1, stream); +			saveFunction(me->continueAfterWalking, stream);  		} else { -			fputc(0, fp); +			putch(0, stream);  		} -		put2bytes(me -> direction, fp); -		put2bytes(me -> angle, fp); -		put2bytes(me -> angleOffset, fp); -		put2bytes(me -> wantAngle, fp); -		putSigned(me -> directionWhenDoneWalking, fp); -		putSigned(me -> inPoly, fp); -		putSigned(me -> walkToPoly, fp); - -		fputc(me -> r, fp); -		fputc(me -> g, fp); -		fputc(me -> b, fp); -		fputc(me -> colourmix, fp); -		fputc(me -> transparency, fp); - -		saveObjectRef(me -> thisType, fp); - -		me = me -> next; +		put2bytes(me->direction, stream); +		put2bytes(me->angle, stream); +		put2bytes(me->angleOffset, stream); +		put2bytes(me->wantAngle, stream); +		putSigned(me->directionWhenDoneWalking, stream); +		putSigned(me->inPoly, stream); +		putSigned(me->walkToPoly, stream); + +		putch(me->r, stream); +		putch(me->g, stream); +		putch(me->b, stream); +		putch(me->colourmix, stream); +		putch(me->transparency, stream); + +		saveObjectRef(me->thisType, stream); + +		me = me->next;  	}  	return true;  } -bool loadPeople(FILE *fp) { +bool loadPeople(Common::SeekableReadStream *stream) {  	onScreenPerson * * pointy = & allPeople;  	onScreenPerson *me; -	scaleHorizon = getSigned(fp); -	scaleDivide = getSigned(fp); +	scaleHorizon = getSigned(stream); +	scaleDivide = getSigned(stream); -	int countPeople = get2bytes(fp); +	int countPeople = get2bytes(stream);  	int a;  	allPeople = NULL; -	for (a = 0; a < countPeople; a ++) { +	for (a = 0; a < countPeople; ++a) {  		me = new onScreenPerson; -		if (! checkNew(me)) return false; - -		me -> myPersona = new persona; -		if (! checkNew(me -> myPersona)) return false; - -		me -> myAnim = new personaAnimation; -		if (! checkNew(me -> myAnim)) return false; - -		me -> x = getFloat(fp); -		me -> y = getFloat(fp); - -		loadCostume(me -> myPersona, fp); -		loadAnim(me -> myAnim, fp); - -		me -> lastUsedAnim = fgetc(fp) ? me -> myAnim : NULL; - -		me -> scale = getFloat(fp); - -		me -> extra = get2bytes(fp); -		me -> height = get2bytes(fp); -		me -> walkToX = get2bytes(fp); -		me -> walkToY = get2bytes(fp); -		me -> thisStepX = get2bytes(fp); -		me -> thisStepY = get2bytes(fp); -		me -> frameNum = get2bytes(fp); -		me -> frameTick = get2bytes(fp); -		me -> walkSpeed = get2bytes(fp); -		me -> spinSpeed = get2bytes(fp); -		me -> floaty = getSigned(fp); -		me -> show = fgetc(fp); -		me -> walking = fgetc(fp); -		me -> spinning = fgetc(fp); -		if (fgetc(fp)) { -			me -> continueAfterWalking = loadFunction(fp); -			if (! me -> continueAfterWalking) return false; +		if (!checkNew(me)) return false; + +		me->myPersona = new persona; +		if (!checkNew(me->myPersona)) return false; + +		me->myAnim = new personaAnimation; +		if (!checkNew(me->myAnim)) return false; + +		me->x = getFloat(stream); +		me->y = getFloat(stream); + +		loadCostume(me->myPersona, stream); +		loadAnim(me->myAnim, stream); + +		me->lastUsedAnim = getch(stream) ? me->myAnim : NULL; + +		me->scale = getFloat(stream); + +		me->extra = get2bytes(stream); +		me->height = get2bytes(stream); +		me->walkToX = get2bytes(stream); +		me->walkToY = get2bytes(stream); +		me->thisStepX = get2bytes(stream); +		me->thisStepY = get2bytes(stream); +		me->frameNum = get2bytes(stream); +		me->frameTick = get2bytes(stream); +		me->walkSpeed = get2bytes(stream); +		me->spinSpeed = get2bytes(stream); +		me->floaty = getSigned(stream); +		me->show = getch(stream); +		me->walking = getch(stream); +		me->spinning = getch(stream); +		if (getch(stream)) { +			me->continueAfterWalking = loadFunction(stream); +			if (!me->continueAfterWalking) return false;  		} else { -			me -> continueAfterWalking = NULL; +			me->continueAfterWalking = NULL;  		} -		me -> direction = get2bytes(fp); -		me -> angle = get2bytes(fp); +		me->direction = get2bytes(stream); +		me->angle = get2bytes(stream);  		if (ssgVersion >= VERSION(2, 0)) { -			me -> angleOffset = get2bytes(fp); +			me->angleOffset = get2bytes(stream);  		} else { -			me -> angleOffset = 0; +			me->angleOffset = 0;  		} -		me -> wantAngle = get2bytes(fp); -		me -> directionWhenDoneWalking = getSigned(fp); -		me -> inPoly = getSigned(fp); -		me -> walkToPoly = getSigned(fp); +		me->wantAngle = get2bytes(stream); +		me->directionWhenDoneWalking = getSigned(stream); +		me->inPoly = getSigned(stream); +		me->walkToPoly = getSigned(stream);  		if (ssgVersion >= VERSION(2, 0)) { -			me -> r = fgetc(fp); -			me -> g = fgetc(fp); -			me -> b = fgetc(fp); -			me -> colourmix = fgetc(fp); -			me -> transparency = fgetc(fp); +			me->r = getch(stream); +			me->g = getch(stream); +			me->b = getch(stream); +			me->colourmix = getch(stream); +			me->transparency = getch(stream);  		} else { -			setMyDrawMode(me, get2bytes(fp)); +			setMyDrawMode(me, get2bytes(stream));  		} -		me -> thisType = loadObjectRef(fp); +		me->thisType = loadObjectRef(stream);  		// Anti-aliasing settings  		if (ssgVersion >= VERSION(1, 6)) {  			if (ssgVersion < VERSION(2, 0)) {  				// aaLoad -				fgetc(fp); -				getFloat(fp); -				getFloat(fp); +				getch(stream); +				getFloat(stream); +				getFloat(stream);  			}  		} -		me -> next = NULL; +		me->next = NULL;  		* pointy = me; -		pointy = & (me -> next); +		pointy = & (me->next);  	}  //	db ("End of loadPeople");  	return true;  } -#endif  } // End of namespace Sludge diff --git a/engines/sludge/people.h b/engines/sludge/people.h index 11cf10b737..ba726b01be 100644 --- a/engines/sludge/people.h +++ b/engines/sludge/people.h @@ -125,14 +125,12 @@ personaAnimation *makeNullAnim();  void deleteAnim(personaAnimation *orig);
  // Loading and saving
 -#if ALLOW_FILE
 -bool saveAnim(personaAnimation *p, FILE *fp);
 -bool loadAnim(personaAnimation *p, FILE *fp);
 -bool savePeople(FILE *fp);
 -bool loadPeople(FILE *fp);
 -bool saveCostume(persona *cossy, FILE *fp);
 -bool loadCostume(persona *cossy, FILE *fp);
 -#endif
 +bool saveAnim(personaAnimation *p, Common::WriteStream *stream);
 +bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream);
 +bool savePeople(Common::WriteStream *stream);
 +bool loadPeople(Common::SeekableReadStream *stream);
 +bool saveCostume(persona *cossy, Common::WriteStream *stream);
 +bool loadCostume(persona *cossy, Common::SeekableReadStream *stream);
  } // End of namespace Sludge
 diff --git a/engines/sludge/region.cpp b/engines/sludge/region.cpp index 8c55ece9ff..eebcb577dd 100644 --- a/engines/sludge/region.cpp +++ b/engines/sludge/region.cpp @@ -38,11 +38,11 @@ void showBoxes() {  	screenRegion *huntRegion = allScreenRegions;  	while (huntRegion) { -		drawVerticalLine(huntRegion -> x1, huntRegion -> y1, huntRegion -> y2); -		drawVerticalLine(huntRegion -> x2, huntRegion -> y1, huntRegion -> y2); -		drawHorizontalLine(huntRegion -> x1, huntRegion -> y1, huntRegion -> x2); -		drawHorizontalLine(huntRegion -> x1, huntRegion -> y2, huntRegion -> x2); -		huntRegion = huntRegion -> next; +		drawVerticalLine(huntRegion->x1, huntRegion->y1, huntRegion->y2); +		drawVerticalLine(huntRegion->x2, huntRegion->y1, huntRegion->y2); +		drawHorizontalLine(huntRegion->x1, huntRegion->y1, huntRegion->x2); +		drawHorizontalLine(huntRegion->x1, huntRegion->y2, huntRegion->x2); +		huntRegion = huntRegion->next;  	}  } @@ -51,45 +51,44 @@ void removeScreenRegion(int objectNum) {  	screenRegion *killMe;  	while (* huntRegion) { -		if ((* huntRegion) -> thisType -> objectNum == objectNum) { +		if ((* huntRegion)->thisType->objectNum == objectNum) {  			killMe = * huntRegion; -			* huntRegion = killMe -> next; -			removeObjectType(killMe -> thisType); +			* huntRegion = killMe->next; +			removeObjectType(killMe->thisType);  			if (killMe == overRegion) overRegion = NULL;  			delete killMe;  			killMe = NULL;  		} else { -			huntRegion = & ((* huntRegion) -> next); +			huntRegion = & ((* huntRegion)->next);  		}  	}  } -#if ALLOW_FILE -void saveRegions(FILE *fp) { +void saveRegions(Common::WriteStream *stream) {  	int numRegions = 0;  	screenRegion *thisRegion = allScreenRegions;  	while (thisRegion) { -		thisRegion = thisRegion -> next; +		thisRegion = thisRegion->next;  		numRegions ++;  	} -	put2bytes(numRegions, fp); +	put2bytes(numRegions, stream);  	thisRegion = allScreenRegions;  	while (thisRegion) { -		put2bytes(thisRegion -> x1, fp); -		put2bytes(thisRegion -> y1, fp); -		put2bytes(thisRegion -> x2, fp); -		put2bytes(thisRegion -> y2, fp); -		put2bytes(thisRegion -> sX, fp); -		put2bytes(thisRegion -> sY, fp); -		put2bytes(thisRegion -> di, fp); -		saveObjectRef(thisRegion -> thisType, fp); - -		thisRegion = thisRegion -> next; +		put2bytes(thisRegion->x1, stream); +		put2bytes(thisRegion->y1, stream); +		put2bytes(thisRegion->x2, stream); +		put2bytes(thisRegion->y2, stream); +		put2bytes(thisRegion->sX, stream); +		put2bytes(thisRegion->sY, stream); +		put2bytes(thisRegion->di, stream); +		saveObjectRef(thisRegion->thisType, stream); + +		thisRegion = thisRegion->next;  	}  } -void loadRegions(FILE *fp) { -	int numRegions = get2bytes(fp); +void loadRegions(Common::SeekableReadStream *stream) { +	int numRegions = get2bytes(stream);  	screenRegion *newRegion;  	screenRegion * * pointy = & allScreenRegions; @@ -97,26 +96,26 @@ void loadRegions(FILE *fp) {  	while (numRegions --) {  		newRegion = new screenRegion;  		* pointy = newRegion; -		pointy = & (newRegion -> next); - -		newRegion -> x1 = get2bytes(fp); -		newRegion -> y1 = get2bytes(fp); -		newRegion -> x2 = get2bytes(fp); -		newRegion -> y2 = get2bytes(fp); -		newRegion -> sX = get2bytes(fp); -		newRegion -> sY = get2bytes(fp); -		newRegion -> di = get2bytes(fp); -		newRegion -> thisType = loadObjectRef(fp); +		pointy = & (newRegion->next); + +		newRegion->x1 = get2bytes(stream); +		newRegion->y1 = get2bytes(stream); +		newRegion->x2 = get2bytes(stream); +		newRegion->y2 = get2bytes(stream); +		newRegion->sX = get2bytes(stream); +		newRegion->sY = get2bytes(stream); +		newRegion->di = get2bytes(stream); +		newRegion->thisType = loadObjectRef(stream);  	}  	* pointy = NULL;  } -#endif +  void killAllRegions() {  	screenRegion *killRegion;  	while (allScreenRegions) {  		killRegion = allScreenRegions; -		allScreenRegions = allScreenRegions -> next; -		removeObjectType(killRegion -> thisType); +		allScreenRegions = allScreenRegions->next; +		removeObjectType(killRegion->thisType);  		delete killRegion;  	}  	overRegion = NULL; @@ -124,29 +123,29 @@ void killAllRegions() {  bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, int objectNum) {  	screenRegion *newRegion = new screenRegion; -	if (! checkNew(newRegion)) return false; -	newRegion -> di = di; -	newRegion -> x1 = x1; -	newRegion -> y1 = y1; -	newRegion -> x2 = x2; -	newRegion -> y2 = y2; -	newRegion -> sX = sX; -	newRegion -> sY = sY; -	newRegion -> thisType = loadObjectType(objectNum); -	newRegion -> next = allScreenRegions; +	if (!checkNew(newRegion)) return false; +	newRegion->di = di; +	newRegion->x1 = x1; +	newRegion->y1 = y1; +	newRegion->x2 = x2; +	newRegion->y2 = y2; +	newRegion->sX = sX; +	newRegion->sY = sY; +	newRegion->thisType = loadObjectType(objectNum); +	newRegion->next = allScreenRegions;  	allScreenRegions = newRegion; -	return (bool)(newRegion -> thisType != NULL); +	return (bool)(newRegion->thisType != NULL);  }  void getOverRegion() {  	screenRegion *thisRegion = allScreenRegions;  	while (thisRegion) { -		if ((input.mouseX >= thisRegion -> x1 - cameraX) && (input.mouseY >= thisRegion -> y1 - cameraY) && -		        (input.mouseX <= thisRegion -> x2 - cameraX) && (input.mouseY <= thisRegion -> y2 - cameraY)) { +		if ((input.mouseX >= thisRegion->x1 - cameraX) && (input.mouseY >= thisRegion->y1 - cameraY) && +		        (input.mouseX <= thisRegion->x2 - cameraX) && (input.mouseY <= thisRegion->y2 - cameraY)) {  			overRegion = thisRegion;  			return;  		} -		thisRegion = thisRegion -> next; +		thisRegion = thisRegion->next;  	}  	overRegion = NULL;  	return; @@ -156,10 +155,10 @@ screenRegion *getRegionForObject(int obj) {  	screenRegion *thisRegion = allScreenRegions;  	while (thisRegion) { -		if (obj == thisRegion -> thisType -> objectNum) { +		if (obj == thisRegion->thisType->objectNum) {  			return thisRegion;  		} -		thisRegion = thisRegion -> next; +		thisRegion = thisRegion->next;  	}  	return NULL; diff --git a/engines/sludge/region.h b/engines/sludge/region.h index 52c1c588ba..2bc4ab6228 100644 --- a/engines/sludge/region.h +++ b/engines/sludge/region.h @@ -34,11 +34,10 @@ bool addScreenRegion(int x1, int y1, int x2, int y2, int, int, int, int objectNu  void getOverRegion();
  screenRegion *getRegionForObject(int obj);
  void removeScreenRegion(int objectNum);
 +void loadRegions(Common::SeekableReadStream *stream);
 +void saveRegions(Common::WriteStream *stream);
  void killAllRegions();
 -#if ALLOW_FILE
 -void loadRegions(FILE *);
 -void saveRegions(FILE *);
 -#endif
 +
  void showBoxes();
  } // End of namespace Sludge
 diff --git a/engines/sludge/savedata.cpp b/engines/sludge/savedata.cpp index 79e672b5fa..dc061c6465 100644 --- a/engines/sludge/savedata.cpp +++ b/engines/sludge/savedata.cpp @@ -29,6 +29,8 @@  #include "newfatal.h"  #include "moreio.h" +#include "common/file.h" +  #define LOAD_ERROR "Can't load custom data...\n\n"  namespace Sludge { @@ -59,107 +61,109 @@ void loadSaveDebug (int com) {  }  */ -#if ALLOW_FILE -void writeStringEncoded(const char *s, FILE *fp) { +void writeStringEncoded(const char *s, Common::WriteStream *stream) {  	int a, len = strlen(s); -	put2bytes(len, fp); +	put2bytes(len, stream);  	for (a = 0; a < len; a ++) { -		fputc(s[a] ^ encode1, fp); +		putch(s[a] ^ encode1, stream);  		encode1 += encode2;  	}  } -char *readStringEncoded(FILE *fp) { +char *readStringEncoded(Common::File *fp) {  	int a, len = get2bytes(fp);  	char *s = new char[len + 1]; -	if (! checkNew(s)) return NULL; +	if (!checkNew(s)) return NULL;  	for (a = 0; a < len; a ++) { -		s[a] = (char)(fgetc(fp) ^ encode1); +		s[a] = (char)(getch(fp) ^ encode1);  		encode1 += encode2;  	}  	s[len] = 0;  	return s;  } -char *readTextPlain(FILE *fp) { +char *readTextPlain(Common::File *fp) {  	int32_t startPos; -	int stringSize = 0; +	uint32 stringSize = 0;  	bool keepGoing = true;  	char gotChar;  	char *reply; -	startPos = ftell(fp); +	startPos = fp->pos();  	while (keepGoing) { -		gotChar = (char) fgetc(fp); -		if ((gotChar == '\n') || (feof(fp))) { +		gotChar = (char) getch(fp); +		if ((gotChar == '\n') || (fp->eos())) {  			keepGoing = false;  		} else {  			stringSize ++;  		}  	} -	if ((stringSize == 0) && (feof(fp))) { +	if ((stringSize == 0) && (fp->eos())) {  		return NULL;  	} else { -		fseek(fp, startPos, SEEK_SET); +		fp->seek(startPos, SEEK_SET);  		reply = new char[stringSize + 1];  		if (reply == NULL) return NULL; -		size_t bytes_read = fread(reply, stringSize, 1, fp); -		if (bytes_read != stringSize && ferror(fp)) { +		size_t bytes_read = fp->read(reply, stringSize); +		if (bytes_read != stringSize && fp->err()) {  			debugOut("Reading error in readTextPlain.\n");  		} -		fgetc(fp);  // Skip the newline character +		getch(fp);  // Skip the newline character  		reply[stringSize] = 0;  	}  	return reply;  } -#endif  bool fileToStack(char *filename, stackHandler *sH) { -#if ALLOW_FILE +  	variable stringVar;  	stringVar.varType = SVT_NULL;  	const char *checker = saveEncoding ? "[Custom data (encoded)]\r\n" : "[Custom data (ASCII)]\n"; -	FILE *fp = fopen(filename, "rb"); -	if (! fp) { +	Common::File fd; + +	if (!fd.open(filename)) { +#if 0  		char currentDir[1000]; -		if (! getcwd(currentDir, 998)) { +		if (!getcwd(currentDir, 998)) {  			debugOut("Can't get current directory.\n");  		}  		if (chdir(gamePath)) {  			debugOut("Error: Failed changing to directory %s\n", gamePath);  		} -		fp = fopen(filename, "rb"); +  		if (chdir(currentDir)) {  			debugOut("Error: Failed changing to directory %s\n", currentDir);  		} -		if (! fp) { +		if (!fd.open(filename)) {  			return fatal("No such file", filename);  		} +#endif +		return fatal("No such file", filename); //TODO: false value  	}  	encode1 = (unsigned char) saveEncoding & 255;  	encode2 = (unsigned char)(saveEncoding >> 8);  	while (* checker) { -		if (fgetc(fp) != * checker) { -			fclose(fp); +		if (getch(&fd) != * checker) { +			fd.close();  			return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:", filename);  		}  		checker ++;  	}  	if (saveEncoding) { -		char *checker = readStringEncoded(fp); +		char *checker = readStringEncoded(&fd);  		if (strcmp(checker, "UN�LO�CKED")) { -			fclose(fp); +			fd.close();  			return fatal(LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:", filename);  		}  		delete checker; @@ -169,55 +173,55 @@ bool fileToStack(char *filename, stackHandler *sH) {  	for (;;) {  		if (saveEncoding) { -			char i = fgetc(fp) ^ encode1; +			char i = getch(&fd) ^ encode1; -			if (feof(fp)) break; +			if (fd.eos()) break;  			switch (i) {  			case 0: { -				char *g = readStringEncoded(fp); +				char *g = readStringEncoded(&fd);  				makeTextVar(stringVar, g);  				delete g;  			}  			break;  			case 1: -				setVariable(stringVar, SVT_INT, get4bytes(fp)); +				setVariable(stringVar, SVT_INT, get4bytes(&fd));  				break;  			case 2: -				setVariable(stringVar, SVT_INT, fgetc(fp)); +				setVariable(stringVar, SVT_INT, getch(&fd));  				break;  			default:  				fatal(LOAD_ERROR "Corrupt custom data file:", filename); -				fclose(fp); +				fd.close();  				return false;  			}  		} else { -			char *line = readTextPlain(fp); -			if (! line) break; +			char *line = readTextPlain(&fd); +			if (!line) break;  			makeTextVar(stringVar, line);  		}  		if (sH -> first == NULL) {  			// Adds to the TOP of the array... oops! -			if (! addVarToStackQuick(stringVar, sH -> first)) return false; +			if (!addVarToStackQuick(stringVar, sH -> first)) return false;  			sH -> last = sH -> first;  		} else {  			// Adds to the END of the array... much better -			if (! addVarToStackQuick(stringVar, sH -> last -> next)) return false; +			if (!addVarToStackQuick(stringVar, sH -> last -> next)) return false;  			sH -> last = sH -> last -> next;  		}  	} -	fclose(fp); -#endif +	fd.close(); +  	return true;  }  bool stackToFile(char *filename, const variable &from) { -#if ALLOW_FILE +#if 0  	FILE *fp = fopen(filename, saveEncoding ? "wb" : "wt"); -	if (! fp) return fatal("Can't create file", filename); +	if (!fp) return fatal("Can't create file", filename);  	variableStack *hereWeAre = from.varData.theStack -> first; diff --git a/engines/sludge/shaders.cpp b/engines/sludge/shaders.cpp index e11a834775..cd95079ff6 100644 --- a/engines/sludge/shaders.cpp +++ b/engines/sludge/shaders.cpp @@ -33,37 +33,32 @@ extern char *bundleFolder;  //Read in a textfile (GLSL program)  // we need to pass it as a string to the GLSL driver  char *shaderFileRead(const char *name) { -	FILE *fp; +	Common::File fd;  	char *content = NULL;  	char *fn = joinStrings(bundleFolder, name);  	int count = 0;  	if (fn != NULL) { +		if (fd.open(fn)) { -		fp = fopen(fn, "rt"); - -		if (fp != NULL) { - -			fseek(fp, 0, SEEK_END); -			count = ftell(fp); -			rewind(fp); +			fd.seek(0, SEEK_END); +			count = fd.pos(); +			fd.seek(0);  			if (count > 0) {  				content = (char *)malloc(sizeof(char) * (count + 1)); -				count = fread(content, sizeof(char), count, fp); +				count = fd.read(content, sizeof(char) * count);  				content[count] = '\0';  			} -			fclose(fp); - +			fd.close();  		}  	} -  	delete fn; -  	return content;  } +#if 0  static void  printShaderInfoLog(GLuint shader) {  	GLint     infologLength = 0; @@ -116,12 +111,14 @@ printProgramInfoLog(GLuint program) {  	}  	printOpenGLError();   // Check for OpenGL errors  } +#endif  int buildShaders(const char *vertexShader, const char *fragmentShader) { +#if 0  	GLuint VS, FS, prog;  	GLint vertCompiled, fragCompiled;  	GLint linked; -#if 0 +  	// Create Shader Objects  	VS = glCreateShader(GL_VERTEX_SHADER);  	FS = glCreateShader(GL_FRAGMENT_SHADER); @@ -145,10 +142,10 @@ int buildShaders(const char *vertexShader, const char *fragmentShader) {  	printOpenGLError();  	glGetShaderiv(FS, GL_COMPILE_STATUS, &fragCompiled);  	printShaderInfoLog(FS); -#endif +  	if (!vertCompiled || !fragCompiled)  		return 0; - +#endif  	debugOut("\nShaders compiled. \n");  #if 0 @@ -166,13 +163,15 @@ int buildShaders(const char *vertexShader, const char *fragmentShader) {  	printOpenGLError();  	glGetProgramiv(prog, GL_LINK_STATUS, &linked);  	printProgramInfoLog(prog); -#endif +  	if (!linked)  		return 0;  	debugOut("Shader program linked. \n");  	return prog; +#endif +	return 0; //TODO: false value  }  } // End of namespace Sludge diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp index 02a27f13cc..5202168f25 100644 --- a/engines/sludge/sludger.cpp +++ b/engines/sludge/sludger.cpp @@ -127,55 +127,55 @@ const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", "SET_GLOBAL                               "INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET", "INDEXGET",                               "INC_INDEX", "DEC_INDEX", "QUICK_PUSH"                             }; -#if ALLOW_FILE -void loadHandlers(FILE *fp) { -	currentEvents -> leftMouseFunction      = get2bytes(fp); -	currentEvents -> leftMouseUpFunction    = get2bytes(fp); -	currentEvents -> rightMouseFunction     = get2bytes(fp); -	currentEvents -> rightMouseUpFunction   = get2bytes(fp); -	currentEvents -> moveMouseFunction      = get2bytes(fp); -	currentEvents -> focusFunction          = get2bytes(fp); -	currentEvents -> spaceFunction          = get2bytes(fp); + +void loadHandlers(Common::SeekableReadStream *stream) { +	currentEvents->leftMouseFunction      = get2bytes(stream); +	currentEvents->leftMouseUpFunction    = get2bytes(stream); +	currentEvents->rightMouseFunction     = get2bytes(stream); +	currentEvents->rightMouseUpFunction   = get2bytes(stream); +	currentEvents->moveMouseFunction      = get2bytes(stream); +	currentEvents->focusFunction          = get2bytes(stream); +	currentEvents->spaceFunction          = get2bytes(stream);  } -void saveHandlers(FILE *fp) { -	put2bytes(currentEvents -> leftMouseFunction,      fp); -	put2bytes(currentEvents -> leftMouseUpFunction,    fp); -	put2bytes(currentEvents -> rightMouseFunction,     fp); -	put2bytes(currentEvents -> rightMouseUpFunction,   fp); -	put2bytes(currentEvents -> moveMouseFunction,      fp); -	put2bytes(currentEvents -> focusFunction,          fp); -	put2bytes(currentEvents -> spaceFunction,          fp); +void saveHandlers(Common::WriteStream *stream) { +	put2bytes(currentEvents->leftMouseFunction,      stream); +	put2bytes(currentEvents->leftMouseUpFunction,    stream); +	put2bytes(currentEvents->rightMouseFunction,     stream); +	put2bytes(currentEvents->rightMouseUpFunction,   stream); +	put2bytes(currentEvents->moveMouseFunction,      stream); +	put2bytes(currentEvents->focusFunction,          stream); +	put2bytes(currentEvents->spaceFunction,          stream);  } -FILE *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion) { -	FILE *fp = fopen(filename, "rb"); -	if (! fp) { +Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion) { +	Common::File *fp = new Common::File(); +	if (!fp->open(filename)) {  		fatal("Can't open file", filename);  		return NULL;  	}  	bool headerBad = false; -	if (fgetc(fp) != 'S') headerBad = true; -	if (fgetc(fp) != 'L') headerBad = true; -	if (fgetc(fp) != 'U') headerBad = true; -	if (fgetc(fp) != 'D') headerBad = true; -	if (fgetc(fp) != extra1) headerBad = true; -	if (fgetc(fp) != extra2) headerBad = true; +	if (getch(fp) != 'S') headerBad = true; +	if (getch(fp) != 'L') headerBad = true; +	if (getch(fp) != 'U') headerBad = true; +	if (getch(fp) != 'D') headerBad = true; +	if (getch(fp) != extra1) headerBad = true; +	if (getch(fp) != extra2) headerBad = true;  	if (headerBad) {  		fatal(er, filename);  		return NULL;  	}  	char c; -	c = fgetc(fp); -	debug(c); -	while (c = fgetc(fp)) { -		putchar(c); +	c = getch(fp); +	debug("%c", c); +	while ((c = getch(fp))) { +		debug("%c", c);  	} -	int majVersion = fgetc(fp); -	printf("$majVersion %i\n", majVersion); -	int minVersion = fgetc(fp); -	printf("$minVersion %i\n", minVersion); +	int majVersion = getch(fp); +	debug(kSludgeDebugDataLoad, "majVersion %i", majVersion); +	int minVersion = getch(fp); +	debug(kSludgeDebugDataLoad, "minVersion %i", minVersion);  	fileVersion = majVersion * 256 + minVersion;  	char txtVer[120]; @@ -191,89 +191,83 @@ FILE *openAndVerify(char *filename, char extra1, char extra2, const char *er, in  	}  	return fp;  } -#endif  bool initSludge(char *filename) {  	int a = 0;  	mouseCursorAnim = makeNullAnim(); -#if ALLOW_FILE -	FILE *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion); -	if (! fp) return false; +	Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion); +	if (!fp) return false; -	char c = fgetc(fp); -	putchar(c); +	char c = getch(fp);  	if (c) {  		numBIFNames = get2bytes(fp); -		printf("numBIFNames %i\n", numBIFNames); +		debug(kSludgeDebugDataLoad, "numBIFNames %i", numBIFNames);  		allBIFNames = new char *[numBIFNames]; -		if (! checkNew(allBIFNames)) return false; +		if (!checkNew(allBIFNames)) return false;  		for (int fn = 0; fn < numBIFNames; fn ++) {  			allBIFNames[fn] = readString(fp); -			printf("%s\n", allBIFNames[fn]);  		}  		numUserFunc = get2bytes(fp); -		printf("numUserFunc %i\n", numUserFunc); +		debug(kSludgeDebugDataLoad, "numUserFunc %i", numUserFunc);  		allUserFunc = new char *[numUserFunc]; -		if (! checkNew(allUserFunc)) return false; +		if (!checkNew(allUserFunc)) return false;  		for (int fn = 0; fn < numUserFunc; fn ++) {  			allUserFunc[fn] = readString(fp); -			printf("%s\n", allUserFunc[fn]);  		}  		if (gameVersion >= VERSION(1, 3)) {  			numResourceNames = get2bytes(fp); -			printf("numResourceNames %i\n", numResourceNames); +			debug(kSludgeDebugDataLoad, "numResourceNames %i", numResourceNames);  			allResourceNames = new char *[numResourceNames]; -			if (! checkNew(allResourceNames)) return false; +			if (!checkNew(allResourceNames)) return false;  			for (int fn = 0; fn < numResourceNames; fn ++) {  				allResourceNames[fn] = readString(fp); -				printf("%s\n", allResourceNames[fn]);  			}  		}  	}  	winWidth = get2bytes(fp); -	printf("winWidth : %i\n", winWidth); +	debug(kSludgeDebugDataLoad, "winWidth : %i", winWidth);  	winHeight = get2bytes(fp); -	printf("winHeight : %i\n", winHeight); -	specialSettings = fgetc(fp); -	printf("specialSettings : %i\n", specialSettings); -	desiredfps = 1000 / fgetc(fp); +	debug(kSludgeDebugDataLoad, "winHeight : %i", winHeight); +	specialSettings = getch(fp); +	debug(kSludgeDebugDataLoad, "specialSettings : %i", specialSettings); +	desiredfps = 1000 / getch(fp);  	delete[] readString(fp);  // Unused - was used for registration purposes. -	size_t bytes_read = fread(& fileTime, sizeof(FILETIME), 1, fp); -	if (bytes_read != sizeof(FILETIME) && ferror(fp)) { -		debugOut("Reading error in initSludge.\n"); +	size_t bytes_read = fp->read(&fileTime, sizeof(FILETIME)); +	if (bytes_read != sizeof(FILETIME) && fp->err()) { +		debug("Reading error in initSludge.");  	}  	char *dataFol = (gameVersion >= VERSION(1, 3)) ? readString(fp) : joinStrings("", ""); -	printf("dataFol : %s\n", dataFol); +	debug(kSludgeDebugDataLoad, "dataFol : %s", dataFol); -	gameSettings.numLanguages = (gameVersion >= VERSION(1, 3)) ? (fgetc(fp)) : 0; -	printf("numLanguages : %c\n", gameSettings.numLanguages); +	gameSettings.numLanguages = (gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0; +	debug(kSludgeDebugDataLoad, "numLanguages : %c", gameSettings.numLanguages);  	makeLanguageTable(fp);  	if (gameVersion >= VERSION(1, 6)) { -		fgetc(fp); +		getch(fp);  		// aaLoad -		fgetc(fp); +		getch(fp);  		getFloat(fp);  		getFloat(fp);  	}  	char *checker = readString(fp); -	debug(kSludgeDebugDataLoad, "checker : %s\n", checker); +	debug(kSludgeDebugDataLoad, "checker : %s", checker);  	if (strcmp(checker, "okSoFar")) return fatal(ERROR_BAD_HEADER, filename);  	delete checker;  	checker = NULL; -	unsigned char customIconLogo = fgetc(fp); -	kSludgeDebugDataLoad(kSludgeDebugDataLoad, "Game icon: %i", customIconLogo); +	unsigned char customIconLogo = getch(fp); +	debug(kSludgeDebugDataLoad, "Game icon type: %i", customIconLogo);  	if (customIconLogo & 1) {  		// There is an icon - read it! @@ -346,7 +340,7 @@ bool initSludge(char *filename) {  		}  		gameIcon = new unsigned char [iconW * iconH * 4]; -		if (! gameIcon) return fatal("Can't reserve memory for game icon."); +		if (!gameIcon) return fatal("Can't reserve memory for game icon.");  		int32_t transCol = 63519;  		Uint8 *p = (Uint8 *) gameIcon; @@ -388,8 +382,8 @@ bool initSludge(char *filename) {  	if (customIconLogo & 2) {  		// There is an logo - read it!  		debug(kSludgeDebugDataLoad, "There is an logo - read it!"); +#if 0  		int n; -  		long file_pointer = ftell(fp);  		png_structp png_ptr; @@ -402,7 +396,7 @@ bool initSludge(char *filename) {  		char tmp[10];  		bytes_read = fread(tmp, 1, 8, fp);  		if (bytes_read != 8 && ferror(fp)) { -			debugOut("Reading error in initSludge.\n"); +			debugOut("Reading error in initSludge.");  		}  		if (png_sig_cmp((png_byte *) tmp, 0, 8)) {  			// No, it's old-school HSI @@ -463,7 +457,7 @@ bool initSludge(char *filename) {  		if ((logoW != 310) || (logoH != 88)) return fatal("Game logo have wrong dimensions. (Should be 310x88)");  		gameLogo = new unsigned char [logoW * logoH * 4]; -		if (! gameLogo) return fatal("Can't reserve memory for game logo."); +		if (!gameLogo) return fatal("Can't reserve memory for game logo.");  		// int32_t transCol = 63519;  		Uint8 *p = (Uint8 *) gameLogo; @@ -506,13 +500,14 @@ bool initSludge(char *filename) {  				}  			}  		} +#endif  	}  	numGlobals = get2bytes(fp); -	printf("numGlobals : %i\n", numGlobals); +	debug("numGlobals : %i", numGlobals);  	globalVars = new variable[numGlobals]; -	if (! checkNew(globalVars)) return false; +	if (!checkNew(globalVars)) return false;  	for (a = 0; a < numGlobals; a ++) initVarNew(globalVars[a]);  	// Get the original (untranslated) name of the game and convert it to Unicode. @@ -524,8 +519,9 @@ bool initSludge(char *filename) {  	delete gameNameOrig; -	changeToUserDir();  #if 0 +	changeToUserDir(); +  #ifdef _WIN32  	mkdir(gameName);  #else @@ -542,11 +538,13 @@ bool initSludge(char *filename) {  	// There's no startup window on Linux and respecting this  	// option from the ini file would disable commandline options.  #if defined __unix__ && !(defined __APPLE__) -	if (! showSetupWindow()) return 0; +#if 0 +	if (!showSetupWindow()) return 0; +#endif  	saveIniFile(filename);  #else -	if (! gameSettings.noStartWindow) { -		if (! showSetupWindow()) return 0; +	if (!gameSettings.noStartWindow) { +		if (!showSetupWindow()) return 0;  		saveIniFile(filename);  	}  #endif @@ -571,7 +569,7 @@ bool initSludge(char *filename) {  	}  	positionStatus(10, winHeight - 15); -#endif +  	return true;  } @@ -740,16 +738,16 @@ void pauseFunction(loadedFunction *fun) {  	loadedFunction * * huntAndDestroy = & allRunningFunctions;  	while (* huntAndDestroy) {  		if (fun == * huntAndDestroy) { -			(* huntAndDestroy) = (* huntAndDestroy) -> next; +			(* huntAndDestroy) = (* huntAndDestroy)->next;  			fun->next = NULL;  		} else { -			huntAndDestroy = & (* huntAndDestroy) -> next; +			huntAndDestroy = & (* huntAndDestroy)->next;  		}  	}  }  void restartFunction(loadedFunction *fun) { -	fun -> next = allRunningFunctions; +	fun->next = allRunningFunctions;  	allRunningFunctions = fun;  } @@ -757,11 +755,11 @@ void killSpeechTimers() {  	loadedFunction *thisFunction = allRunningFunctions;  	while (thisFunction) { -		if (thisFunction -> freezerLevel == 0 && thisFunction -> isSpeech && thisFunction -> timeLeft) { -			thisFunction -> timeLeft = 0; -			thisFunction -> isSpeech = false; +		if (thisFunction->freezerLevel == 0 && thisFunction->isSpeech && thisFunction->timeLeft) { +			thisFunction->timeLeft = 0; +			thisFunction->isSpeech = false;  		} -		thisFunction = thisFunction -> next; +		thisFunction = thisFunction->next;  	}  	killAllSpeech(); @@ -771,8 +769,8 @@ void completeTimers() {  	loadedFunction *thisFunction = allRunningFunctions;  	while (thisFunction) { -		if (thisFunction -> freezerLevel == 0) thisFunction -> timeLeft = 0; -		thisFunction = thisFunction -> next; +		if (thisFunction->freezerLevel == 0) thisFunction->timeLeft = 0; +		thisFunction = thisFunction->next;  	}  } @@ -780,11 +778,11 @@ void finishFunction(loadedFunction *fun) {  	int a;  	pauseFunction(fun); -	if (fun -> stack) fatal(ERROR_NON_EMPTY_STACK); -	delete fun -> compiledLines; -	for (a = 0; a < fun -> numLocals; a ++) unlinkVar(fun -> localVars[a]); -	delete fun -> localVars; -	unlinkVar(fun -> reg); +	if (fun->stack) fatal(ERROR_NON_EMPTY_STACK); +	delete fun->compiledLines; +	for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]); +	delete fun->localVars; +	unlinkVar(fun->reg);  	delete fun;  	fun = NULL;  } @@ -793,12 +791,12 @@ void abortFunction(loadedFunction *fun) {  	int a;  	pauseFunction(fun); -	while (fun -> stack) trimStack(fun -> stack); -	delete fun -> compiledLines; -	for (a = 0; a < fun -> numLocals; a ++) unlinkVar(fun -> localVars[a]); -	delete fun -> localVars; -	unlinkVar(fun -> reg); -	if (fun -> calledBy) abortFunction(fun -> calledBy); +	while (fun->stack) trimStack(fun->stack); +	delete fun->compiledLines; +	for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]); +	delete fun->localVars; +	unlinkVar(fun->reg); +	if (fun->calledBy) abortFunction(fun->calledBy);  	delete fun;  	fun = NULL;  } @@ -809,12 +807,12 @@ int cancelAFunction(int funcNum, loadedFunction *myself, bool &killedMyself) {  	loadedFunction *fun = allRunningFunctions;  	while (fun) { -		if (fun -> originalNumber == funcNum) { -			fun -> cancelMe = true; +		if (fun->originalNumber == funcNum) { +			fun->cancelMe = true;  			n ++;  			if (fun == myself) killedMyself = true;  		} -		fun = fun -> next; +		fun = fun->next;  	}  	return n;  } @@ -823,12 +821,12 @@ void freezeSubs() {  	loadedFunction *thisFunction = allRunningFunctions;  	while (thisFunction) { -		if (thisFunction -> unfreezable) { +		if (thisFunction->unfreezable) {  			//msgBox ("SLUDGE debugging bollocks!", "Trying to freeze an unfreezable function!");  		} else { -			thisFunction -> freezerLevel ++; +			thisFunction->freezerLevel ++;  		} -		thisFunction = thisFunction -> next; +		thisFunction = thisFunction->next;  	}  } @@ -836,8 +834,8 @@ void unfreezeSubs() {  	loadedFunction *thisFunction = allRunningFunctions;  	while (thisFunction) { -		if (thisFunction -> freezerLevel) thisFunction -> freezerLevel --; -		thisFunction = thisFunction -> next; +		if (thisFunction->freezerLevel) thisFunction->freezerLevel --; +		thisFunction = thisFunction->next;  	}  } @@ -848,25 +846,25 @@ bool continueFunction(loadedFunction *fun) {  	unsigned int param;  	sludgeCommand com; -	if (fun -> cancelMe) { +	if (fun->cancelMe) {  		abortFunction(fun);  		return true;  	} -//	if (numBIFNames) newDebug ("*** Function:", allUserFunc[fun -> originalNumber]); +//	if (numBIFNames) newDebug ("*** Function:", allUserFunc[fun->originalNumber]);  	//debugOut ("SLUDGER: continueFunction\n");  	while (keepLooping) {  		advanceNow = true; -		param = fun -> compiledLines[fun -> runThisLine].param; -		com = fun -> compiledLines[fun -> runThisLine].theCommand; +		param = fun->compiledLines[fun->runThisLine].param; +		com = fun->compiledLines[fun->runThisLine].theCommand;  //		fprintf (stderr, "com: %d param: %d (%s)\n", com, param,  //				(com < numSludgeCommands) ? sludgeText[com] : ERROR_UNKNOWN_MCODE); fflush(stderr);  		if (numBIFNames) {  			setFatalInfo( -			    (fun -> originalNumber < numUserFunc) ? allUserFunc[fun -> originalNumber] : "Unknown user function", +			    (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",  			    (com < numSludgeCommands) ? sludgeText[com] : ERROR_UNKNOWN_MCODE);  //			newDebug (  //				(com < numSludgeCommands) ? sludgeText[com] : "Unknown SLUDGE machine code", @@ -877,9 +875,9 @@ bool continueFunction(loadedFunction *fun) {  		switch (com) {  		case SLU_RETURN: -			if (fun -> calledBy) { -				loadedFunction *returnTo = fun -> calledBy; -				if (fun -> returnSomething) copyVariable(fun -> reg, returnTo -> reg); +			if (fun->calledBy) { +				loadedFunction *returnTo = fun->calledBy; +				if (fun->returnSomething) copyVariable(fun->reg, returnTo->reg);  				finishFunction(fun);  				fun = returnTo;  				restartFunction(fun); @@ -891,20 +889,21 @@ bool continueFunction(loadedFunction *fun) {  			break;  		case SLU_CALLIT: -			switch (fun -> reg.varType) { +			switch (fun->reg.varType) {  			case SVT_FUNC:  				pauseFunction(fun);  				if (numBIFNames) setFatalInfo( -					    (fun -> originalNumber < numUserFunc) ? allUserFunc[fun -> originalNumber] : "Unknown user function", -					    (fun -> reg.varData.intValue < numUserFunc) ? allUserFunc[fun -> reg.varData.intValue] : "Unknown user function"); +					    (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function", +					    (fun->reg.varData.intValue < numUserFunc) ? allUserFunc[fun->reg.varData.intValue] : "Unknown user function"); -				if (! startNewFunctionNum(fun -> reg.varData.intValue, param, fun, fun -> stack)) return false; +				if (!startNewFunctionNum(fun->reg.varData.intValue, param, fun, fun->stack)) return false;  				fun = allRunningFunctions;  				advanceNow = false;     // So we don't do anything else with "fun"  				break;  			case SVT_BUILT: { -				builtReturn br = callBuiltIn(fun -> reg.varData.intValue, param, fun); +				debug(kSludgeDebugStackMachine, "Built-in init value: %i", fun->reg.varData.intValue); +				builtReturn br = callBuiltIn(fun->reg.varData.intValue, param, fun);  				switch (br) {  				case BR_ERROR: @@ -924,13 +923,13 @@ bool continueFunction(loadedFunction *fun) {  					break;  				case BR_CALLAFUNC: { -					int i = fun -> reg.varData.intValue; -					setVariable(fun -> reg, SVT_INT, 1); +					int i = fun->reg.varData.intValue; +					setVariable(fun->reg, SVT_INT, 1);  					pauseFunction(fun);  					if (numBIFNames) setFatalInfo( -						    (fun -> originalNumber < numUserFunc) ? allUserFunc[fun -> originalNumber] : "Unknown user function", +						    (fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",  						    (i < numUserFunc) ? allUserFunc[i] : "Unknown user function"); -					if (! startNewFunctionNum(i, 0, fun, noStack, false)) return false; +					if (!startNewFunctionNum(i, 0, fun, noStack, false)) return false;  					fun = allRunningFunctions;  					advanceNow = false;     // So we don't do anything else with "fun"  				} @@ -950,41 +949,41 @@ bool continueFunction(loadedFunction *fun) {  		// These all grab things and shove 'em into the register  		case SLU_LOAD_NULL: -			setVariable(fun -> reg, SVT_NULL, 0); +			setVariable(fun->reg, SVT_NULL, 0);  			break;  		case SLU_LOAD_FILE: -			setVariable(fun -> reg, SVT_FILE, param); +			setVariable(fun->reg, SVT_FILE, param);  			break;  		case SLU_LOAD_VALUE: -			setVariable(fun -> reg, SVT_INT, param); +			setVariable(fun->reg, SVT_INT, param);  			break;  		case SLU_LOAD_LOCAL: -			if (! copyVariable(fun -> localVars[param], fun -> reg)) return false; +			if (!copyVariable(fun->localVars[param], fun->reg)) return false;  			break;  		case SLU_AND: -			setVariable(fun -> reg, SVT_INT, getBoolean(fun -> reg) && getBoolean(fun -> stack -> thisVar)); -			trimStack(fun -> stack); +			setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) && getBoolean(fun->stack->thisVar)); +			trimStack(fun->stack);  			break;  		case SLU_OR: -			setVariable(fun -> reg, SVT_INT, getBoolean(fun -> reg) || getBoolean(fun -> stack -> thisVar)); -			trimStack(fun -> stack); +			setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) || getBoolean(fun->stack->thisVar)); +			trimStack(fun->stack);  			break;  		case SLU_LOAD_FUNC: -			setVariable(fun -> reg, SVT_FUNC, param); +			setVariable(fun->reg, SVT_FUNC, param);  			break;  		case SLU_LOAD_BUILT: -			setVariable(fun -> reg, SVT_BUILT, param); +			setVariable(fun->reg, SVT_BUILT, param);  			break;  		case SLU_LOAD_OBJTYPE: -			setVariable(fun -> reg, SVT_OBJTYPE, param); +			setVariable(fun->reg, SVT_OBJTYPE, param);  			break;  		case SLU_UNREG: @@ -992,7 +991,7 @@ bool continueFunction(loadedFunction *fun) {  			break;  		case SLU_LOAD_STRING: -			if (! loadStringToVar(fun -> reg, param)) { +			if (!loadStringToVar(fun->reg, param)) {  				return false;  			}  			break; @@ -1000,11 +999,11 @@ bool continueFunction(loadedFunction *fun) {  		case SLU_INDEXGET:  		case SLU_INCREMENT_INDEX:  		case SLU_DECREMENT_INDEX: -			switch (fun -> stack -> thisVar.varType) { +			switch (fun->stack->thisVar.varType) {  			case SVT_NULL:  				if (com == SLU_INDEXGET) { -					setVariable(fun -> reg, SVT_NULL, 0); -					trimStack(fun -> stack); +					setVariable(fun->reg, SVT_NULL, 0); +					trimStack(fun->stack);  				} else {  					return fatal(ERROR_INCDEC_UNKNOWN);  				} @@ -1012,37 +1011,37 @@ bool continueFunction(loadedFunction *fun) {  			case SVT_FASTARRAY:  			case SVT_STACK: -				if (fun -> stack -> thisVar.varData.theStack -> first == NULL) { +				if (fun->stack->thisVar.varData.theStack->first == NULL) {  					return fatal(ERROR_INDEX_EMPTY);  				} else {  					int ii; -					if (! getValueType(ii, SVT_INT, fun -> reg)) return false; -					variable *grab = (fun -> stack -> thisVar.varType == SVT_FASTARRAY) ? -					                 fastArrayGetByIndex(fun -> stack -> thisVar.varData.fastArray, ii) +					if (!getValueType(ii, SVT_INT, fun->reg)) return false; +					variable *grab = (fun->stack->thisVar.varType == SVT_FASTARRAY) ? +					                 fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii)  					                 : -					                 stackGetByIndex(fun -> stack -> thisVar.varData.theStack -> first, ii); +					                 stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii); -					trimStack(fun -> stack); +					trimStack(fun->stack); -					if (! grab) { -						setVariable(fun -> reg, SVT_NULL, 0); +					if (!grab) { +						setVariable(fun->reg, SVT_NULL, 0);  					} else {  						int ii;  						switch (com) {  						case SLU_INCREMENT_INDEX: -							if (! getValueType(ii, SVT_INT, * grab)) return false; -							setVariable(fun -> reg, SVT_INT, ii); -							grab -> varData.intValue = ii + 1; +							if (!getValueType(ii, SVT_INT, * grab)) return false; +							setVariable(fun->reg, SVT_INT, ii); +							grab->varData.intValue = ii + 1;  							break;  						case SLU_DECREMENT_INDEX: -							if (! getValueType(ii, SVT_INT, * grab)) return false; -							setVariable(fun -> reg, SVT_INT, ii); -							grab -> varData.intValue = ii - 1; +							if (!getValueType(ii, SVT_INT, * grab)) return false; +							setVariable(fun->reg, SVT_INT, ii); +							grab->varData.intValue = ii - 1;  							break;  						default: -							if (! copyVariable(* grab, fun -> reg)) return false; +							if (!copyVariable(* grab, fun->reg)) return false;  						}  					}  				} @@ -1054,29 +1053,29 @@ bool continueFunction(loadedFunction *fun) {  			break;  		case SLU_INDEXSET: -			switch (fun -> stack -> thisVar.varType) { +			switch (fun->stack->thisVar.varType) {  			case SVT_STACK: -				if (fun -> stack -> thisVar.varData.theStack -> first == NULL) { +				if (fun->stack->thisVar.varData.theStack->first == NULL) {  					return fatal(ERROR_INDEX_EMPTY);  				} else {  					int ii; -					if (! getValueType(ii, SVT_INT, fun -> reg)) return false; -					if (! stackSetByIndex(fun -> stack -> thisVar.varData.theStack -> first, ii, fun -> stack -> next -> thisVar)) { +					if (!getValueType(ii, SVT_INT, fun->reg)) return false; +					if (!stackSetByIndex(fun->stack->thisVar.varData.theStack->first, ii, fun->stack->next->thisVar)) {  						return false;  					} -					trimStack(fun -> stack); -					trimStack(fun -> stack); +					trimStack(fun->stack); +					trimStack(fun->stack);  				}  				break;  			case SVT_FASTARRAY: {  				int ii; -				if (! getValueType(ii, SVT_INT, fun -> reg)) return false; -				variable *v = fastArrayGetByIndex(fun -> stack -> thisVar.varData.fastArray, ii); +				if (!getValueType(ii, SVT_INT, fun->reg)) return false; +				variable *v = fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii);  				if (v == NULL) return fatal("Not within bounds of fast array."); -				if (! copyVariable(fun -> stack -> next -> thisVar, * v)) return false; -				trimStack(fun -> stack); -				trimStack(fun -> stack); +				if (!copyVariable(fun->stack->next->thisVar, * v)) return false; +				trimStack(fun->stack); +				trimStack(fun->stack);  			}  			break; @@ -1090,81 +1089,81 @@ bool continueFunction(loadedFunction *fun) {  		case SLU_INCREMENT_LOCAL: {  			int ii; -			if (! getValueType(ii, SVT_INT, fun -> localVars[param])) return false; -			setVariable(fun -> reg, SVT_INT, ii); -			setVariable(fun -> localVars[param], SVT_INT, ii + 1); +			if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false; +			setVariable(fun->reg, SVT_INT, ii); +			setVariable(fun->localVars[param], SVT_INT, ii + 1);  		}  		break;  		case SLU_INCREMENT_GLOBAL: {  			int ii; -			if (! getValueType(ii, SVT_INT, globalVars[param])) return false; -			setVariable(fun -> reg, SVT_INT, ii); +			if (!getValueType(ii, SVT_INT, globalVars[param])) return false; +			setVariable(fun->reg, SVT_INT, ii);  			setVariable(globalVars[param], SVT_INT, ii + 1);  		}  		break;  		case SLU_DECREMENT_LOCAL: {  			int ii; -			if (! getValueType(ii, SVT_INT, fun -> localVars[param])) return false; -			setVariable(fun -> reg, SVT_INT, ii); -			setVariable(fun -> localVars[param], SVT_INT, ii - 1); +			if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false; +			setVariable(fun->reg, SVT_INT, ii); +			setVariable(fun->localVars[param], SVT_INT, ii - 1);  		}  		break;  		case SLU_DECREMENT_GLOBAL: {  			int ii; -			if (! getValueType(ii, SVT_INT, globalVars[param])) return false; -			setVariable(fun -> reg, SVT_INT, ii); +			if (!getValueType(ii, SVT_INT, globalVars[param])) return false; +			setVariable(fun->reg, SVT_INT, ii);  			setVariable(globalVars[param], SVT_INT, ii - 1);  		}  		break;  		case SLU_SET_LOCAL: -			if (! copyVariable(fun -> reg, fun -> localVars[param])) return false; +			if (!copyVariable(fun->reg, fun->localVars[param])) return false;  			break;  		case SLU_SET_GLOBAL:  //			newDebug ("  Copying TO global variable", param);  //			newDebug ("  Global type at the moment", globalVars[param].varType); -			if (! copyVariable(fun -> reg, globalVars[param])) return false; +			if (!copyVariable(fun->reg, globalVars[param])) return false;  //			newDebug ("  New type", globalVars[param].varType);  			break;  		case SLU_LOAD_GLOBAL:  //			newDebug ("  Copying FROM global variable", param);  //			newDebug ("  Global type at the moment", globalVars[param].varType); -			if (! copyVariable(globalVars[param], fun -> reg)) return false; +			if (!copyVariable(globalVars[param], fun->reg)) return false;  			break;  		case SLU_STACK_PUSH: -			if (! addVarToStack(fun -> reg, fun -> stack)) return false; +			if (!addVarToStack(fun->reg, fun->stack)) return false;  			break;  		case SLU_QUICK_PUSH: -			if (! addVarToStackQuick(fun -> reg, fun -> stack)) return false; +			if (!addVarToStackQuick(fun->reg, fun->stack)) return false;  			break;  		case SLU_NOT: -			setVariable(fun -> reg, SVT_INT, ! getBoolean(fun -> reg)); +			setVariable(fun->reg, SVT_INT, !getBoolean(fun->reg));  			break;  		case SLU_BR_ZERO: -			if (! getBoolean(fun -> reg)) { +			if (!getBoolean(fun->reg)) {  				advanceNow = false; -				fun -> runThisLine = param; +				fun->runThisLine = param;  			}  			break;  		case SLU_BRANCH:  			advanceNow = false; -			fun -> runThisLine = param; +			fun->runThisLine = param;  			break;  		case SLU_NEGATIVE: {  			int i; -			if (! getValueType(i, SVT_INT, fun -> reg)) return false; -			setVariable(fun -> reg, SVT_INT, -i); +			if (!getValueType(i, SVT_INT, fun->reg)) return false; +			setVariable(fun->reg, SVT_INT, -i);  		}  		break; @@ -1181,62 +1180,62 @@ bool continueFunction(loadedFunction *fun) {  		case SLU_MORETHAN:  		case SLU_LESS_EQUAL:  		case SLU_MORE_EQUAL: -			if (fun -> stack) { +			if (fun->stack) {  				int firstValue, secondValue;  				switch (com) {  				case SLU_PLUS: -					addVariablesInSecond(fun -> stack -> thisVar, fun -> reg); -					trimStack(fun -> stack); +					addVariablesInSecond(fun->stack->thisVar, fun->reg); +					trimStack(fun->stack);  					break;  				case SLU_EQUALS: -					compareVariablesInSecond(fun -> stack -> thisVar, fun -> reg); -					trimStack(fun -> stack); +					compareVariablesInSecond(fun->stack->thisVar, fun->reg); +					trimStack(fun->stack);  					break;  				case SLU_NOT_EQ: -					compareVariablesInSecond(fun -> stack -> thisVar, fun -> reg); -					trimStack(fun -> stack); -					fun -> reg.varData.intValue = ! fun -> reg.varData.intValue; +					compareVariablesInSecond(fun->stack->thisVar, fun->reg); +					trimStack(fun->stack); +					fun->reg.varData.intValue = !fun->reg.varData.intValue;  					break;  				default: -					if (! getValueType(firstValue, SVT_INT, fun -> stack -> thisVar)) return false; -					if (! getValueType(secondValue, SVT_INT, fun -> reg)) return false; -					trimStack(fun -> stack); +					if (!getValueType(firstValue, SVT_INT, fun->stack->thisVar)) return false; +					if (!getValueType(secondValue, SVT_INT, fun->reg)) return false; +					trimStack(fun->stack);  					switch (com) {  					case SLU_MULT: -						setVariable(fun -> reg, SVT_INT, firstValue * secondValue); +						setVariable(fun->reg, SVT_INT, firstValue * secondValue);  						break;  					case SLU_MINUS: -						setVariable(fun -> reg, SVT_INT, firstValue - secondValue); +						setVariable(fun->reg, SVT_INT, firstValue - secondValue);  						break;  					case SLU_MODULUS: -						setVariable(fun -> reg, SVT_INT, firstValue % secondValue); +						setVariable(fun->reg, SVT_INT, firstValue % secondValue);  						break;  					case SLU_DIVIDE: -						setVariable(fun -> reg, SVT_INT, firstValue / secondValue); +						setVariable(fun->reg, SVT_INT, firstValue / secondValue);  						break;  					case SLU_LESSTHAN: -						setVariable(fun -> reg, SVT_INT, firstValue < secondValue); +						setVariable(fun->reg, SVT_INT, firstValue < secondValue);  						break;  					case SLU_MORETHAN: -						setVariable(fun -> reg, SVT_INT, firstValue > secondValue); +						setVariable(fun->reg, SVT_INT, firstValue > secondValue);  						break;  					case SLU_LESS_EQUAL: -						setVariable(fun -> reg, SVT_INT, firstValue <= secondValue); +						setVariable(fun->reg, SVT_INT, firstValue <= secondValue);  						break;  					case SLU_MORE_EQUAL: -						setVariable(fun -> reg, SVT_INT, firstValue >= secondValue); +						setVariable(fun->reg, SVT_INT, firstValue >= secondValue);  						break;  					default: @@ -1252,7 +1251,7 @@ bool continueFunction(loadedFunction *fun) {  			return fatal(ERROR_UNKNOWN_CODE);  		} -		if (advanceNow) fun -> runThisLine ++; +		if (advanceNow) fun->runThisLine ++;  	}  	return true; @@ -1265,22 +1264,22 @@ bool runSludge() {  	loadedFunction *nextFunction;  	while (thisFunction) { -		nextFunction = thisFunction -> next; +		nextFunction = thisFunction->next; -		if (! thisFunction -> freezerLevel) { -			if (thisFunction -> timeLeft) { -				if (thisFunction -> timeLeft < 0) { -					if (! stillPlayingSound(findInSoundCache(speech -> lastFile))) { -						thisFunction -> timeLeft = 0; +		if (!thisFunction->freezerLevel) { +			if (thisFunction->timeLeft) { +				if (thisFunction->timeLeft < 0) { +					if (!stillPlayingSound(findInSoundCache(speech->lastFile))) { +						thisFunction->timeLeft = 0;  					} -				} else if (! -- (thisFunction -> timeLeft)) { +				} else if (!-- (thisFunction->timeLeft)) {  				}  			} else { -				if (thisFunction -> isSpeech) { -					thisFunction -> isSpeech = false; +				if (thisFunction->isSpeech) { +					thisFunction->isSpeech = false;  					killAllSpeech();  				} -				if (! continueFunction(thisFunction)) +				if (!continueFunction(thisFunction))  					return false;  			}  		} @@ -1291,9 +1290,9 @@ bool runSludge() {  	if (loadNow) {  		if (loadNow[0] == ':') {  			saveGame(loadNow + 1); -			setVariable(saverFunc -> reg, SVT_INT, 1); +			setVariable(saverFunc->reg, SVT_INT, 1);  		} else { -			if (! loadGame(loadNow)) return false; +			if (!loadGame(loadNow)) return false;  		}  		delete loadNow;  		loadNow = NULL; @@ -1303,38 +1302,37 @@ bool runSludge() {  }  bool loadFunctionCode(loadedFunction *newFunc) { -#if ALLOW_FILE -	printf("\nCurrent address: %li\n", ftell(bigDataFile)); + +	debug(kSludgeDebugDataLoad, "Current address: %i", bigDataFile->pos());  	unsigned int numLines, numLinesRead; -	if (! openSubSlice(newFunc -> originalNumber)) return false; +	if (!openSubSlice(newFunc->originalNumber)) return false; -	printf("Load function code\n"); +	debug(kSludgeDebugDataLoad, "Load function code"); -	newFunc -> unfreezable  = fgetc(bigDataFile); +	newFunc->unfreezable  = getch(bigDataFile);  	numLines                = get2bytes(bigDataFile); -	printf("numLines: %i\n", numLines); -	newFunc -> numArgs      = get2bytes(bigDataFile); -	printf("numArgs: %i\n", newFunc -> numArgs); -	newFunc -> numLocals    = get2bytes(bigDataFile); -	printf("numLocals: %i\n", newFunc -> numLocals); -	newFunc -> compiledLines = new lineOfCode[numLines]; -	if (! checkNew(newFunc -> compiledLines)) return false; +	debug(kSludgeDebugDataLoad, "numLines: %i", numLines); +	newFunc->numArgs      = get2bytes(bigDataFile); +	debug(kSludgeDebugDataLoad, "numArgs: %i", newFunc->numArgs); +	newFunc->numLocals    = get2bytes(bigDataFile); +	debug(kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals); +	newFunc->compiledLines = new lineOfCode[numLines]; +	if (!checkNew(newFunc->compiledLines)) return false;  	for (numLinesRead = 0; numLinesRead < numLines; numLinesRead ++) { -		newFunc -> compiledLines[numLinesRead].theCommand = (sludgeCommand) fgetc(bigDataFile); -		newFunc -> compiledLines[numLinesRead].param = get2bytes(bigDataFile); -		printf("command line %i: %i\n", numLinesRead, newFunc->compiledLines[numLinesRead].theCommand); +		newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(bigDataFile); +		newFunc->compiledLines[numLinesRead].param = get2bytes(bigDataFile); +		debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead, newFunc->compiledLines[numLinesRead].theCommand);  	}  	finishAccess();  	// Now we need to reserve memory for the local variables -	newFunc -> localVars = new variable[newFunc -> numLocals]; -	if (! checkNew(newFunc -> localVars)) return false; -	for (int a = 0; a < newFunc -> numLocals; a ++) { -		initVarNew(newFunc -> localVars[a]); +	newFunc->localVars = new variable[newFunc->numLocals]; +	if (!checkNew(newFunc->localVars)) return false; +	for (int a = 0; a < newFunc->numLocals; a ++) { +		initVarNew(newFunc->localVars[a]);  	} -#endif  	return true;  } @@ -1342,31 +1340,31 @@ bool loadFunctionCode(loadedFunction *newFunc) {  int startNewFunctionNum(unsigned int funcNum, unsigned int numParamsExpected, loadedFunction *calledBy, variableStack *&vStack, bool returnSommet) {  	loadedFunction *newFunc = new loadedFunction;  	checkNew(newFunc); -	newFunc -> originalNumber = funcNum; +	newFunc->originalNumber = funcNum;  	loadFunctionCode(newFunc); -	if (newFunc -> numArgs != (int)numParamsExpected) return fatal("Wrong number of parameters!"); -	if (newFunc -> numArgs > newFunc -> numLocals) return fatal("More arguments than local variable space!"); +	if (newFunc->numArgs != (int)numParamsExpected) return fatal("Wrong number of parameters!"); +	if (newFunc->numArgs > newFunc->numLocals) return fatal("More arguments than local variable space!");  	// Now, lets copy the parameters from the calling function's stack...  	while (numParamsExpected) {  		numParamsExpected --; -		if (vStack == NULL) return fatal("Corrupted file! The stack's empty and there were still parameters expected"); -		copyVariable(vStack -> thisVar, newFunc -> localVars[numParamsExpected]); +		if (vStack == NULL) return fatal("Corrupted file!The stack's empty and there were still parameters expected"); +		copyVariable(vStack->thisVar, newFunc->localVars[numParamsExpected]);  		trimStack(vStack);  	} -	newFunc -> cancelMe = false; -	newFunc -> timeLeft = 0; -	newFunc -> returnSomething = returnSommet; -	newFunc -> calledBy = calledBy; -	newFunc -> stack = NULL; -	newFunc -> freezerLevel = 0; -	newFunc -> runThisLine = 0; -	newFunc -> isSpeech = 0; -	initVarNew(newFunc -> reg); +	newFunc->cancelMe = false; +	newFunc->timeLeft = 0; +	newFunc->returnSomething = returnSommet; +	newFunc->calledBy = calledBy; +	newFunc->stack = NULL; +	newFunc->freezerLevel = 0; +	newFunc->runThisLine = 0; +	newFunc->isSpeech = 0; +	initVarNew(newFunc->reg);  	restartFunction(newFunc);  	return 1; @@ -1408,40 +1406,40 @@ bool handleInput() {  		l = 0;  	} -	if (! overRegion) getOverRegion(); +	if (!overRegion) getOverRegion();  	if (input.justMoved) { -		if (currentEvents -> moveMouseFunction) { -			if (! startNewFunctionNum(currentEvents -> moveMouseFunction, 0, NULL, noStack)) return false; +		if (currentEvents->moveMouseFunction) { +			if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL, noStack)) return false;  		}  	}  	input.justMoved = false; -	if (lastRegion != overRegion && currentEvents -> focusFunction) { +	if (lastRegion != overRegion && currentEvents->focusFunction) {  		variableStack *tempStack = new variableStack; -		if (! checkNew(tempStack)) return false; +		if (!checkNew(tempStack)) return false; -		initVarNew(tempStack -> thisVar); +		initVarNew(tempStack->thisVar);  		if (overRegion) { -			setVariable(tempStack -> thisVar, SVT_OBJTYPE, overRegion -> thisType -> objectNum); +			setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum);  		} else { -			setVariable(tempStack -> thisVar, SVT_INT, 0); +			setVariable(tempStack->thisVar, SVT_INT, 0);  		} -		tempStack -> next = NULL; -		if (! startNewFunctionNum(currentEvents -> focusFunction, 1, NULL, tempStack)) return false; +		tempStack->next = NULL; +		if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL, tempStack)) return false;  	} -	if (input.leftRelease && currentEvents -> leftMouseUpFunction)  { -		if (! startNewFunctionNum(currentEvents -> leftMouseUpFunction, 0, NULL, noStack)) return false; +	if (input.leftRelease && currentEvents->leftMouseUpFunction)  { +		if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL, noStack)) return false;  	} -	if (input.rightRelease && currentEvents -> rightMouseUpFunction) { -		if (! startNewFunctionNum(currentEvents -> rightMouseUpFunction, 0, NULL, noStack)) return false; +	if (input.rightRelease && currentEvents->rightMouseUpFunction) { +		if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL, noStack)) return false;  	} -	if (input.leftClick && currentEvents -> leftMouseFunction) -		if (! startNewFunctionNum(currentEvents -> leftMouseFunction, 0, NULL, noStack)) return false; -	if (input.rightClick && currentEvents -> rightMouseFunction) { -		if (! startNewFunctionNum(currentEvents -> rightMouseFunction, 0, NULL, noStack)) return false; +	if (input.leftClick && currentEvents->leftMouseFunction) +		if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL, noStack)) return false; +	if (input.rightClick && currentEvents->rightMouseFunction) { +		if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL, noStack)) return false;  	} -	if (input.keyPressed && currentEvents -> spaceFunction) { +	if (input.keyPressed && currentEvents->spaceFunction) {  		char *tempString = NULL;  		switch (input.keyPressed) {  		case 127: @@ -1551,13 +1549,13 @@ bool handleInput() {  		if (tempString) {  			variableStack *tempStack = new variableStack; -			if (! checkNew(tempStack)) return false; -			initVarNew(tempStack -> thisVar); -			makeTextVar(tempStack -> thisVar, tempString); +			if (!checkNew(tempStack)) return false; +			initVarNew(tempStack->thisVar); +			makeTextVar(tempStack->thisVar, tempString);  			delete tempString;  			tempString = NULL; -			tempStack -> next = NULL; -			if (! startNewFunctionNum(currentEvents -> spaceFunction, 1, NULL, tempStack)) return false; +			tempStack->next = NULL; +			if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL, tempStack)) return false;  		}  	}  	input.rightClick = false; diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h index ff24b24155..d67192d511 100644 --- a/engines/sludge/sludger.h +++ b/engines/sludge/sludger.h @@ -29,6 +29,8 @@  #include "csludge.h"
  #include "language.h"
 +#include "common/file.h"
 +
  namespace Sludge {
  #ifndef _WIN32
 @@ -85,15 +87,13 @@ int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *, variableSt  bool handleInput();
  void restartFunction(loadedFunction *fun);
  bool loadFunctionCode(loadedFunction *newFunc);
 -#if ALLOW_FILE
 -void loadHandlers(FILE *fp);
 -void saveHandlers(FILE *fp);
 -#endif
 +void loadHandlers(Common::SeekableReadStream *stream);
 +void saveHandlers(Common::WriteStream *stream);
 +
  void finishFunction(loadedFunction *fun);
  void abortFunction(loadedFunction *fun);
 -#if ALLOW_FILE
 -FILE *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion);
 -#endif
 +Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion);
 +
  void freezeSubs();
  void unfreezeSubs();
  void completeTimers();
 diff --git a/engines/sludge/sound.h b/engines/sludge/sound.h index 5bb3f9d3c9..1c5af969e3 100644 --- a/engines/sludge/sound.h +++ b/engines/sludge/sound.h @@ -31,6 +31,8 @@  #include "variable.h" +#include "common/file.h" +  namespace Sludge {  // Sound list stuff @@ -66,11 +68,9 @@ bool stillPlayingSound(int ch);  bool getSoundCacheStack(stackHandler *sH);  int findInSoundCache(int a); -#if ALLOW_FILE  void debugSounds(); -void loadSounds(FILE *fp); -void saveSounds(FILE *fp); -#endif +void loadSounds(Common::SeekableReadStream *stream); +void saveSounds(Common::WriteStream *stream);  unsigned int getSoundSource(int index); diff --git a/engines/sludge/sound_bass.cpp b/engines/sludge/sound_bass.cpp index 017796cb4d..6f16d66bb3 100644 --- a/engines/sludge/sound_bass.cpp +++ b/engines/sludge/sound_bass.cpp @@ -49,10 +49,10 @@ soundThing soundCache[MAX_SAMPLES];  int defVol = 128;  int defSoundVol = 255; -char *loadEntireFileToMemory(FILE *inputFile, uint32_t size) { +char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {  	char *allData = new char[size]; -	if (! allData) return NULL; -	fread(allData, size, 1, inputFile); +	if (!allData) return NULL; +	inputFile->read(allData, size);  	finishAccess();  	return allData; @@ -136,17 +136,17 @@ bool playMOD(int f, int a, int fromTrack) {  		char *memImage;  		memImage = loadEntireFileToMemory(bigDataFile, length); -		if (! memImage) return fatal(ERROR_MUSIC_MEMORY_LOW); +		if (!memImage) return fatal(ERROR_MUSIC_MEMORY_LOW);  		mod[a] = BASS_MusicLoad(true, memImage, 0, length, BASS_MUSIC_LOOP | BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);  		delete memImage; -		if (! mod[a]) { +		if (!mod[a]) {  		} else {  			setMusicVolume(a, defVol); -			if (! BASS_ChannelPlay(mod[a], true)) +			if (!BASS_ChannelPlay(mod[a], true))  				debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());  			BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER); @@ -161,7 +161,7 @@ void setMusicVolume(int a, int v) {  	int ret;  	if (soundOK && mod[a]) {  		ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL, (float) v / 256); -		if (! ret) { +		if (!ret) {  			debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode());  		}  	} @@ -215,19 +215,19 @@ int findEmptySoundSlot() {  	for (t = 0; t < MAX_SAMPLES; t ++) {  		emptySoundSlot ++;  		emptySoundSlot %= MAX_SAMPLES; -		if (! soundCache[emptySoundSlot].sample) +		if (!soundCache[emptySoundSlot].sample)  			return emptySoundSlot;  	} -	// Argh! They're all playing! Let's trash the oldest that's not looping... +	// Argh!They're all playing!Let's trash the oldest that's not looping...  	for (t = 0; t < MAX_SAMPLES; t ++) {  		emptySoundSlot ++;  		emptySoundSlot %= MAX_SAMPLES; -		if (! soundCache[emptySoundSlot].looping) return emptySoundSlot; +		if (!soundCache[emptySoundSlot].looping) return emptySoundSlot;  	} -	// Holy crap, they're all looping! What's this twat playing at? +	// Holy crap, they're all looping!What's this twat playing at?  	emptySoundSlot ++;  	emptySoundSlot %= MAX_SAMPLES; @@ -246,7 +246,7 @@ void soundWarning (char * t, int i) {  bool forceRemoveSound() {  	for (int a = 0; a < 8; a ++) { -		if (soundCache[a].fileLoaded != -1 && ! stillPlayingSound(a)) { +		if (soundCache[a].fileLoaded != -1 && !stillPlayingSound(a)) {  //			soundWarning ("Deleting silent sound", a);  			freeSound(a);  			return 1; @@ -267,7 +267,7 @@ bool forceRemoveSound() {  int cacheSound(int f) {  	setResourceForFatal(f); -	if (! soundOK) return 0; +	if (!soundOK) return 0;  	int a = findInSoundCache(f);  	if (a != -1) return a; @@ -276,7 +276,7 @@ int cacheSound(int f) {  	freeSound(a);  	uint32_t length = openFileFromNum(f); -	if (! length) return -1; +	if (!length) return -1;  	char *memImage; @@ -286,7 +286,7 @@ int cacheSound(int f) {  		memImage = loadEntireFileToMemory(bigDataFile, length);  		tryAgain = memImage == NULL;  		if (tryAgain) { -			if (! forceRemoveSound()) { +			if (!forceRemoveSound()) {  				fatal(ERROR_SOUND_MEMORY_LOW);  				return -1;  			} @@ -347,32 +347,32 @@ void debugSounds () {  }  // */ -void saveSounds(FILE *fp) { +void saveSounds(Common::WriteStream *stream) {  	if (soundOK) {  		for (int i = 0; i < MAX_SAMPLES; i ++) {  			if (soundCache[i].looping) { -				fputc(1, fp); -				put2bytes(soundCache[i].fileLoaded, fp); -				put2bytes(soundCache[i].vol, fp); +				putch(1, stream); +				put2bytes(soundCache[i].fileLoaded, stream); +				put2bytes(soundCache[i].vol, stream);  			}  		}  	} -	fputc(0, fp); -	put2bytes(defSoundVol, fp); -	put2bytes(defVol, fp); +	putch(0, stream); +	put2bytes(defSoundVol, stream); +	put2bytes(defVol, stream);  } -void loadSounds(FILE *fp) { +void loadSounds(Common::SeekableReadStream *stream) {  	for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i); -	while (fgetc(fp)) { -		int fileLoaded = get2bytes(fp); -		defSoundVol = get2bytes(fp); +	while (getch(stream)) { +		int fileLoaded = get2bytes(stream); +		defSoundVol = get2bytes(stream);  		startSound(fileLoaded, 1);  	} -	defSoundVol = get2bytes(fp); -	defVol = get2bytes(fp); +	defSoundVol = get2bytes(stream); +	defVol = get2bytes(stream);  }  bool getSoundCacheStack(stackHandler *sH) { @@ -382,7 +382,7 @@ bool getSoundCacheStack(stackHandler *sH) {  	for (int a = 0; a < MAX_SAMPLES; a ++) {  		if (soundCache[a].fileLoaded != -1) {  			setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded); -			if (! addVarToStackQuick(newFileHandle, sH -> first)) return false; +			if (!addVarToStackQuick(newFileHandle, sH -> first)) return false;  			if (sH -> last == NULL) sH -> last = sH -> first;  		}  	} diff --git a/engines/sludge/sound_nosound.cpp b/engines/sludge/sound_nosound.cpp index 8f8bb283ea..292148b1fe 100644 --- a/engines/sludge/sound_nosound.cpp +++ b/engines/sludge/sound_nosound.cpp @@ -112,23 +112,22 @@ bool startSound(int f, bool loopy) {  	return true;
  }
 -#if ALLOW_FILE
 -void saveSounds(FILE *fp) {
 -	fputc(0, fp);
 -	put2bytes(defSoundVol, fp);
 -	put2bytes(defVol, fp);
 +void saveSounds(Common::WriteStream *stream) {
 +	putch(0, stream);
 +	put2bytes(defSoundVol, stream);
 +	put2bytes(defVol, stream);
  }
 -void loadSounds(FILE *fp) {
 -	while (fgetc(fp)) {
 -		get2bytes(fp);
 -		get2bytes(fp);
 +void loadSounds(Common::SeekableReadStream *stream) {
 +	while (getch(stream)) {
 +		get2bytes(stream);
 +		get2bytes(stream);
  	}
 -	defSoundVol = get2bytes(fp);
 -	defVol = get2bytes(fp);
 +	defSoundVol = get2bytes(stream);
 +	defVol = get2bytes(stream);
  }
 -#endif
 +
  bool getSoundCacheStack(stackHandler *sH) {
  //#pragma unused (sH)
  	return true;
 diff --git a/engines/sludge/sound_openal.cpp b/engines/sludge/sound_openal.cpp index aa8f8e1325..5faefdb9cc 100644 --- a/engines/sludge/sound_openal.cpp +++ b/engines/sludge/sound_openal.cpp @@ -33,6 +33,8 @@  #include "moreio.h"  #include "fileset.h" +#include "common/file.h" +  #define MAX_SAMPLES 8  #define MAX_MODS 3  #define NUM_BUFS 3 @@ -359,13 +361,12 @@ void playStream(int a, bool isMOD, bool loopy) {  #endif  } -#if ALLOW_FILE -char *loadEntireFileToMemory(FILE *inputFile, uint32_t size) { +char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {  	char *allData = new char[size];  	if (! allData) return NULL; -	size_t bytes_read = fread(allData, size, 1, inputFile); -	if (bytes_read != size && ferror(inputFile)) { +	size_t bytes_read = inputFile->read(allData, size); +	if (bytes_read != size && inputFile->err()) {  		debugOut("Reading error in loadEntireFileToMemory.\n");  	} @@ -373,10 +374,8 @@ char *loadEntireFileToMemory(FILE *inputFile, uint32_t size) {  	return allData;  } -#endif  bool playMOD(int f, int a, int fromTrack) { -#if ALLOW_FILE  	if (! soundOK) return true;  	stopMOD(a); @@ -387,7 +386,6 @@ bool playMOD(int f, int a, int fromTrack) {  		setResourceForFatal(-1);  		return false;  	} -#endif  #if 0  	unsigned char *memImage;  	memImage = (unsigned char *) loadEntireFileToMemory(bigDataFile, length); @@ -592,35 +590,33 @@ bool startSound(int f, bool loopy) {  	return true;  } -#if ALLOW_FILE -void saveSounds(FILE *fp) { +void saveSounds(Common::WriteStream *stream) {  	if (soundOK) {  		for (int i = 0; i < MAX_SAMPLES; i ++) {  			if (soundCache[i].looping) { -				fputc(1, fp); -				put2bytes(soundCache[i].fileLoaded, fp); -				put2bytes(soundCache[i].vol, fp); +				putch(1, stream); +				put2bytes(soundCache[i].fileLoaded, stream); +				put2bytes(soundCache[i].vol, stream);  			}  		}  	} -	fputc(0, fp); -	put2bytes(defSoundVol, fp); -	put2bytes(defVol, fp); +	putch(0, stream); +	put2bytes(defSoundVol, stream); +	put2bytes(defVol, stream);  } -void loadSounds(FILE *fp) { +void loadSounds(Common::SeekableReadStream *stream) {  	for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i); -	while (fgetc(fp)) { -		int fileLoaded = get2bytes(fp); -		defSoundVol = get2bytes(fp); +	while (getch(stream)) { +		int fileLoaded = get2bytes(stream); +		defSoundVol = get2bytes(stream);  		startSound(fileLoaded, 1);  	} -	defSoundVol = get2bytes(fp); -	defVol = get2bytes(fp); +	defSoundVol = get2bytes(stream); +	defVol = get2bytes(stream);  } -#endif  bool getSoundCacheStack(stackHandler *sH) {  	variable newFileHandle; @@ -742,12 +738,12 @@ void playSoundList(soundList *s) {  #endif  } -#if ALLOW_FILE  void playMovieStream(int a) { +#if 0  	if (! soundOK) return;  	ALboolean ok;  	ALuint src; -#if 0 +  	alGenSources(1, &src);  	if (alGetError() != AL_NO_ERROR) {  		debugOut("Failed to create OpenAL source!\n"); @@ -758,22 +754,20 @@ void playMovieStream(int a) {  	ok = alurePlaySourceStream(src, soundCache[a].stream,  	                           10, 0, sound_eos_callback, &intpointers[a]); -#endif  	if (!ok) { -#if 0  		debugOut("Failed to play stream: %s\n", alureGetErrorString());  		alDeleteSources(1, &src);  		if (alGetError() != AL_NO_ERROR) {  			debugOut("Failed to delete OpenAL source!\n");  		} -#endif +  		soundCache[a].playingOnSource = 0;  	} else {  		soundCache[a].playingOnSource = src;  		soundCache[a].playing = true;  	} -}  #endif +}  #if 0  int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate, diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp index 792fe664a3..ec4144f7bf 100644 --- a/engines/sludge/sprites.cpp +++ b/engines/sludge/sprites.cpp @@ -116,7 +116,7 @@ bool reserveSpritePal(spritePalette &sP, int n) {  }  bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) { -#if ALLOW_FILE +#if 0  	int i, tex_num, total, picwidth, picheight, spriteBankVersion = 0, howmany = 0, startIndex = 0;  	int *totalwidth, * maxheight;  	int numTextures = 0; diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp index e7dc4cb4f8..d90d3a2d29 100644 --- a/engines/sludge/statusba.cpp +++ b/engines/sludge/statusba.cpp @@ -41,105 +41,105 @@ extern int fontHeight;  extern float cameraZoom;  void setLitStatus(int i) { -	nowStatus -> litStatus = i; +	nowStatus->litStatus = i;  }  void killLastStatus() { -	if (nowStatus -> firstStatusBar) { -		statusBar *kill = nowStatus -> firstStatusBar; -		nowStatus -> firstStatusBar = kill -> next; -		delete kill -> text; +	if (nowStatus->firstStatusBar) { +		statusBar *kill = nowStatus->firstStatusBar; +		nowStatus->firstStatusBar = kill->next; +		delete kill->text;  		delete kill;  	}  }  void clearStatusBar() { -	statusBar *stat = nowStatus -> firstStatusBar; +	statusBar *stat = nowStatus->firstStatusBar;  	statusBar *kill; -	nowStatus -> litStatus = -1; +	nowStatus->litStatus = -1;  	while (stat) {  		kill = stat; -		stat = stat -> next; -		delete kill -> text; +		stat = stat->next; +		delete kill->text;  		delete kill;  	} -	nowStatus -> firstStatusBar = NULL; +	nowStatus->firstStatusBar = NULL;  }  void addStatusBar() {  	statusBar *newStat = new statusBar;  	if (checkNew(newStat)) { -		newStat -> next = nowStatus -> firstStatusBar; -		newStat -> text = copyString(""); -		nowStatus -> firstStatusBar = newStat; +		newStat->next = nowStatus->firstStatusBar; +		newStat->text = copyString(""); +		nowStatus->firstStatusBar = newStat;  	}  }  void setStatusBar(char *txt) { -	if (nowStatus -> firstStatusBar) { -		delete nowStatus -> firstStatusBar -> text; -		nowStatus -> firstStatusBar -> text = copyString(txt); +	if (nowStatus->firstStatusBar) { +		delete nowStatus->firstStatusBar->text; +		nowStatus->firstStatusBar->text = copyString(txt);  	}  }  void positionStatus(int x, int y) { -	nowStatus -> statusX = x; -	nowStatus -> statusY = y; +	nowStatus->statusX = x; +	nowStatus->statusY = y;  }  void drawStatusBar() { -	int y = nowStatus -> statusY, n = 0; -	statusBar *stat = nowStatus -> firstStatusBar; +	int y = nowStatus->statusY, n = 0; +	statusBar *stat = nowStatus->firstStatusBar;  	fixFont(litVerbLinePalette);  	fixFont(verbLinePalette);  	while (stat) { -		switch (nowStatus -> alignStatus) { +		switch (nowStatus->alignStatus) {  		case IN_THE_CENTRE: -			pasteString(stat -> text, ((winWidth - stringWidth(stat -> text)) >> 1) / cameraZoom, y / cameraZoom, (n ++ == nowStatus -> litStatus) ? litVerbLinePalette : verbLinePalette); +			pasteString(stat->text, ((winWidth - stringWidth(stat->text)) >> 1) / cameraZoom, y / cameraZoom, (n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  			break;  		case 1001: -			pasteString(stat -> text, (winWidth - stringWidth(stat -> text)) - nowStatus -> statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus -> litStatus) ? litVerbLinePalette : verbLinePalette); +			pasteString(stat->text, (winWidth - stringWidth(stat->text)) - nowStatus->statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  			break;  		default: -			pasteString(stat -> text, nowStatus -> statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus -> litStatus) ? litVerbLinePalette : verbLinePalette); +			pasteString(stat->text, nowStatus->statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  		} -		stat = stat -> next; +		stat = stat->next;  		y -= fontHeight;  	}  }  void statusBarColour(byte r, byte g, byte b) {  	setFontColour(verbLinePalette, r, g, b); -	nowStatus -> statusR = r; -	nowStatus -> statusG = g; -	nowStatus -> statusB = b; +	nowStatus->statusR = r; +	nowStatus->statusG = g; +	nowStatus->statusB = b;  }  void statusBarLitColour(byte r, byte g, byte b) {  	setFontColour(litVerbLinePalette, r, g, b); -	nowStatus -> statusLR = r; -	nowStatus -> statusLG = g; -	nowStatus -> statusLB = b; +	nowStatus->statusLR = r; +	nowStatus->statusLG = g; +	nowStatus->statusLB = b;  }  statusStuff *copyStatusBarStuff(statusStuff *here) {  	// Things we want to keep -	here -> statusLR = nowStatus -> statusLR; -	here -> statusLG = nowStatus -> statusLG; -	here -> statusLB = nowStatus -> statusLB; -	here -> statusR = nowStatus -> statusR; -	here -> statusG = nowStatus -> statusG; -	here -> statusB = nowStatus -> statusB; -	here -> alignStatus = nowStatus -> alignStatus; -	here -> statusX = nowStatus -> statusX; -	here -> statusY = nowStatus -> statusY; +	here->statusLR = nowStatus->statusLR; +	here->statusLG = nowStatus->statusLG; +	here->statusLB = nowStatus->statusLB; +	here->statusR = nowStatus->statusR; +	here->statusG = nowStatus->statusG; +	here->statusB = nowStatus->statusB; +	here->alignStatus = nowStatus->alignStatus; +	here->statusX = nowStatus->statusX; +	here->statusY = nowStatus->statusY;  	// Things we want to clear -	here -> litStatus = -1; -	here -> firstStatusBar = NULL; +	here->litStatus = -1; +	here->firstStatusBar = NULL;  	statusStuff *old = nowStatus;  	nowStatus = here; @@ -149,8 +149,8 @@ statusStuff *copyStatusBarStuff(statusStuff *here) {  void restoreBarStuff(statusStuff *here) {  	delete nowStatus; -	setFontColour(verbLinePalette, here -> statusR, here -> statusG, here -> statusB); -	setFontColour(litVerbLinePalette, here -> statusLR, here -> statusLG, here -> statusLB); +	setFontColour(verbLinePalette, here->statusR, here->statusG, here->statusB); +	setFontColour(litVerbLinePalette, here->statusLR, here->statusLG, here->statusLB);  	nowStatus = here;  } @@ -166,68 +166,66 @@ void initStatusBar() {  }  const char *statusBarText() { -	if (nowStatus -> firstStatusBar) { -		return nowStatus -> firstStatusBar -> text; +	if (nowStatus->firstStatusBar) { +		return nowStatus->firstStatusBar->text;  	} else {  		return "";  	}  } -#if ALLOW_FILE -void saveStatusBars(FILE *fp) { -	statusBar *viewLine = nowStatus -> firstStatusBar; +void saveStatusBars(Common::WriteStream *stream) { +	statusBar *viewLine = nowStatus->firstStatusBar; -	put2bytes(nowStatus -> alignStatus, fp); -	putSigned(nowStatus -> litStatus, fp); -	put2bytes(nowStatus -> statusX, fp); -	put2bytes(nowStatus -> statusY, fp); +	put2bytes(nowStatus->alignStatus, stream); +	putSigned(nowStatus->litStatus, stream); +	put2bytes(nowStatus->statusX, stream); +	put2bytes(nowStatus->statusY, stream); -	fputc(nowStatus -> statusR, fp); -	fputc(nowStatus -> statusG, fp); -	fputc(nowStatus -> statusB, fp); -	fputc(nowStatus -> statusLR, fp); -	fputc(nowStatus -> statusLG, fp); -	fputc(nowStatus -> statusLB, fp); +	putch(nowStatus->statusR, stream); +	putch(nowStatus->statusG, stream); +	putch(nowStatus->statusB, stream); +	putch(nowStatus->statusLR, stream); +	putch(nowStatus->statusLG, stream); +	putch(nowStatus->statusLB, stream);  	// Write what's being said  	while (viewLine) { -		fputc(1, fp); -		writeString(viewLine -> text, fp); -		viewLine = viewLine -> next; +		putch(1, stream); +		writeString(viewLine->text, stream); +		viewLine = viewLine->next;  	} -	fputc(0, fp); +	putch(0, stream);  } -bool loadStatusBars(FILE *fp) { +bool loadStatusBars(Common::SeekableReadStream *stream) {  	clearStatusBar(); -	nowStatus -> alignStatus = get2bytes(fp); -	nowStatus -> litStatus = getSigned(fp); -	nowStatus -> statusX = get2bytes(fp); -	nowStatus -> statusY = get2bytes(fp); +	nowStatus->alignStatus = get2bytes(stream); +	nowStatus->litStatus = getSigned(stream); +	nowStatus->statusX = get2bytes(stream); +	nowStatus->statusY = get2bytes(stream); -	nowStatus -> statusR = fgetc(fp); -	nowStatus -> statusG = fgetc(fp); -	nowStatus -> statusB = fgetc(fp); -	nowStatus -> statusLR = fgetc(fp); -	nowStatus -> statusLG = fgetc(fp); -	nowStatus -> statusLB = fgetc(fp); +	nowStatus->statusR = getch(stream); +	nowStatus->statusG = getch(stream); +	nowStatus->statusB = getch(stream); +	nowStatus->statusLR = getch(stream); +	nowStatus->statusLG = getch(stream); +	nowStatus->statusLB = getch(stream); -	setFontColour(verbLinePalette, nowStatus -> statusR, nowStatus -> statusG, nowStatus -> statusB); -	setFontColour(litVerbLinePalette, nowStatus -> statusLR, nowStatus -> statusLG, nowStatus -> statusLB); +	setFontColour(verbLinePalette, nowStatus->statusR, nowStatus->statusG, nowStatus->statusB); +	setFontColour(litVerbLinePalette, nowStatus->statusLR, nowStatus->statusLG, nowStatus->statusLB);  	// Read what's being said -	statusBar * * viewLine = & (nowStatus -> firstStatusBar); +	statusBar * * viewLine = & (nowStatus->firstStatusBar);  	statusBar *newOne; -	while (fgetc(fp)) { +	while (getch(stream)) {  		newOne = new statusBar;  		if (! checkNew(newOne)) return false; -		newOne -> text = readString(fp); -		newOne -> next = NULL; +		newOne->text = readString(stream); +		newOne->next = NULL;  		(* viewLine) = newOne; -		viewLine = & (newOne -> next); +		viewLine = & (newOne->next);  	}  	return true;  } -#endif  } // End of namespace Sludge diff --git a/engines/sludge/statusba.h b/engines/sludge/statusba.h index 2f0d30adc1..03c61cfa6c 100644 --- a/engines/sludge/statusba.h +++ b/engines/sludge/statusba.h @@ -51,11 +51,9 @@ const char *statusBarText();  void positionStatus(int, int);
  void drawStatusBar();
 -#if ALLOW_FILE
  // Load and save
 -bool loadStatusBars(FILE *fp);
 -void saveStatusBars(FILE *fp);
 -#endif
 +bool loadStatusBars(Common::SeekableReadStream *stream);
 +void saveStatusBars(Common::WriteStream *stream);
  // For freezing
  void restoreBarStuff(statusStuff *here);
 diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp index b6bc864fc7..abee33c88a 100644 --- a/engines/sludge/talk.cpp +++ b/engines/sludge/talk.cpp @@ -44,32 +44,32 @@ float speechSpeed = 1;  void initSpeech() {  	speech = new speechStruct;  	if (checkNew(speech)) { -		speech -> currentTalker = NULL; -		speech -> allSpeech = NULL; -		speech -> speechY = 0; -		speech -> lastFile = -1; +		speech->currentTalker = NULL; +		speech->allSpeech = NULL; +		speech->speechY = 0; +		speech->lastFile = -1;  	}  }  void killAllSpeech() { -	if (speech -> lastFile != -1) { +	if (speech->lastFile != -1) {  #if 0 -		huntKillSound(speech -> lastFile); +		huntKillSound(speech->lastFile);  #endif -		speech -> lastFile = -1; +		speech->lastFile = -1;  	} -	if (speech -> currentTalker) { -		makeSilent(* (speech -> currentTalker)); -		speech -> currentTalker = NULL; +	if (speech->currentTalker) { +		makeSilent(* (speech->currentTalker)); +		speech->currentTalker = NULL;  	}  	speechLine *killMe; -	while (speech -> allSpeech) { -		killMe = speech -> allSpeech; -		speech -> allSpeech = speech -> allSpeech -> next; -		delete killMe -> textLine; +	while (speech->allSpeech) { +		killMe = speech->allSpeech; +		speech->allSpeech = speech->allSpeech->next; +		delete killMe->textLine;  		delete killMe;  	}  } @@ -79,7 +79,7 @@ void killAllSpeech() {  inline void setObjFontColour(objectType *t) {  #if 0 -	setFontColour(speech -> talkCol, t -> r, t -> g, t -> b); +	setFontColour(speech->talkCol, t->r, t->g, t->b);  #endif  } @@ -90,10 +90,10 @@ void addSpeechLine(char *theLine, int x, int &offset) {  	speechLine *newLine = new speechLine;  	checkNew(newLine); -	newLine -> next = speech -> allSpeech; -	newLine -> textLine = copyString(theLine); -	newLine -> x = xx1; -	speech -> allSpeech = newLine; +	newLine->next = speech->allSpeech; +	newLine->textLine = copyString(theLine); +	newLine->x = xx1; +	speech->allSpeech = newLine;  	if ((xx1 < 5) && (offset < (5 - xx1))) {  		offset = 5 - xx1;  	} else if ((xx2 >= ((float)winWidth / cameraZoom) - 5) && (offset > (((float)winWidth / cameraZoom) - 5 - xx2))) { @@ -102,7 +102,7 @@ void addSpeechLine(char *theLine, int x, int &offset) {  }  int isThereAnySpeechGoingOn() { -	return speech -> allSpeech ? speech -> lookWhosTalking : -1; +	return speech->allSpeech ? speech->lookWhosTalking : -1;  }  int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) { @@ -117,13 +117,13 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {  #if 0  			if (startSound(sampleFile, false)) {  				speechTime = -10; -				speech -> lastFile = sampleFile; +				speech->lastFile = sampleFile;  				if (speechMode == 2) return -10;  			}  #endif  		}  	} -	speech -> speechY = y; +	speech->speechY = y;  	while (strlen(theText) > wrap) {  		a = wrap; @@ -143,24 +143,24 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {  	addSpeechLine(theText, x, offset);  	y -= fontHeight / cameraZoom; -	if (y < 0) speech -> speechY -= y; -	else if (speech -> speechY > cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom) speech -> speechY = cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom; +	if (y < 0) speech->speechY -= y; +	else if (speech->speechY > cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom) speech->speechY = cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom;  	if (offset) { -		speechLine *viewLine = speech -> allSpeech; +		speechLine *viewLine = speech->allSpeech;  		while (viewLine) { -			viewLine -> x += offset; -			viewLine = viewLine -> next; +			viewLine->x += offset; +			viewLine = viewLine->next;  		}  	}  	return speechTime;  }  int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile, bool animPerson) { -	int i = wrapSpeechXY(theText, thePerson.x - cameraX, thePerson.y - cameraY - (thePerson.scale * (thePerson.height - thePerson.floaty)) - thePerson.thisType -> speechGap, thePerson.thisType -> wrapSpeech, sampleFile); +	int i = wrapSpeechXY(theText, thePerson.x - cameraX, thePerson.y - cameraY - (thePerson.scale * (thePerson.height - thePerson.floaty)) - thePerson.thisType->speechGap, thePerson.thisType->wrapSpeech, sampleFile);  	if (animPerson) {  		makeTalker(thePerson); -		speech -> currentTalker = & thePerson; +		speech->currentTalker = &thePerson;  	}  	return i;  } @@ -168,20 +168,20 @@ int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile, b  int wrapSpeech(char *theText, int objT, int sampleFile, bool animPerson) {  	int i; -	speech -> lookWhosTalking = objT; +	speech->lookWhosTalking = objT;  	onScreenPerson *thisPerson = findPerson(objT);  	if (thisPerson) { -		setObjFontColour(thisPerson -> thisType); +		setObjFontColour(thisPerson->thisType);  		i = wrapSpeechPerson(theText, * thisPerson, sampleFile, animPerson);  	} else {  		screenRegion *thisRegion = getRegionForObject(objT);  		if (thisRegion) { -			setObjFontColour(thisRegion -> thisType); -			i = wrapSpeechXY(theText, ((thisRegion -> x1 + thisRegion -> x2) >> 1) - cameraX, thisRegion -> y1 - thisRegion -> thisType -> speechGap - cameraY, thisRegion -> thisType -> wrapSpeech, sampleFile); +			setObjFontColour(thisRegion->thisType); +			i = wrapSpeechXY(theText, ((thisRegion->x1 + thisRegion->x2) >> 1) - cameraX, thisRegion->y1 - thisRegion->thisType->speechGap - cameraY, thisRegion->thisType->wrapSpeech, sampleFile);  		} else {  			objectType *temp = findObjectType(objT);  			setObjFontColour(temp); -			i = wrapSpeechXY(theText, winWidth >> 1, 10, temp -> wrapSpeech, sampleFile); +			i = wrapSpeechXY(theText, winWidth >> 1, 10, temp->wrapSpeech, sampleFile);  		}  	}  	return i; @@ -189,87 +189,89 @@ int wrapSpeech(char *theText, int objT, int sampleFile, bool animPerson) {  void viewSpeech() {  #if 0 -	int viewY = speech -> speechY; -	speechLine *viewLine = speech -> allSpeech; -	fixFont(speech -> talkCol); +	int viewY = speech->speechY; +	speechLine *viewLine = speech->allSpeech; +	fixFont(speech->talkCol);  	while (viewLine) { -		pasteString(viewLine -> textLine, viewLine -> x, viewY, speech -> talkCol); +		pasteString(viewLine->textLine, viewLine->x, viewY, speech->talkCol);  		viewY -= fontHeight / cameraZoom; -		viewLine = viewLine -> next; +		viewLine = viewLine->next;  	}  #endif  } -#if ALLOW_FILE -void saveSpeech(speechStruct *sS, FILE *fp) { -	speechLine *viewLine = sS -> allSpeech; +void saveSpeech(speechStruct *sS, Common::WriteStream *stream) { +#if 0 +	speechLine *viewLine = sS->allSpeech; -	fputc(sS -> talkCol.originalRed, fp); -	fputc(sS -> talkCol.originalGreen, fp); -	fputc(sS -> talkCol.originalBlue, fp); +	putch(sS->talkCol.originalRed, stream); +	putch(sS->talkCol.originalGreen, stream); +	putch(sS->talkCol.originalBlue, stream); -	putFloat(speechSpeed, fp); +	putFloat(speechSpeed, stream);  	// Write y co-ordinate -	put2bytes(sS -> speechY, fp); +	put2bytes(sS->speechY, stream);  	// Write which character's talking -	put2bytes(sS -> lookWhosTalking, fp); -	if (sS -> currentTalker) { -		fputc(1, fp); -		put2bytes(sS -> currentTalker -> thisType -> objectNum, fp); +	put2bytes(sS->lookWhosTalking, stream); +	if (sS->currentTalker) { +		putch(1, stream); +		put2bytes(sS->currentTalker->thisType->objectNum, stream);  	} else { -		fputc(0, fp); +		putch(0, stream);  	}  	// Write what's being said  	while (viewLine) { -		fputc(1, fp); -		writeString(viewLine -> textLine, fp); -		put2bytes(viewLine -> x, fp); -		viewLine = viewLine -> next; +		putch(1, stream); +		writeString(viewLine->textLine, stream); +		put2bytes(viewLine->x, stream); +		viewLine = viewLine->next;  	} -	fputc(0, fp); +	putch(0, stream); +#endif  } -bool loadSpeech(speechStruct *sS, FILE *fp) { -	speech -> currentTalker = NULL; +bool loadSpeech(speechStruct *sS, Common::SeekableReadStream *stream) { +#if 0 +	speech->currentTalker = NULL;  	killAllSpeech(); -	byte r = fgetc(fp); -	byte g = fgetc(fp); -	byte b = fgetc(fp); -	setFontColour(sS -> talkCol, r, g, b); +	byte r = getch(stream); +	byte g = getch(stream); +	byte b = getch(stream); +	setFontColour(sS->talkCol, r, g, b); -	speechSpeed = getFloat(fp); +	speechSpeed = getFloat(stream);  	// Read y co-ordinate -	sS -> speechY = get2bytes(fp); +	sS->speechY = get2bytes(stream);  	// Read which character's talking -	sS -> lookWhosTalking = get2bytes(fp); +	sS->lookWhosTalking = get2bytes(stream); -	if (fgetc(fp)) { -		sS -> currentTalker = findPerson(get2bytes(fp)); +	if (getch(stream)) { +		sS->currentTalker = findPerson(get2bytes(stream));  	} else { -		sS -> currentTalker = NULL; +		sS->currentTalker = NULL;  	}  	// Read what's being said -	speechLine * * viewLine = & sS -> allSpeech; +	speechLine * * viewLine = &sS->allSpeech;  	speechLine *newOne; -	speech -> lastFile = -1; -	while (fgetc(fp)) { +	speech->lastFile = -1; +	while (getch(stream)) {  		newOne = new speechLine;  		if (! checkNew(newOne)) return false; -		newOne -> textLine = readString(fp); -		newOne -> x = get2bytes(fp); -		newOne -> next = NULL; +		newOne->textLine = readString(stream); +		newOne->x = get2bytes(stream); +		newOne->next = NULL;  		(* viewLine) = newOne; -		viewLine = & (newOne -> next); +		viewLine = &(newOne->next);  	}  	return true; -}  #endif +}  } // End of namespace Sludge diff --git a/engines/sludge/talk.h b/engines/sludge/talk.h index a0fb1a9b8c..2ce4c4a72e 100644 --- a/engines/sludge/talk.h +++ b/engines/sludge/talk.h @@ -47,10 +47,8 @@ void viewSpeech();  void killAllSpeech();
  int isThereAnySpeechGoingOn();
  void initSpeech();
 -#if ALLOW_FILE
 -void saveSpeech(speechStruct *sS, FILE *fp);
 -bool loadSpeech(speechStruct *sS, FILE *fp);
 -#endif
 +void saveSpeech(speechStruct *sS, Common::WriteStream *stream);
 +bool loadSpeech(speechStruct *sS, Common::SeekableReadStream *stream);
  } // End of namespace Sludge
 diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp index 9cb471f2d6..c24946a5b1 100644 --- a/engines/sludge/thumbnail.cpp +++ b/engines/sludge/thumbnail.cpp @@ -40,8 +40,9 @@ int thumbWidth = 0, thumbHeight = 0;  extern GLuint backdropTextureName;  #endif -#if ALLOW_FILE -bool saveThumbnail(FILE *fp) { + +bool saveThumbnail(Common::WriteStream *stream) { +#if 0  	GLuint thumbnailTextureName = 0;  	put4bytes(thumbWidth, fp); @@ -136,8 +137,8 @@ bool saveThumbnail(FILE *fp) {  	}  	fputc('!', fp);  	return true; -}  #endif +}  void showThumbnail(char *filename, int atX, int atY) {  #if 0 @@ -254,15 +255,13 @@ void showThumbnail(char *filename, int atX, int atY) {  #endif  } -#if ALLOW_FILE -bool skipThumbnail(FILE *fp) { -	thumbWidth = get4bytes(fp); -	thumbHeight = get4bytes(fp); +bool skipThumbnail(Common::SeekableReadStream *stream) { +	thumbWidth = get4bytes(stream); +	thumbHeight = get4bytes(stream);  	uint32_t skippy = thumbWidth;  	skippy *= thumbHeight << 1; -	fseek(fp, skippy, 1); -	return (fgetc(fp) == '!'); +	stream->seek(skippy, 1); +	return (getch(stream) == '!');  } -#endif  } // End of namespace Sludge diff --git a/engines/sludge/thumbnail.h b/engines/sludge/thumbnail.h index 3836478a82..4452dcae13 100644 --- a/engines/sludge/thumbnail.h +++ b/engines/sludge/thumbnail.h @@ -24,10 +24,8 @@  namespace Sludge {
 -#if ALLOW_FILE
 -bool saveThumbnail(FILE *fp);
 -bool skipThumbnail(FILE *fp);
 -#endif
 +bool saveThumbnail(Common::WriteStream *stream);
 +bool skipThumbnail(Common::SeekableReadStream *stream);
  void showThumbnail(char *filename, int x, int y);
 diff --git a/engines/sludge/timing.cpp b/engines/sludge/timing.cpp index ae4c0cd102..887c4ed614 100644 --- a/engines/sludge/timing.cpp +++ b/engines/sludge/timing.cpp @@ -26,6 +26,8 @@  namespace Sludge {  int desiredfps = 300;               //holds desired frames per second + +#if 0  Uint32 starttime, endtime;  Uint32 desired_frame_time; @@ -55,5 +57,6 @@ void Wait_Frame(void) {  	starttime = endtime;  } +#endif  } // End of namespace Sludge diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp index 334beb1e84..928b65bb1a 100644 --- a/engines/sludge/variable.cpp +++ b/engines/sludge/variable.cpp @@ -29,6 +29,9 @@  #include "people.h"  #include "fileset.h" +#include "sludge.h" +#include "common/debug.h" +  #include <dirent.h>  #include "moreio.h"  #ifdef _WIN32 @@ -325,9 +328,8 @@ void makeTextVar(variable &thisVar, const char *txt) {  }  bool loadStringToVar(variable &thisVar, int value) { -#if ALLOW_FILE +  	makeTextVar(thisVar, getNumberedString(value)); -#endif  	return (bool)(thisVar.varData.theString != NULL);  } @@ -536,7 +538,7 @@ bool addVarToStack(const variable &va, variableStack *&thisStack) {  	if (! copyMain(va, newStack -> thisVar)) return false;  	newStack -> next = thisStack;  	thisStack = newStack; -	//printf("Variable %s was added to stack\n", getTextFromAnyVar(va)); +	debug(kSludgeDebugStackMachine, "Variable %s was added to stack", getTextFromAnyVar(va));  	return true;  } @@ -551,7 +553,7 @@ bool addVarToStackQuick(variable &va, variableStack *&thisStack) {  	newStack -> next = thisStack;  	thisStack = newStack; -	//printf("Variable %s was added to stack quick\n", getTextFromAnyVar(va)); +	debug(kSludgeDebugStackMachine, "Variable %s was added to stack quick", getTextFromAnyVar(va));  	return true;  } @@ -622,7 +624,7 @@ void trimStack(variableStack *&stack) {  	variableStack *killMe = stack;  	stack = stack -> next; -	//printf("Variable %s was removed from stack\n", 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); diff --git a/engines/sludge/vid.cpp b/engines/sludge/vid.cpp index 266c5bd859..13eea5263c 100644 --- a/engines/sludge/vid.cpp +++ b/engines/sludge/vid.cpp @@ -155,7 +155,7 @@ bool extractSlice(int fileNum, char *toName) {  	unsigned long fileLength = openFileFromNum(fileNum);
  	if (! fileLength) return false; // Error already displayed
 -
 +#if 0
  	FILE *copyVid = fopen(toName, "wb");
  	if (! copyVid) return fatal("Can't extract resource");
 @@ -170,6 +170,7 @@ bool extractSlice(int fileNum, char *toName) {  	}
  	fclose(copyVid);
 +#endif
  	finishAccess();
  	return true;
 diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp index ddcebb1055..f73f4f6e7e 100644 --- a/engines/sludge/zbuffer.cpp +++ b/engines/sludge/zbuffer.cpp @@ -19,8 +19,6 @@   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.   *   */ -#include "common/system.h" -  #include "allfiles.h"  #include "zbuffer.h"  #include "fileset.h" @@ -66,7 +64,7 @@ void sortZPal(int *oldpal, int *newpal, int size) {  }  bool setZBuffer(int y) { -#if ALLOW_FILE +#if 0  	int x, n;  	uint32_t stillToGo = 0;  	int yPalette[16], sorted[16], sortback[16]; | 
