Code cleanup and remove unused code. There should be no behaviour changes.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1558 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-04-29 21:42:22 +00:00
parent 587498fbb1
commit e127a1d32c
7 changed files with 20 additions and 384 deletions

View File

@ -162,7 +162,7 @@ void pie_ChangeTexPage(int tex_index, iTexture* s, int type, BOOL bResource)
/*!
* Print the names of all loaded textures to LOG_ERROR
*/
void pie_PrintLoadedTextures(void)
static void pie_PrintLoadedTextures(void)
{
unsigned int i = 0;

View File

@ -35,18 +35,12 @@
#include "hci.h"
#include "display.h"
#define AMPLITUDE_HEIGHT 100
#define SIZE_SINE_TABLE 100
#define deg (M_PI / SIZE_SINE_TABLE)
/* The arc over which bullets fly */
UBYTE sineHeightTable[SIZE_SINE_TABLE];
//BOOL bScreenShakeActive = FALSE;
//UDWORD screenShakeStarted = 0;
//UDWORD screenShakeLength = 0;
static UBYTE sineHeightTable[SIZE_SINE_TABLE];
void initBulletTable( void )
{
@ -59,16 +53,6 @@ UBYTE height;
}
}
//void attemptScreenShake(void)
//{
// if(!bScreenShakeActive)
// {
// bScreenShakeActive = TRUE;
// screenShakeStarted = gameTime;
// screenShakeLength = 1500;
// }
//}
/* Angle returned is reflected in line x=0 */
SDWORD calcDirection(UDWORD x0, UDWORD y0, UDWORD x1, UDWORD y1)
{
@ -173,114 +157,6 @@ SDWORD sum;
return 0;
}
/* Return a signed difference in direction : a - b
* result is 180 .. -180
*/
SDWORD directionDiff(SDWORD a, SDWORD b)
{
SDWORD diff = a - b;
if (diff > 180)
{
return diff - 360;
}
else if (diff < -180)
{
return 360 + diff;
}
return diff;
}
void WorldPointToScreen( Vector2i *worldPt, Vector2i *screenPt )
{
Vector3i vec, null;
//MAPTILE *psTile;
UDWORD worldX,worldY;
SDWORD xShift,zShift;
Sint32 rx,rz;
/* Get into game context */
/* Get the x,z translation components */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
/* Push identity matrix onto stack */
iV_MatrixBegin();
/* Set the camera position */
pie_MATTRANS(camera.p.x,camera.p.y,camera.p.z);
/* Rotate for the player */
iV_MatrixRotateZ(player.r.z);
iV_MatrixRotateX(player.r.x);
iV_MatrixRotateY(player.r.y);
/* Translate */
iV_TRANSLATE(-rx,-player.p.y,rz);
/* No rotation is necessary*/
null.x = 0; null.y = 0; null.z = 0;
/* Pull out coords now, because we use them twice */
worldX = worldPt->x;
worldY = worldPt->y;
/* Get the coordinates of the object into the grid */
vec.x = ( worldX - player.p.x) - terrainMidX*TILE_UNITS;
vec.z = terrainMidY*TILE_UNITS - (worldY - player.p.z);
/* Which tile is it on? - In order to establish height (y coordinate in 3 space) */
// psTile = mapTile(worldX/TILE_UNITS,worldY/TILE_UNITS);
// vec.y = psTile->height;
vec.y = map_Height(worldX/TILE_UNITS,worldY/TILE_UNITS);
/* Set matrix context to local - get an identity matrix */
iV_MatrixBegin();
/* Translate */
iV_TRANSLATE(vec.x,vec.y,vec.z);
xShift = player.p.x & (TILE_UNITS-1);
zShift = player.p.z & (TILE_UNITS-1);
/* Translate */
iV_TRANSLATE(xShift,0,-zShift);
/* Project - no rotation being done. So effectively mapping from 3 space to 2 space */
pie_RotProj(&null,screenPt);
/* Pop remaining matrices */
pie_MatEnd();
pie_MatEnd();
}
/* Calculates the RELATIVE screen coords of a game object from its BASE_OBJECT pointer */
/* Alex - Saturday 5th July, 1997 */
/* Returns result in POINT pt. They're relative in the sense that even if you pass
a pointer to an object that isn't on screen, it'll still return a result - just that
the coords may be negative or larger than screen dimensions in either (or both) axis (axes).
Remember also, that the Y coordinate axis is reversed for our display in that increasing Y
implies a movement DOWN the screen, and NOT up. */
void
baseObjScreenCoords(BASE_OBJECT *baseObj, Vector2i *pt)
{
Vector2i worldPt;
worldPt.x = baseObj->x;
worldPt.y = baseObj->y;
WorldPointToScreen( &worldPt, pt );
}
/* Get the structure pointer for a specified tile coord. NULL if no structure */
STRUCTURE *getTileStructure(UDWORD x, UDWORD y)
{
@ -428,37 +304,6 @@ BASE_OBJECT *getTileOccupier(UDWORD x, UDWORD y)
return NULL;
}
/* Will return the player who presently has a structure on the specified tile */
UDWORD getTileOwner(UDWORD x, UDWORD y)
{
STRUCTURE *psStruct;
UDWORD retVal;
/* Arbitrary error code - player 8 (non existent) owns tile from invalid request */
retVal = MAX_PLAYERS;
/* Check it has a structure - cannot have owner otherwise */
if(!TILE_HAS_STRUCTURE(mapTile(x,y)))
{
debug( LOG_ERROR, "Asking for the owner of a tile with no structure on it!!!" );
abort();
}
else
{
/* Get a pointer to the structure */
psStruct = getTileStructure(x,y);
/* Did we get one - failsafe really as TILE_HAS_STRUCTURE should get it */
if(psStruct!=NULL)
{
/* Pull out the player number */
retVal = psStruct->player;
}
}
/* returns eith the player number or MAX_PLAYERS to signify error */
return(retVal);
}
// Approximates a square root - never more than 11% out...
UDWORD dirtySqrt( SDWORD x1, SDWORD y1, SDWORD x2, SDWORD y2)
{
@ -471,6 +316,7 @@ UDWORD retVal;
retVal = (MAX(xDif,yDif) + (MIN(xDif,yDif)/2));
return(retVal);
}
//-----------------------------------------------------------------------------------
BOOL droidOnScreen( DROID *psDroid, SDWORD tolerance )
{
@ -490,69 +336,3 @@ SDWORD dX,dY;
}
return(FALSE);
}
void processImpact(UDWORD worldX, UDWORD worldY, UBYTE severity, UDWORD tilesAcross)
{
//MAPTILE *psTile;
UDWORD height;
SDWORD newHeight;
UDWORD distance;
float multiplier;
UDWORD damage;
UDWORD i,j;
UDWORD xDif,yDif;
SDWORD tileX,tileY;
UDWORD maxDisplacement;
UDWORD maxDistance;
ASSERT( severity<MAX_TILE_DAMAGE,"Damage is too severe" );
/* Make sure it's odd */
if( !(tilesAcross & 0x01))
{
tilesAcross-=1;
}
tileX = ((worldX>>TILE_SHIFT)-(tilesAcross/2-1));
tileY = ((worldY>>TILE_SHIFT)-(tilesAcross/2-1));
maxDisplacement = ((tilesAcross/2+1) * TILE_UNITS);
maxDisplacement = (UDWORD)((float)maxDisplacement * (float)1.42);
maxDistance = (UDWORD)sqrt(((float)maxDisplacement * (float)maxDisplacement));
if(tileX < 0) tileX = 0;
if(tileY < 0) tileY = 0;
for(i=tileX; i<tileX+tilesAcross-1; i++)
{
for(j=tileY; j<tileY+tilesAcross-1; j++)
{
/* Only process tiles that are on the map */
if(tileX < (SDWORD)mapWidth && tileY<(SDWORD)mapHeight)
{
xDif = abs(worldX - (i<<TILE_SHIFT));
yDif = abs(worldY - (j<<TILE_SHIFT));
distance = (UDWORD)sqrt(( (float)(xDif*xDif) + (float)(yDif*yDif) ));
multiplier = (1-((float) ( (float)distance / (float) maxDistance)));
multiplier = (float) (1.0 - ((float)distance/(float)maxDistance));
/* Are we talking less than 15% damage? i.e - at the edge of carater? */
if(multiplier<0.15)
{
/* In which case make the crater edge have jagged edges */
multiplier+= (float)((float)(20-rand()%40) * 0.01);
}
height = mapTile(i,j)->height;
damage = (UDWORD) ((float)severity*multiplier);
newHeight = height-damage;
if(newHeight < 0)
{
newHeight = 0;
}
setTileHeight(i,j,newHeight);
}
}
}
}

