pointtree: Remove grid system calls which are no longer used.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9265 4a71c877-e1ca-e34f-864e-861f7616d084
master
Cyp 2010-01-16 22:57:05 +00:00 committed by Git SVN Gateway
parent 97e852b5ec
commit b4919db163
13 changed files with 11 additions and 123 deletions

View File

@ -295,9 +295,6 @@ void droidRelease(DROID *psDroid)
grpLeave(psDroid->psGroup, psDroid); grpLeave(psDroid->psGroup, psDroid);
} }
// remove the object from the grid
gridRemoveObject((BASE_OBJECT *)psDroid);
// remove the droid from the cluster system // remove the droid from the cluster system
clustRemoveObject((BASE_OBJECT *)psDroid); clustRemoveObject((BASE_OBJECT *)psDroid);
@ -460,9 +457,6 @@ void removeDroidBase(DROID *psDel)
} }
} }
// remove the droid from the grid
gridRemoveObject((BASE_OBJECT *)psDel);
// remove the droid from the cluster systerm // remove the droid from the cluster systerm
clustRemoveObject((BASE_OBJECT *)psDel); clustRemoveObject((BASE_OBJECT *)psDel);
@ -578,9 +572,6 @@ BOOL droidRemove(DROID *psDroid, DROID *pList[MAX_PLAYERS])
// remove the droid from the cluster systerm // remove the droid from the cluster systerm
clustRemoveObject((BASE_OBJECT *)psDroid); clustRemoveObject((BASE_OBJECT *)psDroid);
// remove the droid from the grid
gridRemoveObject((BASE_OBJECT *)psDroid);
removeDroid(psDroid, pList); removeDroid(psDroid, pList);
if (psDroid->player == selectedPlayer) if (psDroid->player == selectedPlayer)
@ -2683,7 +2674,6 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
updateDroidOrientation(psDroid); updateDroidOrientation(psDroid);
} }
visTilesUpdate((BASE_OBJECT *)psDroid, rayTerrainCallback); visTilesUpdate((BASE_OBJECT *)psDroid, rayTerrainCallback);
gridAddObject((BASE_OBJECT *)psDroid);
clustNewDroid(psDroid); clustNewDroid(psDroid);
} }
@ -4369,9 +4359,6 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
// Update visibility // Update visibility
visTilesUpdate((BASE_OBJECT*)psD, rayTerrainCallback); visTilesUpdate((BASE_OBJECT*)psD, rayTerrainCallback);
// add back into the grid system
gridAddObject((BASE_OBJECT *)psD);
// check through the 'to' players list of droids to see if any are targetting it // check through the 'to' players list of droids to see if any are targetting it
for (psCurr = apsDroidLists[to]; psCurr != NULL; psCurr = psCurr->psNext) for (psCurr = apsDroidLists[to]; psCurr != NULL; psCurr = psCurr->psNext)
{ {

View File

@ -445,9 +445,6 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
// psFeature->sDisplay.imd = psStats->psImd; // psFeature->sDisplay.imd = psStats->psImd;
// } // }
// add the feature to the grid
gridAddObject((BASE_OBJECT *)psFeature);
return psFeature; return psFeature;
} }
@ -455,7 +452,6 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
/* Release the resources associated with a feature */ /* Release the resources associated with a feature */
void featureRelease(FEATURE *psFeature) void featureRelease(FEATURE *psFeature)
{ {
gridRemoveObject((BASE_OBJECT *)psFeature);
} }
@ -540,9 +536,6 @@ bool removeFeature(FEATURE *psDel)
} }
} }
// remove the feature from the grid
gridRemoveObject((BASE_OBJECT *)psDel);
killFeature(psDel); killFeature(psDel);
return true; return true;

View File

