From 9e1d57e7187ad05216e26511ed7ec6df203fe6e8 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Mon, 23 Apr 2007 17:59:13 +0000 Subject: [PATCH] Permit compilation without binary space partitioning. To test this, comment out the #define BSPIMD line in lib/ivis_common/ivisdef.h header. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1529 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/ivis_common/bspfunc.h | 4 ++++ lib/ivis_common/bspimd.h | 5 +++++ lib/ivis_common/imd.c | 2 ++ lib/ivis_common/imdload.c | 25 +++++++++++-------------- lib/ivis_common/ivisdef.h | 3 --- lib/ivis_opengl/piedraw.c | 2 ++ src/bridge.c | 2 ++ src/component.c | 12 ++++++------ src/display3d.c | 19 ++++++++++++++----- 9 files changed, 46 insertions(+), 28 deletions(-) diff --git a/lib/ivis_common/bspfunc.h b/lib/ivis_common/bspfunc.h index 637b35050..4a02ce983 100644 --- a/lib/ivis_common/bspfunc.h +++ b/lib/ivis_common/bspfunc.h @@ -23,6 +23,8 @@ #include "ivisdef.h" #include "bspimd.h" +#ifdef BSPIMD + /***************************************************************************/ void GetRealCameraPos(OBJPOS *Camera, SDWORD Distance, Vector3i *CameraLoc); @@ -31,3 +33,5 @@ void GetPlane( iIMDShape *s, UDWORD PolygonID, PSPLANE psPlane ); #endif +#endif + diff --git a/lib/ivis_common/bspimd.h b/lib/ivis_common/bspimd.h index 74340a418..7a5e38348 100644 --- a/lib/ivis_common/bspimd.h +++ b/lib/ivis_common/bspimd.h @@ -20,6 +20,8 @@ #ifndef i_BSPIMD #define i_BSPIMD +#ifdef BSPIMD + typedef UDWORD WORLDCOORD; typedef SWORD ANGLE; @@ -142,5 +144,8 @@ BSPTREENODE, *PSBSPTREENODE; /***************************************************************************/ + +#endif + #endif diff --git a/lib/ivis_common/imd.c b/lib/ivis_common/imd.c index 6908e49cc..cb34da57b 100644 --- a/lib/ivis_common/imd.c +++ b/lib/ivis_common/imd.c @@ -462,9 +462,11 @@ void iV_IMDRelease(iIMDShape *s) if (s->connectors) { free(s->connectors); } +#ifdef BSPIMD if (s->BSPNode) { free(s->BSPNode); // I used malloc() so i'm going to use FREE() } +#endif if (s->polys) { for (i = 0; i < s->npolys; i++) { if (s->polys[i].pindex) { diff --git a/lib/ivis_common/imdload.c b/lib/ivis_common/imdload.c index b359150d8..20f7d29c3 100644 --- a/lib/ivis_common/imdload.c +++ b/lib/ivis_common/imdload.c @@ -87,9 +87,9 @@ iIMDShape *iV_ProcessIMD( char **ppFileData, char *FileDataEnd ) int i, nlevels, ptype, pwidth, pheight, texpage; iIMDShape *s, *psShape; BOOL bTextured = FALSE; -#ifdef BSPIMD +//#ifdef BSPIMD UDWORD level; -#endif +//#endif IMDcount++; @@ -196,8 +196,8 @@ iIMDShape *iV_ProcessIMD( char **ppFileData, char *FileDataEnd ) return NULL; } -#ifdef BSPIMD -// if we might have BSP then we need to preread the LEVEL directive +//#ifdef BSPIMD + // if we might have BSP then we need to preread the LEVEL directive if (sscanf(pFileData,"%s %d%n",buffer,&level,&cnt) != 2) { iV_Error(0xff,"(_load_level) file corrupt -J"); return NULL; @@ -208,7 +208,7 @@ iIMDShape *iV_ProcessIMD( char **ppFileData, char *FileDataEnd ) debug(LOG_ERROR, "iV_ProcessIMD(2): expecting 'LEVELS' directive (%s)", buffer); return NULL; } -#endif +//#endif s = _imd_load_level(&pFileData,FileDataEnd,nlevels,texpage); @@ -911,15 +911,12 @@ static iIMDShape *_imd_load_level(char **ppFileData, char *FileDataEnd, int nlev int cnt; iIMDShape *s; char buffer[MAX_FILE_PATH]; -// int level; +#ifdef NEVER_BSPIMD + int level; +#endif int n; int npolys; -#ifdef BSPIMD -// UWORD NumberOfParameters; -// UDWORD count; -#endif - if (nlevels == 0) return NULL; @@ -936,7 +933,7 @@ static iIMDShape *_imd_load_level(char **ppFileData, char *FileDataEnd, int nlev s->nShadowEdges = 0; // if we can be sure that there is no bsp ... the we check for level number at this point -#ifndef BSPIMD +#ifdef NEVER_BSPIMD if (sscanf(pFileData,"%s %d%n",buffer,&level,&cnt) != 2) { debug(LOG_ERROR, "_imd_load_level: file corrupt"); return NULL; @@ -944,7 +941,7 @@ static iIMDShape *_imd_load_level(char **ppFileData, char *FileDataEnd, int nlev pFileData += cnt; if (strcmp(buffer,"LEVEL") != 0) { - debug(LOG_ERROR, "_imd_load_level: excepting 'LEVEL' directive"); + debug(LOG_ERROR, "_imd_load_level: expecting 'LEVEL' directive"); return NULL; } #endif @@ -963,7 +960,7 @@ static iIMDShape *_imd_load_level(char **ppFileData, char *FileDataEnd, int nlev // load points if (strcmp(buffer,"POINTS") != 0) { - debug(LOG_ERROR, "_imd_load_level: expecting 'POINTS' directive"); + debug(LOG_ERROR, "_imd_load_level: expecting 'POINTS' directive, got: %s", buffer); return NULL; } diff --git a/lib/ivis_common/ivisdef.h b/lib/ivis_common/ivisdef.h index c5de830e4..abe3f0955 100644 --- a/lib/ivis_common/ivisdef.h +++ b/lib/ivis_common/ivisdef.h @@ -41,9 +41,6 @@ */ /***************************************************************************/ #define BSPIMD // now defined for all versions (optional BSP handled on all formats) -#ifdef WIN321 //Not really needed I guess, however, see debug.c comments. -Qamly - #define iV_DDX -#endif #define iV_SCANTABLE_MAX 1024 diff --git a/lib/ivis_opengl/piedraw.c b/lib/ivis_opengl/piedraw.c index 4e5509e6b..5d2cc6987 100644 --- a/lib/ivis_opengl/piedraw.c +++ b/lib/ivis_opengl/piedraw.c @@ -150,7 +150,9 @@ static SDWORD polyCount = 0; static inline void pie_PiePoly(PIEPOLY *poly, BOOL bClip); static inline void pie_PiePolyFrame(PIEPOLY *poly, SDWORD frame, BOOL bClip); +#ifdef BSPIMD void DrawTriangleList(BSPPOLYID PolygonNumber); +#endif /***************************************************************************/ /* diff --git a/src/bridge.c b/src/bridge.c index db1e679fb..836c9610e 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -135,7 +135,9 @@ BOOL renderBridgeSection(STRUCTURE *psStructure) dv.z = terrainMidY*TILE_UNITS - (structY - player.p.z); dv.y = structZ; +#ifdef BSPIMD SetBSPObjectPos(structX,dv.y,structY); // world x,y,z coord of structure ... this is needed for the BSP code +#endif /* Push the indentity matrix */ pie_MatBegin(); diff --git a/src/component.c b/src/component.c index 34623e8b1..c39b580b4 100644 --- a/src/component.c +++ b/src/component.c @@ -143,22 +143,20 @@ void updateLightLevels(void) void setMatrix(Vector3i *Position, Vector3i *Rotation, Vector3i *CameraPos, BOOL RotXYZ) { +#ifdef BSPIMD Vector3i BSPCameraPos; OBJPOS Camera = {0,0,0,0,0,0}; Camera.pitch=-45; Camera.yaw=0; +#endif -// Rotation->y=0; - +#ifdef BSPIMD GetRealCameraPos(&Camera,Position->z,&BSPCameraPos); -// SetBSPCameraPos(BSPCameraPos.x,BSPCameraPos.y,BSPCameraPos.z); - // Fixes BSP drawing in buttons. eg Player HQ. SetBSPCameraPos(BSPCameraPos.x,500,BSPCameraPos.z); SetBSPObjectPos(0,0,0); // For imd button the bsp is sourced at 0,0,0 - - SetBSPObjectRot(DEG(-Rotation->y),0); // Droid rotation +#endif pie_PerspectiveBegin(); pie_MatBegin(); @@ -318,7 +316,9 @@ void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i Position->y -= 20; } +#ifdef BSPIMD SetBSPObjectPos(0,0,0); +#endif setMatrix(Position,Rotation,&TmpCamPos,RotXYZ); pie_MatScale(scale); diff --git a/src/display3d.c b/src/display3d.c index 0f7a0c81c..3939b2ef5 100644 --- a/src/display3d.c +++ b/src/display3d.c @@ -315,11 +315,12 @@ static DEF_COLOURS defaultColours; /******************** Functions ********************/ - +#ifdef BSPIMD static UDWORD GetCameraDistance(void) { return distance; } +#endif static void displayMultiChat( void ) { @@ -622,7 +623,7 @@ static void displayTerrain(void) } } - +#ifdef BSPIMD // Parameter is the vector to store the camera position static void CalcBSPCameraPos(Vector3i *NewBSPCamera) { @@ -638,6 +639,7 @@ static void CalcBSPCameraPos(Vector3i *NewBSPCamera) GetRealCameraPos(&Camera,GetCameraDistance(),NewBSPCamera); } +#endif /***************************************************************************/ BOOL doWeDrawRadarBlips( void ) @@ -666,7 +668,9 @@ static void drawTiles(iView *camera, iView *player) { UDWORD i, j; SDWORD zMax; +#ifdef BSPIMD Vector3i BSPCamera; +#endif MAPTILE *psTile; UDWORD specular; UDWORD edgeX, edgeY; @@ -703,8 +707,10 @@ static void drawTiles(iView *camera, iView *player) terrainMidX = visibleXTiles/2; terrainMidY = visibleYTiles/2; +#ifdef BSPIMD CalcBSPCameraPos(&BSPCamera); SetBSPCameraPos(BSPCamera.x, BSPCamera.y, BSPCamera.z); +#endif /* Find our position in tile coordinates */ playerXTile = player->p.x >> TILE_SHIFT; @@ -1997,7 +2003,9 @@ void renderFeature(FEATURE *psFeature) /* features sits at the height of the tile it's centre is on */ dv.y = psFeature->z; +#ifdef BSPIMD SetBSPObjectPos(featX,dv.y,featY); // world x,y,z coord of structure ... this is needed for the BSP code +#endif /* Push the indentity matrix */ iV_MatrixBegin(); @@ -2300,7 +2308,9 @@ void renderStructure(STRUCTURE *psStructure) } else { dv.y = map_TileHeight(structX >> TILE_SHIFT, structY >> TILE_SHIFT); } +#ifdef BSPIMD SetBSPObjectPos(structX,dv.y,structY); // world x,y,z coord of structure ... this is needed for the BSP code +#endif /* Push the indentity matrix */ iV_MatrixBegin(); @@ -2712,9 +2722,6 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition) dv.z = terrainMidY*TILE_UNITS - (psPosition->coords.y - player.p.z); dv.y = psPosition->coords.z; - // world x,y,z coord of deliv point ... this is needed for the BSP code - //SetBSPObjectPos(posX,dv.y,posY); - /* Push the indentity matrix */ iV_MatrixBegin(); @@ -2851,7 +2858,9 @@ static BOOL renderWallSection(STRUCTURE *psStructure) dv.z = terrainMidY*TILE_UNITS - (structY - player.p.z); dv.y = map_Height(structX, structY); +#ifdef BSPIMD SetBSPObjectPos(structX,dv.y,structY); // world x,y,z coord of structure ... this is needed for the BSP code +#endif /* Push the indentity matrix */ iV_MatrixBegin();