View File

@ -22,11 +22,6 @@
#ifndef _geometry_h
#define _geometry_h
#define SIZE_SINE_TABLE 100
#define AMPLITUDE_HEIGHT 100
#define deg (M_PI / SIZE_SINE_TABLE)
#define RESTRICT_iV_ANGLE(x) ((x) & (iV_RMULTP - 1))
typedef struct _t_tri
{
POINT coords[3];
@ -37,44 +32,17 @@ typedef struct _t_quad
POINT coords[4];
} QUAD;
extern void processImpact(UDWORD worldX, UDWORD worldY, UBYTE severity,UDWORD tilesAcross);
extern UDWORD getTileOwner(UDWORD x, UDWORD y);
extern BASE_OBJECT *getTileOccupier(UDWORD x, UDWORD y);
extern STRUCTURE *getTileStructure(UDWORD x, UDWORD y);
extern FEATURE *getTileFeature(UDWORD x, UDWORD y);
//extern BOOL bScreenShakeActive;
//extern UDWORD screenShakeStarted;
//extern UDWORD screenShakeLength;
//extern void attemptScreenShake(void);
extern void baseObjScreenCoords(BASE_OBJECT *baseObj, Vector2i *pt);
extern void WorldPointToScreen( Vector2i *worldPt, Vector2i *screenPt );
extern UDWORD adjustDirection ( SDWORD present, SDWORD difference );
extern SDWORD calcDirection ( UDWORD x0, UDWORD y0, UDWORD x1, UDWORD y1 );
extern void initBulletTable ( void );
extern int inQuad ( POINT *pt, QUAD *quad );
extern DROID *getNearestDroid ( UDWORD x, UDWORD y, BOOL bSelected );
extern UBYTE sineHeightTable[SIZE_SINE_TABLE];
extern BOOL droidOnScreen ( DROID *psDroid, SDWORD tolerance );
#define BOTLEFT 11
#define BOTRIGHT 21
#define TOPLEFT 31
#define TOPRIGHT 41
#define MAX_TILE_DAMAGE 255
#define CRATER_SMALL 3
#define CRATER_MEDIUM 5
#define CRATER_LARGE 7
/* Return a signed difference in direction : a - b
* result is 180 .. -180
*/
extern SDWORD directionDiff ( SDWORD a, SDWORD b );
extern UDWORD dirtySqrt ( SDWORD x1,SDWORD y1, SDWORD x2,SDWORD y2 );
#endif

