Hi all,
Attached are 2 sets of changes to remove some warnings. Those in
warnings_casts.patch cast variables back to what they were before the
binary operations, for example:
- sVal.type = (*InstrPointer) & OPCODE_DATAMASK;
+ sVal.type = (INTERP_TYPE)((*InstrPointer) &
OPCODE_DATAMASK);
I think this is quite harmless.
warnings_changes.patch changes the types of some variables and adds
calls to keyCodeToSDLKey in some assert statements.
I hope those will be of any use, and if they are not in the right
direction I'd be glad to hear what you would expect.
Regards,
Gerard
Index: src/fpath.c
===================================================================
--- src/fpath.c (revision 440)
+++ src/fpath.c (working copy)
@@ -1046,13 +1046,14 @@
}
// create a final route from a gateway route
-static SDWORD fpathGatewayRoute(BASE_OBJECT *psObj, SDWORD routeMode, SDWORD
GWTerrain,
+static FPATH_RETVAL fpathGatewayRoute(BASE_OBJECT *psObj, SDWORD routeMode,
SDWORD GWTerrain,
SDWORD sx, SDWORD sy, SDWORD
fx, SDWORD fy,
MOVE_CONTROL *psMoveCntl)
{
static SDWORD linkx, linky, gwx, gwy, asret, matchPoints;
static ASTAR_ROUTE sAStarRoute;
- SDWORD retval = FPR_OK, gwRet, zone;
+ FPATH_RETVAL retval = FPR_OK;
+ SDWORD gwRet, zone;
static GATEWAY *psCurrRoute, *psGWRoute, *psLastGW;
BOOL bRouting, bFinished;
static BOOL bFirstRoute;
Index: lib/framework/input.c
===================================================================
--- lib/framework/input.c (revision 440)
+++ lib/framework/input.c (working copy)
@@ -83,7 +83,7 @@
strcpy(ascii,"???");
return;
}
- ASSERT( (code >= 0) && (code <= KEY_MAXSCAN), "Invalid key code: %d",
code );
+ ASSERT( (code >= 0) && (keyCodeToSDLKey(code) <= KEY_MAXSCAN), "Invalid
key code: %d", code );
#ifndef _MSC_VER
snprintf(ascii, maxStringSize, "%s",
SDL_GetKeyName(keyCodeToSDLKey(code)));
#else
@@ -399,21 +399,21 @@
/* This returns true if the key is currently depressed */
BOOL keyDown(KEY_CODE code)
{
- ASSERT( (code >= 0) && (code < KEY_MAXSCAN), "Invalid key code: %d",
code );
+ ASSERT( (code >= 0) && (keyCodeToSDLKey(code) < KEY_MAXSCAN), "Invalid
key code: %d", code );
return (aKeyState[code] != KEY_UP);
}
/* This returns true if the key went from being up to being down this frame */
BOOL keyPressed(KEY_CODE code)
{
- ASSERT( (code >= 0) && (code < KEY_MAXSCAN), "Invalid key code: %d",
code );
+ ASSERT( (code >= 0) && (keyCodeToSDLKey(code) < KEY_MAXSCAN), "Invalid
key code: %d", code );
return ((aKeyState[code] == KEY_PRESSED) || (aKeyState[code] ==
KEY_PRESSRELEASE));
}
/* This returns true if the key went from being down to being up this frame */
BOOL keyReleased(KEY_CODE code)
{
- ASSERT( (code >= 0) && (code < KEY_MAXSCAN), "Invalid key code: %d",
code );
+ ASSERT( (code >= 0) && (keyCodeToSDLKey(code) < KEY_MAXSCAN), "Invalid
key code: %d", code );
return ((aKeyState[code] == KEY_RELEASED) || (aKeyState[code] ==
KEY_PRESSRELEASE));
}
@@ -479,7 +479,7 @@
static int mousewarp = -1;
if (mousewarp == -1) {
- int val;
+ DWORD val;
mousewarp = 1;
if (getWarzoneKeyNumeric("nomousewarp", &val)) {
Index: lib/framework/frame.c
===================================================================
--- lib/framework/frame.c (revision 440)
+++ lib/framework/frame.c (working copy)
@@ -446,7 +446,7 @@
If hard_fail is true, we will assert and report on failures.
***************************************************************************/
-static BOOL loadFile2(char *pFileName, char **ppFileData, UDWORD *pFileSize,
+static BOOL loadFile2(const char *pFileName, char **ppFileData, UDWORD
*pFileSize,
BOOL AllocateMem, BOOL hard_fail)
{
PHYSFS_file *pfile;
Index: src/cmddroid.c
===================================================================
--- src/cmddroid.c (revision 440)
+++ src/cmddroid.c (working copy)
@@ -80,10 +80,10 @@
psDroid->group = UBYTE_MAX;
// set the secondary states for the unit
- secondarySetState(psDroid, DSO_ATTACK_RANGE,
psCommander->secondaryOrder & DSS_ARANGE_MASK);
- secondarySetState(psDroid, DSO_REPAIR_LEVEL,
psCommander->secondaryOrder & DSS_REPLEV_MASK);
- secondarySetState(psDroid, DSO_ATTACK_LEVEL,
psCommander->secondaryOrder & DSS_ALEV_MASK);
- secondarySetState(psDroid, DSO_HALTTYPE,
psCommander->secondaryOrder & DSS_HALT_MASK);
+ secondarySetState(psDroid, DSO_ATTACK_RANGE,
(SECONDARY_STATE)(psCommander->secondaryOrder & DSS_ARANGE_MASK));
+ secondarySetState(psDroid, DSO_REPAIR_LEVEL,
(SECONDARY_STATE)(psCommander->secondaryOrder & DSS_REPLEV_MASK));
+ secondarySetState(psDroid, DSO_ATTACK_LEVEL,
(SECONDARY_STATE)(psCommander->secondaryOrder & DSS_ALEV_MASK));
+ secondarySetState(psDroid, DSO_HALTTYPE,
(SECONDARY_STATE)(psCommander->secondaryOrder & DSS_HALT_MASK));
orderDroidObj(psDroid, DORDER_GUARD, (BASE_OBJECT
*)psCommander);
}
Index: lib/script/interp.c
===================================================================
--- lib/script/interp.c (revision 440)
+++ lib/script/interp.c (working copy)
@@ -478,7 +478,7 @@
case OP_PUSHLOCALREF:
// The type of the variable is stored in with
the opcode
- sVal.type = (*InstrPointer) & OPCODE_DATAMASK;
+ sVal.type = (INTERP_TYPE)((*InstrPointer) &
OPCODE_DATAMASK);
/* get local var index */
data = *(InstrPointer + 1);
@@ -508,7 +508,7 @@
case OP_PUSH:
// The type of the value is stored in with the
opcode
- sVal.type = (*InstrPointer) & OPCODE_DATAMASK;
+ sVal.type = (INTERP_TYPE)((*InstrPointer) &
OPCODE_DATAMASK);
// Copy the data as a DWORD
sVal.v.ival = (SDWORD)(*(InstrPointer+1));
TRCPRINTF(("PUSH "));
@@ -525,7 +525,7 @@
break;
case OP_PUSHREF:
// The type of the variable is stored in with
the opcode
- sVal.type = (*InstrPointer) & OPCODE_DATAMASK;
+ sVal.type = (INTERP_TYPE)((*InstrPointer) &
OPCODE_DATAMASK);
// store the pointer
psVar = interpGetVarData(psGlobals,
*(InstrPointer + 1));
sVal.v.oval = &(psVar->v.ival);
@@ -929,12 +929,12 @@
if (to & VAL_REF)
{
toRef = TRUE;
- to = to & ~VAL_REF;
+ to = (INTERP_TYPE)(to & ~VAL_REF);
}
if (from & VAL_REF)
{
fromRef = TRUE;
- from = from & ~VAL_REF;
+ from = (INTERP_TYPE)(from & ~VAL_REF);
}
if (toRef != fromRef)
{
Index: lib/script/codeprint.c
===================================================================
--- lib/script/codeprint.c (revision 440)
+++ lib/script/codeprint.c (working copy)
@@ -19,7 +19,7 @@
if (type & VAL_REF)
{
ref = TRUE;
- type = type & ~VAL_REF;
+ type = (INTERP_TYPE)(type & ~VAL_REF);
}
switch(type)
@@ -124,7 +124,7 @@
/* Display a value from a program that has been packed with an opcode */
void cpPrintPackedVal(UDWORD *ip)
{
- INTERP_TYPE type = (*ip) & OPCODE_DATAMASK;
+ INTERP_TYPE type = (INTERP_TYPE)((*ip) & OPCODE_DATAMASK);
UDWORD i;
UDWORD data = *(ip + 1);
@@ -415,7 +415,7 @@
ip = psProg->pCode;
triggerCode = psProg->numTriggers > 0 ? TRUE : FALSE;
end = (UDWORD *)(((UBYTE *)ip) + psProg->size);
- opcode = (*ip) >> OPCODE_SHIFT;
+ opcode = (OPCODE)((*ip) >> OPCODE_SHIFT);
data = (*ip) & OPCODE_DATAMASK;
while (ip < end)
{
@@ -568,7 +568,7 @@
ASSERT( (ip <= end) || PTRVALID(ip, sizeof(UDWORD)),
"cpPrintProgram: instruction pointer no longer valid" );
- opcode = (*ip) >> OPCODE_SHIFT;
+ opcode = (OPCODE)((*ip) >> OPCODE_SHIFT);
data = (*ip) & OPCODE_DATAMASK;
}
}
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev