From 79b3875fc48d49e61ff6ef4ae2e5a452c507d2e6 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Mon, 19 Feb 2007 14:10:44 +0000 Subject: [PATCH] This commit fixes all warnings (on my system). -Werror added for debug builds. Hopefully this will not cause too much pain, but rather increase code quality for the future. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1144 4a71c877-e1ca-e34f-864e-861f7616d084 --- configure.ac | 4 +-- lib/framework/frame.h | 2 ++ lib/framework/frameresource.c | 1 + lib/gamelib/ani.h | 2 +- lib/ivis_common/pcx.c | 4 +-- lib/ivis_opengl/piedraw.c | 6 ++-- lib/script/Makefile.am | 3 ++ lib/script/chat_lexer.l | 5 --- lib/script/chat_parser.y | 6 ---- lib/script/codeprint.c | 6 ++-- lib/script/event.c | 2 ++ lib/script/interp.c | 68 +++++++++++++++++------------------ lib/script/script_parser.y | 11 +++--- lib/sequence/rpl_reader.c | 1 + lib/sound/openal_track.c | 4 +-- lib/widget/scrap.c | 2 +- src/ai.c | 8 +++++ src/ani.c | 3 +- src/astar.c | 9 ++--- src/droid.c | 4 +-- src/loadsave.c | 8 ++--- src/loadsave.h | 2 +- src/message.c | 16 +++++---- src/projectile.c | 13 +++++++ src/radar.c | 7 +--- src/scriptvals_parser.y | 3 -- src/seqdisp.c | 6 ++-- src/structure.c | 2 +- src/texture.c | 2 +- 29 files changed, 108 insertions(+), 102 deletions(-) diff --git a/configure.ac b/configure.ac index 7a1a2515e..81e85a3f9 100644 --- a/configure.ac +++ b/configure.ac @@ -107,7 +107,8 @@ AC_MSG_CHECKING([whether to compile in debug mode]) AC_MSG_RESULT([$debug]) if test "x$debug" = "xyes" ; then # -O0 turns off all optimizations; this is necessary for accurate debugging - WZ_CFLAGS="${WZ_CFLAGS} -g -O0 -DDEBUG -Wall" + # -Wno-unused-label is necessary because flex produces unused labels that we cannot fix + WZ_CFLAGS="${WZ_CFLAGS} -g -O0 -DDEBUG -Wall -Wno-unused-label -Werror" # add these when the code is ready for them # -Wextra -Wwrite-strings -Wcast-qual -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition" else @@ -284,7 +285,6 @@ else AC_DEFINE(WZ_NOMP3, 1, [Disable mp3 support]) fi - # add some required C flags here # -DYY_STATIC is required by flex WZ_CFLAGS="${WZ_CFLAGS} -DYY_STATIC -DDEFAULT_DATADIR=\\\"${datadir}/warzone2100\\\"" diff --git a/lib/framework/frame.h b/lib/framework/frame.h index 7b65bb5b2..2d5d3a443 100644 --- a/lib/framework/frame.h +++ b/lib/framework/frame.h @@ -23,6 +23,8 @@ #ifndef _frame_h #define _frame_h +#include + #include "platform.h" #include "macros.h" diff --git a/lib/framework/frameresource.c b/lib/framework/frameresource.c index 94198ed1a..601b8a43d 100644 --- a/lib/framework/frameresource.c +++ b/lib/framework/frameresource.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "frame.h" #include "frameresource.h" #include "resly.h" diff --git a/lib/gamelib/ani.h b/lib/gamelib/ani.h index 461b4a03e..a92a4262f 100644 --- a/lib/gamelib/ani.h +++ b/lib/gamelib/ani.h @@ -38,7 +38,7 @@ /***************************************************************************/ -void * anim_GetShapeFunc( char * pStr ); +iIMDShape * anim_GetShapeFunc( char * pStr ); /***************************************************************************/ diff --git a/lib/ivis_common/pcx.c b/lib/ivis_common/pcx.c index 10263b028..dbf9e4449 100644 --- a/lib/ivis_common/pcx.c +++ b/lib/ivis_common/pcx.c @@ -126,8 +126,8 @@ BOOL pie_PNGLoadMem(char *pngimage, iSprite *s) { png_bytep* row_pointers = (png_bytep*)malloc(s->height*sizeof(png_bytep)); - unsigned char* pdata; - unsigned int i; + char* pdata; + int i; const unsigned int line_size = s->width*info_ptr->channels; for (i = 0, pdata = s->bmp; diff --git a/lib/ivis_opengl/piedraw.c b/lib/ivis_opengl/piedraw.c index eb73fb49b..75f6ff865 100644 --- a/lib/ivis_opengl/piedraw.c +++ b/lib/ivis_opengl/piedraw.c @@ -687,7 +687,7 @@ static void pie_DrawShadows(void) glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT); glStencilFunc(GL_ALWAYS, 0, ~0); - pie_ShadowDrawLoop(&pos_lgt0); + pie_ShadowDrawLoop(pos_lgt0); glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); } else { @@ -702,14 +702,14 @@ static void pie_DrawShadows(void) glCullFace(GL_BACK); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); - pie_ShadowDrawLoop(&pos_lgt0); + pie_ShadowDrawLoop(pos_lgt0); // Setup stencil for front faces. glCullFace(GL_FRONT); glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); // Draw shadows again - pie_ShadowDrawLoop(&pos_lgt0); + pie_ShadowDrawLoop(pos_lgt0); } glEnable(GL_CULL_FACE); diff --git a/lib/script/Makefile.am b/lib/script/Makefile.am index 1e92ee81d..c533540e8 100644 --- a/lib/script/Makefile.am +++ b/lib/script/Makefile.am @@ -9,6 +9,9 @@ AM_YFLAGS = -d AM_CPPFLAGS = -I$(top_srcdir) BUILT_SOURCES = script_parser.tab.h chat_parser.tab.h +# This is necessary for -Werror to parse script_parser.y +CFLAGS += -Wno-nonnull + noinst_LIBRARIES = libscript.a noinst_HEADERS = chat_processing.h codeprint.h event.h evntsave.h interp.h \ parse.h script.h stack.h diff --git a/lib/script/chat_lexer.l b/lib/script/chat_lexer.l index 1fec9647d..d59e3e429 100644 --- a/lib/script/chat_lexer.l +++ b/lib/script/chat_lexer.l @@ -45,16 +45,11 @@ #define YYLMAX 255 #endif -/* Store for any string values */ -static char aText[TEXT_BUFFERS][YYLMAX]; -static UDWORD currText=0; - /* Pointer to the input buffer */ static char *pInputBuffer = NULL; static char *pEndBuffer = NULL; static SDWORD playerIndex; -static INTERP_VAL parameter; #define YY_INPUT(buf,result,max_size) \ if (pInputBuffer != pEndBuffer) { \ diff --git a/lib/script/chat_parser.y b/lib/script/chat_parser.y index b7c680968..c04d16df6 100644 --- a/lib/script/chat_parser.y +++ b/lib/script/chat_parser.y @@ -38,12 +38,6 @@ /* Holds information about a processed player chat message */ CHAT_MSG chat_msg; -// The current script code -static SCRIPT_CODE *psCurrScript; - -// The current script context -static SCRIPT_CONTEXT *psCurrContext; - // Parameter variable static INTERP_VAL scrParameter; diff --git a/lib/script/codeprint.c b/lib/script/codeprint.c index cfbc2c21e..fae2bec30 100644 --- a/lib/script/codeprint.c +++ b/lib/script/codeprint.c @@ -154,7 +154,7 @@ void cpPrintPackedVal(INTERP_VAL *ip) { debug( LOG_NEVER, "type: " ); cpPrintType(type); - debug( LOG_NEVER, " value: %x", data ); + debug( LOG_NEVER, " value: %x", data.type ); return; } @@ -186,7 +186,7 @@ void cpPrintPackedVal(INTERP_VAL *ip) { if (asScrTypeTab[i].typeID == type) { - debug( LOG_NEVER, "type: %s value: %x", asScrTypeTab[i].pIdent, data.v.oval ); + debug( LOG_NEVER, "type: %s value: %x", asScrTypeTab[i].pIdent, data.v.ival ); return; } } @@ -577,7 +577,7 @@ void cpPrintProgram(SCRIPT_CODE *psProg) ip += aOpSize[opcode]; break; default: - ASSERT( FALSE,"cpPrintProgram: Unknown opcode: %x", *ip ); + ASSERT( FALSE,"cpPrintProgram: Unknown opcode: %x", ip->type ); break; } diff --git a/lib/script/event.c b/lib/script/event.c index 2c35590a4..6c485589a 100644 --- a/lib/script/event.c +++ b/lib/script/event.c @@ -1294,9 +1294,11 @@ BOOL eventSetTrigger(void) return FALSE; } +#ifdef REALLY_DEBUG_THIS DB_TRACE(("eventSetTrigger %s %s\n", eventGetEventID(psFiringTrigger->psContext->psCode, event), eventGetTriggerID(psFiringTrigger->psContext->psCode, trigger)),2); +#endif // See if this is the event that is running psContext = psFiringTrigger->psContext; diff --git a/lib/script/interp.c b/lib/script/interp.c index 1888b2708..11db202c4 100644 --- a/lib/script/interp.c +++ b/lib/script/interp.c @@ -150,9 +150,7 @@ static SCRIPT_CODE *psCurProg = NULL; static BOOL bCurCallerIsEvent = FALSE; /* Print out trace info if tracing is turned on */ -#define TRCPRINTF(x) \ - if (interpTrace) \ - debug( LOG_NEVER, (#x)) +#define TRCPRINTF(...) do { if (interpTrace) { fprintf( stderr, __VA_ARGS__ ); } } while (FALSE) #define TRCPRINTVAL(x) \ if (interpTrace) \ @@ -426,7 +424,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i } instructionCount++; - TRCPRINTF(("%-6d ", InstrPointer - psProg->pCode)); + TRCPRINTF( "%-6d ", InstrPointer - psProg->pCode ); opcode = (OPCODE)(InstrPointer->v.ival >> OPCODE_SHIFT); //get opcode data = (SDWORD)(InstrPointer->v.ival & OPCODE_DATAMASK); //get data - only used with packed opcodes switch (opcode) @@ -542,9 +540,9 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i /* get local variable */ sVal.v.oval = &(psContext->psCode->ppsLocalVarVal[CurEvent][data]); - TRCPRINTF(("PUSHREF ")); + TRCPRINTF( "PUSHREF " ); TRCPRINTVAL(&sVal); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (!stackPush(&sVal)) { @@ -567,9 +565,9 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i /* copy value */ memcpy(&sVal, (INTERP_VAL *)(InstrPointer + 1), sizeof(INTERP_VAL)); - TRCPRINTF(("PUSH ")); + TRCPRINTF( "PUSH " ); TRCPRINTVAL(&sVal); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (!stackPush(&sVal)) { // Eeerk, out of memory @@ -585,9 +583,9 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i // store pointer to INTERP_VAL sVal.v.oval = interpGetVarData(psGlobals, ((INTERP_VAL *)(InstrPointer + 1))->v.ival); - TRCPRINTF(("PUSHREF ")); + TRCPRINTF( "PUSHREF " ); TRCPRINTVAL(&sVal); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (!stackPush(&sVal)) { // Eeerk, out of memory @@ -600,7 +598,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_OPCODE, "wrong value type passed for OP_POP: %d", InstrPointer->type); - TRCPRINTF(("POP\n")); + TRCPRINTF( "POP\n" ); if (!stackPop(&sVal)) { debug( LOG_ERROR, "interpRunScript: could not do stack pop" ); @@ -619,7 +617,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i goto exit_with_error; } TRCPRINTSTACKTOP(); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); InstrPointer += aOpSize[opcode]; break; case OP_UNARYOP: @@ -633,7 +631,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i goto exit_with_error; } TRCPRINTSTACKTOP(); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); InstrPointer += aOpSize[opcode]; break; case OP_PUSHGLOBAL: @@ -641,7 +639,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_PUSHGLOBAL: %d", InstrPointer->type); - TRCPRINTF(("PUSHGLOBAL %d\n", data)); + TRCPRINTF( "PUSHGLOBAL %d\n", data ); if (data >= numGlobals) { debug( LOG_ERROR, "interpRunScript: variable index out of range" ); @@ -658,9 +656,9 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_POPGLOBAL: %d", InstrPointer->type); - TRCPRINTF(("POPGLOBAL %d ", data)); + TRCPRINTF( "POPGLOBAL %d ", data ); TRCPRINTSTACKTOP(); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (data >= numGlobals) { debug( LOG_ERROR, "interpRunScript: variable index out of range" ); @@ -677,13 +675,13 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_PUSHARRAYGLOBAL: %d", InstrPointer->type); - TRCPRINTF(("PUSHARRAYGLOBAL ")); + TRCPRINTF( "PUSHARRAYGLOBAL " ); if (!interpGetArrayVarData(&InstrPointer, psGlobals, psProg, &psVar)) { debug( LOG_ERROR, "interpRunScript: could not get array var data, CurEvent=%d", CurEvent ); goto exit_with_error; } - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (!stackPush(psVar)) { debug( LOG_ERROR, "interpRunScript: could not do stack push" ); @@ -694,14 +692,14 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_POPARRAYGLOBAL: %d", InstrPointer->type); - TRCPRINTF(("POPARRAYGLOBAL ")); + TRCPRINTF( "POPARRAYGLOBAL " ); if (!interpGetArrayVarData(&InstrPointer, psGlobals, psProg, &psVar)) { debug( LOG_ERROR, "interpRunScript: could not get array var data" ); goto exit_with_error; } TRCPRINTSTACKTOP(); - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); if (!stackPopType(psVar)) { debug( LOG_ERROR, "interpRunScript: could not do pop stack of type" ); @@ -713,8 +711,8 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_JUMPFALSE: %d", InstrPointer->type); - TRCPRINTF(("JUMPFALSE %d (%d)", - (SWORD)data, InstrPointer - psProg->pCode + (SWORD)data)); + TRCPRINTF( "JUMPFALSE %d (%d)", + (SWORD)data, InstrPointer - psProg->pCode + (SWORD)data ); if (!stackPop(&sVal)) { @@ -724,7 +722,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i if (!sVal.v.bval) { // Do the jump - TRCPRINTF((" - done -\n")); + TRCPRINTF( " - done -\n" ); InstrPointer += (SWORD)data; if (InstrPointer < pCodeStart || InstrPointer > pCodeEnd) { @@ -734,7 +732,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i } else { - TRCPRINTF(("\n")); + TRCPRINTF( "\n" ); InstrPointer += aOpSize[opcode]; } break; @@ -742,8 +740,8 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_JUMP: %d", InstrPointer->type); - TRCPRINTF(("JUMP %d (%d)\n", - (SWORD)data, InstrPointer - psProg->pCode + (SWORD)data)); + TRCPRINTF( "JUMP %d (%d)\n", + (SWORD)data, InstrPointer - psProg->pCode + (SWORD)data ); // Do the jump InstrPointer += (SWORD)data; if (InstrPointer < pCodeStart || InstrPointer > pCodeEnd) @@ -758,8 +756,8 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_OPCODE, "wrong value type passed for OP_CALL: %d", InstrPointer->type); - TRCPRINTFUNC( ((INTERP_VAL *)(InstrPointer+1))->v.pFuncExtern ); - TRCPRINTF(("\n")); + TRCPRINTFUNC( ((INTERP_VAL *)(InstrPointer+1))->v.pFuncExtern ); + TRCPRINTF( "\n" ); scriptFunc = ((INTERP_VAL *)(InstrPointer+1))->v.pFuncExtern; //debug(LOG_SCRIPT, "OP_CALL 1"); if (!scriptFunc()) @@ -775,9 +773,9 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_VARCALL: %d", InstrPointer->type); - TRCPRINTF(("VARCALL ")); + TRCPRINTF( "VARCALL " ); TRCPRINTVARFUNC( ((INTERP_VAL *)(InstrPointer+1))->v.pObjGetSet, data ); - TRCPRINTF(("(%d)\n", data)); + TRCPRINTF( "(%d)\n", data ); ASSERT( ((INTERP_VAL *)(InstrPointer+1))->type == VAL_OBJ_GETSET, "wrong set/get function pointer type passed for OP_VARCALL: %d", ((INTERP_VAL *)(InstrPointer+1))->type); @@ -801,7 +799,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i ASSERT( InstrPointer->type == VAL_PKOPCODE, "wrong value type passed for OP_PAUSE: %d", InstrPointer->type); - TRCPRINTF(("PAUSE %d\n", data)); + TRCPRINTF( "PAUSE %d\n", data ); ASSERT( stackEmpty(), "interpRunScript: OP_PAUSE without empty stack" ); @@ -922,7 +920,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i //debug(LOG_SCRIPT, "interpRunScript 3"); psCurProg = NULL; - TRCPRINTF(("%-6d EXIT\n", InstrPointer - psProg->pCode)); + TRCPRINTF( "%-6d EXIT\n", InstrPointer - psProg->pCode ); bInterpRunning = FALSE; return TRUE; @@ -944,7 +942,7 @@ exit_with_error: scrOutputCallTrace(); psCurProg = NULL; - TRCPRINTF(("*** ERROR EXIT ***\n")); + TRCPRINTF( "*** ERROR EXIT ***\n" ); ASSERT(FALSE, "interpRunScript: error while executing a script"); @@ -1141,13 +1139,11 @@ void scrOutputCallTrace(void) pEvent = eventGetEventID(psCurProg, retStack[i].CallerIndex); } - debug(LOG_SCRIPT,"%d: %s (return address: %d)", i, pEvent, retStack[i].ReturnAddress); + debug(LOG_SCRIPT,"%d: %s (return address: %p)", i, pEvent, retStack[i].ReturnAddress); } } else { debug(LOG_SCRIPT, ""); } - - debug(LOG_SCRIPT, ""); } diff --git a/lib/script/script_parser.y b/lib/script/script_parser.y index 5e17ff3e5..55f7eec43 100644 --- a/lib/script/script_parser.y +++ b/lib/script/script_parser.y @@ -630,7 +630,6 @@ void script_debug(const char *pFormat, ...); /* Macro to combine the debugging information in two blocks into a third block */ static UDWORD _dbEntry; static SCRIPT_DEBUG *_psCurr; -static UDWORD _baseOffset; #define COMBINE_DEBUG(psFinal, psBlock1, psBlock2) \ if (genDebugInfo) \ { \ @@ -841,6 +840,7 @@ static UDWORD checkFuncParamTypes(EVENT_SYMBOL *psFSymbol, // The function bei return 0; //all ok } +#ifdef UNUSED /* * function call */ @@ -881,7 +881,7 @@ static CODE_ERROR scriptCodeCallFunction(FUNC_SYMBOL *psFSymbol, // The functio return CE_OK; } - +#endif /* Generate the code for a parameter callback, checking the parameter * types match. @@ -1624,7 +1624,7 @@ static CODE_ERROR scriptCodeVarRef(VAR_SYMBOL *psVariable, // The object variab return CE_OK; } - +#ifdef UNUSED /* Generate the code for a trigger and store it in the trigger list */ static CODE_ERROR scriptCodeTrigger(char *pIdent, CODE_BLOCK *psCode) { @@ -1664,8 +1664,9 @@ static CODE_ERROR scriptCodeTrigger(char *pIdent, CODE_BLOCK *psCode) return CE_OK; } +#endif - +#ifdef UNUSED /* Generate the code for an event and store it in the event list */ static CODE_ERROR scriptCodeEvent(EVENT_SYMBOL *psEvent, TRIGGER_SYMBOL *psTrig, CODE_BLOCK *psCode) { @@ -1703,7 +1704,7 @@ static CODE_ERROR scriptCodeEvent(EVENT_SYMBOL *psEvent, TRIGGER_SYMBOL *psTrig, return CE_OK; } - +#endif /* Store the types of a list of variables into a code block. * The order of the list is reversed so that the type of the diff --git a/lib/sequence/rpl_reader.c b/lib/sequence/rpl_reader.c index 74d3651d1..20a469c09 100644 --- a/lib/sequence/rpl_reader.c +++ b/lib/sequence/rpl_reader.c @@ -17,6 +17,7 @@ along with Warzone 2100; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #ifdef WIN32 #include diff --git a/lib/sound/openal_track.c b/lib/sound/openal_track.c index dcefaf851..b3bf70ac6 100644 --- a/lib/sound/openal_track.c +++ b/lib/sound/openal_track.c @@ -611,8 +611,8 @@ void sound_SetPlayerOrientation( SDWORD iX, SDWORD iY, SDWORD iZ ) //~~~~~~~~~~~ // convert params to rad - float pitch = (float)iX * M_PI / 180; - float roll = (float)iY * M_PI / 180; + // float pitch = (float)iX * M_PI / 180; + // float roll = (float)iY * M_PI / 180; float yaw = (float)iZ * M_PI / 180; ori[0] = -sin( yaw ); diff --git a/lib/widget/scrap.c b/lib/widget/scrap.c index a07481e74..231e89676 100644 --- a/lib/widget/scrap.c +++ b/lib/widget/scrap.c @@ -372,7 +372,7 @@ put_scrap(int type, int srclen, char *src) Lock_Display(); convert_data(type, dst, src, srclen); XChangeProperty(SDL_Display, DefaultRootWindow(SDL_Display), - XA_CUT_BUFFER0, format, 8, PropModeReplace, dst, dstlen); + XA_CUT_BUFFER0, format, 8, PropModeReplace, (unsigned char *)dst, dstlen); free(dst); if ( lost_scrap() ) XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime); diff --git a/src/ai.c b/src/ai.c index eb9295bf0..e3c7a9442 100644 --- a/src/ai.c +++ b/src/ai.c @@ -311,6 +311,14 @@ SDWORD targetAttackWeight(BASE_OBJECT *psTarget, BASE_OBJECT *psAttacker, SDWORD /* See if this type of a droid should be prioritized */ switch (targetDroid->droidType) { + case DROID_SENSOR: + case DROID_ECM: + case DROID_PERSON: + case DROID_TRANSPORTER: + case DROID_DEFAULT: + case DROID_ANY: + break; + case DROID_CYBORG: case DROID_WEAPON: case DROID_CYBORG_SUPER: diff --git a/src/ani.c b/src/ani.c index 63ab95d5e..37228ff5d 100644 --- a/src/ani.c +++ b/src/ani.c @@ -33,8 +33,7 @@ /***************************************************************************/ -void * -anim_GetShapeFunc( char * pStr ) +iIMDShape *anim_GetShapeFunc( char * pStr ) { return resGetData( "IMD", pStr ); } diff --git a/src/astar.c b/src/astar.c index dac5121a9..885147935 100644 --- a/src/astar.c +++ b/src/astar.c @@ -278,7 +278,7 @@ static FP_NODE *fpathHashPresent(FP_NODE *apsTable[], SDWORD x, SDWORD y) return psFound; }*/ - +#if OPEN_LIST == 0 || OPEN_LIST == 1 // Remove a node from the hash table static FP_NODE *fpathHashRemove(FP_NODE *apsTable[], SDWORD x, SDWORD y) { @@ -311,7 +311,9 @@ static FP_NODE *fpathHashRemove(FP_NODE *apsTable[], SDWORD x, SDWORD y) return psFound; } +#endif +#if OPEN_LIST == 0 || OPEN_LIST == 1 // Remove a node from the hash table static FP_NODE *fpathHashCondRemove(FP_NODE *apsTable[], SDWORD x, SDWORD y, SDWORD dist) { @@ -349,7 +351,7 @@ static FP_NODE *fpathHashCondRemove(FP_NODE *apsTable[], SDWORD x, SDWORD y, SDW return psFound; } - +#endif // Reset the hash tables static void fpathHashReset(void) @@ -714,7 +716,7 @@ static FP_NODE *fpathOpenGet(void) #endif -#if OPEN_LIST == 1 || OPEN_LIST == 2 +#if OPEN_LIST == 0 || OPEN_LIST == 1 // Remove a node from the open list static void fpathOpenRemove(FP_NODE *psNode) { @@ -750,7 +752,6 @@ static void fpathOpenRemove(FP_NODE *psNode) } } } - #endif diff --git a/src/droid.c b/src/droid.c index 7feaf20d8..aabb715e8 100644 --- a/src/droid.c +++ b/src/droid.c @@ -406,11 +406,9 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo psDroid->armour -= armourDamage; }*/ - debug( LOG_ATTACK, " body left: %d armour left: %d\n", - psDroid->body, psDroid->armour); - /* now check for auto return on droid's secondary orders */ secondaryCheckDamageLevel(psDroid); + /* now check for scripted run-away based on health */ orderHealthCheck(psDroid); diff --git a/src/loadsave.c b/src/loadsave.c index 5646f05b3..090875b68 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -25,7 +25,7 @@ * return a filename to use for the ops. */ -#include +#include #include #include "lib/framework/frame.h" @@ -91,7 +91,7 @@ void drawBlueBox (UDWORD x,UDWORD y, UDWORD w, UDWORD h); BOOL closeLoadSave (void); BOOL runLoadSave (BOOL bResetMissionWidgets); BOOL displayLoadSave (void); -static BOOL _addLoadSave (BOOL bLoad, const char *sSearchPath, const char *sExtension, const char *title); +static BOOL _addLoadSave (BOOL bLoad, const char *sSearchPath, const char *sExtension, char *title); static BOOL _runLoadSave (BOOL bResetMissionWidgets); static void displayLoadBanner (WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours); static void displayLoadSlot (WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours); @@ -127,7 +127,7 @@ BOOL saveMidMission(void) } // //////////////////////////////////////////////////////////////////////////// -BOOL addLoadSave(LOADSAVE_MODE mode, const char *sSearchPath, const char *sExtension, const char *title) +BOOL addLoadSave(LOADSAVE_MODE mode, const char *sSearchPath, const char *sExtension, char *title) { BOOL bLoad; @@ -154,7 +154,7 @@ BOOL bLoad; //**************************************************************************************** // Load menu/save menu? //***************************************************************************************** -static BOOL _addLoadSave(BOOL bLoad, const char *sSearchPath, const char *sExtension, const char *title) +static BOOL _addLoadSave(BOOL bLoad, const char *sSearchPath, const char *sExtension, char *title) { W_FORMINIT sFormInit; W_BUTINIT sButInit; diff --git a/src/loadsave.h b/src/loadsave.h index e86eb9425..c39723595 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -63,7 +63,7 @@ extern BOOL bRequestLoad; extern void drawBlueBox (UDWORD x,UDWORD y, UDWORD w, UDWORD h); -extern BOOL addLoadSave (LOADSAVE_MODE mode, const char *defaultdir, const char *extension,const char *title); +extern BOOL addLoadSave(LOADSAVE_MODE mode, const char *defaultdir, const char *extension, char *title); extern BOOL closeLoadSave (void); extern BOOL runLoadSave (BOOL bResetMissionWidgets); extern BOOL displayLoadSave (void); diff --git a/src/message.c b/src/message.c index 70ae660a7..80546fe91 100644 --- a/src/message.c +++ b/src/message.c @@ -852,15 +852,17 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) if (psViewData->pData == NULL) { debug( LOG_ERROR, "Unable to allocate memory" ); - abort(); + assert( FALSE ); return NULL; + } else { + int tmp; + + audioName[0] = '\0'; + sscanf( pViewMsgData, ", %d,%d,%d,%[^','],%d%n", &LocX, &LocY, &LocZ, + audioName, &tmp, &cnt); + proxType = tmp; } - - - audioName[0] = '\0'; - sscanf(pViewMsgData, ",%d,%d,%d,%[^','],%d%n", &LocX, &LocY, &LocZ, - audioName,&proxType,&cnt); - pViewMsgData += cnt; + pViewMsgData += cnt; //allocate audioID if ( strcmp( audioName, "0" ) == 0 ) diff --git a/src/projectile.c b/src/projectile.c index 11387804f..3d8ef3109 100644 --- a/src/projectile.c +++ b/src/projectile.c @@ -957,6 +957,19 @@ proj_InFlightIndirectFunc( PROJ_OBJECT *psObj ) { switch(psStats->weaponSubClass) { + case WSC_MGUN: + case WSC_CANNON: + case WSC_MORTARS: + case WSC_ENERGY: + case WSC_GAUSS: + case WSC_HOWITZERS: + case WSC_AAGUN: + case WSC_LAS_SAT: + case WSC_BOMB: + case WSC_COUNTER: + case NUM_WEAPON_SUBCLASS: + case INVALID_SUBCLASS: + break; case WSC_FLAME: effectGiveAuxVar(PERCENT(iDist,iRad)); pos.x = psObj->x; diff --git a/src/radar.c b/src/radar.c index 485bff994..70674b932 100644 --- a/src/radar.c +++ b/src/radar.c @@ -457,8 +457,6 @@ void drawRadar(void) scrollMaxY = scrollMinY+127; #endif - - CalcRadarPixelSize(&boxSizeH,&boxSizeV); CalcRadarScroll(boxSizeH,boxSizeV); @@ -474,14 +472,11 @@ void drawRadar(void) iV_TransBoxFill( RADTLX,RADTLY, RADTLX + RADWIDTH, RADTLY + RADHEIGHT); - pie_RenderRadar(&RadarImage,radarBuffer,RadarWidth,RADTLX,RADTLY); - + pie_RenderRadar( &RadarImage, (char*)radarBuffer, RadarWidth, RADTLX, RADTLY ); DrawRadarExtras(boxSizeH,boxSizeV); - UpdateRadar(boxSizeH,boxSizeV); RadarRedraw = FALSE; - } void downloadAtStartOfFrame( void ) diff --git a/src/scriptvals_parser.y b/src/scriptvals_parser.y index 9fb9c3989..ae1f3ad60 100644 --- a/src/scriptvals_parser.y +++ b/src/scriptvals_parser.y @@ -224,11 +224,8 @@ var_init_list: /* NULL token */ var_init: var_entry TYPE var_value { INTERP_VAL data; /* structure to to hold all types */ - DROID_TEMPLATE *psTemplate; BASE_OBJECT *psObj; - VIEWDATA *psViewData; char *pString; - RESEARCH *psResearch; SDWORD compIndex; /* set type */ diff --git a/src/seqdisp.c b/src/seqdisp.c index e8c0d40d8..ec37bc668 100644 --- a/src/seqdisp.c +++ b/src/seqdisp.c @@ -367,7 +367,7 @@ void seq_SetVideoPath(void) if (!bHardPath) { strcpy(aHardPath, "sequences/"); -/*#ifdef WIN32 +#ifdef WAS_WIN32_NOW_UNUSED fileHandle = FindFirstFile("sequences/*.rpl",&findData); if (fileHandle == INVALID_HANDLE_VALUE) { @@ -382,10 +382,8 @@ void seq_SetVideoPath(void) return; } #else -*/ bHardPath=TRUE; //yes, always true, as it should be on windows ALSO. - -//#endif +#endif } } diff --git a/src/structure.c b/src/structure.c index 06ac97993..ae4331333 100644 --- a/src/structure.c +++ b/src/structure.c @@ -1227,7 +1227,7 @@ BOOL loadStructureWeapons(char *pWeaponData, UDWORD bufferSize) WeaponName[j][0] = '\0'; } - sscanf(pWeaponData, "%[^','],%[^','],%[^','],%[^','],%[^','],%*d", StructureName, &WeaponName[0], &WeaponName[1], &WeaponName[2], &WeaponName[3]); + sscanf(pWeaponData, "%[^','],%[^','],%[^','],%[^','],%[^','],%*d", StructureName, WeaponName[0], WeaponName[1], WeaponName[2], WeaponName[3]); if (!getResourceName(StructureName)) { diff --git a/src/texture.c b/src/texture.c index 21fc48726..a29149ab4 100644 --- a/src/texture.c +++ b/src/texture.c @@ -231,7 +231,7 @@ BOOL getTileRadarColours(void) { UDWORD x, y, i, j, w, h, t; iBitmap *b, *s; - UBYTE tempBMP[TILE_WIDTH * TILE_HEIGHT]; + char tempBMP[TILE_WIDTH * TILE_HEIGHT]; w = tilesPCX.width / TILE_WIDTH; h = tilesPCX.height / TILE_HEIGHT;