View File

@ -28,7 +28,6 @@
#include <string.h>
/* loop position printf's */
//#define DEBUG_GROUP1
#include "lib/framework/frame.h"
#include "lib/framework/input.h"
#include "lib/framework/strres.h"
@ -100,7 +99,7 @@
#include "objmem.h"
#endif
#define MISSION_COMPLETE_DELAY 4000
static void fireWaitingCallbacks(void);
/*
* Global variables
@ -109,10 +108,10 @@ SDWORD loopPieCount;
SDWORD loopTileCount;
SDWORD loopPolyCount;
SDWORD loopStateChanges;
/*
* local variables
*/
static BOOL paused=FALSE;
static BOOL video=FALSE;
static BOOL bQuitVideo=FALSE;
@ -135,9 +134,7 @@ static UDWORD numTransporterDroids[MAX_PLAYERS];
static UDWORD numCommandDroids[MAX_PLAYERS];
static UDWORD numConstructorDroids[MAX_PLAYERS];
// flag to signal a quick exit from the game
static BOOL fastExit;
static SDWORD videoMode;
static SDWORD g_iGlobalVol;
LOOP_MISSION_STATE loopMissionState = LMS_NORMAL;
@ -150,35 +147,16 @@ UDWORD mcTime;
BOOL display3D = TRUE;
extern BOOL godMode;
BOOL gamePaused( void );
void setGamePauseStatus( BOOL val );
void setGameUpdatePause(BOOL state);
void setAudioPause(BOOL state);
void setScriptPause(BOOL state);
void setScrollPause(BOOL state);
// signal a fast exit from the game
void loopFastExit(void)
{
fastExit = TRUE;
}
/* The main game loop */
GAMECODE gameLoop(void)
{
DROID *psCurr, *psNext;
STRUCTURE *psCBuilding, *psNBuilding;
// BOOL bPlayerHasHQ = FALSE;
FEATURE *psCFeat, *psNFeat;
UDWORD i,widgval;
BOOL quitting=FALSE;
INT_RETVAL intRetVal;
int clearMode;
// DumpVRAM(); // use mouse to scroll through vram
// dumpimdpoints();
#ifdef DEBUG
heapIntegrityCheck(psDroidHeap);
@ -202,8 +180,6 @@ GAMECODE gameLoop(void)
}
pie_ScreenFlip(clearMode);//gameloopflip
fastExit = FALSE;
HandleClosingWindows(); // Needs to be done outside the pause case.
audio_Update();
@ -306,7 +282,6 @@ GAMECODE gameLoop(void)
if(bMultiPlayer)
{
multiPlayerLoop();
// RecvMessage();
}
fireWaitingCallbacks(); //Now is the good time to fire waiting callbacks (since interpreter is off now)
@ -483,15 +458,9 @@ GAMECODE gameLoop(void)
// debug( LOG_NEVER, "loop: Smoke/Explosion Update\n");
/* Ensure smoke drifts up! */
// raiseSmoke();
// updateGravitons();
/* update animations */
animObj_Update();
/* Raise and increase frames of explosions */
// updateExplosions();
/* Update all the temporary world effects */
// processEffects();
@ -626,8 +595,7 @@ GAMECODE gameLoop(void)
}
/* Check for quit */
// if (keyPressed(KEY_ESC) || intRetVal == INT_QUIT)
if ((intRetVal == INT_QUIT) || fastExit)
if (intRetVal == INT_QUIT)
{
if (!video)
{
@ -644,46 +612,24 @@ GAMECODE gameLoop(void)
}
if (!video)
{
//if (!quitting && intRetVal != INT_FULLSCREENPAUSE)
if (!quitting)
{
if (!gameUpdatePaused())
{
if (display3D)
{
/*bPlayerHasHQ=FALSE;
for (psStructure = apsStructLists[selectedPlayer]; psStructure &&
!bPlayerHasHQ; psStructure = psStructure->psNext)
{
if (psStructure->pStructureType->type == REF_HQ)
{
bPlayerHasHQ = TRUE;
}
}
*/
// bPlayerHasHQ = radarCheckForHQ(selectedPlayer);
if( //(intRetVal != INT_INTELPAUSE) &&
(dragBox3D.status != DRAG_DRAGGING) &&
(wallDrag.status != DRAG_DRAGGING))
if (dragBox3D.status != DRAG_DRAGGING
&& wallDrag.status != DRAG_DRAGGING)
{
ProcessRadarInput();
}
processInput();
//no key clicks or in Intelligence Screen
// if (intRetVal == INT_INTELPAUSE)
if (intRetVal == INT_NONE && !InGameOpUp)// || intRetVal == INT_INTELPAUSE)
if (intRetVal == INT_NONE && !InGameOpUp)
{
// debug( LOG_NEVER, "loop: 3D input\n");
//quitting = processInput();
//don't want to handle the mouse input here when in intelligence screen
//if (intRetVal != INT_INTELPAUSE)
//{
processMouseClickInput();
//}
}
// debug( LOG_NEVER, "loop: display3D\n");
displayWorld();
}
else
@ -734,26 +680,7 @@ GAMECODE gameLoop(void)
//#endif
}
/*else if (!quitting)
{
// Display the in game interface
debug( LOG_NEVER, "loop: Display widgets\n");
if(widgetsOn)
{
pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
pie_SetFogStatus(FALSE);
intDisplayWidgets();
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
pie_SetFogStatus(TRUE);
}
}*/
}
// debug( LOG_NEVER, "loop: key presses\n");
/* Check for toggling video playbackmode */
if (bQuitVideo)
@ -804,11 +731,9 @@ GAMECODE gameLoop(void)
clearMode = CLEAR_BLACK;//force to black 3DFX
}
if(!quitting && !fastExit)
if (!quitting)
{
//JPS 24 feb??? pie_ScreenFlip(clearMode);//gameloopflip
{
/* Check for toggling display mode */
if ((keyDown(KEY_LALT) || keyDown(KEY_RALT)) &&
keyPressed(KEY_RETURN))
@ -820,15 +745,6 @@ GAMECODE gameLoop(void)
dispModeChange();
}
}
}
/* if(missionComplete)
{
if (gameTime>(mcTime+MISSION_COMPLETE_DELAY))
{
quitting = TRUE;
}
}*/
// deal with the mission state
switch (loopMissionState)
@ -866,26 +782,7 @@ GAMECODE gameLoop(void)
break;
}
if (fastExit)
{
pie_SetFogStatus(FALSE);
pie_ScreenFlip(CLEAR_BLACK);//gameloopflip
pie_ScreenFlip(CLEAR_BLACK);//gameloopflip
{
/* Check for toggling display mode */
if ((keyDown(KEY_LALT) || keyDown(KEY_RALT)) &&
keyPressed(KEY_RETURN))
{
screenToggleMode();
#ifdef DISP2D
disp2DModeChange();
#endif
dispModeChange();
}
}
return GAMECODE_FASTEXIT;
}
else if (quitting)
if (quitting)
{
pie_SetFogStatus(FALSE);
pie_ScreenFlip(CLEAR_BLACK);//gameloopflip
@ -910,12 +807,6 @@ GAMECODE gameLoop(void)
return GAMECODE_PLAYVIDEO;
}
/*
if( (intMode == INT_NORMAL) && (forceWidgetsOn == TRUE) )
{
forceWidgetsOn = FALSE;
}
*/
return GAMECODE_CONTINUE;
}
@ -1204,7 +1095,7 @@ void incNumConstructorDroids(UDWORD player)
}
/* Fire waiting beacon messages which we couldn't run before */
void fireWaitingCallbacks(void)
static void fireWaitingCallbacks(void)
{
BOOL bOK = TRUE;

View File

@ -97,7 +97,5 @@ void incNumDroids(UDWORD player);
void incNumCommandDroids(UDWORD player);
void incNumConstructorDroids(UDWORD player);
void fireWaitingCallbacks(void); //Fire stored beacon messages
#endif

View File

@ -1311,7 +1311,6 @@ void mapCalcAALine(SDWORD X1, SDWORD Y1,
}
/* Return linear interpolated height of x,y */
//extern SDWORD map_Height(UDWORD x, UDWORD y)
extern SWORD map_Height(UDWORD x, UDWORD y)
{
SDWORD retVal;
@ -1327,9 +1326,9 @@ extern SWORD map_Height(UDWORD x, UDWORD y)
ASSERT( y < WORLD_COORD(mapHeight),
"mapHeight: y(%u) coordinate bigger than map height(%u)", y, WORLD_COORD(mapHeight) );
/* Tile comp */
tileX = x >> TILE_SHIFT;
tileY = y >> TILE_SHIFT;
/* Turn into tile coordinates */
tileX = MAP_COORD(x);
tileY = MAP_COORD(y);
/* Inter tile comp */
ox = (x & (TILE_UNITS-1));

View File

@ -6542,7 +6542,7 @@ BOOL destroyStruct(STRUCTURE *psDel)
/* shake the screen if we're near enough */
if(clipXY(pos.x,pos.z))
{
shakeStart(); //attemptScreenShake();
shakeStart();
}
//--------------------------------------- And finally, add a boom sound!!!!