@ -1888,7 +1888,7 @@ void kf_KillSelected(void)
} }
} }
#if 0 // There's no gridDisplayCoverage anymore.
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// display the grid info for all the selected objects // display the grid info for all the selected objects
void kf_ShowGridInfo(void) void kf_ShowGridInfo(void)
@ -1913,6 +1913,7 @@ void kf_ShowGridInfo(void)
} }
} }
} }
#endif
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -242,8 +242,8 @@ GAMECODE gameLoop(void)
// Update the visibility change stuff // Update the visibility change stuff
visUpdateLevel(); visUpdateLevel();
// do the grid garbage collection // Put all droids/structures/features into the grid.
gridGarbageCollect(); gridReset();
if (!editPaused()) if (!editPaused())
{ {

View File

@ -57,11 +57,14 @@ void gridReset(void)
for (unsigned type = 0; type != sizeof(start)/sizeof(*start); ++type) for (unsigned type = 0; type != sizeof(start)/sizeof(*start); ++type)
{ {
for (BASE_OBJECT *psObj = start[type]; psObj != NULL; psObj = psObj->psNext) for (BASE_OBJECT *psObj = start[type]; psObj != NULL; psObj = psObj->psNext)
{
if (!psObj->died)
{ {
gridPointTree->insert(psObj, psObj->pos.x, psObj->pos.y); gridPointTree->insert(psObj, psObj->pos.x, psObj->pos.y);
} }
} }
} }
}
gridPointTree->sort(); gridPointTree->sort();
} }
@ -73,35 +76,6 @@ void gridShutDown(void)
gridPointTree = NULL; gridPointTree = NULL;
} }
// add an object to the grid system
void gridAddObject(BASE_OBJECT *psObj)
{
ASSERT_OR_RETURN(, psObj != NULL, "Attempted to add a NULL pointer");
ASSERT_OR_RETURN(, !isDead(psObj), "Attempted to add dead object %s(%d) to the map grid!", objInfo(psObj), (int)psObj->id);
//gridCalcCoverage(psObj, (SDWORD)psObj->pos.x, (SDWORD)psObj->pos.y, GRID_ADDOBJECT);
}
// move an object within the grid
// oldX,oldY are the old position of the object in world coords
void gridMoveDroid(DROID* psDroid, SDWORD oldX, SDWORD oldY)
{
if (map_coord(psDroid->pos.x) == map_coord(oldX)
&& map_coord(psDroid->pos.y) == map_coord(oldY))
{
// havn't changed the tile the object is on, don't bother updating
return;
}
//gridCalcCoverage((BASE_OBJECT*)psDroid, oldX,oldY, GRID_REMOVEOBJECT);
//gridCalcCoverage((BASE_OBJECT*)psDroid, psDroid->pos.x, psDroid->pos.y, GRID_ADDOBJECT);
}
// remove an object from the grid system
void gridRemoveObject(BASE_OBJECT *psObj)
{
//gridCalcCoverage(psObj, (SDWORD)psObj->pos.x, (SDWORD)psObj->pos.y, GRID_REMOVEOBJECT);
}
static bool isInRadius(int32_t x, int32_t y, uint32_t radius) static bool isInRadius(int32_t x, int32_t y, uint32_t radius)
{ {
return x*x + y*y <= radius*radius; return x*x + y*y <= radius*radius;

View File

@ -38,26 +38,9 @@ extern BOOL gridInitialise(void);
// shutdown the grid system // shutdown the grid system
extern void gridShutDown(void); extern void gridShutDown(void);
// reset the grid system // Reset the grid system. Called once per update.
extern void gridReset(void); extern void gridReset(void);
// TODO THIS FUNCTION DOES NOT DO ANYTHING ANYMORE. Delete this function
extern void gridAddObject(BASE_OBJECT *psObj);
// TODO THIS FUNCTION DOES NOT DO ANYTHING ANYMORE. Delete this function
extern void gridMoveDroid(DROID* psDroid, SDWORD oldX, SDWORD oldY);
// TODO THIS FUNCTION DOES NOT DO ANYTHING ANYMORE. Delete this function
extern void gridRemoveObject(BASE_OBJECT *psObj);
// Calls gridReset().
// TODO Remove this function, call gridReset() directly.
extern void gridGarbageCollect(void);
// Display all the grid's an object is a member of
// TODO This function doesn't do anything, should probably be deleted.
extern void gridDisplayCoverage(BASE_OBJECT *psObj);
#define PREVIOUS_DEFAULT_GRID_SEARCH_RADIUS (20*TILE_UNITS) #define PREVIOUS_DEFAULT_GRID_SEARCH_RADIUS (20*TILE_UNITS)
/// Find all objects within radius. Call gridIterate() to get the search results. /// Find all objects within radius. Call gridIterate() to get the search results.
extern void gridStartIterate(int32_t x, int32_t y, uint32_t radius); extern void gridStartIterate(int32_t x, int32_t y, uint32_t radius);

View File

@ -658,11 +658,6 @@ void missionFlyTransportersIn( SDWORD iPlayer, BOOL bTrackTransporter )
// Check that this transporter actually contains some droids // Check that this transporter actually contains some droids
if (psTransporter->psGroup && psTransporter->psGroup->refCount > 1) if (psTransporter->psGroup && psTransporter->psGroup->refCount > 1)
{ {
// Remove map information from previous map
free(psTransporter->watchedTiles);
psTransporter->watchedTiles = NULL;
psTransporter->numWatchedTiles = 0;
// Remove out of stored list and add to current Droid list // Remove out of stored list and add to current Droid list
if (droidRemove(psTransporter, mission.apsDroidLists)) if (droidRemove(psTransporter, mission.apsDroidLists))
{ {
@ -867,22 +862,13 @@ void restoreMissionData(void)
for(psObj = (BASE_OBJECT *)apsDroidLists[inc]; psObj; psObj=psObj->psNext) for(psObj = (BASE_OBJECT *)apsDroidLists[inc]; psObj; psObj=psObj->psNext)
{ {
psObj->died = false; //make sure the died flag is not set psObj->died = false; //make sure the died flag is not set
gridAddObject(psObj);
} }
apsStructLists[inc] = mission.apsStructLists[inc]; apsStructLists[inc] = mission.apsStructLists[inc];
mission.apsStructLists[inc] = NULL; mission.apsStructLists[inc] = NULL;
for(psObj = (BASE_OBJECT *)apsStructLists[inc]; psObj; psObj=psObj->psNext)
{
gridAddObject(psObj);
}
apsFeatureLists[inc] = mission.apsFeatureLists[inc]; apsFeatureLists[inc] = mission.apsFeatureLists[inc];
mission.apsFeatureLists[inc] = NULL; mission.apsFeatureLists[inc] = NULL;
for(psObj = (BASE_OBJECT *)apsFeatureLists[inc]; psObj; psObj=psObj->psNext)
{
gridAddObject(psObj);
}
apsFlagPosLists[inc] = mission.apsFlagPosLists[inc]; apsFlagPosLists[inc] = mission.apsFlagPosLists[inc];
mission.apsFlagPosLists[inc] = NULL; mission.apsFlagPosLists[inc] = NULL;
@ -1047,7 +1033,6 @@ void restoreMissionLimboData(void)
{ {
addDroid(psDroid, apsDroidLists); addDroid(psDroid, apsDroidLists);
psDroid->cluster = 0; psDroid->cluster = 0;
gridAddObject((BASE_OBJECT *)psDroid);
//reset droid orders //reset droid orders
orderDroid(psDroid, DORDER_STOP); orderDroid(psDroid, DORDER_STOP);
//the location of the droid should be valid! //the location of the droid should be valid!
@ -1890,7 +1875,6 @@ void unloadTransporter(DROID *psTransporter, UDWORD x, UDWORD y, BOOL goingHome)
//reset droid orders //reset droid orders
orderDroid(psDroid, DORDER_STOP); orderDroid(psDroid, DORDER_STOP);
gridAddObject((BASE_OBJECT *)psDroid);
psDroid->selected = false; psDroid->selected = false;
if (!bMultiPlayer) if (!bMultiPlayer)
{ {

View File

@ -3214,7 +3214,6 @@ void moveUpdateDroid(DROID *psDroid)
|| map_coord(oldy) != map_coord(psDroid->pos.y)) || map_coord(oldy) != map_coord(psDroid->pos.y))
{ {
visTilesUpdate((BASE_OBJECT *)psDroid, rayTerrainCallback); visTilesUpdate((BASE_OBJECT *)psDroid, rayTerrainCallback);
gridMoveDroid(psDroid, (SDWORD)oldx,(SDWORD)oldy);
// object moved from one tile to next, check to see if droid is near stuff.(oil) // object moved from one tile to next, check to see if droid is near stuff.(oil)
checkLocalFeatures(psDroid); checkLocalFeatures(psDroid);

View File

@ -185,14 +185,8 @@ BOOL recvDroidSecondary()
if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2) if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2)
|| abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2)) || abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2))
{ {
int oldx = psDroid->pos.x;
int oldy = psDroid->pos.y;
// Jump it, even if it is on screen (may want to change this) // Jump it, even if it is on screen (may want to change this)
psDroid->pos = pos; psDroid->pos = pos;
// Tell the grid system that the object has moved
gridMoveDroid(psDroid, oldx, oldy);
} }
return true; return true;
@ -426,8 +420,6 @@ BOOL recvDroidDisEmbark()
// Initialise the movement data // Initialise the movement data
initDroidMovement(psFoundDroid); initDroidMovement(psFoundDroid);
// must add it to the grid for targeting to work
gridAddObject((BASE_OBJECT *)psFoundDroid);
} }
return true; return true;
} }
@ -906,14 +898,8 @@ BOOL recvGroupOrder()
if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2) if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2)
|| abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2)) || abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2))
{ {
int oldx = psDroid->pos.x;
int oldy = psDroid->pos.y;
// Jump it, even if it is on screen (may want to change this) // Jump it, even if it is on screen (may want to change this)
psDroid->pos = pos; psDroid->pos = pos;
// Tell the grid system that the object has moved
gridMoveDroid(psDroid, oldx, oldy);
} }
} }

View File

@ -592,7 +592,6 @@ static void offscreenUpdate(DROID *psDroid,
UWORD dir, UWORD dir,
DROID_ORDER order) DROID_ORDER order)
{ {
UDWORD oldx,oldy;
PROPULSION_STATS *psPropStats; PROPULSION_STATS *psPropStats;
SDWORD xdiff,ydiff, distSq; SDWORD xdiff,ydiff, distSq;
@ -613,16 +612,13 @@ static void offscreenUpdate(DROID *psDroid,
{ {
if( ((UDWORD)fx != 0) && ((UDWORD)fy != 0) ) if( ((UDWORD)fx != 0) && ((UDWORD)fy != 0) )
{ {
oldx = psDroid->pos.x; debug(LOG_SYNC, "Jumping droid %d from (%u,%u) to (%u,%u)", (int)psDroid->id, psDroid->pos.x, psDroid->pos.y, (UDWORD)fx, (UDWORD)fy);
oldy = psDroid->pos.y;
debug(LOG_SYNC, "Jumping droid %d from (%u,%u) to (%u,%u)", (int)psDroid->id, oldx, oldy, (UDWORD)fx, (UDWORD)fy);
psDroid->sMove.fx = fx; //update x psDroid->sMove.fx = fx; //update x
psDroid->sMove.fy = fy; //update y psDroid->sMove.fy = fy; //update y
psDroid->pos.x = (UWORD) fx; //update move progress psDroid->pos.x = (UWORD) fx; //update move progress
psDroid->pos.y = (UWORD) fy; psDroid->pos.y = (UWORD) fy;
gridMoveDroid(psDroid, (SDWORD)oldx,(SDWORD)oldy);
psDroid->direction = dir % 360; // update rotation psDroid->direction = dir % 360; // update rotation
@ -635,12 +631,9 @@ static void offscreenUpdate(DROID *psDroid,
} }
else else
{ {
oldx = psDroid->pos.x; debug(LOG_SYNC, "Moving droid %d from (%u,%u) to (%u,%u)", (int)psDroid->id, psDroid->pos.x, psDroid->pos.y, (UDWORD)fx, (UDWORD)fy);
oldy = psDroid->pos.y;
debug(LOG_SYNC, "Moving droid %d from (%u,%u) to (%u,%u)", (int)psDroid->id, oldx, oldy, (UDWORD)fx, (UDWORD)fy);
psDroid->pos.x = (UWORD)x; //update x psDroid->pos.x = (UWORD)x; //update x
psDroid->pos.y = (UWORD)y; //update y psDroid->pos.y = (UWORD)y; //update y
gridMoveDroid(psDroid, (SDWORD)oldx,(SDWORD)oldy);
psDroid->direction = dir % 360; // update rotation psDroid->direction = dir % 360; // update rotation
} }

View File

@ -618,9 +618,6 @@ void killStruct(STRUCTURE *psBuilding)
} }
} }
// remove the object from the grid
gridRemoveObject((BASE_OBJECT *)psBuilding);
destroyObject((BASE_OBJECT**)apsStructLists, (BASE_OBJECT*)psBuilding); destroyObject((BASE_OBJECT**)apsStructLists, (BASE_OBJECT*)psBuilding);
} }

View File

@ -1874,8 +1874,6 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
SET_TILE_NOTBLOCKING(psTile); SET_TILE_NOTBLOCKING(psTile);
} }
gridAddObject((BASE_OBJECT *)psBuilding);
clustNewStruct(psBuilding); clustNewStruct(psBuilding);
asStructLimits[player][max].currentQuantity++; asStructLimits[player][max].currentQuantity++;
} }
@ -5036,9 +5034,6 @@ BOOL removeStruct(STRUCTURE *psDel, BOOL bDestroy)
} }
} }
// remove the structure from the grid
gridRemoveObject((BASE_OBJECT *)psDel);
// remove the structure from the cluster // remove the structure from the cluster
cluster = psDel->cluster; cluster = psDel->cluster;
clustRemoveObject((BASE_OBJECT *)psDel); clustRemoveObject((BASE_OBJECT *)psDel);
@ -7747,9 +7742,6 @@ STRUCTURE * giftSingleStructure(STRUCTURE *psStructure, UBYTE attackPlayer, BOOL
//add back into cluster system //add back into cluster system
clustNewStruct(psStructure); clustNewStruct(psStructure);
//add back into the grid system
gridAddObject((BASE_OBJECT *)psStructure);
if (psStructure->status == SS_BUILT) if (psStructure->status == SS_BUILT)
{ {
buildingComplete(psStructure); buildingComplete(psStructure);

View File

@ -1437,7 +1437,6 @@ void transporterRemoveDroid(UDWORD id)
initDroidMovement(psDroid); initDroidMovement(psDroid);
//reset droid orders //reset droid orders
orderDroid(psDroid, DORDER_STOP); orderDroid(psDroid, DORDER_STOP);
gridAddObject((BASE_OBJECT *)psDroid);
psDroid->cluster = 0; psDroid->cluster = 0;
// check if it is a commander // check if it is a commander
if (psDroid->droidType == DROID_COMMAND) if (psDroid->droidType == DROID_COMMAND)