On Monday 16 July 2007, Per Inge Mathisen wrote: > Nice, this removes a lot of ugly casts. Unfortunately, that patch > would break the netcode badly. In order to convert basedef's xyz from > UWORD to UDWORD, we will have to check or change the size of all xyz > coordinates going over the network, too (in src/multi*.c). So the > patch needs a little more work before it can be committed, > unfortunately.
What about the follwing patch ? I'm not sure about multigifts.c changes as I don't know why there was an explicit cast from UDWORD to UWORD (the nx/ny stuff) Also there was a bug I think as previously there was - NetAdd(m,m.size,x); m.size += sizeof(UWORD); - NetAdd(m,m.size,x); m.size += sizeof(UWORD); 2 times sending x seems wrong to me, right ? Also please note that I just compiled the changes but did no test via a multiplayer network game. -- Best regards/Schöne Grüße Martin () ascii ribbon campaign - against html mail /\ - against microsoft attachments Computers and Internet gave you freedom. TCPA would TAKE your FREEDOM! http://www.againsttcpa.com
Index: action.c =================================================================== --- action.c (revision 2124) +++ action.c (working copy) @@ -1255,9 +1255,9 @@ } addDroid(psDroid, apsDroidLists); //set the x/y up since they were set to INVALID_XY when moved offWorld - missionGetTransporterExit(selectedPlayer, (UWORD*)&droidX, (UWORD*)&droidY); // FIXME passing type-punned pointer of wrong size! - psDroid->x = (UWORD)droidX; - psDroid->y = (UWORD)droidY; + missionGetTransporterExit(selectedPlayer, &droidX, &droidY); + psDroid->x = droidX; + psDroid->y = droidY; //fly Transporter back to get some more droids orderDroidLoc( psDroid, DORDER_TRANSPORTIN, getLandingX(selectedPlayer), getLandingY(selectedPlayer)); Index: multibot.c =================================================================== --- multibot.c (revision 2124) +++ multibot.c (working copy) @@ -252,7 +252,7 @@ { DROID *psDroid; UDWORD id,player; - UWORD x, y; + UDWORD x, y; NetGet(pMsg,0,id); NetGet(pMsg,4,x); @@ -942,7 +942,7 @@ UDWORD sizecount=0; DROID_TEMPLATE dt; DROID *pD,*existingdroid; - UWORD x,y,z; + UDWORD x,y,z; UDWORD id; UBYTE player; UBYTE i; Index: multigifts.c =================================================================== --- multigifts.c (revision 2124) +++ multigifts.c (working copy) @@ -573,7 +573,6 @@ { UDWORD i; UDWORD x,y; - UWORD nx,ny; FEATURE *pF=NULL; SDWORD type = FEAT_GEN_ARTE; NETMSG m; @@ -602,13 +601,11 @@ NetAdd(m,m.size,type); m.size += sizeof(type); - nx = (UWORD)x; - NetAdd(m,m.size,nx); - m.size += sizeof(UWORD); + NetAdd(m,m.size,x); + m.size += sizeof(x); - ny = (UWORD)y; - NetAdd(m,m.size,ny); - m.size += sizeof(UWORD); + NetAdd(m,m.size,y); + m.size += sizeof(y); NetAdd(m,m.size,pF->id); m.size += sizeof(pF->id); @@ -638,7 +635,6 @@ // Vector3i position; static UDWORD lastgift=0; UDWORD i,x,y,quantity,count; - UWORD nx,ny; NETMSG m; FEATURE *pF; SDWORD type = FEAT_OIL_DRUM; @@ -688,10 +684,8 @@ pF = buildFeature((asFeatureStats+i),x<<TILE_SHIFT, y<<TILE_SHIFT,FALSE); - nx = (UWORD)x; - ny = (UWORD)y; - NetAdd(m,m.size,x); m.size += sizeof(UWORD); - NetAdd(m,m.size,x); m.size += sizeof(UWORD); + NetAdd(m,m.size,x); m.size += sizeof(x); + NetAdd(m,m.size,y); m.size += sizeof(y); NetAdd(m,m.size,pF->id); m.size += sizeof(pF->id); m.body[m.size] = ONEPLAYER; @@ -760,7 +754,6 @@ FEATURE *pF; UDWORD i,count; UDWORD x,y; - UWORD nx,ny; m.type = NET_ARTIFACTS; m.size = 1; @@ -785,12 +778,10 @@ pF = buildFeature((asFeatureStats+i),x<<TILE_SHIFT, y<<TILE_SHIFT,FALSE); - nx = (UWORD)x; - ny = (UWORD)y; - NetAdd(m,m.size,nx); - m.size += sizeof(UWORD); - NetAdd(m,m.size,ny); - m.size += sizeof(UWORD); + NetAdd(m,m.size,x); + m.size += sizeof(x); + NetAdd(m,m.size,y); + m.size += sizeof(y); NetAdd(m,m.size,pF->id); m.size += sizeof(pF->id); @@ -827,7 +818,7 @@ UDWORD index,count,i,quantity,ref; SDWORD type; FEATURE *pF; - UWORD tx,ty; + UDWORD tx,ty; quantity = (UDWORD) pMsg->body[0]; index = 1; Index: multistruct.c =================================================================== --- multistruct.c (revision 2124) +++ multistruct.c (working copy) @@ -88,7 +88,8 @@ BOOL recvBuildStarted(NETMSG *pMsg) { UDWORD targetId,order,droidId,structId,structStat; - UWORD x,z,y,player; + UDWORD x,z,y; + UWORD player; STRUCTURE_STATS *psStats; DROID *psDroid; UDWORD typeindex,actionX,actionY; @@ -175,7 +176,7 @@ { UDWORD strId;//,i; STRUCTURE *psStr; - UWORD x,y,z; + UDWORD x,y,z; UDWORD type,typeindex; UBYTE player; Index: transporter.c =================================================================== --- transporter.c (revision 2124) +++ transporter.c (working copy) @@ -1731,7 +1731,7 @@ /*launches the defined transporter to the offworld map*/ BOOL launchTransporter(DROID *psTransporter) { - UWORD iX, iY; + UDWORD iX, iY; //close the interface intResetScreen(TRUE); Index: multisync.c =================================================================== --- multisync.c (revision 2124) +++ multisync.c (working copy) @@ -547,8 +547,8 @@ { // calculate difference between remote and local - xdiff = psDroid->x - (UWORD)fx; - ydiff = psDroid->y - (UWORD)fy; + xdiff = psDroid->x - (UDWORD)fx; + ydiff = psDroid->y - (UDWORD)fy; distSq = (xdiff*xdiff) + (ydiff*ydiff); // if more than 2 squares, jump it. @@ -562,8 +562,8 @@ psDroid->sMove.fx = fx; //update x psDroid->sMove.fy = fy; //update y - psDroid->x = (UWORD) fx; //update move progress - psDroid->y = (UWORD) fy; + psDroid->x = (UDWORD) fx; //update move progress + psDroid->y = (UDWORD) fy; gridMoveObject((BASE_OBJECT *)psDroid, (SDWORD)oldx,(SDWORD)oldy); psDroid->direction = dir % 360; // update rotation @@ -580,8 +580,8 @@ { oldx = psDroid->x; oldy = psDroid->y; - psDroid->x = (UWORD)x; //update x - psDroid->y = (UWORD)y; //update y + psDroid->x = x; //update x + psDroid->y = y; //update y gridMoveObject((BASE_OBJECT *)psDroid, (SDWORD)oldx,(SDWORD)oldy); psDroid->direction = dir % 360; // update rotation } @@ -739,7 +739,7 @@ // receive checking info about a structure and update local world state BOOL recvStructureCheck( NETMSG *m) { - UWORD x,y,z; + UDWORD x,y,z; UDWORD ref,type,j; UBYTE i,player; UBYTE cap; Index: basedef.h =================================================================== --- basedef.h (revision 2124) +++ basedef.h (working copy) @@ -51,7 +51,7 @@ #define BASE_ELEMENTS1(pointerType) \ OBJECT_TYPE type; /* The type of object */ \ UDWORD id; /* ID number of the object */ \ - UWORD x,y,z; /* Object's location */ \ + UDWORD x,y,z; /* Object's location */ \ float direction; /* Object's direction +ve rotation about y axis*/ \ SWORD pitch; /* Object's pitch +ve nose up*/ \ SWORD roll /* Object's roll +ve left up, right down */ Index: mapgrid.c =================================================================== --- mapgrid.c (revision 2124) +++ mapgrid.c (working copy) @@ -264,7 +264,7 @@ { ASSERT( (x >= 0) && (x < gridWidth*GRID_UNITS) && (y >= 0) && (y < gridHeight*GRID_UNITS), - "gridStartIterate: coords off grid" ); + "gridStartIterate: coords off grid x:%d y:%d", x, y ); x = x / GRID_UNITS; y = y / GRID_UNITS; Index: mission.c =================================================================== --- mission.c (revision 2124) +++ mission.c (working copy) @@ -777,26 +777,26 @@ #define EDGE_SIZE 1 /* pick nearest map edge to point */ -void missionGetNearestCorner( UWORD iX, UWORD iY, UWORD *piOffX, UWORD *piOffY ) +void missionGetNearestCorner( UDWORD iX, UDWORD iY, UDWORD *piOffX, UDWORD *piOffY ) { UDWORD iMidX = (scrollMinX + scrollMaxX)/2, iMidY = (scrollMinY + scrollMaxY)/2; - if ( ((UDWORD)(iX>>TILE_SHIFT)) < iMidX ) + if ( (iX>>TILE_SHIFT) < iMidX ) { - *piOffX = (UWORD) ((scrollMinX << TILE_SHIFT) + (EDGE_SIZE*TILE_UNITS)); + *piOffX = (scrollMinX << TILE_SHIFT) + (EDGE_SIZE*TILE_UNITS); } else { - *piOffX = (UWORD) ((scrollMaxX << TILE_SHIFT) - (EDGE_SIZE*TILE_UNITS)); + *piOffX = (scrollMaxX << TILE_SHIFT) - (EDGE_SIZE*TILE_UNITS); } - if ( ((UDWORD)(iY>>TILE_SHIFT)) < iMidY ) + if ( (iY>>TILE_SHIFT) < iMidY ) { - *piOffY = (UWORD) ((scrollMinY << TILE_SHIFT) + (EDGE_SIZE*TILE_UNITS)); + *piOffY = (scrollMinY << TILE_SHIFT) + (EDGE_SIZE*TILE_UNITS); } else { - *piOffY = (UWORD) ((scrollMaxY << TILE_SHIFT) - (EDGE_SIZE*TILE_UNITS)); + *piOffY = (scrollMaxY << TILE_SHIFT) - (EDGE_SIZE*TILE_UNITS); } } @@ -804,7 +804,7 @@ void missionFlyTransportersIn( SDWORD iPlayer, BOOL bTrackTransporter ) { DROID *psTransporter, *psNext; - UWORD iX, iY, iZ; + UDWORD iX, iY, iZ; SDWORD iLandX, iLandY, iDx, iDy; FRACT_D fR; @@ -2590,7 +2590,7 @@ DROID *psDroid, *psNext; DROID **ppCurrentList, **ppStoredList; UDWORD droidX, droidY; - UWORD iX, iY; + UDWORD iX, iY; DROID_GROUP *psGroup; if (goingHome) @@ -3953,18 +3953,18 @@ } //returns the x coord for where the Transporter can land (for player 0) -UWORD getLandingX( SDWORD iPlayer ) +UDWORD getLandingX( SDWORD iPlayer ) { ASSERT( iPlayer<MAX_NOGO_AREAS, "getLandingX: player %d out of range", iPlayer ); - return (UWORD)((sLandingZone[iPlayer].x1 + (sLandingZone[iPlayer].x2 - + return ((sLandingZone[iPlayer].x1 + (sLandingZone[iPlayer].x2 - sLandingZone[iPlayer].x1)/2) << TILE_SHIFT); } //returns the y coord for where the Transporter can land -UWORD getLandingY( SDWORD iPlayer ) +UDWORD getLandingY( SDWORD iPlayer ) { ASSERT( iPlayer<MAX_NOGO_AREAS, "getLandingY: player %d out of range", iPlayer ); - return (UWORD)((sLandingZone[iPlayer].y1 + (sLandingZone[iPlayer].y2 - + return ((sLandingZone[iPlayer].y1 + (sLandingZone[iPlayer].y2 - sLandingZone[iPlayer].y1)/2) << TILE_SHIFT); } @@ -4034,20 +4034,20 @@ } } -void missionGetTransporterEntry( SDWORD iPlayer, UWORD *iX, UWORD *iY ) +void missionGetTransporterEntry( SDWORD iPlayer, UDWORD *iX, UDWORD *iY ) { ASSERT( iPlayer<MAX_PLAYERS, "missionGetTransporterEntry: player %i too high", iPlayer ); - *iX = (UWORD) (mission.iTranspEntryTileX[iPlayer] << TILE_SHIFT); - *iY = (UWORD) (mission.iTranspEntryTileY[iPlayer] << TILE_SHIFT); + *iX = (mission.iTranspEntryTileX[iPlayer] << TILE_SHIFT); + *iY = (mission.iTranspEntryTileY[iPlayer] << TILE_SHIFT); } -void missionGetTransporterExit( SDWORD iPlayer, UWORD *iX, UWORD *iY ) +void missionGetTransporterExit( SDWORD iPlayer, UDWORD *iX, UDWORD *iY ) { ASSERT( iPlayer<MAX_PLAYERS, "missionGetTransporterExit: player %i too high", iPlayer ); - *iX = (UWORD) (mission.iTranspExitTileX[iPlayer] << TILE_SHIFT); - *iY = (UWORD) (mission.iTranspExitTileY[iPlayer] << TILE_SHIFT); + *iX = (mission.iTranspExitTileX[iPlayer] << TILE_SHIFT); + *iY = (mission.iTranspExitTileY[iPlayer] << TILE_SHIFT); } /*update routine for mission details */ Index: mission.h =================================================================== --- mission.h (revision 2124) +++ mission.h (working copy) @@ -117,9 +117,9 @@ /*resets the pause states */ extern void resetMissionPauseState(void); //returns the x coord for where the Transporter can land -extern UWORD getLandingX( SDWORD iPlayer ); +extern UDWORD getLandingX( SDWORD iPlayer ); //returns the y coord for where the Transporter can land -extern UWORD getLandingY( SDWORD iPlayer ); +extern UDWORD getLandingY( SDWORD iPlayer ); /*checks that the timer has been set and that a Transporter exists before adding the timer button*/ extern void addTransporterTimerInterface(void); @@ -153,8 +153,8 @@ /* move transporter offworld */ extern void missionMoveTransporterOffWorld( DROID *psTransporter ); /* pick nearest map edge to point */ -extern void missionGetNearestCorner( UWORD iX, UWORD iY, - UWORD *piOffX, UWORD *piOffY ); +extern void missionGetNearestCorner( UDWORD iX, UDWORD iY, + UDWORD *piOffX, UDWORD *piOffY ); extern void missionSetReinforcementTime( UDWORD iTime ); extern UDWORD missionGetReinforcementTime(void); @@ -168,8 +168,8 @@ extern void missionSetTransporterEntry( SDWORD iPlayer, SDWORD iEntryTileX, SDWORD iEntryTileY ); extern void missionSetTransporterExit( SDWORD iPlayer, SDWORD iExitTileX, SDWORD iExitTileY ); -extern void missionGetTransporterEntry( SDWORD iPlayer, UWORD *iX, UWORD *iY ); -extern void missionGetTransporterExit( SDWORD iPlayer, UWORD *iX, UWORD *iY ); +extern void missionGetTransporterEntry( SDWORD iPlayer, UDWORD *iX, UDWORD *iY ); +extern void missionGetTransporterExit( SDWORD iPlayer, UDWORD *iX, UDWORD *iY ); //access functions for droidsToSafety flag extern void setDroidsToSafetyFlag(BOOL set);
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev